Replace ecosystem tag constants with typed enum - #1361
Conversation
Derive Evm/Svm `transactionFields` from the typed `Internal` field lists
instead of restating them as string literals, so the array order (the
bitmask field codes shared with the Rust store) can't drift from the
variant lists. The two redundant contract tests are dropped; the
`Internal.all*TransactionFields` pins to the Rust ordinals remain.
Replace the `ECO_UNKNOWN/EVM/SVM` u8 constants and bare-integer match
with an `Ecosystem { Evm, Svm }` enum. The not-yet-learned state is now
`Option::None` rather than a magic variant; the atomic keeps a `u8` tag
(`0` = unset) behind `to_tag`/`from_tag`, and `materialize` dispatches on
an exhaustive `Some(Evm)/Some(Svm)/None` match.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019sLva7B7C64twV9DVcJb6X
|
Warning Review limit reachedYou鈥檝e reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 17 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details鈿欙笍 Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 馃搾 Files selected for processing (9)
Comment |
The store's ecosystem is fixed per chain by config, so model it that way
instead of learning it lazily from the first merged page:
- `Ecosystem` becomes a data-carrying enum `Evm { should_checksum } | Svm
| Fuel`. `should_checksum` (a per-chain EVM constant) moves out of its
own field into the `Evm` variant, so it can't be set without EVM or
forgotten for it.
- The unset state is gone. The enum has no `Unknown`/`None`; `ecosystem`
is a plain immutable field set at construction, dropping both atomics,
the `u8` tag round-trip, and the lazy learn-on-merge branch.
- Fuel is a first-class variant rather than an untracked case; its store
is inert (Fuel keeps transactions inline) but honestly typed.
- Expose `newEvm`/`newSvm`/`newFuel` factories; ReScript `make` takes the
ecosystem (+ EVM checksum) and dispatches. ChainState derives both from
config (`config.ecosystem.name`, `!lowercaseAddresses`), so even
`CustomSources` chains construct the right store.
`merge` no longer transfers ecosystem/checksum (both fixed at
construction); a debug assert pins the page-vs-store ecosystem match.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019sLva7B7C64twV9DVcJb6X
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
Bring in main (incl. #1361 typed transaction-store ecosystem). Apply the same to BlockStore: replace the ECO_* u8 constants + atomics with a construction-time Ecosystem { Evm { should_checksum }, Svm, Fuel } enum and new_evm/new_svm/new_fuel factories; merge no longer learns the ecosystem (debug-asserts page==store). ReScript BlockStore.make takes ~ecosystem/~shouldChecksum and ChainState derives both from config, mirroring TransactionStore.
Replace magic number constants (
ECO_UNKNOWN,ECO_EVM,ECO_SVM) with a properEcosystemenum in the transaction store, improving type safety and code clarity.Key changes:
Ecosystemenum withEvmandSvmvariants, eliminating the need for anUnknownvariant by usingOption<Ecosystem>to represent the unset stateEcosystem::to_tag()andEcosystem::from_tag()methods to convert between the enum and theu8tags stored in the atomicecosystem()andset_ecosystem()helper methods onTransactionStoreto encapsulate tag conversion logicInternaldefinitions instead of maintaining separate hardcoded arrays, eliminating drift risk between Rust and ReScript orderingsImplementation details:
The persistent store starts with ecosystem unset (
0), learned from the first merged page. UsingOption<Ecosystem>makes this unset state explicit in the type system rather than relying on a magic constant. The atomic still storesu8tags for serialization, but all code paths now work with the typed enum.https://claude.ai/code/session_019sLva7B7C64twV9DVcJb6X