@@ -115,8 +115,8 @@ func compareSidecarsByValue(
115115
116116func compareSidecars (
117117 blockRoot: Eth2Digest ,
118- a: openArray [ref BlobSidecar | ref DataColumnSidecar ],
119- b: openArray [BlobIdentifier | DataColumnIdentifier ]
118+ a: openArray [ref BlobSidecar ],
119+ b: openArray [BlobIdentifier ]
120120): bool =
121121 if len (a) != len (b):
122122 return false
@@ -127,14 +127,32 @@ func compareSidecars(
127127 return false
128128 true
129129
130- func compareIdentifiers (
131- a, b: openArray [DataColumnIdentifier ]): bool =
132- if len (a) != len (b):
130+ func compareSidecars (
131+ blockRoot: Eth2Digest ,
132+ a: openArray [ref DataColumnSidecar ],
133+ b: DataColumnsByRootIdentifier
134+ ): bool =
135+ if len (a) != len (b.indices):
133136 return false
134137 if len (a) == 0 :
135138 return true
139+ if b.block_root != blockRoot:
140+ return false
136141 for i in 0 ..< len (a):
137- if (a[i].block_root != b[i].block_root) or (a[i].index != b[i].index):
142+ if (a[i][].index != b.indices[i]):
143+ return false
144+ true
145+
146+ func compareIdentifiers (
147+ a, b: DataColumnsByRootIdentifier ): bool =
148+ if len (a.indices) != len (b.indices):
149+ return false
150+ if a.block_root != b.block_root:
151+ return false
152+ if len (a.indices) == 0 :
153+ return true
154+ for i in 0 ..< len (a.indices):
155+ if (a.indices[i] != b.indices[i]):
138156 return false
139157 true
140158
@@ -1475,37 +1493,33 @@ suite "ColumnQuarantine data structure test suite " & preset():
14751493 broot1 = genBlockRoot (1 )
14761494 broot2 = genBlockRoot (2 )
14771495 expected1 = [
1478- @ [
1479- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (63 )),
1480- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (64 )),
1481- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (95 )),
1482- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (96 ))],
1483- @ [
1484- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (63 )),
1485- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (64 )),
1486- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (95 )),
1487- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (96 ))],
1488- @ [
1489- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (63 )),
1490- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (64 )),
1491- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (95 )),
1492- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (96 ))],
1493- @ [
1494- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (63 )),
1495- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (64 )),
1496- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (95 )),
1497- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (96 ))],
1498- @ [
1499- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (64 )),
1500- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (95 )),
1501- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (96 ))],
1502- @ [
1503- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (95 )),
1504- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (96 ))],
1505- @ [
1506- DataColumnIdentifier (block_root: broot1, index: ColumnIndex (96 ))],
1507- @ [],
1508- @ []
1496+ DataColumnsByRootIdentifier (
1497+ block_root: broot1,
1498+ indices: DataColumnIndices @ [ColumnIndex (63 ), 64 , 95 , 96 ]),
1499+ DataColumnsByRootIdentifier (
1500+ block_root: broot1,
1501+ indices: DataColumnIndices @ [ColumnIndex (63 ), 64 , 95 , 96 ]),
1502+ DataColumnsByRootIdentifier (
1503+ block_root: broot1,
1504+ indices: DataColumnIndices @ [ColumnIndex (63 ), 64 , 95 , 96 ]),
1505+ DataColumnsByRootIdentifier (
1506+ block_root: broot1,
1507+ indices: DataColumnIndices @ [ColumnIndex (63 ), 64 , 95 , 96 ]),
1508+ DataColumnsByRootIdentifier (
1509+ block_root: broot1,
1510+ indices: DataColumnIndices @ [ColumnIndex (64 ), 95 , 96 ]),
1511+ DataColumnsByRootIdentifier (
1512+ block_root: broot1,
1513+ indices: DataColumnIndices @ [ColumnIndex (95 ), 96 ]),
1514+ DataColumnsByRootIdentifier (
1515+ block_root: broot1,
1516+ indices: DataColumnIndices @ [ColumnIndex (96 )]),
1517+ DataColumnsByRootIdentifier (
1518+ block_root: broot1,
1519+ indices: DataColumnIndices @ []),
1520+ DataColumnsByRootIdentifier (
1521+ block_root: broot1,
1522+ indices: DataColumnIndices @ [])
15091523 ]
15101524 sidecars1 =
15111525 block :
@@ -1534,10 +1548,10 @@ suite "ColumnQuarantine data structure test suite " & preset():
15341548 let
15351549 missing1 = bq.fetchMissingSidecars (broot1, fuluBlock1)
15361550 missing2 = bq.fetchMissingSidecars (broot2, fuluBlock2)
1537- missing3 = bq. fetchMissingSidecars (broot1, fuluBlock1,
1538- peerCustodyColumns1)
1539- missing4 = bq. fetchMissingSidecars (broot2, fuluBlock2,
1540- peerCustodyColumns2)
1551+ missing3 =
1552+ bq. fetchMissingSidecars (broot1, fuluBlock1, peerCustodyColumns1)
1553+ missing4 =
1554+ bq. fetchMissingSidecars (broot2, fuluBlock2, peerCustodyColumns2)
15411555
15421556 check:
15431557 compareSidecars (
@@ -1549,7 +1563,7 @@ suite "ColumnQuarantine data structure test suite " & preset():
15491563
15501564 check:
15511565 compareIdentifiers (expected1[i], missing3)
1552- len (missing4) == 0
1566+ len (missing4.indices ) == 0
15531567
15541568 if i >= len (sidecars1):
15551569 break
@@ -1597,7 +1611,7 @@ suite "ColumnQuarantine data structure test suite " & preset():
15971611 func checkSupernodeExpected (
15981612 root: Eth2Digest ,
15991613 index: int ,
1600- missing: openArray [ DataColumnIdentifier ]
1614+ missing: DataColumnsByRootIdentifier
16011615 ): bool =
16021616 const ExpectedVectors = [
16031617 (@ [63 , 64 , 65 , 66 , 95 , 96 , 97 , 98 ], 0 .. 57 ),
@@ -1614,11 +1628,12 @@ suite "ColumnQuarantine data structure test suite " & preset():
16141628 doAssert (index in 0 .. 65 )
16151629 for expect in ExpectedVectors :
16161630 if index in expect[1 ]:
1617- if len (expect[0 ]) != len (missing):
1631+ if len (expect[0 ]) != len (missing.indices ):
16181632 return false
1619- for i in 0 ..< len (missing):
1620- if (missing[i].block_root != root) or
1621- (int (missing[i].index) != expect[0 ][i]):
1633+ for i in 0 ..< len (missing.indices):
1634+ if missing.block_root != root:
1635+ return false
1636+ if (int (missing.indices[i]) != expect[0 ][i]):
16221637 return false
16231638 return true
16241639 false
@@ -1627,8 +1642,8 @@ suite "ColumnQuarantine data structure test suite " & preset():
16271642 let
16281643 missing1 = bq.fetchMissingSidecars (broot1, fuluBlock1)
16291644 missing2 = bq.fetchMissingSidecars (broot2, fuluBlock2)
1630- missing3 = bq. fetchMissingSidecars (broot1, fuluBlock1,
1631- peerCustodyColumns1)
1645+ missing3 =
1646+ bq. fetchMissingSidecars (broot1, fuluBlock1, peerCustodyColumns1)
16321647 check:
16331648 compareSidecars (
16341649 broot1,
@@ -1832,34 +1847,38 @@ suite "ColumnQuarantine data structure test suite " & preset():
18321847
18331848 check:
18341849 len (bq) == 0
1835- len (bq.fetchMissingSidecars (broot1, fuluBlock1, custodyColumns)) ==
1836- len (custodyColumns)
1837- len (bq.fetchMissingSidecars (broot2, fuluBlock2, custodyColumns)) ==
1838- len (custodyColumns)
1850+ len (bq.fetchMissingSidecars (
1851+ broot1, fuluBlock1, custodyColumns).indices) == len (custodyColumns)
1852+ len (bq.fetchMissingSidecars (
1853+ broot2, fuluBlock2, custodyColumns).indices) == len (custodyColumns)
18391854
18401855 for index in 0 ..< len (custodyColumns):
18411856 bq.put (broot1, sidecars1[index])
18421857 check:
18431858 len (bq) == (index + 1 )
1844- len (bq.fetchMissingSidecars (broot1, fuluBlock1, custodyColumns)) ==
1845- len (custodyColumns) - (index + 1 )
1859+ len (bq.fetchMissingSidecars (
1860+ broot1, fuluBlock1, custodyColumns).indices) ==
1861+ len (custodyColumns) - (index + 1 )
18461862 bq.put (broot1, sidecars1d[index])
18471863 check:
18481864 len (bq) == (index + 1 )
1849- len (bq.fetchMissingSidecars (broot1, fuluBlock1, custodyColumns)) ==
1850- len (custodyColumns) - (index + 1 )
1865+ len (bq.fetchMissingSidecars (
1866+ broot1, fuluBlock1, custodyColumns).indices) ==
1867+ len (custodyColumns) - (index + 1 )
18511868
18521869 for index in 0 ..< len (custodyColumns):
18531870 bq.put (broot2, sidecars2[index])
18541871 check:
18551872 len (bq) == len (custodyColumns) + (index + 1 )
1856- len (bq.fetchMissingSidecars (broot2, fuluBlock2, custodyColumns)) ==
1857- len (custodyColumns) - (index + 1 )
1873+ len (bq.fetchMissingSidecars (
1874+ broot2, fuluBlock2, custodyColumns).indices) ==
1875+ len (custodyColumns) - (index + 1 )
18581876 bq.put (broot2, sidecars2d[index])
18591877 check:
18601878 len (bq) == len (custodyColumns) + (index + 1 )
1861- len (bq.fetchMissingSidecars (broot2, fuluBlock2, custodyColumns)) ==
1862- len (custodyColumns) - (index + 1 )
1879+ len (bq.fetchMissingSidecars (
1880+ broot2, fuluBlock2, custodyColumns).indices) ==
1881+ len (custodyColumns) - (index + 1 )
18631882
18641883 bq.remove (broot2)
18651884 check len (bq) == len (custodyColumns)
0 commit comments