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 redundant MaxCollateral from gouging checks #1076

Merged
merged 3 commits into from
Mar 20, 2024
Merged
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ updated using the settings API:
"maxUploadPrice": "3000000000000000000000000000", // 3000 SC per 1 TiB
"migrationSurchargeMultiplier": 10, // overpay up to 10x for sectors migrations on critical slabs
"minAccountExpiry": 86400000000000, // 1 day
"minMaxCollateral": "10000000000000000000000000", // at least up to 10 SC per contract
"minMaxEphemeralAccountBalance": "1000000000000000000000000", // 1 SC
"minPriceTableValidity": 300000000000 // 5 minutes
}
Expand Down
4 changes: 0 additions & 4 deletions api/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ type (

// GougingSettings contain some price settings used in price gouging.
GougingSettings struct {
// MinMaxCollateral is the minimum value for 'MaxCollateral' in the host's
// price settings
MinMaxCollateral types.Currency `json:"minMaxCollateral"`

// MaxRPCPrice is the maximum allowed base price for RPCs
MaxRPCPrice types.Currency `json:"maxRPCPrice"`

Expand Down
1 change: 0 additions & 1 deletion autopilot/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ func evaluateConfig(cfg api.AutopilotConfig, cs api.ConsensusState, fee types.Cu

// these are not optimised, so we keep the same values as the user
// provided
MinMaxCollateral: gs.MinMaxCollateral,
HostBlockHeightLeeway: gs.HostBlockHeightLeeway,
MinPriceTableValidity: gs.MinPriceTableValidity,
MinAccountExpiry: gs.MinAccountExpiry,
Expand Down
2 changes: 1 addition & 1 deletion autopilot/hostscore.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func collateralScore(cfg api.AutopilotConfig, pt rhpv3.HostPriceTable, allocatio
cutoffMultiplier := uint64(4)

if expectedCollateral.Cmp(cutoff) < 0 {
return 0 // expectedCollateral <= cutoff -> score is 0
return math.SmallestNonzeroFloat64 // expectedCollateral <= cutoff -> score is basically 0
} else if expectedCollateral.Cmp(cutoff.Mul64(cutoffMultiplier)) >= 0 {
return 1 // expectedCollateral is 10x cutoff -> score is 1
} else {
Expand Down
1 change: 0 additions & 1 deletion build/env_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var (
// configured with on startup. These values can be adjusted using the
// settings API.
DefaultGougingSettings = api.GougingSettings{
MinMaxCollateral: types.Siacoins(10), // at least up to 10 SC per contract
MaxRPCPrice: types.Siacoins(1).Div64(1000), // 1mS per RPC
MaxContractPrice: types.Siacoins(1), // 1 SC per contract
MaxDownloadPrice: types.Siacoins(3000), // 3000 SC per 1 TiB
Expand Down
1 change: 0 additions & 1 deletion build/env_testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var (
//
// NOTE: default gouging settings for testnet are identical to mainnet.
DefaultGougingSettings = api.GougingSettings{
MinMaxCollateral: types.Siacoins(10), // at least up to 10 SC per contract
MaxRPCPrice: types.Siacoins(1).Div64(1000), // 1mS per RPC
MaxContractPrice: types.Siacoins(15), // 15 SC per contract
MaxDownloadPrice: types.Siacoins(3000), // 3000 SC per 1 TiB
Expand Down
1 change: 0 additions & 1 deletion internal/test/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ var (
}

GougingSettings = api.GougingSettings{
MinMaxCollateral: types.Siacoins(10), // at least up to 10 SC per contract
MaxRPCPrice: types.Siacoins(1).Div64(1000), // 1mS per RPC
MaxContractPrice: types.Siacoins(10), // 10 SC per contract
MaxDownloadPrice: types.Siacoins(1).Mul64(1000), // 1000 SC per 1 TiB
Expand Down
12 changes: 0 additions & 12 deletions worker/gouging.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,6 @@ func checkPriceGougingHS(gs api.GougingSettings, hs *rhpv2.HostSettings) error {
return fmt.Errorf("contract price exceeds max: %v > %v", hs.ContractPrice, gs.MaxContractPrice)
}

// check max collateral
if hs.MaxCollateral.IsZero() {
return errors.New("MaxCollateral of host is 0")
}
if hs.MaxCollateral.Cmp(gs.MinMaxCollateral) < 0 {
return fmt.Errorf("MaxCollateral is below minimum: %v < %v", hs.MaxCollateral, gs.MinMaxCollateral)
}

// check max EA balance
if hs.MaxEphemeralAccountBalance.Cmp(gs.MinMaxEphemeralAccountBalance) < 0 {
return fmt.Errorf("'MaxEphemeralAccountBalance' is less than the allowed minimum value, %v < %v", hs.MaxEphemeralAccountBalance, gs.MinMaxEphemeralAccountBalance)
Expand Down Expand Up @@ -219,10 +211,6 @@ func checkPriceGougingPT(gs api.GougingSettings, cs api.ConsensusState, txnFee t
if pt.MaxCollateral.IsZero() {
return errors.New("MaxCollateral of host is 0")
}
if pt.MaxCollateral.Cmp(gs.MinMaxCollateral) < 0 {
return fmt.Errorf("MaxCollateral is below minimum: %v < %v", pt.MaxCollateral, gs.MinMaxCollateral)
}

// check ReadLengthCost - should be 1H as it's unused by hosts
if types.NewCurrency64(1).Cmp(pt.ReadLengthCost) < 0 {
return fmt.Errorf("ReadLengthCost of host is %v but should be %v", pt.ReadLengthCost, types.NewCurrency64(1))
Expand Down
Loading