Skip to content

Commit

Permalink
Merge pull request #557 from binance-chain/release/v0.5.6
Browse files Browse the repository at this point in the history
prepare for releasing v0.5.6
  • Loading branch information
rickyyangz authored Apr 12, 2019
2 parents 9d82687 + 4ffc293 commit f93ee14
Show file tree
Hide file tree
Showing 36 changed files with 381 additions and 212 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
# Changelog

## 0.5.4
## 0.5.5

IMPROVEMENTS

* [\#518](https://github.com/binance-chain/node/pull/518) [Gov] Adapt to changes in cosmos
* [\#521](https://github.com/binance-chain/node/pull/521) [List] Add check for list proposal hook.
* [\#517](https://github.com/binance-chain/node/pull/517) [Validator] Split fee address and operator address
* [\#516](https://github.com/binance-chain/node/pull/516) [Publish] IocNoFill semantic correct
* [\#514](https://github.com/binance-chain/node/pull/514) [Upgrade] Support config for upgrade height
* [\#509](https://github.com/binance-chain/node/pull/509) [MatchEngine] Make the lot size reasonable for low price
* [\#498](https://github.com/binance-chain/node/pull/498) [MatchEngine] Rename price of TradingPair to list_price
* [\#497](https://github.com/binance-chain/node/pull/497) [Build] Support `build-windows`
* [\#496](https://github.com/binance-chain/node/pull/476) [StateSync] Cache latest snapshot in memory
* [\#526](https://github.com/binance-chain/node/pull/518) [ApiServer] Add gov queries in api server


BUG FIXES

* [\#508](https://github.com/binance-chain/node/pull/508) [\#511](https://github.com/binance-chain/node/pull/511) [\#501](https://github.com/binance-chain/node/pull/501) [Dex] Fix all potential int64 overflows, remove all use of float64, and optimize some calculation
* [\#478](https://github.com/binance-chain/node/pull/478) [Publish] Dump order ids for large expire message.

## 0.5.4

IMPROVEMENTS

BUG FIXES

Expand Down
14 changes: 8 additions & 6 deletions Gopkg.lock

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

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
[[override]]
name = "github.com/tendermint/tendermint"
source = "github.com/binance-chain/bnc-tendermint"
version = "=v0.30.1-binance.2"
version = "=v0.30.1-binance.4"

[[constraint]]
name = "github.com/cosmos/cosmos-sdk"
source = "github.com/binance-chain/bnc-cosmos-sdk"
version = "=v0.25.0-binance.15"
version = "=v0.25.0-binance.16"

[[constraint]]
name = "github.com/btcsuite/btcd"
Expand Down Expand Up @@ -87,4 +87,4 @@

[[constraint]]
name = "github.com/natefinch/lumberjack"
version = "2.1.0"
version = "2.1.0"
16 changes: 11 additions & 5 deletions admin/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func GetHandler(config *config.Config) types.AbciQueryHandler {
}
res := abci.ResponseQuery{
Code: uint32(sdk.ABCICodeOK),
Value: []byte{uint8(runtime.RunningMode)},
Value: []byte{uint8(runtime.GetRunningMode())},
}
return &res
}
Expand All @@ -47,20 +47,26 @@ func GetHandler(config *config.Config) types.AbciQueryHandler {
return &res
}

var runningMode runtime.Mode
if mode == "0" {
runtime.RunningMode = runtime.NormalMode
runningMode = runtime.NormalMode
} else if mode == "1" {
runtime.RunningMode = runtime.TransferOnlyMode
runningMode = runtime.TransferOnlyMode
} else if mode == "2" {
runtime.RunningMode = runtime.RecoverOnlyMode
runningMode = runtime.RecoverOnlyMode
} else {
res := sdk.ErrUnknownRequest("invalid mode").QueryResult()
return &res
}
err = runtime.UpdateRunningMode(config, runningMode)
if err != nil {
res := sdk.ErrUnknownRequest(err.Error()).QueryResult()
return &res
}

res := abci.ResponseQuery{
Code: uint32(sdk.ABCICodeOK),
Value: []byte{uint8(runtime.RunningMode)},
Value: []byte{uint8(runtime.GetRunningMode())},
}
return &res
}
Expand Down
11 changes: 6 additions & 5 deletions admin/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ var TxBlackList = map[runtime.Mode][]string{
}

func TxNotAllowedError() sdk.Error {
return sdk.ErrInternal(fmt.Sprintf("The tx is not allowed, RunningMode: %v", runtime.RunningMode))
return sdk.ErrInternal(fmt.Sprintf("The tx is not allowed, RunningMode: %v", runtime.GetRunningMode()))
}

func IsTxAllowed(tx sdk.Tx) bool {
if runtime.RunningMode == runtime.NormalMode {
mode := runtime.GetRunningMode()
if mode == runtime.NormalMode {
return true
}

for _, msg := range tx.GetMsgs() {
if !isMsgAllowed(msg) {
if !isMsgAllowed(msg, mode) {
return false
}
}
return true
}

func isMsgAllowed(msg sdk.Msg) bool {
for _, msgType := range TxBlackList[runtime.RunningMode] {
func isMsgAllowed(msg sdk.Msg, mode runtime.Mode) bool {
for _, msgType := range TxBlackList[mode] {
if msgType == msg.Type() {
return false
}
Expand Down
58 changes: 33 additions & 25 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ type BinanceChain struct {

// NewBinanceChain creates a new instance of the BinanceChain.
func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptions ...func(*baseapp.BaseApp)) *BinanceChain {
// set running mode from cmd parameter or config
err := runtime.SetRunningMode(runtime.Mode(ServerContext.StartMode))
if err != nil {
cmn.Exit(err.Error())
}
// create app-level codec for txs and accounts
var cdc = Codec
// create composed tx decoder
Expand All @@ -122,7 +117,10 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp
upgradeConfig: ServerContext.UpgradeConfig,
publicationConfig: ServerContext.PublicationConfig,
}
// set upgrade config
app.setUpgradeConfig()
app.SetPruning(viper.GetString("pruning"))
app.initRunningMode()
app.SetCommitMultiStoreTracer(traceStore)

// mappers
Expand All @@ -135,7 +133,7 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp
app.stakeKeeper = stake.NewKeeper(
cdc,
common.StakeStoreKey, common.TStakeStoreKey,
app.CoinKeeper, app.ParamHub.Subspace(stake.DefaultParamspace),
app.CoinKeeper, app.Pool, app.ParamHub.Subspace(stake.DefaultParamspace),
app.RegisterCodespace(stake.DefaultCodespace),
)
app.ValAddrCache = NewValAddrCache(app.stakeKeeper)
Expand Down Expand Up @@ -196,6 +194,7 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp

// finish app initialization
app.SetInitChainer(app.initChainerFn())
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.MountStoresIAVL(
common.MainStoreKey,
Expand All @@ -213,7 +212,7 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp
app.MountStoresTransient(common.TParamsStoreKey, common.TStakeStoreKey)

// block store required to hydrate dex OB
err = app.LoadCMSLatestVersion()
err := app.LoadCMSLatestVersion()
if err != nil {
cmn.Exit(err.Error())
}
Expand All @@ -228,10 +227,7 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp
if err != nil {
cmn.Exit(err.Error())
}

// set upgrade config
app.setUpgradeConfig()


// remaining plugin init
app.initDex(tradingPairMapper)
app.initPlugins()
Expand All @@ -242,8 +238,14 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp

// setUpgradeConfig will overwrite default upgrade config
func (app *BinanceChain) setUpgradeConfig() {
upgrade.Mgr.AddUpgradeHeight(upgrade.FixOrderSeqInPriceLevelName, app.upgradeConfig.FixOrderSeqInPriceLevelHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.FixDropFilledOrderSeqName, app.upgradeConfig.FixDropFilledOrderSeqHeight)
// upgrade.Mgr.AddUpgradeHeight(,)
}

func (app *BinanceChain) initRunningMode() {
err := runtime.RecoverFromFile(ServerContext.Config.RootDir, runtime.Mode(ServerContext.StartMode))
if err != nil {
cmn.Exit(err.Error())
}
}

func (app *BinanceChain) initDex(pairMapper dex.TradingPairMapper) {
Expand Down Expand Up @@ -433,6 +435,11 @@ func (app *BinanceChain) isBreatheBlock(height int64, lastBlockTime time.Time, b
}
}

func (app *BinanceChain) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) (res abci.ResponseBeginBlock) {
upgrade.Mgr.BeginBlocker(ctx)
return
}

func (app *BinanceChain) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
// lastBlockTime would be 0 if this is the first block.
lastBlockTime := app.CheckState.Ctx.BlockHeader().Time
Expand Down Expand Up @@ -473,27 +480,27 @@ func (app *BinanceChain) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) a
proposals = pub.CollectProposalsForPublish(passed, failed)
}

var completedUbd []stake.UnbondingDelegation
var validatorUpdates abci.ValidatorUpdates
if isBreatheBlock || ctx.RouterCallRecord()["stake"] {
// some endblockers without fees will execute after publish to make publication run as early as possible.
validatorUpdates, completedUbd = stake.EndBlocker(ctx, app.stakeKeeper)
app.ValAddrCache.ClearCache()
}

if app.publicationConfig.ShouldPublishAny() &&
pub.IsLive {
var stakeUpdates pub.StakeUpdates
stakeUpdates = pub.CollectStakeUpdatesForPublish(completedUbd)
if height >= app.publicationConfig.FromHeightInclusive {
app.publish(tradesToPublish, &proposals, blockFee, ctx, height, blockTime.UnixNano())
app.publish(tradesToPublish, &proposals, &stakeUpdates, blockFee, ctx, height, blockTime.UnixNano())
}

// clean up intermediate cached data
app.DexKeeper.ClearOrderChanges()
app.DexKeeper.ClearRoundFee()
}

var validatorUpdates abci.ValidatorUpdates
// TODO: confirm with zz height == 1 is only to keep consistent with testnet (Binance Chain Commit: d1f295b; Cosmos Release: =v0.25.0-binance.5; Tendermint Release: =v0.29.1-binance.2;),
// otherwise, apphash fail
// I think we don't need it after next reset because at height = 1 validatorUpdates is nil
if isBreatheBlock || height == 1 || ctx.RouterCallRecord()["stake"] {
// some endblockers without fees will execute after publish to make publication run as early as possible.
validatorUpdates = stake.EndBlocker(ctx, app.stakeKeeper)
app.ValAddrCache.ClearCache()
}

//match may end with transaction failure, which is better to save into
//the EndBlock response. However, current cosmos doesn't support this.
//future TODO: add failure info.
Expand Down Expand Up @@ -645,7 +652,7 @@ func MakeCodec() *wire.Codec {
return cdc
}

func (app *BinanceChain) publish(tradesToPublish []*pub.Trade, proposalsToPublish *pub.Proposals, blockFee pub.BlockFee, ctx sdk.Context, height, blockTime int64) {
func (app *BinanceChain) publish(tradesToPublish []*pub.Trade, proposalsToPublish *pub.Proposals, stakeUpdates *pub.StakeUpdates, blockFee pub.BlockFee, ctx sdk.Context, height, blockTime int64) {
pub.Logger.Info("start to collect publish information", "height", height)

var accountsToPublish map[string]pub.Account
Expand Down Expand Up @@ -690,6 +697,7 @@ func (app *BinanceChain) publish(tradesToPublish []*pub.Trade, proposalsToPublis
blockTime,
tradesToPublish,
proposalsToPublish,
stakeUpdates,
app.DexKeeper.OrderChanges, // thread-safety is guarded by the signal from RemoveDoneCh
app.DexKeeper.OrderInfosForPub, // thread-safety is guarded by the signal from RemoveDoneCh
accountsToPublish,
Expand Down
13 changes: 4 additions & 9 deletions app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"path/filepath"
"text/template"

"github.com/cosmos/cosmos-sdk/server"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/common"

"github.com/cosmos/cosmos-sdk/server"
)

var configTemplate *template.Template
Expand Down Expand Up @@ -44,10 +45,6 @@ orderKeeperConcurrency = {{ .BaseConfig.OrderKeeperConcurrency }}
breatheBlockDaysCountBack = {{ .BaseConfig.BreatheBlockDaysCountBack }}
[upgrade]
# fixOrderSeqInPriceLevel height
fixOrderSeqInPriceLevelHeight = {{ .UpgradeConfig.FixOrderSeqInPriceLevelHeight }}
# fixDropFilledOrderSeq height
fixDropFilledOrderSeqHeight = {{ .UpgradeConfig.FixDropFilledOrderSeqHeight }}
[addr]
# Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Expand Down Expand Up @@ -284,14 +281,12 @@ func defaultBaseConfig() *BaseConfig {
}

type UpgradeConfig struct {
FixOrderSeqInPriceLevelHeight int64
FixDropFilledOrderSeqHeight int64
// example
// FixXxxHeight int64 `mapstructure:"fixXxxHeight"`
}

func defaultUpgradeConfig() *UpgradeConfig {
return &UpgradeConfig{
FixDropFilledOrderSeqHeight: 2855000,
FixOrderSeqInPriceLevelHeight: 2855000,
}
}

Expand Down
5 changes: 3 additions & 2 deletions app/fee_distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
"github.com/binance-chain/node/common/fees"
"github.com/binance-chain/node/common/log"
"github.com/binance-chain/node/common/types"

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

func NewValAddrCache(stakeKeeper stake.Keeper) *ValAddrCache {
return &ValAddrCache{
cache := &ValAddrCache{
cache: make(map[string]sdk.AccAddress),
stakeKeeper: stakeKeeper,
}

return cache
}

type ValAddrCache struct {
Expand Down
Loading

0 comments on commit f93ee14

Please sign in to comment.