From 926e6bba22e8f4f5236e60c91f67f2f7bbff699f Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Fri, 29 Sep 2023 02:55:09 -0500 Subject: [PATCH] Better synchronization targeting --- go-libp2p-blossomsub/pubsub.go | 6 +- .../consensus/ceremony/broadcast_messaging.go | 118 +++++++++ .../ceremony_data_clock_consensus_engine.go | 43 ++++ node/consensus/ceremony/consensus_frames.go | 49 ++-- node/consensus/ceremony/peer_messaging.go | 80 +++--- node/p2p/blossomsub.go | 4 + node/p2p/pubsub.go | 1 + node/protobufs/ceremony.pb.go | 234 ++++++++++++++---- node/protobufs/ceremony.proto | 12 +- node/protobufs/protobufs.go | 2 + 10 files changed, 437 insertions(+), 112 deletions(-) diff --git a/go-libp2p-blossomsub/pubsub.go b/go-libp2p-blossomsub/pubsub.go index b38720d..411dd19 100644 --- a/go-libp2p-blossomsub/pubsub.go +++ b/go-libp2p-blossomsub/pubsub.go @@ -23,8 +23,8 @@ import ( logging "github.com/ipfs/go-log/v2" ) -// DefaultMaximumMessageSize is 1mb. -const DefaultMaxMessageSize = 1 << 20 +// DefaultMaximumMessageSize is 16.7 MB. +const DefaultMaxMessageSize = 1 << 24 var ( // TimeCacheDuration specifies how long a message ID will be remembered as seen. @@ -492,7 +492,7 @@ func WithRawTracer(tracer RawTracer) Option { } // WithMaxMessageSize sets the global maximum message size for pubsub wire -// messages. The default value is 1MiB (DefaultMaxMessageSize). +// messages. The default value is 16.7MiB (DefaultMaxMessageSize). // // Observe the following warnings when setting this option. // diff --git a/node/consensus/ceremony/broadcast_messaging.go b/node/consensus/ceremony/broadcast_messaging.go index 08bc5c2..27f7e28 100644 --- a/node/consensus/ceremony/broadcast_messaging.go +++ b/node/consensus/ceremony/broadcast_messaging.go @@ -8,6 +8,7 @@ import ( "time" "github.com/iden3/go-iden3-crypto/poseidon" + "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" "go.uber.org/zap" "golang.org/x/crypto/sha3" @@ -104,6 +105,7 @@ func (e *CeremonyDataClockConsensusEngine) handleMessage( message.From, msg.Address, any, + false, ); err != nil { return errors.Wrap(err, "handle message") } @@ -123,11 +125,122 @@ func (e *CeremonyDataClockConsensusEngine) handleMessage( if err := e.handleKeyBundle(message.From, msg.Address, any); err != nil { return errors.Wrap(err, "handle message") } + case protobufs.CeremonyPeerListAnnounceType: + if err := e.handleCeremonyPeerListAnnounce( + message.From, + msg.Address, + any, + ); err != nil { + return errors.Wrap(err, "handle message") + } } return nil } +func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce( + peerID []byte, + address []byte, + any *anypb.Any, +) error { + if bytes.Equal(peerID, e.pubSub.GetPeerID()) { + return nil + } + + announce := &protobufs.CeremonyPeerListAnnounce{} + if err := any.UnmarshalTo(announce); err != nil { + return errors.Wrap(err, "handle ceremony peer list announce") + } + + e.peerAnnounceMapMx.Lock() + e.peerAnnounceMap[string(peerID)] = announce + e.peerAnnounceMapMx.Unlock() + + e.peerMapMx.Lock() + for _, p := range announce.PeerList { + if bytes.Equal(p.PeerId, e.pubSub.GetPeerID()) { + continue + } + + pr, ok := e.peerMap[string(p.PeerId)] + if !ok { + if bytes.Equal(p.PeerId, peerID) { + e.peerMap[string(p.PeerId)] = &peerInfo{ + peerId: p.PeerId, + multiaddr: e.pubSub.GetMultiaddrOfPeer(peerID), + maxFrame: p.MaxFrame, + direct: bytes.Equal(p.PeerId, peerID), + lastSeen: time.Now().Unix(), + } + } else { + e.peerMap[string(p.PeerId)] = &peerInfo{ + peerId: p.PeerId, + multiaddr: p.Multiaddr, + maxFrame: p.MaxFrame, + direct: bytes.Equal(p.PeerId, peerID), + lastSeen: time.Now().Unix(), + } + } + } else { + if bytes.Equal(p.PeerId, peerID) { + e.peerMap[string(p.PeerId)] = &peerInfo{ + peerId: p.PeerId, + multiaddr: e.pubSub.GetMultiaddrOfPeer(peerID), + maxFrame: p.MaxFrame, + direct: bytes.Equal(p.PeerId, peerID), + lastSeen: time.Now().Unix(), + } + } else { + if pr.direct { + dst := int64(p.MaxFrame) - int64(pr.maxFrame) + if time.Now().Unix()-pr.lastSeen > 30 { + e.peerMap[string(p.PeerId)] = &peerInfo{ + peerId: p.PeerId, + multiaddr: p.Multiaddr, + maxFrame: p.MaxFrame, + direct: false, + lastSeen: time.Now().Unix(), + } + } else if dst > 4 { + e.logger.Warn( + "peer sent announcement with higher frame index for peer", + zap.String("sender_peer", peer.ID(peerID).String()), + zap.String("announced_peer", peer.ID(pr.peerId).String()), + zap.Int64("frame_distance", dst), + ) + } else if dst < -4 { + e.logger.Debug( + "peer sent announcement with lower frame index for peer", + zap.String("sender_peer", peer.ID(peerID).String()), + zap.String("announced_peer", peer.ID(pr.peerId).String()), + zap.Int64("frame_distance", dst), + ) + } else { + e.peerMap[string(p.PeerId)] = &peerInfo{ + peerId: p.PeerId, + multiaddr: p.Multiaddr, + maxFrame: p.MaxFrame, + direct: false, + lastSeen: time.Now().Unix(), + } + } + } else { + e.peerMap[string(p.PeerId)] = &peerInfo{ + peerId: p.PeerId, + multiaddr: p.Multiaddr, + maxFrame: p.MaxFrame, + direct: false, + lastSeen: time.Now().Unix(), + } + } + } + } + } + e.peerMapMx.Unlock() + + return nil +} + func (e *CeremonyDataClockConsensusEngine) handleCeremonyLobbyStateTransition( transition *protobufs.CeremonyLobbyStateTransition, ) error { @@ -339,7 +452,12 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFrameData( peerID []byte, address []byte, any *anypb.Any, + isSync bool, ) error { + if isSync && bytes.Equal(peerID, e.pubSub.GetPeerID()) { + return nil + } + frame := &protobufs.ClockFrame{} if err := any.UnmarshalTo(frame); err != nil { return errors.Wrap(err, "handle clock frame data") diff --git a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go index 83bbc08..596d580 100644 --- a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go +++ b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go @@ -31,6 +31,14 @@ const ( SyncStatusSynchronizing ) +type peerInfo struct { + peerId []byte + multiaddr string + maxFrame uint64 + lastSeen int64 + direct bool +} + type CeremonyDataClockConsensusEngine struct { frame uint64 activeFrame *protobufs.ClockFrame @@ -69,7 +77,11 @@ type CeremonyDataClockConsensusEngine struct { dependencyMapMx sync.Mutex stagedKeyCommitsMx sync.Mutex stagedLobbyStateTransitionsMx sync.Mutex + peerMapMx sync.Mutex + peerAnnounceMapMx sync.Mutex lastKeyBundleAnnouncementFrame uint64 + peerAnnounceMap map[string]*protobufs.CeremonyPeerListAnnounce + peerMap map[string]*peerInfo } var _ consensus.DataConsensusEngine = (*CeremonyDataClockConsensusEngine)(nil) @@ -137,6 +149,8 @@ func NewCeremonyDataClockConsensusEngine( stagedKeyCommits: make(InclusionMap), stagedKeyPolynomials: make(PolynomialMap), syncingStatus: SyncStatusNotSyncing, + peerAnnounceMap: map[string]*protobufs.CeremonyPeerListAnnounce{}, + peerMap: map[string]*peerInfo{}, } logger.Info("constructing consensus engine") @@ -194,6 +208,35 @@ func (e *CeremonyDataClockConsensusEngine) Start( go e.handlePendingCommits(i) } + go func() { + for { + time.Sleep(30 * time.Second) + + list := &protobufs.CeremonyPeerListAnnounce{ + PeerList: []*protobufs.CeremonyPeer{}, + } + + e.peerMapMx.Lock() + e.peerMap[string(e.pubSub.GetPeerID())] = &peerInfo{ + peerId: e.pubSub.GetPeerID(), + multiaddr: "", + maxFrame: e.frame, + } + for _, v := range e.peerMap { + list.PeerList = append(list.PeerList, &protobufs.CeremonyPeer{ + PeerId: v.peerId, + Multiaddr: v.multiaddr, + MaxFrame: v.maxFrame, + }) + } + e.peerMapMx.Unlock() + + if err := e.publishMessage(e.filter, list); err != nil { + e.logger.Debug("error publishing message", zap.Error(err)) + } + } + }() + go func() { for e.state < consensus.EngineStateStopping { switch e.state { diff --git a/node/consensus/ceremony/consensus_frames.go b/node/consensus/ceremony/consensus_frames.go index d5fccd0..f298ab2 100644 --- a/node/consensus/ceremony/consensus_frames.go +++ b/node/consensus/ceremony/consensus_frames.go @@ -16,7 +16,6 @@ import ( "go.uber.org/zap" "golang.org/x/crypto/sha3" "google.golang.org/protobuf/proto" - "source.quilibrium.com/quilibrium/monorepo/go-libp2p-blossomsub/pb" "source.quilibrium.com/quilibrium/monorepo/nekryptology/pkg/core/curves" "source.quilibrium.com/quilibrium/monorepo/nekryptology/pkg/vdf" "source.quilibrium.com/quilibrium/monorepo/node/consensus" @@ -828,6 +827,29 @@ func (e *CeremonyDataClockConsensusEngine) commitLongestPath() ( return current, nil } +func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer() ( + []byte, + uint64, + error, +) { + e.peerMapMx.Lock() + max := e.frame + var peer []byte = nil + for _, v := range e.peerMap { + if v.maxFrame > max { + peer = v.peerId + max = v.maxFrame + } + } + e.peerMapMx.Unlock() + + if peer == nil { + return nil, 0, p2p.ErrNoPeersAvailable + } + + return peer, max, nil +} + func (e *CeremonyDataClockConsensusEngine) collect( currentFramePublished *protobufs.ClockFrame, ) (*protobufs.ClockFrame, error) { @@ -841,29 +863,25 @@ func (e *CeremonyDataClockConsensusEngine) collect( return nil, errors.Wrap(err, "collect") } + maxFrame := uint64(0) if e.syncingStatus == SyncStatusNotSyncing { - peerId, err := e.pubSub.GetRandomPeer(e.filter) + var peerId []byte + peerId, maxFrame, err = e.GetMostAheadPeer() if err != nil { - if errors.Is(err, p2p.ErrNoPeersAvailable) { - e.logger.Warn("no peers available, skipping sync") - } else { - e.logger.Error("error while fetching random peer", zap.Error(err)) - } + e.logger.Warn("no peers available, skipping sync") } else { e.syncingStatus = SyncStatusAwaitingResponse e.logger.Info( "setting syncing target", zap.String("peer_id", peer.ID(peerId).String()), ) - channel := e.createPeerReceiveChannel(peerId) - e.pubSub.Subscribe(channel, e.handleSync, true) - e.syncingTarget = peerId e.pubSub.Subscribe( append(append([]byte{}, e.filter...), peerId...), - func(message *pb.Message) error { return nil }, + e.handleSync, true, ) + e.syncingTarget = peerId go func() { time.Sleep(2 * time.Second) @@ -882,6 +900,7 @@ func (e *CeremonyDataClockConsensusEngine) collect( } } + performedSync := false waitDecay := time.Duration(2000) for e.syncingStatus != SyncStatusNotSyncing { e.logger.Info( @@ -892,13 +911,14 @@ func (e *CeremonyDataClockConsensusEngine) collect( time.Sleep(waitDecay * time.Millisecond) waitDecay = waitDecay * 2 - if waitDecay >= (100 * (2 << 6)) { + if waitDecay >= (100 * (2 << 7)) { if e.syncingStatus == SyncStatusAwaitingResponse { e.logger.Info("maximum wait for sync response, skipping sync") e.syncingStatus = SyncStatusNotSyncing break } else { - waitDecay = 100 * (2 << 6) + waitDecay = 100 * (2 << 7) + performedSync = true } } } @@ -926,7 +946,8 @@ func (e *CeremonyDataClockConsensusEngine) collect( zap.Uint64("frame_number", latestFrame.FrameNumber), ) - if latestFrame.FrameNumber >= currentFramePublished.FrameNumber { + if latestFrame.FrameNumber >= currentFramePublished.FrameNumber && + (!performedSync || e.frame+32 >= maxFrame) { e.setFrame(latestFrame) e.state = consensus.EngineStateProving return latestFrame, nil diff --git a/node/consensus/ceremony/peer_messaging.go b/node/consensus/ceremony/peer_messaging.go index c512529..707a6b0 100644 --- a/node/consensus/ceremony/peer_messaging.go +++ b/node/consensus/ceremony/peer_messaging.go @@ -47,6 +47,7 @@ func (e *CeremonyDataClockConsensusEngine) handleSync( message.From, msg.Address, any, + true, ); err != nil { return errors.Wrap(err, "handle sync") } @@ -87,24 +88,6 @@ func (e *CeremonyDataClockConsensusEngine) handleSync( return nil } -func (e *CeremonyDataClockConsensusEngine) createPeerReceiveChannel( - peerID []byte, -) []byte { - return append( - append(append([]byte{}, e.filter...), peerID...), - e.pubSub.GetPeerID()..., - ) -} - -func (e *CeremonyDataClockConsensusEngine) createPeerSendChannel( - peerID []byte, -) []byte { - return append( - append(append([]byte{}, e.filter...), e.pubSub.GetPeerID()...), - peerID..., - ) -} - func (e *CeremonyDataClockConsensusEngine) handleClockFramesResponse( peerID []byte, address []byte, @@ -399,8 +382,11 @@ func (e *CeremonyDataClockConsensusEngine) handleProvingKeyRequest( return nil } - channel := e.createPeerSendChannel(peerID) - e.pubSub.Subscribe(channel, e.handleSync, true) + e.pubSub.Subscribe( + append(append([]byte{}, e.filter...), peerID...), + e.handleSync, + true, + ) e.logger.Debug( "received proving key request", @@ -453,8 +439,11 @@ func (e *CeremonyDataClockConsensusEngine) handleProvingKeyRequest( } } - if err := e.publishMessage(channel, provingKey); err != nil { - return errors.Wrap(err, "handle proving key request") + if err := e.publishMessage( + append(append([]byte{}, e.filter...), peerID...), + provingKey, + ); err != nil { + return nil } return nil @@ -474,9 +463,11 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFramesRequest( return errors.Wrap(err, "handle clock frame request") } - channel := e.createPeerSendChannel(peerID) - - e.pubSub.Subscribe(channel, e.handleSync, true) + e.pubSub.Subscribe( + append(append([]byte{}, e.filter...), peerID...), + e.handleSync, + true, + ) e.logger.Info( "received clock frame request", @@ -502,19 +493,22 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFramesRequest( ) return errors.Wrap(err, "handle clock frame request") } else { - e.logger.Info( + e.logger.Debug( "peer asked for undiscovered frame", zap.Binary("peer_id", peerID), zap.Binary("address", address), zap.Uint64("frame_number", request.FromFrameNumber), ) - if err = e.publishMessage(channel, &protobufs.ClockFramesResponse{ - Filter: request.Filter, - FromFrameNumber: 0, - ToFrameNumber: 0, - ClockFrames: []*protobufs.ClockFrame{}, - }); err != nil { + if err = e.publishMessage( + append(append([]byte{}, e.filter...), peerID...), + &protobufs.ClockFramesResponse{ + Filter: request.Filter, + FromFrameNumber: 0, + ToFrameNumber: 0, + ClockFrames: []*protobufs.ClockFrame{}, + }, + ); err != nil { return errors.Wrap(err, "handle clock frame request") } @@ -567,7 +561,7 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFramesRequest( } } else { if err = e.publishMessage( - channel, + append(append([]byte{}, e.filter...), peerID...), frame, ); err != nil { return errors.Wrap(err, "handle clock frame request") @@ -609,7 +603,7 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFramesRequest( } if err = e.publishMessage( - channel, + append(append([]byte{}, e.filter...), peerID...), frame, ); err != nil { return errors.Wrap(err, "handle clock frame request") @@ -625,23 +619,5 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFramesRequest( searchSpan = nextSpan } - e.logger.Info( - "sending response", - zap.Binary("peer_id", peerID), - zap.Binary("address", address), - zap.Uint64("from", from), - zap.Uint64("to", to), - zap.Uint64("total_frames", uint64(len(set))), - ) - - if err = e.publishMessage(channel, &protobufs.ClockFramesResponse{ - Filter: request.Filter, - FromFrameNumber: request.FromFrameNumber, - ToFrameNumber: to, - ClockFrames: set, - }); err != nil { - return errors.Wrap(err, "handle clock frame request") - } - return nil } diff --git a/node/p2p/blossomsub.go b/node/p2p/blossomsub.go index f1cf52f..edba100 100644 --- a/node/p2p/blossomsub.go +++ b/node/p2p/blossomsub.go @@ -305,6 +305,10 @@ func (b *BlossomSub) GetNetworkPeersCount() int { return len(b.h.Network().Peers()) } +func (b *BlossomSub) GetMultiaddrOfPeer(peerId []byte) string { + return b.h.Peerstore().Addrs(peer.ID(peerId))[0].String() +} + func discoverPeers( p2pConfig *config.P2PConfig, ctx context.Context, diff --git a/node/p2p/pubsub.go b/node/p2p/pubsub.go index f9d6e76..3fff37c 100644 --- a/node/p2p/pubsub.go +++ b/node/p2p/pubsub.go @@ -14,4 +14,5 @@ type PubSub interface { GetPeerstoreCount() int GetNetworkPeersCount() int GetRandomPeer(bitmask []byte) ([]byte, error) + GetMultiaddrOfPeer(peerId []byte) string } diff --git a/node/protobufs/ceremony.pb.go b/node/protobufs/ceremony.pb.go index 8a06c18..7dc3f94 100644 --- a/node/protobufs/ceremony.pb.go +++ b/node/protobufs/ceremony.pb.go @@ -972,6 +972,116 @@ func (x *CeremonyValidatingState) GetNextRoundParticipants() []*Ed448PublicKey { return nil } +type CeremonyPeerListAnnounce struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PeerList []*CeremonyPeer `protobuf:"bytes,1,rep,name=peer_list,json=peerList,proto3" json:"peer_list,omitempty"` +} + +func (x *CeremonyPeerListAnnounce) Reset() { + *x = CeremonyPeerListAnnounce{} + if protoimpl.UnsafeEnabled { + mi := &file_ceremony_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CeremonyPeerListAnnounce) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CeremonyPeerListAnnounce) ProtoMessage() {} + +func (x *CeremonyPeerListAnnounce) ProtoReflect() protoreflect.Message { + mi := &file_ceremony_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CeremonyPeerListAnnounce.ProtoReflect.Descriptor instead. +func (*CeremonyPeerListAnnounce) Descriptor() ([]byte, []int) { + return file_ceremony_proto_rawDescGZIP(), []int{13} +} + +func (x *CeremonyPeerListAnnounce) GetPeerList() []*CeremonyPeer { + if x != nil { + return x.PeerList + } + return nil +} + +type CeremonyPeer struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PeerId []byte `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` + Multiaddr string `protobuf:"bytes,2,opt,name=multiaddr,proto3" json:"multiaddr,omitempty"` + MaxFrame uint64 `protobuf:"varint,3,opt,name=max_frame,json=maxFrame,proto3" json:"max_frame,omitempty"` +} + +func (x *CeremonyPeer) Reset() { + *x = CeremonyPeer{} + if protoimpl.UnsafeEnabled { + mi := &file_ceremony_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CeremonyPeer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CeremonyPeer) ProtoMessage() {} + +func (x *CeremonyPeer) ProtoReflect() protoreflect.Message { + mi := &file_ceremony_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CeremonyPeer.ProtoReflect.Descriptor instead. +func (*CeremonyPeer) Descriptor() ([]byte, []int) { + return file_ceremony_proto_rawDescGZIP(), []int{14} +} + +func (x *CeremonyPeer) GetPeerId() []byte { + if x != nil { + return x.PeerId + } + return nil +} + +func (x *CeremonyPeer) GetMultiaddr() string { + if x != nil { + return x.Multiaddr + } + return "" +} + +func (x *CeremonyPeer) GetMaxFrame() uint64 { + if x != nil { + return x.MaxFrame + } + return 0 +} + var File_ceremony_proto protoreflect.FileDescriptor var file_ceremony_proto_rawDesc = []byte{ @@ -1260,11 +1370,24 @@ var file_ceremony_proto_rawDesc = []byte{ 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x64, 0x34, 0x34, 0x38, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x52, 0x15, 0x6e, 0x65, 0x78, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x50, 0x61, 0x72, 0x74, - 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x42, 0x3a, 0x5a, 0x38, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2f, 0x6d, 0x6f, 0x6e, - 0x6f, 0x72, 0x65, 0x70, 0x6f, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x62, 0x0a, 0x18, 0x43, 0x65, 0x72, 0x65, + 0x6d, 0x6f, 0x6e, 0x79, 0x50, 0x65, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6e, 0x6e, 0x6f, + 0x75, 0x6e, 0x63, 0x65, 0x12, 0x46, 0x0a, 0x09, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, + 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, + 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x63, 0x65, 0x72, 0x65, 0x6d, 0x6f, + 0x6e, 0x79, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x65, 0x72, 0x65, 0x6d, 0x6f, 0x6e, 0x79, 0x50, 0x65, + 0x65, 0x72, 0x52, 0x08, 0x70, 0x65, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x62, 0x0a, 0x0c, + 0x43, 0x65, 0x72, 0x65, 0x6d, 0x6f, 0x6e, 0x79, 0x50, 0x65, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x07, + 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, + 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x64, + 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x61, + 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x46, 0x72, 0x61, 0x6d, 0x65, + 0x42, 0x3a, 0x5a, 0x38, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, + 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, + 0x72, 0x69, 0x75, 0x6d, 0x2f, 0x6d, 0x6f, 0x6e, 0x6f, 0x72, 0x65, 0x70, 0x6f, 0x2f, 0x6e, 0x6f, + 0x64, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x73, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1279,7 +1402,7 @@ func file_ceremony_proto_rawDescGZIP() []byte { return file_ceremony_proto_rawDescData } -var file_ceremony_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_ceremony_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_ceremony_proto_goTypes = []interface{}{ (*CeremonyTranscript)(nil), // 0: quilibrium.node.ceremony.pb.CeremonyTranscript (*CeremonyLobbyState)(nil), // 1: quilibrium.node.ceremony.pb.CeremonyLobbyState @@ -1294,59 +1417,62 @@ var file_ceremony_proto_goTypes = []interface{}{ (*CeremonyInProgressState)(nil), // 10: quilibrium.node.ceremony.pb.CeremonyInProgressState (*CeremonyFinalizingState)(nil), // 11: quilibrium.node.ceremony.pb.CeremonyFinalizingState (*CeremonyValidatingState)(nil), // 12: quilibrium.node.ceremony.pb.CeremonyValidatingState - (*BLS48581G1PublicKey)(nil), // 13: quilibrium.node.keys.pb.BLS48581G1PublicKey - (*BLS48581G2PublicKey)(nil), // 14: quilibrium.node.keys.pb.BLS48581G2PublicKey - (*Ed448PublicKey)(nil), // 15: quilibrium.node.keys.pb.Ed448PublicKey - (*Ed448Signature)(nil), // 16: quilibrium.node.keys.pb.Ed448Signature - (*BLS48581Signature)(nil), // 17: quilibrium.node.keys.pb.BLS48581Signature - (*X448PublicKey)(nil), // 18: quilibrium.node.keys.pb.X448PublicKey + (*CeremonyPeerListAnnounce)(nil), // 13: quilibrium.node.ceremony.pb.CeremonyPeerListAnnounce + (*CeremonyPeer)(nil), // 14: quilibrium.node.ceremony.pb.CeremonyPeer + (*BLS48581G1PublicKey)(nil), // 15: quilibrium.node.keys.pb.BLS48581G1PublicKey + (*BLS48581G2PublicKey)(nil), // 16: quilibrium.node.keys.pb.BLS48581G2PublicKey + (*Ed448PublicKey)(nil), // 17: quilibrium.node.keys.pb.Ed448PublicKey + (*Ed448Signature)(nil), // 18: quilibrium.node.keys.pb.Ed448Signature + (*BLS48581Signature)(nil), // 19: quilibrium.node.keys.pb.BLS48581Signature + (*X448PublicKey)(nil), // 20: quilibrium.node.keys.pb.X448PublicKey } var file_ceremony_proto_depIdxs = []int32{ - 13, // 0: quilibrium.node.ceremony.pb.CeremonyTranscript.g1_powers:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey - 14, // 1: quilibrium.node.ceremony.pb.CeremonyTranscript.g2_powers:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey - 13, // 2: quilibrium.node.ceremony.pb.CeremonyTranscript.running_g1_256_witnesses:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey - 14, // 3: quilibrium.node.ceremony.pb.CeremonyTranscript.running_g2_256_powers:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey + 15, // 0: quilibrium.node.ceremony.pb.CeremonyTranscript.g1_powers:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey + 16, // 1: quilibrium.node.ceremony.pb.CeremonyTranscript.g2_powers:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey + 15, // 2: quilibrium.node.ceremony.pb.CeremonyTranscript.running_g1_256_witnesses:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey + 16, // 3: quilibrium.node.ceremony.pb.CeremonyTranscript.running_g2_256_powers:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey 9, // 4: quilibrium.node.ceremony.pb.CeremonyLobbyState.ceremony_open_state:type_name -> quilibrium.node.ceremony.pb.CeremonyOpenState 10, // 5: quilibrium.node.ceremony.pb.CeremonyLobbyState.ceremony_in_progress_state:type_name -> quilibrium.node.ceremony.pb.CeremonyInProgressState 11, // 6: quilibrium.node.ceremony.pb.CeremonyLobbyState.ceremony_finalizing_state:type_name -> quilibrium.node.ceremony.pb.CeremonyFinalizingState 12, // 7: quilibrium.node.ceremony.pb.CeremonyLobbyState.ceremony_validating_state:type_name -> quilibrium.node.ceremony.pb.CeremonyValidatingState 0, // 8: quilibrium.node.ceremony.pb.CeremonyLobbyState.latest_transcript:type_name -> quilibrium.node.ceremony.pb.CeremonyTranscript - 15, // 9: quilibrium.node.ceremony.pb.CeremonySeenProverAttestation.seen_prover_key:type_name -> quilibrium.node.keys.pb.Ed448PublicKey - 16, // 10: quilibrium.node.ceremony.pb.CeremonySeenProverAttestation.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature - 15, // 11: quilibrium.node.ceremony.pb.CeremonyDroppedProverAttestation.dropped_prover_key:type_name -> quilibrium.node.keys.pb.Ed448PublicKey - 16, // 12: quilibrium.node.ceremony.pb.CeremonyDroppedProverAttestation.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature - 13, // 13: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g1_powers:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey - 14, // 14: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g2_powers:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey - 13, // 15: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g1_256_witness:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey - 14, // 16: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g2_256_witness:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey - 16, // 17: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature - 16, // 18: quilibrium.node.ceremony.pb.CeremonyTranscriptCommit.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature - 17, // 19: quilibrium.node.ceremony.pb.CeremonyTranscriptCommit.contribution_signature:type_name -> quilibrium.node.keys.pb.BLS48581Signature + 17, // 9: quilibrium.node.ceremony.pb.CeremonySeenProverAttestation.seen_prover_key:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 18, // 10: quilibrium.node.ceremony.pb.CeremonySeenProverAttestation.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature + 17, // 11: quilibrium.node.ceremony.pb.CeremonyDroppedProverAttestation.dropped_prover_key:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 18, // 12: quilibrium.node.ceremony.pb.CeremonyDroppedProverAttestation.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature + 15, // 13: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g1_powers:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey + 16, // 14: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g2_powers:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey + 15, // 15: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g1_256_witness:type_name -> quilibrium.node.keys.pb.BLS48581G1PublicKey + 16, // 16: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.additive_g2_256_witness:type_name -> quilibrium.node.keys.pb.BLS48581G2PublicKey + 18, // 17: quilibrium.node.ceremony.pb.CeremonyTranscriptShare.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature + 18, // 18: quilibrium.node.ceremony.pb.CeremonyTranscriptCommit.prover_signature:type_name -> quilibrium.node.keys.pb.Ed448Signature + 19, // 19: quilibrium.node.ceremony.pb.CeremonyTranscriptCommit.contribution_signature:type_name -> quilibrium.node.keys.pb.BLS48581Signature 5, // 20: quilibrium.node.ceremony.pb.CeremonyAdvanceRound.commits:type_name -> quilibrium.node.ceremony.pb.CeremonyTranscriptCommit - 18, // 21: quilibrium.node.ceremony.pb.CeremonyLobbyJoin.identity_key:type_name -> quilibrium.node.keys.pb.X448PublicKey - 18, // 22: quilibrium.node.ceremony.pb.CeremonyLobbyJoin.signed_pre_key:type_name -> quilibrium.node.keys.pb.X448PublicKey - 16, // 23: quilibrium.node.ceremony.pb.CeremonyLobbyJoin.public_key_signature_ed448:type_name -> quilibrium.node.keys.pb.Ed448Signature + 20, // 21: quilibrium.node.ceremony.pb.CeremonyLobbyJoin.identity_key:type_name -> quilibrium.node.keys.pb.X448PublicKey + 20, // 22: quilibrium.node.ceremony.pb.CeremonyLobbyJoin.signed_pre_key:type_name -> quilibrium.node.keys.pb.X448PublicKey + 18, // 23: quilibrium.node.ceremony.pb.CeremonyLobbyJoin.public_key_signature_ed448:type_name -> quilibrium.node.keys.pb.Ed448Signature 7, // 24: quilibrium.node.ceremony.pb.CeremonyOpenState.joined_participants:type_name -> quilibrium.node.ceremony.pb.CeremonyLobbyJoin - 15, // 25: quilibrium.node.ceremony.pb.CeremonyOpenState.preferred_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey - 15, // 26: quilibrium.node.ceremony.pb.CeremonyInProgressState.active_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 17, // 25: quilibrium.node.ceremony.pb.CeremonyOpenState.preferred_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 17, // 26: quilibrium.node.ceremony.pb.CeremonyInProgressState.active_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey 2, // 27: quilibrium.node.ceremony.pb.CeremonyInProgressState.latest_seen_prover_attestations:type_name -> quilibrium.node.ceremony.pb.CeremonySeenProverAttestation 3, // 28: quilibrium.node.ceremony.pb.CeremonyInProgressState.dropped_participant_attestations:type_name -> quilibrium.node.ceremony.pb.CeremonyDroppedProverAttestation 6, // 29: quilibrium.node.ceremony.pb.CeremonyInProgressState.transcript_round_advance_commits:type_name -> quilibrium.node.ceremony.pb.CeremonyAdvanceRound - 15, // 30: quilibrium.node.ceremony.pb.CeremonyInProgressState.next_round_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey - 15, // 31: quilibrium.node.ceremony.pb.CeremonyFinalizingState.active_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 17, // 30: quilibrium.node.ceremony.pb.CeremonyInProgressState.next_round_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 17, // 31: quilibrium.node.ceremony.pb.CeremonyFinalizingState.active_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey 2, // 32: quilibrium.node.ceremony.pb.CeremonyFinalizingState.latest_seen_prover_attestations:type_name -> quilibrium.node.ceremony.pb.CeremonySeenProverAttestation 3, // 33: quilibrium.node.ceremony.pb.CeremonyFinalizingState.dropped_participant_attestations:type_name -> quilibrium.node.ceremony.pb.CeremonyDroppedProverAttestation 5, // 34: quilibrium.node.ceremony.pb.CeremonyFinalizingState.commits:type_name -> quilibrium.node.ceremony.pb.CeremonyTranscriptCommit 4, // 35: quilibrium.node.ceremony.pb.CeremonyFinalizingState.shares:type_name -> quilibrium.node.ceremony.pb.CeremonyTranscriptShare - 15, // 36: quilibrium.node.ceremony.pb.CeremonyFinalizingState.next_round_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 17, // 36: quilibrium.node.ceremony.pb.CeremonyFinalizingState.next_round_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey 5, // 37: quilibrium.node.ceremony.pb.CeremonyValidatingState.commits:type_name -> quilibrium.node.ceremony.pb.CeremonyTranscriptCommit 0, // 38: quilibrium.node.ceremony.pb.CeremonyValidatingState.updated_transcript:type_name -> quilibrium.node.ceremony.pb.CeremonyTranscript - 15, // 39: quilibrium.node.ceremony.pb.CeremonyValidatingState.next_round_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey - 40, // [40:40] is the sub-list for method output_type - 40, // [40:40] is the sub-list for method input_type - 40, // [40:40] is the sub-list for extension type_name - 40, // [40:40] is the sub-list for extension extendee - 0, // [0:40] is the sub-list for field type_name + 17, // 39: quilibrium.node.ceremony.pb.CeremonyValidatingState.next_round_participants:type_name -> quilibrium.node.keys.pb.Ed448PublicKey + 14, // 40: quilibrium.node.ceremony.pb.CeremonyPeerListAnnounce.peer_list:type_name -> quilibrium.node.ceremony.pb.CeremonyPeer + 41, // [41:41] is the sub-list for method output_type + 41, // [41:41] is the sub-list for method input_type + 41, // [41:41] is the sub-list for extension type_name + 41, // [41:41] is the sub-list for extension extendee + 0, // [0:41] is the sub-list for field type_name } func init() { file_ceremony_proto_init() } @@ -1512,6 +1638,30 @@ func file_ceremony_proto_init() { return nil } } + file_ceremony_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CeremonyPeerListAnnounce); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ceremony_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CeremonyPeer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_ceremony_proto_msgTypes[1].OneofWrappers = []interface{}{ (*CeremonyLobbyState_CeremonyOpenState)(nil), @@ -1525,7 +1675,7 @@ func file_ceremony_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_ceremony_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 15, NumExtensions: 0, NumServices: 0, }, diff --git a/node/protobufs/ceremony.proto b/node/protobufs/ceremony.proto index 8876337..d5152b7 100644 --- a/node/protobufs/ceremony.proto +++ b/node/protobufs/ceremony.proto @@ -123,4 +123,14 @@ message CeremonyValidatingState { repeated CeremonyTranscriptCommit commits = 1; CeremonyTranscript updated_transcript = 2; repeated quilibrium.node.keys.pb.Ed448PublicKey next_round_participants = 3; -} \ No newline at end of file +} + +message CeremonyPeerListAnnounce { + repeated CeremonyPeer peer_list = 1; +} + +message CeremonyPeer { + bytes peer_id = 1; + string multiaddr = 2; + uint64 max_frame = 3; +} diff --git a/node/protobufs/protobufs.go b/node/protobufs/protobufs.go index df5ad38..67af4bb 100644 --- a/node/protobufs/protobufs.go +++ b/node/protobufs/protobufs.go @@ -21,6 +21,8 @@ const ( CeremonyInProgressStateType = CeremonyPrefix + "CeremonyInProgressState" CeremonyFinalizingStateType = CeremonyPrefix + "CeremonyFinalizingState" CeremonyValidatingStateType = CeremonyPrefix + "CeremonyValidatingState" + CeremonyPeerListAnnounceType = CeremonyPrefix + "CeremonyPeerListAnnounce" + CeremonyPeerType = CeremonyPrefix + "CeremonyPeer" ApplicationType = AppPrefix + "Application" ExecutionContextType = AppPrefix + "ExecutionContext" MessageType = AppPrefix + "Message"