Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e9cb4ae
WIP fixing tests
aaronbuchwald Apr 15, 2024
3e9e560
Fix tests that depend on divergent betaVirtuous/betaRogue values
aaronbuchwald Apr 15, 2024
9043105
Fix TestEngineBlockingChitResponse by updating Beta value to 2
aaronbuchwald Apr 16, 2024
2aed4ad
Re-write TestSnowballAddPreviouslyRejected wo divergent betas
aaronbuchwald Apr 16, 2024
f28feef
Remove TestSnowballAddRejected duplicate of TestSnowballAddPreviously…
aaronbuchwald Apr 16, 2024
d0a67da
Fix TestNewSnowballUnary update unary node string finalized status to…
aaronbuchwald Apr 16, 2024
919bc7b
Fix TestSnowballResetChild by marking non-conflicting unary node as u…
aaronbuchwald Apr 16, 2024
0c4c318
Fix TestSnowballResetSibling by updating finalized status
aaronbuchwald Apr 16, 2024
565c5b1
Fix TestSnowballFilterBinaryChildren + add rough graphs
aaronbuchwald Apr 17, 2024
83e89e5
Remove extra graphs
aaronbuchwald Apr 17, 2024
762e2d8
Fix TestSnowballFineGrained and add graphs
aaronbuchwald Apr 17, 2024
d6ca46d
Remove added graphs from TestSnowballFineGrained
aaronbuchwald Apr 17, 2024
3fc80b2
Update snow commit threshold documentation and hint
aaronbuchwald Apr 17, 2024
f2ad242
Remove comment about BetaRogue rounds from flat test
aaronbuchwald Apr 17, 2024
3a67abc
Remove incorrect references to BetaRogue
aaronbuchwald Apr 17, 2024
f360fe1
Update subnets snow params documentation
aaronbuchwald Apr 17, 2024
21aae99
Fix fun alphaConfidence test cases
aaronbuchwald Apr 17, 2024
99ccae2
Update beta value in TestDualAlphaOptimization back to 20
aaronbuchwald Apr 17, 2024
9c3b006
Undo formatting on tree code
aaronbuchwald Apr 17, 2024
94869fb
Remove unused commitThresholdDeprecationMsg
aaronbuchwald Apr 17, 2024
2876b22
Auto-format config/config.go
aaronbuchwald Apr 17, 2024
430c3f2
Remove no longer needed invalid params check
aaronbuchwald Apr 19, 2024
4d2c88f
Remove dead code setting unary node child
aaronbuchwald Apr 19, 2024
e4d5990
Add TestSnowballAddDecidedFirstBit to test dropping already rejected …
aaronbuchwald Apr 23, 2024
e18800e
Remove dead code from binaryNode that handled the case a child node f…
aaronbuchwald Apr 23, 2024
0518a9e
Update TestSnowballAddDecidedFirstBit to use 6 instead of 3 to target…
aaronbuchwald Apr 23, 2024
beb7a90
Merge branch 'master' into consolidate-beta
aaronbuchwald Apr 23, 2024
386e92e
Remove dead code from binaryNode RecordPoll
aaronbuchwald Apr 23, 2024
7913c77
Merge branch 'master' into consolidate-beta
aaronbuchwald Apr 23, 2024
c4f3f21
Merge branch 'master' into consolidate-beta
aaronbuchwald Apr 24, 2024
11367b7
Fix Beta param in test broken by merge
aaronbuchwald Apr 24, 2024
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
13 changes: 2 additions & 11 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ const (
var (
// Deprecated key --> deprecation message (i.e. which key replaces it)
// TODO: deprecate "BootstrapIDsKey" and "BootstrapIPsKey"
commitThresholdDeprecationMsg = fmt.Sprintf("use --%s instead", SnowCommitThresholdKey)
deprecatedKeys = map[string]string{
deprecatedKeys = map[string]string{
KeystoreAPIEnabledKey: keystoreDeprecationMsg,

SnowRogueCommitThresholdKey: commitThresholdDeprecationMsg,
SnowVirtuousCommitThresholdKey: commitThresholdDeprecationMsg,
}

errConflictingACPOpinion = errors.New("supporting and objecting to the same ACP")
Expand Down Expand Up @@ -95,8 +91,7 @@ func getConsensusConfig(v *viper.Viper) snowball.Parameters {
K: v.GetInt(SnowSampleSizeKey),
AlphaPreference: v.GetInt(SnowPreferenceQuorumSizeKey),
AlphaConfidence: v.GetInt(SnowConfidenceQuorumSizeKey),
BetaVirtuous: v.GetInt(SnowCommitThresholdKey),
BetaRogue: v.GetInt(SnowCommitThresholdKey),
Beta: v.GetInt(SnowCommitThresholdKey),
ConcurrentRepolls: v.GetInt(SnowConcurrentRepollsKey),
OptimalProcessing: v.GetInt(SnowOptimalProcessingKey),
MaxOutstandingItems: v.GetInt(SnowMaxProcessingKey),
Expand All @@ -106,10 +101,6 @@ func getConsensusConfig(v *viper.Viper) snowball.Parameters {
p.AlphaPreference = v.GetInt(SnowQuorumSizeKey)
p.AlphaConfidence = p.AlphaPreference
}
if v.IsSet(SnowRogueCommitThresholdKey) {
p.BetaVirtuous = v.GetInt(SnowRogueCommitThresholdKey)
p.BetaRogue = v.GetInt(SnowRogueCommitThresholdKey)
}
return p
}

Expand Down
20 changes: 6 additions & 14 deletions config/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ Snow consensus requires repolling transactions that are issued during low time
of network usage. This parameter lets one define how aggressive the client will
be in finalizing these pending transactions. This should only be changed after
careful consideration of the tradeoffs of Snow consensus. The value must be at
least `1` and at most `--snow-rogue-commit-threshold`. Defaults to `4`.
least `1` and at most `--snow-commit-threshold`. Defaults to `4`.

##### `--snow-sample-size` (int)

Expand All @@ -977,21 +977,13 @@ transaction. This parameter lets us define the `alpha` value used for consensus.
This should only be changed after careful consideration of the tradeoffs of Snow
consensus. The value must be at greater than `k/2`. Defaults to `15`.

##### `--snow-virtuous-commit-threshold` (int)
##### `--snow-commit-threshold` (int)

Snow consensus defines `beta1` as the number of consecutive polls that a
virtuous transaction must increase its confidence for it to be accepted. This
parameter lets us define the `beta1` value used for consensus. This should only
Snow consensus defines `beta` as the number of consecutive polls that a
container must increase its confidence for it to be accepted. This
parameter lets us define the `beta` value used for consensus. This should only
be changed after careful consideration of the tradeoffs of Snow consensus. The
value must be at least `1`. Defaults to `15`.

##### `--snow-rogue-commit-threshold` (int)

Snow consensus defines `beta2` as the number of consecutive polls that a rogue
transaction must increase its confidence for it to be accepted. This parameter
lets us define the `beta2` value used for consensus. This should only be changed
after careful consideration of the tradeoffs of Snow consensus. The value must
be at least `beta1`. Defaults to `20`.
value must be at least `1`. Defaults to `20`.

##### `--snow-optimal-processing` (int)

Expand Down
5 changes: 1 addition & 4 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,7 @@ func addNodeFlags(fs *pflag.FlagSet) {
fs.Int(SnowPreferenceQuorumSizeKey, snowball.DefaultParameters.AlphaPreference, fmt.Sprintf("Threshold of nodes required to update this node's preference in a network poll. Ignored if %s is provided", SnowQuorumSizeKey))
fs.Int(SnowConfidenceQuorumSizeKey, snowball.DefaultParameters.AlphaConfidence, fmt.Sprintf("Threshold of nodes required to increase this node's confidence in a network poll. Ignored if %s is provided", SnowQuorumSizeKey))

fs.Int(SnowCommitThresholdKey, snowball.DefaultParameters.BetaRogue, "Beta value to use for transactions")
// TODO: Remove these once enough time has passed with SnowCommitThresholdKey
fs.Int(SnowVirtuousCommitThresholdKey, snowball.DefaultParameters.BetaVirtuous, "This flag is temporarily ignored due to the X-chain linearization")
fs.Int(SnowRogueCommitThresholdKey, snowball.DefaultParameters.BetaRogue, "Beta value to use for rogue transactions")
fs.Int(SnowCommitThresholdKey, snowball.DefaultParameters.Beta, "Beta value to use for consensus")

fs.Int(SnowConcurrentRepollsKey, snowball.DefaultParameters.ConcurrentRepolls, "Minimum number of concurrent polls for finalizing consensus")
fs.Int(SnowOptimalProcessingKey, snowball.DefaultParameters.OptimalProcessing, "Optimal number of processing containers in consensus")
Expand Down
2 changes: 0 additions & 2 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ const (
SnowQuorumSizeKey = "snow-quorum-size"
SnowPreferenceQuorumSizeKey = "snow-preference-quorum-size"
SnowConfidenceQuorumSizeKey = "snow-confidence-quorum-size"
SnowVirtuousCommitThresholdKey = "snow-virtuous-commit-threshold"
SnowRogueCommitThresholdKey = "snow-rogue-commit-threshold"
SnowCommitThresholdKey = "snow-commit-threshold"
SnowConcurrentRepollsKey = "snow-concurrent-repolls"
SnowOptimalProcessingKey = "snow-optimal-processing"
Expand Down
5 changes: 2 additions & 3 deletions snow/consensus/snowball/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ type Unary interface {
// Return whether a choice has been finalized
Finalized() bool

// Returns a new binary snowball instance with the agreement parameters
// transferred. Takes in the new beta value and the original choice
Extend(beta, originalPreference int) Binary
// Returns a new binary snowball instance with the original choice.
Extend(originalPreference int) Binary

// Returns a new unary snowflake instance with the same state
Clone() Unary
Expand Down
3 changes: 1 addition & 2 deletions snow/consensus/snowball/consensus_performance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func TestDualAlphaOptimization(t *testing.T) {
K: 20,
AlphaPreference: 15,
AlphaConfidence: 15,
BetaVirtuous: 15,
BetaRogue: 20,
Beta: 20,
}
seed uint64 = 0
source = prng.NewMT19937()
Expand Down
8 changes: 4 additions & 4 deletions snow/consensus/snowball/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ var (
type snowballFactory struct{}

func (snowballFactory) NewNnary(params Parameters, choice ids.ID) Nnary {
sb := newNnarySnowball(params.BetaVirtuous, params.BetaRogue, choice)
sb := newNnarySnowball(params.Beta, choice)
return &sb
}

func (snowballFactory) NewUnary(params Parameters) Unary {
sb := newUnarySnowball(params.BetaVirtuous)
sb := newUnarySnowball(params.Beta)
return &sb
}

type snowflakeFactory struct{}

func (snowflakeFactory) NewNnary(params Parameters, choice ids.ID) Nnary {
sf := newNnarySnowflake(params.BetaVirtuous, params.BetaRogue, choice)
sf := newNnarySnowflake(params.Beta, choice)
return &sf
}

func (snowflakeFactory) NewUnary(params Parameters) Unary {
sf := newUnarySnowflake(params.BetaVirtuous)
sf := newUnarySnowflake(params.Beta)
return &sf
}
5 changes: 2 additions & 3 deletions snow/consensus/snowball/flat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ func TestFlat(t *testing.T) {
K: 3,
AlphaPreference: 2,
AlphaConfidence: 3,
BetaVirtuous: 1,
BetaRogue: 2,
Beta: 2,
}
f := NewFlat(SnowballFactory, params, Red)
f.Add(Green)
Expand Down Expand Up @@ -51,7 +50,7 @@ func TestFlat(t *testing.T) {

require.True(f.RecordPoll(threeGreen))
require.Equal(Green, f.Preference())
require.False(f.Finalized()) // Not finalized before BetaRogue rounds
require.False(f.Finalized()) // Not finalized before Beta rounds

require.True(f.RecordPoll(threeGreen))
require.Equal(Green, f.Preference())
Expand Down
4 changes: 2 additions & 2 deletions snow/consensus/snowball/nnary_snowball.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

var _ Nnary = (*nnarySnowball)(nil)

func newNnarySnowball(betaVirtuous, betaRogue int, choice ids.ID) nnarySnowball {
func newNnarySnowball(beta int, choice ids.ID) nnarySnowball {
return nnarySnowball{
nnarySnowflake: newNnarySnowflake(betaVirtuous, betaRogue, choice),
nnarySnowflake: newNnarySnowflake(beta, choice),
preference: choice,
preferenceStrength: make(map[ids.ID]int),
}
Expand Down
20 changes: 8 additions & 12 deletions snow/consensus/snowball/nnary_snowball_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import (
func TestNnarySnowball(t *testing.T) {
require := require.New(t)

betaVirtuous := 2
betaRogue := 2
beta := 2

sb := newNnarySnowball(betaVirtuous, betaRogue, Red)
sb := newNnarySnowball(beta, Red)
sb.Add(Blue)
sb.Add(Green)

Expand Down Expand Up @@ -54,10 +53,9 @@ func TestNnarySnowball(t *testing.T) {
func TestVirtuousNnarySnowball(t *testing.T) {
require := require.New(t)

betaVirtuous := 1
betaRogue := 2
beta := 1

sb := newNnarySnowball(betaVirtuous, betaRogue, Red)
sb := newNnarySnowball(beta, Red)

require.Equal(Red, sb.Preference())
require.False(sb.Finalized())
Expand All @@ -70,10 +68,9 @@ func TestVirtuousNnarySnowball(t *testing.T) {
func TestNarySnowballRecordUnsuccessfulPoll(t *testing.T) {
require := require.New(t)

betaVirtuous := 2
betaRogue := 2
beta := 2

sb := newNnarySnowball(betaVirtuous, betaRogue, Red)
sb := newNnarySnowball(beta, Red)
sb.Add(Blue)

require.Equal(Red, sb.Preference())
Expand Down Expand Up @@ -109,10 +106,9 @@ func TestNarySnowballRecordUnsuccessfulPoll(t *testing.T) {
func TestNarySnowballDifferentSnowflakeColor(t *testing.T) {
require := require.New(t)

betaVirtuous := 2
betaRogue := 2
beta := 2

sb := newNnarySnowball(betaVirtuous, betaRogue, Red)
sb := newNnarySnowball(beta, Red)
sb.Add(Blue)

require.Equal(Red, sb.Preference())
Expand Down
27 changes: 8 additions & 19 deletions snow/consensus/snowball/nnary_snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import (

var _ Nnary = (*nnarySnowflake)(nil)

func newNnarySnowflake(betaVirtuous, betaRogue int, choice ids.ID) nnarySnowflake {
func newNnarySnowflake(beta int, choice ids.ID) nnarySnowflake {
return nnarySnowflake{
nnarySlush: newNnarySlush(choice),
betaVirtuous: betaVirtuous,
betaRogue: betaRogue,
nnarySlush: newNnarySlush(choice),
beta: beta,
}
}

Expand All @@ -25,29 +24,20 @@ type nnarySnowflake struct {
// wrap the n-nary slush logic
nnarySlush

// betaVirtuous is the number of consecutive successful queries required for
// finalization on a virtuous instance.
betaVirtuous int

// betaRogue is the number of consecutive successful queries required for
// finalization on a rogue instance.
betaRogue int
// beta is the number of consecutive successful queries required for
// finalization.
beta int

// confidence tracks the number of successful polls in a row that have
// returned the preference
confidence int

// rogue tracks if this instance has multiple choices or only one
rogue bool

// finalized prevents the state from changing after the required number of
// consecutive polls has been reached
finalized bool
}

func (sf *nnarySnowflake) Add(choice ids.ID) {
sf.rogue = sf.rogue || choice != sf.preference
}
func (*nnarySnowflake) Add(_ ids.ID) {}

func (sf *nnarySnowflake) RecordSuccessfulPoll(choice ids.ID) {
if sf.finalized {
Expand All @@ -62,8 +52,7 @@ func (sf *nnarySnowflake) RecordSuccessfulPoll(choice ids.ID) {
sf.confidence = 1
}

sf.finalized = (!sf.rogue && sf.confidence >= sf.betaVirtuous) ||
sf.confidence >= sf.betaRogue
sf.finalized = sf.confidence >= sf.beta
sf.nnarySlush.RecordSuccessfulPoll(choice)
}

Expand Down
49 changes: 8 additions & 41 deletions snow/consensus/snowball/nnary_snowflake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import (
func TestNnarySnowflake(t *testing.T) {
require := require.New(t)

betaVirtuous := 2
betaRogue := 2
beta := 2

sf := newNnarySnowflake(betaVirtuous, betaRogue, Red)
sf := newNnarySnowflake(beta, Red)
sf.Add(Blue)
sf.Add(Green)

Expand Down Expand Up @@ -50,25 +49,24 @@ func TestNnarySnowflake(t *testing.T) {
func TestNnarySnowflakeConfidenceReset(t *testing.T) {
require := require.New(t)

betaVirtuous := 4
betaRogue := 4
beta := 4

sf := newNnarySnowflake(betaVirtuous, betaRogue, Red)
sf := newNnarySnowflake(beta, Red)
sf.Add(Blue)
sf.Add(Green)

require.Equal(Red, sf.Preference())
require.False(sf.Finalized())

// Increase Blue's confidence without finalizing
for i := 0; i < betaRogue-1; i++ {
for i := 0; i < beta-1; i++ {
sf.RecordSuccessfulPoll(Blue)
require.Equal(Blue, sf.Preference())
require.False(sf.Finalized())
}

// Increase Red's confidence without finalizing
for i := 0; i < betaRogue-1; i++ {
for i := 0; i < beta-1; i++ {
sf.RecordSuccessfulPoll(Red)
require.Equal(Red, sf.Preference())
require.False(sf.Finalized())
Expand All @@ -83,40 +81,9 @@ func TestNnarySnowflakeConfidenceReset(t *testing.T) {
func TestVirtuousNnarySnowflake(t *testing.T) {
require := require.New(t)

betaVirtuous := 2
betaRogue := 3

sb := newNnarySnowflake(betaVirtuous, betaRogue, Red)
require.Equal(Red, sb.Preference())
require.False(sb.Finalized())

sb.RecordSuccessfulPoll(Red)
require.Equal(Red, sb.Preference())
require.False(sb.Finalized())

sb.RecordSuccessfulPoll(Red)
require.Equal(Red, sb.Preference())
require.True(sb.Finalized())
}

func TestRogueNnarySnowflake(t *testing.T) {
require := require.New(t)

betaVirtuous := 1
betaRogue := 2

sb := newNnarySnowflake(betaVirtuous, betaRogue, Red)
require.False(sb.rogue)

sb.Add(Red)
require.False(sb.rogue)

sb.Add(Blue)
require.True(sb.rogue)

sb.Add(Red)
require.True(sb.rogue)
beta := 2

sb := newNnarySnowflake(beta, Red)
require.Equal(Red, sb.Preference())
require.False(sb.Finalized())

Expand Down
Loading