Align Constant Variables With Latest Spec Changes (#989)

* add todo for 712

* update constants from latest spec
This commit is contained in:
terence tsao 2018-11-28 14:46:04 -08:00 committed by Raul Jordan
parent 647ccf99a2
commit 13d805f398
3 changed files with 45 additions and 39 deletions

View File

@ -346,7 +346,7 @@ func CopyValidators(validatorSet []*pb.ValidatorRecord) []*pb.ValidatorRecord {
// it exits the validator if it's below.
func CheckValidatorMinDeposit(validatorSet []*pb.ValidatorRecord, currentSlot uint64) []*pb.ValidatorRecord {
for index, validator := range validatorSet {
MinDepositInGWei := params.BeaconConfig().MinDeposit * params.BeaconConfig().Gwei
MinDepositInGWei := params.BeaconConfig().MinOnlineDepositSize * params.BeaconConfig().Gwei
isValidatorActive := validator.Status == uint64(params.Active)
if validator.Balance < MinDepositInGWei && isValidatorActive {
validatorSet[index] = ExitValidator(validator, currentSlot, false)

View File

@ -401,7 +401,7 @@ func TestChangeValidators(t *testing.T) {
}
func TestValidatorMinDeposit(t *testing.T) {
minDeposit := params.BeaconConfig().MinDeposit * params.BeaconConfig().Gwei
minDeposit := params.BeaconConfig().MinOnlineDepositSize * params.BeaconConfig().Gwei
currentSlot := uint64(99)
validators := []*pb.ValidatorRecord{
{Status: uint64(params.Active), Balance: uint64(minDeposit) + 1},

View File

@ -19,34 +19,36 @@ type ValidatorSetDeltaFlags int
// BeaconChainConfig contains configs for node to participate in beacon chain.
type BeaconChainConfig struct {
ShardCount uint64 // ShardCount is the fixed number of shards in Ethereum 2.0.
DepositSize uint64 // DepositSize is how much a validator has deposited in Eth.
MinDeposit uint64 // MinDeposit is the minimal amount of Ether a validator needs to participate.
Gwei uint64 // Gwei is the denomination of Gwei in Ether.
DepositContractAddress common.Address // DepositContractAddress is the address of validator registration contract in PoW chain.
TargetCommitteeSize uint64 // TargetCommitteeSize is the minimal number of validator needs to be in a committee.
GenesisTime time.Time // GenesisTime used by the protocol.
SlotDuration uint64 // SlotDuration is how many seconds are in a single slot.
SyncPollingInterval int64 // SyncPollingInterval queries network nodes for sync status.
CycleLength uint64 // CycleLength is one beacon chain cycle length in slots.
MinValidatorSetChangeInterval uint64 // MinValidatorSetChangeInterval is the slots needed before validator set changes.
RandaoSlotsPerLayer uint64 // RandaoSlotsPerLayer defines how many randao slot a proposer can peel off once.
SqrtExpDropTime uint64 // SqrtEDropTime is a constant to reflect time it takes to cut offline validators deposits by 39.4%.
MinWithdrawalPeriod uint64 // MinWithdrawalPeriod defines the slots between a validator exit and validator balance being withdrawable.
WithdrawalsPerCycle uint64 // WithdrawalsPerCycle defines how many withdrawals can go through per cycle.
CollectivePenaltyCalculationPeriod uint64 // CollectivePenaltyCalculationPeriod defines the period length for an aggregated penalty amount.
DeletionPeriod uint64 // DeletionPeriod define the period length of when validator is deleted from the pool.
ShardPersistentCommitteeChangePeriod uint64 // ShardPersistentCommitteeChangePeriod defines how often shard committee gets shuffled.
BaseRewardQuotient uint64 // BaseRewardQuotient is used to calculate validator per-slot interest rate.
MaxValidatorChurnQuotient uint64 // MaxValidatorChurnQuotient defines the quotient how many validators can change each time.
POWHashVotingPeriod uint64 // POWHashVotingPeriod defines how often PoW hash gets updated in beacon node.
POWContractMerkleTreeDepth uint64 // POWContractMerkleTreeDepth defines the depth of PoW contract merkle tree.
MaxSpecialsPerBlock uint64 // MaxSpecialsPerBlock defines the max number special records permitted per beacon block.
LogOutMessage string // LogOutMessage is the message a validator submits to log out.
InitialForkVersion uint32 // InitialForkVersion is used to track fork version between state transitions.
SimulatedBlockRandao [32]byte // SimulatedBlockRandao is a RANDAO seed stubbed in side simulated block to advance local beacon chain.
ModuloBias uint64 // ModuloBias is the upper bound of validator shuffle function. Can shuffle validator lists up to that size.
BootstrappedValidatorsCount uint64 // BootstrappedValidatorsCount is the number of validators we seed to start beacon chain.
ShardCount uint64 // ShardCount is the fixed number of shards in Ethereum 2.0.
DepositSize uint64 // DepositSize is how much a validator has deposited in Eth.
MinTopUpSize uint64 // MinTopUpSize is the minimal amount of Ether a validator can top up.
MinOnlineDepositSize uint64 // MinOnlineDepositSize is the minimal amount of Ether a validator needs to participate.
Gwei uint64 // Gwei is the denomination of Gwei in Ether.
DepositContractAddress common.Address // DepositContractAddress is the address of validator registration contract in PoW chain.
DepositsForChainStart uint64 // DepositsForChainStart defines how many deposits needed to start off beacon chain.
TargetCommitteeSize uint64 // TargetCommitteeSize is the minimal number of validator needs to be in a committee.
SlotDuration uint64 // SlotDuration is how many seconds are in a single slot.
CycleLength uint64 // CycleLength is one beacon chain cycle length in slots.
MinValidatorSetChangeInterval uint64 // MinValidatorSetChangeInterval is the slots needed before validator set changes.
ShardPersistentCommitteeChangePeriod uint64 // ShardPersistentCommitteeChangePeriod defines how often shard committee gets shuffled.
MinAttestationInclusionDelay uint64 // MinAttestationInclusionDelay defines how long validator has to wait to include attestation for beacon block.
SqrtExpDropTime uint64 // SqrtEDropTime is a constant to reflect time it takes to cut offline validators deposits by 39.4%.
WithdrawalsPerCycle uint64 // WithdrawalsPerCycle defines how many withdrawals can go through per cycle.
MinWithdrawalPeriod uint64 // MinWithdrawalPeriod defines the slots between a validator exit and validator balance being withdrawable.
DeletionPeriod uint64 // DeletionPeriod define the period length of when validator is deleted from the pool.
CollectivePenaltyCalculationPeriod uint64 // CollectivePenaltyCalculationPeriod defines the period length for an aggregated penalty amount.
PowReceiptRootVotingPeriod uint64 // PowReceiptRootVotingPeriod defines how often PoW hash gets updated in beacon node.
SlashingWhistlerBlowerRewardDenominator uint64 // SlashingWhistlerBlowerRewardDenominator defines how the reward denominator of whistler blower.
BaseRewardQuotient uint64 // BaseRewardQuotient is used to calculate validator per-slot interest rate.
IncluderRewardShareQuotient uint64 // IncluderRewardShareQuotient defines the reward quotient for proposer.
MaxValidatorChurnQuotient uint64 // MaxValidatorChurnQuotient defines the quotient how many validators can change each time.
POWContractMerkleTreeDepth uint64 // POWContractMerkleTreeDepth defines the depth of PoW contract merkle tree.
InitialForkVersion uint32 // InitialForkVersion is used to track fork version between state transitions.
SimulatedBlockRandao [32]byte // SimulatedBlockRandao is a RANDAO seed stubbed in side simulated block to advance local beacon chain.
ModuloBias uint64 // ModuloBias is the upper bound of validator shuffle function. Can shuffle validator lists up to that size.
BootstrappedValidatorsCount uint64 // BootstrappedValidatorsCount is the number of validators we seed to start beacon chain.
SyncPollingInterval int64 // SyncPollingInterval queries network nodes for sync status.
GenesisTime time.Time // GenesisTime used by the protocol.
}
// ShardChainConfig contains configs for node to participate in shard chains.
@ -58,37 +60,39 @@ type ShardChainConfig struct {
var defaultBeaconConfig = &BeaconChainConfig{
ShardCount: 1024,
DepositSize: 32,
MinDeposit: 16,
MinTopUpSize: 1,
MinOnlineDepositSize: 16,
Gwei: 1e9,
DepositsForChainStart: 16384,
TargetCommitteeSize: uint64(256),
GenesisTime: time.Date(2018, 9, 0, 0, 0, 0, 0, time.UTC),
SlotDuration: uint64(16),
SyncPollingInterval: 16 * 4, // Query nodes over the network every 4 slots for sync status.
CycleLength: uint64(64),
MinValidatorSetChangeInterval: uint64(256),
RandaoSlotsPerLayer: uint64(4096),
MinAttestationInclusionDelay: uint64(4),
SqrtExpDropTime: uint64(65536),
MinWithdrawalPeriod: uint64(4096),
WithdrawalsPerCycle: uint64(8),
WithdrawalsPerCycle: uint64(4),
BaseRewardQuotient: uint64(32768),
MaxValidatorChurnQuotient: uint64(32),
InitialForkVersion: 0,
ModuloBias: 16777216 - 1,
BootstrappedValidatorsCount: 16384,
SyncPollingInterval: 16 * 4, // Query nodes over the network every 4 slots for sync status.
GenesisTime: time.Date(2018, 9, 0, 0, 0, 0, 0, time.UTC),
}
var demoBeaconConfig = &BeaconChainConfig{
ShardCount: 5,
DepositSize: 32,
MinDeposit: 16,
MinTopUpSize: 1,
MinOnlineDepositSize: 16,
Gwei: 1e9,
DepositsForChainStart: 16384,
TargetCommitteeSize: uint64(3),
GenesisTime: time.Now(),
SlotDuration: uint64(2),
SyncPollingInterval: 2 * 4, // Query nodes over the network every 4 slots for sync status.
CycleLength: uint64(5),
MinValidatorSetChangeInterval: uint64(15),
RandaoSlotsPerLayer: uint64(5),
MinAttestationInclusionDelay: uint64(4),
SqrtExpDropTime: uint64(65536),
MinWithdrawalPeriod: uint64(20),
WithdrawalsPerCycle: uint64(2),
@ -97,6 +101,8 @@ var demoBeaconConfig = &BeaconChainConfig{
InitialForkVersion: 0,
ModuloBias: 16777216 - 1,
SimulatedBlockRandao: [32]byte{'S', 'I', 'M', 'U', 'L', 'A', 'T', 'E', 'R'},
SyncPollingInterval: 2 * 4, // Query nodes over the network every 4 slots for sync status.
GenesisTime: time.Now(),
}
var defaultShardConfig = &ShardChainConfig{