github.com/ethereum-optimism/optimism@v1.7.2/op-node/p2p/app_params.go (about) 1 package p2p 2 3 import ( 4 "time" 5 6 "github.com/ethereum-optimism/optimism/op-node/rollup" 7 ) 8 9 type ApplicationScoreParams struct { 10 ValidResponseCap float64 11 ValidResponseWeight float64 12 ValidResponseDecay float64 13 14 ErrorResponseCap float64 15 ErrorResponseWeight float64 16 ErrorResponseDecay float64 17 18 RejectedPayloadCap float64 19 RejectedPayloadWeight float64 20 RejectedPayloadDecay float64 21 22 DecayToZero float64 23 DecayInterval time.Duration 24 } 25 26 func LightApplicationScoreParams(cfg *rollup.Config) ApplicationScoreParams { 27 slot := time.Duration(cfg.BlockTime) * time.Second 28 if slot == 0 { 29 slot = 2 * time.Second 30 } 31 // We initialize an "epoch" as 6 blocks suggesting 6 blocks, 32 // each taking ~ 2 seconds, is 12 seconds 33 epoch := 6 * slot 34 tenEpochs := 10 * epoch 35 return ApplicationScoreParams{ 36 // Max positive score from valid responses: 5 37 ValidResponseCap: 10, 38 ValidResponseWeight: 0.5, 39 ValidResponseDecay: ScoreDecay(tenEpochs, slot), 40 41 // Takes 10 error responses to reach the default gossip threshold of -10 42 // But at most we track 9. These errors include not supporting p2p sync 43 // so we don't (yet) want to ignore gossip from a peer based on this measure alone. 44 ErrorResponseCap: 9, 45 ErrorResponseWeight: -1, 46 ErrorResponseDecay: ScoreDecay(tenEpochs, slot), 47 48 // Takes 5 rejected payloads to reach the default ban threshold of -100 49 RejectedPayloadCap: 20, 50 RejectedPayloadWeight: -20, 51 RejectedPayloadDecay: ScoreDecay(tenEpochs, slot), 52 53 DecayToZero: DecayToZero, 54 DecayInterval: slot, 55 } 56 }