diff --git a/bin/protoc b/bin/protoc new file mode 100755 index 000000000..04c229706 Binary files /dev/null and b/bin/protoc differ diff --git a/crates/papyrus_execution/src/objects.rs b/crates/papyrus_execution/src/objects.rs index 78dcb0c71..ed91050c6 100644 --- a/crates/papyrus_execution/src/objects.rs +++ b/crates/papyrus_execution/src/objects.rs @@ -97,6 +97,10 @@ pub struct FeeEstimation { pub data_gas_consumed: Felt, /// The gas price for DA blob. pub data_gas_price: GasPrice, + // TODO(Tzahi): Add l2_gas_consumed. Verify overall_fee estimation of l1_gas_price only is + // close enough (as there are roundings) to the fee of both l1_gas_price and l2_gas_price. + /// The L2 gas price for execution. + pub l2_gas_price: GasPrice, /// The total amount of fee. This is equal to: /// gas_consumed * gas_price + data_gas_consumed * data_gas_price. pub overall_fee: Fee, @@ -153,7 +157,7 @@ pub(crate) fn tx_execution_output_to_fee_estimation( block_context: &BlockContext, ) -> ExecutionResult { let gas_prices = &block_context.block_info().gas_prices; - let (gas_price, data_gas_price) = ( + let (l1_gas_price, l1_data_gas_price, l2_gas_price) = ( GasPrice( gas_prices.get_l1_gas_price_by_fee_type(&tx_execution_output.price_unit.into()).get(), ), @@ -162,15 +166,19 @@ pub(crate) fn tx_execution_output_to_fee_estimation( .get_l1_data_gas_price_by_fee_type(&tx_execution_output.price_unit.into()) .get(), ), + GasPrice( + gas_prices.get_l2_gas_price_by_fee_type(&tx_execution_output.price_unit.into()).get(), + ), ); let gas_vector = tx_execution_output.execution_info.receipt.gas; Ok(FeeEstimation { gas_consumed: gas_vector.l1_gas.into(), - gas_price, + gas_price: l1_gas_price, data_gas_consumed: gas_vector.l1_data_gas.into(), - data_gas_price, + data_gas_price: l1_data_gas_price, + l2_gas_price, overall_fee: tx_execution_output.execution_info.receipt.fee, unit: tx_execution_output.price_unit, }) diff --git a/crates/papyrus_execution/src/testing_instances.rs b/crates/papyrus_execution/src/testing_instances.rs index af53c859b..6f4867cc5 100644 --- a/crates/papyrus_execution/src/testing_instances.rs +++ b/crates/papyrus_execution/src/testing_instances.rs @@ -69,6 +69,7 @@ auto_impl_get_test_instance! { pub gas_price: GasPrice, pub data_gas_consumed: Felt, pub data_gas_price: GasPrice, + pub l2_gas_price: GasPrice, pub overall_fee: Fee, pub unit: PriceUnit, } diff --git a/crates/papyrus_rpc/src/v0_8/execution_test.rs b/crates/papyrus_rpc/src/v0_8/execution_test.rs index e3320dd16..3a380c3ce 100644 --- a/crates/papyrus_rpc/src/v0_8/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_8/execution_test.rs @@ -153,10 +153,15 @@ lazy_static! { price_in_wei: GasPrice(100 * u128::pow(10, 9)), price_in_fri: GasPrice(0), }; + //TODO: Tests for data_gas_price and l2_gas_price. pub static ref DATA_GAS_PRICE: GasPricePerToken = GasPricePerToken{ price_in_wei: GasPrice(1), price_in_fri: GasPrice(0), }; + pub static ref L2_GAS_PRICE: GasPricePerToken = GasPricePerToken{ + price_in_wei: GasPrice(1), + price_in_fri: GasPrice(0), + }; pub static ref MAX_FEE: Fee = Fee(1000000 * GAS_PRICE.price_in_wei.0); pub static ref BLOCK_TIMESTAMP: BlockTimestamp = BlockTimestamp(1234); pub static ref SEQUENCER_ADDRESS: SequencerContractAddress = @@ -175,6 +180,7 @@ lazy_static! { gas_price: GAS_PRICE.price_in_wei, data_gas_consumed: Felt::ZERO, data_gas_price: DATA_GAS_PRICE.price_in_wei, + l2_gas_price: L2_GAS_PRICE.price_in_wei, overall_fee: Fee(166500000000000,), unit: PriceUnit::Wei, }; @@ -184,6 +190,7 @@ lazy_static! { gas_price: GAS_PRICE.price_in_wei, data_gas_consumed: Felt::ZERO, data_gas_price: DATA_GAS_PRICE.price_in_wei, + l2_gas_price: L2_GAS_PRICE.price_in_wei, overall_fee: Fee(166500000000000,), unit: PriceUnit::Wei, }; @@ -1208,6 +1215,7 @@ async fn call_estimate_message_fee() { gas_price: GAS_PRICE.price_in_wei, data_gas_consumed: Felt::ZERO, data_gas_price: DATA_GAS_PRICE.price_in_wei, + l2_gas_price: L2_GAS_PRICE.price_in_wei, overall_fee: Fee(0), unit: PriceUnit::default(), };