-
Notifications
You must be signed in to change notification settings - Fork 184
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
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.23% 41.17% -0.07%
==========================================
Files 2061 2065 +4
Lines 182702 182905 +203
==========================================
- Hits 75345 75307 -38
- Misses 101049 101290 +241
Partials 6308 6308
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
"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 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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++ { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Cmd.Flags().StringVar(&flagDatadir, "datadir", "/var/flow/data/protocol", | ||
"directory that stores the protocol state") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Cmd.Flags().StringVar(&flagChunkDataPackDir, "chunk_data_pack_dir", "/var/flow/data/chunk_data_pack", | ||
"directory that stores the protocol state") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Thanks for updating the PR! I left some comments.
defer func() { | ||
err := closer() | ||
if err != nil { | ||
log.Error().Err(err).Msg("failed to close storages") | ||
} | ||
}() |
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 to consider returning closer()
error as well.
0c99a9e
to
df4891d
Compare
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.