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 contract state column, migration surcharge multiplier setting, hostd walletd hide gpu preference #416

Merged
merged 3 commits into from
Nov 15, 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
6 changes: 6 additions & 0 deletions .changeset/quick-forks-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'hostd': minor
'walletd': minor
---

App preferences no longer list unused GPU setting.
5 changes: 5 additions & 0 deletions .changeset/sixty-suns-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The configuration now includes a setting for a migration surcharge multiplier which allows you to set a factor for increasing the max download price when trying to repair critically low health sectors.
5 changes: 5 additions & 0 deletions .changeset/soft-yaks-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The contracts table now includes a column for state that shows: pending, active, complete, or failed.
26 changes: 26 additions & 0 deletions apps/renterd/contexts/config/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,32 @@ export function getFields({
}
: {},
},
migrationSurchargeMultiplier: {
category: 'gouging',
type: 'number',
title: 'Migration surcharge multiplier',
units: '* download price',
placeholder: '10',
decimalsLimit: 1,
description: (
<>
Factor that gets applied on the max download price when trying to
download migration-critical sectors from a host that is price gouging.
For example, when migrating a low-health file, if the download is
failing but would potentially succeed with looser gouging settings, we
apply the migration surcharge multiplier to overpay on every sector
download if it means saving the file/migration.
</>
),
suggestion: new BigNumber(10),
suggestionTip: 'The default multiplier is 10x the download price.',
hidden: !showAdvanced,
validation: showAdvanced
? {
required: 'required',
}
: {},
},

// Redundancy
minShards: {
Expand Down
9 changes: 9 additions & 0 deletions apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
},
{
minShards: 10,
Expand Down Expand Up @@ -90,6 +91,7 @@ describe('tansforms', () => {
minMaxCollateral: new BigNumber('10'),
minMaxEphemeralAccountBalance: new BigNumber('1'),
minPriceTableValidityMinutes: new BigNumber(5),
migrationSurchargeMultiplier: new BigNumber(10),
minShards: new BigNumber(10),
totalShards: new BigNumber(30),
includeRedundancyMaxStoragePrice: false,
Expand Down Expand Up @@ -134,6 +136,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
},
{
minShards: 10,
Expand Down Expand Up @@ -169,6 +172,7 @@ describe('tansforms', () => {
minMaxCollateral: new BigNumber('10'),
minMaxEphemeralAccountBalance: new BigNumber('1'),
minPriceTableValidityMinutes: new BigNumber(5),
migrationSurchargeMultiplier: new BigNumber(10),
minShards: new BigNumber(10),
totalShards: new BigNumber(30),
includeRedundancyMaxStoragePrice: true,
Expand Down Expand Up @@ -327,6 +331,7 @@ describe('tansforms', () => {
minPriceTableValidityMinutes: new BigNumber(5),
minShards: new BigNumber(10),
totalShards: new BigNumber(30),
migrationSurchargeMultiplier: new BigNumber(10),
includeRedundancyMaxStoragePrice: false,
includeRedundancyMaxUploadPrice: false,
},
Expand All @@ -348,6 +353,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
})
})

Expand Down Expand Up @@ -379,6 +385,7 @@ describe('tansforms', () => {
minMaxCollateral: new BigNumber('10'),
minMaxEphemeralAccountBalance: new BigNumber('1'),
minPriceTableValidityMinutes: new BigNumber(5),
migrationSurchargeMultiplier: new BigNumber(10),
minShards: new BigNumber(10),
totalShards: new BigNumber(30),
includeRedundancyMaxStoragePrice: true,
Expand All @@ -402,6 +409,7 @@ describe('tansforms', () => {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
})
})

Expand Down Expand Up @@ -551,6 +559,7 @@ function buildAllResponses() {
minMaxCollateral: '10000000000000000000000000',
minMaxEphemeralAccountBalance: '1000000000000000000000000',
minPriceTableValidity: 300000000000,
migrationSurchargeMultiplier: 10,
},
redundancy: {
minShards: 10,
Expand Down
3 changes: 3 additions & 0 deletions apps/renterd/contexts/config/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export function transformUpGouging(
minMaxEphemeralAccountBalance: toHastings(
values.minMaxEphemeralAccountBalance
).toString(),
migrationSurchargeMultiplier:
values.migrationSurchargeMultiplier.toNumber(),
}
}

Expand Down Expand Up @@ -323,6 +325,7 @@ export function transformDownGouging(
g.minMaxEphemeralAccountBalance,
scDecimalPlaces
),
migrationSurchargeMultiplier: new BigNumber(g.migrationSurchargeMultiplier),
}
}

Expand Down
1 change: 1 addition & 0 deletions apps/renterd/contexts/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const defaultGouging = {
minPriceTableValidityMinutes: undefined as BigNumber | undefined,
minAccountExpiryDays: undefined as BigNumber | undefined,
minMaxEphemeralAccountBalance: undefined as BigNumber | undefined,
migrationSurchargeMultiplier: undefined as BigNumber | undefined,
}

export const defaultRedundancy = {
Expand Down
71 changes: 71 additions & 0 deletions apps/renterd/contexts/contracts/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import {
stripPrefix,
Tooltip,
ValueNum,
Badge,
Separator,
} from '@siafoundation/design-system'
import { ArrowUpLeft16 } from '@siafoundation/react-icons'
import { humanBytes, humanDate } from '@siafoundation/sia-js'
import { ContractData, TableColumnId } from './types'
import { ContractContextMenu } from '../../components/Contracts/ContractContextMenu'
import { ContractState } from '@siafoundation/react-renterd'

type Context = {
currentHeight: number
Expand Down Expand Up @@ -95,6 +98,59 @@ export const columns: ContractsTableColumn[] = [
return <ValueCopyable size="12" value={hostKey} label="host public key" />
},
},
{
id: 'state',
label: 'state',
category: 'general',
render: ({ data: { state } }) => {
return (
<Tooltip
content={
<div className="flex flex-col gap-1.5">
<div className="flex">
<Text className="flex-1" weight="medium">
pending
</Text>
<Text className="flex-[2]" color="subtle">
Contract has been added.
</Text>
</div>
<Separator className="w-full" />
<div className="flex">
<Text className="flex-1" weight="medium">
active
</Text>
<Text className="flex-[2]" color="subtle">
Contract has appeared on chain.
</Text>
</div>
<Separator className="w-full" />
<div className="flex">
<Text className="flex-1" weight="medium">
complete
</Text>
<Text className="flex-[2]" color="subtle">
Storage proof has appeared on chain.
</Text>
</div>
<Separator className="w-full" />
<div className="flex">
<Text className="flex-1" weight="medium">
failed
</Text>
<Text className="flex-[2]" color="subtle">
Storage proof was not submitted before the end of proof
window.
</Text>
</div>
</div>
}
>
<Badge variant={getContractStateColor(state)}>{state}</Badge>
</Tooltip>
)
},
},
{
id: 'timeline',
label: 'timeline',
Expand Down Expand Up @@ -207,3 +263,18 @@ export const columns: ContractsTableColumn[] = [
),
},
]

function getContractStateColor(state: ContractState) {
if (state === 'active') {
return 'amber'
}
if (state === 'failed') {
return 'red'
}
if (state === 'pending') {
return 'amber'
}
if (state === 'complete') {
return 'green'
}
}
1 change: 1 addition & 0 deletions apps/renterd/contexts/contracts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function useContractsMain() {
return {
id: c.id,
contractId: c.id,
state: c.state,
hostIp: c.hostIP,
hostKey: c.hostKey,
location: geoHosts.find((h) => h.public_key === c.hostKey)?.location,
Expand Down
10 changes: 10 additions & 0 deletions apps/renterd/contexts/contracts/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ContractState } from '@siafoundation/react-renterd'
import BigNumber from 'bignumber.js'

export type ContractData = {
id: string
hostIp: string
hostKey: string
state: ContractState
location?: [number, number]
isRenewed: boolean
renewedFrom: string
Expand All @@ -28,6 +30,7 @@ export type TableColumnId =
| 'contractId'
| 'hostIp'
| 'hostKey'
| 'state'
| 'timeline'
| 'startTime'
| 'endTime'
Expand All @@ -41,6 +44,7 @@ export const columnsDefaultVisible: TableColumnId[] = [
'contractId',
'hostIp',
'hostKey',
'state',
'timeline',
'size',
'totalCost',
Expand All @@ -53,6 +57,7 @@ export type SortField =
| 'contractId'
| 'hostIp'
| 'hostKey'
| 'state'
| 'timeline'
| 'startTime'
| 'endTime'
Expand Down Expand Up @@ -84,6 +89,11 @@ export const sortOptions: {
label: 'host public key',
category: 'general',
},
{
id: 'state',
label: 'state',
category: 'general',
},
{
id: 'timeline',
label: 'timeline',
Expand Down
1 change: 1 addition & 0 deletions apps/renterd/contexts/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export function Dialogs() {
<SettingsDialog
open={dialog === 'settings'}
onOpenChange={onOpenChange}
showGpuSetting
/>
<RenterdSendSiacoinDialog />
<WalletSingleAddressDetailsDialog
Expand Down
56 changes: 32 additions & 24 deletions libs/design-system/src/app/SettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ type Props = {
open: boolean
onOpenChange: (open: boolean) => void
securityEl?: React.ReactNode
showGpuSetting?: boolean
}

export function SettingsDialog({ open, onOpenChange, securityEl }: Props) {
export function SettingsDialog({
open,
onOpenChange,
securityEl,
showGpuSetting,
}: Props) {
const { settings, setSettings, gpu } = useAppSettings()

return (
Expand Down Expand Up @@ -96,30 +102,32 @@ export function SettingsDialog({ open, onOpenChange, securityEl }: Props) {
</Paragraph>
</div>
</Alert>
<Alert>
<div className="flex flex-col gap-4">
<div className="flex gap-2 items-center">
<Text>
<Information16 />
</Text>
<Heading size="20" className="flex-1">
GPU
</Heading>
<Switch
disabled={!gpu.canGpuRender}
checked={gpu.canGpuRender && gpu.isGpuEnabled}
onCheckedChange={gpu.setIsGpuEnabled}
size="medium"
/>
{showGpuSetting && (
<Alert>
<div className="flex flex-col gap-4">
<div className="flex gap-2 items-center">
<Text>
<Information16 />
</Text>
<Heading size="20" className="flex-1">
GPU
</Heading>
<Switch
disabled={!gpu.canGpuRender}
checked={gpu.canGpuRender && gpu.isGpuEnabled}
onCheckedChange={gpu.setIsGpuEnabled}
size="medium"
/>
</div>
<Paragraph size="14">
Enable features that require a GPU.{' '}
{gpu.canGpuRender
? ''
: 'This device does not support GPU rendering.'}
</Paragraph>
</div>
<Paragraph size="14">
Enable features that require a GPU.{' '}
{gpu.canGpuRender
? ''
: 'This device does not support GPU rendering.'}
</Paragraph>
</div>
</Alert>
</Alert>
)}
</div>
</div>
<Separator className="w-full" />
Expand Down
Loading