0

I'd like to know how checkpoints for the monero network are formed and hardcoded in the checkpoint.cpp. Especially when having a fresh fork with the first genesis block having to be made. How to effectively generate the very first checkpoint?

From the Monero source code:

    ADD_CHECKPOINT2(1,     "771fbcd656ec1464d3a02ead5e18644030007a0fc664c0a964d30922821a8148", "0x2");
    ADD_CHECKPOINT2(10,    "c0e3b387e47042f72d8ccdca88071ff96bff1ac7cde09ae113dbb7ad3fe92381", "0x2a974");
    ADD_CHECKPOINT2(100,   "ac3e11ca545e57c49fca2b4e8c48c03c23be047c43e471e1394528b1f9f80b2d", "0x35d14b");
    ADD_CHECKPOINT2(1000,  "5acfc45acffd2b2e7345caf42fa02308c5793f15ec33946e969e829f40b03876", "0x36a0373");
    ADD_CHECKPOINT2(10000, "c758b7c81f928be3295d45e230646de8b852ec96a821eac3fea4daf3fcac0ca2", "0x60a91390");

What are those values? Height, block hash, checksum? How are those created specifically?

Additionally, it would be useful to know what effect the PER_BLOCK_CHECKPOINT flag has on checkpoints in general.

Update

I figured out the checkpoint consists out of "height", "transaction id" and "cumulative difficulty" and can be received from the daemon via RPC call:

curl http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block_header_by_height","params":{"height":2851000}}' -H 'Content-Type: application/json'

But, how can I send this RPC call when the daemon wouldn't pass the first block being validated?

Update 2

When the database is finally created, the daemon will retrieve the "block hash" of the first block via:

mdb_block_info* bi = (mdb_block_info*)result.mv_data;
crypto::hash ret = bi->bi_hash;

The daemon will print an EXPECTED HASH and a GIVEN HASH, neither of those work in the checkpoints.cpp, I guess because this is the hash of the transaction ID?

2 Answers 2

2

How to effectively generate the very first checkpoint?

Mine a block and use it's block hash, height and difficulty.

What are those values? Height, block hash, checksum? How are those created specifically?

They are height, block hash and difficulty (src).

Additionally, it would be useful to know what effect the PER_BLOCK_CHECKPOINT flag has on checkpoints in general.

Whether or not to use the compiled-in checkpoints.

But, how can I send this RPC call when the daemon wouldn't pass the first block being validated?

The parameter height. Height 0 is the genesis block, height 1 is the first block being "validated".

I guess because this is the hash of the transaction ID?

No, it's the block hash.

4
  • Thanks for explaining a bit about this, especially that it's the block hash and not txid. How would I mine the first block when the daemon won't start? AlsoPER_BLOCK_CHECKPOINT seems to not disable checkpoints entirely, at least for my fork. Please check my answer to see why I struggled so much and how I could fix it eventually. Commented Aug 17, 2023 at 17:37
  • I never said PER_BLOCK_CHECKPOINT would disable/enable checkpoints, I said "Whether or not to use the compiled-in checkpoints."
    – jtgrassie
    Commented Aug 18, 2023 at 0:00
  • Sorry, but I was talking about these, because I couldn't bypass the issue by disabling PER_BLOCK_CHECKPOINT. I would still try to validate my hardcoded checkpoint which I assume is the compiled-in checkpoint. Commented Aug 18, 2023 at 0:46
  • You asked "what effect the PER_BLOCK_CHECKPOINT flag has on checkpoints in general", not how to disable/bypass.
    – jtgrassie
    Commented Aug 18, 2023 at 9:59
-1

This is fairly not a default Monero fork I have to deal with, but I want to give some information about these checkpoints so other people don't have to suffer that much. I finally figured it out by logging what needed to be logged.

Before @jtgrassie could explain it, I already noticed the Genesis TX does not work as checkpoint hash. But, when the database is finally created, the daemon will retrieve the "block hash" of the first block via:

mdb_block_info* bi = (mdb_block_info*)result.mv_data;
crypto::hash ret = bi->bi_hash;

The daemon will print such GIVEN HASH within its error. Since the operation requires the database which is not in place on the genesis tx generation itself, I have to recompile twice. Once I have the error message, I can input the GIVEN HASH into my checkpoints.cpp.

But it didn't work and this through me off-guard for hours. Apparently, the previously wrong hash was written to the database and all I had to do is reset the database, now it would pass the checkpoint validation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.