@@ -95,13 +95,22 @@ type (
95
95
actionCtx protocol.ActionCtx
96
96
helperCtx HelperContext
97
97
}
98
+
99
+ stateDB interface {
100
+ vm.StateDB
101
+
102
+ CommitContracts () error
103
+ Logs () []* action.Log
104
+ TransactionLogs () []* action.TransactionLog
105
+ clear ()
106
+ Error () error
107
+ }
98
108
)
99
109
100
110
// newParams creates a new context for use in the EVM.
101
111
func newParams (
102
112
ctx context.Context ,
103
113
execution action.TxData ,
104
- stateDB * StateDBAdapter ,
105
114
) (* Params , error ) {
106
115
var (
107
116
actionCtx = protocol .MustGetActionCtx (ctx )
@@ -134,15 +143,15 @@ func newParams(
134
143
}
135
144
case featureCtx .FixGetHashFnHeight :
136
145
getHashFn = func (n uint64 ) common.Hash {
137
- hash , err := getBlockHash (stateDB . blockHeight - (n + 1 ))
146
+ hash , err := getBlockHash (blkCtx . BlockHeight - (n + 1 ))
138
147
if err == nil {
139
148
return common .BytesToHash (hash [:])
140
149
}
141
150
return common.Hash {}
142
151
}
143
152
default :
144
153
getHashFn = func (n uint64 ) common.Hash {
145
- hash , err := getBlockHash (stateDB . blockHeight - n )
154
+ hash , err := getBlockHash (blkCtx . BlockHeight - n )
146
155
if err != nil {
147
156
// initial implementation did wrong, should return common.Hash{} in case of error
148
157
return common .BytesToHash (hash [:])
@@ -241,7 +250,7 @@ func ExecuteContract(
241
250
if err != nil {
242
251
return nil , nil , err
243
252
}
244
- ps , err := newParams (ctx , execution , stateDB )
253
+ ps , err := newParams (ctx , execution )
245
254
if err != nil {
246
255
return nil , nil , err
247
256
}
@@ -428,7 +437,7 @@ func getChainConfig(g genesis.Blockchain, height uint64, id uint32, getBlockTime
428
437
}
429
438
430
439
// Error in executeInEVM is a consensus issue
431
- func executeInEVM (ctx context.Context , evmParams * Params , stateDB * StateDBAdapter ) ([]byte , uint64 , uint64 , string , iotextypes.ReceiptStatus , error ) {
440
+ func executeInEVM (ctx context.Context , evmParams * Params , stateDB stateDB ) ([]byte , uint64 , uint64 , string , iotextypes.ReceiptStatus , error ) {
432
441
var (
433
442
gasLimit = evmParams .blkCtx .GasLimit
434
443
blockHeight = evmParams .blkCtx .BlockHeight
0 commit comments