Skip to content

Commit

Permalink
Merge pull request #244 from eosnetworkfoundation/elmato/add-softfork…
Browse files Browse the repository at this point in the history
…-support

[1.0] Refactor EIP2 enforcement
  • Loading branch information
elmato authored Jan 30, 2025
2 parents 9a95d14 + 97bdfdb commit 3c386a9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/silkworm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
CXX: g++-11

- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build.tar.gz
path: build.tar.gz
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
# private_key: ${{ secrets.TRUSTEVM_CI_APP_KEY }}

- name: Download EOS EVM Silkworm builddir
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build.tar.gz

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ option(SILKWORM_CLANG_COVERAGE "Clang instrumentation for code coverage reports"
option(SILKWORM_CLANG_TIDY "Clang-Tidy linter" OFF)
option(SILKWORM_SANITIZE "Build instrumentation for sanitizers" OFF)
option(SILKWORM_USE_MIMALLOC "Enable using mimalloc for dynamic memory management" ON)
option(WITH_SOFT_FORKS "Enable soft-forks" OFF)

set_property(
DIRECTORY
Expand Down
4 changes: 4 additions & 0 deletions silkworm/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ if(SILKWORM_CORE_USE_ABSEIL)
target_compile_definitions(silkworm_core PUBLIC SILKWORM_CORE_USE_ABSEIL)
endif()

if(WITH_SOFT_FORKS)
target_compile_definitions(silkworm_core PRIVATE WITH_SOFT_FORKS)
endif()

target_link_libraries(
silkworm_core
PUBLIC ${SILKWORM_CORE_PUBLIC_LIBS}
Expand Down
7 changes: 3 additions & 4 deletions silkworm/core/protocol/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ 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()) {
#ifdef DISABLE_EIP2_ENFORCEMENT
const bool enforce_eip2 = false;
#else
const bool enforce_eip2 = true;
bool enforce_eip2 = false;
#ifdef WITH_SOFT_FORKS
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
4 changes: 4 additions & 0 deletions silkworm/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ if(SILKWORM_SANITIZE)
target_compile_definitions(silkworm_node PRIVATE GRPC_ASAN_SUPPRESSED GRPC_TSAN_SUPPRESSED)
endif()

if(WITH_SOFT_FORKS)
target_compile_definitions(silkworm_node PRIVATE WITH_SOFT_FORKS)
endif()

target_include_directories(silkworm_node PUBLIC "${SILKWORM_MAIN_DIR}")

set(SILKWORM_NODE_PUBLIC_LIBS
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 @@ -377,10 +377,9 @@ 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;
}
#ifdef DISABLE_EIP2_ENFORCEMENT
const bool enforce_eip2 = false;
#else
const bool enforce_eip2 = true;
bool enforce_eip2 = false;
#ifdef WITH_SOFT_FORKS
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;
Expand Down

0 comments on commit 3c386a9

Please sign in to comment.