Commit 07d4fd3a authored by Janek Rahrt's avatar Janek Rahrt Committed by GitHub

style: use ethers Null Address (#331)

Co-authored-by: default avatarJanek Rahrt <janek.rahrt@joyn.de>
parent ed6bf9e9
......@@ -2,11 +2,11 @@ import { expect } from '../../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Signer, ContractFactory, Contract } from 'ethers'
import { Signer, ContractFactory, Contract, constants } from 'ethers'
import { smockit, MockContract, smoddit } from '@eth-optimism/smock'
/* Internal Imports */
import { NON_ZERO_ADDRESS, ZERO_ADDRESS } from '../../../../helpers'
import { NON_ZERO_ADDRESS } from '../../../../helpers'
const INITIAL_TOTAL_L1_SUPPLY = 3000
......@@ -81,7 +81,7 @@ describe('OVM_L1ERC20Gateway', () => {
)
await expect(
OVM_L1ERC20Gateway.finalizeWithdrawal(ZERO_ADDRESS, 1)
OVM_L1ERC20Gateway.finalizeWithdrawal(constants.AddressZero, 1)
).to.be.revertedWith(ERR_INVALID_MESSENGER)
})
......@@ -91,7 +91,7 @@ describe('OVM_L1ERC20Gateway', () => {
)
await expect(
OVM_L1ERC20Gateway.finalizeWithdrawal(ZERO_ADDRESS, 1, {
OVM_L1ERC20Gateway.finalizeWithdrawal(constants.AddressZero, 1, {
from: Mock__OVM_L1CrossDomainMessenger.address,
})
).to.be.revertedWith(ERR_INVALID_X_DOMAIN_MSG_SENDER)
......@@ -124,7 +124,7 @@ describe('OVM_L1ERC20Gateway', () => {
const OVM_L2DepositedERC20 = await (
await ethers.getContractFactory('OVM_L2DepositedERC20')
).deploy(ZERO_ADDRESS, '', '')
).deploy(constants.AddressZero, '', '')
const defaultFinalizeWithdrawalGas = await OVM_L2DepositedERC20.getFinalizeWithdrawalL1Gas()
await expect(gasUsed.gt((defaultFinalizeWithdrawalGas * 11) / 10))
})
......
......@@ -2,15 +2,11 @@ import { expect } from '../../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Signer, Contract } from 'ethers'
import { Signer, Contract, constants } from 'ethers'
import { smockit, MockContract } from '@eth-optimism/smock'
/* Internal Imports */
import {
NON_ZERO_ADDRESS,
ZERO_ADDRESS,
makeAddressManager,
} from '../../../../helpers'
import { NON_ZERO_ADDRESS, makeAddressManager } from '../../../../helpers'
const L1_ETH_GATEWAY_NAME = 'Proxy__OVM_L1CrossDomainMessenger'
......@@ -61,7 +57,10 @@ describe('OVM_L1ETHGateway', () => {
it('onlyFromCrossDomainAccount: should revert on calls from a non-crossDomainMessenger L1 account', async () => {
// Deploy new gateway, initialize with random messenger
await expect(
OVM_L1ETHGateway.connect(alice).finalizeWithdrawal(ZERO_ADDRESS, 1)
OVM_L1ETHGateway.connect(alice).finalizeWithdrawal(
constants.AddressZero,
1
)
).to.be.revertedWith(ERR_INVALID_MESSENGER)
})
......@@ -80,7 +79,7 @@ describe('OVM_L1ETHGateway', () => {
)
await expect(
OVM_L1ETHGateway.finalizeWithdrawal(ZERO_ADDRESS, 1)
OVM_L1ETHGateway.finalizeWithdrawal(constants.AddressZero, 1)
).to.be.revertedWith(ERR_INVALID_X_DOMAIN_MSG_SENDER)
})
......@@ -118,7 +117,7 @@ describe('OVM_L1ETHGateway', () => {
// Deploy this just for the getter
const OVM_L2DepositedERC20 = await (
await ethers.getContractFactory('OVM_L2DepositedERC20')
).deploy(ZERO_ADDRESS, '', '')
).deploy(constants.AddressZero, '', '')
await expect(
gasUsed.gt(
......
......@@ -2,7 +2,7 @@ import { expect } from '../../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Signer, ContractFactory, Contract } from 'ethers'
import { Signer, ContractFactory, Contract, constants } from 'ethers'
import {
smockit,
MockContract,
......@@ -11,7 +11,7 @@ import {
} from '@eth-optimism/smock'
/* Internal Imports */
import { NON_ZERO_ADDRESS, ZERO_ADDRESS } from '../../../../helpers'
import { NON_ZERO_ADDRESS } from '../../../../helpers'
const ERR_INVALID_MESSENGER = 'OVM_XCHAIN: messenger contract unauthenticated'
const ERR_INVALID_X_DOMAIN_MSG_SENDER =
......@@ -66,7 +66,7 @@ describe('OVM_L2DepositedERC20', () => {
await OVM_L2DepositedERC20.init(NON_ZERO_ADDRESS)
await expect(
OVM_L2DepositedERC20.finalizeDeposit(ZERO_ADDRESS, 0)
OVM_L2DepositedERC20.finalizeDeposit(constants.AddressZero, 0)
).to.be.revertedWith(ERR_INVALID_MESSENGER)
})
......@@ -76,7 +76,7 @@ describe('OVM_L2DepositedERC20', () => {
)
await expect(
OVM_L2DepositedERC20.finalizeDeposit(ZERO_ADDRESS, 0, {
OVM_L2DepositedERC20.finalizeDeposit(constants.AddressZero, 0, {
from: Mock__OVM_L2CrossDomainMessenger.address,
})
).to.be.revertedWith(ERR_INVALID_X_DOMAIN_MSG_SENDER)
......
......@@ -2,7 +2,7 @@ import { expect } from '../../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Signer, ContractFactory, Contract } from 'ethers'
import { Signer, ContractFactory, Contract, constants } from 'ethers'
import { smockit, MockContract } from '@eth-optimism/smock'
/* Internal Imports */
......@@ -10,7 +10,6 @@ import {
makeAddressManager,
setProxyTarget,
NON_NULL_BYTES32,
ZERO_ADDRESS,
NON_ZERO_ADDRESS,
getXDomainCalldata,
} from '../../../../helpers'
......@@ -121,7 +120,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
it('should revert if the L1 message sender is not the OVM_L1CrossDomainMessenger', async () => {
Mock__OVM_L1MessageSender.smocked.getL1MessageSender.will.return.with(
ZERO_ADDRESS
constants.AddressZero
)
await expect(
......
......@@ -2,7 +2,7 @@ import { expect } from '../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Signer, ContractFactory, Contract, BigNumber } from 'ethers'
import { Signer, ContractFactory, Contract, BigNumber, constants } from 'ethers'
import { smockit, MockContract } from '@eth-optimism/smock'
import {
AppendSequencerBatchParams,
......@@ -25,7 +25,6 @@ import {
getNextBlockNumber,
increaseEthTime,
getBlockTime,
ZERO_ADDRESS,
mineBlock,
} from '../../../helpers'
......@@ -632,7 +631,7 @@ describe('OVM_CanonicalTransactionChain', () => {
timestamp,
blockNumber,
l1QueueOrigin: 0,
l1TxOrigin: ZERO_ADDRESS,
l1TxOrigin: constants.AddressZero,
entrypoint,
gasLimit,
data,
......
......@@ -2,7 +2,7 @@ import { expect } from '../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Signer, ContractFactory, Contract } from 'ethers'
import { Signer, ContractFactory, Contract, constants } from 'ethers'
import { smockit, MockContract } from '@eth-optimism/smock'
/* Internal Imports */
......@@ -10,7 +10,6 @@ import {
makeAddressManager,
setProxyTarget,
NON_NULL_BYTES32,
ZERO_ADDRESS,
getEthTime,
NULL_BYTES32,
increaseEthTime,
......@@ -212,7 +211,10 @@ describe('OVM_StateCommitmentChain', () => {
describe('when the sender is not the OVM_FraudVerifier', () => {
before(async () => {
await AddressManager.setAddress('OVM_FraudVerifier', ZERO_ADDRESS)
await AddressManager.setAddress(
'OVM_FraudVerifier',
constants.AddressZero
)
})
it('should revert', async () => {
......
/* Internal Imports */
import { constants } from 'ethers'
import {
ExecutionManagerTestRunner,
TestDefinition,
......@@ -7,7 +8,6 @@ import {
VERIFIED_EMPTY_CONTRACT_HASH,
NUISANCE_GAS_COSTS,
Helper_TestRunner_BYTELEN,
ZERO_ADDRESS,
} from '../../../../helpers'
const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
......@@ -212,7 +212,7 @@ const test_nuisanceGas: TestDefinition = {
],
},
expectedReturnStatus: true,
expectedReturnValue: ZERO_ADDRESS,
expectedReturnValue: constants.AddressZero,
},
],
},
......
/* Internal Imports */
import { constants } from 'ethers'
import {
ExecutionManagerTestRunner,
TestDefinition,
......@@ -8,7 +9,6 @@ import {
REVERT_FLAGS,
DUMMY_BYTECODE,
UNSAFE_BYTECODE,
ZERO_ADDRESS,
VERIFIED_EMPTY_CONTRACT_HASH,
DUMMY_BYTECODE_BYTELEN,
DUMMY_BYTECODE_HASH,
......@@ -181,7 +181,7 @@ const test_ovmCREATE: TestDefinition = {
},
expectedReturnStatus: true,
expectedReturnValue: {
address: ZERO_ADDRESS,
address: constants.AddressZero,
revertData: DUMMY_REVERT_DATA,
},
},
......@@ -207,7 +207,7 @@ const test_ovmCREATE: TestDefinition = {
},
expectedReturnStatus: true,
expectedReturnValue: {
address: ZERO_ADDRESS,
address: constants.AddressZero,
revertData: DUMMY_REVERT_DATA,
},
},
......@@ -241,7 +241,7 @@ const test_ovmCREATE: TestDefinition = {
},
expectedReturnStatus: true,
expectedReturnValue: {
address: ZERO_ADDRESS,
address: constants.AddressZero,
revertData: DUMMY_REVERT_DATA,
},
},
......@@ -275,7 +275,7 @@ const test_ovmCREATE: TestDefinition = {
},
expectedReturnStatus: true,
expectedReturnValue: {
address: ZERO_ADDRESS,
address: constants.AddressZero,
revertData: DUMMY_REVERT_DATA,
},
},
......@@ -542,7 +542,7 @@ const test_ovmCREATE: TestDefinition = {
},
expectedReturnStatus: true,
expectedReturnValue: {
address: ZERO_ADDRESS,
address: constants.AddressZero,
revertData: DUMMY_REVERT_DATA,
},
},
......@@ -704,7 +704,7 @@ const test_ovmCREATE: TestDefinition = {
},
expectedReturnStatus: true,
expectedReturnValue: {
address: ZERO_ADDRESS,
address: constants.AddressZero,
revertData: DUMMY_REVERT_DATA,
},
},
......@@ -723,7 +723,7 @@ const test_ovmCREATE: TestDefinition = {
],
},
expectedReturnStatus: true,
expectedReturnValue: ZERO_ADDRESS,
expectedReturnValue: constants.AddressZero,
},
],
},
......@@ -737,7 +737,7 @@ const test_ovmCREATE: TestDefinition = {
},
expectedReturnStatus: true,
expectedReturnValue: {
address: ZERO_ADDRESS,
address: constants.AddressZero,
revertData: encodeSolidityError(
'Constructor attempted to deploy unsafe bytecode.'
),
......
/* Internal Imports */
import { constants } from 'ethers'
import {
ExecutionManagerTestRunner,
TestDefinition,
OVM_TX_GAS_LIMIT,
NON_NULL_BYTES32,
ZERO_ADDRESS,
VERIFIED_EMPTY_CONTRACT_HASH,
} from '../../../../helpers'
......@@ -80,8 +80,8 @@ const test_run: TestDefinition = {
timestamp: 0,
queueOrigin: 0,
entrypoint: '$OVM_CALL_HELPER',
origin: ZERO_ADDRESS,
msgSender: ZERO_ADDRESS,
origin: constants.AddressZero,
msgSender: constants.AddressZero,
gasLimit: OVM_TX_GAS_LIMIT,
subSteps: [
{
......@@ -115,8 +115,8 @@ const test_run: TestDefinition = {
// timestamp: 0,
// queueOrigin: 0,
// entrypoint: '$OVM_CALL_HELPER',
// origin: ZERO_ADDRESS,
// msgSender: ZERO_ADDRESS,
// origin: constants.AddressZero,
// msgSender: constants.AddressZero,
// gasLimit: OVM_TX_GAS_LIMIT,
// subSteps: [],
// },
......
......@@ -2,14 +2,13 @@ import '../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Contract, ContractFactory, Signer } from 'ethers'
import { constants, Contract, ContractFactory, Signer } from 'ethers'
import _ from 'lodash'
/* Internal Imports */
import {
DUMMY_ACCOUNTS,
DUMMY_BYTES32,
ZERO_ADDRESS,
EMPTY_ACCOUNT_CODE_HASH,
NON_ZERO_ADDRESS,
NON_NULL_BYTES32,
......@@ -301,7 +300,7 @@ describe('OVM_StateManager gas consumption', () => {
measure('getAccountEthAddress', [DUMMY_ACCOUNT.address], async () => {
await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, {
...DUMMY_ACCOUNT.data,
ethAddress: ZERO_ADDRESS,
ethAddress: constants.AddressZero,
})
})
})
......
......@@ -2,14 +2,13 @@ import { expect } from '../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Contract, ContractFactory, Signer, BigNumber } from 'ethers'
import { Contract, ContractFactory, Signer, BigNumber, constants } from 'ethers'
import _ from 'lodash'
/* Internal Imports */
import {
DUMMY_ACCOUNTS,
DUMMY_BYTES32,
ZERO_ADDRESS,
EMPTY_ACCOUNT_CODE_HASH,
KECCAK_256_NULL,
} from '../../../helpers'
......@@ -304,7 +303,7 @@ describe('OVM_StateManager', () => {
it('should return the zero address', async () => {
expect(
await OVM_StateManager.getAccountEthAddress(DUMMY_ACCOUNTS[0].address)
).to.equal(ZERO_ADDRESS)
).to.equal(constants.AddressZero)
})
})
})
......
......@@ -2,9 +2,9 @@ import { expect } from '../../../setup'
/* External Imports */
import { ethers, waffle } from 'hardhat'
import { ContractFactory, Contract, Wallet } from 'ethers'
import { ContractFactory, Contract, Wallet, constants } from 'ethers'
import { MockContract, smockit } from '@eth-optimism/smock'
import { ZERO_ADDRESS, remove0x } from '@eth-optimism/core-utils'
import { remove0x } from '@eth-optimism/core-utils'
/* Internal Imports */
import { decodeSolidityError } from '../../../helpers'
......@@ -102,7 +102,7 @@ describe('OVM_ProxySequencerEntrypoint', () => {
Helper_PrecompileCaller,
OVM_ProxySequencerEntrypoint,
'init',
[ZERO_ADDRESS, ZERO_ADDRESS]
[constants.AddressZero, constants.AddressZero]
)
const ovmREVERT: any = Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
......
......@@ -3,7 +3,7 @@ import { expect } from '../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { BigNumber, Contract } from 'ethers'
import { BigNumber, constants, Contract } from 'ethers'
import * as rlp from 'rlp'
/* Internal Imports */
......@@ -14,7 +14,6 @@ import {
NULL_BYTES32,
setProxyTarget,
TrieTestGenerator,
ZERO_ADDRESS,
} from '../../../helpers'
import {
MockContract,
......@@ -92,7 +91,7 @@ describe('OVM_StateTransitioner', () => {
describe('proveContractState', () => {
const ovmContractAddress = NON_ZERO_ADDRESS
let ethContractAddress = ZERO_ADDRESS
let ethContractAddress = constants.AddressZero
let account: any
beforeEach(() => {
Mock__OVM_StateManager.smocked.hasAccount.will.return.with(false)
......@@ -229,7 +228,11 @@ describe('OVM_StateTransitioner', () => {
it('should revert', async () => {
await expect(
OVM_StateTransitioner.proveStorageSlot(ZERO_ADDRESS, key, proof)
OVM_StateTransitioner.proveStorageSlot(
constants.AddressZero,
key,
proof
)
).to.be.reverted
})
})
......@@ -259,12 +262,16 @@ describe('OVM_StateTransitioner', () => {
it('should insert the storage slot', async () => {
await expect(
OVM_StateTransitioner.proveStorageSlot(ZERO_ADDRESS, key, proof)
OVM_StateTransitioner.proveStorageSlot(
constants.AddressZero,
key,
proof
)
).to.not.be.reverted
expect(
Mock__OVM_StateManager.smocked.putContractStorage.calls[0]
).to.deep.equal([ZERO_ADDRESS, key, val])
).to.deep.equal([constants.AddressZero, key, val])
})
})
})
......@@ -277,8 +284,8 @@ describe('OVM_StateTransitioner', () => {
timestamp: '0x12',
blockNumber: '0x34',
l1QueueOrigin: '0x00',
l1TxOrigin: ZERO_ADDRESS,
entrypoint: ZERO_ADDRESS,
l1TxOrigin: constants.AddressZero,
entrypoint: constants.AddressZero,
gasLimit: toHexString(gasLimit),
data: '0x1234',
}
......@@ -336,7 +343,7 @@ describe('OVM_StateTransitioner', () => {
balance: 0,
storageRoot: NULL_BYTES32,
codeHash: NULL_BYTES32,
ethAddress: ZERO_ADDRESS,
ethAddress: constants.AddressZero,
isFresh: false,
}
Mock__OVM_StateManager.smocked.hasAccount.will.return.with(false)
......@@ -428,7 +435,7 @@ describe('OVM_StateTransitioner', () => {
Mock__OVM_StateManager.smocked.getAccount.will.return.with({
...account,
ethAddress: ZERO_ADDRESS,
ethAddress: constants.AddressZero,
isFresh: false,
})
......@@ -498,7 +505,7 @@ describe('OVM_StateTransitioner', () => {
Mock__OVM_StateManager.smocked.getAccount.will.return.with({
...account,
storageRoot: storageTest.root,
ethAddress: ZERO_ADDRESS,
ethAddress: constants.AddressZero,
isFresh: false,
})
......
......@@ -2,12 +2,11 @@ import { expect } from '../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { ContractFactory, Contract } from 'ethers'
import { ContractFactory, Contract, constants } from 'ethers'
/* Internal Imports */
import {
makeAddressManager,
ZERO_ADDRESS,
DUMMY_OVM_TRANSACTIONS,
NULL_BYTES32,
hashTransaction,
......@@ -38,7 +37,10 @@ describe('OVM_StateTransitionerFactory', () => {
describe('create', () => {
describe('when the sender is not the OVM_FraudVerifier', () => {
before(async () => {
await AddressManager.setAddress('OVM_FraudVerifier', ZERO_ADDRESS)
await AddressManager.setAddress(
'OVM_FraudVerifier',
constants.AddressZero
)
})
it('should revert', async () => {
......
......@@ -3,12 +3,9 @@ import { expect } from '../../../setup'
/* External Imports */
import { ethers } from 'hardhat'
import { Contract, Signer } from 'ethers'
import { Contract, Signer, constants } from 'ethers'
import { fromHexString, toHexString } from '@eth-optimism/core-utils'
/* Internal Imports */
import { ZERO_ADDRESS } from '../../../helpers'
// Leaving this here for now. If it's sufficiently useful we can throw it in core-utils.
const getHexSlice = (
input: Buffer | string,
......@@ -33,7 +30,7 @@ describe('Lib_EthUtils', () => {
describe('getCode(address,uint256,uint256)', () => {
describe('when the contract does not exist', () => {
const address = ZERO_ADDRESS
const address = constants.AddressZero
describe('when offset = 0', () => {
const offset = 0
......
/* External Imports */
import { ethers } from 'hardhat'
import { Wallet } from 'ethers'
import { constants, Wallet } from 'ethers'
/* Internal Imports */
import { remove0x, fromHexString } from '@eth-optimism/core-utils'
import { ZERO_ADDRESS } from '../constants'
export interface EIP155Transaction {
nonce: number
......@@ -47,7 +46,7 @@ export const encodeCompactTransaction = (transaction: any): string => {
const compressedGasPrice: any = transaction.gasPrice / 1000000
const gasPrice = ethers.utils.zeroPad(compressedGasPrice, 3)
const to = !transaction.to.length
? fromHexString(ZERO_ADDRESS)
? fromHexString(constants.AddressZero)
: fromHexString(transaction.to)
const data = fromHexString(transaction.data)
......
......@@ -21,7 +21,6 @@ export const NULL_BYTES32 =
'0x0000000000000000000000000000000000000000000000000000000000000000'
export const NON_NULL_BYTES32 =
'0x1111111111111111111111111111111111111111111111111111111111111111'
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
export const NON_ZERO_ADDRESS = '0x1111111111111111111111111111111111111111'
export const VERIFIED_EMPTY_CONTRACT_HASH =
......
/* External Imports */
import { BigNumber } from 'ethers'
import { BigNumber, constants } from 'ethers'
/* Internal Imports */
import { DUMMY_BYTES32 } from './bytes32'
import { ZERO_ADDRESS, NON_ZERO_ADDRESS } from '../constants'
import { NON_ZERO_ADDRESS } from '../constants'
import { OVMAccount } from '../types/ovm-types'
export const DUMMY_ACCOUNTS: Array<{
......@@ -17,7 +17,7 @@ export const DUMMY_ACCOUNTS: Array<{
balance: BigNumber.from(456),
storageRoot: DUMMY_BYTES32[0],
codeHash: DUMMY_BYTES32[1],
ethAddress: ZERO_ADDRESS,
ethAddress: constants.AddressZero,
},
},
{
......
import { ZERO_ADDRESS, NULL_BYTES32 } from '../constants'
import { ethers } from 'ethers'
import { NULL_BYTES32 } from '../constants'
import { constants, ethers } from 'ethers'
export interface Transaction {
timestamp: number
......@@ -18,8 +18,8 @@ export const DUMMY_OVM_TRANSACTIONS: Array<Transaction> = [
timestamp: i,
blockNumber: 0,
l1QueueOrigin: 0,
l1TxOrigin: ZERO_ADDRESS,
entrypoint: ZERO_ADDRESS,
l1TxOrigin: constants.AddressZero,
entrypoint: constants.AddressZero,
gasLimit: 0,
data: NULL_BYTES32,
}
......
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