Skip to content

Commit

Permalink
Merge branch 'dev' into make_write_current_stakers_testable
Browse files Browse the repository at this point in the history
  • Loading branch information
abi87 authored Nov 30, 2023
2 parents 9fdd336 + 907b34c commit f528832
Show file tree
Hide file tree
Showing 27 changed files with 282 additions and 285 deletions.
40 changes: 21 additions & 19 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ type ManagerConfig struct {
MeterVMEnabled bool // Should each VM be wrapped with a MeterVM
Metrics metrics.MultiGatherer

AcceptedFrontierGossipFrequency time.Duration
ConsensusAppConcurrency int
FrontierPollFrequency time.Duration
ConsensusAppConcurrency int

// Max Time to spend fetching a container and its
// ancestors when responding to a GetAncestors
Expand Down Expand Up @@ -824,7 +824,7 @@ func (m *manager) createAvalancheChain(
ctx,
vdrs,
msgChan,
m.AcceptedFrontierGossipFrequency,
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
validators.UnhandledSubnetConnector, // avalanche chains don't use subnet connector
Expand Down Expand Up @@ -859,13 +859,14 @@ func (m *manager) createAvalancheChain(
// Create engine, bootstrapper and state-syncer in this order,
// to make sure start callbacks are duly initialized
snowmanEngineConfig := smeng.Config{
Ctx: ctx,
AllGetsServer: snowGetHandler,
VM: vmWrappingProposerVM,
Sender: snowmanMessageSender,
Validators: vdrs,
Params: consensusParams,
Consensus: snowmanConsensus,
Ctx: ctx,
AllGetsServer: snowGetHandler,
VM: vmWrappingProposerVM,
Sender: snowmanMessageSender,
Validators: vdrs,
ConnectedValidators: connectedValidators,
Params: consensusParams,
Consensus: snowmanConsensus,
}
snowmanEngine, err := smeng.New(snowmanEngineConfig)
if err != nil {
Expand Down Expand Up @@ -1166,7 +1167,7 @@ func (m *manager) createSnowmanChain(
ctx,
vdrs,
msgChan,
m.AcceptedFrontierGossipFrequency,
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
subnetConnector,
Expand Down Expand Up @@ -1201,14 +1202,15 @@ func (m *manager) createSnowmanChain(
// Create engine, bootstrapper and state-syncer in this order,
// to make sure start callbacks are duly initialized
engineConfig := smeng.Config{
Ctx: ctx,
AllGetsServer: snowGetHandler,
VM: vm,
Sender: messageSender,
Validators: vdrs,
Params: consensusParams,
Consensus: consensus,
PartialSync: m.PartialSyncPrimaryNetwork && ctx.ChainID == constants.PlatformChainID,
Ctx: ctx,
AllGetsServer: snowGetHandler,
VM: vm,
Sender: messageSender,
Validators: vdrs,
ConnectedValidators: connectedValidators,
Params: consensusParams,
Consensus: consensus,
PartialSync: m.PartialSyncPrimaryNetwork && ctx.ChainID == constants.PlatformChainID,
}
engine, err := smeng.New(engineConfig)
if err != nil {
Expand Down
17 changes: 12 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ const (
subnetConfigFileExt = ".json"
ipResolutionTimeout = 30 * time.Second

ipcDeprecationMsg = "IPC API is deprecated"
keystoreDeprecationMsg = "keystore API is deprecated"
ipcDeprecationMsg = "IPC API is deprecated"
keystoreDeprecationMsg = "keystore API is deprecated"
acceptedFrontierGossipDeprecationMsg = "push-based accepted frontier gossip is deprecated"
)

var (
Expand All @@ -72,6 +73,12 @@ var (
IpcsChainIDsKey: ipcDeprecationMsg,
IpcsPathKey: ipcDeprecationMsg,
KeystoreAPIEnabledKey: keystoreDeprecationMsg,
ConsensusGossipAcceptedFrontierValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipAcceptedFrontierNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipAcceptedFrontierPeerSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptPeerSizeKey: acceptedFrontierGossipDeprecationMsg,
}

errSybilProtectionDisabledStakerWeights = errors.New("sybil protection disabled weights must be positive")
Expand Down Expand Up @@ -1320,9 +1327,9 @@ func GetNodeConfig(v *viper.Viper) (node.Config, error) {
}

// Gossiping
nodeConfig.AcceptedFrontierGossipFrequency = v.GetDuration(ConsensusAcceptedFrontierGossipFrequencyKey)
if nodeConfig.AcceptedFrontierGossipFrequency < 0 {
return node.Config{}, fmt.Errorf("%s must be >= 0", ConsensusAcceptedFrontierGossipFrequencyKey)
nodeConfig.FrontierPollFrequency = v.GetDuration(ConsensusFrontierPollFrequencyKey)
if nodeConfig.FrontierPollFrequency < 0 {
return node.Config{}, fmt.Errorf("%s must be >= 0", ConsensusFrontierPollFrequencyKey)
}

// App handling
Expand Down
2 changes: 1 addition & 1 deletion config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ func addNodeFlags(fs *pflag.FlagSet) {
fs.Duration(BenchlistMinFailingDurationKey, constants.DefaultBenchlistMinFailingDuration, "Minimum amount of time messages to a peer must be failing before the peer is benched")

// Router
fs.Duration(ConsensusAcceptedFrontierGossipFrequencyKey, constants.DefaultAcceptedFrontierGossipFrequency, "Frequency of gossiping accepted frontiers")
fs.Uint(ConsensusAppConcurrencyKey, constants.DefaultConsensusAppConcurrency, "Maximum number of goroutines to use when handling App messages on a chain")
fs.Duration(ConsensusShutdownTimeoutKey, constants.DefaultConsensusShutdownTimeout, "Timeout before killing an unresponsive chain")
fs.Duration(ConsensusFrontierPollFrequencyKey, constants.DefaultFrontierPollFrequency, "Frequency of polling for new consensus frontiers")
fs.Uint(ConsensusGossipAcceptedFrontierValidatorSizeKey, constants.DefaultConsensusGossipAcceptedFrontierValidatorSize, "Number of validators to gossip to when gossiping accepted frontier")
fs.Uint(ConsensusGossipAcceptedFrontierNonValidatorSizeKey, constants.DefaultConsensusGossipAcceptedFrontierNonValidatorSize, "Number of non-validators to gossip to when gossiping accepted frontier")
fs.Uint(ConsensusGossipAcceptedFrontierPeerSizeKey, constants.DefaultConsensusGossipAcceptedFrontierPeerSize, "Number of peers to gossip to when gossiping accepted frontier")
Expand Down
4 changes: 2 additions & 2 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ const (
IpcsChainIDsKey = "ipcs-chain-ids"
IpcsPathKey = "ipcs-path"
MeterVMsEnabledKey = "meter-vms-enabled"
ConsensusAcceptedFrontierGossipFrequencyKey = "consensus-accepted-frontier-gossip-frequency"
ConsensusAppConcurrencyKey = "consensus-app-concurrency"
ConsensusShutdownTimeoutKey = "consensus-shutdown-timeout"
ConsensusFrontierPollFrequencyKey = "consensus-frontier-poll-frequency"
ConsensusGossipAcceptedFrontierValidatorSizeKey = "consensus-accepted-frontier-gossip-validator-size"
ConsensusGossipAcceptedFrontierNonValidatorSizeKey = "consensus-accepted-frontier-gossip-non-validator-size"
ConsensusGossipAcceptedFrontierPeerSizeKey = "consensus-accepted-frontier-gossip-peer-size"
Expand All @@ -154,7 +155,6 @@ const (
AppGossipValidatorSizeKey = "consensus-app-gossip-validator-size"
AppGossipNonValidatorSizeKey = "consensus-app-gossip-non-validator-size"
AppGossipPeerSizeKey = "consensus-app-gossip-peer-size"
ConsensusShutdownTimeoutKey = "consensus-shutdown-timeout"
ProposerVMUseCurrentHeightKey = "proposervm-use-current-height"
FdLimitKey = "fd-limit"
IndexEnabledKey = "index-enabled"
Expand Down
48 changes: 24 additions & 24 deletions genesis/bootstrappers.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,99 +2,99 @@
"mainnet": [
{
"id": "NodeID-A6onFGyJjA37EZ7kYHANMR1PFRT8NmXrF",
"ip": "54.94.43.49:9651"
"ip": "54.232.137.108:9651"
},
{
"id": "NodeID-6SwnPJLH8cWfrJ162JjZekbmzaFpjPcf",
"ip": "52.79.47.77:9651"
"ip": "13.124.187.98:9651"
},
{
"id": "NodeID-GSgaA47umS1px2ohVjodW9621Ks63xDxD",
"ip": "18.229.206.191:9651"
"ip": "54.232.142.167:9651"
},
{
"id": "NodeID-BQEo5Fy1FRKLbX51ejqDd14cuSXJKArH2",
"ip": "3.34.221.73:9651"
"ip": "3.39.67.183:9651"
},
{
"id": "NodeID-Drv1Qh7iJvW3zGBBeRnYfCzk56VCRM2GQ",
"ip": "13.244.155.170:9651"
"ip": "13.245.185.253:9651"
},
{
"id": "NodeID-DAtCoXfLT6Y83dgJ7FmQg8eR53hz37J79",
"ip": "13.244.47.224:9651"
"ip": "13.246.169.11:9651"
},
{
"id": "NodeID-FGRoKnyYKFWYFMb6Xbocf4hKuyCBENgWM",
"ip": "122.248.200.212:9651"
"ip": "13.251.82.39:9651"
},
{
"id": "NodeID-Dw7tuwxpAmcpvVGp9JzaHAR3REPoJ8f2R",
"ip": "52.30.9.211:9651"
"ip": "34.250.50.224:9651"
},
{
"id": "NodeID-4kCLS16Wy73nt1Zm54jFZsL7Msrv3UCeJ",
"ip": "122.248.199.127:9651"
"ip": "18.142.247.237:9651"
},
{
"id": "NodeID-9T7NXBFpp8LWCyc58YdKNoowDipdVKAWz",
"ip": "18.202.190.40:9651"
"ip": "34.252.106.116:9651"
},
{
"id": "NodeID-6ghBh6yof5ouMCya2n9fHzhpWouiZFVVj",
"ip": "15.206.182.45:9651"
"ip": "43.205.156.229:9651"
},
{
"id": "NodeID-HiFv1DpKXkAAfJ1NHWVqQoojjznibZXHP",
"ip": "15.207.11.193:9651"
"ip": "13.233.176.118:9651"
},
{
"id": "NodeID-Fv3t2shrpkmvLnvNzcv1rqRKbDAYFnUor",
"ip": "44.226.118.72:9651"
"ip": "35.164.160.193:9651"
},
{
"id": "NodeID-AaxT2P4uuPAHb7vAD8mNvjQ3jgyaV7tu9",
"ip": "54.185.87.50:9651"
"ip": "54.185.77.104:9651"
},
{
"id": "NodeID-kZNuQMHhydefgnwjYX1fhHMpRNAs9my1",
"ip": "18.158.15.12:9651"
"ip": "3.74.3.14:9651"
},
{
"id": "NodeID-A7GwTSd47AcDVqpTVj7YtxtjHREM33EJw",
"ip": "3.21.38.33:9651"
"ip": "3.135.107.20:9651"
},
{
"id": "NodeID-Hr78Fy8uDYiRYocRYHXp4eLCYeb8x5UuM",
"ip": "54.93.182.129:9651"
"ip": "3.77.28.168:9651"
},
{
"id": "NodeID-9CkG9MBNavnw7EVSRsuFr7ws9gascDQy3",
"ip": "3.128.138.36:9651"
"ip": "18.216.88.69:9651"
},
{
"id": "NodeID-A8jypu63CWp76STwKdqP6e9hjL675kdiG",
"ip": "3.104.107.241:9651"
"ip": "3.24.26.175:9651"
},
{
"id": "NodeID-HsBEx3L71EHWSXaE6gvk2VsNntFEZsxqc",
"ip": "3.106.25.139:9651"
"ip": "52.64.55.185:9651"
},
{
"id": "NodeID-Nr584bLpGgbCUbZFSBaBz3Xum5wpca9Ym",
"ip": "18.162.129.129:9651"
"ip": "16.162.27.145:9651"
},
{
"id": "NodeID-QKGoUvqcgormCoMj6yPw9isY7DX9H4mdd",
"ip": "18.162.161.230:9651"
"ip": "18.163.169.191:9651"
},
{
"id": "NodeID-HCw7S2TVbFPDWNBo1GnFWqJ47f9rDJtt1",
"ip": "52.47.181.114:9651"
"ip": "13.39.184.151:9651"
},
{
"id": "NodeID-FYv1Lb29SqMpywYXH7yNkcFAzRF2jvm3K",
"ip": "15.188.9.42:9651"
"ip": "13.36.28.133:9651"
}
],
"fuji": [
Expand Down
4 changes: 2 additions & 2 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ type Config struct {
ConsensusRouter router.Router `json:"-"`
RouterHealthConfig router.HealthConfig `json:"routerHealthConfig"`
ConsensusShutdownTimeout time.Duration `json:"consensusShutdownTimeout"`
// Gossip a container in the accepted frontier every [AcceptedFrontierGossipFrequency]
AcceptedFrontierGossipFrequency time.Duration `json:"consensusGossipFreq"`
// Poll for new frontiers every [FrontierPollFrequency]
FrontierPollFrequency time.Duration `json:"consensusGossipFreq"`
// ConsensusAppConcurrency defines the maximum number of goroutines to
// handle App messages per chain.
ConsensusAppConcurrency int `json:"consensusAppConcurrency"`
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ func (n *Node) initChainManager(avaxAssetID ids.ID) error {
Metrics: n.MetricsGatherer,
SubnetConfigs: n.Config.SubnetConfigs,
ChainConfigs: n.Config.ChainConfigs,
AcceptedFrontierGossipFrequency: n.Config.AcceptedFrontierGossipFrequency,
FrontierPollFrequency: n.Config.FrontierPollFrequency,
ConsensusAppConcurrency: n.Config.ConsensusAppConcurrency,
BootstrapMaxTimeGetAncestors: n.Config.BootstrapMaxTimeGetAncestors,
BootstrapAncestorsMaxContainersSent: n.Config.BootstrapAncestorsMaxContainersSent,
Expand Down Expand Up @@ -1084,7 +1084,7 @@ func (n *Node) initVMs() error {
ApricotPhase5Time: version.GetApricotPhase5Time(n.Config.NetworkID),
BanffTime: version.GetBanffTime(n.Config.NetworkID),
CortinaTime: version.GetCortinaTime(n.Config.NetworkID),
DTime: version.GetDTime(n.Config.NetworkID),
DurangoTime: version.GetDurangoTime(n.Config.NetworkID),
UseCurrentHeight: n.Config.UseCurrentHeight,
},
}),
Expand Down
3 changes: 1 addition & 2 deletions snow/engine/avalanche/bootstrap/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ func (b *bootstrapper) HealthCheck(ctx context.Context) (interface{}, error) {
func (b *bootstrapper) fetch(ctx context.Context, vtxIDs ...ids.ID) error {
b.needToFetch.Add(vtxIDs...)
for b.needToFetch.Len() > 0 && b.outstandingRequests.Len() < maxOutstandingGetAncestorsRequests {
vtxID := b.needToFetch.CappedList(1)[0]
b.needToFetch.Remove(vtxID)
vtxID, _ := b.needToFetch.Pop() // Length checked in predicate above

// Make sure we haven't already requested this vertex
if b.outstandingRequests.HasValue(vtxID) {
Expand Down
14 changes: 14 additions & 0 deletions snow/engine/common/tracker/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type Peers interface {
ConnectedPercent() float64
// TotalWeight returns the total validator weight
TotalWeight() uint64
// SampleValidator returns a randomly selected connected validator. If there
// are no currently connected validators then it will return false.
SampleValidator() (ids.NodeID, bool)
// PreferredPeers returns the currently connected validators. If there are
// no currently connected validators then it will return the currently
// connected peers.
Expand Down Expand Up @@ -108,6 +111,13 @@ func (p *lockedPeers) TotalWeight() uint64 {
return p.peers.TotalWeight()
}

func (p *lockedPeers) SampleValidator() (ids.NodeID, bool) {
p.lock.RLock()
defer p.lock.RUnlock()

return p.peers.SampleValidator()
}

func (p *lockedPeers) PreferredPeers() set.Set[ids.NodeID] {
p.lock.RLock()
defer p.lock.RUnlock()
Expand Down Expand Up @@ -263,6 +273,10 @@ func (p *peerData) TotalWeight() uint64 {
return p.totalWeight
}

func (p *peerData) SampleValidator() (ids.NodeID, bool) {
return p.connectedValidators.Peek()
}

func (p *peerData) PreferredPeers() set.Set[ids.NodeID] {
if p.connectedValidators.Len() == 0 {
connectedPeers := set.NewSet[ids.NodeID](p.connectedPeers.Len())
Expand Down
16 changes: 9 additions & 7 deletions snow/engine/snowman/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ava-labs/avalanchego/snow/consensus/snowball"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/snow/engine/common/tracker"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
"github.com/ava-labs/avalanchego/snow/validators"
)
Expand All @@ -16,11 +17,12 @@ import (
type Config struct {
common.AllGetsServer

Ctx *snow.ConsensusContext
VM block.ChainVM
Sender common.Sender
Validators validators.Manager
Params snowball.Parameters
Consensus snowman.Consensus
PartialSync bool
Ctx *snow.ConsensusContext
VM block.ChainVM
Sender common.Sender
Validators validators.Manager
ConnectedValidators tracker.Peers
Params snowball.Parameters
Consensus snowman.Consensus
PartialSync bool
}
10 changes: 6 additions & 4 deletions snow/engine/snowman/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ import (
"github.com/ava-labs/avalanchego/snow/consensus/snowball"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/snow/engine/common/tracker"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
"github.com/ava-labs/avalanchego/snow/validators"
)

func DefaultConfig() Config {
return Config{
Ctx: snow.DefaultConsensusContextTest(),
VM: &block.TestVM{},
Sender: &common.SenderTest{},
Validators: validators.NewManager(),
Ctx: snow.DefaultConsensusContextTest(),
VM: &block.TestVM{},
Sender: &common.SenderTest{},
Validators: validators.NewManager(),
ConnectedValidators: tracker.NewPeers(),
Params: snowball.Parameters{
K: 1,
AlphaPreference: 1,
Expand Down
Loading

0 comments on commit f528832

Please sign in to comment.