Skip to content

Commit d44805e

Browse files
committed
Made ST and batch tracing parallel
1 parent cf6e49c commit d44805e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

packages/sequencer/src/protocol/production/BatchProducerModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class BatchProducerModule extends SequencerModule {
198198
const toNetworkState = blocks.at(-1)!.result.afterNetworkState;
199199

200200
const changes = {
201-
commit: merkleTreeStore.commit,
201+
commit: async () => await merkleTreeStore.mergeIntoParent(),
202202
};
203203

204204
return {

packages/sequencer/src/protocol/production/tracing/BatchTracingService.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,20 @@ export class BatchTracingService {
8585

8686
public async traceBatch(
8787
blocks: BlockWithResult[],
88-
merkleTreeStore: CachedMerkleTreeStore,
89-
// TODO Implement and then also test
90-
parallel: boolean = false
88+
merkleTreeStore: CachedMerkleTreeStore
9189
): Promise<BatchTrace> {
9290
if (blocks.length === 0) {
9391
return { blocks: [], stateTransitionTrace: [] };
9492
}
9593

96-
const blockTraces = await this.traceBlocks(blocks);
97-
98-
// Trace STs
99-
const stateTransitionTrace = await this.traceStateTransitions(
100-
blocks,
101-
merkleTreeStore
102-
);
94+
// Traces the STs and the blocks in parallel, however not in separate processes
95+
// Therefore, we only optimize the idle time for async operations like DB reads
96+
const [blockTraces, stateTransitionTrace] = await Promise.all([
97+
// Trace blocks
98+
this.traceBlocks(blocks),
99+
// Trace STs
100+
this.traceStateTransitions(blocks, merkleTreeStore),
101+
]);
103102

104103
return {
105104
blocks: blockTraces,

0 commit comments

Comments
 (0)