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
4 changes: 2 additions & 2 deletions common/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ type Storage interface {
}

type Communication interface {
// Nodes returns all nodes that participate in the epoch.
Nodes() Nodes
// Validators returns all nodes that participate in consensus in the epoch.
Validators() Nodes

// Send sends a message to the given destination node
Send(msg *Message, destination NodeID)
Expand Down
2 changes: 1 addition & 1 deletion nonvalidator/comm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newTestResponder(t *testing.T, myNodeID common.NodeID, tc *testChain) *nonV
}
}

func (r *nonValidatorResponderComm) Nodes() common.Nodes { return r.nodes }
func (r *nonValidatorResponderComm) Validators() common.Nodes { return r.nodes }

// Enqueues a response coming from `destination`.
func (r *nonValidatorResponderComm) Send(msg *common.Message, destination common.NodeID) {
Expand Down
4 changes: 2 additions & 2 deletions nonvalidator/epochs.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (e epochs) canValidate(block common.Block) bool {
// latestValidatorSetRetriever is an allows the epoch replicator to get the latest validator set.
// This is used to calculate the threshold of votes needed to validate an epoch.
type latestValidatorSetRetriever interface {
Nodes() common.Nodes
Validators() common.Nodes
}

// epochDigestCounter counts sealing block responses from validators for each epoch.
Expand Down Expand Up @@ -166,7 +166,7 @@ func (e *epochDigestCounter) collectedSealingBlockInfo(sealingBlockInfo *common.
}
e.logger.Debug("Collected a sealing block", zap.Stringer("QR", sealingBlockInfo), zap.Stringer("From", from))

threshold := common.F(len(e.latestValidatorSetRetriever.Nodes())) + 1
threshold := common.F(len(e.latestValidatorSetRetriever.Validators())) + 1
newEpoch := bh.Seq
epochResponses, ok := e.sealingBlockResponses[newEpoch]
digest := bh.Digest
Expand Down
2 changes: 1 addition & 1 deletion nonvalidator/epochs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ type testValidatorSetRetriever struct {
nodes common.Nodes
}

func (v *testValidatorSetRetriever) Nodes() common.Nodes {
func (v *testValidatorSetRetriever) Validators() common.Nodes {
return v.nodes
}

Expand Down
2 changes: 1 addition & 1 deletion nonvalidator/non_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (n *NonValidator) processReplicationState() error {
if err != nil {
n.Logger.Debug("Failed verifying QC that was next to commit", zap.Error(err))
// We fetch from comm.Nodes instead of the nodes given in the finalization, because this node may give us an adversarial node list.
n.sequenceReplicator.ResendFinalizationRequest(block.BlockHeader().Seq, n.Comm.Nodes().NodeIDs())
n.sequenceReplicator.ResendFinalizationRequest(block.BlockHeader().Seq, n.Comm.Validators().NodeIDs())
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion simplex/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (e *Epoch) init() error {
e.finishCtx, e.finishFn = context.WithCancel(context.Background())
e.blockBuilderCtx = context.Background()
e.blockBuilderCancelFunc = func() {}
e.nodes = e.Comm.Nodes()
e.nodes = e.Comm.Validators()
common.SortNodes(e.nodes)
e.nodeIDs = e.nodes.NodeIDs()
e.timedOutRounds = make(map[uint16]uint64, len(e.nodeIDs))
Expand Down
4 changes: 2 additions & 2 deletions simplex/epoch_failover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ func newRebroadcastComm(nodes Nodes) *rebroadcastComm {
}
}

func (r *rebroadcastComm) Nodes() Nodes {
func (r *rebroadcastComm) Validators() Nodes {
return r.nodes
}

Expand Down Expand Up @@ -1232,7 +1232,7 @@ func runCrashAndRestartExecution(t *testing.T, e *Epoch, bb *testutil.TestBlockB
cloneWAL := wal.Clone()
cloneStorage := storage.Clone()

nodes := e.Comm.Nodes()
nodes := e.Comm.Validators()

// Clone the block builder
bbAfterCrash := testutil.NewTestBlockBuilder().WithBlockShouldBeBuiltBuffer(uint64(cap(bb.BlockShouldBeBuilt)))
Expand Down
36 changes: 18 additions & 18 deletions simplex/epoch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestFinalizeSameSequence(t *testing.T) {
Prev: initialBlock.VerifiedBlock.BlockHeader().Digest,
}
vb, ok := bb.BuildBlock(context.Background(), md, Blacklist{
NodeCount: uint16(len(e.EpochConfig.Comm.Nodes())),
NodeCount: uint16(len(e.EpochConfig.Comm.Validators())),
})
require.True(t, ok)

Expand Down Expand Up @@ -117,7 +117,7 @@ func TestFinalizeSameSequence(t *testing.T) {
require.NoError(t, err)

// create a notarization and now we should send a finalize vote for seq 1 again
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
notarization, err := testutil.NewNotarization(e.Logger, sigAggr, block, nodes[1:])
require.NoError(t, err)
testutil.InjectTestNotarization(t, e, notarization, nodes[1])
Expand Down Expand Up @@ -202,7 +202,7 @@ func testFinalizeSameSequenceGap(t *testing.T, nodes []NodeID, numEmptyNotarizat
}

for range numEmptyNotarizations {
leader := LeaderForRound(e.Comm.Nodes().NodeIDs(), e.Metadata().Round)
leader := LeaderForRound(e.Comm.Validators().NodeIDs(), e.Metadata().Round)
if e.ID.Equals(leader) {
fVote := advanceWithFinalizeCheck(t, e, recordingComm, bb)
finalizeVoteSeqs[fVote.Finalization.Seq] = fVote
Expand All @@ -226,7 +226,7 @@ func testFinalizeSameSequenceGap(t *testing.T, nodes []NodeID, numEmptyNotarizat
Prev: finalizeVoteSeqs[seqToDoubleFinalize-1].Finalization.Digest,
}
vb, ok := bb.BuildBlock(context.Background(), md, Blacklist{
NodeCount: uint16(len(e.EpochConfig.Comm.Nodes())),
NodeCount: uint16(len(e.EpochConfig.Comm.Validators())),
})
require.True(t, ok)

Expand All @@ -236,7 +236,7 @@ func testFinalizeSameSequenceGap(t *testing.T, nodes []NodeID, numEmptyNotarizat
verified <- struct{}{}
}

leader := LeaderForRound(e.Comm.Nodes().NodeIDs(), 1+numEmptyNotarizations+numNotarizations)
leader := LeaderForRound(e.Comm.Validators().NodeIDs(), 1+numEmptyNotarizations+numNotarizations)
if e.ID.Equals(leader) {
return
}
Expand Down Expand Up @@ -275,7 +275,7 @@ func testFinalizeSameSequenceGap(t *testing.T, nodes []NodeID, numEmptyNotarizat
}

// create a notarization and now we should send a finalize vote for seqToDoubleFinalize again
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
notarization, err := testutil.NewNotarization(e.Logger, sigAggr, block, nodes[1:])
require.NoError(t, err)
testutil.InjectTestNotarization(t, e, notarization, nodes[1])
Expand Down Expand Up @@ -378,7 +378,7 @@ func TestEpochHandleNotarizationFutureRound(t *testing.T) {
require.NoError(t, e.Start())

// Create a notarization for round 1 which is a future round because we haven't gone through round 0 yet.
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
notarization, err := testutil.NewNotarization(conf.Logger, sigAggr, secondBlock, nodes)
require.NoError(t, err)

Expand Down Expand Up @@ -444,8 +444,8 @@ func TestEpochIndexFinalization(t *testing.T) {
// when we receive that finalization, we should commit the rest of the finalizations for seqs
// 1 & 2

sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
finalization, _ := testutil.NewFinalizationRecord(t, sigAggr, firstBlock, e.Comm.Nodes().NodeIDs())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
finalization, _ := testutil.NewFinalizationRecord(t, sigAggr, firstBlock, e.Comm.Validators().NodeIDs())
testutil.InjectTestFinalization(t, e, &finalization, nodes[1])

storage.WaitForBlockCommit(2)
Expand Down Expand Up @@ -544,7 +544,7 @@ func TestEpochIncreasesRoundAfterFinalization(t *testing.T) {
require.Equal(t, uint64(0), storage.NumBlocks())

// create the finalized block
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
finalization, _ := testutil.NewFinalizationRecord(t, sigAggr, block, nodes)
testutil.InjectTestFinalization(t, e, &finalization, nodes[1])

Expand Down Expand Up @@ -752,10 +752,10 @@ func TestEpochStartedTwice(t *testing.T) {
}

func advanceRoundFromEmpty(t *testing.T, e *Epoch) {
leader := LeaderForRound(e.Comm.Nodes().NodeIDs(), e.Metadata().Round)
leader := LeaderForRound(e.Comm.Validators().NodeIDs(), e.Metadata().Round)
require.False(t, e.ID.Equals(leader), "epoch cannot be the leader for the empty round")

emptyNote := testutil.NewEmptyNotarization(e.Comm.Nodes().NodeIDs(), e.Metadata().Round)
emptyNote := testutil.NewEmptyNotarization(e.Comm.Validators().NodeIDs(), e.Metadata().Round)
err := e.HandleMessage(&Message{
EmptyNotarization: emptyNote,
}, leader)
Expand Down Expand Up @@ -1016,7 +1016,7 @@ func TestEpochQCSignedByNonExistentNodes(t *testing.T) {

wal.AssertWALSize(1)

sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())

t.Run("notarization with unknown signer isn't taken into account", func(t *testing.T) {
notarization, err := testutil.NewNotarization(conf.Logger, sigAggr, block, []NodeID{{2}, {3}, {5}})
Expand Down Expand Up @@ -1258,7 +1258,7 @@ func TestEpochSendsBlockDigestRequest(t *testing.T) {
require.True(t, built)
block := bb.GetBuiltBlock()

sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
notarization, err := testutil.NewNotarization(conf.Logger, sigAggr, block, nodes)
require.NoError(t, err)

Expand Down Expand Up @@ -1504,7 +1504,7 @@ func TestDoubleIncrementOnPersistNotarization(t *testing.T) {
require.True(t, ok)

block := bb.GetBuiltBlock()
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
notarization, err := testutil.NewNotarization(conf.Logger, sigAggr, block, nodes)
require.NoError(t, err)

Expand Down Expand Up @@ -1596,7 +1596,7 @@ func TestRejectsOldNotarizationAndVotes(t *testing.T) {
}

// send notarization for round 1, after the finalization was sent
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
notarization, err := testutil.NewNotarization(conf.Logger, sigAggr, block, nodes)
require.NoError(t, err)

Expand Down Expand Up @@ -1642,7 +1642,7 @@ func TestBlockDeserializer(t *testing.T) {
func advanceRound(t *testing.T, e *Epoch, bb *testutil.TestBlockBuilder, notarize bool, finalize bool, injectedMD *ProtocolMetadata) (VerifiedBlock, *Notarization) {
require.True(t, notarize || finalize, "must either notarize or finalize a round to advance")
nextSeqToCommit := e.Storage.NumBlocks()
nodes := e.Comm.Nodes()
nodes := e.Comm.Validators()
quorum := Quorum(len(nodes))
// leader is the proposer of the new block for the given round
leader := LeaderForRound(nodes.NodeIDs(), e.Metadata().Round)
Expand All @@ -1655,7 +1655,7 @@ func advanceRound(t *testing.T, e *Epoch, bb *testutil.TestBlockBuilder, notariz
isEpochNode := leader.Equals(e.ID)
if !isEpochNode {
_, ok := bb.BuildBlock(context.Background(), md, Blacklist{
NodeCount: uint16(len(e.EpochConfig.Comm.Nodes())),
NodeCount: uint16(len(e.EpochConfig.Comm.Validators())),
})
require.True(t, ok)
}
Expand Down
30 changes: 15 additions & 15 deletions simplex/recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestWalCreatedProperly(t *testing.T) {
records, err = e.WAL.ReadAll()
require.NoError(t, err)
require.Len(t, records, 2)
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
expectedNotarizationRecord, err := testutil.NewNotarizationRecord(conf.Logger, sigAggr, block, nodes[0:quorum])
require.NoError(t, err)
require.Equal(t, expectedNotarizationRecord, records[1])
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestRecoverFromMultipleNotarizations(t *testing.T) {
require.NoError(t, err)
t.Cleanup(e.Stop)

sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())

protocolMetadata := e.Metadata()
firstBlock, ok := bb.BuildBlock(ctx, protocolMetadata, emptyBlacklist)
Expand Down Expand Up @@ -501,7 +501,7 @@ func TestRecoveryBlocksIndexed(t *testing.T) {
record := BlockRecord(firstBlock.BlockHeader(), fBytes)
wal.Append(record)

sigAggr := conf.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := conf.SignatureAggregatorCreator(conf.Comm.Validators())
firstNotarizationRecord, err := testutil.NewNotarizationRecord(conf.Logger, sigAggr, firstBlock, nodes[0:quorum])
require.NoError(t, err)
wal.Append(firstNotarizationRecord)
Expand Down Expand Up @@ -658,7 +658,7 @@ func TestWalRecoveryTriggersEmptyVoteTimeout(t *testing.T) {
require.NoError(t, wal.Append(blockRecord))

// lets add some notarizations
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Nodes())
sigAggr := e.SignatureAggregatorCreator(conf.Comm.Validators())
notarizationRecord, err := testutil.NewNotarizationRecord(conf.Logger, sigAggr, block, nodes[0:quorum])
require.NoError(t, err)

Expand Down Expand Up @@ -765,7 +765,7 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
require.NoError(t, err)
blockRecord := BlockRecord(block.BlockHeader(), bBytes)

notarizationRecord, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block, nodes[0:quorum])
notarizationRecord, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block, nodes[0:quorum])
require.NoError(t, err)

return [][]byte{blockRecord, notarizationRecord}
Expand All @@ -783,7 +783,7 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
require.NoError(t, err)
blockRecord1 := BlockRecord(block1.BlockHeader(), bBytes1)

_, finalizationRecord1 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block1, nodes[0:quorum])
_, finalizationRecord1 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block1, nodes[0:quorum])

// Create empty notarization for round 0
emptyNotarization0 := testutil.NewEmptyNotarization(nodes[0:quorum], 0)
Expand All @@ -804,23 +804,23 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
bBytes0, err := block0.Bytes()
require.NoError(t, err)
blockRecord0 := BlockRecord(block0.BlockHeader(), bBytes0)
notarizationRecord0, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block0, nodes[0:quorum])
notarizationRecord0, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block0, nodes[0:quorum])
require.NoError(t, err)

block1, ok := bb.BuildBlock(ctx, ProtocolMetadata{Round: 1, Epoch: 0, Seq: 1}, emptyBlacklist)
require.True(t, ok)
bBytes1, err := block1.Bytes()
require.NoError(t, err)
blockRecord1 := BlockRecord(block1.BlockHeader(), bBytes1)
notarizationRecord1, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block1, nodes[0:quorum])
notarizationRecord1, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block1, nodes[0:quorum])
require.NoError(t, err)

block2, ok := bb.BuildBlock(ctx, ProtocolMetadata{Round: 2, Epoch: 0, Seq: 2}, emptyBlacklist)
require.True(t, ok)
bBytes2, err := block2.Bytes()
require.NoError(t, err)
blockRecord2 := BlockRecord(block2.BlockHeader(), bBytes2)
notarizationRecord2, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block2, nodes[0:quorum])
notarizationRecord2, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block2, nodes[0:quorum])
require.NoError(t, err)

// Create empty notarization for round 3
Expand All @@ -847,7 +847,7 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
bBytes3, err := block3.Bytes()
require.NoError(t, err)
blockRecord3 := BlockRecord(block3.BlockHeader(), bBytes3)
_, finalizationRecord3 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block3, nodes[0:quorum])
_, finalizationRecord3 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block3, nodes[0:quorum])

// Create empty notarization for round 2
emptyNotarization2 := testutil.NewEmptyNotarization(nodes[0:quorum], 2)
Expand All @@ -860,7 +860,7 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
bBytes1, err := block1.Bytes()
require.NoError(t, err)
blockRecord1 := BlockRecord(block1.BlockHeader(), bBytes1)
notarizationRecord1, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block1, nodes[0:quorum])
notarizationRecord1, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block1, nodes[0:quorum])
require.NoError(t, err)

// Return in reverse order
Expand All @@ -882,7 +882,7 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
bBytes0, err := block0.Bytes()
require.NoError(t, err)
blockRecord0 := BlockRecord(block0.BlockHeader(), bBytes0)
notarizationRecord0, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block0, nodes[0:quorum])
notarizationRecord0, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block0, nodes[0:quorum])
require.NoError(t, err)

// Create finalization for round 10 (highest)
Expand All @@ -891,7 +891,7 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
bBytes10, err := block10.Bytes()
require.NoError(t, err)
blockRecord10 := BlockRecord(block10.BlockHeader(), bBytes10)
_, finalizationRecord10 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block10, nodes[0:quorum])
_, finalizationRecord10 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block10, nodes[0:quorum])

// Create empty notarization for round 5
emptyNotarization5 := testutil.NewEmptyNotarization(nodes[0:quorum], 5)
Expand All @@ -917,10 +917,10 @@ func TestWalRecoverySetsRoundCorrectly(t *testing.T) {
require.NoError(t, err)
blockRecord2 := BlockRecord(block2.BlockHeader(), bBytes2)

notarizationRecord2, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block2, nodes[0:quorum])
notarizationRecord2, err := testutil.NewNotarizationRecord(conf.Logger, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block2, nodes[0:quorum])
require.NoError(t, err)

_, finalizationRecord2 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Nodes()), block2, nodes[0:quorum])
_, finalizationRecord2 := testutil.NewFinalizationRecord(t, conf.SignatureAggregatorCreator(conf.Comm.Validators()), block2, nodes[0:quorum])

// All records for same round
return [][]byte{
Expand Down
Loading
Loading