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
66bf56a6
Unverified
Commit
66bf56a6
authored
Sep 28, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(contracts): remove unused code from CTC
parent
76c84f21
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
9 additions
and
196 deletions
+9
-196
few-students-pretend.md
.changeset/few-students-pretend.md
+5
-0
deploy.ts
packages/contracts/bin/deploy.ts
+0
-5
CanonicalTransactionChain.sol
...ntracts/contracts/L1/rollup/CanonicalTransactionChain.sol
+3
-64
ICanonicalTransactionChain.sol
...tracts/contracts/L1/rollup/ICanonicalTransactionChain.sol
+0
-9
004-OVM_CanonicalTransactionChain.deploy.ts
...tracts/deploy/004-OVM_CanonicalTransactionChain.deploy.ts
+0
-2
deploy.ts
packages/contracts/tasks/deploy.ts
+0
-11
L1CrossDomainMessenger.spec.ts
...est/contracts/L1/messaging/L1CrossDomainMessenger.spec.ts
+0
-4
deposit.gas.spec.ts
...contracts/test/contracts/L1/messaging/deposit.gas.spec.ts
+0
-4
CanonicalTransactionChain.gas.spec.ts
...contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts
+1
-6
CanonicalTransactionChain.spec.ts
...est/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
+0
-91
No files found.
.changeset/few-students-pretend.md
0 → 100644
View file @
66bf56a6
---
'
@eth-optimism/contracts'
:
minor
---
Remove unused code from CTC
packages/contracts/bin/deploy.ts
View file @
66bf56a6
...
...
@@ -31,10 +31,6 @@ const parseEnv = () => {
return
{
l1BlockTimeSeconds
:
ensure
(
'
BLOCK_TIME_SECONDS
'
,
'
number
'
),
ctcForceInclusionPeriodSeconds
:
ensure
(
'
FORCE_INCLUSION_PERIOD_SECONDS
'
,
'
number
'
),
ctcMaxTransactionGasLimit
:
ensure
(
'
MAX_TRANSACTION_GAS_LIMIT
'
,
'
number
'
),
ctcL2GasDiscountDivisor
:
ensure
(
'
L2_GAS_DISCOUNT_DIVISOR
'
,
'
number
'
),
ctcEnqueueGasCost
:
ensure
(
'
ENQUEUE_GAS_COST
'
,
'
number
'
),
...
...
@@ -51,7 +47,6 @@ const main = async () => {
await
hre
.
run
(
'
deploy
'
,
{
l1BlockTimeSeconds
:
config
.
l1BlockTimeSeconds
,
ctcForceInclusionPeriodSeconds
:
config
.
ctcForceInclusionPeriodSeconds
,
ctcMaxTransactionGasLimit
:
config
.
ctcMaxTransactionGasLimit
,
ctcL2GasDiscountDivisor
:
config
.
ctcL2GasDiscountDivisor
,
ctcEnqueueGasCost
:
config
.
ctcEnqueueGasCost
,
...
...
packages/contracts/contracts/L1/rollup/CanonicalTransactionChain.sol
View file @
66bf56a6
...
...
@@ -20,8 +20,6 @@ import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
* writing them to the 'CTC:batches' instance of the Chain Storage Container.
* The CTC also allows any account to 'enqueue' an L2 transaction, which will require that the
* Sequencer will eventually append it to the rollup state.
* If the Sequencer does not include an enqueued transaction within the 'force inclusion period',
* then any account may force it to be included by calling appendQueueBatch().
*
* Runtime target: EVM
*/
...
...
@@ -50,8 +48,6 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
* Variables *
*************/
uint256 public forceInclusionPeriodSeconds;
uint256 public forceInclusionPeriodBlocks;
uint256 public maxTransactionGasLimit;
...
...
@@ -61,16 +57,12 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
constructor(
address _libAddressManager,
uint256 _forceInclusionPeriodSeconds,
uint256 _forceInclusionPeriodBlocks,
uint256 _maxTransactionGasLimit,
uint256 _l2GasDiscountDivisor,
uint256 _enqueueGasCost
)
Lib_AddressResolver(_libAddressManager)
{
forceInclusionPeriodSeconds = _forceInclusionPeriodSeconds;
forceInclusionPeriodBlocks = _forceInclusionPeriodBlocks;
maxTransactionGasLimit = _maxTransactionGasLimit;
L2_GAS_DISCOUNT_DIVISOR = _l2GasDiscountDivisor;
ENQUEUE_GAS_COST = _enqueueGasCost;
...
...
@@ -250,7 +242,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
uint256 _gasLimit,
bytes memory _data
)
public
external
{
require(
_data.length <= MAX_ROLLUP_TX_SIZE,
...
...
@@ -325,59 +317,6 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
);
}
/**
* Appends a given number of queued transactions as a single batch.
* param _numQueuedTransactions Number of transactions to append.
*/
function appendQueueBatch(
uint256 // _numQueuedTransactions
)
public
pure
{
// TEMPORARY: Disable `appendQueueBatch` for minnet
revert("appendQueueBatch is currently disabled.");
// solhint-disable max-line-length
// _numQueuedTransactions = Math.min(_numQueuedTransactions, getNumPendingQueueElements());
// require(
// _numQueuedTransactions > 0,
// "Must append more than zero transactions."
// );
// bytes32[] memory leaves = new bytes32[](_numQueuedTransactions);
// uint40 nextQueueIndex = getNextQueueIndex();
// for (uint256 i = 0; i < _numQueuedTransactions; i++) {
// if (msg.sender != resolve("OVM_Sequencer")) {
// Lib_OVMCodec.QueueElement memory el = getQueueElement(nextQueueIndex);
// require(
// el.timestamp + forceInclusionPeriodSeconds < block.timestamp,
// "Queue transactions cannot be submitted during the sequencer inclusion period."
// );
// }
// leaves[i] = _getQueueLeafHash(nextQueueIndex);
// nextQueueIndex++;
// }
// Lib_OVMCodec.QueueElement memory lastElement = getQueueElement(nextQueueIndex - 1);
// _appendBatch(
// Lib_MerkleTree.getMerkleRoot(leaves),
// _numQueuedTransactions,
// _numQueuedTransactions,
// lastElement.timestamp,
// lastElement.blockNumber
// );
// emit QueueBatchAppended(
// nextQueueIndex - _numQueuedTransactions,
// _numQueuedTransactions,
// getTotalElements()
// );
// solhint-enable max-line-length
}
/**
* Allows the sequencer to append a batch of transactions.
* @dev This function uses a custom encoding scheme for efficiency reasons.
...
...
@@ -387,7 +326,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
* .param _transactionDataFields Array of raw transaction data.
*/
function appendSequencerBatch()
public
external
{
uint40 shouldStartAtElement;
uint24 totalElementsToAppend;
...
...
@@ -540,7 +479,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
Lib_OVMCodec.ChainBatchHeader memory _batchHeader,
Lib_OVMCodec.ChainInclusionProof memory _inclusionProof
)
public
external
view
returns (
bool
...
...
packages/contracts/contracts/L1/rollup/ICanonicalTransactionChain.sol
View file @
66bf56a6
...
...
@@ -191,15 +191,6 @@ interface ICanonicalTransactionChain {
)
external;
/**
* Appends a given number of queued transactions as a single batch.
* @param _numQueuedTransactions Number of transactions to append.
*/
function appendQueueBatch(
uint256 _numQueuedTransactions
)
external;
/**
* Allows the sequencer to append a batch of transactions.
* @dev This function uses a custom encoding scheme for efficiency reasons.
...
...
packages/contracts/deploy/004-OVM_CanonicalTransactionChain.deploy.ts
View file @
66bf56a6
...
...
@@ -18,8 +18,6 @@ const deployFn: DeployFunction = async (hre) => {
name
:
'
CanonicalTransactionChain
'
,
args
:
[
Lib_AddressManager
.
address
,
(
hre
as
any
).
deployConfig
.
ctcForceInclusionPeriodSeconds
,
(
hre
as
any
).
deployConfig
.
ctcForceInclusionPeriodBlocks
,
(
hre
as
any
).
deployConfig
.
ctcMaxTransactionGasLimit
,
(
hre
as
any
).
deployConfig
.
ctcL2GasDiscountDivisor
,
(
hre
as
any
).
deployConfig
.
ctcEnqueueGasCost
,
...
...
packages/contracts/tasks/deploy.ts
View file @
66bf56a6
...
...
@@ -4,7 +4,6 @@ import { task } from 'hardhat/config'
import
*
as
types
from
'
hardhat/internal/core/params/argumentTypes
'
const
DEFAULT_L1_BLOCK_TIME_SECONDS
=
15
const
DEFAULT_CTC_FORCE_INCLUSION_PERIOD_SECONDS
=
60
*
60
*
24
*
30
// 30 days
const
DEFAULT_CTC_MAX_TRANSACTION_GAS_LIMIT
=
11
_000_000
const
DEFAULT_CTC_L2_GAS_DISCOUNT_DIVISOR
=
32
const
DEFAULT_CTC_ENQUEUE_GAS_COST
=
60
_000
...
...
@@ -18,12 +17,6 @@ task('deploy')
DEFAULT_L1_BLOCK_TIME_SECONDS
,
types
.
int
)
.
addOptionalParam
(
'
ctcForceInclusionPeriodSeconds
'
,
'
Number of seconds that the sequencer has to include transactions before the L1 queue.
'
,
DEFAULT_CTC_FORCE_INCLUSION_PERIOD_SECONDS
,
types
.
int
)
.
addOptionalParam
(
'
ctcMaxTransactionGasLimit
'
,
'
Max gas limit for L1 queue transactions.
'
,
...
...
@@ -91,10 +84,6 @@ task('deploy')
validateAddressArg
(
'
ovmProposerAddress
'
)
validateAddressArg
(
'
ovmAddressManagerOwner
'
)
args
.
ctcForceInclusionPeriodBlocks
=
Math
.
floor
(
args
.
ctcForceInclusionPeriodSeconds
/
args
.
l1BlockTimeSeconds
)
hre
.
deployConfig
=
args
return
runSuper
(
args
)
})
packages/contracts/test/contracts/L1/messaging/L1CrossDomainMessenger.spec.ts
View file @
66bf56a6
...
...
@@ -14,8 +14,6 @@ import {
NON_ZERO_ADDRESS
,
DUMMY_BATCH_HEADERS
,
DUMMY_BATCH_PROOFS
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
,
TrieTestGenerator
,
...
...
@@ -100,8 +98,6 @@ describe('L1CrossDomainMessenger', () => {
)
CanonicalTransactionChain
=
await
Factory__CanonicalTransactionChain
.
deploy
(
AddressManager
.
address
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
MAX_GAS_LIMIT
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
...
...
packages/contracts/test/contracts/L1/messaging/deposit.gas.spec.ts
View file @
66bf56a6
...
...
@@ -6,8 +6,6 @@ import { smoddit } from '@eth-optimism/smock'
/* Internal Imports */
import
{
makeAddressManager
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
,
NON_ZERO_ADDRESS
,
...
...
@@ -46,8 +44,6 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
await
ethers
.
getContractFactory
(
'
CanonicalTransactionChain
'
)
).
deploy
(
AddressManager
.
address
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
MAX_GAS_LIMIT
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
...
...
packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts
View file @
66bf56a6
...
...
@@ -81,13 +81,8 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
let
CanonicalTransactionChain
:
Contract
beforeEach
(
async
()
=>
{
// Use a larger FIP for blocks so that we can send a large number of
// enqueue() transactions without having to manipulate the block number.
const
forceInclusionPeriodBlocks
=
101
CanonicalTransactionChain
=
await
Factory__CanonicalTransactionChain
.
deploy
(
AddressManager
.
address
,
FORCE_INCLUSION_PERIOD_SECONDS
,
forceInclusionPeriodBlocks
,
MAX_GAS_LIMIT
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
...
...
@@ -269,7 +264,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
'
Non-calldata overhead gas cost per transaction:
'
,
(
gasUsed
-
fixedCalldataCost
)
/
numTxs
)
expectApprox
(
gasUsed
,
1
_293_
1
11
,
{
upperPercentDeviation
:
0
})
expectApprox
(
gasUsed
,
1
_293_
6
11
,
{
upperPercentDeviation
:
0
})
}).
timeout
(
10
_000_000
)
})
...
...
packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
View file @
66bf56a6
...
...
@@ -17,17 +17,12 @@ import _ from 'lodash'
import
{
makeAddressManager
,
setProxyTarget
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
,
setEthTime
,
NON_ZERO_ADDRESS
,
getEthTime
,
getNextBlockNumber
,
increaseEthTime
,
getBlockTime
,
mineBlock
,
}
from
'
../../../helpers
'
import
{
predeploys
}
from
'
../../../../src
'
...
...
@@ -132,8 +127,6 @@ describe('CanonicalTransactionChain', () => {
beforeEach
(
async
()
=>
{
CanonicalTransactionChain
=
await
Factory__CanonicalTransactionChain
.
deploy
(
AddressManager
.
address
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
MAX_GAS_LIMIT
,
L2_GAS_DISCOUNT_DIVISOR
,
ENQUEUE_GAS_COST
...
...
@@ -424,89 +417,6 @@ describe('CanonicalTransactionChain', () => {
})
})
describe
(
'
appendQueueBatch disabled
'
,
()
=>
{
it
(
'
should revert
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
appendQueueBatch
(
0
)
).
to
.
be
.
revertedWith
(
'
appendQueueBatch is currently disabled.
'
)
})
})
describe
.
skip
(
'
appendQueueBatch
'
,
()
=>
{
it
(
'
should revert if trying to append zero transactions
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
appendQueueBatch
(
0
)
).
to
.
be
.
revertedWith
(
'
Must append more than zero transactions.
'
)
})
it
(
'
should revert if the queue is empty
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
appendQueueBatch
(
1
)
).
to
.
be
.
revertedWith
(
'
Must append more than zero transactions.
'
)
})
describe
(
'
when the queue is not empty
'
,
()
=>
{
const
target
=
NON_ZERO_ADDRESS
const
gasLimit
=
500
_000
const
data
=
'
0x
'
+
'
12
'
.
repeat
(
1234
)
for
(
const
size
of
ELEMENT_TEST_SIZES
)
{
describe
(
`when the queue has
${
size
}
elements`
,
()
=>
{
beforeEach
(
async
()
=>
{
for
(
let
i
=
0
;
i
<
size
;
i
++
)
{
await
CanonicalTransactionChain
.
enqueue
(
target
,
gasLimit
,
data
)
}
})
describe
(
'
when the sequencer inclusion period has not passed
'
,
()
=>
{
it
(
'
should revert if not called by the sequencer
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
connect
(
signer
).
appendQueueBatch
(
1
)
).
to
.
be
.
revertedWith
(
'
Queue transactions cannot be submitted during the sequencer inclusion period.
'
)
})
it
(
'
should succeed if called by the sequencer
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
connect
(
sequencer
).
appendQueueBatch
(
1
)
)
.
to
.
emit
(
CanonicalTransactionChain
,
'
QueueBatchAppended
'
)
.
withArgs
(
0
,
1
,
1
)
})
})
describe
(
'
when the sequencer inclusion period has passed
'
,
()
=>
{
beforeEach
(
async
()
=>
{
await
increaseEthTime
(
ethers
.
provider
,
FORCE_INCLUSION_PERIOD_SECONDS
*
2
)
})
it
(
'
should be able to append a single element
'
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
appendQueueBatch
(
1
))
.
to
.
emit
(
CanonicalTransactionChain
,
'
QueueBatchAppended
'
)
.
withArgs
(
0
,
1
,
1
)
})
it
(
`should be able to append
${
size
}
elements`
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
appendQueueBatch
(
size
))
.
to
.
emit
(
CanonicalTransactionChain
,
'
QueueBatchAppended
'
)
.
withArgs
(
0
,
size
,
size
)
})
it
(
`should be able to append
${
size
}
elements even if attempting to append
${
size
}
+ 1 elements`
,
async
()
=>
{
await
expect
(
CanonicalTransactionChain
.
appendQueueBatch
(
size
+
1
))
.
to
.
emit
(
CanonicalTransactionChain
,
'
QueueBatchAppended
'
)
.
withArgs
(
0
,
size
,
size
)
})
})
})
}
})
})
describe
(
'
verifyTransaction
'
,
()
=>
{
it
(
'
should successfully verify against a valid queue transaction appended by the sequencer
'
,
async
()
=>
{
const
entrypoint
=
NON_ZERO_ADDRESS
...
...
@@ -576,7 +486,6 @@ describe('CanonicalTransactionChain', () => {
await
CanonicalTransactionChain
.
enqueue
(
entrypoint
,
gasLimit
,
data
)
const
blockNumber
=
await
ethers
.
provider
.
getBlockNumber
()
await
increaseEthTime
(
ethers
.
provider
,
FORCE_INCLUSION_PERIOD_SECONDS
*
2
)
await
CanonicalTransactionChain
.
appendQueueBatch
(
1
)
...
...
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