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
a3da36fe
Commit
a3da36fe
authored
Mar 22, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
txmgr fixes
parent
ddaf933a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
9 deletions
+29
-9
driver.go
op-batcher/batcher/driver.go
+0
-1
driver_test.go
op-batcher/batcher/driver_test.go
+0
-1
txmgr.go
op-service/txmgr/txmgr.go
+21
-5
txmgr_test.go
op-service/txmgr/txmgr_test.go
+8
-2
No files found.
op-batcher/batcher/driver.go
View file @
a3da36fe
...
@@ -357,7 +357,6 @@ func (l *BatchSubmitter) SendTransaction(ctx context.Context, data []byte) (*typ
...
@@ -357,7 +357,6 @@ func (l *BatchSubmitter) SendTransaction(ctx context.Context, data []byte) (*typ
To
:
l
.
Rollup
.
BatchInboxAddress
,
To
:
l
.
Rollup
.
BatchInboxAddress
,
TxData
:
data
,
TxData
:
data
,
From
:
l
.
From
,
From
:
l
.
From
,
ChainID
:
l
.
Rollup
.
L1ChainID
,
GasLimit
:
gas
,
GasLimit
:
gas
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
op-batcher/batcher/driver_test.go
View file @
a3da36fe
...
@@ -47,7 +47,6 @@ func TestSendTransaction(t *testing.T) {
...
@@ -47,7 +47,6 @@ func TestSendTransaction(t *testing.T) {
To
:
batcherInboxAddress
,
To
:
batcherInboxAddress
,
TxData
:
txData
,
TxData
:
txData
,
From
:
sender
,
From
:
sender
,
ChainID
:
chainID
,
GasLimit
:
uint64
(
0
),
GasLimit
:
uint64
(
0
),
}
}
...
...
op-service/txmgr/txmgr.go
View file @
a3da36fe
...
@@ -109,13 +109,16 @@ type ETHBackend interface {
...
@@ -109,13 +109,16 @@ type ETHBackend interface {
/// EstimateGas returns an estimate of the amount of gas needed to execute the given
/// EstimateGas returns an estimate of the amount of gas needed to execute the given
/// transaction against the current pending block.
/// transaction against the current pending block.
EstimateGas
(
ctx
context
.
Context
,
msg
ethereum
.
CallMsg
)
(
uint64
,
error
)
EstimateGas
(
ctx
context
.
Context
,
msg
ethereum
.
CallMsg
)
(
uint64
,
error
)
// ChainID returns the chain ID for this ethereum chain.
ChainID
(
ctx
context
.
Context
)
(
*
big
.
Int
,
error
)
}
}
// SimpleTxManager is a implementation of TxManager that performs linear fee
// SimpleTxManager is a implementation of TxManager that performs linear fee
// bumping of a tx until it confirms.
// bumping of a tx until it confirms.
type
SimpleTxManager
struct
{
type
SimpleTxManager
struct
{
Config
// embed the config directly
Config
// embed the config directly
name
string
name
string
chainID
*
big
.
Int
backend
ETHBackend
backend
ETHBackend
l
log
.
Logger
l
log
.
Logger
...
@@ -132,8 +135,6 @@ type TxCandidate struct {
...
@@ -132,8 +135,6 @@ type TxCandidate struct {
GasLimit
uint64
GasLimit
uint64
// From is the sender (or `from`) of the constructed tx.
// From is the sender (or `from`) of the constructed tx.
From
common
.
Address
From
common
.
Address
/// ChainID is the chain ID to be used in the constructed tx.
ChainID
*
big
.
Int
}
}
// calcGasTipAndFeeCap queries L1 to determine what a suitable miner tip & basefee limit would be for timely inclusion
// calcGasTipAndFeeCap queries L1 to determine what a suitable miner tip & basefee limit would be for timely inclusion
...
@@ -183,8 +184,19 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (*
...
@@ -183,8 +184,19 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (*
return
nil
,
fmt
.
Errorf
(
"failed to get nonce: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to get nonce: %w"
,
err
)
}
}
// If the configured chain ID is nil (can occur if the fetch fails in the constructor),
// we need to try to fetch it again from the backend.
if
m
.
chainID
==
nil
{
childCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
m
.
Config
.
NetworkTimeout
)
m
.
chainID
,
err
=
m
.
backend
.
ChainID
(
childCtx
)
cancel
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to get chain ID: %w"
,
err
)
}
}
rawTx
:=
&
types
.
DynamicFeeTx
{
rawTx
:=
&
types
.
DynamicFeeTx
{
ChainID
:
candidate
.
C
hainID
,
ChainID
:
m
.
c
hainID
,
Nonce
:
nonce
,
Nonce
:
nonce
,
To
:
&
candidate
.
To
,
To
:
&
candidate
.
To
,
GasTipCap
:
gasTipCap
,
GasTipCap
:
gasTipCap
,
...
@@ -316,7 +328,11 @@ func NewSimpleTxManager(name string, l log.Logger, cfg Config, backend ETHBacken
...
@@ -316,7 +328,11 @@ func NewSimpleTxManager(name string, l log.Logger, cfg Config, backend ETHBacken
cfg
.
NetworkTimeout
=
2
*
time
.
Second
cfg
.
NetworkTimeout
=
2
*
time
.
Second
}
}
// On error, ignore. We will try to get the chainID again when used.
chainID
,
_
:=
backend
.
ChainID
(
context
.
Background
())
return
&
SimpleTxManager
{
return
&
SimpleTxManager
{
chainID
:
chainID
,
name
:
name
,
name
:
name
,
Config
:
cfg
,
Config
:
cfg
,
backend
:
backend
,
backend
:
backend
,
...
...
op-service/txmgr/txmgr_test.go
View file @
a3da36fe
...
@@ -54,13 +54,11 @@ func newTestHarness(t *testing.T) *testHarness {
...
@@ -54,13 +54,11 @@ func newTestHarness(t *testing.T) *testHarness {
// createTxCandidate creates a mock [TxCandidate].
// createTxCandidate creates a mock [TxCandidate].
func
(
h
testHarness
)
createTxCandidate
()
TxCandidate
{
func
(
h
testHarness
)
createTxCandidate
()
TxCandidate
{
inbox
:=
common
.
HexToAddress
(
"0x42000000000000000000000000000000000000ff"
)
inbox
:=
common
.
HexToAddress
(
"0x42000000000000000000000000000000000000ff"
)
chainID
:=
big
.
NewInt
(
1
)
sender
:=
common
.
HexToAddress
(
"0xdeadbeef"
)
sender
:=
common
.
HexToAddress
(
"0xdeadbeef"
)
return
TxCandidate
{
return
TxCandidate
{
To
:
inbox
,
To
:
inbox
,
TxData
:
[]
byte
{
0x00
,
0x01
,
0x02
},
TxData
:
[]
byte
{
0x00
,
0x01
,
0x02
},
From
:
sender
,
From
:
sender
,
ChainID
:
chainID
,
GasLimit
:
uint64
(
1337
),
GasLimit
:
uint64
(
1337
),
}
}
}
}
...
@@ -210,6 +208,10 @@ func (b *mockBackend) NonceAt(ctx context.Context, account common.Address, block
...
@@ -210,6 +208,10 @@ func (b *mockBackend) NonceAt(ctx context.Context, account common.Address, block
return
0
,
nil
return
0
,
nil
}
}
func
(
*
mockBackend
)
ChainID
(
ctx
context
.
Context
)
(
*
big
.
Int
,
error
)
{
return
big
.
NewInt
(
1
),
nil
}
// TransactionReceipt queries the mockBackend for a mined txHash. If none is
// TransactionReceipt queries the mockBackend for a mined txHash. If none is
// found, nil is returned for both return values. Otherwise, it retruns a
// found, nil is returned for both return values. Otherwise, it retruns a
// receipt containing the txHash and the gasFeeCap used in the GasUsed to make
// receipt containing the txHash and the gasFeeCap used in the GasUsed to make
...
@@ -652,6 +654,10 @@ func (b *failingBackend) NonceAt(_ context.Context, _ common.Address, _ *big.Int
...
@@ -652,6 +654,10 @@ func (b *failingBackend) NonceAt(_ context.Context, _ common.Address, _ *big.Int
return
0
,
errors
.
New
(
"unimplemented"
)
return
0
,
errors
.
New
(
"unimplemented"
)
}
}
func
(
b
*
failingBackend
)
ChainID
(
ctx
context
.
Context
)
(
*
big
.
Int
,
error
)
{
return
nil
,
errors
.
New
(
"unimplemented"
)
}
// TestWaitMinedReturnsReceiptAfterFailure asserts that WaitMined is able to
// TestWaitMinedReturnsReceiptAfterFailure asserts that WaitMined is able to
// recover from failed calls to the backend. It uses the failedBackend to
// recover from failed calls to the backend. It uses the failedBackend to
// simulate an rpc call failure, followed by the successful return of a receipt.
// simulate an rpc call failure, followed by the successful return of a receipt.
...
...
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