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 collateral from RPC write usage #225

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
20 changes: 7 additions & 13 deletions rhp/v4/rhp.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,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 {
return hp.StoreSectorCost(duration).Add(Usage{
Ingress: hp.IngressPrice.Mul64(round4KiB(sectorLength)),
})
}

// StoreSectorCost returns the cost of storing a sector for the given duration.
func (hp HostPrices) StoreSectorCost(duration uint64) Usage {
return Usage{
Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(duration),
RiskedCollateral: hp.Collateral.Mul64(SectorSize).Mul64(duration),
Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(duration),
Ingress: hp.IngressPrice.Mul64(round4KiB(sectorLength)),
}
}

Expand Down Expand Up @@ -137,10 +130,11 @@ func (hp HostPrices) RPCFreeSectorsCost(sectors int) Usage {
// RPCAppendSectorsCost returns the cost of appending sectors to a contract. The duration
// parameter is the number of blocks until the contract's expiration height.
func (hp HostPrices) RPCAppendSectorsCost(sectors, duration uint64) Usage {
usage := hp.StoreSectorCost(duration)
usage.Storage = usage.Storage.Mul64(sectors)
usage.RiskedCollateral = usage.RiskedCollateral.Mul64(sectors)
return usage
return Usage{
Storage: hp.StoragePrice.Mul64(SectorSize).Mul64(sectors).Mul64(duration),
Ingress: hp.IngressPrice.Mul64(round4KiB(32 * sectors)),
RiskedCollateral: hp.Collateral.Mul64(SectorSize).Mul64(sectors).Mul64(duration),
}
}

// SigHash returns the hash of the host settings used for signing.
Expand Down
Loading