mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 21:04:28 +00:00
Native support for Gnosis Beacon Chain network (#2931)
## Proposed Changes Add a new hardcoded spec for the Gnosis Beacon Chain. Ideally, official Lighthouse executables will be able to connect to the gnosis beacon chain from now on, using `--network gnosis` CLI option.
This commit is contained in:
24
consensus/types/presets/gnosis/altair.yaml
Normal file
24
consensus/types/presets/gnosis/altair.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
# Gnosis Beacon Chain preset - Altair
|
||||
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
# 3 * 2**24 (= 50,331,648)
|
||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR: 50331648
|
||||
# 2**6 (= 64)
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR: 64
|
||||
# 2
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR: 2
|
||||
|
||||
|
||||
# Sync committee
|
||||
# ---------------------------------------------------------------
|
||||
# 2**9 (= 512)
|
||||
SYNC_COMMITTEE_SIZE: 512
|
||||
# 2**8 (= 256)
|
||||
EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 512
|
||||
|
||||
|
||||
# Sync protocol
|
||||
# ---------------------------------------------------------------
|
||||
# 1
|
||||
MIN_SYNC_COMMITTEE_PARTICIPANTS: 1
|
||||
21
consensus/types/presets/gnosis/bellatrix.yaml
Normal file
21
consensus/types/presets/gnosis/bellatrix.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
# Gnosis Beacon Chain preset - Bellatrix
|
||||
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
# 2**24 (= 16,777,216)
|
||||
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX: 16777216
|
||||
# 2**5 (= 32)
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX: 32
|
||||
# 3
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX: 3
|
||||
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# 2**30 (= 1,073,741,824)
|
||||
MAX_BYTES_PER_TRANSACTION: 1073741824
|
||||
# 2**20 (= 1,048,576)
|
||||
MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
|
||||
# 2**8 (= 256)
|
||||
BYTES_PER_LOGS_BLOOM: 256
|
||||
# 2**5 (= 32)
|
||||
MAX_EXTRA_DATA_BYTES: 32
|
||||
94
consensus/types/presets/gnosis/phase0.yaml
Normal file
94
consensus/types/presets/gnosis/phase0.yaml
Normal file
@@ -0,0 +1,94 @@
|
||||
# Gnosis Beacon Chain preset - Phase0
|
||||
|
||||
# Misc
|
||||
# ---------------------------------------------------------------
|
||||
# 2**6 (= 64)
|
||||
MAX_COMMITTEES_PER_SLOT: 64
|
||||
# 2**7 (= 128)
|
||||
TARGET_COMMITTEE_SIZE: 128
|
||||
# 2**11 (= 2,048)
|
||||
MAX_VALIDATORS_PER_COMMITTEE: 2048
|
||||
# See issue 563
|
||||
SHUFFLE_ROUND_COUNT: 90
|
||||
# 4
|
||||
HYSTERESIS_QUOTIENT: 4
|
||||
# 1 (minus 0.25)
|
||||
HYSTERESIS_DOWNWARD_MULTIPLIER: 1
|
||||
# 5 (plus 1.25)
|
||||
HYSTERESIS_UPWARD_MULTIPLIER: 5
|
||||
|
||||
|
||||
# Fork Choice
|
||||
# ---------------------------------------------------------------
|
||||
# 2**3 (= 8)
|
||||
SAFE_SLOTS_TO_UPDATE_JUSTIFIED: 8
|
||||
|
||||
|
||||
# Gwei values
|
||||
# ---------------------------------------------------------------
|
||||
# 2**0 * 10**9 (= 1,000,000,000) Gwei
|
||||
MIN_DEPOSIT_AMOUNT: 1000000000
|
||||
# 2**5 * 10**9 (= 32,000,000,000) Gwei
|
||||
MAX_EFFECTIVE_BALANCE: 32000000000
|
||||
# 2**0 * 10**9 (= 1,000,000,000) Gwei
|
||||
EFFECTIVE_BALANCE_INCREMENT: 1000000000
|
||||
|
||||
|
||||
# Time parameters
|
||||
# ---------------------------------------------------------------
|
||||
# 2**0 (= 1) slots 5 seconds
|
||||
MIN_ATTESTATION_INCLUSION_DELAY: 1
|
||||
# 2**4 (= 16) slots 1.87 minutes
|
||||
SLOTS_PER_EPOCH: 16
|
||||
# 2**0 (= 1) epochs 1.87 minutes
|
||||
MIN_SEED_LOOKAHEAD: 1
|
||||
# 2**2 (= 4) epochs 7.47 minutes
|
||||
MAX_SEED_LOOKAHEAD: 4
|
||||
# 2**6 (= 64) epochs ~2 hours
|
||||
EPOCHS_PER_ETH1_VOTING_PERIOD: 64
|
||||
# 2**13 (= 8,192) slots ~15.9 hours
|
||||
SLOTS_PER_HISTORICAL_ROOT: 8192
|
||||
# 2**2 (= 4) epochs 7.47 minutes
|
||||
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4
|
||||
|
||||
|
||||
# State list lengths
|
||||
# ---------------------------------------------------------------
|
||||
# 2**16 (= 65,536) epochs ~85 days
|
||||
EPOCHS_PER_HISTORICAL_VECTOR: 65536
|
||||
# 2**13 (= 8,192) epochs ~10.6 days
|
||||
EPOCHS_PER_SLASHINGS_VECTOR: 8192
|
||||
# 2**24 (= 16,777,216) historical roots, ~15,243 years
|
||||
HISTORICAL_ROOTS_LIMIT: 16777216
|
||||
# 2**40 (= 1,099,511,627,776) validator spots
|
||||
VALIDATOR_REGISTRY_LIMIT: 1099511627776
|
||||
|
||||
|
||||
# Reward and penalty quotients
|
||||
# ---------------------------------------------------------------
|
||||
# 2**6 (= 64)
|
||||
BASE_REWARD_FACTOR: 25
|
||||
# 2**9 (= 512)
|
||||
WHISTLEBLOWER_REWARD_QUOTIENT: 512
|
||||
# 2**3 (= 8)
|
||||
PROPOSER_REWARD_QUOTIENT: 8
|
||||
# 2**26 (= 67,108,864)
|
||||
INACTIVITY_PENALTY_QUOTIENT: 67108864
|
||||
# 2**7 (= 128) (lower safety margin at Phase 0 genesis)
|
||||
MIN_SLASHING_PENALTY_QUOTIENT: 128
|
||||
# 1 (lower safety margin at Phase 0 genesis)
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER: 1
|
||||
|
||||
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
# 2**4 (= 16)
|
||||
MAX_PROPOSER_SLASHINGS: 16
|
||||
# 2**1 (= 2)
|
||||
MAX_ATTESTER_SLASHINGS: 2
|
||||
# 2**7 (= 128)
|
||||
MAX_ATTESTATIONS: 128
|
||||
# 2**4 (= 16)
|
||||
MAX_DEPOSITS: 16
|
||||
# 2**4 (= 16)
|
||||
MAX_VOLUNTARY_EXITS: 16
|
||||
@@ -596,6 +596,161 @@ impl ChainSpec {
|
||||
..ChainSpec::mainnet()
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a `ChainSpec` compatible with the Gnosis Beacon Chain specification.
|
||||
pub fn gnosis() -> Self {
|
||||
Self {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
genesis_slot: Slot::new(0),
|
||||
far_future_epoch: Epoch::new(u64::MAX),
|
||||
base_rewards_per_epoch: 4,
|
||||
deposit_contract_tree_depth: 32,
|
||||
|
||||
/*
|
||||
* Misc
|
||||
*/
|
||||
max_committees_per_slot: 64,
|
||||
target_committee_size: 128,
|
||||
min_per_epoch_churn_limit: 4,
|
||||
churn_limit_quotient: 4_096,
|
||||
shuffle_round_count: 90,
|
||||
min_genesis_active_validator_count: 4_096,
|
||||
min_genesis_time: 1638968400, // Dec 8, 2020
|
||||
hysteresis_quotient: 4,
|
||||
hysteresis_downward_multiplier: 1,
|
||||
hysteresis_upward_multiplier: 5,
|
||||
|
||||
/*
|
||||
* Gwei values
|
||||
*/
|
||||
min_deposit_amount: option_wrapper(|| {
|
||||
u64::checked_pow(2, 0)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
max_effective_balance: option_wrapper(|| {
|
||||
u64::checked_pow(2, 5)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
ejection_balance: option_wrapper(|| {
|
||||
u64::checked_pow(2, 4)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
effective_balance_increment: option_wrapper(|| {
|
||||
u64::checked_pow(2, 0)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
|
||||
/*
|
||||
* Initial Values
|
||||
*/
|
||||
genesis_fork_version: [0x00, 0x00, 0x00, 0x64],
|
||||
bls_withdrawal_prefix_byte: 0,
|
||||
|
||||
/*
|
||||
* Time parameters
|
||||
*/
|
||||
genesis_delay: 6000, // 100 minutes
|
||||
seconds_per_slot: 5,
|
||||
min_attestation_inclusion_delay: 1,
|
||||
min_seed_lookahead: Epoch::new(1),
|
||||
max_seed_lookahead: Epoch::new(4),
|
||||
min_epochs_to_inactivity_penalty: 4,
|
||||
min_validator_withdrawability_delay: Epoch::new(256),
|
||||
shard_committee_period: 256,
|
||||
|
||||
/*
|
||||
* Reward and penalty quotients
|
||||
*/
|
||||
base_reward_factor: 25,
|
||||
whistleblower_reward_quotient: 512,
|
||||
proposer_reward_quotient: 8,
|
||||
inactivity_penalty_quotient: u64::checked_pow(2, 26).expect("pow does not overflow"),
|
||||
min_slashing_penalty_quotient: 128,
|
||||
proportional_slashing_multiplier: 1,
|
||||
|
||||
/*
|
||||
* Signature domains
|
||||
*/
|
||||
domain_beacon_proposer: 0,
|
||||
domain_beacon_attester: 1,
|
||||
domain_randao: 2,
|
||||
domain_deposit: 3,
|
||||
domain_voluntary_exit: 4,
|
||||
domain_selection_proof: 5,
|
||||
domain_aggregate_and_proof: 6,
|
||||
|
||||
/*
|
||||
* Fork choice
|
||||
*/
|
||||
safe_slots_to_update_justified: 8,
|
||||
proposer_score_boost: None,
|
||||
|
||||
/*
|
||||
* Eth1
|
||||
*/
|
||||
eth1_follow_distance: 1024,
|
||||
seconds_per_eth1_block: 6,
|
||||
deposit_chain_id: 100,
|
||||
deposit_network_id: 100,
|
||||
deposit_contract_address: "0B98057eA310F4d31F2a452B414647007d1645d9"
|
||||
.parse()
|
||||
.expect("chain spec deposit contract address"),
|
||||
|
||||
/*
|
||||
* Altair hard fork params
|
||||
*/
|
||||
inactivity_penalty_quotient_altair: option_wrapper(|| {
|
||||
u64::checked_pow(2, 24)?.checked_mul(3)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
min_slashing_penalty_quotient_altair: u64::checked_pow(2, 6)
|
||||
.expect("pow does not overflow"),
|
||||
proportional_slashing_multiplier_altair: 2,
|
||||
inactivity_score_bias: 4,
|
||||
inactivity_score_recovery_rate: 16,
|
||||
min_sync_committee_participants: 1,
|
||||
epochs_per_sync_committee_period: Epoch::new(512),
|
||||
domain_sync_committee: 7,
|
||||
domain_sync_committee_selection_proof: 8,
|
||||
domain_contribution_and_proof: 9,
|
||||
altair_fork_version: [0x01, 0x00, 0x00, 0x64],
|
||||
altair_fork_epoch: Some(Epoch::new(256)),
|
||||
|
||||
/*
|
||||
* Merge hard fork params
|
||||
*/
|
||||
inactivity_penalty_quotient_bellatrix: u64::checked_pow(2, 24)
|
||||
.expect("pow does not overflow"),
|
||||
min_slashing_penalty_quotient_bellatrix: u64::checked_pow(2, 5)
|
||||
.expect("pow does not overflow"),
|
||||
proportional_slashing_multiplier_bellatrix: 3,
|
||||
bellatrix_fork_version: [0x02, 0x00, 0x00, 0x64],
|
||||
bellatrix_fork_epoch: None,
|
||||
terminal_total_difficulty: Uint256::MAX
|
||||
.checked_sub(Uint256::from(2u64.pow(10)))
|
||||
.expect("subtraction does not overflow")
|
||||
// Add 1 since the spec declares `2**256 - 2**10` and we use
|
||||
// `Uint256::MAX` which is `2*256- 1`.
|
||||
.checked_add(Uint256::one())
|
||||
.expect("addition does not overflow"),
|
||||
terminal_block_hash: Hash256::zero(),
|
||||
terminal_block_hash_activation_epoch: Epoch::new(u64::MAX),
|
||||
|
||||
/*
|
||||
* Network specific
|
||||
*/
|
||||
boot_nodes: vec![],
|
||||
network_id: 100, // Gnosis Chain network id
|
||||
attestation_propagation_slot_range: 32,
|
||||
attestation_subnet_count: 64,
|
||||
random_subnets_per_validator: 1,
|
||||
maximum_gossip_clock_disparity_millis: 500,
|
||||
target_aggregators_per_committee: 16,
|
||||
epochs_per_random_subnet_subscription: 256,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ChainSpec {
|
||||
@@ -746,6 +901,7 @@ impl Config {
|
||||
match self.preset_base.as_str() {
|
||||
"minimal" => Some(EthSpecId::Minimal),
|
||||
"mainnet" => Some(EthSpecId::Mainnet),
|
||||
"gnosis" => Some(EthSpecId::Gnosis),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ use crate::*;
|
||||
use safe_arith::SafeArith;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz_types::typenum::{
|
||||
Unsigned, U0, U1024, U1073741824, U1099511627776, U128, U16, U16777216, U2, U2048, U32, U4,
|
||||
U4096, U512, U64, U65536, U8, U8192,
|
||||
bit::B0, UInt, Unsigned, U0, U1024, U1048576, U1073741824, U1099511627776, U128, U16,
|
||||
U16777216, U2, U2048, U256, U32, U4, U4096, U512, U625, U64, U65536, U8, U8192,
|
||||
};
|
||||
use std::fmt::{self, Debug};
|
||||
use std::str::FromStr;
|
||||
|
||||
use ssz_types::typenum::{bit::B0, UInt, U1048576, U256, U625};
|
||||
pub type U5000 = UInt<UInt<UInt<U625, B0>, B0>, B0>; // 625 * 8 = 5000
|
||||
|
||||
const MAINNET: &str = "mainnet";
|
||||
const MINIMAL: &str = "minimal";
|
||||
pub const GNOSIS: &str = "gnosis";
|
||||
|
||||
/// Used to identify one of the `EthSpec` instances defined here.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -21,6 +21,7 @@ const MINIMAL: &str = "minimal";
|
||||
pub enum EthSpecId {
|
||||
Mainnet,
|
||||
Minimal,
|
||||
Gnosis,
|
||||
}
|
||||
|
||||
impl FromStr for EthSpecId {
|
||||
@@ -30,6 +31,7 @@ impl FromStr for EthSpecId {
|
||||
match s {
|
||||
MAINNET => Ok(EthSpecId::Mainnet),
|
||||
MINIMAL => Ok(EthSpecId::Minimal),
|
||||
GNOSIS => Ok(EthSpecId::Gnosis),
|
||||
_ => Err(format!("Unknown eth spec: {}", s)),
|
||||
}
|
||||
}
|
||||
@@ -40,6 +42,7 @@ impl fmt::Display for EthSpecId {
|
||||
let s = match self {
|
||||
EthSpecId::Mainnet => MAINNET,
|
||||
EthSpecId::Minimal => MINIMAL,
|
||||
EthSpecId::Gnosis => GNOSIS,
|
||||
};
|
||||
write!(f, "{}", s)
|
||||
}
|
||||
@@ -317,3 +320,46 @@ impl EthSpec for MinimalEthSpec {
|
||||
EthSpecId::Minimal
|
||||
}
|
||||
}
|
||||
|
||||
/// Gnosis Beacon Chain specifications.
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct GnosisEthSpec;
|
||||
|
||||
impl EthSpec for GnosisEthSpec {
|
||||
type JustificationBitsLength = U4;
|
||||
type SubnetBitfieldLength = U64;
|
||||
type MaxValidatorsPerCommittee = U2048;
|
||||
type GenesisEpoch = U0;
|
||||
type SlotsPerEpoch = U16;
|
||||
type EpochsPerEth1VotingPeriod = U64;
|
||||
type SlotsPerHistoricalRoot = U8192;
|
||||
type EpochsPerHistoricalVector = U65536;
|
||||
type EpochsPerSlashingsVector = U8192;
|
||||
type HistoricalRootsLimit = U16777216;
|
||||
type ValidatorRegistryLimit = U1099511627776;
|
||||
type MaxProposerSlashings = U16;
|
||||
type MaxAttesterSlashings = U2;
|
||||
type MaxAttestations = U128;
|
||||
type MaxDeposits = U16;
|
||||
type MaxVoluntaryExits = U16;
|
||||
type SyncCommitteeSize = U512;
|
||||
type SyncCommitteeSubnetCount = U4;
|
||||
type MaxBytesPerTransaction = U1073741824; // 1,073,741,824
|
||||
type MaxTransactionsPerPayload = U1048576; // 1,048,576
|
||||
type BytesPerLogsBloom = U256;
|
||||
type GasLimitDenominator = U1024;
|
||||
type MinGasLimit = U5000;
|
||||
type MaxExtraDataBytes = U32;
|
||||
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
|
||||
type MaxPendingAttestations = U2048; // 128 max attestations * 16 slots per epoch
|
||||
type SlotsPerEth1VotingPeriod = U1024; // 64 epochs * 16 slots per epoch
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
ChainSpec::gnosis()
|
||||
}
|
||||
|
||||
fn spec_name() -> EthSpecId {
|
||||
EthSpecId::Gnosis
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ impl BellatrixPreset {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::{MainnetEthSpec, MinimalEthSpec};
|
||||
use crate::{GnosisEthSpec, MainnetEthSpec, MinimalEthSpec};
|
||||
use serde::de::DeserializeOwned;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
@@ -226,6 +226,11 @@ mod test {
|
||||
preset_test::<MainnetEthSpec>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gnosis_presets_consistent() {
|
||||
preset_test::<GnosisEthSpec>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn minimal_presets_consistent() {
|
||||
preset_test::<MinimalEthSpec>();
|
||||
|
||||
Reference in New Issue
Block a user