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

Fix L1ToL2 tx postgres ingestion #292

Merged
merged 7 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class L1ChainDataPersister extends ChainDataProcessor {
return this.markProcessed(index)
}

const logs: Log[] = await this.getLogsForBlock(block.hash)
const logs: Log[] = await this.getLogsForBlock(block)

log.debug(
`Got ${logs.length} logs from block ${block.number}: ${JSON.stringify(
Expand Down Expand Up @@ -195,15 +195,19 @@ export class L1ChainDataPersister extends ChainDataProcessor {
* @param blockHash The block hash for the block in which we're searching for logs.
* @returns The combined array of Logs that we care about based on our topics.
*/
private async getLogsForBlock(blockHash: string): Promise<Log[]> {
private async getLogsForBlock(block: Block): Promise<Log[]> {
if (!this.topics.length) {
return []
}

// TODO: Protect against reorgs which change the block number from under us
// Once Ganache supports EIP-234 then we should move this back to using blockHash
// https://github.com/trufflesuite/ganache-core/issues/136
tynes marked this conversation as resolved.
Show resolved Hide resolved
const logsArrays: Log[][] = await Promise.all(
this.topics.map((topic) =>
this.l1Provider.getLogs({
blockHash,
toBlock: block.number,
fromBlock: block.number,
topics: [topic],
})
)
Expand Down
7 changes: 4 additions & 3 deletions packages/rollup-core/src/app/data/producers/log-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ export const L1ToL2TxEnqueuedLogHandler = async (
'hex'
).toNumber()
rollupTransaction.calldata = add0x(parsedLogData[3])
rollupTransaction.l1TxLogIndex = l.logIndex
} catch (e) {
// This is, by definition, just an ill-formatted, and therefore invalid, tx.
log.debug(
`Error parsing calldata tx from CalldataTxEnqueued event. Calldata: ${tx.data}. Error: ${e.message}. Stack: ${e.stack}.`
`Error parsing calldata tx from L1ToL2TxEnqueued event. Calldata: ${tx.data}. Error: ${e.message}. Stack: ${e.stack}.`
)
}

Expand Down Expand Up @@ -334,7 +335,7 @@ export const SequencerBatchAppendedLogHandler = async (
} catch (e) {
// This is, by definition, just an ill-formatted, and therefore invalid, tx.
log.debug(
`Error parsing calldata tx from CalldataTxEnqueued event. Calldata: ${tx.data}. Error: ${e.message}. Stack: ${e.stack}.`
`Error parsing calldata tx from SequencerBatchAppended event. Calldata: ${tx.data}. Error: ${e.message}. Stack: ${e.stack}.`
)
return
}
Expand Down Expand Up @@ -375,7 +376,7 @@ export const StateBatchAppendedLogHandler = async (
} catch (e) {
// This is, by definition, just an ill-formatted, and therefore invalid, tx.
log.debug(
`Error parsing calldata tx from CalldataTxEnqueued event. Calldata: ${tx.data}. Error: ${e.message}. Stack: ${e.stack}.`
`Error parsing calldata tx from StateBatchAppended event. Calldata: ${tx.data}. Error: ${e.message}. Stack: ${e.stack}.`
)
return
}
Expand Down
4 changes: 3 additions & 1 deletion packages/rollup-services/src/exec/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ const createL1ChainDataPersister = async (): Promise<L1ChainDataPersister> => {
getL1Provider(),
[
{
topic: ethers.utils.id('L1ToL2TxEnqueued(bytes)'), // 0x2a9dd32a4056f7419a3a05b09f30cf775204afed73c0981470da34d97ca5e5cd
topic: ethers.utils.id(
'L1ToL2TxEnqueued(address,address,uint32,bytes)'
), // 7f897cd072f041e68ba57be8f0eec7b8933b0b113622ed8ef85685764f6e7986
contractAddress: Environment.getOrThrow(
Environment.l1ToL2TransactionQueueContractAddress
),
Expand Down