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
4a225203
Unverified
Commit
4a225203
authored
Sep 17, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(contracts): add ctc benchmark with queue tx
parent
9151df0f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
2 deletions
+55
-2
OVM_CanonicalTransactionChain.gas.spec.ts
...racts/L1/rollup/OVM_CanonicalTransactionChain.gas.spec.ts
+55
-2
No files found.
packages/contracts/test/contracts/L1/rollup/OVM_CanonicalTransactionChain.gas.spec.ts
View file @
4a225203
...
@@ -4,6 +4,7 @@ import { Signer, ContractFactory, Contract, constants } from 'ethers'
...
@@ -4,6 +4,7 @@ import { Signer, ContractFactory, Contract, constants } from 'ethers'
import
{
smockit
,
MockContract
}
from
'
@eth-optimism/smock
'
import
{
smockit
,
MockContract
}
from
'
@eth-optimism/smock
'
import
{
import
{
AppendSequencerBatchParams
,
AppendSequencerBatchParams
,
BatchContext
,
encodeAppendSequencerBatch
,
encodeAppendSequencerBatch
,
}
from
'
@eth-optimism/core-utils
'
}
from
'
@eth-optimism/core-utils
'
import
{
TransactionResponse
}
from
'
@ethersproject/abstract-provider
'
import
{
TransactionResponse
}
from
'
@ethersproject/abstract-provider
'
...
@@ -15,7 +16,6 @@ import {
...
@@ -15,7 +16,6 @@ import {
makeAddressManager
,
makeAddressManager
,
setProxyTarget
,
setProxyTarget
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
getEthTime
,
getEthTime
,
getNextBlockNumber
,
getNextBlockNumber
,
NON_ZERO_ADDRESS
,
NON_ZERO_ADDRESS
,
...
@@ -78,11 +78,14 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
...
@@ -78,11 +78,14 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
let
OVM_CanonicalTransactionChain
:
Contract
let
OVM_CanonicalTransactionChain
:
Contract
beforeEach
(
async
()
=>
{
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
OVM_CanonicalTransactionChain
=
OVM_CanonicalTransactionChain
=
await
Factory__OVM_CanonicalTransactionChain
.
deploy
(
await
Factory__OVM_CanonicalTransactionChain
.
deploy
(
AddressManager
.
address
,
AddressManager
.
address
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_SECONDS
,
FORCE_INCLUSION_PERIOD_BLOCKS
,
forceInclusionPeriodBlocks
,
MAX_GAS_LIMIT
MAX_GAS_LIMIT
)
)
...
@@ -196,6 +199,56 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
...
@@ -196,6 +199,56 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
(
receipt
.
gasUsed
.
toNumber
()
-
fixedCalldataCost
)
/
numTxs
(
receipt
.
gasUsed
.
toNumber
()
-
fixedCalldataCost
)
/
numTxs
)
)
}).
timeout
(
100000000
)
}).
timeout
(
100000000
)
it
(
'
100 Sequencer transactions and 100 Queue transactions in 100 contexts
'
,
async
()
=>
{
console
.
log
(
`Benchmark: 100 Sequencer transactions and 100 Queue transactions in 100 contexts`
)
const
transactionTemplate
=
'
0x
'
+
'
11
'
.
repeat
(
400
)
const
transactions
=
[]
const
numTxs
=
100
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
transactions
.
push
(
transactionTemplate
)
}
// Enqueue the transactions and record their contexts
const
target
=
NON_ZERO_ADDRESS
const
gasLimit
=
500
_000
const
data
=
'
0x
'
+
'
12
'
.
repeat
(
1234
)
const
numEnqueues
=
numTxs
const
queueContexts
:
BatchContext
[]
=
[]
for
(
let
i
=
0
;
i
<
numEnqueues
;
i
++
)
{
await
OVM_CanonicalTransactionChain
.
enqueue
(
target
,
gasLimit
,
data
)
queueContexts
.
push
({
blockNumber
:
(
await
getNextBlockNumber
(
ethers
.
provider
))
-
1
,
timestamp
:
await
getEthTime
(
ethers
.
provider
),
numSequencedTransactions
:
1
,
numSubsequentQueueTransactions
:
1
,
})
}
const
fixedCalldataCost
=
(
transactionTemplate
.
slice
(
2
).
length
/
2
)
*
16
*
numTxs
const
res
=
await
appendSequencerBatch
(
OVM_CanonicalTransactionChain
,
{
shouldStartAtElement
:
0
,
totalElementsToAppend
:
numTxs
+
numEnqueues
,
contexts
:
queueContexts
,
transactions
,
})
const
receipt
=
await
res
.
wait
()
console
.
log
(
'
Benchmark complete.
'
)
console
.
log
(
'
Gas used:
'
,
receipt
.
gasUsed
.
toNumber
())
console
.
log
(
'
Fixed calldata cost:
'
,
fixedCalldataCost
)
console
.
log
(
'
Non-calldata overhead gas cost per transaction:
'
,
(
receipt
.
gasUsed
.
toNumber
()
-
fixedCalldataCost
)
/
numTxs
)
}).
timeout
(
10
_000_000
)
})
})
describe
(
'
enqueue [ @skip-on-coverage ]
'
,
()
=>
{
describe
(
'
enqueue [ @skip-on-coverage ]
'
,
()
=>
{
...
...
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