Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/rollup-core/src/app/data/data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
3 changes: 2 additions & 1 deletion packages/rollup-core/test/db/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
46 changes: 44 additions & 2 deletions packages/rollup-core/test/db/l1-data-service.dbspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () => {
Expand Down