Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ base-reth-transaction-tracing = { path = "crates/transaction-tracing" }

# base/tips
# Note: default-features = false avoids version conflicts with reth's alloy/op-alloy dependencies
tips-core = { git = "https://github.com/base/tips", rev = "98c9ab49419e62352fe29cf79873141aaa3eb956", default-features = false }
tips-core = { git = "https://github.com/base/tips", rev = "a21ee492dede17f31eea108c12c669a8190f31aa", default-features = false }

# reth
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.2" }
Expand Down
10 changes: 5 additions & 5 deletions crates/metering/src/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ where
let execution_time = tx_start.elapsed().as_micros();

results.push(TransactionResult {
coinbase_diff: gas_fees.to_string(),
eth_sent_to_coinbase: "0".to_string(),
coinbase_diff: gas_fees,
eth_sent_to_coinbase: U256::from(0),
from_address: from,
gas_fees: gas_fees.to_string(),
gas_price: gas_price.to_string(),
gas_fees,
gas_price: U256::from(gas_price),
gas_used,
to_address: to,
tx_hash,
value: value.to_string(),
value,
execution_time_us: execution_time,
});
}
Expand Down
10 changes: 5 additions & 5 deletions crates/metering/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ where

// Calculate average gas price
let bundle_gas_price = if total_gas_used > 0 {
(total_gas_fees / U256::from(total_gas_used)).to_string()
total_gas_fees / U256::from(total_gas_used)
} else {
"0".to_string()
U256::from(0)
};

info!(
Expand All @@ -129,9 +129,9 @@ where
Ok(MeterBundleResponse {
bundle_gas_price,
bundle_hash,
coinbase_diff: total_gas_fees.to_string(),
eth_sent_to_coinbase: "0".to_string(),
gas_fees: total_gas_fees.to_string(),
coinbase_diff: total_gas_fees,
eth_sent_to_coinbase: U256::from(0),
gas_fees: total_gas_fees,
results,
state_block_number: header.number,
state_flashblock_index: None,
Expand Down
12 changes: 6 additions & 6 deletions crates/metering/src/tests/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ fn meter_bundle_single_transaction() -> eyre::Result<()> {
assert_eq!(result.from_address, harness.address(User::Alice));
assert_eq!(result.to_address, Some(to));
assert_eq!(result.tx_hash, tx_hash);
assert_eq!(result.gas_price, U256::from(10).to_string());
assert_eq!(result.gas_price, U256::from(10));
assert_eq!(result.gas_used, 21_000);
assert_eq!(result.coinbase_diff, (U256::from(21_000) * U256::from(10)).to_string(),);
assert_eq!(result.coinbase_diff, (U256::from(21_000) * U256::from(10)),);

assert_eq!(total_gas_used, 21_000);
assert_eq!(total_gas_fees, U256::from(21_000) * U256::from(10));
Expand Down Expand Up @@ -265,18 +265,18 @@ fn meter_bundle_multiple_transactions() -> eyre::Result<()> {
assert_eq!(result_1.from_address, harness.address(User::Alice));
assert_eq!(result_1.to_address, Some(to_1));
assert_eq!(result_1.tx_hash, tx_hash_1);
assert_eq!(result_1.gas_price, U256::from(10).to_string());
assert_eq!(result_1.gas_price, U256::from(10));
assert_eq!(result_1.gas_used, 21_000);
assert_eq!(result_1.coinbase_diff, (U256::from(21_000) * U256::from(10)).to_string(),);
assert_eq!(result_1.coinbase_diff, (U256::from(21_000) * U256::from(10)),);

// Check second transaction
let result_2 = &results[1];
assert_eq!(result_2.from_address, harness.address(User::Bob));
assert_eq!(result_2.to_address, Some(to_2));
assert_eq!(result_2.tx_hash, tx_hash_2);
assert_eq!(result_2.gas_price, U256::from(15).to_string());
assert_eq!(result_2.gas_price, U256::from(15));
assert_eq!(result_2.gas_used, 21_000);
assert_eq!(result_2.coinbase_diff, (U256::from(21_000) * U256::from(15)).to_string(),);
assert_eq!(result_2.coinbase_diff, U256::from(21_000) * U256::from(15),);

// Check aggregated values
assert_eq!(total_gas_used, 42_000);
Expand Down
26 changes: 13 additions & 13 deletions crates/metering/src/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ mod tests {

assert_eq!(response.results.len(), 0);
assert_eq!(response.total_gas_used, 0);
assert_eq!(response.gas_fees, "0");
assert_eq!(response.gas_fees, U256::from(0));
assert_eq!(response.state_block_number, 0);

Ok(())
Expand Down Expand Up @@ -168,7 +168,7 @@ mod tests {
assert_eq!(result.from_address, sender_address);
assert_eq!(result.to_address, Some(address!("0x1111111111111111111111111111111111111111")));
assert_eq!(result.gas_used, 21_000);
assert_eq!(result.gas_price, "1000000000");
assert_eq!(result.gas_price, 1_000_000_000);
assert!(result.execution_time_us > 0);

Ok(())
Expand Down Expand Up @@ -236,13 +236,13 @@ mod tests {
let result1 = &response.results[0];
assert_eq!(result1.from_address, address1);
assert_eq!(result1.gas_used, 21_000);
assert_eq!(result1.gas_price, "1000000000");
assert_eq!(result1.gas_price, 1_000_000_000);

// Check second transaction
let result2 = &response.results[1];
assert_eq!(result2.from_address, address2);
assert_eq!(result2.gas_used, 21_000);
assert_eq!(result2.gas_price, "2000000000");
assert_eq!(result2.gas_price, 2_000_000_000);

Ok(())
}
Expand Down Expand Up @@ -408,25 +408,25 @@ mod tests {
// Check first transaction (3 gwei)
let result1 = &response.results[0];
let expected_gas_fees_1 = U256::from(21_000) * U256::from(3_000_000_000u64);
assert_eq!(result1.gas_fees, expected_gas_fees_1.to_string());
assert_eq!(result1.gas_price, "3000000000");
assert_eq!(result1.coinbase_diff, expected_gas_fees_1.to_string());
assert_eq!(result1.gas_fees, expected_gas_fees_1);
assert_eq!(result1.gas_price, U256::from(3000000000u64));
assert_eq!(result1.coinbase_diff, expected_gas_fees_1);

// Check second transaction (7 gwei)
let result2 = &response.results[1];
let expected_gas_fees_2 = U256::from(21_000) * U256::from(7_000_000_000u64);
assert_eq!(result2.gas_fees, expected_gas_fees_2.to_string());
assert_eq!(result2.gas_price, "7000000000");
assert_eq!(result2.coinbase_diff, expected_gas_fees_2.to_string());
assert_eq!(result2.gas_fees, expected_gas_fees_2);
assert_eq!(result2.gas_price, U256::from(7000000000u64));
assert_eq!(result2.coinbase_diff, expected_gas_fees_2);

// Check bundle totals
let total_gas_fees = expected_gas_fees_1 + expected_gas_fees_2;
assert_eq!(response.gas_fees, total_gas_fees.to_string());
assert_eq!(response.coinbase_diff, total_gas_fees.to_string());
assert_eq!(response.gas_fees, total_gas_fees);
assert_eq!(response.coinbase_diff, total_gas_fees);
assert_eq!(response.total_gas_used, 42_000);

// Bundle gas price should be weighted average: (3*21000 + 7*21000) / (21000 + 21000) = 5 gwei
assert_eq!(response.bundle_gas_price, "5000000000");
assert_eq!(response.bundle_gas_price, U256::from(5000000000u64));

Ok(())
}
Expand Down