Skip to content

Conversation

powerslider
Copy link

Why this should be merged

Check #4386

How this works

  • Move plugin/evm/customrawdb in coreth to vms/evm/sync in avalanchego as part of state sync code migration effort.

How this was tested

Existing UT that come with the migrated code.

Need to be documented in RELEASES.md?

no

resolves #4386

Signed-off-by: Tsvetan Dimitrov (tsvetan.dimitrov23@gmail.com)

- 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 (tsvetan.dimitrov23@gmail.com)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have this file? This contains dead code/a function that isn't actually a test.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I agree with this. I will check why this was historically added in the first place, but we can definitely remove it from here.

Copy link
Contributor

Choose a reason for hiding this comment

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

What does the _ext suffix on these files mean? Should we remove it?

… 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
@powerslider
Copy link
Author

powerslider commented Oct 10, 2025

@joshua-kim I added lots of new tests that enable having the following coverage for the package:

coverage: 88.2% of statements
ok  	github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb	0.305s	coverage: 88.2% of statements

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress 🏗️

Development

Successfully merging this pull request may close these issues.

Migrate customrawdb package from coreth to avalanchego

3 participants