From af85bf3817fe2279a82b35609c6db507940e79dd Mon Sep 17 00:00:00 2001 From: lukechampine Date: Fri, 29 Nov 2024 11:07:16 -0500 Subject: [PATCH] mod: Update core to v0.6.3 --- go.mod | 2 +- go.sum | 6 +-- rhp/v4/rpc.go | 2 +- rhp/v4/rpc_test.go | 28 -------------- rhp/v4/server.go | 25 +++---------- wallet/wallet_test.go | 85 ------------------------------------------- 6 files changed, 9 insertions(+), 139 deletions(-) diff --git a/go.mod b/go.mod index a1ff3a1..16e7d32 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.23.2 require ( go.etcd.io/bbolt v1.3.11 - go.sia.tech/core v0.6.2 + go.sia.tech/core v0.6.3 go.sia.tech/mux v1.3.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.29.0 diff --git a/go.sum b/go.sum index 8bcd91f..8994e15 100644 --- a/go.sum +++ b/go.sum @@ -6,10 +6,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= -go.sia.tech/core v0.6.1 h1:eaExM2E2eNr43su2XDkY5J24E3F54YGS7hcC3WtVjVk= -go.sia.tech/core v0.6.1/go.mod h1:P3C1BWa/7J4XgdzWuaYHBvLo2RzZ0UBaJM4TG1GWB2g= -go.sia.tech/core v0.6.2 h1:8NEjxyD93A+EhZopsBy/LvuHH+zUSjRNKnf9rXgtIwU= -go.sia.tech/core v0.6.2/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk= +go.sia.tech/core v0.6.3 h1:7VdCSF61td1iatjGc5xt8WwCZgyB91mTvKhuL35o234= +go.sia.tech/core v0.6.3/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk= go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c= go.sia.tech/mux v1.3.0/go.mod h1:I46++RD4beqA3cW9Xm9SwXbezwPqLvHhVs9HLpDtt58= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/rhp/v4/rpc.go b/rhp/v4/rpc.go index 93d5973..922cde3 100644 --- a/rhp/v4/rpc.go +++ b/rhp/v4/rpc.go @@ -287,7 +287,7 @@ func RPCWriteSector(ctx context.Context, t TransportClient, prices rhp4.HostPric return RPCWriteSectorResult{ Root: resp.Root, - Usage: prices.RPCWriteSectorCost(uint64(length), duration), + Usage: prices.RPCWriteSectorCost(length), }, nil } diff --git a/rhp/v4/rpc_test.go b/rhp/v4/rpc_test.go index 937fdb9..2e72ebb 100644 --- a/rhp/v4/rpc_test.go +++ b/rhp/v4/rpc_test.go @@ -156,8 +156,6 @@ func TestSettings(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -216,8 +214,6 @@ func TestFormContract(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -275,8 +271,6 @@ func TestFormContractBasis(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -333,8 +327,6 @@ func TestRPCRefresh(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -446,8 +438,6 @@ func TestRPCRenew(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -607,8 +597,6 @@ func TestAccounts(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -708,8 +696,6 @@ func TestReadWriteSector(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -804,8 +790,6 @@ func TestAppendSectors(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -921,8 +905,6 @@ func TestVerifySector(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -1014,8 +996,6 @@ func TestRPCFreeSectors(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -1137,8 +1117,6 @@ func TestRPCSectorRoots(t *testing.T) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -1247,8 +1225,6 @@ func BenchmarkWrite(b *testing.B) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -1337,8 +1313,6 @@ func BenchmarkRead(b *testing.B) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ @@ -1439,8 +1413,6 @@ func BenchmarkContractUpload(b *testing.B) { WalletAddress: w.Address(), MaxCollateral: types.Siacoins(10000), MaxContractDuration: 1000, - MaxSectorDuration: 3 * 144, - MaxSectorBatchSize: 100, RemainingStorage: 100 * proto4.SectorSize, TotalStorage: 100 * proto4.SectorSize, Prices: proto4.HostPrices{ diff --git a/rhp/v4/server.go b/rhp/v4/server.go index af45916..116742b 100644 --- a/rhp/v4/server.go +++ b/rhp/v4/server.go @@ -17,17 +17,6 @@ import ( "lukechampine.com/frand" ) -const ( - sectorsPerTiB = (1 << 40) / (1 << 22) - memoryPer1TiB = sectorsPerTiB * 32 - - sectorsPer10TiB = 10 * sectorsPerTiB - memoryPer10TiB = sectorsPer10TiB * 32 - - sectorsPer100TiB = 100 * sectorsPerTiB - memoryPer100TiB = sectorsPer100TiB * 32 -) - var protocolVersion = [3]byte{4, 0, 0} type ( @@ -233,8 +222,7 @@ func (s *Server) handleRPCWriteSector(stream net.Conn) error { if err := rhp4.ReadRequest(stream, &req); err != nil { return errorDecodingError("failed to read request: %v", err) } - settings := s.settings.RHP4Settings() - if err := req.Validate(s.hostKey.PublicKey(), settings.MaxSectorDuration); err != nil { + if err := req.Validate(s.hostKey.PublicKey(), rhp4.TempSectorDuration); err != nil { return errorBadRequest("request invalid: %v", err) } prices := req.Prices @@ -253,7 +241,7 @@ func (s *Server) handleRPCWriteSector(stream net.Conn) error { return errorDecodingError("failed to read sector data: %v", err) } - usage := prices.RPCWriteSectorCost(req.DataLength, req.Duration) + usage := prices.RPCWriteSectorCost(req.DataLength) if err = s.contractor.DebitAccount(req.Token.Account, usage); err != nil { return fmt.Errorf("failed to debit account: %w", err) } @@ -284,8 +272,7 @@ func (s *Server) handleRPCFreeSectors(stream net.Conn) error { fc := state.Revision - settings := s.settings.RHP4Settings() - if err := req.Validate(s.hostKey.PublicKey(), fc, settings.MaxSectorBatchSize); err != nil { + if err := req.Validate(s.hostKey.PublicKey(), fc, rhp4.MaxSectorBatchSize); err != nil { return errorBadRequest("request invalid: %v", err) } prices := req.Prices @@ -347,8 +334,7 @@ func (s *Server) handleRPCAppendSectors(stream net.Conn) error { return errorDecodingError("failed to read request: %v", err) } - settings := s.settings.RHP4Settings() - if err := req.Validate(s.hostKey.PublicKey(), settings.MaxSectorBatchSize); err != nil { + if err := req.Validate(s.hostKey.PublicKey(), rhp4.MaxSectorBatchSize); err != nil { return errorBadRequest("request invalid: %v", err) } @@ -483,8 +469,7 @@ func (s *Server) handleRPCSectorRoots(stream net.Conn) error { defer unlock() // validate the request fields - settings := s.settings.RHP4Settings() - if err := req.Validate(s.hostKey.PublicKey(), state.Revision, settings.MaxSectorBatchSize); err != nil { + if err := req.Validate(s.hostKey.PublicKey(), state.Revision, rhp4.MaxSectorBatchSize); err != nil { return rhp4.NewRPCError(rhp4.ErrorCodeBadRequest, err.Error()) } prices := req.Prices diff --git a/wallet/wallet_test.go b/wallet/wallet_test.go index 152d185..eef384d 100644 --- a/wallet/wallet_test.go +++ b/wallet/wallet_test.go @@ -1792,91 +1792,6 @@ func TestSingleAddressWalletEventTypes(t *testing.T) { mineAndSync(t, cm, ws, wm, types.VoidAddress, 1) assertEvent(t, wm, types.Hash256(types.FileContractID(fce.ID).V2RenterOutputID()), wallet.EventTypeV2ContractResolution, renterPayout, types.ZeroCurrency, cm.Tip().Height+network.MaturityDelay) }) - - t.Run("v2 contract resolution - finalization", func(t *testing.T) { - // create a storage contract - renterPayout := types.Siacoins(10000) - fc := types.V2FileContract{ - RenterOutput: types.SiacoinOutput{ - Address: addr, - Value: renterPayout, - }, - HostOutput: types.SiacoinOutput{ - Address: types.VoidAddress, - Value: types.ZeroCurrency, - }, - ProofHeight: cm.TipState().Index.Height + 10, - ExpirationHeight: cm.TipState().Index.Height + 20, - - RenterPublicKey: pk.PublicKey(), - HostPublicKey: pk.PublicKey(), - } - contractValue := renterPayout.Add(cm.TipState().V2FileContractTax(fc)) - sigHash := cm.TipState().ContractSigHash(fc) - sig := pk.SignHash(sigHash) - fc.RenterSignature = sig - fc.HostSignature = sig - - // create a transaction with the contract - txn := types.V2Transaction{ - FileContracts: []types.V2FileContract{fc}, - } - basis, toSign, err := wm.FundV2Transaction(&txn, contractValue, false) - if err != nil { - t.Fatal(err) - } - wm.SignV2Inputs(&txn, toSign) - - // broadcast the transaction - if _, err := cm.AddV2PoolTransactions(basis, []types.V2Transaction{txn}); err != nil { - t.Fatal(err) - } - // current tip - tip := cm.Tip() - // mine a block to confirm the contract formation - mineAndSync(t, cm, ws, wm, types.VoidAddress, 1) - - // this is annoying because we have to keep the file contract - // proof - _, applied, err := cm.UpdatesSince(tip, 1000) - if err != nil { - t.Fatal(err) - } - - // get the confirmed file contract element - var fce types.V2FileContractElement - applied[0].ForEachV2FileContractElement(func(ele types.V2FileContractElement, _ bool, _ *types.V2FileContractElement, _ types.V2FileContractResolutionType) { - fce = ele - }) - for _, cau := range applied { - cau.UpdateElementProof(&fce.StateElement) - } - - // finalize the contract - finalRevision := fce.V2FileContract - finalRevision.RevisionNumber = math.MaxUint64 - finalRevisionSigHash := cm.TipState().ContractSigHash(finalRevision) - // create a renewal - finalization := types.V2FileContractFinalization(pk.SignHash(finalRevisionSigHash)) - - // create the renewal transaction - resolutionTxn := types.V2Transaction{ - FileContractResolutions: []types.V2FileContractResolution{ - { - Parent: fce, - Resolution: &finalization, - }, - }, - } - - // broadcast the renewal - if _, err := cm.AddV2PoolTransactions(cm.Tip(), []types.V2Transaction{resolutionTxn}); err != nil { - t.Fatal(err) - } - // mine a block to confirm the renewal - mineAndSync(t, cm, ws, wm, types.VoidAddress, 1) - assertEvent(t, wm, types.Hash256(types.FileContractID(fce.ID).V2RenterOutputID()), wallet.EventTypeV2ContractResolution, renterPayout, types.ZeroCurrency, cm.Tip().Height+network.MaturityDelay) - }) } func TestV2TPoolRace(t *testing.T) {