diff --git a/.github/workflows/deploy-contract.yml b/.github/workflows/deploy-contract.yml index 5fe6f78a67..dcd0bbb7ae 100644 --- a/.github/workflows/deploy-contract.yml +++ b/.github/workflows/deploy-contract.yml @@ -31,10 +31,6 @@ jobs: **/**.go go.mod go.sum - - uses: actions/setup-go@v4 - with: - go-version: "1.21" - check-latest: true - name: Test contract run: | sudo make contract-tools diff --git a/Makefile b/Makefile index 55a67bc7db..5286c1df9d 100644 --- a/Makefile +++ b/Makefile @@ -234,7 +234,6 @@ $(STATIK): contract-tools: ifeq (, $(shell which stringer)) @echo "Installing stringer..." - @echo "$(shell go env GOVERSION)" @go get golang.org/x/tools/cmd/stringer else @echo "stringer already installed; skipping..." diff --git a/app/app.go b/app/app.go index baf2c4bbec..570518e7c0 100644 --- a/app/app.go +++ b/app/app.go @@ -55,8 +55,6 @@ import ( feegrantkeeper "cosmossdk.io/x/feegrant/keeper" feegrantmodule "cosmossdk.io/x/feegrant/module" "cosmossdk.io/x/upgrade" - authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" - // upgradeclient "cosmossdk.io/x/upgrade/client" // TODO(dudong2) upgradekeeper "cosmossdk.io/x/upgrade/keeper" upgradetypes "cosmossdk.io/x/upgrade/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -64,6 +62,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "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" @@ -115,7 +114,6 @@ import ( 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" - // ibcclientclient "github.com/cosmos/ibc-go/v8/modules/core/02-client/client" // TODO(dudong2) 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" @@ -171,10 +169,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{}, diff --git a/app/upgrades.go b/app/upgrades.go index 560521b523..a77de95374 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -45,7 +45,7 @@ import ( feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" ) -func (app *EthermintApp) RegisterUpgradeHandlers( // TODO(dudong2) +func (app *EthermintApp) RegisterUpgradeHandlers( cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper, consensusParamsKeeper consensusparamskeeper.Keeper, @@ -86,7 +86,7 @@ func (app *EthermintApp) RegisterUpgradeHandlers( // TODO(dudong2) } baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) - app.UpgradeKeeper.SetUpgradeHandler( // TODO(dudong2) + app.UpgradeKeeper.SetUpgradeHandler( planName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -110,15 +110,13 @@ func (app *EthermintApp) RegisterUpgradeHandlers( // TODO(dudong2) 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)) + if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{ + Added: []string{ + consensusparamtypes.StoreKey, + crisistypes.StoreKey, + }, } + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } } diff --git a/encoding/config.go b/encoding/config.go index 17493bb2c5..ed1b224c89 100644 --- a/encoding/config.go +++ b/encoding/config.go @@ -31,8 +31,7 @@ import ( feemarketv1 "github.com/evmos/ethermint/api/ethermint/feemarket/v1" enccodec "github.com/evmos/ethermint/encoding/codec" evmtypes "github.com/evmos/ethermint/x/evm/types" - - "github.com/ethereum/go-ethereum/common" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" ) // MakeConfig creates an EncodingConfig for testing @@ -44,88 +43,10 @@ func MakeConfig(mb module.BasicManager) params.EncodingConfig { ValidatorAddressCodec: address.Bech32Codec{Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix()}, } - // evm/MsgEthereumTx, evm/MsgUpdateParams, feemarket/MsgUpdateParams // TODO(dudong2) - signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), func(msg protov2.Message) ([][]byte, error) { - msgEthereumTx, ok := msg.(*evmv1.MsgEthereumTx) - if !ok { - return nil, nil - } - - if len(msgEthereumTx.From) > 0 { - return [][]byte{common.HexToAddress(msgEthereumTx.From).Bytes()}, nil - } - - var dataAny *types.Any - var err error - switch msgEthereumTx.Data.TypeUrl { - case "/ethermint.evm.v1.LegacyTx": - legacyTx := evmtypes.LegacyTx{} - evmtypes.ModuleCdc.MustUnmarshal(msgEthereumTx.Data.Value, &legacyTx) - dataAny, err = evmtypes.PackTxData(&legacyTx) - if err != nil { - return nil, err - } - case "/ethermint.evm.v1.DynamicFeeTx": - dynamicFeeTx := evmtypes.DynamicFeeTx{} - evmtypes.ModuleCdc.MustUnmarshal(msgEthereumTx.Data.Value, &dynamicFeeTx) - dataAny, err = evmtypes.PackTxData(&dynamicFeeTx) - if err != nil { - return nil, err - } - case "/ethermint.evm.v1.AccessListTx": - accessListTx := evmtypes.AccessListTx{} - evmtypes.ModuleCdc.MustUnmarshal(msgEthereumTx.Data.Value, &accessListTx) - dataAny, err = evmtypes.PackTxData(&accessListTx) - if err != nil { - return nil, err - } - } - t := evmtypes.MsgEthereumTx{Data: dataAny} - t.Hash = t.AsTransaction().Hash().Hex() - - signers := [][]byte{} - for _, signer := range t.GetSigners() { - signers = append(signers, signer.Bytes()) - } - - return signers, nil - }) - - signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgUpdateParams{}), func(msg protov2.Message) ([][]byte, error) { - msgUpdateParams, ok := msg.(*evmv1.MsgUpdateParams) - if !ok { - return nil, nil - } - - t := evmtypes.MsgUpdateParams{ - Authority: msgUpdateParams.Authority, - } - - signers := [][]byte{} - for _, signer := range t.GetSigners() { - signers = append(signers, signer.Bytes()) - } - - return signers, nil - }) - - signingOptions.DefineCustomGetSigners(protov2.MessageName(&feemarketv1.MsgUpdateParams{}), func(msg protov2.Message) ([][]byte, error) { - msgUpdateParams, ok := msg.(*feemarketv1.MsgUpdateParams) - if !ok { - return nil, nil - } - - t := evmtypes.MsgUpdateParams{ - Authority: msgUpdateParams.Authority, - } - - signers := [][]byte{} - for _, signer := range t.GetSigners() { - signers = append(signers, signer.Bytes()) - } - - return signers, nil - }) + // evm/MsgEthereumTx, evm/MsgUpdateParams, feemarket/MsgUpdateParams + signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgUpdateParams{}), evmtypes.GetSignersFromMsgUpdateParamsV2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&feemarketv1.MsgUpdateParams{}), feemarkettypes.GetSignersFromMsgUpdateParamsV2) interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, diff --git a/x/evm/module.go b/x/evm/module.go index 564c757560..a5013d0b76 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -186,7 +186,7 @@ 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(_ simtypes.StoreDecoderRegistry) { - // sdr[types.StoreKey] = simtypes.NewStoreDecoderFuncFromCollectionsSchema(am.ak.Schema) // TODO(dudong2) + // sdr[types.StoreKey] = simtypes.NewStoreDecoderFuncFromCollectionsSchema(am.ak.Schema) } // GenerateGenesisState creates a randomized GenState of the evm module. diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index 1903804eb5..c3c0aa57de 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -468,3 +468,71 @@ func (m *MsgUpdateParams) ValidateBasic() error { func (m MsgUpdateParams) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&m)) } + +func GetSignersFromMsgEthereumTxV2(msg protov2.Message) ([][]byte, error) { + msgv1, err := GetMsgEthereumTxFromMsgV2(msg) + if err != nil { + return nil, err + } + + signers := [][]byte{} + for _, signer := range msgv1.GetSigners() { + signers = append(signers, signer.Bytes()) + } + + return signers, nil +} + +func GetMsgEthereumTxFromMsgV2(msg protov2.Message) (MsgEthereumTx, error) { + msgv2, ok := msg.(*evmv1.MsgEthereumTx) + if !ok { + return MsgEthereumTx{}, nil + } + + var dataAny *codectypes.Any + var err error + switch msgv2.Data.TypeUrl { + case "/ethermint.evm.v1.LegacyTx": + legacyTx := LegacyTx{} + ModuleCdc.MustUnmarshal(msgv2.Data.Value, &legacyTx) + dataAny, err = PackTxData(&legacyTx) + if err != nil { + return MsgEthereumTx{}, err + } + case "/ethermint.evm.v1.DynamicFeeTx": + dynamicFeeTx := DynamicFeeTx{} + ModuleCdc.MustUnmarshal(msgv2.Data.Value, &dynamicFeeTx) + dataAny, err = PackTxData(&dynamicFeeTx) + if err != nil { + return MsgEthereumTx{}, err + } + case "/ethermint.evm.v1.AccessListTx": + accessListTx := AccessListTx{} + ModuleCdc.MustUnmarshal(msgv2.Data.Value, &accessListTx) + dataAny, err = PackTxData(&accessListTx) + if err != nil { + return MsgEthereumTx{}, err + } + } + msgv1 := MsgEthereumTx{Data: dataAny} + msgv1.Hash = msgv1.AsTransaction().Hash().Hex() + return msgv1, nil +} + +func GetSignersFromMsgUpdateParamsV2(msg protov2.Message) ([][]byte, error) { + msgv2, ok := msg.(*evmv1.MsgUpdateParams) + if !ok { + return nil, nil + } + + msgv1 := MsgUpdateParams{ + Authority: msgv2.Authority, + } + + signers := [][]byte{} + for _, signer := range msgv1.GetSigners() { + signers = append(signers, signer.Bytes()) + } + + return signers, nil +} diff --git a/x/feemarket/module.go b/x/feemarket/module.go index f6457543c2..9118fd2d51 100644 --- a/x/feemarket/module.go +++ b/x/feemarket/module.go @@ -179,7 +179,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(_ simtypes.StoreDecoderRegistry) { - // sdr[teyps.StoreKey] = simtypes.NewStoreDecoderFuncFromCollectionsSchema(schema collections.Schema) // TODO(dudong2) + // sdr[types.StoreKey] = simtypes.NewStoreDecoderFuncFromCollectionsSchema(schema collections.Schema) } // GenerateGenesisState creates a randomized GenState of the fee market module. diff --git a/x/feemarket/types/msg.go b/x/feemarket/types/msg.go index 71d49fdbc9..5a23260aae 100644 --- a/x/feemarket/types/msg.go +++ b/x/feemarket/types/msg.go @@ -1,8 +1,11 @@ package types import ( + protov2 "google.golang.org/protobuf/proto" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + feemarketv1 "github.com/evmos/ethermint/api/ethermint/feemarket/v1" ) var _ sdk.Msg = &MsgUpdateParams{} @@ -26,3 +29,21 @@ func (m *MsgUpdateParams) ValidateBasic() error { func (m MsgUpdateParams) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&m)) } + +func GetSignersFromMsgUpdateParamsV2(msg protov2.Message) ([][]byte, error) { + msgv2, ok := msg.(*feemarketv1.MsgUpdateParams) + if !ok { + return nil, nil + } + + msgv1 := MsgUpdateParams{ + Authority: msgv2.Authority, + } + + signers := [][]byte{} + for _, signer := range msgv1.GetSigners() { + signers = append(signers, signer.Bytes()) + } + + return signers, nil +}