Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions preset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package client

import _ "embed"
import "log"

import "gopkg.in/yaml.v3"

//go:embed presets/mainnet/phase0.yaml
var mainnetPhase0 []byte

//go:embed presets/mainnet/altair.yaml
var mainnetAltair []byte

//go:embed presets/mainnet/bellatrix.yaml
var mainnetBellatrix []byte

//go:embed presets/mainnet/capella.yaml
var mainnetCapella []byte

//go:embed presets/mainnet/deneb.yaml
var mainnetDeneb []byte

//go:embed presets/mainnet/electra.yaml
var mainnetElectra []byte

//go:embed presets/minimal/phase0.yaml
var minimalPhase0 []byte

//go:embed presets/minimal/altair.yaml
var minimalAltair []byte

//go:embed presets/minimal/bellatrix.yaml
var minimalBellatrix []byte

//go:embed presets/minimal/capella.yaml
var minimalCapella []byte

//go:embed presets/minimal/deneb.yaml
var minimalDeneb []byte

//go:embed presets/minimal/electra.yaml
var minimalElectra []byte

var (
MainnetPreset map[string]interface{}
MinimalPreset map[string]interface{}
)

func init() {
err := yaml.Unmarshal(minimalPhase0, &MinimalPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(minimalAltair, &MinimalPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(minimalBellatrix, &MinimalPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(minimalCapella, &MinimalPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(minimalDeneb, &MinimalPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(minimalElectra, &MinimalPreset)
if err != nil {
log.Fatal(err)
}

err = yaml.Unmarshal(mainnetPhase0, &MainnetPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(mainnetAltair, &MainnetPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(mainnetBellatrix, &MainnetPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(mainnetCapella, &MainnetPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(mainnetDeneb, &MainnetPreset)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(mainnetElectra, &MainnetPreset)
if err != nil {
log.Fatal(err)
}
}
14 changes: 14 additions & 0 deletions preset_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package client

import "testing"

func TestPresetInitialization(t *testing.T) {
t.Run("consensus-specs presets init", func(t *testing.T) {
if MainnetPreset == nil {
t.Error("MainnetConfig should be initialized")
}
if MinimalPreset == nil {
t.Error("MinimalConfig should be initialized")
}
})
}
24 changes: 24 additions & 0 deletions presets/mainnet/altair.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Mainnet preset - Altair

# Rewards and penalties
# ---------------------------------------------------------------
# 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) participants
SYNC_COMMITTEE_SIZE: 512
# 2**8 (= 256) epochs
EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 256

# Sync protocol
# ---------------------------------------------------------------
# 2**0 (= 1) participants
MIN_SYNC_COMMITTEE_PARTICIPANTS: 1
# SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD (= 32 * 256) epochs
UPDATE_TIMEOUT: 8192
21 changes: 21 additions & 0 deletions presets/mainnet/bellatrix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Mainnet preset - Bellatrix

# Rewards and penalties
# ---------------------------------------------------------------
# 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) bytes
MAX_BYTES_PER_TRANSACTION: 1073741824
# 2**20 (= 1,048,576) transactions
MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256) bytes
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32) bytes
MAX_EXTRA_DATA_BYTES: 32
16 changes: 16 additions & 0 deletions presets/mainnet/capella.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Mainnet preset - Capella

# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16) credential changes
MAX_BLS_TO_EXECUTION_CHANGES: 16

# Execution
# ---------------------------------------------------------------
# 2**4 (= 16) withdrawals
MAX_WITHDRAWALS_PER_PAYLOAD: 16

# Withdrawals processing
# ---------------------------------------------------------------
# 2**14 (= 16384) validators
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: 16384
16 changes: 16 additions & 0 deletions presets/mainnet/deneb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Mainnet preset - Deneb

# Execution
# ---------------------------------------------------------------
# 2**12 (= 4,096) blob commitments
MAX_BLOB_COMMITMENTS_PER_BLOCK: 4096

# Networking
# ---------------------------------------------------------------
# floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK) (= 4 + 1 + 12 = 17)
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 17

# Blob
# ---------------------------------------------------------------
# 2**12 (= 4,096) field elements
FIELD_ELEMENTS_PER_BLOB: 4096
50 changes: 50 additions & 0 deletions presets/mainnet/electra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Mainnet preset - Electra

# Gwei values
# ---------------------------------------------------------------
# 2**5 * 10**9 (= 32,000,000,000) Gwei
MIN_ACTIVATION_BALANCE: 32000000000
# 2**11 * 10**9 (= 2,048,000,000,000) Gwei
MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000

# Rewards and penalties
# ---------------------------------------------------------------
# 2**12 (= 4,096)
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096
# 2**12 (= 4,096)
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096

# State list lengths
# ---------------------------------------------------------------
# 2**27 (= 134,217,728) pending deposits
PENDING_DEPOSITS_LIMIT: 134217728
# 2**27 (= 134,217,728) pending partial withdrawals
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 134217728
# 2**18 (= 262,144) pending consolidations
PENDING_CONSOLIDATIONS_LIMIT: 262144

# Max operations per block
# ---------------------------------------------------------------
# 2**0 (= 1) attester slashings
MAX_ATTESTER_SLASHINGS_ELECTRA: 1
# 2**3 (= 8) attestations
MAX_ATTESTATIONS_ELECTRA: 8

# Execution
# ---------------------------------------------------------------
# 2**13 (= 8,192) deposit requests
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD: 8192
# 2**4 (= 16) withdrawal requests
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 16
# 2**1 (= 2) consolidation requests
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2

# Withdrawals processing
# ---------------------------------------------------------------
# 2**3 (= 8) pending withdrawals
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8

# Pending deposits processing
# ---------------------------------------------------------------
# 2**4 (= 16) pending deposits
MAX_PENDING_DEPOSITS_PER_EPOCH: 16
83 changes: 83 additions & 0 deletions presets/mainnet/phase0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Mainnet preset - Phase0

# Misc
# ---------------------------------------------------------------
# 2**6 (= 64) committees
MAX_COMMITTEES_PER_SLOT: 64
# 2**7 (= 128) committees
TARGET_COMMITTEE_SIZE: 128
# 2**11 (= 2,048) validators
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

# 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, 12 seconds
MIN_ATTESTATION_INCLUSION_DELAY: 1
# 2**5 (= 32) slots, 6.4 minutes
SLOTS_PER_EPOCH: 32
# 2**0 (= 1) epochs, 6.4 minutes
MIN_SEED_LOOKAHEAD: 1
# 2**2 (= 4) epochs, 25.6 minutes
MAX_SEED_LOOKAHEAD: 4
# 2**6 (= 64) epochs, ~6.8 hours
EPOCHS_PER_ETH1_VOTING_PERIOD: 64
# 2**13 (= 8,192) slots, ~27 hours
SLOTS_PER_HISTORICAL_ROOT: 8192
# 2**2 (= 4) epochs, 25.6 minutes
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4

# State list lengths
# ---------------------------------------------------------------
# 2**16 (= 65,536) epochs, ~0.8 years
EPOCHS_PER_HISTORICAL_VECTOR: 65536
# 2**13 (= 8,192) epochs, ~36 days
EPOCHS_PER_SLASHINGS_VECTOR: 8192
# 2**24 (= 16,777,216) historical roots, ~52,262 years
HISTORICAL_ROOTS_LIMIT: 16777216
# 2**40 (= 1,099,511,627,776) validator spots
VALIDATOR_REGISTRY_LIMIT: 1099511627776

# Rewards and penalties
# ---------------------------------------------------------------
# 2**6 (= 64)
BASE_REWARD_FACTOR: 64
# 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 Phase0 genesis)
MIN_SLASHING_PENALTY_QUOTIENT: 128
# 1 (lower safety margin at Phase0 genesis)
PROPORTIONAL_SLASHING_MULTIPLIER: 1

# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16) proposer slashings
MAX_PROPOSER_SLASHINGS: 16
# 2**1 (= 2) attester slashings
MAX_ATTESTER_SLASHINGS: 2
# 2**7 (= 128) attestations
MAX_ATTESTATIONS: 128
# 2**4 (= 16) deposits
MAX_DEPOSITS: 16
# 2**4 (= 16) voluntary exits
MAX_VOLUNTARY_EXITS: 16
24 changes: 24 additions & 0 deletions presets/minimal/altair.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Minimal preset - Altair

# Rewards and penalties
# ---------------------------------------------------------------
# 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
# ---------------------------------------------------------------
# [customized] 2**5 (= 32) participants
SYNC_COMMITTEE_SIZE: 32
# [customized] 2**3 (= 8) epochs
EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 8

# Sync protocol
# ---------------------------------------------------------------
# 2**0 (= 1) participants
MIN_SYNC_COMMITTEE_PARTICIPANTS: 1
# [customized] SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD (= 8 * 8) epochs
UPDATE_TIMEOUT: 64
21 changes: 21 additions & 0 deletions presets/minimal/bellatrix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Minimal preset - Bellatrix

# Rewards and penalties
# ---------------------------------------------------------------
# 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) bytes
MAX_BYTES_PER_TRANSACTION: 1073741824
# 2**20 (= 1,048,576) transactions
MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256) bytes
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32) bytes
MAX_EXTRA_DATA_BYTES: 32
16 changes: 16 additions & 0 deletions presets/minimal/capella.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Minimal preset - Capella

# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16) credential changes
MAX_BLS_TO_EXECUTION_CHANGES: 16

# Execution
# ---------------------------------------------------------------
# [customized] 2**2 (= 4) withdrawals
MAX_WITHDRAWALS_PER_PAYLOAD: 4

# Withdrawals processing
# ---------------------------------------------------------------
# [customized] 2**4 (= 16) validators
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: 16
Loading