Skip to content

Commit

Permalink
Abort query if not enough stake connected
Browse files Browse the repository at this point in the history
Signed-off-by: Yacov Manevich <[email protected]>
  • Loading branch information
yacovm committed Aug 28, 2024
1 parent 1f0d2f7 commit 5575080
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion snow/engine/snowman/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import (
"github.com/ava-labs/avalanchego/utils/units"
)

const nonVerifiedCacheSize = 64 * units.MiB
const (
minConnectedStakeToQuery = 0.75
nonVerifiedCacheSize = 64 * units.MiB
)

var _ common.Engine = (*Engine)(nil)

Expand Down Expand Up @@ -875,6 +878,17 @@ func (e *Engine) sendQuery(
zap.Stringer("validators", e.Validators),
)

stakeConnectedRatio := e.Config.ConnectedValidators.ConnectedPercent()

if stakeConnectedRatio < minConnectedStakeToQuery {
e.Ctx.Log.Warn("dropped query for block",
zap.String("reason", "insufficient stake connected"),
zap.Stringer("blkID", blkID),
zap.Float64("ratio", stakeConnectedRatio),
)
return
}

vdrIDs, err := e.Validators.Sample(e.Ctx.SubnetID, e.Params.K)
if err != nil {
e.Ctx.Log.Warn("dropped query for block",
Expand Down

0 comments on commit 5575080

Please sign in to comment.