diff --git a/Makefile b/Makefile index dc6b1d4037..73565cdff4 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ FABRIC_DEV_REGISTRY_PRE_CMD ?= docker login -u docker -p docker nexus3.hyperledg THIRDPARTY_FABRIC_CA_BRANCH ?= master THIRDPARTY_FABRIC_CA_COMMIT ?= v1.1.0 THIRDPARTY_FABRIC_BRANCH ?= master -THIRDPARTY_FABRIC_COMMIT ?= 68f268379c78cabbd4325fc2e40059a8c46912ae +THIRDPARTY_FABRIC_COMMIT ?= a8cc2c46d8cec1ad199741c0630a46ccb24084ac # Force removal of images in cleanup (overridable) FIXTURE_DOCKER_REMOVE_FORCE ?= false diff --git a/internal/github.com/hyperledger/fabric/core/ledger/ledger_interface.go b/internal/github.com/hyperledger/fabric/core/ledger/ledger_interface.go index 90de98bbf7..d2fd7e91bf 100644 --- a/internal/github.com/hyperledger/fabric/core/ledger/ledger_interface.go +++ b/internal/github.com/hyperledger/fabric/core/ledger/ledger_interface.go @@ -30,7 +30,7 @@ import ( // PeerLedgerProvider provides handle to ledger instances type PeerLedgerProvider interface { - Initialize(statelisteners StateListeners) + Initialize(statelisteners []StateListener) // Create creates a new ledger with the given genesis block. // This function guarantees that the creation of ledger and committing the genesis block would an atomic action // The chain id retrieved from the genesis block is treated as a ledger id @@ -271,6 +271,8 @@ func (txSim *TxSimulationResults) ContainsPvtWrites() bool { return txSim.PvtSimulationResults != nil } +//go:generate counterfeiter -o mock/state_listener.go -fake-name StateListener . StateListener + // StateListener allows a custom code for performing additional stuff upon state change // for a perticular namespace against which the listener is registered. // This helps to perform custom tasks other than the state updates. @@ -283,11 +285,10 @@ func (txSim *TxSimulationResults) ContainsPvtWrites() bool { // function returns an error, the ledger implementation is expected to halt block commit operation // and result in a panic type StateListener interface { - HandleStateUpdates(ledgerID string, stateUpdates StateUpdates) error + InterestedInNamespaces() []string + HandleStateUpdates(ledgerID string, stateUpdates StateUpdates, committingBlockNum uint64) error + StateCommitDone(channelID string) } // StateUpdates is the generic type to represent the state updates -type StateUpdates interface{} - -// StateListeners maintains the association between a namespace to its corresponding listener -type StateListeners map[string]StateListener +type StateUpdates map[string]interface{} diff --git a/internal/github.com/hyperledger/fabric/discovery/client/api.go b/internal/github.com/hyperledger/fabric/discovery/client/api.go index 1d4fa3dd62..19e9db0706 100644 --- a/internal/github.com/hyperledger/fabric/discovery/client/api.go +++ b/internal/github.com/hyperledger/fabric/discovery/client/api.go @@ -14,7 +14,6 @@ import ( "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protos/discovery" "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protos/gossip" "github.com/pkg/errors" - "golang.org/x/net/context" "google.golang.org/grpc" ) @@ -30,16 +29,13 @@ type Signer func(msg []byte) ([]byte, error) // Dialer connects to the server type Dialer func() (*grpc.ClientConn, error) -// Client defines the client-side API of the discovery service -type Client interface { - // Send sends the Request and returns the response, or error on failure - Send(context.Context, *Request) (Response, error) -} - // Response aggregates several responses from the discovery service type Response interface { // ForChannel returns a ChannelResponse in the context of a given channel ForChannel(string) ChannelResponse + + // ForLocal returns a LocalResponse in the context of no channel + ForLocal() LocalResponse } // ChannelResponse aggregates responses for a given channel @@ -54,7 +50,16 @@ type ChannelResponse interface { // chaincode in a given channel context, or error if something went wrong. // The method returns a random set of endorsers, such that signatures from all of them // combined, satisfy the endorsement policy. - Endorsers(string) (Endorsers, error) + // The selection is based on the given selection hints: + // PrioritySelector: Determines which endorsers are selected over others + // ExclusionFilter: Determines which endorsers are not selected + Endorsers(cc string, ps PrioritySelector, ef ExclusionFilter) (Endorsers, error) +} + +// LocalResponse aggregates responses for a channel-less scope +type LocalResponse interface { + // Peers returns a response for a local peer membership query, or error if something went wrong + Peers() ([]*Peer, error) } // Endorsers defines a set of peers that are sufficient diff --git a/internal/github.com/hyperledger/fabric/discovery/client/client.go b/internal/github.com/hyperledger/fabric/discovery/client/client.go index d277db3050..a4dc61119f 100644 --- a/internal/github.com/hyperledger/fabric/discovery/client/client.go +++ b/internal/github.com/hyperledger/fabric/discovery/client/client.go @@ -17,21 +17,21 @@ import ( "time" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/gossip/util" "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protos/discovery" + "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protos/gossip" "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/msp" "github.com/pkg/errors" ) var ( - configTypes = []discovery.QueryType{discovery.ConfigQueryType, discovery.PeerMembershipQueryType, discovery.ChaincodeQueryType} + configTypes = []discovery.QueryType{discovery.ConfigQueryType, discovery.PeerMembershipQueryType, discovery.ChaincodeQueryType, discovery.LocalMembershipQueryType} ) -type client struct { +// Client interacts with the discovery server +type Client struct { lastRequest []byte lastSignature []byte createConnection Dialer - authInfo *discovery.AuthInfo signRequest Signer } @@ -87,6 +87,18 @@ func (req *Request) AddEndorsersQuery(chaincodes ...string) *Request { return req } +// AddLocalPeersQuery adds to the request a local peer query +func (req *Request) AddLocalPeersQuery() *Request { + q := &discovery.Query_LocalPeers{ + LocalPeers: &discovery.LocalPeerQuery{}, + } + req.Queries = append(req.Queries, &discovery.Query{ + Query: q, + }) + req.addQueryMapping(discovery.LocalMembershipQueryType, "") + return req +} + // AddPeersQuery adds to the request a peer query func (req *Request) AddPeersQuery() *Request { ch := req.lastChannel @@ -113,17 +125,17 @@ func (req *Request) addQueryMapping(queryType discovery.QueryType, key string) { } // Send sends the request and returns the response, or error on failure -func (c *client) Send(ctx context.Context, req *Request) (Response, error) { - req.Authentication = c.authInfo - payload, err := proto.Marshal(req.Request) +func (c *Client) Send(ctx context.Context, req *Request, auth *discovery.AuthInfo) (Response, error) { + reqToBeSent := *req.Request + reqToBeSent.Authentication = auth + payload, err := proto.Marshal(&reqToBeSent) if err != nil { return nil, errors.Wrap(err, "failed marshaling Request to bytes") } - sig := c.lastSignature // Only sign the Request if it is different than the previous Request sent. // Otherwise, use the last signature from the previous send. - // This is not only to save CPU cycles in the client-side, + // This is not only to save CPU cycles in the Client-side, // but also for the server side to be able to memoize the signature verification. // We have the use the previous signature, because many signature schemes are not deterministic. if !bytes.Equal(c.lastRequest, payload) { @@ -143,10 +155,6 @@ func (c *client) Send(ctx context.Context, req *Request) (Response, error) { return nil, errors.Wrap(err, "failed connecting to discovery service") } - defer func() { - req.Queries = nil - }() - cl := discovery.NewDiscoveryClient(conn) resp, err := cl.Discover(ctx, &discovery.SignedRequest{ Payload: payload, @@ -166,6 +174,14 @@ type resultOrError interface { type response map[key]resultOrError +type localResponse struct { + response +} + +func (cr *localResponse) Peers() ([]*Peer, error) { + return parsePeers(discovery.LocalMembershipQueryType, cr.response, "") +} + type channelResponse struct { response channel string @@ -188,10 +204,10 @@ func (cr *channelResponse) Config() (*discovery.ConfigResult, error) { return nil, res.(error) } -func (cr *channelResponse) Peers() ([]*Peer, error) { - res, exists := cr.response[key{ - queryType: discovery.PeerMembershipQueryType, - channel: cr.channel, +func parsePeers(queryType discovery.QueryType, r response, channel string) ([]*Peer, error) { + res, exists := r[key{ + queryType: queryType, + channel: channel, }] if !exists { @@ -205,7 +221,11 @@ func (cr *channelResponse) Peers() ([]*Peer, error) { return nil, res.(error) } -func (cr *channelResponse) Endorsers(cc string) (Endorsers, error) { +func (cr *channelResponse) Peers() ([]*Peer, error) { + return parsePeers(discovery.PeerMembershipQueryType, cr.response, cr.channel) +} + +func (cr *channelResponse) Endorsers(cc string, ps PrioritySelector, ef ExclusionFilter) (Endorsers, error) { // If we have a key that has no chaincode field, // it means it's an error returned from the service if err, exists := cr.response[key{ @@ -228,18 +248,39 @@ func (cr *channelResponse) Endorsers(cc string) (Endorsers, error) { desc := res.(*endorsementDescriptor) rand.Seed(time.Now().Unix()) - randomLayoutIndex := rand.Intn(len(desc.layouts)) - layout := desc.layouts[randomLayoutIndex] + // We iterate over all layouts to find one that we have enough peers to select + for _, index := range rand.Perm(len(desc.layouts)) { + layout := desc.layouts[index] + endorsers, canLayoutBeSatisfied := selectPeersForLayout(desc.endorsersByGroups, layout, ps, ef) + if canLayoutBeSatisfied { + return endorsers, nil + } + } + return nil, errors.New("no endorsement combination can be satisfied") +} + +func selectPeersForLayout(endorsersByGroups map[string][]*Peer, layout map[string]int, ps PrioritySelector, ef ExclusionFilter) (Endorsers, bool) { var endorsers []*Peer for grp, count := range layout { - endorsersOfGrp := randomEndorsers(count, desc.endorsersByGroups[grp]) + shuffledEndorsers := Endorsers(endorsersByGroups[grp]).Shuffle() + endorsersOfGrp := shuffledEndorsers.Filter(ef).Sort(ps) + // We couldn't select enough peers for this layout because the current group + // requires more peers than we have available to be selected if len(endorsersOfGrp) < count { - return nil, errors.Errorf("layout has a group that requires at least %d peers, but only %d peers are known", count, len(endorsersOfGrp)) + return nil, false } + endorsersOfGrp = endorsersOfGrp[:count] endorsers = append(endorsers, endorsersOfGrp...) } + // The current (randomly chosen) layout can be satisfied, so return it + // instead of checking the next one. + return endorsers, true +} - return endorsers, nil +func (resp response) ForLocal() LocalResponse { + return &localResponse{ + response: resp, + } } func (resp response) ForChannel(ch string) ChannelResponse { @@ -265,7 +306,9 @@ func computeResponse(queryMapping map[discovery.QueryType]map[string]int, r *dis case discovery.ChaincodeQueryType: err = resp.mapEndorsers(channel2index, r) case discovery.PeerMembershipQueryType: - err = resp.mapPeerMembership(channel2index, r) + err = resp.mapPeerMembership(channel2index, r, discovery.PeerMembershipQueryType) + case discovery.LocalMembershipQueryType: + err = resp.mapPeerMembership(channel2index, r, discovery.LocalMembershipQueryType) } if err != nil { return nil, err @@ -296,14 +339,14 @@ func (resp response) mapConfig(channel2index map[string]int, r *discovery.Respon return nil } -func (resp response) mapPeerMembership(channel2index map[string]int, r *discovery.Response) error { +func (resp response) mapPeerMembership(channel2index map[string]int, r *discovery.Response, qt discovery.QueryType) error { for ch, index := range channel2index { membersRes, err := r.MembershipAt(index) if membersRes == nil && err == nil { return errors.Errorf("expected QueryResult of either PeerMembershipResult or Error but got %v instead", r.Results[index]) } key := key{ - queryType: discovery.PeerMembershipQueryType, + queryType: qt, channel: ch, } @@ -312,7 +355,7 @@ func (resp response) mapPeerMembership(channel2index map[string]int, r *discover continue } - peers, err2 := peersForChannel(membersRes) + peers, err2 := peersForChannel(membersRes, qt) if err2 != nil { return errors.Wrap(err2, "failed constructing peer membership out of response") } @@ -322,7 +365,7 @@ func (resp response) mapPeerMembership(channel2index map[string]int, r *discover return nil } -func peersForChannel(membersRes *discovery.PeerMembershipResult) ([]*Peer, error) { +func peersForChannel(membersRes *discovery.PeerMembershipResult, qt discovery.QueryType) ([]*Peer, error) { var peers []*Peer for org, peersOfCurrentOrg := range membersRes.PeersByOrg { for _, peer := range peersOfCurrentOrg.Peers { @@ -330,9 +373,18 @@ func peersForChannel(membersRes *discovery.PeerMembershipResult) ([]*Peer, error if err != nil { return nil, errors.Wrap(err, "failed unmarshaling alive message") } - stateInfoMsg, err := peer.StateInfo.ToGossipMessage() - if err != nil { - return nil, errors.Wrap(err, "failed unmarshaling stateInfo message") + var stateInfoMsg *gossip.SignedGossipMessage + if isStateInfoExpected(qt) { + stateInfoMsg, err = peer.StateInfo.ToGossipMessage() + if err != nil { + return nil, errors.Wrap(err, "failed unmarshaling stateInfo message") + } + if err := validateStateInfoMessage(stateInfoMsg); err != nil { + return nil, errors.Wrap(err, "failed validating stateInfo message") + } + } + if err := validateAliveMessage(aliveMsg); err != nil { + return nil, errors.Wrap(err, "failed validating alive message") } peers = append(peers, &Peer{ MSPID: org, @@ -345,6 +397,10 @@ func peersForChannel(membersRes *discovery.PeerMembershipResult) ([]*Peer, error return peers, nil } +func isStateInfoExpected(qt discovery.QueryType) bool { + return qt != discovery.LocalMembershipQueryType +} + func (resp response) mapEndorsers(channel2index map[string]int, r *discovery.Response) error { for ch, index := range channel2index { ccQueryRes, err := r.EndorsersAt(index) @@ -430,35 +486,62 @@ func endorser(peer *discovery.Peer, chaincode, channel string) (*Peer, error) { if err != nil { return nil, errors.Wrap(err, "failed unmarshaling gossip envelope to state info message") } - sId := &msp.SerializedIdentity{} - if err := proto.Unmarshal(peer.Identity, sId); err != nil { + if err := validateAliveMessage(aliveMsg); err != nil { + return nil, errors.Wrap(err, "failed validating alive message") + } + if err := validateStateInfoMessage(stateInfMsg); err != nil { + return nil, errors.Wrap(err, "failed validating stateInfo message") + } + sID := &msp.SerializedIdentity{} + if err := proto.Unmarshal(peer.Identity, sID); err != nil { return nil, errors.Wrap(err, "failed unmarshaling peer's identity") } return &Peer{ Identity: peer.Identity, StateInfoMessage: stateInfMsg, AliveMessage: aliveMsg, - MSPID: sId.Mspid, + MSPID: sID.Mspid, }, nil } -func randomEndorsers(count int, totalPeers []*Peer) Endorsers { - var endorsers []*Peer - for _, index := range util.GetRandomIndices(count, len(totalPeers)-1) { - endorsers = append(endorsers, totalPeers[index]) - } - return endorsers -} - type endorsementDescriptor struct { endorsersByGroups map[string][]*Peer layouts []map[string]int } -func NewClient(createConnection Dialer, authInfo *discovery.AuthInfo, s Signer) *client { - return &client{ +// NewClient creates a new Client instance +func NewClient(createConnection Dialer, s Signer) *Client { + return &Client{ createConnection: createConnection, - authInfo: authInfo, signRequest: s, } } + +func validateAliveMessage(message *gossip.SignedGossipMessage) error { + am := message.GetAliveMsg() + if am == nil { + return errors.New("message isn't an alive message") + } + m := am.Membership + if m == nil { + return errors.New("membership is empty") + } + if am.Timestamp == nil { + return errors.New("timestamp is nil") + } + return nil +} + +func validateStateInfoMessage(message *gossip.SignedGossipMessage) error { + si := message.GetStateInfo() + if si == nil { + return errors.New("message isn't a stateInfo message") + } + if si.Timestamp == nil { + return errors.New("timestamp is nil") + } + if si.Properties == nil { + return errors.New("properties is nil") + } + return nil +} diff --git a/internal/github.com/hyperledger/fabric/protos/discovery/extensions.go b/internal/github.com/hyperledger/fabric/protos/discovery/extensions.go index 5a3a00534c..26c30d3bd3 100644 --- a/internal/github.com/hyperledger/fabric/protos/discovery/extensions.go +++ b/internal/github.com/hyperledger/fabric/protos/discovery/extensions.go @@ -14,6 +14,7 @@ const ( ConfigQueryType PeerMembershipQueryType ChaincodeQueryType + LocalMembershipQueryType ) // ConfigAt returns the ConfigResult at a given index in the Response, diff --git a/internal/github.com/hyperledger/fabric/protos/discovery/protocol.pb.go b/internal/github.com/hyperledger/fabric/protos/discovery/protocol.pb.go index d34b23908c..0ba2f699a3 100644 --- a/internal/github.com/hyperledger/fabric/protos/discovery/protocol.pb.go +++ b/internal/github.com/hyperledger/fabric/protos/discovery/protocol.pb.go @@ -24,6 +24,7 @@ It has these top-level messages: PeerMembershipResult ChaincodeQuery ChaincodeQueryResult + LocalPeerQuery EndorsementDescriptor Layout Peers @@ -175,6 +176,7 @@ type Query struct { // *Query_ConfigQuery // *Query_PeerQuery // *Query_CcQuery + // *Query_LocalPeers Query isQuery_Query `protobuf_oneof:"query"` } @@ -196,10 +198,14 @@ type Query_PeerQuery struct { type Query_CcQuery struct { CcQuery *ChaincodeQuery `protobuf:"bytes,4,opt,name=ccQuery,oneof"` } +type Query_LocalPeers struct { + LocalPeers *LocalPeerQuery `protobuf:"bytes,5,opt,name=localPeers,oneof"` +} func (*Query_ConfigQuery) isQuery_Query() {} func (*Query_PeerQuery) isQuery_Query() {} func (*Query_CcQuery) isQuery_Query() {} +func (*Query_LocalPeers) isQuery_Query() {} func (m *Query) GetQuery() isQuery_Query { if m != nil { @@ -236,12 +242,20 @@ func (m *Query) GetCcQuery() *ChaincodeQuery { return nil } +func (m *Query) GetLocalPeers() *LocalPeerQuery { + if x, ok := m.GetQuery().(*Query_LocalPeers); ok { + return x.LocalPeers + } + return nil +} + // XXX_OneofFuncs is for the internal use of the proto package. func (*Query) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _Query_OneofMarshaler, _Query_OneofUnmarshaler, _Query_OneofSizer, []interface{}{ (*Query_ConfigQuery)(nil), (*Query_PeerQuery)(nil), (*Query_CcQuery)(nil), + (*Query_LocalPeers)(nil), } } @@ -264,6 +278,11 @@ func _Query_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { if err := b.EncodeMessage(x.CcQuery); err != nil { return err } + case *Query_LocalPeers: + b.EncodeVarint(5<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.LocalPeers); err != nil { + return err + } case nil: default: return fmt.Errorf("Query.Query has unexpected type %T", x) @@ -298,6 +317,14 @@ func _Query_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) err := b.DecodeMessage(msg) m.Query = &Query_CcQuery{msg} return true, err + case 5: // query.localPeers + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(LocalPeerQuery) + err := b.DecodeMessage(msg) + m.Query = &Query_LocalPeers{msg} + return true, err default: return false, nil } @@ -322,6 +349,11 @@ func _Query_OneofSizer(msg proto.Message) (n int) { n += proto.SizeVarint(4<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s + case *Query_LocalPeers: + s := proto.Size(x.LocalPeers) + n += proto.SizeVarint(5<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) @@ -613,6 +645,15 @@ func (m *ChaincodeQueryResult) GetContent() []*EndorsementDescriptor { return nil } +// LocalPeerQuery queries for peers in a non channel context +type LocalPeerQuery struct { +} + +func (m *LocalPeerQuery) Reset() { *m = LocalPeerQuery{} } +func (m *LocalPeerQuery) String() string { return proto.CompactTextString(m) } +func (*LocalPeerQuery) ProtoMessage() {} +func (*LocalPeerQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } + // EndorsementDescriptor contains information about which peers can be used // to request endorsement from, such that the endorsement policy would be fulfilled. // Here is how to compute a set of peers to ask an endorsement from, given an EndorsementDescriptor: @@ -638,7 +679,7 @@ type EndorsementDescriptor struct { func (m *EndorsementDescriptor) Reset() { *m = EndorsementDescriptor{} } func (m *EndorsementDescriptor) String() string { return proto.CompactTextString(m) } func (*EndorsementDescriptor) ProtoMessage() {} -func (*EndorsementDescriptor) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } +func (*EndorsementDescriptor) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } func (m *EndorsementDescriptor) GetChaincode() string { if m != nil { @@ -672,7 +713,7 @@ type Layout struct { func (m *Layout) Reset() { *m = Layout{} } func (m *Layout) String() string { return proto.CompactTextString(m) } func (*Layout) ProtoMessage() {} -func (*Layout) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } +func (*Layout) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } func (m *Layout) GetQuantitiesByGroup() map[string]uint32 { if m != nil { @@ -689,7 +730,7 @@ type Peers struct { func (m *Peers) Reset() { *m = Peers{} } func (m *Peers) String() string { return proto.CompactTextString(m) } func (*Peers) ProtoMessage() {} -func (*Peers) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } +func (*Peers) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } func (m *Peers) GetPeers() []*Peer { if m != nil { @@ -712,7 +753,7 @@ type Peer struct { func (m *Peer) Reset() { *m = Peer{} } func (m *Peer) String() string { return proto.CompactTextString(m) } func (*Peer) ProtoMessage() {} -func (*Peer) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } +func (*Peer) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } func (m *Peer) GetStateInfo() *gossip.Envelope { if m != nil { @@ -743,7 +784,7 @@ type Error struct { func (m *Error) Reset() { *m = Error{} } func (m *Error) String() string { return proto.CompactTextString(m) } func (*Error) ProtoMessage() {} -func (*Error) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } +func (*Error) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } func (m *Error) GetContent() string { if m != nil { @@ -760,7 +801,7 @@ type Endpoints struct { func (m *Endpoints) Reset() { *m = Endpoints{} } func (m *Endpoints) String() string { return proto.CompactTextString(m) } func (*Endpoints) ProtoMessage() {} -func (*Endpoints) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } +func (*Endpoints) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } func (m *Endpoints) GetEndpoint() []*Endpoint { if m != nil { @@ -778,7 +819,7 @@ type Endpoint struct { func (m *Endpoint) Reset() { *m = Endpoint{} } func (m *Endpoint) String() string { return proto.CompactTextString(m) } func (*Endpoint) ProtoMessage() {} -func (*Endpoint) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } +func (*Endpoint) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } func (m *Endpoint) GetHost() string { if m != nil { @@ -807,6 +848,7 @@ func init() { proto.RegisterType((*PeerMembershipResult)(nil), "sdk.discovery.PeerMembershipResult") proto.RegisterType((*ChaincodeQuery)(nil), "sdk.discovery.ChaincodeQuery") proto.RegisterType((*ChaincodeQueryResult)(nil), "sdk.discovery.ChaincodeQueryResult") + proto.RegisterType((*LocalPeerQuery)(nil), "sdk.discovery.LocalPeerQuery") proto.RegisterType((*EndorsementDescriptor)(nil), "sdk.discovery.EndorsementDescriptor") proto.RegisterType((*Layout)(nil), "sdk.discovery.Layout") proto.RegisterType((*Peers)(nil), "sdk.discovery.Peers") @@ -893,69 +935,71 @@ var _Discovery_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("discovery/protocol.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1019 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xdd, 0x6e, 0xe3, 0x44, - 0x1b, 0x6e, 0xd2, 0xa6, 0x49, 0xde, 0xfe, 0x4f, 0xb3, 0xfd, 0xf2, 0x45, 0x68, 0xb7, 0x6b, 0x69, - 0xa1, 0x5a, 0x24, 0xbb, 0x2a, 0x5a, 0x01, 0xed, 0x82, 0xd4, 0x6e, 0x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 0x9c, 0x41, 0xc7, 0x1c, 0x48, 0xbf, 0x16, - 0x6b, 0xe6, 0x17, 0x69, 0x50, 0xcf, 0xc2, 0xfc, 0x7f, 0x58, 0x2b, 0x17, 0xc7, 0x3f, 0xdb, 0x41, - 0x24, 0xc2, 0x7c, 0x6c, 0xfb, 0x34, 0x71, 0xc2, 0x22, 0x43, 0x16, 0xe3, 0x24, 0x40, 0xe6, 0xdc, - 0xc9, 0x4f, 0xaa, 0xfa, 0x8f, 0xe3, 0x4e, 0x25, 0x1e, 0xaf, 0x4b, 0xe4, 0x8b, 0x7f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0x44, 0x33, 0xd9, 0xf5, 0xec, 0x09, 0x00, 0x00, + // 1045 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xdb, 0x6e, 0xdb, 0x46, + 0x13, 0xb6, 0x64, 0xcb, 0x92, 0xc6, 0xe7, 0xb5, 0xe2, 0x5f, 0xbf, 0x50, 0x24, 0x0e, 0x81, 0xb4, + 0x46, 0x0a, 0x90, 0x86, 0x8b, 0xa0, 0xad, 0x9d, 0x16, 0xb0, 0x63, 0x37, 0x0a, 0x50, 0xc3, 0x31, + 0x53, 0x14, 0x45, 0x6f, 0x04, 0x8a, 0x1a, 0x93, 0x44, 0x49, 0x2e, 0xbd, 0xbb, 0x34, 0xc0, 0xbb, + 0x3e, 0x41, 0x1f, 0xa0, 0xb7, 0xbd, 0x29, 0xfa, 0x08, 0x7d, 0xba, 0x82, 0x7b, 0xa0, 0x28, 0x59, + 0x42, 0x0a, 0xf4, 0x8e, 0x3b, 0xf3, 0x7d, 0x73, 0xf8, 0x66, 0xc8, 0x25, 0xf4, 0x27, 0x11, 0xf7, + 0xe9, 0x03, 0xb2, 0xc2, 0xc9, 0x18, 0x15, 0xd4, 0xa7, 0xb1, 0x2d, 0x1f, 0x48, 0xb7, 0xf2, 0x0c,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, 0x7e, 0x0b, 0xb9, + 0x53, 0x91, 0xc7, 0xeb, 0xd2, 0xf2, 0xc5, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x43, 0x25, + 0xb6, 0x3b, 0x0a, 0x00, 0x00, } diff --git a/scripts/third_party_pins/fabric/apply_fabric_client_utils.sh b/scripts/third_party_pins/fabric/apply_fabric_client_utils.sh index da0f07bdb0..2b712c18bc 100755 --- a/scripts/third_party_pins/fabric/apply_fabric_client_utils.sh +++ b/scripts/third_party_pins/fabric/apply_fabric_client_utils.sh @@ -304,7 +304,7 @@ mv ${TMP_PROJECT_PATH}/bccsp/factory/pkcs11factory.go ${TMP_PROJECT_PATH}/bccsp/ mv ${TMP_PROJECT_PATH}/bccsp/factory/pluginfactory.go ${TMP_PROJECT_PATH}/bccsp/factory/plugin/pluginfactory.go FILTER_FILENAME="bccsp/factory/pkcs11/pkcs11factory.go" -sed -i'' -e '/\+build !nopkcs11/d' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}" +sed -i'' -e '/\+build pkcs11/d' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}" sed -i'' -e 's/package factory/package pkcs11/g' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}" sed -i'' -e 's/config \*FactoryOpts/p11Opts \*pkcs11.PKCS11Opts/g' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}" sed -i'' -e 's/if config == nil || config.Pkcs11Opts == nil/if p11Opts == nil/g' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}" diff --git a/third_party/github.com/hyperledger/fabric/common/cauthdsl/policyparser.go b/third_party/github.com/hyperledger/fabric/common/cauthdsl/policyparser.go index 112fa0b6f1..7f67d62887 100644 --- a/third_party/github.com/hyperledger/fabric/common/cauthdsl/policyparser.go +++ b/third_party/github.com/hyperledger/fabric/common/cauthdsl/policyparser.go @@ -25,6 +25,7 @@ import ( "reflect" "regexp" "strconv" + "strings" "github.com/Knetic/govaluate" "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common" @@ -32,8 +33,29 @@ import ( "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/utils" ) -var regex *regexp.Regexp = regexp.MustCompile("^([[:alnum:].-]+)([.])(member|admin|client|peer|orderer)$") -var regexErr *regexp.Regexp = regexp.MustCompile("^No parameter '([^']+)' found[.]$") +// Gate values +const ( + GateAnd = "And" + GateOr = "Or" + GateOutOf = "OutOf" +) + +// Role values for principals +const ( + RoleAdmin = "admin" + RoleMember = "member" + RoleClient = "client" + RolePeer = "peer" + // RoleOrderer = "orderer" TODO +) + +var ( + regex = regexp.MustCompile( + fmt.Sprintf("^([[:alnum:].-]+)([.])(%s|%s|%s|%s)$", + RoleAdmin, RoleMember, RoleClient, RolePeer), + ) + regexErr = regexp.MustCompile("^No parameter '([^']+)' found[.]$") +) // a stub function - it returns the same string as it's passed. // This will be evaluated by second/third passes to convert to a proto policy @@ -154,13 +176,13 @@ func secondPass(args ...interface{}) (interface{}, error) { /* get the right role */ var r msp.MSPRole_MSPRoleType switch subm[0][3] { - case "member": + case RoleMember: r = msp.MSPRole_MEMBER - case "admin": + case RoleAdmin: r = msp.MSPRole_ADMIN - case "client": + case RoleClient: r = msp.MSPRole_CLIENT - case "peer": + case RolePeer: r = msp.MSPRole_PEER default: return nil, fmt.Errorf("Error parsing role %s", t) @@ -207,24 +229,37 @@ func newContext() *context { // FromString takes a string representation of the policy, // parses it and returns a SignaturePolicyEnvelope that -// implements that policy. The supported language is as follows +// implements that policy. The supported language is as follows: // // GATE(P[, P]) // -// where +// where: // - GATE is either "and" or "or" // - P is either a principal or another nested call to GATE // -// a principal is defined as +// A principal is defined as: // // ORG.ROLE // -// where +// where: // - ORG is a string (representing the MSP identifier) -// - ROLE is either the string "member", "admin", "client", "peer", or the string "orderer" representing the required role +// - ROLE takes the value of any of the RoleXXX constants representing +// the required role func FromString(policy string) (*common.SignaturePolicyEnvelope, error) { // first we translate the and/or business into outof gates - intermediate, err := govaluate.NewEvaluableExpressionWithFunctions(policy, map[string]govaluate.ExpressionFunction{"AND": and, "and": and, "OR": or, "or": or, "OUTOF": outof, "outof": outof, "OutOf": outof}) + intermediate, err := govaluate.NewEvaluableExpressionWithFunctions( + policy, map[string]govaluate.ExpressionFunction{ + GateAnd: and, + strings.ToLower(GateAnd): and, + strings.ToUpper(GateAnd): and, + GateOr: or, + strings.ToLower(GateOr): or, + strings.ToUpper(GateOr): or, + GateOutOf: outof, + strings.ToLower(GateOutOf): outof, + strings.ToUpper(GateOutOf): outof, + }, + ) if err != nil { return nil, err } diff --git a/third_party/github.com/hyperledger/fabric/protos/peer/configuration.pb.go b/third_party/github.com/hyperledger/fabric/protos/peer/configuration.pb.go index 519e3a33b0..d3c91c8dcd 100644 --- a/third_party/github.com/hyperledger/fabric/protos/peer/configuration.pb.go +++ b/third_party/github.com/hyperledger/fabric/protos/peer/configuration.pb.go @@ -61,25 +61,70 @@ func (m *AnchorPeer) GetPort() int32 { return 0 } +// APIResource represents an API resource in the peer whose ACL +// is determined by the policy_ref field +type APIResource struct { + PolicyRef string `protobuf:"bytes,1,opt,name=policy_ref,json=policyRef" json:"policy_ref,omitempty"` +} + +func (m *APIResource) Reset() { *m = APIResource{} } +func (m *APIResource) String() string { return proto.CompactTextString(m) } +func (*APIResource) ProtoMessage() {} +func (*APIResource) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{2} } + +func (m *APIResource) GetPolicyRef() string { + if m != nil { + return m.PolicyRef + } + return "" +} + +// ACLs provides mappings for resources in a channel. APIResource encpasulates +// reference to a policy used to determine ACL for the resource +type ACLs struct { + Acls map[string]*APIResource `protobuf:"bytes,1,rep,name=acls" json:"acls,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` +} + +func (m *ACLs) Reset() { *m = ACLs{} } +func (m *ACLs) String() string { return proto.CompactTextString(m) } +func (*ACLs) ProtoMessage() {} +func (*ACLs) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{3} } + +func (m *ACLs) GetAcls() map[string]*APIResource { + if m != nil { + return m.Acls + } + return nil +} + func init() { proto.RegisterType((*AnchorPeers)(nil), "sdk.protos.AnchorPeers") proto.RegisterType((*AnchorPeer)(nil), "sdk.protos.AnchorPeer") + proto.RegisterType((*APIResource)(nil), "sdk.protos.APIResource") + proto.RegisterType((*ACLs)(nil), "sdk.protos.ACLs") } func init() { proto.RegisterFile("peer/configuration.proto", fileDescriptor4) } var fileDescriptor4 = []byte{ - // 192 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8f, 0x3d, 0x8f, 0xc3, 0x20, - 0x0c, 0x86, 0xc5, 0x7d, 0x49, 0x47, 0x6e, 0x62, 0x62, 0x8c, 0x32, 0xe5, 0x16, 0x90, 0xee, 0xe3, - 0x07, 0xb4, 0xea, 0xde, 0x2a, 0x63, 0x97, 0x8a, 0x50, 0x02, 0x48, 0x6d, 0x8c, 0x0c, 0x19, 0xfa, - 0xef, 0x2b, 0x40, 0x55, 0x3a, 0xf1, 0x62, 0x3f, 0x8f, 0x6c, 0x53, 0x1e, 0x8c, 0x41, 0xa9, 0x61, - 0x9e, 0xbc, 0x5d, 0x50, 0x25, 0x0f, 0xb3, 0x08, 0x08, 0x09, 0xd8, 0x47, 0x79, 0x62, 0xb7, 0xa3, - 0xcd, 0x66, 0xd6, 0x0e, 0xf0, 0x60, 0x0c, 0x46, 0xf6, 0x4f, 0xbf, 0x54, 0xf9, 0x9e, 0xb2, 0x19, - 0x39, 0x69, 0x5f, 0xfb, 0xe6, 0x87, 0x55, 0x29, 0x8a, 0x15, 0x1d, 0x1a, 0xb5, 0x6a, 0xdd, 0x1f, - 0xa5, 0x6b, 0x8b, 0x31, 0xfa, 0xe6, 0x20, 0x26, 0x4e, 0x5a, 0xd2, 0x7f, 0x0e, 0x25, 0xe7, 0x5a, - 0x00, 0x4c, 0xfc, 0xa5, 0x25, 0xfd, 0xfb, 0x50, 0xf2, 0x76, 0x4f, 0x3b, 0x40, 0x2b, 0xdc, 0x2d, - 0x18, 0xbc, 0x98, 0xb3, 0x35, 0x28, 0x26, 0x35, 0xa2, 0xd7, 0x8f, 0x71, 0x79, 0x87, 0xe3, 0xb7, - 0xf5, 0xc9, 0x2d, 0xa3, 0xd0, 0x70, 0x95, 0x4f, 0xa8, 0xac, 0xa8, 0xac, 0xa8, 0xcc, 0xe8, 0x58, - 0x8f, 0xfa, 0xbd, 0x07, 0x00, 0x00, 0xff, 0xff, 0x6d, 0xf2, 0x7b, 0x6f, 0xf7, 0x00, 0x00, 0x00, + // 295 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xdf, 0x4b, 0xfb, 0x30, + 0x14, 0xc5, 0xe9, 0x7e, 0x7c, 0x61, 0xb7, 0xdf, 0x07, 0x89, 0x20, 0x45, 0x10, 0x46, 0x9f, 0x36, + 0x91, 0x14, 0xa6, 0x82, 0xf8, 0x56, 0xa7, 0x0f, 0xc2, 0xc0, 0x91, 0x47, 0x5f, 0x46, 0x16, 0x6f, + 0x7f, 0x60, 0x6d, 0xca, 0x4d, 0x2a, 0xf4, 0xcd, 0x3f, 0x5d, 0x9a, 0x6c, 0xab, 0x4f, 0x39, 0x39, + 0xf9, 0x9c, 0xcb, 0x21, 0x17, 0xa2, 0x06, 0x91, 0x12, 0xa5, 0xeb, 0xac, 0xcc, 0x5b, 0x92, 0xb6, + 0xd4, 0x35, 0x6f, 0x48, 0x5b, 0xcd, 0xfe, 0xb9, 0xc3, 0xc4, 0xcf, 0x10, 0xa6, 0xb5, 0x2a, 0x34, + 0x6d, 0x11, 0xc9, 0xb0, 0x7b, 0xf8, 0x2f, 0xdd, 0x75, 0xd7, 0x27, 0x4d, 0x14, 0xcc, 0xc7, 0x8b, + 0x70, 0xc5, 0x7c, 0xc8, 0xf0, 0x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