@@ -23,7 +23,7 @@ import (
23
23
"github.com/ethereum/go-ethereum/eth"
24
24
"github.com/ethereum/go-ethereum/eth/tracers"
25
25
"github.com/ethereum/go-ethereum/ethdb"
26
- "github.com/ethereum/go-ethereum/lib/ethapi "
26
+ "github.com/ethereum/go-ethereum/export "
27
27
"github.com/ethereum/go-ethereum/params"
28
28
"github.com/ethereum/go-ethereum/rpc"
29
29
"github.com/sei-protocol/sei-chain/utils"
@@ -64,15 +64,15 @@ type AccessListResult struct {
64
64
GasUsed hexutil.Uint64 `json:"gasUsed"`
65
65
}
66
66
67
- func (s * SimulationAPI ) CreateAccessList (ctx context.Context , args ethapi .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash ) (result * AccessListResult , returnErr error ) {
67
+ func (s * SimulationAPI ) CreateAccessList (ctx context.Context , args export .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash ) (result * AccessListResult , returnErr error ) {
68
68
startTime := time .Now ()
69
69
defer recordMetrics ("eth_createAccessList" , s .connectionType , startTime , returnErr == nil )
70
70
bNrOrHash := rpc .BlockNumberOrHashWithNumber (rpc .PendingBlockNumber )
71
71
if blockNrOrHash != nil {
72
72
bNrOrHash = * blockNrOrHash
73
73
}
74
74
ctx = context .WithValue (ctx , CtxIsWasmdPrecompileCallKey , wasmd .IsWasmdCall (args .To ))
75
- acl , gasUsed , vmerr , err := ethapi .AccessList (ctx , s .backend , bNrOrHash , args )
75
+ acl , gasUsed , vmerr , err := export .AccessList (ctx , s .backend , bNrOrHash , args )
76
76
if err != nil {
77
77
return nil , err
78
78
}
@@ -83,31 +83,31 @@ func (s *SimulationAPI) CreateAccessList(ctx context.Context, args ethapi.Transa
83
83
return result , nil
84
84
}
85
85
86
- func (s * SimulationAPI ) EstimateGas (ctx context.Context , args ethapi .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash , overrides * ethapi .StateOverride ) (result hexutil.Uint64 , returnErr error ) {
86
+ func (s * SimulationAPI ) EstimateGas (ctx context.Context , args export .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash , overrides * export .StateOverride ) (result hexutil.Uint64 , returnErr error ) {
87
87
startTime := time .Now ()
88
88
defer recordMetricsWithError ("eth_estimateGas" , s .connectionType , startTime , returnErr )
89
89
bNrOrHash := rpc .BlockNumberOrHashWithNumber (rpc .LatestBlockNumber )
90
90
if blockNrOrHash != nil {
91
91
bNrOrHash = * blockNrOrHash
92
92
}
93
93
ctx = context .WithValue (ctx , CtxIsWasmdPrecompileCallKey , wasmd .IsWasmdCall (args .To ))
94
- estimate , err := ethapi .DoEstimateGas (ctx , s .backend , args , bNrOrHash , overrides , s .backend .RPCGasCap ())
94
+ estimate , err := export .DoEstimateGas (ctx , s .backend , args , bNrOrHash , overrides , nil , s .backend .RPCGasCap ())
95
95
return estimate , err
96
96
}
97
97
98
- func (s * SimulationAPI ) EstimateGasAfterCalls (ctx context.Context , args ethapi .TransactionArgs , calls []ethapi .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash , overrides * ethapi .StateOverride ) (result hexutil.Uint64 , returnErr error ) {
98
+ func (s * SimulationAPI ) EstimateGasAfterCalls (ctx context.Context , args export .TransactionArgs , calls []export .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash , overrides * export .StateOverride ) (result hexutil.Uint64 , returnErr error ) {
99
99
startTime := time .Now ()
100
100
defer recordMetricsWithError ("eth_estimateGasAfterCalls" , s .connectionType , startTime , returnErr )
101
101
bNrOrHash := rpc .BlockNumberOrHashWithNumber (rpc .LatestBlockNumber )
102
102
if blockNrOrHash != nil {
103
103
bNrOrHash = * blockNrOrHash
104
104
}
105
105
ctx = context .WithValue (ctx , CtxIsWasmdPrecompileCallKey , wasmd .IsWasmdCall (args .To ))
106
- estimate , err := ethapi .DoEstimateGasAfterCalls (ctx , s .backend , args , calls , bNrOrHash , overrides , s .backend .RPCEVMTimeout (), s .backend .RPCGasCap ())
106
+ estimate , err := export .DoEstimateGasAfterCalls (ctx , s .backend , args , calls , bNrOrHash , overrides , s .backend .RPCEVMTimeout (), s .backend .RPCGasCap ())
107
107
return estimate , err
108
108
}
109
109
110
- func (s * SimulationAPI ) Call (ctx context.Context , args ethapi .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash , overrides * ethapi .StateOverride , blockOverrides * ethapi .BlockOverrides ) (result hexutil.Bytes , returnErr error ) {
110
+ func (s * SimulationAPI ) Call (ctx context.Context , args export .TransactionArgs , blockNrOrHash * rpc.BlockNumberOrHash , overrides * export .StateOverride , blockOverrides * export .BlockOverrides ) (result hexutil.Bytes , returnErr error ) {
111
111
startTime := time .Now ()
112
112
defer recordMetrics ("eth_call" , s .connectionType , startTime , returnErr == nil )
113
113
defer func () {
@@ -124,7 +124,7 @@ func (s *SimulationAPI) Call(ctx context.Context, args ethapi.TransactionArgs, b
124
124
blockNrOrHash = & latest
125
125
}
126
126
ctx = context .WithValue (ctx , CtxIsWasmdPrecompileCallKey , wasmd .IsWasmdCall (args .To ))
127
- callResult , err := ethapi .DoCall (ctx , s .backend , args , * blockNrOrHash , overrides , blockOverrides , s .backend .RPCEVMTimeout (), s .backend .RPCGasCap ())
127
+ callResult , err := export .DoCall (ctx , s .backend , args , * blockNrOrHash , overrides , blockOverrides , s .backend .RPCEVMTimeout (), s .backend .RPCGasCap ())
128
128
if err != nil {
129
129
return nil , err
130
130
}
@@ -204,16 +204,16 @@ func (b *Backend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHas
204
204
return state .NewDBImpl (sdkCtx , b .keeper , true ), b .getHeader (big .NewInt (height )), nil
205
205
}
206
206
207
- func (b * Backend ) GetTransaction (ctx context.Context , txHash common.Hash ) (tx * ethtypes.Transaction , blockHash common.Hash , blockNumber uint64 , index uint64 , err error ) {
207
+ func (b * Backend ) GetTransaction (ctx context.Context , txHash common.Hash ) (found bool , tx * ethtypes.Transaction , blockHash common.Hash , blockNumber uint64 , index uint64 , err error ) {
208
208
sdkCtx := b .ctxProvider (LatestCtxHeight )
209
209
receipt , err := b .keeper .GetReceipt (sdkCtx , txHash )
210
210
if err != nil {
211
- return nil , common.Hash {}, 0 , 0 , err
211
+ return false , nil , common.Hash {}, 0 , 0 , err
212
212
}
213
213
txHeight := int64 (receipt .BlockNumber )
214
214
block , err := blockByNumber (ctx , b .tmClient , & txHeight )
215
215
if err != nil {
216
- return nil , common.Hash {}, 0 , 0 , err
216
+ return false , nil , common.Hash {}, 0 , 0 , err
217
217
}
218
218
txIndex := hexutil .Uint (receipt .TransactionIndex )
219
219
tmTx := block .Block .Txs [int (txIndex )]
@@ -223,11 +223,11 @@ func (b *Backend) GetTransaction(ctx context.Context, txHash common.Hash) (tx *e
223
223
return err == nil
224
224
})
225
225
if ! found {
226
- return nil , common.Hash {}, 0 , 0 , errors .New ("failed to find transaction in block" )
226
+ return false , nil , common.Hash {}, 0 , 0 , errors .New ("failed to find transaction in block" )
227
227
}
228
228
tx = getEthTxForTxBz (tmTx , b .txDecoder )
229
229
blockHash = common .BytesToHash (block .Block .Header .Hash ().Bytes ())
230
- return tx , blockHash , uint64 (txHeight ), uint64 (evmTxIndex ), nil
230
+ return true , tx , blockHash , uint64 (txHeight ), uint64 (evmTxIndex ), nil
231
231
}
232
232
233
233
func (b * Backend ) ChainDb () ethdb.Database {
@@ -323,7 +323,6 @@ func (b *Backend) StateAtTransaction(ctx context.Context, block *ethtypes.Block,
323
323
if err != nil {
324
324
return nil , vm.BlockContext {}, nil , nil , err
325
325
}
326
- txContext := core .NewEVMTxContext (msg )
327
326
blockContext , err := b .keeper .GetVMBlockContext (b .ctxProvider (prevBlockHeight ), core .GasPool (b .RPCGasCap ()))
328
327
if err != nil {
329
328
return nil , vm.BlockContext {}, nil , nil , err
@@ -352,7 +351,7 @@ func (b *Backend) StateAtTransaction(ctx context.Context, block *ethtypes.Block,
352
351
}
353
352
statedb .WithCtx (statedb .Ctx ().WithEVMEntryViaWasmdPrecompile (wasmd .IsWasmdCall (tx .To ())))
354
353
// Not yet the searched for transaction, execute on top of the current state
355
- vmenv := vm .NewEVM (* blockContext , txContext , statedb , b .ChainConfig (), vm.Config {})
354
+ vmenv := vm .NewEVM (* blockContext , statedb , b .ChainConfig (), vm.Config {})
356
355
statedb .SetTxContext (tx .Hash (), idx )
357
356
if _ , err := core .ApplyMessage (vmenv , msg , new (core.GasPool ).AddGas (tx .Gas ())); err != nil {
358
357
return nil , vm.BlockContext {}, nil , nil , fmt .Errorf ("transaction %#x failed: %v" , tx .Hash (), err )
@@ -391,11 +390,10 @@ func (b *Backend) StateAtBlock(ctx context.Context, block *ethtypes.Block, reexe
391
390
}
392
391
393
392
func (b * Backend ) GetEVM (_ context.Context , msg * core.Message , stateDB vm.StateDB , _ * ethtypes.Header , vmConfig * vm.Config , blockCtx * vm.BlockContext ) * vm.EVM {
394
- txContext := core .NewEVMTxContext (msg )
395
393
if blockCtx == nil {
396
394
blockCtx , _ = b .keeper .GetVMBlockContext (b .ctxProvider (LatestCtxHeight ).WithIsEVM (true ).WithEVMEntryViaWasmdPrecompile (wasmd .IsWasmdCall (msg .To )), core .GasPool (b .RPCGasCap ()))
397
395
}
398
- return vm .NewEVM (* blockCtx , txContext , stateDB , b .ChainConfig (), * vmConfig )
396
+ return vm .NewEVM (* blockCtx , stateDB , b .ChainConfig (), * vmConfig )
399
397
}
400
398
401
399
func (b * Backend ) CurrentHeader () * ethtypes.Header {
0 commit comments