Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(blockifier): enforce_fee() impl by api::executable_transaction::AccountTransaction #2377

Merged
Merged
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
6 changes: 1 addition & 5 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,7 @@ impl<U: UpdatableState> ExecutableTransaction<U> for AccountTransaction {

impl TransactionInfoCreator for AccountTransaction {
fn create_tx_info(&self) -> TransactionInfo {
match &self.tx {
Transaction::Declare(tx) => tx.create_tx_info(self.only_query),
Transaction::DeployAccount(tx) => tx.create_tx_info(self.only_query),
Transaction::Invoke(tx) => tx.create_tx_info(self.only_query),
}
self.tx.create_tx_info(self.only_query)
}
}

Expand Down
17 changes: 17 additions & 0 deletions crates/blockifier/src/transaction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::contract_class::EntryPointType;
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress};
use starknet_api::executable_transaction::{
AccountTransaction,
DeclareTransaction,
DeployAccountTransaction,
InvokeTransaction,
Expand Down Expand Up @@ -179,6 +180,16 @@ impl TransactionInfoCreator for L1HandlerTransaction {
}
}

impl TransactionInfoCreatorInner for AccountTransaction {
fn create_tx_info(&self, only_query: bool) -> TransactionInfo {
match self {
Self::Declare(tx) => tx.create_tx_info(only_query),
Self::DeployAccount(tx) => tx.create_tx_info(only_query),
Self::Invoke(tx) => tx.create_tx_info(only_query),
}
}
}

impl<S: State> Executable<S> for DeclareTransaction {
fn run_execute(
&self,
Expand Down Expand Up @@ -393,6 +404,12 @@ impl TransactionInfoCreatorInner for InvokeTransaction {
}
}

/// Determines whether the fee should be enforced for the given transaction.
pub fn enforce_fee(tx: &AccountTransaction, only_query: bool) -> bool {
// TODO(AvivG): Consider implemetation without 'create_tx_info'.
tx.create_tx_info(only_query).enforce_fee()
}

/// Attempts to declare a contract class by setting the contract class in the state with the
/// specified class hash.
fn try_declare<S: State>(
Expand Down
Loading