Skip to content

Commit

Permalink
refactor: use TransactionContext::get_fee_token_address (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware authored Jul 29, 2024
1 parent 5511419 commit ad54542
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
11 changes: 3 additions & 8 deletions crates/blockifier/src/concurrency/worker_logic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,15 @@ fn verify_sequencer_balance_update<S: StateReader>(
// We assume the balance is at most 2^128, so the "low" value is sufficient.
expected_sequencer_balance_low: u128,
) {
let TransactionContext { block_context, tx_info } = tx_context;
let tx_version_state = state.pin_version(tx_index);
let (sequencer_balance_key_low, sequencer_balance_key_high) =
get_sequencer_balance_keys(block_context);
get_sequencer_balance_keys(&tx_context.block_context);
for (expected_balance, storage_key) in [
(felt!(expected_sequencer_balance_low), sequencer_balance_key_low),
(Felt::ZERO, sequencer_balance_key_high),
] {
let actual_balance = tx_version_state
.get_storage_at(
block_context.chain_info.fee_token_address(&tx_info.fee_type()),
storage_key,
)
.unwrap();
let actual_balance =
tx_version_state.get_storage_at(tx_context.fee_token_address(), storage_key).unwrap();
assert_eq!(expected_balance, actual_balance);
}
}
Expand Down
7 changes: 3 additions & 4 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ impl AccountTransaction {
let msb_amount = Felt::from(0_u8);

let TransactionContext { block_context, tx_info } = tx_context.as_ref();
let storage_address = block_context.chain_info.fee_token_address(&tx_info.fee_type());
let storage_address = tx_context.fee_token_address();
let fee_transfer_call = CallEntryPoint {
class_hash: None,
code_address: None,
Expand Down Expand Up @@ -388,10 +388,9 @@ impl AccountTransaction {
tx_context: Arc<TransactionContext>,
actual_fee: Fee,
) -> TransactionExecutionResult<CallInfo> {
let TransactionContext { block_context, tx_info } = tx_context.as_ref();
let fee_address = block_context.chain_info.fee_token_address(&tx_info.fee_type());
let fee_address = tx_context.fee_token_address();
let (sequencer_balance_key_low, sequencer_balance_key_high) =
get_sequencer_balance_keys(block_context);
get_sequencer_balance_keys(&tx_context.block_context);
let mut transfer_state = TransactionalState::create_transactional(state);

// Set the initial sequencer balance to avoid tarnishing the read-set of the transaction.
Expand Down

0 comments on commit ad54542

Please sign in to comment.