diff --git a/go.mod b/go.mod index 1071740d..d09e0364 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/prometheus/client_golang v1.13.0 github.com/ryanuber/columnize v2.1.2+incompatible github.com/spf13/cobra v1.5.0 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.1 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/umbracle/fastrlp v0.0.0-20220527094140-59d5dd30e722 github.com/umbracle/go-eth-bn256 v0.0.0-20190607160430-b36caf4e0f6b @@ -61,7 +61,7 @@ require ( lukechampine.com/blake3 v1.1.7 // indirect ) -require github.com/0xPolygon/go-ibft v0.0.0-20220810095021-e43142f8d267 +require github.com/0xPolygon/go-ibft v0.3.0 require ( cloud.google.com/go v0.102.0 // indirect diff --git a/go.sum b/go.sum index 3c06b7a5..24b228f3 100644 --- a/go.sum +++ b/go.sum @@ -71,10 +71,8 @@ filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7 git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw= git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= -github.com/0xPolygon/go-ibft v0.0.0-20220729102524-0f95a9c3a08c h1:y9Fw+byHhcrV8378z20d2WlyIoHOZiZbPIVAQ9VDuyw= -github.com/0xPolygon/go-ibft v0.0.0-20220729102524-0f95a9c3a08c/go.mod h1:pXhBaK+CcHr3eUAWynKyHGTxgDwpJ3O1tvbGthN+pN4= -github.com/0xPolygon/go-ibft v0.0.0-20220810095021-e43142f8d267 h1:+mFLx9IKW16fOcTKjZjkom3TGnihOuPwYAz2c6+UUWQ= -github.com/0xPolygon/go-ibft v0.0.0-20220810095021-e43142f8d267/go.mod h1:QPrugDXgsCFy2FeCJ0YokPrnyi1GoLhDj/PLO1dSoNY= +github.com/0xPolygon/go-ibft v0.3.0 h1:4j8yaRgArErnZy1alQUHOSStD/ogAoEWVRn/CG0JlvI= +github.com/0xPolygon/go-ibft v0.3.0/go.mod h1:mJGwdcGvLdg9obtnzBqx1aAzuhzvGeWav5AiUWN7F3Q= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= @@ -661,6 +659,7 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -1175,8 +1174,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -1185,8 +1185,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= @@ -1262,8 +1263,9 @@ go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= @@ -1945,6 +1947,8 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= +pgregory.net/rapid v0.5.3 h1:163N50IHFqr1phZens4FQOdPgfJscR7a562mjQqeo4M= +pgregory.net/rapid v0.5.3/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/vendor/github.com/0xPolygon/go-ibft/core/backend.go b/vendor/github.com/0xPolygon/go-ibft/core/backend.go index 258b1208..ceab0d12 100644 --- a/vendor/github.com/0xPolygon/go-ibft/core/backend.go +++ b/vendor/github.com/0xPolygon/go-ibft/core/backend.go @@ -1,3 +1,5 @@ +// Package core implements IBFT consensus +// backend.go defines interfaces of backend, that performs detailed procedure rather than consensus package core import ( @@ -6,23 +8,26 @@ import ( ) // MessageConstructor defines a message constructor interface +// All constructed messages must be signed by a validator for the whole message type MessageConstructor interface { - // BuildPrePrepareMessage builds a PREPREPARE message based on the passed in proposal + // BuildPrePrepareMessage builds a PREPREPARE message based on the passed in view and proposal BuildPrePrepareMessage( - proposal []byte, + rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, ) *proto.Message - // BuildPrepareMessage builds a PREPARE message based on the passed in proposal + // BuildPrepareMessage builds a PREPARE message based on the passed in view and proposal hash BuildPrepareMessage(proposalHash []byte, view *proto.View) *proto.Message - // BuildCommitMessage builds a COMMIT message based on the passed in proposal + // BuildCommitMessage builds a COMMIT message based on the passed in view and proposal hash + // Must create a committed seal for proposal hash and include it into the message BuildCommitMessage(proposalHash []byte, view *proto.View) *proto.Message - // BuildRoundChangeMessage builds a ROUND_CHANGE message based on the passed in proposal + // BuildRoundChangeMessage builds a ROUND_CHANGE message based on the passed in view, + // latest prepared proposal, and latest prepared certificate BuildRoundChangeMessage( - proposal []byte, + proposal *proto.Proposal, certificate *proto.PreparedCertificate, view *proto.View, ) *proto.Message @@ -30,20 +35,24 @@ type MessageConstructor interface { // Verifier defines the verifier interface type Verifier interface { - // IsValidBlock checks if the proposed block is child of parent - IsValidBlock(block []byte) bool + // IsValidProposal checks if the proposal is valid + IsValidProposal(rawProposal []byte) bool - // IsValidSender checks if signature is from sender - IsValidSender(msg *proto.Message) bool + // IsValidValidator checks if a signature in message is signed by sender + // Must check the following things: + // (1) recover the signature and the signer matches from address in message + // (2) the signer address is one of the validators at the height in message + IsValidValidator(msg *proto.Message) bool // IsProposer checks if the passed in ID is the Proposer for current view (sequence, round) IsProposer(id []byte, height, round uint64) bool // IsValidProposalHash checks if the hash matches the proposal - IsValidProposalHash(proposal, hash []byte) bool + IsValidProposalHash(proposal *proto.Proposal, hash []byte) bool - // IsValidCommittedSeal checks if the seal for the proposal is valid - IsValidCommittedSeal(proposal []byte, committedSeal *messages.CommittedSeal) bool + // IsValidCommittedSeal checks + // if signature for proposal hash in committed seal is signed by a validator + IsValidCommittedSeal(proposalHash []byte, committedSeal *messages.CommittedSeal) bool } // Backend defines an interface all backend implementations @@ -52,20 +61,18 @@ type Backend interface { MessageConstructor Verifier - // BuildProposal builds a new block proposal - BuildProposal(blockNumber uint64) []byte + // BuildProposal builds a new proposal for the given view (height and round) + BuildProposal(view *proto.View) []byte - // InsertBlock inserts a proposal with the specified committed seals - InsertBlock(proposal []byte, committedSeals []*messages.CommittedSeal) + // InsertProposal inserts a proposal with the specified committed seals + // the reason why we are including round here is because a single committedSeal + // has signed the tuple of (rawProposal, round) + InsertProposal(proposal *proto.Proposal, committedSeals []*messages.CommittedSeal) // ID returns the validator's ID ID() []byte - // MaximumFaultyNodes returns the maximum number of faulty nodes based - // on the validator set. - MaximumFaultyNodes() uint64 - - // Quorum returns what is the quorum size for the - // specified block height. - Quorum(blockHeight uint64) uint64 + // HasQuorum returns true if the quorum is reached + // for the specified height. + HasQuorum(height uint64, msgs []*proto.Message, msgType proto.MessageType) bool } diff --git a/vendor/github.com/0xPolygon/go-ibft/core/ibft.go b/vendor/github.com/0xPolygon/go-ibft/core/ibft.go index 69778601..db3fd86e 100644 --- a/vendor/github.com/0xPolygon/go-ibft/core/ibft.go +++ b/vendor/github.com/0xPolygon/go-ibft/core/ibft.go @@ -12,23 +12,32 @@ import ( "github.com/0xPolygon/go-ibft/messages/proto" ) +// Logger represents the logger behaviour type Logger interface { Info(msg string, args ...interface{}) Debug(msg string, args ...interface{}) Error(msg string, args ...interface{}) } +// Messages represents the message managing behaviour type Messages interface { // Messages modifiers // AddMessage(message *proto.Message) PruneByHeight(height uint64) + SignalEvent(message *proto.Message) + // Messages fetchers // GetValidMessages( view *proto.View, messageType proto.MessageType, isValid func(*proto.Message) bool, ) []*proto.Message + GetExtendedRCC( + height uint64, + isValidMessage func(message *proto.Message) bool, + isValidRCC func(round uint64, msgs []*proto.Message) bool, + ) []*proto.Message GetMostRoundChangeMessages(minRound, height uint64) []*proto.Message // Messages subscription handlers // @@ -36,10 +45,13 @@ type Messages interface { Unsubscribe(id messages.SubscriptionID) } +const ( + round0Timeout = 10 * time.Second + roundFactorBase = float64(2) +) + var ( errTimeoutExpired = errors.New("round timeout expired") - - round0Timeout = 10 * time.Second ) // IBFT represents a single instance of the IBFT state machine @@ -123,14 +135,10 @@ func NewIBFT( func (i *IBFT) startRoundTimer(ctx context.Context, round uint64) { defer i.wg.Done() - var ( - duration = int(i.baseRoundTimeout) - roundFactor = int(math.Pow(float64(2), float64(round))) - roundTimeout = time.Duration(duration * roundFactor) - ) + roundTimeout := getRoundTimeout(i.baseRoundTimeout, i.additionalTimeout, round) // Create a new timer instance - timer := time.NewTimer(roundTimeout + i.additionalTimeout) + timer := time.NewTimer(roundTimeout) select { case <-ctx.Done(): @@ -143,9 +151,9 @@ func (i *IBFT) startRoundTimer(ctx context.Context, round uint64) { } } -// signalRoundExpired notifies the sequence routine (RunSequence) that it -// should move to a new round. The quit channel is used to abort this call -// if another routine has already signaled a round change request. +// signalRoundExpired notifies the sequence routine (RunSequence) that it +// should move to a new round. The quit channel is used to abort this call +// if another routine has already signaled a round change request. func (i *IBFT) signalRoundExpired(ctx context.Context) { select { case i.roundExpired <- struct{}{}: @@ -153,8 +161,8 @@ func (i *IBFT) signalRoundExpired(ctx context.Context) { } } -// signalRoundDone notifies the sequence routine (RunSequence) that the -// consensus sequence is finished +// signalRoundDone notifies the sequence routine (RunSequence) that the +// consensus sequence is finished func (i *IBFT) signalRoundDone(ctx context.Context) { select { case i.roundDone <- struct{}{}: @@ -200,8 +208,8 @@ func (i *IBFT) watchForFutureProposal(ctx context.Context) { Height: height, Round: nextRound, }, - MinNumMessages: 1, - HasMinRound: true, + HasMinRound: true, + HasQuorumFn: i.backend.HasQuorum, }) ) @@ -242,7 +250,6 @@ func (i *IBFT) watchForRoundChangeCertificates(ctx context.Context) { view = i.state.getView() height = view.Height round = view.Round - quorum = i.backend.Quorum(height) sub = i.messages.Subscribe(messages.SubscriptionDetails{ MessageType: proto.MessageType_ROUND_CHANGE, @@ -250,8 +257,10 @@ func (i *IBFT) watchForRoundChangeCertificates(ctx context.Context) { Height: height, Round: round + 1, // only for higher rounds }, - MinNumMessages: 1, - HasMinRound: true, + HasMinRound: true, + HasQuorumFn: func(_ uint64, messages []*proto.Message, _ proto.MessageType) bool { + return len(messages) >= 1 + }, }) ) @@ -261,20 +270,21 @@ func (i *IBFT) watchForRoundChangeCertificates(ctx context.Context) { select { case <-ctx.Done(): return - case round := <-sub.SubCh: + case <-sub.SubCh: rcc := i.handleRoundChangeMessage( &proto.View{ Height: height, Round: round, }, - quorum, ) if rcc == nil { continue } + newRound := rcc.RoundChangeMessages[0].View.Round + // we received a valid RCC for a higher round - i.signalNewRCC(ctx, round) + i.signalNewRCC(ctx, newRound) return } @@ -325,6 +335,7 @@ func (i *IBFT) RunSequence(ctx context.Context, h uint64) { i.moveToNewRound(ev.round) i.acceptProposal(ev.proposalMessage) i.state.setRoundStarted(true) + i.sendPrepareMessage(view) case round := <-i.roundCertificate: teardown() i.log.Info("received future RCC", "round", round) @@ -344,7 +355,7 @@ func (i *IBFT) RunSequence(ctx context.Context, h uint64) { teardown() return - case <-ctx.Done(): + case <-ctxRound.Done(): teardown() i.log.Debug("sequence cancelled") @@ -394,17 +405,16 @@ func (i *IBFT) waitForRCC( round uint64, ) *proto.RoundChangeCertificate { var ( - quorum = i.backend.Quorum(height) - view = &proto.View{ + view = &proto.View{ Height: height, Round: round, } sub = i.messages.Subscribe( messages.SubscriptionDetails{ - MessageType: proto.MessageType_ROUND_CHANGE, - View: view, - MinNumMessages: int(quorum), + MessageType: proto.MessageType_ROUND_CHANGE, + View: view, + HasQuorumFn: i.backend.HasQuorum, }, ) ) @@ -416,7 +426,7 @@ func (i *IBFT) waitForRCC( case <-ctx.Done(): return nil case <-sub.SubCh: - rcc := i.handleRoundChangeMessage(view, quorum) + rcc := i.handleRoundChangeMessage(view) if rcc == nil { continue } @@ -428,18 +438,18 @@ func (i *IBFT) waitForRCC( // handleRoundChangeMessage validates the round change message // and constructs a RCC if possible -func (i *IBFT) handleRoundChangeMessage(view *proto.View, quorum uint64) *proto.RoundChangeCertificate { +func (i *IBFT) handleRoundChangeMessage(view *proto.View) *proto.RoundChangeCertificate { var ( - height = view.Height - round = view.Round + height = view.Height + hasAcceptedProposal = i.state.getProposal() != nil ) - isValidFn := func(msg *proto.Message) bool { - proposal := messages.ExtractLastPreparedProposedBlock(msg) + isValidMsgFn := func(msg *proto.Message) bool { + proposal := messages.ExtractLastPreparedProposal(msg) certificate := messages.ExtractLatestPC(msg) // Check if the prepared certificate is valid - if !i.validPC(certificate, round, height) { + if !i.validPC(certificate, msg.View.Round, height) { return false } @@ -447,25 +457,35 @@ func (i *IBFT) handleRoundChangeMessage(view *proto.View, quorum uint64) *proto. return i.proposalMatchesCertificate(proposal, certificate) } - msgs := i.messages.GetValidMessages( - view, - proto.MessageType_ROUND_CHANGE, - isValidFn, + isValidRCCFn := func(round uint64, msgs []*proto.Message) bool { + // In case of that ROUND-CHANGE message's round match validator's round + // Accept such messages only if the validator has not accepted a proposal at the round + if round == view.Round && hasAcceptedProposal { + return false + } + + return i.backend.HasQuorum(height, msgs, proto.MessageType_ROUND_CHANGE) + } + + extendedRCC := i.messages.GetExtendedRCC( + height, + isValidMsgFn, + isValidRCCFn, ) - if len(msgs) < int(quorum) { + if extendedRCC == nil { return nil } return &proto.RoundChangeCertificate{ - RoundChangeMessages: msgs, + RoundChangeMessages: extendedRCC, } } // proposalMatchesCertificate checks a prepared certificate // against a proposal func (i *IBFT) proposalMatchesCertificate( - proposal []byte, + proposal *proto.Proposal, certificate *proto.PreparedCertificate, ) bool { // Both the certificate and proposal need to be set @@ -501,7 +521,7 @@ func (i *IBFT) proposalMatchesCertificate( return true } -// runStates is the main loop which performs state transitions +// runStates is the main loop which performs state transitions func (i *IBFT) runStates(ctx context.Context) { var timeout error @@ -541,9 +561,11 @@ func (i *IBFT) runNewRound(ctx context.Context) error { // Subscribe for PREPREPARE messages sub = i.messages.Subscribe( messages.SubscriptionDetails{ - MessageType: proto.MessageType_PREPREPARE, - View: view, - MinNumMessages: 1, + MessageType: proto.MessageType_PREPREPARE, + View: view, + HasQuorumFn: func(_ uint64, messages []*proto.Message, _ proto.MessageType) bool { + return len(messages) >= 1 + }, }, ) ) @@ -565,10 +587,8 @@ func (i *IBFT) runNewRound(ctx context.Context) error { continue } - // Accept the proposal since it's valid - i.acceptProposal(proposalMessage) - // Multicast the PREPARE message + i.state.setProposalMessage(proposalMessage) i.sendPrepareMessage(view) i.log.Debug("prepare message multicasted") @@ -592,6 +612,11 @@ func (i *IBFT) validateProposalCommon(msg *proto.Message, view *proto.View) bool proposalHash = messages.ExtractProposalHash(msg) ) + // round matches + if proposal.Round != view.Round { + return false + } + // is proposer if !i.backend.IsProposer(msg.From, height, round) { return false @@ -602,8 +627,8 @@ func (i *IBFT) validateProposalCommon(msg *proto.Message, view *proto.View) bool return false } - // is valid block - return i.backend.IsValidBlock(proposal) + // is valid proposal + return i.backend.IsValidProposal(proposal.GetRawProposal()) } // validateProposal0 validates the proposal for round 0 @@ -638,7 +663,6 @@ func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { round = view.Round proposalHash = messages.ExtractProposalHash(msg) - certificate = messages.ExtractRoundChangeCertificate(msg) rcc = messages.ExtractRoundChangeCertificate(msg) ) @@ -648,12 +672,12 @@ func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { } // Make sure there is a certificate - if certificate == nil { + if rcc == nil { return false } // Make sure there are Quorum RCC - if len(certificate.RoundChangeMessages) < int(i.backend.Quorum(height)) { + if !i.backend.HasQuorum(view.Height, rcc.RoundChangeMessages, proto.MessageType_ROUND_CHANGE) { return false } @@ -662,12 +686,31 @@ func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { return false } + if !messages.HasUniqueSenders(rcc.RoundChangeMessages) { + return false + } + // Make sure all messages in the RCC are valid Round Change messages - for _, rc := range certificate.RoundChangeMessages { + for _, rc := range rcc.RoundChangeMessages { // Make sure the message is a Round Change message if rc.Type != proto.MessageType_ROUND_CHANGE { return false } + + // Height of the message matches height of the proposal + if rc.View.Height != height { + return false + } + + // Round of the message matches round of the proposal + if rc.View.Round != round { + return false + } + + // Sender of RCC is valid + if !i.backend.IsValidValidator(rc) { + return false + } } // Extract possible rounds and their corresponding @@ -680,14 +723,14 @@ func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { roundsAndPreparedBlockHashes := make([]roundHashTuple, 0) for _, rcMessage := range rcc.RoundChangeMessages { - certificate := messages.ExtractLatestPC(rcMessage) + cert := messages.ExtractLatestPC(rcMessage) // Check if there is a certificate, and if it's a valid PC - if certificate != nil && i.validPC(certificate, msg.View.Round, height) { - hash := messages.ExtractProposalHash(certificate.ProposalMessage) + if cert != nil && i.validPC(cert, msg.View.Round, height) { + hash := messages.ExtractProposalHash(cert.ProposalMessage) roundsAndPreparedBlockHashes = append(roundsAndPreparedBlockHashes, roundHashTuple{ - round: rcMessage.View.Round, + round: cert.ProposalMessage.View.Round, hash: hash, }) } @@ -699,12 +742,12 @@ func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { // Find the max round var ( - maxRound uint64 = 0 - expectedHash []byte = nil + maxRound uint64 + expectedHash []byte ) for _, tuple := range roundsAndPreparedBlockHashes { - if tuple.round > maxRound { + if tuple.round >= maxRound { maxRound = tuple.round expectedHash = tuple.hash } @@ -713,8 +756,8 @@ func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { return bytes.Equal(expectedHash, proposalHash) } -// handlePrePrepare parses the received proposal and performs -// a transition to PREPARE state, if the proposal is valid +// handlePrePrepare parses the received proposal and performs +// a transition to PREPARE state, if the proposal is valid func (i *IBFT) handlePrePrepare(view *proto.View) *proto.Message { isValidPrePrepare := func(message *proto.Message) bool { if view.Round == 0 { @@ -747,15 +790,12 @@ func (i *IBFT) runPrepare(ctx context.Context) error { // Grab the current view view = i.state.getView() - // Grab quorum information - quorum = i.backend.Quorum(view.Height) - // Subscribe to PREPARE messages sub = i.messages.Subscribe( messages.SubscriptionDetails{ - MessageType: proto.MessageType_PREPARE, - View: view, - MinNumMessages: int(quorum) - 1, + MessageType: proto.MessageType_PREPARE, + View: view, + HasQuorumFn: i.backend.HasQuorum, }, ) ) @@ -770,7 +810,7 @@ func (i *IBFT) runPrepare(ctx context.Context) error { // Stop signal received, exit return errTimeoutExpired case <-sub.SubCh: - if !i.handlePrepare(view, quorum) { + if !i.handlePrepare(view) { // quorum of valid prepare messages not received, retry continue } @@ -780,9 +820,9 @@ func (i *IBFT) runPrepare(ctx context.Context) error { } } -// handlePrepare parses available prepare messages and performs -// a transition to COMMIT state, if quorum was reached -func (i *IBFT) handlePrepare(view *proto.View, quorum uint64) bool { +// handlePrepare parses available prepare messages and performs +// a transition to COMMIT state, if quorum was reached +func (i *IBFT) handlePrepare(view *proto.View) bool { isValidPrepare := func(message *proto.Message) bool { // Verify that the proposal hash is valid return i.backend.IsValidProposalHash( @@ -797,7 +837,7 @@ func (i *IBFT) handlePrepare(view *proto.View, quorum uint64) bool { isValidPrepare, ) - if len(prepareMessages) < int(quorum)-1 { + if !i.backend.HasQuorum(view.Height, prepareMessages, proto.MessageType_PREPARE) { // quorum not reached, keep polling return false } @@ -827,15 +867,12 @@ func (i *IBFT) runCommit(ctx context.Context) error { // Grab the current view view = i.state.getView() - // Grab quorum information - quorum = i.backend.Quorum(view.Height) - // Subscribe to COMMIT messages sub = i.messages.Subscribe( messages.SubscriptionDetails{ - MessageType: proto.MessageType_COMMIT, - View: view, - MinNumMessages: int(quorum), + MessageType: proto.MessageType_COMMIT, + View: view, + HasQuorumFn: i.backend.HasQuorum, }, ) ) @@ -850,7 +887,7 @@ func (i *IBFT) runCommit(ctx context.Context) error { // Stop signal received, exit return errTimeoutExpired case <-sub.SubCh: - if !i.handleCommit(view, quorum) { + if !i.handleCommit(view) { // quorum not reached, retry continue } @@ -860,9 +897,9 @@ func (i *IBFT) runCommit(ctx context.Context) error { } } -// handleCommit parses available commit messages and performs -// a transition to FIN state, if quorum was reached -func (i *IBFT) handleCommit(view *proto.View, quorum uint64) bool { +// handleCommit parses available commit messages and performs +// a transition to FIN state, if quorum was reached +func (i *IBFT) handleCommit(view *proto.View) bool { isValidCommit := func(message *proto.Message) bool { var ( proposalHash = messages.ExtractCommitHash(message) @@ -878,15 +915,21 @@ func (i *IBFT) handleCommit(view *proto.View, quorum uint64) bool { } commitMessages := i.messages.GetValidMessages(view, proto.MessageType_COMMIT, isValidCommit) - if len(commitMessages) < int(quorum) { + if !i.backend.HasQuorum(view.Height, commitMessages, proto.MessageType_COMMIT) { // quorum not reached, keep polling return false } + commitSeals, err := messages.ExtractCommittedSeals(commitMessages) + if err != nil { + // safe check + i.log.Error("failed to extract committed seals from commit messages: %+v", err) + + return false + } + // Set the committed seals - i.state.setCommittedSeals( - messages.ExtractCommittedSeals(commitMessages), - ) + i.state.setCommittedSeals(commitSeals) // Move to the fin state i.state.changeState(fin) @@ -901,8 +944,11 @@ func (i *IBFT) runFin() { // Insert the block to the node's underlying // blockchain layer - i.backend.InsertBlock( - i.state.getProposal(), + i.backend.InsertProposal( + &proto.Proposal{ + RawProposal: i.state.getRawDataFromProposal(), + Round: i.state.getRound(), + }, i.state.getCommittedSeals(), ) @@ -929,10 +975,14 @@ func (i *IBFT) buildProposal(ctx context.Context, view *proto.View) *proto.Messa ) if round == 0 { - proposal := i.backend.BuildProposal(height) + rawProposal := i.backend.BuildProposal( + &proto.View{ + Height: height, + Round: round, + }) return i.backend.BuildPrePrepareMessage( - proposal, + rawProposal, nil, &proto.View{ Height: height, @@ -949,22 +999,42 @@ func (i *IBFT) buildProposal(ctx context.Context, view *proto.View) *proto.Messa } // check the messages for any previous proposal (if they have any, it's the same proposal) - var previousProposal []byte + var ( + previousProposal []byte + maxRound uint64 + ) + // take previous proposal among the round change messages for the highest round for _, msg := range rcc.RoundChangeMessages { - // if message contains block, break latestPC := messages.ExtractLatestPC(msg) + if latestPC == nil { + continue + } - if latestPC != nil { - previousProposal = messages.ExtractLastPreparedProposedBlock(msg) + // skip if message's round is equals to/less than maxRound + msgRound := msg.View.Round + if msgRound <= maxRound { + continue + } + + lastPB := messages.ExtractLastPreparedProposal(msg) + if lastPB == nil { + continue + } - break + if msgRound > maxRound { + previousProposal = lastPB.RawProposal + maxRound = msgRound } } if previousProposal == nil { // build new proposal - proposal := i.backend.BuildProposal(height) + proposal := i.backend.BuildProposal( + &proto.View{ + Height: height, + Round: round, + }) return i.backend.BuildPrePrepareMessage( proposal, @@ -1003,13 +1073,21 @@ func (i *IBFT) AddMessage(message *proto.Message) { // Check if the message should even be considered if i.isAcceptableMessage(message) { i.messages.AddMessage(message) + + msgs := i.messages.GetValidMessages( + message.View, + message.Type, + func(_ *proto.Message) bool { return true }) + if i.backend.HasQuorum(message.View.Height, msgs, message.Type) { + i.messages.SignalEvent(message) + } } } // isAcceptableMessage checks if the message can even be accepted func (i *IBFT) isAcceptableMessage(message *proto.Message) bool { // Make sure the message sender is ok - if !i.backend.IsValidSender(message) { + if !i.backend.IsValidValidator(message) { return false } @@ -1028,12 +1106,12 @@ func (i *IBFT) isAcceptableMessage(message *proto.Message) bool { return message.View.Round >= i.state.getRound() } -// ExtendRoundTimeout extends each round's timer by the specified amount. +// ExtendRoundTimeout extends each round's timer by the specified amount. func (i *IBFT) ExtendRoundTimeout(amount time.Duration) { i.additionalTimeout = amount } -// validPC verifies that the prepared certificate is valid +// validPC verifies that the prepared certificate is valid func (i *IBFT) validPC( certificate *proto.PreparedCertificate, rLimit, @@ -1049,13 +1127,15 @@ func (i *IBFT) validPC( return false } + // Order of messages is important! + // Message with type of MessageType_PREPREPARE must be the first element of allMessages slice allMessages := append( []*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages..., ) // Make sure there are at least Quorum (PP + P) messages - if len(allMessages) < int(i.backend.Quorum(i.state.getHeight())) { + if !i.backend.HasQuorum(i.state.getHeight(), allMessages, proto.MessageType_PREPARE) { return false } @@ -1091,6 +1171,11 @@ func (i *IBFT) validPC( return false } + // Make sure all have the same round + if !messages.AllHaveSameRound(allMessages) { + return false + } + // Make sure the proposal message is sent by the proposer // for the round proposal := certificate.ProposalMessage @@ -1098,10 +1183,20 @@ func (i *IBFT) validPC( return false } + // Make sure that the proposal sender is valid + if !i.backend.IsValidValidator(proposal) { + return false + } + // Make sure the Prepare messages are validators, apart from the proposer for _, message := range certificate.PrepareMessages { // Make sure the sender is part of the validator set - if !i.backend.IsValidSender(message) { + if !i.backend.IsValidValidator(message) { + return false + } + + // Make sure the current node is not the proposer + if i.backend.IsProposer(message.From, message.View.Height, message.View.Round) { return false } } @@ -1118,7 +1213,7 @@ func (i *IBFT) sendPreprepareMessage(message *proto.Message) { func (i *IBFT) sendRoundChangeMessage(height, newRound uint64) { i.transport.Multicast( i.backend.BuildRoundChangeMessage( - i.state.getLatestPreparedProposedBlock(), + i.state.getLatestPreparedProposal(), i.state.getLatestPC(), &proto.View{ Height: height, @@ -1147,3 +1242,20 @@ func (i *IBFT) sendCommitMessage(view *proto.View) { ), ) } + +// getRoundTimeout creates a round timeout based on the base timeout and the current round. +// Exponentially increases timeout depending on the round number. +// For instance: +// - round 1: 1 sec +// - round 2: 2 sec +// - round 3: 4 sec +// - round 4: 8 sec +func getRoundTimeout(baseRoundTimeout, additionalTimeout time.Duration, round uint64) time.Duration { + var ( + duration = int(baseRoundTimeout) + roundFactor = int(math.Pow(roundFactorBase, float64(round))) + roundTimeout = time.Duration(duration * roundFactor) + ) + + return roundTimeout + additionalTimeout +} diff --git a/vendor/github.com/0xPolygon/go-ibft/core/state.go b/vendor/github.com/0xPolygon/go-ibft/core/state.go index 2c773dd8..eebb18fd 100644 --- a/vendor/github.com/0xPolygon/go-ibft/core/state.go +++ b/vendor/github.com/0xPolygon/go-ibft/core/state.go @@ -16,19 +16,19 @@ const ( fin ) -func (s stateType) String() (str string) { +func (s stateType) String() string { switch s { case newRound: - str = "new round" + return "new round" case prepare: - str = "prepare" + return "prepare" case commit: - str = "commit" + return "commit" case fin: - str = "fin" + return "fin" } - return + return "" } type state struct { @@ -40,11 +40,11 @@ type state struct { // latestPC is the latest prepared certificate latestPC *proto.PreparedCertificate - // latestPreparedProposedBlock is the block + // latestPreparedProposal is the proposal // for which Q(N)-1 PREPARE messages were received - latestPreparedProposedBlock []byte + latestPreparedProposal *proto.Proposal - // accepted block proposal for current round + // accepted proposal for current round proposalMessage *proto.Message // validated commit seals @@ -75,7 +75,7 @@ func (s *state) clear(height uint64) { s.name = newRound s.proposalMessage = nil s.latestPC = nil - s.latestPreparedProposedBlock = nil + s.latestPreparedProposal = nil s.view = &proto.View{ Height: height, @@ -90,11 +90,11 @@ func (s *state) getLatestPC() *proto.PreparedCertificate { return s.latestPC } -func (s *state) getLatestPreparedProposedBlock() []byte { +func (s *state) getLatestPreparedProposal() *proto.Proposal { s.RLock() defer s.RUnlock() - return s.latestPreparedProposedBlock + return s.latestPreparedProposal } func (s *state) getProposalMessage() *proto.Message { @@ -132,7 +132,7 @@ func (s *state) getHeight() uint64 { return s.view.Height } -func (s *state) getProposal() []byte { +func (s *state) getProposal() *proto.Proposal { s.RLock() defer s.RUnlock() @@ -143,6 +143,16 @@ func (s *state) getProposal() []byte { return nil } +func (s *state) getRawDataFromProposal() []byte { + proposal := s.getProposal() + + if proposal != nil { + return proposal.RawProposal + } + + return nil +} + func (s *state) getCommittedSeals() []*messages.CommittedSeal { s.RLock() defer s.RUnlock() @@ -198,13 +208,13 @@ func (s *state) newRound() { func (s *state) finalizePrepare( certificate *proto.PreparedCertificate, - latestPPB []byte, + latestPPB *proto.Proposal, ) { s.Lock() defer s.Unlock() s.latestPC = certificate - s.latestPreparedProposedBlock = latestPPB + s.latestPreparedProposal = latestPPB // Move to the commit state s.name = commit diff --git a/vendor/github.com/0xPolygon/go-ibft/messages/event_manager.go b/vendor/github.com/0xPolygon/go-ibft/messages/event_manager.go index 1f115177..11d1636c 100644 --- a/vendor/github.com/0xPolygon/go-ibft/messages/event_manager.go +++ b/vendor/github.com/0xPolygon/go-ibft/messages/event_manager.go @@ -1,10 +1,13 @@ +// Package messages defines a sub-module to handle IBFT messages package messages import ( - "github.com/0xPolygon/go-ibft/messages/proto" - "github.com/google/uuid" "sync" "sync/atomic" + + "github.com/google/uuid" + + "github.com/0xPolygon/go-ibft/messages/proto" ) type eventManager struct { @@ -20,6 +23,7 @@ func newEventManager() *eventManager { } } +// SubscriptionID is a unique number to identify Subscription type SubscriptionID int32 // Subscription is the subscription @@ -51,6 +55,9 @@ type SubscriptionDetails struct { // HasMinRound is the flag indicating if the // round number is a lower bound HasMinRound bool + + // HasQuorumFn is the function used to check for quorum existence + HasQuorumFn func(height uint64, messages []*proto.Message, msgType proto.MessageType) bool } // subscribe registers a new listener for message events @@ -106,7 +113,6 @@ func (em *eventManager) close() { func (em *eventManager) signalEvent( messageType proto.MessageType, view *proto.View, - totalMessages int, ) { if atomic.LoadInt64(&em.numSubscriptions) == 0 { // No reason to lock the subscriptions map @@ -121,7 +127,6 @@ func (em *eventManager) signalEvent( subscription.pushEvent( messageType, view, - totalMessages, ) } } diff --git a/vendor/github.com/0xPolygon/go-ibft/messages/event_subscription.go b/vendor/github.com/0xPolygon/go-ibft/messages/event_subscription.go index 2d8b3c93..39b74c60 100644 --- a/vendor/github.com/0xPolygon/go-ibft/messages/event_subscription.go +++ b/vendor/github.com/0xPolygon/go-ibft/messages/event_subscription.go @@ -45,7 +45,6 @@ func (es *eventSubscription) runLoop() { func (es *eventSubscription) eventSupported( messageType proto.MessageType, view *proto.View, - totalMessages int, ) bool { // The heights must match if view.Height != es.details.View.Height { @@ -66,22 +65,15 @@ func (es *eventSubscription) eventSupported( } // The type of message must match - if messageType != es.details.MessageType { - return false - } - - // The total number of messages must be - // greater of equal to the subscription threshold - return totalMessages >= es.details.MinNumMessages + return messageType == es.details.MessageType } // pushEvent sends the event off for processing by the subscription. [NON-BLOCKING] func (es *eventSubscription) pushEvent( messageType proto.MessageType, view *proto.View, - totalMessages int, ) { - if !es.eventSupported(messageType, view, totalMessages) { + if !es.eventSupported(messageType, view) { return } diff --git a/vendor/github.com/0xPolygon/go-ibft/messages/helpers.go b/vendor/github.com/0xPolygon/go-ibft/messages/helpers.go index cc11693f..e1683f35 100644 --- a/vendor/github.com/0xPolygon/go-ibft/messages/helpers.go +++ b/vendor/github.com/0xPolygon/go-ibft/messages/helpers.go @@ -2,28 +2,36 @@ package messages import ( "bytes" + "errors" "github.com/0xPolygon/go-ibft/messages/proto" ) +var ( + // ErrWrongCommitMessageType is an error indicating wrong type in commit messages + ErrWrongCommitMessageType = errors.New("wrong type message is included in COMMIT messages") +) + +// CommittedSeal Validator proof of signing a committed proposal type CommittedSeal struct { Signer []byte Signature []byte } // ExtractCommittedSeals extracts the committed seals from the passed in messages -func ExtractCommittedSeals(commitMessages []*proto.Message) []*CommittedSeal { +func ExtractCommittedSeals(commitMessages []*proto.Message) ([]*CommittedSeal, error) { committedSeals := make([]*CommittedSeal, 0) for _, commitMessage := range commitMessages { if commitMessage.Type != proto.MessageType_COMMIT { - continue + // safe check + return nil, ErrWrongCommitMessageType } committedSeals = append(committedSeals, ExtractCommittedSeal(commitMessage)) } - return committedSeals + return committedSeals, nil } // ExtractCommittedSeal extracts the committed seal from the passed in message @@ -47,8 +55,8 @@ func ExtractCommitHash(commitMessage *proto.Message) []byte { return commitData.CommitData.ProposalHash } -// ExtractProposal extracts the proposal from the passed in message -func ExtractProposal(proposalMessage *proto.Message) []byte { +// ExtractProposal extracts the (rawData,r) proposal from the passed in message +func ExtractProposal(proposalMessage *proto.Message) *proto.Proposal { if proposalMessage.Type != proto.MessageType_PREPREPARE { return nil } @@ -102,15 +110,15 @@ func ExtractLatestPC(roundChangeMessage *proto.Message) *proto.PreparedCertifica return rcData.RoundChangeData.LatestPreparedCertificate } -// ExtractLastPreparedProposedBlock extracts the latest prepared proposed block from the passed in message -func ExtractLastPreparedProposedBlock(roundChangeMessage *proto.Message) []byte { +// ExtractLastPreparedProposal extracts the latest prepared proposal from the passed in message +func ExtractLastPreparedProposal(roundChangeMessage *proto.Message) *proto.Proposal { if roundChangeMessage.Type != proto.MessageType_ROUND_CHANGE { return nil } rcData, _ := roundChangeMessage.Payload.(*proto.Message_RoundChangeData) - return rcData.RoundChangeData.LastPreparedProposedBlock + return rcData.RoundChangeData.LastPreparedProposal } // HasUniqueSenders checks if the messages have unique senders @@ -139,7 +147,7 @@ func HaveSameProposalHash(messages []*proto.Message) bool { return false } - var hash []byte = nil + var hash []byte for _, message := range messages { var extractedHash []byte @@ -149,6 +157,8 @@ func HaveSameProposalHash(messages []*proto.Message) bool { extractedHash = ExtractProposalHash(message) case proto.MessageType_PREPARE: extractedHash = ExtractPrepareHash(message) + case proto.MessageType_COMMIT, proto.MessageType_ROUND_CHANGE: + return false default: return false } @@ -183,6 +193,23 @@ func AllHaveLowerRound(messages []*proto.Message, round uint64) bool { return true } +// AllHaveSameRound checks if all messages have the same round +func AllHaveSameRound(messages []*proto.Message) bool { + if len(messages) < 1 { + return false + } + + var round = messages[0].View.Round + + for _, message := range messages { + if message.View.Round != round { + return false + } + } + + return true +} + // AllHaveSameHeight checks if all messages have the same height func AllHaveSameHeight(messages []*proto.Message, height uint64) bool { if len(messages) < 1 { diff --git a/vendor/github.com/0xPolygon/go-ibft/messages/messages.go b/vendor/github.com/0xPolygon/go-ibft/messages/messages.go index 8fc6b6b9..ac7e054b 100644 --- a/vendor/github.com/0xPolygon/go-ibft/messages/messages.go +++ b/vendor/github.com/0xPolygon/go-ibft/messages/messages.go @@ -27,12 +27,10 @@ func (ms *Messages) Subscribe(details SubscriptionDetails) *Subscription { subscription := ms.eventManager.subscribe(details) // Check if any condition is already met - if numMessages := ms.numMessages( - details.View, - details.MessageType, - ); numMessages >= details.MinNumMessages { - // Conditions are already met, alert the event manager - ms.eventManager.signalEvent(details.MessageType, details.View, numMessages) + msgs := ms.GetValidMessages(details.View, details.MessageType, func(_ *proto.Message) bool { return true }) + + if details.HasQuorumFn(details.View.Height, msgs, details.MessageType) { + ms.eventManager.signalEvent(details.MessageType, details.View) } return subscription @@ -74,17 +72,20 @@ func (ms *Messages) AddMessage(message *proto.Message) { // Append the message to the appropriate queue messages := heightMsgMap.getViewMessages(message.View) messages[string(message.From)] = message +} +// SignalEvent signals event +func (ms *Messages) SignalEvent(message *proto.Message) { ms.eventManager.signalEvent( message.Type, &proto.View{ Height: message.View.Height, Round: message.View.Round, }, - len(messages), ) } +// Close closes event manager func (ms *Messages) Close() { ms.eventManager.close() } @@ -211,6 +212,52 @@ func (ms *Messages) GetValidMessages( return validMessages } +// GetExtendedRCC returns Round-Change-Certificate for the highest round +func (ms *Messages) GetExtendedRCC( + height uint64, + isValidMessage func(message *proto.Message) bool, + isValidRCC func(round uint64, messages []*proto.Message) bool, +) []*proto.Message { + messageType := proto.MessageType_ROUND_CHANGE + + mux := ms.muxMap[messageType] + mux.Lock() + defer mux.Unlock() + + // Get all ROUND-CHANGE messages for the height + roundMessageMap := ms.getMessageMap(messageType)[height] + + var ( + highestRound uint64 + extendedRCC []*proto.Message + ) + + for round, messages := range roundMessageMap { + validMessages := make([]*proto.Message, 0, len(messages)) + + if round <= highestRound { + continue + } + + for _, msg := range messages { + if !isValidMessage(msg) { + continue + } + + validMessages = append(validMessages, msg) + } + + if !isValidRCC(round, validMessages) { + continue + } + + highestRound = round + extendedRCC = validMessages + } + + return extendedRCC +} + // GetMostRoundChangeMessages fetches most round change messages // for the minimum round and above func (ms *Messages) GetMostRoundChangeMessages(minRound, height uint64) []*proto.Message { diff --git a/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.pb.go b/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.pb.go index 46caf21c..9bbe6c58 100644 --- a/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.pb.go +++ b/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.27.1 -// protoc v3.21.2 -// source: messages.proto +// protoc-gen-go v1.25.0 +// protoc v3.21.9 +// source: messages/proto/messages.proto package proto import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // MessageType defines the types of messages // circulating in the system type MessageType int32 @@ -58,11 +63,11 @@ func (x MessageType) String() string { } func (MessageType) Descriptor() protoreflect.EnumDescriptor { - return file_messages_proto_enumTypes[0].Descriptor() + return file_messages_proto_messages_proto_enumTypes[0].Descriptor() } func (MessageType) Type() protoreflect.EnumType { - return &file_messages_proto_enumTypes[0] + return &file_messages_proto_messages_proto_enumTypes[0] } func (x MessageType) Number() protoreflect.EnumNumber { @@ -71,7 +76,7 @@ func (x MessageType) Number() protoreflect.EnumNumber { // Deprecated: Use MessageType.Descriptor instead. func (MessageType) EnumDescriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{0} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{0} } // View defines the current status @@ -89,7 +94,7 @@ type View struct { func (x *View) Reset() { *x = View{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[0] + mi := &file_messages_proto_messages_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -102,7 +107,7 @@ func (x *View) String() string { func (*View) ProtoMessage() {} func (x *View) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[0] + mi := &file_messages_proto_messages_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -115,7 +120,7 @@ func (x *View) ProtoReflect() protoreflect.Message { // Deprecated: Use View.ProtoReflect.Descriptor instead. func (*View) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{0} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{0} } func (x *View) GetHeight() uint64 { @@ -159,7 +164,7 @@ type Message struct { func (x *Message) Reset() { *x = Message{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[1] + mi := &file_messages_proto_messages_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -172,7 +177,7 @@ func (x *Message) String() string { func (*Message) ProtoMessage() {} func (x *Message) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[1] + mi := &file_messages_proto_messages_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -185,7 +190,7 @@ func (x *Message) ProtoReflect() protoreflect.Message { // Deprecated: Use Message.ProtoReflect.Descriptor instead. func (*Message) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{1} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{1} } func (x *Message) GetView() *View { @@ -286,7 +291,7 @@ type PrePrepareMessage struct { unknownFields protoimpl.UnknownFields // proposal is the actual data being proposed for consensus - Proposal []byte `protobuf:"bytes,1,opt,name=proposal,proto3" json:"proposal,omitempty"` + Proposal *Proposal `protobuf:"bytes,1,opt,name=proposal,proto3" json:"proposal,omitempty"` // proposalHash is the Keccak hash of the proposal ProposalHash []byte `protobuf:"bytes,2,opt,name=proposalHash,proto3" json:"proposalHash,omitempty"` // certificate is the RCC that can accompany @@ -297,7 +302,7 @@ type PrePrepareMessage struct { func (x *PrePrepareMessage) Reset() { *x = PrePrepareMessage{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[2] + mi := &file_messages_proto_messages_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -310,7 +315,7 @@ func (x *PrePrepareMessage) String() string { func (*PrePrepareMessage) ProtoMessage() {} func (x *PrePrepareMessage) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[2] + mi := &file_messages_proto_messages_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -323,10 +328,10 @@ func (x *PrePrepareMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use PrePrepareMessage.ProtoReflect.Descriptor instead. func (*PrePrepareMessage) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{2} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{2} } -func (x *PrePrepareMessage) GetProposal() []byte { +func (x *PrePrepareMessage) GetProposal() *Proposal { if x != nil { return x.Proposal } @@ -360,7 +365,7 @@ type PrepareMessage struct { func (x *PrepareMessage) Reset() { *x = PrepareMessage{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[3] + mi := &file_messages_proto_messages_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -373,7 +378,7 @@ func (x *PrepareMessage) String() string { func (*PrepareMessage) ProtoMessage() {} func (x *PrepareMessage) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[3] + mi := &file_messages_proto_messages_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -386,7 +391,7 @@ func (x *PrepareMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use PrepareMessage.ProtoReflect.Descriptor instead. func (*PrepareMessage) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{3} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{3} } func (x *PrepareMessage) GetProposalHash() []byte { @@ -411,7 +416,7 @@ type CommitMessage struct { func (x *CommitMessage) Reset() { *x = CommitMessage{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[4] + mi := &file_messages_proto_messages_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -424,7 +429,7 @@ func (x *CommitMessage) String() string { func (*CommitMessage) ProtoMessage() {} func (x *CommitMessage) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[4] + mi := &file_messages_proto_messages_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -437,7 +442,7 @@ func (x *CommitMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use CommitMessage.ProtoReflect.Descriptor instead. func (*CommitMessage) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{4} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{4} } func (x *CommitMessage) GetProposalHash() []byte { @@ -460,9 +465,9 @@ type RoundChangeMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // lastPreparedProposedBlock is the last block + // lastProposal is the last proposal // to reach Q(N) - 1 PREPARE messages - LastPreparedProposedBlock []byte `protobuf:"bytes,1,opt,name=lastPreparedProposedBlock,proto3" json:"lastPreparedProposedBlock,omitempty"` + LastPreparedProposal *Proposal `protobuf:"bytes,1,opt,name=lastPreparedProposal,proto3" json:"lastPreparedProposal,omitempty"` // latestPreparedCertificate is the PC that accompanies // the last proposal LatestPreparedCertificate *PreparedCertificate `protobuf:"bytes,2,opt,name=latestPreparedCertificate,proto3" json:"latestPreparedCertificate,omitempty"` @@ -471,7 +476,7 @@ type RoundChangeMessage struct { func (x *RoundChangeMessage) Reset() { *x = RoundChangeMessage{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[5] + mi := &file_messages_proto_messages_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -484,7 +489,7 @@ func (x *RoundChangeMessage) String() string { func (*RoundChangeMessage) ProtoMessage() {} func (x *RoundChangeMessage) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[5] + mi := &file_messages_proto_messages_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -497,12 +502,12 @@ func (x *RoundChangeMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use RoundChangeMessage.ProtoReflect.Descriptor instead. func (*RoundChangeMessage) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{5} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{5} } -func (x *RoundChangeMessage) GetLastPreparedProposedBlock() []byte { +func (x *RoundChangeMessage) GetLastPreparedProposal() *Proposal { if x != nil { - return x.LastPreparedProposedBlock + return x.LastPreparedProposal } return nil } @@ -531,7 +536,7 @@ type PreparedCertificate struct { func (x *PreparedCertificate) Reset() { *x = PreparedCertificate{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[6] + mi := &file_messages_proto_messages_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -544,7 +549,7 @@ func (x *PreparedCertificate) String() string { func (*PreparedCertificate) ProtoMessage() {} func (x *PreparedCertificate) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[6] + mi := &file_messages_proto_messages_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -557,7 +562,7 @@ func (x *PreparedCertificate) ProtoReflect() protoreflect.Message { // Deprecated: Use PreparedCertificate.ProtoReflect.Descriptor instead. func (*PreparedCertificate) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{6} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{6} } func (x *PreparedCertificate) GetProposalMessage() *Message { @@ -588,7 +593,7 @@ type RoundChangeCertificate struct { func (x *RoundChangeCertificate) Reset() { *x = RoundChangeCertificate{} if protoimpl.UnsafeEnabled { - mi := &file_messages_proto_msgTypes[7] + mi := &file_messages_proto_messages_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -601,7 +606,7 @@ func (x *RoundChangeCertificate) String() string { func (*RoundChangeCertificate) ProtoMessage() {} func (x *RoundChangeCertificate) ProtoReflect() protoreflect.Message { - mi := &file_messages_proto_msgTypes[7] + mi := &file_messages_proto_messages_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -614,7 +619,7 @@ func (x *RoundChangeCertificate) ProtoReflect() protoreflect.Message { // Deprecated: Use RoundChangeCertificate.ProtoReflect.Descriptor instead. func (*RoundChangeCertificate) Descriptor() ([]byte, []int) { - return file_messages_proto_rawDescGZIP(), []int{7} + return file_messages_proto_messages_proto_rawDescGZIP(), []int{7} } func (x *RoundChangeCertificate) GetRoundChangeMessages() []*Message { @@ -624,102 +629,166 @@ func (x *RoundChangeCertificate) GetRoundChangeMessages() []*Message { return nil } -var File_messages_proto protoreflect.FileDescriptor - -var file_messages_proto_rawDesc = []byte{ - 0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x34, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x05, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x22, 0xe9, 0x02, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x12, 0x19, 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x05, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x52, 0x04, 0x76, 0x69, 0x65, 0x77, 0x12, 0x12, 0x0a, - 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x72, 0x6f, - 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, - 0x20, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x12, 0x3c, 0x0a, 0x0e, 0x70, 0x72, 0x65, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x44, - 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x50, 0x72, 0x65, 0x50, - 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, - 0x0e, 0x70, 0x72, 0x65, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, - 0x33, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, - 0x44, 0x61, 0x74, 0x61, 0x12, 0x30, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x61, - 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3f, 0x0a, 0x0f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x13, 0x2e, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, - 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x22, 0x8e, 0x01, 0x0a, 0x11, 0x50, 0x72, 0x65, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, - 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, - 0x6f, 0x73, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, - 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, - 0x48, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x70, - 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, 0x73, 0x68, 0x12, 0x39, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, - 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x65, 0x72, 0x74, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x65, 0x22, 0x34, 0x0a, 0x0e, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, - 0x6c, 0x48, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x6f, - 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, 0x73, 0x68, 0x22, 0x59, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, - 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, 0x73, 0x68, 0x12, 0x24, - 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x53, 0x65, 0x61, 0x6c, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, - 0x53, 0x65, 0x61, 0x6c, 0x22, 0xa6, 0x01, 0x0a, 0x12, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, - 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x19, 0x6c, - 0x61, 0x73, 0x74, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x6f, - 0x73, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x19, +// Proposal is the tuple (raw_proposal, round) +type Proposal struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // rawProposal is an original proposal like block + RawProposal []byte `protobuf:"bytes,1,opt,name=rawProposal,proto3" json:"rawProposal,omitempty"` + // round is the round for which the proposal is created + Round uint64 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` +} + +func (x *Proposal) Reset() { + *x = Proposal{} + if protoimpl.UnsafeEnabled { + mi := &file_messages_proto_messages_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Proposal) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Proposal) ProtoMessage() {} + +func (x *Proposal) ProtoReflect() protoreflect.Message { + mi := &file_messages_proto_messages_proto_msgTypes[8] + 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 Proposal.ProtoReflect.Descriptor instead. +func (*Proposal) Descriptor() ([]byte, []int) { + return file_messages_proto_messages_proto_rawDescGZIP(), []int{8} +} + +func (x *Proposal) GetRawProposal() []byte { + if x != nil { + return x.RawProposal + } + return nil +} + +func (x *Proposal) GetRound() uint64 { + if x != nil { + return x.Round + } + return 0 +} + +var File_messages_proto_messages_proto protoreflect.FileDescriptor + +var file_messages_proto_messages_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x34, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, + 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, + 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x22, 0xe9, 0x02, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x12, 0x19, 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x05, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x52, 0x04, 0x76, 0x69, 0x65, 0x77, 0x12, 0x12, 0x0a, 0x04, + 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, + 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x20, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x3c, 0x0a, 0x0e, 0x70, 0x72, 0x65, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x44, 0x61, + 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x50, 0x72, 0x65, 0x50, 0x72, + 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0e, + 0x70, 0x72, 0x65, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x33, + 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x44, + 0x61, 0x74, 0x61, 0x12, 0x30, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x61, 0x74, + 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3f, 0x0a, 0x0f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, + 0x61, 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, + 0x2e, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x22, 0x99, 0x01, 0x0a, 0x11, 0x50, 0x72, 0x65, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x6f, + 0x73, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x50, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x22, + 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, 0x73, 0x68, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, + 0x73, 0x68, 0x12, 0x39, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, + 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x22, 0x34, 0x0a, + 0x0e, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, 0x73, 0x68, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48, + 0x61, 0x73, 0x68, 0x22, 0x59, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, + 0x48, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x61, 0x6c, 0x48, 0x61, 0x73, 0x68, 0x12, 0x24, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x74, 0x65, 0x64, 0x53, 0x65, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x53, 0x65, 0x61, 0x6c, 0x22, 0xa7, + 0x01, 0x0a, 0x12, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3d, 0x0a, 0x14, 0x6c, 0x61, 0x73, 0x74, 0x50, 0x72, 0x65, + 0x70, 0x61, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x14, 0x6c, 0x61, 0x73, 0x74, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x70, - 0x6f, 0x73, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x52, 0x0a, 0x19, 0x6c, 0x61, 0x74, - 0x65, 0x73, 0x74, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x50, - 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x65, 0x52, 0x19, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, - 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x22, 0x7d, 0x0a, - 0x13, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x65, 0x12, 0x32, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, - 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x0f, 0x70, 0x72, 0x65, 0x70, - 0x61, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x08, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0f, 0x70, 0x72, 0x65, - 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x54, 0x0a, 0x16, - 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x65, 0x72, 0x74, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x3a, 0x0a, 0x13, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x13, 0x72, - 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x73, 0x2a, 0x48, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x52, 0x45, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x10, - 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x10, 0x01, 0x12, 0x0a, - 0x0a, 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x4f, - 0x55, 0x4e, 0x44, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x03, 0x42, 0x11, 0x5a, 0x0f, - 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x52, 0x0a, 0x19, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x50, 0x72, + 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, + 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x19, 0x6c, + 0x61, 0x74, 0x65, 0x73, 0x74, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x43, 0x65, 0x72, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x22, 0x7d, 0x0a, 0x13, 0x50, 0x72, 0x65, 0x70, + 0x61, 0x72, 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, + 0x32, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x0f, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0f, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x54, 0x0a, 0x16, 0x52, 0x6f, 0x75, 0x6e, 0x64, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x65, 0x12, 0x3a, 0x0a, 0x13, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, + 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x13, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x42, 0x0a, + 0x08, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x61, 0x77, + 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, + 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x72, + 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x72, 0x6f, 0x75, 0x6e, + 0x64, 0x2a, 0x48, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x52, 0x45, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x10, 0x00, + 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x10, 0x01, 0x12, 0x0a, 0x0a, + 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x4f, 0x55, + 0x4e, 0x44, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x03, 0x42, 0x11, 0x5a, 0x0f, 0x2f, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_messages_proto_rawDescOnce sync.Once - file_messages_proto_rawDescData = file_messages_proto_rawDesc + file_messages_proto_messages_proto_rawDescOnce sync.Once + file_messages_proto_messages_proto_rawDescData = file_messages_proto_messages_proto_rawDesc ) -func file_messages_proto_rawDescGZIP() []byte { - file_messages_proto_rawDescOnce.Do(func() { - file_messages_proto_rawDescData = protoimpl.X.CompressGZIP(file_messages_proto_rawDescData) +func file_messages_proto_messages_proto_rawDescGZIP() []byte { + file_messages_proto_messages_proto_rawDescOnce.Do(func() { + file_messages_proto_messages_proto_rawDescData = protoimpl.X.CompressGZIP(file_messages_proto_messages_proto_rawDescData) }) - return file_messages_proto_rawDescData + return file_messages_proto_messages_proto_rawDescData } -var file_messages_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_messages_proto_goTypes = []interface{}{ +var file_messages_proto_messages_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_messages_proto_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_messages_proto_messages_proto_goTypes = []interface{}{ (MessageType)(0), // 0: MessageType (*View)(nil), // 1: View (*Message)(nil), // 2: Message @@ -729,33 +798,36 @@ var file_messages_proto_goTypes = []interface{}{ (*RoundChangeMessage)(nil), // 6: RoundChangeMessage (*PreparedCertificate)(nil), // 7: PreparedCertificate (*RoundChangeCertificate)(nil), // 8: RoundChangeCertificate + (*Proposal)(nil), // 9: Proposal } -var file_messages_proto_depIdxs = []int32{ +var file_messages_proto_messages_proto_depIdxs = []int32{ 1, // 0: Message.view:type_name -> View 0, // 1: Message.type:type_name -> MessageType 3, // 2: Message.preprepareData:type_name -> PrePrepareMessage 4, // 3: Message.prepareData:type_name -> PrepareMessage 5, // 4: Message.commitData:type_name -> CommitMessage 6, // 5: Message.roundChangeData:type_name -> RoundChangeMessage - 8, // 6: PrePrepareMessage.certificate:type_name -> RoundChangeCertificate - 7, // 7: RoundChangeMessage.latestPreparedCertificate:type_name -> PreparedCertificate - 2, // 8: PreparedCertificate.proposalMessage:type_name -> Message - 2, // 9: PreparedCertificate.prepareMessages:type_name -> Message - 2, // 10: RoundChangeCertificate.roundChangeMessages:type_name -> Message - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name -} - -func init() { file_messages_proto_init() } -func file_messages_proto_init() { - if File_messages_proto != nil { + 9, // 6: PrePrepareMessage.proposal:type_name -> Proposal + 8, // 7: PrePrepareMessage.certificate:type_name -> RoundChangeCertificate + 9, // 8: RoundChangeMessage.lastPreparedProposal:type_name -> Proposal + 7, // 9: RoundChangeMessage.latestPreparedCertificate:type_name -> PreparedCertificate + 2, // 10: PreparedCertificate.proposalMessage:type_name -> Message + 2, // 11: PreparedCertificate.prepareMessages:type_name -> Message + 2, // 12: RoundChangeCertificate.roundChangeMessages:type_name -> Message + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name +} + +func init() { file_messages_proto_messages_proto_init() } +func file_messages_proto_messages_proto_init() { + if File_messages_proto_messages_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_messages_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*View); i { case 0: return &v.state @@ -767,7 +839,7 @@ func file_messages_proto_init() { return nil } } - file_messages_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Message); i { case 0: return &v.state @@ -779,7 +851,7 @@ func file_messages_proto_init() { return nil } } - file_messages_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PrePrepareMessage); i { case 0: return &v.state @@ -791,7 +863,7 @@ func file_messages_proto_init() { return nil } } - file_messages_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PrepareMessage); i { case 0: return &v.state @@ -803,7 +875,7 @@ func file_messages_proto_init() { return nil } } - file_messages_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CommitMessage); i { case 0: return &v.state @@ -815,7 +887,7 @@ func file_messages_proto_init() { return nil } } - file_messages_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RoundChangeMessage); i { case 0: return &v.state @@ -827,7 +899,7 @@ func file_messages_proto_init() { return nil } } - file_messages_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PreparedCertificate); i { case 0: return &v.state @@ -839,7 +911,7 @@ func file_messages_proto_init() { return nil } } - file_messages_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_messages_proto_messages_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RoundChangeCertificate); i { case 0: return &v.state @@ -851,8 +923,20 @@ func file_messages_proto_init() { return nil } } + file_messages_proto_messages_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Proposal); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - file_messages_proto_msgTypes[1].OneofWrappers = []interface{}{ + file_messages_proto_messages_proto_msgTypes[1].OneofWrappers = []interface{}{ (*Message_PreprepareData)(nil), (*Message_PrepareData)(nil), (*Message_CommitData)(nil), @@ -862,19 +946,19 @@ func file_messages_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_messages_proto_rawDesc, + RawDescriptor: file_messages_proto_messages_proto_rawDesc, NumEnums: 1, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_messages_proto_goTypes, - DependencyIndexes: file_messages_proto_depIdxs, - EnumInfos: file_messages_proto_enumTypes, - MessageInfos: file_messages_proto_msgTypes, + GoTypes: file_messages_proto_messages_proto_goTypes, + DependencyIndexes: file_messages_proto_messages_proto_depIdxs, + EnumInfos: file_messages_proto_messages_proto_enumTypes, + MessageInfos: file_messages_proto_messages_proto_msgTypes, }.Build() - File_messages_proto = out.File - file_messages_proto_rawDesc = nil - file_messages_proto_goTypes = nil - file_messages_proto_depIdxs = nil + File_messages_proto_messages_proto = out.File + file_messages_proto_messages_proto_rawDesc = nil + file_messages_proto_messages_proto_goTypes = nil + file_messages_proto_messages_proto_depIdxs = nil } diff --git a/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.proto b/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.proto index 21ac8548..3115c9dc 100644 --- a/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.proto +++ b/vendor/github.com/0xPolygon/go-ibft/messages/proto/messages.proto @@ -46,7 +46,7 @@ message Message { // PrePrepareMessage is the message for the PREPREPARE phase message PrePrepareMessage { // proposal is the actual data being proposed for consensus - bytes proposal = 1; + Proposal proposal = 1; // proposalHash is the Keccak hash of the proposal bytes proposalHash = 2; @@ -73,9 +73,9 @@ message CommitMessage { // RoundChangeMessage is the message for the ROUND CHANGE phase message RoundChangeMessage { - // lastPreparedProposedBlock is the last block + // lastProposal is the last proposal // to reach Q(N) - 1 PREPARE messages - bytes lastPreparedProposedBlock = 1; + Proposal lastPreparedProposal = 1; // latestPreparedCertificate is the PC that accompanies // the last proposal @@ -98,4 +98,13 @@ message PreparedCertificate { message RoundChangeCertificate { // roundChangeMessages are the ROUND CHANGE messages repeated Message roundChangeMessages = 1; -} \ No newline at end of file +} + +// Proposal is the tuple (raw_proposal, round) +message Proposal { + // rawProposal is an original proposal like block + bytes rawProposal = 1; + + // round is the round for which the proposal is created + uint64 round = 2; +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 59ac7b02..4add87bb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -15,8 +15,8 @@ cloud.google.com/go/secretmanager/internal ## explicit; go 1.17 filippo.io/edwards25519 filippo.io/edwards25519/field -# github.com/0xPolygon/go-ibft v0.0.0-20220810095021-e43142f8d267 -## explicit; go 1.17 +# github.com/0xPolygon/go-ibft v0.3.0 +## explicit; go 1.19 github.com/0xPolygon/go-ibft/core github.com/0xPolygon/go-ibft/messages github.com/0xPolygon/go-ibft/messages/proto @@ -704,7 +704,7 @@ github.com/spf13/cobra # github.com/spf13/pflag v1.0.5 ## explicit; go 1.12 github.com/spf13/pflag -# github.com/stretchr/testify v1.8.0 +# github.com/stretchr/testify v1.8.1 ## explicit; go 1.13 github.com/stretchr/testify/assert # github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7