Skip to content

Commit d02fb79

Browse files
committed
feat: renterd min protocol version
1 parent da530ca commit d02fb79

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

.changeset/large-buckets-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'renterd': minor
3+
---
4+
5+
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

apps/renterd/contexts/config/fields.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,32 @@ export function getFields({
290290
}
291291
: {},
292292
},
293+
minProtocolVersion: {
294+
type: 'text',
295+
category: 'hosts',
296+
title: 'Min protocol version',
297+
description: (
298+
<>
299+
The minimum protocol version that autopilot will consider when forming
300+
contracts with hosts.
301+
</>
302+
),
303+
suggestion: advancedDefaults?.minProtocolVersion,
304+
suggestionTip: `Defaults to ${advancedDefaults?.minProtocolVersion}.`,
305+
hidden: !isAutopilotEnabled || !showAdvanced,
306+
validation:
307+
isAutopilotEnabled && showAdvanced
308+
? {
309+
required: 'required',
310+
validate: {
311+
version: (value: string) => {
312+
const regex = /^\d+\.\d+\.\d+$/
313+
return regex.test(value) || 'must be a valid version number'
314+
},
315+
},
316+
}
317+
: {},
318+
},
293319

294320
// contract
295321
defaultContractSet: {

apps/renterd/contexts/config/transform.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('tansforms', () => {
2828
maxDowntimeHours: 1440,
2929
minRecentScanFailures: 10,
3030
scoreOverrides: null,
31+
minProtocolVersion: null,
3132
},
3233
contracts: {
3334
set: 'autopilot',
@@ -73,6 +74,7 @@ describe('tansforms', () => {
7374
allowRedundantIPs: false,
7475
maxDowntimeHours: new BigNumber('1440'),
7576
minRecentScanFailures: new BigNumber('10'),
77+
minProtocolVersion: '',
7678
defaultContractSet: 'myset',
7779
uploadPackingEnabled: true,
7880
hostBlockHeightLeeway: new BigNumber(4),
@@ -178,6 +180,7 @@ describe('tansforms', () => {
178180
allowRedundantIPs: false,
179181
maxDowntimeHours: new BigNumber('1440'),
180182
minRecentScanFailures: new BigNumber('10'),
183+
minProtocolVersion: '',
181184
},
182185
undefined
183186
)
@@ -187,6 +190,7 @@ describe('tansforms', () => {
187190
maxDowntimeHours: 1440,
188191
minRecentScanFailures: 10,
189192
scoreOverrides: null,
193+
minProtocolVersion: '1.6.0',
190194
},
191195
contracts: {
192196
set: 'autopilot',
@@ -218,6 +222,7 @@ describe('tansforms', () => {
218222
allowRedundantIPs: false,
219223
maxDowntimeHours: new BigNumber('1440'),
220224
minRecentScanFailures: new BigNumber('10'),
225+
minProtocolVersion: '1.7.0',
221226
},
222227
{
223228
foobar1: 'value',
@@ -239,6 +244,7 @@ describe('tansforms', () => {
239244
maxDowntimeHours: 1440,
240245
minRecentScanFailures: 10,
241246
scoreOverrides: null,
247+
minProtocolVersion: '1.7.0',
242248
},
243249
contracts: {
244250
foobar: 'value',
@@ -271,6 +277,7 @@ describe('tansforms', () => {
271277
allowRedundantIPs: false,
272278
maxDowntimeHours: new BigNumber('1440'),
273279
minRecentScanFailures: new BigNumber('10'),
280+
minProtocolVersion: '1.7.0',
274281
},
275282
{
276283
contracts: {
@@ -286,6 +293,7 @@ describe('tansforms', () => {
286293
maxDowntimeHours: 1440,
287294
minRecentScanFailures: 10,
288295
scoreOverrides: null,
296+
minProtocolVersion: '1.7.0',
289297
},
290298
contracts: {
291299
set: 'autopilot',
@@ -335,6 +343,7 @@ describe('tansforms', () => {
335343
allowRedundantIPs: false,
336344
maxDowntimeHours: new BigNumber('1440'),
337345
minRecentScanFailures: new BigNumber('10'),
346+
minProtocolVersion: '1.7.0',
338347
defaultContractSet: 'myset',
339348
uploadPackingEnabled: false,
340349
hostBlockHeightLeeway: new BigNumber(4),
@@ -487,6 +496,7 @@ function buildAllResponses() {
487496
maxDowntimeHours: 1440,
488497
minRecentScanFailures: 10,
489498
scoreOverrides: null,
499+
minProtocolVersion: '1.7.0',
490500
},
491501
contracts: {
492502
set: 'autopilot',

apps/renterd/contexts/config/transform.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export function transformUpAutopilot(
9191
minRecentScanFailures: v.minRecentScanFailures.toNumber(),
9292
allowRedundantIPs: v.allowRedundantIPs,
9393
scoreOverrides: existingValues?.hosts.scoreOverrides || null,
94+
minProtocolVersion: v.minProtocolVersion,
9495
},
9596
}
9697
}
@@ -219,6 +220,7 @@ export function transformDownAutopilot(
219220
allowRedundantIPs: config.hosts.allowRedundantIPs,
220221
maxDowntimeHours: new BigNumber(config.hosts.maxDowntimeHours),
221222
minRecentScanFailures: new BigNumber(config.hosts.minRecentScanFailures),
223+
minProtocolVersion: config.hosts.minProtocolVersion || '',
222224
}
223225
}
224226

apps/renterd/contexts/config/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const defaultAutopilot = {
1818
allowRedundantIPs: false,
1919
maxDowntimeHours: undefined as BigNumber | undefined,
2020
minRecentScanFailures: undefined as BigNumber | undefined,
21+
minProtocolVersion: '',
2122
}
2223

2324
export const defaultContractSet = {
@@ -87,6 +88,7 @@ export function getAdvancedDefaultAutopilot(
8788
allowRedundantIPs: false,
8889
maxDowntimeHours: new BigNumber(336),
8990
minRecentScanFailures: new BigNumber(10),
91+
minProtocolVersion: '1.6.0',
9092
prune: true,
9193
}
9294
: {
@@ -97,6 +99,7 @@ export function getAdvancedDefaultAutopilot(
9799
allowRedundantIPs: false,
98100
maxDowntimeHours: new BigNumber(336),
99101
minRecentScanFailures: new BigNumber(10),
102+
minProtocolVersion: '1.6.0',
100103
prune: true,
101104
}),
102105
}

libs/renterd-types/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export type AutopilotHostsConfig = {
211211
scoreOverrides: { [key: PublicKey]: number }
212212
maxDowntimeHours: number
213213
minRecentScanFailures: number
214+
minProtocolVersion: string
214215
}
215216

216217
export type AutopilotContractsConfig = {

0 commit comments

Comments
 (0)