Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the meaning of prev_root #78

Open
jackzhp opened this issue Dec 18, 2022 · 7 comments
Open

the meaning of prev_root #78

jackzhp opened this issue Dec 18, 2022 · 7 comments

Comments

@jackzhp
Copy link

jackzhp commented Dec 18, 2022

I don't understand its meaning.

Why for the genesis block(mainnet), it has prev_root 0000000000000000002a8bc32f43277fe9c063b9c99ea252b483941dcd06e217
and for floo net, it is 00000000000000000017ff4903ef366c8f62e3151ba74e41b8332a126542f538?

Thanks.

@jackzhp
Copy link
Author

jackzhp commented Dec 18, 2022

Then I found that 0000000000000000002a8bc32f43277fe9c063b9c99ea252b483941dcd06e217
is the block # of BTC at height 558653(15th Jan 2019 15:00:22)

while 00000000000000000017ff4903ef366c8f62e3151ba74e41b8332a126542f538 is the block # of BTC at height 555959(
28th Dec 2018 20:15:09)

Why Grin contains the info from BTC? very weird.

@tromp
Copy link
Contributor

tromp commented Dec 18, 2022

Not that weird; it serves as proof that the Grin Genesis blocks were generated after those Bitcoin blocks were (similar to the Bitcoin genesis block containing the message “The Times 03/Jan/2009 Chancellor on brink of second bailout for banks”). This further allays possible fears that the chain could have been fast mined before the public.

@jackzhp
Copy link
Author

jackzhp commented Dec 20, 2022

Thanks for responding to me.

OK. then does this really get into the MMR? it say prev_root.

suppose it does not get into the header MMR, then the first node of the header MMR is the blake2b(32) hash of
HeaderEntry(block#0 hash + timestamp + totalDifficult + secondary_scale + isSecondary).
ie. 40ADAD0AEC27797B48840AA9E00472015C21BAEA118CE7A2FF1A82C0F8F5BF82000000005C3E03D600000004000000000000074001 (*****)
and its hash_with_index 0(8 bytes): gives: A4E6257532125F637CED6F3A1D1BD0BDAAF0C77630337DEDC0C14BD3E88F0246

this does not match the block#1.prev_root 5671FB28C1509E422D9B8F60CE90E9AC9041E3B9FEBD34A79C03048844ED2733 (%%%%%)

suppose it(the BTC block hash) does not get into the header MMR, it's the first node, and the genesis block gives the 2nd node. blake2b(32) hash the (***** line) with index 1(the 2nd node), this gives: DC205D06D4358D797B8A03D02EB52DD792BD151B8C64F2D315D6489804109C91
And then the 3rd Node is C0B2622CF9DDD8B22821B1FFCC133AB5EDA5F85812C697C36CDF1370241F7DA8, still not expected (%%%%% line)

Anyone has any idea on this?
I guess I did not get (the ***** line) right, but this is specified in block.rs.

@tromp
Copy link
Contributor

tromp commented Dec 20, 2022

the first node of the header MMR is the blake2b(32) hash of
HeaderEntry(block#0 hash + timestamp + totalDifficult + secondary_scale + isSecondary).

What do you mean by "block#0 hash"?
The HeaderEntry hash is set to the BlockHeader hash which is the Blake2b hash of the prepow header as defined in

https://github.com/mimblewimble/grin/blob/684f0a387ae1ac47e34e68aae2cf94514b86aaf4/core/src/core/block.rs#L322

@jackzhp
Copy link
Author

jackzhp commented Dec 21, 2022

eventually, I found that for header MMR, to build the mountain, only the index + cuckoo_solution is hashed for those leaf nodes, now block#x.prev_root is indeed the root of the header MMR.

@jackzhp
Copy link
Author

jackzhp commented Dec 21, 2022

And the BTC block hash does not get into the MMR.

@tromp
Copy link
Contributor

tromp commented Dec 21, 2022

cuckoo_solution is hashed

Where in the code did you see this happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants