diff --git a/packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol b/packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol index 8e1262733b60..7cb19f00b1c4 100644 --- a/packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol +++ b/packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol @@ -4,10 +4,19 @@ pragma solidity ^0.7.0; /* Interface Imports */ import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol"; +/* Contract Imports */ +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + /** * @title mockOVM_BondManager */ -contract mockOVM_BondManager is iOVM_BondManager { +contract mockOVM_BondManager is iOVM_BondManager, Lib_AddressResolver { + constructor( + address _libAddressManager + ) + Lib_AddressResolver(_libAddressManager) + {} + function recordGasSpent( bytes32 _preStateRoot, bytes32 _txHash, @@ -59,7 +68,8 @@ contract mockOVM_BondManager is iOVM_BondManager { bool ) { - return true; + // Only authenticate sequencer to submit state root batches. + return _who == resolve("OVM_Sequencer"); } function getGasSpent( diff --git a/packages/contracts/src/contract-deployment/config.ts b/packages/contracts/src/contract-deployment/config.ts index 7011d38b7614..ae07a2681b76 100644 --- a/packages/contracts/src/contract-deployment/config.ts +++ b/packages/contracts/src/contract-deployment/config.ts @@ -164,6 +164,7 @@ export const makeContractDeployConfig = async ( }, OVM_BondManager: { factory: getContractFactory('mockOVM_BondManager'), + params: [AddressManager.address], }, OVM_ETH: { factory: getContractFactory('OVM_ETH'), diff --git a/packages/contracts/test/contracts/mockOVM/verification/mockOVM_BondManager.spec.ts b/packages/contracts/test/contracts/mockOVM/verification/mockOVM_BondManager.spec.ts new file mode 100644 index 000000000000..12002bf1085a --- /dev/null +++ b/packages/contracts/test/contracts/mockOVM/verification/mockOVM_BondManager.spec.ts @@ -0,0 +1,46 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from '@nomiclabs/buidler' +import { Signer, Contract } from 'ethers' + +/* Internal Imports */ +import { makeAddressManager } from '../../../helpers' + +describe('mockOVM_BondManager', () => { + let sequencer: Signer + let nonSequencer: Signer + before(async () => { + ;[sequencer, nonSequencer] = await ethers.getSigners() + }) + + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let mockOVM_BondManager: Contract + before(async () => { + mockOVM_BondManager = await ( + await ethers.getContractFactory('mockOVM_BondManager') + ).deploy(AddressManager.address) + + AddressManager.setAddress('OVM_Sequencer', await sequencer.getAddress()) + }) + + describe('isCollateralized', () => { + it('should return true for OVM_Sequencer', async () => { + expect( + await mockOVM_BondManager.isCollateralized(await sequencer.getAddress()) + ).to.equal(true) + }) + + it('should return false for non-sequencer', async () => { + expect( + await mockOVM_BondManager.isCollateralized( + await nonSequencer.getAddress() + ) + ).to.equal(false) + }) + }) +})