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

Simplify RHP4 DevEx #233

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions rhp/v4/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
15 changes: 11 additions & 4 deletions rhp/v4/rhp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ 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.
SectorSize = 1 << 22 // 4 MiB
)
Expand Down Expand Up @@ -98,9 +107,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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit update docstring to reflect change

return Usage{
Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(duration),
Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(TempSectorDuration),
Ingress: hp.IngressPrice.Mul64(round4KiB(sectorLength)),
}
}
Expand Down Expand Up @@ -171,8 +180,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"`
Expand Down