Skip to content

Commit

Permalink
refactor(renterd): gouging base units
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Sep 17, 2024
1 parent 39cb991 commit 973438a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-dragons-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The configuration now internally uses the updated gouging base units.
10 changes: 4 additions & 6 deletions apps/renterd/contexts/config/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@ export function firstTimeGougingData({
return {
...gouging,
maxStoragePrice: averages.settings.storage_price,
maxDownloadPrice: new BigNumber(averages.settings.download_price)
.times(TBToBytes(1))
.toString(),
maxUploadPrice: new BigNumber(averages.settings.upload_price)
.times(TBToBytes(1))
.toString(),
maxDownloadPrice: new BigNumber(
averages.settings.download_price
).toString(),
maxUploadPrice: new BigNumber(averages.settings.upload_price).toString(),
}
}
8 changes: 4 additions & 4 deletions apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ describe('tansforms', () => {
foobar: 'value',
hostBlockHeightLeeway: 4,
maxContractPrice: '20000000000000000000000000',
maxDownloadPrice: '1004310000000000000000000000',
maxDownloadPrice: '1004310000000000',
maxRPCPrice: '99970619000000000000000000',
maxStoragePrice: '210531181019',
maxUploadPrice: '1000232323000000000000000000',
maxUploadPrice: '1000232323000000',
minAccountExpiry: 86400000000000,
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
Expand Down Expand Up @@ -573,10 +573,10 @@ function buildAllResponses() {
gouging: {
hostBlockHeightLeeway: 4,
maxContractPrice: '20000000000000000000000000',
maxDownloadPrice: '1004310000000000000000000000',
maxDownloadPrice: '1004310000000000',
maxRPCPrice: '99970619000000000000000000',
maxStoragePrice: '210531181019',
maxUploadPrice: '1000232323000000000000000000',
maxUploadPrice: '1000232323000000',
minAccountExpiry: 86400000000000,
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
Expand Down
8 changes: 6 additions & 2 deletions apps/renterd/contexts/config/transformDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
weeksToBlocks,
nanosecondsInDays,
nanosecondsInMinutes,
valuePerByteToPerTB,
} from '@siafoundation/units'
import BigNumber from 'bignumber.js'
import {
Expand Down Expand Up @@ -148,10 +149,13 @@ export function transformDownGouging({
scDecimalPlaces
), // TB/month
maxUploadPriceTB: toSiacoins(
new BigNumber(gouging.maxUploadPrice),
valuePerByteToPerTB(new BigNumber(gouging.maxUploadPrice)),
scDecimalPlaces
),
maxDownloadPriceTB: toSiacoins(
valuePerByteToPerTB(new BigNumber(gouging.maxDownloadPrice)),
scDecimalPlaces
),
maxDownloadPriceTB: toSiacoins(gouging.maxDownloadPrice, scDecimalPlaces),
maxContractPrice: toSiacoins(gouging.maxContractPrice, scDecimalPlaces),
maxRPCPriceMillion: toSiacoins(
valuePerOneToPerMillion(new BigNumber(gouging.maxRPCPrice)),
Expand Down
9 changes: 7 additions & 2 deletions apps/renterd/contexts/config/transformUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
valuePerMillionToPerOne,
daysInNanoseconds,
minutesInNanoseconds,
valuePerTBToPerByte,
} from '@siafoundation/units'
import {
AutopilotData,
Expand Down Expand Up @@ -118,8 +119,12 @@ export function transformUpGouging(
maxStoragePrice: toHastings(
valuePerTBPerMonthToPerBytePerBlock(values.maxStoragePriceTBMonth)
).toString(),
maxUploadPrice: toHastings(values.maxUploadPriceTB).toString(),
maxDownloadPrice: toHastings(values.maxDownloadPriceTB).toString(),
maxUploadPrice: toHastings(
valuePerTBToPerByte(values.maxUploadPriceTB)
).toString(),
maxDownloadPrice: toHastings(
valuePerTBToPerByte(values.maxDownloadPriceTB)
).toString(),
maxContractPrice: toHastings(values.maxContractPrice).toString(),
hostBlockHeightLeeway: Math.round(
values.hostBlockHeightLeeway?.toNumber() || 0
Expand Down

0 comments on commit 973438a

Please sign in to comment.