diff --git a/cmd/dev/snapshots.cpp b/cmd/dev/snapshots.cpp index 0311c569ad..a0646e0942 100644 --- a/cmd/dev/snapshots.cpp +++ b/cmd/dev/snapshots.cpp @@ -351,8 +351,8 @@ static void print_header(const BlockHeader& header, const std::string& snapshot_ << "difficulty=" << intx::to_string(header.difficulty) << "\n" << "gas_limit=" << header.gas_limit << "\n" << "gas_used=" << header.gas_used << "\n" - << "data_gas_used=" << (header.data_gas_used ? *header.data_gas_used : 0) << "\n" - << "excess_data_gas=" << (header.excess_data_gas ? *header.excess_data_gas : 0) << "\n" + << "blob_gas_used=" << header.blob_gas_used.value_or(0) << "\n" + << "excess_blob_gas=" << header.excess_blob_gas.value_or(0) << "\n" << "logs_bloom=" << to_hex(header.logs_bloom) << "\n" << "extra_data=" << to_hex(header.extra_data) << "\n" << "rlp=" << to_hex([&]() { Bytes b; rlp::encode(b, header); return b; }()) << "\n"; @@ -496,7 +496,7 @@ static void print_txn(const Transaction& txn, const std::string& snapshot_filena << "value=" << intx::to_string(txn.value) << "\n" << "gas_limit=" << txn.gas_limit << "\n" << "max_fee_per_gas=" << intx::to_string(txn.max_fee_per_gas) << "\n" - << "max_fee_per_data_gas=" << intx::to_string(txn.max_fee_per_data_gas) << "\n" + << "max_fee_per_blob_gas=" << intx::to_string(txn.max_fee_per_blob_gas) << "\n" << "max_priority_fee_per_gas=" << intx::to_string(txn.max_priority_fee_per_gas) << "\n" << "odd_y_parity=" << txn.odd_y_parity << "\n" << "v=" << intx::to_string(txn.v()) << "\n" diff --git a/cmd/dev/toolbox.cpp b/cmd/dev/toolbox.cpp index fa3ef2f5b6..94fbba40aa 100644 --- a/cmd/dev/toolbox.cpp +++ b/cmd/dev/toolbox.cpp @@ -173,8 +173,8 @@ static void print_header(const BlockHeader& header) { << "difficulty=" << intx::to_string(header.difficulty) << "\n" << "gas_limit=" << header.gas_limit << "\n" << "gas_used=" << header.gas_used << "\n" - << "data_gas_used=" << (header.data_gas_used ? *header.data_gas_used : 0) << "\n" - << "excess_data_gas=" << (header.excess_data_gas ? *header.excess_data_gas : 0) << "\n" + << "blob_gas_used=" << header.blob_gas_used.value_or(0) << "\n" + << "excess_blob_gas=" << header.excess_blob_gas.value_or(0) << "\n" << "logs_bloom=" << to_hex(header.logs_bloom) << "\n" << "extra_data=" << to_hex(header.extra_data) << "\n" << "rlp=" << to_hex([&]() { Bytes b; rlp::encode(b, header); return b; }()) << "\n"; diff --git a/cmd/state-transition/state_transition.cpp b/cmd/state-transition/state_transition.cpp index b54e7a8a4a..1449031b11 100644 --- a/cmd/state-transition/state_transition.cpp +++ b/cmd/state-transition/state_transition.cpp @@ -338,7 +338,7 @@ void StateTransition::run() { auto pre_block_validation = ruleSet->pre_validate_block_body(block, *state); auto block_validation = ruleSet->validate_block_header(block.header, *state, true); - auto pre_txn_validation = protocol::pre_validate_transaction(txn, rev, config.chain_id, block.header.base_fee_per_gas, block.header.data_gas_price()); + auto pre_txn_validation = protocol::pre_validate_transaction(txn, rev, config.chain_id, block.header.base_fee_per_gas, block.header.blob_gas_price()); auto txn_validation = protocol::validate_transaction(txn, processor.evm().state(), processor.available_gas()); // std::cout << "pre: " << std::endl; diff --git a/cmd/test/ethereum.cpp b/cmd/test/ethereum.cpp index 6c7c498247..9d9150dd6c 100644 --- a/cmd/test/ethereum.cpp +++ b/cmd/test/ethereum.cpp @@ -389,7 +389,7 @@ RunResults transaction_test(const nlohmann::json& j, bool) { if (ValidationResult err{ pre_validate_transaction(txn, rev, config.chain_id, /*base_fee_per_gas=*/std::nullopt, - /*data_gas_price=*/std::nullopt)}; + /*blob_gas_price=*/std::nullopt)}; err != ValidationResult::kOk) { if (should_be_valid) { std::cout << "Validation error " << magic_enum::enum_name(err) << std::endl; diff --git a/silkworm/core/execution/precompile.hpp b/silkworm/core/execution/precompile.hpp index 3d8e606ace..38797df06e 100644 --- a/silkworm/core/execution/precompile.hpp +++ b/silkworm/core/execution/precompile.hpp @@ -87,17 +87,7 @@ inline constexpr std::optional kContracts[]{ SupportedContract{{bn_mul_gas, bn_mul_run}, EVMC_BYZANTIUM}, // 0x07 SupportedContract{{snarkv_gas, snarkv_run}, EVMC_BYZANTIUM}, // 0x08 SupportedContract{{blake2_f_gas, blake2_f_run}, EVMC_ISTANBUL}, // 0x09 - std::nullopt, // 0x0a - std::nullopt, // 0x0b - std::nullopt, // 0x0c - std::nullopt, // 0x0d - std::nullopt, // 0x0e - std::nullopt, // 0x0f - std::nullopt, // 0x10 - std::nullopt, // 0x11 - std::nullopt, // 0x12 - std::nullopt, // 0x13 - SupportedContract{{point_evaluation_gas, point_evaluation_run}, EVMC_CANCUN}, // 0x14 + SupportedContract{{point_evaluation_gas, point_evaluation_run}, EVMC_CANCUN}, // 0x0a }; [[nodiscard]] bool is_precompile(const evmc::address&, evmc_revision) noexcept; diff --git a/silkworm/core/execution/precompile_test.cpp b/silkworm/core/execution/precompile_test.cpp index 152f8c035e..fc662f14ab 100644 --- a/silkworm/core/execution/precompile_test.cpp +++ b/silkworm/core/execution/precompile_test.cpp @@ -581,7 +581,7 @@ TEST_CASE("is_precompile") { CHECK(is_precompile(0x0000000000000000000000000000000000000007_address, EVMC_CANCUN) == true); CHECK(is_precompile(0x0000000000000000000000000000000000000008_address, EVMC_CANCUN) == true); CHECK(is_precompile(0x0000000000000000000000000000000000000009_address, EVMC_CANCUN) == true); - CHECK(is_precompile(0x000000000000000000000000000000000000000a_address, EVMC_CANCUN) == false); + CHECK(is_precompile(0x000000000000000000000000000000000000000a_address, EVMC_CANCUN) == true); CHECK(is_precompile(0x000000000000000000000000000000000000000b_address, EVMC_CANCUN) == false); CHECK(is_precompile(0x000000000000000000000000000000000000000c_address, EVMC_CANCUN) == false); CHECK(is_precompile(0x000000000000000000000000000000000000000d_address, EVMC_CANCUN) == false); @@ -591,7 +591,7 @@ TEST_CASE("is_precompile") { CHECK(is_precompile(0x0000000000000000000000000000000000000011_address, EVMC_CANCUN) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000012_address, EVMC_CANCUN) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000013_address, EVMC_CANCUN) == false); - CHECK(is_precompile(0x0000000000000000000000000000000000000014_address, EVMC_CANCUN) == true); + CHECK(is_precompile(0x0000000000000000000000000000000000000014_address, EVMC_CANCUN) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000015_address, EVMC_CANCUN) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000016_address, EVMC_CANCUN) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000017_address, EVMC_CANCUN) == false); @@ -611,7 +611,7 @@ TEST_CASE("is_precompile") { CHECK(is_precompile(0x0000000000000000000000000000000000000007_address, EVMC_PRAGUE) == true); CHECK(is_precompile(0x0000000000000000000000000000000000000008_address, EVMC_PRAGUE) == true); CHECK(is_precompile(0x0000000000000000000000000000000000000009_address, EVMC_PRAGUE) == true); - CHECK(is_precompile(0x000000000000000000000000000000000000000a_address, EVMC_PRAGUE) == false); + CHECK(is_precompile(0x000000000000000000000000000000000000000a_address, EVMC_PRAGUE) == true); CHECK(is_precompile(0x000000000000000000000000000000000000000b_address, EVMC_PRAGUE) == false); CHECK(is_precompile(0x000000000000000000000000000000000000000c_address, EVMC_PRAGUE) == false); CHECK(is_precompile(0x000000000000000000000000000000000000000d_address, EVMC_PRAGUE) == false); @@ -621,7 +621,7 @@ TEST_CASE("is_precompile") { CHECK(is_precompile(0x0000000000000000000000000000000000000011_address, EVMC_PRAGUE) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000012_address, EVMC_PRAGUE) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000013_address, EVMC_PRAGUE) == false); - CHECK(is_precompile(0x0000000000000000000000000000000000000014_address, EVMC_PRAGUE) == true); + CHECK(is_precompile(0x0000000000000000000000000000000000000014_address, EVMC_PRAGUE) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000015_address, EVMC_PRAGUE) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000016_address, EVMC_PRAGUE) == false); CHECK(is_precompile(0x0000000000000000000000000000000000000017_address, EVMC_PRAGUE) == false); diff --git a/silkworm/core/execution/processor.cpp b/silkworm/core/execution/processor.cpp index 703b8c701b..dae8675857 100644 --- a/silkworm/core/execution/processor.cpp +++ b/silkworm/core/execution/processor.cpp @@ -65,9 +65,9 @@ void ExecutionProcessor::execute_transaction(const Transaction& txn, Receipt& re const intx::uint256 effective_gas_price{txn.effective_gas_price(base_fee_per_gas)}; state_.subtract_from_balance(*txn.from, txn.gas_limit * effective_gas_price); - // EIP-4844 data gas cost (calc_data_fee) - const intx::uint256 data_gas_price{evm_.block().header.data_gas_price().value_or(0)}; - state_.subtract_from_balance(*txn.from, txn.total_data_gas() * data_gas_price); + // EIP-4844 blob gas cost (calc_data_fee) + const intx::uint256 blob_gas_price{evm_.block().header.blob_gas_price().value_or(0)}; + state_.subtract_from_balance(*txn.from, txn.total_blob_gas() * blob_gas_price); const intx::uint128 g0{protocol::intrinsic_gas(txn, rev)}; assert(g0 <= UINT64_MAX); // true due to the precondition (transaction must be valid) diff --git a/silkworm/core/protocol/base_rule_set.cpp b/silkworm/core/protocol/base_rule_set.cpp index 834d1d97fc..02ffafc4a9 100644 --- a/silkworm/core/protocol/base_rule_set.cpp +++ b/silkworm/core/protocol/base_rule_set.cpp @@ -48,18 +48,18 @@ ValidationResult BaseRuleSet::pre_validate_block_body(const Block& block, const return ValidationResult::kWrongWithdrawalsRoot; } - std::optional data_gas_used{std::nullopt}; + std::optional blob_gas_used{std::nullopt}; if (rev >= EVMC_CANCUN) { - data_gas_used = 0; + blob_gas_used = 0; for (const Transaction& tx : block.transactions) { - *data_gas_used += tx.total_data_gas(); + *blob_gas_used += tx.total_blob_gas(); } - if (data_gas_used > kMaxDataGasPerBlock) { + if (blob_gas_used > kMaxBlobGasPerBlock) { return ValidationResult::kTooManyBlobs; } } - if (header.data_gas_used != data_gas_used) { - return ValidationResult::kWrongDataGasUsed; + if (header.blob_gas_used != blob_gas_used) { + return ValidationResult::kWrongBlobGasUsed; } if (block.ommers.empty()) { @@ -201,15 +201,15 @@ ValidationResult BaseRuleSet::validate_block_header(const BlockHeader& header, c } if (rev < EVMC_CANCUN) { - if (header.data_gas_used || header.excess_data_gas || header.parent_beacon_block_root) { + if (header.blob_gas_used || header.excess_blob_gas || header.parent_beacon_block_root) { return ValidationResult::kFieldBeforeFork; } } else { - if (!header.data_gas_used || !header.excess_data_gas || !header.parent_beacon_block_root) { + if (!header.blob_gas_used || !header.excess_blob_gas || !header.parent_beacon_block_root) { return ValidationResult::kMissingField; } - if (header.excess_data_gas != calc_excess_data_gas(*parent)) { - return ValidationResult::kWrongExcessDataGas; + if (header.excess_blob_gas != calc_excess_blob_gas(*parent)) { + return ValidationResult::kWrongExcessBlobGas; } } diff --git a/silkworm/core/protocol/param.hpp b/silkworm/core/protocol/param.hpp index 43639aed54..7f9162963f 100644 --- a/silkworm/core/protocol/param.hpp +++ b/silkworm/core/protocol/param.hpp @@ -62,11 +62,11 @@ inline constexpr uint64_t kElasticityMultiplier{2}; // EIP-4844: Shard Blob Transactions inline constexpr uint8_t kBlobCommitmentVersionKzg{1}; -inline constexpr uint64_t kMaxDataGasPerBlock{1u << 19}; -inline constexpr uint64_t kTargetDataGasPerBlock{1u << 18}; -inline constexpr uint64_t kDataGasPerBlob{1u << 17}; -inline constexpr uint64_t kMinDataGasPrice{1}; -inline constexpr uint64_t kDataGasPriceUpdateFraction{2225652}; +inline constexpr uint64_t kGasPerBlob{1u << 17}; +inline constexpr uint64_t kTargetBlobGasPerBlock{3 * kGasPerBlob}; +inline constexpr uint64_t kMaxBlobGasPerBlock{6 * kGasPerBlob}; +inline constexpr uint64_t kMinBlobGasPrice{1}; +inline constexpr uint64_t kBlobGasPriceUpdateFraction{3338477}; // EIP-4788: Beacon block root in the EVM inline constexpr uint64_t kSystemCallGasLimit{30'000'000}; diff --git a/silkworm/core/protocol/validation.cpp b/silkworm/core/protocol/validation.cpp index 0f99a449f0..bf3bc27c4a 100644 --- a/silkworm/core/protocol/validation.cpp +++ b/silkworm/core/protocol/validation.cpp @@ -40,7 +40,7 @@ bool transaction_type_is_supported(TransactionType type, evmc_revision rev) { ValidationResult pre_validate_transaction(const Transaction& txn, const evmc_revision rev, const uint64_t chain_id, const std::optional& base_fee_per_gas, - const std::optional& data_gas_price) { + const std::optional& blob_gas_price) { if (txn.chain_id.has_value()) { if (rev < EVMC_SPURIOUS_DRAGON) { // EIP-155 transaction before EIP-155 was activated @@ -101,13 +101,13 @@ ValidationResult pre_validate_transaction(const Transaction& txn, const evmc_rev return ValidationResult::kWrongBlobCommitmentVersion; } } - SILKWORM_ASSERT(data_gas_price); - if (txn.max_fee_per_data_gas < data_gas_price) { - return ValidationResult::kMaxFeePerDataGasTooLow; + SILKWORM_ASSERT(blob_gas_price); + if (txn.max_fee_per_blob_gas < blob_gas_price) { + return ValidationResult::kMaxFeePerBlobGasTooLow; + } + if (!txn.to) { + return ValidationResult::kBlobCreateTransaction; } - // TODO(yperbasis): There is an equal amount of versioned hashes, kzg commitments and blobs. - // The KZG commitments hash to the versioned hashes, i.e. kzg_to_versioned_hash(kzg[i]) == versioned_hash[i] - // The KZG commitments match the blob contents. } return ValidationResult::kOk; @@ -147,11 +147,11 @@ ValidationResult validate_transaction(const Transaction& txn, const IntraBlockSt ValidationResult pre_validate_transactions(const Block& block, const ChainConfig& config) { const BlockHeader& header{block.header}; const evmc_revision rev{config.revision(header.number, header.timestamp)}; - const std::optional data_gas_price{header.data_gas_price()}; + const std::optional blob_gas_price{header.blob_gas_price()}; for (const Transaction& txn : block.transactions) { ValidationResult err{pre_validate_transaction(txn, rev, config.chain_id, - header.base_fee_per_gas, data_gas_price)}; + header.base_fee_per_gas, blob_gas_price)}; if (err != ValidationResult::kOk) { return err; } @@ -192,14 +192,14 @@ intx::uint256 expected_base_fee_per_gas(const BlockHeader& parent) { } } -uint64_t calc_excess_data_gas(const BlockHeader& parent) { - const uint64_t parent_excess_data_gas{parent.excess_data_gas.value_or(0)}; - const uint64_t consumed_data_gas{parent.data_gas_used.value_or(0)}; +uint64_t calc_excess_blob_gas(const BlockHeader& parent) { + const uint64_t parent_excess_blob_gas{parent.excess_blob_gas.value_or(0)}; + const uint64_t consumed_blob_gas{parent.blob_gas_used.value_or(0)}; - if (parent_excess_data_gas + consumed_data_gas < kTargetDataGasPerBlock) { + if (parent_excess_blob_gas + consumed_blob_gas < kTargetBlobGasPerBlock) { return 0; } else { - return parent_excess_data_gas + consumed_data_gas - kTargetDataGasPerBlock; + return parent_excess_blob_gas + consumed_blob_gas - kTargetBlobGasPerBlock; } } diff --git a/silkworm/core/protocol/validation.hpp b/silkworm/core/protocol/validation.hpp index 0123340660..9832ad2656 100644 --- a/silkworm/core/protocol/validation.hpp +++ b/silkworm/core/protocol/validation.hpp @@ -94,12 +94,13 @@ enum class [[nodiscard]] ValidationResult{ kWrongWithdrawalsRoot, // EIP-4844: Shard Blob Transactions - kWrongDataGasUsed, - kWrongExcessDataGas, + kWrongBlobGasUsed, + kWrongExcessBlobGas, kNoBlobs, kTooManyBlobs, kWrongBlobCommitmentVersion, - kMaxFeePerDataGasTooLow, // max_fee_per_data_gas < data_gas_price + kMaxFeePerBlobGasTooLow, // max_fee_per_blob_gas < blob_gas_price + kBlobCreateTransaction, // Blob transactions cannot have the form of a create transaction }; namespace protocol { @@ -112,7 +113,7 @@ namespace protocol { //! \remarks These function is agnostic to whole block validity ValidationResult pre_validate_transaction(const Transaction& txn, evmc_revision revision, uint64_t chain_id, const std::optional& base_fee_per_gas, - const std::optional& data_gas_price); + const std::optional& blob_gas_price); ValidationResult pre_validate_transactions(const Block& block, const ChainConfig& config); @@ -128,7 +129,7 @@ namespace protocol { intx::uint256 expected_base_fee_per_gas(const BlockHeader& parent); //! \see EIP-4844: Shard Blob Transactions - uint64_t calc_excess_data_gas(const BlockHeader& parent); + uint64_t calc_excess_blob_gas(const BlockHeader& parent); //! \brief Calculate the transaction root of a block body evmc::bytes32 compute_transaction_root(const BlockBody& body); diff --git a/silkworm/core/protocol/validation_test.cpp b/silkworm/core/protocol/validation_test.cpp index e95bf1b2ae..727495de80 100644 --- a/silkworm/core/protocol/validation_test.cpp +++ b/silkworm/core/protocol/validation_test.cpp @@ -25,67 +25,67 @@ namespace silkworm::protocol { TEST_CASE("Validate transaction types") { const std::optional base_fee_per_gas{std::nullopt}; - const std::optional data_gas_price{std::nullopt}; + const std::optional blob_gas_price{std::nullopt}; Transaction txn; txn.type = TransactionType::kLegacy; - CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kUnsupportedTransactionType); txn.type = static_cast(0x03); // unsupported transaction type - CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kUnsupportedTransactionType); txn.type = TransactionType::kAccessList; - CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kUnsupportedTransactionType); txn.type = TransactionType::kDynamicFee; - CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_ISTANBUL, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_BERLIN, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kUnsupportedTransactionType); - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kUnsupportedTransactionType); } TEST_CASE("Validate max_fee_per_gas") { const std::optional base_fee_per_gas{1'000'000'000}; - const std::optional data_gas_price{std::nullopt}; + const std::optional blob_gas_price{std::nullopt}; Transaction txn; txn.type = TransactionType::kDynamicFee; txn.max_priority_fee_per_gas = 500'000'000; txn.max_fee_per_gas = 700'000'000; - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kMaxFeeLessThanBase); txn.max_priority_fee_per_gas = 3'000'000'000; txn.max_fee_per_gas = 2'000'000'000; - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) == + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) == ValidationResult::kMaxPriorityFeeGreaterThanMax); txn.max_priority_fee_per_gas = 2'000'000'000; txn.max_fee_per_gas = 2'000'000'000; - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kMaxPriorityFeeGreaterThanMax); txn.max_priority_fee_per_gas = 1'000'000'000; txn.max_fee_per_gas = 2'000'000'000; - CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, data_gas_price) != + CHECK(pre_validate_transaction(txn, EVMC_LONDON, 1, base_fee_per_gas, blob_gas_price) != ValidationResult::kMaxPriorityFeeGreaterThanMax); } diff --git a/silkworm/core/types/block.cpp b/silkworm/core/types/block.cpp index 5a29655352..2f3451d75b 100644 --- a/silkworm/core/types/block.cpp +++ b/silkworm/core/types/block.cpp @@ -56,15 +56,15 @@ static intx::uint256 fake_exponential(const intx::uint256& factor, return output / denominator; } -std::optional BlockHeader::data_gas_price() const { - if (!excess_data_gas) { +std::optional BlockHeader::blob_gas_price() const { + if (!excess_blob_gas) { return std::nullopt; } return fake_exponential( - protocol::kMinDataGasPrice, - *excess_data_gas, - protocol::kDataGasPriceUpdateFraction); + protocol::kMinBlobGasPrice, + *excess_blob_gas, + protocol::kBlobGasPriceUpdateFraction); } //! \brief Recover transaction senders for each block. @@ -106,11 +106,11 @@ namespace rlp { if (header.withdrawals_root) { rlp_head.payload_length += kHashLength + 1; } - if (header.data_gas_used) { - rlp_head.payload_length += length(*header.data_gas_used); + if (header.blob_gas_used) { + rlp_head.payload_length += length(*header.blob_gas_used); } - if (header.excess_data_gas) { - rlp_head.payload_length += length(*header.excess_data_gas); + if (header.excess_blob_gas) { + rlp_head.payload_length += length(*header.excess_blob_gas); } if (header.parent_beacon_block_root) { rlp_head.payload_length += kHashLength + 1; @@ -154,11 +154,11 @@ namespace rlp { if (header.withdrawals_root) { encode(to, *header.withdrawals_root); } - if (header.data_gas_used) { - encode(to, *header.data_gas_used); + if (header.blob_gas_used) { + encode(to, *header.blob_gas_used); } - if (header.excess_data_gas) { - encode(to, *header.excess_data_gas); + if (header.excess_blob_gas) { + encode(to, *header.excess_blob_gas); } if (header.parent_beacon_block_root) { encode(to, *header.parent_beacon_block_root); @@ -217,17 +217,17 @@ namespace rlp { } if (from.length() > leftover) { - to.data_gas_used = 0; - to.excess_data_gas = 0; + to.blob_gas_used = 0; + to.excess_blob_gas = 0; to.parent_beacon_block_root = evmc::bytes32{}; - if (DecodingResult res{decode_items(from, *to.data_gas_used, *to.excess_data_gas, + if (DecodingResult res{decode_items(from, *to.blob_gas_used, *to.excess_blob_gas, *to.parent_beacon_block_root)}; !res) { return res; } } else { - to.data_gas_used = std::nullopt; - to.excess_data_gas = std::nullopt; + to.blob_gas_used = std::nullopt; + to.excess_blob_gas = std::nullopt; to.parent_beacon_block_root = std::nullopt; } diff --git a/silkworm/core/types/block.hpp b/silkworm/core/types/block.hpp index f22945e7be..c44b006889 100644 --- a/silkworm/core/types/block.hpp +++ b/silkworm/core/types/block.hpp @@ -77,8 +77,8 @@ struct BlockHeader { std::optional withdrawals_root{std::nullopt}; // EIP-4895 // Added in Cancun - std::optional data_gas_used{std::nullopt}; // EIP-4844 - std::optional excess_data_gas{std::nullopt}; // EIP-4844 + std::optional blob_gas_used{std::nullopt}; // EIP-4844 + std::optional excess_blob_gas{std::nullopt}; // EIP-4844 std::optional parent_beacon_block_root{std::nullopt}; // EIP-4788 [[nodiscard]] evmc::bytes32 hash(bool for_sealing = false, bool exclude_extra_data_sig = false) const; @@ -88,7 +88,7 @@ struct BlockHeader { [[nodiscard]] ethash::hash256 boundary() const; //! \see https://eips.ethereum.org/EIPS/eip-4844#gas-accounting - [[nodiscard]] std::optional data_gas_price() const; + [[nodiscard]] std::optional blob_gas_price() const; friend bool operator==(const BlockHeader&, const BlockHeader&) = default; }; diff --git a/silkworm/core/types/block_test.cpp b/silkworm/core/types/block_test.cpp index c218300b57..b09c52e014 100644 --- a/silkworm/core/types/block_test.cpp +++ b/silkworm/core/types/block_test.cpp @@ -197,8 +197,8 @@ TEST_CASE("Cancun Header RLP") { .prev_randao = 0xd01681d2b3acdebff0288a02a1648b3910500961982d5ecdbef064af7c34090b_bytes32, .base_fee_per_gas = 2'700'000'000, .withdrawals_root = 0xbac9348581b0ee244d6eb61076b63c4e4afa70430c804ab0e6a0ab69d9a9d323_bytes32, - .data_gas_used = 456, - .excess_data_gas = 789633, + .blob_gas_used = 456, + .excess_blob_gas = 789633, .parent_beacon_block_root = 0x22_bytes32, }; diff --git a/silkworm/core/types/transaction.cpp b/silkworm/core/types/transaction.cpp index 05883b3c73..3fe59a5f16 100644 --- a/silkworm/core/types/transaction.cpp +++ b/silkworm/core/types/transaction.cpp @@ -93,7 +93,7 @@ namespace rlp { if (txn.type != TransactionType::kLegacy) { h.payload_length += length(txn.access_list); if (txn.type == TransactionType::kBlob) { - h.payload_length += length(txn.max_fee_per_data_gas); + h.payload_length += length(txn.max_fee_per_blob_gas); h.payload_length += length(txn.blob_versioned_hashes); } } @@ -174,7 +174,7 @@ namespace rlp { encode(to, txn.access_list); if (txn.type == TransactionType::kBlob) { - encode(to, txn.max_fee_per_data_gas); + encode(to, txn.max_fee_per_blob_gas); encode(to, txn.blob_versioned_hashes); } } @@ -275,9 +275,9 @@ namespace rlp { } if (to.type != TransactionType::kBlob) { - to.max_fee_per_data_gas = 0; + to.max_fee_per_blob_gas = 0; to.blob_versioned_hashes.clear(); - } else if (DecodingResult res{decode_items(from, to.max_fee_per_data_gas, to.blob_versioned_hashes)}; !res) { + } else if (DecodingResult res{decode_items(from, to.max_fee_per_blob_gas, to.blob_versioned_hashes)}; !res) { return res; } @@ -311,7 +311,7 @@ namespace rlp { if (h->list) { // Legacy transaction to.type = TransactionType::kLegacy; to.access_list.clear(); - to.max_fee_per_data_gas = 0; + to.max_fee_per_blob_gas = 0; to.blob_versioned_hashes.clear(); const uint64_t leftover{from.length() - h->payload_length}; @@ -422,7 +422,7 @@ intx::uint512 UnsignedTransaction::maximum_gas_cost() const { // See https://github.com/ethereum/EIPs/pull/3594 intx::uint512 max_gas_cost{intx::umul(intx::uint256{gas_limit}, max_fee_per_gas)}; // and https://eips.ethereum.org/EIPS/eip-4844#gas-accounting - max_gas_cost += intx::umul(intx::uint256{total_data_gas()}, max_fee_per_data_gas); + max_gas_cost += intx::umul(intx::uint256{total_blob_gas()}, max_fee_per_blob_gas); return max_gas_cost; } @@ -438,8 +438,8 @@ intx::uint256 UnsignedTransaction::effective_gas_price(const intx::uint256& base return priority_fee_per_gas(base_fee_per_gas) + base_fee_per_gas; } -uint64_t UnsignedTransaction::total_data_gas() const { - return protocol::kDataGasPerBlob * blob_versioned_hashes.size(); +uint64_t UnsignedTransaction::total_blob_gas() const { + return protocol::kGasPerBlob * blob_versioned_hashes.size(); } } // namespace silkworm diff --git a/silkworm/core/types/transaction.hpp b/silkworm/core/types/transaction.hpp index 47b905e7aa..bbab209fbc 100644 --- a/silkworm/core/types/transaction.hpp +++ b/silkworm/core/types/transaction.hpp @@ -65,7 +65,7 @@ struct UnsignedTransaction { std::vector access_list{}; // EIP-2930 // EIP-4844: Shard Blob Transactions - intx::uint256 max_fee_per_data_gas{0}; + intx::uint256 max_fee_per_blob_gas{0}; std::vector blob_versioned_hashes{}; //! \brief Maximum possible cost of normal and data (EIP-4844) gas @@ -74,7 +74,7 @@ struct UnsignedTransaction { [[nodiscard]] intx::uint256 priority_fee_per_gas(const intx::uint256& base_fee_per_gas) const; // EIP-1559 [[nodiscard]] intx::uint256 effective_gas_price(const intx::uint256& base_fee_per_gas) const; // EIP-1559 - [[nodiscard]] uint64_t total_data_gas() const; // EIP-4844 + [[nodiscard]] uint64_t total_blob_gas() const; // EIP-4844 void encode_for_signing(Bytes& into) const; diff --git a/silkworm/core/types/transaction_test.cpp b/silkworm/core/types/transaction_test.cpp index dab9583449..20d8fd4c97 100644 --- a/silkworm/core/types/transaction_test.cpp +++ b/silkworm/core/types/transaction_test.cpp @@ -57,11 +57,11 @@ TEST_CASE("Legacy Transaction RLP") { CHECK(view.empty()); CHECK(decoded == txn); - // Check that non-legacy fields (access_list, max_fee_per_data_gas, blob_versioned_hashes) and from are cleared + // Check that non-legacy fields (access_list, max_fee_per_blob_gas, blob_versioned_hashes) and from are cleared decoded.max_priority_fee_per_gas = 17; decoded.max_fee_per_gas = 31; decoded.access_list = access_list; - decoded.max_fee_per_data_gas = 123; + decoded.max_fee_per_blob_gas = 123; decoded.blob_versioned_hashes.push_back(0xefc552d1df2a6a8e2643912171d040e4de0db43cd53b728c3e4d26952f710be8_bytes32); decoded.from = 0x811a752c8cd697e3cb27279c330ed1ada745a8d7_address; view = encoded; @@ -125,10 +125,10 @@ TEST_CASE("EIP-2930 Transaction RLP") { CHECK(view.empty()); CHECK(decoded == txn); - // Check that post-EIP-2930 fields (max_fee_per_data_gas, blob_versioned_hashes) and from are cleared + // Check that post-EIP-2930 fields (max_fee_per_blob_gas, blob_versioned_hashes) and from are cleared decoded.max_priority_fee_per_gas = 17; decoded.max_fee_per_gas = 31; - decoded.max_fee_per_data_gas = 123; + decoded.max_fee_per_blob_gas = 123; decoded.blob_versioned_hashes.push_back(0xefc552d1df2a6a8e2643912171d040e4de0db43cd53b728c3e4d26952f710be8_bytes32); decoded.from = 0x811a752c8cd697e3cb27279c330ed1ada745a8d7_address; view = encoded_wrapped; @@ -175,7 +175,7 @@ TEST_CASE("EIP-4844 Transaction RLP") { .to = 0x811a752c8cd697e3cb27279c330ed1ada745a8d7_address, .data = *from_hex("04f7"), .access_list = access_list, - .max_fee_per_data_gas = 123, + .max_fee_per_blob_gas = 123, .blob_versioned_hashes = { 0xc6bdd1de713471bd6cfa62dd8b5a5b42969ed09e26212d3377f3f8426d8ec210_bytes32, 0x8aaeccaf3873d07cef005aca28c39f8a9f8bdb1ec8d79ffc25afc0a4fa2ab736_bytes32, diff --git a/silkworm/node/snapshot/snapshot_test.cpp b/silkworm/node/snapshot/snapshot_test.cpp index 6d2aa4b21a..943b172287 100644 --- a/silkworm/node/snapshot/snapshot_test.cpp +++ b/silkworm/node/snapshot/snapshot_test.cpp @@ -393,7 +393,7 @@ TEST_CASE("TransactionSnapshot::slice_tx_payload", "[silkworm][node][snapshot]") .to = 0x811a752c8cd697e3cb27279c330ed1ada745a8d7_address, .data = *from_hex("04f7"), .access_list = access_list, - .max_fee_per_data_gas = 123, + .max_fee_per_blob_gas = 123, .blob_versioned_hashes = { 0xc6bdd1de713471bd6cfa62dd8b5a5b42969ed09e26212d3377f3f8426d8ec210_bytes32, 0x8aaeccaf3873d07cef005aca28c39f8a9f8bdb1ec8d79ffc25afc0a4fa2ab736_bytes32, diff --git a/silkworm/node/stagedsync/remote_client.cpp b/silkworm/node/stagedsync/remote_client.cpp index 53a07380b5..381e4e60c0 100644 --- a/silkworm/node/stagedsync/remote_client.cpp +++ b/silkworm/node/stagedsync/remote_client.cpp @@ -52,11 +52,11 @@ static void serialize_header(const BlockHeader& bh, ::execution::Header* header) if (bh.withdrawals_root) { header->set_allocated_withdrawal_hash(rpc::H256_from_bytes32(*bh.withdrawals_root).release()); } - if (bh.data_gas_used) { - header->set_data_gas_used(*bh.data_gas_used); + if (bh.blob_gas_used) { + header->set_data_gas_used(*bh.blob_gas_used); } - if (bh.excess_data_gas) { - header->set_excess_data_gas(*bh.excess_data_gas); + if (bh.excess_blob_gas) { + header->set_excess_data_gas(*bh.excess_blob_gas); } } @@ -84,10 +84,10 @@ static void deserialize_header(const ::execution::Header& received_header, Block header.withdrawals_root = rpc::bytes32_from_H256(received_header.withdrawal_hash()); } if (received_header.has_data_gas_used()) { - header.data_gas_used = received_header.data_gas_used(); + header.blob_gas_used = received_header.data_gas_used(); } if (received_header.has_excess_data_gas()) { - header.excess_data_gas = received_header.excess_data_gas(); + header.excess_blob_gas = received_header.excess_data_gas(); } } diff --git a/third_party/blst b/third_party/blst index a7fd1f584d..3dd0f804b1 160000 --- a/third_party/blst +++ b/third_party/blst @@ -1 +1 @@ -Subproject commit a7fd1f584d26b0ae6cdc427976ea1d8980f7e15d +Subproject commit 3dd0f804b1819e5d03fb22ca2e6fac105932043a diff --git a/third_party/evmone b/third_party/evmone index 778dfcb724..33c66e70f5 160000 --- a/third_party/evmone +++ b/third_party/evmone @@ -1 +1 @@ -Subproject commit 778dfcb7248d0cd7080f23b0cb9fe62a39f51eae +Subproject commit 33c66e70f5ac1bc575f71cde1ebb9c2e5b1c4d22