Skip to content

Commit

Permalink
FAB-2665 - delivery client should sign msgs to orderer
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-2665

CLI and peer were not signing delivery client. This is needed
for stricter orderer changes coming in.

Change-Id: I3b09a688f5c6592cd8f15424b06bd21b85e4f313
Signed-off-by: Srinivasan Muralidharan <[email protected]>
  • Loading branch information
Srinivasan Muralidharan committed Mar 6, 2017
1 parent 3000b25 commit a4adb11
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
59 changes: 29 additions & 30 deletions core/deliverservice/blocksprovider/blocksprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
gossipcommon "github.com/hyperledger/fabric/gossip/common"
"github.com/hyperledger/fabric/gossip/discovery"

"github.com/hyperledger/fabric/common/localmsp"
"github.com/hyperledger/fabric/protos/common"
gossip_proto "github.com/hyperledger/fabric/protos/gossip"
"github.com/hyperledger/fabric/protos/orderer"
Expand Down Expand Up @@ -175,39 +176,37 @@ func (b *blocksProviderImpl) RequestBlocks(ledgerInfoProvider LedgerInfo) error
}

func (b *blocksProviderImpl) seekOldest() error {
return b.client.Send(&common.Envelope{
Payload: utils.MarshalOrPanic(&common.Payload{
Header: &common.Header{
ChannelHeader: utils.MarshalOrPanic(&common.ChannelHeader{
ChannelId: b.chainID,
}),
SignatureHeader: utils.MarshalOrPanic(&common.SignatureHeader{}),
},
Data: utils.MarshalOrPanic(&orderer.SeekInfo{
Start: &orderer.SeekPosition{Type: &orderer.SeekPosition_Oldest{Oldest: &orderer.SeekOldest{}}},
Stop: &orderer.SeekPosition{Type: &orderer.SeekPosition_Specified{Specified: &orderer.SeekSpecified{Number: math.MaxUint64}}},
Behavior: orderer.SeekInfo_BLOCK_UNTIL_READY,
}),
}),
})
seekInfo := &orderer.SeekInfo{
Start: &orderer.SeekPosition{Type: &orderer.SeekPosition_Oldest{Oldest: &orderer.SeekOldest{}}},
Stop: &orderer.SeekPosition{Type: &orderer.SeekPosition_Specified{Specified: &orderer.SeekSpecified{Number: math.MaxUint64}}},
Behavior: orderer.SeekInfo_BLOCK_UNTIL_READY,
}

//TODO- epoch and msgVersion may need to be obtained for nowfollowing usage in orderer/configupdate/configupdate.go
msgVersion := int32(0)
epoch := uint64(0)
env, err := utils.CreateSignedEnvelope(common.HeaderType_CONFIG_UPDATE, b.chainID, localmsp.NewSigner(), seekInfo, msgVersion, epoch)
if err != nil {
return err
}
return b.client.Send(env)
}

func (b *blocksProviderImpl) seekLatestFromCommitter(height uint64) error {
return b.client.Send(&common.Envelope{
Payload: utils.MarshalOrPanic(&common.Payload{
Header: &common.Header{
ChannelHeader: utils.MarshalOrPanic(&common.ChannelHeader{
ChannelId: b.chainID,
}),
SignatureHeader: utils.MarshalOrPanic(&common.SignatureHeader{}),
},
Data: utils.MarshalOrPanic(&orderer.SeekInfo{
Start: &orderer.SeekPosition{Type: &orderer.SeekPosition_Specified{Specified: &orderer.SeekSpecified{Number: height}}},
Stop: &orderer.SeekPosition{Type: &orderer.SeekPosition_Specified{Specified: &orderer.SeekSpecified{Number: math.MaxUint64}}},
Behavior: orderer.SeekInfo_BLOCK_UNTIL_READY,
}),
}),
})
seekInfo := &orderer.SeekInfo{
Start: &orderer.SeekPosition{Type: &orderer.SeekPosition_Specified{Specified: &orderer.SeekSpecified{Number: height}}},
Stop: &orderer.SeekPosition{Type: &orderer.SeekPosition_Specified{Specified: &orderer.SeekSpecified{Number: math.MaxUint64}}},
Behavior: orderer.SeekInfo_BLOCK_UNTIL_READY,
}

//TODO- epoch and msgVersion may need to be obtained for nowfollowing usage in orderer/configupdate/configupdate.go
msgVersion := int32(0)
epoch := uint64(0)
env, err := utils.CreateSignedEnvelope(common.HeaderType_CONFIG_UPDATE, b.chainID, localmsp.NewSigner(), seekInfo, msgVersion, epoch)
if err != nil {
return err
}
return b.client.Send(env)
}

func createGossipMsg(chainID string, payload *gossip_proto.Payload) *gossip_proto.GossipMessage {
Expand Down
30 changes: 15 additions & 15 deletions peer/channel/deliverclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"math"

"github.com/hyperledger/fabric/common/localmsp"
"github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
"github.com/hyperledger/fabric/protos/utils"
Expand All @@ -39,22 +40,21 @@ func newDeliverClient(client ab.AtomicBroadcast_DeliverClient, chainID string) *
}

func seekHelper(chainID string, start *ab.SeekPosition) *common.Envelope {
return &common.Envelope{
Payload: utils.MarshalOrPanic(&common.Payload{
Header: &common.Header{
ChannelHeader: utils.MarshalOrPanic(&common.ChannelHeader{
ChannelId: chainID,
}),
SignatureHeader: utils.MarshalOrPanic(&common.SignatureHeader{}),
},

Data: utils.MarshalOrPanic(&ab.SeekInfo{
Start: &ab.SeekPosition{Type: &ab.SeekPosition_Oldest{Oldest: &ab.SeekOldest{}}},
Stop: &ab.SeekPosition{Type: &ab.SeekPosition_Specified{Specified: &ab.SeekSpecified{Number: math.MaxUint64}}},
Behavior: ab.SeekInfo_BLOCK_UNTIL_READY,
}),
}),
seekInfo := &ab.SeekInfo{
Start: &ab.SeekPosition{Type: &ab.SeekPosition_Oldest{Oldest: &ab.SeekOldest{}}},
Stop: &ab.SeekPosition{Type: &ab.SeekPosition_Specified{Specified: &ab.SeekSpecified{Number: math.MaxUint64}}},
Behavior: ab.SeekInfo_BLOCK_UNTIL_READY,
}

//TODO- epoch and msgVersion may need to be obtained for nowfollowing usage in orderer/configupdate/configupdate.go
msgVersion := int32(0)
epoch := uint64(0)
env, err := utils.CreateSignedEnvelope(common.HeaderType_CONFIG_UPDATE, chainID, localmsp.NewSigner(), seekInfo, msgVersion, epoch)
if err != nil {
fmt.Printf("Error signing envelope %s\n", err)
return nil
}
return env
}

func (r *deliverClient) seekOldest() error {
Expand Down

0 comments on commit a4adb11

Please sign in to comment.