Skip to content

Commit 144f3c0

Browse files
committed
fix: make D-Chain opt-in, don't block node health
- genesis/builder: skip D-Chain if DChainGenesis is empty - node: only mark D-Chain critical if VM plugin available - chains/manager: non-critical chain failures don't block bootstrapped health check Nodes can now boot with just P/X/C chains. D-Chain, Q-Chain, and other optional VMs are loaded when their plugins are present.
1 parent b3b4f0b commit 144f3c0

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

chains/manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,11 @@ func (m *manager) createChain(chainParams ChainParameters) {
611611
log.Err(err),
612612
)
613613

614+
// Non-critical chain failed (e.g. D-Chain with missing VM plugin).
615+
// Mark it as bootstrapped so it doesn't block the node's health check.
616+
// The chain-specific health check below still reports the failure.
617+
sb.Bootstrapped(chainParams.ID)
618+
614619
// Register the health check for this chain regardless of if it was
615620
// created or not. This attempts to notify the node operator that their
616621
// node may not be properly validating the net they expect to be

genesis/builder/builder.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func FromConfig(config *genesiscfg.Config) ([]byte, ids.ID, error) {
556556
}
557557
}
558558

559-
// Specify all primary network chains
559+
// Specify primary network chains (X, C always; D only if genesis provided)
560560
chains := []genesis.Chain{
561561
{
562562
GenesisData: xvmGenesisBytes,
@@ -575,12 +575,16 @@ func FromConfig(config *genesiscfg.Config) ([]byte, ids.ID, error) {
575575
VMID: constants.EVMID,
576576
Name: "C-Chain",
577577
},
578-
{
578+
}
579+
580+
// D-Chain (primary network DEX) is optional — skip if no genesis provided
581+
if config.DChainGenesis != "" {
582+
chains = append(chains, genesis.Chain{
579583
GenesisData: getGenesis(config.DChainGenesis),
580584
ChainID: constants.PrimaryNetworkID,
581585
VMID: constants.DexVMID,
582586
Name: "D-Chain",
583-
},
587+
})
584588
}
585589

586590
pChainGenesis, err := genesis.New(

node/node.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,14 +1129,21 @@ func (n *Node) initChainManager(xAssetID ids.ID) error {
11291129
cChainID,
11301130
)
11311131

1132-
// D-Chain is optional — only mark critical if present in genesis
1132+
// D-Chain (primary network DEX) is opt-in — only critical if the VM plugin
1133+
// is actually available. This allows nodes to run without the DEX VM while
1134+
// still fully validating P/X/C chains.
11331135
var dChainID ids.ID
11341136
if optionalVMCount > 0 {
11351137
createDexVMTx, err := builder.VMGenesis(n.Config.GenesisBytes, constants.DexVMID)
11361138
if err == nil {
11371139
dChainID = createDexVMTx.ID()
1138-
criticalChains.Add(dChainID)
1139-
n.Log.Info("D-Chain marked as critical", "chainID", dChainID)
1140+
// Only mark as critical if the VM plugin is installed
1141+
if _, vmErr := n.VMManager.GetFactory(context.Background(), constants.DexVMID); vmErr == nil {
1142+
criticalChains.Add(dChainID)
1143+
n.Log.Info("D-Chain VM available, marked as critical", "chainID", dChainID)
1144+
} else {
1145+
n.Log.Info("D-Chain in genesis but VM not available — skipping (non-critical)", "chainID", dChainID)
1146+
}
11401147
} else {
11411148
n.Log.Info("D-Chain not in genesis, skipping")
11421149
}

0 commit comments

Comments
 (0)