ethers.js
ethers.js copied to clipboard
fix: correctly handle V check for big chain IDs
Fixes a bug in @ethersproject/transactions where certain valid signature V parameters would be considered invalid when a sufficiently large chain ID is used. Signature V parameter will always be just one byte, so has a potential value of 0 to 255. Check in question would do the calculation (sig.v ?== 27 + sig.recoveryParam + chainId * 2 + 8). When chainId is >= 111, the right-hand side of the formula will always be greater than 255 and therefore the check will always fail. Fix is to add a modulo 256 to the right-hand side of the equation.
A quick note: causes signing with Ledger wallets on networks with big chain IDs to fail consistently. ethers.Wallet is not subject to this problem because it always returns a signature with a V parameter of 27 or 28 (considered a "maybe protected" signature). I believe either is technically fine. Geth handles both cases.
This fixes https://github.com/ethers-io/ext-signer-ledger/issues/6
Fix in ethers-rs: https://github.com/gakonst/ethers-rs/commit/da3808301386a4a05a99f2b0bdc6ee5edc1cb02e
Issue still seems to be present in latest versions of Ethers. We're running into this issue again because ethers+ledger doesn't work out of the box with our new Optimism Goerli testnet which has a chain ID of 420. I think the fix is pretty straightforward, but let me know if anything is confusing.
Issue still seems to be present in latest versions of Ethers. We're running into this issue again because ethers+ledger doesn't work out of the box with our new Optimism Goerli testnet which has a chain ID of 420. I think the fix is pretty straightforward, but let me know if anything is confusing.
Confirmed still an issue.
Have you tried using v6? It separates chain ID when passed as a EIP-155 v into a .v and .networkV.