Skip to content

Commit 37e94c3

Browse files
committed
rebase
1 parent 4db861d commit 37e94c3

File tree

10 files changed

+31
-21
lines changed

10 files changed

+31
-21
lines changed

evmrpc/send.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (s *SendAPI) simulateTx(ctx context.Context, tx *ethtypes.Transaction) (est
158158
AccessList: &al,
159159
ChainID: (*hexutil.Big)(tx.ChainId()),
160160
}
161-
estimate_, err := export.DoEstimateGas(ctx, s.backend, txArgs, bNrOrHash, nil, s.backend.RPCGasCap())
161+
estimate_, err := export.DoEstimateGas(ctx, s.backend, txArgs, bNrOrHash, nil, nil, s.backend.RPCGasCap())
162162
if err != nil {
163163
err = fmt.Errorf("failed to estimate gas: %w", err)
164164
return

evmrpc/simulate.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ func (b *Backend) GetEVM(_ context.Context, msg *core.Message, stateDB vm.StateD
385385
if blockCtx == nil {
386386
blockCtx, _ = b.keeper.GetVMBlockContext(b.ctxProvider(LatestCtxHeight).WithIsEVM(true).WithEVMEntryViaWasmdPrecompile(wasmd.IsWasmdCall(msg.To)), core.GasPool(b.RPCGasCap()))
387387
}
388-
return vm.NewEVM(*blockCtx, txContext, stateDB, b.ChainConfig(), *vmConfig, b.keeper.CustomPrecompiles())
388+
evm := vm.NewEVM(*blockCtx, stateDB, b.ChainConfig(), *vmConfig, b.keeper.CustomPrecompiles())
389+
evm.SetTxContext(txContext)
390+
return evm
389391
}
390392

391393
func (b *Backend) CurrentHeader() *ethtypes.Header {

evmrpc/simulate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestEstimateGas(t *testing.T) {
6262
}
6363
resObj = sendRequestGood(t, "estimateGas", txArgs, nil, map[string]interface{}{})
6464
result = resObj["result"].(string)
65-
require.Equal(t, "0x53f9", result) // 21497
65+
require.Equal(t, "0x54ac", result) // 21497
6666

6767
Ctx = Ctx.WithBlockHeight(8)
6868
}

evmrpc/tests/utils.go

+2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ func signAndEncodeTx(txData ethtypes.TxData, mnemonic string) []byte {
191191
typedTx, _ = ethtx.NewDynamicFeeTx(signed)
192192
case *ethtypes.BlobTx:
193193
typedTx, _ = ethtx.NewBlobTx(signed)
194+
case *ethtypes.SetCodeTx:
195+
typedTx, _ = ethtx.NewSetCodeTx(signed)
194196
default:
195197
panic("invalid tx type")
196198
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ replace (
356356
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.55
357357
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0
358358
github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.5
359-
github.com/ethereum/go-ethereum => ../go-ethereum-tmp // github.com/sei-protocol/go-ethereum-tmp v1.15.0-sei-2
359+
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum-tmp v1.15.0-sei-5
360360
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
361361
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.47
362362
// Latest goleveldb is broken, we have to stick to this version

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,8 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod
20092009
github.com/securego/gosec/v2 v2.11.0 h1:+PDkpzR41OI2jrw1q6AdXZCbsNGNGT7pQjal0H0cArI=
20102010
github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo=
20112011
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
2012+
github.com/sei-protocol/go-ethereum-tmp v1.15.0-sei-5 h1:S87yuBaXdX+p2GAXQtIQvd9usCNdUFK6ziOQya9EbJ4=
2013+
github.com/sei-protocol/go-ethereum-tmp v1.15.0-sei-5/go.mod h1:4q+4t48P2C03sjqGvTXix5lEOplf5dz4CTosbjt5tGs=
20122014
github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA=
20132015
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
20142016
github.com/sei-protocol/sei-cosmos v0.3.55 h1:wDWLcKdKN87eWTVHhRbPcR9Fuy2D9bmmCro6GgaU3SE=

precompiles/pointer/pointer_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestAddNative(t *testing.T) {
3434
require.Nil(t, err)
3535
statedb := state.NewDBImpl(ctx, &testApp.EvmKeeper, true)
3636
blockCtx, _ := testApp.EvmKeeper.GetVMBlockContext(ctx, core.GasPool(suppliedGas))
37-
evm := vm.NewEVM(*blockCtx, vm.TxContext{}, statedb, cfg, vm.Config{}, testApp.EvmKeeper.CustomPrecompiles())
37+
evm := vm.NewEVM(*blockCtx, statedb, cfg, vm.Config{}, testApp.EvmKeeper.CustomPrecompiles())
3838
_, g, err := p.RunAndCalculateGas(evm, caller, caller, append(p.GetExecutor().(*pointer.PrecompileExecutor).AddNativePointerID, args...), suppliedGas, nil, nil, false, false)
3939
require.NotNil(t, err)
4040
require.NotNil(t, statedb.GetPrecompileError())
@@ -53,7 +53,7 @@ func TestAddNative(t *testing.T) {
5353
}},
5454
})
5555
statedb = state.NewDBImpl(ctx, &testApp.EvmKeeper, false)
56-
evm = vm.NewEVM(*blockCtx, vm.TxContext{}, statedb, cfg, vm.Config{}, testApp.EvmKeeper.CustomPrecompiles())
56+
evm = vm.NewEVM(*blockCtx, statedb, cfg, vm.Config{}, testApp.EvmKeeper.CustomPrecompiles())
5757
ret, g, err := p.RunAndCalculateGas(evm, caller, caller, append(p.GetExecutor().(*pointer.PrecompileExecutor).AddNativePointerID, args...), suppliedGas, nil, nil, false, false)
5858
require.Nil(t, err)
5959
require.Equal(t, uint64(8889527), g)
@@ -82,7 +82,7 @@ func TestAddNative(t *testing.T) {
8282
testApp.EvmKeeper.DeleteERC20NativePointer(statedb.Ctx(), "test", version)
8383
testApp.EvmKeeper.SetERC20NativePointerWithVersion(statedb.Ctx(), "test", pointerAddr, version-1)
8484
statedb = state.NewDBImpl(statedb.Ctx(), &testApp.EvmKeeper, true)
85-
evm = vm.NewEVM(*blockCtx, vm.TxContext{}, statedb, cfg, vm.Config{}, testApp.EvmKeeper.CustomPrecompiles())
85+
evm = vm.NewEVM(*blockCtx, statedb, cfg, vm.Config{}, testApp.EvmKeeper.CustomPrecompiles())
8686
_, _, err = p.RunAndCalculateGas(evm, caller, caller, append(p.GetExecutor().(*pointer.PrecompileExecutor).AddNativePointerID, args...), suppliedGas, nil, nil, false, false)
8787
require.Nil(t, err)
8888
require.Nil(t, statedb.GetPrecompileError())

x/evm/ante/basic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (gl BasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, n
4747
return ctx, sdkerrors.ErrInvalidCoins
4848
}
4949

50-
intrGas, err := core.IntrinsicGas(etx.Data(), etx.AccessList(), nil, etx.To() == nil, true, true, true)
50+
intrGas, err := core.IntrinsicGas(etx.Data(), etx.AccessList(), etx.SetCodeAuthorizations(), etx.To() == nil, true, true, true)
5151
if err != nil {
5252
return ctx, err
5353
}

x/evm/keeper/evm.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ func (k *Keeper) createReadOnlyEVM(ctx sdk.Context, from sdk.AccAddress) (*vm.EV
179179
return nil, err
180180
}
181181
cfg := types.DefaultChainConfig().EthereumConfig(k.ChainID(ctx))
182-
return vm.NewEVM(*blockCtx, stateDB, cfg, vm.Config{}, k.customPrecompiles), nil
182+
txCtx := vm.TxContext{Origin: k.GetEVMAddressOrDefault(ctx, from)}
183+
evm := vm.NewEVM(*blockCtx, stateDB, cfg, vm.Config{}, k.customPrecompiles)
184+
evm.SetTxContext(txCtx)
185+
return evm, nil
183186
}
184187

185188
func (k *Keeper) getEvmGasLimitFromCtx(ctx sdk.Context) uint64 {

x/evm/keeper/msg_server.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,19 @@ func (k *Keeper) GetGasPool() core.GasPool {
211211

212212
func (k *Keeper) GetEVMMessage(ctx sdk.Context, tx *ethtypes.Transaction, sender common.Address) *core.Message {
213213
msg := &core.Message{
214-
Nonce: tx.Nonce(),
215-
GasLimit: tx.Gas(),
216-
GasPrice: new(big.Int).Set(tx.GasPrice()),
217-
GasFeeCap: new(big.Int).Set(tx.GasFeeCap()),
218-
GasTipCap: new(big.Int).Set(tx.GasTipCap()),
219-
To: tx.To(),
220-
Value: tx.Value(),
221-
Data: tx.Data(),
222-
AccessList: tx.AccessList(),
223-
BlobHashes: tx.BlobHashes(),
224-
BlobGasFeeCap: tx.BlobGasFeeCap(),
225-
From: sender,
214+
Nonce: tx.Nonce(),
215+
GasLimit: tx.Gas(),
216+
GasPrice: new(big.Int).Set(tx.GasPrice()),
217+
GasFeeCap: new(big.Int).Set(tx.GasFeeCap()),
218+
GasTipCap: new(big.Int).Set(tx.GasTipCap()),
219+
To: tx.To(),
220+
Value: tx.Value(),
221+
Data: tx.Data(),
222+
AccessList: tx.AccessList(),
223+
BlobHashes: tx.BlobHashes(),
224+
BlobGasFeeCap: tx.BlobGasFeeCap(),
225+
SetCodeAuthorizations: tx.SetCodeAuthorizations(),
226+
From: sender,
226227
}
227228
// If baseFee provided, set gasPrice to effectiveGasPrice.
228229
baseFee := k.GetBaseFee(ctx)

0 commit comments

Comments
 (0)