Skip to content

Commit

Permalink
fix: renterd max rpc price rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Mar 21, 2024
1 parent 3a1b3d4 commit 105c46b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-ligers-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': patch
---

Fixed an issue where the max RPC price configuration would round decimal values to 0. Closes https://github.com/SiaFoundation/renterd/issues/1050
6 changes: 5 additions & 1 deletion apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,18 @@ describe('tansforms', () => {
},
contractSet,
uploadPacking,
gouging,
gouging: {
...gouging,
maxRPCPrice: '100000000000000000',
},
redundancy,
})
expect(settings.downloadTBMonth).toEqual(new BigNumber('92.72'))
// a little different due to rounding
expect(
transformUpAutopilot('Mainnet', settings, autopilot).contracts.download
).toEqual(91088814814815)
expect(settings.maxRpcPriceMillion).toEqual(new BigNumber('0.1'))

settings = transformDown({
hasBeenConfigured: true,
Expand Down
6 changes: 4 additions & 2 deletions apps/renterd/contexts/config/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export function transformDownGouging({
averages,
hasBeenConfigured,
})

return {
maxStoragePriceTBMonth: toSiacoins(
new BigNumber(gouging.maxStoragePrice) // bytes/block
Expand All @@ -274,8 +275,9 @@ export function transformDownGouging({
),
maxDownloadPriceTB: toSiacoins(gouging.maxDownloadPrice, scDecimalPlaces),
maxContractPrice: toSiacoins(gouging.maxContractPrice, scDecimalPlaces),
maxRpcPriceMillion: toSiacoins(gouging.maxRPCPrice, scDecimalPlaces).times(
1_000_000
maxRpcPriceMillion: toSiacoins(
new BigNumber(gouging.maxRPCPrice).times(1_000_000),
scDecimalPlaces
),
hostBlockHeightLeeway: new BigNumber(gouging.hostBlockHeightLeeway),
minPriceTableValidityMinutes: new BigNumber(
Expand Down

0 comments on commit 105c46b

Please sign in to comment.