cdk-erigon - ChainDB name is not recognized

2024-11-13 19:50:29

https://github.com/0xPolygonHermez/cdk-erigon/blob/06e93d49704726977297cf1d5055f43185e313bd/cmd/utils/flags.go#L2253-L2295

    chain = ctx.String(ChainFlag.Name)
    if strings.HasPrefix(chain, "dynamic") {
        configFilePath := ctx.String(ConfigFlag.Name)
        if configFilePath == "" {
            Fatalf("Config file is required for dynamic chain")
        }

        // Be sure to set this first
        params.DynamicChainConfigPath = filepath.Dir(configFilePath)
        filename := path.Join(params.DynamicChainConfigPath, chain+"-conf.json")

        genesis := core.GenesisBlockByChainName(chain)

        dConf := DynamicConfig{}

        if _, err := os.Stat(filename); err == nil {
            dConfBytes, err := os.ReadFile(filename)
            if err != nil {
                panic(err)
            }
            if err := json.Unmarshal(dConfBytes, &dConf); err != nil {
                panic(err)
            }
        }

        genesis.Timestamp = dConf.Timestamp
        genesis.GasLimit = dConf.GasLimit
        genesis.Difficulty = big.NewInt(dConf.Difficulty)

        cfg.Genesis = genesis

        genesisHash := libcommon.HexToHash(dConf.Root)
        if !ctx.IsSet(NetworkIdFlag.Name) {
            cfg.NetworkID = params.NetworkIDByChainName(chain)
        }
        SetDNSDiscoveryDefaults(cfg, genesisHash)
    } else {
        switch chain {
        default:
            genesis := core.GenesisBlockByChainName(chain)
            genesisHash := params.GenesisHashByChainName(chain)
            if (genesis == nil) || (genesisHash == nil) {
                Fatalf("ChainDB name is not recognized: %s", chain)

新建的自定义链,名称需要以dynamic关键词,例如dynamic-bcskill-testnet, 否则会获取对应的hash进行比对

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »