feat(flatkv): add comprehensive writing test coverage and centralize account-field semantics#3057
Open
blindchaser wants to merge 6 commits intomainfrom
Open
feat(flatkv): add comprehensive writing test coverage and centralize account-field semantics#3057blindchaser wants to merge 6 commits intomainfrom
blindchaser wants to merge 6 commits intomainfrom
Conversation
- Fix fullScanLtHash to include legacyDB scan (was silently incomplete) - Add/enhance 18 write tests: semantic routing, delete semantics, cross-changeset ordering, input validation, metadata persistence, reopen correctness, snapshot+truncation, and fault tolerance
…account-field semantics Add explicit AccountValue helpers (NonceBytes, CodeHashBytes, ClearNonce, ClearCodeHash) to encode the asymmetric delete contract at the type level. Remove dead pendingAccountWrite.isDelete code path. Fix fullScanLtHash to include legacyDB. Add read-only LoadVersion mode. Includes write, persistence, fault-tolerance, and LtHash correctness tests across all sub-DBs.
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3057 +/- ##
==========================================
+ Coverage 58.32% 58.35% +0.02%
==========================================
Files 2079 2079
Lines 171899 171897 -2
==========================================
+ Hits 100268 100318 +50
+ Misses 62674 62636 -38
+ Partials 8957 8943 -14
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
cody-littley
approved these changes
Mar 12, 2026
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
Centralize account-field read/delete semantics into explicit
AccountValuemethods, remove deadpendingAccountWrite.isDeletecode path, fixfullScanLtHashlegacyDB omission, and add comprehensive write/persistence/fault-tolerance test coverage across all FlatKV sub-DBs.KVPair.Deletefor account fields (nonce, codehash) is a field reset withinAccountValue, not a physical row removal.NonceBytesalways returns(zero, true)for zero nonce;CodeHashBytesreturns(nil, false)for zero codehash. Storage, code, and legacy deletes remain physical tombstones. The accountDB row always persists -- there is no row-level delete.keys.go: AddNonceBytes,CodeHashBytes,ClearNonce,ClearCodeHashtoAccountValue. Each method encodes the asymmetric nonce/codehash delete contract at the type level.store.go: RemoveisDeletefrompendingAccountWrite. Document that account-field deletes are field resets, not row tombstones.store_read.go: Replace duplicated inline nonce/codehash extraction (2 call sites) withNonceBytes()/CodeHashBytes(). Remove deadpaw.isDeleteguard and unusedencoding/binaryimport.store_write.go:ApplyChangeSetsdelete path callsClearNonce()/ClearCodeHash()instead of manual zeroing. LtHash pair construction enforcesDelete: falsefor account rows.commitBatchesremoves deadpaw.isDeletebranch -- account writes always useSet.lthash_correctness_test.go:fullScanLtHashnow includeslegacyDBscan, fixing an omission where legacy entries were excluded from ground-truth LtHash computation.store_test.go,store_read_test.go,store_write_test.go: All test changeset names corrected from"test"/"empty"/"write"/"delete"to"evm"so data flows through the actual EVM key routing path.Test plan
keys_test.go-- 4 new unit tests:TestAccountValueNonceBytes: zero, non-zero, max uint64 nonce encoding; alwaysfound=true.TestAccountValueCodeHashBytes: zero codehash returns(nil, false); non-zero returns bytes.TestAccountValueClearNonce: zeroes nonce, preserves codehash.TestAccountValueClearCodeHash: zeroes codehash, preserves nonce.store_write_test.go-- 8 new tests:TestDeleteSemanticsCodehashAsymmetry: nonce delete returns(zero, found=true), codehash delete returns(nil, found=false), accountDB row persists, code physically deleted.TestCrossApplyChangeSetsOrdering: write-then-delete and delete-then-write for storage keys within same block.TestCrossApplyChangeSetsAccountOrdering: 4 subtests for nonce/codehash write-delete ordering and asymmetric visibility.TestEmptyCommitWALPayloadsDiffer: nil vs empty changeset WAL payload distinction.TestSubDBEntryCount: live entry counts after writes, overwrites, and deletes across sub-DBs; account delete does not reduce count.TestApplyChangeSetsInvalidNonceLength/TestApplyChangeSetsInvalidCodehashLength: input validation error paths.TestAccountValueEncodingTransition: EOA (40 bytes) to contract (72 bytes) and back via codehash add/delete; nonce survives transitions.lthash_correctness_test.go-- 6 new tests:TestFullScanLtHashIncludesLegacy: ground-truth scan covers legacyDB.TestLtHashCrossApply{Account,Storage,Code,Legacy,Mixed}Overwrite: same-key overwrite across twoApplyChangeSetscalls in one block, full-scan verified for each key type and all types combined.snapshot_test.go-- 7 new tests:TestReopenAfterEmptyCommits/TestReopenAfterDeletes: version and LtHash persistence across close/reopen; asymmetric nonce/codehash delete visibility after restart.TestWALTruncationThenRollback: snapshot + WAL truncation + rollback to earlier version.TestReopenAfterSnapshotAndTruncation: reopen from snapshot after WAL truncation.TestSingleDBOpenFailure/TestGlobalMetadataCorruption/TestLocalMetaCorruption: fault injection -- corrupt MANIFEST, global version, local meta;LoadVersionrejects.TestWALDirectoryDeleted: recovery from missing WAL directory when snapshot is current.TestWALSegmentCorruption: corrupt WAL segments prevent catchup to target version.store_meta_test.go-- 1 new test:TestGlobalMetadataPersistence: global version and LtHash checksum survive close/reopen via metadataDB.