diff --git a/packages/rollup-core/src/app/data/data-service.ts b/packages/rollup-core/src/app/data/data-service.ts index 6284ba19ad312..feebe10388c5b 100644 --- a/packages/rollup-core/src/app/data/data-service.ts +++ b/packages/rollup-core/src/app/data/data-service.ts @@ -224,7 +224,9 @@ export class DefaultDataService implements DataService { await this.rdb.execute( `UPDATE l1_rollup_tx - SET geth_submission_queue_index = ${submissionQueueIndex}, index_within_submission = 0 + SET + geth_submission_queue_index = ${submissionQueueIndex}, + index_within_submission = COALESCE(index_within_submission, 0) WHERE l1_tx_hash = '${txHash}' AND l1_tx_log_index = ${txLogIndex}`, txContext ) diff --git a/packages/rollup-core/test/db/helpers.ts b/packages/rollup-core/test/db/helpers.ts index 41b150d6dd1d4..a4c5fccfabd14 100644 --- a/packages/rollup-core/test/db/helpers.ts +++ b/packages/rollup-core/test/db/helpers.ts @@ -141,13 +141,14 @@ export const createRollupTx = ( queueOrigin: QueueOrigin, txIndex: number = 0, submissionIndex: number = 0, + calldata?: string, l1MessageSender?: string, logIndex: number = 0 ): RollupTransaction => { return { indexWithinSubmission: submissionIndex, target: tx.to, - calldata: tx.data, + calldata: calldata || tx.data, sender: tx.from, l1MessageSender, gasLimit: gasLimit.toNumber(), diff --git a/packages/rollup-core/test/db/l1-data-service.dbspec.ts b/packages/rollup-core/test/db/l1-data-service.dbspec.ts index c2b9b4795d72a..8909394ce2383 100644 --- a/packages/rollup-core/test/db/l1-data-service.dbspec.ts +++ b/packages/rollup-core/test/db/l1-data-service.dbspec.ts @@ -182,8 +182,23 @@ describe('L1 Data Service (will fail if postgres is not running with expected sc await dataService.insertL1BlockAndTransactions(l1Block, [tx], true) - const rTx1 = createRollupTx(tx, QueueOrigin.SAFETY_QUEUE) - const rTx2 = createRollupTx(tx, QueueOrigin.SAFETY_QUEUE, 0, 1) + const rTx1Calldata: string = keccak256FromUtf8('calldata 1') + const rTx2Calldata: string = keccak256FromUtf8('calldata 2') + + const rTx1 = createRollupTx( + tx, + QueueOrigin.SAFETY_QUEUE, + 0, + 0, + rTx1Calldata + ) + const rTx2 = createRollupTx( + tx, + QueueOrigin.SAFETY_QUEUE, + 0, + 1, + rTx2Calldata + ) let submissionIndex = await dataService.insertL1RollupTransactions( tx.hash, @@ -212,6 +227,33 @@ describe('L1 Data Service (will fail if postgres is not running with expected sc GethSubmissionQueueStatus.QUEUED, `Incorrect queue status!` ) + + const rollupTxRes: Row[] = await postgres.select( + `SELECT index_within_submission, calldata + FROM l1_rollup_tx + WHERE geth_submission_queue_index = 0 + ORDER BY index_within_submission ASC` + ) + rollupTxRes.length.should.equal( + 2, + `Incorrect number of rollup transactions within the submission!` + ) + rollupTxRes[0]['index_within_submission'].should.equal( + 0, + `Incorrect first tx index!` + ) + rollupTxRes[0]['calldata'].should.equal( + rTx1Calldata, + 'Incorrect transaction came first!' + ) + rollupTxRes[1]['index_within_submission'].should.equal( + 1, + `Incorrect second tx index!` + ) + rollupTxRes[1]['calldata'].should.equal( + rTx2Calldata, + 'Incorrect transaction came second!' + ) }) it('Should not queue unqueued geth submission if l1 block is not processed', async () => {