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

Question about state transition #36

Closed
charliewinston14 opened this issue Feb 2, 2025 · 6 comments
Closed

Question about state transition #36

charliewinston14 opened this issue Feb 2, 2025 · 6 comments
Assignees

Comments

@charliewinston14
Copy link

charliewinston14 commented Feb 2, 2025

For the first safrole transition, 463954_000.json, I have a question about the recent history (beta) MMR result.

The expected beta result seems to expect a MMR with a single peak of "0xbc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a".

How is this determined?

I am arriving at a single peak of "0x0000000000000000000000000000000000000000000000000000000000000000".

Rational:

  • Pre-state beta is blank, so no initial peaks to append too
  • There are no work reports, so the commitment map from accumulation should be blank {} (according to 12.16 in GP 0.5.4) and not include any services. Without services, MB ([s E4(s)⌢ E(h) ∣ (s,h) ∈ C],HK ) should result in a zero hash.

So it's essentially doing a MMR append with a blank array (since no pre-state beta exists) and a zero hash (since a binary merkle tree of a blank array is a zero hash) which all ultimately result to "0x0000000000000000000000000000000000000000000000000000000000000000".

@deadline314
Copy link

deadline314 commented Feb 6, 2025

In fact, 463954_000.json is not the first block; it is the first block after the genesis block. Therefore, its pre_state is based on the genesis state(tiny).

A new test vector has now been released. In the test vector, you will see that the first block is labeled 1_000.json rather than 0_000.json because it is the first block following the genesis block.

If it were truly the first block, the beta field should be empty, as it would not have any recent history. An empty beta should be encoded as 0x00.

Since the encoding formula involves two variable-length encodings:

  1. The first encoding can be found at this reference. At this stage, the recent blocks are empty, so the encoded result is E(0)^E(∅), which results in 0.
  2. The second encoding is detailed here. Since the beefy root is empty in this case, the encoded result is also E(0)^E(∅), which results in 0 as well.

As a result, for the genesis block, you will observe the following outcome:

[
    "0x0300000000000000000000000000000000000000000000000000000000000000",
    "0x00",
    "c3",
    ""
]

@sourabhniyogi
Copy link
Contributor

Closing for now

@sourabhniyogi
Copy link
Contributor

reopening given #49

@sourabhniyogi
Copy link
Contributor

@charliewinston14 Can you kindly check this issue is still present in this recent commit? Thank you!

@charliewinston14
Copy link
Author

Looks good now!

@sourabhniyogi sourabhniyogi self-assigned this Feb 14, 2025
@sourabhniyogi
Copy link
Contributor

Thank you!

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

3 participants