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 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
9 changes: 5 additions & 4 deletions packages/core-utils/src/app/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ export const getTxSigner = async (
* @throws Error If r, s, or v are not the correct length.
*/
export const rsvToSignature = (r: string, s: string, v: number): string => {
const vString = remove0x(numberToHexString(v, 1))
const vString = remove0x(numberToHexString(v, 2))
const sig = `${add0x(r)}${remove0x(s)}${vString}`
// '0x' + 64 chars for r + 64 chars for s + 2 chars for v = 132
if (sig.length !== 132) {

// '0x' + 64 chars for r + 64 chars for s + 4 chars for v = 134
if (sig.length !== 134) {
throw Error(
`Invalid v [${vString}], r [${r}], s[${s}]. v [${vString.length}] should be 2 chars, r [${r.length}] should be 64 chars, and s [${s.length}] should be 64 chars.`
`Invalid v [${vString}], r [${r}], s[${s}]. v [${vString.length}] should be 4 chars, r [${r.length}] should be 64 chars, and s [${s.length}] should be 64 chars.`
)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/rollup-core/src/app/data/data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class DefaultDataService implements DataService {
txContext?: any
): Promise<void> {
return this.rdb.execute(
`${l1BlockInsertStatement}
`${l1BlockInsertStatement}
VALUES (${getL1BlockInsertValue(block, processed)})`,
txContext
)
Expand All @@ -114,8 +114,9 @@ export class DefaultDataService implements DataService {
const values: string[] = transactions.map(
(tx, index) => `(${getL1TransactionInsertValue(tx, index)})`
)

return this.rdb.execute(
`${l1TxInsertStatement}
`${l1TxInsertStatement}
VALUES ${values.join(',')}`,
txContext
)
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