Commit 53e4cae8 authored by Maurelian's avatar Maurelian Committed by Kelvin Fichter

feat(contracts): hard code address manager owner as gas burn admin

parent bc6756c5
...@@ -34,8 +34,6 @@ services: ...@@ -34,8 +34,6 @@ services:
# these keys are hardhat's first 2 accounts, DO NOT use in production # these keys are hardhat's first 2 accounts, DO NOT use in production
DEPLOYER_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" DEPLOYER_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
SEQUENCER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" SEQUENCER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
# this address is hardhat's third accounts, DO NOT use in production
BURN_ADMIN_ADDRESS: "0xD1D84F0e28D6fedF03c73151f98dF95139700aa7"
# skip compilation when run in docker-compose, since the contracts # skip compilation when run in docker-compose, since the contracts
# were already compiled in the builder step # were already compiled in the builder step
NO_COMPILE: 1 NO_COMPILE: 1
......
...@@ -34,8 +34,6 @@ services: ...@@ -34,8 +34,6 @@ services:
# these keys are hardhat's first 2 accounts, DO NOT use in production # these keys are hardhat's first 2 accounts, DO NOT use in production
DEPLOYER_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" DEPLOYER_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
SEQUENCER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" SEQUENCER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
# this address is hardhat's third accounts, DO NOT use in production.
BURN_ADMIN_ADDRESS: "0xD1D84F0e28D6fedF03c73151f98dF95139700aa7"
GAS_PRICE_ORACLE_OWNER: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" GAS_PRICE_ORACLE_OWNER: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
# setting the whitelist owner to address(0) disables the whitelist # setting the whitelist owner to address(0) disables the whitelist
WHITELIST_OWNER: "0x0000000000000000000000000000000000000000" WHITELIST_OWNER: "0x0000000000000000000000000000000000000000"
......
import { Wallet, utils } from 'ethers' import { Wallet } from 'ethers'
import path from 'path' import path from 'path'
import dirtree from 'directory-tree' import dirtree from 'directory-tree'
import fs from 'fs' import fs from 'fs'
...@@ -17,7 +17,6 @@ import hre from 'hardhat' ...@@ -17,7 +17,6 @@ import hre from 'hardhat'
const sequencer = new Wallet(process.env.SEQUENCER_PRIVATE_KEY) const sequencer = new Wallet(process.env.SEQUENCER_PRIVATE_KEY)
const deployer = new Wallet(process.env.DEPLOYER_PRIVATE_KEY) const deployer = new Wallet(process.env.DEPLOYER_PRIVATE_KEY)
const burnAdminAddress = utils.getAddress(process.env.BURN_ADMIN_ADDRESS)
const parseEnv = () => { const parseEnv = () => {
const ensure = (env, type) => { const ensure = (env, type) => {
...@@ -55,7 +54,6 @@ const main = async () => { ...@@ -55,7 +54,6 @@ const main = async () => {
sccSequencerPublishWindow: config.sccFraudProofWindow, sccSequencerPublishWindow: config.sccFraudProofWindow,
ovmSequencerAddress: sequencer.address, ovmSequencerAddress: sequencer.address,
ovmProposerAddress: sequencer.address, ovmProposerAddress: sequencer.address,
ovmBurnAdmin: burnAdminAddress,
ovmAddressManagerOwner: deployer.address, ovmAddressManagerOwner: deployer.address,
noCompile: process.env.NO_COMPILE ? true : false, noCompile: process.env.NO_COMPILE ? true : false,
}) })
......
...@@ -87,12 +87,12 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes ...@@ -87,12 +87,12 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
**********************/ **********************/
/** /**
* Modifier to enforce that only the OVM_BurnAdmin contract may * Modifier to enforce that, if configured, only the OVM_Sequencer contract may
* successfully call a method. * successfully call a method.
*/ */
modifier onlyBurnAdmin() { modifier onlyBurnAdmin() {
require( require(
msg.sender == resolve("OVM_BurnAdmin"), msg.sender == libAddressManager.owner(),
"Only callable by the Burn Admin." "Only callable by the Burn Admin."
); );
_; _;
......
...@@ -39,12 +39,6 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -39,12 +39,6 @@ const deployFn: DeployFunction = async (hre) => {
name: 'OVM_Proposer', name: 'OVM_Proposer',
address: (hre as any).deployConfig.ovmProposerAddress, address: (hre as any).deployConfig.ovmProposerAddress,
}) })
await registerAddress({
hre,
name: 'OVM_BurnAdmin',
address: (hre as any).deployConfig.ovmBurnAdmin,
})
} }
deployFn.tags = ['Lib_AddressManager'] deployFn.tags = ['Lib_AddressManager']
......
...@@ -65,12 +65,6 @@ task('deploy') ...@@ -65,12 +65,6 @@ task('deploy')
undefined, undefined,
types.string types.string
) )
.addOptionalParam(
'ovmBurnAdmin',
'Address that can update gas burn parameters in the CTC. Must be provided or this deployment will fail.',
undefined,
types.string
)
.setAction(async (args, hre: any, runSuper) => { .setAction(async (args, hre: any, runSuper) => {
// Necessary because hardhat doesn't let us attach non-optional parameters to existing tasks. // Necessary because hardhat doesn't let us attach non-optional parameters to existing tasks.
const validateAddressArg = (argName: string) => { const validateAddressArg = (argName: string) => {
......
...@@ -63,11 +63,11 @@ const appendSequencerBatch = async ( ...@@ -63,11 +63,11 @@ const appendSequencerBatch = async (
} }
describe('CanonicalTransactionChain', () => { describe('CanonicalTransactionChain', () => {
let signer: Signer let addressManagerOwner: Signer
let sequencer: Signer let sequencer: Signer
let burnAdmin: Signer let otherSigner: Signer
before(async () => { before(async () => {
;[signer, sequencer, burnAdmin] = await ethers.getSigners() ;[addressManagerOwner, sequencer, otherSigner] = await ethers.getSigners()
}) })
let AddressManager: Contract let AddressManager: Contract
...@@ -79,11 +79,6 @@ describe('CanonicalTransactionChain', () => { ...@@ -79,11 +79,6 @@ describe('CanonicalTransactionChain', () => {
await sequencer.getAddress() await sequencer.getAddress()
) )
await AddressManager.setAddress(
'OVM_BurnAdmin',
await burnAdmin.getAddress()
)
Mock__StateCommitmentChain = await smockit( Mock__StateCommitmentChain = await smockit(
await ethers.getContractFactory('StateCommitmentChain') await ethers.getContractFactory('StateCommitmentChain')
) )
...@@ -143,17 +138,17 @@ describe('CanonicalTransactionChain', () => { ...@@ -143,17 +138,17 @@ describe('CanonicalTransactionChain', () => {
describe('Gas param setters', () => { describe('Gas param setters', () => {
describe('setGasDivisor', async () => { describe('setGasDivisor', async () => {
it('should revert when not called by the Burn Admin', async () => { it('should revert when not called by the sequencer', async () => {
await expect( await expect(
CanonicalTransactionChain.connect(signer).setGasDivisor(32) CanonicalTransactionChain.connect(otherSigner).setGasDivisor(32)
).to.be.revertedWith('Only callable by the Burn Admin.') ).to.be.revertedWith('Only callable by the Burn Admin.')
}) })
it('should update the l2GasDiscountDivisor and enqueueL2GasPrepaid correctly', async () => { it('should update the l2GasDiscountDivisor and enqueueL2GasPrepaid correctly', async () => {
const newGasDivisor = 19 const newGasDivisor = 19
await CanonicalTransactionChain.connect(burnAdmin).setGasDivisor( await CanonicalTransactionChain.connect(
newGasDivisor addressManagerOwner
) ).setGasDivisor(newGasDivisor)
const enqueueGasCost = await CanonicalTransactionChain.enqueueGasCost() const enqueueGasCost = await CanonicalTransactionChain.enqueueGasCost()
const enqueueL2GasPrepaid = const enqueueL2GasPrepaid =
...@@ -163,23 +158,27 @@ describe('CanonicalTransactionChain', () => { ...@@ -163,23 +158,27 @@ describe('CanonicalTransactionChain', () => {
it('should emit an L2GasParamsUpdated event', async () => { it('should emit an L2GasParamsUpdated event', async () => {
await expect( await expect(
CanonicalTransactionChain.connect(burnAdmin).setGasDivisor(88) CanonicalTransactionChain.connect(addressManagerOwner).setGasDivisor(
88
)
).to.emit(CanonicalTransactionChain, 'L2GasParamsUpdated') ).to.emit(CanonicalTransactionChain, 'L2GasParamsUpdated')
}) })
}) })
describe('setEnqueueGasCost', async () => { describe('setEnqueueGasCost', async () => {
it('should revert when not called by the Burn Admin', async () => { it('should revert when not called by the sequencer', async () => {
await expect( await expect(
CanonicalTransactionChain.connect(signer).setEnqueueGasCost(60000) CanonicalTransactionChain.connect(otherSigner).setEnqueueGasCost(
60000
)
).to.be.revertedWith('Only callable by the Burn Admin.') ).to.be.revertedWith('Only callable by the Burn Admin.')
}) })
it('should update the enqueueGasCost and enqueueL2GasPrepaid correctly', async () => { it('should update the enqueueGasCost and enqueueL2GasPrepaid correctly', async () => {
const newEnqueueGasCost = 31113 const newEnqueueGasCost = 31113
await CanonicalTransactionChain.connect(burnAdmin).setEnqueueGasCost( await CanonicalTransactionChain.connect(
newEnqueueGasCost addressManagerOwner
) ).setEnqueueGasCost(newEnqueueGasCost)
const l2GasDiscountDivisor = const l2GasDiscountDivisor =
await CanonicalTransactionChain.l2GasDiscountDivisor() await CanonicalTransactionChain.l2GasDiscountDivisor()
...@@ -192,7 +191,9 @@ describe('CanonicalTransactionChain', () => { ...@@ -192,7 +191,9 @@ describe('CanonicalTransactionChain', () => {
it('should emit an L2GasParamsUpdated event', async () => { it('should emit an L2GasParamsUpdated event', async () => {
await expect( await expect(
CanonicalTransactionChain.connect(burnAdmin).setEnqueueGasCost(31514) CanonicalTransactionChain.connect(
addressManagerOwner
).setEnqueueGasCost(31514)
).to.emit(CanonicalTransactionChain, 'L2GasParamsUpdated') ).to.emit(CanonicalTransactionChain, 'L2GasParamsUpdated')
}) })
}) })
...@@ -342,7 +343,7 @@ describe('CanonicalTransactionChain', () => { ...@@ -342,7 +343,7 @@ describe('CanonicalTransactionChain', () => {
await setEthTime(ethers.provider, timestamp) await setEthTime(ethers.provider, timestamp)
const transactionHash = getTransactionHash( const transactionHash = getTransactionHash(
await signer.getAddress(), await addressManagerOwner.getAddress(),
target, target,
gasLimit, gasLimit,
data data
...@@ -386,7 +387,7 @@ describe('CanonicalTransactionChain', () => { ...@@ -386,7 +387,7 @@ describe('CanonicalTransactionChain', () => {
await setEthTime(ethers.provider, timestamp) await setEthTime(ethers.provider, timestamp)
transactionHash = getTransactionHash( transactionHash = getTransactionHash(
await signer.getAddress(), await addressManagerOwner.getAddress(),
target, target,
gasLimit, gasLimit,
data data
...@@ -429,7 +430,7 @@ describe('CanonicalTransactionChain', () => { ...@@ -429,7 +430,7 @@ describe('CanonicalTransactionChain', () => {
await setEthTime(ethers.provider, timestamp) await setEthTime(ethers.provider, timestamp)
transactionHash = getTransactionHash( transactionHash = getTransactionHash(
await signer.getAddress(), await addressManagerOwner.getAddress(),
target, target,
gasLimit, gasLimit,
data data
...@@ -507,19 +508,22 @@ describe('CanonicalTransactionChain', () => { ...@@ -507,19 +508,22 @@ describe('CanonicalTransactionChain', () => {
it('should revert if not called by the sequencer', async () => { it('should revert if not called by the sequencer', async () => {
await expect( await expect(
appendSequencerBatch(CanonicalTransactionChain.connect(signer), { appendSequencerBatch(
transactions: ['0x1234'], CanonicalTransactionChain.connect(addressManagerOwner),
contexts: [ {
{ transactions: ['0x1234'],
numSequencedTransactions: 0, contexts: [
numSubsequentQueueTransactions: 0, {
timestamp: 0, numSequencedTransactions: 0,
blockNumber: 0, numSubsequentQueueTransactions: 0,
}, timestamp: 0,
], blockNumber: 0,
shouldStartAtElement: 0, },
totalElementsToAppend: 1, ],
}) shouldStartAtElement: 0,
totalElementsToAppend: 1,
}
)
).to.be.revertedWith('Function can only be called by the Sequencer.') ).to.be.revertedWith('Function can only be called by the Sequencer.')
}) })
......
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