Skip to content

Commit

Permalink
Problem: sdk 0.50 is not used
Browse files Browse the repository at this point in the history
fix dependencies

fix build

upgrade protogen image

Co-authored-by: mmsqe <[email protected]>

wait for block properly

fix py-lint

fix test

fix py-lint
  • Loading branch information
yihuang authored and skosito committed Jan 5, 2025
1 parent 1ebf85a commit 99eeed5
Show file tree
Hide file tree
Showing 185 changed files with 4,226 additions and 3,144 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
Expand Down
80 changes: 41 additions & 39 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand All @@ -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()

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -605,7 +607,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -635,7 +637,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -665,7 +667,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -720,7 +722,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -750,7 +752,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -780,7 +782,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -810,7 +812,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand All @@ -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()
Expand All @@ -843,7 +845,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -872,7 +874,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
sdk.NewCoins(
sdk.NewCoin(
"photon",
sdk.NewInt(1),
sdkmath.NewInt(1),
),
),
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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{
Expand Down
Loading

0 comments on commit 99eeed5

Please sign in to comment.