github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/node/config.go (about) 1 package node 2 3 import ( 4 types "github.com/prysmaticlabs/eth2-types" 5 "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" 6 "github.com/prysmaticlabs/prysm/shared/cmd" 7 "github.com/prysmaticlabs/prysm/shared/params" 8 "github.com/prysmaticlabs/prysm/shared/tracing" 9 "github.com/urfave/cli/v2" 10 ) 11 12 func configureTracing(cliCtx *cli.Context) error { 13 return tracing.Setup( 14 "beacon-chain", // service name 15 cliCtx.String(cmd.TracingProcessNameFlag.Name), 16 cliCtx.String(cmd.TracingEndpointFlag.Name), 17 cliCtx.Float64(cmd.TraceSampleFractionFlag.Name), 18 cliCtx.Bool(cmd.EnableTracingFlag.Name), 19 ) 20 } 21 22 func configureChainConfig(cliCtx *cli.Context) { 23 if cliCtx.IsSet(cmd.ChainConfigFileFlag.Name) { 24 chainConfigFileName := cliCtx.String(cmd.ChainConfigFileFlag.Name) 25 params.LoadChainConfigFile(chainConfigFileName) 26 } 27 } 28 29 func configureHistoricalSlasher(cliCtx *cli.Context) { 30 if cliCtx.Bool(flags.HistoricalSlasherNode.Name) { 31 c := params.BeaconConfig() 32 // Save a state every 4 epochs. 33 c.SlotsPerArchivedPoint = params.BeaconConfig().SlotsPerEpoch * 4 34 params.OverrideBeaconConfig(c) 35 cmdConfig := cmd.Get() 36 // Allow up to 4096 attestations at a time to be requested from the beacon nde. 37 cmdConfig.MaxRPCPageSize = int(params.BeaconConfig().SlotsPerEpoch.Mul(params.BeaconConfig().MaxAttestations)) 38 cmd.Init(cmdConfig) 39 log.Warnf( 40 "Setting %d slots per archive point and %d max RPC page size for historical slasher usage. This requires additional storage", 41 c.SlotsPerArchivedPoint, 42 cmdConfig.MaxRPCPageSize, 43 ) 44 } 45 } 46 47 func configureSlotsPerArchivedPoint(cliCtx *cli.Context) { 48 if cliCtx.IsSet(flags.SlotsPerArchivedPoint.Name) { 49 c := params.BeaconConfig() 50 c.SlotsPerArchivedPoint = types.Slot(cliCtx.Int(flags.SlotsPerArchivedPoint.Name)) 51 params.OverrideBeaconConfig(c) 52 } 53 } 54 55 func configureEth1Config(cliCtx *cli.Context) { 56 if cliCtx.IsSet(flags.ChainID.Name) { 57 c := params.BeaconConfig() 58 c.DepositChainID = cliCtx.Uint64(flags.ChainID.Name) 59 params.OverrideBeaconConfig(c) 60 } 61 if cliCtx.IsSet(flags.NetworkID.Name) { 62 c := params.BeaconConfig() 63 c.DepositNetworkID = cliCtx.Uint64(flags.NetworkID.Name) 64 params.OverrideBeaconConfig(c) 65 } 66 if cliCtx.IsSet(flags.DepositContractFlag.Name) { 67 c := params.BeaconConfig() 68 c.DepositContractAddress = cliCtx.String(flags.DepositContractFlag.Name) 69 params.OverrideBeaconConfig(c) 70 } 71 } 72 73 func configureNetwork(cliCtx *cli.Context) { 74 if cliCtx.IsSet(cmd.BootstrapNode.Name) { 75 c := params.BeaconNetworkConfig() 76 c.BootstrapNodes = cliCtx.StringSlice(cmd.BootstrapNode.Name) 77 params.OverrideBeaconNetworkConfig(c) 78 } 79 if cliCtx.IsSet(flags.ContractDeploymentBlock.Name) { 80 networkCfg := params.BeaconNetworkConfig() 81 networkCfg.ContractDeploymentBlock = uint64(cliCtx.Int(flags.ContractDeploymentBlock.Name)) 82 params.OverrideBeaconNetworkConfig(networkCfg) 83 } 84 } 85 86 func configureInteropConfig(cliCtx *cli.Context) { 87 genStateIsSet := cliCtx.IsSet(flags.InteropGenesisStateFlag.Name) 88 genTimeIsSet := cliCtx.IsSet(flags.InteropGenesisTimeFlag.Name) 89 numValsIsSet := cliCtx.IsSet(flags.InteropNumValidatorsFlag.Name) 90 votesIsSet := cliCtx.IsSet(flags.InteropMockEth1DataVotesFlag.Name) 91 92 if genStateIsSet || genTimeIsSet || numValsIsSet || votesIsSet { 93 bCfg := params.BeaconConfig() 94 bCfg.ConfigName = "interop" 95 params.OverrideBeaconConfig(bCfg) 96 } 97 }