Skip to content

Commit 502f81c

Browse files
committed
Use nodeIDs to generate root cluster block
1 parent 54ce8d5 commit 502f81c

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

cmd/bootstrap/run/cluster_block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func GenerateRootClusterBlocks(epoch uint64, clusters flow.ClusterList) []*clust
1616
panic(fmt.Sprintf("failed to get cluster by index: %v", i))
1717
}
1818

19-
rootBlock, err := clusterstate.CanonicalRootBlock(epoch, cluster)
19+
rootBlock, err := clusterstate.CanonicalRootBlock(epoch, cluster.NodeIDs())
2020
if err != nil {
2121
panic(fmt.Errorf("failed to get canonical root block: %w", err))
2222
}

consensus/hotstuff/committees/cluster_committee_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (suite *ClusterSuite) SetupTest() {
4949
suite.members = unittest.IdentityListFixture(5, unittest.WithRole(flow.RoleCollection))
5050
suite.me = suite.members[0]
5151
counter := uint64(1)
52-
rootBlock, err := clusterstate.CanonicalRootBlock(counter, suite.members.ToSkeleton())
52+
rootBlock, err := clusterstate.CanonicalRootBlock(counter, suite.members.ToSkeleton().NodeIDs())
5353
suite.Require().NoError(err)
5454
suite.root = rootBlock
5555

engine/collection/test/cluster_switchover_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func NewClusterSwitchoverTestCase(t *testing.T, conf ClusterSwitchoverTestConf)
173173
}
174174

175175
// generate root cluster block
176-
rootClusterBlock, err := cluster.CanonicalRootBlock(commit.Counter, model.ToIdentityList(signers).ToSkeleton())
176+
rootClusterBlock, err := cluster.CanonicalRootBlock(commit.Counter, clusterQC.VoterIDs)
177177
require.NoError(tc.T(), err)
178178
// generate cluster root qc
179179
qc, err := run.GenerateClusterRootQC(signers, model.ToIdentityList(signers).ToSkeleton(), rootClusterBlock)

integration/epochs/epoch_qc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (s *Suite) TestEpochQuorumCertificate() {
6666

6767
// find cluster and create root block
6868
cluster, _, _ := clustering.ByNodeID(node.NodeID)
69-
rootBlock, err := clusterstate.CanonicalRootBlock(uint64(epochCounter), cluster)
69+
rootBlock, err := clusterstate.CanonicalRootBlock(epochCounter, cluster.NodeIDs())
7070
s.Require().NoError(err)
7171

7272
key, signer := test.AccountKeyGenerator().NewWithSigner()

integration/testnet/network.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,35 +1419,35 @@ func setupClusterGenesisBlockQCs(nClusters uint, epochCounter uint64, confs []Co
14191419
participants := participantsUnsorted.Sort(flow.Canonical[flow.Identity])
14201420
collectors := participants.Filter(filter.HasRole[flow.Identity](flow.RoleCollection)).ToSkeleton()
14211421
assignments := unittest.ClusterAssignment(nClusters, collectors)
1422-
clusters, err := factory.NewClusterList(assignments, collectors)
1422+
_, err := factory.NewClusterList(assignments, collectors)
14231423
if err != nil {
14241424
return nil, nil, nil, fmt.Errorf("could not create cluster list: %w", err)
14251425
}
14261426

14271427
rootBlocks := make([]*cluster.Block, 0, nClusters)
14281428
qcs := make([]*flow.QuorumCertificate, 0, nClusters)
14291429

1430-
for _, cluster := range clusters {
1430+
for _, assignment := range assignments {
14311431
// generate root cluster block
1432-
block, err := clusterstate.CanonicalRootBlock(epochCounter, cluster)
1432+
block, err := clusterstate.CanonicalRootBlock(epochCounter, assignment)
14331433
if err != nil {
14341434
return nil, nil, nil, fmt.Errorf("failed to generate canonical root block: %w", err)
14351435
}
14361436

14371437
lookup := make(map[flow.Identifier]struct{})
1438-
for _, node := range cluster {
1439-
lookup[node.NodeID] = struct{}{}
1438+
for _, nodeID := range assignment {
1439+
lookup[nodeID] = struct{}{}
14401440
}
14411441

14421442
// gather cluster participants
1443-
clusterNodeInfos := make([]bootstrap.NodeInfo, 0, len(cluster))
1443+
clusterNodeInfos := make([]bootstrap.NodeInfo, 0, len(assignment))
14441444
for _, conf := range confs {
14451445
_, exists := lookup[conf.NodeID]
14461446
if exists {
14471447
clusterNodeInfos = append(clusterNodeInfos, conf.NodeInfo)
14481448
}
14491449
}
1450-
if len(cluster) != len(clusterNodeInfos) { // sanity check
1450+
if len(assignment) != len(clusterNodeInfos) { // sanity check
14511451
return nil, nil, nil, fmt.Errorf("requiring a node info for each cluster participant")
14521452
}
14531453

integration/tests/collection/suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func (suite *CollectorSuite) ClusterStateFor(id flow.Identifier) *clusterstateim
339339

340340
setup, ok := suite.net.Result().ServiceEvents[0].Event.(*flow.EpochSetup)
341341
suite.Require().True(ok, "could not get root seal setup")
342-
rootBlock, err := clusterstate.CanonicalRootBlock(setup.Counter, myCluster)
342+
rootBlock, err := clusterstate.CanonicalRootBlock(setup.Counter, myCluster.NodeIDs())
343343
suite.Require().NoError(err)
344344
node := suite.net.ContainerByID(id)
345345

module/epochs/qc_voter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (voter *RootQCVoter) Vote(ctx context.Context, epoch protocol.TentativeEpoc
9999
log.Info().Msg("preparing to generate vote for cluster root qc")
100100

101101
// create the canonical root block for our cluster
102-
root, err := clusterstate.CanonicalRootBlock(counter, cluster)
102+
root, err := clusterstate.CanonicalRootBlock(counter, cluster.NodeIDs())
103103
if err != nil {
104104
return fmt.Errorf("could not create cluster root block: %w", err)
105105
}

state/cluster/root_block.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ func CanonicalClusterID(epoch uint64, participants flow.IdentifierList) flow.Cha
1515

1616
// CanonicalRootBlock returns the canonical root block for the given
1717
// cluster in the given epoch. It contains an empty collection referencing
18-
func CanonicalRootBlock(epoch uint64, participants flow.IdentitySkeletonList) (*cluster.Block, error) {
19-
chainID := CanonicalClusterID(epoch, participants.NodeIDs())
18+
func CanonicalRootBlock(epoch uint64, participants flow.IdentifierList) (*cluster.Block, error) {
19+
chainID := CanonicalClusterID(epoch, participants)
2020
rootHeaderBody, err := flow.NewRootHeaderBody(flow.UntrustedHeaderBody{
2121
ChainID: chainID,
2222
ParentID: flow.ZeroID,

state/protocol/inmem/epoch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (es *committedEpoch) Cluster(index uint) (protocol.Cluster, error) {
234234
return nil, fmt.Errorf("could not encode signer indices for rootQCVoteData.VoterIDs: %w", err)
235235
}
236236

237-
rootBlock, err := cluster.CanonicalRootBlock(epochCounter, members)
237+
rootBlock, err := cluster.CanonicalRootBlock(epochCounter, members.NodeIDs())
238238
if err != nil {
239239
return nil, fmt.Errorf("could not generate canonical root block: %w", err)
240240
}

0 commit comments

Comments
 (0)