Skip to content

Commit

Permalink
feat: add gas vector to execution resources
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavGrs committed Jun 3, 2024
1 parent e5f4bc7 commit 976b5ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/block_hash/receipt_commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ fn chain_execution_resources(
) -> HashChain {
hash_chain
.chain(&Felt::ZERO) // L2 gas consumed
.chain(&execution_resources.l1_gas_consumed.into())
.chain(&execution_resources.da_l1_data_gas_consumed.into())
.chain(&execution_resources.gas_consumed.l1_gas.into())
.chain(&execution_resources.gas_consumed.l1_data_gas.into())
}
7 changes: 3 additions & 4 deletions src/block_hash/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use starknet_types_core::felt::Felt;
use crate::core::{ClassHash, CompiledClassHash, ContractAddress, EthAddress, Nonce};
use crate::state::ThinStateDiff;
use crate::transaction::{
Builtin, ExecutionResources, Fee, L2ToL1Payload, MessageToL1,
Builtin, ExecutionResources, Fee, GasVector, L2ToL1Payload, MessageToL1,
RevertedTransactionExecutionStatus, TransactionExecutionStatus, TransactionOutputCommon,
};

Expand All @@ -20,9 +20,8 @@ pub(crate) fn get_transaction_output() -> TransactionOutputCommon {
steps: 98,
builtin_instance_counter: HashMap::from([(Builtin::Bitwise, 11), (Builtin::EcOp, 22)]),
memory_holes: 76,
da_l1_gas_consumed: 54,
da_l1_data_gas_consumed: 32,
l1_gas_consumed: 16580,
da_gas_consumed: GasVector { l1_gas: 54, l1_data_gas: 10 },
gas_consumed: GasVector { l1_gas: 16580, l1_data_gas: 32 },
};
TransactionOutputCommon {
actual_fee: Fee(99804),
Expand Down
11 changes: 8 additions & 3 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,15 +958,20 @@ pub struct PaymasterData(pub Vec<Felt>);
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
pub struct AccountDeploymentData(pub Vec<Felt>);

#[derive(Debug, Default, Deserialize, Serialize, Clone, Eq, PartialEq)]
pub struct GasVector {
pub l1_gas: u64,
pub l1_data_gas: u64,
}

/// The execution resources used by a transaction.
#[derive(Debug, Default, Deserialize, Serialize, Clone, Eq, PartialEq)]
pub struct ExecutionResources {
pub steps: u64,
pub builtin_instance_counter: HashMap<Builtin, u64>,
pub memory_holes: u64,
pub da_l1_gas_consumed: u64,
pub da_l1_data_gas_consumed: u64,
pub l1_gas_consumed: u64,
pub da_gas_consumed: GasVector,
pub gas_consumed: GasVector,
}

#[derive(Hash, Debug, Deserialize, Serialize, Clone, Eq, PartialEq)]
Expand Down

0 comments on commit 976b5ff

Please sign in to comment.