Skip to content

Commit

Permalink
Pass data gas prices to blockifier (#1729)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak authored Feb 28, 2024
1 parent 941b1b9 commit 6499f7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vm/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub struct BlockInfo {
pub gas_price_fri: [c_uchar; 32],
pub version: *const c_char,
pub block_hash_to_be_revealed: [c_uchar; 32],
pub data_gas_price_wei: [c_uchar; 32],
pub data_gas_price_fri: [c_uchar; 32],
pub use_blob_data: c_uchar,
}

#[no_mangle]
Expand Down Expand Up @@ -379,6 +382,8 @@ fn build_block_context(
let sequencer_addr = StarkFelt::new(block_info.sequencer_address).unwrap();
let gas_price_wei_felt = StarkFelt::new(block_info.gas_price_wei).unwrap();
let gas_price_fri_felt = StarkFelt::new(block_info.gas_price_fri).unwrap();
let data_gas_price_wei_felt = StarkFelt::new(block_info.data_gas_price_wei).unwrap();
let data_gas_price_fri_felt = StarkFelt::new(block_info.data_gas_price_fri).unwrap();
let default_gas_price = NonZeroU128::new(1).unwrap();

let mut old_block_number_and_hash: Option<BlockNumberHashPair> = None;
Expand All @@ -395,10 +400,10 @@ fn build_block_context(
gas_prices: GasPrices {
eth_l1_gas_price: NonZeroU128::new(felt_to_u128(gas_price_wei_felt)).unwrap_or(default_gas_price),
strk_l1_gas_price: NonZeroU128::new(felt_to_u128(gas_price_fri_felt)).unwrap_or(default_gas_price),
eth_l1_data_gas_price: default_gas_price,
strk_l1_data_gas_price: default_gas_price,
eth_l1_data_gas_price: NonZeroU128::new(felt_to_u128(data_gas_price_wei_felt)).unwrap_or(default_gas_price),
strk_l1_data_gas_price: NonZeroU128::new(felt_to_u128(data_gas_price_fri_felt)).unwrap_or(default_gas_price),
},
use_kzg_da: false,
use_kzg_da: block_info.use_blob_data == 1,
}, ChainInfo{
chain_id: ChainId(chain_id_str.to_string()),
fee_token_addresses: FeeTokenAddresses {
Expand Down
8 changes: 8 additions & 0 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ typedef struct BlockInfo {
unsigned char gas_price_fri[FELT_SIZE];
char* version;
unsigned char block_hash_to_be_revealed[FELT_SIZE];
unsigned char data_gas_price_wei[FELT_SIZE];
unsigned char data_gas_price_fri[FELT_SIZE];
unsigned char use_blob_data;
} BlockInfo;
extern void cairoVMCall(CallInfo* call_info_ptr, BlockInfo* block_info_ptr, uintptr_t readerHandle, char* chain_id,
Expand Down Expand Up @@ -188,6 +191,11 @@ func makeCBlockInfo(blockInfo *BlockInfo) C.BlockInfo {
copyFeltIntoCArray(blockInfo.Header.GasPriceSTRK, &cBlockInfo.gas_price_fri[0])
cBlockInfo.version = cstring([]byte(blockInfo.Header.ProtocolVersion))
copyFeltIntoCArray(blockInfo.BlockHashToBeRevealed, &cBlockInfo.block_hash_to_be_revealed[0])
if blockInfo.Header.L1DAMode == core.Blob {
copyFeltIntoCArray(blockInfo.Header.L1DataGasPrice.PriceInWei, &cBlockInfo.data_gas_price_wei[0])
copyFeltIntoCArray(blockInfo.Header.L1DataGasPrice.PriceInFri, &cBlockInfo.data_gas_price_fri[0])
cBlockInfo.use_blob_data = 1
}
return cBlockInfo
}

Expand Down

0 comments on commit 6499f7f

Please sign in to comment.