Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,14 @@ func (e *Epoch) handleFinalizeVoteMessage(message *FinalizeVote, from NodeID) er

if round.finalization != nil {
e.Logger.Debug("Received finalize vote for an already finalized round", zap.Uint64("round", vote.Round))

if from.Equals(e.ID) {
return nil
}
// send the finalization to the sender in case they missed it
e.Comm.Send(&Message{
Finalization: round.finalization,
}, from)
return nil
}

Expand Down Expand Up @@ -1113,7 +1121,7 @@ func (e *Epoch) rebroadcastPastFinalizeVotes() error {
}
finalizeVoteMessage = msg
}
e.Logger.Debug("Rebroadcasting finalization", zap.Uint64("round", r), zap.Uint64("seq", finalizeVoteMessage.FinalizeVote.Finalization.Seq))
e.Logger.Debug("Rebroadcasting finalize vote", zap.Uint64("round", r), zap.Uint64("seq", finalizeVoteMessage.FinalizeVote.Finalization.Seq))
e.Comm.Broadcast(finalizeVoteMessage)
}

Expand Down
18 changes: 8 additions & 10 deletions replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,6 @@ func testReplicationAfterNodeDisconnects(t *testing.T, nodes []simplex.NodeID, s
}
}

func onlyAllowBlockProposalsAndNotarizations(msg *simplex.Message, _, to simplex.NodeID) bool {
// TODO: remove hardcoded node id
if to.Equals(simplex.NodeID{4}) {
return (msg.BlockMessage != nil || msg.VerifiedBlockMessage != nil || msg.Notarization != nil)
}

return true
}

// sendVotesToOneNode allows block messages to be sent to all nodes, and only
// passes vote messages to one node. This will allows that node to notarize the block,
// while the other blocks will timeout
Expand Down Expand Up @@ -849,6 +840,14 @@ func TestReplicationNotarizationWithoutFinalizations(t *testing.T) {
func testReplicationNotarizationWithoutFinalizations(t *testing.T, numBlocks uint64, nodes []simplex.NodeID) {
net := NewInMemNetwork(t, nodes)

onlyAllowBlockProposalsAndNotarizations := func(msg *simplex.Message, _, to simplex.NodeID) bool {
if to.Equals(nodes[3]) {
return (msg.BlockMessage != nil || msg.VerifiedBlockMessage != nil || msg.Notarization != nil)
}

return true
}

nodeConfig := func(from simplex.NodeID) *TestNodeConfig {
comm := NewTestComm(from, net, onlyAllowBlockProposalsAndNotarizations)
return &TestNodeConfig{
Expand All @@ -875,7 +874,6 @@ func testReplicationNotarizationWithoutFinalizations(t *testing.T, numBlocks uin
for _, n := range net.Instances[:3] {
n.Storage.WaitForBlockCommit(uint64(i))
}

}

laggingNode.WAL.AssertNotarization(numBlocks - 1)
Expand Down
13 changes: 10 additions & 3 deletions testutil/comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package testutil

import (
"bytes"
"fmt"
"sync"

"github.com/ava-labs/simplex"
Expand Down Expand Up @@ -69,11 +70,17 @@ func (c *TestComm) Send(msg *simplex.Message, destination simplex.NodeID) {

for _, instance := range c.net.Instances {
if bytes.Equal(instance.E.ID, destination) {
instance.ingress <- struct {
select {
case instance.ingress <- struct {
msg *simplex.Message
from simplex.NodeID
}{msg: msg, from: c.from}
return
}{msg: msg, from: c.from}:
return
default:
// drop the message if the ingress channel is full
formattedString := fmt.Sprintf("Ingress channel is too full, failing test. From %v -> to %v", c.from, destination)
panic(formattedString)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion testutil/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewSimplexNode(t *testing.T, nodeID simplex.NodeID, net *InMemNetwork, conf
ingress: make(chan struct {
msg *simplex.Message
from simplex.NodeID
}, 100)}
}, 1000)}

ti.currentTime.Store(epochConfig.StartTime.UnixMilli())

Expand Down