Skip to content

Commit

Permalink
chore(blockifier): create 'from' Transaction to BlockifierTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
avivg-starkware committed Dec 8, 2024
1 parent 7683084 commit 54581cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
8 changes: 3 additions & 5 deletions crates/blockifier/src/transaction/transaction_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@ pub enum Transaction {
L1Handler(L1HandlerTransaction),
}

impl From<starknet_api::executable_transaction::Transaction> for Transaction {
fn from(value: starknet_api::executable_transaction::Transaction) -> Self {
impl Transaction {
pub fn new_for_sequencing(value: starknet_api::executable_transaction::Transaction) -> Self {
match value {
starknet_api::executable_transaction::Transaction::Account(tx) => {
Transaction::Account(AccountTransaction::new_with_default_flags(tx))
Transaction::Account(AccountTransaction::new_for_sequencing(tx))
}
starknet_api::executable_transaction::Transaction::L1Handler(tx) => {
Transaction::L1Handler(tx)
}
}
}
}

impl Transaction {
pub fn nonce(&self) -> Nonce {
match self {
Self::Account(tx) => tx.nonce(),
Expand Down
17 changes: 2 additions & 15 deletions crates/starknet_batcher/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use blockifier::execution::contract_class::RunnableCompiledClass;
use blockifier::state::cached_state::CommitmentStateDiff;
use blockifier::state::errors::StateError;
use blockifier::state::global_cache::GlobalContractCache;
use blockifier::transaction::account_transaction::AccountTransaction;
use blockifier::transaction::objects::TransactionExecutionInfo;
use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction;
use blockifier::versioned_constants::{VersionedConstants, VersionedConstantsOverrides};
Expand Down Expand Up @@ -150,20 +149,8 @@ impl BlockBuilderTrait for BlockBuilder {

let mut executor_input_chunk = vec![];
for tx in &next_tx_chunk {
// TODO(AvivG): Create a 'from' tx to BlockifierTransaction to simplify & remove
// 'match'.
let executable_tx = match tx {
Transaction::Account(account_tx) => {
BlockifierTransaction::Account(AccountTransaction::new_for_sequencing(
// TODO(yair): Avoid this clone.
account_tx.clone(),
))
}
Transaction::L1Handler(l1_handler_tx) => {
// TODO(yair): Avoid this clone.
BlockifierTransaction::L1Handler(l1_handler_tx.clone())
}
};
// TODO(yair): Avoid this clone.
let executable_tx = BlockifierTransaction::new_for_sequencing(tx.clone());
executor_input_chunk.push(executable_tx);
}
let results = self.executor.add_txs_to_block(&executor_input_chunk);
Expand Down

0 comments on commit 54581cf

Please sign in to comment.