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
971387d1
Commit
971387d1
authored
Mar 23, 2023
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Use new API
parent
e354d5e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
17 deletions
+10
-17
driver.go
op-batcher/batcher/driver.go
+8
-14
driver_test.go
op-batcher/batcher/driver_test.go
+2
-3
No files found.
op-batcher/batcher/driver.go
View file @
971387d1
...
...
@@ -314,7 +314,7 @@ func (l *BatchSubmitter) loop() {
}
// Record TX Status
if
receipt
,
err
:=
l
.
S
endTransaction
(
l
.
ctx
,
txdata
.
Bytes
());
err
!=
nil
{
if
receipt
,
err
:=
l
.
s
endTransaction
(
l
.
ctx
,
txdata
.
Bytes
());
err
!=
nil
{
l
.
recordFailedTx
(
txdata
.
ID
(),
err
)
}
else
{
l
.
recordConfirmedTx
(
txdata
.
ID
(),
receipt
)
...
...
@@ -343,31 +343,25 @@ const networkTimeout = 2 * time.Second // How long a single network request can
// along with op-proposer changes to include the updated tx manager
const
txManagerTimeout
=
2
*
time
.
Minute
// How long the tx manager can take to send a transaction.
//
S
endTransaction creates & submits a transaction to the batch inbox address with the given `data`.
//
s
endTransaction creates & submits a transaction to the batch inbox address with the given `data`.
// It currently uses the underlying `txmgr` to handle transaction sending & price management.
// This is a blocking method. It should not be called concurrently.
func
(
l
*
BatchSubmitter
)
S
endTransaction
(
ctx
context
.
Context
,
data
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
func
(
l
*
BatchSubmitter
)
s
endTransaction
(
ctx
context
.
Context
,
data
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
// Do the gas estimation offline. A value of 0 will cause the [txmgr] to estimate the gas limit.
intrinsicGas
,
err
:=
core
.
IntrinsicGas
(
data
,
nil
,
false
,
true
,
true
,
false
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to calculate intrinsic gas: %w"
,
err
)
}
// Create the transaction
tx
,
err
:=
l
.
txMgr
.
CraftTx
(
ctx
,
txmgr
.
TxCandidate
{
// Send the transaction through the txmgr
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
txManagerTimeout
)
defer
cancel
()
if
receipt
,
err
:=
l
.
txMgr
.
Send
(
ctx
,
txmgr
.
TxCandidate
{
To
:
l
.
Rollup
.
BatchInboxAddress
,
TxData
:
data
,
From
:
l
.
From
,
GasLimit
:
intrinsicGas
,
})
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to create tx: %w"
,
err
)
}
// Send the transaction through the txmgr
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
txManagerTimeout
)
defer
cancel
()
if
receipt
,
err
:=
l
.
txMgr
.
Send
(
ctx
,
tx
);
err
!=
nil
{
});
err
!=
nil
{
l
.
log
.
Warn
(
"unable to publish tx"
,
"err"
,
err
,
"data_size"
,
len
(
data
))
return
nil
,
err
}
else
{
...
...
op-batcher/batcher/driver_test.go
View file @
971387d1
...
...
@@ -73,10 +73,9 @@ func TestBatchSubmitter_SendTransaction(t *testing.T) {
GasUsed
:
gas
,
}
txMgr
.
On
(
"CraftTx"
,
mock
.
Anything
,
candidate
)
.
Return
(
tx
,
nil
)
txMgr
.
On
(
"Send"
,
mock
.
Anything
,
tx
)
.
Return
(
&
expectedReceipt
,
nil
)
txMgr
.
On
(
"Send"
,
mock
.
Anything
,
candidate
)
.
Return
(
&
expectedReceipt
,
nil
)
receipt
,
err
:=
bs
.
S
endTransaction
(
context
.
Background
(),
tx
.
Data
())
receipt
,
err
:=
bs
.
s
endTransaction
(
context
.
Background
(),
tx
.
Data
())
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
receipt
,
&
expectedReceipt
)
}
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