Skip to content

Commit fa42902

Browse files
blockifier: implement conversion from commitment state diff to state maps
1 parent 7bd0e75 commit fa42902

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

crates/blockifier/src/state/cached_state.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,28 @@ impl From<StateMaps> for CommitmentStateDiff {
687687
}
688688
}
689689

690+
#[cfg(any(test, feature = "testing"))]
691+
impl From<CommitmentStateDiff> for StateMaps {
692+
fn from(commitment_state_diff: CommitmentStateDiff) -> Self {
693+
Self {
694+
class_hashes: commitment_state_diff.address_to_class_hash.into_iter().collect(),
695+
nonces: commitment_state_diff.address_to_nonce.into_iter().collect(),
696+
compiled_class_hashes: commitment_state_diff
697+
.class_hash_to_compiled_class_hash
698+
.into_iter()
699+
.collect(),
700+
storage: commitment_state_diff
701+
.storage_updates
702+
.into_iter()
703+
.flat_map(|(address, storage)| {
704+
storage.into_iter().map(move |(key, value)| ((address, key), value))
705+
})
706+
.collect(),
707+
declared_contracts: Default::default(),
708+
}
709+
}
710+
}
711+
690712
impl From<CommitmentStateDiff> for ThinStateDiff {
691713
fn from(commitment_state_diff: CommitmentStateDiff) -> Self {
692714
Self {

0 commit comments

Comments
 (0)