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

Reject high s value in signature starting from evm_version 3 #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Loading