Problem
H256 is the lingua franca for many distinct hash kinds across ethexe — Ethereum block hashes, malachite envelope hashes, payload digests, etc. Mixing them at signature level is dangerous; the most visible footgun today is the MB hash vs the EB (Ethereum block) hash, which both appear in CompactMb, in MalachiteEvent, and in the MbStorageRO/RW trait surface as bare H256. Compiler can't help when a caller swaps one for the other.
Goal
- Add
ethexe-common as a dep of ethexe-malachite-core (currently leaf-isolated).
- Move
ethexe_malachite_core::Block to ethexe_common::malachite::MB (carrying parent_hash: HashOf<MB>, height: u64, payload: BlockPayload, reserved: [u8; 64]). BlockPayload moves with it.
- Restructure
CompactMb: same fields as MB but with payload_hash: H256 in place of BlockPayload. Move it to ethexe_common::malachite alongside MB.
- Replace
H256 with HashOf<MB> everywhere it represents a malachite block hash: trait sigs in MbStorageRO/RW, DBGlobals::latest_finalized_mb_hash, Externalities callbacks, CommitCertificate::block_hash, MalachiteEvent::*::mb_hash, etc.
- Introduce
pub type EB = SimpleBlockData; and a SimpleBlockData::typed_hash() -> HashOf<EB> that lifts the existing Ethereum block hash into the typed wrapper without recomputing.
HashOf<T> encodes/decodes as 32 bytes (phantom is #[codec(skip)]), so the wire format stays byte-identical to bare H256.
Non-goals
- No data migrations — DB can change shape freely on this branch.
Acceptance
ethexe-common::malachite exports MB, BlockPayload, CompactMb, EB.
MbStorageRO/RW keys take HashOf<MB> not H256.
DBGlobals::latest_finalized_mb_hash, CompactMb::parent, Externalities callback hash args all typed.
- All ethexe-* tests pass.
Problem
H256is the lingua franca for many distinct hash kinds across ethexe — Ethereum block hashes, malachite envelope hashes, payload digests, etc. Mixing them at signature level is dangerous; the most visible footgun today is the MB hash vs the EB (Ethereum block) hash, which both appear inCompactMb, inMalachiteEvent, and in theMbStorageRO/RWtrait surface as bareH256. Compiler can't help when a caller swaps one for the other.Goal
ethexe-commonas a dep ofethexe-malachite-core(currently leaf-isolated).ethexe_malachite_core::Blocktoethexe_common::malachite::MB(carryingparent_hash: HashOf<MB>,height: u64,payload: BlockPayload,reserved: [u8; 64]).BlockPayloadmoves with it.CompactMb: same fields asMBbut withpayload_hash: H256in place ofBlockPayload. Move it toethexe_common::malachitealongsideMB.H256withHashOf<MB>everywhere it represents a malachite block hash: trait sigs inMbStorageRO/RW,DBGlobals::latest_finalized_mb_hash,Externalitiescallbacks,CommitCertificate::block_hash,MalachiteEvent::*::mb_hash, etc.pub type EB = SimpleBlockData;and aSimpleBlockData::typed_hash() -> HashOf<EB>that lifts the existing Ethereum block hash into the typed wrapper without recomputing.HashOf<T>encodes/decodes as 32 bytes (phantom is#[codec(skip)]), so the wire format stays byte-identical to bareH256.Non-goals
Acceptance
ethexe-common::malachiteexportsMB,BlockPayload,CompactMb,EB.MbStorageRO/RWkeys takeHashOf<MB>notH256.DBGlobals::latest_finalized_mb_hash,CompactMb::parent,Externalitiescallback hash args all typed.