Skip to content

Commit

Permalink
Avoid calling ChainConfig's dao_block function when the ruleset is kT…
Browse files Browse the repository at this point in the history
…rust
  • Loading branch information
elmato committed Jan 11, 2024
1 parent 2137248 commit 624e7cc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion silkworm/core/execution/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Receipt>& 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_);
}

Expand Down
3 changes: 2 additions & 1 deletion silkworm/core/protocol/base_rule_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion silkworm/core/protocol/rule_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 624e7cc

Please sign in to comment.