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
4fe39597
Commit
4fe39597
authored
Oct 27, 2022
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address PR feedback
parent
40724cea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
channel.go
op-node/rollup/derive/channel.go
+2
-6
channel_test.go
op-node/rollup/derive/channel_test.go
+16
-0
No files found.
op-node/rollup/derive/channel.go
View file @
4fe39597
...
@@ -72,16 +72,12 @@ func (ch *Channel) AddFrame(frame Frame, l1InclusionBlock eth.L1BlockRef) error
...
@@ -72,16 +72,12 @@ func (ch *Channel) AddFrame(frame Frame, l1InclusionBlock eth.L1BlockRef) error
// Prune frames with a number higher than the closing frame number when we receive a closing frame
// Prune frames with a number higher than the closing frame number when we receive a closing frame
if
frame
.
IsLast
&&
ch
.
endFrameNumber
<
ch
.
highestFrameNumber
{
if
frame
.
IsLast
&&
ch
.
endFrameNumber
<
ch
.
highestFrameNumber
{
// Do a linear scan over saved inputs instead of ranging over ID numbers
// Do a linear scan over saved inputs instead of ranging over ID numbers
var
idsToPrune
[]
uint64
for
id
,
prunedFrame
:=
range
ch
.
inputs
{
for
id
,
prunedFrame
:=
range
ch
.
inputs
{
if
id
>=
uint64
(
ch
.
endFrameNumber
)
{
if
id
>=
uint64
(
ch
.
endFrameNumber
)
{
idsToPrune
=
append
(
idsToPrune
,
id
)
delete
(
ch
.
inputs
,
id
)
}
}
ch
.
size
-=
frameSize
(
prunedFrame
)
ch
.
size
-=
frameSize
(
prunedFrame
)
}
}
for
_
,
id
:=
range
idsToPrune
{
delete
(
ch
.
inputs
,
id
)
}
ch
.
highestFrameNumber
=
ch
.
endFrameNumber
ch
.
highestFrameNumber
=
ch
.
endFrameNumber
}
}
// Update highest seen frame number after pruning
// Update highest seen frame number after pruning
...
@@ -141,7 +137,7 @@ func (ch *Channel) Reader() io.Reader {
...
@@ -141,7 +137,7 @@ func (ch *Channel) Reader() io.Reader {
if
!
ok
{
if
!
ok
{
panic
(
"dev error in channel.Reader. Must be called after the channel is ready."
)
panic
(
"dev error in channel.Reader. Must be called after the channel is ready."
)
}
}
readers
=
append
(
readers
,
bytes
.
New
Buff
er
(
frame
.
Data
))
readers
=
append
(
readers
,
bytes
.
New
Read
er
(
frame
.
Data
))
}
}
return
io
.
MultiReader
(
readers
...
)
return
io
.
MultiReader
(
readers
...
)
}
}
...
...
op-node/rollup/derive/channel_test.go
View file @
4fe39597
...
@@ -61,6 +61,14 @@ func TestFrameValidity(t *testing.T) {
...
@@ -61,6 +61,14 @@ func TestFrameValidity(t *testing.T) {
shouldErr
:
[]
bool
{
false
,
true
},
shouldErr
:
[]
bool
{
false
,
true
},
sizes
:
[]
uint64
{
204
,
204
},
sizes
:
[]
uint64
{
204
,
204
},
},
},
{
name
:
"duplicate closing frames"
,
frames
:
[]
Frame
{
{
ID
:
id
,
FrameNumber
:
2
,
IsLast
:
true
,
Data
:
[]
byte
(
"four"
)},
{
ID
:
id
,
FrameNumber
:
2
,
IsLast
:
true
,
Data
:
[]
byte
(
"seven__"
)}},
shouldErr
:
[]
bool
{
false
,
true
},
sizes
:
[]
uint64
{
204
,
204
},
},
{
{
name
:
"frame past closing"
,
name
:
"frame past closing"
,
frames
:
[]
Frame
{
frames
:
[]
Frame
{
...
@@ -77,6 +85,14 @@ func TestFrameValidity(t *testing.T) {
...
@@ -77,6 +85,14 @@ func TestFrameValidity(t *testing.T) {
shouldErr
:
[]
bool
{
false
,
false
},
shouldErr
:
[]
bool
{
false
,
false
},
sizes
:
[]
uint64
{
207
,
204
},
sizes
:
[]
uint64
{
207
,
204
},
},
},
{
name
:
"multiple valid frames"
,
frames
:
[]
Frame
{
{
ID
:
id
,
FrameNumber
:
10
,
Data
:
[]
byte
(
"seven__"
)},
{
ID
:
id
,
FrameNumber
:
2
,
Data
:
[]
byte
(
"four"
)}},
shouldErr
:
[]
bool
{
false
,
false
},
sizes
:
[]
uint64
{
207
,
411
},
},
}
}
for
_
,
tc
:=
range
testCases
{
for
_
,
tc
:=
range
testCases
{
...
...
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