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 prune sector roots, fix host interactions data, onboarding display, balance evolution, decimal inputs #433

Merged
merged 5 commits into from
Dec 5, 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/chilly-walls-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

Fixed an issue with the host interaction values showing as 0s on the host explorer.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-snakes-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The advanced configuration now includes a prune sector roots setting.
5 changes: 5 additions & 0 deletions .changeset/short-cheetahs-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/react-renterd': minor
---

Update host interaction type casing.
5 changes: 5 additions & 0 deletions .changeset/six-buses-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The wallet page now shows the balance evolution again, using the new wallet metrics API.
5 changes: 5 additions & 0 deletions .changeset/small-pandas-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/react-renterd': minor
---

Add metrics APIs.
6 changes: 6 additions & 0 deletions .changeset/swift-cobras-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'hostd': minor
'renterd': minor
---

The onboarding wizard no longer shows on the login page.
7 changes: 7 additions & 0 deletions .changeset/warm-ants-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'hostd': minor
'renterd': minor
'@siafoundation/design-system': minor
---

Fixed an issue where number fields would not properly handle user input starting with a decimal separator.
6 changes: 3 additions & 3 deletions apps/hostd/components/CmdKDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ type Props = {
}

export function CmdKDialog({ open, onOpenChange, setOpen }: Props) {
const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
const { isConnected } = useConnectivity({
route: connectivityRoute,
})
// Toggle the menu when ⌘K is pressed
useEffect(() => {
if (!isUnlocked || !isConnected) {
if (!isUnlockedAndAuthedRoute || !isConnected) {
return
}
const down = (e: KeyboardEvent) => {
Expand All @@ -28,7 +28,7 @@ export function CmdKDialog({ open, onOpenChange, setOpen }: Props) {

document.addEventListener('keydown', down)
return () => document.removeEventListener('keydown', down)
}, [isUnlocked, isConnected, setOpen])
}, [isUnlockedAndAuthedRoute, isConnected, setOpen])

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions apps/hostd/components/OnboardingBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useVolumes } from '../contexts/volumes'
import useLocalStorageState from 'use-local-storage-state'

export function OnboardingBar() {
const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
const { openDialog } = useDialog()
const { dataset: volumes } = useVolumes()
const settings = useSettings()
Expand All @@ -38,7 +38,7 @@ export function OnboardingBar() {
)
const syncStatus = useSyncStatus()

if (!isUnlocked) {
if (!isUnlockedAndAuthedRoute) {
return null
}

Expand Down
6 changes: 3 additions & 3 deletions apps/hostd/contexts/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ export function useConfigMain() {
}
}, [form, resetFormDataIfAllDataFetched])

const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
useEffect(() => {
if (isUnlocked) {
if (isUnlockedAndAuthedRoute) {
revalidateAndResetFormData()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isUnlocked])
}, [isUnlockedAndAuthedRoute])

useEffect(() => {
if (form.formState.isSubmitting) {
Expand Down
6 changes: 3 additions & 3 deletions apps/hostd/hooks/useSyncStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@siafoundation/react-hostd'

export function useSyncStatus() {
const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
const state = useStateConsensus({
config: {
swr: {
Expand All @@ -26,14 +26,14 @@ export function useSyncStatus() {
})

const syncPercent =
isUnlocked && nodeBlockHeight && estimatedBlockHeight
isUnlockedAndAuthedRoute && nodeBlockHeight && estimatedBlockHeight
? Number(
(Math.min(nodeBlockHeight / estimatedBlockHeight, 1) * 100).toFixed(1)
)
: 0

const walletScanPercent =
isUnlocked && nodeBlockHeight && wallet.data
isUnlockedAndAuthedRoute && nodeBlockHeight && wallet.data
? Number(
(
Math.min(wallet.data.scanHeight / estimatedBlockHeight, 1) * 100
Expand Down
6 changes: 3 additions & 3 deletions apps/renterd/components/CmdKDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ type Props = {
}

export function CmdKDialog({ open, onOpenChange, setOpen }: Props) {
const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
const { isConnected } = useConnectivity({
route: connectivityRoute,
})
// Toggle the menu when ⌘K is pressed
useEffect(() => {
if (!isUnlocked || !isConnected) {
if (!isUnlockedAndAuthedRoute || !isConnected) {
return
}
const down = (e: KeyboardEvent) => {
Expand All @@ -28,7 +28,7 @@ export function CmdKDialog({ open, onOpenChange, setOpen }: Props) {

document.addEventListener('keydown', down)
return () => document.removeEventListener('keydown', down)
}, [isUnlocked, isConnected, setOpen])
}, [isUnlockedAndAuthedRoute, isConnected, setOpen])

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/components/OnboardingBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useAppSettings } from '@siafoundation/react-core'
import useLocalStorageState from 'use-local-storage-state'

export function OnboardingBar() {
const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
const app = useApp()
const { openDialog } = useDialog()
const wallet = useWallet()
Expand All @@ -47,7 +47,7 @@ export function OnboardingBar() {
const syncStatus = useSyncStatus()
const notEnoughContracts = useNotEnoughContracts()

if (!isUnlocked || app.autopilot.status !== 'on') {
if (!isUnlockedAndAuthedRoute || app.autopilot.status !== 'on') {
return null
}

Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/components/TransfersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ function getProgress(transfer: { loaded?: number; size?: number }) {
}

export function TransfersBar() {
const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
const { uploadsList, uploadCancel, downloadsList, downloadCancel } =
useFiles()
const [maximized, setMaximized] = useState<boolean>(true)

const uploadCount = uploadsList.length
const downloadCount = downloadsList.length

if (!isUnlocked) {
if (!isUnlockedAndAuthedRoute) {
return null
}

Expand Down
10 changes: 6 additions & 4 deletions apps/renterd/components/Wallet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BalanceEvolution,
EntityList,
PaginatorUnknownTotal,
WalletLayoutActions,
Expand All @@ -17,7 +18,8 @@ import { WalletFilterBar } from './WalletFilterBar'
export function Wallet() {
const { openDialog } = useDialog()
const wallet = useWallet()
const { dataset, offset, limit, pageCount, dataState } = useTransactions()
const { dataset, offset, limit, pageCount, dataState, balances, metrics } =
useTransactions()
const { isSynced, syncPercent, isWalletSynced, walletScanPercent } =
useSyncStatus()

Expand Down Expand Up @@ -49,14 +51,14 @@ export function Wallet() {
stats={<WalletFilterBar />}
>
<div className="p-6 flex flex-col gap-5">
{/* {balances?.length ? (
{balances?.length ? (
<BalanceEvolution
// see comment above
chartType="line"
balances={balances}
isLoading={transactions.isValidating}
isLoading={metrics.isValidating}
/>
) : null} */}
) : null}
<EntityList
title="Transactions"
isLoading={dataState === 'loading'}
Expand Down
28 changes: 28 additions & 0 deletions apps/renterd/contexts/config/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,34 @@ export function getFields({
}
: {},
},
prune: {
type: 'boolean',
category: 'storage',
title: 'Prune sector roots',
description: (
<>
When enabled, autopilot will try to prune deleted sector roots from
contracts one contract at a time, for a max duration of 10 minutes per
contract. For old hosts this process takes quite a while, while for
new hosts it is fast. For new hosts pruning effectively deletes data
from the contract, allowing the renter to stop paying for storage they
are not using.
</>
),
suggestion: advancedDefaults?.prune,
suggestionTip: (
<>
The default value is <Code>{advancedDefaults?.prune}</Code>.
</>
),
hidden: !isAutopilotEnabled || !showAdvanced,
validation:
isAutopilotEnabled && showAdvanced
? {
required: 'required',
}
: {},
},

// hosts
allowRedundantIPs: {
Expand Down
6 changes: 3 additions & 3 deletions apps/renterd/contexts/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,13 @@ export function useConfigMain() {
}
}, [form, resetFormDataIfAllDataFetched])

const { isUnlocked } = useAppSettings()
const { isUnlockedAndAuthedRoute } = useAppSettings()
useEffect(() => {
if (isUnlocked && app.autopilot.status !== 'init') {
if (isUnlockedAndAuthedRoute && app.autopilot.status !== 'init') {
revalidateAndResetFormData()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isUnlocked, app.autopilot.status])
}, [isUnlockedAndAuthedRoute, app.autopilot.status])

useEffect(() => {
if (form.formState.isSubmitting) {
Expand Down
13 changes: 13 additions & 0 deletions apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('tansforms', () => {
download: 1099511627776,
upload: 1100000000000,
storage: 1000000000000,
prune: true,
},
},
{ default: 'myset' },
Expand Down Expand Up @@ -75,6 +76,7 @@ describe('tansforms', () => {
downloadTBMonth: new BigNumber('1.1'),
uploadTBMonth: new BigNumber('1.1'),
storageTB: new BigNumber('1'),
prune: true,
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
Expand Down Expand Up @@ -121,6 +123,7 @@ describe('tansforms', () => {
download: 1099511627776,
upload: 1100000000000,
storage: 1000000000000,
prune: true,
},
},
{ default: 'myset' },
Expand Down Expand Up @@ -177,6 +180,7 @@ describe('tansforms', () => {
totalShards: new BigNumber(30),
includeRedundancyMaxStoragePrice: true,
includeRedundancyMaxUploadPrice: true,
prune: true,
} as SettingsData)
})
})
Expand All @@ -195,6 +199,7 @@ describe('tansforms', () => {
downloadTBMonth: new BigNumber('0.785365448411428571428571428571'),
uploadTBMonth: new BigNumber('0.785714285714285714285714285714'),
storageTB: new BigNumber('1'),
prune: true,
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
Expand All @@ -221,6 +226,7 @@ describe('tansforms', () => {
download: 1099511627776,
upload: 1100000000000,
storage: 1000000000000,
prune: true,
},
})
})
Expand All @@ -237,6 +243,7 @@ describe('tansforms', () => {
downloadTBMonth: new BigNumber('0.785365448411428571428571428571'),
uploadTBMonth: new BigNumber('0.785714285714285714285714285714'),
storageTB: new BigNumber('1'),
prune: true,
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
Expand Down Expand Up @@ -280,6 +287,7 @@ describe('tansforms', () => {
download: 1099511627776,
upload: 1100000000000,
storage: 1000000000000,
prune: true,
},
})
})
Expand All @@ -296,6 +304,7 @@ describe('tansforms', () => {
downloadTBMonth: new BigNumber('0.785365448411428571428571428571'),
uploadTBMonth: new BigNumber('0.785714285714285714285714285714'),
storageTB: new BigNumber('1'),
prune: true,
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
Expand Down Expand Up @@ -329,6 +338,7 @@ describe('tansforms', () => {
download: 1099511627776,
upload: 1100000000000,
storage: 1000000000000,
prune: true,
},
})
})
Expand Down Expand Up @@ -363,6 +373,7 @@ describe('tansforms', () => {
downloadTBMonth: new BigNumber('0.785365448411428571428571428571'),
uploadTBMonth: new BigNumber('0.785714285714285714285714285714'),
storageTB: new BigNumber('1'),
prune: true,
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
Expand Down Expand Up @@ -419,6 +430,7 @@ describe('tansforms', () => {
downloadTBMonth: new BigNumber('0.785365448411428571428571428571'),
uploadTBMonth: new BigNumber('0.785714285714285714285714285714'),
storageTB: new BigNumber('1'),
prune: true,
allowRedundantIPs: false,
maxDowntimeHours: new BigNumber('1440'),
minRecentScanFailures: new BigNumber('10'),
Expand Down Expand Up @@ -594,6 +606,7 @@ function buildAllResponses() {
download: 1099511627776,
upload: 1100000000000,
storage: 1000000000000,
prune: true,
},
},
contractSet: { default: 'myset' },
Expand Down
Loading