diff --git a/CHANGELOG.md b/CHANGELOG.md index c65817870..da530ccf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## v1.0.7 + +This is a hotfix release for the BSC/opBNB mainnet and testnet. + +### Features + +- [#167](https://github.com/bnb-chain/reth/pull/167): feat: add missing leaves cache + +### Bug Fixes + +- [#183](https://github.com/bnb-chain/reth/pull/183): fix: bsc panic in fullnode mode +- [#184](https://github.com/bnb-chain/reth/pull/184): fix: the gas price checking issue of opBNB +- [#200](https://github.com/bnb-chain/reth/pull/200): fix: branch node children decoding + ## v1.0.6 This release merges with upstream version v1.1.0, making the new engine as the default. It includes new features and diff --git a/Cargo.lock b/Cargo.lock index b0799003c..87a2d5fb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1654,7 +1654,7 @@ dependencies = [ [[package]] name = "bsc-reth" -version = "1.0.6" +version = "1.0.7" dependencies = [ "clap", "reth-bsc-chainspec", @@ -2964,7 +2964,7 @@ dependencies = [ [[package]] name = "ef-tests" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -5899,7 +5899,7 @@ dependencies = [ [[package]] name = "op-reth" -version = "1.0.6" +version = "1.0.7" dependencies = [ "clap", "reth-cli-util", @@ -7042,7 +7042,7 @@ dependencies = [ [[package]] name = "reth" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7115,7 +7115,7 @@ dependencies = [ [[package]] name = "reth-auto-seal-consensus" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -7145,7 +7145,7 @@ dependencies = [ [[package]] name = "reth-basic-payload-builder" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -7168,7 +7168,7 @@ dependencies = [ [[package]] name = "reth-beacon-consensus" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-primitives", @@ -7219,7 +7219,7 @@ dependencies = [ [[package]] name = "reth-bench" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -7254,7 +7254,7 @@ dependencies = [ [[package]] name = "reth-blockchain-tree" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7262,6 +7262,7 @@ dependencies = [ "alloy-primitives", "aquamarine", "assert_matches", + "dashmap 6.1.0", "linked_hash_set", "metrics", "parking_lot 0.12.3", @@ -7293,7 +7294,7 @@ dependencies = [ [[package]] name = "reth-blockchain-tree-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "reth-consensus", @@ -7305,7 +7306,7 @@ dependencies = [ [[package]] name = "reth-bsc-chainspec" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7323,7 +7324,7 @@ dependencies = [ [[package]] name = "reth-bsc-cli" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -7366,7 +7367,7 @@ dependencies = [ [[package]] name = "reth-bsc-consensus" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -7410,7 +7411,7 @@ dependencies = [ [[package]] name = "reth-bsc-engine" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -7458,7 +7459,7 @@ dependencies = [ [[package]] name = "reth-bsc-evm" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-primitives", @@ -7487,7 +7488,7 @@ dependencies = [ [[package]] name = "reth-bsc-forks" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-primitives", @@ -7498,7 +7499,7 @@ dependencies = [ [[package]] name = "reth-bsc-node" -version = "1.0.6" +version = "1.0.7" dependencies = [ "eyre", "futures", @@ -7533,7 +7534,7 @@ dependencies = [ [[package]] name = "reth-bsc-payload-builder" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -7559,7 +7560,7 @@ dependencies = [ [[package]] name = "reth-bsc-primitives" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-primitives", @@ -7577,7 +7578,7 @@ dependencies = [ [[package]] name = "reth-chain-state" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7610,7 +7611,7 @@ dependencies = [ [[package]] name = "reth-chainspec" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-eips", @@ -7632,7 +7633,7 @@ dependencies = [ [[package]] name = "reth-cli" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap", @@ -7644,7 +7645,7 @@ dependencies = [ [[package]] name = "reth-cli-commands" -version = "1.0.6" +version = "1.0.7" dependencies = [ "ahash", "alloy-eips", @@ -7705,7 +7706,7 @@ dependencies = [ [[package]] name = "reth-cli-runner" -version = "1.0.6" +version = "1.0.7" dependencies = [ "reth-tasks", "tokio", @@ -7714,7 +7715,7 @@ dependencies = [ [[package]] name = "reth-cli-util" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -7731,7 +7732,7 @@ dependencies = [ [[package]] name = "reth-codecs" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7754,7 +7755,7 @@ dependencies = [ [[package]] name = "reth-codecs-derive" -version = "1.0.6" +version = "1.0.7" dependencies = [ "convert_case", "proc-macro2", @@ -7765,7 +7766,7 @@ dependencies = [ [[package]] name = "reth-config" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "eyre", @@ -7782,7 +7783,7 @@ dependencies = [ [[package]] name = "reth-consensus" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "auto_impl", @@ -7792,7 +7793,7 @@ dependencies = [ [[package]] name = "reth-consensus-common" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -7807,7 +7808,7 @@ dependencies = [ [[package]] name = "reth-consensus-debug-client" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7830,7 +7831,7 @@ dependencies = [ [[package]] name = "reth-db" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "arbitrary", @@ -7871,7 +7872,7 @@ dependencies = [ [[package]] name = "reth-db-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-primitives", @@ -7899,7 +7900,7 @@ dependencies = [ [[package]] name = "reth-db-common" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-primitives", @@ -7927,7 +7928,7 @@ dependencies = [ [[package]] name = "reth-db-models" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "arbitrary", @@ -7943,7 +7944,7 @@ dependencies = [ [[package]] name = "reth-discv4" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -7969,7 +7970,7 @@ dependencies = [ [[package]] name = "reth-discv5" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -7993,7 +7994,7 @@ dependencies = [ [[package]] name = "reth-dns-discovery" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-primitives", @@ -8021,7 +8022,7 @@ dependencies = [ [[package]] name = "reth-downloaders" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8058,7 +8059,7 @@ dependencies = [ [[package]] name = "reth-e2e-test-utils" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8096,7 +8097,7 @@ dependencies = [ [[package]] name = "reth-ecies" -version = "1.0.6" +version = "1.0.7" dependencies = [ "aes", "alloy-primitives", @@ -8126,7 +8127,7 @@ dependencies = [ [[package]] name = "reth-engine-local" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -8156,7 +8157,7 @@ dependencies = [ [[package]] name = "reth-engine-primitives" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "reth-execution-types", @@ -8168,7 +8169,7 @@ dependencies = [ [[package]] name = "reth-engine-service" -version = "1.0.6" +version = "1.0.7" dependencies = [ "futures", "pin-project", @@ -8196,13 +8197,14 @@ dependencies = [ [[package]] name = "reth-engine-tree" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-rpc-types-engine", "assert_matches", + "dashmap 6.1.0", "futures", "metrics", "rand 0.8.5", @@ -8244,7 +8246,7 @@ dependencies = [ [[package]] name = "reth-engine-util" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -8274,7 +8276,7 @@ dependencies = [ [[package]] name = "reth-errors" -version = "1.0.6" +version = "1.0.7" dependencies = [ "reth-blockchain-tree-api", "reth-consensus", @@ -8286,7 +8288,7 @@ dependencies = [ [[package]] name = "reth-eth-wire" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8321,7 +8323,7 @@ dependencies = [ [[package]] name = "reth-eth-wire-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-consensus", @@ -8344,7 +8346,7 @@ dependencies = [ [[package]] name = "reth-ethereum-cli" -version = "1.0.6" +version = "1.0.7" dependencies = [ "clap", "eyre", @@ -8355,7 +8357,7 @@ dependencies = [ [[package]] name = "reth-ethereum-consensus" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "reth-chainspec", @@ -8367,7 +8369,7 @@ dependencies = [ [[package]] name = "reth-ethereum-engine-primitives" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8386,7 +8388,7 @@ dependencies = [ [[package]] name = "reth-ethereum-forks" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-primitives", @@ -8405,7 +8407,7 @@ dependencies = [ [[package]] name = "reth-ethereum-payload-builder" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "reth-basic-payload-builder", @@ -8429,7 +8431,7 @@ dependencies = [ [[package]] name = "reth-etl" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "rayon", @@ -8439,7 +8441,7 @@ dependencies = [ [[package]] name = "reth-evm" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8462,7 +8464,7 @@ dependencies = [ [[package]] name = "reth-evm-ethereum" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8487,7 +8489,7 @@ dependencies = [ [[package]] name = "reth-execution-errors" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8502,7 +8504,7 @@ dependencies = [ [[package]] name = "reth-execution-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8519,7 +8521,7 @@ dependencies = [ [[package]] name = "reth-exex" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8564,7 +8566,7 @@ dependencies = [ [[package]] name = "reth-exex-test-utils" -version = "1.0.6" +version = "1.0.7" dependencies = [ "eyre", "futures-util", @@ -8596,7 +8598,7 @@ dependencies = [ [[package]] name = "reth-exex-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8612,7 +8614,7 @@ dependencies = [ [[package]] name = "reth-fs-util" -version = "1.0.6" +version = "1.0.7" dependencies = [ "serde", "serde_json", @@ -8621,7 +8623,7 @@ dependencies = [ [[package]] name = "reth-invalid-block-hooks" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -8645,7 +8647,7 @@ dependencies = [ [[package]] name = "reth-ipc" -version = "1.0.6" +version = "1.0.7" dependencies = [ "async-trait", "bytes 1.7.2", @@ -8667,7 +8669,7 @@ dependencies = [ [[package]] name = "reth-libmdbx" -version = "1.0.6" +version = "1.0.7" dependencies = [ "bitflags 2.6.0", "byteorder", @@ -8688,7 +8690,7 @@ dependencies = [ [[package]] name = "reth-mdbx-sys" -version = "1.0.6" +version = "1.0.7" dependencies = [ "bindgen 0.70.1", "cc", @@ -8696,7 +8698,7 @@ dependencies = [ [[package]] name = "reth-metrics" -version = "1.0.6" +version = "1.0.7" dependencies = [ "futures", "metrics", @@ -8707,14 +8709,14 @@ dependencies = [ [[package]] name = "reth-net-banlist" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", ] [[package]] name = "reth-net-nat" -version = "1.0.6" +version = "1.0.7" dependencies = [ "futures-util", "if-addrs", @@ -8728,7 +8730,7 @@ dependencies = [ [[package]] name = "reth-network" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8788,7 +8790,7 @@ dependencies = [ [[package]] name = "reth-network-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types-admin 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8810,7 +8812,7 @@ dependencies = [ [[package]] name = "reth-network-p2p" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8830,7 +8832,7 @@ dependencies = [ [[package]] name = "reth-network-peers" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -8846,7 +8848,7 @@ dependencies = [ [[package]] name = "reth-network-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "humantime-serde", "reth-ethereum-forks", @@ -8859,7 +8861,7 @@ dependencies = [ [[package]] name = "reth-nippy-jar" -version = "1.0.6" +version = "1.0.7" dependencies = [ "anyhow", "bincode", @@ -8877,7 +8879,7 @@ dependencies = [ [[package]] name = "reth-node-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "reth-engine-primitives", "reth-evm", @@ -8894,7 +8896,7 @@ dependencies = [ [[package]] name = "reth-node-builder" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -8960,7 +8962,7 @@ dependencies = [ [[package]] name = "reth-node-core" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -9010,7 +9012,7 @@ dependencies = [ [[package]] name = "reth-node-ethereum" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-primitives", @@ -9047,7 +9049,7 @@ dependencies = [ [[package]] name = "reth-node-events" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -9069,7 +9071,7 @@ dependencies = [ [[package]] name = "reth-node-metrics" -version = "1.0.6" +version = "1.0.7" dependencies = [ "eyre", "http 1.1.0", @@ -9095,7 +9097,7 @@ dependencies = [ [[package]] name = "reth-node-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "reth-chainspec", "reth-db-api", @@ -9104,7 +9106,7 @@ dependencies = [ [[package]] name = "reth-optimism-chainspec" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -9122,7 +9124,7 @@ dependencies = [ [[package]] name = "reth-optimism-cli" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -9166,7 +9168,7 @@ dependencies = [ [[package]] name = "reth-optimism-consensus" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "reth-chainspec", @@ -9181,7 +9183,7 @@ dependencies = [ [[package]] name = "reth-optimism-evm" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9208,7 +9210,7 @@ dependencies = [ [[package]] name = "reth-optimism-forks" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-chains", "alloy-primitives", @@ -9219,7 +9221,7 @@ dependencies = [ [[package]] name = "reth-optimism-node" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -9273,7 +9275,7 @@ dependencies = [ [[package]] name = "reth-optimism-payload-builder" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -9306,7 +9308,7 @@ dependencies = [ [[package]] name = "reth-optimism-primitives" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "reth-primitives", @@ -9315,7 +9317,7 @@ dependencies = [ [[package]] name = "reth-optimism-rpc" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -9354,7 +9356,7 @@ dependencies = [ [[package]] name = "reth-optimism-storage" -version = "1.0.6" +version = "1.0.7" dependencies = [ "reth-codecs", "reth-db-api", @@ -9365,7 +9367,7 @@ dependencies = [ [[package]] name = "reth-payload-builder" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -9386,7 +9388,7 @@ dependencies = [ [[package]] name = "reth-payload-primitives" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -9407,7 +9409,7 @@ dependencies = [ [[package]] name = "reth-payload-validator" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-rpc-types", "reth-chainspec", @@ -9417,7 +9419,7 @@ dependencies = [ [[package]] name = "reth-primitives" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9463,7 +9465,7 @@ dependencies = [ [[package]] name = "reth-primitives-traits" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9491,7 +9493,7 @@ dependencies = [ [[package]] name = "reth-provider" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9541,7 +9543,7 @@ dependencies = [ [[package]] name = "reth-prune" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "assert_matches", @@ -9570,7 +9572,7 @@ dependencies = [ [[package]] name = "reth-prune-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "arbitrary", @@ -9590,7 +9592,7 @@ dependencies = [ [[package]] name = "reth-revm" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "reth-chainspec", @@ -9607,7 +9609,7 @@ dependencies = [ [[package]] name = "reth-rpc" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -9677,7 +9679,7 @@ dependencies = [ [[package]] name = "reth-rpc-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -9703,7 +9705,7 @@ dependencies = [ [[package]] name = "reth-rpc-api-testing-util" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -9722,7 +9724,7 @@ dependencies = [ [[package]] name = "reth-rpc-builder" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-network", "alloy-primitives", @@ -9775,7 +9777,7 @@ dependencies = [ [[package]] name = "reth-rpc-engine-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -9811,7 +9813,7 @@ dependencies = [ [[package]] name = "reth-rpc-eth-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-dyn-abi", "alloy-eips", @@ -9852,7 +9854,7 @@ dependencies = [ [[package]] name = "reth-rpc-eth-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9896,7 +9898,7 @@ dependencies = [ [[package]] name = "reth-rpc-layer" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-rpc-types-engine", "http 1.1.0", @@ -9911,7 +9913,7 @@ dependencies = [ [[package]] name = "reth-rpc-server-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -9926,7 +9928,7 @@ dependencies = [ [[package]] name = "reth-rpc-types-compat" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -9942,7 +9944,7 @@ dependencies = [ [[package]] name = "reth-stages" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -9993,7 +9995,7 @@ dependencies = [ [[package]] name = "reth-stages-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "aquamarine", @@ -10021,7 +10023,7 @@ dependencies = [ [[package]] name = "reth-stages-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "arbitrary", @@ -10038,7 +10040,7 @@ dependencies = [ [[package]] name = "reth-static-file" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "assert_matches", @@ -10063,7 +10065,7 @@ dependencies = [ [[package]] name = "reth-static-file-types" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "clap", @@ -10074,7 +10076,7 @@ dependencies = [ [[package]] name = "reth-storage-api" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -10092,7 +10094,7 @@ dependencies = [ [[package]] name = "reth-storage-errors" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -10104,7 +10106,7 @@ dependencies = [ [[package]] name = "reth-tasks" -version = "1.0.6" +version = "1.0.7" dependencies = [ "auto_impl", "dyn-clone", @@ -10121,7 +10123,7 @@ dependencies = [ [[package]] name = "reth-testing-utils" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10134,7 +10136,7 @@ dependencies = [ [[package]] name = "reth-tokio-util" -version = "1.0.6" +version = "1.0.7" dependencies = [ "tokio", "tokio-stream", @@ -10143,7 +10145,7 @@ dependencies = [ [[package]] name = "reth-tracing" -version = "1.0.6" +version = "1.0.7" dependencies = [ "clap", "eyre", @@ -10157,7 +10159,7 @@ dependencies = [ [[package]] name = "reth-transaction-pool" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10202,7 +10204,7 @@ dependencies = [ [[package]] name = "reth-trie" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -10233,7 +10235,7 @@ dependencies = [ [[package]] name = "reth-trie-common" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-consensus", "alloy-genesis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10257,7 +10259,7 @@ dependencies = [ [[package]] name = "reth-trie-db" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -10292,11 +10294,12 @@ dependencies = [ [[package]] name = "reth-trie-parallel" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", "criterion", + "dashmap 6.1.0", "derive_more 1.0.0", "itertools 0.13.0", "metrics", @@ -10319,11 +10322,12 @@ dependencies = [ [[package]] name = "reth-trie-prefetch" -version = "1.0.6" +version = "1.0.7" dependencies = [ "alloy-primitives", "alloy-rlp", "criterion", + "dashmap 6.1.0", "derive_more 1.0.0", "metrics", "proptest", @@ -10346,7 +10350,7 @@ dependencies = [ [[package]] name = "revm" version = "14.0.3" -source = "git+https://github.com/bnb-chain/revm?rev=v1.0.4#0978bcb4189c547e7b71b2f11389ff2214fbe319" +source = "git+https://github.com/bnb-chain/revm?rev=v1.0.5#a9752c97d2c742d25405a4a9a698f30f5007da6e" dependencies = [ "auto_impl", "cfg-if", @@ -10379,7 +10383,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "10.0.3" -source = "git+https://github.com/bnb-chain/revm?rev=v1.0.4#0978bcb4189c547e7b71b2f11389ff2214fbe319" +source = "git+https://github.com/bnb-chain/revm?rev=v1.0.5#a9752c97d2c742d25405a4a9a698f30f5007da6e" dependencies = [ "revm-primitives", "serde", @@ -10388,7 +10392,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "11.0.3" -source = "git+https://github.com/bnb-chain/revm?rev=v1.0.4#0978bcb4189c547e7b71b2f11389ff2214fbe319" +source = "git+https://github.com/bnb-chain/revm?rev=v1.0.5#a9752c97d2c742d25405a4a9a698f30f5007da6e" dependencies = [ "alloy-rlp", "aurora-engine-modexp", @@ -10416,7 +10420,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "10.0.0" -source = "git+https://github.com/bnb-chain/revm?rev=v1.0.4#0978bcb4189c547e7b71b2f11389ff2214fbe319" +source = "git+https://github.com/bnb-chain/revm?rev=v1.0.5#a9752c97d2c742d25405a4a9a698f30f5007da6e" dependencies = [ "alloy-eip2930", "alloy-eip7702", diff --git a/Cargo.toml b/Cargo.toml index c39bbbb66..36e689d7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "1.0.6" +version = "1.0.7" edition = "2021" rust-version = "1.81" license = "MIT OR Apache-2.0" @@ -615,9 +615,9 @@ tikv-jemallocator = "0.6" tracy-client = "0.17.3" [patch.crates-io] -revm = { git = "https://github.com/bnb-chain/revm", rev = "v1.0.4" } -revm-interpreter = { git = "https://github.com/bnb-chain/revm", rev = "v1.0.4" } -revm-primitives = { git = "https://github.com/bnb-chain/revm", rev = "v1.0.4" } +revm = { git = "https://github.com/bnb-chain/revm", rev = "v1.0.5" } +revm-interpreter = { git = "https://github.com/bnb-chain/revm", rev = "v1.0.5" } +revm-primitives = { git = "https://github.com/bnb-chain/revm", rev = "v1.0.5" } alloy-rpc-types-eth = { git = "https://github.com/bnb-chain/alloy", rev = "718060680134e6bb40d97d3c6fb56fd1950ced36" } alloy-consensus = { git = "https://github.com/bnb-chain/alloy", rev = "718060680134e6bb40d97d3c6fb56fd1950ced36" } alloy-eips = { git = "https://github.com/bnb-chain/alloy", rev = "718060680134e6bb40d97d3c6fb56fd1950ced36" } diff --git a/README.md b/README.md index edf9597d4..8056ff24f 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,9 @@ [discord-url]: https://discord.gg/z2VpC455eU -BNB Chain Reth is a blockchain client based on [Reth](https://github.com/paradigmxyz/reth/), designed to provide seamless -support for [BNB Smart Chain(BSC)](https://github.com/bnb-chain/bsc) and [opBNB](https://github.com/bnb-chain/op-geth). +BNB Chain Reth is a blockchain client based on [Reth](https://github.com/paradigmxyz/reth/), designed to provide +seamless support for [BNB Smart Chain(BSC)](https://github.com/bnb-chain/bsc) +and [opBNB](https://github.com/bnb-chain/op-geth). ## Build from Source @@ -76,7 +77,9 @@ export network=bsc --chain=${network} \ --http \ --http.api="eth, net, txpool, web3, rpc" \ - --log.file.directory ./datadir/logs + --log.file.directory ./datadir/logs \ + --enable-prefetch \ + --optimize.enable-execution-cache ``` You can run `bsc-reth --help` for command explanations. @@ -102,7 +105,9 @@ docker run -d -p 8545:8545 -p 30303:30303 -p 30303:30303/udp -v ${data_dir}:/dat --chain=${network} \ --http \ --http.api="eth, net, txpool, web3, rpc" \ - --log.file.directory /data/logs + --log.file.directory /data/logs \ + --enable-prefetch \ + --optimize.enable-execution-cache ``` ### Snapshots @@ -200,7 +205,9 @@ export L2_RPC=https://opbnb-mainnet-rpc.bnbchain.org --authrpc.jwtsecret=./jwt.txt \ --http \ --http.api="eth, net, txpool, web3, rpc" \ - --log.file.directory ./datadir/logs + --log.file.directory ./datadir/logs \ + --enable-prefetch \ + --optimize.enable-execution-cache ``` You can run `op-reth --help` for command explanations. More details on running opbnb nodes can be @@ -236,7 +243,9 @@ docker run -d -p 8545:8545 -p 30303:30303 -p 30303:30303/udp -v ${data_dir}:/dat --authrpc.jwtsecret=/jwt/jwt.txt \ --http \ --http.api="eth, net, txpool, web3, rpc" \ - --log.file.directory /data/logs + --log.file.directory /data/logs \ + --enable-prefetch \ + --optimize.enable-execution-cache ``` ## Contribution diff --git a/crates/blockchain-tree/Cargo.toml b/crates/blockchain-tree/Cargo.toml index 45ee65a8f..bfe696936 100644 --- a/crates/blockchain-tree/Cargo.toml +++ b/crates/blockchain-tree/Cargo.toml @@ -48,6 +48,7 @@ metrics.workspace = true # misc aquamarine.workspace = true linked_hash_set.workspace = true +dashmap = "6.1.0" [dev-dependencies] reth-chainspec.workspace = true diff --git a/crates/blockchain-tree/src/chain.rs b/crates/blockchain-tree/src/chain.rs index eee273d85..149cdaaa4 100644 --- a/crates/blockchain-tree/src/chain.rs +++ b/crates/blockchain-tree/src/chain.rs @@ -7,6 +7,7 @@ use super::externals::TreeExternals; use crate::BundleStateDataRef; use alloy_eips::ForkBlock; use alloy_primitives::{map::HashMap, BlockHash, BlockNumber, B256, U256}; +use dashmap::DashMap; use reth_blockchain_tree_api::{ error::{BlockchainTreeError, InsertBlockErrorKind}, BlockAttachment, BlockValidationKind, @@ -23,13 +24,17 @@ use reth_provider::{ FullExecutionDataProvider, ProviderError, StateRootProvider, TryIntoHistoricalStateProvider, }; use reth_revm::database::StateProviderDatabase; -use reth_trie::{updates::TrieUpdates, HashedPostState, TrieInput}; +use reth_trie::{ + updates::{StorageTrieUpdates, TrieUpdates}, + HashedPostState, TrieInput, +}; use reth_trie_parallel::parallel_root::ParallelStateRoot; use reth_trie_prefetch::TriePrefetch; use std::{ clone::Clone, collections::BTreeMap, ops::{Deref, DerefMut}, + sync::Arc, time::Instant, }; @@ -213,8 +218,11 @@ impl AppendableChain { let provider = BundleStateProvider::new(state_provider, bundle_state_data_provider); - let (prefetch_tx, interrupt_tx) = - if enable_prefetch { Self::setup_prefetch(externals) } else { (None, None) }; + let (prefetch_tx, interrupt_tx, missing_leaves_cache) = if enable_prefetch { + Self::setup_prefetch(externals) + } else { + (None, None, Default::default()) + }; let db = StateProviderDatabase::new(&provider); let executor = externals.executor_factory.executor(db, prefetch_tx); @@ -243,7 +251,7 @@ impl AppendableChain { consistent_view, TrieInput::from_state(execution_outcome.hash_state_slow()), ) - .incremental_root_with_updates() + .incremental_root_with_updates_and_cache(missing_leaves_cache) .map(|(root, updates)| (root, Some(updates))) .map_err(ProviderError::from)? } else { @@ -343,11 +351,13 @@ impl AppendableChain { Ok(()) } + #[allow(clippy::type_complexity)] fn setup_prefetch( externals: &TreeExternals, ) -> ( Option>, Option>, + Arc>, ) where N: ProviderNodeTypes, @@ -358,13 +368,17 @@ impl AppendableChain { let mut trie_prefetch = TriePrefetch::new(); let provider_factory = externals.provider_factory.clone(); + let missing_leaves_cache = Arc::new(DashMap::new()); + let missing_leaves_cache_clone = Arc::clone(&missing_leaves_cache); tokio::spawn({ async move { - trie_prefetch.run(provider_factory, prefetch_rx, interrupt_rx).await; + trie_prefetch + .run(provider_factory, prefetch_rx, interrupt_rx, missing_leaves_cache_clone) + .await; } }); - (Some(prefetch_tx), Some(interrupt_tx)) + (Some(prefetch_tx), Some(interrupt_tx), missing_leaves_cache) } } diff --git a/crates/bsc/engine/src/task.rs b/crates/bsc/engine/src/task.rs index da4a0e0a6..babb46bcf 100644 --- a/crates/bsc/engine/src/task.rs +++ b/crates/bsc/engine/src/task.rs @@ -421,21 +421,20 @@ impl< } for header in disconnected_headers { storage.insert_new_header(header.clone()); - let result = - fork_choice_tx.send(ForkChoiceMessage::NewHeader(NewHeaderEvent { - header: header.clone(), - // if the pipeline sync is true, the fork choice will not use the safe - // and finalized hash. - // this can make Block Sync Engine to use pipeline sync mode. - pipeline_sync, - local_header: latest_unsafe_header.clone(), - })); - if result.is_err() { - error!(target: "consensus::parlia", "Failed to send new block event to - fork choice"); - } } drop(storage); + let result = fork_choice_tx.send(ForkChoiceMessage::NewHeader(NewHeaderEvent { + header: sealed_header.clone(), + // if the pipeline sync is true, the fork choice will not use the safe + // and finalized hash. + // this can make Block Sync Engine to use pipeline sync mode. + pipeline_sync, + local_header: latest_unsafe_header.clone(), + })); + if result.is_err() { + error!(target: "consensus::parlia", "Failed to send new block event to + fork choice"); + } let result = chain_tracker_tx.send(ForkChoiceMessage::NewHeader(NewHeaderEvent { header: sealed_header.clone(), diff --git a/crates/config/src/config.rs b/crates/config/src/config.rs index 3f87e1ef1..92b091f31 100644 --- a/crates/config/src/config.rs +++ b/crates/config/src/config.rs @@ -309,7 +309,7 @@ pub struct MerkleConfig { impl Default for MerkleConfig { fn default() -> Self { - Self { clean_threshold: 5_000 } + Self { clean_threshold: 50_000 } } } diff --git a/crates/engine/tree/Cargo.toml b/crates/engine/tree/Cargo.toml index 0202f0ee2..d5215d1d8 100644 --- a/crates/engine/tree/Cargo.toml +++ b/crates/engine/tree/Cargo.toml @@ -51,6 +51,7 @@ reth-metrics = { workspace = true, features = ["common"] } # misc tracing.workspace = true +dashmap = "6.1.0" # optional deps for test-utils reth-prune-types = { workspace = true, optional = true } diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 0399e8bc2..0d090ace9 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -13,6 +13,7 @@ use alloy_rpc_types_engine::{ CancunPayloadFields, ExecutionPayload, ForkchoiceState, PayloadStatus, PayloadStatusEnum, PayloadValidationError, }; +use dashmap::DashMap; use reth_beacon_consensus::{ BeaconConsensusEngineEvent, BeaconEngineMessage, ForkchoiceStateTracker, InvalidHeaderCache, OnForkChoiceUpdated, MIN_BLOCKS_FOR_PIPELINE_RUN, @@ -44,7 +45,10 @@ use reth_provider::{ }; use reth_revm::database::StateProviderDatabase; use reth_stages_api::ControlFlow; -use reth_trie::{updates::TrieUpdates, HashedPostState, TrieInput}; +use reth_trie::{ + updates::{StorageTrieUpdates, TrieUpdates}, + HashedPostState, TrieInput, +}; use reth_trie_parallel::parallel_root::{ParallelStateRoot, ParallelStateRootError}; use reth_trie_prefetch::TriePrefetch; use std::{ @@ -2213,11 +2217,11 @@ where } trace!(target: "engine::tree", block=?block.num_hash(), "Executing block"); - let (prefetch_tx, interrupt_tx) = + let (prefetch_tx, interrupt_tx, missing_leaves_cache) = if self.enable_prefetch && !self.skip_state_root_validation { self.setup_prefetch() } else { - (None, None) + (None, None, Default::default()) }; let executor = self @@ -2274,9 +2278,11 @@ where // different view of the database. let persistence_in_progress = self.persistence_state.in_progress(); if !persistence_in_progress { - state_root_result = match self - .compute_state_root_parallel(block.parent_hash, &hashed_state) - { + state_root_result = match self.compute_state_root_parallel( + block.parent_hash, + &hashed_state, + missing_leaves_cache, + ) { Ok((state_root, trie_output)) => Some((state_root, trie_output)), Err(ParallelStateRootError::Provider(ProviderError::ConsistentView(error))) => { debug!(target: "engine", %error, "Parallel state root computation failed consistency check, falling back"); @@ -2361,6 +2367,7 @@ where &self, parent_hash: B256, hashed_state: &HashedPostState, + missing_leaves_cache: Arc>, ) -> Result<(B256, TrieUpdates), ParallelStateRootError> { let consistent_view = ConsistentDbView::new_with_latest_tip(self.provider.clone())?; let mut input = TrieInput::default(); @@ -2383,7 +2390,8 @@ where // Extend with block we are validating root for. input.append_ref(hashed_state); - ParallelStateRoot::new(consistent_view, input).incremental_root_with_updates() + ParallelStateRoot::new(consistent_view, input) + .incremental_root_with_updates_and_cache(missing_leaves_cache) } /// Handles an error that occurred while inserting a block. @@ -2627,20 +2635,31 @@ where Ok(()) } - fn setup_prefetch(&self) -> (Option>, Option>) { + #[allow(clippy::type_complexity)] + fn setup_prefetch( + &self, + ) -> ( + Option>, + Option>, + Arc>, + ) { let (prefetch_tx, prefetch_rx) = tokio::sync::mpsc::unbounded_channel(); let (interrupt_tx, interrupt_rx) = oneshot::channel(); let mut trie_prefetch = TriePrefetch::new(); let provider_factory = self.provider.clone(); + let missing_leaves_cache = Arc::new(DashMap::new()); + let missing_leaves_cache_clone = Arc::clone(&missing_leaves_cache); tokio::spawn({ async move { - trie_prefetch.run(provider_factory, prefetch_rx, interrupt_rx).await; + trie_prefetch + .run(provider_factory, prefetch_rx, interrupt_rx, missing_leaves_cache_clone) + .await; } }); - (Some(prefetch_tx), Some(interrupt_tx)) + (Some(prefetch_tx), Some(interrupt_tx), missing_leaves_cache) } } diff --git a/crates/optimism/node/src/args.rs b/crates/optimism/node/src/args.rs index 54be83dc5..2707748c3 100644 --- a/crates/optimism/node/src/args.rs +++ b/crates/optimism/node/src/args.rs @@ -39,7 +39,7 @@ pub struct RollupArgs { pub discovery_v4: bool, /// Enable the engine2 experimental features on op-reth binary - #[arg(long = "engine.experimental", default_value = "false")] + #[arg(long = "engine.experimental", default_value = "true")] pub experimental: bool, /// Configure persistence threshold for engine experimental. @@ -59,7 +59,7 @@ impl Default for RollupArgs { enable_genesis_walkback: false, compute_pending_block: false, discovery_v4: false, - experimental: false, + experimental: true, persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD, memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, } diff --git a/crates/trie/db/tests/witness.rs b/crates/trie/db/tests/witness.rs index 59656383d..20f8cfbb9 100644 --- a/crates/trie/db/tests/witness.rs +++ b/crates/trie/db/tests/witness.rs @@ -6,6 +6,8 @@ use alloy_primitives::{ Address, Bytes, B256, U256, }; use alloy_rlp::EMPTY_STRING_CODE; +use reth_db::{cursor::DbCursorRW, tables}; +use reth_db_api::transaction::DbTxMut; use reth_primitives::{constants::EMPTY_ROOT_HASH, Account, StorageEntry}; use reth_provider::{test_utils::create_test_provider_factory, HashingWriter}; use reth_trie::{proof::Proof, witness::TrieWitness, HashedPostState, HashedStorage, StateRoot}; @@ -91,3 +93,53 @@ fn includes_nodes_for_destroyed_storage_nodes() { assert_eq!(witness.get(&keccak256(node)), Some(node)); } } + +#[test] +fn correctly_decodes_branch_node_values() { + let factory = create_test_provider_factory(); + let provider = factory.provider_rw().unwrap(); + + let address = Address::random(); + let hashed_address = keccak256(address); + let hashed_slot1 = B256::with_last_byte(1); + let hashed_slot2 = B256::with_last_byte(2); + + // Insert account and slots into database + provider.insert_account_for_hashing([(address, Some(Account::default()))]).unwrap(); + let mut hashed_storage_cursor = + provider.tx_ref().cursor_dup_write::().unwrap(); + hashed_storage_cursor + .upsert(hashed_address, StorageEntry { key: hashed_slot1, value: U256::from(1) }) + .unwrap(); + hashed_storage_cursor + .upsert(hashed_address, StorageEntry { key: hashed_slot2, value: U256::from(1) }) + .unwrap(); + + let state_root = StateRoot::from_tx(provider.tx_ref()).root().unwrap(); + let multiproof = Proof::from_tx(provider.tx_ref()) + .multiproof(HashMap::from_iter([( + hashed_address, + HashSet::from_iter([hashed_slot1, hashed_slot2]), + )])) + .unwrap(); + + let witness = TrieWitness::from_tx(provider.tx_ref()) + .compute(HashedPostState { + accounts: HashMap::from([(hashed_address, Some(Account::default()))]), + storages: HashMap::from([( + hashed_address, + HashedStorage::from_iter( + false, + [hashed_slot1, hashed_slot2].map(|hashed_slot| (hashed_slot, U256::from(2))), + ), + )]), + }) + .unwrap(); + assert!(witness.contains_key(&state_root)); + for node in multiproof.account_subtree.values() { + assert_eq!(witness.get(&keccak256(node)), Some(node)); + } + for node in multiproof.storages.iter().flat_map(|(_, storage)| storage.subtree.values()) { + assert_eq!(witness.get(&keccak256(node)), Some(node)); + } +} diff --git a/crates/trie/parallel/Cargo.toml b/crates/trie/parallel/Cargo.toml index 64a4644bd..1ffb21dc1 100644 --- a/crates/trie/parallel/Cargo.toml +++ b/crates/trie/parallel/Cargo.toml @@ -31,6 +31,7 @@ tracing.workspace = true # misc thiserror.workspace = true derive_more.workspace = true +dashmap = "6.1.0" rayon.workspace = true itertools.workspace = true diff --git a/crates/trie/parallel/src/parallel_root.rs b/crates/trie/parallel/src/parallel_root.rs index 328530adb..796191e91 100644 --- a/crates/trie/parallel/src/parallel_root.rs +++ b/crates/trie/parallel/src/parallel_root.rs @@ -3,6 +3,7 @@ use crate::metrics::ParallelStateRootMetrics; use crate::{stats::ParallelTrieTracker, storage_root_targets::StorageRootTargets}; use alloy_primitives::B256; use alloy_rlp::{BufMut, Encodable}; +use dashmap::DashMap; use itertools::Itertools; use reth_execution_errors::StorageRootError; use reth_provider::{ @@ -12,7 +13,7 @@ use reth_trie::{ hashed_cursor::{HashedCursorFactory, HashedPostStateCursorFactory}, node_iter::{TrieElement, TrieNodeIter}, trie_cursor::{InMemoryTrieCursorFactory, TrieCursorFactory}, - updates::TrieUpdates, + updates::{StorageTrieUpdates, TrieUpdates}, walker::TrieWalker, HashBuilder, Nibbles, StorageRoot, TrieAccount, TrieInput, }; @@ -61,19 +62,28 @@ where { /// Calculate incremental state root in parallel. pub fn incremental_root(self) -> Result { - self.calculate(false).map(|(root, _)| root) + self.calculate(false, None).map(|(root, _)| root) } /// Calculate incremental state root with updates in parallel. pub fn incremental_root_with_updates( self, ) -> Result<(B256, TrieUpdates), ParallelStateRootError> { - self.calculate(true) + self.calculate(true, None) + } + + /// Calculate incremental state root with missing leaves cache. + pub fn incremental_root_with_updates_and_cache( + self, + miss_leaves_cache: Arc>, + ) -> Result<(B256, TrieUpdates), ParallelStateRootError> { + self.calculate(true, Some(miss_leaves_cache)) } fn calculate( self, retain_updates: bool, + miss_leaves_cache: Option>>, ) -> Result<(B256, TrieUpdates), ParallelStateRootError> { let mut tracker = ParallelTrieTracker::default(); let trie_nodes_sorted = Arc::new(self.input.nodes.into_sorted()); @@ -171,14 +181,19 @@ where // be a possibility of re-adding a non-modified leaf to the hash builder. None => { tracker.inc_missed_leaves(); - StorageRoot::new_hashed( - trie_cursor_factory.clone(), - hashed_cursor_factory.clone(), - hashed_address, - #[cfg(feature = "metrics")] - self.metrics.storage_trie.clone(), - ) - .calculate(retain_updates)? + match miss_leaves_cache.clone().and_then(|cache| { + cache.get(&hashed_address).map(|value| value.clone()) + }) { + Some((root, updates)) => (root, 0usize, updates), + None => StorageRoot::new_hashed( + trie_cursor_factory.clone(), + hashed_cursor_factory.clone(), + hashed_address, + #[cfg(feature = "metrics")] + self.metrics.storage_trie.clone(), + ) + .calculate(retain_updates)?, + } } }; diff --git a/crates/trie/prefetch/Cargo.toml b/crates/trie/prefetch/Cargo.toml index 1155fc8d8..7c70e6c22 100644 --- a/crates/trie/prefetch/Cargo.toml +++ b/crates/trie/prefetch/Cargo.toml @@ -33,6 +33,7 @@ tracing.workspace = true thiserror.workspace = true derive_more.workspace = true rayon.workspace = true +dashmap = "6.1.0" # async tokio = { workspace = true, default-features = false, features = ["sync", "rt", "macros"] } diff --git a/crates/trie/prefetch/src/prefetch.rs b/crates/trie/prefetch/src/prefetch.rs index 5a0980b8d..992c3630a 100644 --- a/crates/trie/prefetch/src/prefetch.rs +++ b/crates/trie/prefetch/src/prefetch.rs @@ -1,6 +1,7 @@ use std::{collections::HashMap, sync::Arc}; use alloy_primitives::B256; +use dashmap::DashMap; use rayon::prelude::*; use reth_execution_errors::StorageRootError; use reth_primitives::revm_primitives::EvmState; @@ -13,6 +14,7 @@ use reth_trie::{ node_iter::{TrieElement, TrieNodeIter}, stats::TrieTracker, trie_cursor::TrieCursorFactory, + updates::StorageTrieUpdates, walker::TrieWalker, HashedPostState, HashedStorage, StorageRoot, }; @@ -62,6 +64,7 @@ impl TriePrefetch { provider_factory: Factory, mut prefetch_rx: UnboundedReceiver, mut interrupt_rx: Receiver<()>, + missing_leaves_cache: Arc>, ) where Factory: DatabaseProviderFactory + Clone + 'static, { @@ -78,8 +81,9 @@ impl TriePrefetch { let consistent_view = ConsistentDbView::new_with_latest_tip(provider_factory.clone()).unwrap(); let hashed_state_clone = hashed_state.clone(); let arc_tracker_clone = Arc::clone(&arc_tracker); + let missing_leaves_cache = Arc::clone(&missing_leaves_cache); join_set.spawn(async move { - if let Err(e) = self_clone.prefetch_accounts::(consistent_view, hashed_state_clone, arc_tracker_clone).await { + if let Err(e) = self_clone.prefetch_accounts::(consistent_view, hashed_state_clone, arc_tracker_clone, missing_leaves_cache).await { debug!(target: "trie::trie_prefetch", ?e, "Error while prefetching account trie storage"); }; }); @@ -167,6 +171,7 @@ impl TriePrefetch { consistent_view: ConsistentDbView, hashed_state: HashedPostState, arc_prefetch_tracker: Arc>, + missing_leaves_cache: Arc>, ) -> Result<(), TriePrefetchError> where Factory: DatabaseProviderFactory, @@ -213,19 +218,23 @@ impl TriePrefetch { TrieElement::Leaf(hashed_address, _) => { tracker.inc_leaf(); match storage_roots.remove(&hashed_address) { - Some(result) => result, + Some(_) => (), // Since we do not store all intermediate nodes in the database, there might // be a possibility of re-adding a non-modified leaf to the hash builder. - None => StorageRoot::new_hashed( - trie_cursor_factory.clone(), - hashed_cursor_factory.clone(), - hashed_address, - #[cfg(feature = "metrics")] - self.metrics.clone(), - ) - .prefetch() - .ok() - .unwrap_or_default(), + None => { + if let Ok((storage_root, _, updates)) = StorageRoot::new_hashed( + trie_cursor_factory.clone(), + hashed_cursor_factory.clone(), + hashed_address, + #[cfg(feature = "metrics")] + self.metrics.clone(), + ) + .calculate(true) + { + missing_leaves_cache + .insert(hashed_address, (storage_root, updates)); + } + } }; } } diff --git a/crates/trie/trie/src/witness.rs b/crates/trie/trie/src/witness.rs index c042a0d82..3238047c7 100644 --- a/crates/trie/trie/src/witness.rs +++ b/crates/trie/trie/src/witness.rs @@ -218,9 +218,14 @@ where TrieNode::Branch(branch) => { next_path.push(key[path.len()]); let children = branch_node_children(path.clone(), &branch); - for (child_path, node_hash) in children { + for (child_path, value) in children { if !key.starts_with(&child_path) { - trie_nodes.insert(child_path, Either::Left(node_hash)); + let value = if value.len() < B256::len_bytes() { + Either::Right(value.to_vec()) + } else { + Either::Left(B256::from_slice(&value[1..])) + }; + trie_nodes.insert(child_path, value); } } } @@ -311,8 +316,13 @@ where match TrieNode::decode(&mut &node[..])? { TrieNode::Branch(branch) => { let children = branch_node_children(path, &branch); - for (child_path, branch_hash) in children { - hash_builder.add_branch(child_path, branch_hash, false); + for (child_path, value) in children { + if value.len() < B256::len_bytes() { + hash_builder.add_leaf(child_path, value); + } else { + let hash = B256::from_slice(&value[1..]); + hash_builder.add_branch(child_path, hash, false); + } } break } @@ -342,14 +352,14 @@ where } /// Returned branch node children with keys in order. -fn branch_node_children(prefix: Nibbles, node: &BranchNode) -> Vec<(Nibbles, B256)> { +fn branch_node_children(prefix: Nibbles, node: &BranchNode) -> Vec<(Nibbles, &[u8])> { let mut children = Vec::with_capacity(node.state_mask.count_ones() as usize); let mut stack_ptr = node.as_ref().first_child_index(); for index in CHILD_INDEX_RANGE { if node.state_mask.is_bit_set(index) { let mut child_path = prefix.clone(); child_path.push(index); - children.push((child_path, B256::from_slice(&node.stack[stack_ptr][1..]))); + children.push((child_path, &node.stack[stack_ptr][..])); stack_ptr += 1; } }