Skip to content

Commit b86432d

Browse files
Collection of PRs that require UI update (#1512)
This is a temporary branch to merge PRs into that break the UI. Once this is complete, we can update the UI in a single version, update the version in this branche's `go.mod`, test that it is working and then merge everything at once. Required Updates: - [x] `/account/:id/resetdrift` moved to worker (#1464) - [x] `/search/hosts` to `/hosts` (#1484) - [x] `/wallet` (#1478) - [x] `/search/objects` and `/objects/*path` to `/listobjects` (#1493) - [x] gouging settings now use base units (#1505) - [x] removed `/autopilot/host` and `/autopilot/hosts` (#1508) - [x] removed `/slab/:key/objects` and integrated it into the list objects endpoint (#1517) - [x] endpoints no longer default to "default" bucket #1541
2 parents 19bcf68 + 632d32a commit b86432d

File tree

139 files changed

+7183
-6116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+7183
-6116
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ body:
6666
description: |
6767
The configuration of your bus
6868
```bash
69-
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/contractset
70-
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/gouging
71-
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/redundancy
72-
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/uploadpacking
69+
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/gouging
70+
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/pinned
71+
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/s3
72+
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/uploads
7373
```
7474
placeholder: Paste the output of the above commands here
7575
validations:

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
autopilot
2626
bus bus/client
2727
worker worker/client
28+
flags: |
29+
-japecheck.types=false
2830
test:
2931
needs: analyze
3032
runs-on: ${{ matrix.os }}

README.md

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ overview of all settings configurable through the CLI.
5454
| `Log.Database.Level` | Logger level for database queries (info\|warn\|error). Defaults to 'warn' | `warn` | `--log.database.level` | `RENTERD_LOG_DATABASE_LEVEL`, `RENTERD_LOG_LEVEL` | `log.database.level` |
5555
| `Log.Database.IgnoreRecordNotFoundError` | Enable ignoring 'not found' errors resulting from database queries. Defaults to 'true' | `true` | `--log.database.ignoreRecordNotFoundError` | `RENTERD_LOG_DATABASE_IGNORE_RECORD_NOT_FOUND_ERROR` | `log.database.ignoreRecordNotFoundError` |
5656
| `Log.Database.SlowThreshold` | Threshold for slow queries in logger. Defaults to 100ms | `100ms` | `--log.database.slowThreshold` | `RENTERD_LOG_DATABASE_SLOW_THRESHOLD` | `log.database.slowThreshold` |
57-
| `Log.Database.Level (DEPRECATED)` | Logger level | `warn` | `--db.logger.logLevel` | `RENTERD_DB_LOGGER_LOG_LEVEL` | `log.database.level` |
58-
| `Log.Database.IgnoreRecordNotFoundError (DEPRECATED)` | Ignores 'not found' errors in logger | `true` | `--db.logger.ignoreNotFoundError`| `RENTERD_DB_LOGGER_IGNORE_NOT_FOUND_ERROR` | `log.ignoreRecordNotFoundError` |
59-
| `Log.Database.SlowThreshold (DEPRECATED)` | Threshold for slow queries in logger | `100ms` | `--db.logger.slowThreshold` | `RENTERD_DB_LOGGER_SLOW_THRESHOLD` | `log.slowThreshold` |
60-
| `Log.Path (DEPRECATED)` | Path to directory for logs | - | `--log-path` | `RENTERD_LOG_PATH` | `log.path` |
6157
| `Database.MySQL.URI` | Database URI for the bus | - | `--db.uri` | `RENTERD_DB_URI` | `database.mysql.uri` |
6258
| `Database.MySQL.User` | Database username for the bus | `renterd` | `--db.user` | `RENTERD_DB_USER` | `database.mysql.user` |
6359
| `Database.MySQL.Password` | Database password for the bus | - | - | `RENTERD_DB_PASSWORD` | `database.mysql.password` |
@@ -70,7 +66,6 @@ overview of all settings configurable through the CLI.
7066
| `Bus.GatewayAddr` | Address for Sia peer connections | `:9981` | `--bus.gatewayAddr` | `RENTERD_BUS_GATEWAY_ADDR` | `bus.gatewayAddr` |
7167
| `Bus.RemoteAddr` | Remote address for the bus | - | - | `RENTERD_BUS_REMOTE_ADDR` | `bus.remoteAddr` |
7268
| `Bus.RemotePassword` | Remote password for the bus | - | - | `RENTERD_BUS_API_PASSWORD` | `bus.remotePassword` |
73-
| `Bus.PersistInterval` | Interval for persisting consensus updates | `1m` | `--bus.persistInterval` | - | `bus.persistInterval` |
7469
| `Bus.UsedUTXOExpiry` | Expiry for used UTXOs in transactions | `24h` | `--bus.usedUTXOExpiry` | - | `bus.usedUtxoExpiry` |
7570
| `Bus.SlabBufferCompletionThreshold` | Threshold for slab buffer upload | `4096` | `--bus.slabBufferCompletionThreshold` | `RENTERD_BUS_SLAB_BUFFER_COMPLETION_THRESHOLD` | `bus.slabBufferCompletionThreshold` |
7671
| `Worker.AllowPrivateIPs` | Allows hosts with private IPs | - | `--worker.allowPrivateIPs` | - | `worker.allowPrivateIPs` |
@@ -102,7 +97,8 @@ overview of all settings configurable through the CLI.
10297
| `S3.Enabled` | Enables/disables S3 API | `true` | `--s3.enabled` | `RENTERD_S3_ENABLED` | `s3.enabled` |
10398
| `S3.HostBucketBases` | Enables bucket rewriting in the router for the provided bases | - | `--s3.hostBucketBases` | `RENTERD_S3_HOST_BUCKET_BASES` | `s3.hostBucketBases` |
10499
| `S3.HostBucketEnabled` | Enables bucket rewriting in the router | - | `--s3.hostBucketEnabled` | `RENTERD_S3_HOST_BUCKET_ENABLED` | `s3.hostBucketEnabled` |
105-
| `S3.KeypairsV4 (DEPRECATED)` | V4 keypairs for S3 | - | - | - | `s3.keypairsV4` |
100+
| `Explorer.Disable` | Disables explorer service | `false` | `--explorer.disable` | `RENTERD_EXPLORER_DISABLE` | `explorer.disable` |
101+
| `Explorer.URL` | URL of service to retrieve data about the Sia network | `https://api.siascan.com` | `--explorer.url` | `RENTERD_EXPLORER_URL` | `explorer.url` |
106102

107103
### Single-Node Setup
108104

@@ -558,65 +554,6 @@ formed.
558554
}
559555
```
560556

561-
### Contract Set
562-
563-
The contract set settings on the bus allow specifying a default contract set.
564-
This contract set will be returned by the `bus` through the upload parameters,
565-
and decides what contracts data is upload or migrated to by default. This
566-
setting does not have a default value, it can be updated using the settings API:
567-
568-
- `GET /api/bus/setting/contractset`
569-
- `PUT /api/bus/setting/contractset`
570-
571-
```json
572-
{
573-
"default": "autopilot"
574-
}
575-
```
576-
577-
In most cases the default set should match the set from your autopilot
578-
configuration in order for migrations to work properly. The contract set can be
579-
overridden by passing it as a query string parameter to the worker's upload and
580-
migrate endpoints.
581-
582-
- `PUT /api/worker/objects/foo?contractset=foo`
583-
584-
### Redundancy
585-
586-
The default redundancy on mainnet is 30-10, on testnet it is 6-2. The redundancy
587-
can be updated using the settings API:
588-
589-
- `GET /api/bus/setting/redundancy`
590-
- `PUT /api/bus/setting/redundancy`
591-
592-
The redundancy can also be passed through query string parameters on the upload
593-
endpoint in the worker API:
594-
595-
- `PUT /api/worker/objects/foo?minshards=2&totalshards=5`
596-
597-
### Gouging
598-
599-
The default gouging settings are listed below. The gouging settings can be
600-
updated using the settings API:
601-
602-
- `GET /api/bus/setting/gouging`
603-
- `PUT /api/bus/setting/gouging`
604-
605-
```json
606-
{
607-
"hostBlockHeightLeeway": 6, // 6 blocks
608-
"maxContractPrice": "15000000000000000000000000", // 15 SC per contract
609-
"maxDownloadPrice": "3000000000000000000000000000", // 3000 SC per 1 TB
610-
"maxRPCPrice": "1000000000000000000000", // 1mS per RPC
611-
"maxStoragePrice": "631593542824", // 3000 SC per TB per month
612-
"maxUploadPrice": "3000000000000000000000000000", // 3000 SC per 1 TB
613-
"migrationSurchargeMultiplier": 10, // overpay up to 10x for sectors migrations on critical slabs
614-
"minAccountExpiry": 86400000000000, // 1 day
615-
"minMaxEphemeralAccountBalance": "1000000000000000000000000", // 1 SC
616-
"minPriceTableValidity": 300000000000 // 5 minutes
617-
}
618-
```
619-
620557
### Blocklist
621558

622559
Unfortunately the Sia blockchain is subject to hosts that announced themselves

alerts/prometheus.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package alerts
2+
3+
import "go.sia.tech/renterd/internal/prometheus"
4+
5+
// PrometheusMetric implements prometheus.Marshaller.
6+
func (a Alert) PrometheusMetric() (metrics []prometheus.Metric) {
7+
metrics = append(metrics, prometheus.Metric{
8+
Name: "renterd_alert",
9+
Labels: map[string]any{
10+
"id": a.ID,
11+
"severity": a.Severity.String(),
12+
"message": a.Message,
13+
"timestamp": a.Timestamp,
14+
},
15+
Value: 1,
16+
})
17+
return
18+
}
19+
20+
// PrometheusMetric implements prometheus.Marshaller.
21+
func (a AlertsResponse) PrometheusMetric() (metrics []prometheus.Metric) {
22+
metrics = prometheus.Slice(a.Alerts).PrometheusMetric()
23+
return
24+
}

api/autopilot.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type (
8686
// AutopilotStateResponse is the response type for the /autopilot/state
8787
// endpoint.
8888
AutopilotStateResponse struct {
89+
ID string `json:"id"`
8990
Configured bool `json:"configured"`
9091
Migrating bool `json:"migrating"`
9192
MigratingLastStart TimeRFC3339 `json:"migratingLastStart"`

api/bucket.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import (
44
"errors"
55
)
66

7-
const (
8-
DefaultBucketName = "default"
9-
)
10-
117
var (
128
// ErrBucketExists is returned when trying to create a bucket that already
139
// exists.

api/bus.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import (
88
)
99

1010
var (
11+
ErrInvalidOffset = errors.New("offset must be non-negative")
12+
ErrInvalidLength = errors.New("length must be positive")
13+
ErrInvalidLimit = errors.New("limit must be -1 or bigger")
1114
ErrMarkerNotFound = errors.New("marker not found")
1215
ErrMaxFundAmountExceeded = errors.New("renewal exceeds max fund amount")
16+
ErrExplorerDisabled = errors.New("explorer is disabled")
1317
)
1418

1519
type (
@@ -64,6 +68,13 @@ type (
6468
StartTime TimeRFC3339 `json:"startTime"`
6569
Network string `json:"network"`
6670
BuildState
71+
Explorer ExplorerState `json:"explorer"`
72+
}
73+
74+
// ExplorerState contains static information about explorer data sources.
75+
ExplorerState struct {
76+
Enabled bool `json:"enabled"`
77+
URL string `json:"url,omitempty"`
6778
}
6879

6980
ContractSetUpdateRequest struct {

api/contract.go

Lines changed: 35 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,32 @@ type (
5050

5151
// ContractMetadata contains all metadata for a contract.
5252
ContractMetadata struct {
53-
ID types.FileContractID `json:"id"`
54-
HostIP string `json:"hostIP"`
55-
HostKey types.PublicKey `json:"hostKey"`
56-
SiamuxAddr string `json:"siamuxAddr"`
57-
58-
ProofHeight uint64 `json:"proofHeight"`
59-
RevisionHeight uint64 `json:"revisionHeight"`
60-
RevisionNumber uint64 `json:"revisionNumber"`
61-
Size uint64 `json:"size"`
62-
StartHeight uint64 `json:"startHeight"`
63-
State string `json:"state"`
64-
WindowStart uint64 `json:"windowStart"`
65-
WindowEnd uint64 `json:"windowEnd"`
66-
67-
ContractPrice types.Currency `json:"contractPrice"`
68-
RenewedFrom types.FileContractID `json:"renewedFrom"`
69-
Spending ContractSpending `json:"spending"`
70-
TotalCost types.Currency `json:"totalCost"`
71-
72-
ContractSets []string `json:"contractSets"`
53+
ID types.FileContractID `json:"id"`
54+
HostKey types.PublicKey `json:"hostKey"`
55+
56+
ProofHeight uint64 `json:"proofHeight"`
57+
RenewedFrom types.FileContractID `json:"renewedFrom"`
58+
RevisionHeight uint64 `json:"revisionHeight"`
59+
RevisionNumber uint64 `json:"revisionNumber"`
60+
Size uint64 `json:"size"`
61+
StartHeight uint64 `json:"startHeight"`
62+
State string `json:"state"`
63+
WindowStart uint64 `json:"windowStart"`
64+
WindowEnd uint64 `json:"windowEnd"`
65+
66+
// costs & spending
67+
ContractPrice types.Currency `json:"contractPrice"`
68+
InitialRenterFunds types.Currency `json:"initialRenterFunds"`
69+
Spending ContractSpending `json:"spending"`
70+
71+
// following fields are decorated
72+
HostIP string `json:"hostIP"`
73+
ContractSets []string `json:"contractSets,omitempty"`
74+
SiamuxAddr string `json:"siamuxAddr,omitempty"`
75+
76+
// following fields are only set on archived contracts
77+
ArchivalReason string `json:"archivalReason,omitempty"`
78+
RenewedTo types.FileContractID `json:"renewedTo,omitempty"`
7379
}
7480

7581
// ContractPrunableData wraps a contract's size information with its id.
@@ -80,11 +86,10 @@ type (
8086

8187
// ContractSpending contains all spending details for a contract.
8288
ContractSpending struct {
83-
Uploads types.Currency `json:"uploads"`
84-
Downloads types.Currency `json:"downloads"`
85-
FundAccount types.Currency `json:"fundAccount"`
8689
Deletions types.Currency `json:"deletions"`
90+
FundAccount types.Currency `json:"fundAccount"`
8791
SectorRoots types.Currency `json:"sectorRoots"`
92+
Uploads types.Currency `json:"uploads"`
8893
}
8994

9095
ContractSpendingRecord struct {
@@ -96,29 +101,6 @@ type (
96101
MissedHostPayout types.Currency `json:"missedHostPayout"`
97102
ValidRenterPayout types.Currency `json:"validRenterPayout"`
98103
}
99-
100-
// An ArchivedContract contains all information about a contract with a host
101-
// that has been moved to the archive either due to expiring or being renewed.
102-
ArchivedContract struct {
103-
ID types.FileContractID `json:"id"`
104-
HostIP string `json:"hostIP"`
105-
HostKey types.PublicKey `json:"hostKey"`
106-
RenewedTo types.FileContractID `json:"renewedTo"`
107-
Spending ContractSpending `json:"spending"`
108-
109-
ArchivalReason string `json:"archivalReason"`
110-
ContractPrice types.Currency `json:"contractPrice"`
111-
ProofHeight uint64 `json:"proofHeight"`
112-
RenewedFrom types.FileContractID `json:"renewedFrom"`
113-
RevisionHeight uint64 `json:"revisionHeight"`
114-
RevisionNumber uint64 `json:"revisionNumber"`
115-
Size uint64 `json:"size"`
116-
StartHeight uint64 `json:"startHeight"`
117-
State string `json:"state"`
118-
TotalCost types.Currency `json:"totalCost"`
119-
WindowStart uint64 `json:"windowStart"`
120-
WindowEnd uint64 `json:"windowEnd"`
121-
}
122104
)
123105

124106
type (
@@ -137,11 +119,11 @@ type (
137119

138120
// ContractAddRequest is the request type for the /contract/:id endpoint.
139121
ContractAddRequest struct {
140-
Contract rhpv2.ContractRevision `json:"contract"`
141-
ContractPrice types.Currency `json:"contractPrice"`
142-
StartHeight uint64 `json:"startHeight"`
143-
State string `json:"state,omitempty"`
144-
TotalCost types.Currency `json:"totalCost"`
122+
ContractPrice types.Currency `json:"contractPrice"`
123+
InitialRenterFunds types.Currency `json:"initialRenterFunds"`
124+
Revision rhpv2.ContractRevision `json:"revision"`
125+
StartHeight uint64 `json:"startHeight"`
126+
State string `json:"state,omitempty"`
145127
}
146128

147129
// ContractFormRequest is the request type for the POST /contracts endpoint.
@@ -192,17 +174,6 @@ type (
192174
RenterFunds types.Currency `json:"renterFunds"`
193175
}
194176

195-
// ContractRenewedRequest is the request type for the /contract/:id/renewed
196-
// endpoint.
197-
ContractRenewedRequest struct {
198-
Contract rhpv2.ContractRevision `json:"contract"`
199-
ContractPrice types.Currency `json:"contractPrice"`
200-
RenewedFrom types.FileContractID `json:"renewedFrom"`
201-
StartHeight uint64 `json:"startHeight"`
202-
State string `json:"state,omitempty"`
203-
TotalCost types.Currency `json:"totalCost"`
204-
}
205-
206177
// ContractRootsResponse is the response type for the /contract/:id/roots
207178
// endpoint.
208179
ContractRootsResponse struct {
@@ -223,18 +194,18 @@ type (
223194

224195
ContractsOpts struct {
225196
ContractSet string `json:"contractset"`
197+
FilterMode string `json:"filterMode"`
226198
}
227199
)
228200

229201
// Total returns the total cost of the contract spending.
230202
func (x ContractSpending) Total() types.Currency {
231-
return x.Uploads.Add(x.Downloads).Add(x.FundAccount).Add(x.Deletions).Add(x.SectorRoots)
203+
return x.Uploads.Add(x.FundAccount).Add(x.Deletions).Add(x.SectorRoots)
232204
}
233205

234206
// Add returns the sum of the current and given contract spending.
235207
func (x ContractSpending) Add(y ContractSpending) (z ContractSpending) {
236208
z.Uploads = x.Uploads.Add(y.Uploads)
237-
z.Downloads = x.Downloads.Add(y.Downloads)
238209
z.FundAccount = x.FundAccount.Add(y.FundAccount)
239210
z.Deletions = x.Deletions.Add(y.Deletions)
240211
z.SectorRoots = x.SectorRoots.Add(y.SectorRoots)

0 commit comments

Comments
 (0)