@@ -22,7 +22,6 @@ import (
22
22
23
23
"github.com/ethereum/go-ethereum/common"
24
24
"github.com/ethereum/go-ethereum/consensus/misc"
25
- "github.com/ethereum/go-ethereum/core/state"
26
25
"github.com/ethereum/go-ethereum/core/types"
27
26
"github.com/ethereum/go-ethereum/core/vm"
28
27
"github.com/ethereum/go-ethereum/crypto"
@@ -53,7 +52,7 @@ func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain) *StatePro
53
52
// Process returns the receipts and logs accumulated during the process and
54
53
// returns the amount of gas that was used in the process. If any of the
55
54
// transactions failed to execute due to insufficient gas it will return an error.
56
- func (p * StateProcessor ) Process (block * types.Block , statedb * state .StateDB , cfg vm.Config ) (* ProcessResult , error ) {
55
+ func (p * StateProcessor ) Process (block * types.Block , statedb vm .StateDB , cfg vm.Config ) (* ProcessResult , error ) {
57
56
var (
58
57
receipts types.Receipts
59
58
usedGas = new (uint64 )
@@ -64,15 +63,9 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
64
63
gp = new (GasPool ).AddGas (block .GasLimit ())
65
64
)
66
65
67
- var usedStateDb vm.StateDB
68
- if w := statedb .Wrapped (); w != nil {
69
- usedStateDb = w
70
- } else {
71
- usedStateDb = statedb
72
- }
73
66
// Mutate the block and state according to any hard-fork specs
74
67
if p .config .DAOForkSupport && p .config .DAOForkBlock != nil && p .config .DAOForkBlock .Cmp (block .Number ()) == 0 {
75
- misc .ApplyDAOHardFork (usedStateDb )
68
+ misc .ApplyDAOHardFork (statedb )
76
69
}
77
70
var (
78
71
context vm.BlockContext
@@ -82,12 +75,12 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
82
75
// Apply pre-execution system calls.
83
76
context = NewEVMBlockContext (header , p .chain , nil )
84
77
85
- vmenv := vm .NewEVM (context , vm.TxContext {}, usedStateDb , p .config , cfg )
78
+ vmenv := vm .NewEVM (context , vm.TxContext {}, statedb , p .config , cfg )
86
79
if beaconRoot := block .BeaconRoot (); beaconRoot != nil {
87
- ProcessBeaconBlockRoot (* beaconRoot , vmenv , usedStateDb )
80
+ ProcessBeaconBlockRoot (* beaconRoot , vmenv , statedb )
88
81
}
89
82
if p .config .IsPrague (block .Number (), block .Time ()) {
90
- ProcessParentBlockHash (block .ParentHash (), vmenv , usedStateDb )
83
+ ProcessParentBlockHash (block .ParentHash (), vmenv , statedb )
91
84
}
92
85
93
86
// Iterate over and process the individual transactions
@@ -130,7 +123,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
130
123
// ApplyTransactionWithEVM attempts to apply a transaction to the given state database
131
124
// and uses the input parameters for its environment similar to ApplyTransaction. However,
132
125
// this method takes an already created EVM instance as input.
133
- func ApplyTransactionWithEVM (msg * Message , config * params.ChainConfig , gp * GasPool , statedb * state .StateDB , blockNumber * big.Int , blockHash common.Hash , tx * types.Transaction , usedGas * uint64 , evm * vm.EVM ) (receipt * types.Receipt , err error ) {
126
+ func ApplyTransactionWithEVM (msg * Message , config * params.ChainConfig , gp * GasPool , statedb vm .StateDB , blockNumber * big.Int , blockHash common.Hash , tx * types.Transaction , usedGas * uint64 , evm * vm.EVM ) (receipt * types.Receipt , err error ) {
134
127
if evm .Config .Tracer != nil && evm .Config .Tracer .OnTxStart != nil {
135
128
evm .Config .Tracer .OnTxStart (evm .GetVMContext (), tx , msg .From )
136
129
if evm .Config .Tracer .OnTxEnd != nil {
@@ -139,16 +132,10 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo
139
132
}()
140
133
}
141
134
}
142
- var usedStateDb vm.StateDB
143
- if w := statedb .Wrapped (); w != nil {
144
- usedStateDb = w
145
- } else {
146
- usedStateDb = statedb
147
- }
148
135
149
136
// Create a new context to be used in the EVM environment.
150
137
txContext := NewEVMTxContext (msg )
151
- evm .Reset (txContext , usedStateDb )
138
+ evm .Reset (txContext , statedb )
152
139
153
140
// Apply the transaction to the current state (included in the env).
154
141
result , err := ApplyMessage (evm , msg , gp )
@@ -159,7 +146,7 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo
159
146
// Update the state with pending changes.
160
147
var root []byte
161
148
if config .IsByzantium (blockNumber ) {
162
- usedStateDb .Finalise (true )
149
+ statedb .Finalise (true )
163
150
} else {
164
151
root = statedb .IntermediateRoot (config .IsEIP158 (blockNumber )).Bytes ()
165
152
}
@@ -169,7 +156,7 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo
169
156
}
170
157
171
158
// MakeReceipt generates the receipt object for a transaction given its execution result.
172
- func MakeReceipt (evm * vm.EVM , result * ExecutionResult , statedb * state .StateDB , blockNumber * big.Int , blockHash common.Hash , tx * types.Transaction , usedGas uint64 , root []byte ) * types.Receipt {
159
+ func MakeReceipt (evm * vm.EVM , result * ExecutionResult , statedb vm .StateDB , blockNumber * big.Int , blockHash common.Hash , tx * types.Transaction , usedGas uint64 , root []byte ) * types.Receipt {
173
160
// Create a new receipt for the transaction, storing the intermediate root and gas used
174
161
// by the tx.
175
162
receipt := & types.Receipt {Type : tx .Type (), PostState : root , CumulativeGasUsed : usedGas }
@@ -193,9 +180,12 @@ func MakeReceipt(evm *vm.EVM, result *ExecutionResult, statedb *state.StateDB, b
193
180
194
181
// Merge the tx-local access event into the "block-local" one, in order to collect
195
182
// all values, so that the witness can be built.
196
- if statedb .GetTrie ().IsVerkle () {
197
- statedb .AccessEvents ().Merge (evm .AccessEvents )
198
- }
183
+ //
184
+ // TODO (@holiman): Add this back (but not necessarily _here_)
185
+ //
186
+ //if statedb.GetTrie().IsVerkle() {
187
+ // statedb.AccessEvents().Merge(evm.AccessEvents)
188
+ //}
199
189
200
190
// Set the receipt logs and create the bloom filter.
201
191
receipt .Logs = statedb .GetLogs (tx .Hash (), blockNumber .Uint64 (), blockHash )
@@ -210,7 +200,7 @@ func MakeReceipt(evm *vm.EVM, result *ExecutionResult, statedb *state.StateDB, b
210
200
// and uses the input parameters for its environment. It returns the receipt
211
201
// for the transaction, gas used and an error if the transaction failed,
212
202
// indicating the block was invalid.
213
- func ApplyTransaction (config * params.ChainConfig , bc ChainContext , author * common.Address , gp * GasPool , statedb * state .StateDB , header * types.Header , tx * types.Transaction , usedGas * uint64 , cfg vm.Config ) (* types.Receipt , error ) {
203
+ func ApplyTransaction (config * params.ChainConfig , bc ChainContext , author * common.Address , gp * GasPool , statedb vm .StateDB , header * types.Header , tx * types.Transaction , usedGas * uint64 , cfg vm.Config ) (* types.Receipt , error ) {
214
204
msg , err := TransactionToMessage (tx , types .MakeSigner (config , header .Number , header .Time ), header .BaseFee )
215
205
if err != nil {
216
206
return nil , err
0 commit comments