Skip to content

Commit

Permalink
fix: renterd onboarding, host setting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Nov 7, 2023
1 parent 110b3c9 commit 367d761
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 106 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-steaks-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The maxDowntimeHours setting default value is now 336.
5 changes: 5 additions & 0 deletions .changeset/funny-crabs-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

Added support for the minRecentScanFailures autopilot hosts setting.
5 changes: 5 additions & 0 deletions .changeset/hot-humans-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'website': minor
---

The navbar now includes the logo and "sia" as text.
7 changes: 7 additions & 0 deletions .changeset/itchy-lizards-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'hostd': minor
'renterd': minor
'@siafoundation/design-system': minor
---

Extremely small siacoin values will now show as hastings by default rather than 0SC.
5 changes: 5 additions & 0 deletions .changeset/tender-crabs-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

Refined the warnings in the files feature navbar and file explorer empty states.
11 changes: 6 additions & 5 deletions apps/renterd/components/Files/EmptyState/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LinkButton, Text } from '@siafoundation/design-system'
import { Code, LinkButton, Text } from '@siafoundation/design-system'
import { CloudUpload32 } from '@siafoundation/react-icons'
import { routes } from '../../../config/routes'
import { useFiles } from '../../../contexts/files'
Expand Down Expand Up @@ -35,12 +35,13 @@ export function EmptyState() {
</Text>
<div className="flex flex-col gap-6 justify-center items-center">
<Text color="subtle" className="text-center max-w-[500px]">
Before you can upload files you must configure autopilot. Autopilot
finds contracts with hosts based on the settings you choose.
Autopilot also repairs your data as hosts come and go.
Before you can upload files you must configure your settings. Once
configured, <Code>renterd</Code> will find contracts with hosts
based on the settings you choose. <Code>renterd</Code> will also
repair your data as hosts come and go.
</Text>
<LinkButton variant="accent" href={routes.config.index}>
Configure autopilot →
Configure
</LinkButton>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
import { Link, Text, Tooltip } from '@siafoundation/design-system'
import { Text, Tooltip } from '@siafoundation/design-system'
import { Warning16 } from '@siafoundation/react-icons'
import { useFiles } from '../../../contexts/files'
import { routes } from '../../../config/routes'
import { useContractSetMismatch } from '../checks/useContractSetMismatch'
import { useDefaultContractSetNotSet } from '../checks/useDefaultContractSetNotSet'
import { useAutopilotNotConfigured } from '../checks/useAutopilotNotConfigured'
import { useNotEnoughContracts } from '../checks/useNotEnoughContracts'

export function FilesStatsMenuWarnings() {
const { dataState, isViewingRootOfABucket, isViewingBuckets } = useFiles()
const contractSetMismatch = useContractSetMismatch()
const defaultContractSetNotSet = useDefaultContractSetNotSet()
const autopilotNotConfigured = useAutopilotNotConfigured()
const notEnoughContracts = useNotEnoughContracts()

// onboard/warn about default contract set
if (defaultContractSetNotSet.active) {
return (
<div className="flex gap-1">
<Text size="12" font="mono" weight="medium" color="amber">
<Warning16 />
</Text>
<Text size="12" font="mono" weight="medium" color="amber">
Configure a default contract set to get started.{' '}
<Link
underline="hover"
size="12"
font="mono"
weight="medium"
color="amber"
href={routes.config.index}
>
Configuration →
</Link>
</Text>
</div>
)
}

// warn about contract set mismatch
if (contractSetMismatch.active) {
Expand Down Expand Up @@ -65,66 +32,5 @@ export function FilesStatsMenuWarnings() {
)
}

const autopilotNotConfiguredViewingBuckets =
autopilotNotConfigured.active && isViewingBuckets
const autopilotNotConfiguredRootDirectory =
autopilotNotConfigured.active &&
isViewingRootOfABucket &&
dataState !== 'noneYet'
const autopilotNotConfiguredNotRootDirectory =
autopilotNotConfigured.active && !isViewingRootOfABucket
if (
autopilotNotConfiguredViewingBuckets ||
autopilotNotConfiguredRootDirectory ||
autopilotNotConfiguredNotRootDirectory
) {
return (
<div className="flex gap-1">
<Text size="12" font="mono" weight="medium" color="amber">
<Warning16 />
</Text>
<Text size="12" font="mono" weight="medium" color="amber">
Configure autopilot to get started.{' '}
<Link
underline="none"
size="12"
font="mono"
weight="medium"
color="amber"
href={routes.config.index}
>
Autopilot →
</Link>
</Text>
</div>
)
}

const notEnoughContractsViewingBuckets =
notEnoughContracts.active && isViewingBuckets
const notEnoughContractsRootDirectoryAndExistingFiles =
notEnoughContracts.active &&
isViewingRootOfABucket &&
dataState !== 'noneYet'
const notEnoughContractsNotRootDirectory =
notEnoughContracts.active && !isViewingRootOfABucket
if (
notEnoughContractsViewingBuckets ||
notEnoughContractsRootDirectoryAndExistingFiles ||
notEnoughContractsNotRootDirectory
) {
return (
<div className="flex gap-1">
<Text size="12" font="mono" weight="medium" color="amber">
<Warning16 />
</Text>
<Text size="12" font="mono" weight="medium" color="amber">
Not enought contracts to upload files. {notEnoughContracts.count}/
{notEnoughContracts.required}
</Text>
</div>
)
}

return null
}
4 changes: 3 additions & 1 deletion apps/renterd/components/OnboardingBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export function OnboardingBar() {
return null
}

const walletBalance = new BigNumber(wallet.data?.confirmed || 0)
const walletBalance = new BigNumber(
wallet.data ? wallet.data.confirmed + wallet.data.unconfirmed : 0
)
const allowance = new BigNumber(autopilot.data?.contracts.allowance || 0)

const step1Configured = app.autopilot.state.data?.configured
Expand Down
22 changes: 22 additions & 0 deletions apps/renterd/contexts/config/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,28 @@ export function getFields({
}
: {},
},
minRecentScanFailures: {
type: 'number',
category: 'hosts',
title: 'Min recent scan failures',
description: (
<>
The minimum number of recent scan failures that autopilot will
tolerate.
</>
),
units: 'scans',
decimalsLimit: 0,
suggestion: advancedDefaultAutopilot.minRecentScanFailures,
suggestionTip: `Defaults to ${advancedDefaultAutopilot.minRecentScanFailures.toNumber()}.`,
hidden: !isAutopilotEnabled || !showAdvanced,
validation:
isAutopilotEnabled && showAdvanced
? {
required: 'required',
}
: {},
},

// wallet
defragThreshold: {
Expand Down
15 changes: 12 additions & 3 deletions apps/renterd/contexts/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,26 @@ export function useConfigMain() {
throw Error(configAppResponse.error)
}

triggerSuccessToast('Configuration has been saved.')
if (isAutopilotEnabled) {
// Sync default contract set if necessary. Only syncs if the setting
// is enabled in case the user changes in advanced mode and then
// goes back to simple mode.
// Might be simpler nice to just override in simple mode without a
// special setting since this is how other settings like allowance
// behave - but leaving for now.
syncDefaultContractSet(finalValues.autopilotContractSet)

// Trigger the autopilot loop with new settings applied.
autopilotTrigger.post({
payload: {
forceScan: false,
forceScan: true,
},
})
}

// if autopilot is being configured for the first time,
triggerSuccessToast('Configuration has been saved.')

// If autopilot is being configured for the first time,
// revalidate the empty hosts list.
if (firstTimeSettingConfig) {
const refreshHostsAfterDelay = async () => {
Expand Down
11 changes: 11 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', () => {
hosts: {
allowRedundantIPs: false,
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
},
contracts: {
Expand Down Expand Up @@ -75,6 +76,7 @@ describe('tansforms', () => {
storageTB: new BigNumber('1'),
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
defragThreshold: new BigNumber('1000'),
defaultContractSet: 'myset',
uploadPackingEnabled: true,
Expand Down Expand Up @@ -105,6 +107,7 @@ describe('tansforms', () => {
hosts: {
allowRedundantIPs: false,
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
},
contracts: {
Expand Down Expand Up @@ -152,6 +155,7 @@ describe('tansforms', () => {
storageTB: new BigNumber('1'),
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
defragThreshold: new BigNumber('1000'),
defaultContractSet: 'myset',
uploadPackingEnabled: true,
Expand Down Expand Up @@ -188,6 +192,7 @@ describe('tansforms', () => {
storageTB: new BigNumber('1'),
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
defragThreshold: new BigNumber('1000'),
},
undefined
Expand All @@ -199,6 +204,7 @@ describe('tansforms', () => {
hosts: {
allowRedundantIPs: false,
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
},
contracts: {
Expand Down Expand Up @@ -228,6 +234,7 @@ describe('tansforms', () => {
storageTB: new BigNumber('1'),
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
defragThreshold: new BigNumber('1000'),
},
{
Expand Down Expand Up @@ -255,6 +262,7 @@ describe('tansforms', () => {
foobar: 'value',
allowRedundantIPs: false,
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
},
contracts: {
Expand Down Expand Up @@ -303,6 +311,7 @@ describe('tansforms', () => {
storageTB: new BigNumber('1'),
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
defragThreshold: new BigNumber('1000'),
defaultContractSet: 'myset',
uploadPackingEnabled: false,
Expand Down Expand Up @@ -356,6 +365,7 @@ describe('tansforms', () => {
storageTB: new BigNumber('1'),
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
defragThreshold: new BigNumber('1000'),
defaultContractSet: 'myset',
uploadPackingEnabled: false,
Expand Down Expand Up @@ -514,6 +524,7 @@ function buildAllResponses() {
hosts: {
allowRedundantIPs: false,
maxDowntimeHours: 1440,
minRecentScanFailures: 10,
scoreOverrides: null,
},
contracts: {
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 @@ -85,6 +85,7 @@ export function transformUpAutopilot(
hosts: {
...existingValues?.hosts,
maxDowntimeHours: v.maxDowntimeHours.toNumber(),
minRecentScanFailures: v.minRecentScanFailures.toNumber(),
allowRedundantIPs: v.allowRedundantIPs,
scoreOverrides: existingValues?.hosts.scoreOverrides || null,
},
Expand Down Expand Up @@ -241,6 +242,7 @@ export function transformDownAutopilot(
// hosts
allowRedundantIPs: config.hosts.allowRedundantIPs,
maxDowntimeHours: new BigNumber(config.hosts.maxDowntimeHours),
minRecentScanFailures: new BigNumber(config.hosts.minRecentScanFailures),
// wallet
defragThreshold: new BigNumber(config.wallet.defragThreshold),
}
Expand Down
4 changes: 3 additions & 1 deletion apps/renterd/contexts/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const defaultAutopilot = {
// hosts
allowRedundantIPs: false,
maxDowntimeHours: undefined as BigNumber | undefined,
minRecentScanFailures: undefined as BigNumber | undefined,
// wallet
defragThreshold: undefined as BigNumber | undefined,
}
Expand Down Expand Up @@ -84,7 +85,8 @@ export const advancedDefaultAutopilot: AutopilotData = {
amountHosts: new BigNumber(50),
autopilotContractSet: 'autopilot',
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber(1440),
maxDowntimeHours: new BigNumber(336),
minRecentScanFailures: new BigNumber(10),
defragThreshold: new BigNumber(1000),
}

Expand Down
4 changes: 3 additions & 1 deletion libs/design-system/src/components/ValueSc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Props = {
tooltip?: string
fixed?: number
dynamicUnits?: boolean
hastingUnits?: boolean
extendedSuffix?: string
showTooltip?: boolean
}
Expand All @@ -25,6 +26,7 @@ export function ValueSc({
variant = 'change',
fixed = 3,
dynamicUnits = true,
hastingUnits = true,
extendedSuffix,
showTooltip = true,
}: Props) {
Expand Down Expand Up @@ -52,7 +54,7 @@ export function ValueSc({
fixed,
dynamicUnits,
})}`
: humanSiacoin(value, { fixed, dynamicUnits })}
: humanSiacoin(value, { fixed, dynamicUnits, hastingUnits })}
<Text size="20" weight="medium" font="mono" ellipsis color="subtle">
{extendedSuffix ? `${extendedSuffix}` : ''}
</Text>
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 @@ -346,6 +346,7 @@ export interface AutopilotHostsConfig {
allowRedundantIPs: boolean
scoreOverrides: { [key: PublicKey]: number }
maxDowntimeHours: number
minRecentScanFailures: number
}

export interface AutopilotContractsConfig {
Expand Down

0 comments on commit 367d761

Please sign in to comment.