From 0be3ae9d2c27a2840acf22ef38067e370b7c69b8 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 09:48:42 -0300 Subject: [PATCH 01/24] fix: increase max_blob_count to 9 according to eip 7691 --- crates/vm/levm/src/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 0d27ec1ca..79645f8fa 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -49,7 +49,7 @@ pub const MAX_BLOB_NUMBER_PER_BLOCK: usize = 6; pub const TARGET_BLOB_GAS_PER_BLOCK: U256 = U256([393216, 0, 0, 0]); // TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB pub const MIN_BASE_FEE_PER_BLOB_GAS: U256 = U256::one(); pub const BLOB_BASE_FEE_UPDATE_FRACTION: U256 = U256([3338477, 0, 0, 0]); -pub const MAX_BLOB_COUNT: usize = 6; +pub const MAX_BLOB_COUNT: usize = 9; pub const VALID_BLOB_PREFIXES: [u8; 2] = [0x01, 0x02]; // Block constants From 88064a38b84d64723647814b3e1f04344a19d205 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 10:20:43 -0300 Subject: [PATCH 02/24] Update roadmap with EIP-7702's status --- crates/vm/levm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vm/levm/README.md b/crates/vm/levm/README.md index 9eb8a75ff..33f1a1a24 100644 --- a/crates/vm/levm/README.md +++ b/crates/vm/levm/README.md @@ -83,7 +83,7 @@ There are a lot of EIPs schedule to include in this upgrade but for `levm` we'll | ------------------------- | ------ | | Implement EIP-2537 | ✅ | | Implement EIP-7623 | ✅ | -| Implement EIP-7702 | 🏗️ | +| Implement EIP-7702 | ✅️ | | Make Prague EF tests pass | ❌ | ### Milestone 5: Integrate `ethrex L2` <> `levm` From aae689c55c95e3df09b23be87e9b9c2392103abf Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 10:22:49 -0300 Subject: [PATCH 03/24] Add EIP-7691 to the roadmap --- crates/vm/levm/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/vm/levm/README.md b/crates/vm/levm/README.md index 33f1a1a24..ca02fa72f 100644 --- a/crates/vm/levm/README.md +++ b/crates/vm/levm/README.md @@ -83,6 +83,7 @@ There are a lot of EIPs schedule to include in this upgrade but for `levm` we'll | ------------------------- | ------ | | Implement EIP-2537 | ✅ | | Implement EIP-7623 | ✅ | +| Implement EIP-7691 | 🏗️ | | Implement EIP-7702 | ✅️ | | Make Prague EF tests pass | ❌ | From 63967788ad7252ca3b0576f92241b0e731f4a9c8 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 10:29:31 -0300 Subject: [PATCH 04/24] Update value --- crates/blockchain/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/blockchain/constants.rs b/crates/blockchain/constants.rs index 651c0b038..29abd42bf 100644 --- a/crates/blockchain/constants.rs +++ b/crates/blockchain/constants.rs @@ -45,7 +45,7 @@ pub const GAS_PER_BLOB: u64 = 1 << 17; pub const TARGET_BLOB_GAS_PER_BLOCK: u64 = 393216; /// Target number of the blob per block. -pub const TARGET_BLOB_NUMBER_PER_BLOCK: u64 = 3; +pub const TARGET_BLOB_NUMBER_PER_BLOCK: u64 = 6; /// Max number of blobs per block pub const MAX_BLOB_NUMBER_PER_BLOCK: u64 = 2 * TARGET_BLOB_NUMBER_PER_BLOCK; From 2cd0cfc36dafe7693c69f52b8412cff593d39f0f Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 10:57:10 -0300 Subject: [PATCH 05/24] Add function to encapsulate max_blobs_per_block --- crates/vm/levm/src/constants.rs | 13 ++++++++++++- crates/vm/levm/src/vm.rs | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 79645f8fa..bac1f4556 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -5,6 +5,8 @@ use k256::{ }; use std::sync::LazyLock; +use revm_primitives::SpecId; + pub const WORD_SIZE_IN_BYTES: U256 = U256([32, 0, 0, 0]); pub const WORD_SIZE_IN_BYTES_USIZE: usize = 32; pub const WORD_SIZE_IN_BYTES_U64: u64 = 32; @@ -49,7 +51,8 @@ pub const MAX_BLOB_NUMBER_PER_BLOCK: usize = 6; pub const TARGET_BLOB_GAS_PER_BLOCK: U256 = U256([393216, 0, 0, 0]); // TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB pub const MIN_BASE_FEE_PER_BLOB_GAS: U256 = U256::one(); pub const BLOB_BASE_FEE_UPDATE_FRACTION: U256 = U256([3338477, 0, 0, 0]); -pub const MAX_BLOB_COUNT: usize = 9; +pub const MAX_BLOB_COUNT: usize = 6; +pub const MAX_BLOB_COUNT_ELECTRA: usize = 9; pub const VALID_BLOB_PREFIXES: [u8; 2] = [0x01, 0x02]; // Block constants @@ -68,3 +71,11 @@ pub const SET_CODE_DELEGATION_BYTES: [u8; 3] = [0xef, 0x01, 0x00]; pub const EIP7702_DELEGATED_CODE_LEN: usize = 23; pub const PER_AUTH_BASE_COST: u64 = 12500; pub const PER_EMPTY_ACCOUNT_COST: u64 = 25000; + +pub const fn max_blobs_per_block(specid: SpecId) -> usize { + match specid { + SpecId::PRAGUE => MAX_BLOB_COUNT_ELECTRA, + SpecId::PRAGUE_EOF => MAX_BLOB_COUNT_ELECTRA, + _ => MAX_BLOB_COUNT, + } +} diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index 70d538e4b..f91e84ea1 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -928,7 +928,7 @@ impl VM { } // (14) TYPE_3_TX_BLOB_COUNT_EXCEEDED - if blob_hashes.len() > MAX_BLOB_COUNT { + if blob_hashes.len() > max_blobs_per_block(self.env.spec_id) { return Err(VMError::TxValidation( TxValidationError::Type3TxBlobCountExceeded, )); From 5602e210032e50f8bb041f80d6e7fec299bb41f1 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 11:05:07 -0300 Subject: [PATCH 06/24] Revert "Update value" This reverts commit 63967788ad7252ca3b0576f92241b0e731f4a9c8. --- crates/blockchain/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/blockchain/constants.rs b/crates/blockchain/constants.rs index 29abd42bf..651c0b038 100644 --- a/crates/blockchain/constants.rs +++ b/crates/blockchain/constants.rs @@ -45,7 +45,7 @@ pub const GAS_PER_BLOB: u64 = 1 << 17; pub const TARGET_BLOB_GAS_PER_BLOCK: u64 = 393216; /// Target number of the blob per block. -pub const TARGET_BLOB_NUMBER_PER_BLOCK: u64 = 6; +pub const TARGET_BLOB_NUMBER_PER_BLOCK: u64 = 3; /// Max number of blobs per block pub const MAX_BLOB_NUMBER_PER_BLOCK: u64 = 2 * TARGET_BLOB_NUMBER_PER_BLOCK; From 57af4ed93e3b0cfc537e223bd49ae841f6ee4baf Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 11:22:24 -0300 Subject: [PATCH 07/24] Remove unused constant --- crates/vm/levm/src/constants.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index bac1f4556..6677b3c6a 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -45,7 +45,6 @@ pub mod create_opcode { } pub const VERSIONED_HASH_VERSION_KZG: u8 = 0x01; -pub const MAX_BLOB_NUMBER_PER_BLOCK: usize = 6; // Blob constants pub const TARGET_BLOB_GAS_PER_BLOCK: U256 = U256([393216, 0, 0, 0]); // TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB From f04ba079eddac39f7553e32d9ffbf294e1ac746b Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 11:59:05 -0300 Subject: [PATCH 08/24] Make MAX_BLOB_NUMBER_PER_BLOCK equal 6 rather than double TARGET_BLOB_NUMBER_PER_BLOCK --- crates/blockchain/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/blockchain/constants.rs b/crates/blockchain/constants.rs index 651c0b038..83ba57674 100644 --- a/crates/blockchain/constants.rs +++ b/crates/blockchain/constants.rs @@ -48,7 +48,7 @@ pub const TARGET_BLOB_GAS_PER_BLOCK: u64 = 393216; pub const TARGET_BLOB_NUMBER_PER_BLOCK: u64 = 3; /// Max number of blobs per block -pub const MAX_BLOB_NUMBER_PER_BLOCK: u64 = 2 * TARGET_BLOB_NUMBER_PER_BLOCK; +pub const MAX_BLOB_NUMBER_PER_BLOCK: u64 = 6; /// Maximum consumable blob gas for data blobs per block. pub const MAX_BLOB_GAS_PER_BLOCK: u64 = MAX_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB; From 589fd8cea3158e72bdef1b4beeb43536b8cb30fc Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 12:29:17 -0300 Subject: [PATCH 09/24] Move max_blobs_per_block to vm.rs --- crates/vm/levm/src/constants.rs | 8 -------- crates/vm/levm/src/vm.rs | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 6677b3c6a..3f088671a 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -70,11 +70,3 @@ pub const SET_CODE_DELEGATION_BYTES: [u8; 3] = [0xef, 0x01, 0x00]; pub const EIP7702_DELEGATED_CODE_LEN: usize = 23; pub const PER_AUTH_BASE_COST: u64 = 12500; pub const PER_EMPTY_ACCOUNT_COST: u64 = 25000; - -pub const fn max_blobs_per_block(specid: SpecId) -> usize { - match specid { - SpecId::PRAGUE => MAX_BLOB_COUNT_ELECTRA, - SpecId::PRAGUE_EOF => MAX_BLOB_COUNT_ELECTRA, - _ => MAX_BLOB_COUNT, - } -} diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index f91e84ea1..708d45441 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -1678,3 +1678,11 @@ fn eip7702_recover_address(auth_tuple: &AuthorizationTuple) -> Result usize { + match specid { + SpecId::PRAGUE => MAX_BLOB_COUNT_ELECTRA, + SpecId::PRAGUE_EOF => MAX_BLOB_COUNT_ELECTRA, + _ => MAX_BLOB_COUNT, + } +} From 7cdc8d51e35e5e056e1b20926c3a2e5dff4dca71 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 12:34:49 -0300 Subject: [PATCH 10/24] Remove unused SpecID import --- crates/vm/levm/src/constants.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 3f088671a..84d80dadd 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -5,8 +5,6 @@ use k256::{ }; use std::sync::LazyLock; -use revm_primitives::SpecId; - pub const WORD_SIZE_IN_BYTES: U256 = U256([32, 0, 0, 0]); pub const WORD_SIZE_IN_BYTES_USIZE: usize = 32; pub const WORD_SIZE_IN_BYTES_U64: u64 = 32; From 47105299eeb61fd2c649edb5993a5e5a6b0def33 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 12:35:44 -0300 Subject: [PATCH 11/24] Add BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE --- crates/vm/levm/src/constants.rs | 1 + crates/vm/levm/src/vm.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 84d80dadd..11962a91d 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -48,6 +48,7 @@ pub const VERSIONED_HASH_VERSION_KZG: u8 = 0x01; pub const TARGET_BLOB_GAS_PER_BLOCK: U256 = U256([393216, 0, 0, 0]); // TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB pub const MIN_BASE_FEE_PER_BLOB_GAS: U256 = U256::one(); pub const BLOB_BASE_FEE_UPDATE_FRACTION: U256 = U256([3338477, 0, 0, 0]); +pub const BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE: U256 = U256([5007716, 0, 0, 0]); // Defined in [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691) pub const MAX_BLOB_COUNT: usize = 6; pub const MAX_BLOB_COUNT_ELECTRA: usize = 9; pub const VALID_BLOB_PREFIXES: [u8; 2] = [0x01, 0x02]; diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index dc0e5b09d..3a07db43f 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -1692,3 +1692,11 @@ pub const fn max_blobs_per_block(specid: SpecId) -> usize { _ => MAX_BLOB_COUNT, } } + +pub const fn blob_base_fee_update_fraction(specid: SpecId) -> U256 { + match specid { + SpecId::PRAGUE => BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE, + SpecId::PRAGUE_EOF => BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE, + _ => BLOB_BASE_FEE_UPDATE_FRACTION, + } +} From 4e6fe46584bbbad01ca273b474b69fd98968bc54 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 12:50:09 -0300 Subject: [PATCH 12/24] Add blob_base_fee_update_fraction to the get_base_fee_per_blob_gas function --- crates/vm/levm/src/vm.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index 3a07db43f..d2f89e424 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -741,7 +741,7 @@ impl VM { fake_exponential( MIN_BASE_FEE_PER_BLOB_GAS, self.env.block_excess_blob_gas.unwrap_or_default(), - BLOB_BASE_FEE_UPDATE_FRACTION, + blob_base_fee_update_fraction(self.env.spec_id), ) } @@ -1693,6 +1693,13 @@ pub const fn max_blobs_per_block(specid: SpecId) -> usize { } } +/// According to EIP-7691 +/// (https://eips.ethereum.org/EIPS/eip-7691#specification): +/// +/// "These changes imply that get_base_fee_per_blob_gas and +/// calc_excess_blob_gas functions defined in EIP-4844 use the new +/// values for the first block of the fork (and for all subsequent +/// blocks)." pub const fn blob_base_fee_update_fraction(specid: SpecId) -> U256 { match specid { SpecId::PRAGUE => BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE, From ab2bb718ee3972a032d9b11c1731ddae7903e281 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 12:56:24 -0300 Subject: [PATCH 13/24] Change get_blob_base_fee_update_fraction name --- crates/vm/levm/src/vm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index d2f89e424..349ee30c7 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -741,7 +741,7 @@ impl VM { fake_exponential( MIN_BASE_FEE_PER_BLOB_GAS, self.env.block_excess_blob_gas.unwrap_or_default(), - blob_base_fee_update_fraction(self.env.spec_id), + get_blob_base_fee_update_fraction_value(self.env.spec_id), ) } @@ -1700,7 +1700,7 @@ pub const fn max_blobs_per_block(specid: SpecId) -> usize { /// calc_excess_blob_gas functions defined in EIP-4844 use the new /// values for the first block of the fork (and for all subsequent /// blocks)." -pub const fn blob_base_fee_update_fraction(specid: SpecId) -> U256 { +pub const fn get_blob_base_fee_update_fraction_value(specid: SpecId) -> U256 { match specid { SpecId::PRAGUE => BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE, SpecId::PRAGUE_EOF => BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE, From af5bf01d024de77d8478e623d8dc3496b079d762 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:07:42 -0300 Subject: [PATCH 14/24] Add warning regarding the blob count constants --- crates/vm/levm/src/constants.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 11962a91d..4499baf6d 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -49,8 +49,12 @@ pub const TARGET_BLOB_GAS_PER_BLOCK: U256 = U256([393216, 0, 0, 0]); // TARGET_B pub const MIN_BASE_FEE_PER_BLOB_GAS: U256 = U256::one(); pub const BLOB_BASE_FEE_UPDATE_FRACTION: U256 = U256([3338477, 0, 0, 0]); pub const BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE: U256 = U256([5007716, 0, 0, 0]); // Defined in [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691) + +// WARNING: Do _not_ use the MAX_BLOB_COUNT_* family of constants as +// is. Use the `max_blobs_per_block` function instead pub const MAX_BLOB_COUNT: usize = 6; pub const MAX_BLOB_COUNT_ELECTRA: usize = 9; + pub const VALID_BLOB_PREFIXES: [u8; 2] = [0x01, 0x02]; // Block constants From 1595df9ee3442ff2c861cfc1669d3f20e329e4e7 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:20:36 -0300 Subject: [PATCH 15/24] Add another warning sign --- crates/vm/levm/src/constants.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 4499baf6d..1b0b941f8 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -47,6 +47,10 @@ pub const VERSIONED_HASH_VERSION_KZG: u8 = 0x01; // Blob constants pub const TARGET_BLOB_GAS_PER_BLOCK: U256 = U256([393216, 0, 0, 0]); // TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB pub const MIN_BASE_FEE_PER_BLOB_GAS: U256 = U256::one(); + +// WARNING: Do _not_ use the BLOB_BASE_FEE_UPDATE_FRACTION_* family of +// constants as is. Use the `get_blob_base_fee_update_fraction_value` +// function instead pub const BLOB_BASE_FEE_UPDATE_FRACTION: U256 = U256([3338477, 0, 0, 0]); pub const BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE: U256 = U256([5007716, 0, 0, 0]); // Defined in [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691) From 838ded7299d1094d6bc6cf97770b50fa4c57bb7b Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:29:58 -0300 Subject: [PATCH 16/24] Add comment explaining why this function has to be changed in the future --- crates/common/types/block.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/common/types/block.rs b/crates/common/types/block.rs index fb4b3eaf9..6e62bd338 100644 --- a/crates/common/types/block.rs +++ b/crates/common/types/block.rs @@ -340,7 +340,14 @@ fn check_gas_limit(gas_limit: u64, parent_gas_limit: u64) -> bool { && gas_limit >= GAS_LIMIT_MINIMUM } -// Calculates the base fee per blob gas for the current block based on it's parent excess blob gas +/// Calculates the base fee per blob gas for the current block based on +/// it's parent excess blob gas. +/// WARNING: BLOB_BASE_FEE_UPDATE_FRACTION has a different value after +/// prague. See +/// [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691#specification). +/// +/// A function named `get_blob_base_fee_update_fraction_value` exists +/// to use the correct value accordingly. pub fn calculate_base_fee_per_blob_gas(parent_excess_blob_gas: u64) -> u64 { fake_exponential( MIN_BASE_FEE_PER_BLOB_GAS, From bb86fea4f01cceabd21294f6b5329dc96723849a Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:36:28 -0300 Subject: [PATCH 17/24] Change comment for calculate_base_fee_per_blob_gas --- crates/common/types/block.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/common/types/block.rs b/crates/common/types/block.rs index 6e62bd338..eb98b5888 100644 --- a/crates/common/types/block.rs +++ b/crates/common/types/block.rs @@ -342,12 +342,9 @@ fn check_gas_limit(gas_limit: u64, parent_gas_limit: u64) -> bool { /// Calculates the base fee per blob gas for the current block based on /// it's parent excess blob gas. -/// WARNING: BLOB_BASE_FEE_UPDATE_FRACTION has a different value after -/// prague. See +/// NOTE: BLOB_BASE_FEE_UPDATE_FRACTION has a different value after +/// prague fork. See /// [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691#specification). -/// -/// A function named `get_blob_base_fee_update_fraction_value` exists -/// to use the correct value accordingly. pub fn calculate_base_fee_per_blob_gas(parent_excess_blob_gas: u64) -> u64 { fake_exponential( MIN_BASE_FEE_PER_BLOB_GAS, From 2520586388c79cde57c151c8c31f7bd6ba400095 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:46:10 -0300 Subject: [PATCH 18/24] Add the new value for target blob gas per block pectra --- crates/vm/levm/src/constants.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/vm/levm/src/constants.rs b/crates/vm/levm/src/constants.rs index 1b0b941f8..02cd6d591 100644 --- a/crates/vm/levm/src/constants.rs +++ b/crates/vm/levm/src/constants.rs @@ -46,6 +46,8 @@ pub const VERSIONED_HASH_VERSION_KZG: u8 = 0x01; // Blob constants pub const TARGET_BLOB_GAS_PER_BLOCK: U256 = U256([393216, 0, 0, 0]); // TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB +pub const TARGET_BLOB_GAS_PER_BLOCK_PECTRA: U256 = U256([786432, 0, 0, 0]); // TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB + pub const MIN_BASE_FEE_PER_BLOB_GAS: U256 = U256::one(); // WARNING: Do _not_ use the BLOB_BASE_FEE_UPDATE_FRACTION_* family of From 812b37b658d9379ea5af034c00cc29d6c7654ead Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:52:00 -0300 Subject: [PATCH 19/24] Mark EIP 7691 as resolved with this PR. --- crates/vm/levm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vm/levm/README.md b/crates/vm/levm/README.md index f2290ba77..d2453071b 100644 --- a/crates/vm/levm/README.md +++ b/crates/vm/levm/README.md @@ -84,7 +84,7 @@ There are a lot of EIPs schedule to include in this upgrade but for `levm` we'll | ------------------------- | ------ | | Implement EIP-2537 | ✅ | | Implement EIP-7623 | ✅ | -| Implement EIP-7691 | 🏗️ | +| Implement EIP-7691 | ✅️ | | Implement EIP-7702 | ✅️ | | Make Prague EF tests pass | ❌ | From 3c954e41d0d75029fee33e4af2f4f8c0a1c4cc02 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:53:03 -0300 Subject: [PATCH 20/24] Revert "Make MAX_BLOB_NUMBER_PER_BLOCK equal 6 rather than double TARGET_BLOB_NUMBER_PER_BLOCK" This reverts commit f04ba079eddac39f7553e32d9ffbf294e1ac746b. --- crates/blockchain/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/blockchain/constants.rs b/crates/blockchain/constants.rs index 83ba57674..651c0b038 100644 --- a/crates/blockchain/constants.rs +++ b/crates/blockchain/constants.rs @@ -48,7 +48,7 @@ pub const TARGET_BLOB_GAS_PER_BLOCK: u64 = 393216; pub const TARGET_BLOB_NUMBER_PER_BLOCK: u64 = 3; /// Max number of blobs per block -pub const MAX_BLOB_NUMBER_PER_BLOCK: u64 = 6; +pub const MAX_BLOB_NUMBER_PER_BLOCK: u64 = 2 * TARGET_BLOB_NUMBER_PER_BLOCK; /// Maximum consumable blob gas for data blobs per block. pub const MAX_BLOB_GAS_PER_BLOCK: u64 = MAX_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB; From d2e4b85af20cc6a5ca231ed423e52e5cc06c9ef5 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 14:56:03 -0300 Subject: [PATCH 21/24] Add comment explaining why the function exists --- crates/vm/levm/src/vm.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index 349ee30c7..ebf8ca675 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -1685,6 +1685,9 @@ fn eip7702_recover_address(auth_tuple: &AuthorizationTuple) -> Result usize { match specid { SpecId::PRAGUE => MAX_BLOB_COUNT_ELECTRA, From 0b3d3103ad4b2459bdb43b99e64d829e517fad78 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 15:00:56 -0300 Subject: [PATCH 22/24] Update prague EF tests state --- crates/vm/levm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vm/levm/README.md b/crates/vm/levm/README.md index d2453071b..dcc8234d8 100644 --- a/crates/vm/levm/README.md +++ b/crates/vm/levm/README.md @@ -86,7 +86,7 @@ There are a lot of EIPs schedule to include in this upgrade but for `levm` we'll | Implement EIP-7623 | ✅ | | Implement EIP-7691 | ✅️ | | Implement EIP-7702 | ✅️ | -| Make Prague EF tests pass | ❌ | +| Make Prague EF tests pass | ✅ | ### Milestone 5: Integrate `ethrex L2` <> `levm` From d5e5280d7d5ebdf6b100ffea1c72f532d77ba671 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 15:12:17 -0300 Subject: [PATCH 23/24] Add EIP-7691 to the list of EIP's to include --- crates/vm/levm/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/vm/levm/README.md b/crates/vm/levm/README.md index dcc8234d8..9f6b1182a 100644 --- a/crates/vm/levm/README.md +++ b/crates/vm/levm/README.md @@ -78,6 +78,7 @@ There are a lot of EIPs schedule to include in this upgrade but for `levm` we'll - EIP-2537: Precompile for BLS12-381 curve operations - EIP-7623: Increase calldata cost +- EIP-7691: Blob throughput increase - EIP-7702: Set EOA account code | Task Description | Status | From a102aab500e1d2010068045ca8f6042a45da2c42 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 23 Jan 2025 15:28:00 -0300 Subject: [PATCH 24/24] Add prague as a supported fork in the LEVM roadmap --- crates/vm/levm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vm/levm/README.md b/crates/vm/levm/README.md index 9f6b1182a..bb8c2e302 100644 --- a/crates/vm/levm/README.md +++ b/crates/vm/levm/README.md @@ -6,7 +6,7 @@ Implementation of a simple Ethereum Virtual Machine in Rust. | Fork | Status | | -------------- | ------ | -| Prague | 🏗️ | +| Prague | ✅️ | | Cancun | ✅ | | Shanghai | ✅ | | Paris (Merge) | ✅ |