-
Notifications
You must be signed in to change notification settings - Fork 810
feat(sync/customrawdb): migrate customrawdb package from coreth #4387
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
feat(sync/customrawdb): migrate customrawdb package from coreth #4387
Conversation
- Move `plugin/evm/customrawdb` in `coreth` to `vms/evm/sync` in `avalanchego` as part of state sync code migration effort. resolves #4386 Signed-off-by: Tsvetan Dimitrov ([email protected])
296bb75
to
fff1df9
Compare
… assertions - Add tests: - Time markers (offline_pruning, populate_missing_tries): missing marker and bad-encoding cases. - Pruning disabled flag: presence toggling. - Acceptor tip: invalid length error and write/read behavior (table-driven: none, single_write, overwrite). - State sync: sync root read/write, code-to-fetch iterate/delete, segments/storage tries iterate/unpack/clear, sync performed latest (empty/increasing/unsorted). - Snapshot: block hash read/write/delete and account iterator key-length filtering. - ParseStateSchemeExt: Firewood on empty DB, conflict on existing scheme, passthrough for "hash". - Refactor/behavioral tightening (internal-only): - Add unexported sentinels: errMarkerNotFound, errMarkerInvalid, errAcceptorTipInvalid. - Normalize time marker reads: use `Has()` for presence and return `errMarkerNotFound` when absent/empty. Wrap decode errors with `errMarkerInvalid`. - Wrap acceptor tip invalid-length with `errAcceptorTipInvalid`. - Tests assert with `require.ErrorIs` for known sentinels. - Schema organization: - Group all package-level globals in a single var block in schema_ext.go - Add clear section headers to improve readability
@joshua-kim I added lots of new tests that enable having the following coverage for the package:
I fixed most of the minor comments and will get back on the rest of your points once I have more historical context from the team. |
… add sentinel errors, fix tests - Replace geth-style zero/nil read returns with explicit errors across customrawdb. - Add exported sentinel errors: - ErrEntryNotFound, ErrInvalidData, ErrStateSchemeConflict, ErrInvalidArgument - Update accessors to return errors consistently. - Align tests with new errors and function signatures. - Convert cases to table-driven, snake_case names. - Add no-op clear tests for segments/storage tries. - Add invalid-length/invalid-encoding tests (snapshot block hash, time markers). - Add iterator error checks after loops.
… add sentinel errors, fix tests - Replace geth-style zero/nil read returns with explicit errors across customrawdb. - Add exported sentinel errors: - ErrEntryNotFound, ErrInvalidData, ErrStateSchemeConflict, ErrInvalidArgument - Update accessors to return errors consistently. - Align tests with new errors and function signatures. - Convert cases to table-driven, snake_case names. - Add no-op clear tests for segments/storage tries. - Add invalid-length/invalid-encoding tests (snapshot block hash, time markers). - Add iterator error checks after loops.
@joshua-kim all comments should be fixed. Discussed with the team to omit |
…sibilities - Rename scheme.go -> db.go (state scheme parsing, shared package items). - Rename state_sync.go -> sync_progress.go (state sync progress + iterators). - Merge snapshot helpers into markers.go (all node/chain metadata in one place). - De-flake and simplify tests: - Make time-marker writes deterministic by passing a fixed timestamp in tests - Simplify ReadChainConfig tests, remove mutate case and rely on dedicated invalid JSON test. - Use require.ErrorIs consistently for error assertions.
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParseStateScheme(t *testing.T) { |
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.
No action required, but I'd probably slightly prefer this as a test vector... Admittedly this might be more succinct as is.
Why this should be merged
Check #4386
How this works
plugin/evm/customrawdb
incoreth
tovms/evm/sync
inavalanchego
as part of state sync code migration effort.geth
-style zero/nil read returns with explicit errors across customrawdb.ErrEntryNotFound
,ErrInvalidData
,ErrStateSchemeConflict
,ErrInvalidArgument
How this was tested
Existing UT that come with the migrated code plus newly added UT to cover the entire package API.
Need to be documented in RELEASES.md?
no
resolves #4386
Signed-off-by: Tsvetan Dimitrov ([email protected])