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
a9db57ad
Commit
a9db57ad
authored
Mar 20, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix nits
⚙
parent
a4ae95f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
32 deletions
+39
-32
channel_builder_test.go
op-batcher/batcher/channel_builder_test.go
+3
-0
channel_manager_test.go
op-batcher/batcher/channel_manager_test.go
+32
-30
channel_out.go
op-node/rollup/derive/channel_out.go
+4
-2
No files found.
op-batcher/batcher/channel_builder_test.go
View file @
a9db57ad
...
@@ -419,6 +419,9 @@ func TestOutputFramesHappy(t *testing.T) {
...
@@ -419,6 +419,9 @@ func TestOutputFramesHappy(t *testing.T) {
// There should be many frames in the channel builder now
// There should be many frames in the channel builder now
require
.
Greater
(
t
,
cb
.
NumFrames
(),
1
)
require
.
Greater
(
t
,
cb
.
NumFrames
(),
1
)
for
_
,
frame
:=
range
cb
.
frames
{
require
.
Len
(
t
,
frame
.
data
,
int
(
channelConfig
.
MaxFrameSize
))
}
}
}
// TestMaxRLPBytesPerChannel tests the [channelBuilder.OutputFrames]
// TestMaxRLPBytesPerChannel tests the [channelBuilder.OutputFrames]
...
...
op-batcher/batcher/channel_manager_test.go
View file @
a9db57ad
...
@@ -156,8 +156,10 @@ func TestChannelManagerNextTxData(t *testing.T) {
...
@@ -156,8 +156,10 @@ func TestChannelManagerNextTxData(t *testing.T) {
require
.
Equal
(
t
,
expectedTxData
,
m
.
pendingTransactions
[
expectedChannelID
])
require
.
Equal
(
t
,
expectedTxData
,
m
.
pendingTransactions
[
expectedChannelID
])
}
}
// TestClearChannelManager tests clearing the channel manager.
// TestChannelManager_Clear tests clearing the channel manager.
func
TestClearChannelManager
(
t
*
testing
.
T
)
{
func
TestChannelManager_Clear
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
// Create a channel manager
// Create a channel manager
log
:=
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
log
:=
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
rng
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
rng
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
...
@@ -174,11 +176,11 @@ func TestClearChannelManager(t *testing.T) {
...
@@ -174,11 +176,11 @@ func TestClearChannelManager(t *testing.T) {
})
})
// Channel Manager state should be empty by default
// Channel Manager state should be empty by default
require
.
Empty
(
t
,
m
.
blocks
)
require
.
Empty
(
m
.
blocks
)
require
.
Equal
(
t
,
common
.
Hash
{},
m
.
tip
)
require
.
Equal
(
common
.
Hash
{},
m
.
tip
)
require
.
Nil
(
t
,
m
.
pendingChannel
)
require
.
Nil
(
m
.
pendingChannel
)
require
.
Empty
(
t
,
m
.
pendingTransactions
)
require
.
Empty
(
m
.
pendingTransactions
)
require
.
Empty
(
t
,
m
.
confirmedTransactions
)
require
.
Empty
(
m
.
confirmedTransactions
)
// Add a block to the channel manager
// Add a block to the channel manager
a
,
_
:=
derivetest
.
RandomL2Block
(
rng
,
4
)
a
,
_
:=
derivetest
.
RandomL2Block
(
rng
,
4
)
...
@@ -187,25 +189,25 @@ func TestClearChannelManager(t *testing.T) {
...
@@ -187,25 +189,25 @@ func TestClearChannelManager(t *testing.T) {
Hash
:
a
.
Hash
(),
Hash
:
a
.
Hash
(),
Number
:
a
.
NumberU64
(),
Number
:
a
.
NumberU64
(),
}
}
require
.
NoError
(
t
,
m
.
AddL2Block
(
a
))
require
.
NoError
(
m
.
AddL2Block
(
a
))
// Make sure there is a channel builder
// Make sure there is a channel builder
require
.
NoError
(
t
,
m
.
ensurePendingChannel
(
l1BlockID
))
require
.
NoError
(
m
.
ensurePendingChannel
(
l1BlockID
))
require
.
NotNil
(
t
,
m
.
pendingChannel
)
require
.
NotNil
(
m
.
pendingChannel
)
require
.
Equal
(
t
,
0
,
len
(
m
.
confirmedTransactions
)
)
require
.
Len
(
m
.
confirmedTransactions
,
0
)
// Process the blocks
// Process the blocks
// We should have a pending channel with 1 frame
// We should have a pending channel with 1 frame
// and no more blocks since processBlocks consumes
// and no more blocks since processBlocks consumes
// the list
// the list
require
.
NoError
(
t
,
m
.
processBlocks
())
require
.
NoError
(
m
.
processBlocks
())
require
.
NoError
(
t
,
m
.
pendingChannel
.
co
.
Flush
())
require
.
NoError
(
m
.
pendingChannel
.
co
.
Flush
())
require
.
NoError
(
t
,
m
.
pendingChannel
.
OutputFrames
())
require
.
NoError
(
m
.
pendingChannel
.
OutputFrames
())
_
,
err
:=
m
.
nextTxData
()
_
,
err
:=
m
.
nextTxData
()
require
.
NoError
(
t
,
err
)
require
.
NoError
(
err
)
require
.
Equal
(
t
,
0
,
len
(
m
.
blocks
)
)
require
.
Len
(
m
.
blocks
,
0
)
require
.
Equal
(
t
,
newL1Tip
,
m
.
tip
)
require
.
Equal
(
newL1Tip
,
m
.
tip
)
require
.
Equal
(
t
,
1
,
len
(
m
.
pendingTransactions
)
)
require
.
Len
(
m
.
pendingTransactions
,
1
)
// Add a new block so we can test clearing
// Add a new block so we can test clearing
// the channel manager with a full state
// the channel manager with a full state
...
@@ -213,19 +215,19 @@ func TestClearChannelManager(t *testing.T) {
...
@@ -213,19 +215,19 @@ func TestClearChannelManager(t *testing.T) {
Number
:
big
.
NewInt
(
1
),
Number
:
big
.
NewInt
(
1
),
ParentHash
:
a
.
Hash
(),
ParentHash
:
a
.
Hash
(),
},
nil
,
nil
,
nil
,
nil
)
},
nil
,
nil
,
nil
,
nil
)
require
.
NoError
(
t
,
m
.
AddL2Block
(
b
))
require
.
NoError
(
m
.
AddL2Block
(
b
))
require
.
Equal
(
t
,
1
,
len
(
m
.
blocks
)
)
require
.
Len
(
m
.
blocks
,
1
)
require
.
Equal
(
t
,
b
.
Hash
(),
m
.
tip
)
require
.
Equal
(
b
.
Hash
(),
m
.
tip
)
// Clear the channel manager
// Clear the channel manager
m
.
Clear
()
m
.
Clear
()
// Check that the entire channel manager state cleared
// Check that the entire channel manager state cleared
require
.
Empty
(
t
,
m
.
blocks
)
require
.
Empty
(
m
.
blocks
)
require
.
Equal
(
t
,
common
.
Hash
{},
m
.
tip
)
require
.
Equal
(
common
.
Hash
{},
m
.
tip
)
require
.
Nil
(
t
,
m
.
pendingChannel
)
require
.
Nil
(
m
.
pendingChannel
)
require
.
Empty
(
t
,
m
.
pendingTransactions
)
require
.
Empty
(
m
.
pendingTransactions
)
require
.
Empty
(
t
,
m
.
confirmedTransactions
)
require
.
Empty
(
m
.
confirmedTransactions
)
}
}
// TestChannelManagerTxConfirmed checks the [ChannelManager.TxConfirmed] function.
// TestChannelManagerTxConfirmed checks the [ChannelManager.TxConfirmed] function.
...
@@ -259,7 +261,7 @@ func TestChannelManagerTxConfirmed(t *testing.T) {
...
@@ -259,7 +261,7 @@ func TestChannelManagerTxConfirmed(t *testing.T) {
require
.
Equal
(
t
,
expectedTxData
,
returnedTxData
)
require
.
Equal
(
t
,
expectedTxData
,
returnedTxData
)
require
.
Equal
(
t
,
0
,
m
.
pendingChannel
.
NumFrames
())
require
.
Equal
(
t
,
0
,
m
.
pendingChannel
.
NumFrames
())
require
.
Equal
(
t
,
expectedTxData
,
m
.
pendingTransactions
[
expectedChannelID
])
require
.
Equal
(
t
,
expectedTxData
,
m
.
pendingTransactions
[
expectedChannelID
])
require
.
Equal
(
t
,
1
,
len
(
m
.
pendingTransactions
)
)
require
.
Len
(
t
,
m
.
pendingTransactions
,
1
)
// An unknown pending transaction should not be marked as confirmed
// An unknown pending transaction should not be marked as confirmed
// and should not be removed from the pending transactions map
// and should not be removed from the pending transactions map
...
@@ -270,14 +272,14 @@ func TestChannelManagerTxConfirmed(t *testing.T) {
...
@@ -270,14 +272,14 @@ func TestChannelManagerTxConfirmed(t *testing.T) {
blockID
:=
eth
.
BlockID
{
Number
:
0
,
Hash
:
common
.
Hash
{
0x69
}}
blockID
:=
eth
.
BlockID
{
Number
:
0
,
Hash
:
common
.
Hash
{
0x69
}}
m
.
TxConfirmed
(
unknownTxID
,
blockID
)
m
.
TxConfirmed
(
unknownTxID
,
blockID
)
require
.
Empty
(
t
,
m
.
confirmedTransactions
)
require
.
Empty
(
t
,
m
.
confirmedTransactions
)
require
.
Equal
(
t
,
1
,
len
(
m
.
pendingTransactions
)
)
require
.
Len
(
t
,
m
.
pendingTransactions
,
1
)
// Now let's mark the pending transaction as confirmed
// Now let's mark the pending transaction as confirmed
// and check that it is removed from the pending transactions map
// and check that it is removed from the pending transactions map
// and added to the confirmed transactions map
// and added to the confirmed transactions map
m
.
TxConfirmed
(
expectedChannelID
,
blockID
)
m
.
TxConfirmed
(
expectedChannelID
,
blockID
)
require
.
Empty
(
t
,
m
.
pendingTransactions
)
require
.
Empty
(
t
,
m
.
pendingTransactions
)
require
.
Equal
(
t
,
1
,
len
(
m
.
confirmedTransactions
)
)
require
.
Len
(
t
,
m
.
confirmedTransactions
,
1
)
require
.
Equal
(
t
,
blockID
,
m
.
confirmedTransactions
[
expectedChannelID
])
require
.
Equal
(
t
,
blockID
,
m
.
confirmedTransactions
[
expectedChannelID
])
}
}
...
@@ -307,7 +309,7 @@ func TestChannelManagerTxFailed(t *testing.T) {
...
@@ -307,7 +309,7 @@ func TestChannelManagerTxFailed(t *testing.T) {
require
.
Equal
(
t
,
expectedTxData
,
returnedTxData
)
require
.
Equal
(
t
,
expectedTxData
,
returnedTxData
)
require
.
Equal
(
t
,
0
,
m
.
pendingChannel
.
NumFrames
())
require
.
Equal
(
t
,
0
,
m
.
pendingChannel
.
NumFrames
())
require
.
Equal
(
t
,
expectedTxData
,
m
.
pendingTransactions
[
expectedChannelID
])
require
.
Equal
(
t
,
expectedTxData
,
m
.
pendingTransactions
[
expectedChannelID
])
require
.
Equal
(
t
,
1
,
len
(
m
.
pendingTransactions
)
)
require
.
Len
(
t
,
m
.
pendingTransactions
,
1
)
// Trying to mark an unknown pending transaction as failed
// Trying to mark an unknown pending transaction as failed
// shouldn't modify state
// shouldn't modify state
...
...
op-node/rollup/derive/channel_out.go
View file @
a9db57ad
...
@@ -19,8 +19,10 @@ var ErrNotDepositTx = errors.New("first transaction in block is not a deposit tx
...
@@ -19,8 +19,10 @@ var ErrNotDepositTx = errors.New("first transaction in block is not a deposit tx
var
ErrTooManyRLPBytes
=
errors
.
New
(
"batch would cause RLP bytes to go over limit"
)
var
ErrTooManyRLPBytes
=
errors
.
New
(
"batch would cause RLP bytes to go over limit"
)
// FrameV0OverHeadSize is the absolute minimum size of a frame.
// FrameV0OverHeadSize is the absolute minimum size of a frame.
// This is the fixed overhead frame size,
// This is the fixed overhead frame size, calculated as specified
// calculated as follows: 16 + 2 + 4 + 1 = 23 bytes.
// in the [Frame Format] specs: 16 + 2 + 4 + 1 = 23 bytes.
//
// [Frame Format]: https://github.com/ethereum-optimism/optimism/blob/develop/specs/derivation.md#frame-format
const
FrameV0OverHeadSize
=
23
const
FrameV0OverHeadSize
=
23
type
ChannelOut
struct
{
type
ChannelOut
struct
{
...
...
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