Skip to content

Commit

Permalink
feat: renterd min protocol version
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Apr 15, 2024
1 parent 23c71de commit 8444fae
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-buckets-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The configuration now includes the min protocol version option, the value defaults to 1.6.0 when using simple configuration mode. Closes https://github.com/SiaFoundation/renterd/issues/1141 Closes https://github.com/SiaFoundation/web/issues/573
26 changes: 26 additions & 0 deletions apps/renterd/contexts/config/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,32 @@ export function getFields({
}
: {},
},
minProtocolVersion: {
type: 'text',
category: 'hosts',
title: 'Min protocol version',
description: (
<>
The minimum protocol version that autopilot will consider when forming
contracts with hosts.
</>
),
suggestion: advancedDefaults?.minProtocolVersion,
suggestionTip: `Defaults to ${advancedDefaults?.minProtocolVersion}.`,
hidden: !isAutopilotEnabled || !showAdvanced,
validation:
isAutopilotEnabled && showAdvanced
? {
required: 'required',
validate: {
version: (value: string) => {
const regex = /^\d+\.\d+\.\d+$/
return regex.test(value) || 'must be a valid version number'
},
},
}
: {},
},

// contract
defaultContractSet: {
Expand Down
10 changes: 10 additions & 0 deletions apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('tansforms', () => {
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
minProtocolVersion: null,
},
contracts: {
set: 'autopilot',
Expand Down Expand Up @@ -73,6 +74,7 @@ describe('tansforms', () => {
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
minProtocolVersion: '',
defaultContractSet: 'myset',
uploadPackingEnabled: true,
hostBlockHeightLeeway: new BigNumber(4),
Expand Down Expand Up @@ -178,6 +180,7 @@ describe('tansforms', () => {
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
minProtocolVersion: '',
},
undefined
)
Expand All @@ -187,6 +190,7 @@ describe('tansforms', () => {
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
minProtocolVersion: '1.6.0',
},
contracts: {
set: 'autopilot',
Expand Down Expand Up @@ -218,6 +222,7 @@ describe('tansforms', () => {
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
minProtocolVersion: '1.7.0',
},
{
foobar1: 'value',
Expand All @@ -239,6 +244,7 @@ describe('tansforms', () => {
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
minProtocolVersion: '1.7.0',
},
contracts: {
foobar: 'value',
Expand Down Expand Up @@ -271,6 +277,7 @@ describe('tansforms', () => {
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
minProtocolVersion: '1.7.0',
},
{
contracts: {
Expand All @@ -286,6 +293,7 @@ describe('tansforms', () => {
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
minProtocolVersion: '1.7.0',
},
contracts: {
set: 'autopilot',
Expand Down Expand Up @@ -335,6 +343,7 @@ describe('tansforms', () => {
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
minProtocolVersion: '1.7.0',
defaultContractSet: 'myset',
uploadPackingEnabled: false,
hostBlockHeightLeeway: new BigNumber(4),
Expand Down Expand Up @@ -487,6 +496,7 @@ function buildAllResponses() {
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
minProtocolVersion: '1.7.0',
},
contracts: {
set: 'autopilot',
Expand Down
2 changes: 2 additions & 0 deletions apps/renterd/contexts/config/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export function transformUpAutopilot(
minRecentScanFailures: v.minRecentScanFailures.toNumber(),
allowRedundantIPs: v.allowRedundantIPs,
scoreOverrides: existingValues?.hosts.scoreOverrides || null,
minProtocolVersion: v.minProtocolVersion,
},
}
}
Expand Down Expand Up @@ -219,6 +220,7 @@ export function transformDownAutopilot(
allowRedundantIPs: config.hosts.allowRedundantIPs,
maxDowntimeHours: new BigNumber(config.hosts.maxDowntimeHours),
minRecentScanFailures: new BigNumber(config.hosts.minRecentScanFailures),
minProtocolVersion: config.hosts.minProtocolVersion || '',
}
}

Expand Down
3 changes: 3 additions & 0 deletions apps/renterd/contexts/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const defaultAutopilot = {
allowRedundantIPs: false,
maxDowntimeHours: undefined as BigNumber | undefined,
minRecentScanFailures: undefined as BigNumber | undefined,
minProtocolVersion: '',
}

export const defaultContractSet = {
Expand Down Expand Up @@ -87,6 +88,7 @@ export function getAdvancedDefaultAutopilot(
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber(336),
minRecentScanFailures: new BigNumber(10),
minProtocolVersion: '1.6.0',
prune: true,
}
: {
Expand All @@ -97,6 +99,7 @@ export function getAdvancedDefaultAutopilot(
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber(336),
minRecentScanFailures: new BigNumber(10),
minProtocolVersion: '1.6.0',
prune: true,
}),
}
Expand Down
1 change: 1 addition & 0 deletions libs/renterd-types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export type AutopilotHostsConfig = {
scoreOverrides: { [key: PublicKey]: number }
maxDowntimeHours: number
minRecentScanFailures: number
minProtocolVersion: string
}

export type AutopilotContractsConfig = {
Expand Down

0 comments on commit 8444fae

Please sign in to comment.