diff --git a/Cargo.lock b/Cargo.lock index 0a2292ead8..291ab12ab2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -992,7 +992,7 @@ dependencies = [ [[package]] name = "blockifier" version = "0.5.0-rc.3" -source = "git+https://github.com/bidzyyys/blockifier?branch=feature/scale-codec#a18daa717a894fbe64ba0fde42ba8861175245f7" +source = "git+https://github.com/bidzyyys/blockifier?branch=feature/scale-codec#59950ded347f60bfcbbc31300ff713e5423448e2" dependencies = [ "anyhow", "ark-ec", @@ -1189,7 +1189,7 @@ checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cairo-felt" version = "0.9.1" -source = "git+https://github.com/bidzyyys/cairo-vm?branch=feature/scale-codec#0641b5a018cd6fee7a01e627cab839f39bfaecb4" +source = "git+https://github.com/bidzyyys/cairo-vm?branch=feature/scale-codec#eb835a9034e208a1756226d64e004cb55e417b96" dependencies = [ "lazy_static", "num-bigint", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "cairo-vm" version = "0.9.1" -source = "git+https://github.com/bidzyyys/cairo-vm?branch=feature/scale-codec#0641b5a018cd6fee7a01e627cab839f39bfaecb4" +source = "git+https://github.com/bidzyyys/cairo-vm?branch=feature/scale-codec#eb835a9034e208a1756226d64e004cb55e417b96" dependencies = [ "anyhow", "ark-ff 0.4.2", diff --git a/crates/client/l1-messages/src/worker.rs b/crates/client/l1-messages/src/worker.rs index 8d65588c42..938a0192ff 100644 --- a/crates/client/l1-messages/src/worker.rs +++ b/crates/client/l1-messages/src/worker.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use blockifier::transaction::transactions::L1HandlerTransaction; use ethers::providers::{Http, Provider, StreamExt}; use ethers::types::U256; pub use mc_eth_client::config::EthereumClientConfig; @@ -146,7 +147,7 @@ where let chain_id = client.runtime_api().chain_id(best_block_hash).map_err(L1MessagesWorkerError::RuntimeApiError)?; let tx_hash = tx.compute_hash(chain_id, false); - let transaction = blockifier::transaction::transactions::L1HandlerTransaction { tx, tx_hash, paid_fee_on_l1 }; + let transaction = L1HandlerTransaction { tx, tx_hash, paid_fee_on_l1 }; let extrinsic = client.runtime_api().convert_l1_transaction(best_block_hash, transaction).map_err(|e| { log::error!("⟠ Failed to convert L1 Transaction via Runtime Api: {:?}", e); diff --git a/crates/client/rpc/src/events/mod.rs b/crates/client/rpc/src/events/mod.rs index ea7558685f..872dc65702 100644 --- a/crates/client/rpc/src/events/mod.rs +++ b/crates/client/rpc/src/events/mod.rs @@ -67,12 +67,12 @@ where })?; for event in raw_events { emitted_events.push(EmittedEvent { - from_address: Felt252Wrapper::from(event.from_address).0, - keys: event.content.keys.into_iter().map(|felt| Felt252Wrapper::from(felt).0).collect(), - data: event.content.data.0.into_iter().map(|felt| Felt252Wrapper::from(felt).0).collect(), + from_address: Felt252Wrapper::from(event.from_address).into(), + keys: event.content.keys.into_iter().map(|felt| Felt252Wrapper::from(felt).into()).collect(), + data: event.content.data.0.into_iter().map(|felt| Felt252Wrapper::from(felt).into()).collect(), block_hash: Some(block_hash.into()), block_number: Some(block_number), - transaction_hash: Felt252Wrapper::from(*tx_hash).0, + transaction_hash: Felt252Wrapper::from(*tx_hash).into(), }) } } diff --git a/crates/client/rpc/src/lib.rs b/crates/client/rpc/src/lib.rs index 5e40030938..42950c84f1 100644 --- a/crates/client/rpc/src/lib.rs +++ b/crates/client/rpc/src/lib.rs @@ -1004,6 +1004,8 @@ where .collect(); let tx = starknet_api::transaction::L1HandlerTransaction { version: TransactionVersion::ZERO, + // Nonce is not used during the message fee estimation. + // Just put whatever. nonce: Nonce(StarkFelt::ZERO), contract_address: Felt252Wrapper::from(message.to_address).into(), entry_point_selector: Felt252Wrapper::from(message.entry_point_selector).into(), @@ -1012,7 +1014,7 @@ where let tx_hash = tx.compute_hash(chain_id, true); // Hardcoded `paid_fee_on_l1` value as it is not relevant here - L1HandlerTransaction { tx, tx_hash, paid_fee_on_l1: Fee(10) } + L1HandlerTransaction { tx, tx_hash, paid_fee_on_l1: Fee(1) } }; let fee_estimate = self.do_estimate_message_fee(substrate_block_hash, transaction)?; diff --git a/crates/pallets/starknet/src/lib.rs b/crates/pallets/starknet/src/lib.rs index 10f058d1ee..a11018ba8d 100644 --- a/crates/pallets/starknet/src/lib.rs +++ b/crates/pallets/starknet/src/lib.rs @@ -743,13 +743,12 @@ pub mod pallet { // The first tx validation would fail because the contract is not deployed yet, // so we skip the entrypoint execution for now (Nonce(StarkFelt::ONE), Nonce(StarkFelt::ZERO)) => { - // Self::validate_unsigned_tx(&transaction)?; valid_transaction_builder = valid_transaction_builder.and_requires((sender_address, Nonce(StarkFelt::ZERO))); } - // Future transaction, we validate the entrypoing in order to avoid having the mempool flooded + // Future transaction, we validate the entrypoint in order to avoid having the mempool flooded // There is a possiblility of false negative, where a previous tx execution you make the future - // one possible, atm we are ok with this, the user will just way for the + // one possible, atm we are ok with this, the user will just wait for the // first one to be executed and then send the next one // May be removed in the future tho (transaction_nonce, sender_nonce) if transaction_nonce > sender_nonce => { diff --git a/crates/primitives/block/src/header.rs b/crates/primitives/block/src/header.rs index a7bcf05325..34e781c49e 100644 --- a/crates/primitives/block/src/header.rs +++ b/crates/primitives/block/src/header.rs @@ -1,11 +1,8 @@ -use blockifier::blockifier::block::{BlockInfo, GasPrices}; -use blockifier::context::{BlockContext, ChainInfo, FeeTokenAddresses}; -use blockifier::versioned_constants::VersionedConstants; +use blockifier::blockifier::block::GasPrices; use mp_felt::Felt252Wrapper; use mp_hashers::HasherT; use sp_core::U256; -use starknet_api::block::{BlockNumber, BlockTimestamp}; -use starknet_api::core::{ChainId, ContractAddress}; +use starknet_api::core::ContractAddress; use starknet_api::hash::StarkHash; #[derive(Clone, Debug)] @@ -62,21 +59,6 @@ impl Header { } } - /// Converts to a blockifier BlockContext - pub fn into_block_context(self, fee_token_addresses: FeeTokenAddresses, chain_id: ChainId) -> BlockContext { - BlockContext::new_unchecked( - &BlockInfo { - block_number: BlockNumber(self.block_number), - block_timestamp: BlockTimestamp(self.block_timestamp), - sequencer_address: self.sequencer_address, - gas_prices: self.l1_gas_price, - use_kzg_da: true, - }, - &ChainInfo { chain_id, fee_token_addresses }, - VersionedConstants::latest_constants(), - ) - } - /// Compute the hash of the header. pub fn hash(&self) -> Felt252Wrapper { let data: &[Felt252Wrapper] = &[ diff --git a/crates/primitives/block/src/tests.rs b/crates/primitives/block/src/tests.rs index 2cda192582..9c430006cc 100644 --- a/crates/primitives/block/src/tests.rs +++ b/crates/primitives/block/src/tests.rs @@ -1,17 +1,11 @@ use core::convert::TryFrom; -use std::num::NonZeroU128; -use blockifier::blockifier::block::GasPrices; -use blockifier::context::FeeTokenAddresses; use mp_felt::Felt252Wrapper; use mp_hashers::pedersen::PedersenHasher; use mp_hashers::HasherT; -use starknet_api::block::{BlockNumber, BlockTimestamp}; -use starknet_api::core::{ChainId, ContractAddress, PatriciaKey}; +use starknet_api::core::{ContractAddress, PatriciaKey}; use starknet_api::hash::{StarkFelt, StarkHash}; -use crate::Header; - fn generate_dummy_header() -> Vec { vec![ Felt252Wrapper::ONE, // block_number @@ -78,48 +72,3 @@ fn test_real_header_hash() { assert_eq!(hash, expected_hash); } - -#[test] -fn test_to_block_context() { - let sequencer_address = ContractAddress(PatriciaKey(StarkFelt::try_from("0xFF").unwrap())); - // Create a block header. - let block_header = Header { - block_number: 1, - block_timestamp: 1, - sequencer_address, - parent_block_hash: Default::default(), - transaction_count: Default::default(), - event_count: Default::default(), - protocol_version: Default::default(), - l1_gas_price: unsafe { - GasPrices { - eth_l1_gas_price: NonZeroU128::new_unchecked(10), - strk_l1_gas_price: NonZeroU128::new_unchecked(10), - eth_l1_data_gas_price: NonZeroU128::new_unchecked(10), - strk_l1_data_gas_price: NonZeroU128::new_unchecked(10), - } - }, - extra_data: Default::default(), - }; - // Create a fee token address. - let fee_token_addresses = FeeTokenAddresses { - eth_fee_token_address: ContractAddress(PatriciaKey(StarkFelt::try_from("AA").unwrap())), - strk_fee_token_address: ContractAddress(PatriciaKey(StarkFelt::try_from("BB").unwrap())), - }; - // Create a chain id. - let chain_id = ChainId("0x1".to_string()); - // Try to serialize the block header. - let block_context = block_header.into_block_context(fee_token_addresses.clone(), chain_id); - // Check that the block context was serialized correctly. - assert_eq!(block_context.block_info().block_number, BlockNumber(1)); - assert_eq!(block_context.block_info().block_timestamp, BlockTimestamp(1)); - assert_eq!(block_context.block_info().sequencer_address, sequencer_address); - assert_eq!( - &block_context.chain_info().fee_token_addresses.eth_fee_token_address, - &fee_token_addresses.eth_fee_token_address - ); - assert_eq!( - &block_context.chain_info().fee_token_addresses.strk_fee_token_address, - &fee_token_addresses.strk_fee_token_address - ); -}