From 7addac1fbcd7196ec0a0ec01fbb160f39d459c32 Mon Sep 17 00:00:00 2001 From: PJ Date: Thu, 18 Jan 2024 09:56:43 +0100 Subject: [PATCH] all: remove unused registry code --- api/worker.go | 9 ---- internal/testing/cluster.go | 3 +- internal/testing/host.go | 5 +- worker/rhpv3.go | 91 ------------------------------------- 4 files changed, 3 insertions(+), 105 deletions(-) diff --git a/api/worker.go b/api/worker.go index d280698b7..7ee2800f4 100644 --- a/api/worker.go +++ b/api/worker.go @@ -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"` diff --git a/internal/testing/cluster.go b/internal/testing/cluster.go index 47eb4f84c..d55539cd7 100644 --- a/internal/testing/cluster.go +++ b/internal/testing/cluster.go @@ -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 } diff --git a/internal/testing/host.go b/internal/testing/host.go index 2d0b75b4e..e7943a7d3 100644 --- a/internal/testing/host.go +++ b/internal/testing/host.go @@ -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 diff --git a/worker/rhpv3.go b/worker/rhpv3.go index 49109550a..7f83af4f2 100644 --- a/worker/rhpv3.go +++ b/worker/rhpv3.go @@ -3,7 +3,6 @@ package worker import ( "bytes" "context" - "encoding/binary" "encoding/json" "errors" "fmt" @@ -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") @@ -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