Skip to content
Draft
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
12 changes: 11 additions & 1 deletion crates/starknet-devnet-core/src/blocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use indexmap::IndexMap;
use starknet_api::block::{
BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockStatus, BlockTimestamp,
BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockStatus, BlockTimestamp, GasPrice,
};
use starknet_api::data_availability::L1DataAvailabilityMode;
use starknet_api::felt;
Expand All @@ -12,6 +12,7 @@ use starknet_types::felt::{BlockHash, TransactionHash};
use starknet_types::rpc::block::{
BlockHeader as TypesBlockHeader, PendingBlockHeader as TypesPendingBlockHeader, ResourcePrice,
};
use starknet_types::rpc::gas_modification::GasModification;
use starknet_types::traits::HashProducer;
use starknet_types_core::hash::{Pedersen, StarkHash};

Expand Down Expand Up @@ -393,6 +394,15 @@ impl StarknetBlock {
pub(crate) fn set_timestamp(&mut self, timestamp: BlockTimestamp) {
self.header.block_header_without_hash.timestamp = timestamp;
}

pub(crate) fn apply_gas_modification(&mut self, gas_modification: &GasModification) {
self.header.block_header_without_hash.l1_gas_price.price_in_fri =
GasPrice(gas_modification.l1_gas_price.get());
self.header.block_header_without_hash.l1_data_gas_price.price_in_fri =
GasPrice(gas_modification.l1_data_gas_price.get());
self.header.block_header_without_hash.l2_gas_price.price_in_fri =
GasPrice(gas_modification.l2_gas_price.get());
}
}

impl HashProducer for StarknetBlock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ mod tests {
.declare_contract_class(class_hash, None, contract_class.into())
.unwrap();
starknet.block_context = Starknet::init_block_context(
nonzero!(GAS_PRICE),
nonzero!(GAS_PRICE),
nonzero!(GAS_PRICE),
nonzero!(GAS_PRICE),
nonzero!(GAS_PRICE),
nonzero!(GAS_PRICE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,6 @@ mod tests {
// change storage of dummy contract

starknet.block_context = Starknet::init_block_context(
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
Expand All @@ -430,12 +427,9 @@ mod tests {
DEVNET_DEFAULT_STARTING_BLOCK_NUMBER,
);
starknet.next_block_gas = GasModification {
gas_price_wei: nonzero!(1u128),
data_gas_price_wei: nonzero!(1u128),
l2_gas_price_wei: nonzero!(1u128),
gas_price_fri: nonzero!(1u128),
data_gas_price_fri: nonzero!(1u128),
l2_gas_price_fri: nonzero!(1u128),
l1_gas_price: nonzero!(1u128),
l1_data_gas_price: nonzero!(1u128),
l2_gas_price: nonzero!(1u128),
};

starknet.restart_pending_block().unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,6 @@ mod tests {
.predeploy_contract(dummy_contract_address, dummy_contract_class_hash)
.unwrap();
starknet.block_context = Starknet::init_block_context(
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
nonzero!(1u128),
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet-devnet-core/src/starknet/estimations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ pub fn estimate_message_fee(

let mut transactional_state = CachedState::create_transactional(&mut state.state);

let l1_transaction = estimate_message_fee.create_blockifier_l1_transaction()?;
let executable_tx = estimate_message_fee.create_blockifier_l1_handler_tx()?;

estimate_transaction_fee(
&mut transactional_state,
&block_context,
Transaction::L1Handler(l1_transaction),
Transaction::L1Handler(executable_tx),
true,
// Using only L1 gas, because msgs coming from L1 are L1 txs, with their own gas cost
GasVectorComputationMode::NoL2Gas,
Expand Down
Loading