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
90435d07
Unverified
Commit
90435d07
authored
Jan 02, 2025
by
Matthew Slipper
Committed by
GitHub
Jan 02, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Fix concurrent map write (#13527)
mtx on channel_manager too
parent
3772b5f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
channel_manager.go
op-batcher/batcher/channel_manager.go
+11
-0
No files found.
op-batcher/batcher/channel_manager.go
View file @
90435d07
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"fmt"
"fmt"
"io"
"io"
"math"
"math"
"sync"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
...
@@ -55,6 +56,8 @@ type channelManager struct {
...
@@ -55,6 +56,8 @@ type channelManager struct {
channelQueue
[]
*
channel
channelQueue
[]
*
channel
// used to lookup channels by tx ID upon tx success / failure
// used to lookup channels by tx ID upon tx success / failure
txChannels
map
[
string
]
*
channel
txChannels
map
[
string
]
*
channel
mtx
sync
.
Mutex
}
}
func
NewChannelManager
(
log
log
.
Logger
,
metr
metrics
.
Metricer
,
cfgProvider
ChannelConfigProvider
,
rollupCfg
*
rollup
.
Config
)
*
channelManager
{
func
NewChannelManager
(
log
log
.
Logger
,
metr
metrics
.
Metricer
,
cfgProvider
ChannelConfigProvider
,
rollupCfg
*
rollup
.
Config
)
*
channelManager
{
...
@@ -93,6 +96,9 @@ func (s *channelManager) pendingBlocks() int {
...
@@ -93,6 +96,9 @@ func (s *channelManager) pendingBlocks() int {
// TxFailed records a transaction as failed. It will attempt to resubmit the data
// TxFailed records a transaction as failed. It will attempt to resubmit the data
// in the failed transaction.
// in the failed transaction.
func
(
s
*
channelManager
)
TxFailed
(
_id
txID
)
{
func
(
s
*
channelManager
)
TxFailed
(
_id
txID
)
{
s
.
mtx
.
Lock
()
defer
s
.
mtx
.
Unlock
()
id
:=
_id
.
String
()
id
:=
_id
.
String
()
if
channel
,
ok
:=
s
.
txChannels
[
id
];
ok
{
if
channel
,
ok
:=
s
.
txChannels
[
id
];
ok
{
delete
(
s
.
txChannels
,
id
)
delete
(
s
.
txChannels
,
id
)
...
@@ -105,6 +111,8 @@ func (s *channelManager) TxFailed(_id txID) {
...
@@ -105,6 +111,8 @@ func (s *channelManager) TxFailed(_id txID) {
// TxConfirmed marks a transaction as confirmed on L1. Only if the channel timed out
// TxConfirmed marks a transaction as confirmed on L1. Only if the channel timed out
// the channelManager's state is modified.
// the channelManager's state is modified.
func
(
s
*
channelManager
)
TxConfirmed
(
_id
txID
,
inclusionBlock
eth
.
BlockID
)
{
func
(
s
*
channelManager
)
TxConfirmed
(
_id
txID
,
inclusionBlock
eth
.
BlockID
)
{
s
.
mtx
.
Lock
()
defer
s
.
mtx
.
Unlock
()
id
:=
_id
.
String
()
id
:=
_id
.
String
()
if
channel
,
ok
:=
s
.
txChannels
[
id
];
ok
{
if
channel
,
ok
:=
s
.
txChannels
[
id
];
ok
{
...
@@ -191,6 +199,9 @@ func (s *channelManager) nextTxData(channel *channel) (txData, error) {
...
@@ -191,6 +199,9 @@ func (s *channelManager) nextTxData(channel *channel) (txData, error) {
// When switching DA type, the channelManager state will be rebuilt
// When switching DA type, the channelManager state will be rebuilt
// with a new ChannelConfig.
// with a new ChannelConfig.
func
(
s
*
channelManager
)
TxData
(
l1Head
eth
.
BlockID
)
(
txData
,
error
)
{
func
(
s
*
channelManager
)
TxData
(
l1Head
eth
.
BlockID
)
(
txData
,
error
)
{
s
.
mtx
.
Lock
()
defer
s
.
mtx
.
Unlock
()
channel
,
err
:=
s
.
getReadyChannel
(
l1Head
)
channel
,
err
:=
s
.
getReadyChannel
(
l1Head
)
if
err
!=
nil
{
if
err
!=
nil
{
return
emptyTxData
,
err
return
emptyTxData
,
err
...
...
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