diff --git a/Cargo.lock b/Cargo.lock index 6e00d3cd..f72ca479 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11662,7 +11662,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tips-core" version = "0.1.0" -source = "git+https://github.com/base/tips?rev=98c9ab49419e62352fe29cf79873141aaa3eb956#98c9ab49419e62352fe29cf79873141aaa3eb956" +source = "git+https://github.com/base/tips?rev=a21ee492dede17f31eea108c12c669a8190f31aa#a21ee492dede17f31eea108c12c669a8190f31aa" dependencies = [ "alloy-consensus", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index f50fbb15..c94ed8d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/crates/metering/src/meter.rs b/crates/metering/src/meter.rs index c9236201..9a8bff0b 100644 --- a/crates/metering/src/meter.rs +++ b/crates/metering/src/meter.rs @@ -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, }); } diff --git a/crates/metering/src/rpc.rs b/crates/metering/src/rpc.rs index 31bd2616..345940d4 100644 --- a/crates/metering/src/rpc.rs +++ b/crates/metering/src/rpc.rs @@ -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!( @@ -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, diff --git a/crates/metering/src/tests/meter.rs b/crates/metering/src/tests/meter.rs index d861eb40..b34f4e48 100644 --- a/crates/metering/src/tests/meter.rs +++ b/crates/metering/src/tests/meter.rs @@ -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)); @@ -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); diff --git a/crates/metering/src/tests/rpc.rs b/crates/metering/src/tests/rpc.rs index 5d630628..2b2065f8 100644 --- a/crates/metering/src/tests/rpc.rs +++ b/crates/metering/src/tests/rpc.rs @@ -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(()) @@ -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(()) @@ -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(()) } @@ -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(()) }