diff --git a/.changeset/strong-bags-beam.md b/.changeset/strong-bags-beam.md
new file mode 100644
index 000000000..026ca2ffd
--- /dev/null
+++ b/.changeset/strong-bags-beam.md
@@ -0,0 +1,5 @@
+---
+'renterd': minor
+---
+
+Storage and upload price settings no longer default to or have the option to include redundancy. The price with the configured redundancy is now always shown below.
diff --git a/apps/renterd/components/Config/ConfigStats.tsx b/apps/renterd/components/Config/ConfigStats.tsx
index b03bf07b3..1ad5c76d5 100644
--- a/apps/renterd/components/Config/ConfigStats.tsx
+++ b/apps/renterd/components/Config/ConfigStats.tsx
@@ -64,35 +64,38 @@ export function ConfigStats() {
per TB/month with {redundancyMultiplier.toFixed(1)}x redundancy
-
-
- {perMonth.fiat && (
-
-
- `(${perMonth.currency.prefix}${v.toFixed(
- perMonth.currency.fixed
- )})`
- }
- />
-
- )}
-
- to store {humanBytes(TBToBytes(storageTB).toNumber())}/month with{' '}
- {redundancyMultiplier.toFixed(1)}x redundancy
-
-
+ {/* additionally show estimated spending for total storage if it's different from per TB */}
+ {!estimatedSpendingPerTB.eq(estimatedSpendingPerMonth) && (
+
+
+ {perMonth.fiat && (
+
+
+ `(${perMonth.currency.prefix}${v.toFixed(
+ perMonth.currency.fixed
+ )})`
+ }
+ />
+
+ )}
+
+ to store {humanBytes(TBToBytes(storageTB).toNumber())}/month with{' '}
+ {redundancyMultiplier.toFixed(1)}x redundancy
+
+
+ )}
)
diff --git a/apps/renterd/contexts/config/fields.tsx b/apps/renterd/contexts/config/fields.tsx
index 08e7ec7d3..ed727108d 100644
--- a/apps/renterd/contexts/config/fields.tsx
+++ b/apps/renterd/contexts/config/fields.tsx
@@ -2,7 +2,7 @@
import {
Code,
ConfigFields,
- FieldSwitch,
+ Separator,
Text,
Tooltip,
hoursInDays,
@@ -12,6 +12,8 @@ import {
import BigNumber from 'bignumber.js'
import React from 'react'
import { defaultValues, SettingsData } from './types'
+import { humanSiacoin, toHastings } from '@siafoundation/units'
+import { Information16 } from '@carbon/icons-react'
export const scDecimalPlaces = 6
@@ -28,9 +30,11 @@ type GetFields = {
isAutopilotEnabled: boolean
advancedDefaults?: SettingsData
showAdvanced: boolean
+ maxStoragePriceTBMonth: BigNumber
+ maxUploadPriceTB: BigNumber
+ minShards: BigNumber
+ totalShards: BigNumber
redundancyMultiplier: BigNumber
- includeRedundancyMaxStoragePrice: boolean
- includeRedundancyMaxUploadPrice: boolean
storageAverage?: BigNumber
uploadAverage?: BigNumber
downloadAverage?: BigNumber
@@ -41,9 +45,11 @@ export function getFields({
isAutopilotEnabled,
advancedDefaults,
showAdvanced,
+ maxStoragePriceTBMonth,
+ maxUploadPriceTB,
+ minShards,
+ totalShards,
redundancyMultiplier,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
storageAverage,
uploadAverage,
downloadAverage,
@@ -336,37 +342,51 @@ export function getFields({
category: 'gouging',
type: 'siacoin',
title: 'Max storage price',
- description: <>The max allowed price to store 1 TB per month.>,
+ description: (
+ <>
+ The max allowed price a host is allowed to charge to store 1 TB worth
+ of data per month.
+ >
+ ),
units: 'SC/TB/month',
average: storageAverage,
- averageTip: getAverageTip(
- includeRedundancyMaxStoragePrice,
- redundancyMultiplier
- ),
- after: function After({ form, fields }) {
+ averageTip: 'Averages provided by Sia Central.',
+ after: function After() {
+ if (!maxStoragePriceTBMonth || !minShards || !totalShards) {
+ return null
+ }
return (
-
-
-
-
- Including {redundancyMultiplier.toFixed(1)}x redundancy
+ <>
+
+
+ Price per TB/month when factoring in the configured{' '}
+ {minShards} of {totalShards} redundancy.
+ >
+ }
+ >
+
+
+
+
+
+ {humanSiacoin(
+ toHastings(maxStoragePriceTBMonth).times(
+ redundancyMultiplier
+ ),
+ {
+ fixed: 0,
+ dynamicUnits: false,
+ }
+ )}
+ /TB/month with redundancy
-
-
-
+
+
+ >
)
},
decimalsLimitSc: scDecimalPlaces,
@@ -378,37 +398,49 @@ export function getFields({
category: 'gouging',
type: 'siacoin',
title: 'Max upload price',
- description: <>The max allowed price to upload 1 TB.>,
- units: 'SC/TB/month',
- average: uploadAverage,
- averageTip: getAverageTip(
- includeRedundancyMaxUploadPrice,
- redundancyMultiplier
+ description: (
+ <>
+ The max allowed price a host is allowed to charge for uploading 1 TB
+ worth of data.
+ >
),
- after: function After({ form, fields }) {
+ units: 'SC/TB',
+ average: uploadAverage,
+ averageTip: 'Averages provided by Sia Central.',
+ after: function After() {
+ if (!maxUploadPriceTB || !minShards || !totalShards) {
+ return null
+ }
return (
-
-
-
-
- Including {redundancyMultiplier.toFixed(1)}x redundancy
+ <>
+
+
+ Price per TB when factoring in the configured {minShards} of{' '}
+ {totalShards} redundancy.
+ >
+ }
+ >
+
+
+
-
-
-
+
+ {humanSiacoin(
+ toHastings(maxUploadPriceTB).times(redundancyMultiplier),
+ {
+ fixed: 0,
+ dynamicUnits: false,
+ }
+ )}
+ /TB with redundancy
+
+
+
+ >
)
},
decimalsLimitSc: scDecimalPlaces,
@@ -421,7 +453,7 @@ export function getFields({
type: 'siacoin',
title: 'Max download price',
description: <>The max allowed price to download 1 TB.>,
- units: 'SC/TB/month',
+ units: 'SC/TB',
average: downloadAverage,
averageTip: `Averages provided by Sia Central.`,
decimalsLimitSc: scDecimalPlaces,
@@ -639,50 +671,5 @@ export function getFields({
}
: {},
},
-
- // hidden fields used by other config options
- includeRedundancyMaxStoragePrice: {
- type: 'boolean',
- title: 'Include redundancy',
- validation: {},
- },
- includeRedundancyMaxUploadPrice: {
- type: 'boolean',
- title: 'Include redundancy',
- validation: {},
- },
- }
-}
-
-function getAverageTip(
- includeRedundancy: boolean,
- redundancyMultiplier: BigNumber
-) {
- if (includeRedundancy) {
- return `The average price is adjusted for ${redundancyMultiplier.toFixed(
- 1
- )}x redundancy. Averages provided by Sia Central.`
- }
- return `The average price is not adjusted for redundancy. Averages provided by Sia Central.`
-}
-
-function getRedundancyTip(
- includeRedundancy: boolean,
- redundancyMultiplier: BigNumber
-) {
- if (includeRedundancy) {
- return (
-
-
- Specified max price includes the cost of{' '}
- {redundancyMultiplier.toFixed(1)}x redundancy.
-
-
- Redundancy is calculated from the ratio of data shards:{' '}
- total shards / min shards
.
-
-
- )
}
- return `Specified max price does not include redundancy.`
}
diff --git a/apps/renterd/contexts/config/index.tsx b/apps/renterd/contexts/config/index.tsx
index 846888525..791f19ef2 100644
--- a/apps/renterd/contexts/config/index.tsx
+++ b/apps/renterd/contexts/config/index.tsx
@@ -21,9 +21,9 @@ import {
export function useConfigMain() {
const {
+ autopilotState,
autopilot,
contractSet,
- display,
gouging,
redundancy,
uploadPacking,
@@ -42,8 +42,6 @@ export function useConfigMain() {
storageTB,
downloadTBMonth,
uploadTBMonth,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
redundancyMultiplier,
fields,
showAdvanced,
@@ -53,6 +51,10 @@ export function useConfigMain() {
// resources required to intialize form
const resources = useMemo(
() => ({
+ autopilotState: {
+ data: autopilotState.data,
+ error: autopilotState.error,
+ },
autopilot: {
data: autopilot.data,
error: autopilot.error,
@@ -73,10 +75,6 @@ export function useConfigMain() {
data: redundancy.data,
error: redundancy.error,
},
- display: {
- data: display.data,
- error: display.error,
- },
averages: {
data: averages.data,
error: averages.error,
@@ -88,6 +86,8 @@ export function useConfigMain() {
},
}),
[
+ autopilotState.data,
+ autopilotState.error,
autopilot.data,
autopilot.error,
contractSet.data,
@@ -98,8 +98,6 @@ export function useConfigMain() {
gouging.error,
redundancy.data,
redundancy.error,
- display.data,
- display.error,
averages.data,
averages.error,
appSettings.settings.siaCentral,
@@ -111,13 +109,13 @@ export function useConfigMain() {
return null
}
return transformDown({
+ hasBeenConfigured: resources.autopilotState.data?.configured,
autopilot: resources.autopilot.data,
contractSet: resources.contractSet.data,
uploadPacking: resources.uploadPacking.data,
gouging: resources.gouging.data,
averages: resources.averages.data,
redundancy: resources.redundancy.data,
- display: resources.display.data,
})
}, [resources])
@@ -128,36 +126,36 @@ export function useConfigMain() {
const revalidateAndResetForm = useCallback(async () => {
// these do not seem to throw on errors, just return undefined
+ const _autopilotState = await autopilotState.mutate()
const _autopilot = isAutopilotEnabled ? await autopilot.mutate() : undefined
const _contractSet = await contractSet.mutate()
const _gouging = await gouging.mutate()
const _redundancy = await redundancy.mutate()
const _uploadPacking = await uploadPacking.mutate()
- const _display = await display.mutate()
if (!gouging || !redundancy) {
triggerErrorToast('Error fetching settings.')
return null
}
form.reset(
transformDown({
+ hasBeenConfigured: _autopilotState.configured,
autopilot: _autopilot,
contractSet: _contractSet,
uploadPacking: _uploadPacking,
gouging: _gouging,
averages: averages.data,
redundancy: _redundancy,
- display: _display,
})
)
}, [
form,
+ autopilotState,
isAutopilotEnabled,
autopilot,
contractSet,
gouging,
uploadPacking,
redundancy,
- display,
averages.data,
])
@@ -174,8 +172,6 @@ export function useConfigMain() {
const { canEstimate, estimatedSpendingPerMonth, estimatedSpendingPerTB } =
useEstimates({
isAutopilotEnabled,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
redundancyMultiplier,
maxStoragePriceTBMonth,
storageTB,
diff --git a/apps/renterd/contexts/config/resources.ts b/apps/renterd/contexts/config/resources.ts
index 3573ee79d..15536ca4e 100644
--- a/apps/renterd/contexts/config/resources.ts
+++ b/apps/renterd/contexts/config/resources.ts
@@ -1,17 +1,21 @@
import { SWRError } from '@siafoundation/react-core'
import {
AutopilotConfig,
+ AutopilotState,
ContractSetSettings,
GougingSettings,
RedundancySettings,
UploadPackingSettings,
} from '@siafoundation/react-renterd'
-import { ConfigDisplaySettings } from '../../hooks/useConfigDisplaySettings'
import { SiaCentralHostsNetworkAveragesResponse } from '@siafoundation/sia-central'
import BigNumber from 'bignumber.js'
import { TBToBytes } from '@siafoundation/units'
export type Resources = {
+ autopilotState: {
+ data?: AutopilotState
+ error?: SWRError
+ }
autopilot: {
data?: AutopilotConfig
error?: SWRError
@@ -32,10 +36,6 @@ export type Resources = {
data?: RedundancySettings
error?: SWRError
}
- display: {
- data?: ConfigDisplaySettings
- error?: SWRError
- }
averages: {
data?: SiaCentralHostsNetworkAveragesResponse
error?: SWRError
@@ -48,18 +48,19 @@ export type Resources = {
}
export function checkIfAllResourcesLoaded({
+ autopilotState,
autopilot,
contractSet,
uploadPacking,
gouging,
redundancy,
- display,
averages,
appSettings,
}: Resources) {
return !!(
// these settings have initial daemon values
(
+ autopilotState.data &&
redundancy.data &&
uploadPacking.data &&
gouging.data &&
@@ -67,7 +68,6 @@ export function checkIfAllResourcesLoaded({
// until the user sets them
(autopilot.data || autopilot.error) &&
(contractSet.data || contractSet.error) &&
- (display.data || display.error) &&
// other data dependencies
(!appSettings.settings.siaCentral || averages.data)
)
diff --git a/apps/renterd/contexts/config/transform.spec.ts b/apps/renterd/contexts/config/transform.spec.ts
index 1c309d2a2..f9c588351 100644
--- a/apps/renterd/contexts/config/transform.spec.ts
+++ b/apps/renterd/contexts/config/transform.spec.ts
@@ -18,9 +18,10 @@ import {
describe('tansforms', () => {
describe('down', () => {
- it('default works', () => {
+ it('default', () => {
expect(
transformDown({
+ hasBeenConfigured: true,
autopilot: {
hosts: {
allowRedundantIPs: false,
@@ -59,10 +60,6 @@ describe('tansforms', () => {
minShards: 10,
totalShards: 30,
},
- display: {
- includeRedundancyMaxStoragePrice: false,
- includeRedundancyMaxUploadPrice: false,
- },
})
).toEqual({
autopilotContractSet: 'autopilot',
@@ -92,13 +89,12 @@ describe('tansforms', () => {
migrationSurchargeMultiplier: new BigNumber(10),
minShards: new BigNumber(10),
totalShards: new BigNumber(30),
- includeRedundancyMaxStoragePrice: false,
- includeRedundancyMaxUploadPrice: false,
} as SettingsData)
})
- it('default works with first time user overrides', () => {
+ it('applies first time user overrides', () => {
const values = transformDown({
+ hasBeenConfigured: false,
autopilot: undefined,
contractSet: undefined,
uploadPacking: {
@@ -121,7 +117,6 @@ describe('tansforms', () => {
minShards: 10,
totalShards: 30,
},
- display: undefined,
averages: {
settings: {
download_price: (4e24).toString(),
@@ -130,90 +125,42 @@ describe('tansforms', () => {
},
},
})
- expect(values.maxUploadPriceTB).toEqual(new BigNumber('12000000000000'))
+ expect(values.maxUploadPriceTB).toEqual(new BigNumber('4000000000000'))
expect(values.maxDownloadPriceTB).toEqual(new BigNumber('4000000000000'))
expect(values.maxStoragePriceTBMonth).toEqual(
- new BigNumber('51840000000000000')
+ new BigNumber('17280000000000000')
)
})
- it('with include redundancy for storage and upload', () => {
- expect(
- transformDown({
- autopilot: {
- hosts: {
- allowRedundantIPs: false,
- maxDowntimeHours: 1440,
- minRecentScanFailures: 10,
- scoreOverrides: null,
- },
- contracts: {
- set: 'autopilot',
- amount: 51,
- allowance: '8408400000000000000000000000',
- period: 6048,
- renewWindow: 2248,
- download: 1099511627776,
- upload: 1100000000000,
- storage: 1000000000000,
- prune: true,
- },
- },
- contractSet: { default: 'myset' },
- uploadPacking: { enabled: true },
- gouging: {
- hostBlockHeightLeeway: 4,
- maxContractPrice: '20000000000000000000000000',
- maxDownloadPrice: '1004310000000000000000000000',
- maxRPCPrice: '99970619000000000000000000',
- maxStoragePrice: '210531181019',
- maxUploadPrice: '1000232323000000000000000000',
- minAccountExpiry: 86400000000000,
- minMaxCollateral: '10000000000000000000000000',
- minMaxEphemeralAccountBalance: '1000000000000000000000000',
- minPriceTableValidity: 300000000000,
- migrationSurchargeMultiplier: 10,
- },
- redundancy: {
- minShards: 10,
- totalShards: 30,
- },
- display: {
- includeRedundancyMaxStoragePrice: true,
- includeRedundancyMaxUploadPrice: true,
- },
- })
- ).toEqual({
- autopilotContractSet: 'autopilot',
- allowanceMonth: new BigNumber('6006'),
- amountHosts: new BigNumber('51'),
- periodWeeks: new BigNumber('6'),
- renewWindowWeeks: new BigNumber('2.2301587301587302'),
- downloadTBMonth: new BigNumber('0.79'),
- uploadTBMonth: new BigNumber('0.79'),
- storageTB: new BigNumber('1'),
- allowRedundantIPs: false,
- maxDowntimeHours: new BigNumber('1440'),
- minRecentScanFailures: new BigNumber('10'),
- defaultContractSet: 'myset',
- uploadPackingEnabled: true,
- hostBlockHeightLeeway: new BigNumber(4),
- maxContractPrice: new BigNumber('20'),
- maxDownloadPriceTB: new BigNumber('1004.31'),
- maxRpcPriceMillion: new BigNumber('99970619'),
- maxStoragePriceTBMonth: new BigNumber('2728.484106'),
- maxUploadPriceTB: new BigNumber('3000.696969'),
- minAccountExpiryDays: new BigNumber(1),
- minMaxCollateral: new BigNumber('10'),
- minMaxEphemeralAccountBalance: new BigNumber('1'),
- minPriceTableValidityMinutes: new BigNumber(5),
- migrationSurchargeMultiplier: new BigNumber(10),
- minShards: new BigNumber(10),
- totalShards: new BigNumber(30),
- includeRedundancyMaxStoragePrice: true,
- includeRedundancyMaxUploadPrice: true,
- prune: true,
- } as SettingsData)
+ it('does not apply overrides if missing averages', () => {
+ const values = transformDown({
+ hasBeenConfigured: false,
+ autopilot: undefined,
+ contractSet: undefined,
+ uploadPacking: {
+ enabled: false,
+ },
+ gouging: {
+ hostBlockHeightLeeway: 4,
+ maxContractPrice: '20000000000000000000000000',
+ maxDownloadPrice: '1004310000000000000000000000',
+ maxRPCPrice: '99970619000000000000000000',
+ maxStoragePrice: '210531181019',
+ maxUploadPrice: '1000232323000000000000000000',
+ minAccountExpiry: 86400000000000,
+ minMaxCollateral: '10000000000000000000000000',
+ minMaxEphemeralAccountBalance: '1000000000000000000000000',
+ minPriceTableValidity: 300000000000,
+ migrationSurchargeMultiplier: 10,
+ },
+ redundancy: {
+ minShards: 10,
+ totalShards: 30,
+ },
+ })
+ expect(values.maxUploadPriceTB).toEqual(new BigNumber('1000.232323'))
+ expect(values.maxDownloadPriceTB).toEqual(new BigNumber('1004.31'))
+ expect(values.maxStoragePriceTBMonth).toEqual(new BigNumber('909.494702'))
})
})
@@ -407,8 +354,6 @@ describe('tansforms', () => {
minShards: new BigNumber(10),
totalShards: new BigNumber(30),
migrationSurchargeMultiplier: new BigNumber(10),
- includeRedundancyMaxStoragePrice: false,
- includeRedundancyMaxUploadPrice: false,
},
{
maxStoragePrice: '77777777777',
@@ -432,62 +377,6 @@ describe('tansforms', () => {
})
})
- it('up gouging with include redundancy for storage', () => {
- expect(
- transformUpGouging(
- {
- autopilotContractSet: 'autopilot',
- allowanceMonth: new BigNumber('6006'),
- amountHosts: new BigNumber('51'),
- periodWeeks: new BigNumber('6'),
- renewWindowWeeks: new BigNumber('2.2301587301587302'),
- downloadTBMonth: new BigNumber('0.785365448411428571428571428571'),
- uploadTBMonth: new BigNumber('0.785714285714285714285714285714'),
- storageTB: new BigNumber('1'),
- prune: true,
- allowRedundantIPs: false,
- maxDowntimeHours: new BigNumber('1440'),
- minRecentScanFailures: new BigNumber('10'),
- defaultContractSet: 'myset',
- uploadPackingEnabled: false,
- hostBlockHeightLeeway: new BigNumber(4),
- maxContractPrice: new BigNumber('20'),
- maxDownloadPriceTB: new BigNumber('1004.31'),
- maxRpcPriceMillion: new BigNumber('99970619'),
- maxStoragePriceTBMonth: new BigNumber('909.494702'),
- maxUploadPriceTB: new BigNumber('1000.232323'),
- minAccountExpiryDays: new BigNumber(1),
- minMaxCollateral: new BigNumber('10'),
- minMaxEphemeralAccountBalance: new BigNumber('1'),
- minPriceTableValidityMinutes: new BigNumber(5),
- migrationSurchargeMultiplier: new BigNumber(10),
- minShards: new BigNumber(10),
- totalShards: new BigNumber(30),
- includeRedundancyMaxStoragePrice: true,
- includeRedundancyMaxUploadPrice: false,
- },
- {
- maxStoragePrice: '77777777777',
- foobar: 'value',
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- } as any
- )
- ).toEqual({
- foobar: 'value',
- hostBlockHeightLeeway: 4,
- maxContractPrice: '20000000000000000000000000',
- maxDownloadPrice: '1004310000000000000000000000',
- maxRPCPrice: '99970619000000000000000000',
- maxStoragePrice: '70177060340',
- maxUploadPrice: '1000232323000000000000000000',
- minAccountExpiry: 86400000000000,
- minMaxCollateral: '10000000000000000000000000',
- minMaxEphemeralAccountBalance: '1000000000000000000000000',
- minPriceTableValidity: 300000000000,
- migrationSurchargeMultiplier: 10,
- })
- })
-
it('up redundancy', () => {
expect(
transformUpRedundancy(
@@ -511,15 +400,10 @@ describe('tansforms', () => {
describe('up down', () => {
it('converts ap download up down', () => {
- const {
- autopilot,
- contractSet,
- uploadPacking,
- gouging,
- redundancy,
- display,
- } = buildAllResponses()
+ const { autopilot, contractSet, uploadPacking, gouging, redundancy } =
+ buildAllResponses()
let settings = transformDown({
+ hasBeenConfigured: true,
autopilot: {
...autopilot,
contracts: {
@@ -532,7 +416,6 @@ describe('tansforms', () => {
uploadPacking,
gouging,
redundancy,
- display,
})
expect(settings.downloadTBMonth).toEqual(new BigNumber('92.72'))
// a little different due to rounding
@@ -541,6 +424,7 @@ describe('tansforms', () => {
).toEqual(91088814814815)
settings = transformDown({
+ hasBeenConfigured: true,
autopilot: {
...autopilot,
contracts: {
@@ -553,7 +437,6 @@ describe('tansforms', () => {
uploadPacking,
gouging,
redundancy,
- display,
})
expect(settings.downloadTBMonth).toEqual(new BigNumber('92.72'))
// using the rounded value results in same value
@@ -638,9 +521,5 @@ function buildAllResponses() {
minShards: 10,
totalShards: 30,
},
- display: {
- includeRedundancyMaxStoragePrice: false,
- includeRedundancyMaxUploadPrice: false,
- },
}
}
diff --git a/apps/renterd/contexts/config/transform.ts b/apps/renterd/contexts/config/transform.ts
index 40943874d..c6cebed00 100644
--- a/apps/renterd/contexts/config/transform.ts
+++ b/apps/renterd/contexts/config/transform.ts
@@ -27,9 +27,7 @@ import {
scDecimalPlaces,
SettingsData,
getAdvancedDefaultAutopilot,
- DisplayData,
ContractSetData,
- defaultDisplay,
defaultContractSet,
GougingData,
RedundancyData,
@@ -37,7 +35,6 @@ import {
defaultAutopilot,
advancedDefaultContractSet,
} from './types'
-import { ConfigDisplaySettings } from '../../hooks/useConfigDisplaySettings'
import { firstTimeGougingData } from './resources'
const filterUndefinedKeys = (obj: Record) => {
@@ -135,23 +132,8 @@ export function transformUpGouging(
values.maxStoragePriceTBMonth // TB/month
.div(monthsToBlocks(1)) // TB/block
.div(TBToBytes(1))
- .div(
- getRedundancyMultiplierIfIncluded(
- values.minShards,
- values.totalShards,
- values.includeRedundancyMaxStoragePrice
- )
- ) // bytes/block
- ).toString(),
- maxUploadPrice: toHastings(
- values.maxUploadPriceTB.div(
- getRedundancyMultiplierIfIncluded(
- values.minShards,
- values.totalShards,
- values.includeRedundancyMaxUploadPrice
- )
- )
).toString(),
+ maxUploadPrice: toHastings(values.maxUploadPriceTB).toString(),
maxDownloadPrice: toHastings(values.maxDownloadPriceTB).toString(),
maxContractPrice: toHastings(values.maxContractPrice).toString(),
minMaxCollateral: toHastings(values.minMaxCollateral).toString(),
@@ -181,17 +163,6 @@ export function transformUpRedundancy(
}
}
-export function transformUpDisplay(
- values: DisplayData,
- existingValues: Record | undefined
-): ConfigDisplaySettings {
- return {
- ...existingValues,
- includeRedundancyMaxStoragePrice: values.includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice: values.includeRedundancyMaxUploadPrice,
- }
-}
-
// down
export function transformDownAutopilot(
config?: AutopilotConfig
@@ -271,26 +242,12 @@ export function transformDownUploadPacking(
}
}
-export function transformDownDisplay(d?: ConfigDisplaySettings): DisplayData {
- if (!d) {
- return defaultDisplay
- }
- return {
- includeRedundancyMaxStoragePrice: d.includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice: d.includeRedundancyMaxUploadPrice,
- }
-}
-
export function transformDownGouging({
gouging: _gouging,
- redundancy,
- display,
averages,
hasBeenConfigured,
}: {
gouging: GougingSettings
- redundancy: RedundancyData
- display: DisplayData
averages?: {
settings: {
download_price: string
@@ -309,24 +266,11 @@ export function transformDownGouging({
maxStoragePriceTBMonth: toSiacoins(
new BigNumber(gouging.maxStoragePrice) // bytes/block
.times(monthsToBlocks(1)) // bytes/month
- .times(TBToBytes(1)) // tb/month
- .times(
- getRedundancyMultiplierIfIncluded(
- redundancy.minShards,
- redundancy.totalShards,
- display.includeRedundancyMaxStoragePrice
- )
- ),
+ .times(TBToBytes(1)), // tb/month
scDecimalPlaces
), // TB/month
maxUploadPriceTB: toSiacoins(
- new BigNumber(gouging.maxUploadPrice).times(
- getRedundancyMultiplierIfIncluded(
- redundancy.minShards,
- redundancy.totalShards,
- display.includeRedundancyMaxUploadPrice
- )
- ),
+ new BigNumber(gouging.maxUploadPrice),
scDecimalPlaces
),
maxDownloadPriceTB: toSiacoins(gouging.maxDownloadPrice, scDecimalPlaces),
@@ -360,12 +304,12 @@ export function transformDownRedundancy(r: RedundancySettings): RedundancyData {
}
export type RemoteData = {
+ hasBeenConfigured: boolean
autopilot: AutopilotConfig | undefined
contractSet: ContractSetSettings | undefined
uploadPacking: UploadPackingSettings
gouging: GougingSettings
redundancy: RedundancySettings
- display: ConfigDisplaySettings | undefined
averages?: {
settings: {
download_price: string
@@ -376,18 +320,14 @@ export type RemoteData = {
}
export function transformDown({
+ hasBeenConfigured,
autopilot,
contractSet,
uploadPacking,
gouging,
- redundancy: _redundancy,
- display: _display,
+ redundancy,
averages,
}: RemoteData): SettingsData {
- // display will be undefined if its the first time the user is configuring
- const hasBeenConfigured = !!_display
- const display = transformDownDisplay(_display)
- const redundancy = transformDownRedundancy(_redundancy)
return {
// autopilot
...transformDownAutopilot(autopilot),
@@ -399,14 +339,10 @@ export function transformDown({
...transformDownGouging({
gouging,
averages,
- redundancy,
- display,
hasBeenConfigured,
}),
// redundancy
- ...redundancy,
- // config app
- ...display,
+ ...transformDownRedundancy(redundancy),
}
}
@@ -427,30 +363,11 @@ export function getRedundancyMultiplier(
return redundancyMult
}
-export function getRedundancyMultiplierIfIncluded(
- minShards: BigNumber,
- totalShards: BigNumber,
- includeRedundancy: boolean
-): BigNumber {
- const redundancyMult = getRedundancyMultiplier(minShards, totalShards)
- return includeRedundancy ? redundancyMult : new BigNumber(1)
-}
-
export function storagePricePerMonthToPerBlock(value: BigNumber) {
return value // TB/month
.div(monthsToBlocks(1)) // TB/block
.div(TBToBytes(1)) // bytes/block
}
-export function storagePricePerMonthToPerBlockWithRedundancy(
- value: BigNumber,
- minShards: BigNumber,
- totalShards: BigNumber,
- includeRedundancy: boolean
-) {
- return storagePricePerMonthToPerBlock(value).div(
- getRedundancyMultiplierIfIncluded(minShards, totalShards, includeRedundancy)
- )
-}
export function valuePerMonthToPerPeriod(
valuePerMonth: BigNumber,
diff --git a/apps/renterd/contexts/config/types.ts b/apps/renterd/contexts/config/types.ts
index 25c5a8eb9..75b212eef 100644
--- a/apps/renterd/contexts/config/types.ts
+++ b/apps/renterd/contexts/config/types.ts
@@ -28,11 +28,6 @@ export const defaultUploadPacking = {
uploadPackingEnabled: true,
}
-export const defaultDisplay = {
- includeRedundancyMaxStoragePrice: true,
- includeRedundancyMaxUploadPrice: true,
-}
-
export const defaultGouging = {
maxRpcPriceMillion: undefined as BigNumber | undefined,
maxStoragePriceTBMonth: undefined as BigNumber | undefined,
@@ -63,14 +58,11 @@ export const defaultValues = {
...defaultGouging,
// redundancy
...defaultRedundancy,
- // config display
- ...defaultDisplay,
}
export type AutopilotData = typeof defaultAutopilot
export type ContractSetData = typeof defaultContractSet
export type UploadPackingData = typeof defaultUploadPacking
-export type DisplayData = typeof defaultDisplay
export type GougingData = typeof defaultGouging
export type RedundancyData = typeof defaultRedundancy
export type SettingsData = typeof defaultValues
@@ -116,10 +108,6 @@ export const advancedDefaultContractSet: ContractSetData = {
defaultContractSet: 'autopilot',
}
-export const advancedDefaultDisplay: DisplayData = {
- ...defaultDisplay,
-}
-
export const advancedDefaultUploadPacking: UploadPackingData = {
...defaultUploadPacking,
}
@@ -148,7 +136,6 @@ export function getAdvancedDefaults(
return {
...getAdvancedDefaultAutopilot(network),
...advancedDefaultContractSet,
- ...advancedDefaultDisplay,
...advancedDefaultUploadPacking,
...advancedDefaultGouging,
...getAdvancedDefaultRedundancy(network),
diff --git a/apps/renterd/contexts/config/useAverages.tsx b/apps/renterd/contexts/config/useAverages.tsx
index 0615cf48d..0f0d6378b 100644
--- a/apps/renterd/contexts/config/useAverages.tsx
+++ b/apps/renterd/contexts/config/useAverages.tsx
@@ -1,20 +1,9 @@
import BigNumber from 'bignumber.js'
import { useMemo } from 'react'
import { monthsToBlocks, TBToBytes, toSiacoins } from '@siafoundation/units'
-import { getRedundancyMultiplierIfIncluded } from './transform'
import { useSiaCentralHostsNetworkAverages } from '@siafoundation/react-sia-central'
-export function useAverages({
- minShards,
- totalShards,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
-}: {
- minShards: BigNumber
- totalShards: BigNumber
- includeRedundancyMaxStoragePrice: boolean
- includeRedundancyMaxUploadPrice: boolean
-}) {
+export function useAverages() {
const averages = useSiaCentralHostsNetworkAverages({
config: {
swr: {
@@ -29,17 +18,10 @@ export function useAverages({
toSiacoins(averages.data.settings.storage_price) // bytes/block
.times(monthsToBlocks(1)) // bytes/month
.times(TBToBytes(1)) // TB/month
- .times(
- getRedundancyMultiplierIfIncluded(
- minShards,
- totalShards,
- includeRedundancyMaxStoragePrice
- )
- ) // redundancy
.toFixed(0)
)
: undefined,
- [averages.data, minShards, totalShards, includeRedundancyMaxStoragePrice]
+ [averages.data]
)
const uploadAverage = useMemo(
() =>
@@ -47,17 +29,10 @@ export function useAverages({
? new BigNumber(
toSiacoins(averages.data.settings.upload_price) // bytes
.times(TBToBytes(1)) // TB
- .times(
- getRedundancyMultiplierIfIncluded(
- minShards,
- totalShards,
- includeRedundancyMaxUploadPrice
- )
- ) // redundancy
.toFixed(0)
)
: undefined,
- [averages.data, minShards, totalShards, includeRedundancyMaxUploadPrice]
+ [averages.data]
)
const downloadAverage = useMemo(
() =>
diff --git a/apps/renterd/contexts/config/useEstimates.tsx b/apps/renterd/contexts/config/useEstimates.tsx
index afb21fc4e..2c3f00213 100644
--- a/apps/renterd/contexts/config/useEstimates.tsx
+++ b/apps/renterd/contexts/config/useEstimates.tsx
@@ -3,8 +3,6 @@ import { useMemo } from 'react'
export function useEstimates({
isAutopilotEnabled,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
redundancyMultiplier,
maxStoragePriceTBMonth,
storageTB,
@@ -14,8 +12,6 @@ export function useEstimates({
uploadTBMonth,
}: {
isAutopilotEnabled: boolean
- includeRedundancyMaxStoragePrice: boolean
- includeRedundancyMaxUploadPrice: boolean
redundancyMultiplier: BigNumber
maxStoragePriceTBMonth: BigNumber
storageTB: BigNumber
@@ -63,13 +59,13 @@ export function useEstimates({
? maxDownloadPriceTB
: new BigNumber(0)
- const storageCostPerMonth = includeRedundancyMaxStoragePrice
- ? _maxStoragePriceTBMonth.times(_storageTB)
- : _maxStoragePriceTBMonth.times(redundancyMultiplier).times(_storageTB)
+ const storageCostPerMonth = _maxStoragePriceTBMonth
+ .times(redundancyMultiplier)
+ .times(_storageTB)
const downloadCostPerMonth = _maxDownloadPriceTB.times(_downloadTBMonth)
- const uploadCostPerMonth = includeRedundancyMaxUploadPrice
- ? _maxUploadPriceTB.times(_uploadTBMonth)
- : _maxUploadPriceTB.times(redundancyMultiplier).times(_uploadTBMonth)
+ const uploadCostPerMonth = _maxUploadPriceTB
+ .times(redundancyMultiplier)
+ .times(_uploadTBMonth)
const totalCostPerMonth = storageCostPerMonth
.plus(downloadCostPerMonth)
@@ -77,8 +73,6 @@ export function useEstimates({
return totalCostPerMonth
}, [
canEstimate,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
redundancyMultiplier,
maxStoragePriceTBMonth,
storageTB,
diff --git a/apps/renterd/contexts/config/useForm.tsx b/apps/renterd/contexts/config/useForm.tsx
index 182a8264b..fdc998b1e 100644
--- a/apps/renterd/contexts/config/useForm.tsx
+++ b/apps/renterd/contexts/config/useForm.tsx
@@ -21,12 +21,6 @@ export function useForm() {
const uploadTBMonth = form.watch('uploadTBMonth')
const minShards = form.watch('minShards')
const totalShards = form.watch('totalShards')
- const includeRedundancyMaxStoragePrice = form.watch(
- 'includeRedundancyMaxStoragePrice'
- )
- const includeRedundancyMaxUploadPrice = form.watch(
- 'includeRedundancyMaxUploadPrice'
- )
const redundancyMultiplier = useMemo(
() => getRedundancyMultiplier(minShards, totalShards),
[minShards, totalShards]
@@ -38,12 +32,7 @@ export function useForm() {
uploadAverage,
downloadAverage,
contractAverage,
- } = useAverages({
- minShards,
- totalShards,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
- })
+ } = useAverages()
const app = useApp()
const isAutopilotEnabled = app.autopilot.status === 'on'
@@ -64,22 +53,26 @@ export function useForm() {
advancedDefaults,
isAutopilotEnabled,
showAdvanced,
+ maxStoragePriceTBMonth,
+ maxUploadPriceTB,
redundancyMultiplier,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
storageAverage,
uploadAverage,
downloadAverage,
contractAverage,
+ minShards,
+ totalShards,
})
}
return getFields({
advancedDefaults,
isAutopilotEnabled,
showAdvanced,
+ maxStoragePriceTBMonth,
+ maxUploadPriceTB,
redundancyMultiplier,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
+ minShards,
+ totalShards,
})
}, [
renterdState.data,
@@ -91,8 +84,10 @@ export function useForm() {
downloadAverage,
contractAverage,
redundancyMultiplier,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
+ maxStoragePriceTBMonth,
+ maxUploadPriceTB,
+ minShards,
+ totalShards,
])
return {
@@ -106,8 +101,6 @@ export function useForm() {
uploadTBMonth,
minShards,
totalShards,
- includeRedundancyMaxStoragePrice,
- includeRedundancyMaxUploadPrice,
redundancyMultiplier,
showAdvanced,
setShowAdvanced,
diff --git a/apps/renterd/contexts/config/useOnValid.tsx b/apps/renterd/contexts/config/useOnValid.tsx
index 3c2026e22..3f4d5b450 100644
--- a/apps/renterd/contexts/config/useOnValid.tsx
+++ b/apps/renterd/contexts/config/useOnValid.tsx
@@ -13,14 +13,12 @@ import {
import { SettingsData, defaultValues } from './types'
import {
transformUpAutopilot,
- transformUpDisplay,
transformUpContractSet,
transformUpGouging,
transformUpRedundancy,
transformUpUploadPacking,
} from './transform'
import { delay, useMutate } from '@siafoundation/react-core'
-import { configDisplaySettingsKey } from '../../hooks/useConfigDisplaySettings'
import { Resources } from './resources'
import { useSyncContractSet } from './useSyncContractSet'
import BigNumber from 'bignumber.js'
@@ -81,7 +79,6 @@ export function useOnValid({
uploadPackingResponse,
gougingResponse,
redundancyResponse,
- configAppResponse,
] = await Promise.all([
settingUpdate.put({
params: {
@@ -116,12 +113,6 @@ export function useOnValid({
resources.redundancy.data
),
}),
- settingUpdate.put({
- params: {
- key: configDisplaySettingsKey,
- },
- payload: transformUpDisplay(finalValues, resources.display.data),
- }),
])
if (autopilotResponse?.error) {
@@ -139,9 +130,6 @@ export function useOnValid({
if (redundancyResponse.error) {
throw Error(redundancyResponse.error)
}
- if (configAppResponse.error) {
- throw Error(configAppResponse.error)
- }
if (isAutopilotEnabled) {
// Sync default contract set if necessary. Only syncs if the setting
diff --git a/apps/renterd/contexts/config/useResources.tsx b/apps/renterd/contexts/config/useResources.tsx
index 5d6974db6..4c2d1c175 100644
--- a/apps/renterd/contexts/config/useResources.tsx
+++ b/apps/renterd/contexts/config/useResources.tsx
@@ -3,7 +3,6 @@ import { useAutopilotConfig } from '@siafoundation/react-renterd'
import { useSyncContractSet } from './useSyncContractSet'
import { useAppSettings } from '@siafoundation/react-core'
import { useContractSetSettings } from '../../hooks/useContractSetSettings'
-import { useConfigDisplaySettings } from '../../hooks/useConfigDisplaySettings'
import { useGougingSettings } from '../../hooks/useGougingSettings'
import { useRedundancySettings } from '../../hooks/useRedundancySettings'
import { useUploadPackingSettings } from '../../hooks/useUploadPackingSettings'
@@ -30,14 +29,6 @@ export function useResources() {
},
},
})
- const display = useConfigDisplaySettings({
- config: {
- swr: {
- errorRetryCount: 0,
- refreshInterval: minutesInMilliseconds(1),
- },
- },
- })
// settings with initial defaults
const gouging = useGougingSettings({
config: {
@@ -77,9 +68,9 @@ export function useResources() {
const appSettings = useAppSettings()
return {
+ autopilotState: app.autopilot.state,
autopilot,
contractSet,
- display,
gouging,
redundancy,
uploadPacking,
diff --git a/apps/renterd/hooks/useConfigDisplaySettings.tsx b/apps/renterd/hooks/useConfigDisplaySettings.tsx
deleted file mode 100644
index 288b97dec..000000000
--- a/apps/renterd/hooks/useConfigDisplaySettings.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { HookArgsSwr } from '@siafoundation/react-core'
-import { useSetting } from '@siafoundation/react-renterd'
-
-export const configDisplaySettingsKey = 'v0-config-display-options'
-
-export type ConfigDisplaySettings = {
- includeRedundancyMaxStoragePrice: boolean
- includeRedundancyMaxUploadPrice: boolean
-}
-
-export function useConfigDisplaySettings(
- args?: HookArgsSwr
-) {
- return useSetting({
- ...args,
- params: { key: configDisplaySettingsKey },
- })
-}
diff --git a/libs/design-system/src/form/ConfigurationNumber.tsx b/libs/design-system/src/form/ConfigurationNumber.tsx
index 8228b0751..c72ffe673 100644
--- a/libs/design-system/src/form/ConfigurationNumber.tsx
+++ b/libs/design-system/src/form/ConfigurationNumber.tsx
@@ -42,7 +42,7 @@ export function ConfigurationNumber<
)
return (
-
+
-
+
-
+
diff --git a/libs/design-system/src/form/ConfigurationSwitch.tsx b/libs/design-system/src/form/ConfigurationSwitch.tsx
index 2c2b754ec..7df880dba 100644
--- a/libs/design-system/src/form/ConfigurationSwitch.tsx
+++ b/libs/design-system/src/form/ConfigurationSwitch.tsx
@@ -23,7 +23,7 @@ export function ConfigurationSwitch<
})
return (