@@ -41,7 +41,7 @@ func NewExecutor(
4141}
4242
4343// RunTxns executes the provided transaction and applies the state changes
44- // to the pending state
44+ // to the preconfirmed state
4545func (e * executor ) RunTxns (state * BuildState , txns []mempool.BroadcastedTransaction ) (err error ) {
4646 if len (txns ) == 0 {
4747 return nil
@@ -58,7 +58,7 @@ func (e *executor) RunTxns(state *BuildState, txns []mempool.BroadcastedTransact
5858 }()
5959
6060 // Create a state writer for the transaction execution
61- stateWriter := sync .NewPendingStateWriter (state .Pending .StateUpdate .StateDiff , state .Pending .NewClasses , headState )
61+ stateWriter := sync .NewPendingStateWriter (state .Preconfirmed .StateUpdate .StateDiff , state .Preconfirmed .NewClasses , headState )
6262
6363 // Prepare declared classes, if any
6464 var declaredClasses []core.Class
@@ -80,7 +80,7 @@ func (e *executor) RunTxns(state *BuildState, txns []mempool.BroadcastedTransact
8080 declaredClasses ,
8181 paidFeesOnL1 ,
8282 & vm.BlockInfo {
83- Header : state .Pending .Block .Header ,
83+ Header : state .Preconfirmed .Block .Header ,
8484 BlockHashToBeRevealed : state .RevealedBlockHash ,
8585 },
8686 stateWriter ,
@@ -102,16 +102,16 @@ func (e *executor) RunTxns(state *BuildState, txns []mempool.BroadcastedTransact
102102
103103 // Adapt results to core type (which use reference types)
104104 receipts := make ([]* core.TransactionReceipt , len (txns ))
105- mergedStateDiff := vm2core . AdaptStateDiff ( vmResults . Traces [ 0 ] .StateDiff )
105+ stateDiffs := make ([] * core .StateDiff , len ( vmResults . Traces ) )
106106 for i , trace := range vmResults .Traces {
107107 adaptedStateDiff := vm2core .AdaptStateDiff (trace .StateDiff )
108- mergedStateDiff .Merge (& adaptedStateDiff )
109108 adaptedReceipt := vm2core .Receipt (vmResults .OverallFees [i ], txns [i ].Transaction , & vmResults .Traces [i ], & vmResults .Receipts [i ])
110109 receipts [i ] = & adaptedReceipt
110+ stateDiffs [i ] = & adaptedStateDiff
111111 }
112112
113- // Update pending block with transaction results
114- updatePendingBlock (state .Pending , receipts , coreTxns , mergedStateDiff )
113+ // Update preconfirmed block with transaction results
114+ updatePreconfirmedBlock (state .Preconfirmed , receipts , coreTxns , stateDiffs )
115115
116116 for i := range vmResults .GasConsumed {
117117 state .L2GasConsumed += vmResults .GasConsumed [i ].L2Gas
@@ -138,22 +138,25 @@ func (e *executor) processClassDeclaration(txn *mempool.BroadcastedTransaction,
138138 return nil
139139}
140140
141- // updatePendingBlock updates the pending block with transaction results
142- func updatePendingBlock (
143- pending * sync. Pending ,
141+ // updatePreconfirmedBlock updates the preconfirmed block with transaction results
142+ func updatePreconfirmedBlock (
143+ preconfirmed * core. PreConfirmed ,
144144 receipts []* core.TransactionReceipt ,
145145 transactions []core.Transaction ,
146- stateDiff core.StateDiff ,
146+ stateDiffs [] * core.StateDiff ,
147147) {
148- pending .Block .Receipts = append (pending .Block .Receipts , receipts ... )
149- pending .Block .Transactions = append (pending .Block .Transactions , transactions ... )
150- pending .Block .TransactionCount += uint64 (len (transactions ))
148+ preconfirmed .Block .Receipts = append (preconfirmed .Block .Receipts , receipts ... )
149+ preconfirmed .TransactionStateDiffs = append (preconfirmed .TransactionStateDiffs , stateDiffs ... )
150+ preconfirmed .Block .Transactions = append (preconfirmed .Block .Transactions , transactions ... )
151+ preconfirmed .Block .TransactionCount += uint64 (len (transactions ))
151152 for _ , receipt := range receipts {
152- pending .Block .EventCount += uint64 (len (receipt .Events ))
153+ preconfirmed .Block .EventCount += uint64 (len (receipt .Events ))
154+ }
155+ for _ , stateDiff := range stateDiffs {
156+ preconfirmed .StateUpdate .StateDiff .Merge (stateDiff )
153157 }
154- pending .StateUpdate .StateDiff .Merge (& stateDiff )
155158}
156159
157160func (e * executor ) Finish (state * BuildState ) (blockchain.SimulateResult , error ) {
158- return e .blockchain .Simulate (state .Pending .Block , state .Pending .StateUpdate , state .Pending .NewClasses , nil )
161+ return e .blockchain .Simulate (state .Preconfirmed .Block , state .Preconfirmed .StateUpdate , state .Preconfirmed .NewClasses , nil )
159162}
0 commit comments