-
Notifications
You must be signed in to change notification settings - Fork 179
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
[Util] Add verify execution result cmd #6746
base: master
Are you sure you want to change the base?
Conversation
@@ -661,42 +646,3 @@ func executorsOf(receipts []*flow.ExecutionReceipt, resultID flow.Identifier) (f | |||
|
|||
return agrees, disagrees | |||
} | |||
|
|||
// EndStateCommitment computes the end state of the given chunk. | |||
func EndStateCommitment(result *flow.ExecutionResult, chunkIndex uint64, systemChunk bool) (flow.StateCommitment, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving these functions to a separate package, so that it can be reused.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6746 +/- ##
==========================================
- Coverage 41.19% 41.18% -0.01%
==========================================
Files 2052 2063 +11
Lines 182215 182822 +607
==========================================
+ Hits 75069 75301 +232
- Misses 100852 101216 +364
- Partials 6294 6305 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
"last k sealed blocks to verify") | ||
|
||
Cmd.Flags().StringVar(&flagFromTo, "from_to", "", | ||
"the height range to verify blocks, i.e, 1-1000, 1000-2000, 2000-3000, etc.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the height range to verify blocks, i.e, 1-1000, 1000-2000, 2000-3000, etc.") | |
"the height range to verify blocks (inclusive), i.e, 1-1000, 1000-2000, 2000-3000, etc.") |
|
||
blockID := header.ID() | ||
|
||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like something was removed. should the also be removed?
return chunkVerifier | ||
} | ||
|
||
func initFvmOptions(chainID flow.ChainID, headers storage.Headers) []fvm.Option { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this reuse code from the standard initialization? I worry that the config will drift and we will need to maintain multiple this init in multiple files
89ae34a
to
6453fb4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly reviewed from Go programming perspective and left some comments.
} | ||
|
||
log.Info().Msgf("verifying range from %d to %d", from, to) | ||
err = verifier.VerifyRange(from, to, flow.Testnet, flagDatadir, flagChunkDataPackDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to use chain ID provided by user.
err = verifier.VerifyRange(from, to, flow.Testnet, flagDatadir, flagChunkDataPackDir) | |
err = verifier.VerifyRange(from, to, flow.ChainID(flagChain), flagDatadir, flagChunkDataPackDir) |
|
||
} else { | ||
log.Info().Msgf("verifying last %d sealed blocks", flagLastK) | ||
err := verifier.VerifyLastKHeight(flagLastK, flow.Testnet, flagDatadir, flagChunkDataPackDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Need to use chain ID provided by user.
err := verifier.VerifyLastKHeight(flagLastK, flow.Testnet, flagDatadir, flagChunkDataPackDir) | |
err := verifier.VerifyLastKHeight(flagLastK, flow.ChainID(flagChain), flagDatadir, flagChunkDataPackDir) |
log.Info().Msgf("verifying range from %d to %d", from, to) | ||
err = verifier.VerifyRange(from, to, flow.Testnet, flagDatadir, flagChunkDataPackDir) | ||
if err != nil { | ||
log.Fatal().Err(err).Msg("could not verify last k height") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatal().Err(err).Msg("could not verify last k height") | |
log.Fatal().Err(err).Msg("could not verify range from %d to %d", from, to) |
if err != nil { | ||
return fmt.Errorf("could not init storages: %w", err) | ||
} | ||
defer db.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to close chunkDataPackDB (e.g. by using "chunkDataPackDB.Close()" in defer
)?
Maybe have a separate initChunkDataPack()
to return chunkDataPackDB
so we can close it in defer
.
} | ||
|
||
root := state.Params().SealedRoot().Height | ||
from := lastSealed.Height - k + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check if k
<= lastSealed.Height
to prevent overflow since from
is uint64?
if err != nil { | ||
return fmt.Errorf("could not init storages: %w", err) | ||
} | ||
defer db.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above about closing ChunkDataPackDB.
} | ||
defer db.Close() | ||
|
||
for height := from; height <= to; height++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check from
against first verifiable block as in VerifyLastKHeight()
?
|
||
_, err = verifier.Verify(vcd) | ||
if err != nil { | ||
return fmt.Errorf("could not verify %d-th chunk: %w", i, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add height in the error message.
Cmd.Flags().StringVar(&flagDatadir, "datadir", "/var/flow/data/protocol", | ||
"directory that stores the protocol state") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make datadir
required.
Cmd.Flags().StringVar(&flagDatadir, "datadir", "/var/flow/data/protocol", | |
"directory that stores the protocol state") | |
Cmd.Flags().StringVar(&flagDatadir, "datadir", "/var/flow/data/protocol", | |
"directory that stores the protocol state") | |
_ = Cmd.MarkFlagRequired("datadir") |
Cmd.Flags().StringVar(&flagChunkDataPackDir, "chunk_data_pack_dir", "/var/flow/data/chunk_data_pack", | ||
"directory that stores the protocol state") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make chunk_data_pack_dir
required.
Cmd.Flags().StringVar(&flagChunkDataPackDir, "chunk_data_pack_dir", "/var/flow/data/chunk_data_pack", | |
"directory that stores the protocol state") | |
Cmd.Flags().StringVar(&flagChunkDataPackDir, "chunk_data_pack_dir", "/var/flow/data/chunk_data_pack", | |
"directory that stores the protocol state") | |
_ = Cmd.MarkFlagRequired("chunk_data_pack_dir") |
Working towards #6557
This PR implemented option 4 in the above issue.
It adds a util command
verify-execution-result
that takes execution node's data and verifies every single chunks for a range blocks.Since we would like to make sure future cadence versions are backward compatible. This util allows us to capture any backward compatibilities issue from either FVM or cadence related changes.
For instance, if cadence introduces a breaking change, then it will be caught by running this
verify-execution-result
with a latest snapshot of EN. The util can verify the last 1M blocks, and 1 of the chunk might fail caused by the breaking change.I have verified with the latest testnet snapshot, and it worked. It verified 200K blocks after 3 hours, roughly 18 blocks per sec. The memory needed is about 14G.
Future optimization can be done by parallelizing the verification.