mirror of
https://github.com/luxfi/bft.git
synced 2026-10-30 17:01:54 +00:00
The module is luxfi/bft and that is now the only name it answers to. - simplex/ -> engine/. Upstream's module is named for the protocol, so its root package and its engine package shared that name; under luxfi/bft the engine package would have collided with the module's own root package. It is the consensus engine, so engine.Epoch and engine.NewEpoch read without stutter. - Identifiers keep the qualifier where it carries meaning and only change the word: a block produced by this protocol as against a pre-existing chain's block is a real distinction, so makeNonSimplexBlock became makeNonBFTBlock, lastNonSimplexInnerBlockHeight became lastNonBFTInnerBlockHeight, newSnowToSimplexChain became newSnowToBFTChain. Dropping the qualifier outright would have left names that assert nothing. - The canoto-tagged fields of StateMachineMetadata lose the prefix entirely: EpochInfo, ProtocolMetadata, Blacklist. The wire format is unchanged — canoto keys off the tag numbers, which still read 1,2,3,4,5, and the generated .canoto.go files were renamed in step with the source. The msm fuzz and encoding round-trip tests cover this. - Prose cites the protocol paper by reference number instead of by name, so the origin stays findable without the name. The HyperSDK sentence still says Avalanche because that sentence is about Avalanche's VM and is true. Also here, from review of the logger port: - monitor_test's Fatal panics instead of returning. It reported a state the caller had declared impossible and then carried on regardless, which made it the one Fatal in the tree that was weaker than the original. - TestInstanceNonValidatorBootstraps asserts the property it is named for — that the node was still a non-validator when the bootstrap finished — rather than counting how many times a debug line was emitted. The count tracks how often onEpochChange happened to observe the branch, so transitions can coalesce; it measured 2 here where it had been reliably 3, and a logger-cost explanation was tested and refuted. The count never checked the property either way: a node that wrongly became a validator mid-bootstrap would still have counted 3. - SilenceExceptKeywords documents last-call-wins, and Trace/Verbo now reaching hooks is recorded where a future hook author will see it. Co-authored-by: Hanzo Dev <[email protected]>
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package random_network
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/luxfi/bft/engine"
|
|
)
|
|
|
|
type FuzzConfig struct {
|
|
// The minimum and maximum number of nodes in the network.
|
|
MinNodes int // Default is 3.
|
|
MaxNodes int // Default is 10.
|
|
|
|
// The minimum and maximum number of transactions to be issued at a block. Default is between 5 and 20.
|
|
MinTxsPerIssue int
|
|
MaxTxsPerIssue int
|
|
|
|
// Number of transactions per block. Default is 15.
|
|
TxsPerBlock int
|
|
|
|
// The number of blocks that must be finalized before ending the fuzz test. Default is 100.
|
|
NumFinalizedBlocks int
|
|
|
|
RandomSeed int64
|
|
|
|
// Probability that a node will be randomly crashed. Default is .1 (10%).
|
|
NodeCrashProbability float64
|
|
|
|
// Probability that a crashed node will be restarted. Default is .5 (50%).
|
|
NodeRecoverProbability float64
|
|
|
|
// Amount to advance the time by. Default is engine.DefaultMaxProposalWaitTime / 5.
|
|
AdvanceTimeTickAmount time.Duration
|
|
|
|
// Creates main.log for network logs and {nodeID-short}.log for each node.
|
|
// NodeID is represented as a 16-character hex string (first 8 bytes).
|
|
// Default directory is "tmp".
|
|
// If empty, logging to files is disabled and logs will only be printed to console.
|
|
LogDirectory string
|
|
}
|
|
|
|
func DefaultFuzzConfig() *FuzzConfig {
|
|
return &FuzzConfig{
|
|
MinNodes: 3,
|
|
MaxNodes: 10,
|
|
MinTxsPerIssue: 5,
|
|
MaxTxsPerIssue: 20,
|
|
TxsPerBlock: 15,
|
|
NumFinalizedBlocks: 100,
|
|
RandomSeed: time.Now().UnixMilli(),
|
|
NodeCrashProbability: 0.1,
|
|
NodeRecoverProbability: 0.5,
|
|
AdvanceTimeTickAmount: engine.DefaultMaxProposalWaitTime / 5,
|
|
LogDirectory: "tmp",
|
|
}
|
|
}
|