-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blockifier): add
get_execution_info_v1
syscall
- Loading branch information
Showing
9 changed files
with
1,074 additions
and
15 deletions.
There are no files selected for viewing
900 changes: 900 additions & 0 deletions
900
...ifier/feature_contracts/cairo_native/compiled/test_contract_execution_info_v1.sierra.json
Large diffs are not rendered by default.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
crates/blockifier/feature_contracts/cairo_native/test_contract_execution_info_v1.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#[starknet::contract] | ||
mod TestContract { | ||
use box::BoxTrait; | ||
use starknet::ClassHash; | ||
use starknet::ContractAddress; | ||
use starknet::syscalls::get_execution_info_syscall; | ||
use starknet::info::ExecutionInfo; | ||
use starknet::info::BlockInfo; | ||
use starknet::info::TxInfo; | ||
use starknet::{SyscallResultTrait, SyscallResult}; | ||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
#[external(v0)] | ||
fn test_get_execution_info( | ||
self: @ContractState, | ||
expected_block_number: u64, | ||
expected_block_timestamp: u64, | ||
expected_sequencer_address: ContractAddress, | ||
expected_tx_info: TxInfo, | ||
expected_caller_address: felt252, | ||
expected_contract_address: felt252, | ||
expected_entry_point_selector: felt252, | ||
) { | ||
let execution_info = get_execution_info_syscall().unwrap_syscall().unbox(); | ||
let block_info = execution_info.block_info.unbox(); | ||
|
||
assert(block_info.block_number == expected_block_number, 'BLOCK_NUMBER_MISMATCH'); | ||
assert(block_info.block_timestamp == expected_block_timestamp, 'BLOCK_TIMESTAMP_MISMATCH'); | ||
assert( | ||
block_info.sequencer_address.into() == expected_sequencer_address, 'SEQUENCER_MISMATCH', | ||
); | ||
|
||
let tx_info = execution_info.tx_info.unbox(); | ||
assert(tx_info.version == expected_tx_info.version, 'TX_INFO_VERSION_MISMATCH'); | ||
assert( | ||
tx_info.account_contract_address.into() == expected_tx_info.account_contract_address, | ||
'ACCOUNT_C_ADDRESS_MISMATCH', | ||
); | ||
assert(tx_info.max_fee == expected_tx_info.max_fee, 'TX_INFO_MAX_FEE_MISMATCH'); | ||
assert(tx_info.signature == expected_tx_info.signature, 'TX_INFO_SIGNATURE_MISMATCH'); | ||
assert( | ||
tx_info.transaction_hash == expected_tx_info.transaction_hash, 'TX_INFO_HASH_MISMATCH', | ||
); | ||
assert(tx_info.chain_id == expected_tx_info.chain_id, 'TX_INFO_CHAIN_ID_MISMATCH'); | ||
assert(tx_info.nonce == expected_tx_info.nonce, 'TX_INFO_NONCE_MISMATCH'); | ||
|
||
assert(execution_info.caller_address.into() == expected_caller_address, 'CALLER_MISMATCH'); | ||
assert( | ||
execution_info.contract_address.into() == expected_contract_address, 'CONTRACT_MISMATCH' | ||
); | ||
assert( | ||
execution_info.entry_point_selector == expected_entry_point_selector, | ||
'SELECTOR_MISMATCH' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters