Skip to content

Commit

Permalink
Merge pull request #820 from binance-chain/develop
Browse files Browse the repository at this point in the history
Release v0.8.1
  • Loading branch information
rickyyangz authored Jan 19, 2021
2 parents 8975227 + 352486d commit 4c5511e
Show file tree
Hide file tree
Showing 39 changed files with 1,369 additions and 37 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.8.1
FEATURES
* [\#809](https://github.com/binance-chain/node/pull/809) [Token] Implement BEP84
* [\#810](https://github.com/binance-chain/node/pull/810) [Token] Transfer ownership of BEP2/BEP8 token
* [\#811](https://github.com/binance-chain/node/pull/811) [Token] change the symbol minimum length to 2
* [\#815](https://github.com/binance-chain/node/pull/815) [Token] burn transaction sender token fix


## 0.8.0-hf.2
BUG FIXES
[sync] fix memory leak issue in hotsync

## 0.8.0-hf.1
BUG FIXES
[CLI] bnbcli API Server get token issue
Expand Down
18 changes: 18 additions & 0 deletions admin/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank"

"github.com/binance-chain/node/common/runtime"
"github.com/binance-chain/node/plugins/account"
"github.com/binance-chain/node/plugins/bridge"
"github.com/binance-chain/node/plugins/dex/order"
list "github.com/binance-chain/node/plugins/dex/types"
"github.com/binance-chain/node/plugins/tokens/burn"
"github.com/binance-chain/node/plugins/tokens/freeze"
"github.com/binance-chain/node/plugins/tokens/issue"
"github.com/binance-chain/node/plugins/tokens/ownership"
"github.com/binance-chain/node/plugins/tokens/seturi"
"github.com/binance-chain/node/plugins/tokens/swap"
"github.com/binance-chain/node/plugins/tokens/timelock"
)

Expand All @@ -27,6 +33,18 @@ var transferOnlyModeBlackList = []string{
timelock.TimeRelockMsg{}.Type(),
issue.IssueMiniMsg{}.Type(),
issue.IssueTinyMsg{}.Type(),
seturi.SetURIMsg{}.Type(),
list.ListMsg{}.Type(),
list.ListMiniMsg{}.Type(),
ownership.TransferOwnershipMsg{}.Type(),
swap.HTLTMsg{}.Type(),
swap.DepositHTLTMsg{}.Type(),
swap.ClaimHTLTMsg{}.Type(),
swap.RefundHTLTMsg{}.Type(),
account.SetAccountFlagsMsg{}.Type(),
bridge.BindMsg{}.Type(),
bridge.UnbindMsg{}.Type(),
bridge.TransferOutMsg{}.Type(),
}

var TxBlackList = map[runtime.Mode][]string{
Expand Down
8 changes: 8 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
dextypes "github.com/binance-chain/node/plugins/dex/types"
"github.com/binance-chain/node/plugins/tokens"
"github.com/binance-chain/node/plugins/tokens/issue"
"github.com/binance-chain/node/plugins/tokens/ownership"
"github.com/binance-chain/node/plugins/tokens/seturi"
"github.com/binance-chain/node/plugins/tokens/swap"
"github.com/binance-chain/node/plugins/tokens/timelock"
Expand Down Expand Up @@ -316,10 +317,15 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) {
upgrade.Mgr.AddUpgradeHeight(upgrade.ListingRuleUpgrade, upgradeConfig.ListingRuleUpgradeHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.FixZeroBalance, upgradeConfig.FixZeroBalanceHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.LaunchBscUpgrade, upgradeConfig.LaunchBscUpgradeHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.EnableAccountScriptsForCrossChainTransfer, upgradeConfig.EnableAccountScriptsForCrossChainTransferHeight)

upgrade.Mgr.AddUpgradeHeight(upgrade.BEP8, upgradeConfig.BEP8Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP67, upgradeConfig.BEP67Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP70, upgradeConfig.BEP70Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP82, upgradeConfig.BEP82Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP84, upgradeConfig.BEP84Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP87, upgradeConfig.BEP87Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.FixFailAckPackage, upgradeConfig.FixFailAckPackageHeight)

// register store keys of upgrade
upgrade.Mgr.RegisterStoreKeys(upgrade.BEP9, common.TimeLockStoreKey.Name())
Expand Down Expand Up @@ -363,6 +369,8 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) {
seturi.SetURIMsg{}.Type(),
dextypes.ListMiniMsg{}.Type(),
)

upgrade.Mgr.RegisterMsgTypes(upgrade.BEP82, ownership.TransferOwnershipMsg{}.Type())
}

func getABCIQueryBlackList(queryConfig *config.QueryConfig) map[string]bool {
Expand Down
39 changes: 38 additions & 1 deletion app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"text/template"

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

"github.com/spf13/viper"

"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/common"
)
Expand Down Expand Up @@ -73,6 +75,16 @@ BEP8Height = {{ .UpgradeConfig.BEP8Height }}
BEP67Height = {{ .UpgradeConfig.BEP67Height }}
# Block height of BEP70 upgrade
BEP70Height = {{ .UpgradeConfig.BEP70Height }}
# Block height of BEP82 upgrade
BEP82Height = {{ .UpgradeConfig.BEP82Height }}
# Block height of BEP84 upgrade
BEP84Height = {{ .UpgradeConfig.BEP84Height }}
# Block height of BEP87 upgrade
BEP87Height = {{ .UpgradeConfig.BEP87Height }}
# Block height of FixFailAckPackage upgrade
FixFailAckPackageHeight = {{ .UpgradeConfig.FixFailAckPackageHeight }}
# Block height of EnableAccountScriptsForCrossChainTransferHeight upgrade
EnableAccountScriptsForCrossChainTransferHeight = {{ .UpgradeConfig.EnableAccountScriptsForCrossChainTransferHeight }}
[query]
# ABCI query interface black list, suggested value: ["custom/gov/proposals", "custom/timelock/timelocks", "custom/atomicSwap/swapcreator", "custom/atomicSwap/swaprecipient"]
Expand Down Expand Up @@ -145,6 +157,11 @@ publishCrossTransfer = {{ .PublicationConfig.PublishCrossTransfer }}
crossTransferTopic = "{{ .PublicationConfig.CrossTransferTopic }}"
crossTransferKafka = "{{ .PublicationConfig.CrossTransferKafka }}"
# Whether we want publish mirror events
publishMirror = {{ .PublicationConfig.PublishMirror }}
mirrorTopic = "{{ .PublicationConfig.MirrorTopic }}"
mirrorKafka = "{{ .PublicationConfig.MirrorKafka }}"
# Whether we want publish side proposals
publishSideProposal = {{ .PublicationConfig.PublishSideProposal }}
sideProposalTopic = "{{ .PublicationConfig.SideProposalTopic }}"
Expand Down Expand Up @@ -304,6 +321,10 @@ type PublicationConfig struct {
CrossTransferTopic string `mapstructure:"crossTransferTopic"`
CrossTransferKafka string `mapstructure:"crossTransferKafka"`

PublishMirror bool `mapstructure:"publishMirror"`
MirrorTopic string `mapstructure:"mirrorTopic"`
MirrorKafka string `mapstructure:"mirrorKafka"`

PublishSideProposal bool `mapstructure:"publishSideProposal"`
SideProposalTopic string `mapstructure:"sideProposalTopic"`
SideProposalKafka string `mapstructure:"sideProposalKafka"`
Expand Down Expand Up @@ -379,6 +400,10 @@ func defaultPublicationConfig() *PublicationConfig {
CrossTransferTopic: "crossTransfer",
CrossTransferKafka: "127.0.0.1:9092",

PublishMirror: false,
MirrorTopic: "mirror",
MirrorKafka: "127.0.0.1:9092",

PublishSideProposal: false,
SideProposalTopic: "sideProposal",
SideProposalKafka: "127.0.0.1:9092",
Expand Down Expand Up @@ -415,6 +440,7 @@ func (pubCfg PublicationConfig) ShouldPublishAny() bool {
pubCfg.PublishStaking ||
pubCfg.PublishSlashing ||
pubCfg.PublishCrossTransfer ||
pubCfg.PublishMirror ||
pubCfg.PublishSideProposal ||
pubCfg.PublishBreatheBlock
}
Expand Down Expand Up @@ -493,6 +519,12 @@ type UpgradeConfig struct {
BEP8Height int64 `mapstructure:"BEP8Height"`
BEP67Height int64 `mapstructure:"BEP67Height"`
BEP70Height int64 `mapstructure:"BEP70Height"`

BEP82Height int64 `mapstructure:"BEP82Height"`
BEP84Height int64 `mapstructure:"BEP84Height"`
BEP87Height int64 `mapstructure:"BEP87Height"`
FixFailAckPackageHeight int64 `mapstructure:"FixFailAckPackageHeight"`
EnableAccountScriptsForCrossChainTransferHeight int64 `mapstructure:"EnableAccountScriptsForCrossChainTransferHeight"`
}

func defaultUpgradeConfig() *UpgradeConfig {
Expand All @@ -511,7 +543,12 @@ func defaultUpgradeConfig() *UpgradeConfig {
BEP8Height: 1,
BEP67Height: 1,
BEP70Height: 1,
LaunchBscUpgradeHeight: math.MaxInt64,
LaunchBscUpgradeHeight: 1,
BEP82Height: math.MaxInt64,
BEP84Height: math.MaxInt64,
BEP87Height: math.MaxInt64,
FixFailAckPackageHeight: math.MaxInt64,
EnableAccountScriptsForCrossChainTransferHeight: math.MaxInt64,
}
}

Expand Down
7 changes: 6 additions & 1 deletion app/pub/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"fmt"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/binance-chain/node/common/types"
orderPkg "github.com/binance-chain/node/plugins/dex/order"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type msgType int8
Expand All @@ -23,6 +24,7 @@ const (
distributionTpe
slashingTpe
crossTransferTpe
mirrorTpe
sideProposalType
breatheBlockTpe
)
Expand Down Expand Up @@ -56,6 +58,8 @@ func (this msgType) String() string {
return "Slashing"
case crossTransferTpe:
return "CrossTransfer"
case mirrorTpe:
return "Mirror"
case sideProposalType:
return "SideProposal"
case breatheBlockTpe:
Expand All @@ -80,6 +84,7 @@ var latestSchemaVersions = map[msgType]int{
distributionTpe: 0,
slashingTpe: 0,
crossTransferTpe: 0,
mirrorTpe: 0,
sideProposalType: 0,
breatheBlockTpe: 0,
}
Expand Down
66 changes: 66 additions & 0 deletions app/pub/msgs_mirror.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package pub

import "fmt"

type Mirror struct {
TxHash string
ChainId string
Type string
RelayerFee int64
Sender string
Contract string
BEP20Name string
BEP20Symbol string
BEP2Symbol string
OldTotalSupply int64
TotalSupply int64
Decimals int
Fee int64
}

func (msg Mirror) String() string {
return fmt.Sprintf("Mirror: txHash: %s, sender: %s, bep2Symbol: %s", msg.TxHash, msg.Sender, msg.BEP2Symbol)
}

func (msg Mirror) ToNativeMap() map[string]interface{} {
var native = make(map[string]interface{})
native["txHash"] = msg.TxHash
native["chainId"] = msg.ChainId
native["type"] = msg.Type
native["relayerFee"] = msg.RelayerFee
native["sender"] = msg.Sender
native["contract"] = msg.Contract
native["bep20Name"] = msg.BEP20Name
native["bep20Symbol"] = msg.BEP20Symbol
native["bep2Symbol"] = msg.BEP2Symbol
native["oldTotalSupply"] = msg.OldTotalSupply
native["totalSupply"] = msg.TotalSupply
native["decimals"] = msg.Decimals
native["fee"] = msg.Fee
return native
}

// deliberated not implemented Ess
type Mirrors struct {
Height int64
Num int
Timestamp int64
Mirrors []Mirror
}

func (msg Mirrors) String() string {
return fmt.Sprintf("Mirrors in block %d, num: %d", msg.Height, msg.Num)
}

func (msg Mirrors) ToNativeMap() map[string]interface{} {
var native = make(map[string]interface{})
native["height"] = msg.Height
mirrors := make([]map[string]interface{}, len(msg.Mirrors), len(msg.Mirrors))
for idx, t := range msg.Mirrors {
mirrors[idx] = t.ToNativeMap()
}
native["timestamp"] = msg.Timestamp
native["num"] = msg.Num
native["mirrors"] = mirrors
return native
}
35 changes: 35 additions & 0 deletions app/pub/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,41 @@ func PublishEvent(
publisher.publish(&crossTransferMsg, crossTransferTpe, toPublish.Height, toPublish.Timestamp.UnixNano())
}

if cfg.PublishMirror {
var msgNum int
mirrors := make([]Mirror, 0)

for _, mirror := range eventData.MirrorData {
msgNum++
mr := Mirror{
TxHash: mirror.TxHash,
ChainId: mirror.ChainId,
Type: mirror.Type,
RelayerFee: mirror.RelayerFee,
Sender: mirror.Sender,
Contract: mirror.Contract,
BEP20Name: mirror.BEP20Name,
BEP20Symbol: mirror.BEP20Symbol,
BEP2Symbol: mirror.BEP2Symbol,
OldTotalSupply: mirror.OldTotalSupply,
TotalSupply: mirror.TotalSupply,
Decimals: mirror.Decimals,
Fee: mirror.Fee,
}

mirrors = append(mirrors, mr)
}

mirrorsMsg := Mirrors{
Num: msgNum,
Height: toPublish.Height,
Timestamp: toPublish.Timestamp.Unix(),
Mirrors: mirrors,
}
publisher.publish(&mirrorsMsg, mirrorTpe, toPublish.Height, toPublish.Timestamp.UnixNano())

}

if cfg.PublishBreatheBlock && toPublish.IsBreatheBlock {
breatheBlockMsg := BreatheBlockMsg{
Height: toPublish.Height,
Expand Down
17 changes: 17 additions & 0 deletions app/pub/publisher_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type KafkaMarketDataPublisher struct {
distributionCodec *goavro.Codec
slashingCodec *goavro.Codec
crossTransferCodec *goavro.Codec
mirrorCodec *goavro.Codec
sideProposalCodec *goavro.Codec
breatheBlockCodec *goavro.Codec

Expand Down Expand Up @@ -184,6 +185,16 @@ func (publisher *KafkaMarketDataPublisher) newProducers() (config *sarama.Config
return
}
}
if Cfg.PublishMirror {
if _, ok := publisher.producers[Cfg.MirrorTopic]; !ok {
publisher.producers[Cfg.MirrorTopic], err =
publisher.connectWithRetry(strings.Split(Cfg.MirrorKafka, KafkaBrokerSep), config)
}
if err != nil {
Logger.Error("failed to create mirror producer", "err", err)
return
}
}
if Cfg.PublishSideProposal {
if _, ok := publisher.producers[Cfg.SideProposalTopic]; !ok {
publisher.producers[Cfg.SideProposalTopic], err =
Expand Down Expand Up @@ -295,6 +306,8 @@ func (publisher KafkaMarketDataPublisher) resolveTopic(tpe msgType) (topic strin
topic = Cfg.SlashingTopic
case crossTransferTpe:
topic = Cfg.CrossTransferTopic
case mirrorTpe:
topic = Cfg.MirrorTopic
case sideProposalType:
topic = Cfg.SideProposalTopic
case breatheBlockTpe:
Expand Down Expand Up @@ -385,6 +398,8 @@ func (publisher *KafkaMarketDataPublisher) marshal(msg AvroOrJsonMsg, tpe msgTyp
codec = publisher.slashingCodec
case crossTransferTpe:
codec = publisher.crossTransferCodec
case mirrorTpe:
codec = publisher.mirrorCodec
case sideProposalType:
codec = publisher.sideProposalCodec
case breatheBlockTpe:
Expand Down Expand Up @@ -420,6 +435,8 @@ func (publisher *KafkaMarketDataPublisher) initAvroCodecs() (err error) {
return err
} else if publisher.crossTransferCodec, err = goavro.NewCodec(crossTransferSchema); err != nil {
return err
} else if publisher.mirrorCodec, err = goavro.NewCodec(mirrorSchema); err != nil {
return err
} else if publisher.sideProposalCodec, err = goavro.NewCodec(sideProposalsSchema); err != nil {
return err
} else if publisher.breatheBlockCodec, err = goavro.NewCodec(breatheBlockSchema); err != nil {
Expand Down
Loading

0 comments on commit 4c5511e

Please sign in to comment.