Skip to content

Commit

Permalink
Rename diff_size to l1_diff_size (#875)
Browse files Browse the repository at this point in the history
* Rename diff_size to l1_diff_size

* Fix lint
  • Loading branch information
yaziciahmet authored Jul 10, 2024
1 parent 6b2f52d commit 76d5646
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion bin/citrea/tests/evm/web3_py/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_get_transaction_receipt(self):
self.assertEqual(receipt['transactionHash'], self.first_tx_hash)
self.assertEqual(receipt['from'], "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266")
self.assertEqual(receipt['to'], "0x0000000000000000000000000000000000000000")
self.assertGreater(int(receipt['diffSize'], 16), 0)
self.assertGreater(int(receipt['l1DiffSize'], 16), 0)
self.assertGreater(int(receipt['l1FeeRate'], 16), 0)

def test_get_transaction_count(self):
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
},
gas_used: gas_used as u128,
log_index_start,
diff_size: tx_info.diff_size,
l1_diff_size: tx_info.l1_diff_size,
};
log_index_start += logs_len;

Expand Down Expand Up @@ -198,7 +198,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
},
gas_used: gas_used as u128,
log_index_start,
diff_size: tx_info.diff_size,
l1_diff_size: tx_info.l1_diff_size,
};
log_index_start += logs_len;

Expand Down
7 changes: 5 additions & 2 deletions crates/evm/src/evm/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{BASE_FEE_VAULT, L1_FEE_VAULT};

#[derive(Copy, Clone, Default, Debug)]
pub struct TxInfo {
pub diff_size: u64,
pub l1_diff_size: u64,
pub l1_fee: U256,
}

Expand Down Expand Up @@ -350,7 +350,10 @@ impl<SPEC: Spec, EXT: CitreaExternalExt, DB: Database> CitreaHandler<SPEC, EXT,
let diff_size = calc_diff_size(context).map_err(EVMError::Database)? as u64;
let l1_fee_rate = context.external.l1_fee_rate();
let l1_fee = U256::from(diff_size) * U256::from(l1_fee_rate);
context.external.set_tx_info(TxInfo { diff_size, l1_fee });
context.external.set_tx_info(TxInfo {
l1_diff_size: diff_size,
l1_fee,
});
if context.is_system_caller() {
// System caller doesn't pay L1 fee.
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/evm/primitive_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,5 @@ pub(crate) struct Receipt {
pub(crate) receipt: reth_primitives::Receipt,
pub(crate) gas_used: u128,
pub(crate) log_index_start: u64,
pub(crate) diff_size: u64,
pub(crate) l1_diff_size: u64,
}
20 changes: 10 additions & 10 deletions crates/evm/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub(crate) struct EstimatedTxExpenses {
/// L1 fee.
l1_fee: U256,
/// L1 diff size.
diff_size: u64,
l1_diff_size: u64,
}

impl EstimatedTxExpenses {
Expand All @@ -83,7 +83,7 @@ pub struct EstimatedDiffSize {
/// Gas used.
pub gas: U64,
/// Diff size.
pub diff_size: U64,
pub l1_diff_size: U64,
}

#[rpc_gen(client, server)]
Expand Down Expand Up @@ -929,7 +929,7 @@ impl<C: sov_modules_api::Context> Evm<C> {

Ok(EstimatedDiffSize {
gas: estimated.gas_used,
diff_size: U64::from(estimated.diff_size),
l1_diff_size: U64::from(estimated.l1_diff_size),
})
}

Expand Down Expand Up @@ -1024,7 +1024,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
gas_used: U64::from(MIN_TRANSACTION_GAS),
base_fee: env_base_fee,
l1_fee: tx_info.l1_fee,
diff_size: tx_info.diff_size,
l1_diff_size: tx_info.l1_diff_size,
});
}
}
Expand Down Expand Up @@ -1080,7 +1080,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
let (result, mut l1_fee, mut diff_size) = match result {
Ok((result, tx_info)) => match result.result {
ExecutionResult::Success { .. } => {
(result.result, tx_info.l1_fee, tx_info.diff_size)
(result.result, tx_info.l1_fee, tx_info.l1_diff_size)
}
ExecutionResult::Halt { reason, gas_used } => {
return Err(RpcInvalidTransactionError::halt(reason, gas_used).into())
Expand Down Expand Up @@ -1211,7 +1211,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
gas_used: U64::from(highest_gas_limit),
base_fee: env_base_fee,
l1_fee,
diff_size,
l1_diff_size: diff_size,
})
}

Expand Down Expand Up @@ -1666,8 +1666,8 @@ pub(crate) fn build_rpc_receipt(
format!("{:#x}", block.l1_fee_rate).into(),
),
(
"diffSize".into(),
format!("{:#x}", receipt.diff_size).into(),
"l1DiffSize".into(),
format!("{:#x}", receipt.l1_diff_size).into(),
),
]
.into_iter()
Expand Down Expand Up @@ -1788,14 +1788,14 @@ fn update_estimated_gas_range(
// cap the highest gas limit with succeeding gas limit
*highest_gas_limit = tx_gas_limit;
*l1_fee = tx_info.l1_fee;
*diff_size = tx_info.diff_size;
*diff_size = tx_info.l1_diff_size;
}
ExecutionResult::Revert { .. } => {
// increase the lowest gas limit
*lowest_gas_limit = tx_gas_limit;

*l1_fee = tx_info.l1_fee;
*diff_size = tx_info.diff_size;
*diff_size = tx_info.l1_diff_size;
}
ExecutionResult::Halt { reason, .. } => {
match reason {
Expand Down
18 changes: 9 additions & 9 deletions crates/evm/src/tests/call_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn call_multiple_test() {
},
gas_used: 132943,
log_index_start: 0,
diff_size: 565,
l1_diff_size: 565,
},
Receipt {
receipt: reth_primitives::Receipt {
Expand All @@ -121,7 +121,7 @@ fn call_multiple_test() {
},
gas_used: 43730,
log_index_start: 0,
diff_size: 220,
l1_diff_size: 220,
},
Receipt {
receipt: reth_primitives::Receipt {
Expand All @@ -132,7 +132,7 @@ fn call_multiple_test() {
},
gas_used: 26630,
log_index_start: 0,
diff_size: 220,
l1_diff_size: 220,
},
Receipt {
receipt: reth_primitives::Receipt {
Expand All @@ -143,7 +143,7 @@ fn call_multiple_test() {
},
gas_used: 26630,
log_index_start: 0,
diff_size: 220,
l1_diff_size: 220,
}
]
)
Expand Down Expand Up @@ -212,7 +212,7 @@ fn call_test() {
},
gas_used: 132943,
log_index_start: 0,
diff_size: 565,
l1_diff_size: 565,
},
Receipt {
receipt: reth_primitives::Receipt {
Expand All @@ -223,7 +223,7 @@ fn call_test() {
},
gas_used: 43730,
log_index_start: 0,
diff_size: 220,
l1_diff_size: 220,
}
]
)
Expand Down Expand Up @@ -894,7 +894,7 @@ fn test_l1_fee_success() {
},
gas_used: 114235,
log_index_start: 0,
diff_size: 477,
l1_diff_size: 477,
},]
)
}
Expand Down Expand Up @@ -1047,7 +1047,7 @@ fn test_l1_fee_halt() {
},
gas_used: 106947,
log_index_start: 0,
diff_size: 445,
l1_diff_size: 445,
},
Receipt {
receipt: reth_primitives::Receipt {
Expand All @@ -1058,7 +1058,7 @@ fn test_l1_fee_halt() {
},
gas_used: 1000000,
log_index_start: 0,
diff_size: 52,
l1_diff_size: 52,
},
]
);
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/tests/hooks_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn create_pending_transaction(hash: B256, index: u64) -> PendingTransaction {
},
gas_used: 100,
log_index_start: 0,
diff_size: 0,
l1_diff_size: 0,
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/evm/src/tests/queries/basic_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ fn check_against_third_block_receipts(receipts: Vec<AnyTransactionReceipt>) {
"from": "0x9e1abd37ec34bbc688b6a2b7d9387d9256cf1773",
"to": "0x819c5497b157177315e1204f52e588b393771719",
"l1FeeRate": "0x1",
"diffSize": "0x9c",
"l1DiffSize": "0x9c",
"contractAddress": null,
"logs": [
{
Expand Down Expand Up @@ -504,7 +504,7 @@ fn check_against_third_block_receipts(receipts: Vec<AnyTransactionReceipt>) {
"from": "0x9e1abd37ec34bbc688b6a2b7d9387d9256cf1773",
"to": "0x819c5497b157177315e1204f52e588b393771719",
"l1FeeRate": "0x1",
"diffSize": "0x9c",
"l1DiffSize": "0x9c",
"contractAddress": null,
"logs": [
{
Expand Down Expand Up @@ -555,7 +555,7 @@ fn check_against_third_block_receipts(receipts: Vec<AnyTransactionReceipt>) {
"from": "0x9e1abd37ec34bbc688b6a2b7d9387d9256cf1773",
"to": "0x819c5497b157177315e1204f52e588b393771719",
"l1FeeRate": "0x1",
"diffSize": "0x9c",
"l1DiffSize": "0x9c",
"contractAddress": null,
"logs": [
{
Expand Down Expand Up @@ -606,7 +606,7 @@ fn check_against_third_block_receipts(receipts: Vec<AnyTransactionReceipt>) {
"from": "0x9e1abd37ec34bbc688b6a2b7d9387d9256cf1773",
"to": "0x819c5497b157177315e1204f52e588b393771719",
"l1FeeRate": "0x1",
"diffSize": "0x9c",
"l1DiffSize": "0x9c",
"contractAddress": null,
"logs": [
{
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/tests/queries/estimate_gas_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn test_tx_request_fields_gas() {
);
assert_eq!(
contract_diff_size.unwrap(),
serde_json::from_value::<EstimatedDiffSize>(json![{"gas":"0x6601","diffSize":"0xdc"}])
serde_json::from_value::<EstimatedDiffSize>(json![{"gas":"0x6601","l1DiffSize":"0xdc"}])
.unwrap()
);

Expand Down
10 changes: 5 additions & 5 deletions crates/evm/src/tests/sys_tx_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn test_sys_bitcoin_light_client() {
},
gas_used: 48522,
log_index_start: 0,
diff_size: 168,
l1_diff_size: 168,
},
Receipt { // BitcoinLightClient::setBlockInfo(U256, U256)
receipt: reth_primitives::Receipt {
Expand All @@ -67,7 +67,7 @@ fn test_sys_bitcoin_light_client() {
},
gas_used: 78491,
log_index_start: 0,
diff_size: 296,
l1_diff_size: 296,
},
Receipt {
receipt: reth_primitives::Receipt {
Expand All @@ -93,7 +93,7 @@ fn test_sys_bitcoin_light_client() {
},
gas_used: 258971,
log_index_start: 1,
diff_size: 744,
l1_diff_size: 744,
}
]
);
Expand Down Expand Up @@ -201,7 +201,7 @@ fn test_sys_bitcoin_light_client() {
},
gas_used: 78491,
log_index_start: 0,
diff_size: 296,
l1_diff_size: 296,
},
Receipt {
receipt: reth_primitives::Receipt {
Expand All @@ -212,7 +212,7 @@ fn test_sys_bitcoin_light_client() {
},
gas_used: 114235,
log_index_start: 1,
diff_size: 477,
l1_diff_size: 477,
},
]
);
Expand Down

0 comments on commit 76d5646

Please sign in to comment.