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
7472b5b1
Commit
7472b5b1
authored
Jan 25, 2023
by
Sebastian Stammler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Improve logging
parent
58593202
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
channel_manager.go
op-batcher/batcher/channel_manager.go
+16
-9
No files found.
op-batcher/batcher/channel_manager.go
View file @
7472b5b1
...
@@ -86,7 +86,7 @@ func (s *channelManager) TxFailed(id txID) {
...
@@ -86,7 +86,7 @@ func (s *channelManager) TxFailed(id txID) {
s
.
pendingChannel
.
PushFrame
(
id
,
data
)
s
.
pendingChannel
.
PushFrame
(
id
,
data
)
delete
(
s
.
pendingTransactions
,
id
)
delete
(
s
.
pendingTransactions
,
id
)
}
else
{
}
else
{
s
.
log
.
Warn
(
"unknown
frame
transaction marked as failed"
,
"id"
,
id
)
s
.
log
.
Warn
(
"unknown transaction marked as failed"
,
"id"
,
id
)
}
}
}
}
...
@@ -97,7 +97,7 @@ func (s *channelManager) TxFailed(id txID) {
...
@@ -97,7 +97,7 @@ func (s *channelManager) TxFailed(id txID) {
func
(
s
*
channelManager
)
TxConfirmed
(
id
txID
,
inclusionBlock
eth
.
BlockID
)
{
func
(
s
*
channelManager
)
TxConfirmed
(
id
txID
,
inclusionBlock
eth
.
BlockID
)
{
s
.
log
.
Trace
(
"marked transaction as confirmed"
,
"id"
,
id
,
"block"
,
inclusionBlock
)
s
.
log
.
Trace
(
"marked transaction as confirmed"
,
"id"
,
id
,
"block"
,
inclusionBlock
)
if
_
,
ok
:=
s
.
pendingTransactions
[
id
];
!
ok
{
if
_
,
ok
:=
s
.
pendingTransactions
[
id
];
!
ok
{
s
.
log
.
Info
(
"marked transaction as confirmed despite having no record of it
"
,
"id"
,
id
,
"block"
,
inclusionBlock
)
s
.
log
.
Warn
(
"unknown transaction marked as confirmed
"
,
"id"
,
id
,
"block"
,
inclusionBlock
)
// TODO: This can occur if we clear the channel while there are still pending transactions
// TODO: This can occur if we clear the channel while there are still pending transactions
// We need to keep track of stale transactions instead
// We need to keep track of stale transactions instead
return
return
...
@@ -108,13 +108,13 @@ func (s *channelManager) TxConfirmed(id txID, inclusionBlock eth.BlockID) {
...
@@ -108,13 +108,13 @@ func (s *channelManager) TxConfirmed(id txID, inclusionBlock eth.BlockID) {
// If this channel timed out, put the pending blocks back into the local saved blocks
// If this channel timed out, put the pending blocks back into the local saved blocks
// and then reset this state so it can try to build a new channel.
// and then reset this state so it can try to build a new channel.
if
s
.
pendingChannelIsTimedOut
()
{
if
s
.
pendingChannelIsTimedOut
()
{
s
.
log
.
Warn
(
"Channel timed out"
,
"chID"
,
s
.
pendingChannel
)
s
.
log
.
Warn
(
"Channel timed out"
,
"chID"
,
s
.
pendingChannel
.
ID
()
)
s
.
blocks
=
append
(
s
.
pendingChannel
.
Blocks
(),
s
.
blocks
...
)
s
.
blocks
=
append
(
s
.
pendingChannel
.
Blocks
(),
s
.
blocks
...
)
s
.
clearPendingChannel
()
s
.
clearPendingChannel
()
}
}
// If we are done with this channel, record that.
// If we are done with this channel, record that.
if
s
.
pendingChannelIsFullySubmitted
()
{
if
s
.
pendingChannelIsFullySubmitted
()
{
s
.
log
.
Info
(
"Channel is fully submitted"
,
"chID"
,
s
.
pendingChannel
)
s
.
log
.
Info
(
"Channel is fully submitted"
,
"chID"
,
s
.
pendingChannel
.
ID
()
)
s
.
clearPendingChannel
()
s
.
clearPendingChannel
()
}
}
}
}
...
@@ -163,6 +163,7 @@ func (s *channelManager) pendingChannelIsFullySubmitted() bool {
...
@@ -163,6 +163,7 @@ func (s *channelManager) pendingChannelIsFullySubmitted() bool {
// nextTxData pops off s.datas & handles updating the internal state
// nextTxData pops off s.datas & handles updating the internal state
func
(
s
*
channelManager
)
nextTxData
()
([]
byte
,
txID
,
error
)
{
func
(
s
*
channelManager
)
nextTxData
()
([]
byte
,
txID
,
error
)
{
if
s
.
pendingChannel
==
nil
||
!
s
.
pendingChannel
.
HasFrame
()
{
if
s
.
pendingChannel
==
nil
||
!
s
.
pendingChannel
.
HasFrame
()
{
s
.
log
.
Trace
(
"no next tx data"
)
return
nil
,
txID
{},
io
.
EOF
// TODO: not enough data error instead
return
nil
,
txID
{},
io
.
EOF
// TODO: not enough data error instead
}
}
...
@@ -184,7 +185,7 @@ func (s *channelManager) nextTxData() ([]byte, txID, error) {
...
@@ -184,7 +185,7 @@ func (s *channelManager) nextTxData() ([]byte, txID, error) {
// It may buffer very large channels as well.
// It may buffer very large channels as well.
func
(
s
*
channelManager
)
TxData
(
l1Head
eth
.
L1BlockRef
)
([]
byte
,
txID
,
error
)
{
func
(
s
*
channelManager
)
TxData
(
l1Head
eth
.
L1BlockRef
)
([]
byte
,
txID
,
error
)
{
dataPending
:=
s
.
pendingChannel
!=
nil
&&
s
.
pendingChannel
.
HasFrame
()
dataPending
:=
s
.
pendingChannel
!=
nil
&&
s
.
pendingChannel
.
HasFrame
()
s
.
log
.
Debug
(
"Requested tx data"
,
"l1Head"
,
l1Head
,
"data_pending"
,
dataPending
,
"block
_count
"
,
len
(
s
.
blocks
))
s
.
log
.
Debug
(
"Requested tx data"
,
"l1Head"
,
l1Head
,
"data_pending"
,
dataPending
,
"block
s_pending
"
,
len
(
s
.
blocks
))
// Short circuit if there is a pending frame.
// Short circuit if there is a pending frame.
if
dataPending
{
if
dataPending
{
...
@@ -207,7 +208,7 @@ func (s *channelManager) TxData(l1Head eth.L1BlockRef) ([]byte, txID, error) {
...
@@ -207,7 +208,7 @@ func (s *channelManager) TxData(l1Head eth.L1BlockRef) ([]byte, txID, error) {
}
}
if
err
:=
s
.
pendingChannel
.
OutputFrames
();
err
!=
nil
{
if
err
:=
s
.
pendingChannel
.
OutputFrames
();
err
!=
nil
{
return
nil
,
txID
{},
fmt
.
Errorf
(
"creat
e
frames with channel builder: %w"
,
err
)
return
nil
,
txID
{},
fmt
.
Errorf
(
"creat
ing
frames with channel builder: %w"
,
err
)
}
}
return
s
.
nextTxData
()
return
s
.
nextTxData
()
...
@@ -235,19 +236,25 @@ func (s *channelManager) addBlocks() error {
...
@@ -235,19 +236,25 @@ func (s *channelManager) addBlocks() error {
)
)
for
;
blockidx
<
len
(
s
.
blocks
);
blockidx
++
{
for
;
blockidx
<
len
(
s
.
blocks
);
blockidx
++
{
if
err
:=
s
.
pendingChannel
.
AddBlock
(
s
.
blocks
[
blockidx
]);
s
.
pendingChannel
.
IsFull
()
{
if
err
:=
s
.
pendingChannel
.
AddBlock
(
s
.
blocks
[
blockidx
]);
s
.
pendingChannel
.
IsFull
()
{
channelFull
=
true
break
break
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
return
fmt
.
Errorf
(
"adding block[%d] to channel builder: %w"
,
blockidx
,
err
)
return
fmt
.
Errorf
(
"adding block[%d] to channel builder: %w"
,
blockidx
,
err
)
}
}
}
}
blocksAdded
:=
blockidx
+
1
s
.
log
.
Debug
(
"Added blocks to channel"
,
"num_blocks"
,
blockidx
+
1
,
"channel_full"
,
channelFull
)
s
.
log
.
Debug
(
"Added blocks to channel"
,
if
blockidx
+
1
==
len
(
s
.
blocks
)
{
"blocks_added"
,
blocksAdded
,
"channel_full"
,
channelFull
,
"blocks_pending"
,
len
(
s
.
blocks
)
-
blocksAdded
,
)
if
blocksAdded
==
len
(
s
.
blocks
)
{
// all blocks processed, reuse slice
// all blocks processed, reuse slice
s
.
blocks
=
s
.
blocks
[
:
0
]
s
.
blocks
=
s
.
blocks
[
:
0
]
}
else
{
}
else
{
// remove processed blocks
// remove processed blocks
s
.
blocks
=
s
.
blocks
[
block
idx
+
1
:
]
s
.
blocks
=
s
.
blocks
[
block
sAdded
:
]
}
}
return
nil
return
nil
}
}
...
...
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