From 6499f7ff9143e4d389c18fb70f48f877afbd7869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Wed, 28 Feb 2024 21:41:23 +0300 Subject: [PATCH] Pass data gas prices to blockifier (#1729) --- vm/rust/src/lib.rs | 11 ++++++++--- vm/vm.go | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/vm/rust/src/lib.rs b/vm/rust/src/lib.rs index 30e372ac85..184bb40bc7 100644 --- a/vm/rust/src/lib.rs +++ b/vm/rust/src/lib.rs @@ -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] @@ -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 = None; @@ -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 { diff --git a/vm/vm.go b/vm/vm.go index f785766053..9b46371dda 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -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, @@ -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 }