Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth: Round up bumped gas price for the replacement transactions #2126

Merged
merged 3 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- \#2110 Transparently support HTTP/2 for segment requests while allowing HTTP/1 via GODEBUG runtime flags (@yondonfu)
- \#2124 Do not retry transcoding if HTTP client closed/canceled the connection (@leszko)
- \#2122 Add the upload segment timeout to improve failing fast (@leszko)
- \#2126 Round up bumped gas price for the replacement transactions (@leszko)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can actually go in the "General" section under "Features" since this change impacts all user types.


#### Orchestrator

Expand Down
3 changes: 2 additions & 1 deletion eth/transactionManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ func (tm *TransactionManager) newAdjustedTx(tx *types.Transaction) *types.Transa
func applyPriceBump(val *big.Int, priceBump uint64) *big.Int {
a := big.NewInt(100 + int64(priceBump))
b := new(big.Int).Mul(a, val)
return b.Div(b, big.NewInt(100))
// div round up
return b.Div(new(big.Int).Add(b, big.NewInt(99)), big.NewInt(100))
}

func newReplacementTx(tx *types.Transaction) *types.Transaction {
Expand Down
12 changes: 9 additions & 3 deletions eth/transactionManager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,16 @@ func TestApplyPriceBump(t *testing.T) {
res = applyPriceBump(big.NewInt(500), 101)
assert.Equal(big.NewInt(1005), res)

// Test round down when result is not a whole number
// 50 * 1.11 = 55.5 -> 55
// Tests round up when result is not a whole number
// 50 * 1.11 = 55.5 -> 56
res = applyPriceBump(big.NewInt(50), 11)
assert.Equal(big.NewInt(55), res)
assert.Equal(big.NewInt(56), res)
// 501 * 1.11 = 556.11 -> 557
res = applyPriceBump(big.NewInt(501), 11)
assert.Equal(big.NewInt(557), res)
// 9 * 1.11 = 9.99 -> 10
res = applyPriceBump(big.NewInt(9), 11)
assert.Equal(big.NewInt(10), res)
}

func TestNewReplacementTx(t *testing.T) {
Expand Down