mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
The live guard refused to start a chain whose K was below the number of validators that existed. But sampling is stake-weighted: a validator is drawn in proportion to what it staked, however many validators there are, and K only sets how many draws a poll makes. Tying K to the headcount gave a validator holding a billionth of the stake the same standing as one holding a fifth, and refused to boot a producing chain because a small staker had joined. The guard keeps what makes a committee safe — the overlap bound and at least single-fault tolerance — and stops counting heads. The tier floor stays a reported target: refusing to start does not add validators, it pins every node on whatever it last booted. Co-authored-by: Hanzo Dev <[email protected]>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
// Copyright (C) 2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package config
|
|
|
|
import "testing"
|
|
|
|
// BenchmarkCertPolicy_Validate isolates the rule-check path (no
|
|
// parsing).
|
|
func BenchmarkCertPolicy_Validate(b *testing.B) {
|
|
cp := CertPolicy{Mode: CertModeStrict, Variant: CertVariantHybrid, TimeoutMs: 5_000, Fallback: CertModeFast}
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
if err := cp.Validate(); err != nil {
|
|
b.Fatalf("Validate: %v", err)
|
|
}
|
|
}
|
|
}
|
|
|
|
// BenchmarkCertPolicy_RequiredLegs measures the leg-set computation.
|
|
// Called per cert verification to know which legs to require.
|
|
func BenchmarkCertPolicy_RequiredLegs(b *testing.B) {
|
|
cp := CertPolicy{Mode: CertModeHeavy, Variant: CertVariantHybrid, TimeoutMs: 8_000, Fallback: CertModeFast}
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
_ = cp.RequiredLegs()
|
|
}
|
|
}
|
|
|
|
// BenchmarkCertPolicy_WireName measures the wire-name format path
|
|
// (called on every cert emission for the wire identifier).
|
|
func BenchmarkCertPolicy_WireName(b *testing.B) {
|
|
cp := CertPolicy{Mode: CertModeHeavy, Variant: CertVariantStrict, TimeoutMs: 8_000, Fallback: CertModeFast}
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
_ = cp.WireName()
|
|
}
|
|
}
|