Commit 128e0f84 authored by Mark Tyneway's avatar Mark Tyneway

dtl: support unprotected txs

When syncing from L2, all transactions were assumed to be
protected. To prevent a network split for replicas,
the DTL needs to check for transactions that are not
protected and handle parsing the `v` parameter
appropriately.
parent d141095c
---
'@eth-optimism/data-transport-layer': patch
---
Handle unprotected transactions
...@@ -2,8 +2,18 @@ ...@@ -2,8 +2,18 @@
import { ethers } from 'ethers' import { ethers } from 'ethers'
export const parseSignatureVParam = ( export const parseSignatureVParam = (
v: number | ethers.BigNumber, v: number | ethers.BigNumber | string,
chainId: number chainId: number
): number => { ): number => {
return ethers.BigNumber.from(v).toNumber() - 2 * chainId - 35 v = ethers.BigNumber.from(v).toNumber()
// Handle normalized v
if (v === 0 || v === 1) {
return v
}
// Handle unprotected transactions
if (v === 27 || v === 28) {
return v - 27
}
// Handle EIP155 transactions
return v - 2 * chainId - 35
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment