diff --git a/silkworm/core/protocol/merge_rule_set.cpp b/silkworm/core/protocol/merge_rule_set.cpp index 9819452c91..94b296bb0d 100644 --- a/silkworm/core/protocol/merge_rule_set.cpp +++ b/silkworm/core/protocol/merge_rule_set.cpp @@ -87,18 +87,26 @@ void MergeRuleSet::initialize(EVM& evm) { return; } - if (evm.revision() < EVMC_CANCUN) { - return; + if (evm.revision() >= EVMC_CANCUN) { + // EIP-4788: Beacon block root in the EVM + SILKWORM_ASSERT(header.parent_beacon_block_root); + Transaction system_txn{}; + system_txn.type = TransactionType::kSystem; + system_txn.to = kBeaconRootsAddress; + system_txn.data = Bytes{ByteView{*header.parent_beacon_block_root}}; + system_txn.set_sender(kSystemAddress); + evm.execute(system_txn, kSystemCallGasLimit); } - // EIP-4788: Beacon block root in the EVM - SILKWORM_ASSERT(header.parent_beacon_block_root); - Transaction system_txn{}; - system_txn.type = TransactionType::kSystem; - system_txn.to = kBeaconRootsAddress; - system_txn.data = Bytes{ByteView{*header.parent_beacon_block_root}}; - system_txn.set_sender(kSystemAddress); - evm.execute(system_txn, kSystemCallGasLimit); + if (evm.revision() >= EVMC_PRAGUE) { + // EIP-2935: Serve historical block hashes from state + Transaction system_txn{}; + system_txn.type = TransactionType::kSystem; + system_txn.to = kHistoryStorageAddress; + system_txn.data = Bytes{ByteView{header.parent_hash}}; + system_txn.set_sender(kSystemAddress); + evm.execute(system_txn, kSystemCallGasLimit); + } } void MergeRuleSet::finalize(IntraBlockState& state, const Block& block) { diff --git a/silkworm/core/protocol/param.hpp b/silkworm/core/protocol/param.hpp index 4690aa6dae..20493971dc 100644 --- a/silkworm/core/protocol/param.hpp +++ b/silkworm/core/protocol/param.hpp @@ -80,6 +80,9 @@ inline constexpr uint64_t kSystemCallGasLimit{30'000'000}; inline constexpr evmc::address kSystemAddress{0xfffffffffffffffffffffffffffffffffffffffe_address}; inline constexpr evmc::address kBeaconRootsAddress{0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02_address}; +// EIP-2935: Serve historical block hashes from state +inline constexpr evmc::address kHistoryStorageAddress{0x0aae40965e6800cd9b1f4b05ff21581047e3f91e_address}; + // Used in Bor inline constexpr size_t kExtraSealSize{65};