Skip to content

Commit

Permalink
build(blockifier_reexecution): add offline reexecution data struct
Browse files Browse the repository at this point in the history
  • Loading branch information
aner-starkware committed Oct 31, 2024
1 parent a0b6b84 commit 50632de
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use blockifier::blockifier::transaction_executor::TransactionExecutor;
use blockifier::bouncer::BouncerConfig;
use blockifier::context::BlockContext;
use blockifier::execution::contract_class::ContractClass as BlockifierContractClass;
use blockifier::state::cached_state::{CachedState, CommitmentStateDiff};
use blockifier::state::cached_state::{CachedState, CommitmentStateDiff, StateMaps};
use blockifier::state::errors::StateError;
use blockifier::state::state_api::{StateReader, StateResult};
use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction;
Expand Down Expand Up @@ -42,6 +42,14 @@ pub type ReexecutionResult<T> = Result<T, ReexecutionError>;

pub type StarknetContractClassMapping = HashMap<ClassHash, StarknetContractClass>;

pub struct OfflineReexecutionData {
state_maps: StateMaps,
contract_class_mapping: StarknetContractClassMapping,
block_context_next_block: BlockContext,
transactions_next_block: Vec<BlockifierTransaction>,
state_diff_next_block: CommitmentStateDiff,
}

pub struct TestStateReader {
rpc_state_reader: RpcStateReader,
#[allow(dead_code)]
Expand Down Expand Up @@ -267,12 +275,13 @@ impl ReexecutionStateReader for TestStateReader {
class_hash: ClassHash,
) -> ReexecutionResult<StarknetContractClass> {
let params = json!({
"block_id": self.0.block_id,
"block_id": self.rpc_state_reader.block_id,
"class_hash": class_hash.0.to_string(),
});
let contract_class: StarknetContractClass =
serde_json::from_value(self.0.send_rpc_request("starknet_getClass", params.clone())?)
.map_err(serde_err_to_state_err)?;
let contract_class: StarknetContractClass = serde_json::from_value(
self.rpc_state_reader.send_rpc_request("starknet_getClass", params.clone())?,
)
.map_err(serde_err_to_state_err)?;
Ok(contract_class)
}
}
Expand Down

0 comments on commit 50632de

Please sign in to comment.