def config( shard_count, target_committee_size, max_balance_churn_quotient, max_indices_per_slashable_vote, max_exit_dequeues_per_epoch, shuffle_round_count, slots_per_historical_root, deposit_contract_address, deposit_contract_tree_depth, min_deposit_amount, max_deposit_amount, fork_choice_balance_increment, ejection_balance, genesis_fork_version, genesis_slot, genesis_epoch, genesis_start_shard, bls_withdrawal_prefix_byte, seconds_per_slot, min_attestation_inclusion_delay, slots_per_epoch, min_seed_lookahead, activation_exit_delay, epochs_per_eth1_voting_period, min_validator_withdrawability_delay, persistent_committee_period, latest_active_index_roots_length, latest_randao_mixes_length, latest_slashed_exit_length, base_reward_quotient, whistleblower_reward_quotient, attestation_inclusion_reward_quotient, inactivity_penalty_quotient, min_penalty_quotient, max_proposer_slashings, max_attester_slashings, max_attestations, max_deposits, max_voluntary_exits, max_transfers): return Eth2Config( SHARD_COUNT=shard_count, TARGET_COMMITTEE_SIZE=target_committee_size, MAX_BALANCE_CHURN_QUOTIENT=max_balance_churn_quotient, MAX_INDICES_PER_SLASHABLE_VOTE=max_indices_per_slashable_vote, MAX_EXIT_DEQUEUES_PER_EPOCH=max_exit_dequeues_per_epoch, SHUFFLE_ROUND_COUNT=shuffle_round_count, SLOTS_PER_HISTORICAL_ROOT=slots_per_historical_root, DEPOSIT_CONTRACT_ADDRESS=deposit_contract_address, DEPOSIT_CONTRACT_TREE_DEPTH=deposit_contract_tree_depth, MIN_DEPOSIT_AMOUNT=min_deposit_amount, MAX_DEPOSIT_AMOUNT=max_deposit_amount, FORK_CHOICE_BALANCE_INCREMENT=fork_choice_balance_increment, EJECTION_BALANCE=ejection_balance, GENESIS_FORK_VERSION=genesis_fork_version, GENESIS_SLOT=genesis_slot, GENESIS_EPOCH=genesis_epoch, GENESIS_START_SHARD=genesis_start_shard, BLS_WITHDRAWAL_PREFIX_BYTE=bls_withdrawal_prefix_byte, SECONDS_PER_SLOT=seconds_per_slot, MIN_ATTESTATION_INCLUSION_DELAY=min_attestation_inclusion_delay, SLOTS_PER_EPOCH=slots_per_epoch, MIN_SEED_LOOKAHEAD=min_seed_lookahead, ACTIVATION_EXIT_DELAY=activation_exit_delay, EPOCHS_PER_ETH1_VOTING_PERIOD=epochs_per_eth1_voting_period, MIN_VALIDATOR_WITHDRAWABILITY_DELAY=min_validator_withdrawability_delay, PERSISTENT_COMMITTEE_PERIOD=persistent_committee_period, LATEST_ACTIVE_INDEX_ROOTS_LENGTH=latest_active_index_roots_length, LATEST_RANDAO_MIXES_LENGTH=latest_randao_mixes_length, LATEST_SLASHED_EXIT_LENGTH=latest_slashed_exit_length, BASE_REWARD_QUOTIENT=base_reward_quotient, WHISTLEBLOWER_REWARD_QUOTIENT=whistleblower_reward_quotient, ATTESTATION_INCLUSION_REWARD_QUOTIENT= attestation_inclusion_reward_quotient, INACTIVITY_PENALTY_QUOTIENT=inactivity_penalty_quotient, MIN_PENALTY_QUOTIENT=min_penalty_quotient, MAX_PROPOSER_SLASHINGS=max_proposer_slashings, MAX_ATTESTER_SLASHINGS=max_attester_slashings, MAX_ATTESTATIONS=max_attestations, MAX_DEPOSITS=max_deposits, MAX_VOLUNTARY_EXITS=max_voluntary_exits, MAX_TRANSFERS=max_transfers, )
def generate_config_by_dict(dict_config): dict_config['DEPOSIT_CONTRACT_ADDRESS'] = b'\x00' * 20 for key in list(dict_config): if 'DOMAIN_' in key: # DOMAIN is defined in SignatureDomain dict_config.pop(key, None) return Eth2Config(**dict_config)
def generate_config_by_dict(dict_config: Dict[str, Any]) -> Eth2Config: filtered_keys = ( "DOMAIN_", "ETH1_FOLLOW_DISTANCE", "TARGET_AGGREGATORS_PER_COMMITTEE", "RANDOM_SUBNETS_PER_VALIDATOR", "EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION", # Phase 1 "MAX_EPOCHS_PER_CROSSLINK", "EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS", "EPOCHS_PER_CUSTODY_PERIOD", "CUSTODY_PERIOD_TO_RANDAO_PADDING", "SHARD_SLOTS_PER_BEACON_SLOT", "EPOCHS_PER_SHARD_PERIOD", "PHASE_1_FORK_EPOCH", "PHASE_1_FORK_SLOT", ) return Eth2Config(**assoc( keyfilter(lambda name: all(key not in name for key in filtered_keys), dict_config), "GENESIS_EPOCH", compute_epoch_at_slot(dict_config["GENESIS_SLOT"], dict_config["SLOTS_PER_EPOCH"]), ))
def config(shard_count, target_committee_size, max_indices_per_attestation, min_per_epoch_churn_limit, churn_limit_quotient, shuffle_round_count, min_deposit_amount, max_effective_balance, ejection_balance, effective_balance_increment, genesis_slot, genesis_epoch, bls_withdrawal_prefix, seconds_per_slot, min_attestation_inclusion_delay, slots_per_epoch, min_seed_lookahead, activation_exit_delay, slots_per_eth1_voting_period, slots_per_historical_root, min_validator_withdrawability_delay, persistent_committee_period, max_epochs_per_crosslink, min_epochs_to_inactivity_penalty, epochs_per_historical_vector, epochs_per_slashed_balances_vector, base_reward_factor, whistleblowing_reward_quotient, proposer_reward_quotient, inactivity_penalty_quotient, min_slashing_penalty_quotient, max_proposer_slashings, max_attester_slashings, max_attestations, max_deposits, max_voluntary_exits, max_transfers, genesis_active_validator_count): # adding some config validity conditions here # abstract out into the config object? assert shard_count >= slots_per_epoch return Eth2Config( SHARD_COUNT=shard_count, TARGET_COMMITTEE_SIZE=target_committee_size, MAX_INDICES_PER_ATTESTATION=max_indices_per_attestation, MIN_PER_EPOCH_CHURN_LIMIT=min_per_epoch_churn_limit, CHURN_LIMIT_QUOTIENT=churn_limit_quotient, SHUFFLE_ROUND_COUNT=shuffle_round_count, MIN_DEPOSIT_AMOUNT=min_deposit_amount, MAX_EFFECTIVE_BALANCE=max_effective_balance, EJECTION_BALANCE=ejection_balance, EFFECTIVE_BALANCE_INCREMENT=effective_balance_increment, GENESIS_SLOT=genesis_slot, GENESIS_EPOCH=genesis_epoch, BLS_WITHDRAWAL_PREFIX=bls_withdrawal_prefix, SECONDS_PER_SLOT=seconds_per_slot, MIN_ATTESTATION_INCLUSION_DELAY=min_attestation_inclusion_delay, SLOTS_PER_EPOCH=slots_per_epoch, MIN_SEED_LOOKAHEAD=min_seed_lookahead, ACTIVATION_EXIT_DELAY=activation_exit_delay, SLOTS_PER_ETH1_VOTING_PERIOD=slots_per_eth1_voting_period, SLOTS_PER_HISTORICAL_ROOT=slots_per_historical_root, MIN_VALIDATOR_WITHDRAWABILITY_DELAY=min_validator_withdrawability_delay, PERSISTENT_COMMITTEE_PERIOD=persistent_committee_period, MAX_EPOCHS_PER_CROSSLINK=max_epochs_per_crosslink, MIN_EPOCHS_TO_INACTIVITY_PENALTY=min_epochs_to_inactivity_penalty, EPOCHS_PER_HISTORICAL_VECTOR=epochs_per_historical_vector, EPOCHS_PER_SLASHED_BALANCES_VECTOR=epochs_per_slashed_balances_vector, BASE_REWARD_FACTOR=base_reward_factor, WHISTLEBLOWING_REWARD_QUOTIENT=whistleblowing_reward_quotient, PROPOSER_REWARD_QUOTIENT=proposer_reward_quotient, INACTIVITY_PENALTY_QUOTIENT=inactivity_penalty_quotient, MIN_SLASHING_PENALTY_QUOTIENT=min_slashing_penalty_quotient, MAX_PROPOSER_SLASHINGS=max_proposer_slashings, MAX_ATTESTER_SLASHINGS=max_attester_slashings, MAX_ATTESTATIONS=max_attestations, MAX_DEPOSITS=max_deposits, MAX_VOLUNTARY_EXITS=max_voluntary_exits, MAX_TRANSFERS=max_transfers, GENESIS_ACTIVE_VALIDATOR_COUNT=genesis_active_validator_count, )
def from_genesis_config(cls, config_profile: str) -> 'BeaconChainConfig': """ Construct an instance of ``cls`` reading the genesis configuration data under the local data directory. """ if config_profile == "mainnet": beacon_chain_class = BeaconChain else: beacon_chain_class = SkeletonLakeChain try: with open(_get_eth2_genesis_config_file_path( config_profile)) as config_file: genesis_config = json.load(config_file) except FileNotFoundError as e: raise Exception("unable to load genesis config: %s", e) eth2_config = Eth2Config.from_formatted_dict( genesis_config["eth2_config"]) # NOTE: have to ``override_lengths`` before we can parse the ``BeaconState`` override_lengths(eth2_config) genesis_state = from_formatted_dict(genesis_config["genesis_state"], BeaconState) genesis_validator_key_map = load_genesis_key_map( genesis_config["genesis_validator_key_pairs"]) return cls(genesis_state, eth2_config, genesis_validator_key_map, beacon_chain_class=beacon_chain_class)
def _update_config_if_needed(cls, config: Eth2Config) -> Eth2Config: """ Some ad-hoc work arounds... - Increase the count of allowed Transfer operations, even though we start with 0. """ if cls.name == "transfer": return config._replace(MAX_TRANSFERS=1) return config
def generate_config_by_dict(dict_config: Dict[str, Any]) -> Eth2Config: filtered_keys = ("DOMAIN_", "EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS") return Eth2Config(**assoc( keyfilter(lambda name: all(key not in name for key in filtered_keys), dict_config), "GENESIS_EPOCH", compute_epoch_of_slot(dict_config["GENESIS_SLOT"], dict_config["SLOTS_PER_EPOCH"]), ))
def _create_genesis_config( config_profile: Literal["minimal", "mainnet"], eth2_config: Eth2Config, genesis_state: BeaconState, key_pairs: Iterable[Dict[str, str]], ) -> Dict[str, Any]: return { "profile": config_profile, "eth2_config": eth2_config.to_formatted_dict(), "genesis_state_root": encode_hex(genesis_state.hash_tree_root), "genesis_validator_key_pairs": key_pairs, "genesis_state": to_formatted_dict(genesis_state), }
def generate_config_by_dict(dict_config: Dict[str, Any]) -> Eth2Config: filtered_keys = ( "DOMAIN_", "ETH1_FOLLOW_DISTANCE", "TARGET_AGGREGATORS_PER_COMMITTEE", "RANDOM_SUBNETS_PER_VALIDATOR", "EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION", # Phase 1 "MAX_EPOCHS_PER_CROSSLINK", "EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS", "EPOCHS_PER_CUSTODY_PERIOD", "CUSTODY_PERIOD_TO_RANDAO_PADDING", "SHARD_SLOTS_PER_BEACON_SLOT", "EPOCHS_PER_SHARD_PERIOD", "PHASE_1_FORK_EPOCH", "PHASE_1_GENESIS_SLOT", "PHASE_1_FORK_SLOT", "PHASE_1_FORK_VERSION", "SECONDS_PER_ETH1_BLOCK", "INITIAL_ACTIVE_SHARDS", "MAX_SHARDS", "ONLINE_SHARDS", "ONLINE_PERIOD", "LIGHT_CLIENT_COMMITTEE_SIZE", "LIGHT_CLIENT_COMMITTEE_PERIOD", "SHARD_BLOCK_CHUNK_SIZE", "MAX_SHARD_BLOCK_CHUNKS", "TARGET_SHARD_BLOCK_SIZE", "SHARD_BLOCK_OFFSETS", "MAX_SHARD_BLOCKS_PER_ATTESTATION", "MAX_GASPRICE", "MIN_GASPRICE", "GASPRICE_ADJUSTMENT_COEFFICIENT", "RANDAO_PENALTY_EPOCH", "RANDAO_PENALTY_EPOCHS", "MAX_REVEAL_LATENESS_DECREMENT", "MAX_CUSTODY_KEY_REVEALS", "MAX_EARLY_DERIVED_SECRET_REVEALS", "MAX_CUSTODY_SLASHINGS", "EARLY_DERIVED_SECRET_REVEAL_SLOT_REWARD_MULTIPLE", "EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS", "EPOCHS_PER_CUSTODY_PERIOD", "CUSTODY_PERIOD_TO_RANDAO_PADDING", "MINOR_REWARD_QUOTIENT", ) return Eth2Config( **keyfilter(lambda name: all(key not in name for key in filtered_keys), dict_config))
def generate_config_by_dict(dict_config: Dict[str, Any]) -> Eth2Config: config_without_domains = keyfilter(lambda name: "DOMAIN_" not in name, dict_config) config_without_phase_1 = keyfilter( lambda name: "EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS" not in name, config_without_domains, ) return Eth2Config(**assoc( config_without_phase_1, "GENESIS_EPOCH", compute_epoch_of_slot( dict_config['GENESIS_SLOT'], dict_config['SLOTS_PER_EPOCH'], )))
def main_validator() -> None: logger = _setup_logging() parser = parse_cli_args() arguments = parser.parse_args() trinity_config = load_trinity_config_from_parser_args( parser, arguments, APP_IDENTIFIER_VALIDATOR_CLIENT, (ValidatorClientAppConfig,) ) # NOTE: we do not want the rest of the functionality in # ``trinity.bootstrap.ensure_data_dir_is_initialized create_dir_if_missing(trinity_config.data_dir) validator_client_app_config = trinity_config.get_app_config( ValidatorClientAppConfig ) root_dir = validator_client_app_config.root_dir create_dir_if_missing(root_dir) try: genesis_config = _load_genesis_config_at( validator_client_app_config.genesis_config_path ) except FileNotFoundError: genesis_time = Timestamp(int(time.time())) genesis_config = generate_genesis_config("minimal", genesis_time) eth2_config = Eth2Config.from_formatted_dict(genesis_config["eth2_config"]) override_lengths(eth2_config) key_pairs = load_genesis_key_map(genesis_config["genesis_validator_key_pairs"]) genesis_state = from_formatted_dict(genesis_config["genesis_state"], BeaconState) slots_per_epoch = Slot(eth2_config.SLOTS_PER_EPOCH) seconds_per_slot = eth2_config.SECONDS_PER_SLOT genesis_time = genesis_state.genesis_time config = Config( key_pairs=key_pairs, root_data_dir=root_dir, slots_per_epoch=slots_per_epoch, seconds_per_slot=seconds_per_slot, genesis_time=genesis_time, ) # NOTE: we deviate from the multiprocess-driven Component-based # application machinery here until said machinery is more stable # with respect to boot, shutdown and general concurrent control. trio.run(arguments.func, logger, config, arguments)
def from_genesis_config(cls) -> 'BeaconChainConfig': """ Construct an instance of ``cls`` reading the genesis configuration data under the local data directory. """ try: with open(_get_eth2_genesis_config_file_path()) as config_file: genesis_config = json.load(config_file) except FileNotFoundError: genesis_config = generate_genesis_config("minimal") eth2_config = Eth2Config.from_formatted_dict(genesis_config["eth2_config"]) # NOTE: have to ``override_lengths`` before we can parse the ``BeaconState`` override_lengths(eth2_config) genesis_state = from_formatted_dict(genesis_config["genesis_state"], BeaconState) genesis_validator_key_map = load_genesis_key_map( genesis_config["genesis_validator_key_pairs"] ) return cls(genesis_state, eth2_config, genesis_validator_key_map)
def generate_config_by_dict(dict_config: Dict[str, Any]) -> Eth2Config: filtered_keys = ( "DOMAIN_", # TODO: Fork choice rule "SAFE_SLOTS_TO_UPDATE_JUSTIFIED", # Phase 1 "MAX_EPOCHS_PER_CROSSLINK", "EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS", "EPOCHS_PER_CUSTODY_PERIOD", "CUSTODY_PERIOD_TO_RANDAO_PADDING", "SHARD_SLOTS_PER_BEACON_SLOT", "EPOCHS_PER_SHARD_PERIOD", "PHASE_1_FORK_EPOCH", "PHASE_1_FORK_SLOT", ) return Eth2Config(**assoc( keyfilter(lambda name: all(key not in name for key in filtered_keys), dict_config), "GENESIS_EPOCH", compute_epoch_at_slot(dict_config["GENESIS_SLOT"], dict_config["SLOTS_PER_EPOCH"]), ))
SERENITY_CONFIG = Eth2Config( # Misc SHARD_COUNT=2**10, # (= 1,024) shards TARGET_COMMITTEE_SIZE=2**7, # (= 128) validators MAX_BALANCE_CHURN_QUOTIENT=2**5, # (= 32) MAX_INDICES_PER_SLASHABLE_VOTE=2**12, # (= 4,096) votes MAX_EXIT_DEQUEUES_PER_EPOCH=2**2, # (= 4) SHUFFLE_ROUND_COUNT=90, # Deposit contract DEPOSIT_CONTRACT_ADDRESS=ZERO_ADDRESS, # TBD DEPOSIT_CONTRACT_TREE_DEPTH=2**5, # (= 32) # Gwei values MIN_DEPOSIT_AMOUNT=Gwei(2**0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei MAX_DEPOSIT_AMOUNT=Gwei(2**5 * GWEI_PER_ETH), # (= 32,000,000,00) Gwei FORK_CHOICE_BALANCE_INCREMENT=Gwei(2**0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei EJECTION_BALANCE=Gwei(2**4 * GWEI_PER_ETH), # (= 16,000,000,000) Gwei # Initial values GENESIS_FORK_VERSION=0, GENESIS_SLOT=GENESIS_SLOT, GENESIS_EPOCH=slot_to_epoch(GENESIS_SLOT, SLOTS_PER_EPOCH), GENESIS_START_SHARD=Shard(0), BLS_WITHDRAWAL_PREFIX_BYTE=b'\x00', # Time parameters SECONDS_PER_SLOT=Second(6), # seconds MIN_ATTESTATION_INCLUSION_DELAY=2**2, # (= 4) slots SLOTS_PER_EPOCH=SLOTS_PER_EPOCH, # (= 64) slots MIN_SEED_LOOKAHEAD=2**0, # (= 1) epochs ACTIVATION_EXIT_DELAY=2**2, # (= 4) epochs EPOCHS_PER_ETH1_VOTING_PERIOD=2**4, # (= 16) epochs MIN_VALIDATOR_WITHDRAWABILITY_DELAY=2**8, # (= 256) epochs PERSISTENT_COMMITTEE_PERIOD=2**11, # (= 2,048) epochs # State list lengths SLOTS_PER_HISTORICAL_ROOT=2**13, # (= 8,192) slots LATEST_ACTIVE_INDEX_ROOTS_LENGTH=2**13, # (= 8,192) epochs LATEST_RANDAO_MIXES_LENGTH=2**13, # (= 8,192) epochs LATEST_SLASHED_EXIT_LENGTH=2**13, # (= 8,192) epochs # Reward and penalty quotients BASE_REWARD_QUOTIENT=2**10, # (= 1,024) WHISTLEBLOWER_REWARD_QUOTIENT=2**9, # (= 512) ATTESTATION_INCLUSION_REWARD_QUOTIENT=2**3, # (= 8) INACTIVITY_PENALTY_QUOTIENT=2**24, # (= 16,777,216) MIN_PENALTY_QUOTIENT=2**5, # Max operations per block MAX_PROPOSER_SLASHINGS=2**4, # (= 16) MAX_ATTESTER_SLASHINGS=2**0, # (= 1) MAX_ATTESTATIONS=2**7, # (= 128) MAX_DEPOSITS=2**4, # (= 16) MAX_VOLUNTARY_EXITS=2**4, # (= 16) MAX_TRANSFERS=2**4, # (= 16) )
def config( max_committees_per_slot, target_committee_size, max_validators_per_committee, min_per_epoch_churn_limit, churn_limit_quotient, shuffle_round_count, min_genesis_active_validator_count, min_genesis_time, min_deposit_amount, max_effective_balance, ejection_balance, effective_balance_increment, genesis_slot, genesis_epoch, bls_withdrawal_prefix, seconds_per_slot, min_attestation_inclusion_delay, slots_per_epoch, min_seed_lookahead, max_seed_lookahead, slots_per_eth1_voting_period, slots_per_historical_root, min_validator_withdrawability_delay, persistent_committee_period, min_epochs_to_inactivity_penalty, epochs_per_historical_vector, epochs_per_slashings_vector, historical_roots_limit, validator_registry_limit, base_reward_factor, whistleblower_reward_quotient, proposer_reward_quotient, inactivity_penalty_quotient, min_slashing_penalty_quotient, max_proposer_slashings, max_attester_slashings, max_attestations, max_deposits, max_voluntary_exits, safe_slots_to_update_justified, deposit_contract_address, ): return Eth2Config( MAX_COMMITTEES_PER_SLOT=max_committees_per_slot, TARGET_COMMITTEE_SIZE=target_committee_size, MAX_VALIDATORS_PER_COMMITTEE=max_validators_per_committee, MIN_PER_EPOCH_CHURN_LIMIT=min_per_epoch_churn_limit, CHURN_LIMIT_QUOTIENT=churn_limit_quotient, SHUFFLE_ROUND_COUNT=shuffle_round_count, MIN_GENESIS_ACTIVE_VALIDATOR_COUNT=min_genesis_active_validator_count, MIN_GENESIS_TIME=min_genesis_time, MIN_DEPOSIT_AMOUNT=min_deposit_amount, MAX_EFFECTIVE_BALANCE=max_effective_balance, EJECTION_BALANCE=ejection_balance, EFFECTIVE_BALANCE_INCREMENT=effective_balance_increment, GENESIS_SLOT=genesis_slot, GENESIS_EPOCH=genesis_epoch, BLS_WITHDRAWAL_PREFIX=bls_withdrawal_prefix, SECONDS_PER_SLOT=seconds_per_slot, MIN_ATTESTATION_INCLUSION_DELAY=min_attestation_inclusion_delay, SLOTS_PER_EPOCH=slots_per_epoch, MIN_SEED_LOOKAHEAD=min_seed_lookahead, MAX_SEED_LOOKAHEAD=max_seed_lookahead, SLOTS_PER_ETH1_VOTING_PERIOD=slots_per_eth1_voting_period, SLOTS_PER_HISTORICAL_ROOT=slots_per_historical_root, MIN_VALIDATOR_WITHDRAWABILITY_DELAY=min_validator_withdrawability_delay, PERSISTENT_COMMITTEE_PERIOD=persistent_committee_period, MIN_EPOCHS_TO_INACTIVITY_PENALTY=min_epochs_to_inactivity_penalty, EPOCHS_PER_HISTORICAL_VECTOR=epochs_per_historical_vector, EPOCHS_PER_SLASHINGS_VECTOR=epochs_per_slashings_vector, HISTORICAL_ROOTS_LIMIT=historical_roots_limit, VALIDATOR_REGISTRY_LIMIT=validator_registry_limit, BASE_REWARD_FACTOR=base_reward_factor, WHISTLEBLOWER_REWARD_QUOTIENT=whistleblower_reward_quotient, PROPOSER_REWARD_QUOTIENT=proposer_reward_quotient, INACTIVITY_PENALTY_QUOTIENT=inactivity_penalty_quotient, MIN_SLASHING_PENALTY_QUOTIENT=min_slashing_penalty_quotient, MAX_PROPOSER_SLASHINGS=max_proposer_slashings, MAX_ATTESTER_SLASHINGS=max_attester_slashings, MAX_ATTESTATIONS=max_attestations, MAX_DEPOSITS=max_deposits, MAX_VOLUNTARY_EXITS=max_voluntary_exits, SAFE_SLOTS_TO_UPDATE_JUSTIFIED=safe_slots_to_update_justified, DEPOSIT_CONTRACT_ADDRESS=deposit_contract_address, )
MINIMAL_SERENITY_CONFIG = Eth2Config( # Misc SHARD_COUNT=8, TARGET_COMMITTEE_SIZE=4, MAX_VALIDATORS_PER_COMMITTEE=4096, MIN_PER_EPOCH_CHURN_LIMIT=4, CHURN_LIMIT_QUOTIENT=65536, SHUFFLE_ROUND_COUNT=10, # Genesis MIN_GENESIS_ACTIVE_VALIDATOR_COUNT=64, MIN_GENESIS_TIME=1578009600, # (= Jan 3, 2020) # Gwei values MIN_DEPOSIT_AMOUNT=Gwei(2 ** 0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei MAX_EFFECTIVE_BALANCE=Gwei(2 ** 5 * GWEI_PER_ETH), # (= 32,000,000,00) Gwei EJECTION_BALANCE=Gwei(2 ** 4 * GWEI_PER_ETH), # (= 16,000,000,000) Gwei EFFECTIVE_BALANCE_INCREMENT=Gwei(2 ** 0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei # Initial values GENESIS_SLOT=Slot(0), GENESIS_EPOCH=Epoch(0), BLS_WITHDRAWAL_PREFIX=0, # Time parameters SECONDS_PER_SLOT=Second(6), # seconds MIN_ATTESTATION_INCLUSION_DELAY=2 ** 0, # (= 1) slots SLOTS_PER_EPOCH=8, MIN_SEED_LOOKAHEAD=2 ** 0, # (= 1) epochs ACTIVATION_EXIT_DELAY=2 ** 2, # (= 4) epochs SLOTS_PER_ETH1_VOTING_PERIOD=16, SLOTS_PER_HISTORICAL_ROOT=64, MIN_VALIDATOR_WITHDRAWABILITY_DELAY=256, PERSISTENT_COMMITTEE_PERIOD=2 ** 11, # (= 2,048) epochs MAX_EPOCHS_PER_CROSSLINK=4, MIN_EPOCHS_TO_INACTIVITY_PENALTY=4, # State list lengths EPOCHS_PER_HISTORICAL_VECTOR=64, EPOCHS_PER_SLASHINGS_VECTOR=64, HISTORICAL_ROOTS_LIMIT=2 ** 24, VALIDATOR_REGISTRY_LIMIT=2 ** 40, # Reward and penalty quotients BASE_REWARD_FACTOR=2 ** 6, # (= 64) WHISTLEBLOWER_REWARD_QUOTIENT=2 ** 9, # (= 512) PROPOSER_REWARD_QUOTIENT=2 ** 3, INACTIVITY_PENALTY_QUOTIENT=2 ** 25, # (= 33,554,432) MIN_SLASHING_PENALTY_QUOTIENT=2 ** 5, # Max operations per block MAX_PROPOSER_SLASHINGS=2 ** 4, # (= 16) MAX_ATTESTER_SLASHINGS=2 ** 0, # (= 1) MAX_ATTESTATIONS=2 ** 7, # (= 128) MAX_DEPOSITS=2 ** 4, # (= 16) MAX_VOLUNTARY_EXITS=2 ** 4, # (= 16) MAX_TRANSFERS=0, # Deposit contract DEPOSIT_CONTRACT_ADDRESS=decode_hex( "0x1234567890123456789012345678901234567890" ), # TBD )
def generate_config_by_dict(dict_config): for key in list(dict_config): if 'DOMAIN_' in key: # DOMAIN is defined in SignatureDomain dict_config.pop(key, None) return Eth2Config(**dict_config)
SERENITY_CONFIG = Eth2Config( # Misc MAX_COMMITTEES_PER_SLOT=2**6, # (= 64) committees TARGET_COMMITTEE_SIZE=2**7, # (= 128) validators MAX_VALIDATORS_PER_COMMITTEE=2**11, # (= 2,048) validators MIN_PER_EPOCH_CHURN_LIMIT=2**2, CHURN_LIMIT_QUOTIENT=2**16, SHUFFLE_ROUND_COUNT=90, HYSTERESIS_QUOTIENT=4, HYSTERESIS_DOWNWARD_MULTIPLIER=1, HYSTERESIS_UPWARD_MULTIPLIER=5, # Genesis MIN_GENESIS_ACTIVE_VALIDATOR_COUNT=2**14, MIN_GENESIS_TIME=1578009600, # (= Jan 3, 2020) # Gwei values MIN_DEPOSIT_AMOUNT=Gwei(2**0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei MAX_EFFECTIVE_BALANCE=Gwei(2**5 * GWEI_PER_ETH), # (= 32,000,000,00) Gwei EJECTION_BALANCE=Gwei(2**4 * GWEI_PER_ETH), # (= 16,000,000,000) Gwei EFFECTIVE_BALANCE_INCREMENT=Gwei(2**0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei # Initial values GENESIS_FORK_VERSION=Version(b"\x00" * 4), BLS_WITHDRAWAL_PREFIX=b"\x00", # Time parameters GENESIS_DELAY=Second(172800), SECONDS_PER_SLOT=Second(12), # seconds MIN_ATTESTATION_INCLUSION_DELAY=2**0, # (= 1) slots SLOTS_PER_EPOCH=2**5, # (= 32) slots MIN_SEED_LOOKAHEAD=2**0, # (= 1) epochs MAX_SEED_LOOKAHEAD=2**2, # (= 4) epochs SLOTS_PER_HISTORICAL_ROOT=2**13, # (= 8,192) slots MIN_VALIDATOR_WITHDRAWABILITY_DELAY=2**8, # (= 256) epochs SHARD_COMMITTEE_PERIOD=2**8, # (= 256) epochs MIN_EPOCHS_TO_INACTIVITY_PENALTY=2**2, # State list lengths EPOCHS_PER_ETH1_VOTING_PERIOD=32, EPOCHS_PER_HISTORICAL_VECTOR=2**16, EPOCHS_PER_SLASHINGS_VECTOR=2**13, HISTORICAL_ROOTS_LIMIT=2**24, VALIDATOR_REGISTRY_LIMIT=2**40, # Reward and penalty quotients BASE_REWARD_FACTOR=2**6, # (= 64) WHISTLEBLOWER_REWARD_QUOTIENT=2**9, # (= 512) PROPOSER_REWARD_QUOTIENT=2**3, INACTIVITY_PENALTY_QUOTIENT=2**24, # (= 16,777,216) MIN_SLASHING_PENALTY_QUOTIENT=2**5, # Max operations per block MAX_PROPOSER_SLASHINGS=2**4, # (= 16) MAX_ATTESTER_SLASHINGS=2**1, # (= 2) MAX_ATTESTATIONS=2**7, # (= 128) MAX_DEPOSITS=2**4, # (= 16) MAX_VOLUNTARY_EXITS=2**4, # (= 16) # Fork choice SAFE_SLOTS_TO_UPDATE_JUSTIFIED=8, # Deposit contract DEPOSIT_CONTRACT_ADDRESS=decode_hex( "0x1234567890123456789012345678901234567890"), # TBD )
SERENITY_CONFIG = Eth2Config( # Misc SHARD_COUNT=2**10, # (= 1,024) shards TARGET_COMMITTEE_SIZE=2**7, # (= 128) validators MAX_INDICES_PER_ATTESTATION=2**12, # (= 4,096) votes MIN_PER_EPOCH_CHURN_LIMIT=2**2, CHURN_LIMIT_QUOTIENT=2**16, SHUFFLE_ROUND_COUNT=90, # Gwei values MIN_DEPOSIT_AMOUNT=Gwei(2**0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei MAX_EFFECTIVE_BALANCE=Gwei(2**5 * GWEI_PER_ETH), # (= 32,000,000,00) Gwei EJECTION_BALANCE=Gwei(2**4 * GWEI_PER_ETH), # (= 16,000,000,000) Gwei EFFECTIVE_BALANCE_INCREMENT=Gwei(2**0 * GWEI_PER_ETH), # (= 1,000,000,000) Gwei # Initial values GENESIS_SLOT=Slot(0), GENESIS_EPOCH=Epoch(0), BLS_WITHDRAWAL_PREFIX=0, # Time parameters SECONDS_PER_SLOT=Second(6), # seconds MIN_ATTESTATION_INCLUSION_DELAY=2**0, # (= 1) slots SLOTS_PER_EPOCH=2**6, # (= 64) slots MIN_SEED_LOOKAHEAD=2**0, # (= 1) epochs ACTIVATION_EXIT_DELAY=2**2, # (= 4) epochs SLOTS_PER_ETH1_VOTING_PERIOD=2**10, # (= 16) epochs SLOTS_PER_HISTORICAL_ROOT=2**13, # (= 8,192) slots MIN_VALIDATOR_WITHDRAWABILITY_DELAY=2**8, # (= 256) epochs PERSISTENT_COMMITTEE_PERIOD=2**11, # (= 2,048) epochs MAX_EPOCHS_PER_CROSSLINK=2**6, MIN_EPOCHS_TO_INACTIVITY_PENALTY=2**2, # State list lengths EPOCHS_PER_HISTORICAL_VECTOR=2**16, EPOCHS_PER_SLASHED_BALANCES_VECTOR=2**13, # Reward and penalty quotients BASE_REWARD_FACTOR=2**6, # (= 64) WHISTLEBLOWING_REWARD_QUOTIENT=2**9, # (= 512) PROPOSER_REWARD_QUOTIENT=2**3, INACTIVITY_PENALTY_QUOTIENT=2**25, # (= 33,554,432) MIN_SLASHING_PENALTY_QUOTIENT=2**5, # Max operations per block MAX_PROPOSER_SLASHINGS=2**4, # (= 16) MAX_ATTESTER_SLASHINGS=2**0, # (= 1) MAX_ATTESTATIONS=2**7, # (= 128) MAX_DEPOSITS=2**4, # (= 16) MAX_VOLUNTARY_EXITS=2**4, # (= 16) MAX_TRANSFERS=0, # Genesis GENESIS_ACTIVE_VALIDATOR_COUNT=2**16, )