Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract StateManager from ExecutionManager #132

Merged
merged 16 commits into from
Jun 9, 2020
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
22 changes: 14 additions & 8 deletions packages/ovm/test/contracts/execution-manager.executeCall.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {

import {
ExecutionManagerContractDefinition as ExecutionManager,
FullStateManagerContractDefinition as StateManager,
TestDummyContractDefinition as DummyContract,
} from '@eth-optimism/rollup-contracts'

Expand Down Expand Up @@ -46,6 +47,7 @@ describe('Execution Manager -- Call opcodes', () => {
const [wallet] = getWallets(provider)
// Create pointers to our execution manager & simple copier contract
let executionManager: Contract
let stateManager: Contract
let dummyContract: ContractFactory
let dummyContractAddress: Address

Expand All @@ -59,6 +61,12 @@ describe('Execution Manager -- Call opcodes', () => {
[DEFAULT_OPCODE_WHITELIST_MASK, '0x' + '00'.repeat(20), GAS_LIMIT, true],
{ gasLimit: DEFAULT_ETHNODE_GAS_LIMIT }
)
// Set the state manager as well
stateManager = new Contract(
await executionManager.getStateManagerAddress(),
StateManager.abi,
wallet
)

// Deploy SimpleCopier with the ExecutionManager
dummyContractAddress = await manuallyDeployOvmContract(
Expand Down Expand Up @@ -89,7 +97,7 @@ describe('Execution Manager -- Call opcodes', () => {
'dummyFunction',
[intParam, bytesParam]
)
const nonce = await executionManager.getOvmContractNonce(wallet.address)
const nonce = await stateManager.getOvmContractNonce(wallet.address)
const transaction = {
nonce,
gasLimit: GAS_LIMIT,
Expand Down Expand Up @@ -131,7 +139,7 @@ describe('Execution Manager -- Call opcodes', () => {
'dummyFunction',
[intParam, bytesParam]
)
const nonce = await executionManager.getOvmContractNonce(wallet.address)
const nonce = await stateManager.getOvmContractNonce(wallet.address)
const transaction = {
nonce,
gasLimit: GAS_LIMIT,
Expand Down Expand Up @@ -167,7 +175,7 @@ describe('Execution Manager -- Call opcodes', () => {
'dummyFunction',
[intParam, bytesParam]
)
const nonce = await executionManager.getOvmContractNonce(wallet.address)
const nonce = await stateManager.getOvmContractNonce(wallet.address)
const transaction = {
nonce,
gasLimit: GAS_LIMIT,
Expand Down Expand Up @@ -204,7 +212,7 @@ describe('Execution Manager -- Call opcodes', () => {
'dummyFunction',
[intParam, bytesParam]
)
const nonce = await executionManager.getOvmContractNonce(wallet.address)
const nonce = await stateManager.getOvmContractNonce(wallet.address)
const transaction = {
nonce,
gasLimit: GAS_LIMIT,
Expand All @@ -229,9 +237,7 @@ describe('Execution Manager -- Call opcodes', () => {
s
)
await provider.waitForTransaction(tx.hash)
const nonceAfter = await executionManager.getOvmContractNonce(
wallet.address
)
const nonceAfter = await stateManager.getOvmContractNonce(wallet.address)
nonceAfter.should.equal(parseInt(nonce, 10) + 1)
})

Expand All @@ -244,7 +250,7 @@ describe('Execution Manager -- Call opcodes', () => {
'dummyFunction',
[intParam, bytesParam]
)
const nonce = await executionManager.getOvmContractNonce(wallet.address)
const nonce = await stateManager.getOvmContractNonce(wallet.address)
const transaction = {
nonce,
gasLimit: GAS_LIMIT,
Expand Down
10 changes: 9 additions & 1 deletion packages/ovm/test/contracts/simple-storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '../setup'
import { getLogger, add0x, getCurrentTime } from '@eth-optimism/core-utils'
import {
ExecutionManagerContractDefinition as ExecutionManager,
FullStateManagerContractDefinition as StateManager,
TestSimpleStorageArgsFromCalldataDefinition as SimpleStorage,
} from '@eth-optimism/rollup-contracts'
import {
Expand Down Expand Up @@ -38,6 +39,7 @@ describe('SimpleStorage', () => {
const [wallet] = getWallets(provider)
// Create pointers to our execution manager & simple storage contract
let executionManager: Contract
let stateManager: Contract
let simpleStorage: ContractFactory
let simpleStorageOvmAddress: Address

Expand All @@ -51,6 +53,12 @@ describe('SimpleStorage', () => {
[DEFAULT_OPCODE_WHITELIST_MASK, '0x' + '00'.repeat(20), GAS_LIMIT, true],
{ gasLimit: DEFAULT_ETHNODE_GAS_LIMIT }
)
// Set the state manager as well
stateManager = new Contract(
await executionManager.getStateManagerAddress(),
StateManager.abi,
wallet
)

// Deploy SimpleStorage with the ExecutionManager
simpleStorageOvmAddress = await manuallyDeployOvmContract(
Expand Down Expand Up @@ -104,7 +112,7 @@ describe('SimpleStorage', () => {
.toString('hex')

const innerCallData: string = add0x(`${getStorageMethodId}${slot}`)
const nonce = await executionManager.getOvmContractNonce(wallet.address)
const nonce = await stateManager.getOvmContractNonce(wallet.address)
const transaction = {
nonce,
gasLimit: GAS_LIMIT,
Expand Down
9 changes: 8 additions & 1 deletion packages/ovm/test/contracts/tx-origin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@eth-optimism/rollup-core'
import {
ExecutionManagerContractDefinition as ExecutionManager,
FullStateManagerContractDefinition as StateManager,
TestSimpleTxOriginContractDefinition as SimpleTxOrigin,
} from '@eth-optimism/rollup-contracts'

Expand All @@ -36,6 +37,7 @@ describe('SimpleTxOrigin', () => {
const provider = createMockProvider({ gasLimit: DEFAULT_ETHNODE_GAS_LIMIT })
const [wallet] = getWallets(provider)
let executionManager: Contract
let stateManager: Contract
let simpleTxOrigin: ContractFactory
let simpleTxOriginOvmAddress: Address

Expand All @@ -49,6 +51,11 @@ describe('SimpleTxOrigin', () => {
[DEFAULT_OPCODE_WHITELIST_MASK, '0x' + '00'.repeat(20), GAS_LIMIT, true],
{ gasLimit: DEFAULT_ETHNODE_GAS_LIMIT }
)
stateManager = new Contract(
await executionManager.getStateManagerAddress(),
StateManager.abi,
wallet
)

// Deploy SimpleTxOrigin with the ExecutionManager
simpleTxOriginOvmAddress = await manuallyDeployOvmContract(
Expand All @@ -72,7 +79,7 @@ describe('SimpleTxOrigin', () => {
.toString('hex')

const innerCallData: string = add0x(`${getStorageMethodId}`)
const nonce = await executionManager.getOvmContractNonce(wallet.address)
const nonce = await stateManager.getOvmContractNonce(wallet.address)
const transaction = {
nonce,
gasLimit: GAS_LIMIT,
Expand Down
Loading