Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BEP8 Mini-BEP2 token features #725

Merged
merged 106 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from 102 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
3bafdde
add mini_token type
Mar 23, 2020
c1cbdab
complete minitoken issue
Mar 25, 2020
353d64c
fix miniToken/issue
Mar 25, 2020
07eb545
burn setTokens tx; cli
Mar 30, 2020
b2541f0
init trading related change
Mar 31, 2020
8ea6289
select top K active symbols for match by quick select
Apr 1, 2020
2754f39
decide maker by last match height intead of height
Apr 2, 2020
b5b83eb
reuse some BEP2 txs for mini token
Apr 3, 2020
2a91ffc
add files
Apr 7, 2020
19f0b59
add dex-mini keeper
Apr 13, 2020
5747530
clean code; fix avro schema
Apr 14, 2020
b153299
refactor mini_keeper
Apr 15, 2020
abae60c
change maxTotalSupply to tokenType for mini token
Apr 26, 2020
0e59635
refactor WIP
Apr 29, 2020
9c93f41
parallel match
Apr 30, 2020
6878065
fix wrong symbol
May 2, 2020
3de38ca
fix abci handler for mini
May 3, 2020
d92a2ca
fix test
May 4, 2020
da397b1
refactor dex keeper
May 8, 2020
11033eb
format
May 8, 2020
36fd5f5
fix ut
May 8, 2020
9b21c30
rename file
May 8, 2020
55627f0
change order
May 8, 2020
25cd11d
remove hardcode home in shell scripts
May 9, 2020
e1dbad6
fix upgrade version
May 9, 2020
e46b8b9
Merge branch 'mini_token_bak' of https://github.com/binance-chain/nod…
May 9, 2020
7ddd914
add fork check
May 9, 2020
e172524
fix mini match
May 9, 2020
1c90c81
fix schema
May 9, 2020
3d23390
add height before load snapshot
May 9, 2020
55e0fc6
fix mini publish number
May 9, 2020
372c1f1
register minitoken wire
May 11, 2020
62a28ce
Merge branch 'mini_token_bak' of https://github.com/binance-chain/nod…
May 11, 2020
f53bf97
Revert "Merge branch 'mini_token_bak' of https://github.com/binance-c…
May 11, 2020
9b15a1b
register mini token wire
May 11, 2020
6c2045e
add mini-token api query
May 11, 2020
e214047
fix api server
May 12, 2020
0184d7d
merge from origin/develop; resolve conflicts
May 12, 2020
434a201
fix ut
May 12, 2020
7516839
remove minitoken plugin
May 12, 2020
daaa4a3
fix config
May 12, 2020
9cfa7ab
fix issue mini abci
May 12, 2020
513169e
move mini token mapper to token mapper
May 13, 2020
69549eb
fix ut
May 13, 2020
9d2a587
add ut
May 14, 2020
cc81f5c
fix ut
May 14, 2020
6d4f740
fix ut
May 14, 2020
76dace5
add integration test for mini
May 14, 2020
b0be4a8
fix integration test
May 14, 2020
b52a6b9
refactor
May 15, 2020
d6cecbb
refactor
May 15, 2020
ff04b92
refactor
May 15, 2020
acfa33f
fix ut
May 18, 2020
6a86f02
fix ut
May 18, 2020
cd76c6e
fix incompatibility
May 19, 2020
8afd0ec
change dependency
May 19, 2020
5e80b6f
format
May 19, 2020
bd69db3
fmt
May 19, 2020
69e6e6a
reorder dex keeper param
May 20, 2020
3002358
seperate token classification and validation
May 20, 2020
b785df7
merge mini-trade/order into trade/order while publish
May 20, 2020
4a04f49
refactor
May 20, 2020
ff93e97
separate issue-mini and issue-tiny
May 21, 2020
bb5c884
refactor
May 21, 2020
9a39fc6
register issueTinyMsg
May 21, 2020
221248f
clean
May 21, 2020
ca7778c
clean code
May 22, 2020
a90d59f
replace IToken interface by struct while marshal
May 22, 2020
5dd0464
some refactor
rickyyangz May 25, 2020
931952d
change list-mini route
May 25, 2020
7008425
merge mini handler
May 25, 2020
6451b5d
fix ut
May 25, 2020
0bab3af
Merge branch 'mini_token_bak' into mini_ref
EnderCrypto May 25, 2020
e2af6cf
Merge pull request #734 from binance-chain/mini_ref
EnderCrypto May 25, 2020
1c31a84
fix
May 25, 2020
187d5f0
symbol selector refactor
rickyyangz May 25, 2020
141cb6f
fix order cancel
May 25, 2020
901887e
Merge pull request #735 from binance-chain/mini_ref_2
EnderCrypto May 25, 2020
61c7234
format
May 25, 2020
03e4179
Merge branch 'mini_token_bak' of https://github.com/binance-chain/nod…
May 25, 2020
cf892b1
fix compiling error
May 25, 2020
9ca6580
refactor lastMatchHeight
May 25, 2020
f52d5a9
fix ut
May 25, 2020
0cc2199
orderkeeper refactor
rickyyangz May 25, 2020
6654f83
Merge pull request #736 from binance-chain/mini_ref_3
EnderCrypto May 26, 2020
46b5f07
format
May 26, 2020
12f93e5
lot size calculation for busd pairs
May 26, 2020
b2fa9b8
small refactor
May 26, 2020
3cfbb4d
handle new listing
May 27, 2020
e5197c4
msg&handler refactor
rickyyangz May 27, 2020
eba975b
Merge pull request #738 from binance-chain/mini_ref_4
EnderCrypto May 27, 2020
a057234
msg&handler refactor
rickyyangz May 28, 2020
c64d30a
fix msg compatible issue
rickyyangz May 28, 2020
c5d4f75
format & tidy handler
rickyyangz May 28, 2020
a2b1ef0
format
rickyyangz May 28, 2020
5ee9959
Merge pull request #739 from binance-chain/mini_ref_5
EnderCrypto May 28, 2020
79c4ba5
use sdk's BEP8
May 29, 2020
d0e008f
config default upgrade height
Jun 1, 2020
1b26233
change mini token max cap to 1000000e8
Jun 1, 2020
465f71e
fix comment
Jun 1, 2020
9c41029
change mini token fee
Jun 1, 2020
919c17b
fix test
Jun 1, 2020
fe23b1d
refactor
Jun 2, 2020
ef982cd
change mini token fee distribution
Jun 2, 2020
ebc2fa3
refactor
Jun 2, 2020
e53f637
refactor
Jun 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions admin/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var transferOnlyModeBlackList = []string{
timelock.TimeLockMsg{}.Type(),
timelock.TimeUnlockMsg{}.Type(),
timelock.TimeRelockMsg{}.Type(),
issue.IssueMiniMsg{}.Type(),
issue.IssueTinyMsg{}.Type(),
}

var TxBlackList = map[runtime.Mode][]string{
Expand Down
46 changes: 30 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import (
"github.com/binance-chain/node/plugins/param"
"github.com/binance-chain/node/plugins/param/paramhub"
"github.com/binance-chain/node/plugins/tokens"
"github.com/binance-chain/node/plugins/tokens/issue"
"github.com/binance-chain/node/plugins/tokens/seturi"
tkstore "github.com/binance-chain/node/plugins/tokens/store"
"github.com/binance-chain/node/plugins/tokens/swap"
"github.com/binance-chain/node/plugins/tokens/timelock"
Expand Down Expand Up @@ -266,10 +268,11 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) {
upgrade.Mgr.AddUpgradeHeight(upgrade.LotSizeOptimization, upgradeConfig.LotSizeUpgradeHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.ListingRuleUpgrade, upgradeConfig.ListingRuleUpgradeHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.FixZeroBalance, upgradeConfig.FixZeroBalanceHeight)

upgrade.Mgr.AddUpgradeHeight(upgrade.BEP8, upgradeConfig.BEP8Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP67, upgradeConfig.BEP67Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP70, upgradeConfig.BEP70Height)


// register store keys of upgrade
upgrade.Mgr.RegisterStoreKeys(upgrade.BEP9, common.TimeLockStoreKey.Name())
upgrade.Mgr.RegisterStoreKeys(upgrade.BEP3, common.AtomicSwapStoreKey.Name())
Expand All @@ -289,6 +292,13 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) {
swap.ClaimHTLTMsg{}.Type(),
swap.RefundHTLTMsg{}.Type(),
)
// register msg types of upgrade
upgrade.Mgr.RegisterMsgTypes(upgrade.BEP8,
issue.IssueMiniMsg{}.Type(),
issue.IssueTinyMsg{}.Type(),
seturi.SetURIMsg{}.Type(),
list.ListMiniMsg{}.Type(),
)
}

func getABCIQueryBlackList(queryConfig *config.QueryConfig) map[string]bool {
Expand All @@ -307,9 +317,8 @@ func (app *BinanceChain) initRunningMode() {
}

func (app *BinanceChain) initDex(pairMapper dex.TradingPairMapper) {
app.DexKeeper = dex.NewOrderKeeper(common.DexStoreKey, app.AccountKeeper, pairMapper,
app.RegisterCodespace(dex.DefaultCodespace), app.baseConfig.OrderKeeperConcurrency,
app.Codec, app.publicationConfig.ShouldPublishAny())

app.DexKeeper = dex.NewDexKeeper(common.DexStoreKey, app.AccountKeeper, pairMapper, app.RegisterCodespace(dex.DefaultCodespace), app.baseConfig.OrderKeeperConcurrency, app.Codec, app.publicationConfig.ShouldPublishAny())
app.DexKeeper.SubscribeParamChange(app.ParamHub)
app.DexKeeper.SetBUSDSymbol(app.dexConfig.BUSDSymbol)

Expand All @@ -332,6 +341,7 @@ func (app *BinanceChain) initDex(pairMapper dex.TradingPairMapper) {
stateDB,
app.LastBlockHeight(),
app.TxDecoder)

}

func (app *BinanceChain) initPlugins() {
Expand Down Expand Up @@ -527,12 +537,11 @@ func (app *BinanceChain) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) a

isBreatheBlock := app.isBreatheBlock(height, lastBlockTime, blockTime)
var tradesToPublish []*pub.Trade

if sdk.IsUpgrade(upgrade.BEP19) || !isBreatheBlock {
if app.publicationConfig.ShouldPublishAny() && pub.IsLive {
tradesToPublish = pub.MatchAndAllocateAllForPublish(app.DexKeeper, ctx)
tradesToPublish = pub.MatchAndAllocateAllForPublish(app.DexKeeper, ctx, isBreatheBlock)
} else {
app.DexKeeper.MatchAndAllocateAll(ctx, nil)
app.DexKeeper.MatchAndAllocateSymbols(ctx, nil, isBreatheBlock)
}
}

Expand All @@ -552,6 +561,7 @@ func (app *BinanceChain) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) a
}

app.DexKeeper.StoreTradePrices(ctx)

blockFee := distributeFee(ctx, app.AccountKeeper, app.ValAddrCache, app.publicationConfig.PublishBlockFee)

tags, passed, failed := gov.EndBlocker(ctx, app.govKeeper)
Expand Down Expand Up @@ -770,10 +780,13 @@ func (app *BinanceChain) publish(tradesToPublish []*pub.Trade, proposalsToPublis
var blockToPublish *pub.Block
var latestPriceLevels order.ChangedPriceLevelsMap

orderChanges := app.DexKeeper.GetAllOrderChanges()
orderInfoForPublish := app.DexKeeper.GetAllOrderInfosForPub()

duration := pub.Timer(app.Logger, fmt.Sprintf("collect publish information, height=%d", height), func() {
if app.publicationConfig.PublishAccountBalance {
txRelatedAccounts := app.Pool.TxRelatedAddrs()
tradeRelatedAccounts := pub.GetTradeAndOrdersRelatedAccounts(app.DexKeeper, tradesToPublish)
tradeRelatedAccounts := pub.GetTradeAndOrdersRelatedAccounts(app.DexKeeper, tradesToPublish, orderChanges, orderInfoForPublish)
accountsToPublish = pub.GetAccountBalances(
app.AccountKeeper,
ctx,
Expand Down Expand Up @@ -802,33 +815,34 @@ func (app *BinanceChain) publish(tradesToPublish []*pub.Trade, proposalsToPublis
pub.Logger.Info("start to publish", "height", height,
"blockTime", blockTime, "numOfTrades", len(tradesToPublish),
"numOfOrders", // the order num we collected here doesn't include trade related orders
len(app.DexKeeper.OrderChanges),
len(orderChanges),
"numOfProposals",
proposalsToPublish.NumOfMsgs,
"numOfStakeUpdates",
stakeUpdates.NumOfMsgs,
"numOfAccounts",
len(accountsToPublish))
pub.ToRemoveOrderIdCh = make(chan string, pub.ToRemoveOrderIdChannelSize)
pub.ToRemoveOrderIdCh = make(chan pub.OrderSymbolId, pub.ToRemoveOrderIdChannelSize)

pub.ToPublishCh <- pub.NewBlockInfoToPublish(
height,
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
orderChanges, // thread-safety is guarded by the signal from RemoveDoneCh
orderInfoForPublish, // thread-safety is guarded by the signal from RemoveDoneCh
accountsToPublish,
latestPriceLevels,
blockFee,
app.DexKeeper.RoundOrderFees,
app.DexKeeper.RoundOrderFees, //only use DexKeeper RoundOrderFees
transferToPublish,
blockToPublish)

// remove item from OrderInfoForPublish when we published removed order (cancel, iocnofill, fullyfilled, expired)
for id := range pub.ToRemoveOrderIdCh {
pub.Logger.Debug("delete order from order changes map", "orderId", id)
delete(app.DexKeeper.OrderInfosForPub, id)
for o := range pub.ToRemoveOrderIdCh {
pub.Logger.Debug("delete order from order changes map", "symbol", o.Symbol, "orderId", o.Id)
app.DexKeeper.RemoveOrderInfosForPub(o.Symbol, o.Id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems you can get symbol from the orderInfosForPub

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need use symbol to get order keeper

}

pub.Logger.Debug("finish publish", "height", height)
Expand Down
10 changes: 5 additions & 5 deletions app/app_pub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func setupAppTest(t *testing.T) (*assert.Assertions, *require.Assertions, *Binan
pub.IsLive = true

keeper := app.DexKeeper
keeper.CollectOrderInfoForPublish = true
keeper.EnablePublish()
tradingPair := dextypes.NewTradingPair("XYZ-000", "BNB", 102000)
keeper.PairMapper.AddTradingPair(app.DeliverState.Ctx, tradingPair)
keeper.AddEngine(tradingPair)
Expand All @@ -112,8 +112,8 @@ func setupAppTest(t *testing.T) (*assert.Assertions, *require.Assertions, *Binan
keeper.FeeManager.FeeConfig.CancelFee = 12
keeper.FeeManager.FeeConfig.CancelFeeNative = 6

_, buyerAcc := testutils.NewAccountForPub(ctx, am, 100000000000, 0, 0) // give user enough coins to pay the fee
_, sellerAcc := testutils.NewAccountForPub(ctx, am, 100000000000, 0, 0)
_, buyerAcc := testutils.NewAccountForPub(ctx, am, 100000000000, 0, 0, "XYZ-000") // give user enough coins to pay the fee
_, sellerAcc := testutils.NewAccountForPub(ctx, am, 100000000000, 0, 0, "XYZ-000")
return assert.New(t), require.New(t), app, buyerAcc, sellerAcc
}

Expand All @@ -140,7 +140,7 @@ func TestAppPub_MatchOrder(t *testing.T) {

ctx := app.DeliverState.Ctx
msg := orderPkg.NewNewOrderMsg(buyerAcc.GetAddress(), orderPkg.GenerateOrderID(1, buyerAcc.GetAddress()), orderPkg.Side.BUY, "XYZ-000_BNB", 102000, 300000000)
handler := orderPkg.NewHandler(app.GetCodec(), app.DexKeeper, app.AccountKeeper)
handler := orderPkg.NewHandler(app.GetCodec(), app.DexKeeper)
app.DeliverState.Ctx = app.DeliverState.Ctx.WithBlockHeight(41).WithBlockTime(time.Unix(0, 100))
buyerAcc.SetSequence(1)
app.AccountKeeper.SetAccount(ctx, buyerAcc)
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestAppPub_MatchOrder(t *testing.T) {

func TestAppPub_MatchAndCancelFee(t *testing.T) {
assert, require, app, buyerAcc, sellerAcc := setupAppTest(t)
handler := orderPkg.NewHandler(app.GetCodec(), app.DexKeeper, app.AccountKeeper)
handler := orderPkg.NewHandler(app.GetCodec(), app.DexKeeper)
ctx := app.DeliverState.Ctx

// ==== Place a to-be-matched sell order and a to-be-cancelled buy order (in different symbol)
Expand Down
2 changes: 2 additions & 0 deletions app/apptest/match_allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func SetupTest(initPrices ...int64) (crypto.Address, sdk.Context, []sdk.Account)
func SetupTest_new(initPrices ...int64) (crypto.Address, sdk.Context, []sdk.Account) {
// for new match engine
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP19, -1)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP8, -1)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP70, -1)
addr := secp256k1.GenPrivKey().PubKey().Address()
accAddr := sdk.AccAddress(addr)
baseAcc := auth.BaseAccount{Address: accAddr}
Expand Down
12 changes: 10 additions & 2 deletions app/apptest/ordertx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ func Test_handleNewOrder_DeliverTx(t *testing.T) {
tradingPair := types.NewTradingPair("BTC-000", "BNB", 1e8)
testApp.DexKeeper.PairMapper.AddTradingPair(ctx, tradingPair)
testApp.DexKeeper.AddEngine(tradingPair)
testApp.DexKeeper.GetEngines()["BTC-000_BNB"].LastMatchHeight = -1

tradingPair2 := types.NewTradingPair("ETH-001", "BNB", 1e8)
testApp.DexKeeper.PairMapper.AddTradingPair(ctx, tradingPair2)
testApp.DexKeeper.AddEngine(tradingPair2)
testApp.DexKeeper.GetEngines()["ETH-001_BNB"].LastMatchHeight = -1

add := Account(0).GetAddress()
oid := fmt.Sprintf("%X-0", add)
Expand Down Expand Up @@ -159,9 +161,11 @@ func Test_Match(t *testing.T) {
ethPair := types.NewTradingPair("ETH-000", "BNB", 97e8)
testApp.DexKeeper.PairMapper.AddTradingPair(ctx, ethPair)
testApp.DexKeeper.AddEngine(ethPair)
testApp.DexKeeper.GetEngines()["ETH-000_BNB"].LastMatchHeight = -1
btcPair := types.NewTradingPair("BTC-000", "BNB", 96e8)
testApp.DexKeeper.PairMapper.AddTradingPair(ctx, btcPair)
testApp.DexKeeper.AddEngine(btcPair)
testApp.DexKeeper.GetEngines()["BTC-000_BNB"].LastMatchHeight = -1
testApp.DexKeeper.FeeManager.UpdateConfig(newTestFeeConfig())

// setup accounts
Expand Down Expand Up @@ -209,9 +213,11 @@ func Test_Match(t *testing.T) {
buys, sells, pendingMatch := getOrderBook("BTC-000_BNB")
assert.Equal(4, len(buys))
assert.Equal(3, len(sells))

assert.Equal(true, pendingMatch)
testApp.DexKeeper.MatchAndAllocateAll(ctx, nil)
testApp.DexKeeper.MatchAndAllocateSymbols(ctx, nil, false)
buys, sells, pendingMatch = getOrderBook("BTC-000_BNB")

assert.Equal(0, len(buys))
assert.Equal(3, len(sells))
assert.Equal(false, pendingMatch)
Expand Down Expand Up @@ -266,8 +272,9 @@ func Test_Match(t *testing.T) {
assert.Equal(4, len(buys))
assert.Equal(3, len(sells))

testApp.DexKeeper.MatchAndAllocateAll(ctx, nil)
testApp.DexKeeper.MatchAndAllocateSymbols(ctx, nil, false)
buys, sells, _ = getOrderBook("ETH-000_BNB")

t.Logf("buys: %v", buys)
t.Logf("sells: %v", sells)
assert.Equal(1, len(buys))
Expand Down Expand Up @@ -313,6 +320,7 @@ func Test_handleCancelOrder_CheckTx(t *testing.T) {
tradingPair := types.NewTradingPair("BTC-000", "BNB", 1e8)
testApp.DexKeeper.PairMapper.AddTradingPair(ctx, tradingPair)
testApp.DexKeeper.AddEngine(tradingPair)
testApp.DexKeeper.GetEngines()["BTC-000_BNB"].LastMatchHeight = -1
testApp.DexKeeper.FeeManager.UpdateConfig(newTestFeeConfig())

// setup accounts
Expand Down
12 changes: 9 additions & 3 deletions app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ LotSizeUpgradeHeight = {{ .UpgradeConfig.LotSizeUpgradeHeight }}
ListingRuleUpgradeHeight = {{ .UpgradeConfig.ListingRuleUpgradeHeight }}
# Block height of FixZeroBalanceHeight upgrade
FixZeroBalanceHeight = {{ .UpgradeConfig.FixZeroBalanceHeight }}
# Block height of BEP8 upgrade
BEP8Height = {{ .UpgradeConfig.BEP8Height }}
# Block height of BEP67 upgrade
BEP67Height = {{ .UpgradeConfig.BEP67Height }}
# Block height of BEP70 upgrade
Expand Down Expand Up @@ -360,6 +362,7 @@ func defaultBaseConfig() *BaseConfig {
}

type UpgradeConfig struct {

// Galileo Upgrade
BEP6Height int64 `mapstructure:"BEP6Height"`
BEP9Height int64 `mapstructure:"BEP9Height"`
Expand All @@ -368,14 +371,16 @@ type UpgradeConfig struct {
// Hubble Upgrade
BEP12Height int64 `mapstructure:"BEP12Height"`
// Archimedes Upgrade
BEP3Height int64 `mapstructure:"BEP3Height"`
BEP3Height int64 `mapstructure:"BEP3Height"`

// TODO: add upgrade name
FixSignBytesOverflowHeight int64 `mapstructure:"FixSignBytesOverflowHeight"`
LotSizeUpgradeHeight int64 `mapstructure:"LotSizeUpgradeHeight"`
ListingRuleUpgradeHeight int64 `mapstructure:"ListingRuleUpgradeHeight"`
FixZeroBalanceHeight int64 `mapstructure:"FixZeroBalanceHeight"`

// TODO: add upgrade name
BEP8Height int64 `mapstructure:"BEP8Height"`
BEP67Height int64 `mapstructure:"BEP67Height"`
BEP70Height int64 `mapstructure:"BEP70Height"`
}
Expand All @@ -393,8 +398,9 @@ func defaultUpgradeConfig() *UpgradeConfig {
LotSizeUpgradeHeight: math.MaxInt64,
ListingRuleUpgradeHeight: math.MaxInt64,
FixZeroBalanceHeight: math.MaxInt64,
BEP67Height: 1,
BEP70Height: 1,
BEP8Height: math.MaxInt64,
BEP67Height: math.MaxInt64,
BEP70Height: math.MaxInt64,
}
}

Expand Down
11 changes: 4 additions & 7 deletions app/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,12 @@ func (app *BinanceChain) processErrAbciResponseForPub(txBytes []byte) {
case order.NewOrderMsg:
app.Logger.Info("failed to process NewOrderMsg", "oid", msg.Id)
// The error on deliver should be rare and only impact witness publisher's performance
app.DexKeeper.OrderChangesMtx.Lock()
app.DexKeeper.OrderChanges = append(app.DexKeeper.OrderChanges, order.OrderChange{msg.Id, order.FailedBlocking, "", msg})
app.DexKeeper.OrderChangesMtx.Unlock()
app.DexKeeper.UpdateOrderChangeSync(order.OrderChange{msg.Id, order.FailedBlocking, "", msg}, msg.Symbol)
case order.CancelOrderMsg:
app.Logger.Info("failed to process CancelOrderMsg", "oid", msg.RefId)
// The error on deliver should be rare and only impact witness publisher's performance
app.DexKeeper.OrderChangesMtx.Lock()
// OrderInfo must has been in keeper.OrderInfosForPub
app.DexKeeper.OrderChanges = append(app.DexKeeper.OrderChanges, order.OrderChange{msg.RefId, order.FailedBlocking, "", msg})
app.DexKeeper.OrderChangesMtx.Unlock()
// OrderInfo must has been in keeper.orderInfosForPub
app.DexKeeper.UpdateOrderChangeSync(order.OrderChange{msg.RefId, order.FailedBlocking, "", msg}, msg.Symbol)
default:
// deliberately do nothing for message other than NewOrderMsg
// in future, we may publish fail status of send msg
Expand Down Expand Up @@ -195,6 +191,7 @@ func (app *BinanceChain) reInitChain() error {
snapshot.Manager().GetStateDB(),
app.LastBlockHeight(),
app.TxDecoder)

app.initParams()

// init app cache
Expand Down
Loading