@@ -229,6 +229,17 @@ func (s *Storage) writeContractUpdate(
229
229
230
230
// Commit serializes/saves all values in the readCache in storage (through the runtime interface).
231
231
func (s * Storage ) Commit (inter * interpreter.Interpreter , commitContractUpdates bool ) error {
232
+ return s .commit (inter , commitContractUpdates , true )
233
+ }
234
+
235
+ // NondeterministicCommit serializes and commits all values in the deltas storage
236
+ // in nondeterministic order. This function is used when commit ordering isn't
237
+ // required (e.g. migration programs).
238
+ func (s * Storage ) NondeterministicCommit (inter * interpreter.Interpreter , commitContractUpdates bool ) error {
239
+ return s .commit (inter , commitContractUpdates , false )
240
+ }
241
+
242
+ func (s * Storage ) commit (inter * interpreter.Interpreter , commitContractUpdates bool , deterministic bool ) error {
232
243
233
244
if commitContractUpdates {
234
245
s .commitContractUpdates (inter )
@@ -252,7 +263,11 @@ func (s *Storage) Commit(inter *interpreter.Interpreter, commitContractUpdates b
252
263
common .UseMemory (s .memoryGauge , common .NewAtreeEncodedSlabMemoryUsage (deltas ))
253
264
254
265
// TODO: report encoding metric for all encoded slabs
255
- return s .PersistentSlabStorage .FastCommit (runtime .NumCPU ())
266
+ if deterministic {
267
+ return s .PersistentSlabStorage .FastCommit (runtime .NumCPU ())
268
+ } else {
269
+ return s .PersistentSlabStorage .NondeterministicFastCommit (runtime .NumCPU ())
270
+ }
256
271
}
257
272
258
273
func (s * Storage ) commitNewStorageMaps () error {
0 commit comments