Skip to content

Commit

Permalink
Merge branch 'api-breakers' into chris/host-check-json
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Sep 16, 2024
2 parents a4d3cc6 + b871983 commit 5e58468
Show file tree
Hide file tree
Showing 55 changed files with 1,190 additions and 1,339 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ body:
description: |
The configuration of your bus
```bash
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/contractset
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/gouging
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/redundancy
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/setting/uploadpacking
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/gouging
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/pinned
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/s3
curl -u ":[YOUR_PASSWORD]" http://localhost:9980/api/bus/settings/uploads
```
placeholder: Paste the output of the above commands here
validations:
Expand Down
59 changes: 0 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,65 +554,6 @@ formed.
}
```

### Contract Set

The contract set settings on the bus allow specifying a default contract set.
This contract set will be returned by the `bus` through the upload parameters,
and decides what contracts data is upload or migrated to by default. This
setting does not have a default value, it can be updated using the settings API:

- `GET /api/bus/setting/contractset`
- `PUT /api/bus/setting/contractset`

```json
{
"default": "autopilot"
}
```

In most cases the default set should match the set from your autopilot
configuration in order for migrations to work properly. The contract set can be
overridden by passing it as a query string parameter to the worker's upload and
migrate endpoints.

- `PUT /api/worker/objects/foo?contractset=foo`

### Redundancy

The default redundancy on mainnet is 30-10, on testnet it is 6-2. The redundancy
can be updated using the settings API:

- `GET /api/bus/setting/redundancy`
- `PUT /api/bus/setting/redundancy`

The redundancy can also be passed through query string parameters on the upload
endpoint in the worker API:

- `PUT /api/worker/objects/foo?minshards=2&totalshards=5`

### Gouging

The default gouging settings are listed below. The gouging settings can be
updated using the settings API:

- `GET /api/bus/setting/gouging`
- `PUT /api/bus/setting/gouging`

```json
{
"hostBlockHeightLeeway": 6, // 6 blocks
"maxContractPrice": "15000000000000000000000000", // 15 SC per contract
"maxDownloadPrice": "3000000000000000000000000000", // 3000 SC per 1 TB
"maxRPCPrice": "1000000000000000000000", // 1mS per RPC
"maxStoragePrice": "631593542824", // 3000 SC per TB per month
"maxUploadPrice": "3000000000000000000000000000", // 3000 SC per 1 TB
"migrationSurchargeMultiplier": 10, // overpay up to 10x for sectors migrations on critical slabs
"minAccountExpiry": 86400000000000, // 1 day
"minMaxEphemeralAccountBalance": "1000000000000000000000000", // 1 SC
"minPriceTableValidity": 300000000000 // 5 minutes
}
```

### Blocklist

Unfortunately the Sia blockchain is subject to hosts that announced themselves
Expand Down
1 change: 1 addition & 0 deletions api/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type (
// AutopilotStateResponse is the response type for the /autopilot/state
// endpoint.
AutopilotStateResponse struct {
ID string `json:"id"`
Configured bool `json:"configured"`
Migrating bool `json:"migrating"`
MigratingLastStart TimeRFC3339 `json:"migratingLastStart"`
Expand Down
42 changes: 11 additions & 31 deletions api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const (

EventAdd = "add"
EventUpdate = "update"
EventDelete = "delete"
EventArchive = "archive"
EventRenew = "renew"
)
Expand Down Expand Up @@ -51,28 +50,25 @@ type (
Timestamp time.Time `json:"timestamp"`
}

EventHostUpdate struct {
HostKey types.PublicKey `json:"hostKey"`
NetAddr string `json:"netAddr"`
Timestamp time.Time `json:"timestamp"`
}

EventContractSetUpdate struct {
Name string `json:"name"`
ToAdd []types.FileContractID `json:"toAdd"`
ToRemove []types.FileContractID `json:"toRemove"`
Timestamp time.Time `json:"timestamp"`
}

EventSettingUpdate struct {
Key string `json:"key"`
Update interface{} `json:"update"`
Timestamp time.Time `json:"timestamp"`
EventHostUpdate struct {
HostKey types.PublicKey `json:"hostKey"`
NetAddr string `json:"netAddr"`
Timestamp time.Time `json:"timestamp"`
}

EventSettingDelete struct {
Key string `json:"key"`
Timestamp time.Time `json:"timestamp"`
EventSettingUpdate struct {
GougingSettings *GougingSettings `json:"gougingSettings,omitempty"`
PinnedSettings *PinnedSettings `json:"pinnedSettings,omitempty"`
S3Settings *S3Settings `json:"s3Settings,omitempty"`
UploadSettings *UploadSettings `json:"uploadSettings,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
)

Expand Down Expand Up @@ -139,15 +135,6 @@ var (
URL: url,
}
}

WebhookSettingDelete = func(url string, headers map[string]string) webhooks.Webhook {
return webhooks.Webhook{
Event: EventDelete,
Headers: headers,
Module: ModuleSetting,
URL: url,
}
}
)

func ParseEventWebhook(event webhooks.Event) (interface{}, error) {
Expand Down Expand Up @@ -202,19 +189,12 @@ func ParseEventWebhook(event webhooks.Event) (interface{}, error) {
return e, nil
}
case ModuleSetting:
switch event.Event {
case EventUpdate:
if event.Event == EventUpdate {
var e EventSettingUpdate
if err := json.Unmarshal(bytes, &e); err != nil {
return nil, err
}
return e, nil
case EventDelete:
var e EventSettingDelete
if err := json.Unmarshal(bytes, &e); err != nil {
return nil, err
}
return e, nil
}
}
return nil, fmt.Errorf("%w: module %s event %s", ErrUnknownEvent, event.Module, event.Event)
Expand Down
16 changes: 0 additions & 16 deletions api/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,6 @@ type (
AddressContains string `json:"addressContains"`
KeyIn []types.PublicKey `json:"keyIn"`
}

// HostResponse is the response type for the GET
// /api/autopilot/host/:hostkey endpoint.
HostResponse struct {
Host Host `json:"host"`
Checks *HostChecks `json:"checks,omitempty"`
}

HostChecks struct {
Gouging bool `json:"gouging"`
GougingBreakdown HostGougingBreakdown `json:"gougingBreakdown"`
Score float64 `json:"score"`
ScoreBreakdown HostScoreBreakdown `json:"scoreBreakdown"`
Usable bool `json:"usable"`
UnusableReasons []string `json:"unusableReasons,omitempty"`
}
)

type (
Expand Down
4 changes: 2 additions & 2 deletions api/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const (
ObjectSortByName = "name"
ObjectSortBySize = "size"

ObjectSortDirAsc = "asc"
ObjectSortDirDesc = "desc"
SortDirAsc = "asc"
SortDirDesc = "desc"
)

var (
Expand Down
Loading

0 comments on commit 5e58468

Please sign in to comment.