Skip to content

Commit

Permalink
Merge pull request #239 from eosnetworkfoundation/elmato/reject-high-…
Browse files Browse the repository at this point in the history
…s-value

[1.0] Add compile-time toggle for EIP-2 enforcement
  • Loading branch information
elmato authored Jan 24, 2025
2 parents 7cc1d0b + 5a100a7 commit 48fc00a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
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 @@ -368,11 +368,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 @@ -382,8 +377,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

0 comments on commit 48fc00a

Please sign in to comment.