From 624e7cc2c3544d59b5f6c69b5404a1941285f9a3 Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Wed, 10 Jan 2024 21:54:49 -0300 Subject: [PATCH] Avoid calling ChainConfig's dao_block function when the ruleset is kTrust --- silkworm/core/execution/processor.cpp | 3 ++- silkworm/core/protocol/base_rule_set.cpp | 3 ++- silkworm/core/protocol/rule_set.cpp | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/silkworm/core/execution/processor.cpp b/silkworm/core/execution/processor.cpp index 07465ddc..14858322 100644 --- a/silkworm/core/execution/processor.cpp +++ b/silkworm/core/execution/processor.cpp @@ -120,7 +120,8 @@ uint64_t ExecutionProcessor::refund_gas(const Transaction& txn, uint64_t gas_lef ValidationResult ExecutionProcessor::execute_block_no_post_validation(std::vector& receipts) noexcept { const Block& block{evm_.block()}; - if (block.header.number == evm_.config().dao_block()) { + // Avoid calling dao_block() when the ruleset is kTrust to prevent triggering an assertion in the dao_block function + if (evm_.config().protocol_rule_set != protocol::RuleSetType::kTrust && block.header.number == evm_.config().dao_block()) { dao::transfer_balances(state_); } diff --git a/silkworm/core/protocol/base_rule_set.cpp b/silkworm/core/protocol/base_rule_set.cpp index b337734c..83f94ade 100644 --- a/silkworm/core/protocol/base_rule_set.cpp +++ b/silkworm/core/protocol/base_rule_set.cpp @@ -167,7 +167,8 @@ ValidationResult BaseRuleSet::validate_block_header(const BlockHeader& header, c } // https://eips.ethereum.org/EIPS/eip-779 - if (chain_config_.dao_block().has_value() && chain_config_.dao_block().value() <= header.number && + // Avoid calling dao_block() when the ruleset is kTrust to prevent triggering an assertion in the dao_block function + if (chain_config_.protocol_rule_set != RuleSetType::kTrust && chain_config_.dao_block().has_value() && chain_config_.dao_block().value() <= header.number && header.number <= chain_config_.dao_block().value() + 9) { static const Bytes kDaoExtraData{*from_hex("0x64616f2d686172642d666f726b")}; if (header.extra_data != kDaoExtraData) { diff --git a/silkworm/core/protocol/rule_set.cpp b/silkworm/core/protocol/rule_set.cpp index d2ad5367..e8fa0b19 100644 --- a/silkworm/core/protocol/rule_set.cpp +++ b/silkworm/core/protocol/rule_set.cpp @@ -42,7 +42,6 @@ static RuleSetPtr pre_merge_rule_set(const ChainConfig& chain_config) { RuleSetPtr rule_set_factory(const ChainConfig& chain_config) { RuleSetPtr rule_set{pre_merge_rule_set(chain_config)}; if (!rule_set) { - std::cerr << "ERRORORORORR" << std::endl; return nullptr; }