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): have limit_steps_by_resources flag rep charge_fee flag and enforce_fee ret val #833

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
3 changes: 2 additions & 1 deletion crates/blockifier/src/blockifier/stateful_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::state::errors::StateError;
use crate::state::state_api::StateReader;
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::errors::{TransactionExecutionError, TransactionPreValidationError};
use crate::transaction::objects::TransactionInfoCreator;
use crate::transaction::transaction_execution::Transaction;
use crate::transaction::transactions::ValidatableTransaction;

Expand Down Expand Up @@ -113,7 +114,7 @@ impl<S: StateReader> StatefulValidator<S> {
let mut execution_resources = ExecutionResources::default();
let tx_context = Arc::new(self.tx_executor.block_context.to_tx_context(tx));

let limit_steps_by_resources = true;
let limit_steps_by_resources = tx.create_tx_info().enforce_fee();
let validate_call_info = tx.validate_tx(
self.tx_executor.block_state.as_mut().expect(BLOCK_STATE_ACCESS_ERR),
&mut execution_resources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ fn test_tx_info(#[values(false, true)] only_query: bool) {
},
max_fee,
});
let limit_steps_by_resources = true;
let limit_steps_by_resources = false; // Do not limit steps by resources as we use default reasources.
let result = entry_point_call
.execute_directly_given_tx_info(
&mut state,
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/execution/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl EntryPointExecutionContext {
usize::MAX
});

if !limit_steps_by_resources || !tx_info.enforce_fee() {
if !limit_steps_by_resources {
return block_upper_bound;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ fn test_get_execution_info(
),
..trivial_external_entry_point_with_address(test_contract_address)
};

let result =
entry_point_call.execute_directly_given_tx_info(state, tx_info, false, execution_mode);

Expand Down
7 changes: 5 additions & 2 deletions crates/blockifier/src/test_utils/struct_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ impl CallEntryPoint {
/// Executes the call directly, without account context. Limits the number of steps by resource
/// bounds.
pub fn execute_directly(self, state: &mut dyn State) -> EntryPointExecutionResult<CallInfo> {
let limit_steps_by_resources = false; // Do not limit steps by resources as we use default reasources.
self.execute_directly_given_tx_info(
state,
// TODO(Yoni, 1/12/2024): change the default to V3.
TransactionInfo::Deprecated(DeprecatedTransactionInfo::default()),
true,
limit_steps_by_resources,
ExecutionMode::Execute,
)
}
Expand Down Expand Up @@ -82,10 +83,12 @@ impl CallEntryPoint {
self,
state: &mut dyn State,
) -> EntryPointExecutionResult<CallInfo> {
let limit_steps_by_resources = false; // Do not limit steps by resources as we use default reasources.
self.execute_directly_given_tx_info(
state,
// TODO(Yoni, 1/12/2024): change the default to V3.
TransactionInfo::Deprecated(DeprecatedTransactionInfo::default()),
true,
limit_steps_by_resources,
ExecutionMode::Validate,
)
}
Expand Down
3 changes: 1 addition & 2 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ impl AccountTransaction {
concurrency_mode: bool,
) -> TransactionExecutionResult<Option<CallInfo>> {
if !charge_fee || actual_fee == Fee(0) {
// Fee charging is not enforced in some transaction simulations and tests.
// Fee charging is not enforced in some tests.
return Ok(None);
}

Expand Down Expand Up @@ -510,7 +510,6 @@ impl AccountTransaction {

initial_gas: remaining_gas_for_fee_transfer,
};

let mut context = EntryPointExecutionContext::new_invoke(tx_context, true);

Ok(fee_transfer_call
Expand Down
5 changes: 3 additions & 2 deletions crates/blockifier/src/transaction/transaction_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ impl<U: UpdatableState> ExecutableTransaction<U> for L1HandlerTransaction {
_execution_flags: ExecutionFlags,
) -> TransactionExecutionResult<TransactionExecutionInfo> {
let tx_context = Arc::new(block_context.to_tx_context(self));

let limit_steps_by_resources = false;
let mut execution_resources = ExecutionResources::default();
let mut context = EntryPointExecutionContext::new_invoke(tx_context.clone(), true);
let mut context =
EntryPointExecutionContext::new_invoke(tx_context.clone(), limit_steps_by_resources);
let mut remaining_gas = tx_context.initial_sierra_gas();
let execute_call_info =
self.run_execute(state, &mut execution_resources, &mut context, &mut remaining_gas)?;
Expand Down
11 changes: 5 additions & 6 deletions crates/papyrus_execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,13 @@ pub fn execute_call(
execution_config,
override_kzg_da_to_false,
)?;
// TODO(yair): fix when supporting v3 transactions
let tx_info = TransactionInfo::Deprecated(DeprecatedTransactionInfo::default());
let limit_steps_by_resources = false; // Default resource bounds.

let mut context = EntryPointExecutionContext::new_invoke(
// TODO(yair): fix when supporting v3 transactions
Arc::new(TransactionContext {
block_context,
tx_info: TransactionInfo::Deprecated(DeprecatedTransactionInfo::default()),
}),
true, // limit_steps_by_resources
Arc::new(TransactionContext { block_context, tx_info }),
limit_steps_by_resources,
);

let res = call_entry_point
Expand Down
Loading