@@ -166,78 +166,36 @@ let do_emergency_commit
166166 ~last_commit
167167 ~actions_since_last_commit
168168 =
169- (* doesn't need to be at the same time as macroslot,
170- can be early or late depending on other factors *)
171- assert valid_while.upper - valid_while.lower < max_valid_while_size ;
172-
173- (* The vk for the inner account ensures that the outer action state as recorded only goes forward. *)
174- let old_inner = get_account inner_pk txn_snark.source in
175- let new_inner = get_account inner_pk txn_snark.target in
176-
177- let synchronized_outer_action_state = new_inner.app_state.outer_action_state in
178-
179- (* The new actions must be the difference between old synchronized outer action state and new synchronized outer action state. *)
180- assert
181- List.append new_actions old_inner.app_state.outer_action_state
182- = synchronized_outer_action_state ;
183-
184- let synchronized_outer_action_state_length =
185- List.length new_actions + old_inner.app_state.outer_action_state_length in
186-
187- let action_state =
188- (* We don't force sequencer to match on latest action state,
189- since it's unreliable and might roll back. *)
190- List.append unsynchronized_actions synchronized_outer_action_state in
169+ let [ commit ] =
170+ do_commit
171+ ~txn_snark
172+ ~valid_while
173+ ~new_actions
174+ ~new_inner_actions
175+ ~old_inner_action_state_length
176+ ~unsynchronized_actions
177+ ~pause_key
178+ ~da_key
179+ in
191180
192181 (* Emergency checks *)
193- let () =
194- let (target_action_state, n_commits) = count_commits
195- (List.append last_commit outer_action_state_before_last_commit)
196- actions_since_last_commit
197- in
198- (* Check that there has not been any commit after last commit *)
199- assert n_commits = 0 ;
200- assert target_action_state = action_state ;
201- assert valid_while.lower - last_commit.valid_while.upper >= max_sequencer_inactivity
182+ let (target_action_state, n_commits) = count_commits
183+ (List.append last_commit outer_action_state_before_last_commit)
184+ actions_since_last_commit
202185 in
203186
204- let ledger = txn_snark.target in
205- let inner_action_state = new_inner.action_state in
206- let inner_action_state_length = List.length new_inner_actions + old_inner_action_state_length in
187+ (* Check that there has not been any commit after last commit *)
188+ assert n_commits = 0 ;
207189
208- [ { public_key = zeko_pk
209- ; actions = Commit
210- { ledger
211- ; inner_action_state
212- ; inner_action_state_length
213- ; synchronized_outer_action_state
214- ; synchronized_outer_action_state_length
215- ; valid_while
216- }
217- ; app_state =
218- { ledger
219- ; inner_action_state
220- ; inner_action_state_length
221- ; sequencer
222- ; paused = false
223- ; pause_key
224- ; da_key
225- ; acc_set = txn_snark.target_acc_set
226- }
227- ; preconditions =
228- { app_state =
229- { ledger = txn_snark.source
230- ; inner_action_state = old_inner.action_state
231- ; inner_action_state_length = old_inner_action_state_length
232- (* ; sequencer *)
233- ; paused = false
234- ; pause_key
235- ; da_key
236- ; acc_set = txn_snark.source_acc_set
237- }
238- ; valid_while
239- ; action_state
240- }
190+ (* Check that count_commits is matching the precondition *)
191+ assert target_action_state = commit.preconditions.action_state ;
192+
193+ (* Check that enought time elapsed since last commit *)
194+ assert commit.preconditions.valid_while.lower - last_commit.valid_while.upper >= max_sequencer_inactivity;
195+
196+ [ { commit with
197+ children = []
198+ ; preconditions.app_state.sequencer = Ignore
241199 }
242200 ]
243201
0 commit comments