Skip to content

Commit

Permalink
Reject high s values in signatures when evm_version >= 3
Browse files Browse the repository at this point in the history
  • Loading branch information
elmato committed Jan 20, 2025
1 parent 7e88b52 commit ab08ffe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 2 additions & 5 deletions silkworm/core/protocol/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,8 @@ 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)) {
const bool enforce_eip2{eos_evm_version >=3};
if (!is_special_signature(txn.r, txn.s) && !is_valid_signature(txn.r, txn.s, enforce_eip2)) {
return ValidationResult::kInvalidSignature;
}
}
Expand Down
7 changes: 3 additions & 4 deletions silkworm/node/stagedsync/stages/stage_senders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <silkworm/core/protocol/validation.hpp>
#include <silkworm/infra/common/stopwatch.hpp>
#include <silkworm/node/db/access_layer.hpp>
#include <eosevm/version.hpp>

namespace silkworm::stagedsync {

Expand Down Expand Up @@ -371,9 +372,7 @@ 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 enforce_eip2{eosevm::nonce_to_version(header.nonce)>=3};

const bool has_spurious_dragon{rev >= EVMC_SPURIOUS_DRAGON};

Expand All @@ -385,7 +384,7 @@ Stage::Result Senders::add_to_batch(const BlockHeader& header, BlockNum block_nu
return Stage::Result::kInvalidTransaction;
}

if (!is_special_signature(transaction.r, transaction.s) && !is_valid_signature(transaction.r, transaction.s, has_homestead)) {
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 ab08ffe

Please sign in to comment.