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
f03327d6
Commit
f03327d6
authored
Nov 30, 2023
by
Tei Im
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TestBatchEquivalence
parent
9b2d40bd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
140 additions
and
0 deletions
+140
-0
span_batch_test.go
op-e2e/actions/span_batch_test.go
+140
-0
No files found.
op-e2e/actions/span_batch_test.go
View file @
f03327d6
...
@@ -586,3 +586,143 @@ func TestSpanBatchLowThroughputChain(gt *testing.T) {
...
@@ -586,3 +586,143 @@ func TestSpanBatchLowThroughputChain(gt *testing.T) {
require
.
Equal
(
t
,
verifier
.
L2Unsafe
(),
verifier
.
L2Safe
())
require
.
Equal
(
t
,
verifier
.
L2Unsafe
(),
verifier
.
L2Safe
())
require
.
Equal
(
t
,
sequencer
.
L2Safe
(),
verifier
.
L2Safe
())
require
.
Equal
(
t
,
sequencer
.
L2Safe
(),
verifier
.
L2Safe
())
}
}
func
TestBatchEquivalence
(
gt
*
testing
.
T
)
{
t
:=
NewDefaultTesting
(
gt
)
log
:=
testlog
.
Logger
(
t
,
log
.
LvlError
)
p
:=
&
e2eutils
.
TestParams
{
MaxSequencerDrift
:
20
,
// larger than L1 block time we simulate in this test (12)
SequencerWindowSize
:
24
,
ChannelTimeout
:
20
,
L1BlockTime
:
12
,
}
// Delta activated deploy config
dp
:=
e2eutils
.
MakeDeployParams
(
t
,
p
)
minTs
:=
hexutil
.
Uint64
(
0
)
dp
.
DeployConfig
.
L2GenesisDeltaTimeOffset
=
&
minTs
sd
:=
e2eutils
.
Setup
(
t
,
dp
,
defaultAlloc
)
// Delta deactivated deploy config
//dp2 := e2eutils.MakeDeployParams(t, p)
//dp2.DeployConfig.L2GenesisDeltaTimeOffset = nil
//sd2 := sd
//sd2.RollupCfg.Genesis = sd.RollupCfg.Genesis
rcfg2
:=
*
sd
.
RollupCfg
rcfg2
.
DeltaTime
=
nil
sd2
:=
&
e2eutils
.
SetupData
{
L1Cfg
:
sd
.
L1Cfg
,
L2Cfg
:
sd
.
L2Cfg
,
RollupCfg
:
&
rcfg2
,
DeploymentsL1
:
sd
.
DeploymentsL1
,
}
// Setup sequencer
miner
,
seqEngine
,
sequencer
:=
setupSequencerTest
(
t
,
sd
,
log
)
rollupSeqCl
:=
sequencer
.
RollupClient
()
seqEngCl
:=
seqEngine
.
EthClient
()
// Setup Delta activated verifier
_
,
verifier
:=
setupVerifier
(
t
,
sd
,
log
,
miner
.
L1Client
(
t
,
sd
.
RollupCfg
),
&
sync
.
Config
{})
// Setup Delta deactivated verifier
_
,
verifier2
:=
setupVerifier
(
t
,
sd2
,
log
,
miner
.
L1Client
(
t
,
sd2
.
RollupCfg
),
&
sync
.
Config
{})
// Setup Delta activated batcher
batcher
:=
NewL2Batcher
(
log
,
sd
.
RollupCfg
,
&
BatcherCfg
{
MinL1TxSize
:
0
,
MaxL1TxSize
:
128
_000
,
BatcherKey
:
dp
.
Secrets
.
Batcher
,
},
rollupSeqCl
,
miner
.
EthClient
(),
seqEngine
.
EthClient
(),
seqEngine
.
EngineClient
(
t
,
sd
.
RollupCfg
))
// Setup Delta deactivated batcher
batcher2
:=
NewL2Batcher
(
log
,
sd2
.
RollupCfg
,
&
BatcherCfg
{
MinL1TxSize
:
0
,
MaxL1TxSize
:
128
_000
,
BatcherKey
:
dp
.
Secrets
.
Batcher
,
},
rollupSeqCl
,
miner
.
EthClient
(),
seqEngine
.
EthClient
(),
seqEngine
.
EngineClient
(
t
,
sd2
.
RollupCfg
))
const
numTestUsers
=
5
var
privKeys
[
numTestUsers
]
*
ecdsa
.
PrivateKey
var
addrs
[
numTestUsers
]
common
.
Address
for
i
:=
0
;
i
<
numTestUsers
;
i
++
{
// Create a new test account
privateKey
,
err
:=
dp
.
Secrets
.
Wallet
.
PrivateKey
(
accounts
.
Account
{
URL
:
accounts
.
URL
{
Path
:
fmt
.
Sprintf
(
"m/44'/60'/0'/0/%d"
,
10
+
i
),
},
})
privKeys
[
i
]
=
privateKey
addr
:=
crypto
.
PubkeyToAddress
(
privateKey
.
PublicKey
)
require
.
NoError
(
t
,
err
)
addrs
[
i
]
=
addr
}
miner
.
ActEmptyBlock
(
t
)
sequencer
.
ActL1HeadSignal
(
t
)
sequencer
.
ActL2PipelineFull
(
t
)
totalTxCount
:=
0
// Build random blocks
for
sequencer
.
derivation
.
UnsafeL2Head
()
.
L1Origin
.
Number
<
sequencer
.
l1State
.
L1Head
()
.
Number
{
sequencer
.
ActL2StartBlock
(
t
)
// fill the block with random number of L2 txs
for
j
:=
0
;
j
<
rand
.
Intn
(
3
);
j
++
{
userIdx
:=
totalTxCount
%
numTestUsers
signer
:=
types
.
LatestSigner
(
sd
.
L2Cfg
.
Config
)
data
:=
make
([]
byte
,
rand
.
Intn
(
100
))
_
,
err
:=
crand
.
Read
(
data
[
:
])
// fill with random bytes
require
.
NoError
(
t
,
err
)
gas
,
err
:=
core
.
IntrinsicGas
(
data
,
nil
,
false
,
true
,
true
,
false
)
require
.
NoError
(
t
,
err
)
baseFee
:=
seqEngine
.
l2Chain
.
CurrentBlock
()
.
BaseFee
nonce
,
err
:=
seqEngCl
.
PendingNonceAt
(
t
.
Ctx
(),
addrs
[
userIdx
])
require
.
NoError
(
t
,
err
)
tx
:=
types
.
MustSignNewTx
(
privKeys
[
userIdx
],
signer
,
&
types
.
DynamicFeeTx
{
ChainID
:
sd
.
L2Cfg
.
Config
.
ChainID
,
Nonce
:
nonce
,
GasTipCap
:
big
.
NewInt
(
2
*
params
.
GWei
),
GasFeeCap
:
new
(
big
.
Int
)
.
Add
(
new
(
big
.
Int
)
.
Mul
(
baseFee
,
big
.
NewInt
(
2
)),
big
.
NewInt
(
2
*
params
.
GWei
)),
Gas
:
gas
,
To
:
&
dp
.
Addresses
.
Bob
,
Value
:
big
.
NewInt
(
0
),
Data
:
data
,
})
require
.
NoError
(
gt
,
seqEngCl
.
SendTransaction
(
t
.
Ctx
(),
tx
))
seqEngine
.
ActL2IncludeTx
(
addrs
[
userIdx
])(
t
)
totalTxCount
+=
1
}
sequencer
.
ActL2EndBlock
(
t
)
}
// Submit SpanBatch
batcher
.
ActSubmitAll
(
t
)
miner
.
ActL1StartBlock
(
12
)(
t
)
miner
.
ActL1IncludeTx
(
dp
.
Addresses
.
Batcher
)(
t
)
miner
.
ActL1EndBlock
(
t
)
// Run derivation pipeline for verifiers
verifier
.
ActL1HeadSignal
(
t
)
verifier
.
ActL2PipelineFull
(
t
)
verifier2
.
ActL1HeadSignal
(
t
)
verifier2
.
ActL2PipelineFull
(
t
)
// Delta activated verifier must be synced
require
.
Equal
(
t
,
verifier
.
L2Safe
(),
sequencer
.
L2Unsafe
())
// Delta deactivated verifier could not derive SpanBatch
require
.
Equal
(
t
,
verifier2
.
L2Safe
()
.
Number
,
uint64
(
0
))
// Submit SingularBatches
batcher2
.
ActSubmitAll
(
t
)
miner
.
ActL1StartBlock
(
12
)(
t
)
miner
.
ActL1IncludeTx
(
dp
.
Addresses
.
Batcher
)(
t
)
miner
.
ActL1EndBlock
(
t
)
// Run derivation pipeline for verifiers
verifier
.
ActL1HeadSignal
(
t
)
verifier
.
ActL2PipelineFull
(
t
)
verifier2
.
ActL1HeadSignal
(
t
)
verifier2
.
ActL2PipelineFull
(
t
)
// Delta deactivated verifier must be synced
require
.
Equal
(
t
,
verifier
.
L2Safe
(),
verifier2
.
L2Safe
())
}
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