refactor(vara.eth): introduce typed MB/EB hashes, move MB to ethexe-common - #5508
Draft
grishasobol wants to merge 6 commits into
Draft
refactor(vara.eth): introduce typed MB/EB hashes, move MB to ethexe-common#5508grishasobol wants to merge 6 commits into
grishasobol wants to merge 6 commits into
Conversation
grishasobol
force-pushed
the
gsobol/ethexe/malachite-core-concretize-payload
branch
from
May 25, 2026 10:54
733e281 to
eca538f
Compare
grishasobol
force-pushed
the
gsobol/ethexe/malachite-typed-block-hashes
branch
from
May 25, 2026 11:06
2b05f34 to
a5e2859
Compare
grishasobol
added a commit
that referenced
this pull request
May 25, 2026
PR #5508 left MbStorageRO/RW and OnChainStorageRO/RW + BlockMetaStorageRO/RW methods taking raw H256, which forced every caller to thread untyped hashes and use `.inner()` at boundaries. Type the signatures end-to-end so the typed values flow through the codebase: EB-block hashes become `HashOf<EB>`, MB hashes become `HashOf<MB>`. CAS payload hashes (`set_transactions` return, `transactions(payload_hash)`) stay raw H256 since they're content-addressed, not entity-addressed. The cascade is real — ~30 files touched across ethexe/common, ethexe/db, ethexe/compute, ethexe/consensus, ethexe/malachite/service, ethexe/network, ethexe/observer, ethexe/prometheus, ethexe/rpc and ethexe/service. Where a function receives raw H256 from an external source (chain events, malachite-core API, test fixtures) we still cross the typed boundary with a local `mb_h` / `eb_h` helper rather than making `HashOf::new` safe, so each conversion remains explicit and auditable. `Mirror.processOutgoingAction` flow and existing tests continue to compile and lint clean across the workspace.
Member
Author
|
Pushed refactor to type DB trait signatures with CI: https://github.com/gear-tech/gear/actions/runs/26400404637 |
grishasobol
force-pushed
the
gsobol/ethexe/malachite-core-concretize-payload
branch
from
May 25, 2026 17:15
fbd5c67 to
d3341a6
Compare
grishasobol
added a commit
that referenced
this pull request
May 25, 2026
PR #5508 left MbStorageRO/RW and OnChainStorageRO/RW + BlockMetaStorageRO/RW methods taking raw H256, which forced every caller to thread untyped hashes and use `.inner()` at boundaries. Type the signatures end-to-end so the typed values flow through the codebase: EB-block hashes become `HashOf<EB>`, MB hashes become `HashOf<MB>`. CAS payload hashes (`set_transactions` return, `transactions(payload_hash)`) stay raw H256 since they're content-addressed, not entity-addressed. The cascade is real — ~30 files touched across ethexe/common, ethexe/db, ethexe/compute, ethexe/consensus, ethexe/malachite/service, ethexe/network, ethexe/observer, ethexe/prometheus, ethexe/rpc and ethexe/service. Where a function receives raw H256 from an external source (chain events, malachite-core API, test fixtures) we still cross the typed boundary with a local `mb_h` / `eb_h` helper rather than making `HashOf::new` safe, so each conversion remains explicit and auditable. `Mirror.processOutgoingAction` flow and existing tests continue to compile and lint clean across the workspace.
grishasobol
force-pushed
the
gsobol/ethexe/malachite-typed-block-hashes
branch
from
May 25, 2026 17:17
16ced2a to
8411f43
Compare
Base automatically changed from
gsobol/ethexe/malachite-core-concretize-payload
to
master
June 5, 2026 14:56
…rations rename Master rewrote BlockPayload as Operations (#5506) and renamed the malachite block payload field to operations_hash, obsoleting the original PR's first commit. This commit reconstitutes the PR's typing changes on top of current master: - introduces HashOf<EB> / HashOf<MB> through SimpleBlockData.hash, BlockHeader.parent_hash, BlockData.hash, BlockMeta/MbMeta fields, DBGlobals, DBConfig, ChainCommitment.last_advanced_eth_block, BatchCommitment.block_hash, InjectedTransaction.reference_block, and the MbStorageRO/RW + OnChainStorageRO/RW + BlockMetaStorageRO/RW trait signatures - moves CompactMb into ethexe-common::malachite alongside new MB and BlockPayload types (keeping CompactMb re-exported from db.rs for source compat), and adds the reserved [u8; 64] tail - threads typed hashes through observer (ObserverEvent, BlockLoader, EthereumBlockLoader), consensus (validator state machine, ConsensusService trait, batch utils), compute (ComputeEvent, ComputeError, sub-services, executable preparation), ethexe-malachite (MalachiteEvent, CommitCertificate, EthexeExternalities, mempool, quarantine, tx_validity, receive_eb_prepared), processor (BoundPromiseSink), network (set_chain_head, validator list, db_sync ProgramIds), db (RawDatabase + Database trait impls, iterator nodes, verifier errors, dump collector, init migration), rpc (block_at_or_latest_synced, latest_computed_mb), ethereum (IntoBlockId impl), and cli (dump, check, tx commands) - recomputes EXPECTED_TYPE_INFO_HASH in ethexe-common::db::tests now that BlockMeta / MbMeta / CompactMb / BlockHeader / DBGlobals carry typed wrappers - gates the test module in ethexe-malachite::externalities and ethexe-malachite::tx_validity behind `cfg(all(test, never_built))` pending a follow-up that threads HashOf<MB>/HashOf<EB> through the synthetic-chain helpers and assert_eq! boundary conversions (the prod code those tests exercise is fully typed; the surrounding mempool / quarantine / restart_resilience tests still build and pass) Tests: ethexe-common, ethexe-malachite, ethexe-malachite-core, ethexe-compute, ethexe-processor all pass via cargo nextest (153 tests). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
grishasobol
force-pushed
the
gsobol/ethexe/malachite-typed-block-hashes
branch
from
June 8, 2026 10:54
e578635 to
6f761eb
Compare
…dules under typed MB/EB hashes Re-enable the two test modules disabled during the typed-hash rebase. Thread HashOf<MB>/HashOf<EB> through synthetic-chain helpers, add the new CompactMb.reserved field, and convert at the malachite-core H256 boundary via .inner(). 34 tests restored (12 tx_validity + 22 externalities), all passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
ethexe_malachite_core::Block→ethexe_common::malachite::MB), the versionedBlockPayload, andCompactMbintoethexe-commonso the executor crates can use them without depending on the consensus layer.CompactMbnow matchesMB's shape with the opaque payload replaced bypayload_hash(renamed fromtransactions_hash).HashOf<MB>onCompactMb.parent,BlockMeta.last_committed_mb,DBGlobals.{latest_finalized_mb_hash, latest_computed_mb_hash};HashOf<EB>onMbMeta.last_advanced_eb,BlockMeta.last_committed_eb,DBGlobals.{start_block_hash, latest_prepared_eb_hash},DBConfig.genesis_block_hash.pub type EB = SimpleBlockData+SimpleBlockData::typed_hash()/eb_hash_of(H256)to lift the bare Ethereum block hash into the typed wrapper.HashOf<T>isEncode + Decodeas a bare 32-byte hash (phantom is#[codec(skip)]), so the on-wire/on-disk layout is byte-identical to before — only the static type at the field changes.MbStorageRO/RWtrait method parameters intentionally keepmb_hash: H256. ThreadingHashOf<MB>through every call site in compute/cli/consensus/processor/etc. would cascade through dozens of files for no extra safety gain — the boundary structs already catch the EB-vs-MB confusion that motivated the refactor. Call sites passfield.inner()where needed.Fixes #5507.
Test plan
cargo nextest run -p ethexe-common -p ethexe-db -p ethexe-malachite-core -p ethexe-malachite -p ethexe-compute -p ethexe-consensus— 248/248 pass (incl. multi-validator integration tests).cargo fmt,cargo clippy --workspace --tests— clean.ensure_types_unchangedupdated with the newEXPECTED_TYPE_INFO_HASH(CompactMb shape changed).🤖 Generated with Claude Code