Skip to content

chore: remove triedb (rust-eth-triedb/pathdb) state backend#371

Merged
chee-chyuan merged 2 commits into
develop-hardfork-pasteurfrom
remove_triedb
Jun 24, 2026
Merged

chore: remove triedb (rust-eth-triedb/pathdb) state backend#371
chee-chyuan merged 2 commits into
develop-hardfork-pasteurfrom
remove_triedb

Conversation

@chee-chyuan

Copy link
Copy Markdown
Contributor

Summary

  • Removes all triedb code paths from reth-bsc; MDBX is now the only state backend
  • Pins bnb-chain/reth to 6dcb09c0090e046eea6440fbeb58cce5db0476b2 (head of chore: remove triedb (rust-eth-triedb/pathdb) state backend reth#202, which removes the same backend upstream)
  • Drops the four rust-eth-triedb* git deps from Cargo.toml and the bsc-ef-tests crate

Notable shape changes

  • BscBlockBuilder loses the finish_with_difflayer override; the sparse-trie precomputed-root fast path + state_root_with_updates fallback now live in fn finish. request_difflayer helper is gone.
  • BscNextBlockEnvAttributes / BscBlockExecutionCtx lose parent_difflayers and triedb_prefetcher fields.
  • BscBuildArguments loses parent_difflayers; fetch_triedb_difflayers + fetch_parent_difflayers_for_bid are deleted.
  • BscBuiltPayload::executed_block no longer carries a difflayer (upstream ExecutedBlock.difflayer field removed).
  • Removed the now-unused task_executor field from BscPayloadBuilder, BidSimulator, and MainWorkWorker (it was only used to spawn the triedb prefetcher).
  • --statedb.triedb references stripped from README.md, CLAUDE.md, main.rs CLI doc-comments, and miner/config.rs.

Test plan

  • cargo check --workspace --all-features
  • cargo clippy --workspace --tests --all-features (no warnings)
  • cargo test --all -- --test-threads=1 (286 passed)
  • Smoke-test mainnet sync on the resulting binary
  • Smoke-test miner build path (--mining.enabled + --mining.use-sparse-trie-state-root)
  • Smoke-test MEV bid-simulator path

🤖 Generated with Claude Code

Co-authored-by: joey <10592664+joey0612@users.noreply.github.com>
Co-authored-by: cbh876 <3930922419@qq.com>
Co-authored-by: cbh876 <30834644+constbh@users.noreply.github.com>
@hashdit-bot

hashdit-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

Pull Request Review

This PR removes TrieDB-related functionality from a Rust-based BSC execution client (reth-bsc) and standardizes state handling on MDBX with optional sparse-trie precomputation. It also pins all bnb-chain/reth dependencies to a fixed commit (6dcb09c...) and removes rust-eth-triedb* dependencies and associated code paths across miner, payload builder, and EVM builder layers. Documentation and CLI comments were updated to remove --statedb.triedb references and reflect the new single-backend flow.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

Drops all triedb code paths and the four rust-eth-triedb* git deps so the
downstream reth-bsc crate compiles against the upstream Reth tree where
PR bnb-chain/reth#202 has removed the same backend. After this change
the only state backend is MDBX.

Pinned `bnb-chain/reth` to rev 6dcb09c0090e046eea6440fbeb58cce5db0476b2
(PR 202 head) and aligned the bsc-ef-tests crate to the same rev.

- evm/builder.rs: collapsed `is_triedb_active()` + finish_with_difflayer
  override into `fn finish`, keeping the sparse-trie precomputed-root
  fast path and the MDBX `state_root_with_updates` fallback. Removed
  the `request_difflayer` helper.
- evm/{mod,config}.rs: removed `MinerTrieDbPrefetcher` type alias,
  `parent_difflayers` / `triedb_prefetcher` fields on
  `BscNextBlockEnvAttributes` + `BscBlockExecutionCtx`, and the
  `create_block_builder` workaround that scrubbed them.
- engine.rs: dropped the `!is_triedb_active()` gate on the sparse-trie
  spawner; `BscBuiltPayload::executed_block` no longer carries a
  difflayer (upstream `ExecutedBlock.difflayer` field deleted).
- miner/payload.rs: removed `parent_difflayers` from
  `BscBuildArguments`, the `fetch_triedb_difflayers` helper, the
  prefetcher state-hook closures, the pathdb safety guard, and the
  `executed_block.difflayer` assignments.
- miner/bid_simulator.rs: removed the triedb branch from
  `bid_simulate` and its `parent_difflayers` parameter.
- miner/bsc_miner.rs: deleted `fetch_parent_difflayers_for_bid` and
  its caller.
- Removed the now-unused `task_executor` field from
  `BscPayloadBuilder`, `BidSimulator`, and `MainWorkWorker` (it
  existed only to spawn the triedb prefetcher).
- README.md / CLAUDE.md / main.rs / miner/config.rs: purged
  `--statedb.triedb` references.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hashdit-bot

hashdit-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

Pull Request Review

This PR removes the TrieDB/pathdb backend from the Rust BSC client and consolidates state handling on MDBX, including deleting TrieDB-specific execution paths, difflayer plumbing, and prefetcher wiring across miner, payload builder, and bid simulator flows. It also updates all reth-* dependencies to a pinned upstream commit (6dcb09c...) and removes the rust-eth-triedb* git dependencies from workspace manifests/lockfile. Documentation and CLI comments were cleaned up accordingly to remove --statedb.triedb references and reflect sparse-trie behavior in MDBX-only mode.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@chee-chyuan
chee-chyuan changed the base branch from develop to develop-hardfork-pasteur June 24, 2026 03:17
@chee-chyuan
chee-chyuan marked this pull request as ready for review June 24, 2026 03:42
@chee-chyuan
chee-chyuan requested a review from joey0612 as a code owner June 24, 2026 03:42
@chee-chyuan
chee-chyuan merged commit bc5470e into develop-hardfork-pasteur Jun 24, 2026
8 checks passed
joey0612 added a commit that referenced this pull request Jul 8, 2026
* Merge pull request #375 from bnb-chain/feat/pasteur-fork-definition

feat(hardforks): define Pasteur hardfork

* feat(evm/precompiles): add Pasteur precompile set + dedup utilities (#376)

Introduce a dedicated Pasteur precompile set (build_pasteur_precompiles /
pasteur_traced / pasteur()) wired into the dispatcher, currently identical to
the Mendel set. Add a shared dedup module (DuplicateTracker + is_zero_bytes,
ported from bnb-chain/bsc lightclient/v2) that later PRs use to reject duplicate
validator identities and signer pubkeys.

Enabler only — no behavior change yet.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(evm/precompiles): reject duplicate validators in cometBFT 0x67 at Pasteur (#377)

Add the Pasteur cometBFT light-block precompile (0x67), which rejects validator
sets containing duplicate identities. require_unique_validators is threaded
through the decode path and validate_unique_validator_set checks uniqueness of
address, consensus pubkey, BLS key and relayer address across both the trusted
consensus state and the incoming light-block validator set. Unset (zero/empty)
bridge fields are exempt. Pre-Pasteur behavior is unchanged.

Ports bnb-chain/bsc #3623 (cometBFT light-block path).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(evm/precompiles): suspend legacy v1 Tendermint precompiles + reprice 0x67 at Pasteur (#379)

From Pasteur, the legacy v1 Tendermint header (0x64) and IAVL proof (0x65)
precompiles are deprecated and return an error for any input, and the cometBFT
light-block precompile (0x67) is repriced with per-input-byte gas
(base 3000 + 16/byte) so cost scales with the validator/signature count.
Pre-Pasteur behavior (live 0x64/0x65, flat 3000 for 0x67) is unchanged.

Ports bnb-chain/bsc #3726.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(system-contracts): Pasteur StakeHub + Governor upgrade (#380)

* feat(system-contracts): Pasteur StakeHub + Governor upgrade

Add the Pasteur system-contract upgrade: StakeHub (0x2002) and Governor (0x2004)
are swapped to genesis-contract v1.2.6 bytecode at the Pasteur transition on
mainnet/chapel/rialto. Adds the per-network bytecode, registers `pasteur` in
build.rs (which regenerates embedded_contracts.rs), and wires Pasteur into
hardfork_to_dir_name, hardforks_with_system_contracts, and
get_upgrade_system_contracts.

Ports bnb-chain/bsc #3721 + #3727.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(system-contracts): cover Pasteur upgrade at the transition boundary

Add a test driving get_upgrade_system_contracts across the Pasteur transition:
the upgrade fires only when the parent is pre-Pasteur and the block is at/after
it, swapping exactly StakeHub and Governor; blocks fully before or after the fork
emit no Pasteur upgrade.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: remove triedb (rust-eth-triedb/pathdb) state backend (#371)

* chore: reth dep (#366)

Co-authored-by: joey <10592664+joey0612@users.noreply.github.com>
Co-authored-by: cbh876 <3930922419@qq.com>
Co-authored-by: cbh876 <30834644+constbh@users.noreply.github.com>

* chore: remove triedb (rust-eth-triedb/pathdb) state backend

Drops all triedb code paths and the four rust-eth-triedb* git deps so the
downstream reth-bsc crate compiles against the upstream Reth tree where
PR bnb-chain/reth#202 has removed the same backend. After this change
the only state backend is MDBX.

Pinned `bnb-chain/reth` to rev 6dcb09c0090e046eea6440fbeb58cce5db0476b2
(PR 202 head) and aligned the bsc-ef-tests crate to the same rev.

- evm/builder.rs: collapsed `is_triedb_active()` + finish_with_difflayer
  override into `fn finish`, keeping the sparse-trie precomputed-root
  fast path and the MDBX `state_root_with_updates` fallback. Removed
  the `request_difflayer` helper.
- evm/{mod,config}.rs: removed `MinerTrieDbPrefetcher` type alias,
  `parent_difflayers` / `triedb_prefetcher` fields on
  `BscNextBlockEnvAttributes` + `BscBlockExecutionCtx`, and the
  `create_block_builder` workaround that scrubbed them.
- engine.rs: dropped the `!is_triedb_active()` gate on the sparse-trie
  spawner; `BscBuiltPayload::executed_block` no longer carries a
  difflayer (upstream `ExecutedBlock.difflayer` field deleted).
- miner/payload.rs: removed `parent_difflayers` from
  `BscBuildArguments`, the `fetch_triedb_difflayers` helper, the
  prefetcher state-hook closures, the pathdb safety guard, and the
  `executed_block.difflayer` assignments.
- miner/bid_simulator.rs: removed the triedb branch from
  `bid_simulate` and its `parent_difflayers` parameter.
- miner/bsc_miner.rs: deleted `fetch_parent_difflayers_for_bid` and
  its caller.
- Removed the now-unused `task_executor` field from
  `BscPayloadBuilder`, `BidSimulator`, and `MainWorkWorker` (it
  existed only to spawn the triedb prefetcher).
- README.md / CLAUDE.md / main.rs / miner/config.rs: purged
  `--statedb.triedb` references.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: const <122766871+constwz@users.noreply.github.com>
Co-authored-by: joey <10592664+joey0612@users.noreply.github.com>
Co-authored-by: cbh876 <3930922419@qq.com>
Co-authored-by: cbh876 <30834644+constbh@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: bump reth dep to latest remove_triedb (PR #202) commit 0dea17d2

Picks up reth#204 "persist target clamp finalized" on top of the
remove_triedb branch (was 6dcb09c).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* perf(miner): adaptive root-reserve + per-attempt sparse-trie sink (ported to develop-hardfork-pasteur) (#418)

* chore: update pasteur time in qa env

* test: fix Pasteur dormancy test after qanet activation scheduled

qanet now schedules Pasteur at a real timestamp, so the test must assert
its concrete activation instead of dormancy. Mainnet/testnet remain dormant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(rpc/eth_config): return null blobSchedule to match go-bsc (#422)

go-bsc's eth_config (EIP-7910) returns `blobSchedule: null` for forks whose
ChainConfig.BlobConfig(LatestFork(t)) yields nil (e.g. Mendel, Pasteur), while
reth returned a populated object — diverging from the reference client.

reth's eth_config uses alloy's EthConfig, whose EthForkConfig.blob_schedule is a
required (non-optional) BlobParams that always serializes, so it cannot emit
null. Introduce a BSC-specific eth_config RPC (BscEthConfigApi) that returns a
raw JSON value, then null `blobSchedule` on current/next/last per go-bsc's
per-fork logic: keep it only for Cancun/Fermi/Maxwell/Lorentz/Osaka; null for
all others (incl. Mendel/Pasteur). Each snapshot's fork is resolved from its
activationTime via revm_spec_by_timestamp_and_block_number.

RPC introspection only — no consensus impact (both clients enforce the same
blob params in block validation).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: qanet hf time

* test: expect Pasteur dormant on qanet after activation reverted

The qanet Pasteur activation was reverted to unscheduled (u64::MAX) in
cf8d5d1, but the dormancy test still expected the old concrete
timestamp. Fold qanet into the dormant-schedule assertion loop.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: const <122766871+constwz@users.noreply.github.com>
Co-authored-by: joey <10592664+joey0612@users.noreply.github.com>
Co-authored-by: cbh876 <3930922419@qq.com>
Co-authored-by: cbh876 <30834644+constbh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants