OSDN Git Service

fix: use fedConsensusPath to derive for consensus federationNodes (#290)
authorHAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
Mon, 15 Jul 2019 14:52:41 +0000 (22:52 +0800)
committerPaladz <yzhu101@uottawa.ca>
Mon, 15 Jul 2019 14:52:41 +0000 (22:52 +0800)
* add fedConsensusPath

* doc: clean up

config/genesis.go
protocol/state/consensus_result.go

index 4c8e62e..8843d52 100644 (file)
@@ -13,6 +13,7 @@ import (
        "github.com/vapor/protocol/vm/vmutil"
 )
 
        "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},
 var FedAddressPath = [][]byte{
        []byte{0x2C, 0x00, 0x00, 0x00},
        []byte{0x99, 0x00, 0x00, 0x00},
index 9313c4b..e124143 100644 (file)
@@ -14,6 +14,15 @@ import (
        "github.com/vapor/protocol/bc/types"
 )
 
        "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
 // 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 {
 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
 }
        }
        return consensusResult
 }