-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(blockifier_reexecution): convert declare starknet api to declar…
…e blockifier
- Loading branch information
1 parent
55b1ed1
commit e9b484e
Showing
8 changed files
with
86 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
42 changes: 42 additions & 0 deletions
42
crates/blockifier_reexecution/src/state_reader/reexecution_state_reader.rs
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,42 @@ | ||
use blockifier::execution::contract_class::ClassInfo; | ||
use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction; | ||
use starknet_api::core::ClassHash; | ||
use starknet_api::transaction::{Transaction, TransactionHash}; | ||
|
||
use crate::state_reader::errors::ReexecutionError; | ||
use crate::state_reader::test_state_reader::ReexecutionResult; | ||
|
||
pub(crate) trait ReexecutionStateReader { | ||
fn get_class_info(&self, class_hash: ClassHash) -> ReexecutionResult<ClassInfo>; | ||
|
||
// TODO(Aner): extend/refactor to accomodate all types of transactions. | ||
fn api_txs_to_blockifier_txs( | ||
&self, | ||
txs_and_hashes: Vec<(Transaction, TransactionHash)>, | ||
) -> ReexecutionResult<Vec<BlockifierTransaction>> { | ||
txs_and_hashes | ||
.into_iter() | ||
.map(|(tx, tx_hash)| match tx { | ||
Transaction::Invoke(_) | Transaction::DeployAccount(_) => { | ||
BlockifierTransaction::from_api(tx, tx_hash, None, None, None, false) | ||
.map_err(ReexecutionError::from) | ||
} | ||
Transaction::Declare(ref declare_tx) => { | ||
let class_info = self | ||
.get_class_info(declare_tx.class_hash()) | ||
.map_err(ReexecutionError::from)?; | ||
BlockifierTransaction::from_api( | ||
tx, | ||
tx_hash, | ||
Some(class_info), | ||
None, | ||
None, | ||
false, | ||
) | ||
.map_err(ReexecutionError::from) | ||
} | ||
_ => unimplemented!("unimplemented transaction type: {:?}", tx), | ||
}) | ||
.collect::<Result<Vec<_>, _>>() | ||
} | ||
} |
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