diff --git a/core/backend.go b/core/backend.go index 8be7b82..c344f0e 100644 --- a/core/backend.go +++ b/core/backend.go @@ -15,14 +15,14 @@ type MessageConstructor interface { rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message + ) *proto.IbftMessage // BuildPrepareMessage builds a PREPARE message based on the passed in view and proposal hash - BuildPrepareMessage(proposalHash []byte, view *proto.View) *proto.Message + BuildPrepareMessage(proposalHash []byte, view *proto.View) *proto.IbftMessage // 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 + BuildCommitMessage(proposalHash []byte, view *proto.View) *proto.IbftMessage // BuildRoundChangeMessage builds a ROUND_CHANGE message based on the passed in view, // latest prepared proposal, and latest prepared certificate @@ -30,7 +30,7 @@ type MessageConstructor interface { proposal *proto.Proposal, certificate *proto.PreparedCertificate, view *proto.View, - ) *proto.Message + ) *proto.IbftMessage } // Verifier defines the verifier interface @@ -42,7 +42,7 @@ type Verifier interface { // 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 + IsValidValidator(msg *proto.IbftMessage) bool // IsProposer checks if the passed in ID is the Proposer for current view (sequence, round) IsProposer(id []byte, height, round uint64) bool diff --git a/core/byzantine_test.go b/core/byzantine_test.go index 8ceba06..83b63c2 100644 --- a/core/byzantine_test.go +++ b/core/byzantine_test.go @@ -293,7 +293,7 @@ func TestByzantineBehaviour(t *testing.T) { func createBadRoundRoundChangeFn(node *node) buildRoundChangeMessageDelegate { return func(proposal *proto.Proposal, rcc *proto.PreparedCertificate, - view *proto.View) *proto.Message { + view *proto.View) *proto.IbftMessage { if node.byzantine { view.Round++ } @@ -312,7 +312,7 @@ func createBadRoundPrePrepareMessageFn(node *node) buildPrePrepareMessageDelegat proposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message { + ) *proto.IbftMessage { if node.byzantine { view.Round++ } @@ -330,7 +330,7 @@ func createBadRoundPrePrepareMessageFn(node *node) buildPrePrepareMessageDelegat func createBadHashPrePrepareMessageFn(node *node) buildPrePrepareMessageDelegate { return func(proposal []byte, rcc *proto.RoundChangeCertificate, - view *proto.View) *proto.Message { + view *proto.View) *proto.IbftMessage { proposalHash := validProposalHash if node.byzantine { proposalHash = []byte("invalid proposal hash") @@ -347,7 +347,7 @@ func createBadHashPrePrepareMessageFn(node *node) buildPrePrepareMessageDelegate } func createBadHashPrepareMessageFn(node *node) buildPrepareMessageDelegate { - return func(_ []byte, view *proto.View) *proto.Message { + return func(_ []byte, view *proto.View) *proto.IbftMessage { proposalHash := validProposalHash if node.byzantine { proposalHash = []byte("invalid proposal hash") @@ -375,7 +375,7 @@ func createForcedRCProposerFn(c *cluster) isProposerDelegate { } func createBadCommitMessageFn(node *node) buildCommitMessageDelegate { - return func(_ []byte, view *proto.View) *proto.Message { + return func(_ []byte, view *proto.View) *proto.IbftMessage { committedSeal := validCommittedSeal if node.byzantine { committedSeal = []byte("invalid committed seal") diff --git a/core/consensus_test.go b/core/consensus_test.go index f78125a..fd2178c 100644 --- a/core/consensus_test.go +++ b/core/consensus_test.go @@ -31,12 +31,12 @@ func buildBasicPreprepareMessage( certificate *proto.RoundChangeCertificate, from []byte, view *proto.View, -) *proto.Message { - return &proto.Message{ +) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, From: from, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: &proto.Proposal{ RawProposal: rawProposal, @@ -54,12 +54,12 @@ func buildBasicPrepareMessage( proposalHash, from []byte, view *proto.View, -) *proto.Message { - return &proto.Message{ +) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, From: from, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, @@ -73,12 +73,12 @@ func buildBasicCommitMessage( committedSeal, from []byte, view *proto.View, -) *proto.Message { - return &proto.Message{ +) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, From: from, Type: proto.MessageType_COMMIT, - Payload: &proto.Message_CommitData{ + Payload: &proto.IbftMessage_CommitData{ CommitData: &proto.CommitMessage{ ProposalHash: proposalHash, CommittedSeal: committedSeal, @@ -93,12 +93,12 @@ func buildBasicRoundChangeMessage( certificate *proto.PreparedCertificate, view *proto.View, from []byte, -) *proto.Message { - return &proto.Message{ +) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, From: from, Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{ + Payload: &proto.IbftMessage_RoundChangeData{ RoundChangeData: &proto.RoundChangeMessage{ LastPreparedProposal: proposal, LatestPreparedCertificate: certificate, @@ -134,7 +134,7 @@ func TestConsensus_ValidFlow(t *testing.T) { t.Parallel() var ( - multicastFn func(message *proto.Message) + multicastFn func(message *proto.IbftMessage) numNodes = uint64(4) nodes = generateNodeAddresses(numNodes) @@ -144,7 +144,7 @@ func TestConsensus_ValidFlow(t *testing.T) { // commonTransportCallback is the common method modification // required for Transport, for all nodes commonTransportCallback := func(transport *mockTransport, _ int) { - transport.multicastFn = func(message *proto.Message) { + transport.multicastFn = func(message *proto.IbftMessage) { multicastFn(message) } } @@ -182,7 +182,7 @@ func TestConsensus_ValidFlow(t *testing.T) { rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message { + ) *proto.IbftMessage { return buildBasicPreprepareMessage( rawProposal, correctRoundMessage.hash, @@ -192,12 +192,12 @@ func TestConsensus_ValidFlow(t *testing.T) { } // Make sure the prepare message is built correctly - backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.Message { + backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.IbftMessage { return buildBasicPrepareMessage(correctRoundMessage.hash, nodes[nodeIndex], view) } // Make sure the commit message is built correctly - backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.Message { + backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.IbftMessage { return buildBasicCommitMessage(correctRoundMessage.hash, correctRoundMessage.seal, nodes[nodeIndex], view) } @@ -206,7 +206,7 @@ func TestConsensus_ValidFlow(t *testing.T) { proposal *proto.Proposal, certificate *proto.PreparedCertificate, view *proto.View, - ) *proto.Message { + ) *proto.IbftMessage { return buildBasicRoundChangeMessage(proposal, certificate, view, nodes[nodeIndex]) } @@ -231,7 +231,7 @@ func TestConsensus_ValidFlow(t *testing.T) { // Set the multicast callback to relay the message // to the entire cluster - multicastFn = func(message *proto.Message) { + multicastFn = func(message *proto.IbftMessage) { cluster.pushMessage(message) } @@ -260,7 +260,7 @@ func TestConsensus_ValidFlow(t *testing.T) { func TestConsensus_InvalidBlock(t *testing.T) { t.Parallel() - var multicastFn func(message *proto.Message) + var multicastFn func(message *proto.IbftMessage) proposals := [][]byte{ []byte("proposal 1"), // proposed by node 0 @@ -279,7 +279,7 @@ func TestConsensus_InvalidBlock(t *testing.T) { // commonTransportCallback is the common method modification // required for Transport, for all nodes commonTransportCallback := func(transport *mockTransport, _ int) { - transport.multicastFn = func(message *proto.Message) { + transport.multicastFn = func(message *proto.IbftMessage) { multicastFn(message) } } @@ -323,7 +323,7 @@ func TestConsensus_InvalidBlock(t *testing.T) { rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message { + ) *proto.IbftMessage { return buildBasicPreprepareMessage( rawProposal, proposalHashes[view.Round], @@ -334,12 +334,12 @@ func TestConsensus_InvalidBlock(t *testing.T) { } // Make sure the prepare message is built correctly - backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.Message { + backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.IbftMessage { return buildBasicPrepareMessage(proposalHashes[view.Round], nodes[nodeIndex], view) } // Make sure the commit message is built correctly - backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.Message { + backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.IbftMessage { return buildBasicCommitMessage(proposalHashes[view.Round], committedSeal, nodes[nodeIndex], view) } @@ -348,7 +348,7 @@ func TestConsensus_InvalidBlock(t *testing.T) { proposal *proto.Proposal, certificate *proto.PreparedCertificate, view *proto.View, - ) *proto.Message { + ) *proto.IbftMessage { return buildBasicRoundChangeMessage(proposal, certificate, view, nodes[nodeIndex]) } diff --git a/core/drop_test.go b/core/drop_test.go index 2510946..3cdcabb 100644 --- a/core/drop_test.go +++ b/core/drop_test.go @@ -49,7 +49,7 @@ func TestDropAllAndRecover(t *testing.T) { }, getVotingPowerFn: testCommonGetVotingPowertFnForNodes(c.nodes), }, - &mockTransport{multicastFn: func(message *proto.Message) { + &mockTransport{multicastFn: func(message *proto.IbftMessage) { if currentNode.offline { return } @@ -130,7 +130,7 @@ func TestMaxFaultyDroppingMessages(t *testing.T) { insertProposalFn: nil, getVotingPowerFn: testCommonGetVotingPowertFnForNodes(c.nodes), }, - &mockTransport{multicastFn: func(message *proto.Message) { + &mockTransport{multicastFn: func(message *proto.IbftMessage) { if currentNode.faulty && rand.Intn(100) < 50 { return } @@ -183,7 +183,7 @@ func TestAllFailAndGraduallyRecover(t *testing.T) { }, getVotingPowerFn: testCommonGetVotingPowertFnForNodes(c.nodes), }, - &mockTransport{multicastFn: func(msg *proto.Message) { + &mockTransport{multicastFn: func(msg *proto.IbftMessage) { if !currentNode.offline { for _, node := range c.nodes { node.core.AddMessage(msg) diff --git a/core/helpers_test.go b/core/helpers_test.go index 5e4bbb4..76efe83 100644 --- a/core/helpers_test.go +++ b/core/helpers_test.go @@ -52,7 +52,7 @@ func (n *node) buildPrePrepare( rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, -) *proto.Message { +) *proto.IbftMessage { return buildBasicPreprepareMessage( rawProposal, validProposalHash, @@ -65,7 +65,7 @@ func (n *node) buildPrePrepare( func (n *node) buildPrepare( _ []byte, view *proto.View, -) *proto.Message { +) *proto.IbftMessage { return buildBasicPrepareMessage( validProposalHash, n.address, @@ -76,7 +76,7 @@ func (n *node) buildPrepare( func (n *node) buildCommit( _ []byte, view *proto.View, -) *proto.Message { +) *proto.IbftMessage { return buildBasicCommitMessage( validProposalHash, validCommittedSeal, @@ -89,7 +89,7 @@ func (n *node) buildRoundChange( proposal *proto.Proposal, certificate *proto.PreparedCertificate, view *proto.View, -) *proto.Message { +) *proto.IbftMessage { return buildBasicRoundChangeMessage( proposal, certificate, @@ -224,7 +224,7 @@ func (c *cluster) isProposer( ) } -func (c *cluster) gossip(msg *proto.Message) { +func (c *cluster) gossip(msg *proto.IbftMessage) { for _, node := range c.nodes { node.core.AddMessage(msg) } diff --git a/core/ibft.go b/core/ibft.go index 87f4743..afd9dad 100644 --- a/core/ibft.go +++ b/core/ibft.go @@ -22,7 +22,7 @@ type Logger interface { // Messages represents the message managing behaviour type Messages interface { // Messages modifiers // - AddMessage(message *proto.Message) + AddMessage(message *proto.IbftMessage) PruneByHeight(height uint64) SignalEvent(messageType proto.MessageType, view *proto.View) @@ -31,14 +31,14 @@ type Messages interface { GetValidMessages( view *proto.View, messageType proto.MessageType, - isValid func(*proto.Message) bool, - ) []*proto.Message + isValid func(*proto.IbftMessage) bool, + ) []*proto.IbftMessage 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 + isValidMessage func(message *proto.IbftMessage) bool, + isValidRCC func(round uint64, msgs []*proto.IbftMessage) bool, + ) []*proto.IbftMessage + GetMostRoundChangeMessages(minRound, height uint64) []*proto.IbftMessage // Messages subscription handlers // Subscribe(details messages.SubscriptionDetails) *messages.Subscription @@ -193,7 +193,7 @@ func (i *IBFT) signalNewRCC(ctx context.Context, round uint64) { } type newProposalEvent struct { - proposalMessage *proto.Message + proposalMessage *proto.IbftMessage round uint64 } @@ -473,7 +473,7 @@ func (i *IBFT) handleRoundChangeMessage(view *proto.View) *proto.RoundChangeCert hasAcceptedProposal = i.state.getProposal() != nil ) - isValidMsgFn := func(msg *proto.Message) bool { + isValidMsgFn := func(msg *proto.IbftMessage) bool { proposal := messages.ExtractLastPreparedProposal(msg) certificate := messages.ExtractLatestPC(msg) @@ -486,7 +486,7 @@ func (i *IBFT) handleRoundChangeMessage(view *proto.View) *proto.RoundChangeCert return i.proposalMatchesCertificate(proposal, certificate) } - isValidRCCFn := func(round uint64, msgs []*proto.Message) bool { + isValidRCCFn := func(round uint64, msgs []*proto.IbftMessage) 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 { @@ -626,7 +626,7 @@ func (i *IBFT) runNewRound(ctx context.Context) error { // validateProposalCommon does common validations for each proposal, no // matter the round -func (i *IBFT) validateProposalCommon(msg *proto.Message, view *proto.View) bool { +func (i *IBFT) validateProposalCommon(msg *proto.IbftMessage, view *proto.View) bool { var ( height = view.Height round = view.Round @@ -655,7 +655,7 @@ func (i *IBFT) validateProposalCommon(msg *proto.Message, view *proto.View) bool } // validateProposal0 validates the proposal for round 0 -func (i *IBFT) validateProposal0(msg *proto.Message, view *proto.View) bool { +func (i *IBFT) validateProposal0(msg *proto.IbftMessage, view *proto.View) bool { var ( height = view.Height round = view.Round @@ -680,7 +680,7 @@ func (i *IBFT) validateProposal0(msg *proto.Message, view *proto.View) bool { } // validateProposal validates a proposal for round > 0 -func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { +func (i *IBFT) validateProposal(msg *proto.IbftMessage, view *proto.View) bool { var ( height = view.Height round = view.Round @@ -789,8 +789,8 @@ func (i *IBFT) validateProposal(msg *proto.Message, view *proto.View) bool { // 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 { +func (i *IBFT) handlePrePrepare(view *proto.View) *proto.IbftMessage { + isValidPrePrepare := func(message *proto.IbftMessage) bool { if view.Round == 0 { // proposal must be for round 0 return i.validateProposal0(message, view) @@ -853,7 +853,7 @@ 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) bool { - isValidPrepare := func(message *proto.Message) bool { + isValidPrepare := func(message *proto.IbftMessage) bool { // Verify that the proposal hash is valid return i.backend.IsValidProposalHash( i.state.getProposal(), @@ -929,7 +929,7 @@ 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) bool { - isValidCommit := func(message *proto.Message) bool { + isValidCommit := func(message *proto.IbftMessage) bool { var ( proposalHash = messages.ExtractCommitHash(message) committedSeal = messages.ExtractCommittedSeal(message) @@ -1002,7 +1002,7 @@ func (i *IBFT) moveToNewRound(round uint64) { i.state.changeState(newRound) } -func (i *IBFT) buildProposal(ctx context.Context, view *proto.View) *proto.Message { +func (i *IBFT) buildProposal(ctx context.Context, view *proto.View) *proto.IbftMessage { var ( height = view.Height round = view.Round @@ -1091,14 +1091,14 @@ func (i *IBFT) buildProposal(ctx context.Context, view *proto.View) *proto.Messa } // acceptProposal accepts the proposal and moves the state -func (i *IBFT) acceptProposal(proposalMessage *proto.Message) { +func (i *IBFT) acceptProposal(proposalMessage *proto.IbftMessage) { // accept newly proposed block and move to PREPARE state i.state.setProposalMessage(proposalMessage) i.state.changeState(prepare) } // AddMessage adds a new message to the IBFT message system -func (i *IBFT) AddMessage(message *proto.Message) { +func (i *IBFT) AddMessage(message *proto.IbftMessage) { // Make sure the message is present if message == nil { return @@ -1114,7 +1114,7 @@ func (i *IBFT) AddMessage(message *proto.Message) { msgs := i.messages.GetValidMessages( message.View, message.Type, - func(_ *proto.Message) bool { return true }) + func(_ *proto.IbftMessage) bool { return true }) if i.hasQuorumByMsgType(msgs, message.Type) { i.messages.SignalEvent(message.Type, message.View) } @@ -1123,7 +1123,7 @@ func (i *IBFT) AddMessage(message *proto.Message) { } // isAcceptableMessage checks if the message can even be accepted -func (i *IBFT) isAcceptableMessage(message *proto.Message) bool { +func (i *IBFT) isAcceptableMessage(message *proto.IbftMessage) bool { // Make sure the message sender is ok if !i.backend.IsValidValidator(message) { return false @@ -1175,7 +1175,7 @@ func (i *IBFT) validPC( } allMessages := append( - []*proto.Message{certificate.ProposalMessage}, + []*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages..., ) @@ -1231,7 +1231,7 @@ func (i *IBFT) validPC( } // sendPreprepareMessage sends out the preprepare message -func (i *IBFT) sendPreprepareMessage(message *proto.Message) { +func (i *IBFT) sendPreprepareMessage(message *proto.IbftMessage) { i.transport.Multicast(message) } @@ -1270,7 +1270,7 @@ func (i *IBFT) sendCommitMessage(view *proto.View) { } // hasQuorumByMsgType provides information on whether messages of specific types have reached the quorum -func (i *IBFT) hasQuorumByMsgType(msgs []*proto.Message, msgType proto.MessageType) bool { +func (i *IBFT) hasQuorumByMsgType(msgs []*proto.IbftMessage, msgType proto.MessageType) bool { switch msgType { case proto.MessageType_PREPREPARE: return len(msgs) >= 1 @@ -1288,7 +1288,7 @@ func (i *IBFT) subscribe(details messages.SubscriptionDetails) *messages.Subscri msgs := i.messages.GetValidMessages( details.View, details.MessageType, - func(_ *proto.Message) bool { return true }) + func(_ *proto.IbftMessage) bool { return true }) // Check if any condition is already met if i.hasQuorumByMsgType(msgs, details.MessageType) { i.messages.SignalEvent(details.MessageType, details.View) diff --git a/core/ibft_test.go b/core/ibft_test.go index 6e9a0fa..735069b 100644 --- a/core/ibft_test.go +++ b/core/ibft_test.go @@ -16,7 +16,7 @@ import ( "github.com/0xPolygon/go-ibft/messages/proto" ) -func proposalMatches(proposal *proto.Proposal, message *proto.Message) bool { +func proposalMatches(proposal *proto.Proposal, message *proto.IbftMessage) bool { if message == nil || message.Type != proto.MessageType_PREPREPARE { return false } @@ -30,33 +30,33 @@ func proposalMatches(proposal *proto.Proposal, message *proto.Message) bool { bytes.Equal(proposal.RawProposal, extractedProposal.RawProposal) } -func prepareHashMatches(prepareHash []byte, message *proto.Message) bool { +func prepareHashMatches(prepareHash []byte, message *proto.IbftMessage) bool { if message == nil || message.Type != proto.MessageType_PREPARE { return false } - prepareData, _ := message.Payload.(*proto.Message_PrepareData) + prepareData, _ := message.Payload.(*proto.IbftMessage_PrepareData) extractedPrepareHash := prepareData.PrepareData.ProposalHash return bytes.Equal(prepareHash, extractedPrepareHash) } -func commitHashMatches(commitHash []byte, message *proto.Message) bool { +func commitHashMatches(commitHash []byte, message *proto.IbftMessage) bool { if message == nil || message.Type != proto.MessageType_COMMIT { return false } - commitData, _ := message.Payload.(*proto.Message_CommitData) + commitData, _ := message.Payload.(*proto.IbftMessage_CommitData) extractedCommitHash := commitData.CommitData.ProposalHash return bytes.Equal(commitHash, extractedCommitHash) } -func generateMessages(count uint64, messageType proto.MessageType) []*proto.Message { - messages := make([]*proto.Message, count) +func generateMessages(count uint64, messageType proto.MessageType) []*proto.IbftMessage { + messages := make([]*proto.IbftMessage, count) for index := uint64(0); index < count; index++ { - message := &proto.Message{ + message := &proto.IbftMessage{ View: &proto.View{ Height: 0, Round: 0, @@ -66,19 +66,19 @@ func generateMessages(count uint64, messageType proto.MessageType) []*proto.Mess switch message.Type { case proto.MessageType_PREPREPARE: - message.Payload = &proto.Message_PreprepareData{ + message.Payload = &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{}, } case proto.MessageType_PREPARE: - message.Payload = &proto.Message_PrepareData{ + message.Payload = &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{}, } case proto.MessageType_COMMIT: - message.Payload = &proto.Message_CommitData{ + message.Payload = &proto.IbftMessage_CommitData{ CommitData: &proto.CommitMessage{}, } case proto.MessageType_ROUND_CHANGE: - message.Payload = &proto.Message_RoundChangeData{ + message.Payload = &proto.IbftMessage_RoundChangeData{ RoundChangeData: &proto.RoundChangeMessage{}, } } @@ -89,7 +89,7 @@ func generateMessages(count uint64, messageType proto.MessageType) []*proto.Mess return messages } -func generateMessagesWithSender(count uint64, messageType proto.MessageType, sender []byte) []*proto.Message { +func generateMessagesWithSender(count uint64, messageType proto.MessageType, sender []byte) []*proto.IbftMessage { messages := generateMessages(count, messageType) for _, message := range messages { @@ -99,7 +99,7 @@ func generateMessagesWithSender(count uint64, messageType proto.MessageType, sen return messages } -func generateMessagesWithUniqueSender(count uint64, messageType proto.MessageType) []*proto.Message { +func generateMessagesWithUniqueSender(count uint64, messageType proto.MessageType) []*proto.IbftMessage { messages := generateMessages(count, messageType) for index, message := range messages { @@ -109,16 +109,16 @@ func generateMessagesWithUniqueSender(count uint64, messageType proto.MessageTyp return messages } -func appendProposalHash(messages []*proto.Message, proposalHash []byte) { +func appendProposalHash(messages []*proto.IbftMessage, proposalHash []byte) { for _, message := range messages { switch message.Type { case proto.MessageType_PREPREPARE: - ppData, _ := message.Payload.(*proto.Message_PreprepareData) + ppData, _ := message.Payload.(*proto.IbftMessage_PreprepareData) payload := ppData.PreprepareData payload.ProposalHash = proposalHash case proto.MessageType_PREPARE: - pData, _ := message.Payload.(*proto.Message_PrepareData) + pData, _ := message.Payload.(*proto.IbftMessage_PrepareData) payload := pData.PrepareData payload.ProposalHash = proposalHash @@ -127,7 +127,7 @@ func appendProposalHash(messages []*proto.Message, proposalHash []byte) { } } -func setRoundForMessages(messages []*proto.Message, round uint64) { +func setRoundForMessages(messages []*proto.IbftMessage, round uint64) { for _, message := range messages { message.View.Round = round } @@ -143,8 +143,8 @@ func generateSeals(count int) [][]byte { return seals } -func filterMessages(messages []*proto.Message, isValid func(message *proto.Message) bool) []*proto.Message { - newMessages := make([]*proto.Message, 0) +func filterMessages(messages []*proto.IbftMessage, isValid func(message *proto.IbftMessage) bool) []*proto.IbftMessage { + newMessages := make([]*proto.IbftMessage, 0) for _, message := range messages { if isValid(message) { @@ -158,14 +158,14 @@ func filterMessages(messages []*proto.Message, isValid func(message *proto.Messa func generateFilledRCMessages( quorum uint64, proposal *proto.Proposal, - proposalHash []byte) []*proto.Message { + proposalHash []byte) []*proto.IbftMessage { // Generate random RC messages roundChangeMessages := generateMessagesWithUniqueSender(quorum, proto.MessageType_ROUND_CHANGE) prepareMessages := generateMessages(quorum-1, proto.MessageType_PREPARE) // Fill up the prepare message hashes for index, message := range prepareMessages { - message.Payload = &proto.Message_PrepareData{ + message.Payload = &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, @@ -178,14 +178,14 @@ func generateFilledRCMessages( } lastPreparedCertificate := &proto.PreparedCertificate{ - ProposalMessage: &proto.Message{ + ProposalMessage: &proto.IbftMessage{ View: &proto.View{ Height: 0, Round: 1, }, From: []byte("unique node"), Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: proposal, ProposalHash: proposalHash, @@ -198,7 +198,7 @@ func generateFilledRCMessages( // Fill up their certificates for _, message := range roundChangeMessages { - message.Payload = &proto.Message_RoundChangeData{ + message.Payload = &proto.IbftMessage_RoundChangeData{ RoundChangeData: &proto.RoundChangeMessage{ LastPreparedProposal: proposal, LatestPreparedCertificate: lastPreparedCertificate, @@ -226,11 +226,11 @@ func TestRunNewRound_Proposer(t *testing.T) { ctx, cancelFn := context.WithCancel(context.Background()) var ( - newRawProposal = []byte("new block") - multicastedProposal *proto.Message = nil + newRawProposal = []byte("new block") + multicastedProposal *proto.IbftMessage = nil log = mockLogger{} - transport = mockTransport{func(message *proto.Message) { + transport = mockTransport{func(message *proto.IbftMessage) { if message != nil && message.Type == proto.MessageType_PREPREPARE { multicastedProposal = message } @@ -247,11 +247,11 @@ func TestRunNewRound_Proposer(t *testing.T) { rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message { - return &proto.Message{ + ) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: &proto.Proposal{ RawProposal: rawProposal, @@ -313,12 +313,12 @@ func TestRunNewRound_Proposer(t *testing.T) { setRoundForMessages(roundChangeMessages, 1) var ( - multicastedPreprepare *proto.Message = nil - multicastedPrepare *proto.Message = nil - notifyCh = make(chan uint64, 1) + multicastedPreprepare *proto.IbftMessage = nil + multicastedPrepare *proto.IbftMessage = nil + notifyCh = make(chan uint64, 1) log = mockLogger{} - transport = mockTransport{func(message *proto.Message) { + transport = mockTransport{func(message *proto.IbftMessage) { switch message.Type { case proto.MessageType_PREPREPARE: multicastedPreprepare = message @@ -336,11 +336,11 @@ func TestRunNewRound_Proposer(t *testing.T) { buildProposalFn: func(_ uint64) []byte { return correctRoundMessage.proposal.GetRawProposal() }, - buildPrepareMessageFn: func(_ []byte, view *proto.View) *proto.Message { - return &proto.Message{ + buildPrepareMessageFn: func(_ []byte, view *proto.View) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: correctRoundMessage.hash, }, @@ -351,11 +351,11 @@ func TestRunNewRound_Proposer(t *testing.T) { _ []byte, _ *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message { - return &proto.Message{ + ) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: correctRoundMessage.proposal, ProposalHash: correctRoundMessage.hash, @@ -377,8 +377,8 @@ func TestRunNewRound_Proposer(t *testing.T) { getValidMessagesFn: func( view *proto.View, messageType proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( roundChangeMessages, isValid, @@ -386,9 +386,9 @@ func TestRunNewRound_Proposer(t *testing.T) { }, getExtendedRCCFn: func( height uint64, - isValidMessage func(message *proto.Message) bool, - isValidRCC func(round uint64, messages []*proto.Message, - ) bool) []*proto.Message { + isValidMessage func(message *proto.IbftMessage) bool, + isValidRCC func(round uint64, messages []*proto.IbftMessage, + ) bool) []*proto.IbftMessage { return filterMessages( roundChangeMessages, isValidMessage, @@ -442,7 +442,7 @@ func TestRunNewRound_Proposer(t *testing.T) { prepareMessages := generateMessages(quorum-1, proto.MessageType_PREPARE) for index, message := range prepareMessages { - message.Payload = &proto.Message_PrepareData{ + message.Payload = &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: correctRoundMessage.hash, }, @@ -454,19 +454,19 @@ func TestRunNewRound_Proposer(t *testing.T) { setRoundForMessages(roundChangeMessages, 1) // Make sure at least one RC message has a PC - payload, _ := roundChangeMessages[1].Payload.(*proto.Message_RoundChangeData) + payload, _ := roundChangeMessages[1].Payload.(*proto.IbftMessage_RoundChangeData) rcData := payload.RoundChangeData rcData.LastPreparedProposal = lastPreparedProposedProposal rcData.LatestPreparedCertificate = &proto.PreparedCertificate{ - ProposalMessage: &proto.Message{ + ProposalMessage: &proto.IbftMessage{ View: &proto.View{ Height: 0, Round: 0, }, From: []byte("unique node"), Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: lastPreparedProposedProposal, ProposalHash: correctRoundMessage.hash, @@ -478,14 +478,14 @@ func TestRunNewRound_Proposer(t *testing.T) { } var ( - proposerID = []byte("unique node") - multicastedPreprepare *proto.Message = nil - multicastedPrepare *proto.Message = nil - proposal = []byte("proposal") - notifyCh = make(chan uint64, 1) + proposerID = []byte("unique node") + multicastedPreprepare *proto.IbftMessage = nil + multicastedPrepare *proto.IbftMessage = nil + proposal = []byte("proposal") + notifyCh = make(chan uint64, 1) log = mockLogger{} - transport = mockTransport{func(message *proto.Message) { + transport = mockTransport{func(message *proto.IbftMessage) { switch message.Type { case proto.MessageType_PREPREPARE: multicastedPreprepare = message @@ -503,11 +503,11 @@ func TestRunNewRound_Proposer(t *testing.T) { buildProposalFn: func(_ uint64) []byte { return proposal }, - buildPrepareMessageFn: func(_ []byte, view *proto.View) *proto.Message { - return &proto.Message{ + buildPrepareMessageFn: func(_ []byte, view *proto.View) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: correctRoundMessage.hash, }, @@ -518,11 +518,11 @@ func TestRunNewRound_Proposer(t *testing.T) { rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message { - return &proto.Message{ + ) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: &proto.Proposal{ RawProposal: rawProposal, @@ -548,8 +548,8 @@ func TestRunNewRound_Proposer(t *testing.T) { getValidMessagesFn: func( view *proto.View, messageType proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( roundChangeMessages, isValid, @@ -557,9 +557,9 @@ func TestRunNewRound_Proposer(t *testing.T) { }, getExtendedRCCFn: func( height uint64, - isValidMessage func(message *proto.Message) bool, - isValidRCC func(round uint64, messages []*proto.Message) bool, - ) []*proto.Message { + isValidMessage func(message *proto.IbftMessage) bool, + isValidRCC func(round uint64, messages []*proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( roundChangeMessages, isValidMessage, @@ -606,13 +606,13 @@ func TestRunNewRound_Validator_Zero(t *testing.T) { ctx, cancelFn := context.WithCancel(context.Background()) var ( - proposer = []byte("proposer") - multicastedPrepare *proto.Message = nil - notifyCh = make(chan uint64, 1) + proposer = []byte("proposer") + multicastedPrepare *proto.IbftMessage = nil + notifyCh = make(chan uint64, 1) log = mockLogger{} transport = mockTransport{ - func(message *proto.Message) { + func(message *proto.IbftMessage) { if message != nil && message.Type == proto.MessageType_PREPARE { multicastedPrepare = message } @@ -623,11 +623,11 @@ func TestRunNewRound_Validator_Zero(t *testing.T) { return []byte("non proposer") }, getVotingPowerFn: testCommonGetVotingPowertFnForCnt(1), - buildPrepareMessageFn: func(proposal []byte, view *proto.View) *proto.Message { - return &proto.Message{ + buildPrepareMessageFn: func(proposal []byte, view *proto.View) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: correctRoundMessage.hash, }, @@ -654,15 +654,15 @@ func TestRunNewRound_Validator_Zero(t *testing.T) { getValidMessagesFn: func( view *proto.View, _ proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( - []*proto.Message{ + []*proto.IbftMessage{ { View: view, From: proposer, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: correctRoundMessage.proposal, }, @@ -707,18 +707,18 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) { roundMessage := newCorrectRoundMessage(round) - generateProposalWithNoPrevious := func() *proto.Message { + generateProposalWithNoPrevious := func() *proto.IbftMessage { roundChangeMessages := generateMessagesWithUniqueSender(quorum, proto.MessageType_ROUND_CHANGE) setRoundForMessages(roundChangeMessages, round) - return &proto.Message{ + return &proto.IbftMessage{ View: &proto.View{ Height: 0, Round: round, }, From: proposer, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: roundMessage.proposal, ProposalHash: roundMessage.hash, @@ -730,15 +730,15 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) { } } - generateProposalWithPrevious := func() *proto.Message { - return &proto.Message{ + generateProposalWithPrevious := func() *proto.IbftMessage { + return &proto.IbftMessage{ View: &proto.View{ Height: 0, Round: 1, }, From: proposer, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: roundMessage.proposal, ProposalHash: roundMessage.hash, @@ -756,7 +756,7 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) { testTable := []struct { name string - proposalMessage *proto.Message + proposalMessage *proto.IbftMessage }{ { "validator receives valid block proposal (round > 0, new block)", @@ -778,12 +778,12 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) { defer cancelFn() var ( - multicastedPrepare *proto.Message = nil - notifyCh = make(chan uint64, 1) + multicastedPrepare *proto.IbftMessage = nil + notifyCh = make(chan uint64, 1) log = mockLogger{} transport = mockTransport{ - func(message *proto.Message) { + func(message *proto.IbftMessage) { if message != nil && message.Type == proto.MessageType_PREPARE { multicastedPrepare = message } @@ -794,11 +794,11 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) { return []byte("non proposer") }, getVotingPowerFn: testCommonGetVotingPowertFnForCnt(quorum), - buildPrepareMessageFn: func(proposal []byte, view *proto.View) *proto.Message { - return &proto.Message{ + buildPrepareMessageFn: func(proposal []byte, view *proto.View) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: roundMessage.hash, }, @@ -825,10 +825,10 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) { getValidMessagesFn: func( view *proto.View, _ proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( - []*proto.Message{ + []*proto.IbftMessage{ testCase.proposalMessage, }, isValid, @@ -878,21 +878,21 @@ func TestRunPrepare(t *testing.T) { ctx, cancelFn := context.WithCancel(context.Background()) var ( - multicastedCommit *proto.Message = nil - notifyCh = make(chan uint64, 1) + multicastedCommit *proto.IbftMessage = nil + notifyCh = make(chan uint64, 1) log = mockLogger{} - transport = mockTransport{func(message *proto.Message) { + transport = mockTransport{func(message *proto.IbftMessage) { if message != nil && message.Type == proto.MessageType_COMMIT { multicastedCommit = message } }} backend = mockBackend{ - buildCommitMessageFn: func(_ []byte, view *proto.View) *proto.Message { - return &proto.Message{ + buildCommitMessageFn: func(_ []byte, view *proto.View) *proto.IbftMessage { + return &proto.IbftMessage{ View: view, Type: proto.MessageType_COMMIT, - Payload: &proto.Message_CommitData{ + Payload: &proto.IbftMessage_CommitData{ CommitData: &proto.CommitMessage{ ProposalHash: correctRoundMessage.hash, }, @@ -917,14 +917,14 @@ func TestRunPrepare(t *testing.T) { getValidMessagesFn: func( view *proto.View, _ proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( - []*proto.Message{ + []*proto.IbftMessage{ { View: view, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: correctRoundMessage.hash, }, @@ -942,8 +942,8 @@ func TestRunPrepare(t *testing.T) { require.NoError(t, i.validatorManager.Init(0)) i.state.name = prepare i.state.roundStarted = true - i.state.proposalMessage = &proto.Message{ - Payload: &proto.Message_PreprepareData{ + i.state.proposalMessage = &proto.IbftMessage{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: correctRoundMessage.proposal, ProposalHash: correctRoundMessage.hash, @@ -1019,14 +1019,14 @@ func TestRunCommit(t *testing.T) { getValidMessagesFn: func( view *proto.View, _ proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( - []*proto.Message{ + []*proto.IbftMessage{ { View: view, Type: proto.MessageType_COMMIT, - Payload: &proto.Message_CommitData{ + Payload: &proto.IbftMessage_CommitData{ CommitData: &proto.CommitMessage{ ProposalHash: correctRoundMessage.hash, CommittedSeal: committedSeals[0].Signature, @@ -1044,8 +1044,8 @@ func TestRunCommit(t *testing.T) { i := NewIBFT(log, backend, transport) require.NoError(t, i.validatorManager.Init(0)) i.messages = messages - i.state.proposalMessage = &proto.Message{ - Payload: &proto.Message_PreprepareData{ + i.state.proposalMessage = &proto.IbftMessage{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: correctRoundMessage.proposal, ProposalHash: correctRoundMessage.hash, @@ -1197,7 +1197,7 @@ func TestIBFT_IsAcceptableMessage(t *testing.T) { log = mockLogger{} transport = mockTransport{} backend = mockBackend{ - IsValidValidatorFn: func(message *proto.Message) bool { + IsValidValidatorFn: func(message *proto.IbftMessage) bool { return !testCase.invalidSender }, } @@ -1206,7 +1206,7 @@ func TestIBFT_IsAcceptableMessage(t *testing.T) { i := NewIBFT(log, backend, transport) i.state.view = testCase.stateView - message := &proto.Message{ + message := &proto.IbftMessage{ View: testCase.msgView, } @@ -1332,13 +1332,13 @@ func TestIBFT_FutureProposal(t *testing.T) { proposer := []byte("proposer") quorum := uint64(4) - generateEmptyRCMessages := func(count uint64, round uint64) []*proto.Message { + generateEmptyRCMessages := func(count uint64, round uint64) []*proto.IbftMessage { // Generate random RC messages roundChangeMessages := generateMessagesWithUniqueSender(count, proto.MessageType_ROUND_CHANGE) // Fill up their certificates for _, message := range roundChangeMessages { - message.Payload = &proto.Message_RoundChangeData{ + message.Payload = &proto.IbftMessage_RoundChangeData{ RoundChangeData: &proto.RoundChangeMessage{ LastPreparedProposal: nil, LatestPreparedCertificate: nil, @@ -1353,15 +1353,15 @@ func TestIBFT_FutureProposal(t *testing.T) { generateValidProposal := func( view *proto.View, - roundChangeMessages []*proto.Message, - ) *proto.Message { + roundChangeMessages []*proto.IbftMessage, + ) *proto.IbftMessage { roundMessage := newCorrectRoundMessage(view.Round) - return &proto.Message{ + return &proto.IbftMessage{ View: view, From: proposer, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: roundMessage.proposal, ProposalHash: roundMessage.hash, @@ -1373,7 +1373,7 @@ func TestIBFT_FutureProposal(t *testing.T) { } } - generateFilledRCMessagesWithRound := func(quorum, round uint64) []*proto.Message { + generateFilledRCMessagesWithRound := func(quorum, round uint64) []*proto.IbftMessage { messages := generateFilledRCMessages(quorum, correctRoundMessage.proposal, correctRoundMessage.hash) setRoundForMessages(messages, round) @@ -1383,7 +1383,7 @@ func TestIBFT_FutureProposal(t *testing.T) { testTable := []struct { name string proposalView *proto.View - roundChangeMessages []*proto.Message + roundChangeMessages []*proto.IbftMessage notifyRound uint64 }{ { @@ -1451,10 +1451,10 @@ func TestIBFT_FutureProposal(t *testing.T) { getValidMessagesFn: func( view *proto.View, _ proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( - []*proto.Message{ + []*proto.IbftMessage{ validProposal, }, isValid, @@ -1539,13 +1539,13 @@ func TestIBFT_ValidPC(t *testing.T) { certificate := &proto.PreparedCertificate{ ProposalMessage: nil, - PrepareMessages: make([]*proto.Message, 0), + PrepareMessages: make([]*proto.IbftMessage, 0), } assert.False(t, i.validPC(certificate, 0, 0)) certificate = &proto.PreparedCertificate{ - ProposalMessage: &proto.Message{}, + ProposalMessage: &proto.IbftMessage{}, PrepareMessages: nil, } @@ -1568,7 +1568,7 @@ func TestIBFT_ValidPC(t *testing.T) { i := NewIBFT(log, backend, transport) certificate := &proto.PreparedCertificate{ - ProposalMessage: &proto.Message{}, + ProposalMessage: &proto.IbftMessage{}, PrepareMessages: generateMessages(quorum-2, proto.MessageType_PREPARE), } @@ -1591,7 +1591,7 @@ func TestIBFT_ValidPC(t *testing.T) { i := NewIBFT(log, backend, transport) certificate := &proto.PreparedCertificate{ - ProposalMessage: &proto.Message{ + ProposalMessage: &proto.IbftMessage{ Type: proto.MessageType_PREPARE, }, PrepareMessages: generateMessages(quorum-1, proto.MessageType_PREPARE), @@ -1616,7 +1616,7 @@ func TestIBFT_ValidPC(t *testing.T) { i := NewIBFT(log, backend, transport) certificate := &proto.PreparedCertificate{ - ProposalMessage: &proto.Message{ + ProposalMessage: &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, }, PrepareMessages: generateMessages(quorum-1, proto.MessageType_PREPARE), @@ -1645,7 +1645,7 @@ func TestIBFT_ValidPC(t *testing.T) { i := NewIBFT(log, backend, transport) certificate := &proto.PreparedCertificate{ - ProposalMessage: &proto.Message{ + ProposalMessage: &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, From: sender, }, @@ -1679,7 +1679,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure the proposal has a different hash than the prepare messages - appendProposalHash([]*proto.Message{certificate.ProposalMessage}, []byte("proposal hash 1")) + appendProposalHash([]*proto.IbftMessage{certificate.ProposalMessage}, []byte("proposal hash 1")) appendProposalHash(certificate.PrepareMessages, []byte("proposal hash 2")) assert.False(t, i.validPC(certificate, 0, 0)) @@ -1710,7 +1710,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -1752,7 +1752,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -1791,7 +1791,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -1834,7 +1834,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -1860,7 +1860,7 @@ func TestIBFT_ValidPC(t *testing.T) { isProposerFn: func(proposer []byte, _ uint64, _ uint64) bool { return bytes.Equal(proposer, sender) }, - IsValidValidatorFn: func(message *proto.Message) bool { + IsValidValidatorFn: func(message *proto.IbftMessage) bool { // One of the messages will be invalid return !bytes.Equal(message.From, []byte("node 1")) }, @@ -1877,7 +1877,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -1903,7 +1903,7 @@ func TestIBFT_ValidPC(t *testing.T) { isProposerFn: func(proposer []byte, _ uint64, _ uint64) bool { return bytes.Equal(proposer, sender) }, - IsValidValidatorFn: func(message *proto.Message) bool { + IsValidValidatorFn: func(message *proto.IbftMessage) bool { // Proposer is invalid return !bytes.Equal(message.From, sender) }, @@ -1920,7 +1920,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -1959,7 +1959,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -1985,7 +1985,7 @@ func TestIBFT_ValidPC(t *testing.T) { isProposerFn: func(proposer []byte, _ uint64, _ uint64) bool { return bytes.Equal(proposer, sender) }, - IsValidValidatorFn: func(message *proto.Message) bool { + IsValidValidatorFn: func(message *proto.IbftMessage) bool { return true }, } @@ -2002,7 +2002,7 @@ func TestIBFT_ValidPC(t *testing.T) { } // Make sure they all have the same proposal hash - allMessages := append([]*proto.Message{certificate.ProposalMessage}, certificate.PrepareMessages...) + allMessages := append([]*proto.IbftMessage{certificate.ProposalMessage}, certificate.PrepareMessages...) appendProposalHash( allMessages, correctRoundMessage.hash, @@ -2036,10 +2036,10 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: 0, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: &proto.Proposal{ Round: baseView.Round, @@ -2073,10 +2073,10 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: 0, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: &proto.Proposal{ Round: 0, @@ -2110,10 +2110,10 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: 0, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: &proto.Proposal{ Round: baseView.Round, @@ -2144,10 +2144,10 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: 0, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: nil, Proposal: &proto.Proposal{ @@ -2192,10 +2192,10 @@ func TestIBFT_ValidateProposal(t *testing.T) { msg.From = []byte("non unique node id") } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: messages, @@ -2232,10 +2232,10 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: 0, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: generateMessages(quorum-1, proto.MessageType_ROUND_CHANGE), @@ -2280,11 +2280,11 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: 0, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, From: uniqueNode, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: generateMessages(quorum, proto.MessageType_ROUND_CHANGE), @@ -2324,10 +2324,10 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: 0, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: &proto.Proposal{ Round: baseView.Round, @@ -2373,11 +2373,11 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: round, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, From: uniqueNode, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: generateMessages(quorum, proto.MessageType_ROUND_CHANGE), @@ -2416,39 +2416,39 @@ func TestIBFT_ValidateProposal(t *testing.T) { i := NewIBFT(log, backend, transport) // 4 ROUND-CHANGE messages + 1 COMMIT message (wrong type message) - roundChangeMessages := make([]*proto.Message, 0) + roundChangeMessages := make([]*proto.IbftMessage, 0) for idx := 0; idx < int(quorum); idx++ { - roundChangeMessages = append(roundChangeMessages, &proto.Message{ + roundChangeMessages = append(roundChangeMessages, &proto.IbftMessage{ From: []byte(fmt.Sprintf("node%d", idx)), View: &proto.View{ Height: 0, Round: round, }, Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{}, + Payload: &proto.IbftMessage_RoundChangeData{}, }) } - roundChangeMessages = append(roundChangeMessages, &proto.Message{ + roundChangeMessages = append(roundChangeMessages, &proto.IbftMessage{ From: []byte(fmt.Sprintf("node%d", quorum)), View: &proto.View{ Height: 0, Round: 0, }, Type: proto.MessageType_COMMIT, - Payload: &proto.Message_RoundChangeData{}, + Payload: &proto.IbftMessage_RoundChangeData{}, }) baseView := &proto.View{ Height: 0, Round: round, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, From: uniqueNode, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: roundChangeMessages, @@ -2487,17 +2487,17 @@ func TestIBFT_ValidateProposal(t *testing.T) { i := NewIBFT(log, backend, transport) // 4 ROUND-CHANGE messages - roundChangeMessages := make([]*proto.Message, quorum) + roundChangeMessages := make([]*proto.IbftMessage, quorum) for idx := range roundChangeMessages { - roundChangeMessages[idx] = &proto.Message{ + roundChangeMessages[idx] = &proto.IbftMessage{ From: []byte(fmt.Sprintf("node%d", idx)), View: &proto.View{ Height: 100, // wrong height Round: round, }, Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{}, + Payload: &proto.IbftMessage_RoundChangeData{}, } } @@ -2505,11 +2505,11 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: round, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, From: uniqueNode, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: roundChangeMessages, @@ -2548,17 +2548,17 @@ func TestIBFT_ValidateProposal(t *testing.T) { i := NewIBFT(log, backend, transport) // 4 ROUND-CHANGE messages with wrong round - roundChangeMessages := make([]*proto.Message, quorum) + roundChangeMessages := make([]*proto.IbftMessage, quorum) for idx := range roundChangeMessages { - roundChangeMessages[idx] = &proto.Message{ + roundChangeMessages[idx] = &proto.IbftMessage{ From: []byte(fmt.Sprintf("node%d", idx)), View: &proto.View{ Height: 0, Round: round + 1, // wrong round }, Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{}, + Payload: &proto.IbftMessage_RoundChangeData{}, } } @@ -2566,11 +2566,11 @@ func TestIBFT_ValidateProposal(t *testing.T) { Height: 0, Round: round, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, From: uniqueNode, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: roundChangeMessages, @@ -2603,7 +2603,7 @@ func TestIBFT_ValidateProposal(t *testing.T) { isProposerFn: func(proposer []byte, _ uint64, _ uint64) bool { return bytes.Equal(proposer, uniqueNode) }, - IsValidValidatorFn: func(m *proto.Message) bool { + IsValidValidatorFn: func(m *proto.IbftMessage) bool { return !bytes.Equal(m.From, nonValidator) }, } @@ -2613,39 +2613,39 @@ func TestIBFT_ValidateProposal(t *testing.T) { i := NewIBFT(log, backend, transport) // 4 ROUND-CHANGE messages by validators + 1 ROUND-CHANGE message by non-validator - roundChangeMessages := make([]*proto.Message, 0) + roundChangeMessages := make([]*proto.IbftMessage, 0) for idx := 0; idx < int(quorum); idx++ { - roundChangeMessages = append(roundChangeMessages, &proto.Message{ + roundChangeMessages = append(roundChangeMessages, &proto.IbftMessage{ From: []byte(fmt.Sprintf("node%d", idx)), View: &proto.View{ Height: 0, Round: round, }, Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{}, + Payload: &proto.IbftMessage_RoundChangeData{}, }) } - roundChangeMessages = append(roundChangeMessages, &proto.Message{ + roundChangeMessages = append(roundChangeMessages, &proto.IbftMessage{ From: nonValidator, View: &proto.View{ Height: 0, Round: round, }, Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{}, + Payload: &proto.IbftMessage_RoundChangeData{}, }) baseView := &proto.View{ Height: 0, Round: round, } - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: baseView, From: uniqueNode, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: roundChangeMessages, @@ -2690,7 +2690,7 @@ func TestIBFT_ValidateProposal(t *testing.T) { isProposerFn: func(proposer []byte, _ uint64, round uint64) bool { return bytes.Equal(proposer, proposers[round]) }, - IsValidValidatorFn: func(m *proto.Message) bool { + IsValidValidatorFn: func(m *proto.IbftMessage) bool { return !bytes.Equal(m.From, nonValidator) }, isValidProposalHashFn: func(p *proto.Proposal, b []byte) bool { @@ -2723,11 +2723,11 @@ func TestIBFT_ValidateProposal(t *testing.T) { i := NewIBFT(log, backend, transport) // previous PREPREPARE + PREPARE messages whose proposal hashes are not correct - previousProposal := &proto.Message{ + previousProposal := &proto.IbftMessage{ View: views[0], From: proposers[0], Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ // the hash should be (proposal, 0) Proposal: &proto.Proposal{ @@ -2740,13 +2740,13 @@ func TestIBFT_ValidateProposal(t *testing.T) { }, } - previousPrepares := make([]*proto.Message, quorum) + previousPrepares := make([]*proto.IbftMessage, quorum) for idx := range previousPrepares { - previousPrepares[idx] = &proto.Message{ + previousPrepares[idx] = &proto.IbftMessage{ From: []byte(fmt.Sprintf("node%d", idx)), View: views[0], Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: correctProposalHash, }, @@ -2755,14 +2755,14 @@ func TestIBFT_ValidateProposal(t *testing.T) { } // ROUND-CHANGE messages for round 2 - roundChangeMessages := make([]*proto.Message, quorum) + roundChangeMessages := make([]*proto.IbftMessage, quorum) for idx := range roundChangeMessages { - roundChangeMessages[idx] = &proto.Message{ + roundChangeMessages[idx] = &proto.IbftMessage{ From: []byte(fmt.Sprintf("node%d", idx)), View: views[2], Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{ + Payload: &proto.IbftMessage_RoundChangeData{ RoundChangeData: &proto.RoundChangeMessage{ LatestPreparedCertificate: &proto.PreparedCertificate{ ProposalMessage: previousProposal, @@ -2774,11 +2774,11 @@ func TestIBFT_ValidateProposal(t *testing.T) { } // proposal with RoundChangeCertificate - proposal := &proto.Message{ + proposal := &proto.IbftMessage{ View: views[2], From: proposers[2], Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: &proto.RoundChangeCertificate{ RoundChangeMessages: roundChangeMessages, @@ -2831,8 +2831,8 @@ func TestIBFT_WatchForFutureRCC(t *testing.T) { getValidMessagesFn: func( view *proto.View, messageType proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { return filterMessages( roundChangeMessages, isValid, @@ -2840,9 +2840,9 @@ func TestIBFT_WatchForFutureRCC(t *testing.T) { }, getExtendedRCCFn: func( height uint64, - isValidMessage func(message *proto.Message) bool, - isValidRCC func(round uint64, messages []*proto.Message) bool, - ) []*proto.Message { + isValidMessage func(message *proto.IbftMessage) bool, + isValidRCC func(round uint64, messages []*proto.IbftMessage) bool, + ) []*proto.IbftMessage { messages := filterMessages( roundChangeMessages, isValidMessage, @@ -2945,8 +2945,8 @@ func TestIBFT_RunSequence_NewProposal(t *testing.T) { i.newProposal = make(chan newProposalEvent, 1) ev := newProposalEvent{ - proposalMessage: &proto.Message{ - Payload: &proto.Message_PreprepareData{ + proposalMessage: &proto.IbftMessage{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: proposal, }, @@ -3129,7 +3129,7 @@ func TestIBFT_AddMessage(t *testing.T) { var validSender = []byte("node 0") executeTest := func( - msg *proto.Message, shouldAddMessageCalled, shouldSignalEventCalled bool, quorumSize uint64) { + msg *proto.IbftMessage, shouldAddMessageCalled, shouldSignalEventCalled bool, quorumSize uint64) { var ( signalEventCalled = false addMessageCalled = false @@ -3139,7 +3139,7 @@ func TestIBFT_AddMessage(t *testing.T) { messages = mockMessages{} ) - backend.IsValidValidatorFn = func(m *proto.Message) bool { + backend.IsValidValidatorFn = func(m *proto.IbftMessage) bool { return bytes.Equal(m.From, validSender) } @@ -3148,12 +3148,12 @@ func TestIBFT_AddMessage(t *testing.T) { messages.getValidMessagesFn = func( view *proto.View, messageType proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message { - return []*proto.Message{msg} + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage { + return []*proto.IbftMessage{msg} } - messages.addMessageFn = func(m *proto.Message) { + messages.addMessageFn = func(m *proto.IbftMessage) { addMessageCalled = true assert.Equal(t, msg, m) @@ -3183,7 +3183,7 @@ func TestIBFT_AddMessage(t *testing.T) { t.Run("!isAcceptableMessage - invalid sender", func(t *testing.T) { t.Parallel() - msg := &proto.Message{ + msg := &proto.IbftMessage{ View: &proto.View{Height: validHeight, Round: validRound}, Type: validMsgType, } @@ -3193,7 +3193,7 @@ func TestIBFT_AddMessage(t *testing.T) { t.Run("!isAcceptableMessage - invalid view", func(t *testing.T) { t.Parallel() - msg := &proto.Message{ + msg := &proto.IbftMessage{ From: validSender, Type: validMsgType, } @@ -3203,7 +3203,7 @@ func TestIBFT_AddMessage(t *testing.T) { t.Run("!isAcceptableMessage - invalid height", func(t *testing.T) { t.Parallel() - msg := &proto.Message{ + msg := &proto.IbftMessage{ From: validSender, Type: validMsgType, View: &proto.View{Height: validHeight - 1, Round: validRound}, @@ -3214,7 +3214,7 @@ func TestIBFT_AddMessage(t *testing.T) { t.Run("!isAcceptableMessage - invalid round", func(t *testing.T) { t.Parallel() - msg := &proto.Message{ + msg := &proto.IbftMessage{ From: validSender, Type: validMsgType, View: &proto.View{Height: validHeight, Round: validRound - 1}, @@ -3225,7 +3225,7 @@ func TestIBFT_AddMessage(t *testing.T) { t.Run("correct - but quorum not reached", func(t *testing.T) { t.Parallel() - msg := &proto.Message{ + msg := &proto.IbftMessage{ From: validSender, Type: proto.MessageType_PREPARE, View: &proto.View{Height: validHeight, Round: validRound}, @@ -3236,7 +3236,7 @@ func TestIBFT_AddMessage(t *testing.T) { t.Run("correct - quorum reached", func(t *testing.T) { t.Parallel() - msg := &proto.Message{ + msg := &proto.IbftMessage{ From: validSender, Type: validMsgType, View: &proto.View{Height: validHeight, Round: validRound}, diff --git a/core/mock_test.go b/core/mock_test.go index 853eeb5..e012d42 100644 --- a/core/mock_test.go +++ b/core/mock_test.go @@ -42,7 +42,7 @@ func newCorrectRoundMessage(round uint64) roundMessage { // Define delegation methods type isValidBlockDelegate func([]byte) bool -type IsValidValidatorDelegate func(*proto.Message) bool +type IsValidValidatorDelegate func(*proto.IbftMessage) bool type isProposerDelegate func([]byte, uint64, uint64) bool type buildEthereumBlockDelegate func(uint64) []byte type isValidProposalHashDelegate func(*proto.Proposal, []byte) bool @@ -52,14 +52,14 @@ type buildPrePrepareMessageDelegate func( []byte, *proto.RoundChangeCertificate, *proto.View, -) *proto.Message -type buildPrepareMessageDelegate func([]byte, *proto.View) *proto.Message -type buildCommitMessageDelegate func([]byte, *proto.View) *proto.Message +) *proto.IbftMessage +type buildPrepareMessageDelegate func([]byte, *proto.View) *proto.IbftMessage +type buildCommitMessageDelegate func([]byte, *proto.View) *proto.IbftMessage type buildRoundChangeMessageDelegate func( *proto.Proposal, *proto.PreparedCertificate, *proto.View, -) *proto.Message +) *proto.IbftMessage type insertProposalDelegate func(*proto.Proposal, []*messages.CommittedSeal) type idDelegate func() []byte @@ -110,7 +110,7 @@ func (m mockBackend) IsValidProposal(proposal []byte) bool { return true } -func (m mockBackend) IsValidValidator(msg *proto.Message) bool { +func (m mockBackend) IsValidValidator(msg *proto.IbftMessage) bool { if m.IsValidValidatorFn != nil { return m.IsValidValidatorFn(msg) } @@ -154,7 +154,7 @@ func (m mockBackend) BuildPrePrepareMessage( rawProposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, -) *proto.Message { +) *proto.IbftMessage { if m.buildPrePrepareMessageFn != nil { return m.buildPrePrepareMessageFn(rawProposal, certificate, view) } @@ -162,7 +162,7 @@ func (m mockBackend) BuildPrePrepareMessage( return nil } -func (m mockBackend) BuildPrepareMessage(proposal []byte, view *proto.View) *proto.Message { +func (m mockBackend) BuildPrepareMessage(proposal []byte, view *proto.View) *proto.IbftMessage { if m.buildPrepareMessageFn != nil { return m.buildPrepareMessageFn(proposal, view) } @@ -170,7 +170,7 @@ func (m mockBackend) BuildPrepareMessage(proposal []byte, view *proto.View) *pro return nil } -func (m mockBackend) BuildCommitMessage(proposalHash []byte, view *proto.View) *proto.Message { +func (m mockBackend) BuildCommitMessage(proposalHash []byte, view *proto.View) *proto.IbftMessage { if m.buildCommitMessageFn != nil { return m.buildCommitMessageFn(proposalHash, view) } @@ -182,12 +182,12 @@ func (m mockBackend) BuildRoundChangeMessage( proposal *proto.Proposal, certificate *proto.PreparedCertificate, view *proto.View, -) *proto.Message { +) *proto.IbftMessage { if m.buildRoundChangeMessageFn != nil { return m.buildRoundChangeMessageFn(proposal, certificate, view) } - return &proto.Message{ + return &proto.IbftMessage{ View: &proto.View{ Height: view.Height, Round: view.Round, @@ -222,14 +222,14 @@ func (m mockBackend) SequenceCancelled(view *proto.View) error { } // Define delegation methods -type multicastFnDelegate func(*proto.Message) +type multicastFnDelegate func(*proto.IbftMessage) // mockTransport is the mock transport structure that is configurable type mockTransport struct { multicastFn multicastFnDelegate } -func (t mockTransport) Multicast(msg *proto.Message) { +func (t mockTransport) Multicast(msg *proto.IbftMessage) { if t.multicastFn != nil { t.multicastFn(msg) } @@ -264,21 +264,21 @@ func (l mockLogger) Error(msg string, args ...interface{}) { } type mockMessages struct { - addMessageFn func(message *proto.Message) + addMessageFn func(message *proto.IbftMessage) pruneByHeightFn func(height uint64) signalEventFn func(messageType proto.MessageType, messageView *proto.View) getValidMessagesFn func( view *proto.View, messageType proto.MessageType, - isValid func(message *proto.Message) bool, - ) []*proto.Message + isValid func(message *proto.IbftMessage) bool, + ) []*proto.IbftMessage getExtendedRCCFn func( height uint64, - isValidMessage func(message *proto.Message) bool, - isValidRCC func(round uint64, messages []*proto.Message) bool, - ) []*proto.Message - getMostRoundChangeMessagesFn func(uint64, uint64) []*proto.Message + isValidMessage func(message *proto.IbftMessage) bool, + isValidRCC func(round uint64, messages []*proto.IbftMessage) bool, + ) []*proto.IbftMessage + getMostRoundChangeMessagesFn func(uint64, uint64) []*proto.IbftMessage subscribeFn func(details messages.SubscriptionDetails) *messages.Subscription unsubscribeFn func(id messages.SubscriptionID) @@ -287,8 +287,8 @@ type mockMessages struct { func (m mockMessages) GetValidMessages( view *proto.View, messageType proto.MessageType, - isValid func(*proto.Message) bool, -) []*proto.Message { + isValid func(*proto.IbftMessage) bool, +) []*proto.IbftMessage { if m.getValidMessagesFn != nil { return m.getValidMessagesFn(view, messageType, isValid) } @@ -310,7 +310,7 @@ func (m mockMessages) Unsubscribe(id messages.SubscriptionID) { } } -func (m mockMessages) AddMessage(msg *proto.Message) { +func (m mockMessages) AddMessage(msg *proto.IbftMessage) { if m.addMessageFn != nil { m.addMessageFn(msg) } @@ -330,9 +330,9 @@ func (m mockMessages) SignalEvent(msgType proto.MessageType, view *proto.View) { func (m mockMessages) GetExtendedRCC( height uint64, - isValidMessage func(message *proto.Message) bool, - isValidRCC func(round uint64, messages []*proto.Message) bool, -) []*proto.Message { + isValidMessage func(message *proto.IbftMessage) bool, + isValidRCC func(round uint64, messages []*proto.IbftMessage) bool, +) []*proto.IbftMessage { if m.getExtendedRCCFn != nil { return m.getExtendedRCCFn(height, isValidMessage, isValidRCC) } @@ -340,7 +340,7 @@ func (m mockMessages) GetExtendedRCC( return nil } -func (m mockMessages) GetMostRoundChangeMessages(round, height uint64) []*proto.Message { +func (m mockMessages) GetMostRoundChangeMessages(round, height uint64) []*proto.IbftMessage { if m.getMostRoundChangeMessagesFn != nil { return m.getMostRoundChangeMessagesFn(round, height) } @@ -546,7 +546,7 @@ func (m *mockCluster) awaitNCompletions( // pushMessage imitates a message passing service, // it relays a message to all nodes in the network -func (m *mockCluster) pushMessage(message *proto.Message) { +func (m *mockCluster) pushMessage(message *proto.IbftMessage) { for _, node := range m.nodes { node.AddMessage(message) } diff --git a/core/rapid_test.go b/core/rapid_test.go index 9bb33f5..1fb69a0 100644 --- a/core/rapid_test.go +++ b/core/rapid_test.go @@ -207,7 +207,7 @@ func TestProperty(t *testing.T) { t.Parallel() rapid.Check(t, func(t *rapid.T) { - var multicastFn func(message *proto.Message) + var multicastFn func(message *proto.IbftMessage) var ( setup = generatePropertyTestEvent(t) @@ -218,7 +218,7 @@ func TestProperty(t *testing.T) { // commonTransportCallback is the common method modification // required for Transport, for all nodes commonTransportCallback := func(transport *mockTransport, nodeIndex int) { - transport.multicastFn = func(message *proto.Message) { + transport.multicastFn = func(message *proto.IbftMessage) { if message.Type == proto.MessageType_ROUND_CHANGE { setup.setRound(nodeIndex, message.View.Round) } @@ -271,7 +271,7 @@ func TestProperty(t *testing.T) { proposal []byte, certificate *proto.RoundChangeCertificate, view *proto.View, - ) *proto.Message { + ) *proto.IbftMessage { message := setup.getEvent(nodeIndex).getMessage(nodeIndex) return buildBasicPreprepareMessage( @@ -284,14 +284,14 @@ func TestProperty(t *testing.T) { } // Make sure the prepare message is built correctly - backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.Message { + backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.IbftMessage { message := setup.getEvent(nodeIndex).getMessage(nodeIndex) return buildBasicPrepareMessage(message.hash, nodes[nodeIndex], view) } // Make sure the commit message is built correctly - backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.Message { + backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.IbftMessage { message := setup.getEvent(nodeIndex).getMessage(nodeIndex) return buildBasicCommitMessage(message.hash, message.seal, nodes[nodeIndex], view) @@ -302,7 +302,7 @@ func TestProperty(t *testing.T) { proposal *proto.Proposal, certificate *proto.PreparedCertificate, view *proto.View, - ) *proto.Message { + ) *proto.IbftMessage { return buildBasicRoundChangeMessage(proposal, certificate, view, nodes[nodeIndex]) } diff --git a/core/state.go b/core/state.go index 004d8b9..bee977b 100644 --- a/core/state.go +++ b/core/state.go @@ -45,7 +45,7 @@ type state struct { latestPreparedProposal *proto.Proposal // accepted proposal for current round - proposalMessage *proto.Message + proposalMessage *proto.IbftMessage // validated commit seals seals []*messages.CommittedSeal @@ -97,7 +97,7 @@ func (s *state) getLatestPreparedProposal() *proto.Proposal { return s.latestPreparedProposal } -func (s *state) getProposalMessage() *proto.Message { +func (s *state) getProposalMessage() *proto.IbftMessage { s.RLock() defer s.RUnlock() @@ -111,7 +111,7 @@ func (s *state) getProposalHash() []byte { return messages.ExtractProposalHash(s.proposalMessage) } -func (s *state) setProposalMessage(proposalMessage *proto.Message) { +func (s *state) setProposalMessage(proposalMessage *proto.IbftMessage) { s.Lock() defer s.Unlock() diff --git a/core/transport.go b/core/transport.go index a1d021e..a9e81d5 100644 --- a/core/transport.go +++ b/core/transport.go @@ -6,5 +6,5 @@ import "github.com/0xPolygon/go-ibft/messages/proto" // the node uses to communicate with other peers type Transport interface { // Multicast multicasts the message to other peers - Multicast(message *proto.Message) + Multicast(message *proto.IbftMessage) } diff --git a/core/validator_manager.go b/core/validator_manager.go index 139f9fb..885b332 100644 --- a/core/validator_manager.go +++ b/core/validator_manager.go @@ -96,8 +96,8 @@ func (vm *ValidatorManager) HasQuorum(sendersAddrs map[string]struct{}) bool { } // HasPrepareQuorum provides information on whether prepared messages have reached the quorum -func (vm *ValidatorManager) HasPrepareQuorum(stateName stateType, proposalMessage *proto.Message, - msgs []*proto.Message) bool { +func (vm *ValidatorManager) HasPrepareQuorum(stateName stateType, proposalMessage *proto.IbftMessage, + msgs []*proto.IbftMessage) bool { if proposalMessage == nil { // If the state is in prepare phase, the proposal must be set. Otherwise, just return false since // this is a valid scenario e.g. proposal msg is received before prepare msg for the same view @@ -144,7 +144,7 @@ func calculateTotalVotingPower(validatorsVotingPower map[string]*big.Int) *big.I } // convertMessageToAddressSet converts messages slice to addresses map -func convertMessageToAddressSet(messages []*proto.Message) map[string]struct{} { +func convertMessageToAddressSet(messages []*proto.IbftMessage) map[string]struct{} { result := make(map[string]struct{}, len(messages)) for _, x := range messages { diff --git a/messages/helpers.go b/messages/helpers.go index ab83842..89a2424 100644 --- a/messages/helpers.go +++ b/messages/helpers.go @@ -19,7 +19,7 @@ type CommittedSeal struct { } // ExtractCommittedSeals extracts the committed seals from the passed in messages -func ExtractCommittedSeals(commitMessages []*proto.Message) ([]*CommittedSeal, error) { +func ExtractCommittedSeals(commitMessages []*proto.IbftMessage) ([]*CommittedSeal, error) { committedSeals := make([]*CommittedSeal, 0) for _, commitMessage := range commitMessages { @@ -35,8 +35,8 @@ func ExtractCommittedSeals(commitMessages []*proto.Message) ([]*CommittedSeal, e } // ExtractCommittedSeal extracts the committed seal from the passed in message -func ExtractCommittedSeal(commitMessage *proto.Message) *CommittedSeal { - commitData, _ := commitMessage.Payload.(*proto.Message_CommitData) +func ExtractCommittedSeal(commitMessage *proto.IbftMessage) *CommittedSeal { + commitData, _ := commitMessage.Payload.(*proto.IbftMessage_CommitData) return &CommittedSeal{ Signer: commitMessage.From, @@ -45,84 +45,84 @@ func ExtractCommittedSeal(commitMessage *proto.Message) *CommittedSeal { } // ExtractCommitHash extracts the commit proposal hash from the passed in message -func ExtractCommitHash(commitMessage *proto.Message) []byte { +func ExtractCommitHash(commitMessage *proto.IbftMessage) []byte { if commitMessage.Type != proto.MessageType_COMMIT { return nil } - commitData, _ := commitMessage.Payload.(*proto.Message_CommitData) + commitData, _ := commitMessage.Payload.(*proto.IbftMessage_CommitData) return commitData.CommitData.ProposalHash } // ExtractProposal extracts the (rawData,r) proposal from the passed in message -func ExtractProposal(proposalMessage *proto.Message) *proto.Proposal { +func ExtractProposal(proposalMessage *proto.IbftMessage) *proto.Proposal { if proposalMessage.Type != proto.MessageType_PREPREPARE { return nil } - preprepareData, _ := proposalMessage.Payload.(*proto.Message_PreprepareData) + preprepareData, _ := proposalMessage.Payload.(*proto.IbftMessage_PreprepareData) return preprepareData.PreprepareData.Proposal } // ExtractProposalHash extracts the proposal hash from the passed in message -func ExtractProposalHash(proposalMessage *proto.Message) []byte { +func ExtractProposalHash(proposalMessage *proto.IbftMessage) []byte { if proposalMessage.Type != proto.MessageType_PREPREPARE { return nil } - preprepareData, _ := proposalMessage.Payload.(*proto.Message_PreprepareData) + preprepareData, _ := proposalMessage.Payload.(*proto.IbftMessage_PreprepareData) return preprepareData.PreprepareData.ProposalHash } // ExtractRoundChangeCertificate extracts the RCC from the passed in message -func ExtractRoundChangeCertificate(proposalMessage *proto.Message) *proto.RoundChangeCertificate { +func ExtractRoundChangeCertificate(proposalMessage *proto.IbftMessage) *proto.RoundChangeCertificate { if proposalMessage.Type != proto.MessageType_PREPREPARE { return nil } - preprepareData, _ := proposalMessage.Payload.(*proto.Message_PreprepareData) + preprepareData, _ := proposalMessage.Payload.(*proto.IbftMessage_PreprepareData) return preprepareData.PreprepareData.Certificate } // ExtractPrepareHash extracts the prepare proposal hash from the passed in message -func ExtractPrepareHash(prepareMessage *proto.Message) []byte { +func ExtractPrepareHash(prepareMessage *proto.IbftMessage) []byte { if prepareMessage.Type != proto.MessageType_PREPARE { return nil } - prepareData, _ := prepareMessage.Payload.(*proto.Message_PrepareData) + prepareData, _ := prepareMessage.Payload.(*proto.IbftMessage_PrepareData) return prepareData.PrepareData.ProposalHash } // ExtractLatestPC extracts the latest PC from the passed in message -func ExtractLatestPC(roundChangeMessage *proto.Message) *proto.PreparedCertificate { +func ExtractLatestPC(roundChangeMessage *proto.IbftMessage) *proto.PreparedCertificate { if roundChangeMessage.Type != proto.MessageType_ROUND_CHANGE { return nil } - rcData, _ := roundChangeMessage.Payload.(*proto.Message_RoundChangeData) + rcData, _ := roundChangeMessage.Payload.(*proto.IbftMessage_RoundChangeData) return rcData.RoundChangeData.LatestPreparedCertificate } // ExtractLastPreparedProposal extracts the latest prepared proposal from the passed in message -func ExtractLastPreparedProposal(roundChangeMessage *proto.Message) *proto.Proposal { +func ExtractLastPreparedProposal(roundChangeMessage *proto.IbftMessage) *proto.Proposal { if roundChangeMessage.Type != proto.MessageType_ROUND_CHANGE { return nil } - rcData, _ := roundChangeMessage.Payload.(*proto.Message_RoundChangeData) + rcData, _ := roundChangeMessage.Payload.(*proto.IbftMessage_RoundChangeData) return rcData.RoundChangeData.LastPreparedProposal } // HasUniqueSenders checks if the messages have unique senders -func HasUniqueSenders(messages []*proto.Message) bool { +func HasUniqueSenders(messages []*proto.IbftMessage) bool { if len(messages) < 1 { return false } @@ -142,7 +142,7 @@ func HasUniqueSenders(messages []*proto.Message) bool { } // AreValidPCMessages validates PreparedCertificate messages -func AreValidPCMessages(messages []*proto.Message, height uint64, roundLimit uint64) bool { +func AreValidPCMessages(messages []*proto.IbftMessage, height uint64, roundLimit uint64) bool { if len(messages) < 1 { return false } @@ -189,7 +189,7 @@ func AreValidPCMessages(messages []*proto.Message, height uint64, roundLimit uin } // extractPCMessageHash extracts the hash from a PC message -func extractPCMessageHash(message *proto.Message) ([]byte, bool) { +func extractPCMessageHash(message *proto.IbftMessage) ([]byte, bool) { switch message.Type { case proto.MessageType_PREPREPARE: return ExtractProposalHash(message), true diff --git a/messages/helpers_test.go b/messages/helpers_test.go index 8148789..6419020 100644 --- a/messages/helpers_test.go +++ b/messages/helpers_test.go @@ -17,10 +17,10 @@ func TestMessages_ExtractCommittedSeals(t *testing.T) { committedSeal = []byte("committed seal") ) - createCommitMessage := func(signer string) *proto.Message { - return &proto.Message{ + createCommitMessage := func(signer string) *proto.IbftMessage { + return &proto.IbftMessage{ Type: proto.MessageType_COMMIT, - Payload: &proto.Message_CommitData{ + Payload: &proto.IbftMessage_CommitData{ CommitData: &proto.CommitMessage{ CommittedSeal: committedSeal, }, @@ -29,8 +29,8 @@ func TestMessages_ExtractCommittedSeals(t *testing.T) { } } - createWrongMessage := func(signer string, msgType proto.MessageType) *proto.Message { - return &proto.Message{ + createWrongMessage := func(signer string, msgType proto.MessageType) *proto.IbftMessage { + return &proto.IbftMessage{ Type: msgType, } } @@ -44,13 +44,13 @@ func TestMessages_ExtractCommittedSeals(t *testing.T) { tests := []struct { name string - messages []*proto.Message + messages []*proto.IbftMessage expected []*CommittedSeal err error }{ { name: "contains only valid COMMIT messages", - messages: []*proto.Message{ + messages: []*proto.IbftMessage{ createCommitMessage("signer1"), createCommitMessage("signer2"), }, @@ -62,7 +62,7 @@ func TestMessages_ExtractCommittedSeals(t *testing.T) { }, { name: "contains wrong type messages", - messages: []*proto.Message{ + messages: []*proto.IbftMessage{ createCommitMessage("signer1"), createWrongMessage("signer2", proto.MessageType_PREPREPARE), }, @@ -93,14 +93,14 @@ func TestMessages_ExtractCommitHash(t *testing.T) { testTable := []struct { name string expectedCommitHash []byte - message *proto.Message + message *proto.IbftMessage }{ { "valid message", commitHash, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_COMMIT, - Payload: &proto.Message_CommitData{ + Payload: &proto.IbftMessage_CommitData{ CommitData: &proto.CommitMessage{ ProposalHash: commitHash, }, @@ -110,7 +110,7 @@ func TestMessages_ExtractCommitHash(t *testing.T) { { "invalid message", nil, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPARE, }, }, @@ -139,14 +139,14 @@ func TestMessages_ExtractProposal(t *testing.T) { testTable := []struct { name string expectedProposal *proto.Proposal - message *proto.Message + message *proto.IbftMessage }{ { "valid message", proposal, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: proposal, }, @@ -156,7 +156,7 @@ func TestMessages_ExtractProposal(t *testing.T) { { "invalid message", nil, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPARE, }, }, @@ -185,14 +185,14 @@ func TestMessages_ExtractProposalHash(t *testing.T) { testTable := []struct { name string expectedProposalHash []byte - message *proto.Message + message *proto.IbftMessage }{ { "valid message", proposalHash, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -202,7 +202,7 @@ func TestMessages_ExtractProposalHash(t *testing.T) { { "invalid message", nil, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPARE, }, }, @@ -233,14 +233,14 @@ func TestMessages_ExtractRCC(t *testing.T) { testTable := []struct { name string expectedRCC *proto.RoundChangeCertificate - message *proto.Message + message *proto.IbftMessage }{ { "valid message", rcc, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Certificate: rcc, }, @@ -250,7 +250,7 @@ func TestMessages_ExtractRCC(t *testing.T) { { "invalid message", nil, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPARE, }, }, @@ -279,14 +279,14 @@ func TestMessages_ExtractPrepareHash(t *testing.T) { testTable := []struct { name string expectedPrepareHash []byte - message *proto.Message + message *proto.IbftMessage }{ { "valid message", prepareHash, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: prepareHash, }, @@ -296,7 +296,7 @@ func TestMessages_ExtractPrepareHash(t *testing.T) { { "invalid message", nil, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, }, }, @@ -328,14 +328,14 @@ func TestMessages_ExtractLatestPC(t *testing.T) { testTable := []struct { name string expectedPC *proto.PreparedCertificate - message *proto.Message + message *proto.IbftMessage }{ { "valid message", latestPC, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{ + Payload: &proto.IbftMessage_RoundChangeData{ RoundChangeData: &proto.RoundChangeMessage{ LatestPreparedCertificate: latestPC, }, @@ -345,7 +345,7 @@ func TestMessages_ExtractLatestPC(t *testing.T) { { "invalid message", nil, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, }, }, @@ -374,14 +374,14 @@ func TestMessages_ExtractLPPB(t *testing.T) { testTable := []struct { name string expectedLPPB *proto.Proposal - message *proto.Message + message *proto.IbftMessage }{ { "valid message", lastPreparedProposal, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_ROUND_CHANGE, - Payload: &proto.Message_RoundChangeData{ + Payload: &proto.IbftMessage_RoundChangeData{ RoundChangeData: &proto.RoundChangeMessage{ LastPreparedProposal: lastPreparedProposal, }, @@ -391,7 +391,7 @@ func TestMessages_ExtractLPPB(t *testing.T) { { "invalid message", nil, - &proto.Message{ + &proto.IbftMessage{ Type: proto.MessageType_PREPREPARE, }, }, @@ -417,7 +417,7 @@ func TestMessages_HasUniqueSenders(t *testing.T) { testTable := []struct { name string - messages []*proto.Message + messages []*proto.IbftMessage hasUnique bool }{ { @@ -427,7 +427,7 @@ func TestMessages_HasUniqueSenders(t *testing.T) { }, { "non unique senders", - []*proto.Message{ + []*proto.IbftMessage{ { From: []byte("node 1"), }, @@ -439,7 +439,7 @@ func TestMessages_HasUniqueSenders(t *testing.T) { }, { "unique senders", - []*proto.Message{ + []*proto.IbftMessage{ { From: []byte("node 1"), }, @@ -471,7 +471,7 @@ func TestMessages_HaveSameProposalHash(t *testing.T) { testTable := []struct { name string - messages []*proto.Message + messages []*proto.IbftMessage haveSame bool }{ { @@ -481,7 +481,7 @@ func TestMessages_HaveSameProposalHash(t *testing.T) { }, { "invalid message type", - []*proto.Message{ + []*proto.IbftMessage{ { Type: proto.MessageType_ROUND_CHANGE, View: &proto.View{ @@ -495,10 +495,10 @@ func TestMessages_HaveSameProposalHash(t *testing.T) { }, { "hash mismatch", - []*proto.Message{ + []*proto.IbftMessage{ { Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -511,7 +511,7 @@ func TestMessages_HaveSameProposalHash(t *testing.T) { }, { Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: []byte("differing hash"), }, @@ -527,10 +527,10 @@ func TestMessages_HaveSameProposalHash(t *testing.T) { }, { "hash match", - []*proto.Message{ + []*proto.IbftMessage{ { Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -543,7 +543,7 @@ func TestMessages_HaveSameProposalHash(t *testing.T) { }, { Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, @@ -581,7 +581,7 @@ func TestMessages_AllHaveLowerRond(t *testing.T) { testTable := []struct { name string - messages []*proto.Message + messages []*proto.IbftMessage round uint64 haveLower bool }{ @@ -593,14 +593,14 @@ func TestMessages_AllHaveLowerRond(t *testing.T) { }, { "not same lower round", - []*proto.Message{ + []*proto.IbftMessage{ { View: &proto.View{ Height: 0, Round: round, }, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -613,7 +613,7 @@ func TestMessages_AllHaveLowerRond(t *testing.T) { Round: round + 1, }, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, @@ -626,14 +626,14 @@ func TestMessages_AllHaveLowerRond(t *testing.T) { }, { "same higher round", - []*proto.Message{ + []*proto.IbftMessage{ { View: &proto.View{ Height: 0, Round: round + 1, }, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -646,7 +646,7 @@ func TestMessages_AllHaveLowerRond(t *testing.T) { Round: round + 1, }, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, @@ -659,14 +659,14 @@ func TestMessages_AllHaveLowerRond(t *testing.T) { }, { "lower round match", - []*proto.Message{ + []*proto.IbftMessage{ { View: &proto.View{ Height: 0, Round: round, }, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -679,7 +679,7 @@ func TestMessages_AllHaveLowerRond(t *testing.T) { Round: round, }, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, @@ -718,7 +718,7 @@ func TestMessages_AllHaveSameHeight(t *testing.T) { testTable := []struct { name string - messages []*proto.Message + messages []*proto.IbftMessage haveSame bool }{ { @@ -728,13 +728,13 @@ func TestMessages_AllHaveSameHeight(t *testing.T) { }, { "not same height", - []*proto.Message{ + []*proto.IbftMessage{ { View: &proto.View{ Height: height - 1, }, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -746,7 +746,7 @@ func TestMessages_AllHaveSameHeight(t *testing.T) { Height: height, }, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, @@ -758,14 +758,14 @@ func TestMessages_AllHaveSameHeight(t *testing.T) { }, { "same height", - []*proto.Message{ + []*proto.IbftMessage{ { View: &proto.View{ Height: height, Round: 1, }, Type: proto.MessageType_PREPREPARE, - Payload: &proto.Message_PreprepareData{ + Payload: &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ ProposalHash: proposalHash, }, @@ -778,7 +778,7 @@ func TestMessages_AllHaveSameHeight(t *testing.T) { Round: 1, }, Type: proto.MessageType_PREPARE, - Payload: &proto.Message_PrepareData{ + Payload: &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: proposalHash, }, diff --git a/messages/messages.go b/messages/messages.go index b07e86a..2306087 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -51,7 +51,7 @@ func NewMessages() *Messages { } // AddMessage adds a new message to the message queue -func (ms *Messages) AddMessage(message *proto.Message) { +func (ms *Messages) AddMessage(message *proto.IbftMessage) { mux := ms.muxMap[message.Type] mux.Lock() defer mux.Unlock() @@ -169,13 +169,13 @@ func (ms *Messages) getProtoMessages( func (ms *Messages) GetValidMessages( view *proto.View, messageType proto.MessageType, - isValid func(message *proto.Message) bool, -) []*proto.Message { + isValid func(message *proto.IbftMessage) bool, +) []*proto.IbftMessage { mux := ms.muxMap[messageType] mux.Lock() defer mux.Unlock() - validMessages := make([]*proto.Message, 0) + validMessages := make([]*proto.IbftMessage, 0) invalidMessageKeys := make([]string, 0) messages := ms.getProtoMessages(view, messageType) @@ -201,9 +201,9 @@ func (ms *Messages) GetValidMessages( // 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 { + isValidMessage func(message *proto.IbftMessage) bool, + isValidRCC func(round uint64, messages []*proto.IbftMessage) bool, +) []*proto.IbftMessage { messageType := proto.MessageType_ROUND_CHANGE mux := ms.muxMap[messageType] @@ -215,11 +215,11 @@ func (ms *Messages) GetExtendedRCC( var ( highestRound uint64 - extendedRCC []*proto.Message + extendedRCC []*proto.IbftMessage ) for round, messages := range roundMessageMap { - validMessages := make([]*proto.Message, 0, len(messages)) + validMessages := make([]*proto.IbftMessage, 0, len(messages)) if round <= highestRound { continue @@ -246,7 +246,7 @@ func (ms *Messages) GetExtendedRCC( // GetMostRoundChangeMessages fetches most round change messages // for the minimum round and above -func (ms *Messages) GetMostRoundChangeMessages(minRound, height uint64) []*proto.Message { +func (ms *Messages) GetMostRoundChangeMessages(minRound, height uint64) []*proto.IbftMessage { messageType := proto.MessageType_ROUND_CHANGE mux := ms.muxMap[messageType] @@ -277,7 +277,7 @@ func (ms *Messages) GetMostRoundChangeMessages(minRound, height uint64) []*proto return nil } - messages := make([]*proto.Message, 0, bestRoundMessagesCount) + messages := make([]*proto.IbftMessage, 0, bestRoundMessagesCount) for _, msg := range roundMessageMap[bestRound] { messages = append(messages, msg) } @@ -293,7 +293,7 @@ type roundMessageMap map[uint64]protoMessages // protoMessages is the set of messages that circulate. // It contains a mapping between the sender and their messages to avoid duplicates -type protoMessages map[string]*proto.Message +type protoMessages map[string]*proto.IbftMessage // getViewMessages fetches the message queue for the specified view (height + round). // It will initialize a new message array if it's not found diff --git a/messages/messages_test.go b/messages/messages_test.go index baa9f3d..21229cf 100644 --- a/messages/messages_test.go +++ b/messages/messages_test.go @@ -16,12 +16,12 @@ func generateRandomMessages( count int, view *proto.View, messageTypes ...proto.MessageType, -) []*proto.Message { - messages := make([]*proto.Message, 0) +) []*proto.IbftMessage { + messages := make([]*proto.IbftMessage, 0) for index := 0; index < count; index++ { for _, messageType := range messageTypes { - message := &proto.Message{ + message := &proto.IbftMessage{ From: []byte(strconv.Itoa(index)), View: view, Type: messageType, @@ -29,19 +29,19 @@ func generateRandomMessages( switch messageType { case proto.MessageType_PREPREPARE: - message.Payload = &proto.Message_PreprepareData{ + message.Payload = &proto.IbftMessage_PreprepareData{ PreprepareData: &proto.PrePrepareMessage{ Proposal: nil, }, } case proto.MessageType_PREPARE: - message.Payload = &proto.Message_PrepareData{ + message.Payload = &proto.IbftMessage_PrepareData{ PrepareData: &proto.PrepareMessage{ ProposalHash: nil, }, } case proto.MessageType_COMMIT: - message.Payload = &proto.Message_CommitData{ + message.Payload = &proto.IbftMessage_CommitData{ CommitData: &proto.CommitMessage{ ProposalHash: nil, CommittedSeal: nil, @@ -148,7 +148,7 @@ func TestMessages_Prune(t *testing.T) { } // Append random message types - randomMessages := make([]*proto.Message, 0) + randomMessages := make([]*proto.IbftMessage, 0) for _, view := range views { randomMessages = append( randomMessages, @@ -213,7 +213,7 @@ func TestMessages_GetValidMessagesMessage(t *testing.T) { }, } - alwaysInvalidFn := func(_ *proto.Message) bool { + alwaysInvalidFn := func(_ *proto.IbftMessage) bool { return false } @@ -282,7 +282,7 @@ func TestMessages_GetExtendedRCC(t *testing.T) { defer messages.Close() // Generate round messages - randomMessages := map[uint64][]*proto.Message{ + randomMessages := map[uint64][]*proto.IbftMessage{ 0: generateRandomMessages(quorum-1, &proto.View{ Height: height, Round: 0, @@ -313,10 +313,10 @@ func TestMessages_GetExtendedRCC(t *testing.T) { extendedRCC := messages.GetExtendedRCC( height, - func(message *proto.Message) bool { + func(message *proto.IbftMessage) bool { return true }, - func(round uint64, messages []*proto.Message) bool { + func(round uint64, messages []*proto.IbftMessage) bool { return len(messages) >= quorum }, ) @@ -341,7 +341,7 @@ func TestMessages_GetMostRoundChangeMessages(t *testing.T) { mostMessagesRound := uint64(2) // Generate round messages - randomMessages := map[uint64][]*proto.Message{ + randomMessages := map[uint64][]*proto.IbftMessage{ 0: generateRandomMessages(mostMessageCount-2, &proto.View{ Height: 0, Round: 0, diff --git a/messages/proto/helper.go b/messages/proto/helper.go index 1c82a3a..90ee97a 100644 --- a/messages/proto/helper.go +++ b/messages/proto/helper.go @@ -4,8 +4,8 @@ package proto import "google.golang.org/protobuf/proto" // PayloadNoSig returns marshaled message without signature -func (m *Message) PayloadNoSig() ([]byte, error) { - mm, _ := proto.Clone(m).(*Message) +func (m *IbftMessage) PayloadNoSig() ([]byte, error) { + mm, _ := proto.Clone(m).(*IbftMessage) mm.Signature = nil raw, err := proto.Marshal(mm) diff --git a/messages/proto/messages.pb.go b/messages/proto/messages.pb.go index 9bbe6c5..9dbb5a6 100644 --- a/messages/proto/messages.pb.go +++ b/messages/proto/messages.pb.go @@ -1,13 +1,12 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0 -// protoc v3.21.9 +// protoc-gen-go v1.34.1 +// protoc v3.12.4 // 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" @@ -21,10 +20,6 @@ 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 @@ -137,8 +132,8 @@ func (x *View) GetRound() uint64 { return 0 } -// Message defines the base message structure -type Message struct { +// IbftMessage defines the base message structure +type IbftMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -154,15 +149,16 @@ type Message struct { // payload is the specific message payload // // Types that are assignable to Payload: - // *Message_PreprepareData - // *Message_PrepareData - // *Message_CommitData - // *Message_RoundChangeData - Payload isMessage_Payload `protobuf_oneof:"payload"` + // + // *IbftMessage_PreprepareData + // *IbftMessage_PrepareData + // *IbftMessage_CommitData + // *IbftMessage_RoundChangeData + Payload isIbftMessage_Payload `protobuf_oneof:"payload"` } -func (x *Message) Reset() { - *x = Message{} +func (x *IbftMessage) Reset() { + *x = IbftMessage{} if protoimpl.UnsafeEnabled { mi := &file_messages_proto_messages_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -170,13 +166,13 @@ func (x *Message) Reset() { } } -func (x *Message) String() string { +func (x *IbftMessage) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Message) ProtoMessage() {} +func (*IbftMessage) ProtoMessage() {} -func (x *Message) ProtoReflect() protoreflect.Message { +func (x *IbftMessage) ProtoReflect() protoreflect.Message { mi := &file_messages_proto_messages_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -188,101 +184,101 @@ func (x *Message) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Message.ProtoReflect.Descriptor instead. -func (*Message) Descriptor() ([]byte, []int) { +// Deprecated: Use IbftMessage.ProtoReflect.Descriptor instead. +func (*IbftMessage) Descriptor() ([]byte, []int) { return file_messages_proto_messages_proto_rawDescGZIP(), []int{1} } -func (x *Message) GetView() *View { +func (x *IbftMessage) GetView() *View { if x != nil { return x.View } return nil } -func (x *Message) GetFrom() []byte { +func (x *IbftMessage) GetFrom() []byte { if x != nil { return x.From } return nil } -func (x *Message) GetSignature() []byte { +func (x *IbftMessage) GetSignature() []byte { if x != nil { return x.Signature } return nil } -func (x *Message) GetType() MessageType { +func (x *IbftMessage) GetType() MessageType { if x != nil { return x.Type } return MessageType_PREPREPARE } -func (m *Message) GetPayload() isMessage_Payload { +func (m *IbftMessage) GetPayload() isIbftMessage_Payload { if m != nil { return m.Payload } return nil } -func (x *Message) GetPreprepareData() *PrePrepareMessage { - if x, ok := x.GetPayload().(*Message_PreprepareData); ok { +func (x *IbftMessage) GetPreprepareData() *PrePrepareMessage { + if x, ok := x.GetPayload().(*IbftMessage_PreprepareData); ok { return x.PreprepareData } return nil } -func (x *Message) GetPrepareData() *PrepareMessage { - if x, ok := x.GetPayload().(*Message_PrepareData); ok { +func (x *IbftMessage) GetPrepareData() *PrepareMessage { + if x, ok := x.GetPayload().(*IbftMessage_PrepareData); ok { return x.PrepareData } return nil } -func (x *Message) GetCommitData() *CommitMessage { - if x, ok := x.GetPayload().(*Message_CommitData); ok { +func (x *IbftMessage) GetCommitData() *CommitMessage { + if x, ok := x.GetPayload().(*IbftMessage_CommitData); ok { return x.CommitData } return nil } -func (x *Message) GetRoundChangeData() *RoundChangeMessage { - if x, ok := x.GetPayload().(*Message_RoundChangeData); ok { +func (x *IbftMessage) GetRoundChangeData() *RoundChangeMessage { + if x, ok := x.GetPayload().(*IbftMessage_RoundChangeData); ok { return x.RoundChangeData } return nil } -type isMessage_Payload interface { - isMessage_Payload() +type isIbftMessage_Payload interface { + isIbftMessage_Payload() } -type Message_PreprepareData struct { +type IbftMessage_PreprepareData struct { PreprepareData *PrePrepareMessage `protobuf:"bytes,5,opt,name=preprepareData,proto3,oneof"` } -type Message_PrepareData struct { +type IbftMessage_PrepareData struct { PrepareData *PrepareMessage `protobuf:"bytes,6,opt,name=prepareData,proto3,oneof"` } -type Message_CommitData struct { +type IbftMessage_CommitData struct { CommitData *CommitMessage `protobuf:"bytes,7,opt,name=commitData,proto3,oneof"` } -type Message_RoundChangeData struct { +type IbftMessage_RoundChangeData struct { RoundChangeData *RoundChangeMessage `protobuf:"bytes,8,opt,name=roundChangeData,proto3,oneof"` } -func (*Message_PreprepareData) isMessage_Payload() {} +func (*IbftMessage_PreprepareData) isIbftMessage_Payload() {} -func (*Message_PrepareData) isMessage_Payload() {} +func (*IbftMessage_PrepareData) isIbftMessage_Payload() {} -func (*Message_CommitData) isMessage_Payload() {} +func (*IbftMessage_CommitData) isIbftMessage_Payload() {} -func (*Message_RoundChangeData) isMessage_Payload() {} +func (*IbftMessage_RoundChangeData) isIbftMessage_Payload() {} // PrePrepareMessage is the message for the PREPREPARE phase type PrePrepareMessage struct { @@ -528,9 +524,9 @@ type PreparedCertificate struct { // proposalMessage is the proposal message to reach // at least Q(N) - 1 PREPARE messages - ProposalMessage *Message `protobuf:"bytes,1,opt,name=proposalMessage,proto3" json:"proposalMessage,omitempty"` + ProposalMessage *IbftMessage `protobuf:"bytes,1,opt,name=proposalMessage,proto3" json:"proposalMessage,omitempty"` // prepareMessages are the PREPARE messages at least Q(N) - 1 - PrepareMessages []*Message `protobuf:"bytes,2,rep,name=prepareMessages,proto3" json:"prepareMessages,omitempty"` + PrepareMessages []*IbftMessage `protobuf:"bytes,2,rep,name=prepareMessages,proto3" json:"prepareMessages,omitempty"` } func (x *PreparedCertificate) Reset() { @@ -565,14 +561,14 @@ func (*PreparedCertificate) Descriptor() ([]byte, []int) { return file_messages_proto_messages_proto_rawDescGZIP(), []int{6} } -func (x *PreparedCertificate) GetProposalMessage() *Message { +func (x *PreparedCertificate) GetProposalMessage() *IbftMessage { if x != nil { return x.ProposalMessage } return nil } -func (x *PreparedCertificate) GetPrepareMessages() []*Message { +func (x *PreparedCertificate) GetPrepareMessages() []*IbftMessage { if x != nil { return x.PrepareMessages } @@ -587,7 +583,7 @@ type RoundChangeCertificate struct { unknownFields protoimpl.UnknownFields // roundChangeMessages are the ROUND CHANGE messages - RoundChangeMessages []*Message `protobuf:"bytes,1,rep,name=roundChangeMessages,proto3" json:"roundChangeMessages,omitempty"` + RoundChangeMessages []*IbftMessage `protobuf:"bytes,1,rep,name=roundChangeMessages,proto3" json:"roundChangeMessages,omitempty"` } func (x *RoundChangeCertificate) Reset() { @@ -622,7 +618,7 @@ func (*RoundChangeCertificate) Descriptor() ([]byte, []int) { return file_messages_proto_messages_proto_rawDescGZIP(), []int{7} } -func (x *RoundChangeCertificate) GetRoundChangeMessages() []*Message { +func (x *RoundChangeCertificate) GetRoundChangeMessages() []*IbftMessage { if x != nil { return x.RoundChangeMessages } @@ -695,83 +691,84 @@ var file_messages_proto_messages_proto_rawDesc = []byte{ 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, 0x61, 0x6c, 0x12, 0x52, 0x0a, 0x19, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x50, 0x72, + 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x22, 0xed, 0x02, 0x0a, 0x0b, 0x49, 0x62, 0x66, 0x74, 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, 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, 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, + 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, 0x85, 0x01, 0x0a, + 0x13, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x65, 0x12, 0x36, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, + 0x49, 0x62, 0x66, 0x74, 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, 0x36, 0x0a, 0x0f, + 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x49, 0x62, 0x66, 0x74, 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, 0x58, 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, 0x3e, + 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, 0x0c, 0x2e, 0x49, 0x62, + 0x66, 0x74, 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 ( @@ -791,7 +788,7 @@ var file_messages_proto_messages_proto_msgTypes = make([]protoimpl.MessageInfo, var file_messages_proto_messages_proto_goTypes = []interface{}{ (MessageType)(0), // 0: MessageType (*View)(nil), // 1: View - (*Message)(nil), // 2: Message + (*IbftMessage)(nil), // 2: IbftMessage (*PrePrepareMessage)(nil), // 3: PrePrepareMessage (*PrepareMessage)(nil), // 4: PrepareMessage (*CommitMessage)(nil), // 5: CommitMessage @@ -801,19 +798,19 @@ var file_messages_proto_messages_proto_goTypes = []interface{}{ (*Proposal)(nil), // 9: Proposal } 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 + 1, // 0: IbftMessage.view:type_name -> View + 0, // 1: IbftMessage.type:type_name -> MessageType + 3, // 2: IbftMessage.preprepareData:type_name -> PrePrepareMessage + 4, // 3: IbftMessage.prepareData:type_name -> PrepareMessage + 5, // 4: IbftMessage.commitData:type_name -> CommitMessage + 6, // 5: IbftMessage.roundChangeData:type_name -> RoundChangeMessage 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 + 2, // 10: PreparedCertificate.proposalMessage:type_name -> IbftMessage + 2, // 11: PreparedCertificate.prepareMessages:type_name -> IbftMessage + 2, // 12: RoundChangeCertificate.roundChangeMessages:type_name -> IbftMessage 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 @@ -840,7 +837,7 @@ func file_messages_proto_messages_proto_init() { } } file_messages_proto_messages_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Message); i { + switch v := v.(*IbftMessage); i { case 0: return &v.state case 1: @@ -937,10 +934,10 @@ func file_messages_proto_messages_proto_init() { } } file_messages_proto_messages_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*Message_PreprepareData)(nil), - (*Message_PrepareData)(nil), - (*Message_CommitData)(nil), - (*Message_RoundChangeData)(nil), + (*IbftMessage_PreprepareData)(nil), + (*IbftMessage_PrepareData)(nil), + (*IbftMessage_CommitData)(nil), + (*IbftMessage_RoundChangeData)(nil), } type x struct{} out := protoimpl.TypeBuilder{ diff --git a/messages/proto/messages.proto b/messages/proto/messages.proto index 3115c9d..c8a0ae6 100644 --- a/messages/proto/messages.proto +++ b/messages/proto/messages.proto @@ -20,8 +20,8 @@ message View { uint64 round = 2; } -// Message defines the base message structure -message Message { +// IbftMessage defines the base message structure +message IbftMessage { // view is the current view for the message View view = 1; @@ -87,17 +87,17 @@ message RoundChangeMessage { message PreparedCertificate { // proposalMessage is the proposal message to reach // at least Q(N) - 1 PREPARE messages - Message proposalMessage = 1; + IbftMessage proposalMessage = 1; // prepareMessages are the PREPARE messages at least Q(N) - 1 - repeated Message prepareMessages = 2; + repeated IbftMessage prepareMessages = 2; } // RoundChangeCertificate is a collection of // round change messages for a certain round message RoundChangeCertificate { // roundChangeMessages are the ROUND CHANGE messages - repeated Message roundChangeMessages = 1; + repeated IbftMessage roundChangeMessages = 1; } // Proposal is the tuple (raw_proposal, round)