Skip to content

Commit

Permalink
Merge branch 'release/v2.1.x' of https://github.com/irisnet/irishub i…
Browse files Browse the repository at this point in the history
…nto dreamer/master
  • Loading branch information
dreamer committed Nov 15, 2023
2 parents 96eb290 + 9a9f974 commit 85109b8
Show file tree
Hide file tree
Showing 163 changed files with 4,757 additions and 6,141 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
53 changes: 40 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
NetworkType := $(shell if [ -z ${NetworkType} ]; then echo "mainnet"; else echo ${NetworkType}; fi)
CURRENT_DIR = $(shell pwd)
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
DOCKER := $(shell which docker)

# default mainnet EVM_CHAIN_ID
EVM_CHAIN_ID ?= 6688
Expand Down Expand Up @@ -59,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 @@ -141,21 +142,25 @@ distclean: clean
### Protobuf ###
###############################################################################

protoVer=v0.7
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer)
containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer)
containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer)
containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer)
proto-all: proto-tools proto-gen proto-swagger-gen
protoVer=0.13.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-all: proto-format proto-lint proto-gen

proto-gen:
@./scripts/protocgen.sh
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protoc-swagger-gen.sh; fi
@$(protoImage) sh ./scripts/protoc-swagger-gen.sh

proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(protoImage) buf lint --error-format=json

########################################
### Testing
Expand Down Expand Up @@ -194,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 Expand Up @@ -224,4 +229,26 @@ testnet-stop:

testnet-clean:
docker-compose down
sudo rm -rf build/*
sudo rm -rf build/*


########################################
### Test ibc nft-transfer
init-golang-rly: kill-dev install
@echo "Initializing both blockchains..."
./network/init.sh
./network/start.sh
@echo "Initializing relayer..."
./network/relayer/interchain-nft-config/rly.sh

start:
@echo "Starting up test network"
./network/start.sh

start-rly:
./network/hermes/start.sh

kill-dev:
@echo "Killing nftd and removing previous data"
-@rm -rf ./data
-@killall nftd 2>/dev/null
16 changes: 13 additions & 3 deletions ante/decorators.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"

coinswaptypes "github.com/irisnet/irismod/modules/coinswap/types"
servicetypes "github.com/irisnet/irismod/modules/service/types"
Expand All @@ -28,7 +28,12 @@ func NewValidateTokenDecorator(tk tokenkeeper.Keeper) ValidateTokenDecorator {
}

// AnteHandle checks the transaction
func (vtd ValidateTokenDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
func (vtd ValidateTokenDecorator) AnteHandle(
ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) (sdk.Context, error) {
for _, msg := range tx.GetMsgs() {
switch msg := msg.(type) {
case *ibctransfertypes.MsgTransfer:
Expand Down Expand Up @@ -65,7 +70,12 @@ func NewValidateServiceDecorator() ValidateServiceDecorator {
}

// AnteHandle checks the transaction
func (vsd ValidateServiceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
func (vsd ValidateServiceDecorator) AnteHandle(
ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) (sdk.Context, error) {
for _, msg := range tx.GetMsgs() {
switch msg := msg.(type) {
case *servicetypes.MsgCallService:
Expand Down
46 changes: 35 additions & 11 deletions ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

ibcante "github.com/cosmos/ibc-go/v5/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v5/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

ethante "github.com/evmos/ethermint/app/ante"

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 All @@ -36,9 +36,16 @@ type HandlerOptions struct {
// newCosmosAnteHandler creates the default ante handler for Ethereum transactions
func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.NewEthSetUpContextDecorator(options.EvmKeeper), // outermost AnteDecorator. SetUpContext must be called first
ethante.NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against the node's minimal-gas-prices config
ethante.NewEthMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), // Check eth effective gas price against the global MinGasPrice
ethante.NewEthSetUpContextDecorator(
options.EvmKeeper,
), // outermost AnteDecorator. SetUpContext must be called first
ethante.NewEthMempoolFeeDecorator(
options.EvmKeeper,
), // Check eth effective gas price against the node's minimal-gas-prices config
ethante.NewEthMinGasPriceDecorator(
options.FeeMarketKeeper,
options.EvmKeeper,
), // Check eth effective gas price against the global MinGasPrice
ethante.NewEthValidateBasicDecorator(options.EvmKeeper),
ethante.NewEthSigVerificationDecorator(options.EvmKeeper),
ethante.NewEthAccountVerificationDecorator(options.AccountKeeper, options.EvmKeeper),
Expand All @@ -47,7 +54,9 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
ethante.NewEthGasConsumeDecorator(options.EvmKeeper, options.MaxTxGasWanted),
ethante.NewEthIncrementSenderSequenceDecorator(options.AccountKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
ethante.NewEthEmitEventDecorator(options.EvmKeeper), // emit eth tx hash and index at the very last ante handler.
ethante.NewEthEmitEventDecorator(
options.EvmKeeper,
), // emit eth tx hash and index at the very last ante handler.
)
}

Expand All @@ -61,8 +70,15 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewDeductFeeDecorator(
options.AccountKeeper,
options.BankKeeper,
options.FeegrantKeeper,
options.TxFeeChecker,
),
ante.NewSetPubKeyDecorator(
options.AccountKeeper,
), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, DefaultSigVerificationGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
Expand All @@ -85,13 +101,21 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
ethante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
ante.NewDeductFeeDecorator(
options.AccountKeeper,
options.BankKeeper,
options.FeegrantKeeper,
options.TxFeeChecker,
),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
// Note: signature verification uses EIP instead of the cosmos signature validator
ethante.NewLegacyEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ethante.NewLegacyEip712SigVerificationDecorator(
options.AccountKeeper,
options.SignModeHandler,
),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
Expand Down
15 changes: 13 additions & 2 deletions ante/reject_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,33 @@ import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
)

// RejectMessagesDecorator prevents invalid msg types from being executed
type RejectMessagesDecorator struct{}

// AnteHandle rejects messages that requires ethereum-specific authentication.
// AnteHandle rejects the following messages:
// 1. Messages that requires ethereum-specific authentication.
// For example `MsgEthereumTx` requires fee to be deducted in the antehandler in
// order to perform the refund.
// 2. Messages that creates vesting accounts.
func (rmd RejectMessagesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
for _, msg := range tx.GetMsgs() {
if _, ok := msg.(*evmtypes.MsgEthereumTx); ok {
switch msg.(type) {
case *evmtypes.MsgEthereumTx:
return ctx, errorsmod.Wrapf(
errortypes.ErrInvalidType,
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
)

case *vestingtypes.MsgCreateVestingAccount,
*vestingtypes.MsgCreatePermanentLockedAccount,
*vestingtypes.MsgCreatePeriodicVestingAccount:
return ctx, errortypes.Wrap(
errortypes.ErrInvalidType,
"currently doesn't support creating vesting account")
}
}
return next(ctx, tx, simulate)
Expand Down
Loading

0 comments on commit 85109b8

Please sign in to comment.