@@ -25,44 +25,8 @@ describe('prover/orchestrator/multi-block', () => {
2525 } ) ;
2626
2727 describe ( 'multiple blocks' , ( ) => {
28- // Skipping in the interest of speeding up CI
29- it . skip . each ( [ 1 , 4 , 5 ] ) ( 'builds an epoch with %s blocks in sequence' , async ( numBlocks : number ) => {
30- logger . info ( `Seeding world state with ${ numBlocks } blocks` ) ;
31- // One block per checkpoint.
32- const numCheckpoints = numBlocks ;
33- const txCount = 2 ;
34- const blocks = await timesAsync ( numBlocks , i => context . makePendingBlock ( txCount , 0 , i + 1 ) ) ;
35- const blockBlobFields = blocks . map ( block => block . block . body . toBlobFields ( ) ) ;
36- const blobs = ( await Promise . all ( blockBlobFields . map ( blobFields => Blob . getBlobsPerBlock ( blobFields ) ) ) ) . flat ( ) ;
37- const finalBlobChallenges = await BatchedBlob . precomputeBatchedBlobChallenges ( blobs ) ;
38-
39- logger . info ( `Starting new epoch with ${ numBlocks } ` ) ;
40- context . orchestrator . startNewEpoch ( 1 , numCheckpoints , finalBlobChallenges ) ;
41-
42- for ( let i = 0 ; i < blocks . length ; i ++ ) {
43- const { block, txs } = blocks [ i ] ;
44- const slotNumber = block . header . globalVariables . slotNumber . toNumber ( ) ;
45- await context . orchestrator . startNewCheckpoint (
46- makeCheckpointConstants ( slotNumber ) ,
47- [ ] ,
48- 1 /* numBlocks */ ,
49- blockBlobFields [ i ] . length ,
50- context . getPreviousBlockHeader ( block . number ) ,
51- ) ;
52-
53- await context . orchestrator . startNewBlock ( block . number , block . header . globalVariables . timestamp , txs . length ) ;
54- await context . orchestrator . addTxs ( txs ) ;
55- await context . orchestrator . setBlockCompleted ( block . number ) ;
56- }
57-
58- logger . info ( 'Finalising epoch' ) ;
59- const epoch = await context . orchestrator . finaliseEpoch ( ) ;
60- expect ( countHeaderHashes ( epoch . publicInputs . checkpointHeaderHashes ) ) . toEqual ( numCheckpoints ) ;
61- expect ( epoch . proof ) . toBeDefined ( ) ;
62- } ) ;
63-
64- it . each ( [ 1 , 4 ] ) (
65- 'builds an epoch with %s blocks in parallel' ,
28+ it . each ( [ 4 , 5 ] ) (
29+ 'builds an epoch with %s blocks in sequence' ,
6630 async ( numBlocks : number ) => {
6731 logger . info ( `Seeding world state with ${ numBlocks } blocks` ) ;
6832 // One block per checkpoint.
@@ -76,22 +40,21 @@ describe('prover/orchestrator/multi-block', () => {
7640 logger . info ( `Starting new epoch with ${ numBlocks } ` ) ;
7741 context . orchestrator . startNewEpoch ( 1 , numCheckpoints , finalBlobChallenges ) ;
7842
79- await Promise . all (
80- blocks . map ( async ( { block, txs } , i ) => {
81- const slotNumber = block . header . globalVariables . slotNumber . toNumber ( ) ;
82- await context . orchestrator . startNewCheckpoint (
83- makeCheckpointConstants ( slotNumber ) ,
84- [ ] ,
85- 1 /* numBlocks */ ,
86- blockBlobFields [ i ] . length ,
87- context . getPreviousBlockHeader ( block . number ) ,
88- ) ;
43+ for ( let i = 0 ; i < blocks . length ; i ++ ) {
44+ const { block, txs } = blocks [ i ] ;
45+ const slotNumber = block . header . globalVariables . slotNumber . toNumber ( ) ;
46+ await context . orchestrator . startNewCheckpoint (
47+ makeCheckpointConstants ( slotNumber ) ,
48+ [ ] ,
49+ 1 /* numBlocks */ ,
50+ blockBlobFields [ i ] . length ,
51+ context . getPreviousBlockHeader ( block . number ) ,
52+ ) ;
8953
90- await context . orchestrator . startNewBlock ( block . number , block . header . globalVariables . timestamp , txs . length ) ;
91- await context . orchestrator . addTxs ( txs ) ;
92- await context . orchestrator . setBlockCompleted ( block . number ) ;
93- } ) ,
94- ) ;
54+ await context . orchestrator . startNewBlock ( block . number , block . header . globalVariables . timestamp , txs . length ) ;
55+ await context . orchestrator . addTxs ( txs ) ;
56+ await context . orchestrator . setBlockCompleted ( block . number ) ;
57+ }
9558
9659 logger . info ( 'Finalising epoch' ) ;
9760 const epoch = await context . orchestrator . finaliseEpoch ( ) ;
@@ -105,7 +68,7 @@ describe('prover/orchestrator/multi-block', () => {
10568 'builds two consecutive epochs' ,
10669 async ( ) => {
10770 const numEpochs = 2 ;
108- const numBlocks = 4 ;
71+ const numBlocks = 3 ;
10972 const txCount = 2 ;
11073 logger . info ( `Seeding world state with ${ numBlocks * numEpochs } blocks` ) ;
11174 const blocks = await timesAsync ( numBlocks * numEpochs , i => context . makePendingBlock ( txCount , 0 , i + 1 ) ) ;
@@ -122,23 +85,25 @@ describe('prover/orchestrator/multi-block', () => {
12285 ) . flat ( ) ;
12386 const finalBlobChallenges = await BatchedBlob . precomputeBatchedBlobChallenges ( blobs ) ;
12487 context . orchestrator . startNewEpoch ( epochNumber , numCheckpoints , finalBlobChallenges ) ;
88+ for ( let i = 0 ; i < blocksInEpoch . length ; i ++ ) {
89+ const { block, txs } = blocksInEpoch [ i ] ;
90+ const slotNumber = block . header . globalVariables . slotNumber . toNumber ( ) ;
91+ await context . orchestrator . startNewCheckpoint (
92+ makeCheckpointConstants ( slotNumber ) ,
93+ [ ] ,
94+ 1 /* numBlocks */ ,
95+ blockBlobFields [ i ] . length ,
96+ context . getPreviousBlockHeader ( block . number ) ,
97+ ) ;
98+
99+ await context . orchestrator . startNewBlock ( block . number , block . header . globalVariables . timestamp , txs . length ) ;
100+ // txs must be added for each block sequentially.
101+ await context . orchestrator . addTxs ( txs ) ;
102+ }
103+
104+ // setBlockCompleted may be called in parallel, but it must be called after all txs have been added.
125105 await Promise . all (
126- blocksInEpoch . map ( async ( { block, txs } , i ) => {
127- const slotNumber = block . header . globalVariables . slotNumber . toNumber ( ) ;
128- await context . orchestrator . startNewCheckpoint (
129- makeCheckpointConstants ( slotNumber ) ,
130- [ ] ,
131- 1 /* numBlocks */ ,
132- blockBlobFields [ i ] . length ,
133- context . getPreviousBlockHeader ( block . number ) ,
134- ) ;
135-
136- await context . orchestrator . startNewBlock (
137- block . number ,
138- block . header . globalVariables . timestamp ,
139- txs . length ,
140- ) ;
141- await context . orchestrator . addTxs ( txs ) ;
106+ blocksInEpoch . map ( async ( { block } ) => {
142107 await context . orchestrator . setBlockCompleted ( block . number ) ;
143108 } ) ,
144109 ) ;
0 commit comments