Skip to content

Commit

Permalink
Merge pull request #1266 from wukongcheng/silei/develop
Browse files Browse the repository at this point in the history
R4R: Sync release0.12 changes to develop
  • Loading branch information
wukongcheng authored Feb 27, 2019
2 parents 1631677 + dbfcefd commit f26feca
Show file tree
Hide file tree
Showing 258 changed files with 2,437 additions and 1,245 deletions.
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Changelog

## 0.12.3

*February 27th, 2019*

- Fix issue of build config for Ledger Nano
- Fix Dockerfile to be compatible with Ledger build
- Improve documents about address prefix/fee/chain-id for the mainnet


## 0.12.2

*February 26th, 2019*

- Fix the document issue


## 0.12.2-rc0

*February 26th, 2019*

- Set max commission rate and max commission change rate to 100%
- Implement coin flow record feature for "internal transactions"
- Support Ledger Nano S and KMS
- Update the default gas_price_threshold to be 6000iris-nano
- No slashing for Censorship or Downtime
- No slashing for non-voting for proposals
- Configure the default build environment as mainnet
- Set the default gas limit to be 50000
- Fix wrong withdraw address
- Fix gas simulate issue
- Display correct validator consensus pubkey
- Improve the documents


## 0.12.1

*February 14th, 2019*

- Fix the bug of repeatability check about evidence in the tendermint
- Change the invariant level for mainnet


## 0.12.0

*February 11th, 2019*
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
FROM golang:1.11.5-alpine3.9 as builder

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

# Set up GOPATH & PATH

Expand Down
41 changes: 25 additions & 16 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
[[override]]
name = "github.com/tendermint/tendermint"
source = "https://github.com/irisnet/tendermint.git"
version = "=v0.27.3-iris6"
version = "=v0.27.3-iris7"

[[constraint]]
name = "github.com/emicklei/proto"
Expand Down Expand Up @@ -83,8 +83,8 @@
revision = "52158e4697b87de16ed390e1bdaf813e581008fa"

[[constraint]]
name = "github.com/zondax/ledger-goclient"
version = "=v0.1.0"
name = "github.com/zondax/ledger-cosmos-go"
version = "=v0.9.7"

## transitive deps, with releases:

Expand Down Expand Up @@ -114,3 +114,6 @@
[prune]
go-tests = true
unused-packages = true
[[prune.project]]
name = "github.com/zondax/hid"
unused-packages = false
56 changes: 43 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,54 @@ PACKAGES_TYPES=$(shell go list ./... | grep 'irisnet/irishub/types')
PACKAGES_STORE=$(shell go list ./... | grep 'irisnet/irishub/store')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')

all: get_tools get_vendor_deps install

all: get_tools get_vendor_deps install build_cur


COMMIT_HASH := $(shell git rev-parse --short HEAD)

InvariantLevel := $(shell if [ -z ${InvariantLevel} ]; then echo "panic"; else echo ${InvariantLevel}; fi)
NetworkType := $(shell if [ -z ${NetworkType} ]; then echo "testnet"; else echo ${NetworkType}; fi)
InvariantLevel := $(shell if [ -z ${InvariantLevel} ]; then echo "error"; else echo ${InvariantLevel}; fi)
NetworkType := $(shell if [ -z ${NetworkType} ]; then echo "mainnet"; else echo ${NetworkType}; fi)

BUILD_TAGS = netgo

BUILD_FLAGS = -ldflags "\
BUILD_FLAGS = -tags "$(BUILD_TAGS)" -ldflags "\
-X github.com/irisnet/irishub/version.GitCommit=${COMMIT_HASH} \
-X github.com/irisnet/irishub/types.InvariantLevel=${InvariantLevel} \
-X github.com/irisnet/irishub/types.NetworkType=${NetworkType}"
LEDGER_ENABLED ?= true

########################################
### Build/Install

ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
BUILD_TAGS += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
BUILD_TAGS += ledger
endif
endif
endif
endif

########################################
### Tools & dependencies

echo_bech32_prefix:
@echo "\"source scripts/setProdEnv.sh\" to set compile environment variables for your product, or default values will be applied"
@echo "If you want to build binaries for testnet, please execute \"source scripts/setTestEnv.sh\" first"
@echo InvariantLevel=${InvariantLevel}
@echo NetworkType=${NetworkType}

Expand Down Expand Up @@ -66,10 +97,10 @@ install: update_irislcd_swagger_docs echo_bech32_prefix
go install $(BUILD_FLAGS) ./cmd/iristool

build_linux: update_irislcd_swagger_docs echo_bech32_prefix
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/iris ./cmd/iris && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/iriscli ./cmd/iriscli && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/irislcd ./cmd/irislcd && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/iristool ./cmd/iristool
GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/iris ./cmd/iris && \
GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/iriscli ./cmd/iriscli && \
GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/irislcd ./cmd/irislcd && \
GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/iristool ./cmd/iristool

build_cur: update_irislcd_swagger_docs echo_bech32_prefix
go build $(BUILD_FLAGS) -o build/iris ./cmd/iris && \
Expand Down Expand Up @@ -118,17 +149,16 @@ test_sim_iris_slow:
@go test ./app -run TestFullIrisSimulation -v -SimulationEnabled=true -SimulationNumBlocks=1000 -SimulationVerbose=true -timeout 24h

testnet_init:
@echo "Work well only when Bech32PrefixAccAddr equal faa"
@if ! [ -f build/iris ]; then $(MAKE) build_linux ; fi
@if ! [ -f build/nodecluster/node0/iris/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/home ubuntu:16.04 /home/iris testnet --v 4 --output-dir /home/nodecluster --chain-id irishub-test --starting-ip-address 192.168.10.2 ; fi
@echo "To install jq command, please refer to this page: https://stedolan.github.io/jq/download/"
@jq '.app_state.accounts+= [{"address": "faa1ljemm0yznz58qxxs8xyak7fashcfxf5lssn6jm", "coins": [ "1000000iris" ], "sequence_number": "0", "account_number": "0"}]' build/nodecluster/node0/iris/config/genesis.json > build/genesis_temp.json
@if [ ${NetworkType} = "testnet" ]; then jq '.app_state.accounts+= [{"address": "faa1ljemm0yznz58qxxs8xyak7fashcfxf5lssn6jm", "coins": [ "1000000iris" ], "sequence_number": "0", "account_number": "0"}]' build/nodecluster/node0/iris/config/genesis.json > build/genesis_temp.json ; else jq '.app_state.accounts+= [{"address": "iaa1ljemm0yznz58qxxs8xyak7fashcfxf5lgl4zjx", "coins": [ "1000000iris" ], "sequence_number": "0", "account_number": "0"}]' build/nodecluster/node0/iris/config/genesis.json > build/genesis_temp.json ; fi
@sudo cp build/genesis_temp.json build/nodecluster/node0/iris/config/genesis.json
@sudo cp build/genesis_temp.json build/nodecluster/node1/iris/config/genesis.json
@sudo cp build/genesis_temp.json build/nodecluster/node2/iris/config/genesis.json
@sudo cp build/genesis_temp.json build/nodecluster/node3/iris/config/genesis.json
@rm build/genesis_temp.json
@echo "Faucet address: faa1ljemm0yznz58qxxs8xyak7fashcfxf5lssn6jm"
@if [ ${NetworkType} = "testnet" ]; then echo "Faucet address: faa1ljemm0yznz58qxxs8xyak7fashcfxf5lssn6jm" ; else echo "Faucet address: iaa1ljemm0yznz58qxxs8xyak7fashcfxf5lgl4zjx" ; fi
@echo "Faucet coin amount: 1000000iris"
@echo "Faucet key seed: tube lonely pause spring gym veteran know want grid tired taxi such same mesh charge orient bracket ozone concert once good quick dry boss"

Expand All @@ -147,4 +177,4 @@ testnet_unsafe_reset:
@docker run --rm -v $(CURDIR)/build:/home ubuntu:16.04 /home/iris unsafe-reset-all --home=/home/nodecluster/node0/iris
@docker run --rm -v $(CURDIR)/build:/home ubuntu:16.04 /home/iris unsafe-reset-all --home=/home/nodecluster/node1/iris
@docker run --rm -v $(CURDIR)/build:/home ubuntu:16.04 /home/iris unsafe-reset-all --home=/home/nodecluster/node2/iris
@docker run --rm -v $(CURDIR)/build:/home ubuntu:16.04 /home/iris unsafe-reset-all --home=/home/nodecluster/node3/iris
@docker run --rm -v $(CURDIR)/build:/home ubuntu:16.04 /home/iris unsafe-reset-all --home=/home/nodecluster/node3/iris
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewIrisApp(logger log.Logger, db dbm.DB, config *cfg.InstrumentationConfig,
appPrometheusConfig := *config
//Change namespace to appName
appPrometheusConfig.Namespace = appPrometheusNamespace
engine.Add(v0.NewProtocolV0(0, logger, protocolKeeper, app.checkInvariant, &appPrometheusConfig))
engine.Add(v0.NewProtocolV0(0, logger, protocolKeeper, app.checkInvariant, app.trackCoinFlow, &appPrometheusConfig))
// engine.Add(v1.NewProtocolV1(1, ...))
// engine.Add(v2.NewProtocolV1(2, ...))

Expand Down
18 changes: 15 additions & 3 deletions app/baseapp.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"encoding/hex"
"fmt"
"io"
"runtime/debug"
Expand Down Expand Up @@ -73,6 +74,9 @@ type BaseApp struct {
// enable invariant check
checkInvariant bool

// enable track coin flow
trackCoinFlow bool

// flag for sealing
sealed bool
}
Expand Down Expand Up @@ -210,6 +214,9 @@ func (app *BaseApp) SetMinimumFees(fees sdk.Coins) { app.minimumFees = fees }
// SetInvariantCheck sets the invariant check config.
func (app *BaseApp) SetCheckInvariant(check bool) { app.checkInvariant = check }

// SetTrackCoinFlow sets the config about track coin flow
func (app *BaseApp) SetTrackCoinFlow(enable bool) { app.trackCoinFlow = enable }

// NewContext returns a new Context with the correct store, the given header, and nil txBytes.
func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context {
if isCheckTx {
Expand Down Expand Up @@ -381,7 +388,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) (res abc
if err != nil {
result = err.Result()
} else {
result = app.Simulate(tx)
result = app.Simulate(tx, txBytes)
}
case "version":
return abci.ResponseQuery{
Expand Down Expand Up @@ -499,7 +506,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
gasMeter = sdk.NewInfiniteGasMeter()
}
app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(gasMeter).
WithLogger(app.deliverState.ctx.Logger().With("height", app.deliverState.ctx.BlockHeight()))
WithLogger(app.deliverState.ctx.Logger().With("height", app.deliverState.ctx.BlockHeight())).WithCoinFlowTags(sdk.NewCoinFlowRecord(app.trackCoinFlow))

beginBlocker := app.Engine.GetCurrentProtocol().GetBeginBlocker()

Expand Down Expand Up @@ -588,10 +595,12 @@ func validateBasicTxMsgs(msgs []sdk.Msg) sdk.Error {

// retrieve the context for the tx w/ txBytes and other memoized values.
func (app *BaseApp) getContextForTx(mode RunTxMode, txBytes []byte) (ctx sdk.Context) {
txHash := hex.EncodeToString(tmhash.Sum(txBytes))
ctx = app.getState(mode).ctx.
WithTxBytes(txBytes).
WithVoteInfos(app.voteInfos).
WithConsensusParams(app.consensusParams)
WithConsensusParams(app.consensusParams).
WithCoinFlowTrigger(txHash)
if mode == RunTxModeSimulate {
ctx, _ = ctx.CacheContext()
}
Expand Down Expand Up @@ -826,6 +835,9 @@ func (app *BaseApp) runTx(mode RunTxMode, txBytes []byte, tx sdk.Tx) (result sdk
// only update state if all messages pass
if result.IsOK() {
msCache.Write()
ctx.CoinFlowTags().TagWrite()
} else {
ctx.CoinFlowTags().TagClean()
}

return
Expand Down
12 changes: 6 additions & 6 deletions app/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
)

// nolint - Mostly for testing
func (app *BaseApp) Check(tx sdk.Tx) (result sdk.Result) {
return app.runTx(RunTxModeCheck, nil, tx)
func (app *BaseApp) Check(tx sdk.Tx, txBytes []byte) (result sdk.Result) {
return app.runTx(RunTxModeCheck, txBytes, tx)
}

// nolint - full tx execution
func (app *BaseApp) Simulate(tx sdk.Tx) (result sdk.Result) {
return app.runTx(RunTxModeSimulate, nil, tx)
func (app *BaseApp) Simulate(tx sdk.Tx, txBytes []byte) (result sdk.Result) {
return app.runTx(RunTxModeSimulate, txBytes, tx)
}

// nolint
func (app *BaseApp) Deliver(tx sdk.Tx) (result sdk.Result) {
return app.runTx(RunTxModeDeliver, nil, tx)
func (app *BaseApp) Deliver(tx sdk.Tx, txBytes []byte) (result sdk.Result) {
return app.runTx(RunTxModeDeliver, txBytes, tx)
}

// RunForever - BasecoinApp execution and cleanup
Expand Down
5 changes: 5 additions & 0 deletions app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func SetCheckInvariant(check bool) func(*BaseApp) {
return func(bap *BaseApp) { bap.SetCheckInvariant(check) }
}

// SetTrackCoinFlow sets the config about track coin flow
func SetTrackCoinFlow(enable bool) func(*BaseApp) {
return func(bap *BaseApp) { bap.SetTrackCoinFlow(enable) }
}

// nolint - Setter functions
func (app *BaseApp) SetName(name string) {
if app.sealed {
Expand Down
Loading

0 comments on commit f26feca

Please sign in to comment.