Skip to content

Commit e91c8db

Browse files
Merge pull request #399 from ava-labs/dev
v0.8.2
2 parents a789089 + 3c73ab9 commit e91c8db

File tree

29 files changed

+564
-593
lines changed

29 files changed

+564
-593
lines changed

api/info/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ type IsBootstrappedResponse struct {
151151
// IsBootstrapped returns nil and sets [reply.IsBootstrapped] == true iff [args.Chain] exists and is done bootstrapping
152152
// Returns an error if the chain doesn't exist
153153
func (service *Info) IsBootstrapped(_ *http.Request, args *IsBootstrappedArgs, reply *IsBootstrappedResponse) error {
154-
service.log.Info("Info: IsBootstrapped called")
154+
service.log.Info("Info: IsBootstrapped called with chain: %s", args.Chain)
155155
if args.Chain == "" {
156156
return fmt.Errorf("argument 'chain' not given")
157157
}

chains/awaiter.go

Lines changed: 0 additions & 58 deletions
This file was deleted.

chains/awaiter_test.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

chains/manager.go

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -351,28 +351,6 @@ func (m *manager) buildChain(chainParams ChainParameters) (*chain, error) {
351351
ctx.Log.Error("Chain with ID: %s was shutdown due to a panic", chainParams.ID)
352352
})
353353
}
354-
355-
reqWeight := (3*bootstrapWeight + 3) / 4
356-
if reqWeight == 0 {
357-
if err := chain.Engine.Startup(); err != nil {
358-
chain.Handler.Shutdown()
359-
return nil, fmt.Errorf("failed to start consensus engine: %w", err)
360-
}
361-
} else {
362-
awaiter := NewAwaiter(beacons, reqWeight, func() {
363-
ctx.Lock.Lock()
364-
defer ctx.Lock.Unlock()
365-
if err := chain.Engine.Startup(); err != nil {
366-
chain.Ctx.Log.Error("failed to start consensus engine: %s", err)
367-
chain.Handler.Shutdown()
368-
}
369-
})
370-
go m.Net.RegisterConnector(awaiter)
371-
}
372-
373-
if connector, ok := vm.(validators.Connector); ok {
374-
go m.Net.RegisterConnector(connector)
375-
}
376354
return chain, nil
377355
}
378356

@@ -439,11 +417,12 @@ func (m *manager) createAvalancheChain(
439417
if err := engine.Initialize(aveng.Config{
440418
Config: avbootstrap.Config{
441419
Config: common.Config{
442-
Ctx: ctx,
443-
Validators: validators,
444-
Beacons: beacons,
445-
Alpha: bootstrapWeight/2 + 1, // must be > 50%
446-
Sender: &sender,
420+
Ctx: ctx,
421+
Validators: validators,
422+
Beacons: beacons,
423+
StartupAlpha: (3*bootstrapWeight + 3) / 4,
424+
Alpha: bootstrapWeight/2 + 1, // must be > 50%
425+
Sender: &sender,
447426
},
448427
VtxBlocked: vtxBlocker,
449428
TxBlocked: txBlocker,
@@ -519,11 +498,12 @@ func (m *manager) createSnowmanChain(
519498
if err := engine.Initialize(smeng.Config{
520499
Config: smbootstrap.Config{
521500
Config: common.Config{
522-
Ctx: ctx,
523-
Validators: validators,
524-
Beacons: beacons,
525-
Alpha: bootstrapWeight/2 + 1, // must be > 50%
526-
Sender: &sender,
501+
Ctx: ctx,
502+
Validators: validators,
503+
Beacons: beacons,
504+
StartupAlpha: (3*bootstrapWeight + 3) / 4,
505+
Alpha: bootstrapWeight/2 + 1, // must be > 50%
506+
Sender: &sender,
527507
},
528508
Blocked: blocked,
529509
VM: vm,

main/params.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func init() {
194194
fs.BoolVar(&Config.HTTPSEnabled, "http-tls-enabled", false, "Upgrade the HTTP server to HTTPs")
195195
fs.StringVar(&Config.HTTPSKeyFile, "http-tls-key-file", "", "TLS private key file for the HTTPs server")
196196
fs.StringVar(&Config.HTTPSCertFile, "http-tls-cert-file", "", "TLS certificate file for the HTTPs server")
197-
fs.BoolVar(&Config.APIRequireAuthToken, "api-require-auth", false, "Require authorization token to call HTTP APIs")
197+
fs.BoolVar(&Config.APIRequireAuthToken, "api-auth-required", false, "Require authorization token to call HTTP APIs")
198198
fs.StringVar(&Config.APIAuthPassword, "api-auth-password", "", "Password used to create/validate API authorization tokens. Can be changed via API call.")
199199

200200
// Bootstrapping:
@@ -427,7 +427,7 @@ func init() {
427427
Config.HTTPPort = uint16(*httpPort)
428428
if Config.APIRequireAuthToken {
429429
if Config.APIAuthPassword == "" {
430-
errs.Add(errors.New("api-auth-password must be provided if api-require-auth is true"))
430+
errs.Add(errors.New("api-auth-password must be provided if api-auth-required is true"))
431431
return
432432
}
433433
if !password.SufficientlyStrong(Config.APIAuthPassword, password.OK) {

network/network.go

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ type Network interface {
7272
// IP.
7373
Track(ip utils.IPDesc)
7474

75-
// Register a new connector that is called whenever a peer is connected to
76-
// or disconnected from. If the connector returns true, then it will never
77-
// be called again. Thread safety must be managed internally in the network.
78-
// The handler will initially be called with this local node's ID.
79-
RegisterConnector(h validators.Connector)
80-
8175
// Returns the description of the nodes this network is currently connected
8276
// to externally. Thread safety must be managed internally to the network.
8377
Peers() []PeerID
@@ -138,9 +132,8 @@ type network struct {
138132
connectedIPs map[string]struct{}
139133
retryDelay map[string]time.Duration
140134
// TODO: bound the size of [myIPs] to avoid DoS. LRU caching would be ideal
141-
myIPs map[string]struct{} // set of IPs that resulted in my ID.
142-
peers map[[20]byte]*peer
143-
handlers []validators.Connector
135+
myIPs map[string]struct{} // set of IPs that resulted in my ID.
136+
peers map[[20]byte]*peer
144137
}
145138

146139
// NewDefaultNetwork returns a new Network implementation with the provided
@@ -288,6 +281,10 @@ func (n *network) GetAcceptedFrontier(validatorIDs ids.ShortSet, chainID ids.ID,
288281
sent = peer.send(msg)
289282
}
290283
if !sent {
284+
n.log.Debug("failed to send GetAcceptedFrontier(%s, %s, %d)",
285+
vID,
286+
chainID,
287+
requestID)
291288
n.executor.Add(func() { n.router.GetAcceptedFrontierFailed(vID, chainID, requestID) })
292289
n.getAcceptedFrontier.numFailed.Inc()
293290
} else {
@@ -655,24 +652,6 @@ func (n *network) Dispatch() error {
655652
}
656653
}
657654

658-
// RegisterConnector implements the Network interface
659-
func (n *network) RegisterConnector(h validators.Connector) {
660-
n.stateLock.Lock()
661-
defer n.stateLock.Unlock()
662-
663-
if h.Connected(n.id) {
664-
return
665-
}
666-
for _, peer := range n.peers {
667-
if peer.connected {
668-
if h.Connected(peer.id) {
669-
return
670-
}
671-
}
672-
}
673-
n.handlers = append(n.handlers, h)
674-
}
675-
676655
// IPs implements the Network interface
677656
func (n *network) Peers() []PeerID {
678657
n.stateLock.Lock()
@@ -1039,15 +1018,7 @@ func (n *network) connected(p *peer) {
10391018
n.connectedIPs[str] = struct{}{}
10401019
}
10411020

1042-
for i := 0; i < len(n.handlers); {
1043-
if n.handlers[i].Connected(p.id) {
1044-
newLen := len(n.handlers) - 1
1045-
n.handlers[i] = n.handlers[newLen] // remove the current handler
1046-
n.handlers = n.handlers[:newLen]
1047-
} else {
1048-
i++
1049-
}
1050-
}
1021+
n.router.Connected(p.id)
10511022
}
10521023

10531024
// assumes the stateLock is held when called
@@ -1068,14 +1039,6 @@ func (n *network) disconnected(p *peer) {
10681039
}
10691040

10701041
if p.connected {
1071-
for i := 0; i < len(n.handlers); {
1072-
if n.handlers[i].Disconnected(p.id) {
1073-
newLen := len(n.handlers) - 1
1074-
n.handlers[i] = n.handlers[newLen] // remove the current handler
1075-
n.handlers = n.handlers[:newLen]
1076-
} else {
1077-
i++
1078-
}
1079-
}
1042+
n.router.Disconnected(p.id)
10801043
}
10811044
}

0 commit comments

Comments
 (0)