Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
3799b760
Unverified
Commit
3799b760
authored
Oct 04, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(contracts): Add a new 'Burn Admin' entity to control CTC's gas burn params"
parent
2c91ca00
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
45 additions
and
21 deletions
+45
-21
docker-compose-nobuild.yml
ops/docker-compose-nobuild.yml
+2
-0
docker-compose.yml
ops/docker-compose.yml
+2
-0
deploy.ts
packages/contracts/bin/deploy.ts
+3
-1
CanonicalTransactionChain.sol
...ntracts/contracts/L1/rollup/CanonicalTransactionChain.sol
+6
-6
000-Lib_AddressManager.deploy.ts
packages/contracts/deploy/000-Lib_AddressManager.deploy.ts
+6
-0
deploy.ts
packages/contracts/tasks/deploy.ts
+6
-0
deposit.gas.spec.ts
...contracts/test/contracts/L1/messaging/deposit.gas.spec.ts
+2
-2
CanonicalTransactionChain.gas.spec.ts
...contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts
+1
-1
CanonicalTransactionChain.spec.ts
...est/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
+17
-11
No files found.
ops/docker-compose-nobuild.yml
View file @
3799b760
...
...
@@ -34,6 +34,8 @@ services:
# these keys are hardhat's first 2 accounts, DO NOT use in production
DEPLOYER_PRIVATE_KEY
:
"
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
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
# were already compiled in the builder step
NO_COMPILE
:
1
...
...
ops/docker-compose.yml
View file @
3799b760
...
...
@@ -34,6 +34,8 @@ services:
# these keys are hardhat's first 2 accounts, DO NOT use in production
DEPLOYER_PRIVATE_KEY
:
"
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
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"
# setting the whitelist owner to address(0) disables the whitelist
WHITELIST_OWNER
:
"
0x0000000000000000000000000000000000000000"
...
...
packages/contracts/bin/deploy.ts
View file @
3799b760
import
{
Wallet
}
from
'
ethers
'
import
{
Wallet
,
utils
}
from
'
ethers
'
import
path
from
'
path
'
import
dirtree
from
'
directory-tree
'
import
fs
from
'
fs
'
...
...
@@ -17,6 +17,7 @@ import hre from 'hardhat'
const
sequencer
=
new
Wallet
(
process
.
env
.
SEQUENCER_PRIVATE_KEY
)
const
deployer
=
new
Wallet
(
process
.
env
.
DEPLOYER_PRIVATE_KEY
)
const
burnAdminAddress
=
utils
.
getAddress
(
process
.
env
.
BURN_ADMIN_ADDRESS
)
const
parseEnv
=
()
=>
{
const
ensure
=
(
env
,
type
)
=>
{
...
...
@@ -54,6 +55,7 @@ const main = async () => {
sccSequencerPublishWindow
:
config
.
sccFraudProofWindow
,
ovmSequencerAddress
:
sequencer
.
address
,
ovmProposerAddress
:
sequencer
.
address
,
ovmBurnAdmin
:
burnAdminAddress
,
ovmAddressManagerOwner
:
deployer
.
address
,
noCompile
:
process
.
env
.
NO_COMPILE
?
true
:
false
,
})
...
...
packages/contracts/contracts/L1/rollup/CanonicalTransactionChain.sol
View file @
3799b760
...
...
@@ -87,13 +87,13 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
**********************/
/**
* Modifier to enforce that
, if configured, only the OVM_Sequencer
contract may
* Modifier to enforce that
only the OVM_BurnAdmin
contract may
* successfully call a method.
*/
modifier only
Sequencer
() {
modifier only
BurnAdmin
() {
require(
msg.sender == resolve("OVM_
Sequencer
"),
"Only callable by the
Sequencer
."
msg.sender == resolve("OVM_
BurnAdmin
"),
"Only callable by the
Burn Admin
."
);
_;
}
...
...
@@ -108,7 +108,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
*/
function setEnqueueGasCost(uint256 _enqueueGasCost)
external
only
Sequencer
only
BurnAdmin
{
enqueueGasCost = _enqueueGasCost;
enqueueL2GasPrepaid = l2GasDiscountDivisor * _enqueueGasCost;
...
...
@@ -127,7 +127,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
*/
function setGasDivisor(uint256 _l2GasDiscountDivisor)
external
only
Sequencer
only
BurnAdmin
{
l2GasDiscountDivisor = _l2GasDiscountDivisor;
enqueueL2GasPrepaid = _l2GasDiscountDivisor * enqueueGasCost;
...
...
packages/contracts/deploy/000-Lib_AddressManager.deploy.ts
View file @
3799b760
...
...
@@ -39,6 +39,12 @@ const deployFn: DeployFunction = async (hre) => {
name
:
'
OVM_Proposer
'
,
address
:
(
hre
as
any
).
deployConfig
.
ovmProposerAddress
,
})
await
registerAddress
({
hre
,
name
:
'
OVM_BurnAdmin
'
,
address
:
(
hre
as
any
).
deployConfig
.
ovmBurnAdmin
,
})
}
deployFn
.
tags
=
[
'
Lib_AddressManager
'
]
...
...
packages/contracts/tasks/deploy.ts
View file @
3799b760
...
...
@@ -65,6 +65,12 @@ task('deploy')
undefined
,
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
)
=>
{
// Necessary because hardhat doesn't let us attach non-optional parameters to existing tasks.
const
validateAddressArg
=
(
argName
:
string
)
=>
{
...
...
packages/contracts/test/contracts/L1/messaging/deposit.gas.spec.ts
View file @
3799b760
...
...
@@ -146,7 +146,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
const
receipt
=
await
res
.
wait
()
const
gasUsed
=
receipt
.
gasUsed
.
toNumber
()
console
.
log
(
'
- Gas used:
'
,
gasUsed
)
expectApprox
(
gasUsed
,
1
16
_003
,
{
expectApprox
(
gasUsed
,
1
55
_089
,
{
absoluteUpperDeviation
:
500
,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
...
...
@@ -173,7 +173,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
const
receipt
=
await
res
.
wait
()
const
gasUsed
=
receipt
.
gasUsed
.
toNumber
()
console
.
log
(
'
- Gas used:
'
,
gasUsed
)
expectApprox
(
gasUsed
,
163
_844
,
{
expectApprox
(
gasUsed
,
202
_930
,
{
absoluteUpperDeviation
:
500
,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
...
...
packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts
View file @
3799b760
...
...
@@ -314,7 +314,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
console
.
log
(
'
Benchmark complete.
'
)
expectApprox
(
gasUsed
,
1
26
_70
0
,
{
expectApprox
(
gasUsed
,
1
58
_69
0
,
{
absoluteUpperDeviation
:
500
,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
...
...
packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
View file @
3799b760
...
...
@@ -65,8 +65,9 @@ const appendSequencerBatch = async (
describe
(
'
CanonicalTransactionChain
'
,
()
=>
{
let
signer
:
Signer
let
sequencer
:
Signer
let
burnAdmin
:
Signer
before
(
async
()
=>
{
;[
signer
,
sequencer
]
=
await
ethers
.
getSigners
()
;[
signer
,
sequencer
,
burnAdmin
]
=
await
ethers
.
getSigners
()
})
let
AddressManager
:
Contract
...
...
@@ -78,6 +79,11 @@ describe('CanonicalTransactionChain', () => {
await
sequencer
.
getAddress
()
)
await
AddressManager
.
setAddress
(
'
OVM_BurnAdmin
'
,
await
burnAdmin
.
getAddress
()
)
Mock__StateCommitmentChain
=
await
smockit
(
await
ethers
.
getContractFactory
(
'
StateCommitmentChain
'
)
)
...
...
@@ -107,7 +113,7 @@ describe('CanonicalTransactionChain', () => {
AddressManager
.
address
,
MAX_GAS_LIMIT
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
,
ENQUEUE_GAS_COST
)
const
batches
=
await
Factory__ChainStorageContainer
.
deploy
(
...
...
@@ -137,15 +143,15 @@ describe('CanonicalTransactionChain', () => {
describe
(
'
Gas param setters
'
,
()
=>
{
describe
(
'
setGasDivisor
'
,
async
()
=>
{
it
(
'
should revert when not called by the
sequencer
'
,
async
()
=>
{
it
(
'
should revert when not called by the
Burn Admin
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
connect
(
signer
).
setGasDivisor
(
32
)
).
to
.
be
.
revertedWith
(
'
Only callable by the
Sequencer
.
'
)
).
to
.
be
.
revertedWith
(
'
Only callable by the
Burn Admin
.
'
)
})
it
(
'
should update the l2GasDiscountDivisor and enqueueL2GasPrepaid correctly
'
,
async
()
=>
{
const
newGasDivisor
=
19
await
CanonicalTransactionChain
.
connect
(
sequencer
).
setGasDivisor
(
await
CanonicalTransactionChain
.
connect
(
burnAdmin
).
setGasDivisor
(
newGasDivisor
)
...
...
@@ -157,21 +163,21 @@ describe('CanonicalTransactionChain', () => {
it
(
'
should emit an L2GasParamsUpdated event
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
connect
(
sequencer
).
setGasDivisor
(
88
)
CanonicalTransactionChain
.
connect
(
burnAdmin
).
setGasDivisor
(
88
)
).
to
.
emit
(
CanonicalTransactionChain
,
'
L2GasParamsUpdated
'
)
})
})
describe
(
'
setEnqueueGasCost
'
,
async
()
=>
{
it
(
'
should revert when not called by the
sequencer
'
,
async
()
=>
{
it
(
'
should revert when not called by the
Burn Admin
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
connect
(
signer
).
setEnqueueGasCost
(
60000
)
).
to
.
be
.
revertedWith
(
'
Only callable by the
Sequencer
.
'
)
).
to
.
be
.
revertedWith
(
'
Only callable by the
Burn Admin
.
'
)
})
it
(
'
should update the enqueueGasCost and enqueueL2GasPrepaid correctly
'
,
async
()
=>
{
const
newEnqueueGasCost
=
31113
await
CanonicalTransactionChain
.
connect
(
sequencer
).
setEnqueueGasCost
(
await
CanonicalTransactionChain
.
connect
(
burnAdmin
).
setEnqueueGasCost
(
newEnqueueGasCost
)
...
...
@@ -186,7 +192,7 @@ describe('CanonicalTransactionChain', () => {
it
(
'
should emit an L2GasParamsUpdated event
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
connect
(
sequencer
).
setEnqueueGasCost
(
31514
)
CanonicalTransactionChain
.
connect
(
burnAdmin
).
setEnqueueGasCost
(
31514
)
).
to
.
emit
(
CanonicalTransactionChain
,
'
L2GasParamsUpdated
'
)
})
})
...
...
@@ -244,7 +250,7 @@ describe('CanonicalTransactionChain', () => {
// additional gas overhead, it will be enough trigger the gas burn, but not enough to cover
// it.
const
l1GasLimit
=
(
l2GasLimit
-
_enqueueL2GasPrepaid
)
/
l2GasDiscountDivisor
(
l2GasLimit
-
_enqueueL2GasPrepaid
)
/
l2GasDiscountDivisor
await
expect
(
CanonicalTransactionChain
.
enqueue
(
target
,
l2GasLimit
,
data
,
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment