From 50101900d67bd3e5f58dddbd09244775d9aa575c Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 15 Nov 2024 09:39:49 -0800 Subject: [PATCH 1/3] rhp4: hard code temp sector duration --- rhp/v4/encoding.go | 4 ---- rhp/v4/rhp.go | 9 +++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/rhp/v4/encoding.go b/rhp/v4/encoding.go index 01c14bb..720baba 100644 --- a/rhp/v4/encoding.go +++ b/rhp/v4/encoding.go @@ -52,8 +52,6 @@ func (hs HostSettings) EncodeTo(e *types.Encoder) { e.WriteBool(hs.AcceptingContracts) types.V2Currency(hs.MaxCollateral).EncodeTo(e) e.WriteUint64(hs.MaxContractDuration) - e.WriteUint64(hs.MaxSectorDuration) - e.WriteUint64(hs.MaxSectorBatchSize) e.WriteUint64(hs.RemainingStorage) e.WriteUint64(hs.TotalStorage) hs.Prices.EncodeTo(e) @@ -67,8 +65,6 @@ func (hs *HostSettings) DecodeFrom(d *types.Decoder) { hs.AcceptingContracts = d.ReadBool() (*types.V2Currency)(&hs.MaxCollateral).DecodeFrom(d) hs.MaxContractDuration = d.ReadUint64() - hs.MaxSectorDuration = d.ReadUint64() - hs.MaxSectorBatchSize = d.ReadUint64() hs.RemainingStorage = d.ReadUint64() hs.TotalStorage = d.ReadUint64() hs.Prices.DecodeFrom(d) diff --git a/rhp/v4/rhp.go b/rhp/v4/rhp.go index 520971b..bb5873a 100644 --- a/rhp/v4/rhp.go +++ b/rhp/v4/rhp.go @@ -16,6 +16,9 @@ const ( // the contract expires. ProofWindow = 144 // 24 hours + TempSectorDuration = 144 * 3 + MaxSectorBatchSize = (1 << 40) / (SectorSize) + // SectorSize is the size of one sector in bytes. SectorSize = 1 << 22 // 4 MiB ) @@ -98,9 +101,9 @@ func (hp HostPrices) RPCReadSectorCost(length uint64) Usage { // RPCWriteSectorCost returns the cost of executing the WriteSector RPC with the // given sector length and duration. -func (hp HostPrices) RPCWriteSectorCost(sectorLength uint64, duration uint64) Usage { +func (hp HostPrices) RPCWriteSectorCost(sectorLength uint64) Usage { return Usage{ - Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(duration), + Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(TempSectorDuration), Ingress: hp.IngressPrice.Mul64(round4KiB(sectorLength)), } } @@ -171,8 +174,6 @@ type HostSettings struct { AcceptingContracts bool `json:"acceptingContracts"` MaxCollateral types.Currency `json:"maxCollateral"` MaxContractDuration uint64 `json:"maxContractDuration"` - MaxSectorDuration uint64 `json:"maxSectorDuration"` - MaxSectorBatchSize uint64 `json:"maxSectorBatchSize"` RemainingStorage uint64 `json:"remainingStorage"` TotalStorage uint64 `json:"totalStorage"` Prices HostPrices `json:"prices"` From e1e66649fc37dd1f2df07565858b195cb545cbf9 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 15 Nov 2024 10:03:09 -0800 Subject: [PATCH 2/3] fix lint --- rhp/v4/rhp.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rhp/v4/rhp.go b/rhp/v4/rhp.go index bb5873a..bba267a 100644 --- a/rhp/v4/rhp.go +++ b/rhp/v4/rhp.go @@ -16,7 +16,13 @@ const ( // the contract expires. ProofWindow = 144 // 24 hours + // TempSectorDuration is the number of blocks that temp sectors are expected to be stored + // before being removed TempSectorDuration = 144 * 3 + + // MaxSectorBatchSize is the number of sector operations that can be batched into a single RPC. + // For example, the number of sectors appended to a contract within a single RPC append call or the + // number of sectors removed in a single RPC free call. MaxSectorBatchSize = (1 << 40) / (SectorSize) // SectorSize is the size of one sector in bytes. From b0914589a6cc9f60650d694266965ead94005902 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 19 Nov 2024 10:00:16 -0800 Subject: [PATCH 3/3] docs: fix docstring --- rhp/v4/rhp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rhp/v4/rhp.go b/rhp/v4/rhp.go index bba267a..496c5aa 100644 --- a/rhp/v4/rhp.go +++ b/rhp/v4/rhp.go @@ -106,7 +106,7 @@ func (hp HostPrices) RPCReadSectorCost(length uint64) Usage { } // RPCWriteSectorCost returns the cost of executing the WriteSector RPC with the -// given sector length and duration. +// given sector length. func (hp HostPrices) RPCWriteSectorCost(sectorLength uint64) Usage { return Usage{ Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(TempSectorDuration),