1- package seiv3
1+ package evmonly
22
33import (
44 "context"
@@ -13,19 +13,18 @@ import (
1313 "github.com/ethereum/go-ethereum/core/vm"
1414 "github.com/ethereum/go-ethereum/crypto"
1515 "github.com/ethereum/go-ethereum/params"
16- "github.com/sei-protocol/sei-chain/giga/evmonly"
1716 "github.com/sei-protocol/sei-chain/giga/evmonly/precompiles"
1817)
1918
2019// Executor runs raw EVM transactions against an EVM-native state backend.
2120type Executor struct {
2221 cfg Config
23- state evmonly. StateReader
22+ state StateReader
2423}
2524
2625type Option func (* Executor )
2726
28- func WithState (state evmonly. StateReader ) Option {
27+ func WithState (state StateReader ) Option {
2928 return func (e * Executor ) {
3029 if state != nil {
3130 e .state = state
@@ -36,7 +35,7 @@ func WithState(state evmonly.StateReader) Option {
3635func NewExecutor (cfg Config , opts ... Option ) * Executor {
3736 e := & Executor {
3837 cfg : cfg .WithDefaults (),
39- state : evmonly . NewMemoryState (),
38+ state : NewMemoryState (),
4039 }
4140 for _ , opt := range opts {
4241 opt (e )
@@ -48,9 +47,9 @@ func (e *Executor) Config() Config {
4847 return e .cfg
4948}
5049
51- func (e * Executor ) ExecuteBlock (ctx context.Context , req evmonly. BlockRequest ) (* evmonly. BlockResult , error ) {
50+ func (e * Executor ) ExecuteBlock (ctx context.Context , req BlockRequest ) (* BlockResult , error ) {
5251 if len (req .Txs ) == 0 {
53- return & evmonly. BlockResult {}, nil
52+ return & BlockResult {}, nil
5453 }
5554
5655 chainConfig := e .chainConfig (req .Context )
@@ -72,8 +71,8 @@ func (e *Executor) ExecuteBlock(ctx context.Context, req evmonly.BlockRequest) (
7271 gasPool := new (core.GasPool ).AddGas (gasLimit )
7372 baseFee := cloneBig (req .Context .BaseFee )
7473
75- result := & evmonly. BlockResult {
76- Txs : make ([]evmonly. TxResult , 0 , len (parsed )),
74+ result := & BlockResult {
75+ Txs : make ([]TxResult , 0 , len (parsed )),
7776 Receipts : make (ethtypes.Receipts , 0 , len (parsed )),
7877 }
7978 for txIndex , p := range parsed {
@@ -101,31 +100,31 @@ func (e *Executor) executeTx(
101100 evm * vm.EVM ,
102101 stateDB * nativeStateDB ,
103102 gasPool * core.GasPool ,
104- block evmonly. BlockContext ,
103+ block BlockContext ,
105104 p parsedTx ,
106105 txIndex int ,
107106 baseFee * big.Int ,
108107 signer ethtypes.Signer ,
109- ) (evmonly. TxResult , * ethtypes.Receipt , error ) {
108+ ) (TxResult , * ethtypes.Receipt , error ) {
110109 tx := p .tx
111110 if e .cfg .CustomPrecompiles != nil && tx .To () != nil {
112111 if _ , ok := e .cfg .CustomPrecompiles .Get (* tx .To ()); ok {
113- return evmonly. TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : precompiles .ErrCustomPrecompilesOpen },
112+ return TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : precompiles .ErrCustomPrecompilesOpen },
114113 nil ,
115114 precompiles .ErrCustomPrecompilesOpen
116115 }
117116 }
118117 if ! e .cfg .DisableGasPriceCheck && e .cfg .MinGasPrice != nil {
119118 if effectiveGasPrice (tx , baseFee ).Cmp (e .cfg .MinGasPrice ) < 0 {
120- return evmonly. TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : errInsufficientGasPrice },
119+ return TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : errInsufficientGasPrice },
121120 nil ,
122121 errInsufficientGasPrice
123122 }
124123 }
125124
126125 msg , err := core .TransactionToMessage (tx , signer , baseFee )
127126 if err != nil {
128- return evmonly. TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : err }, nil , err
127+ return TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : err }, nil , err
129128 }
130129 msg .SkipNonceChecks = e .cfg .DisableNonceCheck
131130
@@ -134,7 +133,7 @@ func (e *Executor) executeTx(
134133 evm .SetTxContext (core .NewEVMTxContext (msg ))
135134 execResult , err := core .ApplyMessage (evm , msg , gasPool )
136135 if err != nil {
137- return evmonly. TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : err }, nil , err
136+ return TxResult {Hash : tx .Hash (), Sender : p .sender , To : tx .To (), Err : err }, nil , err
138137 }
139138
140139 txLogs := append ([]* ethtypes.Log (nil ), stateDB .logs [logStart :]... )
@@ -165,7 +164,7 @@ func (e *Executor) executeTx(
165164 }
166165 receipt .Bloom = ethtypes .CreateBloom (receipt )
167166
168- txResult := evmonly. TxResult {
167+ txResult := TxResult {
169168 Hash : tx .Hash (),
170169 Sender : p .sender ,
171170 To : tx .To (),
@@ -179,7 +178,7 @@ func (e *Executor) executeTx(
179178 return txResult , receipt , nil
180179}
181180
182- func buildBlockContext (ctx evmonly. BlockContext ) vm.BlockContext {
181+ func buildBlockContext (ctx BlockContext ) vm.BlockContext {
183182 prevRandao := ctx .PrevRandao
184183 baseFee := cloneBig (ctx .BaseFee )
185184 blobBaseFee := cloneBig (ctx .BlobBaseFee )
@@ -232,7 +231,7 @@ func customPrecompileMap(registry precompiles.Registry) map[common.Address]vm.Pr
232231 return contracts
233232}
234233
235- func (e * Executor ) chainConfig (ctx evmonly. BlockContext ) * params.ChainConfig {
234+ func (e * Executor ) chainConfig (ctx BlockContext ) * params.ChainConfig {
236235 var cfg params.ChainConfig
237236 if e .cfg .ChainConfig != nil {
238237 cfg = * e .cfg .ChainConfig
@@ -259,11 +258,4 @@ func effectiveGasPrice(tx *ethtypes.Transaction, baseFee *big.Int) *big.Int {
259258 return tx .GasPrice ()
260259}
261260
262- func cloneBig (v * big.Int ) * big.Int {
263- if v == nil {
264- return new (big.Int )
265- }
266- return new (big.Int ).Set (v )
267- }
268-
269261var errInsufficientGasPrice = fmt .Errorf ("insufficient gas price" )
0 commit comments