Skip to content

Commit

Permalink
Make ChainID a config instead of a param (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen authored Apr 16, 2024
1 parent fbe9c80 commit c5b0abd
Show file tree
Hide file tree
Showing 42 changed files with 151 additions and 175 deletions.
4 changes: 2 additions & 2 deletions aclmapping/evm/mappings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ func (suite *KeeperTestSuite) buildSendMsgTo(to common.Address, amt *big.Int) *t
To: &to,
Value: amt,
Data: []byte(""),
ChainID: suite.App.EvmKeeper.ChainID(suite.Ctx),
ChainID: suite.App.EvmKeeper.ChainID(),
}
ethCfg := types.DefaultChainConfig().EthereumConfig(suite.App.EvmKeeper.ChainID(suite.Ctx))
ethCfg := types.DefaultChainConfig().EthereumConfig(suite.App.EvmKeeper.ChainID())
signer := ethtypes.MakeSigner(ethCfg, big.NewInt(suite.Ctx.BlockHeight()), uint64(suite.Ctx.BlockTime().Unix()))
tx := ethtypes.NewTx(&txData)
tx, err := ethtypes.SignTx(tx, signer, suite.sender)
Expand Down
2 changes: 1 addition & 1 deletion app/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestEvmAnteErrorHandler(t *testing.T) {
Data: []byte{},
Nonce: 1, // will cause ante error
}
chainID := testkeeper.EVMTestApp.EvmKeeper.ChainID(ctx)
chainID := testkeeper.EVMTestApp.EvmKeeper.ChainID()
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down
7 changes: 6 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import (
"github.com/sei-protocol/sei-chain/x/evm"
evmante "github.com/sei-protocol/sei-chain/x/evm/ante"
"github.com/sei-protocol/sei-chain/x/evm/blocktest"
evmconfig "github.com/sei-protocol/sei-chain/x/evm/config"
evmkeeper "github.com/sei-protocol/sei-chain/x/evm/keeper"
"github.com/sei-protocol/sei-chain/x/evm/querier"
"github.com/sei-protocol/sei-chain/x/evm/replay"
Expand Down Expand Up @@ -587,9 +588,13 @@ func New(
wasmOpts...,
)

evmConfig, err := evmconfig.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading EVM config due to %s", err))
}
app.EvmKeeper = *evmkeeper.NewKeeper(keys[evmtypes.StoreKey], memKeys[evmtypes.MemStoreKey],
app.GetSubspace(evmtypes.ModuleName), app.BankKeeper, &app.AccountKeeper, &app.StakingKeeper,
app.TransferKeeper, wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper))
app.TransferKeeper, wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper), &evmConfig)
app.evmRPCConfig, err = evmrpc.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading EVM config due to %s", err))
Expand Down
7 changes: 7 additions & 0 deletions cmd/seid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/sei-protocol/sei-chain/evmrpc"
"github.com/sei-protocol/sei-chain/tools"
"github.com/sei-protocol/sei-chain/x/evm/blocktest"
evmconfig "github.com/sei-protocol/sei-chain/x/evm/config"
"github.com/sei-protocol/sei-chain/x/evm/querier"
"github.com/sei-protocol/sei-chain/x/evm/replay"
"github.com/spf13/cast"
Expand Down Expand Up @@ -381,6 +382,8 @@ func initAppConfig() (string, interface{}) {
ETHBlockTest blocktest.Config `mapstructure:"eth_block_test"`

EvmQuery querier.Config `mapstructure:"evm_query"`

EvmModule evmconfig.Config `mapstructure:"evm_module"`
}

// Optionally allow the chain developer to overwrite the SDK's default
Expand Down Expand Up @@ -424,6 +427,7 @@ func initAppConfig() (string, interface{}) {
ETHReplay: replay.DefaultConfig,
ETHBlockTest: blocktest.DefaultConfig,
EvmQuery: querier.DefaultConfig,
EvmModule: evmconfig.DefaultConfig,
}

customAppTemplate := serverconfig.DefaultConfigTemplate + `
Expand Down Expand Up @@ -503,6 +507,9 @@ eth_blocktest_test_data_path = "{{ .ETHBlockTest.TestDataPath }}"
[evm_query]
evm_query_gas_limit = {{ .EvmQuery.GasLimit }}
[evm_module]
evm_chain_id = {{ .EvmModule.ChainID }}
`

return customAppTemplate, customAppConfig
Expand Down
2 changes: 1 addition & 1 deletion evmrpc/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (i *InfoAPI) BlockNumber() hexutil.Uint64 {
func (i *InfoAPI) ChainId() *hexutil.Big {
startTime := time.Now()
defer recordMetrics("eth_ChainId", startTime, true)
return (*hexutil.Big)(i.keeper.ChainID(i.ctxProvider(LatestCtxHeight)))
return (*hexutil.Big)(i.keeper.ChainID())
}

func (i *InfoAPI) Coinbase() (common.Address, error) {
Expand Down
2 changes: 1 addition & 1 deletion evmrpc/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ func NewNetAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int
func (i *NetAPI) Version() string {
startTime := time.Now()
defer recordMetrics("net_version", startTime, true)
return fmt.Sprintf("%d", i.keeper.ChainID(i.ctxProvider(LatestCtxHeight)).Uint64())
return fmt.Sprintf("%d", i.keeper.ChainID().Uint64())
}
2 changes: 1 addition & 1 deletion evmrpc/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (s *SendAPI) signTransaction(unsignedTx *ethtypes.Transaction, from string)
if !ok {
return nil, errors.New("from address does not have hosted key")
}
chainId := s.keeper.ChainID(s.ctxProvider(LatestCtxHeight))
chainId := s.keeper.ChainID()
signer := ethtypes.LatestSignerForChainID(chainId)
return ethtypes.SignTx(unsignedTx, signer, privKey)
}
4 changes: 2 additions & 2 deletions evmrpc/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func TestSendRawTransaction(t *testing.T) {
To: &to,
Value: big.NewInt(1000),
Data: []byte("abc"),
ChainID: EVMKeeper.ChainID(Ctx),
ChainID: EVMKeeper.ChainID(),
}
mnemonic := "fish mention unlock february marble dove vintage sand hub ordinary fade found inject room embark supply fabric improve spike stem give current similar glimpse"
derivedPriv, _ := hd.Secp256k1.Derive()(mnemonic, "", "")
privKey := hd.Secp256k1.Generate()(derivedPriv)
testPrivHex := hex.EncodeToString(privKey.Bytes())
key, _ := crypto.HexToECDSA(testPrivHex)
ethCfg := types.DefaultChainConfig().EthereumConfig(EVMKeeper.ChainID(Ctx))
ethCfg := types.DefaultChainConfig().EthereumConfig(EVMKeeper.ChainID())
signer := ethtypes.MakeSigner(ethCfg, big.NewInt(Ctx.BlockHeight()), uint64(Ctx.BlockTime().Unix()))
tx := ethtypes.NewTx(&txData)
tx, err := ethtypes.SignTx(tx, signer, key)
Expand Down
5 changes: 3 additions & 2 deletions evmrpc/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/sei-protocol/sei-chain/app"
"github.com/sei-protocol/sei-chain/evmrpc"
"github.com/sei-protocol/sei-chain/utils"
"github.com/sei-protocol/sei-chain/x/evm/config"
"github.com/sei-protocol/sei-chain/x/evm/keeper"
"github.com/sei-protocol/sei-chain/x/evm/types"
evmtypes "github.com/sei-protocol/sei-chain/x/evm/types"
Expand Down Expand Up @@ -449,7 +450,7 @@ func init() {
}

func generateTxData() {
chainId := big.NewInt(types.DefaultChainID.Int64())
chainId := big.NewInt(config.DefaultConfig.ChainID)
to := common.HexToAddress("010203")
var txBuilder1, txBuilder1_5, txBuilder2, txBuilder3, txBuilder4 client.TxBuilder
txBuilder1, tx1 = buildTx(ethtypes.DynamicFeeTx{
Expand Down Expand Up @@ -572,7 +573,7 @@ func generateTxData() {
}

func buildTx(txData ethtypes.DynamicFeeTx) (client.TxBuilder, *ethtypes.Transaction) {
chainId := big.NewInt(types.DefaultChainID.Int64())
chainId := big.NewInt(config.DefaultConfig.ChainID)
mnemonic := "fish mention unlock february marble dove vintage sand hub ordinary fade found inject room embark supply fabric improve spike stem give current similar glimpse"
derivedPriv, _ := hd.Secp256k1.Derive()(mnemonic, "", "")
privKey := hd.Secp256k1.Generate()(derivedPriv)
Expand Down
3 changes: 1 addition & 2 deletions evmrpc/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ func (b *Backend) RPCGasCap() uint64 { return b.config.GasCap }
func (b *Backend) RPCEVMTimeout() time.Duration { return b.config.EVMTimeout }

func (b *Backend) ChainConfig() *params.ChainConfig {
ctx := b.ctxProvider(LatestCtxHeight)
return types.DefaultChainConfig().EthereumConfig(b.keeper.ChainID(ctx))
return types.DefaultChainConfig().EthereumConfig(b.keeper.ChainID())
}

func (b *Backend) GetPoolNonce(_ context.Context, addr common.Address) (uint64, error) {
Expand Down
8 changes: 4 additions & 4 deletions evmrpc/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestEstimateGas(t *testing.T) {
"to": to.Hex(),
"value": "0x10",
"nonce": "0x1",
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID(Ctx)),
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID()),
}
amts := sdk.NewCoins(sdk.NewCoin(EVMKeeper.GetBaseDenom(Ctx), sdk.NewInt(20)))
EVMKeeper.BankKeeper().MintCoins(Ctx, types.ModuleName, amts)
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestEstimateGas(t *testing.T) {
"to": contractAddr.Hex(),
"value": "0x0",
"nonce": "0x2",
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID(Ctx)),
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID()),
"input": fmt.Sprintf("%#x", input),
}
resObj = sendRequestGood(t, "estimateGas", txArgs, nil, map[string]interface{}{})
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestCreateAccessList(t *testing.T) {
"to": contractAddr.Hex(),
"value": "0x0",
"nonce": "0x1",
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID(Ctx)),
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID()),
"input": fmt.Sprintf("%#x", input),
}
amts := sdk.NewCoins(sdk.NewCoin(EVMKeeper.GetBaseDenom(Ctx), sdk.NewInt(20)))
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestCall(t *testing.T) {
"to": contractAddr.Hex(),
"value": "0x0",
"nonce": "0x2",
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID(Ctx)),
"chainId": fmt.Sprintf("%#x", EVMKeeper.ChainID()),
"input": fmt.Sprintf("%#x", input),
}
resObj := sendRequestGood(t, "call", txArgs, nil, map[string]interface{}{}, map[string]interface{}{})
Expand Down
2 changes: 1 addition & 1 deletion evmrpc/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (t *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.H
etx := getEthTxForTxBz(tx, t.txConfig.TxDecoder())
if etx != nil && etx.Hash() == hash {
signer := ethtypes.MakeSigner(
types.DefaultChainConfig().EthereumConfig(t.keeper.ChainID(sdkCtx)),
types.DefaultChainConfig().EthereumConfig(t.keeper.ChainID()),
big.NewInt(sdkCtx.BlockHeight()),
uint64(sdkCtx.BlockTime().Unix()),
)
Expand Down
2 changes: 1 addition & 1 deletion evmrpc/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (t *TxPoolAPI) Content(ctx context.Context) (result map[string]map[string]m

sdkCtx := t.ctxProvider(LatestCtxHeight)
signer := ethtypes.MakeSigner(
types.DefaultChainConfig().EthereumConfig(t.keeper.ChainID(sdkCtx)),
types.DefaultChainConfig().EthereumConfig(t.keeper.ChainID()),
big.NewInt(sdkCtx.BlockHeight()),
uint64(sdkCtx.BlockTime().Unix()),
)
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ require (
github.com/fzipp/gocyclo v0.5.1 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-critic/go-critic v0.6.3 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand Down Expand Up @@ -172,6 +173,7 @@ require (
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
Expand Down Expand Up @@ -765,6 +766,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/guptarohit/asciigraph v0.5.5/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag=
Expand Down
2 changes: 1 addition & 1 deletion precompiles/bank/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestRun(t *testing.T) {
Data: argsNative,
Nonce: 0,
}
chainID := k.ChainID(ctx)
chainID := k.ChainID()
chainCfg := types.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down
2 changes: 1 addition & 1 deletion precompiles/distribution/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestWithdraw(t *testing.T) {
Data: args,
Nonce: 0,
}
chainID := k.ChainID(ctx)
chainID := k.ChainID()
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down
4 changes: 2 additions & 2 deletions precompiles/gov/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestVoteDeposit(t *testing.T) {
Data: args,
Nonce: 0,
}
chainID := k.ChainID(ctx)
chainID := k.ChainID()
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestVoteDeposit(t *testing.T) {
Data: args,
Nonce: 0,
}
chainID := k.ChainID(ctx)
chainID := k.ChainID()
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down
2 changes: 1 addition & 1 deletion precompiles/ibc/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestPrecompile_Run(t *testing.T) {
fields: fields{transferKeeper: &MockTransferKeeper{}},
args: commonArgs,
wantBz: packedTrue,
wantRemainingGas: 992974,
wantRemainingGas: 994040,
wantErr: false,
},
{
Expand Down
2 changes: 1 addition & 1 deletion precompiles/pointer/pointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAddNative(t *testing.T) {
ctx := testApp.GetContextForDeliverTx([]byte{}).WithBlockTime(time.Now())
_, caller := testkeeper.MockAddressPair()
suppliedGas := uint64(10000000)
cfg := types.DefaultChainConfig().EthereumConfig(testApp.EvmKeeper.ChainID(ctx))
cfg := types.DefaultChainConfig().EthereumConfig(testApp.EvmKeeper.ChainID())

// token has no metadata
m, err := p.ABI.MethodById(p.AddNativePointerID)
Expand Down
4 changes: 2 additions & 2 deletions precompiles/staking/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestStaking(t *testing.T) {
Data: args,
Nonce: 0,
}
chainID := k.ChainID(ctx)
chainID := k.ChainID()
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestStakingError(t *testing.T) {
Data: args,
Nonce: 0,
}
chainID := k.ChainID(ctx)
chainID := k.ChainID()
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down
14 changes: 7 additions & 7 deletions precompiles/wasmd/wasmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestInstantiate(t *testing.T) {
require.Equal(t, 2, len(outputs))
require.Equal(t, "sei1hrpna9v7vs3stzyd4z3xf00676kf78zpe2u5ksvljswn2vnjp3yslucc3n", outputs[0].(string))
require.Empty(t, outputs[1].([]byte))
require.Equal(t, uint64(879782), g)
require.Equal(t, uint64(880848), g)

amtsbz, err = sdk.NewCoins().MarshalJSON()
require.Nil(t, err)
Expand All @@ -101,7 +101,7 @@ func TestInstantiate(t *testing.T) {
require.Equal(t, 2, len(outputs))
require.Equal(t, "sei1hrpna9v7vs3stzyd4z3xf00676kf78zpe2u5ksvljswn2vnjp3yslucc3n", outputs[0].(string))
require.Empty(t, outputs[1].([]byte))
require.Equal(t, uint64(902838), g)
require.Equal(t, uint64(903904), g)

// non-existent code ID
args, _ = instantiateMethod.Inputs.Pack(
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestExecute(t *testing.T) {
require.Nil(t, err)
require.Equal(t, 1, len(outputs))
require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(outputs[0].([]byte)))
require.Equal(t, uint64(906041), g)
require.Equal(t, uint64(907107), g)
require.Equal(t, int64(1000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64())

amtsbz, err = sdk.NewCoins().MarshalJSON()
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestQuery(t *testing.T) {
require.Nil(t, err)
require.Equal(t, 1, len(outputs))
require.Equal(t, "{\"message\":\"query test\"}", string(outputs[0].([]byte)))
require.Equal(t, uint64(930367), g)
require.Equal(t, uint64(931433), g)

// bad contract address
args, _ = queryMethod.Inputs.Pack(mockAddr.String(), []byte("{\"info\":{}}"))
Expand Down Expand Up @@ -304,7 +304,7 @@ func TestExecuteBatchOneMessage(t *testing.T) {
require.Nil(t, err)
require.Equal(t, 1, len(outputs))
require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string((outputs[0].([][]byte))[0]))
require.Equal(t, uint64(906041), g)
require.Equal(t, uint64(907107), g)
require.Equal(t, int64(1000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64())

amtsbz, err = sdk.NewCoins().MarshalJSON()
Expand Down Expand Up @@ -409,7 +409,7 @@ func TestExecuteBatchMultipleMessages(t *testing.T) {
require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[0]))
require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[1]))
require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[2]))
require.Equal(t, uint64(725379), g)
require.Equal(t, uint64(726445), g)
require.Equal(t, int64(3000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64())

amtsbz2, err := sdk.NewCoins().MarshalJSON()
Expand All @@ -436,7 +436,7 @@ func TestExecuteBatchMultipleMessages(t *testing.T) {
require.Equal(t, fmt.Sprintf("received test msg from %s with", mockAddr.String()), string(parsedOutputs[0]))
require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[1]))
require.Equal(t, fmt.Sprintf("received test msg from %s with", mockAddr.String()), string(parsedOutputs[2]))
require.Equal(t, uint64(773900), g)
require.Equal(t, uint64(774966), g)
require.Equal(t, int64(1000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64())

// allowed delegatecall
Expand Down
12 changes: 6 additions & 6 deletions proto/evm/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ string minimum_fee_per_gas = 4 [
(gogoproto.jsontag) = "minimum_fee_per_gas"
];
// ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
string chain_id = 6 [
(gogoproto.moretags) = "yaml:\"chain_id\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "chain_id"
];
// string chain_id = 6 [
// (gogoproto.moretags) = "yaml:\"chain_id\"",
// (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
// (gogoproto.nullable) = false,
// (gogoproto.jsontag) = "chain_id"
// ];
// repeated string whitelisted_codehashes_bank_send = 7 [
// (gogoproto.moretags) = "yaml:\"whitelisted_codehashes_bank_send\"",
// (gogoproto.jsontag) = "whitelisted_codehashes_bank_send"
Expand Down
Loading

0 comments on commit c5b0abd

Please sign in to comment.