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