Skip to content

Commit

Permalink
renterd: fix unusable hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Aug 19, 2024
1 parent 41ffeba commit 01d61eb
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
go.sia.tech/core v0.4.4-0.20240814175157-ebc804c7119c
go.sia.tech/coreutils v0.2.6-0.20240814205841-6bd57953a01b
go.sia.tech/hostd v1.1.3-0.20240819175908-6eb158b07bc5
go.sia.tech/hostd v1.1.3-0.20240819214738-33477e5e7918
go.sia.tech/jape v0.12.0
go.sia.tech/renterd v1.0.8-0.20240816153131-8a7fcde128a6
go.sia.tech/walletd v0.8.1-0.20240816204013-cd52e7b8aaa9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ go.sia.tech/coreutils v0.2.6-0.20240814205841-6bd57953a01b h1:iV7PdyUf7CC6slo4Cg
go.sia.tech/coreutils v0.2.6-0.20240814205841-6bd57953a01b/go.mod h1:TjQITC7A7u3sX22sN54SmcPcn+YmnodEqzNElAA7G/s=
go.sia.tech/gofakes3 v0.0.4 h1:Kvo8j5cVdJRBXvV1KBJ69bocY23twG8ao/HCdwuPMeI=
go.sia.tech/gofakes3 v0.0.4/go.mod h1:6hh4lETCMbyFFNWp3FRE838geY6vh1Aeas7LtYDpQdc=
go.sia.tech/hostd v1.1.3-0.20240819175908-6eb158b07bc5 h1:UbKYEau6SNlQ8+l1USfdOzxRc56RZSRC/F5xUjWbGok=
go.sia.tech/hostd v1.1.3-0.20240819175908-6eb158b07bc5/go.mod h1:HCxy9lZMjqZ+OEBlufeGzBwcmEOx2SWmEAtESnO9Tx8=
go.sia.tech/hostd v1.1.3-0.20240819214738-33477e5e7918 h1:HLwTSfXk/ypSogdIxWL26xG77K+CVzToULJ6xNhzGfc=
go.sia.tech/hostd v1.1.3-0.20240819214738-33477e5e7918/go.mod h1:HCxy9lZMjqZ+OEBlufeGzBwcmEOx2SWmEAtESnO9Tx8=
go.sia.tech/jape v0.12.0 h1:13fBi7c5X8zxTQ05Cd9ZsIfRJgdvGoZqbEzH861z7BU=
go.sia.tech/jape v0.12.0/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4=
go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU=
Expand Down
85 changes: 84 additions & 1 deletion nodes/renterd.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,17 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
}
}()
workerHandler = jape.BasicAuth("sia is cool")(w.Handler())
if _, err := workerClient.Account(context.Background(), types.PublicKey{}); err != nil {
panic(err)
}

ap, err := autopilot.New(config.Autopilot{
AccountsRefillInterval: time.Second,
Heartbeat: time.Second,
ID: api.DefaultAutopilotID,
MigrationHealthCutoff: 0.99,
MigratorParallelSlabsPerWorker: 1,
RevisionSubmissionBuffer: 0,
RevisionSubmissionBuffer: 10,
ScannerInterval: time.Second,
ScannerBatchSize: 10,
ScannerNumThreads: 1,
Expand All @@ -256,6 +259,7 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
return fmt.Errorf("failed to create autopilot: %w", err)
}
defer ap.Shutdown(ctx)
go ap.Run()
autopilotHandler = jape.BasicAuth("sia is cool")(ap.Handler())

log.Info("node started", zap.Stringer("http", apiListener.Addr()))
Expand Down Expand Up @@ -285,6 +289,83 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
return fmt.Errorf("failed to update autopilot config: %w", err)
}

// Finish worker setup.
if err := w.Setup(ctx, node.APIAddress+"/api/worker", "sia is cool"); err != nil {
return fmt.Errorf("failed to setup worker: %w", err)
} else if err := busClient.SetContractSet(ctx, "autopilot", nil); err != nil {
return fmt.Errorf("failed to set contract set: %w", err)
}

err = busClient.UpdateAutopilot(ctx, api.Autopilot{
ID: api.DefaultAutopilotID,
Config: api.AutopilotConfig{
Contracts: api.ContractsConfig{
Set: "autopilot",
Amount: 1000,
Allowance: types.Siacoins(1000000),
Period: 4320,
RenewWindow: 144 * 7,
Download: 1 << 30,
Upload: 1 << 30,
Storage: 1 << 30,
Prune: false,
},
Hosts: api.HostsConfig{
AllowRedundantIPs: true,
MaxDowntimeHours: 1440,
MinProtocolVersion: "1.6.0",
MinRecentScanFailures: 100,
},
},
})
if err != nil {
return fmt.Errorf("failed to update autopilot: %w", err)
}

err = busClient.UpdateSetting(ctx, api.SettingGouging, api.GougingSettings{
MaxRPCPrice: types.Siacoins(1).Div64(1000), // 1mS per RPC
MaxContractPrice: types.Siacoins(10), // 10 SC per contract
MaxDownloadPrice: types.Siacoins(1).Mul64(1000), // 1000 SC per 1 TiB
MaxUploadPrice: types.Siacoins(1).Mul64(1000), // 1000 SC per 1 TiB
MaxStoragePrice: types.Siacoins(1000).Div64(144 * 30), // 1000 SC per month

HostBlockHeightLeeway: 240, // amount of leeway given to host block height

MinPriceTableValidity: 10 * time.Second, // minimum value for price table validity
MinAccountExpiry: time.Hour, // minimum value for account expiry
MinMaxEphemeralAccountBalance: types.Siacoins(1), // 1SC
})
if err != nil {
return fmt.Errorf("failed to update setting: %w", err)
}
err = busClient.UpdateSetting(ctx, api.SettingContractSet, api.ContractSetSetting{
Default: "autopilot",
})
if err != nil {
return fmt.Errorf("failed to update setting: %w", err)
}
err = busClient.UpdateSetting(ctx, api.SettingPricePinning, api.PricePinSettings{
Enabled: false,
})
if err != nil {
return fmt.Errorf("failed to update setting: %w", err)
}
err = busClient.UpdateSetting(ctx, api.SettingRedundancy, api.RedundancySettings{
MinShards: 2,
TotalShards: 3,
})
if err != nil {
return fmt.Errorf("failed to update setting: %w", err)
}
err = busClient.UpdateSetting(ctx, api.SettingS3Authentication, api.S3AuthenticationSettings{
V4Keypairs: map[string]string{
"TESTINGYNHUWCPKOPSYQ": "Rh30BNyj+qNI4ftYRteoZbHJ3X4Ln71QtZkRXzJ9",
},
})
if err != nil {
return fmt.Errorf("failed to update setting: %w", err)
}

if _, err := autopilotClient.Trigger(true); err != nil {
return fmt.Errorf("failed to trigger autopilot: %w", err)
}
Expand All @@ -293,6 +374,8 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
walletAddress := types.StandardUnlockHash(pk.PublicKey())
if err := m.MineBlocks(ctx, 200, walletAddress); err != nil {
return fmt.Errorf("failed to mine blocks: %w", err)
} else if _, err := autopilotClient.Trigger(true); err != nil {
return fmt.Errorf("failed to trigger autopilot: %w", err)
}
m.Put(node)
if ready != nil {
Expand Down

0 comments on commit 01d61eb

Please sign in to comment.