mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
health: name the CHAIN that is unbootstrapped, not the net (v1.36.29)
/v1/health's `bootstrapped` check publishes chains.Nets.Bootstrapping()
verbatim as its message. Nets.chains is keyed by NET id, and the aggregate
appended the map key rather than asking the net which of its chains had not
converged. So every stuck primary-network chain surfaced as one ID,
11111111111111111111111111111111LpoYY — constants.PrimaryNetworkID, i.e.
ids.Empty — a "chain" the chain manager has never heard of. An operator who
went looking for it got "there is no chain with alias/ID", and N stuck chains
collapsed into a single indistinguishable entry that named none of them.
Measured on lux-devnet luxd-0 (v1.36.23), POST health.health:
"bootstrapped":{"message":["11111111111111111111111111111111LpoYY"],
"error":"chains not bootstrapped","contiguousFailures":3213}
The net owns the bootstrapping set, so the net is what can name those chains:
nets.Net grows Bootstrapping() []ids.ID and chains.Nets aggregates those
instead of its own keys. One place holds the set; one place reads it.
The existing TestNetsBootstrapping asserted the defect (require.Contains
bootstrapping, netID) — that assertion is why it survived review. It now
demands the chain ID and refuses the net ID.
This also cuts the first tag containing dada5a31, the GET /v1/health encoder
fix: apihealth.APIReply carries a time.Duration per check, jsonv2 has no
default representation for it, so every GET degraded to
{"healthy":…,"error":"health reply encode failed"} while the status code still
looked right. Reproduced here directly —
json: cannot marshal from Go time.Duration within "/checks/network/duration"
That fix landed on main on 2026-07-25 but no tag ever carried it: v1.36.28
points at 52de3948, seven commits behind. The fleet runs v1.36.2/23/24, all of
which predate it.
Tests (GOWORK=off CGO_ENABLED=0):
chains ok — TestNetsBootstrappingReportsChainsNotNets fails against the
old aggregate with exactly ids.Empty in the list
nets ok — TestNetBootstrappingNamesTheChains
health ok — the three handler tests fail against the jsonv2 encoder
(checks decode empty) and pass against encoding/json
Co-authored-by: Hanzo Dev <dev@hanzo.ai>
This commit is contained in:
+11
-4
@@ -72,15 +72,22 @@ func (s *Nets) IsChainBootstrapped(chainID ids.ID) bool {
|
||||
|
||||
// Bootstrapping returns the chainIDs of any chains that are still
|
||||
// bootstrapping.
|
||||
//
|
||||
// s.chains is keyed by NET id, not chain id. Reporting the key named the net
|
||||
// instead of the chain: every primary-network chain that failed to converge
|
||||
// surfaced in /v1/health as the single ID
|
||||
// "11111111111111111111111111111111LpoYY" — constants.PrimaryNetworkID, i.e.
|
||||
// ids.Empty — a "chain" the chain manager has never heard of, so the operator
|
||||
// chasing it got "there is no chain with alias/ID". Worse, N stuck chains
|
||||
// collapsed into one indistinguishable entry. Ask each net which of ITS chains
|
||||
// are still bootstrapping; the net owns that set.
|
||||
func (s *Nets) Bootstrapping() []ids.ID {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
|
||||
chainsBootstrapping := make([]ids.ID, 0, len(s.chains))
|
||||
for chainID, chain := range s.chains {
|
||||
if !chain.IsBootstrapped() {
|
||||
chainsBootstrapping = append(chainsBootstrapping, chainID)
|
||||
}
|
||||
for _, chain := range s.chains {
|
||||
chainsBootstrapping = append(chainsBootstrapping, chain.Bootstrapping()...)
|
||||
}
|
||||
|
||||
return chainsBootstrapping
|
||||
|
||||
+44
-2
@@ -158,12 +158,54 @@ func TestNetsBootstrapping(t *testing.T) {
|
||||
chain, ok := chains.GetOrCreate(netID)
|
||||
require.True(ok)
|
||||
|
||||
// Start bootstrapping
|
||||
// Start bootstrapping. What comes back is the CHAIN that is syncing, never
|
||||
// the net that holds it — this assertion used to demand netID, which is
|
||||
// how the phantom "11111111111111111111111111111111LpoYY" survived review.
|
||||
chain.AddChain(chainID)
|
||||
bootstrapping := chains.Bootstrapping()
|
||||
require.Contains(bootstrapping, netID)
|
||||
require.Equal([]ids.ID{chainID}, bootstrapping)
|
||||
require.NotContains(bootstrapping, netID)
|
||||
|
||||
// Finish bootstrapping
|
||||
chain.Bootstrapped(chainID)
|
||||
require.Empty(chains.Bootstrapping())
|
||||
}
|
||||
|
||||
// The "bootstrapped" health check publishes Nets.Bootstrapping() verbatim as
|
||||
// its message. s.chains is keyed by NET id, so returning the key reported
|
||||
// constants.PrimaryNetworkID (ids.Empty, cb58
|
||||
// "11111111111111111111111111111111LpoYY") as though it were an unbootstrapped
|
||||
// CHAIN. Operators saw a chain ID the chain manager denies exists, and every
|
||||
// stuck chain on the net collapsed into that one phantom entry.
|
||||
func TestNetsBootstrappingReportsChainsNotNets(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
chains, err := NewNets(ids.EmptyNodeID, map[ids.ID]nets.Config{
|
||||
constants.PrimaryNetworkID: {},
|
||||
})
|
||||
require.NoError(err)
|
||||
|
||||
primary, _ := chains.GetOrCreate(constants.PrimaryNetworkID)
|
||||
cChainID := ids.GenerateTestID()
|
||||
dChainID := ids.GenerateTestID()
|
||||
primary.AddChain(cChainID)
|
||||
primary.AddChain(dChainID)
|
||||
|
||||
bootstrapping := chains.Bootstrapping()
|
||||
|
||||
// The phantom: never the net's own ID.
|
||||
require.NotContains(bootstrapping, constants.PrimaryNetworkID)
|
||||
require.NotContains(
|
||||
bootstrapping,
|
||||
ids.Empty,
|
||||
"health check reported the primary NET id as an unbootstrapped chain",
|
||||
)
|
||||
// Both stuck chains must be individually nameable.
|
||||
require.ElementsMatch([]ids.ID{cChainID, dChainID}, bootstrapping)
|
||||
|
||||
primary.Bootstrapped(cChainID)
|
||||
require.Equal([]ids.ID{dChainID}, chains.Bootstrapping())
|
||||
|
||||
primary.Bootstrapped(dChainID)
|
||||
require.Empty(chains.Bootstrapping())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user