Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renterd improve onboarding, warnings, fixes, add minRecentScanFailures, adjust maxDowntimeHours, website map page #409

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-queens-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'explorer': minor
---

Fixed an issue loading the host page for hosts that are not benchmarked yet.
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/lemon-dragons-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'website': minor
---

The website now features an improved interactive host map.
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.
5 changes: 5 additions & 0 deletions .changeset/yellow-files-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'explorer': minor
---

Fixed an issue where transaction values were incorrect on the address page transaction list.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The Sia web libraries provide developers with convenient TypeScript SDKs for usi
- [@siafoundation/sia-nodejs](libs/sia-nodejs) - Sia NodeJS client for controlling a v1 `siad`.
- [@siafoundation/design-system](libs/design-system) - React-based design system used across Sia apps and websites.
- [@siafoundation/data-sources](libs/data-sources) - Data sources used for stats on the website.
- [@siafoundation/units](libs/units) - Methods and types for converting and displaying units.

## Internal

Expand Down
15 changes: 6 additions & 9 deletions apps/explorer/app/host/[id]/opengraph-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
import {
getDownloadCost,
getDownloadSpeed,
getStorageCost,
getUploadCost,
} from '../../../lib/host'
import { humanBytes, humanSpeed } from '@siafoundation/sia-js'
getUploadSpeed,
} from '@siafoundation/units'
import { humanBytes } from '@siafoundation/sia-js'
import { truncate } from '@siafoundation/design-system'
import { CurrencyOption, currencyOptions } from '@siafoundation/react-core'

Expand Down Expand Up @@ -76,10 +78,7 @@ export default async function Image({ params }) {
rate: r.rates.sc.usd,
},
}),
subvalue: humanSpeed(
(h.host.benchmark.data_size * 8) /
(h.host.benchmark.download_time / 1000)
),
subvalue: h.host.benchmark && getDownloadSpeed(h.host),
},
{
label: 'upload',
Expand All @@ -90,9 +89,7 @@ export default async function Image({ params }) {
rate: r.rates.sc.usd,
},
}),
subvalue: humanSpeed(
(h.host.benchmark.data_size * 8) / (h.host.benchmark.upload_time / 1000)
),
subvalue: h.host.benchmark && getUploadSpeed(h.host),
},
]

Expand Down
22 changes: 17 additions & 5 deletions apps/explorer/components/Address/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ export function Address({ id, address }: Props) {
...address.unconfirmed_transactions.map((tx) => ({
hash: tx.id,
sc: getTotal({
address: id,
inputs: tx.siacoin_inputs,
outputs: tx.siacoin_outputs,
}),
sf: getTotal({
address: id,
inputs: tx.siafund_inputs,
outputs: tx.siafund_outputs,
}).toNumber(),
Expand All @@ -72,10 +74,12 @@ export function Address({ id, address }: Props) {
...address.transactions.map((tx) => ({
hash: tx.id,
sc: getTotal({
address: id,
inputs: tx.siacoin_inputs,
outputs: tx.siacoin_outputs,
}),
sf: getTotal({
address: id,
inputs: tx.siafund_inputs,
outputs: tx.siafund_outputs,
}).toNumber(),
Expand All @@ -88,7 +92,7 @@ export function Address({ id, address }: Props) {
)
}
return list
}, [address])
}, [id, address])

const utxos = useMemo(() => {
const list: EntityListItemProps[] = []
Expand Down Expand Up @@ -159,15 +163,23 @@ export function Address({ id, address }: Props) {
}

function getTotal({
address,
inputs,
outputs,
}: {
inputs?: { value: string }[]
outputs?: { value: string }[]
address: string
inputs?: { value: string; unlock_hash: string }[]
outputs?: { value: string; unlock_hash: string }[]
}) {
return (outputs || [])
.reduce((acc, o) => acc.plus(o.value), new BigNumber(0))
.reduce(
(acc, o) => (o.unlock_hash === address ? acc.plus(o.value) : acc),
new BigNumber(0)
)
.minus(
(inputs || []).reduce((acc, i) => acc.plus(i.value), new BigNumber(0))
(inputs || []).reduce(
(acc, i) => (i.unlock_hash === address ? acc.plus(i.value) : acc),
new BigNumber(0)
)
)
}
6 changes: 3 additions & 3 deletions apps/explorer/components/Home/HostListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
getStorageCost,
getUploadCost,
getUploadSpeed,
} from '../../lib/host'
} from '@siafoundation/units'
import { useMemo } from 'react'
import { routes } from '../../config/routes'
import { useExchangeRate } from '../../hooks/useExchangeRate'
Expand Down Expand Up @@ -106,7 +106,7 @@ export function HostListItem({ host, rates, entity }: Props) {
</Tooltip>
<Tooltip content="Download speed">
<Text size="10" color="subtle" ellipsis>
{downloadSpeed}
{downloadSpeed || '-'}
</Text>
</Tooltip>
</div>
Expand All @@ -121,7 +121,7 @@ export function HostListItem({ host, rates, entity }: Props) {
</Tooltip>
<Tooltip content="Upload speed">
<Text size="10" color="subtle" ellipsis>
{uploadSpeed}
{uploadSpeed || '-'}
</Text>
</Tooltip>
</div>
Expand Down
10 changes: 7 additions & 3 deletions apps/explorer/components/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {
SiaCentralHostsNetworkMetricsResponse,
} from '@siafoundation/sia-central'
import { hashToAvatar } from '../../lib/avatar'
import { getDownloadCost, getStorageCost, getUploadCost } from '../../lib/host'
import {
getDownloadCost,
getStorageCost,
getUploadCost,
} from '@siafoundation/units'
import { HostListItem } from './HostListItem'
import { useExchangeRate } from '../../hooks/useExchangeRate'

Expand Down Expand Up @@ -62,7 +66,7 @@ export function Home({
<Tooltip
content={`${humanBytes(
metrics?.totals.total_storage -
metrics?.totals.remaining_storage
metrics?.totals.remaining_storage
)} used storage`}
>
<Text
Expand All @@ -72,7 +76,7 @@ export function Home({
>
{humanBytes(
metrics?.totals.total_storage -
metrics?.totals.remaining_storage
metrics?.totals.remaining_storage
)}
</Text>
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Host/HostPricing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getStorageCost,
getUploadCost,
getUploadSpeed,
} from '../../lib/host'
} from '@siafoundation/units'
import { useExchangeRate } from '../../hooks/useExchangeRate'

type Props = {
Expand Down
6 changes: 5 additions & 1 deletion apps/explorer/components/Host/HostSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import {
} from '@siafoundation/design-system'
import BigNumber from 'bignumber.js'
import { humanBytes, humanSiacoin, toSiacoins } from '@siafoundation/sia-js'
import { getDownloadCost, getStorageCost, getUploadCost } from '../../lib/host'
import {
getDownloadCost,
getStorageCost,
getUploadCost,
} from '@siafoundation/units'
import { useExchangeRate } from '../../hooks/useExchangeRate'
import { siacoinToFiat } from '../../lib/currency'

Expand Down
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
}
Loading