Skip to content

Hack to force relay commitment [DO NOT MERGE] #1437

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alistair-singh
Copy link
Contributor

@alistair-singh alistair-singh commented Apr 4, 2025

Relayer failed in live.

{"@timestamp":"2025-04-04T01:41:26.15913+02:00","error":"scan safe commitments: fetch commitment and proof: Proof for leaf is invalid for block 25420895 at hash 0xf409a91637c990d58941c481b38598f2b7b49a3a3e1b27fbec1828d89e04e46d: %!w(\u003cnil\u003e)","level":"fatal","message":"Unhandled error"}

Basically, the proof did not match the onchain MMR root, and the relayer rejected it. On chain MMR root hash 0x2a060a3e22a31c99488a77c0e159b3e681c7057ffcadaf6d47168f84b1845355

You can reproduce with the following command:

snowbridge-relay scan-beefy -p wss://api-polkadot.dwellir.com/$DWELLIR_KEY -b 25420894

Hacked the relayer so that it would skip this commitment and move onto the next one which unblocked the relayer.

@@ -19,7 +20,7 @@ type ScanBlocksResult struct {

func ScanBlocks(ctx context.Context, meta *types.Metadata, api *gsrpc.SubstrateAPI, startBlock uint64) (chan ScanBlocksResult, error) {
results := make(chan ScanBlocksResult)
go scanBlocks(ctx, meta, api, startBlock, results)
go scanBlocks(ctx, meta, api, 25420890, results)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hard code block number to 5 blocks before the block that has the bad commitment so that we can skip directly to the block we want.

@@ -108,7 +109,7 @@ func scanBlocks(ctx context.Context, meta *types.Metadata, api *gsrpc.SubstrateA
}

if sessionIndex > currentSessionIndex {
currentSessionIndex = sessionIndex
//currentSessionIndex = sessionIndex
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do not increment the session, which essentially makes it try every block in the next session, pushing all found commitments through instead of the first commitment per session.

logrus.WithError(err).Error("scanned commitment")
//emitError(fmt.Errorf("fetch commitment and proof: %w", err))
//return
continue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When there is an error skip to the next commitment.

@yrong
Copy link
Contributor

yrong commented Apr 4, 2025

Cool! Though it seems more like a workaround.

I noticed that in #1342 we removed the on-demand command, which allows one-shot syncing from an arbitrary Beefy block-not just the boundry session block.

I'd suggest to add it back-it could be useful for scenarios like this.

@yrong
Copy link
Contributor

yrong commented Apr 11, 2025

allows one-shot syncing from an arbitrary Beefy block-not just the boundry session block.

@alistair-singh #1456 is merged. So maybe we can close this PR?

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

Successfully merging this pull request may close these issues.

2 participants