endorser/execution: cover DualStateDB to 98% with dual-side assertions - #345
Merged
arner merged 3 commits intoSep 1, 2026
Merged
Conversation
- New dual_statedb_test.go builds both a go-ethereum StateDB and the endorser SnapshotDB, wraps them in a DualStateDB, and asserts each mutation is reflected on both sides. - Covers accounts, balances/nonces, code, storage (incl. transient and committed), refunds, self-destruct, access list, Prepare, snapshot / revert, logs, Finalise, Result, and pass-through accessors. - Adds EVMEngine read-helper tests (BalanceAt / StorageAt / CodeAt / NonceAt) for the fresh-snapshot path. - dual_statedb.go coverage: 0% -> 98.3%. Package: 22.3% -> 47.4%. Remainder lives in *_logger.go which the issue lists as out of scope. Signed-off-by: Storm1289 <divakarsharma2934@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #345 +/- ##
==========================================
+ Coverage 34.07% 36.62% +2.54%
==========================================
Files 82 82
Lines 11652 11652
==========================================
+ Hits 3970 4267 +297
+ Misses 7347 7042 -305
- Partials 335 343 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎉 OZ Hardhat Compatibility — 11 tests fixed!Stale baseline entries (11) — remove these
Full breakdown — 5519 passed, 874 failed, 1 skipped (6394 total, 86.3% passing)By suite
Expected failures by cause (608)
Lock in the win — run |
Perf Smoke — CI baseline (lower-bound against test committer)
|
Storm1289
marked this pull request as ready for review
August 25, 2026 10:29
arner
approved these changes
Aug 26, 2026
arner
left a comment
Contributor
There was a problem hiding this comment.
Nice! Also functions as documentation on which features we do implement and what we skip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #320.
Adds
endorser/execution/dual_statedb_test.go. The tests build both a go-ethereum in-memorystate.StateDBand the endorserSnapshotDB, wrap them in aDualStateDB, and assert that every mutation is reflected consistently on both sides.Also adds four focused tests for
EVMEngine.BalanceAt,StorageAt,CodeAt, andNonceAt, covering the fresh-snapshot read path.Coverage delta
dual_statedb.go(issue's primary target)statedb.goWhat's tested
All method categories from the issue are covered:
CreateAccount,CreateContract,Exist,Empty,TouchAddBalance,SubBalance,SetNonceSetCode,GetCodeSize,GetCodeHashSetState,GetStateAndCommittedState,GetStorageRoot, transient statePrepareprecompile seedingFinaliseResultLogsIsNewContractLogsForBurnAccountsWitnessAccessEventsOpen question for the maintainer
The package-level coverage is capped by the two
*_logger.gofiles (eth_statedb_logger.goandstatedb_logger.go), which the issue explicitly lists as out of scope. Together they are ~770 LOC of pure logging pass-throughs (~22% of the package by size), gated behind theDebugLogsconfig, and both remain at ~0%.Two ways to reconcile the 70% target while keeping those files out of scope:
endorser/execution/*_logger.goto thecodecov.ymlignorelist, matching the existing**/*.pb.go/**/*.sql.gopattern for non-review-worthy code. In-scope coverage would then be represented accurately.I didn't touch
codecov.ymlin this PR. Happy to add the ignore lines in a follow-up commit if you prefer option 1.Out of scope
eth_statedb_logger.go/statedb_logger.go- debug wrappers, config-gatedTest plan
go build ./...go test -race -count=1 ./endorser/execution/...go test -cover ./endorser/execution/...→ 47.4% package, 98.3% ondual_statedb.go