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

Remove unused registry code #905

Merged
merged 2 commits into from
Jan 18, 2024
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
9 changes: 0 additions & 9 deletions api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,6 @@ type (
AccountKey types.PrivateKey `json:"accountKey"`
}

// RHPRegistryUpdateRequest is the request type for the /rhp/registry/update
// endpoint.
RHPRegistryUpdateRequest struct {
HostKey types.PublicKey `json:"hostKey"`
SiamuxAddr string `json:"siamuxAddr"`
RegistryKey rhpv3.RegistryKey `json:"registryKey"`
RegistryValue rhpv3.RegistryValue `json:"registryValue"`
}

// DownloadStatsResponse is the response type for the /stats/downloads endpoint.
DownloadStatsResponse struct {
AvgDownloadSpeedMBPS float64 `json:"avgDownloadSpeedMbps"`
Expand Down
3 changes: 1 addition & 2 deletions internal/testing/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,12 @@ func addStorageFolderToHost(ctx context.Context, hosts []*Host) error {
return nil
}

// announceHosts adds storage and a registry to each host and announces them to
// announceHosts configures hosts with default settings and announces them to
// the group
func announceHosts(hosts []*Host) error {
for _, host := range hosts {
settings := defaultHostSettings
settings.NetAddress = host.RHPv2Addr()
settings.MaxRegistryEntries = 1 << 18
if err := host.settings.UpdateSettings(settings); err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions internal/testing/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ var defaultHostSettings = settings.Settings{

PriceTableValidity: 10 * time.Second,

AccountExpiry: 30 * 24 * time.Hour, // 1 month
MaxAccountBalance: types.Siacoins(10),
MaxRegistryEntries: 1e3,
AccountExpiry: 30 * 24 * time.Hour, // 1 month
MaxAccountBalance: types.Siacoins(10),
}

// Close shutsdown the host
Expand Down
91 changes: 0 additions & 91 deletions worker/rhpv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package worker
import (
"bytes"
"context"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -792,52 +791,6 @@ func RPCReadSector(ctx context.Context, t *transportV3, w io.Writer, pt rhpv3.Ho
return
}

// RPCReadRegistry calls the ExecuteProgram RPC with an MDM program that reads
// the specified registry value.
func RPCReadRegistry(ctx context.Context, t *transportV3, payment rhpv3.PaymentMethod, key rhpv3.RegistryKey) (rv rhpv3.RegistryValue, err error) {
defer wrapErr(&err, "ReadRegistry")
s, err := t.DialStream(ctx)
if err != nil {
return rhpv3.RegistryValue{}, err
}
defer s.Close()

req := &rhpv3.RPCExecuteProgramRequest{
FileContractID: types.FileContractID{},
Program: []rhpv3.Instruction{&rhpv3.InstrReadRegistry{}},
ProgramData: append(key.PublicKey[:], key.Tweak[:]...),
}
if err := s.WriteRequest(rhpv3.RPCExecuteProgramID, nil); err != nil {
return rhpv3.RegistryValue{}, err
} else if err := processPayment(s, payment); err != nil {
return rhpv3.RegistryValue{}, err
} else if err := s.WriteResponse(req); err != nil {
return rhpv3.RegistryValue{}, err
}

var cancellationToken types.Specifier
s.ReadResponse(&cancellationToken, 16) // unused

const maxExecuteProgramResponseSize = 16 * 1024
var resp rhpv3.RPCExecuteProgramResponse
if err := s.ReadResponse(&resp, maxExecuteProgramResponseSize); err != nil {
return rhpv3.RegistryValue{}, err
} else if len(resp.Output) < 64+8+1 {
return rhpv3.RegistryValue{}, errors.New("invalid output length")
}
var sig types.Signature
copy(sig[:], resp.Output[:64])
rev := binary.LittleEndian.Uint64(resp.Output[64:72])
data := resp.Output[72 : len(resp.Output)-1]
typ := resp.Output[len(resp.Output)-1]
return rhpv3.RegistryValue{
Data: data,
Revision: rev,
Type: typ,
Signature: sig,
}, nil
}

func RPCAppendSector(ctx context.Context, t *transportV3, renterKey types.PrivateKey, pt rhpv3.HostPriceTable, rev *types.FileContractRevision, payment rhpv3.PaymentMethod, sector *[rhpv2.SectorSize]byte) (sectorRoot types.Hash256, cost types.Currency, err error) {
defer wrapErr(&err, "AppendSector")

Expand Down Expand Up @@ -1147,50 +1100,6 @@ func initialRevision(formationTxn types.Transaction, hostPubKey, renterPubKey ty
}
}

// RPCUpdateRegistry calls the ExecuteProgram RPC with an MDM program that
// updates the specified registry value.
func RPCUpdateRegistry(ctx context.Context, t *transportV3, payment rhpv3.PaymentMethod, key rhpv3.RegistryKey, value rhpv3.RegistryValue) (err error) {
defer wrapErr(&err, "UpdateRegistry")
s, err := t.DialStream(ctx)
if err != nil {
return err
}
defer s.Close()

var data bytes.Buffer
e := types.NewEncoder(&data)
key.Tweak.EncodeTo(e)
e.WriteUint64(value.Revision)
value.Signature.EncodeTo(e)
key.PublicKey.EncodeTo(e)
e.Write(value.Data)
e.Flush()
req := &rhpv3.RPCExecuteProgramRequest{
FileContractID: types.FileContractID{},
Program: []rhpv3.Instruction{&rhpv3.InstrUpdateRegistry{}},
ProgramData: data.Bytes(),
}
if err := s.WriteRequest(rhpv3.RPCExecuteProgramID, nil); err != nil {
return err
} else if err := processPayment(s, payment); err != nil {
return err
} else if err := s.WriteResponse(req); err != nil {
return err
}

var cancellationToken types.Specifier
s.ReadResponse(&cancellationToken, 16) // unused

const maxExecuteProgramResponseSize = 16 * 1024
var resp rhpv3.RPCExecuteProgramResponse
if err := s.ReadResponse(&resp, maxExecuteProgramResponseSize); err != nil {
return err
} else if resp.OutputLength != 0 {
return errors.New("invalid output length")
}
return nil
}

func payByContract(rev *types.FileContractRevision, amount types.Currency, refundAcct rhpv3.Account, sk types.PrivateKey) (rhpv3.PayByContractRequest, error) {
if rev.RevisionNumber == math.MaxUint64 {
return rhpv3.PayByContractRequest{}, errMaxRevisionReached
Expand Down
Loading