mirror of
https://github.com/luxfi/genesis.git
synced 2026-07-27 05:54:08 +00:00
feat(configs): operator-overridable C-Chain genesis via LUX_CCHAIN_GENESIS_FILE
Adds env-driven override at the lowest layer of the genesis loader so
downstream networks (e.g. <tenant> at chainId 8675312) can reuse a
stock lqd binary without forking configs/{network}/cchain.json.
Resolution order in loadEmbeddedGenesisWithDynamic:
1. LUX_CCHAIN_GENESIS_FILE — absolute path to a JSON file. Read at
boot, used verbatim as the C-Chain genesis bytes.
2. embedded configs/{network}/cchain.json (the previous default,
immutable per-network).
Net behaviour for stock callers is unchanged: env unset → embedded
default. The override only fires when the file exists and is readable;
a misconfigured path fails loud with a wrapped error so misconfiguration
isn't silently masked by the embedded fallback.
Pairs with luxfi/node@d0a248f5 (LUX_AUTOMINE_CCHAIN_GENESIS_PATH for the
single-node automine path). The two cover both startup modes lqd uses.
This commit is contained in:
+19
-4
@@ -194,10 +194,25 @@ func loadEmbeddedGenesisWithDynamic(networkName string, dynamicPChain *genesis.P
|
||||
}
|
||||
}
|
||||
|
||||
// Load C-Chain genesis (always embedded, immutable)
|
||||
cchainData, err := embeddedGenesis.ReadFile(filepath.Join(networkName, "cchain.json"))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read cchain.json: %w", err)
|
||||
// Load C-Chain genesis. Operator override:
|
||||
// LUX_CCHAIN_GENESIS_FILE — absolute path to a JSON file that
|
||||
// replaces the embedded cchain.json verbatim. Lets downstream
|
||||
// networks (Liquidity at chainId 8675312, etc.) reuse the lqd
|
||||
// binary without forking the embedded genesis tree.
|
||||
//
|
||||
// Unset → embedded default (per-network, immutable).
|
||||
var cchainData []byte
|
||||
if override := os.Getenv("LUX_CCHAIN_GENESIS_FILE"); override != "" {
|
||||
body, ferr := os.ReadFile(override)
|
||||
if ferr != nil {
|
||||
return nil, fmt.Errorf("read LUX_CCHAIN_GENESIS_FILE=%q: %w", override, ferr)
|
||||
}
|
||||
cchainData = body
|
||||
} else {
|
||||
cchainData, err = embeddedGenesis.ReadFile(filepath.Join(networkName, "cchain.json"))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read cchain.json: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Build combined genesis config
|
||||
|
||||
Reference in New Issue
Block a user