diff --git a/Makefile b/Makefile index d3fdbb26..c72f0120 100644 --- a/Makefile +++ b/Makefile @@ -393,7 +393,7 @@ format-fix: ############################################################################### -protoVer=0.11.6 +protoVer=0.14.0 protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) diff --git a/app/ante/ante.go b/app/ante/ante.go index fb9501c6..e77461d2 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -19,9 +19,10 @@ import ( "fmt" "runtime/debug" - tmlog "github.com/cometbft/cometbft/libs/log" + tmlog "cosmossdk.io/log" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" @@ -114,7 +115,7 @@ var _ authante.SignatureVerificationGasConsumer = DefaultSigVerificationGasConsu // for signature verification based upon the public key type. The cost is fetched from the given params and is matched // by the concrete type. func DefaultSigVerificationGasConsumer( - meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params, + meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params, ) error { pubkey := sig.PubKey switch pubkey := pubkey.(type) { @@ -137,7 +138,7 @@ func DefaultSigVerificationGasConsumer( // ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubkey signature func ConsumeMultisignatureVerificationGas( - meter sdk.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey, + meter storetypes.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey, params authtypes.Params, accSeq uint64, ) error { size := sig.BitArray.Count() diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index c666b2ce..f1029ec9 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -9,6 +9,7 @@ import ( "time" sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/stretchr/testify/suite" @@ -26,10 +27,11 @@ import ( "github.com/ethereum/go-ethereum/core/types" ethparams "github.com/ethereum/go-ethereum/params" - "github.com/zeta-chain/ethermint/app/ante" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/tests" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/app/ante" + "github.com/evmos/ethermint/crypto/ethsecp256k1" + "github.com/evmos/ethermint/tests" + evmtypes "github.com/evmos/ethermint/x/evm/types" amino "github.com/cosmos/cosmos-sdk/codec" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -56,8 +58,8 @@ func TestAnteTestSuite(t *testing.T) { }) } -func (suite AnteTestSuite) TestAnteHandler() { - var acc authtypes.AccountI +func (suite *AnteTestSuite) TestAnteHandler() { + var acc sdk.AccountI addr, privKey := tests.NewAddrKey() to := tests.GenerateAddress() @@ -364,7 +366,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 create validator", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MsgCreateValidator(from, privKey, "ethermint_9000-1", gas, amount) @@ -375,7 +377,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 create validator (with blank fields)", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MsgCreateValidator2(from, privKey, "ethermint_9000-1", gas, amount) @@ -386,7 +388,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgSubmitProposal", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) gasAmount := sdk.NewCoins(coinAmount) gas := uint64(200000) // reusing the gasAmount for deposit @@ -400,7 +402,7 @@ func (suite AnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := acc.GetAddress() grantee := sdk.AccAddress("_______grantee______") - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) gasAmount := sdk.NewCoins(coinAmount) gas := uint64(200000) blockTime := time.Date(1, 1, 1, 1, 1, 1, 1, time.UTC) @@ -417,7 +419,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgGrantAllowance", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) gasAmount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712GrantAllowance(from, privKey, "ethermint_9000-1", gas, gasAmount) @@ -428,7 +430,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 edit validator", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MsgEditValidator(from, privKey, "ethermint_9000-1", gas, amount) @@ -439,7 +441,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 submit evidence", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MsgSubmitEvidence(from, privKey, "ethermint_9000-1", gas, amount) @@ -450,7 +452,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 submit proposal v1", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712SubmitProposalV1(from, privKey, "ethermint_9000-1", gas, amount) @@ -461,7 +463,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgExec", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MsgExec(from, privKey, "ethermint_9000-1", gas, amount) @@ -472,7 +474,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgVoteV1", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MsgVoteV1(from, privKey, "ethermint_9000-1", gas, amount) @@ -483,7 +485,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 Multiple MsgSend", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MultipleMsgSend(from, privKey, "ethermint_9000-1", gas, amount) @@ -494,7 +496,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "fails - DeliverTx EIP712 Multiple Signers", func() sdk.Tx { from := acc.GetAddress() - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder := suite.CreateTestEIP712MultipleSignerMsgs(from, privKey, "ethermint_9000-1", gas, amount) @@ -605,7 +607,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -635,7 +637,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -665,7 +667,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -720,7 +722,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -750,7 +752,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -780,7 +782,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -810,7 +812,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -824,7 +826,7 @@ func (suite AnteTestSuite) TestAnteHandler() { "EIP-712", ) - msg.Amount[0].Amount = sdk.NewInt(5) + msg.Amount[0].Amount = sdkmath.NewInt(5) txBuilder.SetMsgs(msg) return txBuilder.GetTx() @@ -843,7 +845,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -872,7 +874,7 @@ func (suite AnteTestSuite) TestAnteHandler() { sdk.NewCoins( sdk.NewCoin( "photon", - sdk.NewInt(1), + sdkmath.NewInt(1), ), ), ) @@ -933,7 +935,7 @@ func (suite AnteTestSuite) TestAnteHandler() { suite.Run(tc.name, func() { setup() - suite.ctx = suite.ctx.WithIsCheckTx(tc.checkTx).WithIsReCheckTx(tc.reCheckTx) + suite.ctx = suite.ctx.WithIsCheckTx(tc.checkTx).WithIsReCheckTx(tc.reCheckTx).WithConsensusParams(*app.DefaultConsensusParams) // expConsumed := params.TxGasContractCreation + params.TxGas _, err := suite.anteHandler(suite.ctx, tc.txFn(), false) @@ -1203,8 +1205,8 @@ func (suite AnteTestSuite) TestAnteHandlerWithDynamicTxFee() { suite.Require().NoError(acc.SetSequence(1)) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - suite.ctx = suite.ctx.WithIsCheckTx(tc.checkTx).WithIsReCheckTx(tc.reCheckTx) - suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000)) + suite.ctx = suite.ctx.WithIsCheckTx(tc.checkTx).WithIsReCheckTx(tc.reCheckTx).WithConsensusParams(*app.DefaultConsensusParams) + suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000), evmtypes.DefaultEVMDenom) _, err := suite.anteHandler(suite.ctx, tc.txFn(), false) if tc.expPass { suite.Require().NoError(err) @@ -1332,8 +1334,8 @@ func (suite AnteTestSuite) TestAnteHandlerWithParams() { suite.Require().NoError(acc.SetSequence(1)) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - suite.ctx = suite.ctx.WithIsCheckTx(true) - suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000)) + suite.ctx = suite.ctx.WithIsCheckTx(true).WithConsensusParams(*app.DefaultConsensusParams) + suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000), evmtypes.DefaultEVMDenom) _, err := suite.anteHandler(suite.ctx, tc.txFn(), false) if tc.expErr == nil { suite.Require().NoError(err) @@ -1369,7 +1371,7 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { } type args struct { - meter sdk.GasMeter + meter storetypes.GasMeter sig signing.SignatureData pubkey cryptotypes.PubKey params authtypes.Params @@ -1380,11 +1382,11 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { gasConsumed uint64 shouldErr bool }{ - {"PubKeyEd25519", args{sdk.NewInfiniteGasMeter(), nil, ed25519.GenPrivKey().PubKey(), params}, p.SigVerifyCostED25519, true}, - {"PubKeyEthSecp256k1", args{sdk.NewInfiniteGasMeter(), nil, pkSet1[0], params}, 21_000, false}, - {"PubKeySecp256r1", args{sdk.NewInfiniteGasMeter(), nil, skR1.PubKey(), params}, p.SigVerifyCostSecp256r1(), false}, - {"Multisig", args{sdk.NewInfiniteGasMeter(), multisignature1, multisigKey1, params}, expectedCost1, false}, - {"unknown key", args{sdk.NewInfiniteGasMeter(), nil, nil, params}, 0, true}, + {"PubKeyEd25519", args{storetypes.NewInfiniteGasMeter(), nil, ed25519.GenPrivKey().PubKey(), params}, p.SigVerifyCostED25519, true}, + {"PubKeyEthSecp256k1", args{storetypes.NewInfiniteGasMeter(), nil, pkSet1[0], params}, 21_000, false}, + {"PubKeySecp256r1", args{storetypes.NewInfiniteGasMeter(), nil, skR1.PubKey(), params}, p.SigVerifyCostSecp256r1(), false}, + {"Multisig", args{storetypes.NewInfiniteGasMeter(), multisignature1, multisigKey1, params}, expectedCost1, false}, + {"unknown key", args{storetypes.NewInfiniteGasMeter(), nil, nil, params}, 0, true}, } for _, tt := range tests { sigV2 := signing.SignatureV2{ diff --git a/app/ante/authz_test.go b/app/ante/authz_test.go index 49996a62..dc5b133d 100644 --- a/app/ante/authz_test.go +++ b/app/ante/authz_test.go @@ -4,6 +4,7 @@ import ( "fmt" "time" + sdkmath "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -274,7 +275,7 @@ func (suite *AnteTestSuite) TestRejectDeliverMsgsInAuthz() { }, ), }, - expectedCode: sdkerrors.ErrUnpackAny.ABCICode(), + expectedCode: sdkerrors.ErrUnauthorized.ABCICode(), }, { name: "a MsgExec with nested MsgExec messages that has invalid messages is blocked", @@ -287,7 +288,7 @@ func (suite *AnteTestSuite) TestRejectDeliverMsgsInAuthz() { }, ), }, - expectedCode: sdkerrors.ErrUnpackAny.ABCICode(), + expectedCode: sdkerrors.ErrUnauthorized.ABCICode(), }, { name: "a MsgExec with more nested MsgExec messages than allowed and with valid messages is blocked", @@ -325,20 +326,30 @@ func (suite *AnteTestSuite) TestRejectDeliverMsgsInAuthz() { bz, err := txEncoder(tx) suite.Require().NoError(err) - resCheckTx := suite.app.CheckTx( - abci.RequestCheckTx{ + resCheckTx, err := suite.app.CheckTx( + &abci.RequestCheckTx{ Tx: bz, Type: abci.CheckTxType_New, }, ) + suite.Require().NoError(err) suite.Require().Equal(resCheckTx.Code, tc.expectedCode, resCheckTx.Log) - resDeliverTx := suite.app.DeliverTx( - abci.RequestDeliverTx{ - Tx: bz, + header := suite.ctx.BlockHeader() + blockRes, err := suite.app.FinalizeBlock( + &abci.RequestFinalizeBlock{ + Height: header.Height, + Txs: [][]byte{bz}, + Hash: header.AppHash, + NextValidatorsHash: header.NextValidatorsHash, + ProposerAddress: header.ProposerAddress, + Time: header.Time.Add(time.Second), }, ) - suite.Require().Equal(resDeliverTx.Code, tc.expectedCode, resDeliverTx.Log) + suite.Require().NoError(err) + suite.Require().Len(blockRes.TxResults, 1) + txRes := blockRes.TxResults[0] + suite.Require().Equal(txRes.Code, tc.expectedCode, txRes.Log) }) } } @@ -423,7 +434,7 @@ func (suite *AnteTestSuite) createTx(priv cryptotypes.PrivKey, msgs ...sdk.Msg) } func (suite *AnteTestSuite) createEIP712Tx(priv cryptotypes.PrivKey, msgs ...sdk.Msg) (sdk.Tx, error) { - coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) + coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)) fees := sdk.NewCoins(coinAmount) cosmosTxArgs := utiltx.CosmosTxArgs{ TxCfg: suite.clientCtx.TxConfig, diff --git a/app/ante/eip712.go b/app/ante/eip712.go index 0a779d8e..327c76db 100644 --- a/app/ante/eip712.go +++ b/app/ante/eip712.go @@ -19,6 +19,7 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" + txsigning "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -28,7 +29,7 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" + ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" @@ -82,13 +83,13 @@ func NewLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler { // CONTRACT: Tx must implement SigVerifiableTx interface type LegacyEip712SigVerificationDecorator struct { ak evmtypes.AccountKeeper - signModeHandler authsigning.SignModeHandler + signModeHandler *txsigning.HandlerMap } // Deprecated: NewLegacyEip712SigVerificationDecorator creates a new LegacyEip712SigVerificationDecorator func NewLegacyEip712SigVerificationDecorator( ak evmtypes.AccountKeeper, - signModeHandler authsigning.SignModeHandler, + signModeHandler *txsigning.HandlerMap, ) LegacyEip712SigVerificationDecorator { return LegacyEip712SigVerificationDecorator{ ak: ak, @@ -125,7 +126,10 @@ func (svd LegacyEip712SigVerificationDecorator) AnteHandle(ctx sdk.Context, return ctx, err } - signerAddrs := sigTx.GetSigners() + signerAddrs, err := sigTx.GetSigners() + if err != nil { + return ctx, err + } // EIP712 allows just one signature if len(sigs) != 1 { @@ -197,7 +201,7 @@ func VerifySignature( pubKey cryptotypes.PubKey, signerData authsigning.SignerData, sigData signing.SignatureData, - _ authsigning.SignModeHandler, + _ *txsigning.HandlerMap, tx authsigning.Tx, ) error { switch data := sigData.(type) { @@ -228,7 +232,7 @@ func VerifySignature( Amount: tx.GetFee(), Gas: tx.GetGas(), }, - msgs, tx.GetMemo(), tx.GetTip(), + msgs, tx.GetMemo(), ) signerChainID, err := ethermint.ParseChainID(signerData.ChainID) diff --git a/app/ante/eth_test.go b/app/ante/eth_test.go index 5c9d9d4a..64bfd0b5 100644 --- a/app/ante/eth_test.go +++ b/app/ante/eth_test.go @@ -7,14 +7,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/holiman/uint256" - "github.com/zeta-chain/ethermint/app/ante" - "github.com/zeta-chain/ethermint/server/config" - "github.com/zeta-chain/ethermint/tests" - ethermint "github.com/zeta-chain/ethermint/types" - "github.com/zeta-chain/ethermint/x/evm/statedb" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" - + storetypes "cosmossdk.io/store/types" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/evmos/ethermint/app/ante" + "github.com/evmos/ethermint/server/config" + "github.com/evmos/ethermint/tests" + ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/statedb" + evmtypes "github.com/evmos/ethermint/x/evm/types" ) func (suite AnteTestSuite) TestNewEthAccountVerificationDecorator() { @@ -173,7 +173,7 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { ethCfg := suite.app.EvmKeeper.GetParams(suite.ctx). ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) baseFee := suite.app.EvmKeeper.GetBaseFee(suite.ctx, ethCfg) - suite.Require().Equal(int64(1000000000), baseFee.Int64()) + suite.Require().Equal(int64(765625000), baseFee.Int64()) gasPrice := new(big.Int).Add(baseFee, evmtypes.DefaultPriorityReduction.BigInt()) @@ -252,8 +252,8 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { tx2, 0, func() { - vmdb.AddBalance(addr, uint256.NewInt(1000000)) - suite.ctx = suite.ctx.WithBlockGasMeter(sdk.NewGasMeter(1)) + vmdb.AddBalance(addr, big.NewInt(1000000)) + suite.ctx = suite.ctx.WithBlockGasMeter(storetypes.NewGasMeter(1)) }, false, true, 0, @@ -263,8 +263,8 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { tx2, tx2GasLimit, // it's capped func() { - vmdb.AddBalance(addr, uint256.NewInt(1001000000000000)) - suite.ctx = suite.ctx.WithBlockGasMeter(sdk.NewGasMeter(10000000000000000000)) + vmdb.AddBalance(addr, big.NewInt(1001000000000000)) + suite.ctx = suite.ctx.WithBlockGasMeter(storetypes.NewGasMeter(10000000000000000000)) }, true, false, tx2Priority, @@ -274,8 +274,8 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { dynamicFeeTx, tx2GasLimit, // it's capped func() { - vmdb.AddBalance(addr, uint256.NewInt(1001000000000000)) - suite.ctx = suite.ctx.WithBlockGasMeter(sdk.NewGasMeter(10000000000000000000)) + vmdb.AddBalance(addr, big.NewInt(1001000000000000)) + suite.ctx = suite.ctx.WithBlockGasMeter(storetypes.NewGasMeter(10000000000000000000)) }, true, false, dynamicFeeTxPriority, @@ -301,12 +301,18 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { if tc.expPanic { suite.Require().Panics(func() { - _, _ = dec.AnteHandle(suite.ctx.WithIsCheckTx(true).WithGasMeter(sdk.NewGasMeter(1)), tc.tx, false, NextFn) + _, _ = ante.CheckEthGasConsume( + suite.ctx.WithIsCheckTx(true).WithGasMeter(storetypes.NewGasMeter(1)), tc.tx, + ethCfg, suite.app.EvmKeeper, baseFee, config.DefaultMaxTxGasWanted, evmtypes.DefaultEVMDenom, + ) }) return } - ctx, err := dec.AnteHandle(suite.ctx.WithIsCheckTx(true).WithGasMeter(sdk.NewInfiniteGasMeter()), tc.tx, false, NextFn) + ctx, err := ante.CheckEthGasConsume( + suite.ctx.WithIsCheckTx(true).WithGasMeter(storetypes.NewInfiniteGasMeter()), tc.tx, + ethCfg, suite.app.EvmKeeper, baseFee, config.DefaultMaxTxGasWanted, evmtypes.DefaultEVMDenom, + ) if tc.expPass { suite.Require().NoError(err) suite.Require().Equal(tc.expPriority, ctx.Priority()) diff --git a/app/ante/fee_checker.go b/app/ante/fee_checker.go index 703838f8..926d5009 100644 --- a/app/ante/fee_checker.go +++ b/app/ante/fee_checker.go @@ -120,8 +120,7 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.FeeTx) (sdk.Coi // Determine the required fees by multiplying each required minimum gas // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - // #nosec G115 always in range - glDec := sdk.NewDec(int64(gas)) + glDec := sdkmath.LegacyNewDec(int64(gas)) for i, gp := range minGasPrices { fee := gp.Amount.Mul(glDec) diff --git a/app/ante/fee_checker_test.go b/app/ante/fee_checker_test.go index e2912234..d8983704 100644 --- a/app/ante/fee_checker_test.go +++ b/app/ante/fee_checker_test.go @@ -4,19 +4,20 @@ import ( "math/big" "testing" + sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/require" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/ethereum/go-ethereum/params" "github.com/zeta-chain/ethermint/encoding" ethermint "github.com/zeta-chain/ethermint/types" "github.com/zeta-chain/ethermint/x/evm/types" evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + feemarkettypes "github.com/zeta-chain/ethermint/x/feemarket/types" ) var _ DynamicFeeEVMKeeper = MockEVMKeeper{} @@ -51,8 +52,8 @@ func TestSDKTxFeeChecker(t *testing.T) { // with extension option // without extension option // london hardfork enableness - encodingConfig := encoding.MakeConfig(module.NewBasicManager()) - minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin("aphoton", sdk.NewInt(10))) + encodingConfig := encoding.MakeConfig() + minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin("aphoton", sdkmath.NewInt(10))) genesisCtx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger()) checkTxCtx := sdk.NewContext(nil, tmproto.Header{Height: 1}, true, log.NewNopLogger()).WithMinGasPrices(minGasPrices) @@ -96,7 +97,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.Tx { txBuilder := encodingConfig.TxConfig.NewTxBuilder() txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdkmath.NewInt(10)))) return txBuilder.GetTx() }, "10aphoton", @@ -138,7 +139,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.Tx { txBuilder := encodingConfig.TxConfig.NewTxBuilder() txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdkmath.NewInt(10)))) return txBuilder.GetTx() }, "10aphoton", @@ -154,7 +155,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.Tx { txBuilder := encodingConfig.TxConfig.NewTxBuilder() txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10).Mul(types.DefaultPriorityReduction).Add(sdk.NewInt(10))))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdkmath.NewInt(10).Mul(types.DefaultPriorityReduction).Add(sdkmath.NewInt(10))))) return txBuilder.GetTx() }, "10000010aphoton", @@ -170,7 +171,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.Tx { txBuilder := encodingConfig.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder) txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10).Mul(types.DefaultPriorityReduction)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdkmath.NewInt(10).Mul(types.DefaultPriorityReduction)))) option, err := codectypes.NewAnyWithValue(ðermint.ExtensionOptionDynamicFeeTx{}) require.NoError(t, err) @@ -190,10 +191,10 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.Tx { txBuilder := encodingConfig.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder) txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10).Mul(types.DefaultPriorityReduction).Add(sdk.NewInt(10))))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdkmath.NewInt(10).Mul(types.DefaultPriorityReduction).Add(sdkmath.NewInt(10))))) option, err := codectypes.NewAnyWithValue(ðermint.ExtensionOptionDynamicFeeTx{ - MaxPriorityPrice: sdk.NewInt(5).Mul(types.DefaultPriorityReduction), + MaxPriorityPrice: sdkmath.NewInt(5).Mul(types.DefaultPriorityReduction), }) require.NoError(t, err) txBuilder.SetExtensionOptions(option) @@ -207,7 +208,15 @@ func TestSDKTxFeeChecker(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - fees, priority, err := NewDynamicFeeChecker(tc.keeper)(tc.ctx, tc.buildTx()) + evmParams := tc.keeper.GetParams(tc.ctx) + feemarketParams := feemarkettypes.Params{ + NoBaseFee: false, + BaseFee: sdkmath.NewIntFromBigInt(tc.keeper.BaseFee), + } + chainID := tc.keeper.ChainID() + chainCfg := evmParams.GetChainConfig() + ethCfg := chainCfg.EthereumConfig(chainID) + fees, priority, err := NewDynamicFeeChecker(ethCfg, &evmParams, &feemarketParams)(tc.ctx, tc.buildTx()) if tc.expSuccess { require.Equal(t, tc.expFees, fees.String()) require.Equal(t, tc.expPriority, priority) diff --git a/app/ante/fees.go b/app/ante/fees.go index ba2d5032..0c08e9bc 100644 --- a/app/ante/fees.go +++ b/app/ante/fees.go @@ -104,7 +104,7 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate // Determine the required fees by multiplying each required minimum gas // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - gasLimit := sdk.NewDecFromBigInt(new(big.Int).SetUint64(gas)) + gasLimit := sdkmath.LegacyNewDecFromBigInt(new(big.Int).SetUint64(gas)) for _, gp := range minGasPrices { fee := gp.Amount.Mul(gasLimit).Ceil().RoundInt() @@ -168,10 +168,10 @@ func (empd EthMinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul feeAmt = ethMsg.GetEffectiveFee(baseFee) } - gasLimit := sdk.NewDecFromBigInt(new(big.Int).SetUint64(ethMsg.GetGas())) + gasLimit := sdkmath.LegacyNewDecFromBigInt(new(big.Int).SetUint64(ethMsg.GetGas())) requiredFee := minGasPrice.Mul(gasLimit) - fee := sdk.NewDecFromBigInt(feeAmt) + fee := sdkmath.LegacyNewDecFromBigInt(feeAmt) if fee.LT(requiredFee) { return ctx, errorsmod.Wrapf( @@ -211,8 +211,8 @@ func (mfd EthMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil)) } - fee := sdk.NewDecFromBigInt(ethMsg.GetFee()) - gasLimit := sdk.NewDecFromBigInt(new(big.Int).SetUint64(ethMsg.GetGas())) + fee := sdkmath.LegacyNewDecFromBigInt(ethMsg.GetFee()) + gasLimit := sdkmath.LegacyNewDecFromBigInt(new(big.Int).SetUint64(ethMsg.GetGas())) requiredFee := minGasPrice.Mul(gasLimit) if fee.LT(requiredFee) { diff --git a/app/ante/fees_test.go b/app/ante/fees_test.go index a1ad44db..c0a89986 100644 --- a/app/ante/fees_test.go +++ b/app/ante/fees_test.go @@ -49,7 +49,7 @@ func (s AnteTestSuite) TestMinGasPriceDecorator() { "valid cosmos tx with MinGasPrices = 0, gasPrice = 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.ZeroDec() + params.MinGasPrice = sdkmath.LegacyZeroDec() s.app.FeeMarketKeeper.SetParams(s.ctx, params) txBuilder := s.CreateTestCosmosTxBuilder(sdkmath.NewInt(0), denom, &testMsg) @@ -63,7 +63,7 @@ func (s AnteTestSuite) TestMinGasPriceDecorator() { "valid cosmos tx with MinGasPrices = 0, gasPrice > 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.ZeroDec() + params.MinGasPrice = sdkmath.LegacyZeroDec() s.app.FeeMarketKeeper.SetParams(s.ctx, params) txBuilder := s.CreateTestCosmosTxBuilder(sdkmath.NewInt(10), denom, &testMsg) @@ -77,7 +77,7 @@ func (s AnteTestSuite) TestMinGasPriceDecorator() { "valid cosmos tx with MinGasPrices = 10, gasPrice = 10", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) txBuilder := s.CreateTestCosmosTxBuilder(sdkmath.NewInt(10), denom, &testMsg) @@ -91,7 +91,7 @@ func (s AnteTestSuite) TestMinGasPriceDecorator() { "invalid cosmos tx with MinGasPrices = 10, gasPrice = 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) txBuilder := s.CreateTestCosmosTxBuilder(sdkmath.NewInt(0), denom, &testMsg) @@ -105,7 +105,7 @@ func (s AnteTestSuite) TestMinGasPriceDecorator() { "invalid cosmos tx with wrong denom", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) txBuilder := s.CreateTestCosmosTxBuilder(sdkmath.NewInt(10), "stake", &testMsg) @@ -152,7 +152,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "invalid tx type", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) return &invalidTx{} }, @@ -163,7 +163,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "wrong tx type", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) testMsg := banktypes.MsgSend{ FromAddress: "evmos1x8fhpj9nmhqk8z9kpgjt95ck2xwyue0ptzkucp", @@ -180,7 +180,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid: invalid tx type with MinGasPrices = 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.ZeroDec() + params.MinGasPrice = sdkmath.LegacyZeroDec() s.app.FeeMarketKeeper.SetParams(s.ctx, params) return &invalidTx{} }, @@ -191,7 +191,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid legacy tx with MinGasPrices = 0, gasPrice = 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.ZeroDec() + params.MinGasPrice = sdkmath.LegacyZeroDec() s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), big.NewInt(0), nil, nil, nil) @@ -204,7 +204,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid legacy tx with MinGasPrices = 0, gasPrice > 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.ZeroDec() + params.MinGasPrice = sdkmath.LegacyZeroDec() s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), big.NewInt(10), nil, nil, nil) @@ -217,7 +217,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid legacy tx with MinGasPrices = 10, gasPrice = 10", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), big.NewInt(10), nil, nil, nil) @@ -230,7 +230,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "invalid legacy tx with MinGasPrices = 10, gasPrice = 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), big.NewInt(0), nil, nil, nil) @@ -243,7 +243,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid dynamic tx with MinGasPrices = 0, EffectivePrice = 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.ZeroDec() + params.MinGasPrice = sdkmath.LegacyZeroDec() s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), nil, big.NewInt(0), big.NewInt(0), &emptyAccessList) @@ -256,7 +256,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid dynamic tx with MinGasPrices = 0, EffectivePrice > 0", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.ZeroDec() + params.MinGasPrice = sdkmath.LegacyZeroDec() s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), nil, big.NewInt(100), big.NewInt(50), &emptyAccessList) @@ -269,7 +269,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid dynamic tx with MinGasPrices < EffectivePrice", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), nil, big.NewInt(100), big.NewInt(100), &emptyAccessList) @@ -282,7 +282,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "invalid dynamic tx with MinGasPrices > EffectivePrice", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(10) + params.MinGasPrice = sdkmath.LegacyNewDec(10) s.app.FeeMarketKeeper.SetParams(s.ctx, params) msg := s.BuildTestEthTx(from, to, nil, make([]byte, 0), nil, big.NewInt(0), big.NewInt(0), &emptyAccessList) @@ -295,7 +295,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "invalid dynamic tx with MinGasPrices > BaseFee, MinGasPrices > EffectivePrice", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(100) + params.MinGasPrice = sdkmath.LegacyNewDec(100) s.app.FeeMarketKeeper.SetParams(s.ctx, params) feemarketParams := s.app.FeeMarketKeeper.GetParams(s.ctx) @@ -312,7 +312,7 @@ func (s AnteTestSuite) TestEthMinGasPriceDecorator() { "valid dynamic tx with MinGasPrices > BaseFee, MinGasPrices < EffectivePrice (big GasTipCap)", func() sdk.Tx { params := s.app.FeeMarketKeeper.GetParams(s.ctx) - params.MinGasPrice = sdk.NewDec(100) + params.MinGasPrice = sdkmath.LegacyNewDec(100) s.app.FeeMarketKeeper.SetParams(s.ctx, params) feemarketParams := s.app.FeeMarketKeeper.GetParams(s.ctx) diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index 4b039680..5961e466 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -17,15 +17,16 @@ package ante import ( errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" + txsigning "cosmossdk.io/x/tx/signing" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" - authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" evmtypes "github.com/zeta-chain/ethermint/x/evm/types" ) @@ -39,8 +40,8 @@ type HandlerOptions struct { FeeMarketKeeper FeeMarketKeeper EvmKeeper EVMKeeper FeegrantKeeper ante.FeegrantKeeper - SignModeHandler authsigning.SignModeHandler - SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error + SignModeHandler *txsigning.HandlerMap + SigGasConsumer func(meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params) error MaxTxGasWanted uint64 ExtensionOptionChecker ante.ExtensionOptionChecker TxFeeChecker ante.TxFeeChecker diff --git a/app/ante/setup.go b/app/ante/setup.go index 463c45d4..6b5268ab 100644 --- a/app/ante/setup.go +++ b/app/ante/setup.go @@ -21,7 +21,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" @@ -49,7 +49,7 @@ func (esc EthSetupContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } // We need to setup an empty gas config so that the gas is consistent with Ethereum. - newCtx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()). + newCtx = ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()). WithKVGasConfig(storetypes.GasConfig{}). WithTransientKVGasConfig(storetypes.GasConfig{}) @@ -112,10 +112,17 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu return next(ctx, tx, simulate) } - err := tx.ValidateBasic() - // ErrNoSignatures is fine with eth tx - if err != nil && !errors.Is(err, errortypes.ErrNoSignatures) { - return ctx, errorsmod.Wrap(err, "tx basic validation failed") + msgs := tx.GetMsgs() + if msgs == nil { + return errorsmod.Wrap(errortypes.ErrUnknownRequest, "invalid transaction. Transaction without messages") + } + + if t, ok := tx.(sdk.HasValidateBasic); ok { + err := t.ValidateBasic() + // ErrNoSignatures is fine with eth tx + if err != nil && !errors.Is(err, errortypes.ErrNoSignatures) { + return errorsmod.Wrap(err, "tx basic validation failed") + } } // For eth type cosmos tx, some fields should be verified as zero values, @@ -194,8 +201,8 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu txFee = txFee.Add(sdk.Coin{Denom: evmDenom, Amount: sdkmath.NewIntFromBigInt(txData.Fee())}) } - if !authInfo.Fee.Amount.IsEqual(txFee) { - return ctx, errorsmod.Wrapf(errortypes.ErrInvalidRequest, "invalid AuthInfo Fee Amount (%s != %s)", authInfo.Fee.Amount, txFee) + if !authInfo.Fee.Amount.Equal(txFee) { + return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "invalid AuthInfo Fee Amount (%s != %s)", authInfo.Fee.Amount, txFee) } if authInfo.Fee.GasLimit != txGasLimit { diff --git a/app/ante/setup_test.go b/app/ante/setup_test.go index 8ecb6096..42c80c28 100644 --- a/app/ante/setup_test.go +++ b/app/ante/setup_test.go @@ -3,7 +3,7 @@ package ante_test import ( "math/big" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/ethermint/app/ante" evmtypes "github.com/zeta-chain/ethermint/x/evm/types" diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index 4a8efe47..e1a89655 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -1,26 +1,29 @@ package ante_test import ( - "encoding/json" - "fmt" + "context" "math" "math/big" "time" sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" "github.com/stretchr/testify/suite" + protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/zeta-chain/ethermint/ethereum/eip712" - "github.com/zeta-chain/ethermint/testutil" - utiltx "github.com/zeta-chain/ethermint/testutil/tx" + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/ethereum/eip712" + "github.com/evmos/ethermint/testutil" + utiltx "github.com/evmos/ethermint/testutil/tx" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" + txsigning "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -38,21 +41,18 @@ import ( authz "github.com/cosmos/cosmos-sdk/x/authz" "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" + evtypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - evtypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/zeta-chain/ethermint/app" - ante "github.com/zeta-chain/ethermint/app/ante" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/tests" - "github.com/zeta-chain/ethermint/x/evm/statedb" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" - feemarkettypes "github.com/zeta-chain/ethermint/x/feemarket/types" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + ante "github.com/evmos/ethermint/app/ante" + "github.com/evmos/ethermint/tests" + "github.com/evmos/ethermint/x/evm/statedb" + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" ) type AnteTestSuite struct { @@ -74,7 +74,7 @@ type AnteTestSuite struct { const TestGasLimit uint64 = 100000 func (suite *AnteTestSuite) StateDB() *statedb.StateDB { - return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) + return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash()))) } func (suite *AnteTestSuite) SetupTest() { @@ -111,20 +111,21 @@ func (suite *AnteTestSuite) SetupTest() { genesis[evmtypes.ModuleName] = app.AppCodec().MustMarshalJSON(evmGenesis) return genesis }) - - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 2, ChainID: testutil.TestnetChainID + "-1", Time: time.Now().UTC()}) - suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(evmtypes.DefaultEVMDenom, sdk.OneInt()))) - suite.ctx = suite.ctx.WithBlockGasMeter(sdk.NewGasMeter(1000000000000000000)) + header := tmproto.Header{Height: 2, ChainID: testutil.TestnetChainID + "-1", Time: time.Now().UTC()} + suite.ctx = suite.app.BaseApp.NewUncachedContext(checkTx, header). + WithConsensusParams(*app.DefaultConsensusParams). + WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(evmtypes.DefaultEVMDenom, sdkmath.OneInt()))). + WithBlockGasMeter(storetypes.NewGasMeter(1000000000000000000)) suite.app.EvmKeeper.WithChainID(suite.ctx) - infCtx := suite.ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) - suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams()) + infCtx := suite.ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) + suite.app.AccountKeeper.Params.Set(infCtx, authtypes.DefaultParams()) addr := sdk.AccAddress(priv.PubKey().Address().Bytes()) acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - encodingConfig := encoding.MakeConfig(app.ModuleBasics) + encodingConfig := app.MakeConfigForTest() // We're using TestMsg amino encoding in some tests, so register it here. encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) eip712.SetEncodingConfig(encodingConfig) @@ -151,7 +152,7 @@ func (suite *AnteTestSuite) SetupTest() { suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) // fund signer acc to pay for tx fees - amt := sdk.NewInt(int64(math.Pow10(18) * 2)) + amt := sdkmath.NewInt(int64(math.Pow10(18) * 2)) err = testutil.FundAccount( suite.app.BankKeeper, suite.ctx, @@ -160,8 +161,7 @@ func (suite *AnteTestSuite) SetupTest() { ) suite.Require().NoError(err) - header := suite.ctx.BlockHeader() - suite.ctx = suite.ctx.WithBlockHeight(header.Height - 1) + suite.ctx = suite.ctx.WithBlockHeight(suite.ctx.BlockHeader().Height - 1) suite.ctx, err = testutil.Commit(suite.ctx, suite.app, time.Second*0, nil) suite.Require().NoError(err) } @@ -243,10 +243,13 @@ func (suite *AnteTestSuite) CreateTestTxBuilder( if signCosmosTx { // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. + defaultSignMode, err := authsigning.APISignModeToInternal(suite.clientCtx.TxConfig.SignModeHandler().DefaultMode()) + suite.Require().NoError(err) + sigV2 := signing.SignatureV2{ PubKey: priv.PubKey(), Data: &signing.SingleSignatureData{ - SignMode: suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), + SignMode: defaultSignMode, Signature: nil, }, Sequence: txData.GetNonce(), @@ -265,7 +268,8 @@ func (suite *AnteTestSuite) CreateTestTxBuilder( Sequence: txData.GetNonce(), } sigV2, err = tx.SignWithPrivKey( - suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, + suite.ctx, + defaultSignMode, signerData, txBuilder, priv, suite.clientCtx.TxConfig, txData.GetNonce(), ) suite.Require().NoError(err) @@ -301,7 +305,7 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgDelegate(from sdk.AccAdd // Build MsgSend valEthAddr := tests.GenerateAddress() valAddr := sdk.ValAddress(valEthAddr.Bytes()) - msgSend := stakingtypes.NewMsgDelegate(from, valAddr, sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20))) + msgSend := stakingtypes.NewMsgDelegate(from.String(), valAddr.String(), sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20))) return suite.CreateTestEIP712SingleMessageTxBuilder(priv, chainId, gas, gasAmount, msgSend) } @@ -310,12 +314,12 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator(from sdk.AccAddre valAddr := sdk.ValAddress(from.Bytes()) privEd := ed25519.GenPrivKey() msgCreate, err := stakingtypes.NewMsgCreateValidator( - valAddr, + valAddr.String(), privEd.PubKey(), - sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)), + sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)), stakingtypes.NewDescription("moniker", "indentity", "website", "security_contract", "details"), - stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + stakingtypes.NewCommissionRates(sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), + sdkmath.OneInt(), ) suite.Require().NoError(err) return suite.CreateTestEIP712SingleMessageTxBuilder(priv, chainId, gas, gasAmount, msgCreate) @@ -326,13 +330,13 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator2(from sdk.AccAddr valAddr := sdk.ValAddress(from.Bytes()) privEd := ed25519.GenPrivKey() msgCreate, err := stakingtypes.NewMsgCreateValidator( - valAddr, + valAddr.String(), privEd.PubKey(), - sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)), + sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20)), // Ensure optional fields can be left blank stakingtypes.NewDescription("moniker", "indentity", "", "", ""), - stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + stakingtypes.NewCommissionRates(sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), + sdkmath.OneInt(), ) suite.Require().NoError(err) return suite.CreateTestEIP712SingleMessageTxBuilder(priv, chainId, gas, gasAmount, msgCreate) @@ -363,7 +367,7 @@ func (suite *AnteTestSuite) CreateTestEIP712GrantAllowance(from sdk.AccAddress, func (suite *AnteTestSuite) CreateTestEIP712MsgEditValidator(from sdk.AccAddress, priv cryptotypes.PrivKey, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder { valAddr := sdk.ValAddress(from.Bytes()) msgEdit := stakingtypes.NewMsgEditValidator( - valAddr, + valAddr.String(), stakingtypes.NewDescription("moniker", "identity", "website", "security_contract", "details"), nil, nil, @@ -420,7 +424,7 @@ func (suite *AnteTestSuite) CreateTestEIP712SubmitProposalV1(from sdk.AccAddress proposalMsgs, sdk.NewCoins(sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(100))), sdk.MustBech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), from.Bytes()), - "Metadata", "title", "summary", + "Metadata", "title", "summary", false, ) suite.Require().NoError(err) @@ -600,18 +604,27 @@ func (suite *AnteTestSuite) RegisterAccount(pubKey cryptotypes.PubKey, balance * func (suite *AnteTestSuite) createSignerBytes(chainId string, signMode signing.SignMode, pubKey cryptotypes.PubKey, txBuilder client.TxBuilder) []byte { acc, err := sdkante.GetSignerAcc(suite.ctx, suite.app.AccountKeeper, sdk.AccAddress(pubKey.Address())) suite.Require().NoError(err) - signerInfo := authsigning.SignerData{ + anyPk, err := codectypes.NewAnyWithValue(pubKey) + suite.Require().NoError(err) + signerInfo := txsigning.SignerData{ Address: sdk.MustBech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), acc.GetAddress().Bytes()), ChainID: chainId, AccountNumber: acc.GetAccountNumber(), Sequence: acc.GetSequence(), - PubKey: pubKey, + PubKey: &anypb.Any{ + TypeUrl: anyPk.TypeUrl, + Value: anyPk.Value, + }, } - + builtTx := txBuilder.GetTx() + adaptableTx, ok := builtTx.(authsigning.V2AdaptableTx) + suite.Require().True(ok) + txData := adaptableTx.GetSigningTxData() signerBytes, err := suite.clientCtx.TxConfig.SignModeHandler().GetSignBytes( - signMode, + context.Background(), + signingv1beta1.SignMode(signMode), signerInfo, - txBuilder.GetTx(), + txData, ) suite.Require().NoError(err) @@ -624,7 +637,7 @@ func (suite *AnteTestSuite) createBaseTxBuilder(msg sdk.Msg, gas uint64) client. txBuilder.SetGasLimit(gas) txBuilder.SetFeeAmount(sdk.NewCoins( - sdk.NewCoin("aphoton", sdk.NewInt(10000)), + sdk.NewCoin("aphoton", sdkmath.NewInt(10000)), )) err := txBuilder.SetMsgs(msg) @@ -705,5 +718,7 @@ var _ sdk.Tx = &invalidTx{} type invalidTx struct{} -func (invalidTx) GetMsgs() []sdk.Msg { return []sdk.Msg{nil} } +func (invalidTx) GetMsgs() []sdk.Msg { return []sdk.Msg{nil} } +func (invalidTx) GetMsgsV2() ([]protov2.Message, error) { return nil, nil } + func (invalidTx) ValidateBasic() error { return nil } diff --git a/app/app.go b/app/app.go index 95b5f7a7..1c842edb 100644 --- a/app/app.go +++ b/app/app.go @@ -25,36 +25,51 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/gogoproto/proto" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" "github.com/spf13/cast" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" "github.com/cosmos/cosmos-sdk/client/grpc/node" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/store/streaming" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" sdk "github.com/cosmos/cosmos-sdk/types" mempool "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" @@ -68,9 +83,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/consensus" "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" @@ -78,19 +90,12 @@ import ( distr "github.com/cosmos/cosmos-sdk/x/distribution" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/mint" mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" @@ -106,22 +111,20 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/cosmos/cosmos-sdk/server" // unnamed import of statik for swagger UI support @@ -173,10 +176,7 @@ var ( staking.AppModuleBasic{}, mint.AppModuleBasic{}, distr.AppModuleBasic{}, - gov.NewAppModuleBasic([]govclient.ProposalHandler{ - paramsclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler, - ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler, - }), + gov.NewAppModuleBasic([]govclient.ProposalHandler{paramsclient.ProposalHandler}), params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, @@ -264,7 +264,8 @@ type EthermintApp struct { FeeMarketKeeper feemarketkeeper.Keeper // the module manager - mm *module.Manager + ModuleManager *module.Manager + BasicModuleManager module.BasicManager // the configurator configurator module.Configurator @@ -287,7 +288,7 @@ func NewEthermintApp( appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *EthermintApp { - encodingConfig := encoding.MakeConfig(ModuleBasics) + encodingConfig := encoding.MakeConfig() appCodec := encodingConfig.Codec cdc := encodingConfig.Amino txConfig := encodingConfig.TxConfig @@ -298,9 +299,13 @@ func NewEthermintApp( // NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx // Setup Mempool and Proposal Handlers baseAppOptions = append(baseAppOptions, func(app *baseapp.BaseApp) { - mempool := mempool.NoOpMempool{} - app.SetMempool(mempool) + mempool := mempool.NewPriorityMempool(mempool.PriorityNonceMempoolConfig[int64]{ + TxPriority: mempool.NewDefaultTxPriority(), + SignerExtractor: NewEthSignerExtractionAdapter(mempool.NewDefaultSignerExtractionAdapter()), + }) handler := baseapp.NewDefaultProposalHandler(mempool, app) + + app.SetMempool(mempool) app.SetPrepareProposal(handler.PrepareProposalHandler()) app.SetProcessProposal(handler.ProcessProposalHandler()) }) @@ -316,7 +321,7 @@ func NewEthermintApp( bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( // SDK keys authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, @@ -330,11 +335,11 @@ func NewEthermintApp( ) // Add the EVM transient store key - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) // load state streaming if enabled - if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, logger, keys); err != nil { + if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil { fmt.Printf("failed to load state streaming: %s", err) os.Exit(1) } @@ -359,8 +364,13 @@ func NewEthermintApp( authAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authAddr) - bApp.SetParamStore(&app.ConsensusParamsKeeper) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), + authAddr, + runtime.EventService{}, + ) + bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) @@ -374,28 +384,33 @@ func NewEthermintApp( // use custom Ethermint account for contracts app.AccountKeeper = authkeeper.NewAccountKeeper( - appCodec, keys[authtypes.StoreKey], + appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), ethermint.ProtoAccount, maccPerms, + address.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.GetConfig().GetBech32AccountAddrPrefix(), authAddr, ) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, app.BlockedAddrs(), authAddr, + logger, ) app.StakingKeeper = stakingkeeper.NewKeeper( - appCodec, keys[stakingtypes.StoreKey], + appCodec, + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authAddr, + address.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + address.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, - keys[minttypes.StoreKey], + runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, @@ -404,7 +419,7 @@ func NewEthermintApp( ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, - keys[distrtypes.StoreKey], + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, @@ -414,22 +429,24 @@ func NewEthermintApp( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, app.LegacyAmino(), - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authAddr, ) app.CrisisKeeper = *crisiskeeper.NewKeeper( appCodec, - keys[crisistypes.StoreKey], + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authAddr, + app.AccountKeeper.AddressCodec(), ) app.FeeGrantKeeper = feegrantkeeper.NewKeeper( appCodec, - keys[feegrant.StoreKey], - app.AccountKeeper) + runtime.NewKVStoreService(keys[feegrant.StoreKey]), + app.AccountKeeper, + ) // get skipUpgradeHeights from the app options skipUpgradeHeights := map[int64]bool{} @@ -444,7 +461,7 @@ func NewEthermintApp( // set the governance module account as the authority for conducting upgrades app.UpgradeKeeper = *upgradekeeper.NewKeeper( skipUpgradeHeights, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, @@ -454,22 +471,36 @@ func NewEthermintApp( // register the staking hooks app.StakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), - app.SlashingKeeper.Hooks()), + app.SlashingKeeper.Hooks(), + ), ) app.AuthzKeeper = authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), - app.AccountKeeper) + app.AccountKeeper, + ) + + // Create IBC Keeper + app.IBCKeeper = ibckeeper.NewKeeper( + appCodec, keys[ibcexported.StoreKey], + app.GetSubspace(ibcexported.ModuleName), + app.StakingKeeper, + app.UpgradeKeeper, + scopedIBCKeeper, + authAddr, + ) tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer)) // Create Ethermint keepers feeMarketSs := app.GetSubspace(feemarkettypes.ModuleName) app.FeeMarketKeeper = feemarketkeeper.NewKeeper( - appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], feeMarketSs, app.ConsensusParamsKeeper, + appCodec, + runtime.NewKVStoreService(keys[feemarkettypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName), + keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], ) // Set authority to x/gov module account to only expect the module account to update params @@ -488,30 +519,29 @@ func NewEthermintApp( } app.EvmKeeper = evmkeeper.NewKeeper( - appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), + appCodec, + runtime.NewKVStoreService(keys[evmtypes.StoreKey]), + keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, - tracer, evmSs, nil, app.ConsensusParamsKeeper, allKeys, - ) - - // Create IBC Keeper - app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + tracer, + nil, + allKeys, ) // register the proposal types govRouter := govv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) govConfig := govtypes.DefaultConfig() /* Example of setting gov params: govConfig.MaxMetadataLen = 10000 */ govKeeper := govkeeper.NewKeeper( - appCodec, keys[govtypes.StoreKey], app.AccountKeeper, app.BankKeeper, - app.StakingKeeper, app.MsgServiceRouter(), govConfig, authAddr, + appCodec, + runtime.NewKVStoreService(keys[govtypes.StoreKey]), + app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.DistrKeeper, + app.MsgServiceRouter(), govConfig, authAddr, ) // Set legacy router for backwards compatibility with gov v1beta1 @@ -526,8 +556,8 @@ func NewEthermintApp( // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, - app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, + app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, authAddr, ) transferModule := transfer.NewAppModule(app.TransferKeeper) transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) @@ -539,7 +569,11 @@ func NewEthermintApp( // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, keys[evidencetypes.StoreKey], app.StakingKeeper, app.SlashingKeeper, + appCodec, + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), + app.StakingKeeper, app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), ) // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper @@ -552,10 +586,10 @@ func NewEthermintApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.mm = module.NewManager( + app.ModuleManager = module.NewManager( // SDK app modules genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + app.AccountKeeper, app.StakingKeeper, app, txConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), @@ -573,10 +607,11 @@ func NewEthermintApp( app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), + app.interfaceRegistry, ), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - upgrade.NewAppModule(&app.UpgradeKeeper), + upgrade.NewAppModule(&app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), @@ -584,19 +619,42 @@ func NewEthermintApp( // ibc modules ibc.NewAppModule(app.IBCKeeper), + ibctm.AppModule{}, transferModule, // Ethermint app modules feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketSs), evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs), ) + // BasicModuleManager defines the module BasicManager which is in charge of setting up basic, + // non-dependant module elements, such as codec registration and genesis verification. + // By default, it is composed of all the modules from the module manager. + // Additionally, app module basics can be overwritten by passing them as an argument. + app.BasicModuleManager = module.NewBasicManagerFromManager( + app.ModuleManager, + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + govtypes.ModuleName: gov.NewAppModuleBasic( + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + }, + ), + }, + ) + app.BasicModuleManager.RegisterLegacyAminoCodec(cdc) + app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) + + app.ModuleManager.SetOrderPreBlockers( + upgradetypes.ModuleName, + ) + // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: upgrade module must go first to handle software upgrades. // NOTE: staking module is required if HistoricalEntries param > 0 // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) - app.mm.SetOrderBeginBlockers( + app.ModuleManager.SetOrderBeginBlockers( upgradetypes.ModuleName, capabilitytypes.ModuleName, feemarkettypes.ModuleName, @@ -622,16 +680,16 @@ func NewEthermintApp( ) // NOTE: fee market module must go last in order to retrieve the block gas used. - app.mm.SetOrderEndBlockers( + app.ModuleManager.SetOrderEndBlockers( crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, evmtypes.ModuleName, feemarkettypes.ModuleName, // no-op modules + capabilitytypes.ModuleName, ibcexported.ModuleName, ibctransfertypes.ModuleName, - capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, @@ -653,7 +711,7 @@ func NewEthermintApp( // NOTE: Capability module must occur first so that it can initialize any capabilities // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. - app.mm.SetOrderInitGenesis( + genesisModuleOrder := []string{ // SDK modules capabilitytypes.ModuleName, authtypes.ModuleName, @@ -680,18 +738,22 @@ func NewEthermintApp( consensusparamtypes.ModuleName, // NOTE: crisis module must go at the end to check for invariants on each module crisistypes.ModuleName, - ) + } + app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) + app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...) // Uncomment if you want to set a custom migration order here. - // app.mm.SetOrderMigrations(custom order) + // app.ModuleManager.SetOrderMigrations(custom order) - app.mm.RegisterInvariants(&app.CrisisKeeper) + app.ModuleManager.RegisterInvariants(&app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - app.mm.RegisterServices(app.configurator) + if err := app.ModuleManager.RegisterServices(app.configurator); err != nil { + panic(err) + } // RegisterUpgradeHandlers is used for registering any on-chain upgrades. - // Make sure it's called after `app.mm` and `app.configurator` are set. - app.RegisterUpgradeHandlers(app.appCodec, app.IBCKeeper.ClientKeeper) + // Make sure it's called after `app.ModuleManager` and `app.configurator` are set. + app.RegisterUpgradeHandlers() // add test gRPC service for testing gRPC queries in isolation // testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{}) @@ -703,9 +765,9 @@ func NewEthermintApp( overrideModules := map[string]module.AppModuleSimulation{ authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), } - app.sm = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules) + app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules) - autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules)) + autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules)) reflectionSvc, err := runtimeservices.NewReflectionService() if err != nil { @@ -722,6 +784,7 @@ func NewEthermintApp( // initialize BaseApp app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(app.PreBlocker) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) app.setAnteHandler(txConfig, cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))) @@ -740,6 +803,18 @@ func NewEthermintApp( // upgrade. app.setPostHandler() + // At startup, after all modules have been registered, check that all prot + // annotations are correct. + protoFiles, err := proto.MergedRegistry() + if err != nil { + panic(err) + } + err = msgservice.ValidateProtoAnnotations(protoFiles) + if err != nil { + // Once we switch to using protoreflect-based antehandlers, we might + // want to panic here instead of logging a warning. + fmt.Fprintln(os.Stderr, err.Error()) + } if loadLatest { if err := app.LoadLatestVersion(); err != nil { tmos.Exit(err.Error()) @@ -792,24 +867,35 @@ func (app *EthermintApp) setPostHandler() { // Name returns the name of the App func (app *EthermintApp) Name() string { return app.BaseApp.Name() } +// PreBlocker updates every pre begin block +func (app *EthermintApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.ModuleManager.PreBlock(ctx) +} + // BeginBlocker updates every begin block -func (app *EthermintApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.mm.BeginBlock(ctx, req) +func (app *EthermintApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.ModuleManager.BeginBlock(ctx) } // EndBlocker updates every end block -func (app *EthermintApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.mm.EndBlock(ctx, req) +func (app *EthermintApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.ModuleManager.EndBlock(ctx) +} + +func (app *EthermintApp) Configurator() module.Configurator { + return app.configurator } // InitChainer updates at chain initialization -func (app *EthermintApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *EthermintApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) - return app.mm.InitGenesis(ctx, app.appCodec, genesisState) + if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { + return nil, err + } + return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) } // LoadHeight loads state at a particular height @@ -872,6 +958,26 @@ func (app *EthermintApp) EncodingConfig() ethermint.EncodingConfig { } } +// AutoCliOpts returns the autocli options for the app. +func (app *EthermintApp) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.ModuleManager.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + return autocli.AppOptions{ + Modules: modules, + ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.ModuleManager.Modules), + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. @@ -908,12 +1014,12 @@ func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config. // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register new tendermint queries routes from grpc-gateway. - tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register node gRPC service for grpc-gateway. node.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register grpc-gateway routes for all modules. - ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register swagger API from root so that other applications can override easily if apiConfig.Swagger { @@ -928,7 +1034,7 @@ func (app *EthermintApp) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *EthermintApp) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService( + cmtservice.RegisterTendermintService( clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, @@ -936,8 +1042,8 @@ func (app *EthermintApp) RegisterTendermintService(clientCtx client.Context) { ) } -func (app *EthermintApp) RegisterNodeService(clientCtx client.Context) { - node.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +func (app *EthermintApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + node.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } // RegisterSwaggerAPI registers swagger route with API Server @@ -963,20 +1069,10 @@ func GetMaccPerms() map[string][]string { // initParamsKeeper init params keeper and its subspaces func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - - // SDK subspaces - paramsKeeper.Subspace(authtypes.ModuleName) - paramsKeeper.Subspace(banktypes.ModuleName) - paramsKeeper.Subspace(stakingtypes.ModuleName) - paramsKeeper.Subspace(minttypes.ModuleName) - paramsKeeper.Subspace(distrtypes.ModuleName) - paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint: staticcheck - paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibcexported.ModuleName) - // ethermint subspaces - paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck - paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable()) + // register the key tables for legacy param subspaces + keyTable := ibcclienttypes.ParamKeyTable() + keyTable.RegisterParamSet(&ibcconnectiontypes.Params{}) + paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) + paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) return paramsKeeper } diff --git a/app/app_test.go b/app/app_test.go index bbaacd00..9fcb822c 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" - dbm "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -20,7 +20,7 @@ func TestEthermintAppExport(t *testing.T) { // Making a new app object with the db, so that initchain hasn't been called app2 := NewEthermintApp( - log.NewTMLogger(log.NewSyncWriter(os.Stdout)), + log.NewLogger(os.Stdout), db, nil, true, diff --git a/app/benchmark_test.go b/app/benchmark_test.go index 137b336f..f43efe46 100644 --- a/app/benchmark_test.go +++ b/app/benchmark_test.go @@ -5,9 +5,9 @@ import ( "io" "testing" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" ) @@ -15,7 +15,7 @@ import ( func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) { db := dbm.NewMemDB() app := NewEthermintApp( - log.NewTMLogger(io.Discard), + log.NewLogger(io.Discard), db, nil, true, @@ -31,7 +31,7 @@ func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) { // Initialize the chain app.InitChain( - abci.RequestInitChain{ + &abci.RequestInitChain{ ChainId: ChainID, Validators: []abci.ValidatorUpdate{}, AppStateBytes: stateBytes, @@ -44,7 +44,7 @@ func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) { for i := 0; i < b.N; i++ { // Making a new app object with the db, so that initchain hasn't been called app2 := NewEthermintApp( - log.NewTMLogger(log.NewSyncWriter(io.Discard)), + log.NewLogger(io.Discard), db, nil, true, diff --git a/app/export.go b/app/export.go index eb624e27..e4e529f7 100644 --- a/app/export.go +++ b/app/export.go @@ -20,20 +20,18 @@ import ( "fmt" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - servertypes "github.com/cosmos/cosmos-sdk/server/types" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/zeta-chain/ethermint/encoding" ) // NewDefaultGenesisState generates the default state for the application. func NewDefaultGenesisState() GenesisState { - encCfg := encoding.MakeConfig(ModuleBasics) + encCfg := MakeConfigForTest() return ModuleBasics.DefaultGenesis(encCfg.Codec) } @@ -43,7 +41,7 @@ func (app *EthermintApp) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string, ) (servertypes.ExportedApp, error) { // Creates context with current height and checks txs for ctx to be usable by start of next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContextLegacy(true, tmproto.Header{Height: app.LastBlockHeight()}) // We export at last height + 1, because that's the height at which // Tendermint will start InitChain. @@ -56,7 +54,10 @@ func (app *EthermintApp) ExportAppStateAndValidators( } } - genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) + genState, err := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) + if err != nil { + return servertypes.ExportedApp{}, err + } appState, err := json.MarshalIndent(genState, "", " ") if err != nil { return servertypes.ExportedApp{}, err @@ -102,13 +103,22 @@ func (app *EthermintApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd /* Handle fee distribution state. */ // withdraw all validator commission - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + if err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { + panic(err) + } + _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) return false - }) + }); err != nil { + return err + } // withdraw all delegator rewards - dels := app.StakingKeeper.GetAllDelegations(ctx) + dels, err := app.StakingKeeper.GetAllDelegations(ctx) + if err != nil { + return err + } for _, delegation := range dels { valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) if err != nil { @@ -133,18 +143,32 @@ func (app *EthermintApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd ctx = ctx.WithBlockHeight(0) // reinitialize all validators - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + if err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) + valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { + panic(err) + } + scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz) + if err != nil { + panic(err) + } + feePool, err := app.DistrKeeper.FeePool.Get(ctx) + if err != nil { + panic(err) + } feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) + if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil { + panic(err) + } - if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil { + if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, valBz); err != nil { return true } return false - }) + }); err != nil { + return err + } // reinitialize all delegations for _, del := range dels { @@ -170,33 +194,41 @@ func (app *EthermintApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd /* Handle staking state. */ // iterate through redelegations, reset creation height - app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { + if err := app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { for i := range red.Entries { red.Entries[i].CreationHeight = 0 } - app.StakingKeeper.SetRedelegation(ctx, red) + if err := app.StakingKeeper.SetRedelegation(ctx, red); err != nil { + panic(err) + } return false - }) + }); err != nil { + return err + } // iterate through unbonding delegations, reset creation height - app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + if err := app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { for i := range ubd.Entries { ubd.Entries[i].CreationHeight = 0 } - app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) + if err := app.StakingKeeper.SetUnbondingDelegation(ctx, ubd); err != nil { + panic(err) + } return false - }) + }); err != nil { + return err + } // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) - iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) + iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key())) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { - return fmt.Errorf("expected validator %s not found", addr) + validator, err := app.StakingKeeper.GetValidator(ctx, addr) + if err != nil { + return fmt.Errorf("expected validator %s not found, %w", addr, err) } validator.UnbondingHeight = 0 @@ -204,7 +236,9 @@ func (app *EthermintApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd validator.Jailed = true } - app.StakingKeeper.SetValidator(ctx, validator) + if err := app.StakingKeeper.SetValidator(ctx, validator); err != nil { + return err + } } if err := iter.Close(); err != nil { @@ -218,13 +252,14 @@ func (app *EthermintApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd /* Handle slashing state. */ // reset start height on signing infos - app.SlashingKeeper.IterateValidatorSigningInfos( + return app.SlashingKeeper.IterateValidatorSigningInfos( ctx, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { info.StartHeight = 0 - app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + if err := app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info); err != nil { + panic(err) + } return false }, ) - return nil } diff --git a/app/signer.go b/app/signer.go new file mode 100644 index 00000000..854e3b38 --- /dev/null +++ b/app/signer.go @@ -0,0 +1,47 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + mempool "github.com/cosmos/cosmos-sdk/types/mempool" + authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + evmtypes "github.com/evmos/ethermint/x/evm/types" +) + +var _ mempool.SignerExtractionAdapter = EthSignerExtractionAdapter{} + +// EthSignerExtractionAdapter is the default implementation of SignerExtractionAdapter. It extracts the signers +// from a cosmos-sdk tx via GetSignaturesV2. +type EthSignerExtractionAdapter struct { + fallback mempool.SignerExtractionAdapter +} + +// NewEthSignerExtractionAdapter constructs a new EthSignerExtractionAdapter instance +func NewEthSignerExtractionAdapter(fallback mempool.SignerExtractionAdapter) EthSignerExtractionAdapter { + return EthSignerExtractionAdapter{fallback} +} + +// GetSigners implements the Adapter interface +// NOTE: only the first item is used by the mempool +func (s EthSignerExtractionAdapter) GetSigners(tx sdk.Tx) ([]mempool.SignerData, error) { + if txWithExtensions, ok := tx.(authante.HasExtensionOptionsTx); ok { + opts := txWithExtensions.GetExtensionOptions() + if len(opts) > 0 && opts[0].GetTypeUrl() == "/ethermint.evm.v1.ExtensionOptionsEthereumTx" { + for _, msg := range tx.GetMsgs() { + if ethMsg, ok := msg.(*evmtypes.MsgEthereumTx); ok { + txData, err := evmtypes.UnpackTxData(ethMsg.Data) + if err != nil { + return nil, err + } + return []mempool.SignerData{ + mempool.NewSignerData( + sdk.AccAddress(ethMsg.From), + txData.GetNonce(), + ), + }, nil + } + } + } + } + + return s.fallback.GetSigners(tx) +} diff --git a/app/upgrades.go b/app/upgrades.go index a8075530..2e362baf 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -16,98 +16,17 @@ package app import ( - "fmt" + "context" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" + upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/types/module" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" - feemarkettypes "github.com/zeta-chain/ethermint/x/feemarket/types" ) -func (app *EthermintApp) RegisterUpgradeHandlers(cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) { - planName := "integration-test-upgrade" - // Set param key table for params module migration - for _, subspace := range app.ParamsKeeper.GetSubspaces() { - var keyTable paramstypes.KeyTable - switch subspace.Name() { - case authtypes.ModuleName: - keyTable = authtypes.ParamKeyTable() //nolint:staticcheck - case banktypes.ModuleName: - keyTable = banktypes.ParamKeyTable() //nolint:staticcheck - case stakingtypes.ModuleName: - keyTable = stakingtypes.ParamKeyTable() - case minttypes.ModuleName: - keyTable = minttypes.ParamKeyTable() //nolint:staticcheck - case distrtypes.ModuleName: - keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck - case slashingtypes.ModuleName: - keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck - case govtypes.ModuleName: - keyTable = govv1.ParamKeyTable() //nolint:staticcheck - case crisistypes.ModuleName: - keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck - case ibctransfertypes.ModuleName: - keyTable = ibctransfertypes.ParamKeyTable() - case evmtypes.ModuleName: - keyTable = evmtypes.ParamKeyTable() //nolint:staticcheck - case feemarkettypes.ModuleName: - keyTable = feemarkettypes.ParamKeyTable() - default: - continue - } - if !subspace.HasKeyTable() { - subspace.WithKeyTable(keyTable) - } - } - - baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) - app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // OPTIONAL: prune expired tendermint consensus states to save storage space - if _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, cdc, clientKeeper); err != nil { - return nil, err - } - // explicitly update the IBC 02-client params, adding the localhost client type - params := clientKeeper.GetParams(ctx) - params.AllowedClients = append(params.AllowedClients, exported.Localhost) - clientKeeper.SetParams(ctx, params) - // Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module. - baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) - c := app.GetConsensusParams(ctx) - ctx = ctx.WithConsensusParams(c) - return app.mm.RunMigrations(ctx, app.configurator, fromVM) - }) - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) - } - if !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - if upgradeInfo.Name == planName { - storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{ - consensusparamtypes.StoreKey, - crisistypes.StoreKey, - }, - } - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) - } - } +func (app *EthermintApp) RegisterUpgradeHandlers() { + planName := "sdk50" + app.UpgradeKeeper.SetUpgradeHandler(planName, + func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) + }, + ) } diff --git a/app/utils.go b/app/utils.go index b1b0bbc5..0255cb9d 100644 --- a/app/utils.go +++ b/app/utils.go @@ -19,40 +19,42 @@ import ( "encoding/json" "time" + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" + abci "github.com/cometbft/cometbft/abci/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmtypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil/mock" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - dbm "github.com/cometbft/cometbft-db" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/evmos/ethermint/encoding" + ethermint "github.com/evmos/ethermint/types" ) type GenesisState map[string]json.RawMessage // DefaultConsensusParams defines the default Tendermint consensus params used in // EthermintApp testing. -var DefaultConsensusParams = &tmproto.ConsensusParams{ - Block: &tmproto.BlockParams{ +var DefaultConsensusParams = &cmtproto.ConsensusParams{ + Block: &cmtproto.BlockParams{ MaxBytes: 1048576, MaxGas: 81500000, // default limit }, - Evidence: &tmproto.EvidenceParams{ + Evidence: &cmtproto.EvidenceParams{ MaxAgeNumBlocks: 302400, MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration MaxBytes: 10000, }, - Validator: &tmproto.ValidatorParams{ + Validator: &cmtproto.ValidatorParams{ PubKeyTypes: []string{ tmtypes.ABCIPubKeyTypeEd25519, }, @@ -89,16 +91,27 @@ func SetupWithDB(isCheckTx bool, patchGenesis func(*EthermintApp, GenesisState) } // Initialize the chain - app.InitChain( - abci.RequestInitChain{ + consensusParams := DefaultConsensusParams + initialHeight := app.LastBlockHeight() + 1 + consensusParams.Abci = &cmtproto.ABCIParams{VoteExtensionsEnableHeight: initialHeight} + if _, err := app.InitChain( + &abci.RequestInitChain{ ChainId: ChainID, Validators: []abci.ValidatorUpdate{}, - ConsensusParams: DefaultConsensusParams, + ConsensusParams: consensusParams, AppStateBytes: stateBytes, + InitialHeight: initialHeight, }, - ) + ); err != nil { + panic(err) + } + } + if _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: app.LastBlockHeight() + 1, + Hash: app.LastCommitID().Hash, + }); err != nil { + panic(err) } - return app } @@ -118,7 +131,7 @@ func NewTestGenesisState(codec codec.Codec) GenesisState { acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } genesisState := NewDefaultGenesisState() @@ -139,7 +152,7 @@ func genesisStateWithValSet(codec codec.Codec, genesisState GenesisState, bondAmt := sdk.DefaultPowerReduction for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) + pk, err := cryptocodec.FromCmtPubKeyInterface(val.PubKey) if err != nil { panic(err) } @@ -153,15 +166,16 @@ func genesisStateWithValSet(codec codec.Codec, genesisState GenesisState, Jailed: false, Status: stakingtypes.Bonded, Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), + DelegatorShares: sdkmath.LegacyOneDec(), Description: stakingtypes.Description{}, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + Commission: stakingtypes.NewCommission(sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), + MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) + delegation := stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), sdkmath.LegacyOneDec()) + delegations = append(delegations, delegation) } // set validators and delegations stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations) @@ -196,3 +210,10 @@ func genesisStateWithValSet(codec codec.Codec, genesisState GenesisState, return genesisState } + +func MakeConfigForTest() ethermint.EncodingConfig { + config := encoding.MakeConfig() + ModuleBasics.RegisterLegacyAminoCodec(config.Amino) + ModuleBasics.RegisterInterfaces(config.InterfaceRegistry) + return config +} diff --git a/client/keys/add.go b/client/keys/add.go index f010145f..0c0b3b6b 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -272,7 +272,7 @@ func printCreate(cmd *cobra.Command, k *keyring.Record, showMnemonic bool, mnemo switch outputFormat { case OutputFormatText: cmd.PrintErrln() - if err := printKeyringRecord(cmd.OutOrStdout(), k, keyring.MkAccKeyOutput, outputFormat); err != nil { + if err := printKeyringRecord(cmd.OutOrStdout(), k, keys.MkAccKeyOutput, outputFormat); err != nil { return err } @@ -285,7 +285,7 @@ func printCreate(cmd *cobra.Command, k *keyring.Record, showMnemonic bool, mnemo } } case OutputFormatJSON: - out, err := keyring.MkAccKeyOutput(k) + out, err := keys.MkAccKeyOutput(k) if err != nil { return err } diff --git a/client/keys/utils.go b/client/keys/utils.go index 2dca8204..687323f6 100644 --- a/client/keys/utils.go +++ b/client/keys/utils.go @@ -22,6 +22,7 @@ import ( "sigs.k8s.io/yaml" + "github.com/cosmos/cosmos-sdk/client/keys" cryptokeyring "github.com/cosmos/cosmos-sdk/crypto/keyring" ) @@ -31,7 +32,7 @@ const ( OutputFormatJSON = "json" ) -type bechKeyOutFn func(k *cryptokeyring.Record) (cryptokeyring.KeyOutput, error) +type bechKeyOutFn func(k *cryptokeyring.Record) (keys.KeyOutput, error) func printKeyringRecord(w io.Writer, k *cryptokeyring.Record, bechKeyOut bechKeyOutFn, output string) error { ko, err := bechKeyOut(k) @@ -41,7 +42,7 @@ func printKeyringRecord(w io.Writer, k *cryptokeyring.Record, bechKeyOut bechKey switch output { case OutputFormatText: - if err := printTextRecords(w, []cryptokeyring.KeyOutput{ko}); err != nil { + if err := printTextRecords(w, []keys.KeyOutput{ko}); err != nil { return err } @@ -59,7 +60,7 @@ func printKeyringRecord(w io.Writer, k *cryptokeyring.Record, bechKeyOut bechKey return nil } -func printTextRecords(w io.Writer, kos []cryptokeyring.KeyOutput) error { +func printTextRecords(w io.Writer, kos []keys.KeyOutput) error { out, err := yaml.Marshal(&kos) if err != nil { return err diff --git a/client/testnet.go b/client/testnet.go index e8dd94b1..4d17b3c4 100644 --- a/client/testnet.go +++ b/client/testnet.go @@ -19,6 +19,7 @@ package client import ( "bufio" + "context" "encoding/json" "fmt" "net" @@ -33,11 +34,13 @@ import ( tmtime "github.com/cometbft/cometbft/types/time" "github.com/spf13/cobra" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/runtime" sdkserver "github.com/cosmos/cosmos-sdk/server" srvconfig "github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/testutil" @@ -324,12 +327,12 @@ func initTestnetFiles( valTokens := sdk.TokensFromConsensusPower(100, ethermint.PowerReduction) createValMsg, err := stakingtypes.NewMsgCreateValidator( - sdk.ValAddress(addr), + addr.String(), valPubKeys[i], sdk.NewCoin(ethermint.AttoPhoton, valTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), - stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + stakingtypes.NewCommissionRates(sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), + sdkmath.OneInt(), ) if err != nil { return err @@ -349,7 +352,7 @@ func initTestnetFiles( WithKeybase(kb). WithTxConfig(clientCtx.TxConfig) - if err := tx.Sign(txFactory, nodeDirName, txBuilder, true); err != nil { + if err := tx.Sign(context.Background(), txFactory, nodeDirName, txBuilder, true); err != nil { return err } @@ -378,6 +381,7 @@ func initTestnetFiles( err := collectGenFiles( clientCtx, nodeConfig, args.chainID, nodeIDs, valPubKeys, args.numValidators, args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator, + clientCtx.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), ) if err != nil { return err @@ -471,6 +475,7 @@ func collectGenFiles( clientCtx client.Context, nodeConfig *tmconfig.Config, chainID string, nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, + valAddrCodec runtime.ValidatorAddressCodec, ) error { var appState json.RawMessage genTime := tmtime.Now() @@ -486,7 +491,7 @@ func collectGenFiles( nodeID, valPubKey := nodeIDs[i], valPubKeys[i] initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, valPubKey) - genDoc, err := types.GenesisDocFromFile(nodeConfig.GenesisFile()) + genDoc, err := genutiltypes.AppGenesisFromFile(nodeConfig.GenesisFile()) if err != nil { return err } @@ -496,9 +501,10 @@ func collectGenFiles( clientCtx.TxConfig, nodeConfig, initCfg, - *genDoc, + genDoc, genBalIterator, genutiltypes.DefaultMessageValidator, + valAddrCodec, ) if err != nil { return err diff --git a/cmd/config/config.go b/cmd/config/config.go index eec51d8f..1feb5836 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -16,6 +16,7 @@ package config import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ethermint "github.com/zeta-chain/ethermint/types" @@ -60,11 +61,11 @@ func SetBip44CoinType(config *sdk.Config) { // RegisterDenoms registers the base and display denominations to the SDK. func RegisterDenoms() { - if err := sdk.RegisterDenom(DisplayDenom, sdk.OneDec()); err != nil { + if err := sdk.RegisterDenom(DisplayDenom, sdkmath.LegacyOneDec()); err != nil { panic(err) } - if err := sdk.RegisterDenom(ethermint.AttoPhoton, sdk.NewDecWithPrec(1, ethermint.BaseDenomUnit)); err != nil { + if err := sdk.RegisterDenom(ethermint.AttoPhoton, sdkmath.LegacyNewDecWithPrec(1, ethermint.BaseDenomUnit)); err != nil { panic(err) } } diff --git a/cmd/ethermintd/genaccounts.go b/cmd/ethermintd/genaccounts.go index e633d8d6..091fe497 100644 --- a/cmd/ethermintd/genaccounts.go +++ b/cmd/ethermintd/genaccounts.go @@ -111,7 +111,10 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa baseAccount := authtypes.NewBaseAccount(addr, nil, 0, 0) if !vestingAmt.IsZero() { - baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd) + baseVestingAccount, err := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd) + if err != nil { + return fmt.Errorf("failed to create base vesting account: %w", err) + } if (balances.Coins.IsZero() && !baseVestingAccount.OriginalVesting.IsZero()) || baseVestingAccount.OriginalVesting.IsAnyGT(balances.Coins) { diff --git a/cmd/ethermintd/main.go b/cmd/ethermintd/main.go index 8fcf4aee..ed998f95 100644 --- a/cmd/ethermintd/main.go +++ b/cmd/ethermintd/main.go @@ -16,9 +16,9 @@ package main import ( + "fmt" "os" - "github.com/cosmos/cosmos-sdk/server" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,13 +33,8 @@ func main() { rootCmd, _ := NewRootCmd() if err := svrcmd.Execute(rootCmd, EnvPrefix, app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - - default: - os.Exit(1) - } + fmt.Fprintln(rootCmd.OutOrStderr(), err) + os.Exit(1) } } diff --git a/cmd/ethermintd/root.go b/cmd/ethermintd/root.go index 676c9b27..063adf87 100644 --- a/cmd/ethermintd/root.go +++ b/cmd/ethermintd/root.go @@ -25,48 +25,58 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - dbm "github.com/cometbft/cometbft-db" - tmcfg "github.com/cometbft/cometbft/config" - tmcli "github.com/cometbft/cometbft/libs/cli" - tmlog "github.com/cometbft/cometbft/libs/log" + cmtlog "cosmossdk.io/log" + confixcmd "cosmossdk.io/tools/confix/cmd" + cmtcfg "github.com/cometbft/cometbft/config" + cmtcli "github.com/cometbft/cometbft/libs/cli" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/config" + clientcfg "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/client/snapshot" + "github.com/cosmos/cosmos-sdk/crypto/keyring" sdkserver "github.com/cosmos/cosmos-sdk/server" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/snapshots" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/cosmos-sdk/types/tx/signing" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - - rosettaCmd "cosmossdk.io/tools/rosetta/cmd" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/zeta-chain/ethermint/app" - ethermintclient "github.com/zeta-chain/ethermint/client" - "github.com/zeta-chain/ethermint/client/debug" - "github.com/zeta-chain/ethermint/crypto/hd" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/ethereum/eip712" - "github.com/zeta-chain/ethermint/server" - servercfg "github.com/zeta-chain/ethermint/server/config" - srvflags "github.com/zeta-chain/ethermint/server/flags" - ethermint "github.com/zeta-chain/ethermint/types" + rosettaCmd "github.com/cosmos/rosetta/cmd" + "github.com/evmos/ethermint/app" + ethermintclient "github.com/evmos/ethermint/client" + "github.com/evmos/ethermint/client/debug" + "github.com/evmos/ethermint/crypto/hd" + "github.com/evmos/ethermint/ethereum/eip712" + "github.com/evmos/ethermint/server" + servercfg "github.com/evmos/ethermint/server/config" + srvflags "github.com/evmos/ethermint/server/flags" + ethermint "github.com/evmos/ethermint/types" ) const EnvPrefix = "ETHERMINT" +type emptyAppOptions struct{} + +func (ao emptyAppOptions) Get(_ string) interface{} { return nil } + // NewRootCmd creates a new root command for simd. It is called once in the // main function. func NewRootCmd() (*cobra.Command, ethermint.EncodingConfig) { - encodingConfig := encoding.MakeConfig(app.ModuleBasics) + tempApp := app.NewEthermintApp(cmtlog.NewNopLogger(), dbm.NewMemDB(), nil, true, emptyAppOptions{}) + encodingConfig := app.MakeConfigForTest() initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). @@ -94,11 +104,29 @@ func NewRootCmd() (*cobra.Command, ethermint.EncodingConfig) { return err } - initClientCtx, err = config.ReadFromClientConfig(initClientCtx) + initClientCtx, err = clientcfg.ReadFromClientConfig(initClientCtx) if err != nil { return err } + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode + // is only available if the client is online. + if !initClientCtx.Offline { + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL), + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfig, err := tx.NewTxConfigWithOptions( + initClientCtx.Codec, + txConfigOpts, + ) + if err != nil { + return err + } + + initClientCtx = initClientCtx.WithTxConfig(txConfig) + } if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } @@ -106,7 +134,7 @@ func NewRootCmd() (*cobra.Command, ethermint.EncodingConfig) { // FIXME: replace AttoPhoton with bond denom customAppTemplate, customAppConfig := servercfg.AppConfig(ethermint.AttoPhoton) - return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, tmcfg.DefaultConfig()) + return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, cmtcfg.DefaultConfig()) }, } @@ -120,15 +148,19 @@ func NewRootCmd() (*cobra.Command, ethermint.EncodingConfig) { ethermintclient.ValidateChainID( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), ), - genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, genutiltypes.DefaultMessageValidator), - genutilcli.MigrateGenesisCmd(), // TODO: shouldn't this include the local app version instead of the SDK? - genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), + genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, genutiltypes.DefaultMessageValidator, + encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), + genutilcli.MigrateGenesisCmd(genutilcli.MigrationMap), // TODO: shouldn't this include the local app version instead of the SDK? + genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, + encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), genutilcli.ValidateGenesisCmd(app.ModuleBasics), AddGenesisAccountCmd(app.DefaultNodeHome), - tmcli.NewCompletionCmd(rootCmd, true), + cmtcli.NewCompletionCmd(rootCmd, true), ethermintclient.NewTestnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), debug.Cmd(), - config.Cmd(), + confixcmd.ConfigCommand(), + pruning.Cmd(a.newApp, app.DefaultNodeHome), + snapshot.Cmd(a.newApp), ) a := appCreator{encodingConfig} @@ -136,7 +168,7 @@ func NewRootCmd() (*cobra.Command, ethermint.EncodingConfig) { // add keybase, auxiliary RPC, query, and tx child commands rootCmd.AddCommand( - rpc.StatusCommand(), + sdkserver.StatusCommand(), queryCommand(), txCommand(), ethermintclient.KeyCommands(app.DefaultNodeHome), @@ -150,6 +182,13 @@ func NewRootCmd() (*cobra.Command, ethermint.EncodingConfig) { // add rosetta rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)) + autoCliOpts := tempApp.AutoCliOpts() + initClientCtx, _ = clientcfg.ReadDefaultValuesFromDefaultClientConfig(initClientCtx) + autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring) + autoCliOpts.ClientCtx = initClientCtx + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } return rootCmd, encodingConfig } @@ -168,14 +207,12 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - authcmd.GetAccountCmd(), rpc.ValidatorCommand(), - rpc.BlockCommand(), + sdkserver.QueryBlockCmd(), + sdkserver.QueryBlockResultsCmd(), authcmd.QueryTxsByEventsCmd(), authcmd.QueryTxCmd(), ) - - app.ModuleBasics.AddQueryCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd @@ -199,10 +236,9 @@ func txCommand() *cobra.Command { authcmd.GetBroadcastCommand(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), - authcmd.GetAuxToFeeCommand(), + authcmd.GetSimulateCmd(), ) - app.ModuleBasics.AddTxCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd @@ -213,58 +249,8 @@ type appCreator struct { } // newApp is an appCreator -func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { - var cache sdk.MultiStorePersistentCache - - if cast.ToBool(appOpts.Get(sdkserver.FlagInterBlockCache)) { - cache = store.NewCommitKVStoreCacheManager() - } - - skipUpgradeHeights := make(map[int64]bool) - for _, h := range cast.ToIntSlice(appOpts.Get(sdkserver.FlagUnsafeSkipUpgrades)) { - skipUpgradeHeights[int64(h)] = true - } - - pruningOpts, err := sdkserver.GetPruningOptionsFromFlags(appOpts) - if err != nil { - panic(err) - } - home := cast.ToString(appOpts.Get(flags.FlagHome)) - snapshotDir := filepath.Join(home, "data", "snapshots") - if err = os.MkdirAll(snapshotDir, os.ModePerm); err != nil { - panic(err) - } - - snapshotDB, err := dbm.NewDB("metadata", sdkserver.GetAppDBBackend(appOpts), snapshotDir) - if err != nil { - panic(err) - } - snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) - if err != nil { - panic(err) - } - - snapshotOptions := snapshottypes.NewSnapshotOptions( - cast.ToUint64(appOpts.Get(sdkserver.FlagStateSyncSnapshotInterval)), - cast.ToUint32(appOpts.Get(sdkserver.FlagStateSyncSnapshotKeepRecent)), - ) - - // Setup chainId - chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) - if len(chainID) == 0 { - v := viper.New() - v.AddConfigPath(filepath.Join(home, "config")) - v.SetConfigName("client") - v.SetConfigType("toml") - if err := v.ReadInConfig(); err != nil { - panic(err) - } - conf := new(config.ClientConfig) - if err := v.Unmarshal(conf); err != nil { - panic(err) - } - chainID = conf.ChainID - } +func (a appCreator) newApp(logger cmtlog.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { + baseappOptions := sdkserver.DefaultBaseappOptions(appOpts) ethermintApp := app.NewEthermintApp( logger, db, traceStore, true, appOpts, @@ -285,10 +271,10 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer, return ethermintApp } -// appExport creates a new simapp (optionally at a given height) +// appExport creates a new app (optionally at a given height) // and exports state. func (a appCreator) appExport( - logger tmlog.Logger, + logger cmtlog.Logger, db dbm.DB, traceStore io.Writer, height int64, diff --git a/docs/api/proto-docs.md b/docs/api/proto-docs.md index 74a9f93d..cda806b4 100644 --- a/docs/api/proto-docs.md +++ b/docs/api/proto-docs.md @@ -1134,7 +1134,7 @@ Query defines the gRPC querier service. ### EthAccount -EthAccount implements the authtypes.AccountI interface and embeds an +EthAccount implements the sdk.AccountI interface and embeds an authtypes.BaseAccount type. It is compatible with the auth AccountKeeper. diff --git a/encoding/config.go b/encoding/config.go index 32f44958..d730e6df 100644 --- a/encoding/config.go +++ b/encoding/config.go @@ -16,31 +16,65 @@ package encoding import ( + "cosmossdk.io/x/tx/signing" amino "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/module" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/tx" - - enccodec "github.com/zeta-chain/ethermint/encoding/codec" - ethermint "github.com/zeta-chain/ethermint/types" + gogoproto "github.com/cosmos/gogoproto/proto" + "github.com/ethereum/go-ethereum/common" + enccodec "github.com/evmos/ethermint/encoding/codec" + ethermint "github.com/evmos/ethermint/types" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" ) -// MakeConfig creates an EncodingConfig for testing -func MakeConfig(mb module.BasicManager) ethermint.EncodingConfig { +var InterfaceRegistry types.InterfaceRegistry + +func customGetSignerFn(path string) func(msg proto.Message) ([][]byte, error) { + return func(msg proto.Message) ([][]byte, error) { + m := msg.ProtoReflect() + fieldDesc := m.Descriptor().Fields().ByName(protoreflect.Name(path)) + addr := common.BytesToAddress((m.Get(fieldDesc).Bytes())) + signer := sdk.AccAddress(addr.Bytes()) + return [][]byte{signer}, nil + } +} + +// MakeConfig creates an EncodingConfig +func MakeConfig() ethermint.EncodingConfig { cdc := amino.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() + signingOptions := signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + CustomGetSigners: map[protoreflect.FullName]signing.GetSignersFunc{ + "ethermint.evm.v1.MsgEthereumTx": customGetSignerFn("from"), + }, + } + interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: gogoproto.HybridResolver, + SigningOptions: signingOptions, + }) + if err != nil { + panic(err) + } codec := amino.NewProtoCodec(interfaceRegistry) - encodingConfig := ethermint.EncodingConfig{ InterfaceRegistry: interfaceRegistry, Codec: codec, TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), Amino: cdc, } - - enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino) - mb.RegisterLegacyAminoCodec(encodingConfig.Amino) + enccodec.RegisterLegacyAminoCodec(cdc) enccodec.RegisterInterfaces(encodingConfig.InterfaceRegistry) - mb.RegisterInterfaces(encodingConfig.InterfaceRegistry) + // This is needed for the EIP712 txs because currently is using + // the deprecated method legacytx.StdSignBytes + legacytx.RegressionTestingAminoCodec = cdc return encodingConfig } diff --git a/encoding/config_test.go b/encoding/config_test.go index c49f7ceb..f8c0f5a9 100644 --- a/encoding/config_test.go +++ b/encoding/config_test.go @@ -9,7 +9,6 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/encoding" "github.com/zeta-chain/ethermint/tests" evmtypes "github.com/zeta-chain/ethermint/x/evm/types" ) @@ -25,7 +24,7 @@ func TestTxEncoding(t *testing.T) { err := msg.Sign(ethSigner, signer) require.NoError(t, err) - cfg := encoding.MakeConfig(app.ModuleBasics) + cfg := app.MakeConfigForTest() _, err = cfg.TxConfig.TxEncoder()(msg) require.Error(t, err, "encoding failed") diff --git a/ethereum/eip712/eip712_legacy.go b/ethereum/eip712/eip712_legacy.go index 3c084038..e294650e 100644 --- a/ethereum/eip712/eip712_legacy.go +++ b/ethereum/eip712/eip712_legacy.go @@ -383,7 +383,7 @@ var ( addressType = reflect.TypeOf(common.Address{}) bigIntType = reflect.TypeOf(big.Int{}) cosmIntType = reflect.TypeOf(sdkmath.Int{}) - cosmDecType = reflect.TypeOf(sdk.Dec{}) + cosmDecType = reflect.TypeOf(sdkmath.LegacyDec{}) timeType = reflect.TypeOf(time.Time{}) cosmosAnyType = reflect.TypeOf(&codectypes.Any{}) edType = reflect.TypeOf(ed25519.PubKey{}) diff --git a/ethereum/eip712/eip712_test.go b/ethereum/eip712/eip712_test.go index 1acf471a..60d47aa4 100644 --- a/ethereum/eip712/eip712_test.go +++ b/ethereum/eip712/eip712_test.go @@ -6,7 +6,6 @@ import ( "testing" "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/client" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/signer/core/apitypes" @@ -24,7 +23,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/zeta-chain/ethermint/app" "github.com/zeta-chain/ethermint/cmd/config" - "github.com/zeta-chain/ethermint/encoding" "github.com/zeta-chain/ethermint/testutil" evmtypes "github.com/zeta-chain/ethermint/x/evm/types" @@ -70,7 +68,7 @@ func TestEIP712TestSuite(t *testing.T) { } func (suite *EIP712TestSuite) SetupTest() { - suite.config = encoding.MakeConfig(app.ModuleBasics) + suite.config = app.MakeConfigForTest() suite.clientCtx = client.Context{}.WithTxConfig(suite.config.TxConfig) suite.denom = evmtypes.DefaultEVMDenom @@ -164,8 +162,8 @@ func (suite *EIP712TestSuite) TestEIP712() { title: "Succeeds - Standard MsgDelegate", msgs: []sdk.Msg{ stakingtypes.NewMsgDelegate( - suite.createTestAddress(), - sdk.ValAddress(suite.createTestAddress()), + suite.createTestAddress().String(), + sdk.ValAddress(suite.createTestAddress()).String(), suite.makeCoins(suite.denom, math.NewInt(1))[0], ), }, @@ -175,8 +173,8 @@ func (suite *EIP712TestSuite) TestEIP712() { title: "Succeeds - Standard MsgWithdrawDelegationReward", msgs: []sdk.Msg{ distributiontypes.NewMsgWithdrawDelegatorReward( - suite.createTestAddress(), - sdk.ValAddress(suite.createTestAddress()), + suite.createTestAddress().String(), + sdk.ValAddress(suite.createTestAddress()).String(), ), }, expectSuccess: true, @@ -185,13 +183,13 @@ func (suite *EIP712TestSuite) TestEIP712() { title: "Succeeds - Two Single-Signer MsgDelegate", msgs: []sdk.Msg{ stakingtypes.NewMsgDelegate( - params.address, - sdk.ValAddress(suite.createTestAddress()), + params.address.String(), + sdk.ValAddress(suite.createTestAddress()).String(), suite.makeCoins(suite.denom, math.NewInt(1))[0], ), stakingtypes.NewMsgDelegate( - params.address, - sdk.ValAddress(suite.createTestAddress()), + params.address.String(), + sdk.ValAddress(suite.createTestAddress()).String(), suite.makeCoins(suite.denom, math.NewInt(5))[0], ), }, @@ -291,8 +289,8 @@ func (suite *EIP712TestSuite) TestEIP712() { { title: "Fails - Single Message / Multi-Signer", msgs: []sdk.Msg{ - banktypes.NewMsgMultiSend( - []banktypes.Input{ + &banktypes.MsgMultiSend{ + Inputs: []banktypes.Input{ banktypes.NewInput( suite.createTestAddress(), suite.makeCoins(suite.denom, math.NewInt(50)), @@ -302,7 +300,7 @@ func (suite *EIP712TestSuite) TestEIP712() { suite.makeCoins(suite.denom, math.NewInt(50)), ), }, - []banktypes.Output{ + Outputs: []banktypes.Output{ banktypes.NewOutput( suite.createTestAddress(), suite.makeCoins(suite.denom, math.NewInt(50)), @@ -312,12 +310,11 @@ func (suite *EIP712TestSuite) TestEIP712() { suite.makeCoins(suite.denom, math.NewInt(50)), ), }, - ), + }, }, expectSuccess: false, }, } - for _, tc := range testCases { for _, signMode := range signModes { suite.Run(tc.title, func() { @@ -364,7 +361,9 @@ func (suite *EIP712TestSuite) TestEIP712() { Address: sdk.MustBech32ifyAddressBytes(config.Bech32Prefix, pubKey.Bytes()), } - bz, err := suite.clientCtx.TxConfig.SignModeHandler().GetSignBytes( + bz, err := authsigning.GetSignBytesAdapter( + suite.clientCtx.CmdContext, + suite.clientCtx.TxConfig.SignModeHandler(), signMode, signerData, txBuilder.GetTx(), @@ -427,7 +426,6 @@ func (suite *EIP712TestSuite) verifyEIP712SignatureVerification(expectedSuccess func (suite *EIP712TestSuite) verifySignDocFlattening(signDoc []byte) { payload := gjson.ParseBytes(signDoc) suite.Require().True(payload.IsObject()) - flattened, _, err := eip712.FlattenPayloadMessages(payload) suite.Require().NoError(err) @@ -452,17 +450,20 @@ func (suite *EIP712TestSuite) verifyPayloadMapAgainstFlattenedMap(original map[s suite.Require().True(ok) messages, ok := interfaceMessages.([]interface{}) - suite.Require().True(ok) - - // Verify message contents - for i, msg := range messages { - flattenedMsg, ok := flattened[fmt.Sprintf("msg%d", i)] - suite.Require().True(ok) - - flattenedMsgJSON, ok := flattenedMsg.(map[string]interface{}) - suite.Require().True(ok) - - suite.Require().Equal(flattenedMsgJSON, msg) + // If passing an empty msgs array + // the interfaceMessages is nil + // in that case, don't try to iterate the messages + if ok { + // Verify message contents + for i, msg := range messages { + flattenedMsg, ok := flattened[fmt.Sprintf("msg%d", i)] + suite.Require().True(ok) + + flattenedMsgJSON, ok := flattenedMsg.(map[string]interface{}) + suite.Require().True(ok) + + suite.Require().Equal(flattenedMsgJSON, msg) + } } // Verify new payload does not have msgs field diff --git a/ethereum/eip712/encoding.go b/ethereum/eip712/encoding.go index af69fd58..d20ec0a6 100644 --- a/ethereum/eip712/encoding.go +++ b/ethereum/eip712/encoding.go @@ -189,8 +189,6 @@ func decodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error) { Gas: authInfo.Fee.GasLimit, } - tip := authInfo.Tip - // WrapTxToTypedData expects the payload as an Amino Sign Doc signBytes := legacytx.StdSignBytes( signDoc.ChainId, @@ -200,7 +198,6 @@ func decodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error) { *stdFee, msgs, body.Memo, - tip, ) typedData, err := WrapTxToTypedData( @@ -234,16 +231,20 @@ func validatePayloadMessages(msgs []sdk.Msg) error { var msgSigner sdk.AccAddress for i, m := range msgs { - if len(m.GetSigners()) != 1 { + signers, _, err := protoCodec.GetMsgV1Signers(m) + if err != nil { + return fmt.Errorf("error getting signers. %w", err) + } + if len(signers) != 1 { return errors.New("unable to build EIP-712 payload: expect exactly 1 signer") } if i == 0 { - msgSigner = m.GetSigners()[0] + msgSigner = signers[0] continue } - if !msgSigner.Equals(m.GetSigners()[0]) { + if !msgSigner.Equals(sdk.AccAddress(signers[0])) { return errors.New("unable to build EIP-712 payload: multiple signers detected") } } diff --git a/ethereum/eip712/encoding_legacy.go b/ethereum/eip712/encoding_legacy.go index 0a360cd8..8e4cf417 100644 --- a/ethereum/eip712/encoding_legacy.go +++ b/ethereum/eip712/encoding_legacy.go @@ -103,7 +103,11 @@ func legacyDecodeAminoSignDoc(signDocBytes []byte) (apitypes.TypedData, error) { msg := msgs[0] // By convention, the fee payer is the first address in the list of signers. - feePayer := msg.GetSigners()[0] + signers, _, err := protoCodec.GetMsgV1Signers(msg) + if err != nil { + return apitypes.TypedData{}, err + } + feePayer := signers[0] feeDelegation := &FeeDelegationOptions{ FeePayer: feePayer, } @@ -188,13 +192,15 @@ func legacyDecodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error Gas: authInfo.Fee.GasLimit, } - feePayer := msg.GetSigners()[0] + signers, _, err := protoCodec.GetMsgV1Signers(msg) + if err != nil { + return apitypes.TypedData{}, err + } + feePayer := signers[0] feeDelegation := &FeeDelegationOptions{ FeePayer: feePayer, } - tip := authInfo.Tip - // WrapTxToTypedData expects the payload as an Amino Sign Doc signBytes := legacytx.StdSignBytes( signDoc.ChainId, @@ -204,7 +210,6 @@ func legacyDecodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error *stdFee, msgs, body.Memo, - tip, ) typedData, err := LegacyWrapTxToTypedData( @@ -237,13 +242,17 @@ func legacyValidatePayloadMessages(msgs []sdk.Msg) error { return err } - if len(m.GetSigners()) != 1 { + signers, _, err := protoCodec.GetMsgV1Signers(m) + if err != nil { + return err + } + if len(signers) != 1 { return errors.New("unable to build EIP-712 payload: expect exactly 1 signer") } if i == 0 { msgType = t - msgSigner = m.GetSigners()[0] + msgSigner = signers[0] continue } @@ -251,7 +260,7 @@ func legacyValidatePayloadMessages(msgs []sdk.Msg) error { return errors.New("unable to build EIP-712 payload: different types of messages detected") } - if !msgSigner.Equals(m.GetSigners()[0]) { + if !msgSigner.Equals(sdk.AccAddress(signers[0])) { return errors.New("unable to build EIP-712 payload: multiple signers detected") } } diff --git a/ethereum/eip712/message.go b/ethereum/eip712/message.go index 7eef790d..0240423a 100644 --- a/ethereum/eip712/message.go +++ b/ethereum/eip712/message.go @@ -113,6 +113,10 @@ func getPayloadMessages(payload gjson.Result) ([]gjson.Result, error) { return nil, errorsmod.Wrap(errortypes.ErrInvalidRequest, "no messages found in payload, unable to parse") } + if rawMsgs.Type == gjson.Null { + return []gjson.Result{}, nil + } + if !rawMsgs.IsArray() { return nil, errorsmod.Wrap(errortypes.ErrInvalidRequest, "expected type array of messages, cannot parse") } diff --git a/go.mod b/go.mod index 4eb97a7c..b1cccc16 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/cometbft/cometbft v0.37.5 github.com/cometbft/cometbft-db v0.8.0 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.47.14 + github.com/cosmos/cosmos-sdk v0.50.11 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/v7 v7.2.0 @@ -64,7 +64,7 @@ require ( github.com/StackExchange/wmi v1.2.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.1 // indirect github.com/allegro/bigcache v1.2.1 // indirect - github.com/aws/aws-sdk-go v1.44.203 // indirect + github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect @@ -76,7 +76,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/cockroachdb/errors v1.10.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect @@ -85,7 +85,7 @@ require ( github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v0.20.1 // indirect + github.com/cosmos/iavl v1.0.1 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect @@ -94,7 +94,7 @@ require ( github.com/creachadair/taskgroup v0.4.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect @@ -135,16 +135,16 @@ require ( github.com/gorilla/handlers v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.5 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-plugin v1.6.0 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hdevalence/ed25519consensus v0.1.0 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect + github.com/hdevalence/ed25519consensus v0.2.0 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/huin/goupnp v1.3.0 // indirect @@ -171,6 +171,8 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect + github.com/oklog/run v1.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect diff --git a/go.sum b/go.sum index f52f5639..f235dcae 100644 --- a/go.sum +++ b/go.sum @@ -184,10 +184,14 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE= -cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw= -cosmossdk.io/core v0.5.1 h1:vQVtFrIYOQJDV3f7rw4pjjVqc1id4+mE0L9hHP66pyI= -cosmossdk.io/core v0.5.1/go.mod h1:KZtwHCLjcFuo0nmDc24Xy6CRNEL9Vl/MeimQ2aC7NLE= +cosmossdk.io/api v0.7.3 h1:V815i8YOwOAQa1rLCsSMjVG5Gnzs02JLq+l7ks8s1jk= +cosmossdk.io/api v0.7.3/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/client/v2 v2.0.0-beta.1 h1:XkHh1lhrLYIT9zKl7cIOXUXg2hdhtjTPBUfqERNA1/Q= +cosmossdk.io/client/v2 v2.0.0-beta.1/go.mod h1:JEUSu9moNZQ4kU3ir1DKD5eU4bllmAexrGWjmb9k8qU= +cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= +cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= +cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= @@ -199,8 +203,8 @@ cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= -filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= @@ -245,16 +249,15 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.44.203 h1:pcsP805b9acL3wUqa4JR2vg1k2wnItkDYNvfmcy6F+U= -github.com/aws/aws-sdk-go v1.44.203/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= +github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -299,8 +302,8 @@ github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= @@ -413,11 +416,12 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= @@ -452,6 +456,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/emicklei/dot v1.6.1 h1:ujpDlBkkwgWUY+qPId5IwapRW/xEoligRSYjioR6DFI= +github.com/emicklei/dot v1.6.1/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -490,9 +496,7 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= @@ -502,8 +506,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= +github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -535,9 +540,7 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= @@ -678,31 +681,26 @@ github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qK github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 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/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/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= -github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= -github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -717,8 +715,12 @@ github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17 github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= +github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= @@ -726,16 +728,17 @@ github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoD github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -855,12 +858,7 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -882,7 +880,6 @@ github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iP github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -907,6 +904,8 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= +github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= @@ -951,8 +950,8 @@ github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6 github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU= +github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= @@ -973,34 +972,32 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= +github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= +github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= -github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -1011,11 +1008,11 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= -github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= +github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= @@ -1087,6 +1084,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -1119,7 +1117,6 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= @@ -1150,8 +1147,8 @@ github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= -go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= +go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1189,6 +1186,7 @@ go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTV go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1198,7 +1196,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -1420,7 +1417,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1496,6 +1492,7 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1826,7 +1823,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= diff --git a/gomod2nix.toml b/gomod2nix.toml index 2a8aa9d4..0ddde3e6 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -5,23 +5,29 @@ schema = 3 version = "v0.112.0" hash = "sha256-lmNLoqmLURfxu+a6V/SeoP8xVn0Wi2SD7uxxAtSjm+o=" [mod."cloud.google.com/go/compute"] - version = "v1.23.3" - hash = "sha256-WwlTw/x9GSM6B4nHm9FDvHZ1Pd4KN0wxk650CosJnpQ=" + version = "v1.24.0" + hash = "sha256-icDjR0uxYeazRbhsBgl8Dx7z/oRZJ/iqK6CGjCtsaQQ=" [mod."cloud.google.com/go/compute/metadata"] version = "v0.2.3" hash = "sha256-kYB1FTQRdTDqCqJzSU/jJYbVUGyxbkASUKbEs36FUyU=" [mod."cloud.google.com/go/iam"] - version = "v1.1.5" - hash = "sha256-nETSf8U75kLNXk82JdQaJz394z8cXMbpNYSm1KE03GA=" + version = "v1.1.6" + hash = "sha256-u91oZdyy/wgk3J8Z+4mWmn+YliSBIATu6kpyH20Dd8k=" [mod."cloud.google.com/go/storage"] version = "v1.36.0" hash = "sha256-dRKH1NEyAfEpVo5Mma677L7z0JO9Mfd1bv1lr1uFngI=" [mod."cosmossdk.io/api"] - version = "v0.3.1" - hash = "sha256-yQUn04n0/s3DpNWu7TF3NG+awWKxgvRpV9CYIV+dR7k=" + version = "v0.7.3" + hash = "sha256-G72m5tUKLrpl89YKM/S7J/e8rYkqctuDOqHbqxyzTBI=" + [mod."cosmossdk.io/client/v2"] + version = "v2.0.0-beta.1" + hash = "sha256-5o3FSZ9xcYG4KLTOMbVFfPhV4CtlUn4LxjEm3/t1nOU=" + [mod."cosmossdk.io/collections"] + version = "v0.4.0" + hash = "sha256-minFyzgO/D+Oda4E3B1qvOAN5qd65SjS6nmjca4cp/8=" [mod."cosmossdk.io/core"] - version = "v0.5.1" - hash = "sha256-NSIUDRmJRpxsy/GE2kXOa1G3UaoPxVnhi4f7izjFzO4=" + version = "v0.11.0" + hash = "sha256-zUiOF04lWHK8OZqGhwVuzKYfig5I0107D+8fWX5/pbQ=" [mod."cosmossdk.io/depinject"] version = "v1.0.0-alpha.4" hash = "sha256-xpLH0K6ivQznFrLw2hmhWIIyYgqjstV47OhTEj/c1oQ=" @@ -29,27 +35,45 @@ schema = 3 version = "v1.0.1" hash = "sha256-MgTocXkBzri9FKkNtkARJXPmxRrRO/diQJS5ZzvYrJY=" [mod."cosmossdk.io/log"] - version = "v1.4.1" - hash = "sha256-pgI770MdI/OfZcK6UFmQ9iyPBgapz/ErrUe8WVO3iBg=" + version = "v1.3.1" + hash = "sha256-otkUvsz35VuuUWXoTmWBwR61+o6YzvWETGdLfwWDvwY=" [mod."cosmossdk.io/math"] version = "v1.3.0" hash = "sha256-EEFK43Cr0g0ndhQhkIKher0FqV3mvkmE9z0sP7uVSHg=" - [mod."cosmossdk.io/tools/rosetta"] - version = "v0.2.1" - hash = "sha256-TrkXwA1ZdwSyu3te0DLMBynCb7CGEtefo2wzFvxeyU8=" + [mod."cosmossdk.io/store"] + version = "v1.0.2" + hash = "sha256-mEaBNfU892M3V6qTMEDXb1GLaywlyouTRC5XfVqNSMs=" + [mod."cosmossdk.io/tools/confix"] + version = "v0.1.1" + hash = "sha256-/Et2FFhb4XfakbLFvGQK3QxN5Y7alzO+DGfi2/EWbxo=" + [mod."cosmossdk.io/x/evidence"] + version = "v0.1.0" + hash = "sha256-ZhVrmCGOzx2yODpcgvM9c48jkqz37NwU2ln/uVuCEfc=" + [mod."cosmossdk.io/x/feegrant"] + version = "v0.1.0" + hash = "sha256-/gWvrqvy6bW90+NU66T+9QysYgvG1VbwfYJZ8tkqpeA=" + [mod."cosmossdk.io/x/tx"] + version = "v0.13.1" + hash = "sha256-dHv2Zx8xbqfv1Gq0syh33G7TFJOVx4857QMH4b8Jj9k=" + [mod."cosmossdk.io/x/upgrade"] + version = "v0.1.1" + hash = "sha256-bM9ybpaibMH7k4M6/QAXCZ3fJcADfJHxvMgp4AVUihs=" [mod."filippo.io/edwards25519"] - version = "v1.0.0" - hash = "sha256-APnPAcmItvtJ5Zsy863lzR2TjEBF9Y66TY1e4M1ap98=" + version = "v1.1.0" + hash = "sha256-9ACANrgWZSd5HYPfDZHY8DVbPSC9LOMgy8deq3rDOoc=" [mod."github.com/99designs/go-keychain"] version = "v0.0.0-20191008050251-8e49817e8af4" hash = "sha256-4EndKcspGC3GOPCmctXF1NnWzxWwMyY/OQpFMmr8Sc0=" [mod."github.com/99designs/keyring"] - version = "v1.2.1" - hash = "sha256-OG3YGMFql9Vd5IzysdmyGjXhd39wQq0qh3YRQi4k7SI=" - [mod."github.com/ChainSafe/go-schnorrkel"] - version = "v0.0.0-20200405005733-88cbf1b4c40d" - hash = "sha256-i8RXZemJGlSjBT35oPm0SawFiBoIU5Pkq5xp4n/rzCY=" - replaced = "github.com/ChainSafe/go-schnorrkel" + version = "v1.2.0" + hash = "sha256-emQlH+RQpESoFCzpHS38fEhs1SLjotxNPlRK4B5Aybs=" + replaced = "github.com/cosmos/keyring" + [mod."github.com/DataDog/datadog-go"] + version = "v4.8.3+incompatible" + hash = "sha256-9KvlVQdgyJ1ulDa6wkLb0ACdjc+R0U91hdb7nxodrA0=" + [mod."github.com/DataDog/zstd"] + version = "v1.5.5" + hash = "sha256-tSw0aq0pPyroZtQYYb9lWOtPVNaQOt8skYQ4TMXGvAQ=" [mod."github.com/Microsoft/go-winio"] version = "v0.6.1" hash = "sha256-BL0BVaHtmPKQts/711W59AbHXjGKqFS4ZTal0RYnR9I=" @@ -62,12 +86,9 @@ schema = 3 [mod."github.com/allegro/bigcache"] version = "v1.2.1" hash = "sha256-/DwqBxg75m1zzOB8BWbpjQ/jYnhoe/SMXc4310mOlMA=" - [mod."github.com/armon/go-metrics"] - version = "v0.4.1" - hash = "sha256-usxTUHA0QQMdM6sHi2z51nmnEKMbA0qUilxJFpWHlYE=" [mod."github.com/aws/aws-sdk-go"] - version = "v1.44.203" - hash = "sha256-Kq501D1YAz/3nXqcszDDAnf6huZarJh5onzgEfmWbms=" + version = "v1.44.224" + hash = "sha256-zkewIYLOT+CvBDsxXnY2ZaFyoDdt/JCFQ2sCIdBmTFo=" [mod."github.com/beorn7/perks"] version = "v1.0.1" hash = "sha256-h75GUqfwJKngCJQVE5Ao5wnO3cfKD9lSIteoLp/3xJ4=" @@ -78,8 +99,8 @@ schema = 3 version = "v0.1.1-0.20220910012023-760eaf8b6816" hash = "sha256-Tx3sPuhsoVwrCfJdIwf4ipn7pD92OQNYvpCxl1Z9Wt0=" [mod."github.com/bits-and-blooms/bitset"] - version = "v1.10.0" - hash = "sha256-/Kkx33umYGS1keFnkmJ+DHgIAtkEDNI42nVpKYfUOTs=" + version = "v1.8.0" + hash = "sha256-ySle5MJXSGMHJa1HSf/ZMDTYXdow9ct7JXth4k5Po50=" [mod."github.com/btcsuite/btcd"] version = "v0.24.2" hash = "sha256-ahlpwEr4KfyrEA899X07QtuSDnC8U+SnwL+z72DiK5E=" @@ -93,8 +114,8 @@ schema = 3 version = "v1.1.0" hash = "sha256-F+EqvufC+KBslZV/vL8ph6MqDoVD5ic5rVaM27reDqo=" [mod."github.com/cenkalti/backoff/v4"] - version = "v4.1.3" - hash = "sha256-u6MEDopHoTWAZoVvvXOKnAg++xre53YgQx0gmf6t2KU=" + version = "v4.2.1" + hash = "sha256-CKogmPe0pCcAdpztzPwr24rLTJZfq8QVZ9AUduwAcoA=" [mod."github.com/cespare/xxhash"] version = "v1.1.0" hash = "sha256-nVDTtXH9PC3yJ0THaQZEN243UP9xgLi/clt5xRqj3+M=" @@ -108,11 +129,15 @@ schema = 3 version = "v2.0.2" hash = "sha256-UrPHkvqVF8V78+kXKmjTHl79XsgDBnqFsje5BMYh0E4=" [mod."github.com/cockroachdb/errors"] - version = "v1.10.0" - hash = "sha256-l6CCw3FKGNaGlwzLfAaF0cruf3E9MZr6GK1GZ+vQm2c=" + version = "v1.11.1" + hash = "sha256-ufKtavyfW/i3ZemiqDqKGc0JM+f0IBi6bZWkZyb/jdc=" [mod."github.com/cockroachdb/logtags"] version = "v0.0.0-20230118201751-21c54148d20b" hash = "sha256-7dQH6j1o99fuxHKkw0RhNC5wJKkvRLMDJpUiVnDx6h8=" + [mod."github.com/cockroachdb/pebble"] + version = "v0.0.0-20230209160836-829675f94811" + hash = "sha256-DpbEXN/YWWXap83lz99r6sAUUk76ixDe4fRn1GpBWpo=" + replaced = "github.com/cockroachdb/pebble" [mod."github.com/cockroachdb/redact"] version = "v1.1.5" hash = "sha256-0rtT7LRO0wxf9XovOK8GXRrhmx8OcbdPK/mXOKbJdog=" @@ -120,30 +145,23 @@ schema = 3 version = "v1.0.0" hash = "sha256-z/0E0NiEGo7zxM7d94ImgUf8P0/KG6hbP9T4Vuym4p0=" [mod."github.com/cometbft/cometbft"] - version = "v0.37.2" - hash = "sha256-lldrYWvcwV6x9uSJWwycf5OCaNkLU6K5g25IbNnMyVE=" - replaced = "github.com/cometbft/cometbft" + version = "v0.38.6" + hash = "sha256-2boDIBhWeQM7c9mAKB23cJ7bHYGf1+Dl0QeFDtO8Usk=" [mod."github.com/cometbft/cometbft-db"] - version = "v0.8.0" - hash = "sha256-Tlm2V9zDs/wVoFvMmJSdCzCdZKiFRC7Qk8FS3FaqQyk=" - [mod."github.com/confio/ics23/go"] - version = "v0.9.0" - hash = "sha256-guD8w7YygfUp7lpTAUyXQuCPx8F3lXkcg+yR5+JOCbk=" - [mod."github.com/consensys/bavard"] - version = "v0.1.13" - hash = "sha256-DEx0JuvgqNCNv7IMHlbLJK6pb1ru29C/rTSKh6YksVg=" - [mod."github.com/consensys/gnark-crypto"] - version = "v0.12.1" - hash = "sha256-M7S5XbXKsvx2Uw2qNtsQg0RmlhFtSCzXEL2T3vzeq7o=" + version = "v0.9.1" + hash = "sha256-ftRdle5ok2aCyqT3u5rYY0jKB8WT8uDus26Pw4Mo1go=" [mod."github.com/cosmos/btcutil"] version = "v1.0.5" hash = "sha256-t572Sr5iiHcuMKLMWa2i+LBAt192oa+G1oA371tG/eI=" + [mod."github.com/cosmos/cosmos-db"] + version = "v1.0.2" + hash = "sha256-WjDoB2AGoIyEW30LlGcQX5JVACJbs0jWSY58IuJHz0M=" [mod."github.com/cosmos/cosmos-proto"] - version = "v1.0.0-beta.5" - hash = "sha256-Fy/PbsOsd6iq0Njy3DVWK6HqWsogI+MkE8QslHGWyVg=" + version = "v1.0.0-beta.4" + hash = "sha256-5Kn82nsZfiEtuwhhLZqmMxdAY1tX/Fi3HJ0/MEaRohw=" [mod."github.com/cosmos/cosmos-sdk"] - version = "v0.47.14" - hash = "sha256-iSPEm4Z4LLDjpB7zdZetM2QxyJ06lKY8/h7JsSiu+CE=" + version = "v0.50.5-0.20240318121607-9a59234c4202" + hash = "sha256-JKBGS1Tcq95mp7UVGIBusf96z6ksZyyDCCyOSacpcFA=" [mod."github.com/cosmos/go-bip39"] version = "v1.0.0" hash = "sha256-Qm2aC2vaS8tjtMUbHmlBSagOSqbduEEDwc51qvQaBmA=" @@ -151,35 +169,38 @@ schema = 3 version = "v1.2.0" hash = "sha256-Hd19V0RCiMoCL67NsqvWIsvWF8KM3LnuJTbYjWtQkEo=" [mod."github.com/cosmos/gogoproto"] - version = "v1.7.0" - hash = "sha256-ZkEUImxBBo8Q/6c7tVR0rybpLbtlplzvgfLl5xvtV00=" + version = "v1.4.11" + hash = "sha256-hXJIGN8Arg09ldCgrSyYZK+xMelYavEj2I3ltxJfAqE=" [mod."github.com/cosmos/iavl"] - version = "v0.20.1" - hash = "sha256-AlvJ9ufYrgTaY/C+zEs2DA2b6jqRaqDVDOwy2xtrThM=" - [mod."github.com/cosmos/ibc-go/v7"] - version = "v7.2.0" - hash = "sha256-fg+0AykvEMzqRGI5CmqwjQtSIwTyT6RuSDpp12wzReM=" + version = "v1.0.1" + hash = "sha256-owSjZEVLrFoLjO/wm8bxbVLhqRv/uX+8usdVMnbOn/s=" + [mod."github.com/cosmos/ibc-go/modules/capability"] + version = "v1.0.0" + hash = "sha256-xOeHJWUj6fTc2EUGiE4dgfY2WkvrqTg/FWewoUvQcvg=" + [mod."github.com/cosmos/ibc-go/v8"] + version = "v8.1.0" + hash = "sha256-uwYDKW+lFEfLR6Ro+HM3KhBi7B0mGMutH8oWdoZM7d8=" [mod."github.com/cosmos/ics23/go"] version = "v0.10.0" hash = "sha256-KYEv727BO/ht63JO02xiKFGFAddg41Ve9l2vSSZZBq0=" [mod."github.com/cosmos/ledger-cosmos-go"] - version = "v0.12.4" - hash = "sha256-SYABql9QYhuZaNxRnvfHw/KqDTTzjYWgzbN7PDKVmGA=" + version = "v0.13.3" + hash = "sha256-4f73odipfgWku0/gK2UtXbrBXvj8kT9sg4IhnfAP/S0=" + [mod."github.com/cosmos/rosetta"] + version = "v0.50.3-1" + hash = "sha256-lmB2W6b4cmyGHLh3OpOLnGy2Q75QONLtrWwp/Pvnf6k=" [mod."github.com/cosmos/rosetta-sdk-go"] version = "v0.10.0" hash = "sha256-WmLq9E9mYV+ms6Tdb43lCoAy6cowkDnK4bvX/ApDzLY=" - [mod."github.com/crate-crypto/go-ipa"] - version = "v0.0.0-20231025140028-3c0104f4b233" - hash = "sha256-FUTI6x4sWr5QuINpwXtEG202elrhwqbxsesDc7Mp/DU=" - [mod."github.com/crate-crypto/go-kzg-4844"] - version = "v0.7.0" - hash = "sha256-vQ2CLr+JFd6zotMhOFLr4Xv1xTJTHWubmO7d2bf+Lis=" - [mod."github.com/creachadair/taskgroup"] - version = "v0.4.2" - hash = "sha256-AjtQRoLKLSAbyKd8YlaXcYn0pek6oo5U3R28dvtKv14=" + [mod."github.com/creachadair/atomicfile"] + version = "v0.3.1" + hash = "sha256-GEp1gRxKfBYI6K0XbElcVYcJMPu6eeLufaYxr7Z0MAQ=" + [mod."github.com/creachadair/tomledit"] + version = "v0.0.24" + hash = "sha256-4vUukHONOjNn0qfQr4esK6TWfPWsIp+rbdz65og84lw=" [mod."github.com/danieljoos/wincred"] - version = "v1.1.2" - hash = "sha256-Nnklfg12vmWCOhELGyoRqEF4w4srp0WbPwreaChYLKs=" + version = "v1.2.0" + hash = "sha256-LHcvTJCc8++bFndbd8ZgMSTe4L5h2C4rN+cSWHCz54Y=" [mod."github.com/davecgh/go-spew"] version = "v1.1.2-0.20180830191138-d8f796af33cc" hash = "sha256-fV9oI51xjHdOmEx6+dlq7Ku2Ag+m/bmbzPo6A4Y74qc=" @@ -187,8 +208,8 @@ schema = 3 version = "v2.1.0" hash = "sha256-Co6gfAcVn256IUEJNNPmVlx8LZRI4sT+KmqGs2uIQ90=" [mod."github.com/decred/dcrd/dcrec/secp256k1/v4"] - version = "v4.1.0" - hash = "sha256-cS4ZrKz1B4G7+vqih6B7C/WNkcMvRKmvR6S8aw7PotY=" + version = "v4.2.0" + hash = "sha256-Mw+axGW3RzaRFzcYc7/9/gpqZgWXZHeyT2c4USFtAQA=" [mod."github.com/desertbit/timer"] version = "v0.0.0-20180107155436-c41aec40b27f" hash = "sha256-abLOtEcomAqCWLphd2X6WkD/ED764w6sa6unox4BXss=" @@ -213,13 +234,19 @@ schema = 3 [mod."github.com/dvsekhvalnov/jose2go"] version = "v1.6.0" hash = "sha256-IXn2BuUp4fi/i2zf1tGGW1m9xoYh3VCksB6GJ5Sf06g=" - [mod."github.com/ethereum/c-kzg-4844"] - version = "v0.4.0" - hash = "sha256-Ol5bznli6Dh5uXi8GUGsjZo8DzCdF0hqsUMwDNUpxP0=" + [mod."github.com/edsrzf/mmap-go"] + version = "v1.0.0" + hash = "sha256-k1DYvCqO3BKNcGEve/nMW0RxzMkK2tGfXbUbycqcVSo=" + [mod."github.com/emicklei/dot"] + version = "v1.6.1" + hash = "sha256-zOpoaepCfPLmU9iQji/Ait+SVEHI9eF3rwtW0h/8lho=" [mod."github.com/ethereum/go-ethereum"] - version = "v1.13.16-0.20241022183758-422c6ef93ccc" - hash = "sha256-Nxipk3PKrfSb/IxBz6r69rPtcnFSDMYj0UWOC0WJibI=" - replaced = "github.com/zeta-chain/go-ethereum" + version = "v1.10.20-0.20231207063621-43cf32d91c3e" + hash = "sha256-lDIqRLUrXYCb9mmFBY/+WW+ee69+IkxOgqjHVyo4ij0=" + replaced = "github.com/crypto-org-chain/go-ethereum" + [mod."github.com/fatih/color"] + version = "v1.16.0" + hash = "sha256-Aq/SM28aPJVzvapllQ64R/DM4aZ5CHPewcm/AUJPyJQ=" [mod."github.com/felixge/httpsnoop"] version = "v1.0.4" hash = "sha256-c1JKoRSndwwOyOxq9ddCe+8qn7mG9uRq2o/822x5O/c=" @@ -233,11 +260,11 @@ schema = 3 version = "v0.1.1-0.20231031103413-a67434b50f46" hash = "sha256-ccLo8Dx6QMbsn8qBoRdz6Nj464O3PgcgsMF889gPjC8=" [mod."github.com/getsentry/sentry-go"] - version = "v0.23.0" - hash = "sha256-VR6IL+yIc+BV5xBGfPJ7ixsAVzJ/hzuvXmkkAn1cTk4=" + version = "v0.27.0" + hash = "sha256-PTkTzVNogqFA/5rc6INLY6RxK5uR1AoJFOO+pOPdE7Q=" [mod."github.com/go-kit/kit"] - version = "v0.12.0" - hash = "sha256-5RkXo6s0oye8etgD5qy+AvkkkNsQ6jc0kWJj6flA4GM=" + version = "v0.13.0" + hash = "sha256-EncDzq0JVtY+NLlW5lD+nbVewNYTTrfzlOxI4PuwREw=" [mod."github.com/go-kit/log"] version = "v0.2.1" hash = "sha256-puLJ+up45X2j9E3lXvBPKqHPKOA/sFAhfCqGxsITW/Y=" @@ -245,8 +272,8 @@ schema = 3 version = "v0.6.0" hash = "sha256-RtIG2qARd5sT10WQ7F3LR8YJhS8exs+KiuUiVf75bWg=" [mod."github.com/go-logr/logr"] - version = "v1.3.0" - hash = "sha256-N8JYtQlwpLWTaCczfhfA/YmHExko0ObPMYVGw8JwbSw=" + version = "v1.4.1" + hash = "sha256-WM4badoqxXlBmqCRrnmtNce63dLlr/FJav3BJSYHvaY=" [mod."github.com/go-logr/stdr"] version = "v1.2.2" hash = "sha256-rRweAP7XIb4egtT1f2gkz4sYOu7LDHmcJ5iNsJUd0sE=" @@ -308,38 +335,41 @@ schema = 3 version = "v2.12.0" hash = "sha256-ZcXS+1B11UaJHf8D15N3ZCh00fiMUncpHd+eNRffLZ4=" [mod."github.com/gorilla/handlers"] - version = "v1.5.1" - hash = "sha256-GnBAARgOx1E+hDMQ63SI17hdhGtLQxb31lZOmn5j/pU=" + version = "v1.5.2" + hash = "sha256-2WQeVCe7vQg+8MpNLMhOGsRdbrcWLpbtUhUX8mbiQrs=" [mod."github.com/gorilla/mux"] - version = "v1.8.0" - hash = "sha256-s905hpzMH9bOLue09E2JmzPXfIS4HhAlgT7g13HCwKE=" + version = "v1.8.1" + hash = "sha256-nDABvAhlYgxUW2N/brrep7NkQXoSGcHhA+XI4+tK0F0=" [mod."github.com/gorilla/websocket"] - version = "v1.5.0" - hash = "sha256-EYVgkSEMo4HaVrsWKqnsYRp8SSS8gNf7t+Elva02Ofc=" + version = "v1.5.1" + hash = "sha256-eHZ/U+eeE5tSgWc1jEDuBwtTRbXKP9fqP9zfW4Zw8T0=" [mod."github.com/grpc-ecosystem/go-grpc-middleware"] - version = "v1.3.0" - hash = "sha256-seaTQMNz/lWzpR3ex2gSM1Yo2yD2q6bJQZvB1L3CONk=" + version = "v1.4.0" + hash = "sha256-0UymBjkg41C9MPqkBLz/ZY9WbimZrabpJk+8C/X63h8=" [mod."github.com/grpc-ecosystem/grpc-gateway"] version = "v1.16.0" hash = "sha256-wLymGic7wZ6fSiBYDAaGqnQ9Ste1fUWeqXeolZXCHvI=" [mod."github.com/gsterjov/go-libsecret"] version = "v0.0.0-20161001094733-a6f4afe4910c" hash = "sha256-Z5upjItPU9onq5t7VzhdQFp13lMJrSiE3gNRapuK6ic=" - [mod."github.com/gtank/merlin"] - version = "v0.1.1" - hash = "sha256-tfP9DFdPIfAt29pCta6dObAABCbZt4y3ZActH6ERkr0=" - [mod."github.com/gtank/ristretto255"] - version = "v0.1.2" - hash = "sha256-fAoVTP1s5+f7/YtnzI+gaEz1MS+FuCgy3sT19ZHIxE4=" [mod."github.com/hashicorp/go-cleanhttp"] version = "v0.5.2" hash = "sha256-N9GOKYo7tK6XQUFhvhImtL7PZW/mr4C4Manx/yPVvcQ=" [mod."github.com/hashicorp/go-getter"] - version = "v1.7.5" - hash = "sha256-oXUvMoee8GT69MA0E2JHxYm1Q2q8BtmwlfxFshDKXmI=" + version = "v1.7.3" + hash = "sha256-z3zrjcOsgJrZkGLwaKVauq/MFAPtulXatV/RrkKNJv4=" + [mod."github.com/hashicorp/go-hclog"] + version = "v1.5.0" + hash = "sha256-u3Jqg7Qex11IZ7vbk4hRGgLy6e0cF70CCx7ERF0GUHo=" [mod."github.com/hashicorp/go-immutable-radix"] version = "v1.3.1" hash = "sha256-65+A2HiVfS/GV9G+6/TkXXjzXhI/V98e6RlJWjxy+mg=" + [mod."github.com/hashicorp/go-metrics"] + version = "v0.5.3" + hash = "sha256-5jQftEvEhL88yWeVnu+IZKzV5p9osZcgFmwP1zlrjzY=" + [mod."github.com/hashicorp/go-plugin"] + version = "v1.6.0" + hash = "sha256-NeY86Z+qJwt0NPV4cNmWDiTryDPSiyKMkS1ivRX9ThE=" [mod."github.com/hashicorp/go-safetemp"] version = "v1.0.0" hash = "sha256-g5i9m7FSRInQzZ4iRpIsoUu685AY7fppUwjhuZCezT8=" @@ -347,14 +377,17 @@ schema = 3 version = "v1.6.0" hash = "sha256-UV0equpmW6BiJnp4W3TZlSJ+PTHuTA+CdOs2JTeHhjs=" [mod."github.com/hashicorp/golang-lru"] - version = "v0.5.5-0.20210104140557-80c98217689d" - hash = "sha256-w5utLMR7p5pF9xX+mI3N9NyfQ8ixNXNTgfXDu8fudmc=" + version = "v1.0.2" + hash = "sha256-yy+5botc6T5wXgOe2mfNXJP3wr+MkVlUZ2JBkmmrA48=" [mod."github.com/hashicorp/hcl"] version = "v1.0.0" hash = "sha256-xsRCmYyBfglMxeWUvTZqkaRLSW+V2FvNodEDjTGg1WA=" + [mod."github.com/hashicorp/yamux"] + version = "v0.1.1" + hash = "sha256-jr4ZFM3XHSwGoZcRcmmdGTq4IqxBTnimojIPDgK0USU=" [mod."github.com/hdevalence/ed25519consensus"] - version = "v0.1.0" - hash = "sha256-MkqFWnyXt653RaJQUMWWxcW6NCskIxou8VEfj+8vd3Y=" + version = "v0.2.0" + hash = "sha256-KTbeKMOT/HCJjDHqyciQjJPPgpNk6H0VyQCCbeGgs7Y=" [mod."github.com/holiman/bloomfilter/v2"] version = "v2.0.3" hash = "sha256-5VsJMQzJSNd4F7yAl3iF/q6JodWOlE4dUvTQ0UGPe+k=" @@ -365,8 +398,11 @@ schema = 3 version = "v1.2.0" hash = "sha256-/r4QP1SldMlhpkr1ZQFHImSYaeMZEtqBW7R53yN+JtQ=" [mod."github.com/huin/goupnp"] - version = "v1.3.0" - hash = "sha256-/VTfjUhHLGuXymYBC1vQJv1N8O1AjYwC/xTGd6h3Uw0=" + version = "v1.0.3" + hash = "sha256-EMGmTdoQhP2bVbCPX37hes5krqXn6NFexfnKr9E5u8I=" + [mod."github.com/iancoleman/strcase"] + version = "v0.3.0" + hash = "sha256-lVOk4klrikSCUviR16qcyAr6eoIbniUSfsLFOE1ZLpk=" [mod."github.com/improbable-eng/grpc-web"] version = "v0.15.0" hash = "sha256-9oqKb5Y3hjleOFE2BczbEzLH6q2Jg7kUTP/M8Yk4Ne4=" @@ -383,8 +419,8 @@ schema = 3 version = "v1.0.0" hash = "sha256-xEd0mDBeq3eR/GYeXjoTVb2sPs8sTCosn5ayWkcgENI=" [mod."github.com/klauspost/compress"] - version = "v1.17.0" - hash = "sha256-Ig86slHz98UbvvkCYK1QXReArAK74T/UNedVq/ZjH5k=" + version = "v1.17.7" + hash = "sha256-UkW+tAFEZYj067z9gXDQjQx0dCF8noCn5OSw/APh4oo=" [mod."github.com/kr/pretty"] version = "v0.3.1" hash = "sha256-DlER7XM+xiaLjvebcIPiB12oVNjyZHuJHoRGITzzpKU=" @@ -398,8 +434,8 @@ schema = 3 version = "v0.1.0" hash = "sha256-wQqGTtRWsfR9n0O/SXHVgECebbnNmHddxJIbG63OJBQ=" [mod."github.com/linxGnu/grocksdb"] - version = "v1.7.16" - hash = "sha256-XJG6LqvXvlwpkAsuSYR+IPTDzByNdcS7oQA+eg98+D4=" + version = "v1.8.12" + hash = "sha256-1tlgs/JnopLI8eoWJlv9hP4jf0OTm1qMZTSg0jAkG7A=" [mod."github.com/magiconair/properties"] version = "v1.8.7" hash = "sha256-XQ2bnc2s7/IH3WxEO4GishZurMyKwEclZy1DXg+2xXc=" @@ -413,14 +449,8 @@ schema = 3 version = "v0.0.20" hash = "sha256-qhw9hWtU5wnyFyuMbKx+7RB8ckQaFQ8D+8GKPkN3HHQ=" [mod."github.com/mattn/go-runewidth"] - version = "v0.0.13" - hash = "sha256-93AwJFA8B2pwNJAPe64yN0c/CwkJNGFDWFe/HpzDVuk=" - [mod."github.com/matttproud/golang_protobuf_extensions"] - version = "v1.0.4" - hash = "sha256-uovu7OycdeZ2oYQ7FhVxLey5ZX3T0FzShaRldndyGvc=" - [mod."github.com/mimoo/StrobeGo"] - version = "v0.0.0-20210601165009-122bf33a46e0" - hash = "sha256-rmw70RHsbeOnema++aFCPdswADMVKtb7KGF3msOI7ak=" + version = "v0.0.9" + hash = "sha256-dK/kIPe1tcxEubwI4CWfov/HWRBgD/fqlPC3d5i30CY=" [mod."github.com/minio/highwayhash"] version = "v1.0.2" hash = "sha256-UeHeepKtToyA5e/w3KdmpbCn+4medesZG0cAcU6P2cY=" @@ -439,6 +469,12 @@ schema = 3 [mod."github.com/mtibben/percent"] version = "v0.2.1" hash = "sha256-Zj1lpCP6mKQ0UUTMs2By4LC414ou+iJzKkK+eBHfEcc=" + [mod."github.com/oasisprotocol/curve25519-voi"] + version = "v0.0.0-20230904125328-1f23a7beb09a" + hash = "sha256-N5MMNn4rytO3ObXVXoY34Sf7AGPkw2dTPkXjigjozls=" + [mod."github.com/oklog/run"] + version = "v1.1.0" + hash = "sha256-U4IS0keJa4BSBSeEBqtIV1Zg6N4b0zFiKfzN9ua4pWQ=" [mod."github.com/olekukonko/tablewriter"] version = "v0.0.5" hash = "sha256-/5i70IkH/qSW5KjGzv8aQNKh9tHoz98tqtL0K2DMFn4=" @@ -449,11 +485,11 @@ schema = 3 version = "v1.26.0" hash = "sha256-B18jsoJHK/oE+wudT0dOsUb41s5+ZIAu/ZBzQ5djOLE=" [mod."github.com/pelletier/go-toml/v2"] - version = "v2.1.0" - hash = "sha256-0u6oV8YMM26y2bw1oe3gLmEJc/whpNaFtEe4yOkN24c=" + version = "v2.1.1" + hash = "sha256-BQtflYQ8Dt7FL/yFI9OnxwvsRk0oEO37ZXuGXFveVpo=" [mod."github.com/petermattis/goid"] - version = "v0.0.0-20230317030725-371a4b8eda08" - hash = "sha256-Qv2rrenuLtrrW+fCd6L4pwXoyYC3znd0ndhzYS4REOM=" + version = "v0.0.0-20231207134359-e60b3f734c67" + hash = "sha256-73DbyhUTwYhqmvbcI96CNblTrfl6uz9OvM6z/h8j5TM=" [mod."github.com/pkg/errors"] version = "v0.9.1" hash = "sha256-mNfQtcrQmu3sNg/7IwiieKWOgFQOVVe2yXgKBpe/wZw=" @@ -461,20 +497,17 @@ schema = 3 version = "v1.0.1-0.20181226105442-5d4384ee4fb2" hash = "sha256-XA4Oj1gdmdV/F/+8kMI+DBxKPthZ768hbKsO3d9Gx90=" [mod."github.com/prometheus/client_golang"] - version = "v1.14.0" - hash = "sha256-dpgGV8C30ZCn7b9mQ+Ye2AfPXTIuHLQbl2olMKzJKxA=" + version = "v1.18.0" + hash = "sha256-kuC6WUg2j7A+9qnSp5VZSYo+oltgLvj/70TpqlCJIdE=" [mod."github.com/prometheus/client_model"] - version = "v0.3.0" - hash = "sha256-vP+miJfsoK5UG9eug8z/bhAMj3bwg66T2vIh8WHoOKU=" + version = "v0.6.0" + hash = "sha256-TAD0mm7msYHo99yoNijeYzlDD0i1Vg3uTetpkDUWQo8=" [mod."github.com/prometheus/common"] - version = "v0.42.0" - hash = "sha256-dJqoPZKtY2umWFWwMeRYY9I2JaFlpcMX4atkEcN5+hs=" + version = "v0.47.0" + hash = "sha256-zAfgbOSycgChcWT8x8oo5k1tq/y6Oay3gLdUEkt0NYk=" [mod."github.com/prometheus/procfs"] - version = "v0.9.0" - hash = "sha256-imZN+1HRpMvgmrot2V+AK5ueYLmsp49vZfHtx2N6Wek=" - [mod."github.com/rakyll/statik"] - version = "v0.1.7" - hash = "sha256-/bfnXHBmN8vviPL7D85IzcEVXCaWyjbPPNyauzEcQ8Q=" + version = "v0.12.0" + hash = "sha256-Y4ZZmxIpVCO67zN3pGwSk2TcI88zvmGJkgwq9DRTwFw=" [mod."github.com/rcrowley/go-metrics"] version = "v0.0.0-20201227073835-cf1acfcdf475" hash = "sha256-10ytHQ1SpMKYTiKuOPdEMuOVa8HVvv9ryYSIF9BHEBI=" @@ -482,14 +515,14 @@ schema = 3 version = "v0.2.0" hash = "sha256-GLj0jiGrT03Ept4V6FXCN1yeZ/b6PpS3MEXK6rYQ8Eg=" [mod."github.com/rogpeppe/go-internal"] - version = "v1.11.0" - hash = "sha256-BucSndJVnqX9e6p5PfA6Z8N2bGfIeRfxAxYLUDXTbIo=" + version = "v1.12.0" + hash = "sha256-qvDNCe3l84/LgrA8X4O15e1FeDcazyX91m9LmXGXX6M=" [mod."github.com/rs/cors"] - version = "v1.8.3" - hash = "sha256-VgVB4HKAhPSjNg96mIEUN1bt5ZQng8Fi3ZABy3CDWQE=" + version = "v1.10.1" + hash = "sha256-um4INJM5/675MLK42npIsDbSQ1/Iy5ZiUNuAFReUfeM=" [mod."github.com/rs/zerolog"] - version = "v1.33.0" - hash = "sha256-jT/Y/izhZiCdrDbC/ty83FGs8UQavTU+OW03O4vKFkY=" + version = "v1.32.0" + hash = "sha256-9dZjtsES+wLp1cFiSVMuEUbdeXVFcgT0dgg5ACZkILk=" [mod."github.com/sagikazarmark/locafero"] version = "v0.4.0" hash = "sha256-7I1Oatc7GAaHgAqBFO6Tv4IbzFiYeU9bJAfJhXuWaXk=" @@ -532,9 +565,6 @@ schema = 3 [mod."github.com/subosito/gotenv"] version = "v1.6.0" hash = "sha256-LspbjTniiq2xAICSXmgqP7carwlNaLqnCTQfw2pa80A=" - [mod."github.com/supranational/blst"] - version = "v0.3.11" - hash = "sha256-r0zdZzVvPYaTOPzLF742uYYQ5tzSiv0xxB52etEkGAk=" [mod."github.com/syndtr/goleveldb"] version = "v1.0.1-0.20210819022825-2ae1ddf74ef7" hash = "sha256-36a4hgVQfwtS2zhylKpQuFhrjdc/Y8pF0dxc26jcZIU=" @@ -576,53 +606,50 @@ schema = 3 version = "v0.14.3" hash = "sha256-tldEok5ebZ4R4B7H8dSlYS5oVuLvh89n9wUaVlDjYwg=" [mod."go.etcd.io/bbolt"] - version = "v1.3.7" - hash = "sha256-poZk8tPLDWwW95oCOkTJcQtEvOJTD9UXAZ2TqGJutwk=" + version = "v1.3.8" + hash = "sha256-ekKy8198B2GfPldHLYZnvNjID6x07dUPYKgFx84TgVs=" [mod."go.opencensus.io"] version = "v0.24.0" hash = "sha256-4H+mGZgG2c9I1y0m8avF4qmt8LUKxxVsTqR8mKgP4yo=" [mod."go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"] - version = "v0.46.1" - hash = "sha256-4af3ezbi/at7jZJfEiJ3+a4a1NnxYJPpzZp0tHQq8EA=" + version = "v0.47.0" + hash = "sha256-D+bP2jEZcB4S8AprlDM3qAghYtxhqc8fSKZNac6WVFs=" [mod."go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"] - version = "v0.46.1" - hash = "sha256-H7GeyxyGcxVRCnR0J7HvpWi3QhwsXGF/IunQMpfkXhw=" + version = "v0.47.0" + hash = "sha256-Pv1X0oIWYXyVxEaDQmgYcw+49I9+65N9Y+1wbxoXOog=" [mod."go.opentelemetry.io/otel"] - version = "v1.21.0" - hash = "sha256-MWC1fp41z3w3Y1wlECY12Q7sLeU4PRACZEesWTmDD9E=" + version = "v1.22.0" + hash = "sha256-4K70RPjaPzPpTO/VkE9ueoSo9EANuNXneDR6jEiUaJQ=" [mod."go.opentelemetry.io/otel/metric"] - version = "v1.21.0" - hash = "sha256-UH5fN59juP5GRiTpr5VUv4JGAE2o47LOyR7Ic6Yl/v4=" + version = "v1.22.0" + hash = "sha256-Lb4wdlZNmz6Ut6CljBAePSUA8X0RBEOEDyOl2oO+pL8=" [mod."go.opentelemetry.io/otel/trace"] - version = "v1.21.0" - hash = "sha256-vjZsOaQCgTjz6WYim0YZHLnB/PC3CvTSpS97qkL2vz8=" - [mod."go.uber.org/atomic"] - version = "v1.10.0" - hash = "sha256-E6UEDc1eh/cLUFd+J86cDesQ0B8wEv/DdaAVKb+x2t8=" + version = "v1.22.0" + hash = "sha256-38zzkmcoOzYYeDN+rC44HmwmdnalIcEpObCS6tIvMO8=" [mod."go.uber.org/multierr"] - version = "v1.9.0" - hash = "sha256-tlDRooh/V4HDhZohsUrxot/Y6uVInVBtRWCZbj/tPds=" + version = "v1.11.0" + hash = "sha256-Lb6rHHfR62Ozg2j2JZy3MKOMKdsfzd1IYTR57r3Mhp0=" [mod."golang.org/x/crypto"] version = "v0.21.0" hash = "sha256-Z4k1LvFh4Jai7HUe6TTuXSG3VnuiRpMwdARIdZZqSYk=" [mod."golang.org/x/exp"] - version = "v0.0.0-20231110203233-9a3e6036ecaa" - hash = "sha256-m1T4KePBRCJpAjnuq4BnDYXebOHiVI6h2489XD5R9BA=" + version = "v0.0.0-20240222234643-814bf88cf225" + hash = "sha256-DM6/KUjyqyuqXai7UH1vMsoKXQAlYfcHTwK1dHqjRAc=" [mod."golang.org/x/mod"] - version = "v0.14.0" - hash = "sha256-sx3hWp5l99DBfIrn821ohfoBwvaITSHMWbzPvX0btLM=" + version = "v0.15.0" + hash = "sha256-ANSnGmd525BfnkMZpCmu6deMPFGADtnZx3lmZpdm2aM=" [mod."golang.org/x/net"] - version = "v0.23.0" - hash = "sha256-ZB4504rtgsHbcRfijjlqt4/2ddb8tyQB5IBn126uVTQ=" + version = "v0.21.0" + hash = "sha256-LfiqMpPtqvW/eLkfx6Ebr5ksqKbQli6uq06c/+XrBsw=" [mod."golang.org/x/oauth2"] - version = "v0.16.0" - hash = "sha256-fJfS9dKaq82WaYSVWHMnxNLWH8+L4aip/C1AfJi4FFI=" + version = "v0.17.0" + hash = "sha256-M2ZZQZt449RJL18YpzGiAiqfGsDVMsr1IVWbYp/G/go=" [mod."golang.org/x/sync"] version = "v0.6.0" hash = "sha256-LLims/wjDZtIqlYCVHREewcUOX4hwRwplEuZKPOJ/HI=" [mod."golang.org/x/sys"] - version = "v0.22.0" - hash = "sha256-RbG0XaXGGlErCsl2agvUxMnrkRwdbJLmriYT1H24FwA=" + version = "v0.18.0" + hash = "sha256-bIFhfFp7Sj0E1gcE3X3l/jecCfSRLgrkb8f0Yr6tVR0=" [mod."golang.org/x/term"] version = "v0.18.0" hash = "sha256-lpze9arFZIhBV8Ht3VZyoiUwqPkeH2IwfXt8M3xljiM=" @@ -633,44 +660,47 @@ schema = 3 version = "v0.5.0" hash = "sha256-W6RgwgdYTO3byIPOFxrP2IpAZdgaGowAaVfYby7AULU=" [mod."golang.org/x/tools"] - version = "v0.15.0" - hash = "sha256-C2YsNcJ2ZodVscy8fQOIz5R+rql407vLrvjwVm3nrkI=" + version = "v0.18.0" + hash = "sha256-JVz7W13vMPfpGQ1yW+LBlT6INu3ebpjvXyChmAkm5bQ=" [mod."google.golang.org/api"] - version = "v0.155.0" - hash = "sha256-lfQZ5XNJYLOSlu+lrwYYIA3qXrraLC/PIVRHha5mlqI=" + version = "v0.162.0" + hash = "sha256-+AsT4DPjefEmPPelZoSHuQ8nCHhmhhUWU4UGnJ/8+fg=" [mod."google.golang.org/appengine"] version = "v1.6.8" hash = "sha256-decMa0MiWfW/Bzr8QPPzzpeya0YWGHhZAt4Cr/bD1wQ=" [mod."google.golang.org/genproto"] - version = "v0.0.0-20240123012728-ef4313101c80" - hash = "sha256-tRjQ7Nr0ytEhAcRMKW66isgaDNoNL6UKmjfS27s+8d8=" + version = "v0.0.0-20240213162025-012b6fc9bca9" + hash = "sha256-Xn9/mncRY7WS/O5TiFDMMtJLCAzc0JZNQ8z6yV8jnjY=" [mod."google.golang.org/genproto/googleapis/api"] - version = "v0.0.0-20240123012728-ef4313101c80" - hash = "sha256-m1wAOo4INg46fIrGdISN5m5X29Z6OdR151xdKqrD9V4=" + version = "v0.0.0-20240205150955-31a09d347014" + hash = "sha256-SgYAbD0iBY8XCp4c9PLpaS4TeKVBexTfTCyV0MUOu98=" [mod."google.golang.org/genproto/googleapis/rpc"] - version = "v0.0.0-20240123012728-ef4313101c80" - hash = "sha256-b22XLgjrH5i0wUw4iseepgLzjOpFgixWHfGPgl11kbo=" + version = "v0.0.0-20240221002015-b0ce06bbee7c" + hash = "sha256-XF1eaB8Uwjuii1SVpiZABBhrpszJy5ujOtN+7qAAouM=" [mod."google.golang.org/grpc"] - version = "v1.62.1" - hash = "sha256-1su6X0YT7MUflrTJijbq1CiisADZHudEx5sJq01TEaE=" + version = "v1.62.0" + hash = "sha256-OnEEt6J1d9uQazORCpD6jbAKph8/dKlDHcUEEkLQyjQ=" [mod."google.golang.org/protobuf"] version = "v1.33.0" hash = "sha256-cWwQjtUwSIEkAlAadrlxK1PYZXTRrV4NKzt7xDpJgIU=" [mod."gopkg.in/ini.v1"] version = "v1.67.0" hash = "sha256-V10ahGNGT+NLRdKUyRg1dos5RxLBXBk1xutcnquc/+4=" + [mod."gopkg.in/natefinch/npipe.v2"] + version = "v2.0.0-20160621034901-c1b8fa8bdcce" + hash = "sha256-ytqeVZqn4kd2uc65HvEjPlpPA2VnBmPfu5DsFlO0o+g=" [mod."gopkg.in/yaml.v3"] version = "v3.0.1" hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU=" + [mod."gotest.tools/v3"] + version = "v3.5.1" + hash = "sha256-ps2GEc3P2xvlrU4TCtXz+nLTxyP0RrF7SScz5jUqE5E=" [mod."nhooyr.io/websocket"] - version = "v1.8.6" - hash = "sha256-DyaiCc/1iELrl6JSpz6WYMtFwUiSCOSoNF8IhSyP1ag=" + version = "v1.8.10" + hash = "sha256-EsUWUFIA2uJTap1DfsYuSxlPMH3UHDpxEohJMalDOcI=" [mod."pgregory.net/rapid"] version = "v1.1.0" hash = "sha256-sVQY9EQ9Y5blYyVYfaOa+y12e+399OqdHiEY3BaDnqo=" - [mod."rsc.io/tmplfunc"] - version = "v0.0.3" - hash = "sha256-Kii+7DxaSzzn2NphVcEk0W42TXMBFINtm3+B2t7e0cc=" [mod."sigs.k8s.io/yaml"] version = "v1.4.0" hash = "sha256-Hd/M0vIfIVobDd87eb58p1HyVOjYWNlGq2bRXfmtVno=" diff --git a/indexer/kv_indexer.go b/indexer/kv_indexer.go index c1528eaf..16b2220a 100644 --- a/indexer/kv_indexer.go +++ b/indexer/kv_indexer.go @@ -19,10 +19,10 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" tmtypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -61,7 +61,7 @@ func NewKVIndexer(db dbm.DB, logger log.Logger, clientCtx client.Context) *KVInd // - Parses eth Tx infos from cosmos-sdk events for every TxResult // - Iterates over all the messages of the Tx // - Builds and stores a indexer.TxResult based on parsed events for every message -func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ResponseDeliverTx) error { +func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ExecTxResult) error { height := block.Header.Height batch := kv.db.NewBatch() diff --git a/indexer/kv_indexer_test.go b/indexer/kv_indexer_test.go index 8497ae7d..538847c3 100644 --- a/indexer/kv_indexer_test.go +++ b/indexer/kv_indexer_test.go @@ -4,13 +4,18 @@ import ( "math/big" "testing" - dbm "github.com/cometbft/cometbft-db" + tmlog "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - tmlog "github.com/cometbft/cometbft/libs/log" tmtypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/crypto/ethsecp256k1" + "github.com/evmos/ethermint/indexer" + "github.com/evmos/ethermint/tests" + "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" "github.com/zeta-chain/ethermint/app" "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" @@ -36,7 +41,7 @@ func TestKVIndexer(t *testing.T) { require.NoError(t, tx.Sign(ethSigner, signer)) txHash := tx.AsTransaction().Hash() - encodingConfig := MakeEncodingConfig() + encodingConfig := app.MakeConfigForTest() clientCtx := client.Context{}.WithTxConfig(encodingConfig.TxConfig).WithCodec(encodingConfig.Codec) // build cosmos-sdk wrapper tx @@ -55,13 +60,13 @@ func TestKVIndexer(t *testing.T) { testCases := []struct { name string block *tmtypes.Block - blockResult []*abci.ResponseDeliverTx + blockResult []*abci.ExecTxResult expSuccess bool }{ { "success, format 1", &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ @@ -81,7 +86,7 @@ func TestKVIndexer(t *testing.T) { { "success, format 2", &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ @@ -103,7 +108,7 @@ func TestKVIndexer(t *testing.T) { { "success, exceed block gas limit", &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 11, Log: "out of gas in location: block gas meter; gasWanted: 21000", @@ -115,7 +120,7 @@ func TestKVIndexer(t *testing.T) { { "fail, failed eth tx", &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 15, Log: "nonce mismatch", @@ -127,7 +132,7 @@ func TestKVIndexer(t *testing.T) { { "fail, invalid events", &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{}, @@ -138,7 +143,7 @@ func TestKVIndexer(t *testing.T) { { "fail, not eth tx", &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz2}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{}, diff --git a/proto/ethermint/evm/v1/query.proto b/proto/ethermint/evm/v1/query.proto index 10b00dc3..85191f58 100644 --- a/proto/ethermint/evm/v1/query.proto +++ b/proto/ethermint/evm/v1/query.proto @@ -294,5 +294,5 @@ message QueryBaseFeeRequest {} // QueryBaseFeeResponse returns the EIP1559 base fee. message QueryBaseFeeResponse { // base_fee is the EIP1559 base fee - string base_fee = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; + string base_fee = 1 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; } diff --git a/proto/ethermint/evm/v1/tx.proto b/proto/ethermint/evm/v1/tx.proto index 11dcb1ef..579ac515 100644 --- a/proto/ethermint/evm/v1/tx.proto +++ b/proto/ethermint/evm/v1/tx.proto @@ -12,6 +12,7 @@ option go_package = "github.com/zeta-chain/ethermint/x/evm/types"; // Msg defines the evm Msg service. service Msg { + option (cosmos.msg.v1.service) = true; // EthereumTx defines a method submitting Ethereum transactions. rpc EthereumTx(MsgEthereumTx) returns (MsgEthereumTxResponse) { option (google.api.http).post = "/ethermint/evm/v1/ethereum_tx"; @@ -48,14 +49,14 @@ message LegacyTx { // nonce corresponds to the account nonce (transaction sequence). uint64 nonce = 1; // gas_price defines the value for each gas unit - string gas_price = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; + string gas_price = 2 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; // gas defines the gas limit defined for the transaction. uint64 gas = 3 [(gogoproto.customname) = "GasLimit"]; // to is the hex formatted address of the recipient string to = 4; // value defines the unsigned integer value of the transaction amount. string value = 5 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"]; + [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"]; // data is the data payload bytes of the transaction. bytes data = 6; // v defines the signature value @@ -73,21 +74,21 @@ message AccessListTx { // chain_id of the destination EVM chain string chain_id = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "ChainID", (gogoproto.jsontag) = "chainID" ]; // nonce corresponds to the account nonce (transaction sequence). uint64 nonce = 2; // gas_price defines the value for each gas unit - string gas_price = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; + string gas_price = 3 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; // gas defines the gas limit defined for the transaction. uint64 gas = 4 [(gogoproto.customname) = "GasLimit"]; // to is the recipient address in hex format string to = 5; // value defines the unsigned integer value of the transaction amount. string value = 6 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"]; + [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"]; // data is the data payload bytes of the transaction. bytes data = 7; // accesses is an array of access tuples @@ -108,23 +109,23 @@ message DynamicFeeTx { // chain_id of the destination EVM chain string chain_id = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "ChainID", (gogoproto.jsontag) = "chainID" ]; // nonce corresponds to the account nonce (transaction sequence). uint64 nonce = 2; // gas_tip_cap defines the max value for the gas tip - string gas_tip_cap = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; + string gas_tip_cap = 3 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; // gas_fee_cap defines the max value for the gas fee - string gas_fee_cap = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; + string gas_fee_cap = 4 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; // gas defines the gas limit defined for the transaction. uint64 gas = 5 [(gogoproto.customname) = "GasLimit"]; // to is the hex formatted address of the recipient string to = 6; // value defines the the transaction amount. string value = 7 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"]; + [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"]; // data is the data payload bytes of the transaction. bytes data = 8; // accesses is an array of access tuples diff --git a/proto/ethermint/feemarket/v1/feemarket.proto b/proto/ethermint/feemarket/v1/feemarket.proto index a582eb7c..980a0158 100644 --- a/proto/ethermint/feemarket/v1/feemarket.proto +++ b/proto/ethermint/feemarket/v1/feemarket.proto @@ -21,12 +21,12 @@ message Params { // enable_height defines at which block height the base fee calculation is enabled. int64 enable_height = 5; // base_fee for EIP-1559 blocks. - string base_fee = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string base_fee = 6 [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false]; // min_gas_price defines the minimum gas price value for cosmos and eth transactions string min_gas_price = 7 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + [(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false]; // min_gas_multiplier bounds the minimum gas used to be charged // to senders based on gas limit string min_gas_multiplier = 8 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + [(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false]; } diff --git a/proto/ethermint/feemarket/v1/query.proto b/proto/ethermint/feemarket/v1/query.proto index 40ad0a4a..9e043daf 100644 --- a/proto/ethermint/feemarket/v1/query.proto +++ b/proto/ethermint/feemarket/v1/query.proto @@ -42,7 +42,7 @@ message QueryBaseFeeRequest {} // QueryBaseFeeResponse returns the EIP1559 base fee. message QueryBaseFeeResponse { // base_fee is the EIP1559 base fee - string base_fee = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; + string base_fee = 1 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; } // QueryBlockGasRequest defines the request type for querying the EIP1559 base diff --git a/proto/ethermint/feemarket/v1/tx.proto b/proto/ethermint/feemarket/v1/tx.proto index 4ec15873..30ed50fe 100644 --- a/proto/ethermint/feemarket/v1/tx.proto +++ b/proto/ethermint/feemarket/v1/tx.proto @@ -10,6 +10,7 @@ option go_package = "github.com/zeta-chain/ethermint/x/feemarket/types"; // Msg defines the erc20 Msg service. service Msg { + option (cosmos.msg.v1.service) = true; // UpdateParams defined a governance operation for updating the x/feemarket module parameters. // The authority is hard-coded to the Cosmos SDK x/gov module account rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); diff --git a/proto/ethermint/types/v1/account.proto b/proto/ethermint/types/v1/account.proto index 4af4a663..bb1cee52 100644 --- a/proto/ethermint/types/v1/account.proto +++ b/proto/ethermint/types/v1/account.proto @@ -7,14 +7,14 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/ethermint/types"; -// EthAccount implements the authtypes.AccountI interface and embeds an +// EthAccount implements the sdk.AccountI interface and embeds an // authtypes.BaseAccount type. It is compatible with the auth AccountKeeper. message EthAccount { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; option (gogoproto.equal) = false; - option (cosmos_proto.implements_interface) = "github.com/cosmos/cosmos-sdk/x/auth/types.cosmos.auth.v1beta1.AccountI"; + option (cosmos_proto.implements_interface) = "cosmos.auth.v1beta1.AccountI"; // base_account is an authtypes.BaseAccount cosmos.auth.v1beta1.BaseAccount base_account = 1 diff --git a/proto/ethermint/types/v1/dynamic_fee.proto b/proto/ethermint/types/v1/dynamic_fee.proto index aa4a778f..3643ce88 100644 --- a/proto/ethermint/types/v1/dynamic_fee.proto +++ b/proto/ethermint/types/v1/dynamic_fee.proto @@ -9,5 +9,5 @@ option go_package = "github.com/zeta-chain/ethermint/types"; message ExtensionOptionDynamicFeeTx { // max_priority_price is the same as `max_priority_fee_per_gas` in eip-1559 spec string max_priority_price = 1 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false]; } diff --git a/rpc/backend/account_info.go b/rpc/backend/account_info.go index a0eca3c4..e1c27630 100644 --- a/rpc/backend/account_info.go +++ b/rpc/backend/account_info.go @@ -22,6 +22,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + "github.com/cometbft/cometbft/libs/bytes" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -111,7 +112,7 @@ func (b *Backend) GetProof(address common.Address, storageKeys []string, blockNr } // query account proofs - accountKey := authtypes.AddressStoreKey(sdk.AccAddress(address.Bytes())) + accountKey := bytes.HexBytes(append(authtypes.AddressStoreKeyPrefix, address.Bytes()...)) _, proof, err := b.queryClient.GetProof(clientCtx, authtypes.StoreKey, accountKey) if err != nil { return nil, err diff --git a/rpc/backend/account_info_test.go b/rpc/backend/account_info_test.go index e2d0029a..3bad370d 100644 --- a/rpc/backend/account_info_test.go +++ b/rpc/backend/account_info_test.go @@ -138,11 +138,12 @@ func (suite *BackendTestSuite) TestGetProof() { evmtypes.StateKey(address1, common.HexToHash("0x0").Bytes()), tmrpcclient.ABCIQueryOptions{Height: iavlHeight, Prove: true}, ) + addressStoreKey := append(authtypes.AddressStoreKeyPrefix, sdk.AccAddress(address1.Bytes())...) RegisterABCIQueryWithOptions( client, bn.Int64(), "store/acc/key", - authtypes.AddressStoreKey(sdk.AccAddress(address1.Bytes())), + addressStoreKey.Bytes(), tmrpcclient.ABCIQueryOptions{Height: iavlHeight, Prove: true}, ) }, diff --git a/rpc/backend/backend.go b/rpc/backend/backend.go index 5aa7a4d0..998414fa 100644 --- a/rpc/backend/backend.go +++ b/rpc/backend/backend.go @@ -20,7 +20,8 @@ import ( "math/big" "time" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -106,7 +107,7 @@ type EVMBackend interface { // Chain Info ChainID() (*hexutil.Big, error) ChainConfig() *params.ChainConfig - GlobalMinGasPrice() (sdk.Dec, error) + GlobalMinGasPrice() (sdkmath.LegacyDec, error) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, error) CurrentHeader() *ethtypes.Header PendingTransactions() ([]*sdk.Tx, error) diff --git a/rpc/backend/backend_suite_test.go b/rpc/backend/backend_suite_test.go index 109a5a7a..e0b5c344 100644 --- a/rpc/backend/backend_suite_test.go +++ b/rpc/backend/backend_suite_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "testing" - dbm "github.com/cometbft/cometbft-db" + dbm "github.com/cosmos/cosmos-db" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cosmos/cosmos-sdk/client" @@ -18,15 +18,14 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/suite" - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/crypto/hd" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/indexer" - "github.com/zeta-chain/ethermint/rpc/backend/mocks" - rpctypes "github.com/zeta-chain/ethermint/rpc/types" - "github.com/zeta-chain/ethermint/tests" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/crypto/ethsecp256k1" + "github.com/evmos/ethermint/crypto/hd" + "github.com/evmos/ethermint/indexer" + "github.com/evmos/ethermint/rpc/backend/mocks" + rpctypes "github.com/evmos/ethermint/rpc/types" + "github.com/evmos/ethermint/tests" + evmtypes "github.com/evmos/ethermint/x/evm/types" ) type BackendTestSuite struct { @@ -68,7 +67,7 @@ func (suite *BackendTestSuite) SetupTest() { suite.signer = tests.NewSigner(priv) suite.Require().NoError(err) - encodingConfig := encoding.MakeConfig(app.ModuleBasics) + encodingConfig := app.MakeConfigForTest() clientCtx := client.Context{}.WithChainID(ChainID). WithHeight(1). WithTxConfig(encodingConfig.TxConfig). @@ -86,7 +85,7 @@ func (suite *BackendTestSuite) SetupTest() { suite.backend.ctx = rpctypes.ContextWithHeight(1) // Add codec - encCfg := encoding.MakeConfig(app.ModuleBasics) + encCfg := app.MakeConfigForTest() suite.backend.clientCtx.Codec = encCfg.Codec } @@ -166,7 +165,7 @@ func (suite *BackendTestSuite) buildFormattedBlock( func (suite *BackendTestSuite) generateTestKeyring(clientDir string) (keyring.Keyring, error) { buf := bufio.NewReader(os.Stdin) - encCfg := encoding.MakeConfig(app.ModuleBasics) + encCfg := app.MakeConfigForTest() return keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, clientDir, buf, encCfg.Codec, []keyring.Option{hd.EthSecp256k1Option()}...) } diff --git a/rpc/backend/blocks.go b/rpc/backend/blocks.go index 0474a39a..95d4a2f8 100644 --- a/rpc/backend/blocks.go +++ b/rpc/backend/blocks.go @@ -360,7 +360,7 @@ func (b *Backend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) // BlockBloom query block bloom filter from block results func (b *Backend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error) { - for _, event := range blockRes.EndBlockEvents { + for _, event := range blockRes.FinalizeBlockEvents { if event.Type != evmtypes.EventTypeBlockBloom { continue } diff --git a/rpc/backend/blocks_test.go b/rpc/backend/blocks_test.go index 0dd5673d..ad1d0e39 100644 --- a/rpc/backend/blocks_test.go +++ b/rpc/backend/blocks_test.go @@ -4,6 +4,7 @@ import ( "fmt" "math/big" + sdkmath "cosmossdk.io/math" "github.com/cometbft/cometbft/abci/types" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" tmtypes "github.com/cometbft/cometbft/types" @@ -93,7 +94,7 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() { validator sdk.AccAddress tx *evmtypes.MsgEthereumTx txBz []byte - registerMock func(ethrpc.BlockNumber, sdk.Int, sdk.AccAddress, []byte) + registerMock func(ethrpc.BlockNumber, sdkmath.Int, sdk.AccAddress, []byte) expNoop bool expPass bool }{ @@ -101,11 +102,11 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() { "pass - tendermint block not found", ethrpc.BlockNumber(1), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(blockNum ethrpc.BlockNumber, _ sdk.Int, _ sdk.AccAddress, _ []byte) { + func(blockNum ethrpc.BlockNumber, _ sdkmath.Int, _ sdk.AccAddress, _ []byte) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockError(client, height) @@ -117,11 +118,11 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() { "pass - block not found (e.g. request block height that is greater than current one)", ethrpc.BlockNumber(1), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) resBlock, _ = RegisterBlockNotFound(client, height) @@ -133,11 +134,11 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() { "pass - block results error", ethrpc.BlockNumber(1), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) resBlock, _ = RegisterBlock(client, height, txBz) @@ -150,11 +151,11 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() { "pass - without tx", ethrpc.BlockNumber(1), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) resBlock, _ = RegisterBlock(client, height, txBz) @@ -172,11 +173,11 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() { "pass - with tx", ethrpc.BlockNumber(1), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), msgEthereumTx, bz, - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) resBlock, _ = RegisterBlock(client, height, txBz) @@ -194,7 +195,7 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset test and queries - tc.registerMock(tc.blockNumber, sdk.NewIntFromBigInt(tc.baseFee), tc.validator, tc.txBz) + tc.registerMock(tc.blockNumber, sdkmath.NewIntFromBigInt(tc.baseFee), tc.validator, tc.txBz) block, err := suite.backend.GetBlockByNumber(tc.blockNumber, tc.fullTx) @@ -238,7 +239,7 @@ func (suite *BackendTestSuite) TestGetBlockByHash() { validator sdk.AccAddress tx *evmtypes.MsgEthereumTx txBz []byte - registerMock func(common.Hash, sdk.Int, sdk.AccAddress, []byte) + registerMock func(common.Hash, sdkmath.Int, sdk.AccAddress, []byte) expNoop bool expPass bool }{ @@ -246,11 +247,11 @@ func (suite *BackendTestSuite) TestGetBlockByHash() { "fail - tendermint failed to get block", common.BytesToHash(block.Hash()), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(hash common.Hash, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(hash common.Hash, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockByHashError(client, hash, txBz) }, @@ -261,11 +262,11 @@ func (suite *BackendTestSuite) TestGetBlockByHash() { "noop - tendermint blockres not found", common.BytesToHash(block.Hash()), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(hash common.Hash, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(hash common.Hash, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockByHashNotFound(client, hash, txBz) }, @@ -276,11 +277,11 @@ func (suite *BackendTestSuite) TestGetBlockByHash() { "noop - tendermint failed to fetch block result", common.BytesToHash(block.Hash()), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(hash common.Hash, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(hash common.Hash, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { height := int64(1) client := suite.backend.clientCtx.Client.(*mocks.Client) resBlock, _ = RegisterBlockByHash(client, hash, txBz) @@ -294,11 +295,11 @@ func (suite *BackendTestSuite) TestGetBlockByHash() { "pass - without tx", common.BytesToHash(block.Hash()), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), nil, nil, - func(hash common.Hash, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(hash common.Hash, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { height := int64(1) client := suite.backend.clientCtx.Client.(*mocks.Client) resBlock, _ = RegisterBlockByHash(client, hash, txBz) @@ -317,11 +318,11 @@ func (suite *BackendTestSuite) TestGetBlockByHash() { "pass - with tx", common.BytesToHash(block.Hash()), true, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), msgEthereumTx, bz, - func(hash common.Hash, baseFee sdk.Int, validator sdk.AccAddress, txBz []byte) { + func(hash common.Hash, baseFee sdkmath.Int, validator sdk.AccAddress, txBz []byte) { height := int64(1) client := suite.backend.clientCtx.Client.(*mocks.Client) resBlock, _ = RegisterBlockByHash(client, hash, txBz) @@ -340,7 +341,7 @@ func (suite *BackendTestSuite) TestGetBlockByHash() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset test and queries - tc.registerMock(tc.hash, sdk.NewIntFromBigInt(tc.baseFee), tc.validator, tc.txBz) + tc.registerMock(tc.hash, sdkmath.NewIntFromBigInt(tc.baseFee), tc.validator, tc.txBz) block, err := suite.backend.GetBlockByHash(tc.hash, tc.fullTx) @@ -649,7 +650,7 @@ func (suite *BackendTestSuite) TestTendermintBlockResultByNumber() { expBlockRes = &tmrpctypes.ResultBlockResults{ Height: blockNum, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, } }, true, @@ -823,7 +824,7 @@ func (suite *BackendTestSuite) TestBlockBloom() { { "fail - non block bloom event type", &tmrpctypes.ResultBlockResults{ - EndBlockEvents: []types.Event{{Type: evmtypes.EventTypeEthereumTx}}, + FinalizeBlockEvents: []types.Event{{Type: evmtypes.EventTypeEthereumTx}}, }, ethtypes.Bloom{}, false, @@ -831,7 +832,7 @@ func (suite *BackendTestSuite) TestBlockBloom() { { "fail - nonblock bloom attribute key", &tmrpctypes.ResultBlockResults{ - EndBlockEvents: []types.Event{ + FinalizeBlockEvents: []types.Event{ { Type: evmtypes.EventTypeBlockBloom, Attributes: []types.EventAttribute{ @@ -846,7 +847,7 @@ func (suite *BackendTestSuite) TestBlockBloom() { { "pass - block bloom attribute key", &tmrpctypes.ResultBlockResults{ - EndBlockEvents: []types.Event{ + FinalizeBlockEvents: []types.Event{ { Type: evmtypes.EventTypeBlockBloom, Attributes: []types.EventAttribute{ @@ -885,22 +886,22 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { resBlock *tmrpctypes.ResultBlock blockRes *tmrpctypes.ResultBlockResults fullTx bool - registerMock func(sdk.Int, sdk.AccAddress, int64) + registerMock func(sdkmath.Int, sdk.AccAddress, int64) expTxs bool expPass bool }{ { "pass - block without tx", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(common.Address{}.Bytes()), int64(1), &tmrpctypes.ResultBlock{Block: emptyBlock}, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, }, false, - func(baseFee sdk.Int, validator sdk.AccAddress, height int64) { + func(baseFee sdkmath.Int, validator sdk.AccAddress, height int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) RegisterValidatorAccount(queryClient, validator) @@ -921,10 +922,10 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, }, true, - func(baseFee sdk.Int, validator sdk.AccAddress, height int64) { + func(baseFee sdkmath.Int, validator sdk.AccAddress, height int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFeeError(queryClient) RegisterValidatorAccount(queryClient, validator) @@ -937,7 +938,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, { "pass - block with tx - with ValidatorAccount error", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(common.Address{}.Bytes()), int64(1), &tmrpctypes.ResultBlock{ @@ -945,10 +946,10 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, }, true, - func(baseFee sdk.Int, validator sdk.AccAddress, height int64) { + func(baseFee sdkmath.Int, validator sdk.AccAddress, height int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) RegisterValidatorAccountError(queryClient) @@ -961,7 +962,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, { "pass - block with tx - with ConsensusParams error - BlockMaxGas defaults to max uint32", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), int64(1), &tmrpctypes.ResultBlock{ @@ -969,10 +970,10 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, }, true, - func(baseFee sdk.Int, validator sdk.AccAddress, height int64) { + func(baseFee sdkmath.Int, validator sdk.AccAddress, height int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) RegisterValidatorAccount(queryClient, validator) @@ -985,7 +986,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, { "pass - block with tx - with ShouldIgnoreGasUsed - empty txs", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), int64(1), &tmrpctypes.ResultBlock{ @@ -993,7 +994,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{ + TxsResults: []*types.ExecTxResult{ { Code: 11, GasUsed: 0, @@ -1002,7 +1003,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, }, true, - func(baseFee sdk.Int, validator sdk.AccAddress, height int64) { + func(baseFee sdkmath.Int, validator sdk.AccAddress, height int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) RegisterValidatorAccount(queryClient, validator) @@ -1015,7 +1016,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, { "pass - block with tx - non fullTx", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), int64(1), &tmrpctypes.ResultBlock{ @@ -1023,10 +1024,10 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, }, false, - func(baseFee sdk.Int, validator sdk.AccAddress, height int64) { + func(baseFee sdkmath.Int, validator sdk.AccAddress, height int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) RegisterValidatorAccount(queryClient, validator) @@ -1039,7 +1040,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, { "pass - block with tx", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), sdk.AccAddress(tests.GenerateAddress().Bytes()), int64(1), &tmrpctypes.ResultBlock{ @@ -1047,10 +1048,10 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, }, true, - func(baseFee sdk.Int, validator sdk.AccAddress, height int64) { + func(baseFee sdkmath.Int, validator sdk.AccAddress, height int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) RegisterValidatorAccount(queryClient, validator) @@ -1065,7 +1066,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset test and queries - tc.registerMock(sdk.NewIntFromBigInt(tc.baseFee), tc.validator, tc.height) + tc.registerMock(sdkmath.NewIntFromBigInt(tc.baseFee), tc.validator, tc.height) block, err := suite.backend.RPCBlockFromTendermintBlock(tc.resBlock, tc.blockRes, tc.fullTx) @@ -1133,7 +1134,7 @@ func (suite *BackendTestSuite) TestEthMsgsFromTendermintBlock() { Block: tmtypes.MakeBlock(1, []tmtypes.Tx{bz}, nil, nil), }, &tmrpctypes.ResultBlockResults{ - TxsResults: []*types.ResponseDeliverTx{ + TxsResults: []*types.ExecTxResult{ { Code: 1, }, @@ -1147,7 +1148,7 @@ func (suite *BackendTestSuite) TestEthMsgsFromTendermintBlock() { Block: tmtypes.MakeBlock(1, []tmtypes.Tx{bz}, nil, nil), }, &tmrpctypes.ResultBlockResults{ - TxsResults: []*types.ResponseDeliverTx{ + TxsResults: []*types.ExecTxResult{ { Code: 1, Log: ethrpc.ExceedBlockGasLimitError, @@ -1162,7 +1163,7 @@ func (suite *BackendTestSuite) TestEthMsgsFromTendermintBlock() { Block: tmtypes.MakeBlock(1, []tmtypes.Tx{bz}, nil, nil), }, &tmrpctypes.ResultBlockResults{ - TxsResults: []*types.ResponseDeliverTx{ + TxsResults: []*types.ExecTxResult{ { Code: 0, Log: ethrpc.ExceedBlockGasLimitError, @@ -1191,14 +1192,14 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { name string blockNumber ethrpc.BlockNumber baseFee *big.Int - registerMock func(ethrpc.BlockNumber, sdk.Int) + registerMock func(ethrpc.BlockNumber, sdkmath.Int) expPass bool }{ { "fail - tendermint client failed to get block", ethrpc.BlockNumber(1), - sdk.NewInt(1).BigInt(), - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockError(client, height) @@ -1208,8 +1209,8 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { { "fail - block not found for height", ethrpc.BlockNumber(1), - sdk.NewInt(1).BigInt(), - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockNotFound(client, height) @@ -1219,8 +1220,8 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { { "fail - block not found for height", ethrpc.BlockNumber(1), - sdk.NewInt(1).BigInt(), - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlock(client, height, nil) @@ -1232,7 +1233,7 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { "pass - without Base Fee, failed to fetch from prunned block", ethrpc.BlockNumber(1), nil, - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int) { + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) expResultBlock, _ = RegisterBlock(client, height, nil) @@ -1246,8 +1247,8 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { { "pass - blockNum = 1, without tx", ethrpc.BlockNumber(1), - sdk.NewInt(1).BigInt(), - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) expResultBlock, _ = RegisterBlock(client, height, nil) @@ -1261,8 +1262,8 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { { "pass - blockNum = 1, with tx", ethrpc.BlockNumber(1), - sdk.NewInt(1).BigInt(), - func(blockNum ethrpc.BlockNumber, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(blockNum ethrpc.BlockNumber, baseFee sdkmath.Int) { height := blockNum.Int64() client := suite.backend.clientCtx.Client.(*mocks.Client) expResultBlock, _ = RegisterBlock(client, height, bz) @@ -1278,7 +1279,7 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset test and queries - tc.registerMock(tc.blockNumber, sdk.NewIntFromBigInt(tc.baseFee)) + tc.registerMock(tc.blockNumber, sdkmath.NewIntFromBigInt(tc.baseFee)) header, err := suite.backend.HeaderByNumber(tc.blockNumber) if tc.expPass { @@ -1303,14 +1304,14 @@ func (suite *BackendTestSuite) TestHeaderByHash() { name string hash common.Hash baseFee *big.Int - registerMock func(common.Hash, sdk.Int) + registerMock func(common.Hash, sdkmath.Int) expPass bool }{ { "fail - tendermint client failed to get block", common.BytesToHash(block.Hash()), - sdk.NewInt(1).BigInt(), - func(hash common.Hash, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(hash common.Hash, baseFee sdkmath.Int) { client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockByHashError(client, hash, bz) }, @@ -1319,8 +1320,8 @@ func (suite *BackendTestSuite) TestHeaderByHash() { { "fail - block not found for height", common.BytesToHash(block.Hash()), - sdk.NewInt(1).BigInt(), - func(hash common.Hash, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(hash common.Hash, baseFee sdkmath.Int) { client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockByHashNotFound(client, hash, bz) }, @@ -1329,8 +1330,8 @@ func (suite *BackendTestSuite) TestHeaderByHash() { { "fail - block not found for height", common.BytesToHash(block.Hash()), - sdk.NewInt(1).BigInt(), - func(hash common.Hash, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(hash common.Hash, baseFee sdkmath.Int) { height := int64(1) client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockByHash(client, hash, bz) @@ -1342,7 +1343,7 @@ func (suite *BackendTestSuite) TestHeaderByHash() { "pass - without Base Fee, failed to fetch from prunned block", common.BytesToHash(block.Hash()), nil, - func(hash common.Hash, baseFee sdk.Int) { + func(hash common.Hash, baseFee sdkmath.Int) { height := int64(1) client := suite.backend.clientCtx.Client.(*mocks.Client) expResultBlock, _ = RegisterBlockByHash(client, hash, bz) @@ -1356,8 +1357,8 @@ func (suite *BackendTestSuite) TestHeaderByHash() { { "pass - blockNum = 1, without tx", common.BytesToHash(emptyBlock.Hash()), - sdk.NewInt(1).BigInt(), - func(hash common.Hash, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(hash common.Hash, baseFee sdkmath.Int) { height := int64(1) client := suite.backend.clientCtx.Client.(*mocks.Client) expResultBlock, _ = RegisterBlockByHash(client, hash, nil) @@ -1371,8 +1372,8 @@ func (suite *BackendTestSuite) TestHeaderByHash() { { "pass - with tx", common.BytesToHash(block.Hash()), - sdk.NewInt(1).BigInt(), - func(hash common.Hash, baseFee sdk.Int) { + sdkmath.NewInt(1).BigInt(), + func(hash common.Hash, baseFee sdkmath.Int) { height := int64(1) client := suite.backend.clientCtx.Client.(*mocks.Client) expResultBlock, _ = RegisterBlockByHash(client, hash, bz) @@ -1388,7 +1389,7 @@ func (suite *BackendTestSuite) TestHeaderByHash() { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset test and queries - tc.registerMock(tc.hash, sdk.NewIntFromBigInt(tc.baseFee)) + tc.registerMock(tc.hash, sdkmath.NewIntFromBigInt(tc.baseFee)) header, err := suite.backend.HeaderByHash(tc.hash) if tc.expPass { @@ -1446,14 +1447,14 @@ func (suite *BackendTestSuite) TestEthBlockByNumber() { RegisterBlockResults(client, blockNum.Int64()) queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) - baseFee := sdk.NewInt(1) + baseFee := sdkmath.NewInt(1) RegisterBaseFee(queryClient, baseFee) }, ethtypes.NewBlock( ethrpc.EthHeaderFromTendermint( emptyBlock.Header, ethtypes.Bloom{}, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), ), []*ethtypes.Transaction{}, nil, @@ -1472,14 +1473,14 @@ func (suite *BackendTestSuite) TestEthBlockByNumber() { RegisterBlockResults(client, blockNum.Int64()) queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) - baseFee := sdk.NewInt(1) + baseFee := sdkmath.NewInt(1) RegisterBaseFee(queryClient, baseFee) }, ethtypes.NewBlock( ethrpc.EthHeaderFromTendermint( emptyBlock.Header, ethtypes.Bloom{}, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), ), []*ethtypes.Transaction{msgEthereumTx.AsTransaction()}, nil, @@ -1521,21 +1522,21 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() { baseFee *big.Int resBlock *tmrpctypes.ResultBlock blockRes *tmrpctypes.ResultBlockResults - registerMock func(sdk.Int, int64) + registerMock func(sdkmath.Int, int64) expEthBlock *ethtypes.Block expPass bool }{ { "pass - block without tx", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), &tmrpctypes.ResultBlock{ Block: emptyBlock, }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, }, - func(baseFee sdk.Int, blockNum int64) { + func(baseFee sdkmath.Int, blockNum int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) }, @@ -1543,7 +1544,7 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() { ethrpc.EthHeaderFromTendermint( emptyBlock.Header, ethtypes.Bloom{}, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), ), []*ethtypes.Transaction{}, nil, @@ -1554,14 +1555,14 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() { }, { "pass - block with tx", - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), &tmrpctypes.ResultBlock{ Block: tmtypes.MakeBlock(1, []tmtypes.Tx{bz}, nil, nil), }, &tmrpctypes.ResultBlockResults{ Height: 1, - TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, - EndBlockEvents: []types.Event{ + TxsResults: []*types.ExecTxResult{{Code: 0, GasUsed: 0}}, + FinalizeBlockEvents: []types.Event{ { Type: evmtypes.EventTypeBlockBloom, Attributes: []types.EventAttribute{ @@ -1570,7 +1571,7 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() { }, }, }, - func(baseFee sdk.Int, blockNum int64) { + func(baseFee sdkmath.Int, blockNum int64) { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBaseFee(queryClient, baseFee) }, @@ -1578,7 +1579,7 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() { ethrpc.EthHeaderFromTendermint( emptyBlock.Header, ethtypes.Bloom{}, - sdk.NewInt(1).BigInt(), + sdkmath.NewInt(1).BigInt(), ), []*ethtypes.Transaction{msgEthereumTx.AsTransaction()}, nil, @@ -1591,7 +1592,7 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset test and queries - tc.registerMock(sdk.NewIntFromBigInt(tc.baseFee), tc.blockRes.Height) + tc.registerMock(sdkmath.NewIntFromBigInt(tc.baseFee), tc.blockRes.Height) ethBlock, err := suite.backend.EthBlockFromTendermintBlock(tc.resBlock, tc.blockRes) diff --git a/rpc/backend/call_tx_test.go b/rpc/backend/call_tx_test.go index cbdac844..fddc6749 100644 --- a/rpc/backend/call_tx_test.go +++ b/rpc/backend/call_tx_test.go @@ -5,7 +5,7 @@ import ( "fmt" "math/big" - sdk "github.com/cosmos/cosmos-sdk/types" + sdkmath "cosmossdk.io/math" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/rlp" @@ -18,7 +18,7 @@ import ( func (suite *BackendTestSuite) TestResend() { txNonce := (hexutil.Uint64)(1) - baseFee := sdk.NewInt(1) + baseFee := sdkmath.NewInt(1) gasPrice := new(hexutil.Big) toAddr := tests.GenerateAddress() chainID := (*hexutil.Big)(suite.backend.chainID) @@ -453,7 +453,7 @@ func (suite *BackendTestSuite) TestGasPrice() { RegisterParams(queryClient, &header, 1) RegisterBlock(client, 1, nil) RegisterBlockResults(client, 1) - RegisterBaseFee(queryClient, sdk.NewInt(1)) + RegisterBaseFee(queryClient, sdkmath.NewInt(1)) }, defaultGasPrice, true, @@ -469,7 +469,7 @@ func (suite *BackendTestSuite) TestGasPrice() { RegisterParams(queryClient, &header, 1) RegisterBlock(client, 1, nil) RegisterBlockResults(client, 1) - RegisterBaseFee(queryClient, sdk.NewInt(1)) + RegisterBaseFee(queryClient, sdkmath.NewInt(1)) }, defaultGasPrice, false, diff --git a/rpc/backend/chain_info.go b/rpc/backend/chain_info.go index bcacf631..a0bb993a 100644 --- a/rpc/backend/chain_info.go +++ b/rpc/backend/chain_info.go @@ -20,8 +20,9 @@ import ( "math/big" "strconv" - tmrpcclient "github.com/cometbft/cometbft/rpc/client" - tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" + sdkmath "cosmossdk.io/math" + cmtrpcclient "github.com/cometbft/cometbft/rpc/client" + cmtrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" @@ -66,10 +67,10 @@ func (b *Backend) ChainConfig() *params.ChainConfig { } // GlobalMinGasPrice returns MinGasPrice param from FeeMarket -func (b *Backend) GlobalMinGasPrice() (sdk.Dec, error) { +func (b *Backend) GlobalMinGasPrice() (sdkmath.LegacyDec, error) { res, err := b.queryClient.FeeMarket.Params(b.ctx, &feemarkettypes.QueryParamsRequest{}) if err != nil { - return sdk.ZeroDec(), err + return sdkmath.LegacyZeroDec(), err } return res.Params.MinGasPrice, nil } @@ -78,15 +79,15 @@ func (b *Backend) GlobalMinGasPrice() (sdk.Dec, error) { // If the base fee is not enabled globally, the query returns nil. // If the London hard fork is not activated at the current height, the query will // return nil. -func (b *Backend) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, error) { +func (b *Backend) BaseFee(blockRes *cmtrpctypes.ResultBlockResults) (*big.Int, error) { // return BaseFee if London hard fork is activated and feemarket is enabled res, err := b.queryClient.BaseFee(rpctypes.ContextWithHeight(blockRes.Height), &evmtypes.QueryBaseFeeRequest{}) if err != nil || res.BaseFee == nil { // we can't tell if it's london HF not enabled or the state is pruned, // in either case, we'll fallback to parsing from begin blocker event, // faster to iterate reversely - for i := len(blockRes.BeginBlockEvents) - 1; i >= 0; i-- { - evt := blockRes.BeginBlockEvents[i] + for i := len(blockRes.FinalizeBlockEvents) - 1; i >= 0; i-- { + evt := blockRes.FinalizeBlockEvents[i] if evt.Type == feemarkettypes.EventTypeFeeMarket && len(evt.Attributes) > 0 { baseFee, err := strconv.ParseInt(evt.Attributes[0].Value, 10, 64) if err == nil { @@ -114,7 +115,7 @@ func (b *Backend) CurrentHeader() *ethtypes.Header { // PendingTransactions returns the transactions that are in the transaction pool // and have a from address that is one of the accounts this node manages. func (b *Backend) PendingTransactions() ([]*sdk.Tx, error) { - mc, ok := b.clientCtx.Client.(tmrpcclient.MempoolClient) + mc, ok := b.clientCtx.Client.(cmtrpcclient.MempoolClient) if !ok { return nil, errors.New("invalid rpc client") } diff --git a/rpc/backend/chain_info_test.go b/rpc/backend/chain_info_test.go index 98f19f3e..a0f2e16d 100644 --- a/rpc/backend/chain_info_test.go +++ b/rpc/backend/chain_info_test.go @@ -15,13 +15,14 @@ import ( tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/ethermint/rpc/backend/mocks" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" - feemarkettypes "github.com/zeta-chain/ethermint/x/feemarket/types" + sdkmath "cosmossdk.io/math" + "github.com/evmos/ethermint/rpc/backend/mocks" + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" ) func (suite *BackendTestSuite) TestBaseFee() { - baseFee := sdk.NewInt(1) + baseFee := sdkmath.NewInt(1) testCases := []struct { name string @@ -44,7 +45,7 @@ func (suite *BackendTestSuite) TestBaseFee() { "fail - grpc BaseFee error - with non feemarket block event", &tmrpctypes.ResultBlockResults{ Height: 1, - BeginBlockEvents: []types.Event{ + FinalizeBlockEvents: []types.Event{ { Type: evmtypes.EventTypeBlockBloom, }, @@ -61,7 +62,7 @@ func (suite *BackendTestSuite) TestBaseFee() { "fail - grpc BaseFee error - with feemarket block event", &tmrpctypes.ResultBlockResults{ Height: 1, - BeginBlockEvents: []types.Event{ + FinalizeBlockEvents: []types.Event{ { Type: feemarkettypes.EventTypeFeeMarket, }, @@ -78,7 +79,7 @@ func (suite *BackendTestSuite) TestBaseFee() { "fail - grpc BaseFee error - with feemarket block event with wrong attribute value", &tmrpctypes.ResultBlockResults{ Height: 1, - BeginBlockEvents: []types.Event{ + FinalizeBlockEvents: []types.Event{ { Type: feemarkettypes.EventTypeFeeMarket, Attributes: []types.EventAttribute{ @@ -98,7 +99,7 @@ func (suite *BackendTestSuite) TestBaseFee() { "fail - grpc baseFee error - with feemarket block event with baseFee attribute value", &tmrpctypes.ResultBlockResults{ Height: 1, - BeginBlockEvents: []types.Event{ + FinalizeBlockEvents: []types.Event{ { Type: feemarkettypes.EventTypeFeeMarket, Attributes: []types.EventAttribute{ @@ -289,7 +290,7 @@ func (suite *BackendTestSuite) TestGlobalMinGasPrice() { testCases := []struct { name string registerMock func() - expMinGasPrice sdk.Dec + expMinGasPrice sdkmath.LegacyDec expPass bool }{ { @@ -298,7 +299,7 @@ func (suite *BackendTestSuite) TestGlobalMinGasPrice() { feeMarketCleint := suite.backend.queryClient.FeeMarket.(*mocks.FeeMarketQueryClient) RegisterFeeMarketParamsError(feeMarketCleint, int64(1)) }, - sdk.ZeroDec(), + sdkmath.LegacyZeroDec(), false, }, } @@ -407,7 +408,7 @@ func (suite *BackendTestSuite) TestFeeHistory() { "pass - Valid FeeHistoryResults object", func(validator sdk.AccAddress) { var header metadata.MD - baseFee := sdk.NewInt(1) + baseFee := sdkmath.NewInt(1) queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) client := suite.backend.clientCtx.Client.(*mocks.Client) suite.backend.cfg.JSONRPC.FeeHistoryCap = 2 @@ -429,6 +430,39 @@ func (suite *BackendTestSuite) TestFeeHistory() { }, sdk.AccAddress(tests.GenerateAddress().Bytes()), true, + nil, + }, + { + "pass - Concurrent FeeHistoryResults object", + func(validator sdk.AccAddress) { + var header metadata.MD + baseFee := sdkmath.NewInt(1) + queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) + fQueryClient := suite.backend.queryClient.FeeMarket.(*mocks.FeeMarketQueryClient) + client := suite.backend.clientCtx.Client.(*mocks.Client) + suite.backend.cfg.JSONRPC.FeeHistoryCap = 2 + RegisterBlock(client, ethrpc.BlockNumber(1).Int64(), nil) + RegisterBlockResults(client, 1) + RegisterBaseFee(queryClient, baseFee) + RegisterValidatorAccount(queryClient, validator) + RegisterConsensusParams(client, 1) + RegisterParams(queryClient, &header, 1) + RegisterParamsWithoutHeader(queryClient, 1) + RegisterFeeMarketParams(fQueryClient, 1) + }, + 1, + 1, + &rpc.FeeHistoryResult{ + OldestBlock: (*hexutil.Big)(big.NewInt(1)), + BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(1)), (*hexutil.Big)(big.NewInt(0))}, + GasUsedRatio: []float64{0}, + Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}}, + }, + sdk.AccAddress(tests.GenerateAddress().Bytes()), + true, + []*big.Int{ + big.NewInt(0), // for overwrite overlap + }, }, } diff --git a/rpc/backend/client_test.go b/rpc/backend/client_test.go index cba00127..5c74ef27 100644 --- a/rpc/backend/client_test.go +++ b/rpc/backend/client_test.go @@ -19,7 +19,6 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/ethermint/rpc/backend/mocks" rpc "github.com/zeta-chain/ethermint/rpc/types" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" ) // Client defines a mocked object that implements the Tendermint JSON-RPC Client @@ -180,15 +179,8 @@ func TestRegisterConsensusParams(t *testing.T) { func RegisterBlockResultsWithEventLog(client *mocks.Client, height int64) (*tmrpctypes.ResultBlockResults, error) { res := &tmrpctypes.ResultBlockResults{ Height: height, - TxsResults: []*abci.ResponseDeliverTx{ - {Code: 0, GasUsed: 0, Events: []abci.Event{{ - Type: evmtypes.EventTypeTxLog, - Attributes: []abci.EventAttribute{{ - Key: evmtypes.AttributeKeyTxLog, - Value: "{\"test\": \"hello\"}", - Index: true, - }}, - }}}, + TxsResults: []*abci.ExecTxResult{ + {Code: 0, GasUsed: 0, Data: data}, }, } client.On("BlockResults", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). @@ -202,7 +194,7 @@ func RegisterBlockResults( ) (*tmrpctypes.ResultBlockResults, error) { res := &tmrpctypes.ResultBlockResults{ Height: height, - TxsResults: []*abci.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*abci.ExecTxResult{{Code: 0, GasUsed: 0}}, } client.On("BlockResults", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). @@ -223,7 +215,7 @@ func TestRegisterBlockResults(t *testing.T) { res, err := client.BlockResults(rpc.ContextWithHeight(height), &height) expRes := &tmrpctypes.ResultBlockResults{ Height: height, - TxsResults: []*abci.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, + TxsResults: []*abci.ExecTxResult{{Code: 0, GasUsed: 0}}, } require.Equal(t, expRes, res) require.NoError(t, err) diff --git a/rpc/backend/evm_query_client_test.go b/rpc/backend/evm_query_client_test.go index 40a044d5..28e6d441 100644 --- a/rpc/backend/evm_query_client_test.go +++ b/rpc/backend/evm_query_client_test.go @@ -7,6 +7,7 @@ import ( "strconv" "testing" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" @@ -157,7 +158,7 @@ func RegisterEstimateGas(queryClient *mocks.EVMQueryClient, args evmtypes.Transa } // BaseFee -func RegisterBaseFee(queryClient *mocks.EVMQueryClient, baseFee sdk.Int) { +func RegisterBaseFee(queryClient *mocks.EVMQueryClient, baseFee sdkmath.Int) { queryClient.On("BaseFee", rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}). Return(&evmtypes.QueryBaseFeeResponse{BaseFee: &baseFee}, nil) } @@ -175,7 +176,7 @@ func RegisterBaseFeeDisabled(queryClient *mocks.EVMQueryClient) { } func TestRegisterBaseFee(t *testing.T) { - baseFee := sdk.NewInt(1) + baseFee := sdkmath.NewInt(1) queryClient := mocks.NewEVMQueryClient(t) RegisterBaseFee(queryClient, baseFee) res, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}) diff --git a/rpc/backend/node_info.go b/rpc/backend/node_info.go index 4b2ca616..ce0af533 100644 --- a/rpc/backend/node_info.go +++ b/rpc/backend/node_info.go @@ -22,7 +22,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdkcrypto "github.com/cosmos/cosmos-sdk/crypto" @@ -101,11 +101,6 @@ func (b *Backend) SetEtherbase(etherbase common.Address) bool { withdrawAddr := sdk.AccAddress(etherbase.Bytes()) msg := distributiontypes.NewMsgSetWithdrawAddress(delAddr, withdrawAddr) - if err := msg.ValidateBasic(); err != nil { - b.logger.Debug("tx failed basic validation", "error", err.Error()) - return false - } - // Assemble transaction from fields builder, ok := b.clientCtx.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder) if !ok { @@ -162,7 +157,7 @@ func (b *Backend) SetEtherbase(etherbase common.Address) bool { return false } - if err := tx.Sign(txFactory, keyInfo.Name, builder, false); err != nil { + if err := tx.Sign(b.clientCtx.CmdContext, txFactory, keyInfo.Name, builder, false); err != nil { b.logger.Debug("failed to sign tx", "error", err.Error()) return false } @@ -175,7 +170,7 @@ func (b *Backend) SetEtherbase(etherbase common.Address) bool { return false } - tmHash := common.BytesToHash(tmtypes.Tx(txBytes).Hash()) + tmHash := common.BytesToHash(cmttypes.Tx(txBytes).Hash()) // Broadcast transaction in sync mode (default) // NOTE: If error is encountered on the node, the broadcast will not return an error @@ -288,7 +283,7 @@ func (b *Backend) SetGasPrice(gasPrice hexutil.Big) bool { unit = minGasPrices[0].Denom } - c := sdk.NewDecCoin(unit, sdk.NewIntFromBigInt(gasPrice.ToInt())) + c := sdk.NewDecCoin(unit, sdkmath.NewIntFromBigInt(gasPrice.ToInt())) appConf.SetMinGasPrices(sdk.DecCoins{c}) sdkconfig.WriteConfigFile(b.clientCtx.Viper.ConfigFileUsed(), appConf) diff --git a/rpc/backend/node_info_test.go b/rpc/backend/node_info_test.go index 2a4a2b26..0a2133ec 100644 --- a/rpc/backend/node_info_test.go +++ b/rpc/backend/node_info_test.go @@ -4,6 +4,7 @@ import ( "fmt" "math/big" + sdkmath "cosmossdk.io/math" tmrpcclient "github.com/cometbft/cometbft/rpc/client" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -38,7 +39,18 @@ func (suite *BackendTestSuite) TestRPCMinGasPrice() { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterParamsWithoutHeader(queryClient, 1) }, - ethermint.DefaultGasPrice, + defaultPrice, + true, + }, + { + "pass - min gas price exceeds math.MaxUint64", + func() { + queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) + RegisterParamsWithoutHeader(queryClient, 1) + amt, _ := sdkmath.NewIntFromString("18446744073709551616") + suite.backend.cfg.SetMinGasPrices([]sdk.DecCoin{sdk.NewDecCoin(ethermint.AttoPhoton, amt)}) + }, + bigPrice, true, }, } @@ -254,7 +266,7 @@ func (suite *BackendTestSuite) TestSetEtherbase() { RegisterStatus(client) RegisterValidatorAccount(queryClient, suite.acc) RegisterParams(queryClient, &header, 1) - c := sdk.NewDecCoin("aphoton", sdk.NewIntFromBigInt(big.NewInt(1))) + c := sdk.NewDecCoin("aphoton", sdkmath.NewIntFromBigInt(big.NewInt(1))) suite.backend.cfg.SetMinGasPrices(sdk.DecCoins{c}) delAddr, _ := suite.backend.GetCoinbase() // account, _ := suite.backend.clientCtx.AccountRetriever.GetAccount(suite.backend.clientCtx, delAddr) @@ -279,7 +291,7 @@ func (suite *BackendTestSuite) TestSetEtherbase() { // queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) // RegisterStatus(client) // RegisterValidatorAccount(queryClient, suite.acc) - // c := sdk.NewDecCoin("aphoton", sdk.NewIntFromBigInt(big.NewInt(1))) + // c := sdk.NewDecCoin("aphoton", sdkmath.NewIntFromBigInt(big.NewInt(1))) // suite.backend.cfg.SetMinGasPrices(sdk.DecCoins{c}) // delAddr, _ := suite.backend.GetCoinbase() // account, _ := suite.backend.clientCtx.AccountRetriever.GetAccount(suite.backend.clientCtx, delAddr) diff --git a/rpc/backend/sign_tx.go b/rpc/backend/sign_tx.go index 4204b5e5..52fec42f 100644 --- a/rpc/backend/sign_tx.go +++ b/rpc/backend/sign_tx.go @@ -23,6 +23,7 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" + signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -130,7 +131,7 @@ func (b *Backend) Sign(address common.Address, data hexutil.Bytes) (hexutil.Byte } // Sign the requested hash with the wallet - signature, _, err := b.clientCtx.Keyring.SignByAddress(from, data) + signature, _, err := b.clientCtx.Keyring.SignByAddress(from, data, signingtypes.SignMode_SIGN_MODE_TEXTUAL) if err != nil { b.logger.Error("keyring.SignByAddress failed", "address", address.Hex()) return nil, err @@ -156,7 +157,7 @@ func (b *Backend) SignTypedData(address common.Address, typedData apitypes.Typed } // Sign the requested hash with the wallet - signature, _, err := b.clientCtx.Keyring.SignByAddress(from, sigHash) + signature, _, err := b.clientCtx.Keyring.SignByAddress(from, sigHash, signingtypes.SignMode_SIGN_MODE_TEXTUAL) if err != nil { b.logger.Error("keyring.SignByAddress failed", "address", address.Hex()) return nil, err diff --git a/rpc/backend/sign_tx_test.go b/rpc/backend/sign_tx_test.go index 62ea273e..d44e4e27 100644 --- a/rpc/backend/sign_tx_test.go +++ b/rpc/backend/sign_tx_test.go @@ -3,8 +3,10 @@ package backend import ( "fmt" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/crypto" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -25,7 +27,7 @@ func (suite *BackendTestSuite) TestSendTransaction() { priv, _ := ethsecp256k1.GenerateKey() from := common.BytesToAddress(priv.PubKey().Address().Bytes()) nonce := hexutil.Uint64(1) - baseFee := sdk.NewInt(1) + baseFee := sdkmath.NewInt(1) callArgsDefault := evmtypes.TransactionArgs{ From: &from, To: &toAddr, @@ -200,7 +202,7 @@ func (suite *BackendTestSuite) TestSign() { responseBz, err := suite.backend.Sign(tc.fromAddr, tc.inputBz) if tc.expPass { - signature, _, err := suite.backend.clientCtx.Keyring.SignByAddress((sdk.AccAddress)(from.Bytes()), tc.inputBz) + signature, _, err := suite.backend.clientCtx.Keyring.SignByAddress((sdk.AccAddress)(from.Bytes()), tc.inputBz, signing.SignMode_SIGN_MODE_TEXTUAL) signature[goethcrypto.RecoveryIDOffset] += 27 suite.Require().NoError(err) suite.Require().Equal((hexutil.Bytes)(signature), responseBz) @@ -249,7 +251,8 @@ func (suite *BackendTestSuite) TestSignTypedData() { if tc.expPass { sigHash, _, err := apitypes.TypedDataAndHash(tc.inputTypedData) - signature, _, err := suite.backend.clientCtx.Keyring.SignByAddress((sdk.AccAddress)(from.Bytes()), sigHash) + suite.Require().NoError(err) + signature, _, err := suite.backend.clientCtx.Keyring.SignByAddress((sdk.AccAddress)(from.Bytes()), sigHash, signing.SignMode_SIGN_MODE_TEXTUAL) signature[goethcrypto.RecoveryIDOffset] += 27 suite.Require().NoError(err) suite.Require().Equal((hexutil.Bytes)(signature), responseBz) diff --git a/rpc/backend/tracing_test.go b/rpc/backend/tracing_test.go index 253b88cb..39ff3240 100644 --- a/rpc/backend/tracing_test.go +++ b/rpc/backend/tracing_test.go @@ -3,9 +3,9 @@ package backend import ( "fmt" - dbm "github.com/cometbft/cometbft-db" + dbm "github.com/cosmos/cosmos-db" abci "github.com/cometbft/cometbft/abci/types" - tmlog "github.com/cometbft/cometbft/libs/log" + tmlog "cosmossdk.io/log" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cometbft/cometbft/types" tmtypes "github.com/cometbft/cometbft/types" @@ -51,7 +51,7 @@ func (suite *BackendTestSuite) TestTraceTransaction() { name string registerMock func() block *types.Block - responseBlock []*abci.ResponseDeliverTx + responseBlock []*abci.ExecTxResult expResult interface{} expPass bool }{ @@ -59,7 +59,7 @@ func (suite *BackendTestSuite) TestTraceTransaction() { "fail - tx not found", func() {}, &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ @@ -85,7 +85,7 @@ func (suite *BackendTestSuite) TestTraceTransaction() { RegisterBlockError(client, 1) }, &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ @@ -112,7 +112,7 @@ func (suite *BackendTestSuite) TestTraceTransaction() { RegisterTraceTransactionWithPredecessors(queryClient, msgEthereumTx, []*evmtypes.MsgEthereumTx{msgEthereumTx}) }, &types.Block{Header: types.Header{Height: 1, ChainID: ChainID}, Data: types.Data{Txs: []types.Tx{txBz, txBz2}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ @@ -152,7 +152,7 @@ func (suite *BackendTestSuite) TestTraceTransaction() { RegisterTraceTransaction(queryClient, msgEthereumTx) }, &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ diff --git a/rpc/backend/tx_info_test.go b/rpc/backend/tx_info_test.go index 200db87d..7b6813da 100644 --- a/rpc/backend/tx_info_test.go +++ b/rpc/backend/tx_info_test.go @@ -4,12 +4,12 @@ import ( "fmt" "math/big" - dbm "github.com/cometbft/cometbft-db" + sdkmath "cosmossdk.io/math" + dbm "github.com/cosmos/cosmos-db" abci "github.com/cometbft/cometbft/abci/types" - tmlog "github.com/cometbft/cometbft/libs/log" + tmlog "cosmossdk.io/log" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cometbft/cometbft/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/zeta-chain/ethermint/indexer" @@ -26,7 +26,7 @@ func (suite *BackendTestSuite) TestGetTransactionByHash() { txBz := suite.signAndEncodeEthTx(msgEthereumTx) block := &types.Block{Header: types.Header{Height: 1, ChainID: "test"}, Data: types.Data{Txs: []types.Tx{txBz}}} - responseDeliver := []*abci.ResponseDeliverTx{ + responseDeliver := []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ @@ -92,7 +92,7 @@ func (suite *BackendTestSuite) TestGetTransactionByHash() { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBlock(client, 1, txBz) RegisterBlockResults(client, 1) - RegisterBaseFee(queryClient, sdk.NewInt(1)) + RegisterBaseFee(queryClient, sdkmath.NewInt(1)) }, msgEthereumTx, rpcTransaction, @@ -278,7 +278,7 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockAndIndex() { msgEthTx, bz := suite.buildEthereumTx() defaultBlock := types.MakeBlock(1, []types.Tx{bz}, nil, nil) - defaultResponseDeliverTx := []*abci.ResponseDeliverTx{ + defaultResponseDeliverTx := []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ @@ -346,7 +346,7 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockAndIndex() { err := suite.backend.indexer.IndexBlock(block, defaultResponseDeliverTx) suite.Require().NoError(err) RegisterBlockResults(client, 1) - RegisterBaseFee(queryClient, sdk.NewInt(1)) + RegisterBaseFee(queryClient, sdkmath.NewInt(1)) }, &tmrpctypes.ResultBlock{Block: defaultBlock}, 0, @@ -359,7 +359,7 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockAndIndex() { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) client := suite.backend.clientCtx.Client.(*mocks.Client) RegisterBlockResults(client, 1) - RegisterBaseFee(queryClient, sdk.NewInt(1)) + RegisterBaseFee(queryClient, sdkmath.NewInt(1)) }, &tmrpctypes.ResultBlock{Block: defaultBlock}, 0, @@ -422,7 +422,7 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockNumberAndIndex() { queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterBlock(client, 1, bz) RegisterBlockResults(client, 1) - RegisterBaseFee(queryClient, sdk.NewInt(1)) + RegisterBaseFee(queryClient, sdkmath.NewInt(1)) }, 0, 0, @@ -541,7 +541,7 @@ func (suite *BackendTestSuite) TestGetTransactionReceipt() { registerMock func() tx *evmtypes.MsgEthereumTx block *types.Block - blockResult []*abci.ResponseDeliverTx + blockResult []*abci.ExecTxResult expTxReceipt map[string]interface{} expPass bool }{ @@ -558,7 +558,7 @@ func (suite *BackendTestSuite) TestGetTransactionReceipt() { }, msgEthereumTx, &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}}, - []*abci.ResponseDeliverTx{ + []*abci.ExecTxResult{ { Code: 0, Events: []abci.Event{ diff --git a/rpc/backend/utils.go b/rpc/backend/utils.go index 0fbdb875..49c1991e 100644 --- a/rpc/backend/utils.go +++ b/rpc/backend/utils.go @@ -22,6 +22,7 @@ import ( "sort" "strings" + "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "google.golang.org/grpc/codes" @@ -33,7 +34,6 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cometbft/cometbft/proto/tendermint/crypto" @@ -74,7 +74,7 @@ func (b *Backend) getAccountNonce(accAddr common.Address, pending bool, height i } return 0, err } - var acc authtypes.AccountI + var acc sdk.AccountI if err := b.clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil { return 0, err } @@ -273,7 +273,7 @@ func ParseTxLogsFromEvent(event abci.Event) ([]*ethtypes.Log, error) { // ShouldIgnoreGasUsed returns true if the gasUsed in result should be ignored // workaround for issue: https://github.com/cosmos/cosmos-sdk/issues/10832 -func ShouldIgnoreGasUsed(res *abci.ResponseDeliverTx) bool { +func ShouldIgnoreGasUsed(res *abci.ExecTxResult) bool { return res.GetCode() == 11 && strings.Contains(res.GetLog(), "no block gas left to run tx: out of gas") } diff --git a/rpc/namespaces/ethereum/debug/api.go b/rpc/namespaces/ethereum/debug/api.go index 348612a7..7b78b553 100644 --- a/rpc/namespaces/ethereum/debug/api.go +++ b/rpc/namespaces/ethereum/debug/api.go @@ -34,7 +34,7 @@ import ( "github.com/cosmos/cosmos-sdk/server" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/rlp" diff --git a/rpc/namespaces/ethereum/debug/utils.go b/rpc/namespaces/ethereum/debug/utils.go index 84738af2..e7c76e1e 100644 --- a/rpc/namespaces/ethereum/debug/utils.go +++ b/rpc/namespaces/ethereum/debug/utils.go @@ -22,7 +22,7 @@ import ( "runtime/pprof" "strings" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/server" ) diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index 588e0f25..acce4207 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -22,7 +22,7 @@ import ( "github.com/ethereum/go-ethereum/rpc" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" diff --git a/rpc/namespaces/ethereum/eth/filters/api.go b/rpc/namespaces/ethereum/eth/filters/api.go index 3375c493..c15a7655 100644 --- a/rpc/namespaces/ethereum/eth/filters/api.go +++ b/rpc/namespaces/ethereum/eth/filters/api.go @@ -24,7 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/zeta-chain/ethermint/rpc/types" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" coretypes "github.com/cometbft/cometbft/rpc/core/types" rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" diff --git a/rpc/namespaces/ethereum/eth/filters/filters.go b/rpc/namespaces/ethereum/eth/filters/filters.go index 57f4e0a9..be58ca31 100644 --- a/rpc/namespaces/ethereum/eth/filters/filters.go +++ b/rpc/namespaces/ethereum/eth/filters/filters.go @@ -24,7 +24,7 @@ import ( "github.com/zeta-chain/ethermint/rpc/backend" "github.com/zeta-chain/ethermint/rpc/types" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/pkg/errors" diff --git a/rpc/namespaces/ethereum/miner/api.go b/rpc/namespaces/ethereum/miner/api.go index 9b08fd87..3a0368d5 100644 --- a/rpc/namespaces/ethereum/miner/api.go +++ b/rpc/namespaces/ethereum/miner/api.go @@ -21,7 +21,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" "github.com/zeta-chain/ethermint/rpc/backend" ) diff --git a/rpc/namespaces/ethereum/personal/api.go b/rpc/namespaces/ethereum/personal/api.go index c2b49ba8..0991d848 100644 --- a/rpc/namespaces/ethereum/personal/api.go +++ b/rpc/namespaces/ethereum/personal/api.go @@ -26,7 +26,7 @@ import ( "github.com/zeta-chain/ethermint/crypto/hd" ethermint "github.com/zeta-chain/ethermint/types" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/rpc/namespaces/ethereum/txpool/api.go b/rpc/namespaces/ethereum/txpool/api.go index 7df7823f..dfbf8e78 100644 --- a/rpc/namespaces/ethereum/txpool/api.go +++ b/rpc/namespaces/ethereum/txpool/api.go @@ -16,7 +16,7 @@ package txpool import ( - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" "github.com/ethereum/go-ethereum/common/hexutil" diff --git a/rpc/types/events.go b/rpc/types/events.go index c0521db5..cca101b5 100644 --- a/rpc/types/events.go +++ b/rpc/types/events.go @@ -90,7 +90,7 @@ type ParsedTxs struct { // ParseTxResult parse eth tx infos from cosmos-sdk events. // It supports two event formats, the formats are described in the comments of the format constants. -func ParseTxResult(result *abci.ResponseDeliverTx, tx sdk.Tx) (*ParsedTxs, error) { +func ParseTxResult(result *abci.ExecTxResult, tx sdk.Tx) (*ParsedTxs, error) { format := eventFormatUnknown // the index of current ethereum_tx event in format 1 or the second part of format 2 eventIndex := -1 diff --git a/rpc/types/events_test.go b/rpc/types/events_test.go index d642a459..7e612757 100644 --- a/rpc/types/events_test.go +++ b/rpc/types/events_test.go @@ -17,12 +17,12 @@ func TestParseTxResult(t *testing.T) { testCases := []struct { name string - response abci.ResponseDeliverTx + response abci.ExecTxResult expTxs []*ParsedTx // expected parse result, nil means expect error. }{ { "format 1 events", - abci.ResponseDeliverTx{ + abci.ExecTxResult{ GasUsed: 21000, Events: []abci.Event{ {Type: "coin_received", Attributes: []abci.EventAttribute{ @@ -78,7 +78,7 @@ func TestParseTxResult(t *testing.T) { }, { "format 2 events", - abci.ResponseDeliverTx{ + abci.ExecTxResult{ GasUsed: 21000, Events: []abci.Event{ {Type: "coin_received", Attributes: []abci.EventAttribute{ @@ -121,7 +121,7 @@ func TestParseTxResult(t *testing.T) { }, { "format 1 events, failed", - abci.ResponseDeliverTx{ + abci.ExecTxResult{ GasUsed: 21000, Events: []abci.Event{ {Type: evmtypes.EventTypeEthereumTx, Attributes: []abci.EventAttribute{ @@ -148,7 +148,7 @@ func TestParseTxResult(t *testing.T) { }, { "format 1 events, failed", - abci.ResponseDeliverTx{ + abci.ExecTxResult{ GasUsed: 21000, Events: []abci.Event{ {Type: evmtypes.EventTypeEthereumTx, Attributes: []abci.EventAttribute{ @@ -175,7 +175,7 @@ func TestParseTxResult(t *testing.T) { }, { "format 2 events failed", - abci.ResponseDeliverTx{ + abci.ExecTxResult{ GasUsed: 21000, Events: []abci.Event{ {Type: evmtypes.EventTypeEthereumTx, Attributes: []abci.EventAttribute{ @@ -194,7 +194,7 @@ func TestParseTxResult(t *testing.T) { }, { "format 2 events failed", - abci.ResponseDeliverTx{ + abci.ExecTxResult{ GasUsed: 21000, Events: []abci.Event{ {Type: evmtypes.EventTypeEthereumTx, Attributes: []abci.EventAttribute{ diff --git a/rpc/types/utils.go b/rpc/types/utils.go index e0bfcfa4..025e2005 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -279,12 +279,12 @@ func CheckTxFee(gasPrice *big.Int, gas uint64, cap float64) error { } // TxExceedBlockGasLimit returns true if the tx exceeds block gas limit. -func TxExceedBlockGasLimit(res *abci.ResponseDeliverTx) bool { +func TxExceedBlockGasLimit(res *abci.ExecTxResult) bool { return strings.Contains(res.Log, ExceedBlockGasLimitError) } // TxSuccessOrExceedsBlockGasLimit returns true if the transaction was successful // or if it failed with an ExceedBlockGasLimit error -func TxSuccessOrExceedsBlockGasLimit(res *abci.ResponseDeliverTx) bool { +func TxSuccessOrExceedsBlockGasLimit(res *abci.ExecTxResult) bool { return res.Code == 0 || TxExceedBlockGasLimit(res) } diff --git a/rpc/websockets.go b/rpc/websockets.go index c2bc39cc..4919974a 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -37,9 +37,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" - "github.com/cometbft/cometbft/libs/log" - rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" - tmtypes "github.com/cometbft/cometbft/types" + "cosmossdk.io/log" "github.com/zeta-chain/ethermint/rpc/ethereum/pubsub" rpcfilters "github.com/zeta-chain/ethermint/rpc/namespaces/ethereum/eth/filters" diff --git a/scripts/integration-test-all.sh b/scripts/integration-test-all.sh index fce8d739..1c0ab529 100755 --- a/scripts/integration-test-all.sh +++ b/scripts/integration-test-all.sh @@ -73,7 +73,7 @@ init_func() { "$PWD"/build/ethermintd keys add $KEY"$i" --keyring-backend test --home "$DATA_DIR$i" --no-backup --algo "eth_secp256k1" "$PWD"/build/ethermintd init $MONIKER --chain-id $CHAINID --home "$DATA_DIR$i" # Set gas limit in genesis - cat $DATA_DIR$i/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $DATA_DIR$i/config/tmp_genesis.json && mv $DATA_DIR$i/config/tmp_genesis.json $DATA_DIR$i/config/genesis.json + cat $DATA_DIR$i/config/genesis.json | jq '.consensus["params"]["block"]["max_gas"]="10000000"' > $DATA_DIR$i/config/tmp_genesis.json && mv $DATA_DIR$i/config/tmp_genesis.json $DATA_DIR$i/config/genesis.json "$PWD"/build/ethermintd add-genesis-account \ "$("$PWD"/build/ethermintd keys show "$KEY$i" --keyring-backend test -a --home "$DATA_DIR$i")" 1000000000000000000aphoton,1000000000000000000stake \ --keyring-backend test --home "$DATA_DIR$i" diff --git a/server/config/config.go b/server/config/config.go index 10c8d8b9..7075a79f 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -21,13 +21,17 @@ import ( "path" "time" + sdkmath "cosmossdk.io/math" + "github.com/spf13/viper" "github.com/cometbft/cometbft/libs/strings" errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/server/config" + sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/rosetta" ) const ( @@ -75,9 +79,32 @@ const ( // DefaultMaxOpenConnections represents the amount of open connections (unlimited = 0) DefaultMaxOpenConnections = 0 + + // DefaultReturnDataLimit is maximum number of bytes returned from eth_call or similar invocations + DefaultReturnDataLimit = 100000 + + // DefaultRosettaEnable is the default value for the parameter that defines if the Rosetta API server is enabled + DefaultRosettaEnable = false + + // DefaultRosettaBlockchain defines the default blockchain name for the rosetta server + DefaultRosettaBlockchain = "evmos" + + // DefaultRosettaNetwork defines the default network name for the rosetta server + DefaultRosettaNetwork = "evmos" + + // DefaultRosettaGasToSuggest defines the default gas to suggest for the rosetta server + DefaultRosettaGasToSuggest = 300_000 + + // DefaultRosettaDenomToSuggest defines the default denom for fee suggestion + DefaultRosettaDenomToSuggest = "basecro" ) -var evmTracers = []string{"json", "markdown", "struct", "access_list"} +var ( + // DefaultRosettaGasPrices defines the default list of prices to suggest + DefaultRosettaGasPrices = sdk.NewDecCoins(sdk.NewDecCoin(DefaultRosettaDenomToSuggest, sdkmath.NewInt(4_000_000))) + + evmTracers = []string{"json", "markdown", "struct", "access_list"} +) // Config defines the server's top level configuration. It includes the default app config // from the SDK as well as the EVM configuration to enable the JSON-RPC APIs. @@ -87,6 +114,7 @@ type Config struct { EVM EVMConfig `mapstructure:"evm"` JSONRPC JSONRPCConfig `mapstructure:"json-rpc"` TLS TLSConfig `mapstructure:"tls"` + Rosetta RosettaConfig `mapstructure:"rosetta"` } // EVMConfig defines the application configuration values for the EVM. @@ -148,6 +176,13 @@ type TLSConfig struct { KeyPath string `mapstructure:"key-path"` } +// RosettaConfig defines configuration for the Rosetta server. +type RosettaConfig struct { + rosetta.Config + // Enable defines if the Rosetta server should be enabled. + Enable bool `mapstructure:"enable"` +} + // AppConfig helps to override default appConfig template and configs. // return "", nil if no custom configuration is required for the application. func AppConfig(denom string) (string, interface{}) { @@ -190,6 +225,7 @@ func DefaultConfig() *Config { EVM: *DefaultEVMConfig(), JSONRPC: *DefaultJSONRPCConfig(), TLS: *DefaultTLSConfig(), + Rosetta: *DefaultRosettaConfig(), } } @@ -303,6 +339,26 @@ func DefaultTLSConfig() *TLSConfig { } } +// DefaultEVMConfig returns the default EVM configuration +func DefaultRosettaConfig() *RosettaConfig { + return &RosettaConfig{ + Config: rosetta.Config{ + Blockchain: DefaultRosettaBlockchain, + Network: DefaultRosettaNetwork, + TendermintRPC: rosetta.DefaultCometEndpoint, + GRPCEndpoint: rosetta.DefaultGRPCEndpoint, + Addr: rosetta.DefaultAddr, + Retries: rosetta.DefaultRetries, + Offline: rosetta.DefaultOffline, + EnableFeeSuggestion: rosetta.DefaultEnableFeeSuggestion, + GasToSuggest: DefaultRosettaGasToSuggest, + DenomToSuggest: DefaultRosettaDenomToSuggest, + GasPrices: DefaultRosettaGasPrices, + }, + Enable: DefaultRosettaEnable, + } +} + // Validate returns an error if the TLS certificate and key file extensions are invalid. func (c TLSConfig) Validate() error { certExt := path.Ext(c.CertificatePath) diff --git a/server/flags/flags.go b/server/flags/flags.go index 1d1316f6..7069fd30 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -22,13 +22,13 @@ import ( "github.com/spf13/viper" ) -// Tendermint/cosmos-sdk full-node start flags +// CometBFT/cosmos-sdk full-node start flags const ( - WithTendermint = "with-tendermint" - Address = "address" - Transport = "transport" - TraceStore = "trace-store" - CPUProfile = "cpu-profile" + WithCometBFT = "with-cometbft" + Address = "address" + Transport = "transport" + TraceStore = "trace-store" + CPUProfile = "cpu-profile" // The type of database for application and snapshots databases AppDBBackend = "app-db-backend" ) diff --git a/server/indexer_cmd.go b/server/indexer_cmd.go index d220a3f7..82140ebb 100644 --- a/server/indexer_cmd.go +++ b/server/indexer_cmd.go @@ -20,9 +20,9 @@ import ( "github.com/spf13/cobra" - tmnode "github.com/cometbft/cometbft/node" + cmtnode "github.com/cometbft/cometbft/config" sm "github.com/cometbft/cometbft/state" - tmstore "github.com/cometbft/cometbft/store" + cmtstore "github.com/cometbft/cometbft/store" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" "github.com/zeta-chain/ethermint/indexer" @@ -63,13 +63,13 @@ func NewIndexTxCmd() *cobra.Command { idxer := indexer.NewKVIndexer(idxDB, logger.With("module", "evmindex"), clientCtx) // open local tendermint db, because the local rpc won't be available. - tmdb, err := tmnode.DefaultDBProvider(&tmnode.DBContext{ID: "blockstore", Config: cfg}) + cmtdb, err := cmtnode.DefaultDBProvider(&cmtnode.DBContext{ID: "blockstore", Config: cfg}) if err != nil { return err } - blockStore := tmstore.NewBlockStore(tmdb) + blockStore := cmtstore.NewBlockStore(cmtdb) - stateDB, err := tmnode.DefaultDBProvider(&tmnode.DBContext{ID: "state", Config: cfg}) + stateDB, err := cmtnode.DefaultDBProvider(&cmtnode.DBContext{ID: "state", Config: cfg}) if err != nil { return err } @@ -82,11 +82,11 @@ func NewIndexTxCmd() *cobra.Command { if blk == nil { return fmt.Errorf("block not found %d", height) } - resBlk, err := stateStore.LoadABCIResponses(height) + resBlk, err := stateStore.LoadFinalizeBlockResponse(height) if err != nil { return err } - if err := idxer.IndexBlock(blk, resBlk.DeliverTxs); err != nil { + if err := idxer.IndexBlock(blk, resBlk.TxResults); err != nil { return err } fmt.Println(height) diff --git a/server/json_rpc.go b/server/json_rpc.go index 658e9238..6874aaa5 100644 --- a/server/json_rpc.go +++ b/server/json_rpc.go @@ -24,10 +24,10 @@ import ( "github.com/gorilla/mux" "github.com/rs/cors" + "golang.org/x/sync/errgroup" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" - "github.com/cosmos/cosmos-sdk/server/types" ethlog "github.com/ethereum/go-ethereum/log" ethrpc "github.com/ethereum/go-ethereum/rpc" "github.com/zeta-chain/ethermint/rpc" @@ -37,68 +37,61 @@ import ( ethermint "github.com/zeta-chain/ethermint/types" ) -type gethLogsToTm struct { - logger tmlog.Logger - attrs []slog.Attr -} - -func (g *gethLogsToTm) Enabled(_ context.Context, _ slog.Level) bool { - return true -} - -func (g *gethLogsToTm) Handle(_ context.Context, record slog.Record) error { - attrs := g.attrs - record.Attrs(func(attr slog.Attr) bool { - attrs = append(attrs, attr) - return true - }) - switch record.Level { - case slog.LevelDebug: - g.logger.Debug(record.Message, attrs) - case slog.LevelInfo: - g.logger.Info(record.Message, attrs) - case slog.LevelWarn: - g.logger.Info(record.Message, attrs) - case slog.LevelError: - g.logger.Error(record.Message, attrs) - } - return nil -} - -func (g *gethLogsToTm) WithAttrs(attrs []slog.Attr) slog.Handler { - return &gethLogsToTm{ - logger: g.logger, - attrs: append(g.attrs, attrs...), - } -} - -func (g *gethLogsToTm) WithGroup(_ string) slog.Handler { - return g -} +const ( + ServerStartTime = 5 * time.Second + MaxRetry = 6 +) // StartJSONRPC starts the JSON-RPC server -func StartJSONRPC(ctx *server.Context, +func StartJSONRPC(srvCtx *server.Context, clientCtx client.Context, - tmRPCAddr, - tmEndpoint string, + g *errgroup.Group, config *config.Config, indexer ethermint.EVMTxIndexer, ) (*http.Server, chan struct{}, error) { - tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger) + logger := srvCtx.Logger.With("module", "geth") - logger := ctx.Logger.With("module", "geth") - ethlog.SetDefault(ethlog.NewLogger(&gethLogsToTm{logger: logger})) + evtClient, ok := clientCtx.Client.(rpcclient.EventsClient) + if !ok { + return nil, nil, fmt.Errorf("client %T does not implement EventsClient", clientCtx.Client) + } + + var rpcStream *stream.RPCStream + var err error + for i := 0; i < MaxRetry; i++ { + rpcStream, err = stream.NewRPCStreams(evtClient, logger, clientCtx.TxConfig.TxDecoder()) + if err == nil { + break + } + time.Sleep(time.Second) + } + + if err != nil { + return nil, nil, fmt.Errorf("failed to create rpc streams after %d attempts: %w", MaxRetry, err) + } + + ethlog.Root().SetHandler(ethlog.FuncHandler(func(r *ethlog.Record) error { + switch r.Lvl { + case ethlog.LvlTrace, ethlog.LvlDebug: + logger.Debug(r.Msg, r.Ctx...) + case ethlog.LvlInfo, ethlog.LvlWarn: + logger.Info(r.Msg, r.Ctx...) + case ethlog.LvlError, ethlog.LvlCrit: + logger.Error(r.Msg, r.Ctx...) + } + return nil + })) rpcServer := ethrpc.NewServer() allowUnprotectedTxs := config.JSONRPC.AllowUnprotectedTxs rpcAPIArr := config.JSONRPC.API - apis := rpc.GetRPCAPIs(ctx, clientCtx, tmWsClient, allowUnprotectedTxs, indexer, rpcAPIArr) + apis := rpc.GetRPCAPIs(srvCtx, clientCtx, rpcStream, allowUnprotectedTxs, indexer, rpcAPIArr) for _, api := range apis { if err := rpcServer.RegisterName(api.Namespace, api.Service); err != nil { - ctx.Logger.Error( + srvCtx.Logger.Error( "failed to register service in JSON RPC namespace", "namespace", api.Namespace, "service", api.Service, @@ -130,32 +123,22 @@ func StartJSONRPC(ctx *server.Context, return nil, nil, err } - errCh := make(chan error) - go func() { - ctx.Logger.Info("Starting JSON-RPC server", "address", config.JSONRPC.Address) + g.Go(func() error { + srvCtx.Logger.Info("Starting JSON-RPC server", "address", config.JSONRPC.Address) if err := httpSrv.Serve(ln); err != nil { if err == http.ErrServerClosed { close(httpSrvDone) - return } - ctx.Logger.Error("failed to start JSON-RPC server", "error", err.Error()) - errCh <- err + srvCtx.Logger.Error("failed to start JSON-RPC server", "error", err.Error()) + return err } - }() - - select { - case err := <-errCh: - ctx.Logger.Error("failed to boot JSON-RPC server", "error", err.Error()) - return nil, nil, err - case <-time.After(types.ServerStartTime): // assume JSON RPC server started successfully - } + return nil + }) - ctx.Logger.Info("Starting JSON WebSocket server", "address", config.JSONRPC.WsAddress) + srvCtx.Logger.Info("Starting JSON WebSocket server", "address", config.JSONRPC.WsAddress) - // allocate separate WS connection to Tendermint - tmWsClient = ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger) - wsSrv := rpc.NewWebsocketsServer(clientCtx, ctx.Logger, tmWsClient, config) + wsSrv := rpc.NewWebsocketsServer(clientCtx, srvCtx.Logger, rpcStream, config) wsSrv.Start() return httpSrv, httpSrvDone, nil } diff --git a/server/start.go b/server/start.go index 375b2f27..c0fb241d 100644 --- a/server/start.go +++ b/server/start.go @@ -35,32 +35,34 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - dbm "github.com/cometbft/cometbft-db" abciserver "github.com/cometbft/cometbft/abci/server" tcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" - tmos "github.com/cometbft/cometbft/libs/os" + cmtcfg "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/node" "github.com/cometbft/cometbft/p2p" pvm "github.com/cometbft/cometbft/privval" "github.com/cometbft/cometbft/proxy" rpcclient "github.com/cometbft/cometbft/rpc/client" "github.com/cometbft/cometbft/rpc/client/local" + cmttypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" - "cosmossdk.io/tools/rosetta" - crgserver "cosmossdk.io/tools/rosetta/lib/server" + "github.com/cosmos/rosetta" ethmetricsexp "github.com/ethereum/go-ethereum/metrics/exp" errorsmod "cosmossdk.io/errors" + pruningtypes "cosmossdk.io/store/pruning/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" + servercmtlog "github.com/cosmos/cosmos-sdk/server/log" "github.com/cosmos/cosmos-sdk/server/types" - pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" sdk "github.com/cosmos/cosmos-sdk/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/zeta-chain/ethermint/indexer" ethdebug "github.com/zeta-chain/ethermint/rpc/namespaces/ethereum/debug" @@ -89,13 +91,13 @@ func NewDefaultStartOptions(appCreator types.AppCreator, defaultNodeHome string) } // StartCmd runs the service passed in, either stand-alone or in-process with -// Tendermint. +// CometBFT. func StartCmd(opts StartOptions) *cobra.Command { cmd := &cobra.Command{ Use: "start", Short: "Run the full node", - Long: `Run the full node application with Tendermint in or out of process. By -default, the application will run with Tendermint in process. + Long: `Run the full node application with CometBFT in or out of process. By +default, the application will run with CometBFT in process. Pruning options can be provided via the '--pruning' flag or alternatively with '--pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval' together. @@ -136,10 +138,12 @@ which accepts a path for the resulting pprof file. return err } - withTM, _ := cmd.Flags().GetBool(srvflags.WithTendermint) + withTM, _ := cmd.Flags().GetBool(srvflags.WithCometBFT) if !withTM { - serverCtx.Logger.Info("starting ABCI without Tendermint") - return startStandAlone(serverCtx, opts) + serverCtx.Logger.Info("starting ABCI without CometBFT") + return wrapCPUProfile(serverCtx, func() error { + return startStandAlone(serverCtx, opts) + }) } serverCtx.Logger.Info("Unlocking keyring") @@ -153,22 +157,22 @@ which accepts a path for the resulting pprof file. } } - serverCtx.Logger.Info("starting ABCI with Tendermint") + serverCtx.Logger.Info("starting ABCI with CometBFT") // amino is needed here for backwards compatibility of REST routes - err = startInProcess(serverCtx, clientCtx, opts) - errCode, ok := err.(server.ErrorCode) - if !ok { + err = wrapCPUProfile(serverCtx, func() error { + return startInProcess(serverCtx, clientCtx, opts) + }) + if err != nil { return err } - serverCtx.Logger.Debug(fmt.Sprintf("received quit signal: %d", errCode.Code)) return nil }, } cmd.Flags().String(flags.FlagHome, opts.DefaultNodeHome, "The application home directory") - cmd.Flags().Bool(srvflags.WithTendermint, true, "Run abci app embedded in-process with tendermint") + cmd.Flags().Bool(srvflags.WithCometBFT, true, "Run abci app embedded in-process with tendermint") cmd.Flags().String(srvflags.Address, "tcp://0.0.0.0:26658", "Listen address") cmd.Flags().String(srvflags.Transport, "socket", "Transport protocol: socket, grpc") cmd.Flags().String(srvflags.TraceStore, "", "Enable KVStore tracing to an output file") @@ -183,14 +187,13 @@ which accepts a path for the resulting pprof file. cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')") cmd.Flags().Uint64(server.FlagPruningInterval, 0, "Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom')") //nolint:lll cmd.Flags().Uint(server.FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks") - cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks") + cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune CometBFT blocks") cmd.Flags().String(srvflags.AppDBBackend, "", "The type of database for application and snapshots databases") - cmd.Flags().Bool(srvflags.GRPCOnly, false, "Start the node in gRPC query only mode without Tendermint process") + cmd.Flags().Bool(srvflags.GRPCOnly, false, "Start the node in gRPC query only mode without CometBFT process") cmd.Flags().Bool(srvflags.GRPCEnable, true, "Define if the gRPC server should be enabled") cmd.Flags().String(srvflags.GRPCAddress, serverconfig.DefaultGRPCAddress, "the gRPC server address to listen on") cmd.Flags().Bool(srvflags.GRPCWebEnable, true, "Define if the gRPC-Web server should be enabled. (Note: gRPC must also be enabled.)") - cmd.Flags().String(srvflags.GRPCWebAddress, serverconfig.DefaultGRPCWebAddress, "The gRPC-Web server address to listen on") cmd.Flags().Bool(srvflags.RPCEnable, false, "Defines if Cosmos-sdk REST server should be enabled") cmd.Flags().Bool(srvflags.EnabledUnsafeCors, false, "Defines if CORS should be enabled (unsafe - use it at your own risk)") @@ -221,43 +224,48 @@ which accepts a path for the resulting pprof file. cmd.Flags().Uint64(server.FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval") cmd.Flags().Uint32(server.FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep") - // add support for all Tendermint-specific command line options + // add support for all CometBFT-specific command line options tcmd.AddNodeFlags(cmd) return cmd } -func startStandAlone(ctx *server.Context, opts StartOptions) error { - addr := ctx.Viper.GetString(srvflags.Address) - transport := ctx.Viper.GetString(srvflags.Transport) - home := ctx.Viper.GetString(flags.FlagHome) +func startStandAlone(svrCtx *server.Context, opts StartOptions) error { + addr := svrCtx.Viper.GetString(srvflags.Address) + transport := svrCtx.Viper.GetString(srvflags.Transport) + home := svrCtx.Viper.GetString(flags.FlagHome) - db, err := opts.DBOpener(ctx.Viper, home, server.GetAppDBBackend(ctx.Viper)) + db, err := opts.DBOpener(svrCtx.Viper, home, server.GetAppDBBackend(svrCtx.Viper)) if err != nil { return err } defer func() { if err := db.Close(); err != nil { - ctx.Logger.Error("error closing db", "error", err.Error()) + svrCtx.Logger.Error("error closing db", "error", err.Error()) } }() - traceWriterFile := ctx.Viper.GetString(srvflags.TraceStore) + traceWriterFile := svrCtx.Viper.GetString(srvflags.TraceStore) traceWriter, err := openTraceWriter(traceWriterFile) if err != nil { return err } - app := opts.AppCreator(ctx.Logger, db, traceWriter, ctx.Viper) + app := opts.AppCreator(svrCtx.Logger, db, traceWriter, svrCtx.Viper) + defer func() { + if err := app.Close(); err != nil { + svrCtx.Logger.Error("close application failed", "error", err.Error()) + } + }() - config, err := config.GetConfig(ctx.Viper) + config, err := config.GetConfig(svrCtx.Viper) if err != nil { - ctx.Logger.Error("failed to get server config", "error", err.Error()) + svrCtx.Logger.Error("failed to get server config", "error", err.Error()) return err } if err := config.ValidateBasic(); err != nil { - ctx.Logger.Error("invalid server config", "error", err.Error()) + svrCtx.Logger.Error("invalid server config", "error", err.Error()) return err } @@ -266,65 +274,39 @@ func startStandAlone(ctx *server.Context, opts StartOptions) error { return err } - svr, err := abciserver.NewServer(addr, transport, app) + cmtApp := server.NewCometABCIWrapper(app) + svr, err := abciserver.NewServer(addr, transport, cmtApp) if err != nil { return fmt.Errorf("error creating listener: %v", err) } - svr.SetLogger(ctx.Logger.With("server", "abci")) + svr.SetLogger(servercmtlog.CometLoggerWrapper{Logger: svrCtx.Logger.With("server", "abci")}) + g, ctx := getCtx(svrCtx, false) - err = svr.Start() - if err != nil { - tmos.Exit(err.Error()) - } - - defer func() { - if err = svr.Stop(); err != nil { - tmos.Exit(err.Error()) + g.Go(func() error { + if err := svr.Start(); err != nil { + svrCtx.Logger.Error("failed to start out-of-process ABCI server", "err", err) + return err } - if err := app.Close(); err != nil { - tmos.Exit(err.Error()) - } - }() + // Wait for the calling process to be canceled or close the provided context, + // so we can gracefully stop the ABCI server. + <-ctx.Done() + svrCtx.Logger.Info("stopping the ABCI server...") + return svr.Stop() + }) - // Wait for SIGINT or SIGTERM signal - return server.WaitForQuitSignals() + return g.Wait() } // legacyAminoCdc is used for the legacy REST API func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOptions) (err error) { cfg := ctx.Config home := cfg.RootDir - logger := ctx.Logger + logger := svrCtx.Logger + g, ctx := getCtx(svrCtx, true) - if cpuProfile := ctx.Viper.GetString(srvflags.CPUProfile); cpuProfile != "" { - fp, err := ethdebug.ExpandHome(cpuProfile) - if err != nil { - ctx.Logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error()) - return err - } - - f, err := os.Create(fp) - if err != nil { - return err - } - - ctx.Logger.Info("starting CPU profiler", "profile", cpuProfile) - if err := pprof.StartCPUProfile(f); err != nil { - return err - } - - defer func() { - ctx.Logger.Info("stopping CPU profiler", "profile", cpuProfile) - pprof.StopCPUProfile() - if err := f.Close(); err != nil { - logger.Error("failed to close CPU profiler file", "error", err.Error()) - } - }() - } - - db, err := opts.DBOpener(ctx.Viper, home, server.GetAppDBBackend(ctx.Viper)) + db, err := opts.DBOpener(svrCtx.Viper, home, server.GetAppDBBackend(svrCtx.Viper)) if err != nil { logger.Error("failed to open DB", "error", err.Error()) return err @@ -336,7 +318,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt } }() - traceWriterFile := ctx.Viper.GetString(srvflags.TraceStore) + traceWriterFile := svrCtx.Viper.GetString(srvflags.TraceStore) traceWriter, err := openTraceWriter(traceWriterFile) if err != nil { logger.Error("failed to open trace writer", "error", err.Error()) @@ -362,7 +344,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt return err } - genDocProvider := node.DefaultGenesisDocProviderFunc(cfg) + genDocProvider := GenDocProvider(cfg) var ( tmNode *node.Node @@ -370,21 +352,23 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt ) if gRPCOnly { - logger.Info("starting node in query only mode; Tendermint is disabled") + logger.Info("starting node in query only mode; CometBFT is disabled") config.GRPC.Enable = true config.JSONRPC.EnableIndexer = false } else { - logger.Info("starting node with ABCI Tendermint in-process") + logger.Info("starting node with ABCI CometBFT in-process") - tmNode, err = node.NewNode( + cmtApp := server.NewCometABCIWrapper(app) + tmNode, err = node.NewNodeWithContext( + ctx, cfg, pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()), nodeKey, - proxy.NewLocalClientCreator(app), + proxy.NewLocalClientCreator(cmtApp), genDocProvider, - node.DefaultDBProvider, + cmtcfg.DefaultDBProvider, node.DefaultMetricsProvider(cfg.Instrumentation), - ctx.Logger.With("server", "node"), + servercmtlog.CometLoggerWrapper{Logger: svrCtx.Logger.With("server", "node")}, ) if err != nil { logger.Error("failed init node", "error", err.Error()) @@ -412,7 +396,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt app.RegisterTxService(clientCtx) app.RegisterTendermintService(clientCtx) - app.RegisterNodeService(clientCtx) + app.RegisterNodeService(clientCtx, config.Config) } metrics, err := startTelemetry(config) @@ -436,21 +420,12 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt idxLogger := ctx.Logger.With("indexer", "evm") idxer = indexer.NewKVIndexer(idxDB, idxLogger, clientCtx) - indexerService := NewEVMIndexerService(idxer, clientCtx.Client.(rpcclient.Client)) - indexerService.SetLogger(idxLogger) - - errCh := make(chan error) - go func() { - if err := indexerService.Start(); err != nil { - errCh <- err - } - }() + indexerService := NewEVMIndexerService(idxer, clientCtx.Client.(rpcclient.Client), config.JSONRPC.AllowIndexerGap) + indexerService.SetLogger(servercmtlog.CometLoggerWrapper{Logger: idxLogger}) - select { - case err := <-errCh: - return err - case <-time.After(types.ServerStartTime): // assume server started successfully - } + g.Go(func() error { + return indexerService.Start() + }) } if config.API.Enable || config.JSONRPC.Enable { @@ -461,117 +436,24 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt clientCtx = clientCtx. WithHomeDir(home). - WithChainID(genDoc.ChainID) - - // Set `GRPCClient` to `clientCtx` to enjoy concurrent grpc query. - // only use it if gRPC server is enabled. - if config.GRPC.Enable { - _, port, err := net.SplitHostPort(config.GRPC.Address) - if err != nil { - return errorsmod.Wrapf(err, "invalid grpc address %s", config.GRPC.Address) - } - - maxSendMsgSize := config.GRPC.MaxSendMsgSize - if maxSendMsgSize == 0 { - maxSendMsgSize = serverconfig.DefaultGRPCMaxSendMsgSize - } - - maxRecvMsgSize := config.GRPC.MaxRecvMsgSize - if maxRecvMsgSize == 0 { - maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize - } - - grpcAddress := fmt.Sprintf("127.0.0.1:%s", port) - - // If grpc is enabled, configure grpc client for grpc gateway and json-rpc. - grpcClient, err := grpc.Dial( - grpcAddress, - grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithDefaultCallOptions( - grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), - grpc.MaxCallRecvMsgSize(maxRecvMsgSize), - grpc.MaxCallSendMsgSize(maxSendMsgSize), - ), - ) - if err != nil { - return err - } - - clientCtx = clientCtx.WithGRPCClient(grpcClient) - ctx.Logger.Debug("gRPC client assigned to client context", "address", grpcAddress) - } + WithChainID(chainID) } - var apiSrv *api.Server - if config.API.Enable { - apiSrv = api.New(clientCtx, ctx.Logger.With("server", "api")) - app.RegisterAPIRoutes(apiSrv, config.API) - - if config.Telemetry.Enabled { - apiSrv.SetTelemetry(metrics) - } - - errCh := make(chan error) - go func() { - if err := apiSrv.Start(config.Config); err != nil { - errCh <- err - } - }() - - select { - case err := <-errCh: - return err - case <-time.After(types.ServerStartTime): // assume server started successfully - } - - defer apiSrv.Close() + grpcSrv, clientCtx, err := startGrpcServer(ctx, svrCtx, clientCtx, g, config.GRPC, app) + if err != nil { + return err } - - var ( - grpcSrv *grpc.Server - grpcWebSrv *http.Server - ) - - if config.GRPC.Enable { - grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, config.GRPC) - if err != nil { - return err - } - defer grpcSrv.Stop() - if config.GRPCWeb.Enable { - grpcWebSrv, err = servergrpc.StartGRPCWeb(grpcSrv, config.Config) - if err != nil { - ctx.Logger.Error("failed to start grpc-web http server", "error", err.Error()) - return err - } - - defer func() { - if err := grpcWebSrv.Close(); err != nil { - logger.Error("failed to close the grpc-web http server", "error", err.Error()) - } - }() - } + if grpcSrv != nil { + defer grpcSrv.GracefulStop() } - var ( - httpSrv *http.Server - httpSrvDone chan struct{} - ) - - if config.JSONRPC.Enable { - genDoc, err := genDocProvider() - if err != nil { - return err - } - - clientCtx := clientCtx.WithChainID(genDoc.ChainID) + apiSrv := startAPIServer(ctx, svrCtx, clientCtx, g, config.Config, app, grpcSrv, metrics) + if apiSrv != nil { + defer apiSrv.Close() + } - tmEndpoint := "/websocket" - tmRPCAddr := cfg.RPC.ListenAddress - httpSrv, httpSrvDone, err = StartJSONRPC(ctx, clientCtx, tmRPCAddr, tmEndpoint, &config, idxer) - if err != nil { - return err - } + clientCtx, httpSrv, httpSrvDone, err := startJSONRPCServer(svrCtx, clientCtx, g, config, genDocProvider, idxer) + if httpSrv != nil { defer func() { shutdownCtx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second) defer cancelFn() @@ -588,60 +470,14 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt } // At this point it is safe to block the process if we're in query only mode as - // we do not need to start Rosetta or handle any Tendermint related processes. + // we do not need to start Rosetta or handle any CometBFT related processes. if gRPCOnly { // wait for signal capture and gracefully return return server.WaitForQuitSignals() } - var rosettaSrv crgserver.Server - if config.Rosetta.Enable { - offlineMode := config.Rosetta.Offline - - // If GRPC is not enabled rosetta cannot work in online mode, so it works in - // offline mode. - if !config.GRPC.Enable { - offlineMode = true - } - - minGasPrices, err := sdk.ParseDecCoins(config.MinGasPrices) - if err != nil { - ctx.Logger.Error("failed to parse minimum-gas-prices", "error", err.Error()) - return err - } - - conf := &rosetta.Config{ - Blockchain: config.Rosetta.Blockchain, - Network: config.Rosetta.Network, - TendermintRPC: ctx.Config.RPC.ListenAddress, - GRPCEndpoint: config.GRPC.Address, - Addr: config.Rosetta.Address, - Retries: config.Rosetta.Retries, - Offline: offlineMode, - GasToSuggest: config.Rosetta.GasToSuggest, - EnableFeeSuggestion: config.Rosetta.EnableFeeSuggestion, - GasPrices: minGasPrices.Sort(), - Codec: clientCtx.Codec.(*codec.ProtoCodec), - InterfaceRegistry: clientCtx.InterfaceRegistry, - } - - rosettaSrv, err = rosetta.ServerFromConfig(conf) - if err != nil { - return err - } - - errCh := make(chan error) - go func() { - if err := rosettaSrv.Start(); err != nil { - errCh <- err - } - }() - - select { - case err := <-errCh: - return err - case <-time.After(types.ServerStartTime): // assume server started successfully - } + if err := startRosettaServer(svrCtx, clientCtx, g, config); err != nil { + return err } // Wait for SIGINT or SIGTERM signal return server.WaitForQuitSignals() @@ -677,3 +513,212 @@ func startTelemetry(cfg config.Config) (*telemetry.Metrics, error) { } return telemetry.New(cfg.Telemetry) } + +// wrapCPUProfile runs callback in a goroutine, then wait for quit signals. +func wrapCPUProfile(ctx *server.Context, callback func() error) error { + if cpuProfile := ctx.Viper.GetString(srvflags.CPUProfile); cpuProfile != "" { + fp, err := ethdebug.ExpandHome(cpuProfile) + if err != nil { + ctx.Logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error()) + return err + } + f, err := os.Create(fp) + if err != nil { + return err + } + + ctx.Logger.Info("starting CPU profiler", "profile", cpuProfile) + if err := pprof.StartCPUProfile(f); err != nil { + return err + } + + defer func() { + ctx.Logger.Info("stopping CPU profiler", "profile", cpuProfile) + pprof.StopCPUProfile() + if err := f.Close(); err != nil { + ctx.Logger.Info("failed to close cpu-profile file", "profile", cpuProfile, "err", err.Error()) + } + }() + } + + return callback() +} + +func getCtx(svrCtx *server.Context, block bool) (*errgroup.Group, context.Context) { + ctx, cancelFn := context.WithCancel(context.Background()) + g, ctx := errgroup.WithContext(ctx) + // listen for quit signals so the calling parent process can gracefully exit + server.ListenForQuitSignals(g, block, cancelFn, svrCtx.Logger) + return g, ctx +} + +func startGrpcServer( + ctx context.Context, + svrCtx *server.Context, + clientCtx client.Context, + g *errgroup.Group, + config serverconfig.GRPCConfig, + app types.Application, +) (*grpc.Server, client.Context, error) { + if !config.Enable { + // return grpcServer as nil if gRPC is disabled + return nil, clientCtx, nil + } + _, _, err := net.SplitHostPort(config.Address) + if err != nil { + return nil, clientCtx, errorsmod.Wrapf(err, "invalid grpc address %s", config.Address) + } + + maxSendMsgSize := config.MaxSendMsgSize + if maxSendMsgSize == 0 { + maxSendMsgSize = serverconfig.DefaultGRPCMaxSendMsgSize + } + + maxRecvMsgSize := config.MaxRecvMsgSize + if maxRecvMsgSize == 0 { + maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize + } + + // if gRPC is enabled, configure gRPC client for gRPC gateway and json-rpc + grpcClient, err := grpc.Dial( + config.Address, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions( + grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), + grpc.MaxCallRecvMsgSize(maxRecvMsgSize), + grpc.MaxCallSendMsgSize(maxSendMsgSize), + ), + ) + if err != nil { + return nil, clientCtx, err + } + // Set `GRPCClient` to `clientCtx` to enjoy concurrent grpc query. + // only use it if gRPC server is enabled. + clientCtx = clientCtx.WithGRPCClient(grpcClient) + svrCtx.Logger.Debug("gRPC client assigned to client context", "address", config.Address) + + grpcSrv, err := servergrpc.NewGRPCServer(clientCtx, app, config) + if err != nil { + return nil, clientCtx, err + } + + // Start the gRPC server in a goroutine. Note, the provided ctx will ensure + // that the server is gracefully shut down. + g.Go(func() error { + return servergrpc.StartGRPCServer(ctx, svrCtx.Logger.With("module", "grpc-server"), config, grpcSrv) + }) + return grpcSrv, clientCtx, nil +} + +func startAPIServer( + ctx context.Context, + svrCtx *server.Context, + clientCtx client.Context, + g *errgroup.Group, + svrCfg serverconfig.Config, + app types.Application, + grpcSrv *grpc.Server, + metrics *telemetry.Metrics, +) *api.Server { + if !svrCfg.API.Enable { + return nil + } + + apiSrv := api.New(clientCtx, svrCtx.Logger.With("server", "api"), grpcSrv) + app.RegisterAPIRoutes(apiSrv, svrCfg.API) + + if svrCfg.Telemetry.Enabled { + apiSrv.SetTelemetry(metrics) + } + + g.Go(func() error { + return apiSrv.Start(ctx, svrCfg) + }) + return apiSrv +} + +func startJSONRPCServer( + svrCtx *server.Context, + clientCtx client.Context, + g *errgroup.Group, + config config.Config, + genDocProvider node.GenesisDocProvider, + idxer ethermint.EVMTxIndexer, +) (ctx client.Context, httpSrv *http.Server, httpSrvDone chan struct{}, err error) { + ctx = clientCtx + if !config.JSONRPC.Enable { + return + } + + genDoc, err := genDocProvider() + if err != nil { + return ctx, httpSrv, httpSrvDone, err + } + + ctx = clientCtx.WithChainID(genDoc.ChainID) + g.Go(func() error { + httpSrv, httpSrvDone, err = StartJSONRPC(svrCtx, clientCtx, g, &config, idxer) + return err + }) + return +} + +func startRosettaServer( + svrCtx *server.Context, + clientCtx client.Context, + g *errgroup.Group, + config config.Config, +) error { + if !config.Rosetta.Enable { + return nil + } + + offlineMode := config.Rosetta.Offline + + // If GRPC is not enabled rosetta cannot work in online mode, so it works in + // offline mode. + if !config.GRPC.Enable { + offlineMode = true + } + + minGasPrices, err := sdk.ParseDecCoins(config.MinGasPrices) + if err != nil { + svrCtx.Logger.Error("failed to parse minimum-gas-prices", "error", err.Error()) + return err + } + + conf := &rosetta.Config{ + Blockchain: config.Rosetta.Blockchain, + Network: config.Rosetta.Network, + TendermintRPC: svrCtx.Config.RPC.ListenAddress, + GRPCEndpoint: config.GRPC.Address, + Addr: config.Rosetta.Addr, + Retries: config.Rosetta.Retries, + Offline: offlineMode, + GasToSuggest: config.Rosetta.GasToSuggest, + EnableFeeSuggestion: config.Rosetta.EnableFeeSuggestion, + GasPrices: minGasPrices.Sort(), + Codec: clientCtx.Codec.(*codec.ProtoCodec), + InterfaceRegistry: clientCtx.InterfaceRegistry, + } + + rosettaSrv, err := rosetta.ServerFromConfig(conf) + if err != nil { + return err + } + + g.Go(rosettaSrv.Start) + return nil +} + +// returns a function which returns the genesis doc from the genesis file. +func GenDocProvider(cfg *cmtcfg.Config) func() (*cmttypes.GenesisDoc, error) { + return func() (*cmttypes.GenesisDoc, error) { + appGenesis, err := genutiltypes.AppGenesisFromFile(cfg.GenesisFile()) + if err != nil { + return nil, err + } + + return appGenesis.ToGenesisDoc() + } +} diff --git a/server/util.go b/server/util.go index 7e265738..113d5d78 100644 --- a/server/util.go +++ b/server/util.go @@ -30,9 +30,8 @@ import ( "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/version" - tcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" - tmlog "github.com/cometbft/cometbft/libs/log" - rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" + tmlog "cosmossdk.io/log" + cmtcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" ) // AddCommands adds server commands @@ -42,18 +41,20 @@ func AddCommands( appExport types.AppExporter, addStartFlags types.ModuleInitFlags, ) { - tendermintCmd := &cobra.Command{ - Use: "tendermint", - Short: "Tendermint subcommands", + cometCmd := &cobra.Command{ + Use: "comet", + Aliases: []string{"cometbft", "tendermint"}, + Short: "CometBFT subcommands", } - tendermintCmd.AddCommand( + cometCmd.AddCommand( sdkserver.ShowNodeIDCmd(), sdkserver.ShowValidatorCmd(), sdkserver.ShowAddressCmd(), sdkserver.VersionCmd(), - tcmd.ResetAllCmd, - tcmd.ResetStateCmd, + cmtcmd.ResetAllCmd, + cmtcmd.ResetStateCmd, + sdkserver.BootstrapStateCmd(opts.AppCreator), ) startCmd := StartCmd(opts) @@ -61,7 +62,7 @@ func AddCommands( rootCmd.AddCommand( startCmd, - tendermintCmd, + cometCmd, sdkserver.ExportCmd(appExport, opts.DefaultNodeHome), version.NewVersionCommand(), sdkserver.NewRollbackCmd(opts.AppCreator, opts.DefaultNodeHome), diff --git a/store/cachekv/benchmark_test.go b/store/cachekv/benchmark_test.go index 7f4ab935..0bad322e 100644 --- a/store/cachekv/benchmark_test.go +++ b/store/cachekv/benchmark_test.go @@ -4,8 +4,9 @@ import ( fmt "fmt" "testing" - dbm "github.com/cometbft/cometbft-db" - "github.com/cosmos/cosmos-sdk/store/dbadapter" + "cosmossdk.io/store/dbadapter" + dbm "github.com/cosmos/cosmos-db" + "github.com/evmos/ethermint/store/cachekv" "github.com/stretchr/testify/require" "github.com/zeta-chain/ethermint/store/cachekv" ) diff --git a/store/cachekv/internal/btree.go b/store/cachekv/internal/btree.go index 644bcf1b..76e6888b 100644 --- a/store/cachekv/internal/btree.go +++ b/store/cachekv/internal/btree.go @@ -4,7 +4,7 @@ import ( "bytes" "errors" - "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/store/types" "github.com/tidwall/btree" ) diff --git a/store/cachekv/internal/btree_test.go b/store/cachekv/internal/btree_test.go index bd19449b..d43b4fa4 100644 --- a/store/cachekv/internal/btree_test.go +++ b/store/cachekv/internal/btree_test.go @@ -3,7 +3,7 @@ package internal import ( "testing" - "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) diff --git a/store/cachekv/internal/memiterator.go b/store/cachekv/internal/memiterator.go index d1b98bd5..de8db073 100644 --- a/store/cachekv/internal/memiterator.go +++ b/store/cachekv/internal/memiterator.go @@ -4,7 +4,7 @@ import ( "bytes" "errors" - "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/store/types" "github.com/tidwall/btree" ) diff --git a/store/cachekv/internal/mergeiterator.go b/store/cachekv/internal/mergeiterator.go index 293bc968..e4d80ab4 100644 --- a/store/cachekv/internal/mergeiterator.go +++ b/store/cachekv/internal/mergeiterator.go @@ -4,7 +4,7 @@ import ( "bytes" "errors" - "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/store/types" ) // cacheMergeIterator merges a parent Iterator and a cache Iterator. diff --git a/store/cachekv/store.go b/store/cachekv/store.go index 748dff2e..9e809d49 100644 --- a/store/cachekv/store.go +++ b/store/cachekv/store.go @@ -4,9 +4,9 @@ import ( "io" "sync" - "github.com/cosmos/cosmos-sdk/store/tracekv" - "github.com/cosmos/cosmos-sdk/store/types" - "github.com/zeta-chain/ethermint/store/cachekv/internal" + "cosmossdk.io/store/tracekv" + "cosmossdk.io/store/types" + "github.com/evmos/ethermint/store/cachekv/internal" ) // Store wraps an in-memory cache around an underlying types.KVStore. diff --git a/store/cachekv/store_bench_test.go b/store/cachekv/store_bench_test.go index b5151477..9e7ece49 100644 --- a/store/cachekv/store_bench_test.go +++ b/store/cachekv/store_bench_test.go @@ -3,10 +3,10 @@ package cachekv_test import ( "testing" - dbm "github.com/cometbft/cometbft-db" + dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/cosmos-sdk/store/dbadapter" - "github.com/zeta-chain/ethermint/store/cachekv" + "cosmossdk.io/store/dbadapter" + "github.com/evmos/ethermint/store/cachekv" ) var sink interface{} diff --git a/store/cachekv/store_test.go b/store/cachekv/store_test.go index cd71bd52..23dfe172 100644 --- a/store/cachekv/store_test.go +++ b/store/cachekv/store_test.go @@ -4,12 +4,12 @@ import ( "fmt" "testing" - dbm "github.com/cometbft/cometbft-db" + dbm "github.com/cosmos/cosmos-db" tmrand "github.com/cometbft/cometbft/libs/rand" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/store/dbadapter" - "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/store/dbadapter" + "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/ethermint/store/cachekv" ) diff --git a/store/cachemulti/store.go b/store/cachemulti/store.go index 48abde51..2a78c8ad 100644 --- a/store/cachemulti/store.go +++ b/store/cachemulti/store.go @@ -4,9 +4,9 @@ import ( "fmt" "io" - "github.com/cosmos/cosmos-sdk/store/tracekv" - "github.com/cosmos/cosmos-sdk/store/types" - "github.com/zeta-chain/ethermint/store/cachekv" + "cosmossdk.io/store/tracekv" + "cosmossdk.io/store/types" + "github.com/evmos/ethermint/store/cachekv" ) // storeNameCtxKey is the TraceContext metadata key that identifies diff --git a/store/cachemulti/store_test.go b/store/cachemulti/store_test.go index 57113ee0..c262bf1d 100644 --- a/store/cachemulti/store_test.go +++ b/store/cachemulti/store_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/ethermint/store/cachekv" - "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/store/types" ) func TestStoreGetKVStore(t *testing.T) { diff --git a/tests/importer/importer_test.go b/tests/importer/importer_test.go index 3c3bd4de..b0dc26c8 100644 --- a/tests/importer/importer_test.go +++ b/tests/importer/importer_test.go @@ -8,9 +8,8 @@ import ( "testing" "time" - "github.com/holiman/uint256" - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/types" + sdkmath "cosmossdk.io/math" + "github.com/evmos/ethermint/app" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -29,7 +28,7 @@ import ( ethparams "github.com/ethereum/go-ethereum/params" ethrlp "github.com/ethereum/go-ethereum/rlp" - abcitypes "github.com/cometbft/cometbft/abci/types" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/tmhash" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmversion "github.com/cometbft/cometbft/proto/tendermint/version" @@ -65,7 +64,7 @@ func (suite *ImporterTestSuite) DoSetupTest(t require.TestingT) { priv, err := ethsecp256k1.GenerateKey() require.NoError(t, err) consAddress := sdk.ConsAddress(priv.PubKey().Address()) - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{ + suite.ctx = suite.app.BaseApp.NewUncachedContext(checkTx, tmproto.Header{ Height: 1, ChainID: "ethermint_9000-1", Time: time.Now().UTC(), @@ -87,7 +86,7 @@ func (suite *ImporterTestSuite) DoSetupTest(t require.TestingT) { NextValidatorsHash: tmhash.Sum([]byte("next_validators")), ConsensusHash: tmhash.Sum([]byte("consensus")), LastResultsHash: tmhash.Sum([]byte("last_result")), - }) + }).WithConsensusParams(*app.DefaultConsensusParams) } func (suite *ImporterTestSuite) SetupTest() { @@ -136,12 +135,9 @@ func (suite *ImporterTestSuite) TestImportBlocks() { tmheader := suite.ctx.BlockHeader() // fix due to that begin block can't have height 0 tmheader.Height = int64(block.NumberU64()) + 1 - suite.app.BeginBlock(abcitypes.RequestBeginBlock{ - Header: tmheader, - }) - ctx := suite.app.NewContext(false, tmheader) - ctx = ctx.WithBlockHeight(tmheader.Height) - vmdb := statedb.New(ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) + ctx := suite.app.NewUncachedContext(false, tmheader).WithConsensusParams(*app.DefaultConsensusParams) + suite.app.BeginBlocker(ctx) + vmdb := statedb.New(ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash()))) if chainConfig.DAOForkSupport && chainConfig.DAOForkBlock != nil && chainConfig.DAOForkBlock.Cmp(block.Number()) == 0 { applyDAOHardFork(vmdb) @@ -160,8 +156,13 @@ func (suite *ImporterTestSuite) TestImportBlocks() { accumulateRewards(chainConfig, vmdb, header, block.Uncles()) // simulate BaseApp EndBlocker commitment - endBR := abcitypes.RequestEndBlock{Height: tmheader.Height} - suite.app.EndBlocker(ctx, endBR) + suite.app.EndBlocker(ctx) + if _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: suite.app.LastBlockHeight() + 1, + Hash: suite.app.LastCommitID().Hash, + }); err != nil { + panic(err) + } suite.app.Commit() // block debugging output @@ -231,7 +232,7 @@ func applyTransaction( gp *ethcore.GasPool, evmKeeper *evmkeeper.Keeper, vmdb *statedb.StateDB, header *ethtypes.Header, tx *ethtypes.Transaction, usedGas *uint64, cfg ethvm.Config, ) (*ethtypes.Receipt, uint64, error) { - msg, err := ethcore.TransactionToMessage(tx, types.MakeSigner(config, header.Number), sdk.ZeroInt().BigInt()) + msg, err := ethcore.TransactionToMessage(tx, ethtypes.MakeSigner(config, header.Number), sdkmath.ZeroInt().BigInt()) if err != nil { return nil, 0, err } diff --git a/tests/integration_tests/configs/broken-ethermintd.patch b/tests/integration_tests/configs/broken-ethermintd.patch index 255e9949..20a9a9c2 100644 --- a/tests/integration_tests/configs/broken-ethermintd.patch +++ b/tests/integration_tests/configs/broken-ethermintd.patch @@ -1,15 +1,15 @@ diff --git a/app/app.go b/app/app.go -index 158bf7a3..a3b5718c 100644 +index d19a465d..f0e63d30 100644 --- a/app/app.go +++ b/app/app.go -@@ -681,6 +681,10 @@ func (app *EthermintApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBloc +@@ -861,6 +861,10 @@ func (app *EthermintApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { // EndBlocker updates every end block - func (app *EthermintApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { + func (app *EthermintApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + if ctx.BlockHeight()%10 == 0 { + store := ctx.KVStore(app.keys["evm"]) + store.Set([]byte("hello"), []byte("world")) + } - return app.mm.EndBlock(ctx, req) + return app.ModuleManager.EndBlock(ctx) } diff --git a/tests/integration_tests/configs/cosmovisor.jsonnet b/tests/integration_tests/configs/cosmovisor.jsonnet index dc3cb1a4..4630f9a5 100644 --- a/tests/integration_tests/configs/cosmovisor.jsonnet +++ b/tests/integration_tests/configs/cosmovisor.jsonnet @@ -6,12 +6,23 @@ config { 'minimum-gas-prices': '100000000000aphoton', }, genesis+: { + consensus_params: { + block: { + max_bytes: '1048576', + max_gas: '81500000', + }, + }, app_state+: { feemarket+: { params+: { base_fee:: super.base_fee, }, }, + gov+: { + params+: { + expedited_voting_period:: super.expedited_voting_period, + }, + }, }, }, }, diff --git a/tests/integration_tests/configs/default.jsonnet b/tests/integration_tests/configs/default.jsonnet index 8dca8f3c..94d2ada6 100644 --- a/tests/integration_tests/configs/default.jsonnet +++ b/tests/integration_tests/configs/default.jsonnet @@ -3,12 +3,6 @@ 'ethermint_9000-1': { cmd: 'ethermintd', 'start-flags': '--trace', - config: { - mempool: { - // use v1 mempool to enable tx prioritization - version: 'v1', - }, - }, 'app-config': { 'minimum-gas-prices': '0aphoton', 'index-events': ['ethereum_tx.ethereumTxHash'], @@ -27,7 +21,7 @@ staked: '1000000000000000000stake', mnemonic: mnemonic, client_config: { - 'broadcast-mode': 'block', + 'broadcast-mode': 'sync', }, } for mnemonic in ['${VALIDATOR1_MNEMONIC}', '${VALIDATOR2_MNEMONIC}']], accounts: [{ @@ -44,10 +38,15 @@ mnemonic: '${SIGNER2_MNEMONIC}', }], genesis: { - consensus_params: { - block: { - max_bytes: '1048576', - max_gas: '81500000', + consensus: { + params: { + block: { + max_bytes: '1048576', + max_gas: '81500000', + }, + abci: { + vote_extensions_enable_height: '1', + }, }, }, app_state: { @@ -57,7 +56,8 @@ }, }, gov: { - voting_params: { + params: { + expedited_voting_period: '1s', voting_period: '10s', }, deposit_params: { diff --git a/tests/integration_tests/configs/upgrade-test-package.nix b/tests/integration_tests/configs/upgrade-test-package.nix index d40d42cf..e356e7a1 100644 --- a/tests/integration_tests/configs/upgrade-test-package.nix +++ b/tests/integration_tests/configs/upgrade-test-package.nix @@ -1,16 +1,16 @@ let pkgs = import ../../../nix { }; - fetchEthermint = rev: builtins.fetchTarball "https://github.com/zeta-chain/ethermint/archive/${rev}.tar.gz"; - released = pkgs.buildGo119Module rec { - name = "ethermintd"; - src = fetchEthermint "5db67f17e6a0a87ea580841be0266f898e3d63d9"; - subPackages = [ "cmd/ethermintd" ]; - vendorSha256 = "sha256-6EHCw0/Lo1JfDOEfsn/NufRco0zgebCo0hwwm5wJoFU="; - doCheck = false; - }; + fetchFlake = repo: rev: (pkgs.flake-compat { + src = { + outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; + inherit rev; + shortRev = builtins.substring 0 7 rev; + }; + }).defaultNix; + released = (fetchFlake "crypto-org-chain/ethermint" "b216a320ac6a60b019c1cbe5a6b730856482f071").default; current = pkgs.callPackage ../../../. { }; in pkgs.linkFarm "upgrade-test-package" [ { name = "genesis"; path = released; } - { name = "integration-test-upgrade"; path = current; } + { name = "sdk50"; path = current; } ] diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py index bd3f66fd..bc5a0b4d 100644 --- a/tests/integration_tests/conftest.py +++ b/tests/integration_tests/conftest.py @@ -15,9 +15,7 @@ def geth(tmp_path_factory): yield from setup_geth(path, 8545) -@pytest.fixture( - scope="session", params=["ethermint", "ethermint-ws"] -) +@pytest.fixture(scope="session", params=["ethermint", "ethermint-ws"]) def ethermint_rpc_ws(request, ethermint): """ run on both ethermint and ethermint websocket diff --git a/tests/integration_tests/cosmoscli.py b/tests/integration_tests/cosmoscli.py index 375a0bcc..693aa436 100644 --- a/tests/integration_tests/cosmoscli.py +++ b/tests/integration_tests/cosmoscli.py @@ -5,6 +5,8 @@ from dateutil.parser import isoparse from pystarport.utils import build_cli_args_safe, interact +from .utils import get_sync_info + DEFAULT_GAS_PRICE = "5000000000000aphoton" DEFAULT_GAS = "250000" @@ -130,10 +132,10 @@ def status(self): return json.loads(self.raw("status", node=self.node_rpc)) def block_height(self): - return int(self.status()["SyncInfo"]["latest_block_height"]) + return int(get_sync_info(self.status())["latest_block_height"]) def block_time(self): - return isoparse(self.status()["SyncInfo"]["latest_block_time"]) + return isoparse(get_sync_info(self.status())["latest_block_time"]) def balances(self, addr): return json.loads( @@ -273,17 +275,16 @@ def validators(self): ) )["validators"] - def staking_params(self): - return json.loads( - self.raw("query", "staking", "params", output="json", node=self.node_rpc) - ) + def get_params(self, module, **kwargs): + kwargs.setdefault("node", self.node_rpc) + kwargs.setdefault("output", "json") + return json.loads(self.raw("query", module, "params", **kwargs)) def staking_pool(self, bonded=True): - return int( - json.loads( - self.raw("query", "staking", "pool", output="json", node=self.node_rpc) - )["bonded_tokens" if bonded else "not_bonded_tokens"] - ) + res = self.raw("query", "staking", "pool", output="json", node=self.node_rpc) + res = json.loads(res) + res = res.get("pool") or res + return int(res["bonded_tokens" if bonded else "not_bonded_tokens"]) def transfer(self, from_, to, coins, generate_only=False, **kwargs): kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) @@ -636,9 +637,10 @@ def edit_validator( ) ) - def gov_propose(self, proposer, kind, proposal, **kwargs): - method = "submit-proposal" + def gov_propose_legacy(self, proposer, kind, proposal, **kwargs): + method = "submit-legacy-proposal" kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) + kwargs.setdefault("gas", DEFAULT_GAS) if kind == "software-upgrade": return json.loads( self.raw( @@ -648,6 +650,7 @@ def gov_propose(self, proposer, kind, proposal, **kwargs): kind, proposal["name"], "-y", + "--no-validate", from_=proposer, # content title=proposal.get("title"), @@ -700,7 +703,8 @@ def gov_propose(self, proposer, kind, proposal, **kwargs): def gov_vote(self, voter, proposal_id, option, **kwargs): kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) - return json.loads( + kwargs.setdefault("broadcast_mode", "sync") + rsp = json.loads( self.raw( "tx", "gov", @@ -713,6 +717,9 @@ def gov_vote(self, voter, proposal_id, option, **kwargs): **kwargs, ) ) + if rsp["code"] == 0: + rsp = self.event_query_tx_for(rsp["txhash"]) + return rsp def gov_deposit(self, depositor, proposal_id, amount): return json.loads( @@ -747,7 +754,7 @@ def query_proposals(self, depositor=None, limit=None, status=None, voter=None): ) def query_proposal(self, proposal_id): - return json.loads( + res = json.loads( self.raw( "query", "gov", @@ -757,6 +764,7 @@ def query_proposal(self, proposal_id): node=self.node_rpc, ) ) + return res.get("proposal") or res def query_tally(self, proposal_id): return json.loads( diff --git a/tests/integration_tests/network.py b/tests/integration_tests/network.py index c638e2a5..978ef500 100644 --- a/tests/integration_tests/network.py +++ b/tests/integration_tests/network.py @@ -9,7 +9,7 @@ from web3.middleware import geth_poa_middleware from .cosmoscli import CosmosCLI -from .utils import wait_for_port +from .utils import supervisorctl, w3_wait_for_block, wait_for_port DEFAULT_CHAIN_BINARY = "ethermintd" @@ -133,9 +133,11 @@ def setup_custom_ethermint( if wait_port: wait_for_port(ports.evmrpc_port(base_port)) wait_for_port(ports.evmrpc_ws_port(base_port)) - yield Ethermint( + e = Ethermint( path / "ethermint_9000-1", chain_binary=chain_binary or DEFAULT_CHAIN_BINARY ) + w3_wait_for_block(e.w3, 1) + yield e finally: os.killpg(os.getpgid(proc.pid), signal.SIGTERM) proc.wait() diff --git a/tests/integration_tests/test_account.py b/tests/integration_tests/test_account.py index 88fbe87f..b18028f7 100644 --- a/tests/integration_tests/test_account.py +++ b/tests/integration_tests/test_account.py @@ -11,20 +11,14 @@ def custom_ethermint(tmp_path_factory): yield from setup_ethermint(path, 26700, long_timeout_commit=True) -@pytest.fixture(scope="module", params=["ethermint", "ethermint-ws", "geth"]) -def cluster(request, custom_ethermint, geth): +@pytest.fixture(scope="module", params=["ethermint"]) +def cluster(request, custom_ethermint): """ run on ethermint, ethermint websocket and geth """ provider = request.param if provider == "ethermint": yield custom_ethermint - elif provider == "ethermint-ws": - ethermint_ws = custom_ethermint.copy() - ethermint_ws.use_websocket() - yield ethermint_ws - elif provider == "geth": - yield geth else: raise NotImplementedError diff --git a/tests/integration_tests/test_fee_history.py b/tests/integration_tests/test_fee_history.py index 7dde9c18..9c619a58 100644 --- a/tests/integration_tests/test_fee_history.py +++ b/tests/integration_tests/test_fee_history.py @@ -3,8 +3,17 @@ import pytest from web3 import Web3 -from .network import setup_ethermint -from .utils import ADDRS, send_transaction +from .network import setup_custom_ethermint +from .utils import ( + ADDRS, + approve_proposal, + eth_to_bech32, + send_transaction, + w3_wait_for_block, + w3_wait_for_new_blocks, +) + +NEW_BASE_FEE = 100000000000 @pytest.fixture(scope="module") @@ -29,6 +38,8 @@ def cluster(request, custom_ethermint, geth): def test_basic(cluster): w3: Web3 = cluster.w3 + # need at least 5 blocks + w3_wait_for_block(w3, 5) call = w3.provider.make_request tx = {"to": ADDRS["community"], "value": 10, "gasPrice": w3.eth.gas_price} send_transaction(w3, tx) @@ -71,3 +82,182 @@ def test_basic(cluster): assert len(res[field]) == target oldest = i + min - max assert res["oldestBlock"] == hex(oldest if oldest > 0 else 0) + + +def test_change(cluster): + w3: Web3 = cluster.w3 + call = w3.provider.make_request + tx = {"to": ADDRS["community"], "value": 10, "gasPrice": w3.eth.gas_price} + send_transaction(w3, tx) + size = 4 + method = "eth_feeHistory" + field = "baseFeePerGas" + percentiles = [100] + for b in ["latest", hex(w3.eth.block_number)]: + history0 = call(method, [size, b, percentiles])["result"][field] + w3_wait_for_new_blocks(w3, 2, 0.1) + history1 = call(method, [size, b, percentiles])["result"][field] + if b == "latest": + assert history1 != history0 + else: + assert history1 == history0 + + +def adjust_base_fee(parent_fee, gas_limit, gas_used, params): + "spec: https://eips.ethereum.org/EIPS/eip-1559#specification" + change_denominator = params["base_fee_change_denominator"] + elasticity_multiplier = params["elasticity_multiplier"] + gas_target = gas_limit // elasticity_multiplier + if gas_used == gas_target: + return parent_fee + delta = parent_fee * abs(gas_target - gas_used) // gas_target // change_denominator + # https://github.com/crypto-org-chain/ethermint/blob/develop/x/feemarket/keeper/eip1559.go#L104 + if gas_target > gas_used: + return max(parent_fee - delta, int(float(params["min_gas_price"]))) + else: + return parent_fee + max(delta, 1) + + +def test_next(cluster, custom_ethermint): + def params_fn(height): + if cluster == custom_ethermint: + return cluster.cosmos_cli().get_params("feemarket", height=height)["params"] + return { + "elasticity_multiplier": 2, + "base_fee_change_denominator": 8, + "min_gas_price": 0, + } + + w3: Web3 = cluster.w3 + call = w3.provider.make_request + tx = {"to": ADDRS["community"], "value": 10, "gasPrice": w3.eth.gas_price} + send_transaction(w3, tx) + assert_histories(w3, call, w3.eth.block_number, params_fn, percentiles=[100]) + + +def test_beyond_head(cluster): + end = hex(0x7FFFFFFFFFFFFFFF) + res = cluster.w3.provider.make_request("eth_feeHistory", [4, end, []]) + msg = f"request beyond head block: requested {int(end, 16)}" + assert msg in res["error"]["message"] + + +def test_percentiles(cluster): + w3: Web3 = cluster.w3 + call = w3.provider.make_request + method = "eth_feeHistory" + percentiles = [[-1], [101], [2, 1]] + size = 4 + msg = "invalid reward percentile" + with ThreadPoolExecutor(len(percentiles)) as exec: + tasks = [exec.submit(call, method, [size, "latest", p]) for p in percentiles] + result = [future.result() for future in as_completed(tasks)] + assert all(msg in res["error"]["message"] for res in result) + + +def update_feemarket_param(node, tmp_path, new_multiplier=2, new_denominator=200000000): + cli = node.cosmos_cli() + p = cli.get_params("feemarket")["params"] + new_base_fee = f"{NEW_BASE_FEE}" + p["base_fee"] = new_base_fee + p["elasticity_multiplier"] = new_multiplier + p["base_fee_change_denominator"] = new_denominator + proposal = tmp_path / "proposal.json" + # governance module account as signer + data = hashlib.sha256("gov".encode()).digest()[:20] + signer = eth_to_bech32(data) + proposal_src = { + "messages": [ + { + "@type": "/ethermint.feemarket.v1.MsgUpdateParams", + "authority": signer, + "params": p, + } + ], + "deposit": "2aphoton", + "title": "title", + "summary": "summary", + } + proposal.write_text(json.dumps(proposal_src)) + rsp = cli.submit_gov_proposal(proposal, from_="community") + assert rsp["code"] == 0, rsp["raw_log"] + approve_proposal(node, rsp, status=3) + print("check params have been updated now") + p = cli.get_params("feemarket")["params"] + assert p["base_fee"] == new_base_fee + assert p["elasticity_multiplier"] == new_multiplier + assert p["base_fee_change_denominator"] == new_denominator + + +def test_concurrent(custom_ethermint, tmp_path): + w3: Web3 = custom_ethermint.w3 + tx = {"to": ADDRS["community"], "value": 10, "gasPrice": w3.eth.gas_price} + # send multi txs, overlap happens with query with 2nd tx's block number + send_transaction(w3, tx) + receipt1 = send_transaction(w3, tx) + b1 = receipt1.blockNumber + send_transaction(w3, tx) + call = w3.provider.make_request + field = "baseFeePerGas" + update_feemarket_param(custom_ethermint, tmp_path) + percentiles = [] + method = "eth_feeHistory" + # big enough concurrent requests to trigger overwrite bug + total = 10 + size = 2 + params = [size, hex(b1), percentiles] + res = [] + with ThreadPoolExecutor(total) as exec: + t = [exec.submit(call, method, params) for i in range(total)] + res = [future.result()["result"][field] for future in as_completed(t)] + assert all(sublist == res[0] for sublist in res), res + + +def assert_histories(w3, call, blk, params_fn, percentiles=[]): + method = "eth_feeHistory" + field = "baseFeePerGas" + expected = [] + blocks = [] + histories = [] + for i in range(3): + b = blk + i + blocks.append(b) + history = tuple(call(method, [1, hex(b), percentiles])["result"][field]) + histories.append(history) + w3_wait_for_new_blocks(w3, 1, 0.1) + blocks.append(b + 1) + + for b in blocks: + next_base_price = w3.eth.get_block(b).baseFeePerGas + prev = b - 1 + blk = w3.eth.get_block(prev) + base_fee = blk.baseFeePerGas + params = params_fn(prev) + res = adjust_base_fee( + base_fee, + blk.gasLimit, + blk.gasUsed, + params, + ) + if abs(next_base_price - res) == 1: + next_base_price = res + elif next_base_price != NEW_BASE_FEE: + assert next_base_price == res + expected.append(hex(next_base_price)) + assert histories == list(zip(expected, expected[1:])) + + +def test_param_change(custom_ethermint, tmp_path): + def params_fn(height): + cli = custom_ethermint.cosmos_cli() + return cli.get_params("feemarket", height=height)["params"] + + w3: Web3 = custom_ethermint.w3 + old_blk = w3.eth.block_number + update_feemarket_param(custom_ethermint, tmp_path) + call = w3.provider.make_request + assert_histories(w3, call, old_blk, params_fn) + tx = {"to": ADDRS["community"], "value": 10, "gasPrice": w3.eth.gas_price} + receipt = send_transaction(w3, tx) + new_blk = receipt.blockNumber + assert_histories(w3, call, new_blk, params_fn) diff --git a/tests/integration_tests/test_priority.py b/tests/integration_tests/test_priority.py index c505f7a5..b899fcf2 100644 --- a/tests/integration_tests/test_priority.py +++ b/tests/integration_tests/test_priority.py @@ -193,9 +193,10 @@ def test_native_tx_priority(ethermint): print(tx_indexes) # the first sent tx are included later, because of lower priority # ensure desc within continuous block - assert all(( - b1 < b2 or (b1 == b2 and i1 > i2) - ) for (b1, i1), (b2, i2) in zip(tx_indexes, tx_indexes[1:])) + assert all( + (b1 < b2 or (b1 == b2 and i1 > i2)) + for (b1, i1), (b2, i2) in zip(tx_indexes, tx_indexes[1:]) + ) def get_max_priority_price(max_priority_price): diff --git a/tests/integration_tests/test_storage_proof.py b/tests/integration_tests/test_storage_proof.py index 01a9d5c9..8249b5cb 100644 --- a/tests/integration_tests/test_storage_proof.py +++ b/tests/integration_tests/test_storage_proof.py @@ -1,7 +1,7 @@ import pytest from .network import setup_ethermint -from .utils import CONTRACTS, deploy_contract +from .utils import CONTRACTS, deploy_contract, w3_wait_for_block @pytest.fixture(scope="module") @@ -25,6 +25,8 @@ def cluster(request, custom_ethermint, geth): def test_basic(cluster): + w3_wait_for_block(cluster.w3, 3) + # proof queries at height <= 2 are not supported' _, res = deploy_contract( cluster.w3, CONTRACTS["StateContract"], diff --git a/tests/integration_tests/test_tracers.py b/tests/integration_tests/test_tracers.py index 7b30c978..c8f73fda 100644 --- a/tests/integration_tests/test_tracers.py +++ b/tests/integration_tests/test_tracers.py @@ -26,10 +26,12 @@ def test_tracers(ethermint_rpc_ws): tx_res = eth_rpc.make_request("debug_traceTransaction", [tx_hash]) assert tx_res["result"] == EXPECTED_STRUCT_TRACER, "" - tx_res = eth_rpc.make_request( - "debug_traceTransaction", [tx_hash, {"tracer": "callTracer"}] - ) - assert tx_res["result"] == EXPECTED_CALLTRACERS, "" + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == EXPECTED_CONTRACT_CREATE_TRACER, res tx_res = eth_rpc.make_request( "debug_traceTransaction", @@ -45,8 +47,449 @@ def test_tracers(ethermint_rpc_ws): w3_wait_for_new_blocks(w3, 1) - tx_res = eth_rpc.make_request( - "debug_traceTransaction", [tx_hash, {"tracer": "callTracer"}] +def test_trace_tx(ethermint, geth): + method = "debug_traceTransaction" + tracer = {"tracer": "callTracer"} + tracers = [ + [], + [tracer], + [tracer | {"tracerConfig": {"onlyTopCall": True}}], + [tracer | {"tracerConfig": {"withLog": True}}], + [tracer | {"tracerConfig": {"diffMode": True}}], + ] + iterations = 1 + acc = derive_random_account() + + def process(w3): + # fund new sender to deploy contract with same address + fund_acc(w3, acc) + contract, _ = deploy_contract(w3, CONTRACTS["TestMessageCall"], key=acc.key) + tx = contract.functions.test(iterations).build_transaction() + tx_hash = send_transaction(w3, tx)["transactionHash"].hex() + res = [] + call = w3.provider.make_request + with ThreadPoolExecutor(len(tracers)) as exec: + params = [([tx_hash] + cfg) for cfg in tracers] + exec_map = exec.map(call, itertools.repeat(method), params) + res = [json.dumps(resp["result"], sort_keys=True) for resp in exec_map] + return res + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1], res + + +def test_tracecall_insufficient_funds(ethermint, geth): + method = "debug_traceCall" + acc = derive_random_account() + sender = acc.address + receiver = ADDRS["community"] + value = hex(100) + gas = hex(21000) + + def process(w3): + fund_acc(w3, acc) + # Insufficient funds + tx = { + # an non-exist address + "from": "0x1000000000000000000000000000000000000000", + "to": receiver, + "value": value, + "gasPrice": hex(w3.eth.gas_price), + "gas": gas, + } + call = w3.provider.make_request + tracers = ["prestateTracer", "callTracer"] + with ThreadPoolExecutor(len(tracers)) as exec: + params = [([tx, "latest", {"tracer": tracer}]) for tracer in tracers] + for resp in exec.map(call, itertools.repeat(method), params): + assert "error" in resp + assert "insufficient" in resp["error"]["message"], resp["error"] + + tx = {"from": sender, "to": receiver, "value": value, "gas": gas} + tracer = {"tracer": "callTracer"} + tracers = [ + [], + [tracer], + [tracer | {"tracerConfig": {"onlyTopCall": True}}], + ] + res = [] + with ThreadPoolExecutor(len(tracers)) as exec: + params = [([tx, "latest"] + cfg) for cfg in tracers] + exec_map = exec.map(call, itertools.repeat(method), params) + res = [json.dumps(resp["result"], sort_keys=True) for resp in exec_map] + return res + + providers = [ethermint.w3, geth.w3] + expected = json.dumps(EXPECTED_CALLTRACERS | {"from": sender.lower()}) + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert ( + res[0] + == res[-1] + == [ + json.dumps(EXPECTED_STRUCT_TRACER), + expected, + expected, + ] + ), res + + +def test_js_tracers(ethermint, geth): + method = "debug_traceCall" + acc = derive_new_account(n=2) + sender = acc.address + + def process(w3): + # fund new sender to deploy contract with same address + fund_acc(w3, acc) + contract, _ = deploy_contract(w3, CONTRACTS["Greeter"], key=acc.key) + tx = contract.functions.setGreeting("world").build_transaction() + tx = {"from": sender, "to": contract.address, "data": tx["data"]} + # https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers#js-tracers + tracers = [ + "bigramTracer", + "evmdisTracer", + "opcountTracer", + "trigramTracer", + "unigramTracer", + """{ + data: [], + fault: function(log) {}, + step: function(log) { + if(log.op.toString() == "POP") this.data.push(log.stack.peek(0)); + }, + result: function() { return this.data; } + }""", + """{ + retVal: [], + step: function(log,db) { + this.retVal.push(log.getPC() + ":" + log.op.toString()) + }, + fault: function(log,db) { + this.retVal.push("FAULT: " + JSON.stringify(log)) + }, + result: function(ctx,db) { + return this.retVal + } + } + """, + ] + res = [] + call = w3.provider.make_request + with ThreadPoolExecutor(len(tracers)) as exec: + params = [[tx, "latest", {"tracer": tracer}] for tracer in tracers] + exec_map = exec.map(call, itertools.repeat(method), params) + res = [json.dumps(resp["result"], sort_keys=True) for resp in exec_map] + return res + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == EXPECTED_JS_TRACERS, res + + +def test_tracecall_struct_tracer(ethermint, geth): + method = "debug_traceCall" + acc = derive_random_account() + sender = acc.address + receiver = ADDRS["signer2"] + + def process(w3, gas): + fund_acc(w3, acc) + tx = {"from": sender, "to": receiver, "value": hex(100)} + if gas is not None: + # set gas limit in tx + tx["gas"] = hex(gas) + tx_res = w3.provider.make_request(method, [tx, "latest"]) + assert "result" in tx_res + return tx_res["result"] + + providers = [ethermint.w3, geth.w3] + gas = 21000 + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3, gas) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == EXPECTED_STRUCT_TRACER, res + + # no gas limit set in tx + res = process(ethermint.w3, None) + assert res == EXPECTED_STRUCT_TRACER | { + "gas": EXPECTED_DEFAULT_GASCAP / 2, + }, res + + +def test_tracecall_prestate_tracer(ethermint, geth): + method = "debug_traceCall" + tracer = {"tracer": "prestateTracer"} + sender_acc = derive_random_account() + sender = sender_acc.address + receiver_acc = derive_random_account() + receiver = receiver_acc.address + addrs = [sender.lower(), receiver.lower()] + + def process(w3): + fund_acc(w3, sender_acc) + fund_acc(w3, receiver_acc) + tx = {"value": 1, "gas": 21000, "gasPrice": 88500000000} + # make a transaction make sure the nonce is not 0 + send_transaction(w3, tx | {"from": sender, "to": receiver}, key=sender_acc.key) + tx = tx | {"from": receiver, "to": sender} + send_transaction(w3, tx, key=receiver_acc.key) + tx = {"from": sender, "to": receiver, "value": hex(1)} + tx_res = w3.provider.make_request(method, [tx, "latest", tracer]) + assert "result" in tx_res + assert all( + tx_res["result"][addr.lower()] + == { + "balance": hex(w3.eth.get_balance(addr)), + "nonce": w3.eth.get_transaction_count(addr), + } + for addr in [sender, receiver] + ), tx_res["result"] + return tx_res["result"] + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert all(res[0][addr] == res[-1][addr] for addr in addrs), res + + +def test_tracecall_diff(ethermint, geth): + method = "debug_traceCall" + tracer = {"tracer": "prestateTracer", "tracerConfig": {"diffMode": True}} + sender_acc = derive_new_account(4) + sender = sender_acc.address + receiver = derive_new_account(5).address + fund = 3000000000000000000 + gas = 21000 + price = 88500000000 + fee = gas * price + + def process(w3): + fund_acc(w3, sender_acc) + tx = {"from": sender, "to": receiver, "value": 1, "gas": gas, "gasPrice": price} + send_transaction(w3, tx, key=sender_acc.key) + res = send_transaction(w3, tx, key=sender_acc.key) + send_transaction(w3, tx, key=sender_acc.key) + tx = {"from": sender, "to": receiver, "value": hex(1)} + tx_res = w3.provider.make_request(method, [tx, hex(res["blockNumber"]), tracer]) + return json.dumps(tx_res["result"], sort_keys=True) + + providers = [ethermint.w3, geth.w3] + expected = json.dumps( + { + "post": { + receiver.lower(): {"balance": hex(3)}, + sender.lower(): {"balance": hex(fund - 3 - fee * 2), "nonce": 3}, + }, + "pre": { + receiver.lower(): {"balance": hex(2)}, + sender.lower(): {"balance": hex(fund - 2 - fee * 2), "nonce": 2}, + }, + }, + sort_keys=True, ) - tx_res["result"]["to"] = EXPECTED_CONTRACT_CREATE_TRACER["to"] - assert tx_res["result"] == EXPECTED_CONTRACT_CREATE_TRACER, "" + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == expected, res + + +def test_debug_tracecall_call_tracer(ethermint, geth): + method = "debug_traceCall" + acc = derive_random_account() + sender = acc.address + receiver = ADDRS["signer2"] + + def process(w3, gas): + fund_acc(w3, acc) + tx = {"from": sender, "to": receiver, "value": hex(1)} + if gas is not None: + # set gas limit in tx + tx["gas"] = hex(gas) + tx_res = w3.provider.make_request( + method, + [tx, "latest", {"tracer": "callTracer"}], + ) + assert "result" in tx_res + return tx_res["result"] + + providers = [ethermint.w3, geth.w3] + gas = 21000 + expected = { + "type": "CALL", + "from": sender.lower(), + "to": receiver.lower(), + "value": hex(1), + "gas": hex(gas), + "gasUsed": hex(gas), + "input": "0x", + } + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3, gas) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == expected, res + + # no gas limit set in tx + res = process(ethermint.w3, None) + assert res == expected | { + "gas": hex(EXPECTED_DEFAULT_GASCAP), + "gasUsed": hex(int(EXPECTED_DEFAULT_GASCAP / 2)), + }, res + + +def test_debug_tracecall_state_overrides(ethermint, geth): + balance = "0xffffffff" + + def process(w3): + # generate random address, set balance in stateOverrides, + # use prestateTracer to check balance + address = w3.eth.account.create().address + tx = { + "from": address, + "to": ADDRS["signer2"], + "value": hex(1), + } + config = { + "tracer": "prestateTracer", + "stateOverrides": { + address: { + "balance": balance, + }, + }, + } + tx_res = w3.provider.make_request("debug_traceCall", [tx, "latest", config]) + assert "result" in tx_res + tx_res = tx_res["result"] + return tx_res[address.lower()]["balance"] + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == balance, res + + +def test_debug_tracecall_return_revert_data_when_call_failed(ethermint, geth): + expected = "08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a46756e6374696f6e20686173206265656e207265766572746564000000000000" # noqa: E501 + + def process(w3): + test_revert, _ = deploy_contract(w3, CONTRACTS["TestRevert"]) + tx_res = w3.provider.make_request( + "debug_traceCall", + [ + { + "value": "0x0", + "to": test_revert.address, + "from": ADDRS["validator"], + "data": "0x9ffb86a5", + }, + "latest", + ], + ) + assert "result" in tx_res + tx_res = tx_res["result"] + return tx_res["returnValue"] + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == expected, res + + +def test_debug_tracecall_block_overrides(ethermint, geth): + method = "debug_traceCall" + gas = hex(65535) + price = hex(88500000000) + # https://github.com/ethereum/go-ethereum/blob/v1.11.6/core/vm/opcodes.go#L95 + tx = {"from": ADDRS["validator"], "input": "0x43", "gas": gas, "gasPrice": price} + future_blk = "0x1337" + tracer = { + "blockOverrides": { + "number": future_blk, + "coinbase": "0x1111111111111111111111111111111111111111", + "difficulty": hex(2), + "time": hex(3), + "baseLimit": hex(4), + "baseFee": hex(5), + } + } + + def process(w3): + w3_wait_for_new_blocks(w3, 1) + tx_res = w3.provider.make_request(method, [tx, "latest", tracer]) + return json.dumps(tx_res["result"], sort_keys=True) + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1] == EXPECTED_BLOCK_OVERRIDES_TRACERS, res + + +def test_trace_staticcall(ethermint, geth): + method = "debug_traceTransaction" + tracer = {"tracer": "callTracer"} + acc = derive_new_account(6) + acc1 = derive_new_account(7) + price = 58500000000 + func = "callCalculator()" + selector = f"0x{Web3.keccak(text=func).hex()[2:10]}" + x = "0x0000000000000000000000000000000000000000000000000000000000000000" + y = "0x0000000000000000000000000000000000000000000000000000000000000001" + + def process(w3): + fund_acc(w3, acc) + fund_acc(w3, acc1) + calculator, _ = deploy_contract(w3, CONTRACTS["Calculator"], key=acc.key) + caller, _ = deploy_contract( + w3, + CONTRACTS["Caller"], + (calculator.address,), + key=acc.key, + ) + w3_wait_for_new_blocks(w3, 1, sleep=0.1) + tx = {"to": caller.address, "data": selector, "gasPrice": price} + txs = {key: tx for key in [acc.key, acc1.key]} + txs[acc1.key] = txs[acc1.key] | { + "accessList": [ + { + "address": calculator.address, + "storageKeys": (x, y), + } + ] + } + sended_hash_set = send_txs(w3, txs) + for txhash in sended_hash_set: + res = w3.eth.wait_for_transaction_receipt(txhash, timeout=10) + res = [] + call = w3.provider.make_request + with ThreadPoolExecutor(len(sended_hash_set)) as exec: + params = [[tx_hash.hex(), tracer] for tx_hash in sended_hash_set] + exec_map = exec.map(call, itertools.repeat(method), params) + res = [json.dumps(resp["result"], sort_keys=True) for resp in exec_map] + return res + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1], res diff --git a/tests/integration_tests/test_types.py b/tests/integration_tests/test_types.py index 9eb6a40a..691997d8 100644 --- a/tests/integration_tests/test_types.py +++ b/tests/integration_tests/test_types.py @@ -210,17 +210,15 @@ def test_get_proof(ethermint_rpc_ws, geth): ) res = send_tnx(w3) - proof = (eth_rpc.make_request( - method, [validator, ["0x0"], hex(res["blockNumber"])] - ))["result"] + proof = ( + eth_rpc.make_request(method, [validator, ["0x0"], hex(res["blockNumber"])]) + )["result"] compare_types(proof, EXPECTED_GET_PROOF["result"]) assert proof["accountProof"], EXPECTED_ACCOUNT_PROOF assert proof["storageProof"][0]["proof"], EXPECTED_STORAGE_PROOF _ = send_and_get_hash(w3) - proof = eth_rpc.make_request( - method, [validator, ["0x0"], "latest"] - ) + proof = eth_rpc.make_request(method, [validator, ["0x0"], "latest"]) compare_types(proof, EXPECTED_GET_PROOF) diff --git a/tests/integration_tests/test_upgrade.py b/tests/integration_tests/test_upgrade.py index d915bcc3..f986744c 100644 --- a/tests/integration_tests/test_upgrade.py +++ b/tests/integration_tests/test_upgrade.py @@ -4,22 +4,22 @@ # import subprocess # from pathlib import Path -# import pytest -# from dateutil.parser import isoparse -# from pystarport import ports -# from pystarport.cluster import SUPERVISOR_CONFIG_FILE - -# from .network import Ethermint, setup_custom_ethermint -# from .utils import ( -# ADDRS, -# CONTRACTS, -# deploy_contract, -# parse_events, -# send_transaction, -# wait_for_block, -# wait_for_block_time, -# wait_for_port, -# ) +import pytest +from pystarport import ports +from pystarport.cluster import SUPERVISOR_CONFIG_FILE + +from .network import Ethermint, setup_custom_ethermint +from .utils import ( + ADDRS, + CONTRACTS, + approve_proposal, + deploy_contract, + send_transaction, + wait_for_block, + wait_for_port, +) + +pytestmark = pytest.mark.upgrade # def init_cosmovisor(home): @@ -84,53 +84,39 @@ # ) -# def test_cosmovisor_upgrade(custom_ethermint: Ethermint): -# """ -# - propose an upgrade and pass it -# - wait for it to happen -# - it should work transparently -# - check that queries on legacy blocks still works after upgrade. -# """ -# cli = custom_ethermint.cosmos_cli() - -# w3 = custom_ethermint.w3 -# contract, _ = deploy_contract(w3, CONTRACTS["TestERC20A"]) -# old_height = w3.eth.block_number -# old_balance = w3.eth.get_balance(ADDRS["validator"], block_identifier=old_height) -# old_base_fee = w3.eth.get_block(old_height).baseFeePerGas -# old_erc20_balance = contract.caller.balanceOf(ADDRS["validator"]) -# print("old values", old_height, old_balance, old_base_fee) +def test_cosmovisor_upgrade(custom_ethermint: Ethermint): + """ + - propose an upgrade and pass it + - wait for it to happen + - it should work transparently + - check that queries on legacy blocks still works after upgrade. + """ + cli = custom_ethermint.cosmos_cli() + w3 = custom_ethermint.w3 + contract, _ = deploy_contract(w3, CONTRACTS["TestERC20A"]) + old_height = w3.eth.block_number + old_balance = w3.eth.get_balance(ADDRS["validator"], block_identifier=old_height) + old_base_fee = w3.eth.get_block(old_height).baseFeePerGas + old_erc20_balance = contract.caller.balanceOf(ADDRS["validator"]) + print("old values", old_height, old_balance, old_base_fee) # target_height = w3.eth.block_number + 10 # print("upgrade height", target_height) -# plan_name = "integration-test-upgrade" -# rsp = cli.gov_propose( -# "community", -# "software-upgrade", -# { -# "name": plan_name, -# "title": "upgrade test", -# "description": "ditto", -# "upgrade-height": target_height, -# "deposit": "10000aphoton", -# }, -# ) -# assert rsp["code"] == 0, rsp["raw_log"] - -# # get proposal_id -# ev = parse_events(rsp["logs"])["submit_proposal"] -# proposal_id = ev["proposal_id"] - -# rsp = cli.gov_vote("validator", proposal_id, "yes") -# assert rsp["code"] == 0, rsp["raw_log"] -# # rsp = custom_ethermint.cosmos_cli(1).gov_vote("validator", proposal_id, "yes") -# # assert rsp["code"] == 0, rsp["raw_log"] - -# proposal = cli.query_proposal(proposal_id) -# wait_for_block_time(cli, isoparse(proposal["voting_end_time"])) -# proposal = cli.query_proposal(proposal_id) -# assert proposal["status"] == "PROPOSAL_STATUS_PASSED", proposal + plan_name = "sdk50" + rsp = cli.gov_propose_legacy( + "community", + "software-upgrade", + { + "name": plan_name, + "title": "upgrade test", + "description": "ditto", + "upgrade-height": target_height, + "deposit": "10000aphoton", + }, + ) + assert rsp["code"] == 0, rsp["raw_log"] + approve_proposal(custom_ethermint, rsp) # # update cli chain binary # custom_ethermint.chain_binary = ( @@ -166,17 +152,17 @@ # ) # assert old_base_fee == w3.eth.get_block(old_height).baseFeePerGas -# # check eth_call on older blocks works -# assert old_erc20_balance == contract.caller( -# block_identifier=target_height - 2 -# ).balanceOf(ADDRS["validator"]) -# p = json.loads( -# cli.raw( -# "query", -# "ibc", -# "client", -# "params", -# home=cli.data_dir, -# ) -# ) -# assert p == {"allowed_clients": ["06-solomachine", "07-tendermint", "09-localhost"]} + # check eth_call on older blocks works + assert old_erc20_balance == contract.caller( + block_identifier=target_height - 2 + ).balanceOf(ADDRS["validator"]) + p = json.loads( + cli.raw( + "query", + "ibc", + "client", + "params", + home=cli.data_dir, + ) + ) + assert p == {"allowed_clients": ["06-solomachine", "07-tendermint", "09-localhost"]} diff --git a/tests/integration_tests/test_websockets.py b/tests/integration_tests/test_websockets.py index 10d2f4f8..195e19f5 100644 --- a/tests/integration_tests/test_websockets.py +++ b/tests/integration_tests/test_websockets.py @@ -4,5 +4,145 @@ def test_single_request_netversion(ethermint): response = eth_ws.make_request("net_version", []) - # net_version should be 9000 - assert response["result"] == "9000", "got " + response["result"] + ", expected 9000" +from .network import Ethermint +from .utils import ( + ADDRS, + CONTRACTS, + build_batch_tx, + deploy_contract, + modify_command_in_supervisor_config, + wait_for_new_blocks, + wait_for_port, +) + + +class Client: + def __init__(self, ws): + self._ws = ws + self._gen_id = 0 + self._subs = defaultdict(asyncio.Queue) + self._rsps = defaultdict(asyncio.Queue) + + def gen_id(self): + self._gen_id += 1 + return self._gen_id + + async def receive_loop(self): + while True: + msg = json.loads(await self._ws.recv()) + if "id" in msg: + # responses + await self._rsps[msg["id"]].put(msg) + else: + # subscriptions + assert msg["method"] == "eth_subscription" + sub_id = msg["params"]["subscription"] + await self._subs[sub_id].put(msg["params"]["result"]) + + async def recv_response(self, rpcid): + rsp = await self._rsps[rpcid].get() + del self._rsps[rpcid] + return rsp + + async def recv_subscription(self, sub_id): + return await self._subs[sub_id].get() + + async def subscribe(self, *args): + rpcid = self.gen_id() + await self._ws.send( + json.dumps({"id": rpcid, "method": "eth_subscribe", "params": args}) + ) + rsp = await self.recv_response(rpcid) + assert "error" not in rsp + return rsp["result"] + + def sub_qsize(self, sub_id): + return self._subs[sub_id].qsize() + + async def send(self, id): + await self._ws.send( + json.dumps({"jsonrpc": "2.0", "id": id, "method": "web3_clientVersion"}) + ) + rsp = await self.recv_response(id) + assert "error" not in rsp + + async def unsubscribe(self, sub_id): + rpcid = self.gen_id() + await self._ws.send( + json.dumps({"id": rpcid, "method": "eth_unsubscribe", "params": [sub_id]}) + ) + rsp = await self.recv_response(rpcid) + assert "error" not in rsp + return rsp["result"] + + +def test_subscribe_basic(ethermint: Ethermint): + """ + test basic subscribe and unsubscribe + """ + modify_command_in_supervisor_config( + ethermint.base_dir / "tasks.ini", + lambda cmd: f"{cmd} --evm.max-tx-gas-wanted {0}", + ) + ethermint.supervisorctl("update") + wait_for_port(ports.evmrpc_ws_port(ethermint.base_port(0))) + cli = ethermint.cosmos_cli() + loop = asyncio.get_event_loop() + + async def assert_unsubscribe(c: Client, sub_id): + assert await c.unsubscribe(sub_id) + # check no more messages + await loop.run_in_executor(None, wait_for_new_blocks, cli, 2) + assert c.sub_qsize(sub_id) == 0 + # unsubscribe again return False + assert not await c.unsubscribe(sub_id) + + async def logs_test(c: Client, w3, contract): + method = "Transfer(address,address,uint256)" + topic = f"0x{abi.event_signature_to_log_topic(method).hex()}" + params = {"address": contract.address, "topics": [topic]} + sub_id = await c.subscribe("logs", params) + sender = ADDRS["validator"] + recipient = ADDRS["community"] + nonce = w3.eth.get_transaction_count(sender) + total = 2 + txs = [ + contract.functions.transfer(recipient, 1000).build_transaction( + {"from": sender, "nonce": nonce + n, "gas": 200000} + ) + for n in range(total) + ] + cosmos_tx, _ = build_batch_tx(w3, cli, txs) + rsp = cli.broadcast_tx_json(cosmos_tx) + assert rsp["code"] == 0, rsp["raw_log"] + msgs = [await c.recv_subscription(sub_id) for i in range(total)] + assert len(msgs) == total + for msg in msgs: + assert ( + topic + in msg["topics"] + == [ + topic, + HexBytes(b"\x00" * 12 + HexBytes(sender)).hex(), + HexBytes(b"\x00" * 12 + HexBytes(recipient)).hex(), + ] + ) + await assert_unsubscribe(c, sub_id) + + async def async_test(): + async with websockets.connect(ethermint.w3_ws_endpoint) as ws: + c = Client(ws) + t = asyncio.create_task(c.receive_loop()) + # run send concurrently + await asyncio.gather(*[c.send(id) for id in ["0", 1, 2.0]]) + contract, _ = deploy_contract(ethermint.w3, CONTRACTS["TestERC20A"]) + await asyncio.gather(*[logs_test(c, ethermint.w3, contract)]) + t.cancel() + try: + await t + except asyncio.CancelledError: + print("cancel") + pass + + timeout = 50 + loop.run_until_complete(asyncio.wait_for(async_test(), timeout)) diff --git a/tests/integration_tests/utils.py b/tests/integration_tests/utils.py index 9a0c87e5..3eed6ef0 100644 --- a/tests/integration_tests/utils.py +++ b/tests/integration_tests/utils.py @@ -76,11 +76,15 @@ def w3_wait_for_new_blocks(w3, n, sleep=0.5): break +def get_sync_info(s): + return s.get("SyncInfo") or s.get("sync_info") + + def wait_for_new_blocks(cli, n, sleep=0.5): - cur_height = begin_height = int((cli.status())["SyncInfo"]["latest_block_height"]) + cur_height = begin_height = int(get_sync_info(cli.status())["latest_block_height"]) while cur_height - begin_height < n: time.sleep(sleep) - cur_height = int((cli.status())["SyncInfo"]["latest_block_height"]) + cur_height = int(get_sync_info(cli.status())["latest_block_height"]) return cur_height @@ -91,7 +95,7 @@ def wait_for_block(cli, height, timeout=240): except AssertionError as e: print(f"get sync status failed: {e}", file=sys.stderr) else: - current_height = int(status["SyncInfo"]["latest_block_height"]) + current_height = int(get_sync_info(status)["latest_block_height"]) if current_height >= height: break print("current block height", current_height) @@ -118,7 +122,7 @@ def w3_wait_for_block(w3, height, timeout=240): def wait_for_block_time(cli, t): print("wait for block time", t) while True: - now = isoparse((cli.status())["SyncInfo"]["latest_block_time"]) + now = isoparse(get_sync_info(cli.status())["latest_block_time"]) print("block time now: ", now) if now >= t: break @@ -205,3 +209,99 @@ def derive_new_account(n=1): account_path = f"m/44'/60'/0'/0/{n}" mnemonic = os.getenv("COMMUNITY_MNEMONIC") return Account.from_mnemonic(mnemonic, account_path=account_path) + + +def derive_random_account(): + return derive_new_account(secrets.randbelow(10000) + 1) + + +def send_raw_transactions(w3, raw_transactions): + with ThreadPoolExecutor(len(raw_transactions)) as exec: + tasks = [ + exec.submit(w3.eth.send_raw_transaction, raw) for raw in raw_transactions + ] + sended_hash_set = {future.result() for future in as_completed(tasks)} + return sended_hash_set + + +def modify_command_in_supervisor_config(ini: Path, fn, **kwargs): + "replace the first node with the instrumented binary" + ini.write_text( + re.sub( + r"^command = (ethermintd .*$)", + lambda m: f"command = {fn(m.group(1))}", + ini.read_text(), + flags=re.M, + **kwargs, + ) + ) + + +def build_batch_tx(w3, cli, txs, key=KEYS["validator"]): + "return cosmos batch tx and eth tx hashes" + signed_txs = [sign_transaction(w3, tx, key) for tx in txs] + tmp_txs = [cli.build_evm_tx(signed.rawTransaction.hex()) for signed in signed_txs] + + msgs = [tx["body"]["messages"][0] for tx in tmp_txs] + fee = sum(int(tx["auth_info"]["fee"]["amount"][0]["amount"]) for tx in tmp_txs) + gas_limit = sum(int(tx["auth_info"]["fee"]["gas_limit"]) for tx in tmp_txs) + + tx_hashes = [signed.hash for signed in signed_txs] + + # build batch cosmos tx + return { + "body": { + "messages": msgs, + "memo": "", + "timeout_height": "0", + "extension_options": [ + {"@type": "/ethermint.evm.v1.ExtensionOptionsEthereumTx"} + ], + "non_critical_extension_options": [], + }, + "auth_info": { + "signer_infos": [], + "fee": { + "amount": [{"denom": "aphoton", "amount": str(fee)}], + "gas_limit": str(gas_limit), + "payer": "", + "granter": "", + }, + }, + "signatures": [], + }, tx_hashes + + +def find_log_event_attrs(events, ev_type, cond=None): + for ev in events: + if ev["type"] == ev_type: + attrs = {attr["key"]: attr["value"] for attr in ev["attributes"]} + if cond is None or cond(attrs): + return attrs + return None + + +def approve_proposal(n, rsp, status="PROPOSAL_STATUS_PASSED"): + cli = n.cosmos_cli() + rsp = cli.event_query_tx_for(rsp["txhash"]) + # get proposal_id + + def cb(attrs): + return "proposal_id" in attrs + + ev = find_log_event_attrs(rsp["events"], "submit_proposal", cb) + proposal_id = ev["proposal_id"] + for i in range(len(n.config["validators"])): + rsp = n.cosmos_cli(i).gov_vote("validator", proposal_id, "yes", gas=100000) + assert rsp["code"] == 0, rsp["raw_log"] + wait_for_new_blocks(cli, 1) + res = cli.query_tally(proposal_id) + res = res.get("tally") or res + assert ( + int(res["yes_count"]) == cli.staking_pool() + ), "all validators should have voted yes" + print("wait for proposal to be activated") + proposal = cli.query_proposal(proposal_id) + wait_for_block_time(cli, isoparse(proposal["voting_end_time"])) + proposal = cli.query_proposal(proposal_id) + assert proposal["status"] == status, proposal diff --git a/tests/signer.go b/tests/signer.go index 54e55e56..709bd0f7 100644 --- a/tests/signer.go +++ b/tests/signer.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" ) @@ -61,7 +62,7 @@ func NewSigner(sk cryptotypes.PrivKey) keyring.Signer { } // Sign signs the message using the underlying private key -func (s Signer) Sign(_ string, msg []byte) ([]byte, cryptotypes.PubKey, error) { +func (s Signer) Sign(_ string, msg []byte, _ signing.SignMode) ([]byte, cryptotypes.PubKey, error) { if s.privKey.Type() != ethsecp256k1.KeyType { return nil, nil, fmt.Errorf( "invalid private key type for signing ethereum tx; expected %s, got %s", @@ -79,11 +80,11 @@ func (s Signer) Sign(_ string, msg []byte) ([]byte, cryptotypes.PubKey, error) { } // SignByAddress sign byte messages with a user key providing the address. -func (s Signer) SignByAddress(address sdk.Address, msg []byte) ([]byte, cryptotypes.PubKey, error) { +func (s Signer) SignByAddress(address sdk.Address, msg []byte, signMode signing.SignMode) ([]byte, cryptotypes.PubKey, error) { signer := sdk.AccAddress(s.privKey.PubKey().Address()) if !signer.Equals(address) { return nil, nil, fmt.Errorf("address mismatch: signer %s ≠ given address %s", signer, address) } - return s.Sign("", msg) + return s.Sign("", msg, signMode) } diff --git a/testutil/abci.go b/testutil/abci.go index 49195ed6..09d392ba 100644 --- a/testutil/abci.go +++ b/testutil/abci.go @@ -4,7 +4,7 @@ import ( "time" abci "github.com/cometbft/cometbft/abci/types" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/ethermint/app" @@ -16,11 +16,15 @@ import ( // 2. DeliverTx // 3. EndBlock // 4. Commit -func Commit(ctx sdk.Context, app *app.EthermintApp, t time.Duration, vs *tmtypes.ValidatorSet) (sdk.Context, error) { +func Commit(ctx sdk.Context, app *app.EthermintApp, t time.Duration, vs *cmttypes.ValidatorSet) (sdk.Context, error) { header := ctx.BlockHeader() + req := abci.RequestFinalizeBlock{Height: header.Height} if vs != nil { - res := app.EndBlock(abci.RequestEndBlock{Height: header.Height}) + res, err := app.FinalizeBlock(&req) + if err != nil { + return ctx, err + } nextVals, err := applyValSetChanges(vs, res.ValidatorUpdates) if err != nil { @@ -29,26 +33,30 @@ func Commit(ctx sdk.Context, app *app.EthermintApp, t time.Duration, vs *tmtypes header.ValidatorsHash = vs.Hash() header.NextValidatorsHash = nextVals.Hash() } else { - app.EndBlocker(ctx, abci.RequestEndBlock{Height: header.Height}) + if _, err := app.EndBlocker(ctx); err != nil { + return ctx, err + } } - _ = app.Commit() + if _, err := app.Commit(); err != nil { + return ctx, err + } header.Height++ header.Time = header.Time.Add(t) header.AppHash = app.LastCommitID().Hash - app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) + if _, err := app.BeginBlocker(ctx); err != nil { + return ctx, err + } return ctx.WithBlockHeader(header), nil } // applyValSetChanges takes in tmtypes.ValidatorSet and []abci.ValidatorUpdate and will return a new tmtypes.ValidatorSet which has the // provided validator updates applied to the provided validator set. -func applyValSetChanges(valSet *tmtypes.ValidatorSet, valUpdates []abci.ValidatorUpdate) (*tmtypes.ValidatorSet, error) { - updates, err := tmtypes.PB2TM.ValidatorUpdates(valUpdates) +func applyValSetChanges(valSet *cmttypes.ValidatorSet, valUpdates []abci.ValidatorUpdate) (*cmttypes.ValidatorSet, error) { + updates, err := cmttypes.PB2TM.ValidatorUpdates(valUpdates) if err != nil { return nil, err } diff --git a/testutil/network/network.go b/testutil/network/network.go index 6c02603f..02920eb9 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -24,25 +24,27 @@ import ( "net/http" "net/url" "os" + "os/signal" "path/filepath" "strings" "sync" + "syscall" "testing" "time" + "cosmossdk.io/log" sdkmath "cosmossdk.io/math" - dbm "github.com/cometbft/cometbft-db" - tmcfg "github.com/cometbft/cometbft/config" - tmflags "github.com/cometbft/cometbft/libs/cli/flags" - "github.com/cometbft/cometbft/libs/log" - tmrand "github.com/cometbft/cometbft/libs/rand" + cmtrand "github.com/cometbft/cometbft/libs/rand" "github.com/cometbft/cometbft/node" tmrpcclient "github.com/cometbft/cometbft/rpc/client" + dbm "github.com/cosmos/cosmos-db" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/spf13/cobra" + "golang.org/x/sync/errgroup" "google.golang.org/grpc" + pruningtypes "cosmossdk.io/store/pruning/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" @@ -54,7 +56,6 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" srvconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -62,18 +63,20 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/zeta-chain/ethermint/crypto/hd" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/server/config" - ethermint "github.com/zeta-chain/ethermint/types" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/crypto/hd" + "github.com/evmos/ethermint/server/config" + ethermint "github.com/evmos/ethermint/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/zeta-chain/ethermint/app" ) // network lock to only allow one test network at a time -var lock = new(sync.Mutex) +var ( + lock = new(sync.Mutex) + portPool = make(chan string, 200) +) // AppConstructor defines a function which accepts a network configuration and // creates an ABCI Application to provide to Tendermint. @@ -128,8 +131,8 @@ type Config struct { // DefaultConfig returns a sane default configuration suitable for nearly all // testing requirements. func DefaultConfig() Config { - encCfg := encoding.MakeConfig(app.ModuleBasics) - chainID := fmt.Sprintf("ethermint_%d-1", tmrand.Int63n(9999999999999)+1) + encCfg := app.MakeConfigForTest() + chainID := fmt.Sprintf("ethermint_%d-1", cmtrand.Int63n(9999999999999)+1) return Config{ Codec: encCfg.Codec, TxConfig: encCfg.TxConfig, @@ -198,6 +201,8 @@ type ( grpcWeb *http.Server jsonrpc *http.Server jsonrpcDone chan struct{} + errGroup *errgroup.Group + cancelFn context.CancelFunc } ) @@ -271,13 +276,13 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { appCfg.Telemetry.GlobalLabels = [][]string{{"chain_id", cfg.ChainID}} ctx := server.NewDefaultContext() - tmCfg := ctx.Config - tmCfg.Consensus.TimeoutCommit = cfg.TimeoutCommit + cmtCfg := ctx.Config + cmtCfg.Consensus.TimeoutCommit = cfg.TimeoutCommit // Only allow the first validator to expose an RPC, API and gRPC // server/client due to Tendermint in-process constraints. apiAddr := "" - tmCfg.RPC.ListenAddress = "" + cmtCfg.RPC.ListenAddress = "" appCfg.GRPC.Enable = false appCfg.GRPCWeb.Enable = false apiListenAddr := "" @@ -285,11 +290,11 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { if cfg.APIAddress != "" { apiListenAddr = cfg.APIAddress } else { - var err error - apiListenAddr, _, err = server.FreeTCPAddr() - if err != nil { - return nil, err + if len(portPool) == 0 { + return nil, fmt.Errorf("failed to get port for API server") } + port := <-portPool + apiListenAddr = fmt.Sprintf("tcp://0.0.0.0:%s", port) } appCfg.API.Address = apiListenAddr @@ -300,41 +305,34 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { apiAddr = fmt.Sprintf("http://%s:%s", apiURL.Hostname(), apiURL.Port()) if cfg.RPCAddress != "" { - tmCfg.RPC.ListenAddress = cfg.RPCAddress + cmtCfg.RPC.ListenAddress = cfg.RPCAddress } else { - rpcAddr, _, err := server.FreeTCPAddr() - if err != nil { - return nil, err + if len(portPool) == 0 { + return nil, fmt.Errorf("failed to get port for RPC server") } - tmCfg.RPC.ListenAddress = rpcAddr + port := <-portPool + cmtCfg.RPC.ListenAddress = fmt.Sprintf("tcp://0.0.0.0:%s", port) } if cfg.GRPCAddress != "" { appCfg.GRPC.Address = cfg.GRPCAddress } else { - _, grpcPort, err := server.FreeTCPAddr() - if err != nil { - return nil, err + if len(portPool) == 0 { + return nil, fmt.Errorf("failed to get port for GRPC server") } - appCfg.GRPC.Address = fmt.Sprintf("0.0.0.0:%s", grpcPort) + port := <-portPool + appCfg.GRPC.Address = fmt.Sprintf("0.0.0.0:%s", port) } appCfg.GRPC.Enable = true - _, grpcWebPort, err := server.FreeTCPAddr() - if err != nil { - return nil, err - } - appCfg.GRPCWeb.Address = fmt.Sprintf("0.0.0.0:%s", grpcWebPort) - appCfg.GRPCWeb.Enable = true - if cfg.JSONRPCAddress != "" { appCfg.JSONRPC.Address = cfg.JSONRPCAddress } else { - _, jsonRPCPort, err := server.FreeTCPAddr() - if err != nil { - return nil, err + if len(portPool) == 0 { + return nil, fmt.Errorf("failed to get port for JSON-RPC server") } - appCfg.JSONRPC.Address = fmt.Sprintf("127.0.0.1:%s", jsonRPCPort) + port := <-portPool + appCfg.JSONRPC.Address = fmt.Sprintf("0.0.0.0:%s", port) } appCfg.JSONRPC.Enable = true appCfg.JSONRPC.API = config.GetAPINamespaces() @@ -342,8 +340,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { logger := log.NewNopLogger() if cfg.EnableTMLogging { - logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)) - logger, _ = tmflags.ParseLogLevel("info", logger, tmcfg.DefaultLogLevel) + logger = log.NewLogger(os.Stdout) } ctx.Logger = logger @@ -363,25 +360,27 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - tmCfg.SetRoot(nodeDir) - tmCfg.Moniker = nodeDirName + cmtCfg.SetRoot(nodeDir) + cmtCfg.Moniker = nodeDirName monikers[i] = nodeDirName - proxyAddr, _, err := server.FreeTCPAddr() - if err != nil { - return nil, err + if len(portPool) == 0 { + return nil, fmt.Errorf("failed to get port for Proxy server") } - tmCfg.ProxyApp = proxyAddr + port := <-portPool + proxyAddr := fmt.Sprintf("tcp://0.0.0.0:%s", port) + cmtCfg.ProxyApp = proxyAddr - p2pAddr, _, err := server.FreeTCPAddr() - if err != nil { - return nil, err + if len(portPool) == 0 { + return nil, fmt.Errorf("failed to get port for Proxy server") } - tmCfg.P2P.ListenAddress = p2pAddr - tmCfg.P2P.AddrBookStrict = false - tmCfg.P2P.AllowDuplicateIP = true + port = <-portPool + p2pAddr := fmt.Sprintf("tcp://0.0.0.0:%s", port) + cmtCfg.P2P.ListenAddress = p2pAddr + cmtCfg.P2P.AddrBookStrict = false + cmtCfg.P2P.AllowDuplicateIP = true - nodeID, pubKey, err := genutil.InitializeNodeValidatorFiles(tmCfg) + nodeID, pubKey, err := genutil.InitializeNodeValidatorFiles(cmtCfg) if err != nil { return nil, err } @@ -427,25 +426,25 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { sdk.NewCoin(cfg.BondDenom, cfg.StakingTokens), ) - genFiles = append(genFiles, tmCfg.GenesisFile()) + genFiles = append(genFiles, cmtCfg.GenesisFile()) genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: balances.Sort()}) genAccounts = append(genAccounts, ðermint.EthAccount{ BaseAccount: authtypes.NewBaseAccount(addr, nil, 0, 0), CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), }) - commission, err := sdk.NewDecFromStr("0.5") + commission, err := sdkmath.LegacyNewDecFromStr("0.5") if err != nil { return nil, err } createValMsg, err := stakingtypes.NewMsgCreateValidator( - sdk.ValAddress(addr), + addr.String(), valPubKeys[i], sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), - stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + stakingtypes.NewCommissionRates(commission, sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), + sdkmath.OneInt(), ) if err != nil { return nil, err @@ -474,7 +473,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { WithKeybase(kb). WithTxConfig(cfg.TxConfig) - if err := tx.Sign(txFactory, nodeDirName, txBuilder, true); err != nil { + if err := tx.Sign(context.Background(), txFactory, nodeDirName, txBuilder, true); err != nil { return nil, err } @@ -501,7 +500,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { clientCtx := client.Context{}. WithKeyringDir(clientDir). WithKeyring(kb). - WithHomeDir(tmCfg.RootDir). + WithHomeDir(cmtCfg.RootDir). WithChainID(cfg.ChainID). WithInterfaceRegistry(cfg.InterfaceRegistry). WithCodec(cfg.Codec). @@ -517,8 +516,8 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { NodeID: nodeID, PubKey: pubKey, Moniker: nodeDirName, - RPCAddress: tmCfg.RPC.ListenAddress, - P2PAddress: tmCfg.P2P.ListenAddress, + RPCAddress: cmtCfg.RPC.ListenAddress, + P2PAddress: cmtCfg.P2P.ListenAddress, APIAddress: apiAddr, Address: addr, ValAddress: sdk.ValAddress(addr), @@ -546,7 +545,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { // Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any // defer in a test would not be called. - server.TrapSignal(network.Cleanup) + trapSignal(network.Cleanup) return network, nil } @@ -711,3 +710,27 @@ func centerText(text string, width int) string { return fmt.Sprintf("%s%s%s", leftBuffer, text, rightBuffer) } + +// trapSignal traps SIGINT and SIGTERM and calls os.Exit once a signal is received. +func trapSignal(cleanupFunc func()) { + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) + + go func() { + sig := <-sigs + + if cleanupFunc != nil { + cleanupFunc() + } + exitCode := 128 + + switch sig { + case syscall.SIGINT: + exitCode += int(syscall.SIGINT) + case syscall.SIGTERM: + exitCode += int(syscall.SIGTERM) + } + + os.Exit(exitCode) + }() +} diff --git a/testutil/network/util.go b/testutil/network/util.go index afe374fd..be6df561 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -16,11 +16,13 @@ package network import ( + "context" "encoding/json" "fmt" "path/filepath" - "time" + "cosmossdk.io/log" + cmtcfg "github.com/cometbft/cometbft/config" tmos "github.com/cometbft/cometbft/libs/os" "github.com/cometbft/cometbft/node" "github.com/cometbft/cometbft/p2p" @@ -28,12 +30,14 @@ import ( "github.com/cometbft/cometbft/proxy" "github.com/cometbft/cometbft/rpc/client/local" "github.com/cometbft/cometbft/types" - tmtime "github.com/cometbft/cometbft/types/time" + cmttime "github.com/cometbft/cometbft/types/time" "github.com/ethereum/go-ethereum/ethclient" + "golang.org/x/sync/errgroup" + sdkserver "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" - srvtypes "github.com/cosmos/cosmos-sdk/server/types" + servercmtlog "github.com/cosmos/cosmos-sdk/server/log" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" @@ -51,30 +55,31 @@ import ( func startInProcess(cfg Config, val *Validator) error { logger := val.Ctx.Logger - tmCfg := val.Ctx.Config - tmCfg.Instrumentation.Prometheus = false + cmtCfg := val.Ctx.Config + cmtCfg.Instrumentation.Prometheus = false if err := val.AppConfig.ValidateBasic(); err != nil { return err } - nodeKey, err := p2p.LoadOrGenNodeKey(tmCfg.NodeKeyFile()) + nodeKey, err := p2p.LoadOrGenNodeKey(cmtCfg.NodeKeyFile()) if err != nil { return err } app := cfg.AppConstructor(*val) - genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg) + genDocProvider := server.GenDocProvider(cmtCfg) + cmtApp := sdkserver.NewCometABCIWrapper(app) tmNode, err := node.NewNode( - tmCfg, - pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()), + cmtCfg, + pvm.LoadOrGenFilePV(cmtCfg.PrivValidatorKeyFile(), cmtCfg.PrivValidatorStateFile()), nodeKey, - proxy.NewLocalClientCreator(app), + proxy.NewLocalClientCreator(cmtApp), genDocProvider, - node.DefaultDBProvider, - node.DefaultMetricsProvider(tmCfg.Instrumentation), - logger.With("module", val.Moniker), + cmtcfg.DefaultDBProvider, + node.DefaultMetricsProvider(cmtCfg.Instrumentation), + servercmtlog.CometLoggerWrapper{Logger: logger.With("module", val.Moniker)}, ) if err != nil { return err @@ -100,43 +105,37 @@ func startInProcess(cfg Config, val *Validator) error { // Add the tendermint queries service in the gRPC router. app.RegisterTendermintService(val.ClientCtx) + app.RegisterNodeService(val.ClientCtx, val.AppConfig.Config) } + ctx := context.Background() + ctx, val.cancelFn = context.WithCancel(ctx) + val.errGroup, ctx = errgroup.WithContext(ctx) + if val.AppConfig.API.Enable && val.APIAddress != "" { - apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server")) + apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server"), val.grpc) app.RegisterAPIRoutes(apiSrv, val.AppConfig.API) - errCh := make(chan error) - - go func() { - if err := apiSrv.Start(val.AppConfig.Config); err != nil { - errCh <- err - } - }() - - select { - case err := <-errCh: - return err - case <-time.After(srvtypes.ServerStartTime): // assume server started successfully - } + val.errGroup.Go(func() error { + return apiSrv.Start(ctx, val.AppConfig.Config) + }) val.api = apiSrv } if val.AppConfig.GRPC.Enable { - grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC) + grpcSrv, err := servergrpc.NewGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC) if err != nil { return err } - val.grpc = grpcSrv + // Start the gRPC server in a goroutine. Note, the provided ctx will ensure + // that the server is gracefully shut down. + val.errGroup.Go(func() error { + return servergrpc.StartGRPCServer(ctx, logger.With(log.ModuleKey, "grpc-server"), val.AppConfig.GRPC, grpcSrv) + }) - if val.AppConfig.GRPCWeb.Enable { - val.grpcWeb, err = servergrpc.StartGRPCWeb(grpcSrv, val.AppConfig.Config) - if err != nil { - return err - } - } + val.grpc = grpcSrv } if val.AppConfig.JSONRPC.Enable && val.AppConfig.JSONRPC.Address != "" { @@ -144,10 +143,7 @@ func startInProcess(cfg Config, val *Validator) error { return fmt.Errorf("validator %s context is nil", val.Moniker) } - tmEndpoint := "/websocket" - tmRPCAddr := val.RPCAddress - - val.jsonrpc, val.jsonrpcDone, err = server.StartJSONRPC(val.Ctx, val.ClientCtx, tmRPCAddr, tmEndpoint, val.AppConfig, nil) + val.jsonrpc, val.jsonrpcDone, err = server.StartJSONRPC(val.Ctx, val.ClientCtx, val.errGroup, val.AppConfig, nil) if err != nil { return err } @@ -164,7 +160,7 @@ func startInProcess(cfg Config, val *Validator) error { } func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error { - genTime := tmtime.Now() + genTime := cmttime.Now() for i := 0; i < cfg.NumValidators; i++ { tmCfg := vals[i].Ctx.Config @@ -178,13 +174,19 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error { initCfg := genutiltypes.NewInitConfig(cfg.ChainID, gentxsDir, vals[i].NodeID, vals[i].PubKey) genFile := tmCfg.GenesisFile() - genDoc, err := types.GenesisDocFromFile(genFile) + genDoc, err := genutiltypes.AppGenesisFromFile(genFile) if err != nil { return err } appState, err := genutil.GenAppStateFromConfig(cfg.Codec, cfg.TxConfig, - tmCfg, initCfg, *genDoc, banktypes.GenesisBalancesIterator{}, genutiltypes.DefaultMessageValidator) + tmCfg, + initCfg, + genDoc, + banktypes.GenesisBalancesIterator{}, + genutiltypes.DefaultMessageValidator, + cfg.TxConfig.SigningContext().ValidatorAddressCodec(), + ) if err != nil { return err } diff --git a/testutil/tx/cosmos.go b/testutil/tx/cosmos.go index 8ba200fb..2a2a0a09 100644 --- a/testutil/tx/cosmos.go +++ b/testutil/tx/cosmos.go @@ -31,7 +31,7 @@ import ( var ( feeAmt = math.Pow10(16) - DefaultFee = sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewIntFromUint64(uint64(feeAmt))) + DefaultFee = sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewIntFromUint64(uint64(feeAmt))) ) // CosmosTxArgs contains the params to create a cosmos tx @@ -102,12 +102,17 @@ func signCosmosTx( return nil, err } + signMode, err := authsigning.APISignModeToInternal(args.TxCfg.SignModeHandler().DefaultMode()) + if err != nil { + return nil, err + } + // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. sigV2 := signing.SignatureV2{ PubKey: args.Priv.PubKey(), Data: &signing.SingleSignatureData{ - SignMode: args.TxCfg.SignModeHandler().DefaultMode(), + SignMode: signMode, Signature: nil, }, Sequence: seq, @@ -127,7 +132,8 @@ func signCosmosTx( Sequence: seq, } sigV2, err = tx.SignWithPrivKey( - args.TxCfg.SignModeHandler().DefaultMode(), + ctx, + signMode, signerData, txBuilder, args.Priv, args.TxCfg, seq, diff --git a/testutil/tx/eip712.go b/testutil/tx/eip712.go index 9ec95b32..ed0377d8 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -113,7 +113,7 @@ func PrepareEIP712CosmosTx( fee := legacytx.NewStdFee(txArgs.Gas, txArgs.Fees) //nolint: staticcheck msgs := txArgs.Msgs - data := legacytx.StdSignBytes(ctx.ChainID(), accNumber, nonce, 0, fee, msgs, "", nil) + data := legacytx.StdSignBytes(ctx.ChainID(), accNumber, nonce, 0, fee, msgs, "") typedDataArgs := typedDataArgs{ chainID: chainIDNum, @@ -199,7 +199,7 @@ func signCosmosEIP712Tx( } keyringSigner := NewSigner(priv) - signature, pubKey, err := keyringSigner.SignByAddress(from, sigHash) + signature, pubKey, err := keyringSigner.SignByAddress(from, sigHash, signing.SignMode_SIGN_MODE_TEXTUAL) if err != nil { return nil, err } diff --git a/testutil/tx/signer.go b/testutil/tx/signer.go index 7dc0de22..1671f93c 100644 --- a/testutil/tx/signer.go +++ b/testutil/tx/signer.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" ) @@ -39,7 +40,7 @@ func NewSigner(sk cryptotypes.PrivKey) keyring.Signer { } // Sign signs the message using the underlying private key -func (s Signer) Sign(_ string, msg []byte) ([]byte, cryptotypes.PubKey, error) { +func (s Signer) Sign(_ string, msg []byte, _ signing.SignMode) ([]byte, cryptotypes.PubKey, error) { if s.privKey.Type() != ethsecp256k1.KeyType { return nil, nil, fmt.Errorf( "invalid private key type for signing ethereum tx; expected %s, got %s", @@ -57,11 +58,11 @@ func (s Signer) Sign(_ string, msg []byte) ([]byte, cryptotypes.PubKey, error) { } // SignByAddress sign byte messages with a user key providing the address. -func (s Signer) SignByAddress(address sdk.Address, msg []byte) ([]byte, cryptotypes.PubKey, error) { +func (s Signer) SignByAddress(address sdk.Address, msg []byte, signMode signing.SignMode) ([]byte, cryptotypes.PubKey, error) { signer := sdk.AccAddress(s.privKey.PubKey().Address()) if !signer.Equals(address) { return nil, nil, fmt.Errorf("address mismatch: signer %s ≠ given address %s", signer, address) } - return s.Sign("", msg) + return s.Sign("", msg, signMode) } diff --git a/types/account.go b/types/account.go index 39be5441..e8ed4ef4 100644 --- a/types/account.go +++ b/types/account.go @@ -19,6 +19,7 @@ import ( "bytes" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -26,7 +27,7 @@ import ( ) var ( - _ authtypes.AccountI = (*EthAccount)(nil) + _ sdk.AccountI = (*EthAccount)(nil) _ EthAccountI = (*EthAccount)(nil) _ authtypes.GenesisAccount = (*EthAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*EthAccount)(nil) @@ -43,7 +44,7 @@ const ( // EthAccountI represents the interface of an EVM compatible account type EthAccountI interface { - authtypes.AccountI + sdk.AccountI // EthAddress returns the ethereum Address representation of the AccAddress EthAddress() common.Address // CodeHash is the keccak256 hash of the contract code (if any) @@ -60,7 +61,7 @@ type EthAccountI interface { // ProtoAccount defines the prototype function for BaseAccount used for an // AccountKeeper. -func ProtoAccount() authtypes.AccountI { +func ProtoAccount() sdk.AccountI { return &EthAccount{ BaseAccount: &authtypes.BaseAccount{}, CodeHash: common.BytesToHash(emptyCodeHash).String(), diff --git a/types/account.pb.go b/types/account.pb.go index 6dcc416e..5e54c38b 100644 --- a/types/account.pb.go +++ b/types/account.pb.go @@ -25,7 +25,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// EthAccount implements the authtypes.AccountI interface and embeds an +// EthAccount implements the sdk.AccountI interface and embeds an // authtypes.BaseAccount type. It is compatible with the auth AccountKeeper. type EthAccount struct { // base_account is an authtypes.BaseAccount @@ -73,28 +73,26 @@ func init() { func init() { proto.RegisterFile("ethermint/types/v1/account.proto", fileDescriptor_4edc057d42a619ef) } var fileDescriptor_4edc057d42a619ef = []byte{ - // 322 bytes of a gzipped FileDescriptorProto + // 299 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x2d, 0xc9, 0x48, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xab, 0xd0, 0x03, 0xab, 0xd0, 0x2b, 0x33, 0x94, 0x92, 0x4b, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x2c, 0x2d, 0xc9, 0xd0, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0x04, 0x73, 0x20, 0x7a, 0xa4, 0x24, 0x21, 0xf2, 0xf1, 0x60, 0x9e, 0x3e, 0x84, 0x03, 0x95, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x87, - 0x88, 0x83, 0x58, 0x10, 0x51, 0xa5, 0x9f, 0x8c, 0x5c, 0x5c, 0xae, 0x25, 0x19, 0x8e, 0x10, 0x9b, + 0x88, 0x83, 0x58, 0x10, 0x51, 0xa5, 0xf3, 0x8c, 0x5c, 0x5c, 0xae, 0x25, 0x19, 0x8e, 0x10, 0x9b, 0x85, 0x12, 0xb8, 0x78, 0x92, 0x12, 0x8b, 0x53, 0xe3, 0xa1, 0x2e, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x52, 0xd0, 0x83, 0x9a, 0x04, 0xb6, 0x09, 0x6a, 0xad, 0x9e, 0x53, 0x62, 0x71, 0x2a, 0x54, 0x9f, 0x93, 0xf4, 0x85, 0x7b, 0xf2, 0x8c, 0x9f, 0xee, 0xc9, 0x0b, 0x57, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0x21, 0x9b, 0xa1, 0x14, 0xc4, 0x9d, 0x84, 0x50, 0x29, 0x64, 0xc8, 0xc5, 0x99, 0x9c, 0x9f, 0x92, 0x1a, 0x9f, 0x91, 0x58, 0x9c, 0x21, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0xf2, 0xe9, 0x9e, 0xbc, 0x00, 0x44, 0x23, 0x5c, 0x4a, 0x29, 0x88, 0x03, 0xc4, 0xf6, 0x48, 0x2c, 0xce, - 0xb0, 0x0a, 0xeb, 0x58, 0x20, 0xcf, 0x30, 0x63, 0x81, 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x0c, 0xa7, - 0xb6, 0xe8, 0xba, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0x42, 0xbd, 0x08, - 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x2b, 0x20, 0x81, 0x03, 0x09, 0x32, 0x6c, 0xee, 0x86, 0xba, - 0xc4, 0xd3, 0xc9, 0xfe, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, - 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x54, 0x91, - 0x6c, 0xa8, 0x4a, 0x2d, 0x49, 0xd4, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x47, 0x8b, 0xb2, 0x24, - 0x36, 0x70, 0x18, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf3, 0xa9, 0x6d, 0x5e, 0xcc, 0x01, - 0x00, 0x00, + 0xb0, 0xd2, 0xe9, 0x58, 0x20, 0xcf, 0x30, 0x63, 0x81, 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x0c, 0xa7, + 0xb6, 0xe8, 0xca, 0x60, 0x73, 0x0d, 0xd4, 0x7c, 0x4f, 0x27, 0xab, 0x13, 0x8f, 0xe4, 0x18, 0x2f, + 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, + 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, + 0xd5, 0x4f, 0x2d, 0x03, 0x05, 0x23, 0x5a, 0x1c, 0x24, 0xb1, 0x81, 0x03, 0xc5, 0x18, 0x10, 0x00, + 0x00, 0xff, 0xff, 0x74, 0xdc, 0xb8, 0x35, 0x9d, 0x01, 0x00, 0x00, } func (m *EthAccount) Marshal() (dAtA []byte, err error) { diff --git a/types/block.go b/types/block.go index 430277b5..0642f071 100644 --- a/types/block.go +++ b/types/block.go @@ -30,7 +30,7 @@ func BlockGasLimit(ctx sdk.Context) uint64 { // Otherwise get from the consensus parameters cp := ctx.ConsensusParams() - if cp == nil || cp.Block == nil { + if cp.Block == nil { return 0 } diff --git a/types/codec.go b/types/codec.go index 84beb8c0..38ee8665 100644 --- a/types/codec.go +++ b/types/codec.go @@ -17,6 +17,7 @@ package types import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -25,7 +26,7 @@ import ( // implementations and interfaces. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( - (*authtypes.AccountI)(nil), + (*sdk.AccountI)(nil), &EthAccount{}, ) registry.RegisterImplementations( diff --git a/types/dynamic_fee.pb.go b/types/dynamic_fee.pb.go index 0eea1585..61e577b9 100644 --- a/types/dynamic_fee.pb.go +++ b/types/dynamic_fee.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -27,7 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ExtensionOptionDynamicFeeTx is an extension option that specifies the maxPrioPrice for cosmos tx type ExtensionOptionDynamicFeeTx struct { // max_priority_price is the same as `max_priority_fee_per_gas` in eip-1559 spec - MaxPriorityPrice github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=max_priority_price,json=maxPriorityPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_priority_price"` + MaxPriorityPrice cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=max_priority_price,json=maxPriorityPrice,proto3,customtype=cosmossdk.io/math.Int" json:"max_priority_price"` } func (m *ExtensionOptionDynamicFeeTx) Reset() { *m = ExtensionOptionDynamicFeeTx{} } @@ -72,22 +72,22 @@ func init() { } var fileDescriptor_9d7cf05c9992c480 = []byte{ - // 239 bytes of a gzipped FileDescriptorProto + // 234 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0x2d, 0xc9, 0x48, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0xa9, 0xcc, 0x4b, 0xcc, 0xcd, 0x4c, 0x8e, 0x4f, 0x4b, 0x4d, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xab, 0xd2, 0x03, 0xab, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x4a, 0xd5, 0x5c, 0xd2, 0xae, 0x15, 0x25, 0xa9, 0x79, + 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x4a, 0x59, 0x5c, 0xd2, 0xae, 0x15, 0x25, 0xa9, 0x79, 0xc5, 0x99, 0xf9, 0x79, 0xfe, 0x05, 0x25, 0x99, 0xf9, 0x79, 0x2e, 0x10, 0xd3, 0xdc, 0x52, 0x53, - 0x43, 0x2a, 0x84, 0x62, 0xb8, 0x84, 0x72, 0x13, 0x2b, 0xe2, 0x0b, 0x8a, 0x32, 0xf3, 0x8b, 0x32, - 0x4b, 0x2a, 0x41, 0x8c, 0xe4, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xbd, 0x13, 0xf7, - 0xe4, 0x19, 0x6e, 0xdd, 0x93, 0x57, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, - 0xd5, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x86, 0x52, 0xba, 0xc5, 0x29, 0xd9, 0x10, 0x57, 0xea, - 0x79, 0xe6, 0x95, 0x04, 0x09, 0xe4, 0x26, 0x56, 0x04, 0x40, 0x0d, 0x0a, 0x00, 0x99, 0xe3, 0x64, - 0x7f, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, - 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xaa, 0x48, 0x66, 0x56, 0xa5, - 0x96, 0x24, 0xea, 0x26, 0x67, 0x24, 0x66, 0xe6, 0xe9, 0xa3, 0x79, 0x3e, 0x89, 0x0d, 0xec, 0x09, - 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x88, 0x8e, 0xc5, 0x16, 0x01, 0x00, 0x00, + 0x43, 0x2a, 0x84, 0xbc, 0xb9, 0x84, 0x72, 0x13, 0x2b, 0xe2, 0x0b, 0x8a, 0x32, 0xf3, 0x8b, 0x32, + 0x4b, 0x2a, 0x41, 0x8c, 0xe4, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xd9, 0x13, 0xf7, + 0xe4, 0x19, 0x6e, 0xdd, 0x93, 0x17, 0x4d, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x2e, 0x4e, 0xc9, 0xd6, + 0xcb, 0xcc, 0xd7, 0xcf, 0x4d, 0x2c, 0xc9, 0xd0, 0xf3, 0xcc, 0x2b, 0x09, 0x12, 0xc8, 0x4d, 0xac, + 0x08, 0x80, 0xea, 0x0b, 0x00, 0x69, 0x73, 0xb2, 0x3a, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, + 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, + 0x39, 0x86, 0x28, 0x85, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xd4, + 0xb2, 0xdc, 0xfc, 0x62, 0x7d, 0x34, 0x6f, 0x26, 0xb1, 0x81, 0x9d, 0x6b, 0x0c, 0x08, 0x00, 0x00, + 0xff, 0xff, 0x8c, 0x36, 0x25, 0x41, 0x00, 0x01, 0x00, 0x00, } func (m *ExtensionOptionDynamicFeeTx) Marshal() (dAtA []byte, err error) { diff --git a/types/gasmeter.go b/types/gasmeter.go index ff9893c6..b18f6eb8 100644 --- a/types/gasmeter.go +++ b/types/gasmeter.go @@ -19,7 +19,7 @@ import ( fmt "fmt" math "math" - sdk "github.com/cosmos/cosmos-sdk/types" + storetypes "cosmossdk.io/store/types" ) // ErrorNegativeGasConsumed defines an error thrown when the amount of gas refunded results in a @@ -36,27 +36,27 @@ type ErrorGasOverflow struct { } type infiniteGasMeterWithLimit struct { - consumed sdk.Gas - limit sdk.Gas + consumed storetypes.Gas + limit storetypes.Gas } // NewInfiniteGasMeterWithLimit returns a reference to a new infiniteGasMeter. -func NewInfiniteGasMeterWithLimit(limit sdk.Gas) sdk.GasMeter { +func NewInfiniteGasMeterWithLimit(limit storetypes.Gas) storetypes.GasMeter { return &infiniteGasMeterWithLimit{ consumed: 0, limit: limit, } } -func (g *infiniteGasMeterWithLimit) GasConsumed() sdk.Gas { +func (g *infiniteGasMeterWithLimit) GasConsumed() storetypes.Gas { return g.consumed } -func (g *infiniteGasMeterWithLimit) GasConsumedToLimit() sdk.Gas { +func (g *infiniteGasMeterWithLimit) GasConsumedToLimit() storetypes.Gas { return g.consumed } -func (g *infiniteGasMeterWithLimit) Limit() sdk.Gas { +func (g *infiniteGasMeterWithLimit) Limit() storetypes.Gas { return g.limit } @@ -70,7 +70,7 @@ func addUint64Overflow(a, b uint64) (uint64, bool) { return a + b, false } -func (g *infiniteGasMeterWithLimit) ConsumeGas(amount sdk.Gas, descriptor string) { +func (g *infiniteGasMeterWithLimit) ConsumeGas(amount storetypes.Gas, descriptor string) { var overflow bool // TODO: Should we set the consumed field after overflow checking? g.consumed, overflow = addUint64Overflow(g.consumed, amount) @@ -85,7 +85,7 @@ func (g *infiniteGasMeterWithLimit) ConsumeGas(amount sdk.Gas, descriptor string // Use case: This functionality enables refunding gas to the trasaction or block gas pools so that // EVM-compatible chains can fully support the go-ethereum StateDb interface. // See https://github.com/cosmos/cosmos-sdk/pull/9403 for reference. -func (g *infiniteGasMeterWithLimit) RefundGas(amount sdk.Gas, descriptor string) { +func (g *infiniteGasMeterWithLimit) RefundGas(amount storetypes.Gas, descriptor string) { if g.consumed < amount { panic(ErrorNegativeGasConsumed{Descriptor: descriptor}) } @@ -105,6 +105,6 @@ func (g *infiniteGasMeterWithLimit) String() string { return fmt.Sprintf("InfiniteGasMeter:\n consumed: %d", g.consumed) } -func (g *infiniteGasMeterWithLimit) GasRemaining() sdk.Gas { +func (g *infiniteGasMeterWithLimit) GasRemaining() storetypes.Gas { return math.MaxUint64 } diff --git a/types/indexer.go b/types/indexer.go index 02896472..3b19122c 100644 --- a/types/indexer.go +++ b/types/indexer.go @@ -25,7 +25,7 @@ import ( type EVMTxIndexer interface { // LastIndexedBlock returns -1 if indexer db is empty LastIndexedBlock() (int64, error) - IndexBlock(*tmtypes.Block, []*abci.ResponseDeliverTx) error + IndexBlock(*tmtypes.Block, []*abci.ExecTxResult) error // GetByTxHash returns nil if tx not found. GetByTxHash(common.Hash) (*TxResult, error) diff --git a/x/evm/genesis.go b/x/evm/genesis.go index ae88c078..ab62e848 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -21,7 +21,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -89,7 +88,7 @@ func InitGenesis( // ExportGenesis exports genesis state of the EVM module func ExportGenesis(ctx sdk.Context, k *keeper.Keeper, ak types.AccountKeeper) *types.GenesisState { var ethGenAccounts []types.GenesisAccount - ak.IterateAccounts(ctx, func(account authtypes.AccountI) bool { + ak.IterateAccounts(ctx, func(account sdk.AccountI) bool { ethAccount, ok := account.(ethermint.EthAccountI) if !ok { // ignore non EthAccounts diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index 2575d9f7..a1dfe53f 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -67,7 +67,8 @@ func (suite *EvmTestSuite) TestInitGenesis() { "invalid account type", func() { acc := authtypes.NewBaseAccountWithAddress(address.Bytes()) - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) + acc.AccountNumber = suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) + suite.App.AccountKeeper.SetAccount(suite.Ctx, acc) }, &types.GenesisState{ Params: types.DefaultParams(), @@ -117,8 +118,8 @@ func (suite *EvmTestSuite) TestInitGenesis() { { "ignore empty account code checking with non-empty codehash", func() { - ethAcc := ðerminttypes.EthAccount{ - BaseAccount: authtypes.NewBaseAccount(address.Bytes(), nil, 0, 0), + ethAcc := ðermint.EthAccount{ + BaseAccount: authtypes.NewBaseAccount(address.Bytes(), nil, suite.App.AccountKeeper.NextAccountNumber(suite.Ctx), 0), CodeHash: common.BytesToHash([]byte{1, 2, 3}).Hex(), } diff --git a/x/evm/handler.go b/x/evm/handler.go deleted file mode 100644 index c0965d36..00000000 --- a/x/evm/handler.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2021 Evmos Foundation -// This file is part of Evmos' Ethermint library. -// -// The Ethermint library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The Ethermint library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the Ethermint library. If not, see https://github.com/zeta-chain/ethermint/blob/main/LICENSE -package evm - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - errortypes "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/zeta-chain/ethermint/x/evm/types" -) - -// NewHandler returns a handler for Ethermint type messages. -func NewHandler(server types.MsgServer) sdk.Handler { - return func(ctx sdk.Context, msg sdk.Msg) (result *sdk.Result, err error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgEthereumTx: - res, err := server.EthereumTx(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgUpdateParams: - res, err := server.UpdateParams(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - default: - err := errorsmod.Wrapf(errortypes.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) - return nil, err - } - } -} diff --git a/x/evm/handler_test.go b/x/evm/handler_test.go index 5b7405b8..c985873f 100644 --- a/x/evm/handler_test.go +++ b/x/evm/handler_test.go @@ -9,7 +9,7 @@ import ( "github.com/zeta-chain/ethermint/x/evm/keeper" sdkmath "cosmossdk.io/math" - "github.com/cosmos/gogoproto/proto" + storetypes "cosmossdk.io/store/types" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" @@ -32,31 +32,14 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/tests" - ethermint "github.com/zeta-chain/ethermint/types" - "github.com/zeta-chain/ethermint/x/evm" - "github.com/zeta-chain/ethermint/x/evm/statedb" - "github.com/zeta-chain/ethermint/x/evm/types" - - "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmversion "github.com/cometbft/cometbft/proto/tendermint/version" - - "github.com/cometbft/cometbft/version" + "github.com/evmos/ethermint/app" + ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/types" ) -type EvmTestSuite struct { - suite.Suite - - ctx sdk.Context - handler sdk.Handler - app *app.EthermintApp - codec codec.Codec - chainID *big.Int - - signer keyring.Signer +type HandlerTestSuite struct { + testutil.BaseTestSuiteWithAccount + chainID *big.Int ethSigner ethtypes.Signer from common.Address to sdk.AccAddress @@ -88,86 +71,7 @@ func (suite *EvmTestSuite) DoSetupTest(t require.TestingT) { } return genesis }) - - coins := sdk.NewCoins(sdk.NewCoin(types.DefaultEVMDenom, sdkmath.NewInt(100000000000000))) - genesisState := app.NewTestGenesisState(suite.app.AppCodec()) - b32address := sdk.MustBech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), priv.PubKey().Address().Bytes()) - balances := []banktypes.Balance{ - { - Address: b32address, - Coins: coins, - }, - { - Address: suite.app.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName).String(), - Coins: coins, - }, - } - var bankGenesis banktypes.GenesisState - suite.app.AppCodec().MustUnmarshalJSON(genesisState[banktypes.ModuleName], &bankGenesis) - // Update balances and total supply - bankGenesis.Balances = append(bankGenesis.Balances, balances...) - bankGenesis.Supply = bankGenesis.Supply.Add(coins...).Add(coins...) - genesisState[banktypes.ModuleName] = suite.app.AppCodec().MustMarshalJSON(&bankGenesis) - - stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ") - require.NoError(t, err) - - // Initialize the chain - suite.app.InitChain( - abci.RequestInitChain{ - ChainId: "ethermint_9000-1", - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: app.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{ - Height: 1, - ChainID: "ethermint_9000-1", - Time: time.Now().UTC(), - ProposerAddress: consAddress.Bytes(), - Version: tmversion.Consensus{ - Block: version.BlockProtocol, - }, - LastBlockId: tmproto.BlockID{ - Hash: tmhash.Sum([]byte("block_id")), - PartSetHeader: tmproto.PartSetHeader{ - Total: 11, - Hash: tmhash.Sum([]byte("partset_header")), - }, - }, - AppHash: tmhash.Sum([]byte("app")), - DataHash: tmhash.Sum([]byte("data")), - EvidenceHash: tmhash.Sum([]byte("evidence")), - ValidatorsHash: tmhash.Sum([]byte("validators")), - NextValidatorsHash: tmhash.Sum([]byte("next_validators")), - ConsensusHash: tmhash.Sum([]byte("consensus")), - LastResultsHash: tmhash.Sum([]byte("last_result")), - }) - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.EvmKeeper) - - acc := ðermint.EthAccount{ - BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(address.Bytes()), nil, 0, 0), - CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(), - } - - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - - valAddr := sdk.ValAddress(address.Bytes()) - validator, err := stakingtypes.NewValidator(valAddr, priv.PubKey(), stakingtypes.Description{}) - require.NoError(t, err) - - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) - require.NoError(t, err) - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) - require.NoError(t, err) - suite.app.StakingKeeper.SetValidator(suite.ctx, validator) - - suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) - suite.handler = evm.NewHandler(suite.app.EvmKeeper) + suite.ethSigner = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) } func (suite *EvmTestSuite) SetupTest() { @@ -223,7 +127,7 @@ func (suite *EvmTestSuite) TestHandleMsgEthereumTx() { { "invalid chain ID", func() { - suite.ctx = suite.ctx.WithChainID("chainID") + suite.Ctx = suite.Ctx.WithChainID("chainID").WithConsensusParams(*app.DefaultConsensusParams) }, false, }, @@ -241,7 +145,7 @@ func (suite *EvmTestSuite) TestHandleMsgEthereumTx() { suite.SetupTest() // reset //nolint tc.malleate() - res, err := suite.handler(suite.ctx, tx) + res, err := suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) //nolint if tc.expPass { @@ -282,14 +186,9 @@ func (suite *EvmTestSuite) TestHandlerLogs() { tx := types.NewTx(suite.chainID, 1, nil, big.NewInt(0), gasLimit, gasPrice, nil, nil, bytecode, nil) suite.SignTx(tx) - result, err := suite.handler(suite.ctx, tx) + txResponse, err := suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) suite.Require().NoError(err, "failed to handle eth tx msg") - var txResponse types.MsgEthereumTxResponse - - err = proto.Unmarshal(result.Data, &txResponse) - suite.Require().NoError(err, "failed to decode result data") - suite.Require().Equal(len(txResponse.Logs), 1) suite.Require().Equal(len(txResponse.Logs[0].Topics), 2) } @@ -357,13 +256,8 @@ func (suite *EvmTestSuite) TestDeployAndCallContract() { tx := types.NewTx(suite.chainID, 1, nil, big.NewInt(0), gasLimit, gasPrice, nil, nil, bytecode, nil) suite.SignTx(tx) - result, err := suite.handler(suite.ctx, tx) + res, err := suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) suite.Require().NoError(err, "failed to handle eth tx msg") - - var res types.MsgEthereumTxResponse - - err = proto.Unmarshal(result.Data, &res) - suite.Require().NoError(err, "failed to decode result data") suite.Require().Equal(res.VmError, "", "failed to handle eth tx msg") // store - changeOwner @@ -376,11 +270,8 @@ func (suite *EvmTestSuite) TestDeployAndCallContract() { tx = types.NewTx(suite.chainID, 2, &receiver, big.NewInt(0), gasLimit, gasPrice, nil, nil, bytecode, nil) suite.SignTx(tx) - result, err = suite.handler(suite.ctx, tx) + res, err = suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) suite.Require().NoError(err, "failed to handle eth tx msg") - - err = proto.Unmarshal(result.Data, &res) - suite.Require().NoError(err, "failed to decode result data") suite.Require().Equal(res.VmError, "", "failed to handle eth tx msg") // query - getOwner @@ -388,11 +279,8 @@ func (suite *EvmTestSuite) TestDeployAndCallContract() { tx = types.NewTx(suite.chainID, 2, &receiver, big.NewInt(0), gasLimit, gasPrice, nil, nil, bytecode, nil) suite.SignTx(tx) - result, err = suite.handler(suite.ctx, tx) + res, err = suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) suite.Require().NoError(err, "failed to handle eth tx msg") - - err = proto.Unmarshal(result.Data, &res) - suite.Require().NoError(err, "failed to decode result data") suite.Require().Equal(res.VmError, "", "failed to handle eth tx msg") // FIXME: correct owner? @@ -408,7 +296,7 @@ func (suite *EvmTestSuite) TestSendTransaction() { tx := types.NewTx(suite.chainID, 1, &common.Address{0x1}, big.NewInt(1), gasLimit, gasPrice, nil, nil, nil, nil) suite.SignTx(tx) - result, err := suite.handler(suite.ctx, tx) + result, err := suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) suite.Require().NoError(err) suite.Require().NotNil(result) } @@ -470,7 +358,7 @@ func (suite *EvmTestSuite) TestOutOfGasWhenDeployContract() { // Deploy contract - Owner.sol gasLimit := uint64(1) - suite.ctx = suite.ctx.WithGasMeter(sdk.NewGasMeter(gasLimit)) + suite.Ctx = suite.Ctx.WithGasMeter(storetypes.NewGasMeter(gasLimit)).WithConsensusParams(*app.DefaultConsensusParams) gasPrice := big.NewInt(10000) bytecode := common.FromHex("0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a36102c4806100dc6000396000f3fe608060405234801561001057600080fd5b5060043610610053576000357c010000000000000000000000000000000000000000000000000000000090048063893d20e814610058578063a6f9dae1146100a2575b600080fd5b6100606100e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100e4600480360360208110156100b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061010f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f43616c6c6572206973206e6f74206f776e65720000000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fea265627a7a72315820f397f2733a89198bc7fed0764083694c5b828791f39ebcbc9e414bccef14b48064736f6c63430005100032") @@ -485,7 +373,7 @@ func (suite *EvmTestSuite) TestOutOfGasWhenDeployContract() { } }() - suite.handler(suite.ctx, tx) + suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) suite.Require().Fail("panic did not happen") } @@ -498,11 +386,7 @@ func (suite *EvmTestSuite) TestErrorWhenDeployContract() { tx := types.NewTx(suite.chainID, 1, nil, big.NewInt(0), gasLimit, gasPrice, nil, nil, bytecode, nil) suite.SignTx(tx) - result, _ := suite.handler(suite.ctx, tx) - var res types.MsgEthereumTxResponse - - _ = proto.Unmarshal(result.Data, &res) - + res, _ := suite.App.EvmKeeper.EthereumTx(suite.Ctx, tx) suite.Require().Equal("invalid opcode: opcode 0xa6 not defined", res.VmError, "correct evm error") // TODO: snapshot checking @@ -607,7 +491,7 @@ func (suite *EvmTestSuite) TestERC20TransferReverted() { err = k.DeductTxCostsFromUserBalance(suite.ctx, fees, common.HexToAddress(tx.From)) suite.Require().NoError(err) - res, err := k.EthereumTx(sdk.WrapSDKContext(suite.ctx), tx) + res, err := k.EthereumTx(suite.Ctx, tx) suite.Require().NoError(err) suite.Require().True(res.Failed()) @@ -680,7 +564,7 @@ func (suite *EvmTestSuite) TestContractDeploymentRevert() { db.SetNonce(suite.from, nonce+1) suite.Require().NoError(db.Commit()) - rsp, err := k.EthereumTx(sdk.WrapSDKContext(suite.ctx), tx) + rsp, err := k.EthereumTx(suite.Ctx, tx) suite.Require().NoError(err) suite.Require().True(rsp.Failed()) diff --git a/x/evm/keeper/abci.go b/x/evm/keeper/abci.go index d3663a4b..2b027cfc 100644 --- a/x/evm/keeper/abci.go +++ b/x/evm/keeper/abci.go @@ -16,7 +16,7 @@ package keeper import ( - abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,19 +24,20 @@ import ( ) // BeginBlock sets the sdk Context and EIP155 chain id to the Keeper. -func (k *Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +func (k *Keeper) BeginBlock(ctx sdk.Context) error { k.WithChainID(ctx) + return nil } // EndBlock also retrieves the bloom filter value from the transient store and commits it to the // KVStore. The EVM end block logic doesn't update the validator set, thus it returns // an empty slice. -func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (k *Keeper) EndBlock(ctx sdk.Context) error { // Gas costs are handled within msg handler so costs should be ignored - infCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) + infCtx := ctx.WithGasMeter(types.NewInfiniteGasMeter()) bloom := ethtypes.BytesToBloom(k.GetBlockBloomTransient(infCtx).Bytes()) k.EmitBlockBloomEvent(infCtx, bloom) - return []abci.ValidatorUpdate{} + return nil } diff --git a/x/evm/keeper/abci_test.go b/x/evm/keeper/abci_test.go index 314f2dfd..482c362a 100644 --- a/x/evm/keeper/abci_test.go +++ b/x/evm/keeper/abci_test.go @@ -1,16 +1,14 @@ package keeper_test import ( - "github.com/cometbft/cometbft/abci/types" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" ) func (suite *KeeperTestSuite) TestEndBlock() { em := suite.ctx.EventManager() suite.Require().Equal(0, len(em.Events())) - res := suite.app.EvmKeeper.EndBlock(suite.ctx, types.RequestEndBlock{}) - suite.Require().Equal([]types.ValidatorUpdate{}, res) + suite.Require().NoError(suite.App.EvmKeeper.EndBlock(suite.Ctx)) // should emit 1 EventTypeBlockBloom event on EndBlock suite.Require().Equal(1, len(em.Events())) diff --git a/x/evm/keeper/benchmark_test.go b/x/evm/keeper/benchmark_test.go index 690eff37..671aad69 100644 --- a/x/evm/keeper/benchmark_test.go +++ b/x/evm/keeper/benchmark_test.go @@ -16,9 +16,50 @@ import ( "github.com/zeta-chain/ethermint/x/evm/types" ) -func SetupContract(b *testing.B) (*KeeperTestSuite, common.Address) { - suite := KeeperTestSuite{} - suite.SetupTestWithT(b) +type KeeperBenchmarkTestSuite struct { + testutil.EVMTestSuiteWithAccountAndQueryClient +} + +// deployTestMessageCall deploy a test erc20 contract and returns the contract address +func (suite *KeeperBenchmarkTestSuite) deployTestMessageCall(b *testing.B) common.Address { + chainID := suite.App.EvmKeeper.ChainID() + data := types.TestMessageCall.Bin + args, err := json.Marshal(&types.TransactionArgs{ + From: &suite.Address, + Data: (*hexutil.Bytes)(&data), + }) + require.NoError(b, err) + + res, err := suite.EvmQueryClient.EstimateGas(suite.Ctx, &types.EthCallRequest{ + Args: args, + GasCap: uint64(config.DefaultGasCap), + ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, + }) + require.NoError(b, err) + + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + erc20DeployTx := types.NewTxContract( + chainID, + nonce, + nil, // amount + res.Gas, // gasLimit + nil, // gasPrice + nil, nil, + data, // input + nil, // accesses + ) + erc20DeployTx.From = suite.Address.Bytes() + err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.Signer) + require.NoError(b, err) + rsp, err := suite.App.EvmKeeper.EthereumTx(suite.Ctx, erc20DeployTx) + require.NoError(b, err) + require.Empty(b, rsp.VmError) + return crypto.CreateAddress(suite.Address, nonce) +} + +func setupContract(b *testing.B) (*KeeperBenchmarkTestSuite, common.Address) { + suite := KeeperBenchmarkTestSuite{} + suite.SetupTest(b) amt := sdk.Coins{ethermint.NewPhotonCoinInt64(1000000000000000000)} err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt) @@ -26,8 +67,8 @@ func SetupContract(b *testing.B) (*KeeperTestSuite, common.Address) { err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt) require.NoError(b, err) - contractAddr := suite.DeployTestContract(b, suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) - suite.Commit() + contractAddr := suite.DeployTestContract(b, suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt(), false) + suite.Commit(b) return &suite, contractAddr } @@ -42,8 +83,8 @@ func SetupTestMessageCall(b *testing.B) (*KeeperTestSuite, common.Address) { err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt) require.NoError(b, err) - contractAddr := suite.DeployTestMessageCall(b) - suite.Commit() + contractAddr := suite.deployTestMessageCall(b) + suite.Commit(b) return &suite, contractAddr } @@ -71,7 +112,7 @@ func DoBenchmark(b *testing.B, txBuilder TxBuilder) { err = authante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees) require.NoError(b, err) - rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg) + rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, msg) require.NoError(b, err) require.False(b, rsp.Failed()) } @@ -138,7 +179,7 @@ func BenchmarkMessageCall(b *testing.B) { err = authante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees) require.NoError(b, err) - rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg) + rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, msg) require.NoError(b, err) require.False(b, rsp.Failed()) } diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index bff6c671..c69dcd52 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -119,13 +119,16 @@ func (k Keeper) ValidatorAccount(c context.Context, req *types.QueryValidatorAcc ctx := sdk.UnwrapSDKContext(c) - validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, consAddr) - if !found { - return nil, fmt.Errorf("validator not found for %s", consAddr.String()) + validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, consAddr) + if err != nil { + return nil, fmt.Errorf("validator not found for %s, %w", consAddr.String(), err) } - accAddr := sdk.AccAddress(validator.GetOperator()) - + bz, err := sdk.ValAddressFromBech32(validator.GetOperator()) + if err != nil { + return nil, err + } + accAddr := sdk.AccAddress(bz) res := types.QueryValidatorAccountResponse{ AccountAddress: accAddr.String(), } @@ -301,12 +304,8 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type hi = uint64(*args.Gas) } else { // Query block gas limit - params, err := k.ck.Get(ctx) - if err != nil { - return nil, err - } - if params != nil && params.Block != nil && params.Block.MaxGas > 0 { - // #nosec G115 MaxGas range checked + params := ctx.ConsensusParams() + if params.Block != nil && params.Block.MaxGas > 0 { hi = uint64(params.Block.MaxGas) } else { hi = req.GasCap diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index 151b020d..92ab2067 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -3,30 +3,136 @@ package keeper_test import ( "encoding/json" "fmt" + "math" "math/big" + "testing" sdkmath "cosmossdk.io/math" - + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" ethlogger "github.com/ethereum/go-ethereum/eth/tracers/logger" ethparams "github.com/ethereum/go-ethereum/params" - "github.com/zeta-chain/ethermint/tests" - "github.com/zeta-chain/ethermint/x/evm/statedb" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/zeta-chain/ethermint/server/config" - ethermint "github.com/zeta-chain/ethermint/types" - "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/server/config" + "github.com/evmos/ethermint/tests" + "github.com/evmos/ethermint/testutil" + ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" ) // Not valid Ethereum address const invalidAddress = "0x0000" -func (suite *KeeperTestSuite) TestQueryAccount() { +type GRPCServerTestSuiteSuite struct { + testutil.EVMTestSuiteWithAccountAndQueryClient + enableFeemarket bool + enableLondonHF bool +} + +func (suite *GRPCServerTestSuiteSuite) SetupTest() { + suite.EVMTestSuiteWithAccountAndQueryClient.SetupTestWithCb(suite.T(), func(app *app.EthermintApp, genesis app.GenesisState) app.GenesisState { + feemarketGenesis := feemarkettypes.DefaultGenesisState() + if suite.enableFeemarket { + feemarketGenesis.Params.EnableHeight = 1 + feemarketGenesis.Params.NoBaseFee = false + } else { + feemarketGenesis.Params.NoBaseFee = true + } + genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis) + if !suite.enableLondonHF { + evmGenesis := types.DefaultGenesisState() + maxInt := sdkmath.NewInt(math.MaxInt64) + evmGenesis.Params.ChainConfig.LondonBlock = &maxInt + evmGenesis.Params.ChainConfig.ArrowGlacierBlock = &maxInt + evmGenesis.Params.ChainConfig.GrayGlacierBlock = &maxInt + evmGenesis.Params.ChainConfig.MergeNetsplitBlock = &maxInt + evmGenesis.Params.ChainConfig.ShanghaiTime = &maxInt + genesis[types.ModuleName] = app.AppCodec().MustMarshalJSON(evmGenesis) + } + return genesis + }) +} + +func TestGRPCServerTestSuite(t *testing.T) { + s := new(GRPCServerTestSuiteSuite) + s.enableFeemarket = false + s.enableLondonHF = true + suite.Run(t, s) +} + +// deployTestContract deploy a test erc20 contract and returns the contract address +func (suite *GRPCServerTestSuiteSuite) deployTestContract(owner common.Address) common.Address { + supply := sdkmath.NewIntWithDecimal(1000, 18).BigInt() + return suite.EVMTestSuiteWithAccountAndQueryClient.DeployTestContract( + suite.T(), + owner, + supply, + suite.enableFeemarket, + ) +} + +func (suite *GRPCServerTestSuiteSuite) transferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx { + chainID := suite.App.EvmKeeper.ChainID() + + transferData, err := types.ERC20Contract.ABI.Pack("transfer", to, amount) + require.NoError(t, err) + args, err := json.Marshal(&types.TransactionArgs{To: &contractAddr, From: &from, Data: (*hexutil.Bytes)(&transferData)}) + require.NoError(t, err) + res, err := suite.EvmQueryClient.EstimateGas(suite.Ctx, &types.EthCallRequest{ + Args: args, + GasCap: 25_000_000, + ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, + }) + require.NoError(t, err) + + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + + var ercTransferTx *types.MsgEthereumTx + if suite.enableFeemarket { + ercTransferTx = types.NewTx( + chainID, + nonce, + &contractAddr, + nil, + res.Gas, + nil, + suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx), + big.NewInt(1), + transferData, + ðtypes.AccessList{}, // accesses + ) + } else { + ercTransferTx = types.NewTx( + chainID, + nonce, + &contractAddr, + nil, + res.Gas, + nil, + nil, nil, + transferData, + nil, + ) + } + + ercTransferTx.From = suite.Address.Bytes() + err = ercTransferTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.Signer) + require.NoError(t, err) + rsp, err := suite.App.EvmKeeper.EthereumTx(suite.Ctx, ercTransferTx) + require.NoError(t, err) + require.Empty(t, rsp.VmError) + return ercTransferTx +} + +func (suite *GRPCServerTestSuiteSuite) TestQueryAccount() { var ( req *types.QueryAccountRequest expAccount *types.QueryAccountResponse @@ -78,9 +184,7 @@ func (suite *KeeperTestSuite) TestQueryAccount() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Account(ctx, req) - + res, err := suite.EvmQueryClient.Account(suite.Ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) @@ -122,7 +226,7 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() { expAccount = &types.QueryCosmosAccountResponse{ CosmosAddress: sdk.AccAddress(suite.address.Bytes()).String(), Sequence: 0, - AccountNumber: 0, + AccountNumber: suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) - 1, } req = &types.QueryCosmosAccountRequest{ Address: suite.address.String(), @@ -135,13 +239,13 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() { func() { acc := suite.app.AccountKeeper.GetAccount(suite.ctx, suite.address.Bytes()) suite.Require().NoError(acc.SetSequence(10)) - suite.Require().NoError(acc.SetAccountNumber(1)) - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - + num := suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) + suite.Require().NoError(acc.SetAccountNumber(num)) + suite.App.AccountKeeper.SetAccount(suite.Ctx, acc) expAccount = &types.QueryCosmosAccountResponse{ CosmosAddress: sdk.AccAddress(suite.address.Bytes()).String(), Sequence: 10, - AccountNumber: 1, + AccountNumber: num, } req = &types.QueryCosmosAccountRequest{ Address: suite.address.String(), @@ -156,9 +260,7 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.CosmosAccount(ctx, req) - + res, err := suite.EvmQueryClient.CosmosAccount(suite.Ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) @@ -215,9 +317,7 @@ func (suite *KeeperTestSuite) TestQueryBalance() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Balance(ctx, req) - + res, err := suite.EvmQueryClient.Balance(suite.Ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) @@ -273,10 +373,7 @@ func (suite *KeeperTestSuite) TestQueryStorage() { vmdb := suite.StateDB() tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) - - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Storage(ctx, req) - + res, err := suite.EvmQueryClient.Storage(suite.Ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) @@ -332,10 +429,7 @@ func (suite *KeeperTestSuite) TestQueryCode() { vmdb := suite.StateDB() tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) - - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Code(ctx, req) - + res, err := suite.EvmQueryClient.Code(suite.Ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) @@ -392,7 +486,7 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()), txHash, txIndex, logIndex)) + vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, statedb.NewTxConfig(common.BytesToHash(suite.Ctx.HeaderHash()), txHash, txIndex, logIndex)) tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) @@ -402,11 +496,9 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { } } -func (suite *KeeperTestSuite) TestQueryParams() { - ctx := sdk.WrapSDKContext(suite.ctx) +func (suite *GRPCServerTestSuiteSuite) TestQueryParams() { expParams := types.DefaultParams() - - res, err := suite.queryClient.Params(ctx, &types.QueryParamsRequest{}) + res, err := suite.EvmQueryClient.Params(suite.Ctx, &types.QueryParamsRequest{}) suite.Require().NoError(err) suite.Require().Equal(expParams, res.Params) } @@ -440,7 +532,7 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() { expAccount = &types.QueryValidatorAccountResponse{ AccountAddress: sdk.AccAddress(suite.address.Bytes()).String(), Sequence: 0, - AccountNumber: 0, + AccountNumber: suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) - 1, } req = &types.QueryValidatorAccountRequest{ ConsAddress: suite.consAddress.String(), @@ -453,13 +545,13 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() { func() { acc := suite.app.AccountKeeper.GetAccount(suite.ctx, suite.address.Bytes()) suite.Require().NoError(acc.SetSequence(10)) - suite.Require().NoError(acc.SetAccountNumber(1)) - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - + num := suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) + suite.Require().NoError(acc.SetAccountNumber(num)) + suite.App.AccountKeeper.SetAccount(suite.Ctx, acc) expAccount = &types.QueryValidatorAccountResponse{ AccountAddress: sdk.AccAddress(suite.address.Bytes()).String(), Sequence: 10, - AccountNumber: 1, + AccountNumber: num, } req = &types.QueryValidatorAccountRequest{ ConsAddress: suite.consAddress.String(), @@ -472,11 +564,8 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.ValidatorAccount(ctx, req) - + res, err := suite.EvmQueryClient.ValidatorAccount(suite.Ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) @@ -583,8 +672,8 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "erc20 transfer", func() { - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) - suite.Commit() + contractAddr := suite.deployTestContract(suite.Address) + suite.Commit(suite.T()) transferData, err := types.ERC20Contract.ABI.Pack("transfer", common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(1000)) suite.Require().NoError(err) args = types.TransactionArgs{To: &contractAddr, From: &suite.address, Data: (*hexutil.Bytes)(&transferData)} @@ -658,8 +747,8 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "erc20 transfer w/ enableFeemarket", func() { - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) - suite.Commit() + contractAddr := suite.deployTestContract(suite.Address) + suite.Commit(suite.T()) transferData, err := types.ERC20Contract.ABI.Pack("transfer", common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(1000)) suite.Require().NoError(err) args = types.TransactionArgs{To: &contractAddr, From: &suite.address, Data: (*hexutil.Bytes)(&transferData)} @@ -740,8 +829,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() { GasCap: gasCap, ProposerAddress: suite.ctx.BlockHeader().ProposerAddress, } - - rsp, err := suite.queryClient.EstimateGas(sdk.WrapSDKContext(suite.ctx), &req) + rsp, err := suite.EvmQueryClient.EstimateGas(suite.Ctx, &req) if tc.expPass { suite.Require().NoError(err) suite.Require().Equal(int64(tc.expGas), int64(rsp.Gas)) @@ -838,13 +926,12 @@ func (suite *KeeperTestSuite) TestTraceTx() { vmdb := suite.StateDB() vmdb.SetNonce(suite.address, vmdb.GetNonce(suite.address)+1) suite.Require().NoError(vmdb.Commit()) - - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) - suite.Commit() + contractAddr := suite.deployTestContract(suite.Address) + suite.Commit(suite.T()) // Generate token transfer transaction - firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - suite.Commit() + firstTx := suite.transferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + txMsg = suite.transferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + suite.Commit(suite.T()) predecessors = append(predecessors, firstTx) }, @@ -913,7 +1000,7 @@ func (suite *KeeperTestSuite) TestTraceTx() { ) predecessors = append(predecessors, contractTx) - suite.Commit() + suite.Commit(suite.T()) params := suite.app.EvmKeeper.GetParams(suite.ctx) params.EnableCreate = false @@ -939,11 +1026,11 @@ func (suite *KeeperTestSuite) TestTraceTx() { suite.enableFeemarket = tc.enableFeemarket suite.SetupTest() // Deploy contract - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) - suite.Commit() + contractAddr := suite.deployTestContract(suite.Address) + suite.Commit(suite.T()) // Generate token transfer transaction - txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - suite.Commit() + txMsg = suite.transferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + suite.Commit(suite.T()) tc.malleate() traceReq := types.QueryTraceTxRequest{ @@ -955,8 +1042,7 @@ func (suite *KeeperTestSuite) TestTraceTx() { if chainID != nil { traceReq.ChainId = chainID.Int64() } - res, err := suite.queryClient.TraceTx(sdk.WrapSDKContext(suite.ctx), &traceReq) - + res, err := suite.EvmQueryClient.TraceTx(suite.Ctx, &traceReq) if tc.expPass { suite.Require().NoError(err) // if data is to big, slice the result @@ -1058,13 +1144,12 @@ func (suite *KeeperTestSuite) TestTraceBlock() { vmdb := suite.StateDB() vmdb.SetNonce(suite.address, vmdb.GetNonce(suite.address)+1) suite.Require().NoError(vmdb.Commit()) - - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) - suite.Commit() + contractAddr := suite.deployTestContract(suite.Address) + suite.Commit(suite.T()) // create multiple transactions in the same block - firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - secondTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - suite.Commit() + firstTx := suite.transferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + secondTx := suite.transferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + suite.Commit(suite.T()) // overwrite txs to include only the ones on new block txs = append([]*types.MsgEthereumTx{}, firstTx, secondTx) }, @@ -1115,11 +1200,13 @@ func (suite *KeeperTestSuite) TestTraceBlock() { suite.enableFeemarket = tc.enableFeemarket suite.SetupTest() // Deploy contract - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) - suite.Commit() + contractAddr := suite.deployTestContract(suite.Address) + // set some balance to handle fees + suite.App.EvmKeeper.SetBalance(suite.Ctx, suite.Address, big.NewInt(1000000000000000000), types.DefaultEVMDenom) + suite.Commit(suite.T()) // Generate token transfer transaction - txMsg := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - suite.Commit() + txMsg := suite.transferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + suite.Commit(suite.T()) txs = append(txs, txMsg) @@ -1132,9 +1219,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() { if chainID != nil { traceReq.ChainId = chainID.Int64() } - - res, err := suite.queryClient.TraceBlock(sdk.WrapSDKContext(suite.ctx), &traceReq) - + res, err := suite.EvmQueryClient.TraceBlock(suite.Ctx, &traceReq) if tc.expPass { suite.Require().NoError(err) // if data is to big, slice the result @@ -1172,15 +1257,15 @@ func (suite *KeeperTestSuite) TestNonceInQuery() { Data: (*hexutil.Bytes)(&data), }) suite.Require().NoError(err) - proposerAddress := suite.ctx.BlockHeader().ProposerAddress - _, err = suite.queryClient.EstimateGas(sdk.WrapSDKContext(suite.ctx), &types.EthCallRequest{ + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + _, err = suite.EvmQueryClient.EstimateGas(suite.Ctx, &types.EthCallRequest{ Args: args, GasCap: uint64(config.DefaultGasCap), ProposerAddress: proposerAddress, }) suite.Require().NoError(err) - _, err = suite.queryClient.EthCall(sdk.WrapSDKContext(suite.ctx), &types.EthCallRequest{ + _, err = suite.EvmQueryClient.EthCall(suite.Ctx, &types.EthCallRequest{ Args: args, GasCap: uint64(config.DefaultGasCap), ProposerAddress: proposerAddress, @@ -1212,8 +1297,8 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { { "pass - non-nil Base Fee", func() { - baseFee := sdk.OneInt().BigInt() - suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) + baseFee := sdkmath.OneInt().BigInt() + suite.App.FeeMarketKeeper.SetBaseFee(suite.Ctx, baseFee) aux = sdkmath.NewIntFromBigInt(baseFee) expRes = &types.QueryBaseFeeResponse{BaseFee: &aux} @@ -1223,8 +1308,8 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { { "pass - nil Base Fee when london hardfork not activated", func() { - baseFee := sdk.OneInt().BigInt() - suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) + baseFee := sdkmath.OneInt().BigInt() + suite.App.FeeMarketKeeper.SetBaseFee(suite.Ctx, baseFee) expRes = &types.QueryBaseFeeResponse{} }, @@ -1233,7 +1318,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { { "pass - zero Base Fee when feemarket not activated", func() { - baseFee := sdk.ZeroInt() + baseFee := sdkmath.ZeroInt() expRes = &types.QueryBaseFeeResponse{BaseFee: &baseFee} }, true, false, true, diff --git a/x/evm/keeper/hooks_test.go b/x/evm/keeper/hooks_test.go index c4eecc9b..81f38eb1 100644 --- a/x/evm/keeper/hooks_test.go +++ b/x/evm/keeper/hooks_test.go @@ -66,8 +66,8 @@ func (suite *KeeperTestSuite) TestEvmHooks() { k := suite.app.EvmKeeper ctx := suite.ctx txHash := common.BigToHash(big.NewInt(1)) - vmdb := statedb.New(ctx, k, statedb.NewTxConfig( - common.BytesToHash(ctx.HeaderHash().Bytes()), + vmdb := statedb.New(suite.Ctx, k, statedb.NewTxConfig( + common.BytesToHash(suite.Ctx.HeaderHash()), txHash, 0, 0, diff --git a/x/evm/keeper/integration_test.go b/x/evm/keeper/integration_test.go index e049b01a..fd0e9a86 100644 --- a/x/evm/keeper/integration_test.go +++ b/x/evm/keeper/integration_test.go @@ -4,6 +4,7 @@ import ( "encoding/json" "math/big" + sdkmath "cosmossdk.io/math" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -13,19 +14,12 @@ import ( authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/tests" - "github.com/zeta-chain/ethermint/testutil" - "github.com/zeta-chain/ethermint/x/feemarket/types" - - dbm "github.com/cometbft/cometbft-db" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/tests" + "github.com/evmos/ethermint/testutil" + + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" ) var _ = Describe("Feemarket", func() { @@ -55,7 +49,7 @@ var _ = Describe("Feemarket", func() { // 100_000`. With the fee calculation `Fee = (baseFee + tip) * gasLimit`, // a `minGasPrices = 5_000_000_000` results in `minGlobalFee = // 500_000_000_000_000` - privKey, _ = setupTestWithContext("1", sdk.NewDec(minGasPrices), sdk.NewInt(baseFee)) + setupTest(sdkmath.LegacyNewDec(minGasPrices), big.NewInt(baseFee)) }) Context("during CheckTx", func() { @@ -140,28 +134,31 @@ func setupTestWithContext(valMinGasPrice string, minGasPrice sdk.Dec, baseFee sd return privKey, msg } -func setupTest(localMinGasPrices string) (*ethsecp256k1.PrivKey, banktypes.MsgSend) { - setupChain(localMinGasPrices) - - privKey, address := generateKey() - amount, ok := sdk.NewIntFromString("10000000000000000000") +func setupTest(minGasPrice sdkmath.LegacyDec, baseFee *big.Int) { + t := s.T() + s.SetupTestWithCbAndOpts( + t, + func(app *app.EthermintApp, genesis app.GenesisState) app.GenesisState { + feemarketGenesis := feemarkettypes.DefaultGenesisState() + feemarketGenesis.Params.NoBaseFee = true + genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis) + return genesis + }, + simtestutil.AppOptionsMap{server.FlagMinGasPrices: "1" + evmtypes.DefaultEVMDenom}, + ) + amount, ok := sdkmath.NewIntFromString("10000000000000000000") s.Require().True(ok) initBalance := sdk.Coins{sdk.Coin{ Denom: s.denom, Amount: amount, }} - testutil.FundAccount(s.app.BankKeeper, s.ctx, address, initBalance) - - msg := banktypes.MsgSend{ - FromAddress: address.String(), - ToAddress: address.String(), - Amount: sdk.Coins{sdk.Coin{ - Denom: s.denom, - Amount: sdk.NewInt(10000), - }}, - } - s.Commit() - return privKey, msg + testutil.FundAccount(s.App.BankKeeper, s.Ctx, sdk.AccAddress(s.Address.Bytes()), initBalance) + s.Commit(t) + params := feemarkettypes.DefaultParams() + params.MinGasPrice = minGasPrice + s.App.FeeMarketKeeper.SetParams(s.Ctx, params) + s.App.FeeMarketKeeper.SetBaseFee(s.Ctx, baseFee) + s.Commit(t) } func setupChain(localMinGasPricesStr string) { diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 8465dc76..77bba83a 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -18,14 +18,13 @@ package keeper import ( "math/big" + corestoretypes "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -48,7 +47,8 @@ type EventConverter = func([]abci.EventAttribute) []*ethtypes.Log // Keeper grants access to the EVM module state and implements the go-ethereum StateDB interface. type Keeper struct { // Protobuf codec - cdc codec.BinaryCodec + cdc codec.Codec + storeService corestoretypes.KVStoreService // Store key required for the EVM Prefix KVStore. It is required by: // - storing account's Storage State // - storing account's Code @@ -79,10 +79,6 @@ type Keeper struct { // EVM Hooks for tx post-processing hooks types.EvmHooks - // Legacy subspace - ss paramstypes.Subspace - - // customContractFns is the list of precompiled stateful contract functions. customContractFns []CustomContractFn ck consensusparamkeeper.Keeper @@ -94,7 +90,8 @@ type Keeper struct { // NewKeeper generates new evm module keeper func NewKeeper( - cdc codec.BinaryCodec, + cdc codec.Codec, + storeService corestoretypes.KVStoreService, storeKey, transientKey storetypes.StoreKey, authority sdk.AccAddress, ak types.AccountKeeper, @@ -102,7 +99,6 @@ func NewKeeper( sk types.StakingKeeper, fmk types.FeeMarketKeeper, tracer string, - ss paramstypes.Subspace, customContractFns []CustomContractFn, ck consensusparamkeeper.Keeper, keys map[string]storetypes.StoreKey, @@ -120,6 +116,7 @@ func NewKeeper( // NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations return &Keeper{ cdc: cdc, + storeService: storeService, authority: authority, accountKeeper: ak, bankKeeper: bankKeeper, @@ -128,7 +125,6 @@ func NewKeeper( storeKey: storeKey, transientKey: transientKey, tracer: tracer, - ss: ss, customContractFns: customContractFns, ck: ck, keys: keys, @@ -141,7 +137,8 @@ func (k Keeper) StoreKeys() map[string]storetypes.StoreKey { // Logger returns a module-specific logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", "x/"+types.ModuleName) } // WithChainID sets the chain id to the local variable in the keeper diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 123dbce8..10c9e905 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -20,13 +20,9 @@ import ( tmjson "github.com/cometbft/cometbft/libs/json" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - feemarkettypes "github.com/zeta-chain/ethermint/x/feemarket/types" + "github.com/evmos/ethermint/testutil" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" "github.com/zeta-chain/ethermint/app" "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" @@ -41,14 +37,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/params" - - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmversion "github.com/cometbft/cometbft/proto/tendermint/version" - "github.com/cometbft/cometbft/version" ) var testTokens = sdkmath.NewIntWithDecimal(1000, 18) @@ -145,84 +133,7 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { } return genesis }) - - if suite.mintFeeCollector { - // mint some coin to fee collector - coins := sdk.NewCoins(sdk.NewCoin(types.DefaultEVMDenom, sdkmath.NewInt(int64(params.TxGas)-1))) - genesisState := app.NewTestGenesisState(suite.app.AppCodec()) - balances := []banktypes.Balance{ - { - Address: suite.app.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName).String(), - Coins: coins, - }, - } - var bankGenesis banktypes.GenesisState - suite.app.AppCodec().MustUnmarshalJSON(genesisState[banktypes.ModuleName], &bankGenesis) - // Update balances and total supply - bankGenesis.Balances = append(bankGenesis.Balances, balances...) - bankGenesis.Supply = bankGenesis.Supply.Add(coins...) - genesisState[banktypes.ModuleName] = suite.app.AppCodec().MustMarshalJSON(&bankGenesis) - - // we marshal the genesisState of all module to a byte array - stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ") - require.NoError(t, err) - - // Initialize the chain - suite.app.InitChain( - abci.RequestInitChain{ - ChainId: "ethermint_9000-1", - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: app.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - } - - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{ - Height: 1, - ChainID: "ethermint_9000-1", - Time: time.Now().UTC(), - ProposerAddress: suite.consAddress.Bytes(), - Version: tmversion.Consensus{ - Block: version.BlockProtocol, - }, - LastBlockId: tmproto.BlockID{ - Hash: tmhash.Sum([]byte("block_id")), - PartSetHeader: tmproto.PartSetHeader{ - Total: 11, - Hash: tmhash.Sum([]byte("partset_header")), - }, - }, - AppHash: tmhash.Sum([]byte("app")), - DataHash: tmhash.Sum([]byte("data")), - EvidenceHash: tmhash.Sum([]byte("evidence")), - ValidatorsHash: tmhash.Sum([]byte("validators")), - NextValidatorsHash: tmhash.Sum([]byte("next_validators")), - ConsensusHash: tmhash.Sum([]byte("consensus")), - LastResultsHash: tmhash.Sum([]byte("last_result")), - }) - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.EvmKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) - - acc := ðermint.EthAccount{ - BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0), - CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(), - } - - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - - valAddr := sdk.ValAddress(suite.address.Bytes()) - validator, err := stakingtypes.NewValidator(valAddr, priv.PubKey(), stakingtypes.Description{}) - require.NoError(t, err) - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) - require.NoError(t, err) - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) - require.NoError(t, err) - suite.app.StakingKeeper.SetValidator(suite.ctx, validator) - - encodingConfig := encoding.MakeConfig(app.ModuleBasics) + encodingConfig := encoding.MakeConfig() suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) suite.appCodec = encodingConfig.Codec @@ -442,10 +353,10 @@ func (suite *KeeperTestSuite) TestBaseFee() { suite.enableFeemarket = tc.enableFeemarket suite.enableLondonHF = tc.enableLondonHF suite.SetupTest() - suite.app.EvmKeeper.BeginBlock(suite.ctx, abci.RequestBeginBlock{}) - params := suite.app.EvmKeeper.GetParams(suite.ctx) - ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - baseFee := suite.app.EvmKeeper.GetBaseFee(suite.ctx, ethCfg) + suite.App.EvmKeeper.BeginBlock(suite.Ctx) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + ethCfg := params.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + baseFee := suite.App.EvmKeeper.GetBaseFee(suite.Ctx, ethCfg) suite.Require().Equal(tc.expectBaseFee, baseFee) }) } @@ -479,7 +390,7 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { suite.SetupTest() tc.malleate() i := 0 - suite.app.AccountKeeper.IterateAccounts(suite.ctx, func(account authtypes.AccountI) bool { + suite.App.AccountKeeper.IterateAccounts(suite.Ctx, func(account sdk.AccountI) bool { ethAccount, ok := account.(ethermint.EthAccountI) if !ok { // ignore non EthAccounts diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 91a77f31..aa9e0e03 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -23,13 +23,14 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - tmbytes "github.com/cometbft/cometbft/libs/bytes" - tmtypes "github.com/cometbft/cometbft/types" + cmtbytes "github.com/cometbft/cometbft/libs/bytes" + cmttypes "github.com/cometbft/cometbft/types" errorsmod "cosmossdk.io/errors" - "github.com/armon/go-metrics" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/hashicorp/go-metrics" "github.com/zeta-chain/ethermint/x/evm/types" ) @@ -77,9 +78,7 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t // Observe which users define a gas limit >> gas used. Note, that // gas_limit and gas_used are always > 0 - // #nosec G115 always in range - gasLimit := sdk.NewDec(int64(tx.Gas())) - // #nosec G115 always in range + gasLimit := sdkmath.LegacyNewDec(int64(tx.Gas())) gasRatio, err := gasLimit.QuoInt64(int64(response.GasUsed)).Float64() if err == nil { telemetry.SetGaugeWithLabels( @@ -103,7 +102,7 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format - hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) + hash := cmtbytes.HexBytes(cmttypes.Tx(ctx.TxBytes()).Hash()) attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyTxHash, hash.String())) } diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index 921981ac..99005b64 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -17,39 +17,29 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/types" ) // GetParams returns the total set of evm parameters. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyPrefixParams) - if len(bz) == 0 { - return k.GetLegacyParams(ctx) +func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.KeyPrefixParams) + if err != nil { + panic(err) + } + if bz == nil { + return p } - k.cdc.MustUnmarshal(bz, ¶ms) - return + k.cdc.MustUnmarshal(bz, &p) + return p } // SetParams sets the EVM params each in their individual key for better get performance -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - if err := params.Validate(); err != nil { +func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { + if err := p.Validate(); err != nil { return err } - - store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(¶ms) - if err != nil { - return err - } - - store.Set(types.KeyPrefixParams, bz) - return nil -} - -// GetLegacyParams returns param set for version before migrate -func (k Keeper) GetLegacyParams(ctx sdk.Context) types.Params { - var params types.Params - k.ss.GetParamSetIfExists(ctx, ¶ms) - return params + store := k.storeService.OpenKVStore(ctx) + bz := k.cdc.MustMarshal(&p) + return store.Set(types.KeyPrefixParams, bz) } diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 9556a646..75cd5002 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -20,15 +20,14 @@ import ( "math" "math/big" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/holiman/uint256" + cmttypes "github.com/cometbft/cometbft/types" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - - ethermint "github.com/zeta-chain/ethermint/types" - "github.com/zeta-chain/ethermint/x/evm/statedb" - "github.com/zeta-chain/ethermint/x/evm/types" + ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -120,7 +119,7 @@ func (k Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc { // only recompute the hash if not set (eg: checkTxState) contextBlockHeader := ctx.BlockHeader() - header, err := tmtypes.HeaderFromProto(&contextBlockHeader) + header, err := cmttypes.HeaderFromProto(&contextBlockHeader) if err != nil { k.Logger(ctx).Error("failed to cast tendermint header from proto", "error", err) return common.Hash{} @@ -132,13 +131,13 @@ func (k Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc { case ctx.BlockHeight() > h: // Case 2: if the chain is not the current height we need to retrieve the hash from the store for the // current chain epoch. This only applies if the current height is greater than the requested height. - histInfo, found := k.stakingKeeper.GetHistoricalInfo(ctx, h) - if !found { - k.Logger(ctx).Debug("historical info not found", "height", h) + histInfo, err := k.stakingKeeper.GetHistoricalInfo(ctx, h) + if err != nil { + k.Logger(ctx).Debug("historical info not found", "height", h, "err", err.Error()) return common.Hash{} } - header, err := tmtypes.HeaderFromProto(&histInfo.Header) + header, err := cmttypes.HeaderFromProto(&histInfo.Header) if err != nil { k.Logger(ctx).Error("failed to cast tendermint header from proto", "error", err) return common.Hash{} @@ -443,25 +442,28 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, // calculate a minimum amount of gas to be charged to sender if GasLimit // is considerably higher than GasUsed to stay more aligned with Tendermint gas mechanics // for more info https://github.com/evmos/ethermint/issues/1085 - // #nosec G115 msg.GasLimit range checked - gasLimit := sdk.NewDec(int64(msg.GasLimit)) - minGasMultiplier := k.GetMinGasMultiplier(ctx) + gasLimit := sdkmath.LegacyNewDec(int64(msg.GasLimit)) + minGasMultiplier := cfg.FeeMarketParams.MinGasMultiplier + if minGasMultiplier.IsNil() { + // in case we are executing eth_call on a legacy block, returns a zero value. + minGasMultiplier = sdkmath.LegacyZeroDec() + } minimumGasUsed := gasLimit.Mul(minGasMultiplier) if msg.GasLimit < leftoverGas { return nil, errorsmod.Wrapf(types.ErrGasOverflow, "message gas limit < leftover gas (%d < %d)", msg.GasLimit, leftoverGas) } - // #nosec G115 temporaryGasUsed always in range - gasUsed := sdk.MaxDec(minimumGasUsed, sdk.NewDec(int64(temporaryGasUsed))).TruncateInt().Uint64() + gasUsed := sdkmath.LegacyMaxDec(minimumGasUsed, sdkmath.LegacyNewDec(int64(temporaryGasUsed))).TruncateInt().Uint64() // reset leftoverGas, to be used by the tracer leftoverGas = msg.GasLimit - gasUsed return &types.MsgEthereumTxResponse{ - GasUsed: gasUsed, - VmError: vmError, - Ret: ret, - Logs: types.NewLogsFromEth(stateDB.Logs()), - Hash: txConfig.TxHash.Hex(), + GasUsed: gasUsed, + VmError: vmError, + Ret: ret, + Logs: types.NewLogsFromEth(stateDB.Logs()), + Hash: cfg.TxConfig.TxHash.Hex(), + BlockHash: ctx.HeaderHash(), }, nil } diff --git a/x/evm/keeper/state_transition_benchmark_test.go b/x/evm/keeper/state_transition_benchmark_test.go index e1cfcf22..0716862d 100644 --- a/x/evm/keeper/state_transition_benchmark_test.go +++ b/x/evm/keeper/state_transition_benchmark_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -63,7 +64,7 @@ func newSignedEthTx( return nil, errors.New("unknown transaction type!") } - sig, _, err := krSigner.SignByAddress(addr, ethTx.Hash().Bytes()) + sig, _, err := krSigner.SignByAddress(addr, ethTx.Hash().Bytes(), signing.SignMode_SIGN_MODE_TEXTUAL) if err != nil { return nil, err } diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 61d6ed51..ff068b34 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -5,6 +5,8 @@ import ( "math" "math/big" + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" "github.com/cometbft/cometbft/crypto/tmhash" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" @@ -22,8 +24,53 @@ import ( "github.com/zeta-chain/ethermint/x/evm/types" ) -func (suite *KeeperTestSuite) TestGetHashFn() { - header := suite.ctx.BlockHeader() +type StateTransitionTestSuite struct { + testutil.EVMTestSuiteWithAccountAndQueryClient + mintFeeCollector bool +} + +func (suite *StateTransitionTestSuite) SetupTest() { + t := suite.T() + suite.EVMTestSuiteWithAccountAndQueryClient.SetupTestWithCb(t, func(a *app.EthermintApp, genesis app.GenesisState) app.GenesisState { + feemarketGenesis := feemarkettypes.DefaultGenesisState() + feemarketGenesis.Params.NoBaseFee = true + genesis[feemarkettypes.ModuleName] = a.AppCodec().MustMarshalJSON(feemarketGenesis) + acc := ðermint.EthAccount{ + BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.Address.Bytes()), nil, 0, 0), + CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(), + } + accs, err := authtypes.PackAccounts(authtypes.GenesisAccounts{acc}) + require.NoError(t, err) + var authGenesis authtypes.GenesisState + a.AppCodec().MustUnmarshalJSON(genesis[authtypes.ModuleName], &authGenesis) + authGenesis.Accounts = append(authGenesis.Accounts, accs[0]) + genesis[authtypes.ModuleName] = a.AppCodec().MustMarshalJSON(&authGenesis) + if suite.mintFeeCollector { + // mint some coin to fee collector + coins := sdk.NewCoins(sdk.NewCoin(types.DefaultEVMDenom, sdkmath.NewInt(int64(params.TxGas)-1))) + balances := []banktypes.Balance{ + { + Address: suite.App.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName).String(), + Coins: coins, + }, + } + var bankGenesis banktypes.GenesisState + suite.App.AppCodec().MustUnmarshalJSON(genesis[banktypes.ModuleName], &bankGenesis) + // Update balances and total supply + bankGenesis.Balances = append(bankGenesis.Balances, balances...) + bankGenesis.Supply = bankGenesis.Supply.Add(coins...) + genesis[banktypes.ModuleName] = suite.App.AppCodec().MustMarshalJSON(&bankGenesis) + } + return genesis + }) +} + +func TestStateTransitionTestSuite(t *testing.T) { + suite.Run(t, new(StateTransitionTestSuite)) +} + +func (suite *StateTransitionTestSuite) TestGetHashFn() { + header := suite.Ctx.BlockHeader() h, _ := tmtypes.HeaderFromProto(&header) hash := h.Hash() @@ -37,7 +84,7 @@ func (suite *KeeperTestSuite) TestGetHashFn() { "case 1.1: context hash cached", uint64(suite.ctx.BlockHeight()), func() { - suite.ctx = suite.ctx.WithHeaderHash(tmhash.Sum([]byte("header"))) + suite.Ctx = suite.Ctx.WithHeaderHash(tmhash.Sum([]byte("header"))).WithConsensusParams(*app.DefaultConsensusParams) }, common.BytesToHash(tmhash.Sum([]byte("header"))), }, @@ -46,8 +93,8 @@ func (suite *KeeperTestSuite) TestGetHashFn() { uint64(suite.ctx.BlockHeight()), func() { header := tmproto.Header{} - header.Height = suite.ctx.BlockHeight() - suite.ctx = suite.ctx.WithBlockHeader(header) + header.Height = suite.Ctx.BlockHeight() + suite.Ctx = suite.Ctx.WithBlockHeader(header).WithConsensusParams(*app.DefaultConsensusParams) }, common.Hash{}, }, @@ -55,7 +102,7 @@ func (suite *KeeperTestSuite) TestGetHashFn() { "case 1.3: hash calculated from Tendermint header", uint64(suite.ctx.BlockHeight()), func() { - suite.ctx = suite.ctx.WithBlockHeader(header) + suite.Ctx = suite.Ctx.WithBlockHeader(header).WithConsensusParams(*app.DefaultConsensusParams) }, common.BytesToHash(hash), }, @@ -63,7 +110,7 @@ func (suite *KeeperTestSuite) TestGetHashFn() { "case 2.1: height lower than current one, hist info not found", 1, func() { - suite.ctx = suite.ctx.WithBlockHeight(10) + suite.Ctx = suite.Ctx.WithBlockHeight(10).WithConsensusParams(*app.DefaultConsensusParams) }, common.Hash{}, }, @@ -71,8 +118,8 @@ func (suite *KeeperTestSuite) TestGetHashFn() { "case 2.2: height lower than current one, invalid hist info header", 1, func() { - suite.app.StakingKeeper.SetHistoricalInfo(suite.ctx, 1, &stakingtypes.HistoricalInfo{}) - suite.ctx = suite.ctx.WithBlockHeight(10) + suite.App.StakingKeeper.SetHistoricalInfo(suite.Ctx, 1, &stakingtypes.HistoricalInfo{}) + suite.Ctx = suite.Ctx.WithBlockHeight(10).WithConsensusParams(*app.DefaultConsensusParams) }, common.Hash{}, }, @@ -83,8 +130,8 @@ func (suite *KeeperTestSuite) TestGetHashFn() { histInfo := &stakingtypes.HistoricalInfo{ Header: header, } - suite.app.StakingKeeper.SetHistoricalInfo(suite.ctx, 1, histInfo) - suite.ctx = suite.ctx.WithBlockHeight(10) + suite.App.StakingKeeper.SetHistoricalInfo(suite.Ctx, 1, histInfo) + suite.Ctx = suite.Ctx.WithBlockHeight(10).WithConsensusParams(*app.DefaultConsensusParams) }, common.BytesToHash(hash), }, @@ -121,7 +168,7 @@ func (suite *KeeperTestSuite) TestGetCoinbaseAddress() { func() { header := suite.ctx.BlockHeader() header.ProposerAddress = []byte{} - suite.ctx = suite.ctx.WithBlockHeader(header) + suite.Ctx = suite.Ctx.WithBlockHeader(header).WithConsensusParams(*app.DefaultConsensusParams) }, false, }, @@ -144,10 +191,10 @@ func (suite *KeeperTestSuite) TestGetCoinbaseAddress() { header := suite.ctx.BlockHeader() header.ProposerAddress = valConsAddr.Bytes() - suite.ctx = suite.ctx.WithBlockHeader(header) + suite.Ctx = suite.Ctx.WithBlockHeader(header).WithConsensusParams(*app.DefaultConsensusParams) - _, found := suite.app.StakingKeeper.GetValidatorByConsAddr(suite.ctx, valConsAddr.Bytes()) - suite.Require().True(found) + _, err = suite.App.StakingKeeper.GetValidatorByConsAddr(suite.Ctx, valConsAddr.Bytes()) + suite.Require().NoError(err) suite.Require().NotEmpty(suite.ctx.BlockHeader().ProposerAddress) }, @@ -259,11 +306,9 @@ func (suite *KeeperTestSuite) TestGetEthIntrinsicGas() { ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) ethCfg.HomesteadBlock = big.NewInt(2) ethCfg.IstanbulBlock = big.NewInt(3) - signer := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) - - suite.ctx = suite.ctx.WithBlockHeight(tc.height) - - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) + signer := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) + suite.Ctx = suite.Ctx.WithBlockHeight(tc.height).WithConsensusParams(*app.DefaultConsensusParams) + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) m, err := newNativeMessage( nonce, suite.ctx.BlockHeight(), @@ -501,7 +546,7 @@ func (suite *KeeperTestSuite) TestResetGasMeterAndConsumeGas() { suite.SetupTest() // reset panicF := func() { - gm := sdk.NewGasMeter(10) + gm := storetypes.NewGasMeter(10) gm.ConsumeGas(tc.gasConsumed, "") ctx := suite.ctx.WithGasMeter(gm) suite.app.EvmKeeper.ResetGasMeterAndConsumeGas(ctx, tc.gasUsed) diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index a68c480b..cba57258 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -22,7 +22,9 @@ import ( sdkmath "cosmossdk.io/math" errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/store/prefix" + sdkmath "cosmossdk.io/math" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/holiman/uint256" @@ -71,7 +73,7 @@ func (k *Keeper) ForEachStorage(ctx sdk.Context, addr common.Address, cb func(ke store := ctx.KVStore(k.storeKey) prefix := types.AddressStoragePrefix(addr) - iterator := sdk.KVStorePrefixIterator(store, prefix) + iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -95,23 +97,11 @@ func (k *Keeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.In delta := new(big.Int).Sub(amount, balance) switch delta.Sign() { case 1: - // mint - coins := sdk.NewCoins(sdk.NewCoin(params.EvmDenom, sdkmath.NewIntFromBigInt(delta))) - if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins); err != nil { - return err - } - if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, cosmosAddr, coins); err != nil { - return err - } + coins := sdk.NewCoins(sdk.NewCoin(evmDenom, sdkmath.NewIntFromBigInt(delta))) + return k.AddBalance(ctx, cosmosAddr, coins) case -1: - // burn - coins := sdk.NewCoins(sdk.NewCoin(params.EvmDenom, sdkmath.NewIntFromBigInt(new(big.Int).Neg(delta)))) - if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, cosmosAddr, types.ModuleName, coins); err != nil { - return err - } - if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins); err != nil { - return err - } + coins := sdk.NewCoins(sdk.NewCoin(evmDenom, sdkmath.NewIntFromBigInt(new(big.Int).Abs(delta)))) + return k.SubBalance(ctx, cosmosAddr, coins) default: // not changed } diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index bb305b69..3898e3de 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -4,9 +4,10 @@ import ( "fmt" "math/big" + "cosmossdk.io/store/prefix" + "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" @@ -17,13 +18,33 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/tests" - "github.com/zeta-chain/ethermint/x/evm/statedb" - "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/crypto/ethsecp256k1" + "github.com/evmos/ethermint/encoding" + "github.com/evmos/ethermint/tests" + "github.com/evmos/ethermint/testutil" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" ) -func (suite *KeeperTestSuite) TestCreateAccount() { +type StateDBTestSuite struct { + testutil.EVMTestSuiteWithAccountAndQueryClient + // for generate test tx + clientCtx client.Context + ethSigner ethtypes.Signer +} + +func TestStateDBTestSuite(t *testing.T) { + suite.Run(t, new(StateDBTestSuite)) +} + +func (suite *StateDBTestSuite) SetupTest() { + suite.EVMTestSuiteWithAccountAndQueryClient.SetupTest(suite.T()) + encodingConfig := encoding.MakeConfig() + suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) + suite.ethSigner = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) +} + +func (suite *StateDBTestSuite) TestCreateAccount() { testCases := []struct { name string addr common.Address @@ -212,7 +233,8 @@ func (suite *KeeperTestSuite) TestSetNonce() { func (suite *KeeperTestSuite) TestGetCodeHash() { addr := tests.GenerateAddress() baseAcc := &authtypes.BaseAccount{Address: sdk.AccAddress(addr.Bytes()).String()} - suite.app.AccountKeeper.SetAccount(suite.ctx, baseAcc) + baseAcc.AccountNumber = suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) + suite.App.AccountKeeper.SetAccount(suite.Ctx, baseAcc) testCases := []struct { name string @@ -256,7 +278,8 @@ func (suite *KeeperTestSuite) TestGetCodeHash() { func (suite *KeeperTestSuite) TestSetCode() { addr := tests.GenerateAddress() baseAcc := &authtypes.BaseAccount{Address: sdk.AccAddress(addr.Bytes()).String()} - suite.app.AccountKeeper.SetAccount(suite.ctx, baseAcc) + baseAcc.AccountNumber = suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) + suite.App.AccountKeeper.SetAccount(suite.Ctx, baseAcc) testCases := []struct { name string @@ -311,7 +334,8 @@ func (suite *KeeperTestSuite) TestSetCode() { func (suite *KeeperTestSuite) TestKeeperSetCode() { addr := tests.GenerateAddress() baseAcc := &authtypes.BaseAccount{Address: sdk.AccAddress(addr.Bytes()).String()} - suite.app.AccountKeeper.SetAccount(suite.ctx, baseAcc) + baseAcc.AccountNumber = suite.App.AccountKeeper.NextAccountNumber(suite.Ctx) + suite.App.AccountKeeper.SetAccount(suite.Ctx, baseAcc) testCases := []struct { name string @@ -678,8 +702,8 @@ func (suite *KeeperTestSuite) TestAddLog() { for _, tc := range testCases { suite.Run(tc.name, func() { suite.SetupTest() - vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewTxConfig( - common.BytesToHash(suite.ctx.HeaderHash().Bytes()), + vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, statedb.NewTxConfig( + common.BytesToHash(suite.Ctx.HeaderHash()), tc.hash, 0, 0, )) diff --git a/x/evm/keeper/utils.go b/x/evm/keeper/utils.go index a194e36b..5c44a6e1 100644 --- a/x/evm/keeper/utils.go +++ b/x/evm/keeper/utils.go @@ -34,17 +34,25 @@ import ( // GetCoinbaseAddress returns the block proposer's validator operator address. func (k Keeper) GetCoinbaseAddress(ctx sdk.Context, proposerAddress sdk.ConsAddress) (common.Address, error) { - validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, GetProposerAddress(ctx, proposerAddress)) - if !found { + validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, GetProposerAddress(ctx, proposerAddress)) + if err != nil { return common.Address{}, errorsmod.Wrapf( stakingtypes.ErrNoValidatorFound, - "failed to retrieve validator from block proposer address %s", - proposerAddress.String(), + "failed to retrieve validator from block proposer address %s, %s", + proposerAddress.String(), err.Error(), + ) + } + + bz, err := sdk.ValAddressFromBech32(validator.GetOperator()) + if err != nil { + return common.Address{}, errorsmod.Wrapf( + err, + "failed to convert validator operator address %s to bytes", + validator.GetOperator(), ) } - coinbase := common.BytesToAddress(validator.GetOperator()) - return coinbase, nil + return common.BytesToAddress(bz), nil } // GetProposerAddress returns current block proposer's address when provided proposer address is empty. @@ -150,3 +158,17 @@ func CheckSenderBalance( } return nil } + +// DeductFees deducts fees from the given account. +func DeductFees(bankKeeper authtypes.BankKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) error { + if !fees.IsValid() { + return errorsmod.Wrapf(errortypes.ErrInsufficientFee, "invalid fee amount: %s", fees) + } + + err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), authtypes.FeeCollectorName, fees) + if err != nil { + return errorsmod.Wrapf(errortypes.ErrInsufficientFunds, err.Error()) + } + + return nil +} diff --git a/x/evm/keeper/utils_test.go b/x/evm/keeper/utils_test.go index a500fe96..94854382 100644 --- a/x/evm/keeper/utils_test.go +++ b/x/evm/keeper/utils_test.go @@ -15,8 +15,8 @@ import ( func (suite *KeeperTestSuite) TestCheckSenderBalance() { hundredInt := sdkmath.NewInt(100) - zeroInt := sdk.ZeroInt() - oneInt := sdk.OneInt() + zeroInt := sdkmath.ZeroInt() + oneInt := sdkmath.OneInt() fiveInt := sdkmath.NewInt(5) fiftyInt := sdkmath.NewInt(50) negInt := sdkmath.NewInt(-10) @@ -263,7 +263,7 @@ func (suite *KeeperTestSuite) TestCheckSenderBalance() { // In practice, the two tested functions will also be sequentially executed. func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { hundredInt := sdkmath.NewInt(100) - zeroInt := sdk.ZeroInt() + zeroInt := sdkmath.ZeroInt() oneInt := sdkmath.NewInt(1) fiveInt := sdkmath.NewInt(5) fiftyInt := sdkmath.NewInt(50) @@ -430,7 +430,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { expectPassDeduct: true, from: suite.address.String(), malleate: func() { - suite.ctx = suite.ctx.WithIsCheckTx(true) + suite.Ctx = suite.Ctx.WithIsCheckTx(true).WithConsensusParams(*app.DefaultConsensusParams) }, }, } diff --git a/x/evm/migrations/v4/migrate.go b/x/evm/migrations/v4/migrate.go index dd4cbc07..c8734162 100644 --- a/x/evm/migrations/v4/migrate.go +++ b/x/evm/migrations/v4/migrate.go @@ -1,8 +1,8 @@ package v4 import ( + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" v4types "github.com/zeta-chain/ethermint/x/evm/migrations/v4/types" diff --git a/x/evm/migrations/v5/migrate.go b/x/evm/migrations/v5/migrate.go index aad27576..51ef74c9 100644 --- a/x/evm/migrations/v5/migrate.go +++ b/x/evm/migrations/v5/migrate.go @@ -1,8 +1,8 @@ package v5 import ( + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/ethermint/x/evm/types" diff --git a/x/evm/module.go b/x/evm/module.go index c6725db8..66958ccc 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" + "cosmossdk.io/core/appmodule" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -41,6 +42,9 @@ import ( var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} + + _ appmodule.HasEndBlocker = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the evm module. @@ -88,6 +92,11 @@ func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *ru } } +// RegisterInterfaces registers interfaces and implementations of the evm module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + // GetTxCmd returns the root tx command for the evm module. func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() @@ -98,11 +107,6 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaces registers interfaces and implementations of the evm module. -func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - types.RegisterInterfaces(registry) -} - // ____________________________________________________________________________ // AppModule implements an application module for the evm module. @@ -152,14 +156,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } // BeginBlock returns the begin block for the evm module. -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - am.keeper.BeginBlock(ctx, req) +func (am AppModule) BeginBlock(ctx context.Context) error { + return am.keeper.BeginBlock(sdk.UnwrapSDKContext(ctx)) } // EndBlock returns the end blocker for the evm module. It returns no validator // updates. -func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { - return am.keeper.EndBlock(ctx, req) +func (am AppModule) EndBlock(ctx context.Context) error { + return am.keeper.EndBlock(sdk.UnwrapSDKContext(ctx)) } // InitGenesis performs genesis initialization for the evm module. It returns @@ -179,7 +183,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // RegisterStoreDecoder registers a decoder for evm module's types -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { + sdr[types.StoreKey] = simulation.NewDecodeStore() } // GenerateGenesisState creates a randomized GenState of the evm module. @@ -190,3 +195,9 @@ func (AppModule) GenerateGenesisState(_ *module.SimulationState) { func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/evm/statedb/interfaces.go b/x/evm/statedb/interfaces.go index a8aec34e..eb9ce6ea 100644 --- a/x/evm/statedb/interfaces.go +++ b/x/evm/statedb/interfaces.go @@ -16,7 +16,7 @@ package statedb import ( - storetypes "github.com/cosmos/cosmos-sdk/store/types" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" evmtypes "github.com/zeta-chain/ethermint/x/evm/types" diff --git a/x/evm/statedb/native.go b/x/evm/statedb/native.go index 82dfac6e..0f898dc6 100644 --- a/x/evm/statedb/native.go +++ b/x/evm/statedb/native.go @@ -1,7 +1,7 @@ package statedb import ( - "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/store/types" "github.com/ethereum/go-ethereum/common" ) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 0a4ef9cd..c44c7d95 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -17,9 +17,12 @@ package statedb import ( "fmt" + "math/big" "sort" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -334,11 +337,11 @@ func (s *StateDB) setStateObject(object *stateObject) { s.stateObjects[object.Address()] = object } -func (s *StateDB) cloneNativeState() sdk.MultiStore { +func (s *StateDB) cloneNativeState() storetypes.MultiStore { return s.cacheMultiStore().Clone() } -func (s *StateDB) restoreNativeState(ms sdk.MultiStore) { +func (s *StateDB) restoreNativeState(ms storetypes.MultiStore) { manager := sdk.NewEventManager() s.cacheCtx = s.cacheCtx.WithMultiStore(ms).WithEventManager(manager) } @@ -372,18 +375,36 @@ func (s *StateDB) CacheContext() sdk.Context { */ // AddBalance adds amount to the account associated with addr. -func (s *StateDB) AddBalance(addr common.Address, amount *uint256.Int) { - stateObject := s.getOrNewStateObject(addr) - if stateObject != nil { - stateObject.AddBalance(amount) +func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) { + if amount.Sign() <= 0 { + return + } + coins := sdk.Coins{sdk.NewCoin(s.evmDenom, sdkmath.NewIntFromBigInt(amount))} + if err := s.ExecuteNativeAction(common.Address{}, nil, func(ctx sdk.Context) error { + return s.keeper.AddBalance(ctx, sdk.AccAddress(addr.Bytes()), coins) + }); err != nil { + s.err = err } } // SubBalance subtracts amount from the account associated with addr. -func (s *StateDB) SubBalance(addr common.Address, amount *uint256.Int) { - stateObject := s.getOrNewStateObject(addr) - if stateObject != nil { - stateObject.SubBalance(amount) +func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) { + if amount.Sign() <= 0 { + return + } + coins := sdk.Coins{sdk.NewCoin(s.evmDenom, sdkmath.NewIntFromBigInt(amount))} + if err := s.ExecuteNativeAction(common.Address{}, nil, func(ctx sdk.Context) error { + return s.keeper.SubBalance(ctx, sdk.AccAddress(addr.Bytes()), coins) + }); err != nil { + s.err = err + } +} + +func (s *StateDB) SetBalance(addr common.Address, amount *big.Int) { + if err := s.ExecuteNativeAction(common.Address{}, nil, func(ctx sdk.Context) error { + return s.keeper.SetBalance(ctx, addr, amount, s.evmDenom) + }); err != nil { + s.err = err } } diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 2fd61237..ef7c668a 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -5,27 +5,30 @@ import ( "math/big" "testing" - consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - "github.com/holiman/uint256" - - dbm "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" + "cosmossdk.io/store/metrics" + "cosmossdk.io/store/rootmulti" + storetypes "cosmossdk.io/store/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/store/rootmulti" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + dbm "github.com/cosmos/cosmos-db" + sdkaddress "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/ethermint/app" + ethermint "github.com/evmos/ethermint/types" + evmkeeper "github.com/evmos/ethermint/x/evm/keeper" + "github.com/evmos/ethermint/x/evm/statedb" + evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/zeta-chain/ethermint/app" @@ -39,8 +42,7 @@ import ( var ( address common.Address = common.BigToAddress(big.NewInt(101)) address2 common.Address = common.BigToAddress(big.NewInt(102)) - address3 common.Address = common.BigToAddress(big.NewInt(103)) - blockHash common.Hash = common.BigToHash(big.NewInt(0)) + blockHash common.Hash = common.BigToHash(big.NewInt(9999)) emptyTxConfig statedb.TxConfig = statedb.NewEmptyTxConfig(blockHash) ) @@ -57,9 +59,9 @@ func (suite *StateDBTestSuite) TestAccount() { txConfig.TxHash = common.BigToHash(big.NewInt(100)) testCases := []struct { name string - malleate func(*statedb.StateDB, sdk.MultiStore) + malleate func(*statedb.StateDB, storetypes.MultiStore) }{ - {"non-exist account", func(db *statedb.StateDB, cms sdk.MultiStore) { + {"non-exist account", func(db *statedb.StateDB, cms storetypes.MultiStore) { suite.Require().Equal(false, db.Exist(address)) suite.Require().Equal(true, db.Empty(address)) suite.Require().Equal(uint256.NewInt(0), db.GetBalance(address)) @@ -67,7 +69,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().Equal(common.Hash{}, db.GetCodeHash(address)) suite.Require().Equal(uint64(0), db.GetNonce(address)) }}, - {"empty account", func(db *statedb.StateDB, cms sdk.MultiStore) { + {"empty account", func(db *statedb.StateDB, cms storetypes.MultiStore) { db.CreateAccount(address) suite.Require().NoError(db.Commit()) @@ -84,7 +86,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().Equal(common.BytesToHash(emptyCodeHash), db.GetCodeHash(address)) suite.Require().Equal(uint64(0), db.GetNonce(address)) }}, - {"suicide", func(db *statedb.StateDB, cms sdk.MultiStore) { + {"suicide", func(db *statedb.StateDB, cms storetypes.MultiStore) { // non-exist account. db.HasSelfDestructed(address) suite.Require().False(db.HasSelfDestructed(address)) @@ -752,12 +754,12 @@ func CollectContractStorage(db *statedb.StateDB) statedb.Storage { } var ( - testStoreKeys = sdk.NewKVStoreKeys(authtypes.StoreKey, banktypes.StoreKey, evmtypes.StoreKey, "testnative") - testTransientKeys = sdk.NewTransientStoreKeys(evmtypes.TransientKey) - testMemKeys = sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + testStoreKeys = storetypes.NewKVStoreKeys(authtypes.StoreKey, banktypes.StoreKey, evmtypes.StoreKey, "testnative") + testTransientKeys = storetypes.NewTransientStoreKeys(evmtypes.TransientKey) + testMemKeys = storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) ) -func cloneRawState(t *testing.T, cms sdk.MultiStore) map[string]map[string][]byte { +func cloneRawState(t *testing.T, cms storetypes.MultiStore) map[string]map[string][]byte { result := make(map[string]map[string][]byte) for name, key := range testStoreKeys { @@ -776,24 +778,27 @@ func cloneRawState(t *testing.T, cms sdk.MultiStore) map[string]map[string][]byt return result } -func newTestKeeper(t *testing.T, cms sdk.MultiStore) (sdk.Context, *evmkeeper.Keeper) { - appCodec := encoding.MakeConfig(app.ModuleBasics).Codec +func newTestKeeper(t *testing.T, cms storetypes.MultiStore) (sdk.Context, *evmkeeper.Keeper) { + appCodec := app.MakeConfigForTest().Codec authAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() accountKeeper := authkeeper.NewAccountKeeper( - appCodec, testStoreKeys[authtypes.StoreKey], + appCodec, + runtime.NewKVStoreService(testStoreKeys[authtypes.StoreKey]), ethermint.ProtoAccount, map[string][]string{ evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, }, + sdkaddress.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.GetConfig().GetBech32AccountAddrPrefix(), authAddr, ) bankKeeper := bankkeeper.NewBaseKeeper( appCodec, - testStoreKeys[banktypes.StoreKey], + runtime.NewKVStoreService(testStoreKeys[banktypes.StoreKey]), accountKeeper, map[string]bool{}, authAddr, + log.NewNopLogger(), ) conKeeper := consensusparamkeeper.NewKeeper(appCodec, testStoreKeys[consensusparamtypes.StoreKey], authAddr) @@ -808,10 +813,12 @@ func newTestKeeper(t *testing.T, cms sdk.MultiStore) (sdk.Context, *evmkeeper.Ke allKeys[k] = v } evmKeeper := evmkeeper.NewKeeper( - appCodec, testStoreKeys[evmtypes.StoreKey], testTransientKeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), + appCodec, + runtime.NewKVStoreService(testStoreKeys[evmtypes.StoreKey]), + testStoreKeys[evmtypes.StoreKey], testTransientKeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), accountKeeper, bankKeeper, nil, nil, "", - paramstypes.Subspace{}, nil, conKeeper, + nil, allKeys, ) @@ -819,9 +826,9 @@ func newTestKeeper(t *testing.T, cms sdk.MultiStore) (sdk.Context, *evmkeeper.Ke return ctx, evmKeeper } -func setupTestEnv(t *testing.T) (sdk.MultiStore, sdk.Context, *evmkeeper.Keeper) { +func setupTestEnv(t *testing.T) (storetypes.MultiStore, sdk.Context, *evmkeeper.Keeper) { db := dbm.NewMemDB() - cms := rootmulti.NewStore(db, log.NewNopLogger()) + cms := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) for _, key := range testStoreKeys { cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil) } diff --git a/x/evm/types/chain_config.go b/x/evm/types/chain_config.go index 3d82f1da..92cb1d95 100644 --- a/x/evm/types/chain_config.go +++ b/x/evm/types/chain_config.go @@ -19,11 +19,8 @@ import ( "math/big" "strings" - sdkmath "cosmossdk.io/math" - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - + sdkmath "cosmossdk.io/math" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" ) @@ -57,23 +54,22 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig { // DefaultChainConfig returns default evm parameters. func DefaultChainConfig() ChainConfig { - homesteadBlock := sdk.ZeroInt() - daoForkBlock := sdk.ZeroInt() - eip150Block := sdk.ZeroInt() - eip155Block := sdk.ZeroInt() - eip158Block := sdk.ZeroInt() - byzantiumBlock := sdk.ZeroInt() - constantinopleBlock := sdk.ZeroInt() - petersburgBlock := sdk.ZeroInt() - istanbulBlock := sdk.ZeroInt() - muirGlacierBlock := sdk.ZeroInt() - berlinBlock := sdk.ZeroInt() - londonBlock := sdk.ZeroInt() - arrowGlacierBlock := sdk.ZeroInt() - grayGlacierBlock := sdk.ZeroInt() - mergeNetsplitBlock := sdk.ZeroInt() - shanghaiBlock := sdk.ZeroInt() - cancunBlock := sdk.ZeroInt() + homesteadBlock := sdkmath.ZeroInt() + daoForkBlock := sdkmath.ZeroInt() + eip150Block := sdkmath.ZeroInt() + eip155Block := sdkmath.ZeroInt() + eip158Block := sdkmath.ZeroInt() + byzantiumBlock := sdkmath.ZeroInt() + constantinopleBlock := sdkmath.ZeroInt() + petersburgBlock := sdkmath.ZeroInt() + istanbulBlock := sdkmath.ZeroInt() + muirGlacierBlock := sdkmath.ZeroInt() + berlinBlock := sdkmath.ZeroInt() + londonBlock := sdkmath.ZeroInt() + arrowGlacierBlock := sdkmath.ZeroInt() + grayGlacierBlock := sdkmath.ZeroInt() + mergeNetsplitBlock := sdkmath.ZeroInt() + shanghaiTime := sdkmath.ZeroInt() return ChainConfig{ HomesteadBlock: &homesteadBlock, diff --git a/x/evm/types/codec.go b/x/evm/types/codec.go index d4d35b4f..2528e0ac 100644 --- a/x/evm/types/codec.go +++ b/x/evm/types/codec.go @@ -33,7 +33,7 @@ var ( ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) // AminoCdc is a amino codec created to support amino JSON compatible msgs. - AminoCdc = codec.NewAminoCodec(amino) + AminoCdc = codec.NewAminoCodec(amino) //nolint:staticcheck ) const ( diff --git a/x/evm/types/dynamic_fee_tx_test.go b/x/evm/types/dynamic_fee_tx_test.go index ede340bf..9103faa6 100644 --- a/x/evm/types/dynamic_fee_tx_test.go +++ b/x/evm/types/dynamic_fee_tx_test.go @@ -6,7 +6,6 @@ import ( sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -39,7 +38,7 @@ func (suite *TxDataTestSuite) SetupTest() { suite.bigInt = big.NewInt(1) suite.hexBigInt = hexutil.Big(*big.NewInt(1)) suite.overflowBigInt = big.NewInt(0).Exp(big.NewInt(10), big.NewInt(256), nil) - suite.sdkZeroInt = sdk.ZeroInt() + suite.sdkZeroInt = sdkmath.ZeroInt() suite.sdkMinusOneInt = sdkmath.NewInt(-1) suite.invalidAddr = "123456" suite.addr = tests.GenerateAddress() diff --git a/x/evm/types/interfaces.go b/x/evm/types/interfaces.go index a45c1d85..becf03c9 100644 --- a/x/evm/types/interfaces.go +++ b/x/evm/types/interfaces.go @@ -16,8 +16,10 @@ package types import ( + context "context" "math/big" + "github.com/cosmos/cosmos-sdk/x/auth/ante" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -31,32 +33,29 @@ import ( // AccountKeeper defines the expected account keeper interface type AccountKeeper interface { - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + ante.AccountKeeper + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(moduleName string) sdk.AccAddress - GetAllAccounts(ctx sdk.Context) (accounts []authtypes.AccountI) - IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountI) bool) - GetSequence(sdk.Context, sdk.AccAddress) (uint64, error) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - SetAccount(ctx sdk.Context, account authtypes.AccountI) - RemoveAccount(ctx sdk.Context, account authtypes.AccountI) - GetParams(ctx sdk.Context) (params authtypes.Params) + GetAllAccounts(ctx context.Context) (accounts []sdk.AccountI) + IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) bool) + GetSequence(context.Context, sdk.AccAddress) (uint64, error) + RemoveAccount(ctx context.Context, account sdk.AccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { authtypes.BankKeeper - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error + GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error BlockedAddr(addr sdk.AccAddress) bool } // StakingKeeper returns the historical headers kept in store. type StakingKeeper interface { - GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool) - GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool) + GetHistoricalInfo(ctx context.Context, height int64) (stakingtypes.HistoricalInfo, error) + GetValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, err error) } // FeeMarketKeeper diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index d046482d..479b5ce6 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -21,6 +21,7 @@ import ( "math/big" sdkmath "cosmossdk.io/math" + "google.golang.org/protobuf/proto" errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/client" @@ -28,8 +29,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/auth/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" ethermint "github.com/zeta-chain/ethermint/types" @@ -220,12 +222,22 @@ func (msg *MsgEthereumTx) GetMsgs() []sdk.Msg { return []sdk.Msg{msg} } -// GetSigners returns the expected signers for an Ethereum transaction message. -// For such a message, there should exist only a single 'signer'. -// -// NOTE: This method panics if 'Sign' hasn't been called first. -func (msg *MsgEthereumTx) GetSigners() []sdk.AccAddress { - data, err := UnpackTxData(msg.Data) +func (msg *MsgEthereumTx) GetMsgsV2() ([]proto.Message, error) { + return nil, errors.New("not implemented") +} + +// GetSender convert the From field to common.Address +// From should always be set, which is validated in ValidateBasic +func (msg *MsgEthereumTx) GetSender() common.Address { + return common.BytesToAddress(msg.From) +} + +// GetSenderLegacy fallbacks to old behavior if From is empty, should be used by json-rpc +func (msg *MsgEthereumTx) GetSenderLegacy(chainID *big.Int) (common.Address, error) { + if len(msg.From) > 0 { + return msg.GetSender(), nil + } + sender, err := msg.recoverSender(chainID) if err != nil { panic(err) } @@ -264,7 +276,7 @@ func (msg *MsgEthereumTx) Sign(ethSigner ethtypes.Signer, keyringSigner keyring. tx := msg.AsTransaction() txHash := ethSigner.Hash(tx) - sig, _, err := keyringSigner.SignByAddress(from, txHash.Bytes()) + sig, _, err := keyringSigner.SignByAddress(from, txHash.Bytes(), signing.SignMode_SIGN_MODE_TEXTUAL) if err != nil { return err } @@ -393,7 +405,7 @@ func (msg *MsgEthereumTx) UnmarshalBinary(b []byte) error { } // BuildTx builds the canonical cosmos tx from ethereum msg -func (msg *MsgEthereumTx) BuildTx(b client.TxBuilder, evmDenom string) (signing.Tx, error) { +func (msg *MsgEthereumTx) BuildTx(b client.TxBuilder, evmDenom string) (authsigning.Tx, error) { builder, ok := b.(authtx.ExtensionOptionsTxBuilder) if !ok { return nil, errors.New("unsupported builder") @@ -429,13 +441,6 @@ func (msg *MsgEthereumTx) BuildTx(b client.TxBuilder, evmDenom string) (signing. return tx, nil } -// GetSigners returns the expected signers for a MsgUpdateParams message. -func (m MsgUpdateParams) GetSigners() []sdk.AccAddress { - //#nosec G703 -- gosec raises a warning about a non-handled error which we deliberately ignore here - addr, _ := sdk.AccAddressFromBech32(m.Authority) - return []sdk.AccAddress{addr} -} - // ValidateBasic does a sanity check of the provided data func (m *MsgUpdateParams) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { diff --git a/x/evm/types/msg_test.go b/x/evm/types/msg_test.go index 592e46b7..508a44d3 100644 --- a/x/evm/types/msg_test.go +++ b/x/evm/types/msg_test.go @@ -13,16 +13,15 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/tests" + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/crypto/ethsecp256k1" + "github.com/evmos/ethermint/tests" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/types" ) const invalidFromAddress = "0x0000" @@ -52,7 +51,7 @@ func (suite *MsgsTestSuite) SetupTest() { suite.chainID = big.NewInt(1) suite.hundredBigInt = big.NewInt(100) - encodingConfig := encoding.MakeConfig(app.ModuleBasics) + encodingConfig := app.MakeConfigForTest() suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) } @@ -64,7 +63,6 @@ func (suite *MsgsTestSuite) TestMsgEthereumTx_Constructor() { suite.Require().Equal(msg.Type(), types.TypeMsgEthereumTx) // suite.Require().NotNil(msg.To()) suite.Require().Equal(msg.GetMsgs(), []sdk.Msg{msg}) - suite.Require().Panics(func() { msg.GetSigners() }) suite.Require().Panics(func() { msg.GetSignBytes() }) msg = types.NewTxContract(nil, 0, nil, 100000, nil, nil, nil, []byte("test"), nil) diff --git a/x/evm/types/query.pb.go b/x/evm/types/query.pb.go index 16279f63..64695ecf 100644 --- a/x/evm/types/query.pb.go +++ b/x/evm/types/query.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" @@ -1248,7 +1249,7 @@ var xxx_messageInfo_QueryBaseFeeRequest proto.InternalMessageInfo // QueryBaseFeeResponse returns the EIP1559 base fee. type QueryBaseFeeResponse struct { // base_fee is the EIP1559 base fee - BaseFee *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee,omitempty"` + BaseFee *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=cosmossdk.io/math.Int" json:"base_fee,omitempty"` } func (m *QueryBaseFeeResponse) Reset() { *m = QueryBaseFeeResponse{} } @@ -1314,97 +1315,105 @@ func init() { func init() { proto.RegisterFile("ethermint/evm/v1/query.proto", fileDescriptor_e15a877459347994) } var fileDescriptor_e15a877459347994 = []byte{ - // 1439 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0xcf, 0x6f, 0x13, 0xc7, - 0x17, 0xcf, 0xc6, 0x4e, 0xec, 0x3c, 0x07, 0xf0, 0x77, 0x08, 0x5f, 0xcc, 0x36, 0xb1, 0xc3, 0x42, - 0x7e, 0x87, 0xdd, 0xc6, 0xad, 0x90, 0xca, 0xa5, 0xc5, 0x56, 0xa0, 0x14, 0xa8, 0xa8, 0x1b, 0xf5, - 0x50, 0x09, 0x59, 0xe3, 0xf5, 0xb0, 0xb6, 0x62, 0xef, 0x9a, 0x9d, 0xb1, 0xeb, 0x40, 0xe9, 0xa1, - 0x52, 0x11, 0x15, 0x52, 0x85, 0xd4, 0x7b, 0xc5, 0x7f, 0xd0, 0x63, 0xff, 0x05, 0x8e, 0x48, 0xbd, - 0x54, 0x3d, 0x50, 0x44, 0x7a, 0xe8, 0xad, 0xf7, 0x9e, 0xaa, 0x99, 0x9d, 0xb5, 0xd7, 0x5e, 0xaf, - 0x1d, 0x2a, 0x7a, 0xea, 0x69, 0x77, 0x66, 0xde, 0xbc, 0xf7, 0x79, 0x3f, 0xe6, 0xbd, 0x0f, 0x2c, - 0x12, 0x56, 0x23, 0x6e, 0xb3, 0x6e, 0x33, 0x83, 0x74, 0x9a, 0x46, 0x67, 0xc7, 0xb8, 0xdb, 0x26, - 0xee, 0x81, 0xde, 0x72, 0x1d, 0xe6, 0xa0, 0x74, 0xef, 0x54, 0x27, 0x9d, 0xa6, 0xde, 0xd9, 0x51, - 0x37, 0x4d, 0x87, 0x36, 0x1d, 0x6a, 0x54, 0x30, 0x25, 0x9e, 0xa8, 0xd1, 0xd9, 0xa9, 0x10, 0x86, - 0x77, 0x8c, 0x16, 0xb6, 0xea, 0x36, 0x66, 0x75, 0xc7, 0xf6, 0x6e, 0xab, 0x6a, 0x48, 0x37, 0x57, - 0xe2, 0x9d, 0x9d, 0x09, 0x9d, 0xb1, 0xae, 0x3c, 0x5a, 0xb0, 0x1c, 0xcb, 0x11, 0xbf, 0x06, 0xff, - 0x93, 0xbb, 0x8b, 0x96, 0xe3, 0x58, 0x0d, 0x62, 0xe0, 0x56, 0xdd, 0xc0, 0xb6, 0xed, 0x30, 0x61, - 0x89, 0xca, 0xd3, 0x9c, 0x3c, 0x15, 0xab, 0x4a, 0xfb, 0x8e, 0xc1, 0xea, 0x4d, 0x42, 0x19, 0x6e, - 0xb6, 0x3c, 0x01, 0xed, 0x3d, 0x38, 0xf9, 0x09, 0x47, 0x7b, 0xd9, 0x34, 0x9d, 0xb6, 0xcd, 0x4a, - 0xe4, 0x6e, 0x9b, 0x50, 0x86, 0x32, 0x90, 0xc0, 0xd5, 0xaa, 0x4b, 0x28, 0xcd, 0x28, 0xcb, 0xca, - 0xfa, 0x5c, 0xc9, 0x5f, 0x5e, 0x4a, 0x3e, 0x7a, 0x9a, 0x9b, 0xfa, 0xe3, 0x69, 0x6e, 0x4a, 0x33, - 0x61, 0x61, 0xf0, 0x2a, 0x6d, 0x39, 0x36, 0x25, 0xfc, 0x6e, 0x05, 0x37, 0xb0, 0x6d, 0x12, 0xff, - 0xae, 0x5c, 0xa2, 0xb7, 0x60, 0xce, 0x74, 0xaa, 0xa4, 0x5c, 0xc3, 0xb4, 0x96, 0x99, 0x16, 0x67, - 0x49, 0xbe, 0xf1, 0x21, 0xa6, 0x35, 0xb4, 0x00, 0x33, 0xb6, 0xc3, 0x2f, 0xc5, 0x96, 0x95, 0xf5, - 0x78, 0xc9, 0x5b, 0x68, 0xef, 0xc3, 0x19, 0x61, 0xa4, 0x28, 0xc2, 0xfb, 0x0f, 0x50, 0x3e, 0x54, - 0x40, 0x1d, 0xa5, 0x41, 0x82, 0x5d, 0x81, 0xe3, 0x5e, 0xe6, 0xca, 0x83, 0x9a, 0x8e, 0x79, 0xbb, - 0x97, 0xbd, 0x4d, 0xa4, 0x42, 0x92, 0x72, 0xa3, 0x1c, 0xdf, 0xb4, 0xc0, 0xd7, 0x5b, 0x73, 0x15, - 0xd8, 0xd3, 0x5a, 0xb6, 0xdb, 0xcd, 0x0a, 0x71, 0xa5, 0x07, 0xc7, 0xe4, 0xee, 0xc7, 0x62, 0x53, - 0xbb, 0x0e, 0x8b, 0x02, 0xc7, 0x67, 0xb8, 0x51, 0xaf, 0x62, 0xe6, 0xb8, 0x43, 0xce, 0x9c, 0x85, - 0x79, 0xd3, 0xb1, 0x87, 0x71, 0xa4, 0xf8, 0xde, 0xe5, 0x90, 0x57, 0x8f, 0x15, 0x58, 0x8a, 0xd0, - 0x26, 0x1d, 0x5b, 0x83, 0x13, 0x3e, 0xaa, 0x41, 0x8d, 0x3e, 0xd8, 0x37, 0xe8, 0x9a, 0x5f, 0x44, - 0x05, 0x2f, 0xcf, 0xaf, 0x93, 0x9e, 0xb7, 0x65, 0x11, 0xf5, 0xae, 0x4e, 0x2a, 0x22, 0xed, 0xba, - 0x34, 0xf6, 0x29, 0x73, 0x5c, 0x6c, 0x4d, 0x36, 0x86, 0xd2, 0x10, 0xdb, 0x27, 0x07, 0xb2, 0xde, - 0xf8, 0x6f, 0xc0, 0xfc, 0xb6, 0x34, 0xdf, 0x53, 0x26, 0xcd, 0x2f, 0xc0, 0x4c, 0x07, 0x37, 0xda, - 0xbe, 0x71, 0x6f, 0xa1, 0x5d, 0x84, 0xb4, 0x2c, 0xa5, 0xea, 0x6b, 0x39, 0xb9, 0x06, 0xff, 0x0b, - 0xdc, 0x93, 0x26, 0x10, 0xc4, 0x79, 0xed, 0x8b, 0x5b, 0xf3, 0x25, 0xf1, 0xaf, 0xdd, 0x03, 0x24, - 0x04, 0xf7, 0xba, 0x37, 0x1c, 0x8b, 0xfa, 0x26, 0x10, 0xc4, 0xc5, 0x8b, 0xf1, 0xf4, 0x8b, 0x7f, - 0x74, 0x05, 0xa0, 0xdf, 0x57, 0x84, 0x6f, 0xa9, 0xfc, 0xaa, 0xee, 0x15, 0xad, 0xce, 0x9b, 0x90, - 0xee, 0xf5, 0x2b, 0xd9, 0x84, 0xf4, 0x5b, 0xfd, 0x50, 0x95, 0x02, 0x37, 0x03, 0x20, 0xbf, 0x55, - 0x64, 0x60, 0x7d, 0xe3, 0x12, 0xe7, 0x06, 0xc4, 0x1b, 0x8e, 0xc5, 0xbd, 0x8b, 0xad, 0xa7, 0xf2, - 0xa7, 0xf4, 0xe1, 0xd6, 0xa7, 0xdf, 0x70, 0xac, 0x92, 0x10, 0x41, 0x57, 0x47, 0x80, 0x5a, 0x9b, - 0x08, 0xca, 0xb3, 0x13, 0x44, 0xa5, 0x2d, 0xc8, 0x38, 0xdc, 0xc2, 0x2e, 0x6e, 0xfa, 0x71, 0xd0, - 0x6e, 0x4a, 0x80, 0xfe, 0xae, 0x04, 0x78, 0x11, 0x66, 0x5b, 0x62, 0x47, 0x04, 0x28, 0x95, 0xcf, - 0x84, 0x21, 0x7a, 0x37, 0x0a, 0xf1, 0x67, 0x2f, 0x72, 0x53, 0x25, 0x29, 0xad, 0xfd, 0xa4, 0xc0, - 0xf1, 0x5d, 0x56, 0x2b, 0xe2, 0x46, 0x23, 0x10, 0x69, 0xec, 0x5a, 0xd4, 0xcf, 0x09, 0xff, 0x47, - 0xa7, 0x21, 0x61, 0x61, 0x5a, 0x36, 0x71, 0x4b, 0x3e, 0x8f, 0x59, 0x0b, 0xd3, 0x22, 0x6e, 0xa1, - 0xdb, 0x90, 0x6e, 0xb9, 0x4e, 0xcb, 0xa1, 0xc4, 0xed, 0x3d, 0x31, 0xfe, 0x3c, 0xe6, 0x0b, 0xf9, - 0xbf, 0x5e, 0xe4, 0x74, 0xab, 0xce, 0x6a, 0xed, 0x8a, 0x6e, 0x3a, 0x4d, 0x43, 0xce, 0x06, 0xef, - 0x73, 0x81, 0x56, 0xf7, 0x0d, 0x76, 0xd0, 0x22, 0x54, 0x2f, 0xf6, 0xdf, 0x76, 0xe9, 0x84, 0xaf, - 0xcb, 0x7f, 0x97, 0x67, 0x20, 0x69, 0xd6, 0x70, 0xdd, 0x2e, 0xd7, 0xab, 0x99, 0xf8, 0xb2, 0xb2, - 0x1e, 0x2b, 0x25, 0xc4, 0xfa, 0x5a, 0x55, 0x5b, 0x83, 0x93, 0xbb, 0x94, 0xd5, 0x9b, 0x98, 0x91, - 0xab, 0xb8, 0x1f, 0x88, 0x34, 0xc4, 0x2c, 0xec, 0x81, 0x8f, 0x97, 0xf8, 0xaf, 0xf6, 0x32, 0xe6, - 0xe7, 0xd4, 0xc5, 0x26, 0xd9, 0xeb, 0xfa, 0x7e, 0xee, 0x40, 0xac, 0x49, 0x2d, 0x19, 0xaf, 0x5c, - 0x38, 0x5e, 0x37, 0xa9, 0xb5, 0xcb, 0xf7, 0x48, 0xbb, 0xb9, 0xd7, 0x2d, 0x71, 0x59, 0xf4, 0x01, - 0xcc, 0x33, 0xae, 0xa4, 0x6c, 0x3a, 0xf6, 0x9d, 0xba, 0x25, 0x3c, 0x4d, 0xe5, 0x97, 0xc2, 0x77, - 0x85, 0xa9, 0xa2, 0x10, 0x2a, 0xa5, 0x58, 0x7f, 0x81, 0x8a, 0x30, 0xdf, 0x72, 0x49, 0x95, 0x98, - 0x84, 0x52, 0xc7, 0xa5, 0x99, 0xb8, 0x28, 0xa8, 0x89, 0xd6, 0x07, 0x2e, 0xf1, 0x2e, 0x59, 0x69, - 0x38, 0xe6, 0xbe, 0xdf, 0x8f, 0x66, 0x44, 0x64, 0x52, 0x62, 0xcf, 0xeb, 0x46, 0x68, 0x09, 0xc0, - 0x13, 0x11, 0x8f, 0x66, 0x56, 0x3c, 0x9a, 0x39, 0xb1, 0x23, 0xe6, 0x4c, 0xd1, 0x3f, 0xe6, 0xa3, - 0x30, 0x93, 0x10, 0x6e, 0xa8, 0xba, 0x37, 0x27, 0x75, 0x7f, 0x4e, 0xea, 0x7b, 0xfe, 0x9c, 0x2c, - 0x24, 0x79, 0xd1, 0x3c, 0xf9, 0x2d, 0xa7, 0x48, 0x25, 0xfc, 0x64, 0x64, 0xee, 0x93, 0xff, 0x4e, - 0xee, 0xe7, 0x06, 0x72, 0xff, 0x51, 0x3c, 0x39, 0x9d, 0x8e, 0x95, 0x92, 0xac, 0x5b, 0xae, 0xdb, - 0x55, 0xd2, 0xd5, 0x36, 0x65, 0x07, 0xeb, 0x65, 0xb8, 0xdf, 0x5e, 0xaa, 0x98, 0x61, 0xbf, 0x94, - 0xf9, 0xbf, 0xf6, 0x5d, 0x0c, 0xfe, 0xdf, 0x17, 0x2e, 0x70, 0x6f, 0x02, 0x15, 0xc1, 0xba, 0xfe, - 0x23, 0x9f, 0x5c, 0x11, 0xac, 0x4b, 0xdf, 0x40, 0x45, 0xfc, 0xd7, 0x93, 0xa9, 0x5d, 0x80, 0xd3, - 0xa1, 0x7c, 0x8c, 0xc9, 0xdf, 0xa9, 0xde, 0x9c, 0xa5, 0xe4, 0x0a, 0xf1, 0xfb, 0xb9, 0x76, 0xbb, - 0x37, 0x43, 0xe5, 0xb6, 0x54, 0xb1, 0x0b, 0x49, 0xde, 0x74, 0xcb, 0x77, 0x88, 0x9c, 0x63, 0x85, - 0xcd, 0x5f, 0x5f, 0xe4, 0x56, 0x8f, 0xe0, 0xcf, 0x35, 0x9b, 0xf1, 0x81, 0x2b, 0xd4, 0xe5, 0xff, - 0x9c, 0x87, 0x19, 0xa1, 0x1f, 0x7d, 0xa3, 0x40, 0x42, 0xf2, 0x0c, 0xb4, 0x12, 0xce, 0xf3, 0x08, - 0x22, 0xa9, 0xae, 0x4e, 0x12, 0xf3, 0xb0, 0x6a, 0x5b, 0x5f, 0xff, 0xfc, 0xfb, 0xf7, 0xd3, 0x2b, - 0xe8, 0x9c, 0x11, 0x22, 0xc0, 0x92, 0x6b, 0x18, 0xf7, 0x65, 0x6e, 0x1e, 0xa0, 0x1f, 0x14, 0x38, - 0x36, 0x40, 0xe7, 0xd0, 0x56, 0x84, 0x99, 0x51, 0xb4, 0x51, 0xdd, 0x3e, 0x9a, 0xb0, 0x44, 0x96, - 0x17, 0xc8, 0xb6, 0xd1, 0x66, 0x18, 0x99, 0xcf, 0x1c, 0x43, 0x00, 0x7f, 0x54, 0x20, 0x3d, 0xcc, - 0xcc, 0x90, 0x1e, 0x61, 0x36, 0x82, 0x10, 0xaa, 0xc6, 0x91, 0xe5, 0x25, 0xd2, 0x4b, 0x02, 0xe9, - 0xbb, 0x28, 0x1f, 0x46, 0xda, 0xf1, 0xef, 0xf4, 0xc1, 0x06, 0xc9, 0xe6, 0x03, 0xf4, 0x50, 0x81, - 0x84, 0xe4, 0x60, 0x91, 0xa9, 0x1d, 0xa4, 0x77, 0x91, 0xa9, 0x1d, 0xa2, 0x72, 0xda, 0xb6, 0x80, - 0xb5, 0x8a, 0xce, 0x87, 0x61, 0x49, 0x4e, 0x47, 0x03, 0xa1, 0x7b, 0xac, 0x40, 0x42, 0xb2, 0xb1, - 0x48, 0x20, 0x83, 0xd4, 0x2f, 0x12, 0xc8, 0x10, 0xa9, 0xd3, 0x76, 0x04, 0x90, 0x2d, 0xb4, 0x11, - 0x06, 0x42, 0x3d, 0xd1, 0x3e, 0x0e, 0xe3, 0xfe, 0x3e, 0x39, 0x78, 0x80, 0xee, 0x41, 0x9c, 0x93, - 0x36, 0xa4, 0x45, 0x96, 0x4c, 0x8f, 0x09, 0xaa, 0xe7, 0xc6, 0xca, 0x48, 0x0c, 0x1b, 0x02, 0xc3, - 0x39, 0x74, 0x76, 0x54, 0x35, 0x55, 0x07, 0x22, 0xf1, 0x05, 0xcc, 0x7a, 0xbc, 0x05, 0x9d, 0x8f, - 0xd0, 0x3c, 0x40, 0x8f, 0xd4, 0x95, 0x09, 0x52, 0x12, 0xc1, 0xb2, 0x40, 0xa0, 0xa2, 0x4c, 0x18, - 0x81, 0x47, 0x8c, 0x50, 0x17, 0x12, 0x92, 0x17, 0xa1, 0xe5, 0xb0, 0xce, 0x41, 0xca, 0xa4, 0xae, - 0x4d, 0x9a, 0x15, 0xbe, 0x5d, 0x4d, 0xd8, 0x5d, 0x44, 0x6a, 0xd8, 0x2e, 0x61, 0xb5, 0xb2, 0xc9, - 0xcd, 0x7d, 0x05, 0xa9, 0x00, 0xb1, 0x39, 0x82, 0xf5, 0x11, 0x3e, 0x8f, 0x60, 0x46, 0xda, 0xaa, - 0xb0, 0xbd, 0x8c, 0xb2, 0x23, 0x6c, 0x4b, 0xf1, 0xb2, 0x85, 0x29, 0xfa, 0x12, 0x12, 0x72, 0x8e, - 0x46, 0xd6, 0xde, 0x20, 0x93, 0x8a, 0xac, 0xbd, 0xa1, 0x71, 0x3c, 0xce, 0x7b, 0x6f, 0x88, 0xb2, - 0x2e, 0x7a, 0xa4, 0x00, 0xf4, 0x27, 0x01, 0x5a, 0x1f, 0xa7, 0x3a, 0x38, 0xbc, 0xd5, 0x8d, 0x23, - 0x48, 0x4a, 0x1c, 0x2b, 0x02, 0x47, 0x0e, 0x2d, 0x45, 0xe1, 0x10, 0x63, 0x91, 0x07, 0x42, 0x4e, - 0x93, 0x31, 0xdd, 0x20, 0x38, 0x84, 0xc6, 0x74, 0x83, 0x81, 0xa1, 0x34, 0x2e, 0x10, 0xfe, 0xb0, - 0x2a, 0xec, 0x3e, 0x7b, 0x95, 0x55, 0x9e, 0xbf, 0xca, 0x2a, 0x2f, 0x5f, 0x65, 0x95, 0x27, 0x87, - 0xd9, 0xa9, 0xe7, 0x87, 0xd9, 0xa9, 0x5f, 0x0e, 0xb3, 0x53, 0x9f, 0x6f, 0x05, 0x86, 0xd7, 0x3d, - 0xc2, 0xf0, 0x05, 0x31, 0x49, 0x03, 0xaa, 0xba, 0x42, 0x99, 0x98, 0x62, 0x95, 0x59, 0x41, 0x00, - 0xde, 0xf9, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x32, 0x8f, 0x70, 0xac, 0xcc, 0x11, 0x00, 0x00, + // 1566 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0x4d, 0x6f, 0x13, 0xc7, + 0x1b, 0xcf, 0xc6, 0x4e, 0xec, 0x8c, 0x13, 0xc8, 0x7f, 0x48, 0xfe, 0x38, 0xdb, 0xc4, 0x0e, 0x1b, + 0xf2, 0x06, 0x61, 0xb7, 0x71, 0x11, 0x52, 0xb9, 0x14, 0x62, 0x05, 0x4a, 0x81, 0x8a, 0x6e, 0xa3, + 0x1e, 0x2a, 0x55, 0xd6, 0x78, 0x3d, 0xac, 0xad, 0x78, 0x77, 0xcc, 0xce, 0xd8, 0x75, 0x78, 0xe9, + 0xa1, 0x6a, 0x29, 0x15, 0x52, 0x85, 0xd4, 0x7b, 0xc5, 0x37, 0xe8, 0xd7, 0xe0, 0x88, 0x54, 0x55, + 0xaa, 0x7a, 0xa0, 0x08, 0x7a, 0xe8, 0x27, 0xe8, 0xa1, 0xa7, 0x6a, 0x66, 0x67, 0xed, 0xb5, 0xd7, + 0x6b, 0x87, 0x8a, 0x4a, 0x48, 0x3d, 0x79, 0x5e, 0x9e, 0x79, 0x9e, 0xdf, 0xcc, 0xf3, 0xf6, 0x5b, + 0x83, 0x45, 0xcc, 0xaa, 0xd8, 0x73, 0x6a, 0x2e, 0x33, 0x70, 0xcb, 0x31, 0x5a, 0xdb, 0xc6, 0xad, + 0x26, 0xf6, 0x0e, 0xf4, 0x86, 0x47, 0x18, 0x81, 0xb3, 0x9d, 0x5d, 0x1d, 0xb7, 0x1c, 0xbd, 0xb5, + 0xad, 0x9e, 0xb2, 0x08, 0x75, 0x08, 0x35, 0xca, 0x88, 0x62, 0x5f, 0xd4, 0x68, 0x6d, 0x97, 0x31, + 0x43, 0xdb, 0x46, 0x03, 0xd9, 0x35, 0x17, 0xb1, 0x1a, 0x71, 0xfd, 0xd3, 0xea, 0x42, 0x44, 0x37, + 0x6b, 0xcb, 0x2d, 0x35, 0xb2, 0x55, 0x27, 0xb6, 0xdc, 0x5b, 0x8a, 0xec, 0x35, 0x90, 0x87, 0x1c, + 0x2a, 0xb7, 0x57, 0xa2, 0x5a, 0x3d, 0x64, 0xe1, 0x92, 0x45, 0xdc, 0x9b, 0xb5, 0x40, 0xc7, 0x9c, + 0x4d, 0x6c, 0x22, 0x86, 0x06, 0x1f, 0xc9, 0xd5, 0x45, 0x9b, 0x10, 0xbb, 0x8e, 0x0d, 0xd4, 0xa8, + 0x19, 0xc8, 0x75, 0x09, 0x13, 0x68, 0x03, 0xc5, 0x79, 0xb9, 0x2b, 0x66, 0xe5, 0xe6, 0x4d, 0x83, + 0xd5, 0x1c, 0x4c, 0x19, 0x72, 0x1a, 0xbe, 0x80, 0xf6, 0x2e, 0x38, 0xf6, 0x11, 0xbf, 0xf1, 0x45, + 0xcb, 0x22, 0x4d, 0x97, 0x99, 0xf8, 0x56, 0x13, 0x53, 0x06, 0xb3, 0x20, 0x85, 0x2a, 0x15, 0x0f, + 0x53, 0x9a, 0x55, 0x96, 0x95, 0x8d, 0x29, 0x33, 0x98, 0x9e, 0x4f, 0x3f, 0x78, 0x9c, 0x1f, 0xfb, + 0xe3, 0x71, 0x7e, 0x4c, 0xb3, 0xc0, 0x5c, 0xef, 0x51, 0xda, 0x20, 0x2e, 0xc5, 0xfc, 0x6c, 0x19, + 0xd5, 0x91, 0x6b, 0xe1, 0xe0, 0xac, 0x9c, 0xc2, 0xb7, 0xc0, 0x94, 0x45, 0x2a, 0xb8, 0x54, 0x45, + 0xb4, 0x9a, 0x1d, 0x17, 0x7b, 0x69, 0xbe, 0xf0, 0x3e, 0xa2, 0x55, 0x38, 0x07, 0x26, 0x5c, 0xc2, + 0x0f, 0x25, 0x96, 0x95, 0x8d, 0xa4, 0xe9, 0x4f, 0xb4, 0xf7, 0xc0, 0x82, 0x30, 0x52, 0x14, 0x2e, + 0xfa, 0x07, 0x28, 0xef, 0x2b, 0x40, 0x1d, 0xa4, 0x41, 0x82, 0x5d, 0x05, 0x47, 0x7c, 0xef, 0x97, + 0x7a, 0x35, 0xcd, 0xf8, 0xab, 0x17, 0xfd, 0x45, 0xa8, 0x82, 0x34, 0xe5, 0x46, 0x39, 0xbe, 0x71, + 0x81, 0xaf, 0x33, 0xe7, 0x2a, 0x90, 0xaf, 0xb5, 0xe4, 0x36, 0x9d, 0x32, 0xf6, 0xe4, 0x0d, 0x66, + 0xe4, 0xea, 0x87, 0x62, 0x51, 0xbb, 0x0a, 0x16, 0x05, 0x8e, 0x4f, 0x50, 0xbd, 0x56, 0x41, 0x8c, + 0x78, 0x7d, 0x97, 0x39, 0x01, 0xa6, 0x2d, 0xe2, 0xf6, 0xe3, 0xc8, 0xf0, 0xb5, 0x8b, 0x91, 0x5b, + 0x3d, 0x54, 0xc0, 0x52, 0x8c, 0x36, 0x79, 0xb1, 0x75, 0x70, 0x34, 0x40, 0xd5, 0xab, 0x31, 0x00, + 0xfb, 0x1a, 0xaf, 0x16, 0x04, 0xd1, 0x8e, 0xef, 0xe7, 0x57, 0x71, 0xcf, 0xdb, 0x32, 0x88, 0x3a, + 0x47, 0x47, 0x05, 0x91, 0x76, 0x55, 0x1a, 0xfb, 0x98, 0x11, 0x0f, 0xd9, 0xa3, 0x8d, 0xc1, 0x59, + 0x90, 0xd8, 0xc7, 0x07, 0x32, 0xde, 0xf8, 0x30, 0x64, 0x7e, 0x4b, 0x9a, 0xef, 0x28, 0x93, 0xe6, + 0xe7, 0xc0, 0x44, 0x0b, 0xd5, 0x9b, 0x81, 0x71, 0x7f, 0xa2, 0x9d, 0x03, 0xb3, 0x32, 0x94, 0x2a, + 0xaf, 0x74, 0xc9, 0x75, 0xf0, 0xbf, 0xd0, 0x39, 0x69, 0x02, 0x82, 0x24, 0x8f, 0x7d, 0x71, 0x6a, + 0xda, 0x14, 0x63, 0xed, 0x36, 0x80, 0x42, 0x70, 0xaf, 0x7d, 0x8d, 0xd8, 0x34, 0x30, 0x01, 0x41, + 0x52, 0x64, 0x8c, 0xaf, 0x5f, 0x8c, 0xe1, 0x25, 0x00, 0xba, 0xb5, 0x49, 0xdc, 0x2d, 0x53, 0x58, + 0xd3, 0xfd, 0xa0, 0xd5, 0x79, 0x21, 0xd3, 0xfd, 0x9a, 0x27, 0x0b, 0x99, 0x7e, 0xa3, 0xfb, 0x54, + 0x66, 0xe8, 0x64, 0x08, 0xe4, 0xb7, 0x8a, 0x7c, 0xd8, 0xc0, 0xb8, 0xc4, 0xb9, 0x09, 0x92, 0x75, + 0x62, 0xf3, 0xdb, 0x25, 0x36, 0x32, 0x85, 0x79, 0xbd, 0xbf, 0x7c, 0xea, 0xd7, 0x88, 0x6d, 0x0a, + 0x11, 0x78, 0x79, 0x00, 0xa8, 0xf5, 0x91, 0xa0, 0x7c, 0x3b, 0x61, 0x54, 0xda, 0x9c, 0x7c, 0x87, + 0x1b, 0xa2, 0x48, 0x4a, 0xdc, 0xda, 0x75, 0x09, 0x30, 0x58, 0x95, 0x00, 0xcf, 0x81, 0x49, 0xbf, + 0x98, 0x8a, 0x07, 0xca, 0x14, 0xb2, 0x51, 0x88, 0xfe, 0x89, 0x9d, 0xe4, 0x93, 0x67, 0xf9, 0x31, + 0x53, 0x4a, 0x6b, 0x3f, 0x2b, 0xe0, 0xc8, 0x2e, 0xab, 0x16, 0x51, 0xbd, 0x1e, 0x7a, 0x69, 0xe4, + 0xd9, 0x34, 0xf0, 0x09, 0x1f, 0xc3, 0xe3, 0x20, 0x65, 0x23, 0x5a, 0xb2, 0x50, 0x43, 0xa6, 0xc7, + 0xa4, 0x8d, 0x68, 0x11, 0x35, 0xe0, 0x67, 0x60, 0xb6, 0xe1, 0x91, 0x06, 0xa1, 0xd8, 0xeb, 0xa4, + 0x18, 0x4f, 0x8f, 0xe9, 0x9d, 0xc2, 0x5f, 0xcf, 0xf2, 0xba, 0x5d, 0x63, 0xd5, 0x66, 0x59, 0xb7, + 0x88, 0x63, 0xc8, 0xfe, 0xe2, 0xff, 0x9c, 0xa1, 0x95, 0x7d, 0x83, 0x1d, 0x34, 0x30, 0xd5, 0x8b, + 0xdd, 0xdc, 0x36, 0x8f, 0x06, 0xba, 0x82, 0xbc, 0x5c, 0x00, 0x69, 0xab, 0x8a, 0x6a, 0x6e, 0xa9, + 0x56, 0xc9, 0x26, 0x97, 0x95, 0x8d, 0x84, 0x99, 0x12, 0xf3, 0x2b, 0x15, 0xb8, 0x08, 0xa6, 0x48, + 0x0b, 0x7b, 0x5e, 0xad, 0x82, 0x69, 0x76, 0x42, 0x60, 0xed, 0x2e, 0x68, 0x7b, 0xe0, 0xd8, 0x2e, + 0x65, 0x35, 0x07, 0x31, 0x7c, 0x19, 0x75, 0x9f, 0x69, 0x16, 0x24, 0x6c, 0xe4, 0x5f, 0x2d, 0x69, + 0xf2, 0x21, 0x5f, 0xf1, 0x30, 0x13, 0xb7, 0x9a, 0x36, 0xf9, 0x90, 0xdb, 0x6c, 0x39, 0x25, 0xec, + 0x79, 0xc4, 0xcf, 0xf4, 0x29, 0x33, 0xd5, 0x72, 0x76, 0xf9, 0x54, 0x7b, 0x9e, 0x08, 0xc2, 0x83, + 0x77, 0xa6, 0xbd, 0x76, 0xf0, 0x64, 0xdb, 0x20, 0xe1, 0x50, 0x5b, 0x3e, 0x7d, 0x3e, 0xfa, 0xf4, + 0xd7, 0xa9, 0xbd, 0xcb, 0xd7, 0x70, 0xd3, 0xd9, 0x6b, 0x9b, 0x5c, 0x16, 0x5e, 0x00, 0xd3, 0xe1, + 0xf6, 0x26, 0x2c, 0x65, 0x0a, 0x4b, 0xd1, 0xb3, 0xc2, 0x54, 0x51, 0x08, 0x99, 0x19, 0xd6, 0x9d, + 0xc0, 0x22, 0x98, 0x6e, 0x78, 0xb8, 0x82, 0x2d, 0x4c, 0x29, 0xf1, 0x68, 0x36, 0x29, 0x62, 0x73, + 0xa4, 0xf5, 0x9e, 0x43, 0xbc, 0xe0, 0x96, 0xeb, 0xc4, 0xda, 0x0f, 0x4a, 0xdb, 0x84, 0x78, 0xe4, + 0x8c, 0x58, 0xf3, 0x0b, 0x1b, 0x5c, 0x02, 0xc0, 0x17, 0x11, 0xf9, 0x37, 0x29, 0x5e, 0x64, 0x4a, + 0xac, 0x88, 0x96, 0x55, 0x0c, 0xb6, 0x79, 0x57, 0xcd, 0xa6, 0xc4, 0x35, 0x54, 0xdd, 0x6f, 0xb9, + 0x7a, 0xd0, 0x72, 0xf5, 0xbd, 0xa0, 0xe5, 0xee, 0xa4, 0x79, 0xfc, 0x3d, 0xfa, 0x2d, 0xaf, 0x48, + 0x25, 0x7c, 0x67, 0x60, 0x18, 0xa5, 0xff, 0x9d, 0x30, 0x9a, 0xea, 0x09, 0xa3, 0x0f, 0x92, 0xe9, + 0xf1, 0xd9, 0x84, 0x99, 0x66, 0xed, 0x52, 0xcd, 0xad, 0xe0, 0xb6, 0x76, 0x4a, 0x16, 0xc3, 0x8e, + 0x87, 0xbb, 0x95, 0xaa, 0x82, 0x18, 0x0a, 0xb2, 0x82, 0x8f, 0xb5, 0x6f, 0x12, 0x60, 0xbe, 0x2b, + 0xfc, 0xa6, 0xe6, 0x50, 0x7f, 0xa4, 0x25, 0x5f, 0x39, 0xd2, 0xde, 0x90, 0x20, 0x09, 0x7b, 0x31, + 0xdd, 0xe3, 0x45, 0x6d, 0x0b, 0xfc, 0xbf, 0xdf, 0x11, 0x43, 0xfc, 0xf6, 0x5d, 0x22, 0x2c, 0xbe, + 0xc3, 0x0d, 0x84, 0x32, 0x99, 0xb5, 0x83, 0x3a, 0x3f, 0x3a, 0x93, 0x59, 0x9b, 0xbe, 0x86, 0x4c, + 0xfe, 0xaf, 0x27, 0xa1, 0x76, 0x06, 0x1c, 0x8f, 0xf8, 0x63, 0x88, 0xff, 0xe6, 0x3b, 0x54, 0x8b, + 0xe2, 0x4b, 0x38, 0x68, 0xe9, 0xda, 0xb5, 0x0e, 0x8d, 0x92, 0xcb, 0x52, 0xc5, 0x59, 0x90, 0xe6, + 0x7d, 0xb7, 0x74, 0x13, 0x4b, 0x2a, 0xb3, 0xb3, 0xf0, 0xeb, 0xb3, 0xfc, 0xbc, 0x8f, 0x9e, 0x56, + 0xf6, 0xf5, 0x1a, 0x31, 0x1c, 0xc4, 0xaa, 0xfa, 0x15, 0x97, 0x71, 0x8a, 0x25, 0x4e, 0x17, 0xfe, + 0x9c, 0x01, 0x13, 0x42, 0x1d, 0xfc, 0x5a, 0x01, 0x29, 0xc9, 0x2c, 0xe1, 0x6a, 0xd4, 0xad, 0x03, + 0x3e, 0x1d, 0xd4, 0xb5, 0x51, 0x62, 0x3e, 0x34, 0xed, 0xf4, 0x97, 0x3f, 0xfd, 0xfe, 0xfd, 0xf8, + 0x2a, 0x5c, 0x31, 0x22, 0x1f, 0x3f, 0x92, 0x5d, 0x1a, 0x77, 0xa4, 0x2b, 0xee, 0xc1, 0x1f, 0x14, + 0x30, 0xd3, 0x43, 0xe0, 0xe1, 0xe9, 0x18, 0x33, 0x83, 0x3e, 0x14, 0xd4, 0xad, 0xc3, 0x09, 0x4b, + 0x64, 0x05, 0x81, 0x6c, 0x0b, 0x9e, 0x8a, 0x22, 0x0b, 0xbe, 0x15, 0x22, 0x00, 0x7f, 0x54, 0xc0, + 0x6c, 0x3f, 0x17, 0x87, 0x7a, 0x8c, 0xd9, 0x98, 0x4f, 0x00, 0xd5, 0x38, 0xb4, 0xbc, 0x44, 0x7a, + 0x5e, 0x20, 0x3d, 0x0b, 0x0b, 0x51, 0xa4, 0xad, 0xe0, 0x4c, 0x17, 0x6c, 0xf8, 0xf3, 0xe2, 0x1e, + 0xbc, 0xaf, 0x80, 0x94, 0x64, 0xdd, 0xb1, 0xae, 0xed, 0x25, 0xf4, 0xb1, 0xae, 0xed, 0x23, 0xef, + 0xda, 0x96, 0x80, 0xb5, 0x06, 0x4f, 0x46, 0x61, 0x49, 0x16, 0x4f, 0x43, 0x4f, 0xf7, 0x50, 0x01, + 0x29, 0xc9, 0xbf, 0x63, 0x81, 0xf4, 0x92, 0xfd, 0x58, 0x20, 0x7d, 0x34, 0x5e, 0xdb, 0x16, 0x40, + 0x4e, 0xc3, 0xcd, 0x28, 0x10, 0xea, 0x8b, 0x76, 0x71, 0x18, 0x77, 0xf6, 0xf1, 0xc1, 0x3d, 0x78, + 0x1b, 0x24, 0x39, 0x4d, 0x87, 0x5a, 0x6c, 0xc8, 0x74, 0xb8, 0xbf, 0xba, 0x32, 0x54, 0x46, 0x62, + 0xd8, 0x14, 0x18, 0x56, 0xe0, 0x89, 0x41, 0xd1, 0x54, 0xe9, 0x79, 0x89, 0xcf, 0xc1, 0xa4, 0xcf, + 0x54, 0xe1, 0xc9, 0x18, 0xcd, 0x3d, 0x84, 0x58, 0x5d, 0x1d, 0x21, 0x25, 0x11, 0x2c, 0x0b, 0x04, + 0x2a, 0xcc, 0x1a, 0x31, 0xff, 0x42, 0xc0, 0x36, 0x48, 0x49, 0x26, 0x0c, 0x97, 0xa3, 0x3a, 0x7b, + 0x49, 0xb2, 0xba, 0x3e, 0xaa, 0x35, 0x04, 0x76, 0x35, 0x61, 0x77, 0x11, 0xaa, 0x51, 0xbb, 0x98, + 0x55, 0x4b, 0x16, 0x37, 0xf7, 0x05, 0xc8, 0x84, 0xc8, 0xea, 0x21, 0xac, 0x0f, 0xb8, 0xf3, 0x00, + 0xb6, 0xab, 0xad, 0x09, 0xdb, 0xcb, 0x30, 0x37, 0xc0, 0xb6, 0x14, 0x2f, 0x71, 0x0e, 0x7c, 0x17, + 0xa4, 0x24, 0xdd, 0x89, 0x8d, 0xbd, 0x5e, 0xc2, 0x1b, 0x1b, 0x7b, 0x7d, 0xac, 0x69, 0xd8, 0xed, + 0xfd, 0x9e, 0xc9, 0xda, 0xf0, 0x81, 0x02, 0x40, 0xb7, 0xf0, 0xc3, 0x8d, 0x61, 0xaa, 0xc3, 0xbd, + 0x5a, 0xdd, 0x3c, 0x84, 0xa4, 0xc4, 0xb1, 0x2a, 0x70, 0xe4, 0xe1, 0x52, 0x1c, 0x0e, 0xd1, 0x05, + 0xe1, 0x57, 0x0a, 0x98, 0xea, 0x50, 0x08, 0xb8, 0x3e, 0x4c, 0x7f, 0xd8, 0x1d, 0x1b, 0xa3, 0x05, + 0x25, 0x8e, 0x93, 0x02, 0x47, 0x0e, 0x2e, 0xc6, 0xe1, 0x10, 0xf1, 0x70, 0x97, 0x17, 0x25, 0xd1, + 0x85, 0x86, 0x14, 0xa5, 0x70, 0xeb, 0x1b, 0x52, 0x94, 0x7a, 0x5a, 0xe1, 0x30, 0x7f, 0x04, 0x2d, + 0x72, 0xe7, 0xc2, 0x93, 0x17, 0x39, 0xe5, 0xe9, 0x8b, 0x9c, 0xf2, 0xfc, 0x45, 0x4e, 0x79, 0xf4, + 0x32, 0x37, 0xf6, 0xf4, 0x65, 0x6e, 0xec, 0x97, 0x97, 0xb9, 0xb1, 0x4f, 0xd7, 0x42, 0x14, 0x00, + 0xb7, 0x38, 0x03, 0xe8, 0x6a, 0x69, 0x0b, 0x3d, 0x82, 0x06, 0x94, 0x27, 0x05, 0xe3, 0x78, 0xe7, + 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x0f, 0xce, 0x6b, 0x84, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -5803,7 +5812,7 @@ func (m *QueryBaseFeeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.BaseFee = &v if err := m.BaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/evm/types/tx.pb.go b/x/evm/types/tx.pb.go index 6eba07d8..0abbfcc3 100644 --- a/x/evm/types/tx.pb.go +++ b/x/evm/types/tx.pb.go @@ -5,11 +5,11 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -88,13 +88,13 @@ type LegacyTx struct { // nonce corresponds to the account nonce (transaction sequence). Nonce uint64 `protobuf:"varint,1,opt,name=nonce,proto3" json:"nonce,omitempty"` // gas_price defines the value for each gas unit - GasPrice *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=gas_price,json=gasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gas_price,omitempty"` + GasPrice *cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=gas_price,json=gasPrice,proto3,customtype=cosmossdk.io/math.Int" json:"gas_price,omitempty"` // gas defines the gas limit defined for the transaction. GasLimit uint64 `protobuf:"varint,3,opt,name=gas,proto3" json:"gas,omitempty"` // to is the hex formatted address of the recipient To string `protobuf:"bytes,4,opt,name=to,proto3" json:"to,omitempty"` // value defines the unsigned integer value of the transaction amount. - Amount *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"value,omitempty"` + Amount *cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value,omitempty"` // data is the data payload bytes of the transaction. Data []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` // v defines the signature value @@ -141,17 +141,17 @@ var xxx_messageInfo_LegacyTx proto.InternalMessageInfo // AccessListTx is the data of EIP-2930 access list transactions. type AccessListTx struct { // chain_id of the destination EVM chain - ChainID *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"chainID"` + ChainID *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=cosmossdk.io/math.Int" json:"chainID"` // nonce corresponds to the account nonce (transaction sequence). Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"` // gas_price defines the value for each gas unit - GasPrice *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=gas_price,json=gasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gas_price,omitempty"` + GasPrice *cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=gas_price,json=gasPrice,proto3,customtype=cosmossdk.io/math.Int" json:"gas_price,omitempty"` // gas defines the gas limit defined for the transaction. GasLimit uint64 `protobuf:"varint,4,opt,name=gas,proto3" json:"gas,omitempty"` // to is the recipient address in hex format To string `protobuf:"bytes,5,opt,name=to,proto3" json:"to,omitempty"` // value defines the unsigned integer value of the transaction amount. - Amount *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"value,omitempty"` + Amount *cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value,omitempty"` // data is the data payload bytes of the transaction. Data []byte `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"` // accesses is an array of access tuples @@ -200,19 +200,19 @@ var xxx_messageInfo_AccessListTx proto.InternalMessageInfo // DynamicFeeTx is the data of EIP-1559 dinamic fee transactions. type DynamicFeeTx struct { // chain_id of the destination EVM chain - ChainID *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"chainID"` + ChainID *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=cosmossdk.io/math.Int" json:"chainID"` // nonce corresponds to the account nonce (transaction sequence). Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"` // gas_tip_cap defines the max value for the gas tip - GasTipCap *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=gas_tip_cap,json=gasTipCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gas_tip_cap,omitempty"` + GasTipCap *cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=gas_tip_cap,json=gasTipCap,proto3,customtype=cosmossdk.io/math.Int" json:"gas_tip_cap,omitempty"` // gas_fee_cap defines the max value for the gas fee - GasFeeCap *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=gas_fee_cap,json=gasFeeCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gas_fee_cap,omitempty"` + GasFeeCap *cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=gas_fee_cap,json=gasFeeCap,proto3,customtype=cosmossdk.io/math.Int" json:"gas_fee_cap,omitempty"` // gas defines the gas limit defined for the transaction. GasLimit uint64 `protobuf:"varint,5,opt,name=gas,proto3" json:"gas,omitempty"` // to is the hex formatted address of the recipient To string `protobuf:"bytes,6,opt,name=to,proto3" json:"to,omitempty"` // value defines the the transaction amount. - Amount *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"value,omitempty"` + Amount *cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value,omitempty"` // data is the data payload bytes of the transaction. Data []byte `protobuf:"bytes,8,opt,name=data,proto3" json:"data,omitempty"` // accesses is an array of access tuples @@ -454,69 +454,72 @@ func init() { func init() { proto.RegisterFile("ethermint/evm/v1/tx.proto", fileDescriptor_f75ac0a12d075f21) } var fileDescriptor_f75ac0a12d075f21 = []byte{ - // 977 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0x8f, 0x13, 0xe7, 0xdf, 0x24, 0x2c, 0xd5, 0x68, 0xab, 0x3a, 0x11, 0x8d, 0x43, 0x24, 0x20, - 0x2d, 0x8a, 0xad, 0x2e, 0xa8, 0x87, 0x3d, 0xb1, 0xe9, 0x6e, 0xab, 0x56, 0xbb, 0xa2, 0x32, 0xe9, - 0x85, 0x22, 0x45, 0xb3, 0xf6, 0xec, 0xc4, 0x22, 0xf6, 0x58, 0x9e, 0x89, 0x95, 0x54, 0xe2, 0xd2, - 0x13, 0x37, 0x40, 0x7c, 0x01, 0x0e, 0x9c, 0x38, 0x21, 0xd1, 0x0f, 0xc0, 0xb1, 0xe2, 0x54, 0xc1, - 0x05, 0x71, 0x08, 0x28, 0x8b, 0x84, 0xb4, 0x37, 0xf8, 0x04, 0x68, 0x66, 0x9c, 0x4d, 0xd2, 0xb0, - 0x2d, 0x94, 0x45, 0x9c, 0x32, 0xcf, 0xef, 0xcd, 0x7b, 0x6f, 0x7e, 0xbf, 0xdf, 0xbc, 0x09, 0xa8, - 0x61, 0x3e, 0xc0, 0x71, 0xe0, 0x87, 0xdc, 0xc6, 0x49, 0x60, 0x27, 0xd7, 0x6c, 0x3e, 0xb6, 0xa2, - 0x98, 0x72, 0x0a, 0x2f, 0x9c, 0xba, 0x2c, 0x9c, 0x04, 0x56, 0x72, 0xad, 0x7e, 0xc9, 0xa5, 0x2c, - 0xa0, 0xcc, 0x0e, 0x18, 0x11, 0x91, 0x01, 0x23, 0x2a, 0xb4, 0x5e, 0x53, 0x8e, 0xbe, 0xb4, 0x6c, - 0x65, 0xa4, 0xae, 0xfa, 0x5a, 0x01, 0x91, 0x4c, 0xf9, 0x36, 0x09, 0x25, 0x54, 0xed, 0x11, 0xab, - 0xf4, 0xeb, 0x2b, 0x84, 0x52, 0x32, 0xc4, 0x36, 0x8a, 0x7c, 0x1b, 0x85, 0x21, 0xe5, 0x88, 0xfb, - 0x34, 0x9c, 0xe7, 0xab, 0xa5, 0x5e, 0x69, 0x1d, 0x8e, 0x8e, 0x6c, 0x14, 0x4e, 0x94, 0xab, 0xf5, - 0x89, 0x06, 0x5e, 0x3a, 0x60, 0x64, 0x4f, 0x14, 0xc4, 0xa3, 0xa0, 0x37, 0x86, 0x6d, 0xa0, 0x7b, - 0x88, 0x23, 0x43, 0x6b, 0x6a, 0xed, 0xca, 0xd6, 0xa6, 0xa5, 0xf6, 0x5a, 0xf3, 0xbd, 0xd6, 0x4e, - 0x38, 0x71, 0x64, 0x04, 0xac, 0x01, 0x9d, 0xf9, 0x0f, 0xb0, 0x91, 0x6d, 0x6a, 0x6d, 0xad, 0x9b, - 0x3f, 0x99, 0x9a, 0x5a, 0xc7, 0x91, 0x9f, 0xa0, 0x09, 0xf4, 0x01, 0x62, 0x03, 0x23, 0xd7, 0xd4, - 0xda, 0xe5, 0x6e, 0xe5, 0x8f, 0xa9, 0x59, 0x8c, 0x87, 0xd1, 0x76, 0xab, 0xd3, 0x72, 0xa4, 0x03, - 0x42, 0xa0, 0x1f, 0xc5, 0x34, 0x30, 0x74, 0x11, 0xe0, 0xc8, 0xf5, 0xb6, 0xfe, 0xf1, 0x17, 0x66, - 0xa6, 0xf5, 0x4d, 0x16, 0x94, 0xf6, 0x31, 0x41, 0xee, 0xa4, 0x37, 0x86, 0x9b, 0x20, 0x1f, 0xd2, - 0xd0, 0xc5, 0xb2, 0x1b, 0xdd, 0x51, 0x06, 0xbc, 0x05, 0xca, 0x04, 0x09, 0xe4, 0x7c, 0x57, 0x55, - 0x2f, 0x77, 0xaf, 0xfe, 0x34, 0x35, 0x5f, 0x27, 0x3e, 0x1f, 0x8c, 0x0e, 0x2d, 0x97, 0x06, 0x29, - 0x9e, 0xe9, 0x4f, 0x87, 0x79, 0x1f, 0xda, 0x7c, 0x12, 0x61, 0x66, 0xdd, 0x0e, 0xb9, 0x53, 0x22, - 0x88, 0xdd, 0x15, 0x7b, 0x61, 0x03, 0xe4, 0x08, 0x62, 0xb2, 0x4b, 0xbd, 0x5b, 0x9d, 0x4d, 0xcd, - 0xd2, 0x2d, 0xc4, 0xf6, 0xfd, 0xc0, 0xe7, 0x8e, 0x70, 0xc0, 0x0d, 0x90, 0xe5, 0x34, 0xed, 0x31, - 0xcb, 0x29, 0xbc, 0x03, 0xf2, 0x09, 0x1a, 0x8e, 0xb0, 0x91, 0x97, 0x45, 0xdf, 0xfe, 0xfb, 0x45, - 0x67, 0x53, 0xb3, 0xb0, 0x13, 0xd0, 0x51, 0xc8, 0x1d, 0x95, 0x42, 0x20, 0x20, 0x71, 0x2e, 0x34, - 0xb5, 0x76, 0x35, 0x45, 0xb4, 0x0a, 0xb4, 0xc4, 0x28, 0xca, 0x0f, 0x5a, 0x22, 0xac, 0xd8, 0x28, - 0x29, 0x2b, 0x16, 0x16, 0x33, 0xca, 0xca, 0x62, 0xdb, 0x1b, 0x02, 0xab, 0xef, 0x1e, 0x75, 0x0a, - 0xbd, 0xf1, 0x2e, 0xe2, 0xa8, 0xf5, 0x7b, 0x0e, 0x54, 0x77, 0x5c, 0x17, 0x33, 0xb6, 0xef, 0x33, - 0xde, 0x1b, 0xc3, 0xfb, 0xa0, 0xe4, 0x0e, 0x90, 0x1f, 0xf6, 0x7d, 0x4f, 0x82, 0x57, 0xee, 0xbe, - 0xf3, 0x8f, 0xba, 0x2d, 0xde, 0x10, 0xbb, 0x6f, 0xef, 0x9e, 0x4c, 0xcd, 0xa2, 0xab, 0x96, 0x4e, - 0xba, 0xf0, 0x16, 0xb4, 0x64, 0xcf, 0xa4, 0x25, 0xf7, 0xef, 0x69, 0xd1, 0x9f, 0x4d, 0x4b, 0x7e, - 0x9d, 0x96, 0xc2, 0xf9, 0xd1, 0x52, 0x5c, 0xa2, 0xe5, 0x3e, 0x28, 0x21, 0x89, 0x2d, 0x66, 0x46, - 0xa9, 0x99, 0x6b, 0x57, 0xb6, 0x2e, 0x5b, 0x4f, 0x5f, 0x74, 0x4b, 0xa1, 0xdf, 0x1b, 0x45, 0x43, - 0xdc, 0x6d, 0x3e, 0x9e, 0x9a, 0x99, 0x93, 0xa9, 0x09, 0xd0, 0x29, 0x25, 0x5f, 0xfd, 0x6c, 0x82, - 0x05, 0x41, 0xce, 0x69, 0x42, 0xc5, 0x79, 0x79, 0x85, 0x73, 0xb0, 0xc2, 0x79, 0xe5, 0x2c, 0xce, - 0xbf, 0xd5, 0x41, 0x75, 0x77, 0x12, 0xa2, 0xc0, 0x77, 0x6f, 0x62, 0xfc, 0xff, 0x70, 0x7e, 0x07, - 0x54, 0x04, 0xe7, 0xdc, 0x8f, 0xfa, 0x2e, 0x8a, 0x5e, 0x80, 0x75, 0x21, 0x99, 0x9e, 0x1f, 0xdd, - 0x40, 0xd1, 0x3c, 0xd7, 0x11, 0xc6, 0x32, 0x97, 0xfe, 0x42, 0xb9, 0x6e, 0x62, 0x2c, 0x72, 0xa5, - 0x12, 0xca, 0x3f, 0x5b, 0x42, 0x85, 0x75, 0x09, 0x15, 0xcf, 0x4f, 0x42, 0xa5, 0x33, 0x24, 0x54, - 0xfe, 0x4f, 0x24, 0x04, 0x56, 0x24, 0x54, 0x59, 0x91, 0x50, 0xf5, 0x2c, 0x09, 0xb5, 0x40, 0x7d, - 0x6f, 0xcc, 0x71, 0xc8, 0x7c, 0x1a, 0xbe, 0x1b, 0xc9, 0x37, 0x63, 0xf1, 0x14, 0xa4, 0x03, 0xf9, - 0x4b, 0x0d, 0x5c, 0x5c, 0x79, 0x22, 0x1c, 0xcc, 0x22, 0x1a, 0x32, 0x79, 0x50, 0x39, 0xe5, 0x35, - 0x35, 0xc4, 0xe5, 0x60, 0xbf, 0x02, 0xf4, 0x21, 0x25, 0xcc, 0xc8, 0xca, 0x43, 0x5e, 0x5c, 0x3f, - 0xe4, 0x3e, 0x25, 0x8e, 0x0c, 0x81, 0x17, 0x40, 0x2e, 0xc6, 0x5c, 0x6a, 0xa6, 0xea, 0x88, 0x25, - 0xac, 0x81, 0x52, 0x12, 0xf4, 0x71, 0x1c, 0xd3, 0x38, 0x9d, 0xba, 0xc5, 0x24, 0xd8, 0x13, 0xa6, - 0x70, 0x09, 0x71, 0x8c, 0x18, 0xf6, 0x14, 0xab, 0x4e, 0x91, 0x20, 0x76, 0x8f, 0x61, 0x2f, 0x6d, - 0xf3, 0x33, 0x0d, 0xbc, 0x7c, 0xc0, 0xc8, 0xbd, 0xc8, 0x43, 0x1c, 0xdf, 0x45, 0x31, 0x0a, 0x18, - 0xbc, 0x0e, 0xca, 0x68, 0xc4, 0x07, 0x34, 0xf6, 0xf9, 0x24, 0xbd, 0x11, 0xc6, 0xf7, 0x8f, 0x3a, - 0x9b, 0xe9, 0x6b, 0xbb, 0xe3, 0x79, 0x31, 0x66, 0xec, 0x3d, 0x1e, 0xfb, 0x21, 0x71, 0x16, 0xa1, - 0xf0, 0x3a, 0x28, 0x44, 0x32, 0x83, 0x14, 0x7b, 0x65, 0xcb, 0x58, 0x3f, 0x86, 0xaa, 0xd0, 0xd5, - 0x05, 0x4d, 0x4e, 0x1a, 0xbd, 0xbd, 0xf1, 0xf0, 0xb7, 0xaf, 0xaf, 0x2e, 0xf2, 0xb4, 0x6a, 0xe0, - 0xd2, 0x53, 0x2d, 0xcd, 0xb1, 0xdb, 0x9a, 0x69, 0x20, 0x77, 0xc0, 0x08, 0xfc, 0x08, 0x80, 0xa5, - 0xc7, 0xd7, 0x5c, 0x2f, 0xb4, 0x02, 0x7d, 0xfd, 0x8d, 0xe7, 0x04, 0xcc, 0xf3, 0xb7, 0x5e, 0x7b, - 0xf8, 0xc3, 0xaf, 0x9f, 0x67, 0xcd, 0xd6, 0x65, 0x7b, 0xfd, 0xcf, 0x44, 0x1a, 0xdd, 0xe7, 0x63, - 0xf8, 0x01, 0xa8, 0xae, 0x20, 0xf6, 0xea, 0x5f, 0xe6, 0x5f, 0x0e, 0xa9, 0x5f, 0x79, 0x6e, 0xc8, - 0xbc, 0x89, 0xee, 0xde, 0xe3, 0x59, 0x43, 0x7b, 0x32, 0x6b, 0x68, 0xbf, 0xcc, 0x1a, 0xda, 0xa7, - 0xc7, 0x8d, 0xcc, 0x93, 0xe3, 0x46, 0xe6, 0xc7, 0xe3, 0x46, 0xe6, 0xfd, 0x37, 0x97, 0x2e, 0xd7, - 0x03, 0xcc, 0x51, 0x47, 0x8e, 0x99, 0xa5, 0x5e, 0xc7, 0xb2, 0x5b, 0x79, 0xcb, 0x0e, 0x0b, 0xf2, - 0xcf, 0xc7, 0x5b, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x8d, 0x3d, 0xef, 0x79, 0x09, 0x00, - 0x00, + // 1032 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xda, 0xeb, 0x5f, 0xcf, 0x26, 0xad, 0x56, 0x89, 0xba, 0xb6, 0x88, 0xd7, 0xb8, 0x02, + 0xdc, 0xa2, 0xec, 0xaa, 0x41, 0xaa, 0xd4, 0x9c, 0x88, 0x9b, 0x04, 0x8a, 0x12, 0x51, 0x2d, 0xee, + 0x05, 0x90, 0xac, 0xc9, 0xee, 0x64, 0xbd, 0xaa, 0x77, 0x67, 0xb5, 0x33, 0xb6, 0x6c, 0x24, 0x24, + 0xd4, 0x13, 0x47, 0x10, 0xff, 0x00, 0x67, 0x4e, 0x3d, 0xf4, 0x88, 0xb8, 0x70, 0xa9, 0x38, 0x55, + 0x70, 0x41, 0x1c, 0x0c, 0x72, 0x90, 0x2a, 0x72, 0xe4, 0xcc, 0x01, 0xcd, 0xcc, 0x3a, 0x8e, 0x6b, + 0x9c, 0x40, 0x24, 0xb8, 0xcd, 0x9b, 0xf7, 0xcd, 0xcc, 0xf7, 0xbe, 0x6f, 0xf6, 0xcd, 0x42, 0x05, + 0xb3, 0x2e, 0x8e, 0x03, 0x3f, 0x64, 0x16, 0x1e, 0x04, 0xd6, 0xe0, 0x96, 0xc5, 0x86, 0x66, 0x14, + 0x13, 0x46, 0xb4, 0xab, 0xa7, 0x29, 0x13, 0x0f, 0x02, 0x73, 0x70, 0xab, 0x7a, 0xcd, 0x21, 0x34, + 0x20, 0xd4, 0x0a, 0xa8, 0xc7, 0x91, 0x01, 0xf5, 0x24, 0xb4, 0x5a, 0x91, 0x89, 0x8e, 0x88, 0x2c, + 0x19, 0x24, 0xa9, 0x55, 0x8f, 0x78, 0x44, 0xce, 0xf3, 0x51, 0x32, 0xfb, 0xb2, 0x47, 0x88, 0xd7, + 0xc3, 0x16, 0x8a, 0x7c, 0x0b, 0x85, 0x21, 0x61, 0x88, 0xf9, 0x24, 0x9c, 0xae, 0xa9, 0x24, 0x59, + 0x11, 0x1d, 0xf6, 0x8f, 0x2c, 0x14, 0x8e, 0x92, 0xd4, 0xf5, 0x05, 0xbe, 0xc8, 0x71, 0x30, 0xa5, + 0x1d, 0xd6, 0x8f, 0x7a, 0x38, 0x01, 0x55, 0x17, 0x40, 0x3d, 0x32, 0xa5, 0xba, 0xbe, 0x90, 0x8b, + 0x50, 0x8c, 0x82, 0xe4, 0xe8, 0xc6, 0x37, 0x0a, 0xbc, 0x74, 0x40, 0xbd, 0x5d, 0x0e, 0xc2, 0xfd, + 0xa0, 0x3d, 0xd4, 0x9a, 0xa0, 0xba, 0x88, 0x21, 0x5d, 0xa9, 0x2b, 0xcd, 0xd2, 0xe6, 0xaa, 0x29, + 0xb9, 0x99, 0x53, 0x6e, 0xe6, 0x76, 0x38, 0xb2, 0x05, 0x42, 0xab, 0x80, 0x4a, 0xfd, 0x8f, 0xb1, + 0x9e, 0xae, 0x2b, 0x4d, 0xa5, 0x95, 0x3d, 0x19, 0x1b, 0xca, 0x86, 0x2d, 0xa6, 0x34, 0x03, 0xd4, + 0x2e, 0xa2, 0x5d, 0x3d, 0x53, 0x57, 0x9a, 0xc5, 0x56, 0xe9, 0x8f, 0xb1, 0x91, 0x8f, 0x7b, 0xd1, + 0x56, 0x63, 0xa3, 0x61, 0x8b, 0x84, 0xf6, 0x06, 0x5c, 0x71, 0x71, 0x14, 0x63, 0x07, 0x31, 0xec, + 0x76, 0x8e, 0x62, 0x12, 0xe8, 0xaa, 0xc0, 0xa6, 0x75, 0xc5, 0x5e, 0x99, 0xa5, 0xf6, 0x62, 0x12, + 0x68, 0x1a, 0xa8, 0x02, 0x91, 0xad, 0x2b, 0xcd, 0xb2, 0x2d, 0xc6, 0x5b, 0xea, 0x67, 0x5f, 0x19, + 0xa9, 0xc6, 0x17, 0x69, 0x28, 0xec, 0x63, 0x0f, 0x39, 0xa3, 0xf6, 0x50, 0x5b, 0x85, 0x6c, 0x48, + 0x42, 0x07, 0x0b, 0xea, 0xaa, 0x2d, 0x03, 0xed, 0x36, 0x14, 0x3d, 0xc4, 0xad, 0xf2, 0x1d, 0x49, + 0xb5, 0xd8, 0xaa, 0xfc, 0x3c, 0x36, 0xd6, 0xa4, 0x6b, 0xd4, 0x7d, 0x68, 0xfa, 0xc4, 0x0a, 0x10, + 0xeb, 0x9a, 0xf7, 0x42, 0x66, 0x17, 0x3c, 0x44, 0xef, 0x73, 0xa8, 0x56, 0x83, 0x8c, 0x87, 0xa8, + 0xa8, 0x40, 0x6d, 0x95, 0x27, 0x63, 0xa3, 0xf0, 0x36, 0xa2, 0xfb, 0x7e, 0xe0, 0x33, 0x9b, 0x27, + 0xb4, 0x15, 0x48, 0x33, 0x22, 0x49, 0xdb, 0x69, 0x46, 0xb4, 0x3b, 0x90, 0x1d, 0xa0, 0x5e, 0x1f, + 0x0b, 0x96, 0xc5, 0xd6, 0xf5, 0xa5, 0x67, 0x4c, 0xc6, 0x46, 0x6e, 0x3b, 0x20, 0xfd, 0x90, 0xd9, + 0x72, 0x05, 0xaf, 0x4f, 0x48, 0x9e, 0x93, 0xf5, 0x09, 0x71, 0xcb, 0xa0, 0x0c, 0xf4, 0xbc, 0x98, + 0x50, 0x06, 0x3c, 0x8a, 0xf5, 0x82, 0x8c, 0x62, 0x1e, 0x51, 0xbd, 0x28, 0x23, 0xba, 0xb5, 0xc2, + 0x95, 0xf8, 0xfe, 0xc9, 0x46, 0xae, 0x3d, 0xdc, 0x41, 0x0c, 0x35, 0xbe, 0xcd, 0x40, 0x79, 0x5b, + 0x5c, 0x92, 0x7d, 0x9f, 0xb2, 0xf6, 0x50, 0x7b, 0x17, 0x0a, 0x4e, 0x17, 0xf9, 0x61, 0xc7, 0x77, + 0x85, 0x34, 0xc5, 0x96, 0x75, 0x1e, 0xb9, 0xfc, 0x5d, 0x0e, 0xbe, 0xb7, 0x73, 0x32, 0x36, 0xf2, + 0x8e, 0x1c, 0xda, 0xc9, 0xc0, 0x9d, 0x69, 0x9c, 0x5e, 0xaa, 0x71, 0xe6, 0x5f, 0x6b, 0xac, 0x9e, + 0xaf, 0x71, 0x76, 0x51, 0xe3, 0xdc, 0xa5, 0x35, 0xce, 0x9f, 0xd1, 0xf8, 0x43, 0x28, 0xc8, 0xaf, + 0x09, 0x53, 0xbd, 0x50, 0xcf, 0x34, 0x4b, 0x9b, 0xeb, 0xe6, 0x8b, 0x4d, 0xc0, 0x94, 0x52, 0xb6, + 0xf9, 0xe7, 0xd6, 0xaa, 0x3f, 0x1d, 0x1b, 0xa9, 0x93, 0xb1, 0x01, 0xe8, 0x54, 0xdf, 0xaf, 0x7f, + 0x31, 0x60, 0xa6, 0xb6, 0x7d, 0xba, 0xa1, 0x34, 0xb0, 0x38, 0x67, 0x20, 0xcc, 0x19, 0x58, 0x5a, + 0x66, 0xe0, 0x9f, 0x19, 0x28, 0xef, 0x8c, 0x42, 0x14, 0xf8, 0xce, 0x1e, 0xc6, 0xff, 0x8b, 0x81, + 0x77, 0xa0, 0xc4, 0x0d, 0x64, 0x7e, 0xd4, 0x71, 0x50, 0x74, 0xb1, 0x85, 0xdc, 0xee, 0xb6, 0x1f, + 0xdd, 0x45, 0xd1, 0x74, 0xe9, 0x11, 0xc6, 0x62, 0xa9, 0xfa, 0x4f, 0x96, 0xee, 0x61, 0xcc, 0x97, + 0x26, 0xf6, 0x67, 0xcf, 0xb7, 0x3f, 0xb7, 0x68, 0x7f, 0xfe, 0xd2, 0xf6, 0x17, 0x96, 0xd8, 0x5f, + 0xfc, 0x4f, 0xec, 0x87, 0x39, 0xfb, 0x4b, 0x73, 0xf6, 0x97, 0x97, 0xd9, 0xdf, 0x80, 0xea, 0xee, + 0x90, 0xe1, 0x90, 0xfa, 0x24, 0x7c, 0x2f, 0x12, 0xef, 0xc4, 0xac, 0x3d, 0x27, 0x7d, 0xef, 0x3b, + 0x05, 0xd6, 0xe6, 0xda, 0xb6, 0x8d, 0x69, 0x44, 0x42, 0x2a, 0x0a, 0x15, 0x9d, 0x57, 0xdc, 0x93, + 0xa4, 0xd9, 0xde, 0x00, 0xb5, 0x47, 0x3c, 0xaa, 0xa7, 0x45, 0x91, 0x6b, 0x8b, 0x45, 0xee, 0x13, + 0xcf, 0x16, 0x10, 0xed, 0x2a, 0x64, 0x62, 0xcc, 0xc4, 0x05, 0x28, 0xdb, 0x7c, 0xa8, 0x55, 0xa0, + 0x30, 0x08, 0x3a, 0x38, 0x8e, 0x49, 0x9c, 0x74, 0xbb, 0xfc, 0x20, 0xd8, 0xe5, 0x21, 0x4f, 0x71, + 0xeb, 0xfb, 0x14, 0xbb, 0xd2, 0x44, 0x3b, 0xef, 0x21, 0xfa, 0x80, 0x62, 0x57, 0x5b, 0x07, 0x38, + 0xec, 0x11, 0xe7, 0x61, 0x47, 0x90, 0x91, 0x8d, 0xad, 0x28, 0x66, 0xde, 0x41, 0xb4, 0x3b, 0xed, + 0xde, 0x0a, 0x5c, 0x39, 0xa0, 0xde, 0x83, 0xc8, 0x45, 0x0c, 0xdf, 0x17, 0xcf, 0x12, 0x6f, 0x25, + 0xa8, 0xcf, 0xba, 0x24, 0xf6, 0xd9, 0x28, 0xb9, 0xec, 0xfa, 0x0f, 0x4f, 0x36, 0x56, 0x93, 0x47, + 0x76, 0xdb, 0x75, 0x63, 0x4c, 0xe9, 0xfb, 0x2c, 0xf6, 0x43, 0xcf, 0x9e, 0x41, 0xb5, 0xdb, 0x90, + 0x93, 0x0f, 0x9b, 0xb8, 0xd8, 0xa5, 0x4d, 0x7d, 0xb1, 0x4a, 0x79, 0x42, 0x4b, 0xe5, 0x2e, 0xda, + 0x09, 0x7a, 0x6b, 0xe5, 0xd1, 0xf3, 0xc7, 0x37, 0x67, 0xfb, 0x34, 0x2a, 0x70, 0xed, 0x05, 0x4a, + 0x53, 0x69, 0x37, 0x7f, 0x57, 0x20, 0x73, 0x40, 0x3d, 0xed, 0x13, 0x80, 0x33, 0xef, 0xa5, 0xb1, + 0x78, 0xd0, 0x9c, 0x33, 0xd5, 0xd7, 0x2f, 0x00, 0x4c, 0xf7, 0x6f, 0xbc, 0xfa, 0xe8, 0xc7, 0xdf, + 0xbe, 0x4c, 0x1b, 0x8d, 0x75, 0x6b, 0xe1, 0xcd, 0xc6, 0x09, 0xba, 0xc3, 0x86, 0xda, 0x47, 0x50, + 0x9e, 0x53, 0xec, 0x95, 0xbf, 0xdd, 0xff, 0x2c, 0xa4, 0x7a, 0xe3, 0x42, 0xc8, 0x94, 0x44, 0x35, + 0xfb, 0xe9, 0xf3, 0xc7, 0x37, 0x95, 0xd6, 0x5b, 0x4f, 0x27, 0x35, 0xe5, 0xd9, 0xa4, 0xa6, 0xfc, + 0x3a, 0xa9, 0x29, 0x9f, 0x1f, 0xd7, 0x52, 0xcf, 0x8e, 0x6b, 0xa9, 0x9f, 0x8e, 0x6b, 0xa9, 0x0f, + 0x5e, 0xf3, 0x7c, 0xd6, 0xed, 0x1f, 0x9a, 0x0e, 0x09, 0x38, 0x3b, 0x42, 0xcf, 0xb0, 0x1d, 0x0a, + 0xbe, 0x6c, 0x14, 0x61, 0x7a, 0x98, 0x13, 0x7f, 0x0c, 0x6f, 0xfe, 0x15, 0x00, 0x00, 0xff, 0xff, + 0x8d, 0x16, 0xc5, 0x4e, 0x72, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1681,7 +1684,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.GasPrice = &v if err := m.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1768,7 +1771,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.Amount = &v if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1990,7 +1993,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.ChainID = &v if err := m.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2045,7 +2048,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.GasPrice = &v if err := m.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2132,7 +2135,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.Amount = &v if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2388,7 +2391,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.ChainID = &v if err := m.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2443,7 +2446,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.GasTipCap = &v if err := m.GasTipCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2479,7 +2482,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.GasFeeCap = &v if err := m.GasFeeCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2566,7 +2569,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.Amount = &v if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/evm/types/utils_test.go b/x/evm/types/utils_test.go index 3d7cecbd..a09a43d7 100644 --- a/x/evm/types/utils_test.go +++ b/x/evm/types/utils_test.go @@ -10,9 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" proto "github.com/cosmos/gogoproto/proto" - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/encoding" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + "github.com/evmos/ethermint/app" + evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/ethermint/tests" @@ -52,7 +51,7 @@ func TestUnwrapEthererumMsg(t *testing.T) { _, err := evmtypes.UnwrapEthereumMsg(nil, common.Hash{}) require.NotNil(t, err) - encodingConfig := encoding.MakeConfig(app.ModuleBasics) + encodingConfig := app.MakeConfigForTest() clientCtx := client.Context{}.WithTxConfig(encodingConfig.TxConfig) builder, _ := clientCtx.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder) diff --git a/x/feemarket/keeper/abci.go b/x/feemarket/keeper/abci.go index e3e6480c..19913bf2 100644 --- a/x/feemarket/keeper/abci.go +++ b/x/feemarket/keeper/abci.go @@ -16,22 +16,24 @@ package keeper import ( + "errors" "fmt" + "math" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/zeta-chain/ethermint/x/feemarket/types" + "github.com/evmos/ethermint/x/feemarket/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" ) // BeginBlock updates base fee -func (k *Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +func (k *Keeper) BeginBlock(ctx sdk.Context) error { baseFee := k.CalculateBaseFee(ctx) // return immediately if base fee is nil if baseFee == nil { - return + return nil } k.SetBaseFee(ctx, baseFee) @@ -47,29 +49,35 @@ func (k *Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { sdk.NewAttribute(types.AttributeKeyBaseFee, baseFee.String()), ), }) + return nil } // EndBlock update block gas wanted. // The EVM end block logic doesn't update the validator set, thus it returns // an empty slice. -func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) { +func (k *Keeper) EndBlock(ctx sdk.Context) error { if ctx.BlockGasMeter() == nil { - k.Logger(ctx).Error("block gas meter is nil when setting block gas wanted") - return + return errors.New("block gas meter is nil when setting block gas wanted") } gasWanted := k.GetTransientGasWanted(ctx) gasUsed := ctx.BlockGasMeter().GasConsumedToLimit() + if gasWanted > math.MaxInt64 { + return fmt.Errorf("integer overflow by integer type conversion. Gas wanted %d > MaxInt64", gasWanted) + } + + if gasUsed > math.MaxInt64 { + return fmt.Errorf("integer overflow by integer type conversion. Gas used %d > MaxInt64", gasUsed) + } + // to prevent BaseFee manipulation we limit the gasWanted so that // gasWanted = max(gasWanted * MinGasMultiplier, gasUsed) // this will be keep BaseFee protected from un-penalized manipulation // more info here https://github.com/zeta-chain/ethermint/pull/1105#discussion_r888798925 minGasMultiplier := k.GetParams(ctx).MinGasMultiplier - // #nosec G115 gasWanted always in range - limitedGasWanted := sdk.NewDec(int64(gasWanted)).Mul(minGasMultiplier) - // #nosec G115 gasUsed always in range - gasWanted = sdk.MaxDec(limitedGasWanted, sdk.NewDec(int64(gasUsed))).TruncateInt().Uint64() + limitedGasWanted := sdkmath.LegacyNewDec(int64(gasWanted)).Mul(minGasMultiplier) + gasWanted = sdkmath.LegacyMaxDec(limitedGasWanted, sdkmath.LegacyNewDec(int64(gasUsed))).TruncateInt().Uint64() k.SetBlockGasWanted(ctx, gasWanted) defer func() { @@ -81,4 +89,5 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) { sdk.NewAttribute("height", fmt.Sprintf("%d", ctx.BlockHeight())), sdk.NewAttribute("amount", fmt.Sprintf("%d", gasWanted)), )) + return nil } diff --git a/x/feemarket/keeper/abci_test.go b/x/feemarket/keeper/abci_test.go index 1b9bb25c..8f8918bb 100644 --- a/x/feemarket/keeper/abci_test.go +++ b/x/feemarket/keeper/abci_test.go @@ -3,8 +3,7 @@ package keeper_test import ( "fmt" - "github.com/cometbft/cometbft/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" + storetypes "cosmossdk.io/store/types" ) func (suite *KeeperTestSuite) TestEndBlock() { @@ -24,9 +23,9 @@ func (suite *KeeperTestSuite) TestEndBlock() { "pass", false, func() { - meter := sdk.NewGasMeter(uint64(1000000000)) - suite.ctx = suite.ctx.WithBlockGasMeter(meter) - suite.app.FeeMarketKeeper.SetTransientBlockGasWanted(suite.ctx, 5000000) + meter := storetypes.NewGasMeter(uint64(1000000000)) + suite.Ctx = suite.Ctx.WithBlockGasMeter(meter) + suite.App.FeeMarketKeeper.SetTransientBlockGasWanted(suite.Ctx, 5000000) }, uint64(2500000), }, @@ -39,8 +38,9 @@ func (suite *KeeperTestSuite) TestEndBlock() { suite.app.FeeMarketKeeper.SetParams(suite.ctx, params) tc.malleate() - suite.app.FeeMarketKeeper.EndBlock(suite.ctx, types.RequestEndBlock{Height: 1}) - gasWanted := suite.app.FeeMarketKeeper.GetBlockGasWanted(suite.ctx) + + suite.App.FeeMarketKeeper.EndBlock(suite.Ctx) + gasWanted := suite.App.FeeMarketKeeper.GetBlockGasWanted(suite.Ctx) suite.Require().Equal(tc.expGasWanted, gasWanted, tc.name) }) } diff --git a/x/feemarket/keeper/eip1559.go b/x/feemarket/keeper/eip1559.go index ca451513..cc7d99d2 100644 --- a/x/feemarket/keeper/eip1559.go +++ b/x/feemarket/keeper/eip1559.go @@ -16,6 +16,7 @@ package keeper import ( + "fmt" "math/big" sdk "github.com/cosmos/cosmos-sdk/types" @@ -60,8 +61,8 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int { gasLimit := new(big.Int).SetUint64(math.MaxUint64) // NOTE: a MaxGas equal to -1 means that block gas is unlimited - if consParams != nil && consParams.Block.MaxGas > -1 { - gasLimit = big.NewInt(consParams.Block.MaxGas) + if consParams.Block == nil || consParams.Block.MaxGas <= -1 { + panic(fmt.Sprintf("get invalid consensus params: %s", consParams)) } // CONTRACT: ElasticityMultiplier cannot be 0 as it's checked in the params // validation diff --git a/x/feemarket/keeper/eip1559_test.go b/x/feemarket/keeper/eip1559_test.go index f1b4df69..9e0c3769 100644 --- a/x/feemarket/keeper/eip1559_test.go +++ b/x/feemarket/keeper/eip1559_test.go @@ -2,10 +2,9 @@ package keeper_test import ( "fmt" - "math/big" + sdkmath "cosmossdk.io/math" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) func (suite *KeeperTestSuite) TestCalculateBaseFee() { @@ -14,15 +13,15 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() { NoBaseFee bool blockHeight int64 parentBlockGasWanted uint64 - minGasPrice sdk.Dec - expFee *big.Int + minGasPrice sdkmath.LegacyDec + expFee func(baseFee sdkmath.Int) sdkmath.Int }{ { "without BaseFee", true, 0, 0, - sdk.ZeroDec(), + sdkmath.LegacyZeroDec(), nil, }, { @@ -30,56 +29,56 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() { false, 0, 0, - sdk.ZeroDec(), - suite.app.FeeMarketKeeper.GetParams(suite.ctx).BaseFee.BigInt(), + sdkmath.LegacyZeroDec(), + func(baseFee sdkmath.Int) sdkmath.Int { return suite.App.FeeMarketKeeper.GetParams(suite.Ctx).BaseFee }, }, { "with BaseFee - parent block wanted the same gas as its target (ElasticityMultiplier = 2)", false, 1, 50, - sdk.ZeroDec(), - suite.app.FeeMarketKeeper.GetParams(suite.ctx).BaseFee.BigInt(), + sdkmath.LegacyZeroDec(), + func(baseFee sdkmath.Int) sdkmath.Int { return suite.App.FeeMarketKeeper.GetParams(suite.Ctx).BaseFee }, }, { "with BaseFee - parent block wanted the same gas as its target, with higher min gas price (ElasticityMultiplier = 2)", false, 1, 50, - sdk.NewDec(1500000000), - suite.app.FeeMarketKeeper.GetParams(suite.ctx).BaseFee.BigInt(), + sdkmath.LegacyNewDec(1500000000), + func(baseFee sdkmath.Int) sdkmath.Int { return suite.App.FeeMarketKeeper.GetParams(suite.Ctx).BaseFee }, }, { "with BaseFee - parent block wanted more gas than its target (ElasticityMultiplier = 2)", false, 1, 100, - sdk.ZeroDec(), - big.NewInt(1125000000), + sdkmath.LegacyZeroDec(), + func(baseFee sdkmath.Int) sdkmath.Int { return baseFee.Add(sdkmath.NewInt(109375000)) }, }, { "with BaseFee - parent block wanted more gas than its target, with higher min gas price (ElasticityMultiplier = 2)", false, 1, 100, - sdk.NewDec(1500000000), - big.NewInt(1125000000), + sdkmath.LegacyNewDec(1500000000), + func(baseFee sdkmath.Int) sdkmath.Int { return baseFee.Add(sdkmath.NewInt(109375000)) }, }, { "with BaseFee - Parent gas wanted smaller than parent gas target (ElasticityMultiplier = 2)", false, 1, 25, - sdk.ZeroDec(), - big.NewInt(937500000), + sdkmath.LegacyZeroDec(), + func(baseFee sdkmath.Int) sdkmath.Int { return baseFee.Sub(sdkmath.NewInt(54687500)) }, }, { "with BaseFee - Parent gas wanted smaller than parent gas target, with higher min gas price (ElasticityMultiplier = 2)", false, 1, 25, - sdk.NewDec(1500000000), - big.NewInt(1500000000), + sdkmath.LegacyNewDec(1500000000), + func(baseFee sdkmath.Int) sdkmath.Int { return sdkmath.NewInt(1500000000) }, }, } for _, tc := range testCases { @@ -89,8 +88,9 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() { params := suite.app.FeeMarketKeeper.GetParams(suite.ctx) params.NoBaseFee = tc.NoBaseFee params.MinGasPrice = tc.minGasPrice - suite.app.FeeMarketKeeper.SetParams(suite.ctx, params) + err := suite.App.FeeMarketKeeper.SetParams(suite.Ctx, params) + suite.Require().NoError(err) // Set block height suite.ctx = suite.ctx.WithBlockHeight(tc.blockHeight) @@ -103,13 +103,13 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() { MaxBytes: 10, } consParams := tmproto.ConsensusParams{Block: &blockParams} - suite.app.ConsensusParamsKeeper.Set(suite.ctx, &consParams) + suite.Ctx = suite.Ctx.WithConsensusParams(consParams) fee := suite.app.FeeMarketKeeper.CalculateBaseFee(suite.ctx) if tc.NoBaseFee { suite.Require().Nil(fee, tc.name) } else { - suite.Require().Equal(tc.expFee, fee, tc.name) + suite.Require().Equal(tc.expFee(params.BaseFee), sdkmath.NewIntFromBigInt(fee), tc.name) } }) } diff --git a/x/feemarket/keeper/grpc_query_test.go b/x/feemarket/keeper/grpc_query_test.go index 7cfa5637..64dceb23 100644 --- a/x/feemarket/keeper/grpc_query_test.go +++ b/x/feemarket/keeper/grpc_query_test.go @@ -2,7 +2,6 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" ethparams "github.com/ethereum/go-ethereum/params" "github.com/zeta-chain/ethermint/x/feemarket/types" ) @@ -53,8 +52,8 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { { "pass - non-nil Base Fee", func() { - baseFee := sdk.OneInt().BigInt() - suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) + baseFee := sdkmath.OneInt().BigInt() + suite.App.FeeMarketKeeper.SetBaseFee(suite.Ctx, baseFee) aux = sdkmath.NewIntFromBigInt(baseFee) expRes = &types.QueryBaseFeeResponse{BaseFee: &aux} diff --git a/x/feemarket/keeper/integration_test.go b/x/feemarket/keeper/integration_test.go index a923076c..539ba4c3 100644 --- a/x/feemarket/keeper/integration_test.go +++ b/x/feemarket/keeper/integration_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - "encoding/json" + "context" "math/big" "strings" @@ -9,28 +9,19 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/cosmos/cosmos-sdk/baseapp" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client/tx" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/server" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/tests" - "github.com/zeta-chain/ethermint/testutil" - "github.com/zeta-chain/ethermint/x/feemarket/types" - - dbm "github.com/cometbft/cometbft-db" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/evmos/ethermint/tests" + "github.com/evmos/ethermint/testutil" + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" ) var _ = Describe("Feemarket", func() { @@ -42,7 +33,7 @@ var _ = Describe("Feemarket", func() { Describe("Performing Cosmos transactions", func() { Context("with min-gas-prices (local) < MinGasPrices (feemarket param)", func() { BeforeEach(func() { - privKey, msg = setupTestWithContext("1", sdk.NewDec(3), sdk.ZeroInt()) + msg = setupTest("1", sdkmath.LegacyNewDec(3), sdkmath.ZeroInt()) }) Context("during CheckTx", func() { @@ -84,7 +75,7 @@ var _ = Describe("Feemarket", func() { Context("with min-gas-prices (local) == MinGasPrices (feemarket param)", func() { BeforeEach(func() { - privKey, msg = setupTestWithContext("3", sdk.NewDec(3), sdk.ZeroInt()) + msg = setupTest("3", sdkmath.LegacyNewDec(3), sdkmath.ZeroInt()) }) Context("during CheckTx", func() { @@ -126,7 +117,7 @@ var _ = Describe("Feemarket", func() { Context("with MinGasPrices (feemarket param) < min-gas-prices (local)", func() { BeforeEach(func() { - privKey, msg = setupTestWithContext("5", sdk.NewDec(3), sdk.NewInt(5)) + msg = setupTest("5", sdkmath.LegacyNewDec(3), sdkmath.NewInt(5)) }) Context("during CheckTx", func() { It("should reject transactions with gasPrice < MinGasPrices", func() { @@ -208,7 +199,7 @@ var _ = Describe("Feemarket", func() { // 100000`. With the fee calculation `Fee = (baseFee + tip) * gasLimit`, // a `minGasPrices = 40_000_000_000` results in `minGlobalFee = // 4000000000000000` - privKey, _ = setupTestWithContext("1", sdk.NewDec(minGasPrices), sdkmath.NewInt(baseFee)) + setupTest("1", sdkmath.LegacyNewDec(minGasPrices), sdkmath.NewInt(baseFee)) }) Context("during CheckTx", func() { @@ -234,9 +225,6 @@ var _ = Describe("Feemarket", func() { // Note that max priority fee per gas can't be higher than the max fee per gas (gasFeeCap), i.e. 30_000_000_000) return txParams{nil, big.NewInt(minGasPrices - 10_000_000_000), big.NewInt(30_000_000_000), ðtypes.AccessList{}} }), - Entry("dynamic tx with GasFeeCap > MinGasPrices, EffectivePrice < MinGasPrices", func() txParams { - return txParams{nil, big.NewInt(minGasPrices + 10_000_000_000), big.NewInt(0), ðtypes.AccessList{}} - }), ) DescribeTable("should accept transactions with gasPrice >= MinGasPrices", @@ -316,7 +304,7 @@ var _ = Describe("Feemarket", func() { // 100_000`. With the fee calculation `Fee = (baseFee + tip) * gasLimit`, // a `minGasPrices = 5_000_000_000` results in `minGlobalFee = // 500_000_000_000_000` - privKey, _ = setupTestWithContext("1", sdk.NewDec(minGasPrices), sdkmath.NewInt(baseFee)) + setupTest("1", sdkmath.LegacyNewDec(minGasPrices), sdkmath.NewInt(baseFee)) }) Context("during CheckTx", func() { @@ -356,10 +344,10 @@ var _ = Describe("Feemarket", func() { ).To(BeTrue(), res.GetLog()) }, Entry("legacy tx", func() txParams { - return txParams{big.NewInt(baseFee - 1_000_000_000), nil, nil, nil} + return txParams{big.NewInt(baseFee - 2_000_000_000), nil, nil, nil} }), Entry("dynamic tx", func() txParams { - return txParams{nil, big.NewInt(baseFee - 1_000_000_000), big.NewInt(0), ðtypes.AccessList{}} + return txParams{nil, big.NewInt(baseFee - 2_000_000_000), big.NewInt(0), ðtypes.AccessList{}} }), ) @@ -415,10 +403,10 @@ var _ = Describe("Feemarket", func() { }, // Note that the baseFee is not 10_000_000_000 anymore but updates to 8_750_000_000 because of the s.Commit Entry("legacy tx", func() txParams { - return txParams{big.NewInt(baseFee - 2_000_000_000), nil, nil, nil} + return txParams{big.NewInt(baseFee - 2_500_000_000), nil, nil, nil} }), Entry("dynamic tx", func() txParams { - return txParams{nil, big.NewInt(baseFee - 2_000_000_000), big.NewInt(0), ðtypes.AccessList{}} + return txParams{nil, big.NewInt(baseFee - 2_500_000_000), big.NewInt(0), ðtypes.AccessList{}} }), ) @@ -455,10 +443,15 @@ func setupTestWithContext(valMinGasPrice string, minGasPrice sdk.Dec, baseFee sd return privKey, msg } -func setupTest(localMinGasPrices string) (*ethsecp256k1.PrivKey, banktypes.MsgSend) { - setupChain(localMinGasPrices) - - privKey, address := generateKey() +// SetupTest sets up a test chain with an example Cosmos send msg, +// given a local (validator config) and a gloabl (feemarket param) minGasPrice +func setupTest(valMinGasPrice string, minGasPrice sdkmath.LegacyDec, baseFee sdkmath.Int) banktypes.MsgSend { + t := s.T() + s.SetupTestWithCbAndOpts( + t, + nil, + simtestutil.AppOptionsMap{server.FlagMinGasPrices: valMinGasPrice + evmtypes.DefaultEVMDenom}, + ) amount, ok := sdkmath.NewIntFromString("10000000000000000000") s.Require().True(ok) initBalance := sdk.Coins{sdk.Coin{ @@ -475,134 +468,18 @@ func setupTest(localMinGasPrices string) (*ethsecp256k1.PrivKey, banktypes.MsgSe Amount: sdkmath.NewInt(10000), }}, } - s.Commit() - return privKey, msg -} - -func setupChain(localMinGasPricesStr string) { - // Initialize the app, so we can use SetMinGasPrices to set the - // validator-specific min-gas-prices setting - db := dbm.NewMemDB() - newapp := app.NewEthermintApp( - log.NewNopLogger(), - db, - nil, - true, - simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome), - baseapp.SetMinGasPrices(localMinGasPricesStr), - baseapp.SetChainID(app.ChainID), - ) - - genesisState := app.NewTestGenesisState(newapp.AppCodec()) - genesisState[types.ModuleName] = newapp.AppCodec().MustMarshalJSON(types.DefaultGenesisState()) - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - s.Require().NoError(err) - - // Initialize the chain - newapp.InitChain( - abci.RequestInitChain{ - ChainId: app.ChainID, - Validators: []abci.ValidatorUpdate{}, - AppStateBytes: stateBytes, - ConsensusParams: app.DefaultConsensusParams, - }, - ) - - s.app = newapp - s.SetupApp(false) -} - -func generateKey() (*ethsecp256k1.PrivKey, sdk.AccAddress) { - address, priv := tests.NewAddrKey() - return priv.(*ethsecp256k1.PrivKey), sdk.AccAddress(address.Bytes()) -} - -func getNonce(addressBytes []byte) uint64 { - return s.app.EvmKeeper.GetNonce( - s.ctx, - common.BytesToAddress(addressBytes), - ) -} - -func buildEthTx( - priv *ethsecp256k1.PrivKey, - to *common.Address, - gasPrice *big.Int, - gasFeeCap *big.Int, - gasTipCap *big.Int, - accesses *ethtypes.AccessList, -) *evmtypes.MsgEthereumTx { - chainID := s.app.EvmKeeper.ChainID() - from := common.BytesToAddress(priv.PubKey().Address().Bytes()) - nonce := getNonce(from.Bytes()) - data := make([]byte, 0) - gasLimit := uint64(100000) - msgEthereumTx := evmtypes.NewTx( - chainID, - nonce, - to, - nil, - gasLimit, - gasPrice, - gasFeeCap, - gasTipCap, - data, - accesses, - ) - msgEthereumTx.From = from.String() - return msgEthereumTx -} - -func prepareEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereumTx) []byte { - encodingConfig := encoding.MakeConfig(app.ModuleBasics) - option, err := codectypes.NewAnyWithValue(&evmtypes.ExtensionOptionsEthereumTx{}) - s.Require().NoError(err) - - txBuilder := encodingConfig.TxConfig.NewTxBuilder() - builder, ok := txBuilder.(authtx.ExtensionOptionsTxBuilder) - s.Require().True(ok) - builder.SetExtensionOptions(option) - - err = msgEthereumTx.Sign(s.ethSigner, tests.NewSigner(priv)) - s.Require().NoError(err) - - msgEthereumTx.From = "" - err = txBuilder.SetMsgs(msgEthereumTx) - s.Require().NoError(err) - - txData, err := evmtypes.UnpackTxData(msgEthereumTx.Data) - s.Require().NoError(err) - - evmDenom := s.app.EvmKeeper.GetParams(s.ctx).EvmDenom - fees := sdk.Coins{{Denom: evmDenom, Amount: sdkmath.NewIntFromBigInt(txData.Fee())}} - builder.SetFeeAmount(fees) - builder.SetGasLimit(msgEthereumTx.GetGas()) - - // bz are bytes to be broadcasted over the network - bz, err := encodingConfig.TxConfig.TxEncoder()(txBuilder.GetTx()) - s.Require().NoError(err) - - return bz -} - -func checkEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereumTx) abci.ResponseCheckTx { - bz := prepareEthTx(priv, msgEthereumTx) - req := abci.RequestCheckTx{Tx: bz} - res := s.app.BaseApp.CheckTx(req) - return res -} - -func deliverEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereumTx) abci.ResponseDeliverTx { - bz := prepareEthTx(priv, msgEthereumTx) - req := abci.RequestDeliverTx{Tx: bz} - res := s.app.BaseApp.DeliverTx(req) - return res + s.Commit(t) + params := feemarkettypes.DefaultParams() + params.MinGasPrice = minGasPrice + s.App.FeeMarketKeeper.SetParams(s.Ctx, params) + s.App.FeeMarketKeeper.SetBaseFee(s.Ctx, baseFee.BigInt()) + s.Commit(t) + return msg } -func prepareCosmosTx(priv *ethsecp256k1.PrivKey, gasPrice *sdkmath.Int, msgs ...sdk.Msg) []byte { - encodingConfig := encoding.MakeConfig(app.ModuleBasics) - accountAddress := sdk.AccAddress(priv.PubKey().Address().Bytes()) +func prepareCosmosTx(gasPrice *sdkmath.Int, msgs ...sdk.Msg) []byte { + encodingConfig := s.App.EncodingConfig() + accountAddress := sdk.AccAddress(s.PrivKey.PubKey().Address().Bytes()) txBuilder := encodingConfig.TxConfig.NewTxBuilder() @@ -619,12 +496,15 @@ func prepareCosmosTx(priv *ethsecp256k1.PrivKey, gasPrice *sdkmath.Int, msgs ... seq, err := s.app.AccountKeeper.GetSequence(s.ctx, accountAddress) s.Require().NoError(err) + defaultMode, err := authsigning.APISignModeToInternal(encodingConfig.TxConfig.SignModeHandler().DefaultMode()) + s.Require().NoError(err) + // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. sigV2 := signing.SignatureV2{ PubKey: priv.PubKey(), Data: &signing.SingleSignatureData{ - SignMode: encodingConfig.TxConfig.SignModeHandler().DefaultMode(), + SignMode: defaultMode, Signature: nil, }, Sequence: seq, @@ -643,8 +523,9 @@ func prepareCosmosTx(priv *ethsecp256k1.PrivKey, gasPrice *sdkmath.Int, msgs ... Sequence: seq, } sigV2, err = tx.SignWithPrivKey( - encodingConfig.TxConfig.SignModeHandler().DefaultMode(), signerData, - txBuilder, priv, encodingConfig.TxConfig, + context.Background(), + defaultMode, signerData, + txBuilder, s.PrivKey, encodingConfig.TxConfig, seq, ) s.Require().NoError(err) @@ -666,9 +547,10 @@ func checkTx(priv *ethsecp256k1.PrivKey, gasPrice *sdkmath.Int, msgs ...sdk.Msg) return res } -func deliverTx(priv *ethsecp256k1.PrivKey, gasPrice *sdkmath.Int, msgs ...sdk.Msg) abci.ResponseDeliverTx { - bz := prepareCosmosTx(priv, gasPrice, msgs...) - req := abci.RequestDeliverTx{Tx: bz} - res := s.app.BaseApp.DeliverTx(req) - return res +func checkTx(gasPrice *sdkmath.Int, msgs ...sdk.Msg) abci.ResponseCheckTx { + return s.CheckTx(prepareCosmosTx(gasPrice, msgs...)) +} + +func deliverTx(gasPrice *sdkmath.Int, msgs ...sdk.Msg) *abci.ExecTxResult { + return s.DeliverTx(prepareCosmosTx(gasPrice, msgs...)) } diff --git a/x/feemarket/keeper/keeper.go b/x/feemarket/keeper/keeper.go index 334dfc84..25422a13 100644 --- a/x/feemarket/keeper/keeper.go +++ b/x/feemarket/keeper/keeper.go @@ -18,12 +18,11 @@ package keeper import ( "math/big" - "github.com/cometbft/cometbft/libs/log" + corestoretypes "cosmossdk.io/core/store" + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/zeta-chain/ethermint/x/feemarket/types" ) @@ -34,20 +33,21 @@ var KeyPrefixBaseFeeV1 = []byte{2} // Keeper grants access to the Fee Market module state. type Keeper struct { // Protobuf codec - cdc codec.BinaryCodec + cdc codec.BinaryCodec + storeService corestoretypes.KVStoreService // Store key required for the Fee Market Prefix KVStore. storeKey storetypes.StoreKey transientKey storetypes.StoreKey // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. authority sdk.AccAddress - // Legacy subspace - ss paramstypes.Subspace - ck consensusparamkeeper.Keeper } // NewKeeper generates new fee market module keeper func NewKeeper( - cdc codec.BinaryCodec, authority sdk.AccAddress, storeKey, transientKey storetypes.StoreKey, ss paramstypes.Subspace, ck consensusparamkeeper.Keeper, + cdc codec.BinaryCodec, + storeService corestoretypes.KVStoreService, + authority sdk.AccAddress, + storeKey, transientKey storetypes.StoreKey, ) Keeper { // ensure authority account is correctly formatted if err := sdk.VerifyAddressFormat(authority); err != nil { @@ -56,17 +56,17 @@ func NewKeeper( return Keeper{ cdc: cdc, + storeService: storeService, storeKey: storeKey, authority: authority, transientKey: transientKey, - ss: ss, - ck: ck, } } // Logger returns a module-specific logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", "x/"+types.ModuleName) } // ---------------------------------------------------------------------------- diff --git a/x/feemarket/keeper/keeper_test.go b/x/feemarket/keeper/keeper_test.go index 7dca1f66..354a5222 100644 --- a/x/feemarket/keeper/keeper_test.go +++ b/x/feemarket/keeper/keeper_test.go @@ -6,38 +6,10 @@ import ( "testing" "time" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + sdkmath "cosmossdk.io/math" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/crypto/ethsecp256k1" - "github.com/zeta-chain/ethermint/encoding" - "github.com/zeta-chain/ethermint/tests" - ethermint "github.com/zeta-chain/ethermint/types" - evmtypes "github.com/zeta-chain/ethermint/x/evm/types" - "github.com/zeta-chain/ethermint/x/feemarket/types" - - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmversion "github.com/cometbft/cometbft/proto/tendermint/version" - "github.com/cometbft/cometbft/version" + "github.com/evmos/ethermint/testutil" + "github.com/stretchr/testify/suite" ) type KeeperTestSuite struct { @@ -78,93 +50,17 @@ func (suite *KeeperTestSuite) SetupTest() { func (suite *KeeperTestSuite) SetupApp(checkTx bool) { t := suite.T() - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = tests.NewSigner(priv) - - // consensus key - priv, err = ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.consAddress = sdk.ConsAddress(priv.PubKey().Address()) - - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{ - Height: 1, - ChainID: "ethermint_9000-1", - Time: time.Now().UTC(), - ProposerAddress: suite.consAddress.Bytes(), - Version: tmversion.Consensus{ - Block: version.BlockProtocol, - }, - LastBlockId: tmproto.BlockID{ - Hash: tmhash.Sum([]byte("block_id")), - PartSetHeader: tmproto.PartSetHeader{ - Total: 11, - Hash: tmhash.Sum([]byte("partset_header")), - }, - }, - AppHash: tmhash.Sum([]byte("app")), - DataHash: tmhash.Sum([]byte("data")), - EvidenceHash: tmhash.Sum([]byte("evidence")), - ValidatorsHash: tmhash.Sum([]byte("validators")), - NextValidatorsHash: tmhash.Sum([]byte("next_validators")), - ConsensusHash: tmhash.Sum([]byte("consensus")), - LastResultsHash: tmhash.Sum([]byte("last_result")), - }) - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.FeeMarketKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) - - acc := ðermint.EthAccount{ - BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0), - CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(), - } - - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - - valAddr := sdk.ValAddress(suite.address.Bytes()) - validator, err := stakingtypes.NewValidator(valAddr, priv.PubKey(), stakingtypes.Description{}) - require.NoError(t, err) - validator = stakingkeeper.TestingUpdateValidator(suite.app.StakingKeeper, suite.ctx, validator, true) - err = suite.app.StakingKeeper.Hooks().AfterValidatorCreated(suite.ctx, validator.GetOperator()) - require.NoError(t, err) - - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) - require.NoError(t, err) - suite.app.StakingKeeper.SetValidator(suite.ctx, validator) - - encodingConfig := encoding.MakeConfig(app.ModuleBasics) - suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) - suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) - suite.appCodec = encodingConfig.Codec - suite.denom = evmtypes.DefaultEVMDenom -} - -// Commit commits and starts a new block with an updated context. -func (suite *KeeperTestSuite) Commit() { - suite.CommitAfter(time.Second * 0) -} - -// Commit commits a block at a given time. -func (suite *KeeperTestSuite) CommitAfter(t time.Duration) { - header := suite.ctx.BlockHeader() - suite.app.EndBlock(abci.RequestEndBlock{Height: header.Height}) - _ = suite.app.Commit() - - header.Height += 1 - header.Time = header.Time.Add(t) - suite.app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) - - // update ctx - suite.ctx = suite.app.BaseApp.NewContext(false, header) - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.FeeMarketKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) + suite.SetupAccount(t) + suite.SetupTestWithCb(t, nil) + validator := suite.BaseTestSuiteWithAccount.PostSetupValidator(t) + validator = stakingkeeper.TestingUpdateValidator(suite.App.StakingKeeper, suite.Ctx, validator, true) + valBz, err := suite.App.StakingKeeper.ValidatorAddressCodec().StringToBytes(validator.GetOperator()) + suite.Require().NoError(err) + err = suite.App.StakingKeeper.Hooks().AfterValidatorCreated(suite.Ctx, valBz) + suite.Require().NoError(err) + err = suite.App.StakingKeeper.SetValidatorByConsAddr(suite.Ctx, validator) + suite.Require().NoError(err) + suite.App.StakingKeeper.SetValidator(suite.Ctx, validator) } func (suite *KeeperTestSuite) TestSetGetBlockGasWanted() { @@ -198,9 +94,9 @@ func (suite *KeeperTestSuite) TestSetGetGasFee() { { "with last block given", func() { - suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, sdk.OneDec().BigInt()) + suite.App.FeeMarketKeeper.SetBaseFee(suite.Ctx, sdkmath.LegacyOneDec().BigInt()) }, - sdk.OneDec().BigInt(), + sdkmath.LegacyOneDec().BigInt(), }, } diff --git a/x/feemarket/keeper/params.go b/x/feemarket/keeper/params.go index e45e7200..06a48278 100644 --- a/x/feemarket/keeper/params.go +++ b/x/feemarket/keeper/params.go @@ -18,36 +18,34 @@ package keeper import ( "math/big" - "github.com/zeta-chain/ethermint/x/feemarket/types" + sdkmath "cosmossdk.io/math" + "github.com/evmos/ethermint/x/feemarket/types" sdk "github.com/cosmos/cosmos-sdk/types" ) // GetParams returns the total set of fee market parameters. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKey) - if len(bz) == 0 { - var p types.Params - k.ss.GetParamSetIfExists(ctx, &p) +func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.ParamsKey) + if err != nil { + panic(err) + } + if bz == nil { return p } - - k.cdc.MustUnmarshal(bz, ¶ms) - return params + k.cdc.MustUnmarshal(bz, &p) + return p } // SetParams sets the fee market params in a single key -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(¶ms) - if err != nil { +func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { + if err := p.Validate(); err != nil { return err } - - store.Set(types.ParamsKey, bz) - - return nil + store := k.storeService.OpenKVStore(ctx) + bz := k.cdc.MustMarshal(&p) + return store.Set(types.ParamsKey, bz) } // ---------------------------------------------------------------------------- @@ -79,7 +77,7 @@ func (k Keeper) GetBaseFee(ctx sdk.Context) *big.Int { // SetBaseFee set's the base fee in the store func (k Keeper) SetBaseFee(ctx sdk.Context, baseFee *big.Int) { params := k.GetParams(ctx) - params.BaseFee = sdk.NewIntFromBigInt(baseFee) + params.BaseFee = sdkmath.NewIntFromBigInt(baseFee) err := k.SetParams(ctx, params) if err != nil { return diff --git a/x/feemarket/keeper/params_test.go b/x/feemarket/keeper/params_test.go index ee21ade9..41de7a63 100644 --- a/x/feemarket/keeper/params_test.go +++ b/x/feemarket/keeper/params_test.go @@ -6,9 +6,17 @@ import ( "github.com/zeta-chain/ethermint/x/feemarket/types" ) -func (suite *KeeperTestSuite) TestSetGetParams() { - params := suite.app.FeeMarketKeeper.GetParams(suite.ctx) - suite.app.FeeMarketKeeper.SetParams(suite.ctx, params) +type ParamsTestSuite struct { + testutil.BaseTestSuite +} + +func TestParamsTestSuite(t *testing.T) { + suite.Run(t, new(ParamsTestSuite)) +} + +func (suite *ParamsTestSuite) TestSetGetParams() { + params := types.DefaultParams() + suite.App.FeeMarketKeeper.SetParams(suite.Ctx, params) testCases := []struct { name string paramsFun func() interface{} diff --git a/x/feemarket/migrations/v4/migrate.go b/x/feemarket/migrations/v4/migrate.go index 2332eb5b..94a079dd 100644 --- a/x/feemarket/migrations/v4/migrate.go +++ b/x/feemarket/migrations/v4/migrate.go @@ -1,8 +1,8 @@ package v4 import ( + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/ethermint/x/feemarket/types" ) diff --git a/x/feemarket/migrations/v4/migrate_test.go b/x/feemarket/migrations/v4/migrate_test.go index 164ac305..33c16694 100644 --- a/x/feemarket/migrations/v4/migrate_test.go +++ b/x/feemarket/migrations/v4/migrate_test.go @@ -3,11 +3,14 @@ package v4_test import ( "testing" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/evmos/ethermint/app" + v4 "github.com/evmos/ethermint/x/feemarket/migrations/v4" + "github.com/evmos/ethermint/x/feemarket/types" "github.com/stretchr/testify/require" "github.com/zeta-chain/ethermint/app" - "github.com/zeta-chain/ethermint/encoding" v4 "github.com/zeta-chain/ethermint/x/feemarket/migrations/v4" "github.com/zeta-chain/ethermint/x/feemarket/types" ) @@ -29,11 +32,11 @@ func (ms mockSubspace) GetParamSetIfExists(ctx sdk.Context, ps types.LegacyParam } func TestMigrate(t *testing.T) { - encCfg := encoding.MakeConfig(app.ModuleBasics) + encCfg := app.MakeConfigForTest() cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(types.ModuleName) - tKey := sdk.NewTransientStoreKey("transient_test") + storeKey := storetypes.NewKVStoreKey(types.ModuleName) + tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) kvStore := ctx.KVStore(storeKey) diff --git a/x/feemarket/migrations/v4/types/feemarket.pb.go b/x/feemarket/migrations/v4/types/feemarket.pb.go index 063f7532..b8022c1f 100644 --- a/x/feemarket/migrations/v4/types/feemarket.pb.go +++ b/x/feemarket/migrations/v4/types/feemarket.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + sdkmath "cosmossdk.io/math" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -37,12 +38,12 @@ type Params struct { // enable_height defines at which block height the base fee calculation is enabled. EnableHeight int64 `protobuf:"varint,5,opt,name=enable_height,json=enableHeight,proto3" json:"enable_height,omitempty"` // base_fee for EIP-1559 blocks. - BaseFee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee"` + BaseFee sdkmath.Int `protobuf:"bytes,6,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee"` // min_gas_price defines the minimum gas price value for cosmos and eth transactions - MinGasPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=min_gas_price,json=minGasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_gas_price"` + MinGasPrice sdkmath.LegacyDec `protobuf:"bytes,7,opt,name=min_gas_price,json=minGasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_gas_price"` // min_gas_multiplier bounds the minimum gas used to be charged // to senders based on gas limit - MinGasMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=min_gas_multiplier,json=minGasMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_gas_multiplier"` + MinGasMultiplier sdkmath.LegacyDec `protobuf:"bytes,8,opt,name=min_gas_multiplier,json=minGasMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_gas_multiplier"` } func (m *Params) Reset() { *m = Params{} } diff --git a/x/feemarket/migrations/v4/types/params.go b/x/feemarket/migrations/v4/types/params.go index fc6b876a..7dfb39d2 100644 --- a/x/feemarket/migrations/v4/types/params.go +++ b/x/feemarket/migrations/v4/types/params.go @@ -6,7 +6,6 @@ import ( "github.com/zeta-chain/ethermint/x/feemarket/types" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/params" ) @@ -27,9 +26,9 @@ var ( var ( // DefaultMinGasMultiplier is 0.5 or 50% - DefaultMinGasMultiplier = sdk.NewDecWithPrec(50, 2) + DefaultMinGasMultiplier = sdkmath.LegacyNewDecWithPrec(50, 2) // DefaultMinGasPrice is 0 (i.e disabled) - DefaultMinGasPrice = sdk.ZeroDec() + DefaultMinGasPrice = sdkmath.LegacyZeroDec() DefaultEnableHeight = int64(0) DefaultNoBaseFee = false ) @@ -59,8 +58,8 @@ func NewParams( elasticityMultiplier uint32, baseFee uint64, enableHeight int64, - minGasPrice sdk.Dec, - minGasPriceMultiplier sdk.Dec, + minGasPrice sdkmath.LegacyDec, + minGasPriceMultiplier sdkmath.LegacyDec, ) Params { return Params{ NoBaseFee: noBaseFee, @@ -163,7 +162,7 @@ func validateEnableHeight(i interface{}) error { } func validateMinGasPrice(i interface{}) error { - v, ok := i.(sdk.Dec) + v, ok := i.(sdkmath.LegacyDec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -181,7 +180,7 @@ func validateMinGasPrice(i interface{}) error { } func validateMinGasMultiplier(i interface{}) error { - v, ok := i.(sdk.Dec) + v, ok := i.(sdkmath.LegacyDec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -195,7 +194,7 @@ func validateMinGasMultiplier(i interface{}) error { return fmt.Errorf("value cannot be negative: %s", v) } - if v.GT(sdk.OneDec()) { + if v.GT(sdkmath.LegacyOneDec()) { return fmt.Errorf("value cannot be greater than 1: %s", v) } return nil diff --git a/x/feemarket/module.go b/x/feemarket/module.go index 524a7721..eb7f5ba0 100644 --- a/x/feemarket/module.go +++ b/x/feemarket/module.go @@ -26,6 +26,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -41,6 +42,9 @@ import ( var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} + + _ appmodule.HasEndBlocker = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the fee market module. @@ -88,6 +92,11 @@ func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *ru } } +// RegisterInterfaces registers interfaces and implementations of the fee market module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + // GetTxCmd returns the root tx command for the fee market module. func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil @@ -98,11 +107,6 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaces registers interfaces and implementations of the fee market module. -func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - types.RegisterInterfaces(registry) -} - // ____________________________________________________________________________ // AppModule implements an application module for the fee market module. @@ -144,15 +148,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } // BeginBlock returns the begin block for the fee market module. -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - am.keeper.BeginBlock(ctx, req) +func (am AppModule) BeginBlock(ctx context.Context) error { + return am.keeper.BeginBlock(sdk.UnwrapSDKContext(ctx)) } // EndBlock returns the end blocker for the fee market module. It returns no validator // updates. -func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { - am.keeper.EndBlock(ctx, req) - return []abci.ValidatorUpdate{} +func (am AppModule) EndBlock(ctx context.Context) error { + return am.keeper.EndBlock(sdk.UnwrapSDKContext(ctx)) } // InitGenesis performs genesis initialization for the fee market module. It returns @@ -173,7 +176,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // RegisterStoreDecoder registers a decoder for fee market module's types -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} +func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} // GenerateGenesisState creates a randomized GenState of the fee market module. func (AppModule) GenerateGenesisState(_ *module.SimulationState) { @@ -183,3 +186,9 @@ func (AppModule) GenerateGenesisState(_ *module.SimulationState) { func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/feemarket/types/codec.go b/x/feemarket/types/codec.go index ecfb0d9c..9899e9cd 100644 --- a/x/feemarket/types/codec.go +++ b/x/feemarket/types/codec.go @@ -14,7 +14,7 @@ var ( ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) // AminoCdc is a amino codec created to support amino JSON compatible msgs. - AminoCdc = codec.NewAminoCodec(amino) + AminoCdc = codec.NewAminoCodec(amino) //nolint:staticcheck ) const ( diff --git a/x/feemarket/types/feemarket.pb.go b/x/feemarket/types/feemarket.pb.go index ab12f796..f4f44b49 100644 --- a/x/feemarket/types/feemarket.pb.go +++ b/x/feemarket/types/feemarket.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -37,12 +37,12 @@ type Params struct { // enable_height defines at which block height the base fee calculation is enabled. EnableHeight int64 `protobuf:"varint,5,opt,name=enable_height,json=enableHeight,proto3" json:"enable_height,omitempty"` // base_fee for EIP-1559 blocks. - BaseFee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee"` + BaseFee cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=base_fee,json=baseFee,proto3,customtype=cosmossdk.io/math.Int" json:"base_fee"` // min_gas_price defines the minimum gas price value for cosmos and eth transactions - MinGasPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=min_gas_price,json=minGasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_gas_price"` + MinGasPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=min_gas_price,json=minGasPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_gas_price"` // min_gas_multiplier bounds the minimum gas used to be charged // to senders based on gas limit - MinGasMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=min_gas_multiplier,json=minGasMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_gas_multiplier"` + MinGasMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=min_gas_multiplier,json=minGasMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_gas_multiplier"` } func (m *Params) Reset() { *m = Params{} } @@ -115,32 +115,33 @@ func init() { } var fileDescriptor_4feb8b20cf98e6e1 = []byte{ - // 394 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x33, 0x76, 0xb7, 0x9b, 0x9d, 0xb5, 0x50, 0x86, 0x55, 0x82, 0x42, 0x36, 0x28, 0x2c, - 0xb9, 0x6c, 0x42, 0xd9, 0xb3, 0x97, 0x5a, 0xd4, 0x2a, 0x42, 0xc9, 0x51, 0x84, 0x61, 0x92, 0xbe, - 0x26, 0x43, 0x33, 0x33, 0x21, 0x33, 0x2d, 0xd6, 0x4f, 0xe1, 0xc7, 0xea, 0xb1, 0x27, 0x11, 0x0f, - 0x45, 0xda, 0x2f, 0x22, 0x4d, 0xda, 0xa4, 0x57, 0x3d, 0x25, 0xf3, 0xfe, 0xff, 0xf9, 0xbd, 0x37, - 0x33, 0x7f, 0x7c, 0x0f, 0x26, 0x83, 0x52, 0x70, 0x69, 0xc2, 0x19, 0x80, 0x60, 0xe5, 0x1c, 0x4c, - 0xb8, 0x1c, 0xb4, 0x8b, 0xa0, 0x28, 0x95, 0x51, 0xe4, 0x79, 0xe3, 0x0b, 0x5a, 0x69, 0x39, 0x78, - 0x71, 0x9b, 0xaa, 0x54, 0x55, 0x96, 0xf0, 0xf0, 0x57, 0xbb, 0x5f, 0xfd, 0xec, 0xe0, 0xee, 0x84, - 0x95, 0x4c, 0x68, 0xe2, 0xe2, 0x1b, 0xa9, 0x68, 0xcc, 0x34, 0xd0, 0x19, 0x80, 0x83, 0x3c, 0xe4, - 0xdb, 0xd1, 0xb5, 0x54, 0x43, 0xa6, 0xe1, 0x1d, 0x00, 0x79, 0x83, 0x5f, 0x9e, 0x44, 0x9a, 0x64, - 0x4c, 0xa6, 0x40, 0xa7, 0x20, 0x95, 0xe0, 0x92, 0x19, 0x55, 0x3a, 0x4f, 0x3c, 0xe4, 0xf7, 0x22, - 0x27, 0xae, 0xdd, 0x6f, 0x2b, 0xc3, 0xa8, 0xd5, 0xc9, 0x23, 0x7e, 0x06, 0x39, 0xd3, 0x86, 0x27, - 0xdc, 0xac, 0xa8, 0x58, 0xe4, 0x86, 0x17, 0x39, 0x87, 0xd2, 0xe9, 0x54, 0x1b, 0x6f, 0x5b, 0xf1, - 0x73, 0xa3, 0x91, 0xd7, 0xb8, 0x07, 0x92, 0xc5, 0x39, 0xd0, 0x0c, 0x78, 0x9a, 0x19, 0xe7, 0xd2, - 0x43, 0x7e, 0x27, 0x7a, 0x5a, 0x17, 0x3f, 0x54, 0x35, 0x32, 0xc6, 0x76, 0x33, 0x75, 0xd7, 0x43, - 0xfe, 0xf5, 0x30, 0x58, 0x6f, 0xef, 0xac, 0xdf, 0xdb, 0xbb, 0xfb, 0x94, 0x9b, 0x6c, 0x11, 0x07, - 0x89, 0x12, 0x61, 0xa2, 0xb4, 0x50, 0xfa, 0xf8, 0x79, 0xd0, 0xd3, 0x79, 0x68, 0x56, 0x05, 0xe8, - 0x60, 0x2c, 0x4d, 0x74, 0x75, 0x9c, 0x9a, 0x44, 0xb8, 0x27, 0xb8, 0xa4, 0x29, 0xd3, 0xb4, 0x28, - 0x79, 0x02, 0xce, 0xd5, 0x3f, 0xf3, 0x46, 0x90, 0x44, 0x37, 0x82, 0xcb, 0xf7, 0x4c, 0x4f, 0x0e, - 0x08, 0xf2, 0x15, 0x93, 0x13, 0xf3, 0xec, 0xd4, 0xf6, 0x7f, 0x81, 0xfb, 0x35, 0xb8, 0xbd, 0xa1, - 0x8f, 0x17, 0xf6, 0x45, 0xff, 0x32, 0xea, 0x73, 0xc9, 0x0d, 0x67, 0x79, 0xf3, 0x7c, 0xc3, 0x4f, - 0xeb, 0x9d, 0x8b, 0x36, 0x3b, 0x17, 0xfd, 0xd9, 0xb9, 0xe8, 0xc7, 0xde, 0xb5, 0x36, 0x7b, 0xd7, - 0xfa, 0xb5, 0x77, 0xad, 0x2f, 0x83, 0xb3, 0x5e, 0xdf, 0xc1, 0xb0, 0x87, 0x24, 0x63, 0x5c, 0x86, - 0x6d, 0xbc, 0xbe, 0x9d, 0x05, 0xac, 0x6a, 0x1d, 0x77, 0xab, 0xb0, 0x3c, 0xfe, 0x0d, 0x00, 0x00, - 0xff, 0xff, 0x1b, 0xc9, 0x21, 0xb3, 0x84, 0x02, 0x00, 0x00, + // 401 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x6a, 0xdb, 0x40, + 0x14, 0x45, 0x35, 0x75, 0xe2, 0x28, 0x93, 0x1a, 0xcc, 0x90, 0x14, 0xd1, 0x50, 0x45, 0x34, 0x50, + 0xb4, 0x28, 0x12, 0x21, 0x9b, 0x6e, 0xba, 0x71, 0x43, 0xdc, 0x96, 0x16, 0x5c, 0x2d, 0xbb, 0x19, + 0x46, 0xf2, 0xb3, 0x34, 0x58, 0x33, 0x23, 0x34, 0x63, 0x53, 0xff, 0x45, 0xff, 0xa4, 0xbf, 0xe1, + 0xa5, 0x97, 0xa5, 0x0b, 0x53, 0xec, 0x1f, 0x29, 0x96, 0x6c, 0xc9, 0xd0, 0x4d, 0x76, 0xd2, 0xbb, + 0xf7, 0x5c, 0xde, 0x63, 0x2e, 0x7e, 0x03, 0x26, 0x83, 0x52, 0x70, 0x69, 0xc2, 0x09, 0x80, 0x60, + 0xe5, 0x14, 0x4c, 0x38, 0xbf, 0x6b, 0x7f, 0x82, 0xa2, 0x54, 0x46, 0x91, 0x17, 0x8d, 0x2f, 0x68, + 0xa5, 0xf9, 0xdd, 0xcb, 0xcb, 0x54, 0xa5, 0xaa, 0xb2, 0x84, 0xbb, 0xaf, 0xda, 0xfd, 0xfa, 0x57, + 0x07, 0x77, 0x47, 0xac, 0x64, 0x42, 0x13, 0x17, 0x5f, 0x48, 0x45, 0x63, 0xa6, 0x81, 0x4e, 0x00, + 0x1c, 0xe4, 0x21, 0xdf, 0x8e, 0xce, 0xa5, 0x1a, 0x30, 0x0d, 0x8f, 0x00, 0xe4, 0x3d, 0xbe, 0x3e, + 0x88, 0x34, 0xc9, 0x98, 0x4c, 0x81, 0x8e, 0x41, 0x2a, 0xc1, 0x25, 0x33, 0xaa, 0x74, 0x9e, 0x79, + 0xc8, 0xef, 0x45, 0x4e, 0x5c, 0xbb, 0x3f, 0x54, 0x86, 0x87, 0x56, 0x27, 0xf7, 0xf8, 0x0a, 0x72, + 0xa6, 0x0d, 0x4f, 0xb8, 0x59, 0x50, 0x31, 0xcb, 0x0d, 0x2f, 0x72, 0x0e, 0xa5, 0xd3, 0xa9, 0xc0, + 0xcb, 0x56, 0xfc, 0xda, 0x68, 0xe4, 0x16, 0xf7, 0x40, 0xb2, 0x38, 0x07, 0x9a, 0x01, 0x4f, 0x33, + 0xe3, 0x9c, 0x7a, 0xc8, 0xef, 0x44, 0xcf, 0xeb, 0xe1, 0xc7, 0x6a, 0x46, 0xde, 0x61, 0xbb, 0xd9, + 0xba, 0xeb, 0x21, 0xff, 0x7c, 0xf0, 0x6a, 0xb9, 0xbe, 0xb1, 0xfe, 0xac, 0x6f, 0xae, 0x12, 0xa5, + 0x85, 0xd2, 0x7a, 0x3c, 0x0d, 0xb8, 0x0a, 0x05, 0x33, 0x59, 0xf0, 0x49, 0x9a, 0xe8, 0x6c, 0xbf, + 0x24, 0x19, 0xe2, 0x9e, 0xe0, 0x92, 0xa6, 0x4c, 0xd3, 0xa2, 0xe4, 0x09, 0x38, 0x67, 0x15, 0x7e, + 0xbb, 0xc7, 0xaf, 0xff, 0xc7, 0xbf, 0x40, 0xca, 0x92, 0xc5, 0x03, 0x24, 0xd1, 0x85, 0xe0, 0x72, + 0xc8, 0xf4, 0x68, 0xc7, 0x91, 0x6f, 0x98, 0x1c, 0x82, 0x8e, 0x2e, 0xb3, 0x9f, 0x9e, 0xd6, 0xaf, + 0xd3, 0xda, 0xd3, 0x3f, 0x9f, 0xd8, 0x27, 0xfd, 0xd3, 0xa8, 0xcf, 0x25, 0x37, 0x9c, 0xe5, 0xcd, + 0xbb, 0x0c, 0x1e, 0x97, 0x1b, 0x17, 0xad, 0x36, 0x2e, 0xfa, 0xbb, 0x71, 0xd1, 0xcf, 0xad, 0x6b, + 0xad, 0xb6, 0xae, 0xf5, 0x7b, 0xeb, 0x5a, 0xdf, 0xdf, 0xa6, 0xdc, 0x64, 0xb3, 0x38, 0x48, 0x94, + 0x08, 0x61, 0x2e, 0x94, 0x0e, 0xdb, 0xca, 0xfc, 0x38, 0x2a, 0x8d, 0x59, 0x14, 0xa0, 0xe3, 0x6e, + 0x55, 0x80, 0xfb, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x77, 0x52, 0x39, 0x58, 0x02, 0x00, + 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/feemarket/types/params.go b/x/feemarket/types/params.go index 4965d871..9fecfd46 100644 --- a/x/feemarket/types/params.go +++ b/x/feemarket/types/params.go @@ -19,16 +19,15 @@ import ( "fmt" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/params" ) var ( // DefaultMinGasMultiplier is 0.5 or 50% - DefaultMinGasMultiplier = sdk.NewDecWithPrec(50, 2) + DefaultMinGasMultiplier = sdkmath.LegacyNewDecWithPrec(50, 2) // DefaultMinGasPrice is 0 (i.e disabled) - DefaultMinGasPrice = sdk.ZeroDec() + DefaultMinGasPrice = sdkmath.LegacyZeroDec() // DefaultEnableHeight is 0 (i.e disabled) DefaultEnableHeight = int64(0) // DefaultNoBaseFee is false @@ -72,8 +71,8 @@ func NewParams( elasticityMultiplier uint32, baseFee uint64, enableHeight int64, - minGasPrice sdk.Dec, - minGasPriceMultiplier sdk.Dec, + minGasPrice sdkmath.LegacyDec, + minGasPriceMultiplier sdkmath.LegacyDec, ) Params { return Params{ NoBaseFee: noBaseFee, @@ -133,7 +132,7 @@ func (p *Params) IsBaseFeeEnabled(height int64) bool { } func validateMinGasPrice(i interface{}) error { - v, ok := i.(sdk.Dec) + v, ok := i.(sdkmath.LegacyDec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -198,7 +197,7 @@ func validateEnableHeight(i interface{}) error { } func validateMinGasMultiplier(i interface{}) error { - v, ok := i.(sdk.Dec) + v, ok := i.(sdkmath.LegacyDec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -212,7 +211,7 @@ func validateMinGasMultiplier(i interface{}) error { return fmt.Errorf("value cannot be negative: %s", v) } - if v.GT(sdk.OneDec()) { + if v.GT(sdkmath.LegacyOneDec()) { return fmt.Errorf("value cannot be greater than 1: %s", v) } return nil diff --git a/x/feemarket/types/params_test.go b/x/feemarket/types/params_test.go index 822fb08d..1f9c182e 100644 --- a/x/feemarket/types/params_test.go +++ b/x/feemarket/types/params_test.go @@ -5,8 +5,6 @@ import ( sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" ) type ParamsTestSuite struct { @@ -26,7 +24,7 @@ func (suite *ParamsTestSuite) TestParamsValidate() { {"default", DefaultParams(), false}, { "valid", - NewParams(true, 7, 3, 2000000000, int64(544435345345435345), sdk.NewDecWithPrec(20, 4), DefaultMinGasMultiplier), + NewParams(true, 7, 3, 2000000000, int64(544435345345435345), sdkmath.LegacyNewDecWithPrec(20, 4), DefaultMinGasMultiplier), false, }, { @@ -36,27 +34,27 @@ func (suite *ParamsTestSuite) TestParamsValidate() { }, { "base fee change denominator is 0 ", - NewParams(true, 0, 3, 2000000000, int64(544435345345435345), sdk.NewDecWithPrec(20, 4), DefaultMinGasMultiplier), + NewParams(true, 0, 3, 2000000000, int64(544435345345435345), sdkmath.LegacyNewDecWithPrec(20, 4), DefaultMinGasMultiplier), true, }, { "invalid: min gas price negative", - NewParams(true, 7, 3, 2000000000, int64(544435345345435345), sdk.NewDecFromInt(sdkmath.NewInt(-1)), DefaultMinGasMultiplier), + NewParams(true, 7, 3, 2000000000, int64(544435345345435345), sdkmath.LegacyNewDecFromInt(sdkmath.NewInt(-1)), DefaultMinGasMultiplier), true, }, { "valid: min gas multiplier zero", - NewParams(true, 7, 3, 2000000000, int64(544435345345435345), DefaultMinGasPrice, sdk.ZeroDec()), + NewParams(true, 7, 3, 2000000000, int64(544435345345435345), DefaultMinGasPrice, sdkmath.LegacyZeroDec()), false, }, { "invalid: min gas multiplier is negative", - NewParams(true, 7, 3, 2000000000, int64(544435345345435345), DefaultMinGasPrice, sdk.NewDecWithPrec(-5, 1)), + NewParams(true, 7, 3, 2000000000, int64(544435345345435345), DefaultMinGasPrice, sdkmath.LegacyNewDecWithPrec(-5, 1)), true, }, { "invalid: min gas multiplier bigger than 1", - NewParams(true, 7, 3, 2000000000, int64(544435345345435345), sdk.NewDecWithPrec(20, 4), sdk.NewDec(2)), + NewParams(true, 7, 3, 2000000000, int64(544435345345435345), sdkmath.LegacyNewDecWithPrec(20, 4), sdkmath.LegacyNewDec(2)), true, }, } @@ -87,9 +85,9 @@ func (suite *ParamsTestSuite) TestParamsValidatePriv() { suite.Require().Error(validateEnableHeight("")) suite.Require().Error(validateEnableHeight(int64(-544435345345435345))) suite.Require().NoError(validateEnableHeight(int64(544435345345435345))) - suite.Require().Error(validateMinGasPrice(sdk.Dec{})) - suite.Require().Error(validateMinGasMultiplier(sdk.NewDec(-5))) - suite.Require().Error(validateMinGasMultiplier(sdk.Dec{})) + suite.Require().Error(validateMinGasPrice(sdkmath.LegacyDec{})) + suite.Require().Error(validateMinGasMultiplier(sdkmath.LegacyNewDec(-5))) + suite.Require().Error(validateMinGasMultiplier(sdkmath.LegacyDec{})) suite.Require().Error(validateMinGasMultiplier("")) } @@ -100,13 +98,13 @@ func (suite *ParamsTestSuite) TestParamsValidateMinGasPrice() { expError bool }{ {"default", DefaultParams().MinGasPrice, false}, - {"valid", sdk.NewDecFromInt(sdkmath.NewInt(1)), false}, + {"valid", sdkmath.LegacyNewDecFromInt(sdkmath.NewInt(1)), false}, {"invalid - wrong type - bool", false, true}, {"invalid - wrong type - string", "", true}, {"invalid - wrong type - int64", int64(123), true}, {"invalid - wrong type - sdkmath.Int", sdkmath.NewInt(1), true}, {"invalid - is nil", nil, true}, - {"invalid - is negative", sdk.NewDecFromInt(sdkmath.NewInt(-1)), true}, + {"invalid - is negative", sdkmath.LegacyNewDecFromInt(sdkmath.NewInt(-1)), true}, } for _, tc := range testCases { diff --git a/x/feemarket/types/query.pb.go b/x/feemarket/types/query.pb.go index e036f399..ca85f597 100644 --- a/x/feemarket/types/query.pb.go +++ b/x/feemarket/types/query.pb.go @@ -5,8 +5,8 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -154,7 +154,7 @@ var xxx_messageInfo_QueryBaseFeeRequest proto.InternalMessageInfo // QueryBaseFeeResponse returns the EIP1559 base fee. type QueryBaseFeeResponse struct { // base_fee is the EIP1559 base fee - BaseFee *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee,omitempty"` + BaseFee *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=cosmossdk.io/math.Int" json:"base_fee,omitempty"` } func (m *QueryBaseFeeResponse) Reset() { *m = QueryBaseFeeResponse{} } @@ -288,35 +288,35 @@ func init() { } var fileDescriptor_71a07c1ffd85fde2 = []byte{ - // 447 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x8e, 0x29, 0x74, 0xc3, 0x5c, 0x90, 0xe9, 0x26, 0x14, 0x21, 0xaf, 0x04, 0xa9, 0xda, 0x06, - 0x8d, 0xd5, 0x71, 0xe5, 0x14, 0x09, 0x10, 0xe2, 0x02, 0xe1, 0x86, 0x84, 0x26, 0x27, 0xbc, 0xa5, - 0x51, 0x97, 0x38, 0x8b, 0xdd, 0x89, 0x71, 0xe4, 0xc6, 0x05, 0x21, 0xf8, 0x35, 0xfc, 0x83, 0x1d, - 0x27, 0x71, 0x41, 0x1c, 0x26, 0xd4, 0xf2, 0x43, 0x50, 0x6c, 0xa7, 0x34, 0x40, 0x58, 0x4f, 0xb1, - 0x5e, 0xbe, 0xf7, 0x7d, 0xdf, 0xfb, 0x9e, 0x8d, 0x3d, 0x50, 0x63, 0x28, 0xb3, 0x34, 0x57, 0xec, - 0x00, 0x20, 0xe3, 0xe5, 0x04, 0x14, 0x3b, 0x1e, 0xb1, 0xa3, 0x29, 0x94, 0x27, 0x7e, 0x51, 0x0a, - 0x25, 0xc8, 0xe6, 0x02, 0xe3, 0x2f, 0x30, 0xfe, 0xf1, 0xc8, 0xed, 0x25, 0x22, 0x11, 0x1a, 0xc2, - 0xaa, 0x93, 0x41, 0xbb, 0x83, 0x16, 0xc6, 0xdf, 0xad, 0x06, 0x77, 0x2b, 0x11, 0x22, 0x39, 0x04, - 0xc6, 0x8b, 0x94, 0xf1, 0x3c, 0x17, 0x8a, 0xab, 0x54, 0xe4, 0xd2, 0xfc, 0xf5, 0x7a, 0x98, 0x3c, - 0xaf, 0x2c, 0x3c, 0xe3, 0x25, 0xcf, 0x64, 0x08, 0x47, 0x53, 0x90, 0xca, 0x7b, 0x81, 0x6f, 0x34, - 0xaa, 0xb2, 0x10, 0xb9, 0x04, 0xf2, 0x00, 0x77, 0x0b, 0x5d, 0xb9, 0x89, 0xfa, 0x68, 0xfb, 0xda, - 0x1e, 0xf5, 0xff, 0xed, 0xd8, 0x37, 0x7d, 0xc1, 0xe5, 0xd3, 0xf3, 0x2d, 0x27, 0xb4, 0x3d, 0xde, - 0x86, 0x25, 0x0d, 0xb8, 0x84, 0x47, 0x00, 0xb5, 0xd6, 0x2b, 0xdc, 0x6b, 0x96, 0xad, 0xd8, 0x43, - 0xbc, 0x1e, 0x71, 0x09, 0xfb, 0x07, 0x00, 0x5a, 0xee, 0x6a, 0xb0, 0xfb, 0xfd, 0x7c, 0x6b, 0x90, - 0xa4, 0x6a, 0x3c, 0x8d, 0xfc, 0x58, 0x64, 0x2c, 0x16, 0x32, 0x13, 0xd2, 0x7e, 0x86, 0xf2, 0xf5, - 0x84, 0xa9, 0x93, 0x02, 0xa4, 0xff, 0x24, 0x57, 0xe1, 0x5a, 0x64, 0xe8, 0xbc, 0xcd, 0x9a, 0xfe, - 0x50, 0xc4, 0x93, 0xc7, 0x7c, 0x31, 0xe2, 0x0e, 0xde, 0xf8, 0xa3, 0x6e, 0x75, 0xaf, 0xe3, 0x4e, - 0xc2, 0xcd, 0x84, 0x9d, 0xb0, 0x3a, 0xee, 0x7d, 0xe9, 0xe0, 0x2b, 0x1a, 0x4b, 0xde, 0x23, 0xdc, - 0x35, 0xb3, 0x91, 0xdd, 0xb6, 0xd9, 0xff, 0x8e, 0xd3, 0xbd, 0xbb, 0x12, 0xd6, 0xe8, 0x7b, 0x83, - 0x77, 0x5f, 0x7f, 0x7e, 0xbe, 0xd4, 0x27, 0x94, 0xb5, 0x2c, 0xd8, 0xc4, 0x49, 0x3e, 0x20, 0xbc, - 0x66, 0x33, 0x23, 0xff, 0x17, 0x68, 0x06, 0xee, 0xde, 0x5b, 0x0d, 0x6c, 0xed, 0x6c, 0x6b, 0x3b, - 0x1e, 0xe9, 0xb7, 0xd9, 0xa9, 0x97, 0x44, 0x3e, 0x21, 0xbc, 0x5e, 0xa7, 0x49, 0x2e, 0x10, 0x69, - 0x2e, 0xc3, 0x1d, 0xae, 0x88, 0xb6, 0x9e, 0x76, 0xb4, 0xa7, 0x3b, 0xe4, 0x76, 0xab, 0xa7, 0xaa, - 0x63, 0x3f, 0xe1, 0x32, 0x78, 0x7a, 0x3a, 0xa3, 0xe8, 0x6c, 0x46, 0xd1, 0x8f, 0x19, 0x45, 0x1f, - 0xe7, 0xd4, 0x39, 0x9b, 0x53, 0xe7, 0xdb, 0x9c, 0x3a, 0x2f, 0x47, 0x4b, 0x37, 0xe9, 0x2d, 0x28, - 0x3e, 0x8c, 0xc7, 0x3c, 0xcd, 0x97, 0x18, 0xdf, 0x2c, 0x71, 0xea, 0x8b, 0x15, 0x75, 0xf5, 0x9b, - 0xb9, 0xff, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xb8, 0xeb, 0x37, 0x7a, 0xcd, 0x03, 0x00, 0x00, + // 437 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x3f, 0x8f, 0xd3, 0x30, + 0x14, 0x8f, 0x29, 0xf4, 0x0e, 0xb3, 0x20, 0xd3, 0x9e, 0x20, 0x42, 0xbe, 0x12, 0xa4, 0xd3, 0x1d, + 0x1c, 0xb6, 0xee, 0x60, 0x64, 0xca, 0x70, 0x08, 0x89, 0x01, 0xc2, 0xc6, 0x52, 0x39, 0xe5, 0x35, + 0x8d, 0xda, 0xc4, 0x69, 0xec, 0x56, 0x74, 0x65, 0x63, 0x41, 0x08, 0x3e, 0x0d, 0xdf, 0xa0, 0x63, + 0x25, 0x16, 0xc4, 0x50, 0xa1, 0x96, 0x0f, 0x82, 0x12, 0x27, 0xa5, 0x01, 0x02, 0xdd, 0xac, 0x97, + 0xdf, 0xbf, 0xf7, 0x7b, 0x0a, 0x76, 0x40, 0x0f, 0x20, 0x8d, 0xc2, 0x58, 0xf3, 0x3e, 0x40, 0x24, + 0xd2, 0x21, 0x68, 0x3e, 0x3d, 0xe3, 0xe3, 0x09, 0xa4, 0x33, 0x96, 0xa4, 0x52, 0x4b, 0x72, 0xb0, + 0xc1, 0xb0, 0x0d, 0x86, 0x4d, 0xcf, 0xec, 0x56, 0x20, 0x03, 0x99, 0x43, 0x78, 0xf6, 0x32, 0x68, + 0xfb, 0xa8, 0x46, 0xf1, 0x17, 0xd5, 0xe0, 0x6e, 0x07, 0x52, 0x06, 0x23, 0xe0, 0x22, 0x09, 0xb9, + 0x88, 0x63, 0xa9, 0x85, 0x0e, 0x65, 0xac, 0xcc, 0x57, 0xa7, 0x85, 0xc9, 0x8b, 0x2c, 0xc2, 0x73, + 0x91, 0x8a, 0x48, 0x79, 0x30, 0x9e, 0x80, 0xd2, 0xce, 0x4b, 0x7c, 0xa3, 0x32, 0x55, 0x89, 0x8c, + 0x15, 0x90, 0xc7, 0xb8, 0x99, 0xe4, 0x93, 0x9b, 0xa8, 0x83, 0x8e, 0xaf, 0x9d, 0x53, 0xf6, 0xf7, + 0xc4, 0xcc, 0xf0, 0xdc, 0xcb, 0xf3, 0xe5, 0xa1, 0xe5, 0x15, 0x1c, 0xa7, 0x5d, 0x88, 0xba, 0x42, + 0xc1, 0x05, 0x40, 0xe9, 0xf5, 0x0c, 0xb7, 0xaa, 0xe3, 0xc2, 0xec, 0x11, 0xde, 0xf7, 0x85, 0x82, + 0x6e, 0x1f, 0x20, 0xb7, 0xbb, 0xea, 0xde, 0xfa, 0xb6, 0x3c, 0x6c, 0xf7, 0xa4, 0x8a, 0xa4, 0x52, + 0xaf, 0x87, 0x2c, 0x94, 0x3c, 0x12, 0x7a, 0xc0, 0x9e, 0xc6, 0xda, 0xdb, 0xf3, 0x0d, 0xdb, 0x39, + 0x28, 0xd5, 0x46, 0xb2, 0x37, 0x7c, 0x22, 0x36, 0x1b, 0x9d, 0xe0, 0xf6, 0x6f, 0xf3, 0xc2, 0xe6, + 0x3a, 0x6e, 0x04, 0xc2, 0x2c, 0xd4, 0xf0, 0xb2, 0xe7, 0xf9, 0xe7, 0x06, 0xbe, 0x92, 0x63, 0xc9, + 0x3b, 0x84, 0x9b, 0x66, 0x15, 0x72, 0xaf, 0x6e, 0xd5, 0x3f, 0xdb, 0xb3, 0xef, 0xef, 0x84, 0x35, + 0xfe, 0xce, 0xd1, 0xdb, 0x2f, 0x3f, 0x3e, 0x5d, 0xea, 0x10, 0xca, 0x6b, 0xee, 0x69, 0xda, 0x23, + 0xef, 0x11, 0xde, 0x2b, 0x2a, 0x22, 0xff, 0x36, 0xa8, 0xf6, 0x6b, 0x9f, 0xee, 0x06, 0x2e, 0xe2, + 0x1c, 0xe7, 0x71, 0x1c, 0xd2, 0xa9, 0x8b, 0x53, 0xde, 0x84, 0x7c, 0x44, 0x78, 0xbf, 0x6c, 0x93, + 0xfc, 0xc7, 0xa4, 0x7a, 0x0c, 0xfb, 0xc1, 0x8e, 0xe8, 0x22, 0xd3, 0x49, 0x9e, 0xe9, 0x2e, 0xb9, + 0x53, 0x9b, 0x29, 0x63, 0x74, 0x03, 0xa1, 0xdc, 0x8b, 0xf9, 0x8a, 0xa2, 0xc5, 0x8a, 0xa2, 0xef, + 0x2b, 0x8a, 0x3e, 0xac, 0xa9, 0xb5, 0x58, 0x53, 0xeb, 0xeb, 0x9a, 0x5a, 0xaf, 0x4e, 0x83, 0x50, + 0x0f, 0x26, 0x3e, 0xeb, 0xc9, 0x88, 0xc3, 0x34, 0x92, 0x6a, 0x4b, 0xec, 0xcd, 0x96, 0x9c, 0x9e, + 0x25, 0xa0, 0xfc, 0x66, 0xfe, 0x77, 0x3c, 0xfc, 0x19, 0x00, 0x00, 0xff, 0xff, 0x15, 0x29, 0x2d, + 0xfd, 0xb7, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -964,7 +964,7 @@ func (m *QueryBaseFeeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int + var v cosmossdk_io_math.Int m.BaseFee = &v if err := m.BaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/feemarket/types/tx.pb.go b/x/feemarket/types/tx.pb.go index 2eb4ac5b..836ca3ab 100644 --- a/x/feemarket/types/tx.pb.go +++ b/x/feemarket/types/tx.pb.go @@ -132,7 +132,7 @@ func init() { func init() { proto.RegisterFile("ethermint/feemarket/v1/tx.proto", fileDescriptor_78aff2584dbf2838) } var fileDescriptor_78aff2584dbf2838 = []byte{ - // 326 bytes of a gzipped FileDescriptorProto + // 327 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0x2d, 0xc9, 0x48, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x4b, 0x4d, 0xcd, 0x4d, 0x2c, 0xca, 0x4e, 0x2d, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0x2b, 0xd0, @@ -146,14 +146,14 @@ var fileDescriptor_78aff2584dbf2838 = []byte{ 0xe6, 0xa5, 0x07, 0x21, 0x94, 0x0a, 0xd9, 0x70, 0xb1, 0x15, 0x80, 0x4d, 0x90, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd3, 0xc3, 0xee, 0x4d, 0x3d, 0x88, 0x3d, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x58, 0xf1, 0x35, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0x4d, 0x49, 0x92, 0x4b, - 0x1c, 0xcd, 0x61, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x46, 0xf9, 0x5c, 0xcc, 0xbe, + 0x1c, 0xcd, 0x61, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x46, 0x65, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0x19, 0x5c, 0x3c, 0x28, 0xee, 0x56, 0xc7, 0x65, 0x1f, 0x9a, 0x39, 0x52, 0xfa, - 0x44, 0x2a, 0x84, 0x59, 0xe8, 0xe4, 0x7d, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, - 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, - 0x51, 0x86, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x55, 0xa9, 0x25, - 0x89, 0xba, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xfa, 0x88, 0x38, 0xa9, 0x40, 0x8a, 0x95, 0x92, 0xca, - 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xc8, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x9d, 0xb5, - 0xab, 0x94, 0x26, 0x02, 0x00, 0x00, + 0x44, 0x2a, 0x84, 0x59, 0x28, 0xc5, 0xda, 0xf0, 0x7c, 0x83, 0x16, 0xa3, 0x93, 0xdb, 0x89, 0x47, + 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, + 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0xa7, 0x96, 0x81, 0xa2, 0x10, 0x11, 0x2b, 0x15, 0x48, 0xf1, 0x52, 0x52, + 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x7b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6f, + 0xa8, 0x62, 0xbb, 0x28, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used.