Commit 6250cb02 authored by C's avatar C Committed by GitHub

replaced NULL_BYTES32 (#340)

Co-authored-by: default avatarsmartcontracts <kelvinfichter@gmail.com>
parent adb16d5f
...@@ -12,7 +12,6 @@ import { ...@@ -12,7 +12,6 @@ import {
setProxyTarget, setProxyTarget,
NON_NULL_BYTES32, NON_NULL_BYTES32,
NON_ZERO_ADDRESS, NON_ZERO_ADDRESS,
NULL_BYTES32,
DUMMY_BATCH_HEADERS, DUMMY_BATCH_HEADERS,
DUMMY_BATCH_PROOFS, DUMMY_BATCH_PROOFS,
TrieTestGenerator, TrieTestGenerator,
...@@ -231,7 +230,7 @@ describe('OVM_L1CrossDomainMessenger', () => { ...@@ -231,7 +230,7 @@ describe('OVM_L1CrossDomainMessenger', () => {
) )
const proof1 = { const proof1 = {
stateRoot: NULL_BYTES32, stateRoot: ethers.constants.HashZero,
stateRootBatchHeader: DUMMY_BATCH_HEADERS[0], stateRootBatchHeader: DUMMY_BATCH_HEADERS[0],
stateRootProof: DUMMY_BATCH_PROOFS[0], stateRootProof: DUMMY_BATCH_PROOFS[0],
stateTrieWitness: '0x', stateTrieWitness: '0x',
...@@ -255,7 +254,7 @@ describe('OVM_L1CrossDomainMessenger', () => { ...@@ -255,7 +254,7 @@ describe('OVM_L1CrossDomainMessenger', () => {
) )
const proof1 = { const proof1 = {
stateRoot: NULL_BYTES32, stateRoot: ethers.constants.HashZero,
stateRootBatchHeader: DUMMY_BATCH_HEADERS[0], stateRootBatchHeader: DUMMY_BATCH_HEADERS[0],
stateRootProof: DUMMY_BATCH_PROOFS[0], stateRootProof: DUMMY_BATCH_PROOFS[0],
stateTrieWitness: '0x', stateTrieWitness: '0x',
......
...@@ -11,7 +11,6 @@ import { ...@@ -11,7 +11,6 @@ import {
setProxyTarget, setProxyTarget,
NON_NULL_BYTES32, NON_NULL_BYTES32,
getEthTime, getEthTime,
NULL_BYTES32,
increaseEthTime, increaseEthTime,
} from '../../../helpers' } from '../../../helpers'
...@@ -195,7 +194,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -195,7 +194,7 @@ describe('OVM_StateCommitmentChain', () => {
batchRoot: NON_NULL_BYTES32, batchRoot: NON_NULL_BYTES32,
batchSize: 1, batchSize: 1,
prevTotalElements: 0, prevTotalElements: 0,
extraData: NULL_BYTES32, extraData: ethers.constants.HashZero,
} }
beforeEach(async () => { beforeEach(async () => {
......
/* Internal Imports */ /* Internal Imports */
import { constants } from 'ethers' import { constants, ethers } from 'ethers'
import { import {
ExecutionManagerTestRunner, ExecutionManagerTestRunner,
TestDefinition, TestDefinition,
OVM_TX_GAS_LIMIT, OVM_TX_GAS_LIMIT,
NULL_BYTES32,
NON_NULL_BYTES32, NON_NULL_BYTES32,
REVERT_FLAGS, REVERT_FLAGS,
DUMMY_BYTECODE, DUMMY_BYTECODE,
...@@ -80,8 +79,8 @@ const test_ovmCREATE: TestDefinition = { ...@@ -80,8 +79,8 @@ const test_ovmCREATE: TestDefinition = {
}, },
contractStorage: { contractStorage: {
$DUMMY_OVM_ADDRESS_2: { $DUMMY_OVM_ADDRESS_2: {
[NULL_BYTES32]: getStorageXOR(NULL_BYTES32), [ethers.constants.HashZero]: getStorageXOR(ethers.constants.HashZero),
[NON_NULL_BYTES32]: getStorageXOR(NULL_BYTES32), [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero),
}, },
}, },
verifiedContractStorage: { verifiedContractStorage: {
...@@ -89,7 +88,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -89,7 +88,7 @@ const test_ovmCREATE: TestDefinition = {
[NON_NULL_BYTES32]: true, [NON_NULL_BYTES32]: true,
}, },
$DUMMY_OVM_ADDRESS_2: { $DUMMY_OVM_ADDRESS_2: {
[NULL_BYTES32]: true, [ethers.constants.HashZero]: true,
[NON_NULL_BYTES32]: true, [NON_NULL_BYTES32]: true,
}, },
}, },
...@@ -251,7 +250,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -251,7 +250,7 @@ const test_ovmCREATE: TestDefinition = {
address: CREATED_CONTRACT_1, address: CREATED_CONTRACT_1,
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: NULL_BYTES32, expectedReturnValue: ethers.constants.HashZero,
}, },
], ],
}, },
...@@ -322,7 +321,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -322,7 +321,7 @@ const test_ovmCREATE: TestDefinition = {
key: NON_NULL_BYTES32, key: NON_NULL_BYTES32,
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: NULL_BYTES32, expectedReturnValue: ethers.constants.HashZero,
}, },
], ],
}, },
...@@ -350,7 +349,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -350,7 +349,7 @@ const test_ovmCREATE: TestDefinition = {
key: NON_NULL_BYTES32, key: NON_NULL_BYTES32,
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: NULL_BYTES32, expectedReturnValue: ethers.constants.HashZero,
}, },
], ],
}, },
...@@ -431,10 +430,10 @@ const test_ovmCREATE: TestDefinition = { ...@@ -431,10 +430,10 @@ const test_ovmCREATE: TestDefinition = {
{ {
functionName: 'ovmSLOAD', functionName: 'ovmSLOAD',
functionParams: { functionParams: {
key: NULL_BYTES32, key: ethers.constants.HashZero,
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: NULL_BYTES32, expectedReturnValue: ethers.constants.HashZero,
}, },
], ],
}, },
...@@ -773,10 +772,12 @@ const test_ovmCREATE: TestDefinition = { ...@@ -773,10 +772,12 @@ const test_ovmCREATE: TestDefinition = {
), ),
// allowArbitraryDeployment? false // allowArbitraryDeployment? false
'0x0000000000000000000000000000000000000000000000000000000000000012': getStorageXOR( '0x0000000000000000000000000000000000000000000000000000000000000012': getStorageXOR(
NULL_BYTES32 ethers.constants.HashZero
), ),
// non-whitelisted deployer is whitelisted? false // non-whitelisted deployer is whitelisted? false
[NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR(NULL_BYTES32), [NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR(
ethers.constants.HashZero
),
// whitelisted deployer is whitelisted? true // whitelisted deployer is whitelisted? true
[WHITELISTED_DEPLOYER_KEY]: getStorageXOR( [WHITELISTED_DEPLOYER_KEY]: getStorageXOR(
'0x' + '00'.repeat(31) + '01' '0x' + '00'.repeat(31) + '01'
...@@ -859,7 +860,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -859,7 +860,7 @@ const test_ovmCREATE: TestDefinition = {
{ {
functionName: 'ovmCREATE2', functionName: 'ovmCREATE2',
functionParams: { functionParams: {
salt: NULL_BYTES32, salt: ethers.constants.HashZero,
bytecode: '0x', bytecode: '0x',
}, },
expectedReturnStatus: false, expectedReturnStatus: false,
...@@ -909,7 +910,9 @@ const test_ovmCREATE: TestDefinition = { ...@@ -909,7 +910,9 @@ const test_ovmCREATE: TestDefinition = {
'0x' + '00'.repeat(31) + '01' '0x' + '00'.repeat(31) + '01'
), ),
// non-whitelisted deployer is whitelisted? false // non-whitelisted deployer is whitelisted? false
[NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR(NULL_BYTES32), [NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR(
ethers.constants.HashZero
),
// whitelisted deployer is whitelisted? true // whitelisted deployer is whitelisted? true
[WHITELISTED_DEPLOYER_KEY]: getStorageXOR( [WHITELISTED_DEPLOYER_KEY]: getStorageXOR(
'0x' + '00'.repeat(31) + '01' '0x' + '00'.repeat(31) + '01'
......
/* External Imports */
import { ethers } from 'ethers'
/* Internal Imports */ /* Internal Imports */
import { import {
ExecutionManagerTestRunner, ExecutionManagerTestRunner,
TestDefinition, TestDefinition,
OVM_TX_GAS_LIMIT, OVM_TX_GAS_LIMIT,
NULL_BYTES32,
NON_NULL_BYTES32, NON_NULL_BYTES32,
getStorageXOR, getStorageXOR,
} from '../../../../helpers' } from '../../../../helpers'
...@@ -32,7 +34,7 @@ const test_ovmSLOAD: TestDefinition = { ...@@ -32,7 +34,7 @@ const test_ovmSLOAD: TestDefinition = {
}, },
contractStorage: { contractStorage: {
$DUMMY_OVM_ADDRESS_1: { $DUMMY_OVM_ADDRESS_1: {
[NON_NULL_BYTES32]: getStorageXOR(NULL_BYTES32), [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero),
}, },
}, },
verifiedContractStorage: { verifiedContractStorage: {
...@@ -58,7 +60,7 @@ const test_ovmSLOAD: TestDefinition = { ...@@ -58,7 +60,7 @@ const test_ovmSLOAD: TestDefinition = {
key: NON_NULL_BYTES32, key: NON_NULL_BYTES32,
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: NULL_BYTES32, expectedReturnValue: ethers.constants.HashZero,
}, },
], ],
}, },
......
/* External Imports */
import { ethers } from 'ethers'
/* Internal Imports */ /* Internal Imports */
import { import {
ExecutionManagerTestRunner, ExecutionManagerTestRunner,
TestDefinition, TestDefinition,
OVM_TX_GAS_LIMIT, OVM_TX_GAS_LIMIT,
NULL_BYTES32,
NON_NULL_BYTES32, NON_NULL_BYTES32,
REVERT_FLAGS, REVERT_FLAGS,
DUMMY_BYTECODE, DUMMY_BYTECODE,
...@@ -38,10 +40,10 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -38,10 +40,10 @@ const test_ovmSTATICCALL: TestDefinition = {
}, },
contractStorage: { contractStorage: {
$DUMMY_OVM_ADDRESS_1: { $DUMMY_OVM_ADDRESS_1: {
[NON_NULL_BYTES32]: getStorageXOR(NULL_BYTES32), [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero),
}, },
$DUMMY_OVM_ADDRESS_3: { $DUMMY_OVM_ADDRESS_3: {
[NON_NULL_BYTES32]: getStorageXOR(NULL_BYTES32), [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero),
}, },
}, },
verifiedContractStorage: { verifiedContractStorage: {
...@@ -67,8 +69,8 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -67,8 +69,8 @@ const test_ovmSTATICCALL: TestDefinition = {
{ {
functionName: 'ovmSSTORE', functionName: 'ovmSSTORE',
functionParams: { functionParams: {
key: NULL_BYTES32, key: ethers.constants.HashZero,
value: NULL_BYTES32, value: ethers.constants.HashZero,
}, },
expectedReturnStatus: false, expectedReturnStatus: false,
expectedReturnValue: { expectedReturnValue: {
...@@ -97,7 +99,7 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -97,7 +99,7 @@ const test_ovmSTATICCALL: TestDefinition = {
key: NON_NULL_BYTES32, key: NON_NULL_BYTES32,
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: NULL_BYTES32, expectedReturnValue: ethers.constants.HashZero,
}, },
], ],
}, },
...@@ -214,8 +216,8 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -214,8 +216,8 @@ const test_ovmSTATICCALL: TestDefinition = {
{ {
functionName: 'ovmSSTORE', functionName: 'ovmSSTORE',
functionParams: { functionParams: {
key: NULL_BYTES32, key: ethers.constants.HashZero,
value: NULL_BYTES32, value: ethers.constants.HashZero,
}, },
expectedReturnStatus: false, expectedReturnStatus: false,
expectedReturnValue: { expectedReturnValue: {
...@@ -265,7 +267,7 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -265,7 +267,7 @@ const test_ovmSTATICCALL: TestDefinition = {
key: NON_NULL_BYTES32, key: NON_NULL_BYTES32,
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: NULL_BYTES32, expectedReturnValue: ethers.constants.HashZero,
}, },
], ],
}, },
......
...@@ -13,7 +13,6 @@ import { ...@@ -13,7 +13,6 @@ import {
DUMMY_BATCH_PROOFS, DUMMY_BATCH_PROOFS,
DUMMY_OVM_TRANSACTIONS, DUMMY_OVM_TRANSACTIONS,
NON_NULL_BYTES32, NON_NULL_BYTES32,
NULL_BYTES32,
hashTransaction, hashTransaction,
} from '../../../helpers' } from '../../../helpers'
...@@ -23,7 +22,7 @@ const DUMMY_TX_CHAIN_ELEMENTS = [...Array(10).keys()].map((i) => { ...@@ -23,7 +22,7 @@ const DUMMY_TX_CHAIN_ELEMENTS = [...Array(10).keys()].map((i) => {
queueIndex: BigNumber.from(0), queueIndex: BigNumber.from(0),
timestamp: BigNumber.from(i), timestamp: BigNumber.from(i),
blockNumber: BigNumber.from(0), blockNumber: BigNumber.from(0),
txData: NULL_BYTES32, txData: ethers.constants.HashZero,
} }
}) })
...@@ -32,7 +31,7 @@ const DUMMY_HASH = hashTransaction(DUMMY_OVM_TRANSACTIONS[0]) ...@@ -32,7 +31,7 @@ const DUMMY_HASH = hashTransaction(DUMMY_OVM_TRANSACTIONS[0])
const DUMMY_BATCH_PROOFS_WITH_INDEX = [ const DUMMY_BATCH_PROOFS_WITH_INDEX = [
{ {
index: 11, index: 11,
siblings: [NULL_BYTES32], siblings: [ethers.constants.HashZero],
}, },
] ]
...@@ -122,7 +121,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -122,7 +121,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_FraudVerifier.initializeFraudVerification( OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[0], DUMMY_OVM_TRANSACTIONS[0],
...@@ -151,7 +150,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -151,7 +150,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_FraudVerifier.initializeFraudVerification( OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[0], DUMMY_OVM_TRANSACTIONS[0],
...@@ -173,7 +172,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -173,7 +172,7 @@ describe('OVM_FraudVerifier', () => {
it('should deploy a new state transitioner', async () => { it('should deploy a new state transitioner', async () => {
await expect( await expect(
OVM_FraudVerifier.initializeFraudVerification( OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[0], DUMMY_OVM_TRANSACTIONS[0],
...@@ -188,7 +187,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -188,7 +187,7 @@ describe('OVM_FraudVerifier', () => {
expect( expect(
await OVM_FraudVerifier.getStateTransitioner( await OVM_FraudVerifier.getStateTransitioner(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_HASH DUMMY_HASH
) )
).to.equal(Mock__OVM_StateTransitioner.address) ).to.equal(Mock__OVM_StateTransitioner.address)
...@@ -197,7 +196,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -197,7 +196,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert when provided with a incorrect transaction root global index', async () => { it('should revert when provided with a incorrect transaction root global index', async () => {
await expect( await expect(
OVM_FraudVerifier.initializeFraudVerification( OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[0], DUMMY_OVM_TRANSACTIONS[0],
...@@ -223,7 +222,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -223,7 +222,7 @@ describe('OVM_FraudVerifier', () => {
) )
await OVM_FraudVerifier.initializeFraudVerification( await OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[0], DUMMY_OVM_TRANSACTIONS[0],
...@@ -244,7 +243,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -244,7 +243,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_FraudVerifier.finalizeFraudVerification( OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
...@@ -272,7 +271,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -272,7 +271,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_FraudVerifier.finalizeFraudVerification( OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
...@@ -302,7 +301,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -302,7 +301,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_FraudVerifier.finalizeFraudVerification( OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
...@@ -333,7 +332,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -333,7 +332,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_FraudVerifier.finalizeFraudVerification( OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
...@@ -362,7 +361,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -362,7 +361,7 @@ describe('OVM_FraudVerifier', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_FraudVerifier.finalizeFraudVerification( OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
...@@ -379,13 +378,13 @@ describe('OVM_FraudVerifier', () => { ...@@ -379,13 +378,13 @@ describe('OVM_FraudVerifier', () => {
describe('when the provided post-state root differs from the computed one', () => { describe('when the provided post-state root differs from the computed one', () => {
before(() => { before(() => {
Mock__OVM_StateTransitioner.smocked.getPostStateRoot.will.return.with( Mock__OVM_StateTransitioner.smocked.getPostStateRoot.will.return.with(
NULL_BYTES32 ethers.constants.HashZero
) )
}) })
it('should succeed and attempt to delete a state batch', async () => { it('should succeed and attempt to delete a state batch', async () => {
await OVM_FraudVerifier.finalizeFraudVerification( await OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
...@@ -423,16 +422,18 @@ describe('OVM_FraudVerifier', () => { ...@@ -423,16 +422,18 @@ describe('OVM_FraudVerifier', () => {
) )
Mock__OVM_StateTransitioner.smocked.getPostStateRoot.will.return.with( Mock__OVM_StateTransitioner.smocked.getPostStateRoot.will.return.with(
NULL_BYTES32 ethers.constants.HashZero
) )
state2.smocked.getPostStateRoot.will.return.with(NULL_BYTES32) state2.smocked.getPostStateRoot.will.return.with(
ethers.constants.HashZero
)
}) })
it('creates multiple state transitioners per tx hash', async () => { it('creates multiple state transitioners per tx hash', async () => {
await expect( await expect(
OVM_FraudVerifier.initializeFraudVerification( OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[1], DUMMY_OVM_TRANSACTIONS[1],
...@@ -447,13 +448,13 @@ describe('OVM_FraudVerifier', () => { ...@@ -447,13 +448,13 @@ describe('OVM_FraudVerifier', () => {
expect( expect(
await OVM_FraudVerifier.getStateTransitioner( await OVM_FraudVerifier.getStateTransitioner(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_HASH DUMMY_HASH
) )
).to.equal(Mock__OVM_StateTransitioner.address) ).to.equal(Mock__OVM_StateTransitioner.address)
expect( expect(
await OVM_FraudVerifier.getStateTransitioner( await OVM_FraudVerifier.getStateTransitioner(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_HASH_2 DUMMY_HASH_2
) )
).to.equal(state2.address) ).to.equal(state2.address)
...@@ -468,7 +469,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -468,7 +469,7 @@ describe('OVM_FraudVerifier', () => {
it.skip('Case 1: allows proving fraud on the same pre-state root twice', async () => { it.skip('Case 1: allows proving fraud on the same pre-state root twice', async () => {
// finalize previous fraud // finalize previous fraud
await OVM_FraudVerifier.finalizeFraudVerification( await OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
...@@ -479,7 +480,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -479,7 +480,7 @@ describe('OVM_FraudVerifier', () => {
// start new fraud // start new fraud
await OVM_FraudVerifier.initializeFraudVerification( await OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[1], DUMMY_OVM_TRANSACTIONS[1],
...@@ -493,7 +494,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -493,7 +494,7 @@ describe('OVM_FraudVerifier', () => {
// finalize it as well // finalize it as well
await OVM_FraudVerifier.finalizeFraudVerification( await OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH_2, DUMMY_HASH_2,
...@@ -516,7 +517,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -516,7 +517,7 @@ describe('OVM_FraudVerifier', () => {
it.skip('Case 2: does not get blocked by the first transitioner', async () => { it.skip('Case 2: does not get blocked by the first transitioner', async () => {
// start new fraud // start new fraud
await OVM_FraudVerifier.initializeFraudVerification( await OVM_FraudVerifier.initializeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_OVM_TRANSACTIONS[1], DUMMY_OVM_TRANSACTIONS[1],
...@@ -530,7 +531,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -530,7 +531,7 @@ describe('OVM_FraudVerifier', () => {
// finalize the new fraud first // finalize the new fraud first
await OVM_FraudVerifier.finalizeFraudVerification( await OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH_2, DUMMY_HASH_2,
...@@ -550,7 +551,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -550,7 +551,7 @@ describe('OVM_FraudVerifier', () => {
// finalize previous fraud // finalize previous fraud
await OVM_FraudVerifier.finalizeFraudVerification( await OVM_FraudVerifier.finalizeFraudVerification(
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_BATCH_HEADERS[0], DUMMY_BATCH_HEADERS[0],
DUMMY_BATCH_PROOFS[0], DUMMY_BATCH_PROOFS[0],
DUMMY_HASH, DUMMY_HASH,
......
...@@ -11,7 +11,6 @@ import { ...@@ -11,7 +11,6 @@ import {
makeAddressManager, makeAddressManager,
NON_NULL_BYTES32, NON_NULL_BYTES32,
NON_ZERO_ADDRESS, NON_ZERO_ADDRESS,
NULL_BYTES32,
setProxyTarget, setProxyTarget,
TrieTestGenerator, TrieTestGenerator,
} from '../../../helpers' } from '../../../helpers'
...@@ -84,8 +83,8 @@ describe('OVM_StateTransitioner', () => { ...@@ -84,8 +83,8 @@ describe('OVM_StateTransitioner', () => {
OVM_StateTransitioner = await Factory__OVM_StateTransitioner.deploy( OVM_StateTransitioner = await Factory__OVM_StateTransitioner.deploy(
AddressManager.address, AddressManager.address,
0, 0,
NULL_BYTES32, ethers.constants.HashZero,
NULL_BYTES32 ethers.constants.HashZero
) )
}) })
...@@ -99,8 +98,8 @@ describe('OVM_StateTransitioner', () => { ...@@ -99,8 +98,8 @@ describe('OVM_StateTransitioner', () => {
account = { account = {
nonce: 0, nonce: 0,
balance: 0, balance: 0,
storageRoot: NULL_BYTES32, storageRoot: ethers.constants.HashZero,
codeHash: NULL_BYTES32, codeHash: ethers.constants.HashZero,
} }
}) })
...@@ -147,7 +146,7 @@ describe('OVM_StateTransitioner', () => { ...@@ -147,7 +146,7 @@ describe('OVM_StateTransitioner', () => {
AddressManager.address, AddressManager.address,
0, 0,
test.accountTrieRoot, test.accountTrieRoot,
NULL_BYTES32 ethers.constants.HashZero
) )
}) })
...@@ -341,8 +340,8 @@ describe('OVM_StateTransitioner', () => { ...@@ -341,8 +340,8 @@ describe('OVM_StateTransitioner', () => {
account = { account = {
nonce: 0, nonce: 0,
balance: 0, balance: 0,
storageRoot: NULL_BYTES32, storageRoot: ethers.constants.HashZero,
codeHash: NULL_BYTES32, codeHash: ethers.constants.HashZero,
ethAddress: constants.AddressZero, ethAddress: constants.AddressZero,
isFresh: false, isFresh: false,
} }
...@@ -429,8 +428,8 @@ describe('OVM_StateTransitioner', () => { ...@@ -429,8 +428,8 @@ describe('OVM_StateTransitioner', () => {
account = { account = {
nonce: 0, nonce: 0,
balance: 0, balance: 0,
storageRoot: NULL_BYTES32, storageRoot: ethers.constants.HashZero,
codeHash: NULL_BYTES32, codeHash: ethers.constants.HashZero,
} }
Mock__OVM_StateManager.smocked.getAccount.will.return.with({ Mock__OVM_StateManager.smocked.getAccount.will.return.with({
......
...@@ -8,7 +8,6 @@ import { ContractFactory, Contract, constants } from 'ethers' ...@@ -8,7 +8,6 @@ import { ContractFactory, Contract, constants } from 'ethers'
import { import {
makeAddressManager, makeAddressManager,
DUMMY_OVM_TRANSACTIONS, DUMMY_OVM_TRANSACTIONS,
NULL_BYTES32,
hashTransaction, hashTransaction,
} from '../../../helpers' } from '../../../helpers'
...@@ -47,8 +46,8 @@ describe('OVM_StateTransitionerFactory', () => { ...@@ -47,8 +46,8 @@ describe('OVM_StateTransitionerFactory', () => {
await expect( await expect(
OVM_StateTransitionerFactory.create( OVM_StateTransitionerFactory.create(
AddressManager.address, AddressManager.address,
NULL_BYTES32, ethers.constants.HashZero,
NULL_BYTES32, ethers.constants.HashZero,
DUMMY_HASH DUMMY_HASH
) )
).to.be.revertedWith( ).to.be.revertedWith(
......
...@@ -7,7 +7,7 @@ import { MerkleTree } from 'merkletreejs' ...@@ -7,7 +7,7 @@ import { MerkleTree } from 'merkletreejs'
import { fromHexString, toHexString } from '@eth-optimism/core-utils' import { fromHexString, toHexString } from '@eth-optimism/core-utils'
/* Internal Imports */ /* Internal Imports */
import { NON_NULL_BYTES32, NULL_BYTES32 } from '../../../helpers' import { NON_NULL_BYTES32 } from '../../../helpers'
const NODE_COUNTS = [ const NODE_COUNTS = [
2, 2,
...@@ -100,7 +100,13 @@ describe('Lib_MerkleTree', () => { ...@@ -100,7 +100,13 @@ describe('Lib_MerkleTree', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
Lib_MerkleTree.verify(NULL_BYTES32, NULL_BYTES32, 0, [], totalLeaves) Lib_MerkleTree.verify(
ethers.constants.HashZero,
ethers.constants.HashZero,
0,
[],
totalLeaves
)
).to.be.revertedWith( ).to.be.revertedWith(
'Lib_MerkleTree: Total leaves must be greater than zero.' 'Lib_MerkleTree: Total leaves must be greater than zero.'
) )
...@@ -114,8 +120,8 @@ describe('Lib_MerkleTree', () => { ...@@ -114,8 +120,8 @@ describe('Lib_MerkleTree', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
Lib_MerkleTree.verify( Lib_MerkleTree.verify(
NULL_BYTES32, ethers.constants.HashZero,
NULL_BYTES32, ethers.constants.HashZero,
index, index,
[], [],
totalLeaves totalLeaves
...@@ -126,13 +132,13 @@ describe('Lib_MerkleTree', () => { ...@@ -126,13 +132,13 @@ describe('Lib_MerkleTree', () => {
describe('when total siblings does not match provided total leaves', () => { describe('when total siblings does not match provided total leaves', () => {
const totalLeaves = 8 const totalLeaves = 8
const siblings = [NULL_BYTES32, NULL_BYTES32] const siblings = [ethers.constants.HashZero, ethers.constants.HashZero]
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
Lib_MerkleTree.verify( Lib_MerkleTree.verify(
NULL_BYTES32, ethers.constants.HashZero,
NULL_BYTES32, ethers.constants.HashZero,
0, 0,
siblings, siblings,
totalLeaves totalLeaves
......
...@@ -17,8 +17,6 @@ export const RUN_OVM_TEST_GAS = 20_000_000 ...@@ -17,8 +17,6 @@ export const RUN_OVM_TEST_GAS = 20_000_000
export const FORCE_INCLUSION_PERIOD_SECONDS = 600 export const FORCE_INCLUSION_PERIOD_SECONDS = 600
export const FORCE_INCLUSION_PERIOD_BLOCKS = 600 / 12 export const FORCE_INCLUSION_PERIOD_BLOCKS = 600 / 12
export const NULL_BYTES32 =
'0x0000000000000000000000000000000000000000000000000000000000000000'
export const NON_NULL_BYTES32 = export const NON_NULL_BYTES32 =
'0x1111111111111111111111111111111111111111111111111111111111111111' '0x1111111111111111111111111111111111111111111111111111111111111111'
export const NON_ZERO_ADDRESS = '0x1111111111111111111111111111111111111111' export const NON_ZERO_ADDRESS = '0x1111111111111111111111111111111111111111'
......
import { NULL_BYTES32, NON_ZERO_ADDRESS } from '../constants' import { NON_ZERO_ADDRESS } from '../constants'
import { ethers } from 'hardhat' import { ethers } from 'hardhat'
export const DUMMY_BATCH_HEADERS = [ export const DUMMY_BATCH_HEADERS = [
{ {
batchIndex: 0, batchIndex: 0,
batchRoot: NULL_BYTES32, batchRoot: ethers.constants.HashZero,
batchSize: 0, batchSize: 0,
prevTotalElements: 0, prevTotalElements: 0,
extraData: ethers.utils.defaultAbiCoder.encode( extraData: ethers.utils.defaultAbiCoder.encode(
['uint256', 'address'], ['uint256', 'address'],
[NULL_BYTES32, NON_ZERO_ADDRESS] [ethers.constants.HashZero, NON_ZERO_ADDRESS]
), ),
}, },
{ {
batchIndex: 1, batchIndex: 1,
batchRoot: NULL_BYTES32, batchRoot: ethers.constants.HashZero,
batchSize: 0, batchSize: 0,
prevTotalElements: 0, prevTotalElements: 0,
extraData: ethers.utils.defaultAbiCoder.encode( extraData: ethers.utils.defaultAbiCoder.encode(
['uint256', 'address'], ['uint256', 'address'],
[NULL_BYTES32, NON_ZERO_ADDRESS] [ethers.constants.HashZero, NON_ZERO_ADDRESS]
), ),
}, },
] ]
...@@ -27,10 +27,10 @@ export const DUMMY_BATCH_HEADERS = [ ...@@ -27,10 +27,10 @@ export const DUMMY_BATCH_HEADERS = [
export const DUMMY_BATCH_PROOFS = [ export const DUMMY_BATCH_PROOFS = [
{ {
index: 0, index: 0,
siblings: [NULL_BYTES32], siblings: [ethers.constants.HashZero],
}, },
{ {
index: 1, index: 1,
siblings: [NULL_BYTES32], siblings: [ethers.constants.HashZero],
}, },
] ]
import { NULL_BYTES32 } from '../constants'
import { constants, ethers } from 'ethers' import { constants, ethers } from 'ethers'
export interface Transaction { export interface Transaction {
...@@ -21,7 +20,7 @@ export const DUMMY_OVM_TRANSACTIONS: Array<Transaction> = [ ...@@ -21,7 +20,7 @@ export const DUMMY_OVM_TRANSACTIONS: Array<Transaction> = [
l1TxOrigin: constants.AddressZero, l1TxOrigin: constants.AddressZero,
entrypoint: constants.AddressZero, entrypoint: constants.AddressZero,
gasLimit: 0, gasLimit: 0,
data: NULL_BYTES32, data: ethers.constants.HashZero,
} }
}) })
......
...@@ -35,7 +35,6 @@ import { ...@@ -35,7 +35,6 @@ import {
OVM_TX_GAS_LIMIT, OVM_TX_GAS_LIMIT,
RUN_OVM_TEST_GAS, RUN_OVM_TEST_GAS,
NON_NULL_BYTES32, NON_NULL_BYTES32,
NULL_BYTES32,
} from '../constants' } from '../constants'
import { getStorageXOR } from '../' import { getStorageXOR } from '../'
import { UNSAFE_BYTECODE } from '../dummy' import { UNSAFE_BYTECODE } from '../dummy'
...@@ -71,7 +70,7 @@ export class ExecutionManagerTestRunner { ...@@ -71,7 +70,7 @@ export class ExecutionManagerTestRunner {
contractStorage: { contractStorage: {
['0x4200000000000000000000000000000000000002']: { ['0x4200000000000000000000000000000000000002']: {
'0x0000000000000000000000000000000000000000000000000000000000000010': getStorageXOR( '0x0000000000000000000000000000000000000000000000000000000000000010': getStorageXOR(
NULL_BYTES32 ethers.constants.HashZero
), ),
}, },
}, },
......
...@@ -3,9 +3,7 @@ import * as rlp from 'rlp' ...@@ -3,9 +3,7 @@ import * as rlp from 'rlp'
import { default as seedbytes } from 'random-bytes-seed' import { default as seedbytes } from 'random-bytes-seed'
import { SecureTrie, BaseTrie } from 'merkle-patricia-tree' import { SecureTrie, BaseTrie } from 'merkle-patricia-tree'
import { fromHexString, toHexString } from '@eth-optimism/core-utils' import { fromHexString, toHexString } from '@eth-optimism/core-utils'
import { ethers } from 'ethers'
/* Internal Imports */
import { NULL_BYTES32 } from '../constants'
export interface TrieNode { export interface TrieNode {
key: string key: string
...@@ -48,8 +46,8 @@ const rlpEncodeAccount = (account: EthereumAccount): string => { ...@@ -48,8 +46,8 @@ const rlpEncodeAccount = (account: EthereumAccount): string => {
rlp.encode([ rlp.encode([
account.nonce, account.nonce,
account.balance, account.balance,
account.storageRoot || NULL_BYTES32, account.storageRoot || ethers.constants.HashZero,
account.codeHash || NULL_BYTES32, account.codeHash || ethers.constants.HashZero,
]) ])
) )
} }
...@@ -59,8 +57,12 @@ const rlpDecodeAccount = (encoded: string): EthereumAccount => { ...@@ -59,8 +57,12 @@ const rlpDecodeAccount = (encoded: string): EthereumAccount => {
return { return {
nonce: decoded[0].length ? parseInt(decoded[0], 16) : 0, nonce: decoded[0].length ? parseInt(decoded[0], 16) : 0,
balance: decoded[1].length ? parseInt(decoded[1], 16) : 0, balance: decoded[1].length ? parseInt(decoded[1], 16) : 0,
storageRoot: decoded[2].length ? toHexString(decoded[2]) : NULL_BYTES32, storageRoot: decoded[2].length
codeHash: decoded[3].length ? toHexString(decoded[3]) : NULL_BYTES32, ? toHexString(decoded[2])
: ethers.constants.HashZero,
codeHash: decoded[3].length
? toHexString(decoded[3])
: ethers.constants.HashZero,
} }
} }
......
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