Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0 -> main] Add compile-time toggle for EIP-2 enforcement #240

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions silkworm/core/protocol/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ ValidationResult pre_validate_transaction(const Transaction& txn, const evmc_rev

/* Should the sender already be present it means the validation of signature already occurred */
if (!txn.from.has_value()) {
// FIXME: enable has_homestead in some evm_version
//const bool has_homestead{rev >= EVMC_HOMESTEAD};
const bool has_homestead{false};

if (!is_special_signature(txn.r, txn.s) && !is_valid_signature(txn.r, txn.s, has_homestead)) {
#ifdef DISABLE_EIP2_ENFORCEMENT
const bool enforce_eip2 = false;
#else
const bool enforce_eip2 = true;
#endif
if (!is_special_signature(txn.r, txn.s) && !is_valid_signature(txn.r, txn.s, enforce_eip2)) {
return ValidationResult::kInvalidSignature;
}
}
Expand Down
13 changes: 6 additions & 7 deletions silkworm/node/stagedsync/stages/stage_senders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,6 @@ Stage::Result Senders::add_to_batch(const BlockHeader& header, BlockNum block_nu

// We're only interested in revisions up to London, so it's OK to not detect time-based forks.
const evmc_revision rev{node_settings_->chain_config->revision(header)};

// FIXME: enable has_homestead in some evm_version
//const bool has_homestead{rev >= EVMC_HOMESTEAD};
const bool has_homestead{false};

const bool has_spurious_dragon{rev >= EVMC_SPURIOUS_DRAGON};

uint32_t tx_id{0};
Expand All @@ -384,8 +379,12 @@ Stage::Result Senders::add_to_batch(const BlockHeader& header, BlockNum block_nu
<< " for transaction #" << tx_id << " in block #" << block_num << " before it's supported";
return Stage::Result::kInvalidTransaction;
}

if (!is_special_signature(transaction.r, transaction.s) && !is_valid_signature(transaction.r, transaction.s, has_homestead)) {
#ifdef DISABLE_EIP2_ENFORCEMENT
const bool enforce_eip2 = false;
#else
const bool enforce_eip2 = true;
#endif
if (!is_special_signature(transaction.r, transaction.s) && !is_valid_signature(transaction.r, transaction.s, enforce_eip2)) {
log::Error(log_prefix_) << "Got invalid signature for transaction #" << tx_id << " in block #" << block_num;
return Stage::Result::kInvalidTransaction;
}
Expand Down
Loading