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
d346f078
Unverified
Commit
d346f078
authored
Dec 12, 2023
by
Sebastian Stammler
Committed by
GitHub
Dec 12, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8578 from ethereum-optimism/seb/fix-txmgr-gas-est
txmgr: Fix gas estimation call
parents
a298160f
e1e639e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
txmgr.go
op-service/txmgr/txmgr.go
+16
-10
No files found.
op-service/txmgr/txmgr.go
View file @
d346f078
...
@@ -27,8 +27,10 @@ const (
...
@@ -27,8 +27,10 @@ const (
)
)
// new = old * (100 + priceBump) / 100
// new = old * (100 + priceBump) / 100
var
priceBumpPercent
=
big
.
NewInt
(
100
+
priceBump
)
var
(
var
oneHundred
=
big
.
NewInt
(
100
)
priceBumpPercent
=
big
.
NewInt
(
100
+
priceBump
)
oneHundred
=
big
.
NewInt
(
100
)
)
// TxManager is an interface that allows callers to reliably publish txs,
// TxManager is an interface that allows callers to reliably publish txs,
// bumping the gas price if needed, and obtain the receipt of the resulting tx.
// bumping the gas price if needed, and obtain the receipt of the resulting tx.
...
@@ -503,7 +505,7 @@ func (m *SimpleTxManager) queryReceipt(ctx context.Context, txHash common.Hash,
...
@@ -503,7 +505,7 @@ func (m *SimpleTxManager) queryReceipt(ctx context.Context, txHash common.Hash,
// doesn't linger in the mempool. Finally to avoid runaway price increases, fees are capped at a
// doesn't linger in the mempool. Finally to avoid runaway price increases, fees are capped at a
// `feeLimitMultiplier` multiple of the suggested values.
// `feeLimitMultiplier` multiple of the suggested values.
func
(
m
*
SimpleTxManager
)
increaseGasPrice
(
ctx
context
.
Context
,
tx
*
types
.
Transaction
)
(
*
types
.
Transaction
,
error
)
{
func
(
m
*
SimpleTxManager
)
increaseGasPrice
(
ctx
context
.
Context
,
tx
*
types
.
Transaction
)
(
*
types
.
Transaction
,
error
)
{
m
.
l
.
Info
(
"bumping gas price for tx"
,
"hash"
,
tx
.
Hash
(),
"
tip"
,
tx
.
GasTipCap
(),
"fee
"
,
tx
.
GasFeeCap
(),
"gaslimit"
,
tx
.
Gas
())
m
.
l
.
Info
(
"bumping gas price for tx"
,
"hash"
,
tx
.
Hash
(),
"
gasTipCap"
,
tx
.
GasTipCap
(),
"gasFeeCap
"
,
tx
.
GasFeeCap
(),
"gaslimit"
,
tx
.
Gas
())
tip
,
basefee
,
err
:=
m
.
suggestGasPriceCaps
(
ctx
)
tip
,
basefee
,
err
:=
m
.
suggestGasPriceCaps
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
m
.
l
.
Warn
(
"failed to get suggested gas tip and basefee"
,
"err"
,
err
)
m
.
l
.
Warn
(
"failed to get suggested gas tip and basefee"
,
"err"
,
err
)
...
@@ -514,11 +516,11 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa
...
@@ -514,11 +516,11 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa
// Make sure increase is at most [FeeLimitMultiplier] the suggested values
// Make sure increase is at most [FeeLimitMultiplier] the suggested values
maxTip
:=
new
(
big
.
Int
)
.
Mul
(
tip
,
big
.
NewInt
(
int64
(
m
.
cfg
.
FeeLimitMultiplier
)))
maxTip
:=
new
(
big
.
Int
)
.
Mul
(
tip
,
big
.
NewInt
(
int64
(
m
.
cfg
.
FeeLimitMultiplier
)))
if
bumpedTip
.
Cmp
(
maxTip
)
>
0
{
if
bumpedTip
.
Cmp
(
maxTip
)
>
0
{
return
nil
,
fmt
.
Errorf
(
"bumped tip
0x%s is over %dx multiple of the suggested value"
,
bumpedTip
.
Text
(
16
)
,
m
.
cfg
.
FeeLimitMultiplier
)
return
nil
,
fmt
.
Errorf
(
"bumped tip
cap %v is over %dx multiple of the suggested value"
,
bumpedTip
,
m
.
cfg
.
FeeLimitMultiplier
)
}
}
maxFee
:=
calcGasFeeCap
(
new
(
big
.
Int
)
.
Mul
(
basefee
,
big
.
NewInt
(
int64
(
m
.
cfg
.
FeeLimitMultiplier
))),
maxTip
)
maxFee
:=
calcGasFeeCap
(
new
(
big
.
Int
)
.
Mul
(
basefee
,
big
.
NewInt
(
int64
(
m
.
cfg
.
FeeLimitMultiplier
))),
maxTip
)
if
bumpedFee
.
Cmp
(
maxFee
)
>
0
{
if
bumpedFee
.
Cmp
(
maxFee
)
>
0
{
return
nil
,
fmt
.
Errorf
(
"bumped fee
0x%s is over %dx multiple of the suggested value"
,
bumpedFee
.
Text
(
16
)
,
m
.
cfg
.
FeeLimitMultiplier
)
return
nil
,
fmt
.
Errorf
(
"bumped fee
cap %v is over %dx multiple of the suggested value"
,
bumpedFee
,
m
.
cfg
.
FeeLimitMultiplier
)
}
}
rawTx
:=
&
types
.
DynamicFeeTx
{
rawTx
:=
&
types
.
DynamicFeeTx
{
ChainID
:
tx
.
ChainId
(),
ChainID
:
tx
.
ChainId
(),
...
@@ -535,8 +537,8 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa
...
@@ -535,8 +537,8 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa
gas
,
err
:=
m
.
backend
.
EstimateGas
(
ctx
,
ethereum
.
CallMsg
{
gas
,
err
:=
m
.
backend
.
EstimateGas
(
ctx
,
ethereum
.
CallMsg
{
From
:
m
.
cfg
.
From
,
From
:
m
.
cfg
.
From
,
To
:
rawTx
.
To
,
To
:
rawTx
.
To
,
Gas
Fee
Cap
:
bumpedTip
,
Gas
Tip
Cap
:
bumpedTip
,
Gas
Tip
Cap
:
bumpedFee
,
Gas
Fee
Cap
:
bumpedFee
,
Data
:
rawTx
.
Data
,
Data
:
rawTx
.
Data
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -544,11 +546,13 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa
...
@@ -544,11 +546,13 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa
// original tx can get included in a block just before the above call. In this case the
// original tx can get included in a block just before the above call. In this case the
// error is due to the tx reverting with message "block number must be equal to next
// error is due to the tx reverting with message "block number must be equal to next
// expected block number"
// expected block number"
m
.
l
.
Warn
(
"failed to re-estimate gas"
,
"err"
,
err
,
"gaslimit"
,
tx
.
Gas
())
m
.
l
.
Warn
(
"failed to re-estimate gas"
,
"err"
,
err
,
"gaslimit"
,
tx
.
Gas
(),
"gasFeeCap"
,
bumpedFee
,
"gasTipCap"
,
bumpedTip
)
return
nil
,
err
return
nil
,
err
}
}
if
tx
.
Gas
()
!=
gas
{
if
tx
.
Gas
()
!=
gas
{
m
.
l
.
Info
(
"re-estimated gas differs"
,
"oldgas"
,
tx
.
Gas
(),
"newgas"
,
gas
)
m
.
l
.
Info
(
"re-estimated gas differs"
,
"oldgas"
,
tx
.
Gas
(),
"newgas"
,
gas
,
"gasFeeCap"
,
bumpedFee
,
"gasTipCap"
,
bumpedTip
)
}
}
rawTx
.
Gas
=
gas
rawTx
.
Gas
=
gas
...
@@ -600,7 +604,9 @@ func calcThresholdValue(x *big.Int) *big.Int {
...
@@ -600,7 +604,9 @@ func calcThresholdValue(x *big.Int) *big.Int {
// (c) gasFeeCap is no less than calcGasFee(newBaseFee, newTip)
// (c) gasFeeCap is no less than calcGasFee(newBaseFee, newTip)
func
updateFees
(
oldTip
,
oldFeeCap
,
newTip
,
newBaseFee
*
big
.
Int
,
lgr
log
.
Logger
)
(
*
big
.
Int
,
*
big
.
Int
)
{
func
updateFees
(
oldTip
,
oldFeeCap
,
newTip
,
newBaseFee
*
big
.
Int
,
lgr
log
.
Logger
)
(
*
big
.
Int
,
*
big
.
Int
)
{
newFeeCap
:=
calcGasFeeCap
(
newBaseFee
,
newTip
)
newFeeCap
:=
calcGasFeeCap
(
newBaseFee
,
newTip
)
lgr
=
lgr
.
New
(
"old_tip"
,
oldTip
,
"old_feecap"
,
oldFeeCap
,
"new_tip"
,
newTip
,
"new_feecap"
,
newFeeCap
)
lgr
=
lgr
.
New
(
"old_gasTipCap"
,
oldTip
,
"old_gasFeeCap"
,
oldFeeCap
,
"new_gasTipCap"
,
newTip
,
"new_gasFeeCap"
,
newFeeCap
,
"new_basefee"
,
newBaseFee
)
thresholdTip
:=
calcThresholdValue
(
oldTip
)
thresholdTip
:=
calcThresholdValue
(
oldTip
)
thresholdFeeCap
:=
calcThresholdValue
(
oldFeeCap
)
thresholdFeeCap
:=
calcThresholdValue
(
oldFeeCap
)
if
newTip
.
Cmp
(
thresholdTip
)
>=
0
&&
newFeeCap
.
Cmp
(
thresholdFeeCap
)
>=
0
{
if
newTip
.
Cmp
(
thresholdTip
)
>=
0
&&
newFeeCap
.
Cmp
(
thresholdFeeCap
)
>=
0
{
...
...
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