Skip to content

Commit

Permalink
Upgrade IRISHub to v2.1 (#2863)
Browse files Browse the repository at this point in the history
* bump-up: cosmos-sdk v0.47.4

* bump-up: ibc, tibc, irismod, ethermint

* fix: tibc keeper compile error

* feat: load ibc nft-transfer module

* upgrade: add plan v2.1 and fix consensus params migration logic

* chore: update change log

* chore: update changelog

* chore: format code

* bump-up: add v2 suffix to module paths

* fix: revert path in docs

* proto: regeneration

* bump-up: irismod supports x/nft api

* bump-up: nft-transfer

* fix: vesting account loophole

* chore: fix typo

* fix: adjust ante sequence

* ibc: register client app basic module

* bump-up ethermint to resolve panic of accessing consensus parmas at upgrade block

* fix: support legacy proposal and query on ibc nft

* fix: use no-op-mempool to avoid evm tx failure with no signer

* fix collect-gentxs command (#2866)

* fix: adjust keeper init sequence of gov & farm

* refine custom base option function

* fix: set localhost for ibc allow clients

* chore: fix typo in dockerfile

* bump-up: irismod fix farm genesis validation

---------

Co-authored-by: aofengli <[email protected]>
Co-authored-by: Dreamer <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2023
1 parent 5a5a63d commit f3778fb
Show file tree
Hide file tree
Showing 86 changed files with 762 additions and 384 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@

## [Unreleased]

### API Breaking

* (Auth) Query for BaseAccount type account is no longer supported and is replaced by EthAccount type.

### State Machine Breaking

* (IRISHub) [\#2863](https://github.com/irisnet/irishub/pull/2863) Bump up tibc-go version to xxx
* (IRISHub) [\#2863](https://github.com/irisnet/irishub/pull/2863) Bump up irismod version to xxx
* (IRISHub) [\#2863](https://github.com/irisnet/irishub/pull/2863) Bump up ethermint version to v0.22.0
* (IRISHub) [\#2863](https://github.com/irisnet/irishub/pull/2863) Bump up ibc-go version to v7.3.0
* (IRISHub) [\#2863](https://github.com/irisnet/irishub/pull/2863) Bump up cosmos-sdk to v0.47.4
* (IRISHub) [\#2863](https://github.com/irisnet/irishub/pull/2863) Bump up cometbft to v0.37.2

### Features

* (NFT-Transfer) [\#2863](https://github.com/irisnet/irishub/pull/2863) Feat: support inter nft-transfer module

### Bug Fixes
* (IRISHub) [\#2852](https://github.com/irisnet/irishub/pull/2852) refactor: fix eip712 signature and inject ParseChainID method
* (IRISMod) [irismod \#367](https://github.com/irisnet/irismod/pull/367) Fix rest uri conflict in mt module

### Security

* (IRISHub) [\#2865](https://github.com/irisnet/irishub/pull/2865) Disable the vesting account creation to prevent contract address front-running.

## 2.0.0

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Build image: docker build -t irisnet/irishub:v2.0.0 --build-arg EVM_CHAIN_ID=6688 .
# Build image: docker build -t irisnet/irishub:v2.1.0 --build-arg EVM_CHAIN_ID=6688 .
#
FROM golang:1.18-alpine3.16 as builder
FROM golang:1.19.13-alpine3.18 as builder

ARG EVM_CHAIN_ID

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=iris \
-X github.com/cosmos/cosmos-sdk/version.AppName=iris \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/irisnet/irishub/types.EIP155ChainID=$(EVM_CHAIN_ID) \
-X github.com/irisnet/irishub/v2/types.EIP155ChainID=$(EVM_CHAIN_ID) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

ifeq ($(WITH_CLEVELDB),yes)
Expand Down Expand Up @@ -199,7 +199,7 @@ lint: golangci-lint
format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./lite/statik/statik.go" -not -path "*.pb.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./lite/statik/statik.go" -not -path "*.pb.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./lite/statik/statik.go" -not -path "*.pb.go" | xargs goimports -w -local github.com/irisnet/irishub
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./lite/statik/statik.go" -not -path "*.pb.go" | xargs goimports -w -local github.com/irisnet/irishub/v2

benchmark:
@go test -mod=readonly -bench=. ./...
Expand Down
3 changes: 2 additions & 1 deletion ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
oraclekeeper "github.com/irisnet/irismod/modules/oracle/keeper"
tokenkeeper "github.com/irisnet/irismod/modules/token/keeper"

guardiankeeper "github.com/irisnet/irishub/modules/guardian/keeper"
guardiankeeper "github.com/irisnet/irishub/v2/modules/guardian/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand Down Expand Up @@ -64,6 +64,7 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
RejectMessagesDecorator{},
NewRejectVestingDecorator(),
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
Expand Down
31 changes: 31 additions & 0 deletions ante/vesting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ante

import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)

// RejectVestingDecorator is responsible for rejecting the vesting msg
type RejectVestingDecorator struct{}

// NewRejectVestingDecorator returns an instance of ValidateVestingDecorator
func NewRejectVestingDecorator() RejectVestingDecorator {
return RejectVestingDecorator{}
}

// AnteHandle checks the transaction
func (vvd RejectVestingDecorator) AnteHandle(ctx sdk.Context,
tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
for _, msg := range tx.GetMsgs() {
switch msg.(type) {
case *vestingtypes.MsgCreateVestingAccount,
*vestingtypes.MsgCreatePermanentLockedAccount,
*vestingtypes.MsgCreatePeriodicVestingAccount:
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest,
"currently doesn't support creating vesting account")
}
}
return next(ctx, tx, simulate)
}
138 changes: 98 additions & 40 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/streaming"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"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/ante"
Expand All @@ -51,24 +52,31 @@ import (
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/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
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"
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"
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-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"

coinswapkeeper "github.com/irisnet/irismod/modules/coinswap/keeper"
coinswaptypes "github.com/irisnet/irismod/modules/coinswap/types"
"github.com/irisnet/irismod/modules/farm"
farmkeeper "github.com/irisnet/irismod/modules/farm/keeper"
farmtypes "github.com/irisnet/irismod/modules/farm/types"
htlckeeper "github.com/irisnet/irismod/modules/htlc/keeper"
Expand Down Expand Up @@ -97,6 +105,7 @@ import (
tibcnfttypes "github.com/bianjieai/tibc-go/modules/tibc/apps/nft_transfer/types"
tibchost "github.com/bianjieai/tibc-go/modules/tibc/core/24-host"
tibcroutingtypes "github.com/bianjieai/tibc-go/modules/tibc/core/26-routing/types"
tibccli "github.com/bianjieai/tibc-go/modules/tibc/core/client/cli"
tibckeeper "github.com/bianjieai/tibc-go/modules/tibc/core/keeper"

"github.com/evmos/ethermint/ethereum/eip712"
Expand All @@ -108,14 +117,19 @@ import (
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"

"github.com/irisnet/irishub/address"
irishubante "github.com/irisnet/irishub/ante"
"github.com/irisnet/irishub/lite"
guardiankeeper "github.com/irisnet/irishub/modules/guardian/keeper"
guardiantypes "github.com/irisnet/irishub/modules/guardian/types"
mintkeeper "github.com/irisnet/irishub/modules/mint/keeper"
minttypes "github.com/irisnet/irishub/modules/mint/types"
iristypes "github.com/irisnet/irishub/types"
nfttransfer "github.com/bianjieai/nft-transfer"
ibcnfttransferkeeper "github.com/bianjieai/nft-transfer/keeper"
ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types"

"github.com/irisnet/irishub/v2/address"
irishubante "github.com/irisnet/irishub/v2/ante"
"github.com/irisnet/irishub/v2/lite"
guardiankeeper "github.com/irisnet/irishub/v2/modules/guardian/keeper"
guardiantypes "github.com/irisnet/irishub/v2/modules/guardian/types"
"github.com/irisnet/irishub/v2/modules/internft"
mintkeeper "github.com/irisnet/irishub/v2/modules/mint/keeper"
minttypes "github.com/irisnet/irishub/v2/modules/mint/types"
iristypes "github.com/irisnet/irishub/v2/types"
)

var (
Expand Down Expand Up @@ -156,8 +170,9 @@ type IrisApp struct {
ConsensusParamsKeeper consensuskeeper.Keeper

//ibc
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCTransferKeeper ibctransferkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCTransferKeeper ibctransferkeeper.Keeper
IBCNFTTransferKeeper ibcnfttransferkeeper.Keeper

// make scoped keepers public for test purposes
scopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -193,9 +208,10 @@ type IrisApp struct {
// simulation manager
sm *module.SimulationManager

transferModule transfer.AppModule
nfttransferModule tibcnfttransfer.AppModule
mttransferModule tibcmttransfer.AppModule
transferModule transfer.AppModule
nfttransferModule tibcnfttransfer.AppModule
mttransferModule tibcmttransfer.AppModule
ibcnfttransferModule nfttransfer.AppModule
}

// NewIrisApp returns a reference to an initialized IrisApp.
Expand All @@ -212,6 +228,9 @@ func NewIrisApp(
legacyAmino := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry

// Setup Mempool
baseAppOptions = append(baseAppOptions, NoOpMempoolOption())

bApp := baseapp.NewBaseApp(
iristypes.AppName,
logger,
Expand All @@ -237,6 +256,7 @@ func NewIrisApp(
consensustypes.StoreKey,
evidencetypes.StoreKey,
ibctransfertypes.StoreKey,
ibcnfttransfertypes.StoreKey,
capabilitytypes.StoreKey,
guardiantypes.StoreKey,
tokentypes.StoreKey,
Expand Down Expand Up @@ -306,6 +326,7 @@ func NewIrisApp(
)
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedNFTTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibcnfttransfertypes.ModuleName)

app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
Expand Down Expand Up @@ -420,7 +441,8 @@ func NewIrisApp(
app.TIBCKeeper = tibckeeper.NewKeeper(
appCodec,
keys[tibchost.StoreKey],
app.GetSubspace(tibchost.ModuleName), app.StakingKeeper,
app.StakingKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.NFTKeeper = nftkeeper.NewKeeper(
Expand Down Expand Up @@ -467,10 +489,25 @@ func NewIrisApp(
app.transferModule = transfer.NewAppModule(app.IBCTransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.IBCTransferKeeper)

app.IBCNFTTransferKeeper = ibcnfttransferkeeper.NewKeeper(
appCodec,
keys[ibcnfttransfertypes.StoreKey],
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
internft.NewInterNftKeeper(appCodec, app.NFTKeeper, app.AccountKeeper),
scopedNFTTransferKeeper,
)
app.ibcnfttransferModule = nfttransfer.NewAppModule(app.IBCNFTTransferKeeper)
nfttransferIBCModule := nfttransfer.NewIBCModule(app.IBCNFTTransferKeeper)

// routerModule := router.NewAppModule(app.RouterKeeper, transferIBCModule)
// create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(ibcnfttransfertypes.ModuleName, nfttransferIBCModule)
app.IBCKeeper.SetRouter(ibcRouter)

app.nfttransferModule = tibcnfttransfer.NewAppModule(app.TIBCNFTTransferKeeper)
Expand Down Expand Up @@ -554,6 +591,18 @@ func NewIrisApp(
app.ServiceKeeper,
)

govConfig := govtypes.DefaultConfig()
app.GovKeeper = govkeeper.NewKeeper(
appCodec,
keys[govtypes.StoreKey],
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.MsgServiceRouter(),
govConfig,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.FarmKeeper = farmkeeper.NewKeeper(appCodec,
keys[farmtypes.StoreKey],
app.BankKeeper,
Expand All @@ -566,22 +615,21 @@ func NewIrisApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

govConfig := govtypes.DefaultConfig()
app.GovKeeper = govkeeper.NewKeeper(
appCodec,
keys[govtypes.StoreKey],
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.MsgServiceRouter(),
govConfig,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
// 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(tibchost.RouterKey, tibccli.NewProposalHandler(app.TIBCKeeper)).
AddRoute(farmtypes.RouterKey, farm.NewCommunityPoolCreateFarmProposalHandler(app.FarmKeeper))

app.GovKeeper.SetHooks(govtypes.NewMultiGovHooks(
farmkeeper.NewGovHook(app.FarmKeeper),
))

app.GovKeeper.SetLegacyRouter(govRouter)

tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))

// Create Ethermint keepers
Expand Down Expand Up @@ -879,27 +927,37 @@ func initParamsKeeper(
) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

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(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable())
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable())
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable())
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable())
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable())
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable())
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(tokentypes.ModuleName)
paramsKeeper.Subspace(tokentypes.ModuleName).WithKeyTable(tokenv1.ParamKeyTable())
paramsKeeper.Subspace(recordtypes.ModuleName)
paramsKeeper.Subspace(htlctypes.ModuleName)
paramsKeeper.Subspace(coinswaptypes.ModuleName)
paramsKeeper.Subspace(servicetypes.ModuleName)
paramsKeeper.Subspace(htlctypes.ModuleName).WithKeyTable(htlctypes.ParamKeyTable())
paramsKeeper.Subspace(coinswaptypes.ModuleName).WithKeyTable(coinswaptypes.ParamKeyTable())
paramsKeeper.Subspace(servicetypes.ModuleName).WithKeyTable(servicetypes.ParamKeyTable())
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(farmtypes.ModuleName)
paramsKeeper.Subspace(farmtypes.ModuleName).WithKeyTable(farmtypes.ParamKeyTable())
paramsKeeper.Subspace(tibchost.ModuleName)

// ethermint subspaces
paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(feemarkettypes.ModuleName)
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable())
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())

return paramsKeeper
}

func NoOpMempoolOption() func(*baseapp.BaseApp) {
return func(app *baseapp.BaseApp) {
memPool := mempool.NoOpMempool{}
app.SetMempool(memPool)
handler := baseapp.NewDefaultProposalHandler(memPool, app)
app.SetPrepareProposal(handler.PrepareProposalHandler())
app.SetProcessProposal(handler.ProcessProposalHandler())
}
}
2 changes: 1 addition & 1 deletion app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/tx"
enccodec "github.com/evmos/ethermint/encoding/codec"

"github.com/irisnet/irishub/app/params"
"github.com/irisnet/irishub/v2/app/params"
)

// MakeEncodingConfig creates an EncodingConfig for testing
Expand Down
2 changes: 1 addition & 1 deletion app/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app

import (
"github.com/irisnet/irishub/types"
"github.com/irisnet/irishub/v2/types"
)

// NewDefaultGenesisState generates the default state for the application.
Expand Down
Loading

0 comments on commit f3778fb

Please sign in to comment.