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
edec19f0
Unverified
Commit
edec19f0
authored
Dec 22, 2023
by
Michael de Hoog
Committed by
GitHub
Dec 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that fee is increased by at least 10% (#8747)
parent
8b197bc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
txmgr.go
op-service/txmgr/txmgr.go
+3
-5
txmgr_test.go
op-service/txmgr/txmgr_test.go
+4
-4
No files found.
op-service/txmgr/txmgr.go
View file @
edec19f0
...
@@ -30,6 +30,7 @@ const (
...
@@ -30,6 +30,7 @@ const (
var
(
var
(
priceBumpPercent
=
big
.
NewInt
(
100
+
priceBump
)
priceBumpPercent
=
big
.
NewInt
(
100
+
priceBump
)
oneHundred
=
big
.
NewInt
(
100
)
oneHundred
=
big
.
NewInt
(
100
)
ninetyNine
=
big
.
NewInt
(
99
)
)
)
// TxManager is an interface that allows callers to reliably publish txs,
// TxManager is an interface that allows callers to reliably publish txs,
...
@@ -603,15 +604,12 @@ func (m *SimpleTxManager) checkLimits(tip, basefee, bumpedTip, bumpedFee *big.In
...
@@ -603,15 +604,12 @@ func (m *SimpleTxManager) checkLimits(tip, basefee, bumpedTip, bumpedFee *big.In
return
nil
return
nil
}
}
// calcThresholdValue returns
x * priceBumpPercent / 100
// calcThresholdValue returns
ceil(x * priceBumpPercent / 100)
// It guarantees that x is increased by at least 1
// It guarantees that x is increased by at least 1
func
calcThresholdValue
(
x
*
big
.
Int
)
*
big
.
Int
{
func
calcThresholdValue
(
x
*
big
.
Int
)
*
big
.
Int
{
threshold
:=
new
(
big
.
Int
)
.
Mul
(
priceBumpPercent
,
x
)
threshold
:=
new
(
big
.
Int
)
.
Mul
(
priceBumpPercent
,
x
)
threshold
.
Add
(
threshold
,
ninetyNine
)
threshold
.
Div
(
threshold
,
oneHundred
)
threshold
.
Div
(
threshold
,
oneHundred
)
// Guarantee to add at least 1 wei. Edge-case during near-zero fee conditions.
if
threshold
.
Cmp
(
x
)
==
0
{
threshold
.
Add
(
threshold
,
big
.
NewInt
(
1
))
}
return
threshold
return
threshold
}
}
...
...
op-service/txmgr/txmgr_test.go
View file @
edec19f0
...
@@ -907,15 +907,15 @@ func TestIncreaseGasPrice(t *testing.T) {
...
@@ -907,15 +907,15 @@ func TestIncreaseGasPrice(t *testing.T) {
func
TestIncreaseGasPriceLimits
(
t
*
testing
.
T
)
{
func
TestIncreaseGasPriceLimits
(
t
*
testing
.
T
)
{
t
.
Run
(
"no-threshold"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"no-threshold"
,
func
(
t
*
testing
.
T
)
{
testIncreaseGasPriceLimit
(
t
,
gasPriceLimitTest
{
testIncreaseGasPriceLimit
(
t
,
gasPriceLimitTest
{
expTipCap
:
3
6
,
expTipCap
:
4
6
,
expFeeCap
:
493
,
// just below 5*100
expFeeCap
:
354
,
// just below 5*100
})
})
})
})
t
.
Run
(
"with-threshold"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"with-threshold"
,
func
(
t
*
testing
.
T
)
{
testIncreaseGasPriceLimit
(
t
,
gasPriceLimitTest
{
testIncreaseGasPriceLimit
(
t
,
gasPriceLimitTest
{
thr
:
big
.
NewInt
(
params
.
GWei
),
thr
:
big
.
NewInt
(
params
.
GWei
),
expTipCap
:
61
_265_01
7
,
expTipCap
:
131
_326_98
7
,
expFeeCap
:
9
57
_582_949
,
// just below 1 gwei
expFeeCap
:
9
33
_286_308
,
// just below 1 gwei
})
})
})
})
}
}
...
...
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