Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl authored Sep 19, 2024
2 parents 3665e5d + e7ad132 commit 6ec5143
Show file tree
Hide file tree
Showing 103 changed files with 4,040 additions and 3,565 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
uses: n8maninger/action-golang-test@v1
with:
package: "./internal/test/e2e/..."
args: "-failfast;-race;-tags=testing;-timeout=60m"
args: "-failfast;-race;-timeout=60m"
- name: Test Integration - MySQL
if: matrix.os == 'ubuntu-latest'
uses: n8maninger/action-golang-test@v1
Expand All @@ -77,6 +77,6 @@ jobs:
RENTERD_DB_PASSWORD: test
with:
package: "./internal/test/e2e/..."
args: "-failfast;-race;-tags=testing;-timeout=60m"
args: "-failfast;-race;-timeout=60m"
- name: Build
run: go build -o bin/ ./cmd/renterd
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ formed.
"hosts": {
"allowRedundantIPs": false,
"maxDowntimeHours": 1440,
"minRecentScanFailures": 20,
"maxConsecutiveScanFailures": 20,
"scoreOverrides": {}
},
"contracts": {
Expand Down
4 changes: 2 additions & 2 deletions alerts/alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestWebhooks(t *testing.T) {
mux := http.NewServeMux()
var events []webhooks.Event
var mu sync.Mutex
mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/event", func(w http.ResponseWriter, r *http.Request) {
var event webhooks.Event
if err := json.NewDecoder(r.Body).Decode(&event); err != nil {
t.Fatal(err)
Expand All @@ -72,7 +72,7 @@ func TestWebhooks(t *testing.T) {
// register a hook
wh := webhooks.Webhook{
Module: webhookModule,
URL: fmt.Sprintf("http://%v/events", srv.Listener.Addr().String()),
URL: fmt.Sprintf("http://%v/event", srv.Listener.Addr().String()),
}
if hookID := wh.String(); hookID != fmt.Sprintf("%v.%v.%v", wh.URL, wh.Module, "") {
t.Fatalf("wrong result for wh.String(): %v != %v", wh.String(), hookID)
Expand Down
4 changes: 4 additions & 0 deletions api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type (
// an account and the balance reported by a host.
Drift *big.Int `json:"drift"`

// Owner is the owner of the account which is responsible for funding
// it.
Owner string `json:"owner"`

// RequiresSync indicates whether an account needs to be synced with the
// host before it can be used again.
RequiresSync bool `json:"requiresSync"`
Expand Down
10 changes: 5 additions & 5 deletions api/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ type (

// HostsConfig contains all hosts settings used in the autopilot.
HostsConfig struct {
AllowRedundantIPs bool `json:"allowRedundantIPs"`
MaxDowntimeHours uint64 `json:"maxDowntimeHours"`
MinProtocolVersion string `json:"minProtocolVersion"`
MinRecentScanFailures uint64 `json:"minRecentScanFailures"`
ScoreOverrides map[types.PublicKey]float64 `json:"scoreOverrides"`
AllowRedundantIPs bool `json:"allowRedundantIPs"`
MaxDowntimeHours uint64 `json:"maxDowntimeHours"`
MinProtocolVersion string `json:"minProtocolVersion"`
MaxConsecutiveScanFailures uint64 `json:"maxConsecutiveScanFailures"`
ScoreOverrides map[types.PublicKey]float64 `json:"scoreOverrides"`
}
)

Expand Down
20 changes: 20 additions & 0 deletions api/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"errors"

rhpv3 "go.sia.tech/core/rhp/v3"
"go.sia.tech/core/types"
)

Expand Down Expand Up @@ -45,10 +46,29 @@ type (
)

type (
AccountsFundRequest struct {
AccountID rhpv3.Account `json:"accountID"`
Amount types.Currency `json:"amount"`
ContractID types.FileContractID `json:"contractID"`
}

AccountsFundResponse struct {
Deposit types.Currency `json:"deposit"`
}

AccountsSaveRequest struct {
Accounts []Account `json:"accounts"`
}

// BusStateResponse is the response type for the /bus/state endpoint.
BusStateResponse struct {
StartTime TimeRFC3339 `json:"startTime"`
Network string `json:"network"`
BuildState
}

ContractSetUpdateRequest struct {
ToAdd []types.FileContractID `json:"toAdd"`
ToRemove []types.FileContractID `json:"toRemove"`
}
)
40 changes: 40 additions & 0 deletions api/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,54 @@ type (
TotalCost types.Currency `json:"totalCost"`
}

// ContractFormRequest is the request type for the POST /contracts endpoint.
ContractFormRequest struct {
EndHeight uint64 `json:"endHeight"`
HostCollateral types.Currency `json:"hostCollateral"`
HostKey types.PublicKey `json:"hostKey"`
HostIP string `json:"hostIP"`
RenterFunds types.Currency `json:"renterFunds"`
RenterAddress types.Address `json:"renterAddress"`
}

// ContractKeepaliveRequest is the request type for the /contract/:id/keepalive
// endpoint.
ContractKeepaliveRequest struct {
Duration DurationMS `json:"duration"`
LockID uint64 `json:"lockID"`
}

// ContractPruneRequest is the request type for the /contract/:id/prune
// endpoint.
ContractPruneRequest struct {
Timeout DurationMS `json:"timeout"`
}

// ContractPruneResponse is the response type for the /contract/:id/prune
// endpoint.
ContractPruneResponse struct {
ContractSize uint64 `json:"size"`
Pruned uint64 `json:"pruned"`
Remaining uint64 `json:"remaining"`
Error string `json:"error,omitempty"`
}

// ContractAcquireRequest is the request type for the /contract/:id/release
// endpoint.
ContractReleaseRequest struct {
LockID uint64 `json:"lockID"`
}

// ContractRenewRequest is the request type for the /contract/:id/renew
// endpoint.
ContractRenewRequest struct {
EndHeight uint64 `json:"endHeight"`
ExpectedNewStorage uint64 `json:"expectedNewStorage"`
MaxFundAmount types.Currency `json:"maxFundAmount"`
MinNewCollateral types.Currency `json:"minNewCollateral"`
RenterFunds types.Currency `json:"renterFunds"`
}

// ContractRenewedRequest is the request type for the /contract/:id/renewed
// endpoint.
ContractRenewedRequest struct {
Expand Down Expand Up @@ -191,6 +226,11 @@ type (
}
)

// Total returns the total cost of the contract spending.
func (x ContractSpending) Total() types.Currency {
return x.Uploads.Add(x.Downloads).Add(x.FundAccount).Add(x.Deletions).Add(x.SectorRoots)
}

// Add returns the sum of the current and given contract spending.
func (x ContractSpending) Add(y ContractSpending) (z ContractSpending) {
z.Uploads = x.Uploads.Add(y.Uploads)
Expand Down
7 changes: 4 additions & 3 deletions api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ type (
}

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

EventSettingUpdate struct {
Expand Down
4 changes: 2 additions & 2 deletions api/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ type (

// HostsRemoveRequest is the request type for the /hosts/remove endpoint.
HostsRemoveRequest struct {
MaxDowntimeHours DurationH `json:"maxDowntimeHours"`
MinRecentScanFailures uint64 `json:"minRecentScanFailures"`
MaxDowntimeHours DurationH `json:"maxDowntimeHours"`
MaxConsecutiveScanFailures uint64 `json:"maxConsecutiveScanFailures"`
}

// SearchHostsRequest is the request type for the /api/bus/search/hosts
Expand Down
8 changes: 0 additions & 8 deletions api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ type (
Reason string
}

PerformanceMetric struct {
Action string `json:"action"`
HostKey types.PublicKey `json:"hostKey"`
Origin string `json:"origin"`
Duration time.Duration `json:"duration"`
Timestamp TimeRFC3339 `json:"timestamp"`
}

PerformanceMetricsQueryOpts struct {
Action string
HostKey types.PublicKey
Expand Down
38 changes: 0 additions & 38 deletions api/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"net/url"
"time"

rhpv2 "go.sia.tech/core/rhp/v2"
rhpv3 "go.sia.tech/core/rhp/v3"
"go.sia.tech/core/types"
)

Expand Down Expand Up @@ -45,42 +43,6 @@ type (
DependsOn []types.Transaction `json:"dependsOn"`
}

// WalletPrepareFormRequest is the request type for the /wallet/prepare/form
// endpoint.
WalletPrepareFormRequest struct {
EndHeight uint64 `json:"endHeight"`
HostCollateral types.Currency `json:"hostCollateral"`
HostKey types.PublicKey `json:"hostKey"`
HostSettings rhpv2.HostSettings `json:"hostSettings"`
RenterAddress types.Address `json:"renterAddress"`
RenterFunds types.Currency `json:"renterFunds"`
RenterKey types.PublicKey `json:"renterKey"`
}

// WalletPrepareRenewRequest is the request type for the /wallet/prepare/renew
// endpoint.
WalletPrepareRenewRequest struct {
Revision types.FileContractRevision `json:"revision"`
EndHeight uint64 `json:"endHeight"`
ExpectedNewStorage uint64 `json:"expectedNewStorage"`
HostAddress types.Address `json:"hostAddress"`
PriceTable rhpv3.HostPriceTable `json:"priceTable"`
MaxFundAmount types.Currency `json:"maxFundAmount"`
MinNewCollateral types.Currency `json:"minNewCollateral"`
RenterAddress types.Address `json:"renterAddress"`
RenterFunds types.Currency `json:"renterFunds"`
RenterKey types.PrivateKey `json:"renterKey"`
WindowSize uint64 `json:"windowSize"`
}

// WalletPrepareRenewResponse is the response type for the /wallet/prepare/renew
// endpoint.
WalletPrepareRenewResponse struct {
FundAmount types.Currency `json:"fundAmount"`
ToSign []types.Hash256 `json:"toSign"`
TransactionSet []types.Transaction `json:"transactionSet"`
}

// WalletRedistributeRequest is the request type for the /wallet/redistribute
// endpoint.
WalletRedistributeRequest struct {
Expand Down
49 changes: 0 additions & 49 deletions api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ type (
Error string `json:"error,omitempty"`
}

// RHPFormRequest is the request type for the /rhp/form endpoint.
RHPFormRequest struct {
EndHeight uint64 `json:"endHeight"`
HostCollateral types.Currency `json:"hostCollateral"`
HostKey types.PublicKey `json:"hostKey"`
HostIP string `json:"hostIP"`
RenterFunds types.Currency `json:"renterFunds"`
RenterAddress types.Address `json:"renterAddress"`
}

// RHPFormResponse is the response type for the /rhp/form endpoint.
RHPFormResponse struct {
ContractID types.FileContractID `json:"contractID"`
Expand All @@ -105,52 +95,13 @@ type (
Balance types.Currency `json:"balance"`
}

// RHPPruneContractRequest is the request type for the /rhp/contract/:id/prune
// endpoint.
RHPPruneContractRequest struct {
Timeout DurationMS `json:"timeout"`
}

// RHPPruneContractResponse is the response type for the /rhp/contract/:id/prune
// endpoint.
RHPPruneContractResponse struct {
Pruned uint64 `json:"pruned"`
Remaining uint64 `json:"remaining"`
Error string `json:"error,omitempty"`
}

// RHPPriceTableRequest is the request type for the /rhp/pricetable endpoint.
RHPPriceTableRequest struct {
HostKey types.PublicKey `json:"hostKey"`
SiamuxAddr string `json:"siamuxAddr"`
Timeout DurationMS `json:"timeout"`
}

// RHPRenewRequest is the request type for the /rhp/renew endpoint.
RHPRenewRequest struct {
ContractID types.FileContractID `json:"contractID"`
EndHeight uint64 `json:"endHeight"`
ExpectedNewStorage uint64 `json:"expectedNewStorage"`
HostAddress types.Address `json:"hostAddress"`
HostKey types.PublicKey `json:"hostKey"`
MaxFundAmount types.Currency `json:"maxFundAmount"`
MinNewCollateral types.Currency `json:"minNewCollateral"`
SiamuxAddr string `json:"siamuxAddr"`
RenterAddress types.Address `json:"renterAddress"`
RenterFunds types.Currency `json:"renterFunds"`
WindowSize uint64 `json:"windowSize"`
}

// RHPRenewResponse is the response type for the /rhp/renew endpoint.
RHPRenewResponse struct {
Error string `json:"error"`
ContractID types.FileContractID `json:"contractID"`
Contract rhpv2.ContractRevision `json:"contract"`
ContractPrice types.Currency `json:"contractPrice"`
FundAmount types.Currency `json:"fundAmount"`
TransactionSet []types.Transaction `json:"transactionSet"`
}

// RHPScanRequest is the request type for the /rhp/scan endpoint.
RHPScanRequest struct {
HostKey types.PublicKey `json:"hostKey"`
Expand Down
Loading

0 comments on commit 6ec5143

Please sign in to comment.