Skip to content

Commit

Permalink
update documents
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyelong committed Apr 17, 2023
2 parents e4d43ba + 12866e7 commit 805baec
Show file tree
Hide file tree
Showing 74 changed files with 58,627 additions and 48,279 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/BuildAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build-images:
name: Build Images
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v1
Expand Down Expand Up @@ -52,7 +52,6 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
platforms: linux/amd64,linux/arm64

# - name: Build irishub image
# run: source ~/.bashrc; sudo docker build -t irisnet/irishub:latest .
# - name: Login dockerhub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/TestUnit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
test-unit:
name: Test Units
# runs-on: self-hosted
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
uploadAssets:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v1
Expand Down
33 changes: 31 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
# Changelog

## Unreleased
## 2.0.0

### State Machine Breaking

* (IRISHub) [\#2831](https://github.com/irisnet/irishub/pull/2831) Bump up tibc-go version to v0.4.3
* (IRISHub) [\#2831](https://github.com/irisnet/irishub/pull/2831) Bump up irismod version to v1.7.3
* (IRISHub) [\#2766](https://github.com/irisnet/irishub/pull/2766) Bump up cosmos sdk to v0.46.9
* (IRISHub) [\#2822]( https://github.com/irisnet/irishub/pull/2822) Remove ICA module

### Features

* (IRISHub) [\#2776](https://github.com/irisnet/irishub/pull/2776) Feat: support evm

### Improvements

* (IRISHub) [\#2824](https://github.com/irisnet/irishub/pull/2824) Feat: update swagger docs & evm configuration
* (IRISMod) [irismod \#340](https://github.com/irisnet/irismod/pull/340) The token module supports the exchange of two tokens.
* (IRISMod) [irismod \#342](https://github.com/irisnet/irismod/pull/342) Refactor token module.
* (IRISMod) [irismod \#348](https://github.com/irisnet/irismod/pull/348) Adjust the length limit of classID and nftID in nft.

### Bug Fixes

* (IRISHub) [\#2828](https://github.com/irisnet/irishub/pull/2828) Fix solve proposal handler route conflict
* (IRISHub) [\#2827](https://github.com/irisnet/irishub/pull/2827) Fix add ibc client proposal for command
* (IRISHub) [\#2794](https://github.com/irisnet/irishub/pull/2794) Fix auth bech32 account prefix
* (IRISMod) [irismod \#336](https://github.com/irisnet/irismod/pull/336) Fix farm genesis validate failed.
* (IRISMod) [irismod \#327](https://github.com/irisnet/irismod/pull/327) Only export htlc with state=open.
* (IRISMod) [irismod \#347](https://github.com/irisnet/irismod/pull/347) Fix service refund address parse error.
* (IRISMod) [irismod \#350](https://github.com/irisnet/irismod/pull/350) Fix address parse errors caused by service rest api conflicts.

## 1.4.1

*November 28, 2022*
Expand All @@ -20,7 +49,7 @@
* [\#2759](https://github.com/irisnet/irishub/pull/2759) Fix export error when with flag `--for-zero-height`
* [\#2766](https://github.com/irisnet/irishub/pull/2766) Bump up cosmos sdk to v0.46.4
* [\#2768](https://github.com/irisnet/irishub/pull/2768) Bump up ibc-go to v5.0.1
* [\#2770](https://github.com/irisnet/irishub/pull/2770) Bump up irismod to v1.7.0 & Bump up tibc-go to v0.4.0
* [\#2770](https://github.com/irisnet/irishub/pull/2770) Bump up irismod to v1.7.0 & Bump up tibc-go to v0.4.0
* [irismod \#309](https://github.com/irisnet/irismod/pull/309) Refactor nft with cosmos-sdk nft module.
* [irismod \#308](https://github.com/irisnet/irismod/pull/308) Coinswap module adds unilateral injection liquidity function.

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

ARG EVM_CHAIN_ID

# Set up dependencies
ENV PACKAGES make gcc git libc-dev bash linux-headers eudev-dev

Expand All @@ -14,7 +16,7 @@ COPY . .
# Install minimum necessary dependencies
RUN apk add --no-cache $PACKAGES

RUN make build
RUN EVM_CHAIN_ID=$EVM_CHAIN_ID make build

# ----------------------------

Expand Down
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ NetworkType := $(shell if [ -z ${NetworkType} ]; then echo "mainnet"; else echo
CURRENT_DIR = $(shell pwd)
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)

# default mainnet EVM_CHAIN_ID
EVM_CHAIN_ID ?= 6688

export GO111MODULE = on

# process build tags
Expand Down Expand Up @@ -56,6 +59,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/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

ifeq ($(WITH_CLEVELDB),yes)
Expand All @@ -73,17 +77,17 @@ all: tools install lint
# The below include contains the tools.
include contrib/devtools/Makefile

build: go.sum
build: check-evm-chain-id go.sum
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/iris.exe ./cmd/iris
@go build $(BUILD_FLAGS) -o build/iris.exe ./cmd/iris
else
go build $(BUILD_FLAGS) -o build/iris ./cmd/iris
@go build $(BUILD_FLAGS) -o build/iris ./cmd/iris
endif

build-linux: go.sum
build-linux: check-evm-chain-id go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

build-all-binary: go.sum
build-all-binary: check-evm-chain-id go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) CGO_ENABLED=1 -o build/iris-linux-amd64 ./cmd/iris
LEDGER_ENABLED=false GOOS=linux GOARCH=arm64 go build $(BUILD_FLAGS) CGO_ENABLED=1 -o build/iris-linux-arm64 ./cmd/iris
LEDGER_ENABLED=false GOOS=windows GOARCH=amd64 go build $(BUILD_FLAGS) CGO_ENABLED=1 -o build/iris-windows-amd64.exe ./cmd/iris
Expand All @@ -95,8 +99,11 @@ else
go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests
endif

install: go.sum
go install $(BUILD_FLAGS) ./cmd/iris
install: check-evm-chain-id go.sum
@go install $(BUILD_FLAGS) ./cmd/iris

check-evm-chain-id:
@echo "note: EVM_CHAIN_ID is $(EVM_CHAIN_ID)"

update-swagger-docs: statik proto-swagger-gen
$(BINDIR)/statik -src=lite/swagger-ui -dest=lite -f -m
Expand Down
88 changes: 46 additions & 42 deletions ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
package app
package ante

import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"

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

oraclekeeper "github.com/irisnet/irismod/modules/oracle/keeper"
tokenkeeper "github.com/irisnet/irismod/modules/token/keeper"
ethante "github.com/evmos/ethermint/app/ante"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions
BankKeeper bankkeeper.Keeper
TokenKeeper tokenkeeper.Keeper
OracleKeeper oraclekeeper.Keeper
GuardianKeeper guardiankeeper.Keeper
BypassMinFeeMsgTypes []string
}
// NewAnteHandler returns an ante handler responsible for attempting to route an
// Ethereum or SDK transaction to an internal ante handler for performing
// transaction-level processing (e.g. fee payment, signature verification) before
// being passed onto it's respective handler.
func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
return func(
ctx sdk.Context, tx sdk.Tx, sim bool,
) (newCtx sdk.Context, err error) {
var anteHandler sdk.AnteHandler

defer ethante.Recover(ctx.Logger(), &err)

txWithExtensions, ok := tx.(authante.HasExtensionOptionsTx)
if ok {
opts := txWithExtensions.GetExtensionOptions()
if len(opts) > 0 {
switch typeURL := opts[0].GetTypeUrl(); typeURL {
case "/ethermint.evm.v1.ExtensionOptionsEthereumTx":
// handle as *evmtypes.MsgEthereumTx
anteHandler = newEthAnteHandler(options)
case "/ethermint.types.v1.ExtensionOptionsWeb3Tx":
// handle as normal Cosmos SDK tx, except signature is checked for EIP712 representation
anteHandler = newCosmosAnteHandlerEip712(options)
default:
return ctx, errorsmod.Wrapf(
errortypes.ErrUnknownExtensionOptions,
"rejecting tx with unsupported extension option: %s", typeURL,
)
}
return anteHandler(ctx, tx, sim)
}
}

// handle as totally normal Cosmos SDK tx
switch tx.(type) {
case sdk.Tx:
anteHandler = newCosmosAnteHandler(options)
default:
return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid transaction type: %T", tx)
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
// numbers, checks signatures & account numbers, and deducts fees from the first
// signer.
func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
var sigGasConsumer = opts.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
return anteHandler(ctx, tx, sim)
}
return sdk.ChainAnteDecorators(
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewExtensionOptionsDecorator(opts.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(opts.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper, opts.TxFeeChecker),
ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(opts.AccountKeeper),
ante.NewSigGasConsumeDecorator(opts.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(opts.AccountKeeper, opts.SignModeHandler),
NewValidateTokenDecorator(opts.TokenKeeper),
tokenkeeper.NewValidateTokenFeeDecorator(opts.TokenKeeper, opts.BankKeeper),
oraclekeeper.NewValidateOracleAuthDecorator(opts.OracleKeeper, opts.GuardianKeeper),
NewValidateServiceDecorator(),
ante.NewIncrementSequenceDecorator(opts.AccountKeeper),
), nil
}
11 changes: 8 additions & 3 deletions ante/decorators.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app
package ante

import (
"strings"
Expand All @@ -11,7 +11,8 @@ import (
coinswaptypes "github.com/irisnet/irismod/modules/coinswap/types"
servicetypes "github.com/irisnet/irismod/modules/service/types"
tokenkeeper "github.com/irisnet/irismod/modules/token/keeper"
tokentypes "github.com/irisnet/irismod/modules/token/types"
tokentypesv1 "github.com/irisnet/irismod/modules/token/types/v1"
tokentypesv1beta1 "github.com/irisnet/irismod/modules/token/types/v1beta1"
)

// ValidateTokenDecorator is responsible for restricting the token participation of the swap prefix
Expand All @@ -34,7 +35,11 @@ func (vtd ValidateTokenDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
if containSwapCoin(msg.Token) {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "can't transfer coinswap liquidity tokens through the IBC module")
}
case *tokentypes.MsgBurnToken:
case *tokentypesv1.MsgBurnToken:
if _, err := vtd.tk.GetToken(ctx, msg.Coin.Denom); err != nil {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "burnt failed, only native tokens can be burnt")
}
case *tokentypesv1beta1.MsgBurnToken:
if _, err := vtd.tk.GetToken(ctx, msg.Symbol); err != nil {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "burnt failed, only native tokens can be burnt")
}
Expand Down
99 changes: 99 additions & 0 deletions ante/handler_options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package ante

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
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"

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"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions
BankKeeper bankkeeper.Keeper
AccountKeeper authkeeper.AccountKeeper
IBCKeeper *ibckeeper.Keeper
TokenKeeper tokenkeeper.Keeper
OracleKeeper oraclekeeper.Keeper
GuardianKeeper guardiankeeper.Keeper
EvmKeeper ethante.EVMKeeper
FeeMarketKeeper ethante.FeeMarketKeeper
BypassMinFeeMsgTypes []string
MaxTxGasWanted uint64
}

// 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.NewEthValidateBasicDecorator(options.EvmKeeper),
ethante.NewEthSigVerificationDecorator(options.EvmKeeper),
ethante.NewEthAccountVerificationDecorator(options.AccountKeeper, options.EvmKeeper),
ethante.NewEthFeeGrantValidator(options.EvmKeeper, options.FeegrantKeeper),
ethante.NewCanTransferDecorator(options.EvmKeeper),
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.
)
}

// newCosmosAnteHandler creates the default ante handler for Cosmos transactions
func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
RejectMessagesDecorator{},
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
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.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, DefaultSigVerificationGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
NewValidateTokenDecorator(options.TokenKeeper),
tokenkeeper.NewValidateTokenFeeDecorator(options.TokenKeeper, options.BankKeeper),
oraclekeeper.NewValidateOracleAuthDecorator(options.OracleKeeper, options.GuardianKeeper),
NewValidateServiceDecorator(),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
)
}

// newCosmosAnteHandlerEip712 creates the ante handler for transactions signed with EIP712
func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.RejectMessagesDecorator{}, // reject MsgEthereumTxs
ante.NewSetUpContextDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ethante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
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),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
)
}
Loading

0 comments on commit 805baec

Please sign in to comment.