From 105c46b2574e0bcd6cd098e7fdaf110a96895088 Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Thu, 21 Mar 2024 10:03:41 -0400 Subject: [PATCH] fix: renterd max rpc price rounding --- .changeset/dry-ligers-melt.md | 5 +++++ apps/renterd/contexts/config/transform.spec.ts | 6 +++++- apps/renterd/contexts/config/transform.ts | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .changeset/dry-ligers-melt.md diff --git a/.changeset/dry-ligers-melt.md b/.changeset/dry-ligers-melt.md new file mode 100644 index 000000000..22e172012 --- /dev/null +++ b/.changeset/dry-ligers-melt.md @@ -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 diff --git a/apps/renterd/contexts/config/transform.spec.ts b/apps/renterd/contexts/config/transform.spec.ts index 416cdac64..cb3b477a7 100644 --- a/apps/renterd/contexts/config/transform.spec.ts +++ b/apps/renterd/contexts/config/transform.spec.ts @@ -408,7 +408,10 @@ describe('tansforms', () => { }, contractSet, uploadPacking, - gouging, + gouging: { + ...gouging, + maxRPCPrice: '100000000000000000', + }, redundancy, }) expect(settings.downloadTBMonth).toEqual(new BigNumber('92.72')) @@ -416,6 +419,7 @@ describe('tansforms', () => { expect( transformUpAutopilot('Mainnet', settings, autopilot).contracts.download ).toEqual(91088814814815) + expect(settings.maxRpcPriceMillion).toEqual(new BigNumber('0.1')) settings = transformDown({ hasBeenConfigured: true, diff --git a/apps/renterd/contexts/config/transform.ts b/apps/renterd/contexts/config/transform.ts index f1edae708..f3a080335 100644 --- a/apps/renterd/contexts/config/transform.ts +++ b/apps/renterd/contexts/config/transform.ts @@ -261,6 +261,7 @@ export function transformDownGouging({ averages, hasBeenConfigured, }) + return { maxStoragePriceTBMonth: toSiacoins( new BigNumber(gouging.maxStoragePrice) // bytes/block @@ -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(