From 77b1cc1c813f01e7c8bf07fce54f21b374d63bc2 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Wed, 13 Feb 2019 20:04:58 +0530 Subject: [PATCH] Simplify Config (#1579) * clean up config * lint --- shared/params/config.go | 74 ++++++++--------------------------------- 1 file changed, 14 insertions(+), 60 deletions(-) diff --git a/shared/params/config.go b/shared/params/config.go index 6b8051ec9..081d604f3 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -152,65 +152,6 @@ var defaultBeaconConfig = &BeaconChainConfig{ MaxNumLog2Validators: 24, } -var demoBeaconConfig = &BeaconChainConfig{ - // Misc constant. - ShardCount: 5, - TargetCommitteeSize: 3, - EjectionBalance: defaultBeaconConfig.EjectionBalance, - MaxBalanceChurnQuotient: defaultBeaconConfig.MaxBalanceChurnQuotient, - BeaconChainShardNumber: defaultBeaconConfig.BeaconChainShardNumber, - MaxIndicesPerSlashableVote: defaultBeaconConfig.MaxIndicesPerSlashableVote, - LatestBlockRootsLength: defaultBeaconConfig.LatestBlockRootsLength, - LatestRandaoMixesLength: defaultBeaconConfig.LatestRandaoMixesLength, - LatestPenalizedExitLength: defaultBeaconConfig.LatestPenalizedExitLength, - LatestIndexRootsLength: defaultBeaconConfig.LatestIndexRootsLength, - MaxWithdrawalsPerEpoch: defaultBeaconConfig.MaxWithdrawalsPerEpoch, - - // Deposit contract constants. - DepositContractTreeDepth: defaultBeaconConfig.DepositContractTreeDepth, - MaxDepositAmount: defaultBeaconConfig.MaxDepositAmount, - MinDepositAmount: defaultBeaconConfig.MinDepositAmount, - - // Initial value constants. - GenesisForkVersion: defaultBeaconConfig.GenesisForkVersion, - GenesisSlot: defaultBeaconConfig.GenesisSlot, - GenesisEpoch: defaultBeaconConfig.GenesisEpoch, - GenesisStartShard: defaultBeaconConfig.GenesisStartShard, - FarFutureEpoch: defaultBeaconConfig.FarFutureEpoch, - ZeroHash: defaultBeaconConfig.ZeroHash, - EmptySignature: defaultBeaconConfig.EmptySignature, - - // Time parameter constants. - SlotDuration: 2, - MinAttestationInclusionDelay: defaultBeaconConfig.MinAttestationInclusionDelay, - EpochLength: defaultBeaconConfig.EpochLength, - SeedLookahead: defaultBeaconConfig.SeedLookahead, - EntryExitDelay: defaultBeaconConfig.EntryExitDelay, - Eth1DataVotingPeriod: defaultBeaconConfig.Eth1DataVotingPeriod, - Eth1FollowDistance: defaultBeaconConfig.Eth1FollowDistance, - - // Reward and penalty quotients constants. - BaseRewardQuotient: defaultBeaconConfig.BaseRewardQuotient, - WhistlerBlowerRewardQuotient: defaultBeaconConfig.WhistlerBlowerRewardQuotient, - IncluderRewardQuotient: defaultBeaconConfig.IncluderRewardQuotient, - InactivityPenaltyQuotient: defaultBeaconConfig.InactivityPenaltyQuotient, - - // Max operations per block constants. - MaxExits: defaultBeaconConfig.MaxExits, - MaxDeposits: defaultBeaconConfig.MaxDeposits, - MaxAttestations: defaultBeaconConfig.MaxAttestations, - MaxProposerSlashings: defaultBeaconConfig.MaxProposerSlashings, - MaxAttesterSlashings: defaultBeaconConfig.MaxAttesterSlashings, - - // Prysm constants. - DepositsForChainStart: defaultBeaconConfig.DepositsForChainStart, - RandBytes: defaultBeaconConfig.RandBytes, - SyncPollingInterval: 2 * 4, // Query nodes over the network every 4 slots for sync status. - GenesisTime: time.Now(), - MaxNumLog2Validators: defaultBeaconConfig.MaxNumLog2Validators, - SimulatedBlockRandao: [32]byte{'S', 'I', 'M', 'U', 'L', 'A', 'T', 'O', 'R'}, -} - var defaultShardConfig = &ShardChainConfig{ ChunkSize: uint64(256), MaxShardBlockSize: uint64(32768), @@ -231,6 +172,19 @@ func BeaconConfig() *BeaconChainConfig { return beaconConfig } +// DemoBeaconConfig retrieves the demo beacon chain config. +func DemoBeaconConfig() *BeaconChainConfig { + demoConfig := *defaultBeaconConfig + demoConfig.ShardCount = 5 + demoConfig.TargetCommitteeSize = 3 + demoConfig.SlotDuration = 2 + demoConfig.SyncPollingInterval = 2 * 4 // Query nodes over the network every 4 slots for sync status. + demoConfig.GenesisTime = time.Now() + demoConfig.SimulatedBlockRandao = [32]byte{'S', 'I', 'M', 'U', 'L', 'A', 'T', 'O', 'R'} + + return &demoConfig +} + // ShardConfig retrieves shard chain config. func ShardConfig() *ShardChainConfig { return shardConfig @@ -252,7 +206,7 @@ func DemoContractConfig(depositsReq *big.Int, minDeposit *big.Int, maxDeposit *b // UseDemoBeaconConfig for beacon chain services. func UseDemoBeaconConfig() { - beaconConfig = demoBeaconConfig + beaconConfig = DemoBeaconConfig() } // OverrideBeaconConfig by replacing the config. The preferred pattern is to