satellite/overlay: hardcode default values for audit alpha/beta

Alpha=1 and beta=0 are the expected first values for any alpha/beta
reputation system we are using in the codebase. So we are removing the
configurability of these values.

Change-Id: Ic61861b8ea5047fa1438ea6609b1d0048bf0abc3
This commit is contained in:
Moby von Briesen 2020-04-13 17:38:33 -04:00 committed by Maximillian von Briesen
parent e2d5b403e6
commit d7794a4851
8 changed files with 18 additions and 44 deletions

View File

@ -324,8 +324,6 @@ func (planet *Planet) newSatellites(count int, satelliteDatabases satellitedbtes
AuditReputationRepairWeight: 1,
AuditReputationUplinkWeight: 1,
AuditReputationAlpha0: 1,
AuditReputationBeta0: 0,
AuditReputationLambda: 0.95,
AuditReputationWeight: 1,
AuditReputationDQ: 0.6,

View File

@ -30,16 +30,12 @@ import (
// disqualified until the audit reputation reaches the cut-off value.
func TestDisqualificationTooManyFailedAudits(t *testing.T) {
var (
auditDQCutOff = 0.4
alpha0 float64 = 1
beta0 float64
auditDQCutOff = 0.4
)
testplanet.Run(t, testplanet.Config{
SatelliteCount: 1, StorageNodeCount: 1, Reconfigure: testplanet.Reconfigure{
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
config.Overlay.Node.AuditReputationAlpha0 = alpha0
config.Overlay.Node.AuditReputationBeta0 = beta0
config.Overlay.Node.AuditReputationLambda = 1
config.Overlay.Node.AuditReputationWeight = 1
config.Overlay.Node.AuditReputationDQ = auditDQCutOff
@ -58,8 +54,8 @@ func TestDisqualificationTooManyFailedAudits(t *testing.T) {
dossier, err := satellitePeer.Overlay.Service.Get(ctx, nodeID)
require.NoError(t, err)
require.Equal(t, alpha0, dossier.Reputation.AuditReputationAlpha)
require.Equal(t, beta0, dossier.Reputation.AuditReputationBeta)
require.Equal(t, float64(1), dossier.Reputation.AuditReputationAlpha)
require.Equal(t, float64(0), dossier.Reputation.AuditReputationBeta)
prevReputation := calcReputation(dossier)

View File

@ -194,9 +194,6 @@ func BenchmarkNodeSelection(b *testing.B) {
ctx := context.Background()
nodeSelectionConfig := overlay.NodeSelectionConfig{
AuditReputationAlpha0: 1,
AuditReputationBeta0: 0,
AuditCount: 1,
NewNodeFraction: 0.05,
MinimumVersion: "v1.0.0",

View File

@ -37,8 +37,6 @@ type NodeSelectionConfig struct {
AuditReputationRepairWeight float64 `help:"weight to apply to audit reputation for total repair reputation calculation" default:"1.0"`
AuditReputationUplinkWeight float64 `help:"weight to apply to audit reputation for total uplink reputation calculation" default:"1.0"`
AuditReputationAlpha0 float64 `help:"the initial shape 'alpha' used to calculate audit SNs reputation" default:"1.0"`
AuditReputationBeta0 float64 `help:"the initial shape 'beta' value used to calculate audit SNs reputation" default:"0.0"`
AuditReputationLambda float64 `help:"the forgetting factor used to calculate the audit SNs reputation" default:"0.95"`
AuditReputationWeight float64 `help:"the normalization weight used to calculate the audit SNs reputation" default:"1.0"`
AuditReputationDQ float64 `help:"the reputation cut-off for disqualifying SNs based on audit history" default:"0.6"`

View File

@ -43,8 +43,6 @@ func testNodeSelectionConfig(auditCount int64, newNodeFraction float64, distinct
AuditReputationRepairWeight: 1,
AuditReputationUplinkWeight: 1,
AuditReputationAlpha0: 1,
AuditReputationBeta0: 0,
AuditReputationLambda: 1,
AuditReputationWeight: 1,
AuditReputationDQ: 0.5,
@ -102,8 +100,8 @@ func testCache(ctx context.Context, t *testing.T, store overlay.DB) {
valid1, err := service.Get(ctx, valid1ID)
require.NoError(t, err)
require.EqualValues(t, valid1.Id, valid1ID)
require.EqualValues(t, valid1.Reputation.AuditReputationAlpha, nodeSelectionConfig.AuditReputationAlpha0)
require.EqualValues(t, valid1.Reputation.AuditReputationBeta, nodeSelectionConfig.AuditReputationBeta0)
require.EqualValues(t, valid1.Reputation.AuditReputationAlpha, 1)
require.EqualValues(t, valid1.Reputation.AuditReputationBeta, 0)
require.Nil(t, valid1.Reputation.Disqualified)
stats, err := service.UpdateStats(ctx, &overlay.UpdateRequest{
@ -132,8 +130,8 @@ func testCache(ctx context.Context, t *testing.T, store overlay.DB) {
dossier, err := service.Get(ctx, valid2ID)
require.NoError(t, err)
require.EqualValues(t, dossier.Reputation.AuditReputationAlpha, nodeSelectionConfig.AuditReputationAlpha0)
require.EqualValues(t, dossier.Reputation.AuditReputationBeta, nodeSelectionConfig.AuditReputationBeta0)
require.EqualValues(t, dossier.Reputation.AuditReputationAlpha, 1)
require.EqualValues(t, dossier.Reputation.AuditReputationBeta, 0)
require.NotNil(t, dossier.Disqualified)
}
}
@ -150,10 +148,7 @@ func TestRandomizedSelection(t *testing.T) {
cache := db.OverlayCache()
allIDs := make(storj.NodeIDList, totalNodes)
nodeCounts := make(map[storj.NodeID]int)
defaults := overlay.NodeSelectionConfig{
AuditReputationAlpha0: 1,
AuditReputationBeta0: 0,
}
defaults := overlay.NodeSelectionConfig{}
// put nodes in cache
for i := 0; i < totalNodes; i++ {
@ -429,10 +424,15 @@ func TestUpdateCheckIn(t *testing.T) {
require.NoError(t, err)
require.True(t, actualNode.Reputation.LastContactSuccess.After(startOfTest))
require.True(t, actualNode.Reputation.LastContactFailure.UTC().Equal(time.Time{}.UTC()))
actualNode.Address = expectedNode.Address
// we need to overwrite the times so that the deep equal considers them the same
expectedNode.Reputation.LastContactSuccess = actualNode.Reputation.LastContactSuccess
expectedNode.Reputation.LastContactFailure = actualNode.Reputation.LastContactFailure
expectedNode.Reputation.AuditReputationAlpha = 1
expectedNode.Reputation.UnknownAuditReputationAlpha = 1
expectedNode.Reputation.AuditReputationBeta = 0
expectedNode.Reputation.UnknownAuditReputationBeta = 0
expectedNode.Version.Timestamp = actualNode.Version.Timestamp
expectedNode.CreatedAt = actualNode.CreatedAt
require.Equal(t, expectedNode, actualNode)
@ -498,10 +498,7 @@ func TestUpdateCheckIn(t *testing.T) {
func TestCache_DowntimeTracking(t *testing.T) {
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
cache := db.OverlayCache()
defaults := overlay.NodeSelectionConfig{
AuditReputationAlpha0: 1,
AuditReputationBeta0: 0,
}
defaults := overlay.NodeSelectionConfig{}
totalNodes := 10
allIDs := make(storj.NodeIDList, totalNodes)
@ -596,10 +593,7 @@ func TestSuspendedSelection(t *testing.T) {
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
cache := db.OverlayCache()
suspendedIDs := make(map[storj.NodeID]bool)
defaults := overlay.NodeSelectionConfig{
AuditReputationAlpha0: 1,
AuditReputationBeta0: 0,
}
defaults := overlay.NodeSelectionConfig{}
// put nodes in cache
for i := 0; i < totalNodes; i++ {

View File

@ -41,10 +41,7 @@ func testDatabase(ctx context.Context, t *testing.T, cache overlay.DB) {
{storj.NodeID{3}, true, false, false}, // suspended
{storj.NodeID{4}, false, false, true}, // offline
} {
startingRep := overlay.NodeSelectionConfig{
AuditReputationAlpha0: 1,
AuditReputationBeta0: 0,
}
startingRep := overlay.NodeSelectionConfig{}
n := pb.Node{Id: tt.nodeID}
d := overlay.NodeDossier{Node: n, LastIPPort: "", LastNet: ""}

View File

@ -298,7 +298,7 @@ func (cache *overlaycache) UpdateAddress(ctx context.Context, info *overlay.Node
// args $1 - $5
info.Id.Bytes(), address.Address, info.LastNet, int(address.Transport), int(pb.NodeType_INVALID),
// args $6 - $7
defaults.AuditReputationAlpha0, defaults.AuditReputationBeta0,
1, 0,
// args $8
time.Now(),
// args $9
@ -1328,7 +1328,7 @@ func (cache *overlaycache) UpdateCheckIn(ctx context.Context, node overlay.NodeC
// args $9
node.IsUp,
// args $10 - $11
config.AuditReputationAlpha0, config.AuditReputationBeta0,
1, 0,
// args $12 - $17
semVer.Major, semVer.Minor, semVer.Patch, node.Version.GetCommitHash(), node.Version.Timestamp, node.Version.GetRelease(),
// args $18

6
scripts/testdata/satellite-config.yaml.lock vendored Normal file → Executable file
View File

@ -397,12 +397,6 @@ identity.key-path: /root/.local/share/storj/identity/satellite/identity.key
# the number of times a node has been audited to not be considered a New Node
# overlay.node.audit-count: 100
# the initial shape 'alpha' used to calculate audit SNs reputation
# overlay.node.audit-reputation-alpha0: 1
# the initial shape 'beta' value used to calculate audit SNs reputation
# overlay.node.audit-reputation-beta0: 0
# the reputation cut-off for disqualifying SNs based on audit history
# overlay.node.audit-reputation-dq: 0.6