Skip to content

Commit

Permalink
feat: renterd migration surcharge multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Nov 15, 2023
1 parent f3e8cfe commit 1af82db
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-suns-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The configuration now includes a setting for a migration surcharge multiplier which allows you to set a factor for increasing the max download price when trying to repair critically low health sectors.
26 changes: 26 additions & 0 deletions apps/renterd/contexts/config/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,32 @@ export function getFields({
}
: {},
},
migrationSurchargeMultiplier: {
category: 'gouging',
type: 'number',
title: 'Migration surcharge multiplier',
units: '* download price',
placeholder: '10',
decimalsLimit: 1,
description: (
<>
Factor that gets applied on the max download price when trying to
download migration-critical sectors from a host that is price gouging.
For example, when migrating a low-health file, if the download is
failing but would potentially succeed with looser gouging settings, we
apply the migration surcharge multiplier to overpay on every sector
download if it means saving the file/migration.
</>
),
suggestion: new BigNumber(10),
suggestionTip: 'The default multiplier is 10x the download price.',
hidden: !showAdvanced,
validation: showAdvanced
? {
required: 'required',
}
: {},
},

// Redundancy
minShards: {
Expand Down
9 changes: 9 additions & 0 deletions apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
},
{
minShards: 10,
Expand Down Expand Up @@ -90,6 +91,7 @@ describe('tansforms', () => {
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: false,
Expand Down Expand Up @@ -134,6 +136,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
},
{
minShards: 10,
Expand Down Expand Up @@ -169,6 +172,7 @@ describe('tansforms', () => {
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,
Expand Down Expand Up @@ -327,6 +331,7 @@ describe('tansforms', () => {
minPriceTableValidityMinutes: new BigNumber(5),
minShards: new BigNumber(10),
totalShards: new BigNumber(30),
migrationSurchargeMultiplier: new BigNumber(10),
includeRedundancyMaxStoragePrice: false,
includeRedundancyMaxUploadPrice: false,
},
Expand All @@ -348,6 +353,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
})
})

Expand Down Expand Up @@ -379,6 +385,7 @@ describe('tansforms', () => {
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,
Expand All @@ -402,6 +409,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
})
})

Expand Down Expand Up @@ -551,6 +559,7 @@ function buildAllResponses() {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
},
redundancy: {
minShards: 10,
Expand Down
3 changes: 3 additions & 0 deletions apps/renterd/contexts/config/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export function transformUpGouging(
minMaxEphemeralAccountBalance: toHastings(
values.minMaxEphemeralAccountBalance
).toString(),
migrationSurchargeMultiplier:
values.migrationSurchargeMultiplier.toNumber(),
}
}

Expand Down Expand Up @@ -323,6 +325,7 @@ export function transformDownGouging(
g.minMaxEphemeralAccountBalance,
scDecimalPlaces
),
migrationSurchargeMultiplier: new BigNumber(g.migrationSurchargeMultiplier),
}
}

Expand Down
1 change: 1 addition & 0 deletions apps/renterd/contexts/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const defaultGouging = {
minPriceTableValidityMinutes: undefined as BigNumber | undefined,
minAccountExpiryDays: undefined as BigNumber | undefined,
minMaxEphemeralAccountBalance: undefined as BigNumber | undefined,
migrationSurchargeMultiplier: undefined as BigNumber | undefined,
}

export const defaultRedundancy = {
Expand Down
1 change: 1 addition & 0 deletions libs/react-renterd/src/siaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export type GougingSettings = {
minPriceTableValidity: number
minAccountExpiry: number
minMaxEphemeralAccountBalance: string
migrationSurchargeMultiplier: number
}

export type UploadPackingSettings = {
Expand Down

0 comments on commit 1af82db

Please sign in to comment.