Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove state update id on reorg for l2 tx #484

Merged
merged 2 commits into from
Aug 28, 2023
Merged
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
2 changes: 1 addition & 1 deletion packages/backend/src/config/starkex/apex-goerli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function getApexGoerliConfig(env: Env): StarkexConfig {
auth: clientAuth,
},
l2Transactions: {
enabled: true,
enabled: env.boolean('L2_TRANSACTIONS_ENABLED', true),
excludeTypes: ['OraclePricesTick'],
feederGateway: {
getUrl: (batchId: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ describe(FeederGatewayCollector.name, () => {

describe(FeederGatewayCollector.prototype.discardAfter.name, () => {
const mockedL2TransactionRepository = mockObject<L2TransactionRepository>({
deleteAfterBlock: mockFn().resolvesTo(1),
removeStateUpdateIdAfterBlock: mockFn().resolvesTo(1),
})
const feederGatewayCollector = new FeederGatewayCollector(
mockObject<FeederGatewayClient>(),
Expand All @@ -455,7 +455,7 @@ describe(FeederGatewayCollector.name, () => {
await feederGatewayCollector.discardAfter(blockNumber)

expect(
mockedL2TransactionRepository.deleteAfterBlock
mockedL2TransactionRepository.removeStateUpdateIdAfterBlock
).toHaveBeenCalledWith(blockNumber)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export class FeederGatewayCollector {
}

async discardAfter(blockNumber: number) {
await this.l2TransactionRepository.deleteAfterBlock(blockNumber)
await this.l2TransactionRepository.removeStateUpdateIdAfterBlock(
blockNumber
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export class L2TransactionRepository extends BaseRepository {
this.findOldestByTransactionId
)
this.findLatestIncluded = this.wrapFind(this.findLatestIncluded)
this.deleteAfterBlock = this.wrapDelete(this.deleteAfterBlock)
this.removeStateUpdateIdAfterBlock = this.wrapUpdate(
this.removeStateUpdateIdAfterBlock
)
this.deleteByTransactionIds = this.wrapDelete(this.deleteByTransactionIds)
this.deleteAll = this.wrapDelete(this.deleteAll)
this.runInTransactionWithLockedTable = this.wrapAny(
Expand Down Expand Up @@ -607,11 +609,11 @@ export class L2TransactionRepository extends BaseRepository {
return row ? toRecord(row) : undefined
}

async deleteAfterBlock(blockNumber: number) {
async removeStateUpdateIdAfterBlock(blockNumber: number) {
const knex = await this.knex()
return knex('l2_transactions')
.where('block_number', '>', blockNumber)
.delete()
.update({ state_update_id: null })
}

async deleteByTransactionIds(
Expand Down