@@ -95,13 +95,22 @@ type (
9595 actionCtx protocol.ActionCtx
9696 helperCtx HelperContext
9797 }
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+ }
98108)
99109
100110// newParams creates a new context for use in the EVM.
101111func newParams (
102112 ctx context.Context ,
103113 execution action.TxData ,
104- stateDB * StateDBAdapter ,
105114) (* Params , error ) {
106115 var (
107116 actionCtx = protocol .MustGetActionCtx (ctx )
@@ -134,15 +143,15 @@ func newParams(
134143 }
135144 case featureCtx .FixGetHashFnHeight :
136145 getHashFn = func (n uint64 ) common.Hash {
137- hash , err := getBlockHash (stateDB . blockHeight - (n + 1 ))
146+ hash , err := getBlockHash (blkCtx . BlockHeight - (n + 1 ))
138147 if err == nil {
139148 return common .BytesToHash (hash [:])
140149 }
141150 return common.Hash {}
142151 }
143152 default :
144153 getHashFn = func (n uint64 ) common.Hash {
145- hash , err := getBlockHash (stateDB . blockHeight - n )
154+ hash , err := getBlockHash (blkCtx . BlockHeight - n )
146155 if err != nil {
147156 // initial implementation did wrong, should return common.Hash{} in case of error
148157 return common .BytesToHash (hash [:])
@@ -241,7 +250,7 @@ func ExecuteContract(
241250 if err != nil {
242251 return nil , nil , err
243252 }
244- ps , err := newParams (ctx , execution , stateDB )
253+ ps , err := newParams (ctx , execution )
245254 if err != nil {
246255 return nil , nil , err
247256 }
@@ -428,7 +437,7 @@ func getChainConfig(g genesis.Blockchain, height uint64, id uint32, getBlockTime
428437}
429438
430439// 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 ) {
432441 var (
433442 gasLimit = evmParams .blkCtx .GasLimit
434443 blockHeight = evmParams .blkCtx .BlockHeight
0 commit comments