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
1e751d4e
Commit
1e751d4e
authored
Dec 06, 2023
by
pcw109550
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Ensure unit tests to handle Span batches with unprotected txs
parent
9a798189
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
7 deletions
+37
-7
batch_test.go
op-node/rollup/derive/batch_test.go
+12
-3
span_batch_txs_test.go
op-node/rollup/derive/span_batch_txs_test.go
+21
-4
random.go
op-service/testutils/random.go
+4
-0
No files found.
op-node/rollup/derive/batch_test.go
View file @
1e751d4e
...
@@ -30,15 +30,24 @@ func RandomRawSpanBatch(rng *rand.Rand, chainId *big.Int) *RawSpanBatch {
...
@@ -30,15 +30,24 @@ func RandomRawSpanBatch(rng *rand.Rand, chainId *big.Int) *RawSpanBatch {
}
}
var
blockTxCounts
[]
uint64
var
blockTxCounts
[]
uint64
totalblockTxCounts
:=
uint64
(
0
)
totalblockTxCounts
:=
uint64
(
0
)
for
i
:=
0
;
i
<
int
(
blockCount
);
i
++
{
blockTxCounts
=
append
(
blockTxCounts
,
4
)
totalblockTxCounts
+=
4
for
i
:=
1
;
i
<
int
(
blockCount
);
i
++
{
blockTxCount
:=
uint64
(
rng
.
Intn
(
16
))
blockTxCount
:=
uint64
(
rng
.
Intn
(
16
))
blockTxCounts
=
append
(
blockTxCounts
,
blockTxCount
)
blockTxCounts
=
append
(
blockTxCounts
,
blockTxCount
)
totalblockTxCounts
+=
blockTxCount
totalblockTxCounts
+=
blockTxCount
}
}
s
igner
:=
types
.
NewLondonSigner
(
chainId
)
londonS
igner
:=
types
.
NewLondonSigner
(
chainId
)
var
txs
[][]
byte
var
txs
[][]
byte
for
i
:=
0
;
i
<
int
(
totalblockTxCounts
);
i
++
{
for
i
:=
0
;
i
<
int
(
totalblockTxCounts
);
i
++
{
tx
:=
testutils
.
RandomTx
(
rng
,
new
(
big
.
Int
)
.
SetUint64
(
rng
.
Uint64
()),
signer
)
var
tx
*
types
.
Transaction
// ensure unprotected txs are included
if
i
<
4
||
testutils
.
RandomBool
(
rng
)
{
tx
=
testutils
.
RandomLegacyTxNotProtected
(
rng
)
}
else
{
tx
=
testutils
.
RandomTx
(
rng
,
new
(
big
.
Int
)
.
SetUint64
(
rng
.
Uint64
()),
londonSigner
)
}
rawTx
,
err
:=
tx
.
MarshalBinary
()
rawTx
,
err
:=
tx
.
MarshalBinary
()
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
"MarshalBinary:"
+
err
.
Error
())
panic
(
"MarshalBinary:"
+
err
.
Error
())
...
...
op-node/rollup/derive/span_batch_txs_test.go
View file @
1e751d4e
...
@@ -301,19 +301,36 @@ func TestSpanBatchTxsRecoverV(t *testing.T) {
...
@@ -301,19 +301,36 @@ func TestSpanBatchTxsRecoverV(t *testing.T) {
rng
:=
rand
.
New
(
rand
.
NewSource
(
0x123
))
rng
:=
rand
.
New
(
rand
.
NewSource
(
0x123
))
chainID
:=
big
.
NewInt
(
rng
.
Int63n
(
1000
))
chainID
:=
big
.
NewInt
(
rng
.
Int63n
(
1000
))
s
igner
:=
types
.
NewLondonSigner
(
chainID
)
londonS
igner
:=
types
.
NewLondonSigner
(
chainID
)
totalblockTxCount
:=
rng
.
Intn
(
100
)
totalblockTxCount
:=
20
+
rng
.
Intn
(
100
)
var
spanBatchTxs
spanBatchTxs
var
spanBatchTxs
spanBatchTxs
var
txTypes
[]
int
var
txTypes
[]
int
var
txSigs
[]
spanBatchSignature
var
txSigs
[]
spanBatchSignature
var
originalVs
[]
uint64
var
originalVs
[]
uint64
yParityBits
:=
new
(
big
.
Int
)
yParityBits
:=
new
(
big
.
Int
)
protectedBits
:=
new
(
big
.
Int
)
totalLegacyTxCount
:=
0
for
idx
:=
0
;
idx
<
totalblockTxCount
;
idx
++
{
for
idx
:=
0
;
idx
<
totalblockTxCount
;
idx
++
{
tx
:=
testutils
.
RandomTx
(
rng
,
new
(
big
.
Int
)
.
SetUint64
(
rng
.
Uint64
()),
signer
)
var
tx
*
types
.
Transaction
txTypes
=
append
(
txTypes
,
int
(
tx
.
Type
()))
// ensure unprotected txs are included
if
idx
<
4
||
testutils
.
RandomBool
(
rng
)
{
tx
=
testutils
.
RandomLegacyTxNotProtected
(
rng
)
}
else
{
tx
=
testutils
.
RandomTx
(
rng
,
new
(
big
.
Int
)
.
SetUint64
(
rng
.
Uint64
()),
londonSigner
)
}
txType
:=
tx
.
Type
()
txTypes
=
append
(
txTypes
,
int
(
txType
))
var
txSig
spanBatchSignature
var
txSig
spanBatchSignature
v
,
r
,
s
:=
tx
.
RawSignatureValues
()
v
,
r
,
s
:=
tx
.
RawSignatureValues
()
if
txType
==
types
.
LegacyTxType
{
protectedBit
:=
uint
(
0
)
if
tx
.
Protected
()
{
protectedBit
=
uint
(
1
)
}
protectedBits
.
SetBit
(
protectedBits
,
int
(
totalLegacyTxCount
),
protectedBit
)
totalLegacyTxCount
++
}
// Do not fill in txSig.V
// Do not fill in txSig.V
txSig
.
r
,
_
=
uint256
.
FromBig
(
r
)
txSig
.
r
,
_
=
uint256
.
FromBig
(
r
)
txSig
.
s
,
_
=
uint256
.
FromBig
(
s
)
txSig
.
s
,
_
=
uint256
.
FromBig
(
s
)
...
...
op-service/testutils/random.go
View file @
1e751d4e
...
@@ -157,6 +157,10 @@ func RandomTx(rng *rand.Rand, baseFee *big.Int, signer types.Signer) *types.Tran
...
@@ -157,6 +157,10 @@ func RandomTx(rng *rand.Rand, baseFee *big.Int, signer types.Signer) *types.Tran
return
tx
return
tx
}
}
func
RandomLegacyTxNotProtected
(
rng
*
rand
.
Rand
)
*
types
.
Transaction
{
return
RandomLegacyTx
(
rng
,
types
.
HomesteadSigner
{})
}
func
RandomLegacyTx
(
rng
*
rand
.
Rand
,
signer
types
.
Signer
)
*
types
.
Transaction
{
func
RandomLegacyTx
(
rng
*
rand
.
Rand
,
signer
types
.
Signer
)
*
types
.
Transaction
{
key
:=
InsecureRandomKey
(
rng
)
key
:=
InsecureRandomKey
(
rng
)
txData
:=
&
types
.
LegacyTx
{
txData
:=
&
types
.
LegacyTx
{
...
...
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