From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:52:41 +0000 (+0800) Subject: fix: use fedConsensusPath to derive for consensus federationNodes (#290) X-Git-Tag: v1.0.5~132 X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=1ffbb7fc93255972527f240c7ee936a9cf60c4ad fix: use fedConsensusPath to derive for consensus federationNodes (#290) * add fedConsensusPath * doc: clean up --- diff --git a/config/genesis.go b/config/genesis.go index 4c8e62ed..8843d522 100644 --- a/config/genesis.go +++ b/config/genesis.go @@ -13,6 +13,7 @@ import ( "github.com/vapor/protocol/vm/vmutil" ) +// FedAddressPath is used to derive federation root xpubs for signing cross-chain txs var FedAddressPath = [][]byte{ []byte{0x2C, 0x00, 0x00, 0x00}, []byte{0x99, 0x00, 0x00, 0x00}, diff --git a/protocol/state/consensus_result.go b/protocol/state/consensus_result.go index 9313c4bc..e1241434 100644 --- a/protocol/state/consensus_result.go +++ b/protocol/state/consensus_result.go @@ -14,6 +14,15 @@ import ( "github.com/vapor/protocol/bc/types" ) +// fedConsensusPath is used to derive federation root xpubs for signing blocks +var fedConsensusPath = [][]byte{ + []byte{0xff, 0xff, 0xff, 0xff}, + []byte{0xff, 0x00, 0x00, 0x00}, + []byte{0xff, 0xff, 0xff, 0xff}, + []byte{0xff, 0x00, 0x00, 0x00}, + []byte{0xff, 0x00, 0x00, 0x00}, +} + // ConsensusNode represents a consensus node type ConsensusNode struct { XPub chainkd.XPub @@ -311,7 +320,8 @@ func (c *ConsensusResult) GetCoinbaseRewards(blockHeight uint64) ([]CoinbaseRewa func federationNodes() map[string]*ConsensusNode { consensusResult := map[string]*ConsensusNode{} for i, xpub := range config.CommonConfig.Federation.Xpubs { - consensusResult[xpub.String()] = &ConsensusNode{XPub: xpub, VoteNum: 0, Order: uint64(i)} + derivedXPub := xpub.Derive(fedConsensusPath) + consensusResult[derivedXPub.String()] = &ConsensusNode{XPub: derivedXPub, VoteNum: 0, Order: uint64(i)} } return consensusResult }