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

Add verification tool for evm offchain replay #6755

Merged
merged 22 commits into from
Dec 2, 2024

Conversation

zhangchiqing
Copy link
Member

@zhangchiqing zhangchiqing commented Nov 22, 2024

This PR adds a util cmd for verifying the evm offchain replay.

No API change for gateway.

@zhangchiqing zhangchiqing changed the base branch from master to leo/add-testcase-for-offchain-evm-backward-compatibilities November 22, 2024 16:22
@zhangchiqing zhangchiqing marked this pull request as ready for review November 22, 2024 16:23
@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 1.99275% with 541 lines in your changes missing coverage. Please review.

Project coverage is 41.07%. Comparing base (c96b754) to head (1bdc486).

Files with missing lines Patch % Lines
fvm/evm/offchain/utils/verify.go 0.00% 186 Missing ⚠️
cmd/util/cmd/verify-evm-offchain-replay/verify.go 0.00% 112 Missing ⚠️
fvm/evm/testutils/gob.go 0.00% 66 Missing ⚠️
fvm/evm/offchain/utils/replay.go 0.00% 52 Missing ⚠️
cmd/util/cmd/verify-evm-offchain-replay/main.go 0.00% 46 Missing ⚠️
fvm/evm/offchain/blocks/provider.go 0.00% 34 Missing ⚠️
fvm/evm/offchain/blocks/block_proposal.go 0.00% 22 Missing ⚠️
fvm/evm/offchain/sync/replay.go 40.00% 12 Missing ⚠️
fvm/evm/offchain/sync/replayer.go 33.33% 6 Missing ⚠️
fvm/evm/handler/blockHashList.go 0.00% 4 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6755      +/-   ##
==========================================
- Coverage   41.17%   41.07%   -0.11%     
==========================================
  Files        2065     2071       +6     
  Lines      182905   183431     +526     
==========================================
+ Hits        75316    75336      +20     
- Misses     101284   101794     +510     
+ Partials     6305     6301       -4     
Flag Coverage Δ
unittests 41.07% <1.99%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhangchiqing zhangchiqing force-pushed the leo/add-verify-evm-offchain-replay branch from 103f257 to d379a68 Compare November 22, 2024 16:49
Copy link
Contributor

@janezpodhostnik janezpodhostnik left a comment

Choose a reason for hiding this comment

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

Nice!

return nil
}

func parseEVMEvents(evts flow.EventsList) (*events.BlockEventPayload, []events.TransactionEventPayload, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not seem to handle the case where there was a period that did not have blocks executed events, but did have transaction executed.

The solution is to accumulate the transaction executed events, until you hit the next block executed event.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's handled by the NewEVMEventsAccumulator module

return nil
}

func initStorages(chainID flow.ChainID, dataDir string, executionDataDir string) (
Copy link
Contributor

Choose a reason for hiding this comment

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

chain ID is not needed

@zhangchiqing zhangchiqing force-pushed the leo/add-verify-evm-offchain-replay branch 2 times, most recently from 8f6ed3b to 5db925d Compare November 23, 2024 00:57
@zhangchiqing zhangchiqing force-pushed the leo/add-testcase-for-offchain-evm-backward-compatibilities branch from 4fe749e to 27c0f3a Compare November 23, 2024 04:47
@zhangchiqing zhangchiqing force-pushed the leo/add-verify-evm-offchain-replay branch from a725780 to f564161 Compare November 23, 2024 04:48
@zhangchiqing zhangchiqing force-pushed the leo/add-testcase-for-offchain-evm-backward-compatibilities branch from 27c0f3a to 0cfcb7d Compare November 25, 2024 19:13
Base automatically changed from leo/add-testcase-for-offchain-evm-backward-compatibilities to master November 26, 2024 20:56
@zhangchiqing zhangchiqing requested review from janezpodhostnik and removed request for Kay-Zee November 26, 2024 23:30
@zhangchiqing zhangchiqing force-pushed the leo/add-verify-evm-offchain-replay branch from 887419e to a41e107 Compare November 27, 2024 00:40
transactionEvents []events.TransactionEventPayload,
blockEvent *events.BlockEventPayload,
) (types.ReplayResultCollector, error) {
) (types.ReplayResultCollector, []*types.Result, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added the result for comparing trie updates, but the original ReplayBlock is unchanged, so that gateway doesn't need to update its usage.

if chainID == flow.Testnet {
return flowHeight == 211176670
} else if chainID == flow.Mainnet {
return flowHeight == 85981135
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that the proper Flow Height should be 85981134. This is where the EVM contract was first deployed on mainnet, see https://www.flowscan.io/contract/A.e467b9dd11fa00df.EVM/deployments?deployment=85981134

Copy link
Member Author

Choose a reason for hiding this comment

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

This height is used to skip the root height where there is no execution data to read EVM events from.

Technically, you are right, but I can't use 85981134 with mainnet25's data, because 85981134 is a block from mainnet24. And this doesn't matter much as both 85981134 and 85981135 have no EVM events.

It only matters if we are verifying the state change at register level, which is not the case at the moment.

Copy link
Collaborator

@m-Peter m-Peter left a comment

Choose a reason for hiding this comment

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

LGTM! Just one correction on the mainnet first EVM height.

@zhangchiqing zhangchiqing force-pushed the leo/add-verify-evm-offchain-replay branch from 556d903 to 1bdc486 Compare December 2, 2024 22:34
@zhangchiqing zhangchiqing added this pull request to the merge queue Dec 2, 2024
Merged via the queue into master with commit 85913ad Dec 2, 2024
55 checks passed
@zhangchiqing zhangchiqing deleted the leo/add-verify-evm-offchain-replay branch December 2, 2024 23:54
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.

4 participants