Skip to content
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
15 changes: 15 additions & 0 deletions .changeset/quick-ties-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@eth-optimism/integration-tests': patch
'@eth-optimism/common-ts': patch
'@eth-optimism/contracts': patch
'@eth-optimism/contracts-periphery': patch
'@eth-optimism/core-utils': patch
'@eth-optimism/data-transport-layer': patch
'@eth-optimism/fault-detector': patch
'@eth-optimism/integration-tests-bedrock': patch
'@eth-optimism/message-relayer': patch
'@eth-optimism/replica-healthcheck': patch
'@eth-optimism/sdk': patch
---

Updates all ethers versions in response to BN.js bug
40 changes: 14 additions & 26 deletions contracts-bedrock/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import * as RLP from '@ethersproject/rlp'
import { BigNumber, BigNumberish } from '@ethersproject/bignumber'
import { getAddress } from '@ethersproject/address'
import {
hexConcat,
stripZeros,
zeroPad,
arrayify,
BytesLike,
} from '@ethersproject/bytes'
import { keccak256 } from '@ethersproject/keccak256'
import { Zero } from '@ethersproject/constants'
import { ContractReceipt, Event } from '@ethersproject/contracts'
import { BigNumber, BigNumberish, BytesLike, ContractReceipt, ethers, Event } from 'ethers'

function formatNumber(value: BigNumberish, name: string): Uint8Array {
const result = stripZeros(BigNumber.from(value).toHexString())
const result = ethers.utils.stripZeros(BigNumber.from(value).toHexString())
if (result.length > 32) {
throw new Error(`invalid length for ${name}`)
}
Expand All @@ -22,7 +10,7 @@ function formatNumber(value: BigNumberish, name: string): Uint8Array {

function handleNumber(value: string): BigNumber {
if (value === '0x') {
return Zero
return ethers.constants.Zero
}
return BigNumber.from(value)
}
Expand All @@ -32,7 +20,7 @@ function handleAddress(value: string): string {
// @ts-ignore
return null
}
return getAddress(value)
return ethers.utils.getAddress(value)
}

export enum SourceHashDomain {
Expand Down Expand Up @@ -92,7 +80,7 @@ export class DepositTx {

hash() {
const encoded = this.encode()
return keccak256(encoded)
return ethers.utils.keccak256(encoded)
}

sourceHash() {
Expand All @@ -114,32 +102,32 @@ export class DepositTx {
}

const l1BlockHash = this.l1BlockHash
const input = hexConcat([l1BlockHash, zeroPad(marker, 32)])
const depositIDHash = keccak256(input)
const input = ethers.utils.hexConcat([l1BlockHash, ethers.utils.zeroPad(marker, 32)])
const depositIDHash = ethers.utils.keccak256(input)
const domain = BigNumber.from(this.domain).toHexString()
const domainInput = hexConcat([zeroPad(domain, 32), depositIDHash])
this._sourceHash = keccak256(domainInput)
const domainInput = ethers.utils.hexConcat([ethers.utils.zeroPad(domain, 32), depositIDHash])
this._sourceHash = ethers.utils.keccak256(domainInput)
}
return this._sourceHash
}

encode() {
const fields: any = [
this.sourceHash() || '0x',
getAddress(this.from) || '0x',
this.to != null ? getAddress(this.to) : '0x',
ethers.utils.getAddress(this.from) || '0x',
this.to != null ? ethers.utils.getAddress(this.to) : '0x',
formatNumber(this.mint || 0, 'mint'),
formatNumber(this.value || 0, 'value'),
formatNumber(this.gas || 0, 'gas'),
this.data || '0x',
]

return hexConcat([this.type, RLP.encode(fields)])
return ethers.utils.hexConcat([this.type, ethers.utils.RLP.encode(fields)])
}

decode(raw: BytesLike, extra: DepostTxExtraOpts = {}) {
const payload = arrayify(raw)
const transaction = RLP.decode(payload.slice(1))
const payload = ethers.utils.arrayify(raw)
const transaction = ethers.utils.RLP.decode(payload.slice(1))

this._sourceHash = transaction[0]
this.from = handleAddress(transaction[1])
Expand Down
10 changes: 3 additions & 7 deletions contracts-bedrock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
"license": "MIT",
"dependencies": {
"@eth-optimism/contracts": "^0.5.21",
"@ethersproject/address": "^5.6.0",
"@ethersproject/bignumber": "^5.6.0",
"@ethersproject/bytes": "^5.6.1",
"@ethersproject/keccak256": "^5.6.0",
"@ethersproject/rlp": "^5.6.0",
"@openzeppelin/contracts": "^4.5.0",
"@openzeppelin/contracts-upgradeable": "^4.5.2",
"hardhat": "^2.7.1",
"ethers": "^5.6.8",
"hardhat": "^2.9.6",
"merkle-patricia-tree": "^4.2.4",
"rlp": "^2.2.7"
},
Expand Down Expand Up @@ -57,7 +53,7 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.1.0",
"ethereum-waffle": "^3.0.0",
"ethers": "^5.0.0",
"ethers": "^5.6.8",
"hardhat-deploy": "^0.11.4",
"hardhat-gas-reporter": "^1.0.4",
"prettier": "^2.3.2",
Expand Down
Loading