Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2239cce
start adding support for more tests
JereSalo Oct 7, 2025
f0a35b0
add more fork variants and dont return error if expected exception do…
JereSalo Oct 7, 2025
dccc615
add support for post state hash
JereSalo Oct 7, 2025
1ec79df
comment tests we dont want to run
JereSalo Oct 7, 2025
2455583
improve some comments
JereSalo Oct 7, 2025
e770f54
rename network to fork
JereSalo Oct 7, 2025
86c50b5
remove unnecessary checks
JereSalo Oct 7, 2025
dbe4eb8
typo
JereSalo Oct 7, 2025
163d91c
remove unnecessary code
JereSalo Oct 7, 2025
5683de0
update gitignore
JereSalo Oct 7, 2025
05a0280
restore mistake i made
JereSalo Oct 7, 2025
934c8b8
vectors targets
JereSalo Oct 7, 2025
b31f222
refactor all.rs to make it prettier
JereSalo Oct 7, 2025
21f46c4
add some reasons for skipped tests
JereSalo Oct 7, 2025
219a252
add reasons of skipped tests
JereSalo Oct 7, 2025
cd220b9
change comment in createBlobhashTx test
JereSalo Oct 7, 2025
2dbeb13
add comment
JereSalo Oct 7, 2025
965f493
Update tooling/ef_tests/blockchain/tests/all.rs
JereSalo Oct 8, 2025
a1b90fb
Update tooling/ef_tests/blockchain/fork.rs
JereSalo Oct 8, 2025
7d454f9
update comment
JereSalo Oct 8, 2025
0821ac7
merge changes from other branch
JereSalo Oct 8, 2025
b9f4354
fix skipped tests in stateless execution
JereSalo Oct 8, 2025
7822ca4
add extra skips to sp1
JereSalo Oct 8, 2025
6da2845
add comment
JereSalo Oct 8, 2025
28e7c15
Merge branch 'main' into support_blockchain_tests
JereSalo Oct 9, 2025
4cb5194
let chains lint
JereSalo Oct 9, 2025
7c29b20
initial changes
JereSalo Oct 9, 2025
399b8e5
add a comment
JereSalo Oct 9, 2025
c9891d1
uncomment commented test
JereSalo Oct 9, 2025
259dbe5
remove highgaspriceparis from commented tests
JereSalo Oct 9, 2025
822d5ec
merge main
JereSalo Oct 9, 2025
83a34ac
merge other branch
JereSalo Oct 9, 2025
a63a566
update comments
JereSalo Oct 9, 2025
1f67670
Merge branch 'main' into skipped_tests_reason
JereSalo Oct 9, 2025
73db0b9
Merge branch 'skipped_tests_reason' into change_gas_price_bits
JereSalo Oct 9, 2025
f79848c
remove skipped test of gas price
JereSalo Oct 13, 2025
0ea244e
merge main
JereSalo Oct 15, 2025
e6fe454
merge main
JereSalo Oct 15, 2025
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
62 changes: 32 additions & 30 deletions crates/common/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ impl RLPDecode for WrappedEIP4844Transaction {
#[derive(Clone, Debug, PartialEq, Eq, Default, RSerialize, RDeserialize, Archive)]
pub struct LegacyTransaction {
pub nonce: u64,
pub gas_price: u64,
#[rkyv(with=crate::rkyv_utils::U256Wrapper)]
pub gas_price: U256,
pub gas: u64,
/// The recipient of the transaction.
/// Create transactions contain a [`null`](RLP_NULL) value in this field.
Expand All @@ -186,7 +187,8 @@ pub struct LegacyTransaction {
pub struct EIP2930Transaction {
pub chain_id: u64,
pub nonce: u64,
pub gas_price: u64,
#[rkyv(with=crate::rkyv_utils::U256Wrapper)]
pub gas_price: U256,
pub gas_limit: u64,
pub to: TxKind,
#[rkyv(with=crate::rkyv_utils::U256Wrapper)]
Expand Down Expand Up @@ -351,20 +353,19 @@ impl Transaction {
}
}

fn calc_effective_gas_price(&self, base_fee_per_gas: Option<u64>) -> Option<u64> {
if self.max_fee_per_gas()? < base_fee_per_gas? {
fn calc_effective_gas_price(&self, base_fee_per_gas: Option<u64>) -> Option<U256> {
let base_fee = base_fee_per_gas?;
let max_fee = self.max_fee_per_gas()?;
if max_fee < base_fee {
// This is invalid, can't calculate
return None;
}

let priority_fee_per_gas = min(
self.max_priority_fee()?,
self.max_fee_per_gas()?.saturating_sub(base_fee_per_gas?),
);
Some(priority_fee_per_gas + base_fee_per_gas?)
let priority_fee_per_gas = min(self.max_priority_fee()?, max_fee.saturating_sub(base_fee));
Some(U256::from(priority_fee_per_gas) + U256::from(base_fee))
}

pub fn effective_gas_price(&self, base_fee_per_gas: Option<u64>) -> Option<u64> {
pub fn effective_gas_price(&self, base_fee_per_gas: Option<u64>) -> Option<U256> {
match self.tx_type() {
TxType::Legacy => Some(self.gas_price()),
TxType::EIP2930 => Some(self.gas_price()),
Expand All @@ -379,14 +380,14 @@ impl Transaction {
let price = match self.tx_type() {
TxType::Legacy => self.gas_price(),
TxType::EIP2930 => self.gas_price(),
TxType::EIP1559 => self.max_fee_per_gas()?,
TxType::EIP4844 => self.max_fee_per_gas()?,
TxType::EIP7702 => self.max_fee_per_gas()?,
TxType::EIP1559 => U256::from(self.max_fee_per_gas()?),
TxType::EIP4844 => U256::from(self.max_fee_per_gas()?),
TxType::EIP7702 => U256::from(self.max_fee_per_gas()?),
TxType::Privileged => self.gas_price(),
};

Some(U256::saturating_add(
U256::saturating_mul(price.into(), self.gas_limit().into()),
U256::saturating_mul(price, self.gas_limit().into()),
self.value(),
))
}
Expand Down Expand Up @@ -1067,14 +1068,15 @@ impl Transaction {
}
}

pub fn gas_price(&self) -> u64 {
//TODO: It's not very correct to return gas price for legacy and eip-2930 txs but return the max fee per gas for the others, make necessary changes for it to be technically correct.
pub fn gas_price(&self) -> U256 {
match self {
Transaction::LegacyTransaction(tx) => tx.gas_price,
Transaction::EIP2930Transaction(tx) => tx.gas_price,
Transaction::EIP1559Transaction(tx) => tx.max_fee_per_gas,
Transaction::EIP7702Transaction(tx) => tx.max_fee_per_gas,
Transaction::EIP4844Transaction(tx) => tx.max_fee_per_gas,
Transaction::PrivilegedL2Transaction(tx) => tx.max_fee_per_gas,
Transaction::EIP1559Transaction(tx) => U256::from(tx.max_fee_per_gas),
Transaction::EIP7702Transaction(tx) => U256::from(tx.max_fee_per_gas),
Transaction::EIP4844Transaction(tx) => U256::from(tx.max_fee_per_gas),
Transaction::PrivilegedL2Transaction(tx) => U256::from(tx.max_fee_per_gas),
}
}

Expand Down Expand Up @@ -1236,11 +1238,11 @@ impl Transaction {
}

pub fn gas_tip_cap(&self) -> u64 {
self.max_priority_fee().unwrap_or(self.gas_price())
self.max_priority_fee().unwrap_or(self.gas_price().as_u64())
}

pub fn gas_fee_cap(&self) -> u64 {
self.max_fee_per_gas().unwrap_or(self.gas_price())
self.max_fee_per_gas().unwrap_or(self.gas_price().as_u64())
}

pub fn effective_gas_tip(&self, base_fee: Option<u64>) -> Option<u64> {
Expand Down Expand Up @@ -1941,7 +1943,7 @@ mod serde_impl {

Ok(LegacyTransaction {
nonce: deserialize_field::<U256, D>(&mut map, "nonce")?.as_u64(),
gas_price: deserialize_field::<U256, D>(&mut map, "gasPrice")?.as_u64(),
gas_price: deserialize_field::<U256, D>(&mut map, "gasPrice")?,
gas: deserialize_field::<U256, D>(&mut map, "gas")?.as_u64(),
to: deserialize_field::<TxKind, D>(&mut map, "to")?,
value: deserialize_field::<U256, D>(&mut map, "value")?,
Expand All @@ -1964,7 +1966,7 @@ mod serde_impl {
Ok(EIP2930Transaction {
chain_id: deserialize_field::<U256, D>(&mut map, "chainId")?.as_u64(),
nonce: deserialize_field::<U256, D>(&mut map, "nonce")?.as_u64(),
gas_price: deserialize_field::<U256, D>(&mut map, "gasPrice")?.as_u64(),
gas_price: deserialize_field::<U256, D>(&mut map, "gasPrice")?,
gas_limit: deserialize_field::<U256, D>(&mut map, "gas")?.as_u64(),
to: deserialize_field::<TxKind, D>(&mut map, "to")?,
value: deserialize_field::<U256, D>(&mut map, "value")?,
Expand Down Expand Up @@ -2452,7 +2454,7 @@ mod serde_impl {
from: Address::default(),
gas: Some(value.gas),
value: value.value,
gas_price: value.gas_price,
gas_price: value.gas_price.as_u64(),
max_priority_fee_per_gas: None,
max_fee_per_gas: None,
max_fee_per_blob_gas: None,
Expand All @@ -2475,7 +2477,7 @@ mod serde_impl {
from: Address::default(),
gas: Some(value.gas_limit),
value: value.value,
gas_price: value.gas_price,
gas_price: value.gas_price.as_u64(),
max_priority_fee_per_gas: None,
max_fee_per_gas: None,
max_fee_per_blob_gas: None,
Expand Down Expand Up @@ -2626,7 +2628,7 @@ mod tests {
let mut body = BlockBody::empty();
let tx = LegacyTransaction {
nonce: 0,
gas_price: 0x0a,
gas_price: U256::from(0x0a),
gas: 0x05f5e100,
to: TxKind::Call(hex!("1000000000000000000000000000000000000000").into()),
value: 0.into(),
Expand All @@ -2653,7 +2655,7 @@ mod tests {
let tx_eip2930 = EIP2930Transaction {
chain_id: 3503995874084926u64,
nonce: 7,
gas_price: 0x2dbf1f9a,
gas_price: U256::from(0x2dbf1f9a_u64),
gas_limit: 0x186A0,
to: TxKind::Call(hex!("7dcd17433742f4c0ca53122ab541d0ba67fc27df").into()),
value: 2.into(),
Expand Down Expand Up @@ -2707,7 +2709,7 @@ mod tests {
let tx = LegacyTransaction::decode(&encoded_tx_bytes).unwrap();
let expected_tx = LegacyTransaction {
nonce: 0,
gas_price: 1001000000,
gas_price: U256::from(1001000000u64),
gas: 63000,
to: TxKind::Call(Address::from_slice(
&hex::decode("6177843db3138ae69679A54b95cf345ED759450d").unwrap(),
Expand Down Expand Up @@ -3065,7 +3067,7 @@ mod tests {
fn test_legacy_transaction_into_generic() {
let legacy_tx = LegacyTransaction {
nonce: 1,
gas_price: 20_000_000_000,
gas_price: U256::from(20_000_000_000u64),
gas: 21000,
to: TxKind::Call(
Address::from_str("0x742d35Cc6634C0532925a3b844Bc454e4438f44e").unwrap(),
Expand Down Expand Up @@ -3104,7 +3106,7 @@ mod tests {
let eip2930_tx = EIP2930Transaction {
chain_id: 1,
nonce: 1,
gas_price: 20_000_000_000,
gas_price: U256::from(20_000_000_000u64),
gas_limit: 21000,
to: TxKind::Call(
Address::from_str("0x742d35Cc6634C0532925a3b844Bc454e4438f44e").unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion crates/networking/rpc/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub mod test_utils {
fn legacy_tx_for_test(nonce: u64) -> Transaction {
Transaction::LegacyTransaction(LegacyTransaction {
nonce,
gas_price: nonce * BASE_PRICE_IN_WEI,
gas_price: U256::from(nonce) * U256::from(BASE_PRICE_IN_WEI),
gas: 10000,
to: TxKind::Create,
value: 100.into(),
Expand Down
12 changes: 6 additions & 6 deletions crates/networking/rpc/types/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ impl RpcReceiptTxInfo {
let nonce = transaction.nonce();
let from = transaction.sender()?;
let transaction_hash = transaction.hash();
let effective_gas_price =
transaction
.effective_gas_price(base_fee_per_gas)
.ok_or(RpcErr::Internal(
"Could not get effective gas price from tx".into(),
))?;
let effective_gas_price = transaction
.effective_gas_price(base_fee_per_gas)
.ok_or(RpcErr::Internal(
"Could not get effective gas price from tx".into(),
))?
.as_u64();
let transaction_index = index;
let (blob_gas_price, blob_gas_used) = match &transaction {
Transaction::EIP4844Transaction(tx) => (
Expand Down
3 changes: 1 addition & 2 deletions crates/vm/backends/levm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ impl LEVM {
.effective_gas_price(block_header.base_fee_per_gas)
.ok_or(VMError::TxValidation(
TxValidationError::InsufficientMaxFeePerGas,
))?
.into();
))?;

let config = EVMConfig::new_from_chain_config(&chain_config, block_header);
let env = Environment {
Expand Down
2 changes: 1 addition & 1 deletion crates/vm/levm/runner/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl From<InputTransaction> for ethrex_common::types::LegacyTransaction {
fn from(tx: InputTransaction) -> Self {
ethrex_common::types::LegacyTransaction {
nonce: 0,
gas_price: tx.gas_price.try_into().unwrap(),
gas_price: tx.gas_price,
gas: tx.gas_limit,
to: match tx.to {
Some(address) => ethrex_common::types::TxKind::Call(address),
Expand Down
2 changes: 0 additions & 2 deletions tooling/ef_tests/blockchain/tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const SKIPPED_BASE: &[&str] = &[
"static_Call50000_sha256",
"CALLBlake2f_MaxRounds",
"loopMul",
// Gas price higher than u64::MAX; impractical scenario. Fix is on its way on https://github.com/lambdaclass/ethrex/pull/4823
"HighGasPriceParis",
// Skip because it tries to deserialize number > U256::MAX
"ValueOverflowParis",
// Skip because it's a "Create" Blob Transaction, which doesn't actually exist. It never reaches the EVM because we can't even parse it as an actual Transaction.
Expand Down
4 changes: 2 additions & 2 deletions tooling/ef_tests/blockchain/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl From<Transaction> for LegacyTransaction {
fn from(val: Transaction) -> Self {
LegacyTransaction {
nonce: val.nonce.as_u64(),
gas_price: val.gas_price.unwrap_or_default().as_u64(), // TODO: Consider converting this into Option
gas_price: val.gas_price.unwrap_or_default(), // TODO: Consider converting this into Option
gas: val.gas_limit.as_u64(),
// to: match val.to {
// zero if zero == H160::zero() => TxKind::Create,
Expand All @@ -536,7 +536,7 @@ impl From<Transaction> for EIP2930Transaction {
EIP2930Transaction {
chain_id: val.chain_id.map(|id: U256| id.as_u64()).unwrap_or(1),
nonce: val.nonce.as_u64(),
gas_price: val.gas_price.unwrap_or_default().as_u64(),
gas_price: val.gas_price.unwrap_or_default(),
gas_limit: val.gas_limit.as_u64(),
// to: match val.to {
// zero if zero == H160::zero() => TxKind::Create,
Expand Down
4 changes: 2 additions & 2 deletions tooling/ef_tests/state_v2/src/modules/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub async fn get_tx_from_test_case(test_case: &TestCase) -> Result<Transaction,
Transaction::EIP2930Transaction(EIP2930Transaction {
chain_id,
nonce,
gas_price: test_case.gas_price.unwrap().as_u64(),
gas_price: test_case.gas_price.unwrap(),
gas_limit: test_case.gas,
to,
value,
Expand All @@ -232,7 +232,7 @@ pub async fn get_tx_from_test_case(test_case: &TestCase) -> Result<Transaction,
} else {
Transaction::LegacyTransaction(LegacyTransaction {
nonce,
gas_price: test_case.gas_price.unwrap().as_u64(),
gas_price: test_case.gas_price.unwrap(),
gas: test_case.gas,
to,
value,
Expand Down
4 changes: 2 additions & 2 deletions tooling/migrations/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn migrate_transaction(tx: LibmdbxTransaction) -> Transaction {
LibmdbxTransaction::LegacyTransaction(tx) => {
Transaction::LegacyTransaction(LegacyTransaction {
nonce: tx.nonce,
gas_price: tx.gas_price,
gas_price: tx.gas_price.into(),
gas: tx.gas,
to: match tx.to {
LibmdbxTxKind::Create => TxKind::Create,
Expand All @@ -100,7 +100,7 @@ pub fn migrate_transaction(tx: LibmdbxTransaction) -> Transaction {
Transaction::EIP2930Transaction(EIP2930Transaction {
chain_id: tx.chain_id,
nonce: tx.nonce,
gas_price: tx.gas_price,
gas_price: tx.gas_price.into(),
gas_limit: tx.gas_limit,
to: match tx.to {
LibmdbxTxKind::Create => TxKind::Create,
Expand Down