@@ -10,12 +10,17 @@ use blockifier::context::BlockContext;
10
10
use blockifier:: state:: cached_state:: { CachedState , CommitmentStateDiff } ;
11
11
use blockifier:: test_utils:: maybe_dummy_block_hash_and_number;
12
12
use blockifier:: transaction:: transaction_execution:: Transaction ;
13
+ use starknet_committer:: block_committer:: commit:: commit_block;
13
14
use starknet_committer:: block_committer:: input:: {
15
+ ConfigImpl ,
16
+ Input ,
14
17
StarknetStorageKey ,
15
18
StarknetStorageValue ,
16
19
StateDiff ,
17
20
} ;
18
21
use starknet_committer:: patricia_merkle_tree:: types:: CompiledClassHash ;
22
+ use starknet_patricia:: hash:: hash_trait:: HashOutput ;
23
+ use starknet_patricia_storage:: map_storage:: MapStorage ;
19
24
20
25
use crate :: state_trait:: FlowTestState ;
21
26
@@ -79,3 +84,24 @@ pub(crate) fn create_committer_state_diff(state_diff: CommitmentStateDiff) -> St
79
84
. collect ( ) ,
80
85
}
81
86
}
87
+
88
+ /// Commits the state diff, saves the new facts and returns the computed roots.
89
+ async fn commit_state_diff (
90
+ facts : & mut MapStorage ,
91
+ contracts_trie_root_hash : HashOutput ,
92
+ classes_trie_root_hash : HashOutput ,
93
+ state_diff : StateDiff ,
94
+ ) -> ( HashOutput , HashOutput ) {
95
+ let config = ConfigImpl :: default ( ) ;
96
+ // TODO(Nimrod): Remove the clone once commit takes reference to the storage.
97
+ let input = Input {
98
+ storage : facts. storage . clone ( ) ,
99
+ state_diff,
100
+ contracts_trie_root_hash,
101
+ classes_trie_root_hash,
102
+ config,
103
+ } ;
104
+ let filled_forest = commit_block ( input) . await . expect ( "Failed to commit the given block." ) ;
105
+ filled_forest. write_to_storage ( facts) ;
106
+ ( filled_forest. get_contract_root_hash ( ) , filled_forest. get_compiled_class_root_hash ( ) )
107
+ }
0 commit comments