Skip to content

Commit

Permalink
chore: remove todo comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Nov 29, 2023
1 parent b1ada74 commit 0249796
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 109 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/deploy-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
9 changes: 2 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ 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"
mempool "github.com/cosmos/cosmos-sdk/types/mempool"
"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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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{},
Expand Down
20 changes: 9 additions & 11 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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))
}
}
89 changes: 5 additions & 84 deletions encoding/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
68 changes: 68 additions & 0 deletions x/evm/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion x/feemarket/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions x/feemarket/types/msg.go
Original file line number Diff line number Diff line change
@@ -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{}
Expand All @@ -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
}

0 comments on commit 0249796

Please sign in to comment.