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

Fix mmr generation #1307

Merged
merged 4 commits into from
Oct 14, 2024
Merged

Fix mmr generation #1307

merged 4 commits into from
Oct 14, 2024

Conversation

alistair-singh
Copy link
Contributor

@alistair-singh alistair-singh commented Oct 9, 2024

The slice length changes after filtering parathreads.

Test old mmr format without parathreads included:

./build/snowbridge-relay parachain-head-proof \
  --url wss://api-polkadot.dwellir.com/$DWELLIR_API_KEY \
  --beefy-block-hash 495ed6c915cb88a975a577005bb3e5cf7a415797de2088316f5e1cd3d795fe91 \
  --relaychain-block 22890956 \
  --parachain-id 1000

Test new mmr format with parathreads included:

./build/snowbridge-relay parachain-head-proof \
  --url wss://api-westend.dwellir.com/$DWELLIR_API_KEY \
  --beefy-block-hash 6f117b7950151ea125ed32833efefb14a29eb931664ac57a2dbb6f3ecf6dbffe \
  --relaychain-block 22910330 \
  --parachain-id 1000

Commands will exit with 0 exit code if successful.

@alistair-singh alistair-singh requested review from vgeddes and yrong and removed request for vgeddes October 9, 2024 23:44
Copy link
Contributor

@claravanstaden claravanstaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having some tests for this with mocked data would be great. Doesn't have to be in this PR but something that would be nice in the future.

@@ -72,7 +66,8 @@ func ParachainHeadProofFn(cmd *cobra.Command, _ []string) error {
copy(beefyBlockHash[:], beefyBlockHashHex[0:32])

relayChainBlock, _ := cmd.Flags().GetUint64("relaychain-block")
mmrProof, err := conn.GenerateProofForBlock(relayChainBlock, beefyBlockHash)
// magic plus 1 to make the block a leaf index
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this command used in prod or is it a convenience method for testing?

Copy link
Contributor Author

@alistair-singh alistair-singh Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience for testing. If you are concerned about the magic +1 we also do that in the code that runs in prod.

https://github.com/Snowfork/snowbridge/blob/alistair/fix-merkle-proof/relayer/relays/parachain/beefy-listener.go#L239

@vgeddes vgeddes removed their request for review October 10, 2024 12:34
Copy link
Contributor

@yrong yrong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this branch on Westend and transfer for both direction work as expected.

@alistair-singh
Copy link
Contributor Author

alistair-singh commented Oct 10, 2024

Waiting on paseo confirmation to merge. @claravanstaden

I can also pick up testing if you have not managed to get this far.

@claravanstaden
Copy link
Contributor

@alistair-singh testing now...

@claravanstaden
Copy link
Contributor

@alistair-singh Paseo works:

Oct 11 08:31:40 ip-172-31-3-187 start-beefy-relay.sh[3461488]: {"@timestamp":"2024-10-11T08:31:40.905666383Z","commitment":{"blockNumber":3297821,"nextValidatorSetID":5564,"validatorSetID":5563},"level":"info","message":"Sending BEEFY commitment to ethereum writer","validatorSetID":5562}
Oct 11 08:31:41 ip-172-31-3-187 start-beefy-relay.sh[3461488]: {"@timestamp":"2024-10-11T08:31:41.226587147Z","chosenValidator":96,"level":"info","message":"Creating initial bitfield","signedValidatorCount":77,"signedValidators":[0,2,3,4,5,7,8,10,11,12,13,18,21,22,23,24,25,26,28,29,30,32,33,36,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,55,56,57,58,59,62,65,66,67,68,69,72,73,74,76,79,80,84,85,88,90,91,93,96,97,98,100,101,102,103,105,106,107,108,110,111,112,113],"validatorCount":115}
Oct 11 08:31:41 ip-172-31-3-187 start-beefy-relay.sh[3461488]: {"@timestamp":"2024-10-11T08:31:41.907644706Z","Bitfield":["0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111101111011110111001011010011000110010111001111100100111110111111111111011101001101110111111001000011110110111101"],"Commitment":{"blockNumber":3297821,"payload":[{"data":"0x64e80509970a9f2e4e202d8090e23b5b9c6e35a21b8e925e0c2fa90c65112ec6","payloadID":"mh"}],"validatorSetID":5563},"CommitmentHash":"0x2f1dda6ea6d3f91720055c5b43e486d84a063989698329f86cb9bd02c8f19afb","Proof":{"Account":"0x5E5512084987a78F6d70D3420d9Fb77ce2B46743","Index":96,"Proof":["0xb537ed5c55c21cfef135cbd6960a55af82cdc773403db07e6bcb8ae157225fda","0x0f9409f4116812ab737e1f48800be7e134f4a70aef6dee9141091fa8655bed81","0xce38a3b280e7e0dbc2a2da511802953c724fa0749da501a7590410fe95a6df31","0x54440d47924c73e9eb7153657b173bc26a5801b92acefcdf9cecbf4660e97156","0x22e2e18b479970565bbc330afe497478fdec94a34e2e3609cd69bdb22b768d68","0x91a7ae55717003aa28816f37c6b25e4f70cac6efbeac9ad01c07dd320e4de08e","0xe91708b137e708f515d6cdb228b510069e3e327ae2f3795e619ec1d52fff1b23"],"R":"0xf1be526dcdfc4a11d5d803c58eefecd93563ebcc938e8de74d79782487cc5b77","S":"0x1d9c2ba4c6fc0313927148d3dd6f1ef77272600c6731d0648c174455caddfa1b","V":28},"level":"info","message":"Transaction submitted for initial verification","txHash":"0x031b74f39f8438f88309234b1ce52e42d2d29e1fde737e181b3ec1c3d7fc98a8"}

@claravanstaden claravanstaden merged commit eebc7ca into main Oct 14, 2024
1 check passed
@claravanstaden claravanstaden deleted the alistair/fix-merkle-proof branch October 14, 2024 08:08
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

Successfully merging this pull request may close these issues.

3 participants