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
0e227c69
Unverified
Commit
0e227c69
authored
Jul 10, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Make action test proposer tx handling use pending block when estimating gas
parent
ef1ba6b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
l2_proposer.go
op-e2e/actions/l2_proposer.go
+35
-1
No files found.
op-e2e/actions/l2_proposer.go
View file @
0e227c69
...
...
@@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
...
...
@@ -92,7 +93,7 @@ func (p *L2Proposer) sendTx(t Testing, data []byte) {
nonce
,
err
:=
p
.
l1
.
NonceAt
(
t
.
Ctx
(),
p
.
address
,
nil
)
require
.
NoError
(
t
,
err
)
gasLimit
,
err
:=
p
.
l1
.
EstimateGas
(
t
.
Ctx
()
,
ethereum
.
CallMsg
{
gasLimit
,
err
:=
estimateGasPending
(
t
.
Ctx
(),
p
.
l1
,
ethereum
.
CallMsg
{
From
:
p
.
address
,
To
:
&
p
.
contractAddr
,
GasFeeCap
:
gasFeeCap
,
...
...
@@ -120,6 +121,39 @@ func (p *L2Proposer) sendTx(t Testing, data []byte) {
p
.
lastTx
=
tx
.
Hash
()
}
// estimateGasPending calls eth_estimateGas specifying the pending block. This is required for transactions from the
// proposer because they include a reference to the latest block which isn't available via `BLOCKHASH` if `latest` is
// used. In production code, the proposer waits until another L1 block is published but in e2e tests no new L1 blocks
// will be created so pending must be used.
func
estimateGasPending
(
ctx
context
.
Context
,
ec
*
ethclient
.
Client
,
msg
ethereum
.
CallMsg
)
(
uint64
,
error
)
{
var
hex
hexutil
.
Uint64
err
:=
ec
.
Client
()
.
CallContext
(
ctx
,
&
hex
,
"eth_estimateGas"
,
toCallArg
(
msg
),
"pending"
)
if
err
!=
nil
{
return
0
,
err
}
return
uint64
(
hex
),
nil
}
func
toCallArg
(
msg
ethereum
.
CallMsg
)
interface
{}
{
arg
:=
map
[
string
]
interface
{}{
"from"
:
msg
.
From
,
"to"
:
msg
.
To
,
}
if
len
(
msg
.
Data
)
>
0
{
arg
[
"data"
]
=
hexutil
.
Bytes
(
msg
.
Data
)
}
if
msg
.
Value
!=
nil
{
arg
[
"value"
]
=
(
*
hexutil
.
Big
)(
msg
.
Value
)
}
if
msg
.
Gas
!=
0
{
arg
[
"gas"
]
=
hexutil
.
Uint64
(
msg
.
Gas
)
}
if
msg
.
GasPrice
!=
nil
{
arg
[
"gasPrice"
]
=
(
*
hexutil
.
Big
)(
msg
.
GasPrice
)
}
return
arg
}
func
(
p
*
L2Proposer
)
CanPropose
(
t
Testing
)
bool
{
_
,
shouldPropose
,
err
:=
p
.
driver
.
FetchNextOutputInfo
(
t
.
Ctx
())
require
.
NoError
(
t
,
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