mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 13:58:09 -05:00
Normalize ETH to Gwei client-wide (#1381)
This commit is contained in:
committed by
terence tsao
parent
821e7148f8
commit
45e9eda43c
@@ -32,7 +32,7 @@ func generateTestGenesisStateAndBlock(
|
||||
depositInput := &pb.DepositInput{
|
||||
Pubkey: pubkey,
|
||||
}
|
||||
balance := params.BeaconConfig().MaxDeposit * params.BeaconConfig().Gwei
|
||||
balance := params.BeaconConfig().MaxDepositInGwei
|
||||
depositData, err := b.EncodeDepositData(depositInput, balance, time.Now().Unix())
|
||||
if err != nil {
|
||||
t.Fatalf("Could not encode deposit: %v", err)
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestBaseReward(t *testing.T) {
|
||||
b uint64
|
||||
}{
|
||||
{0, 0},
|
||||
{params.BeaconConfig().MinDepositinGwei, 61},
|
||||
{params.BeaconConfig().MinDepositInGwei, 61},
|
||||
{30 * 1e9, 1853},
|
||||
{params.BeaconConfig().MaxDepositInGwei, 1976},
|
||||
{40 * 1e9, 1976},
|
||||
|
||||
@@ -285,7 +285,7 @@ func TestHeadAttestationsNotOk(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWinningRootOk(t *testing.T) {
|
||||
defaultBalance := params.BeaconConfig().MaxDeposit
|
||||
defaultBalance := params.BeaconConfig().MaxDepositInGwei
|
||||
|
||||
ShardCommittees := []*pb.ShardCommitteeArray{
|
||||
{ArrayShardCommittee: []*pb.ShardCommittee{
|
||||
@@ -375,7 +375,7 @@ func TestWinningRootOutOfBound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttestingValidatorsOk(t *testing.T) {
|
||||
defaultBalance := params.BeaconConfig().MaxDeposit
|
||||
defaultBalance := params.BeaconConfig().MaxDepositInGwei
|
||||
|
||||
ShardCommittees := []*pb.ShardCommitteeArray{
|
||||
{ArrayShardCommittee: []*pb.ShardCommittee{
|
||||
|
||||
@@ -30,7 +30,7 @@ func InitialValidatorRegistry() []*pb.ValidatorRecord {
|
||||
pubkey := hashutil.Hash([]byte{byte(i)})
|
||||
validators[i] = &pb.ValidatorRecord{
|
||||
ExitSlot: config.FarFutureSlot,
|
||||
Balance: config.MaxDeposit * config.Gwei,
|
||||
Balance: config.MaxDepositInGwei,
|
||||
Pubkey: pubkey[:],
|
||||
RandaoCommitmentHash32: randaoReveal[:],
|
||||
}
|
||||
@@ -260,8 +260,8 @@ func NewRegistryDeltaChainTip(
|
||||
// """
|
||||
// return min(state.validator_balances[idx], MAX_DEPOSIT * GWEI_PER_ETH)
|
||||
func EffectiveBalance(state *pb.BeaconState, idx uint32) uint64 {
|
||||
if state.ValidatorBalances[idx] > config.MaxDeposit*config.Gwei {
|
||||
return config.MaxDeposit * config.Gwei
|
||||
if state.ValidatorBalances[idx] > config.MaxDepositInGwei {
|
||||
return config.MaxDepositInGwei
|
||||
}
|
||||
return state.ValidatorBalances[idx]
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ func TestShardCommitteesAtSlot_OutOfBounds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEffectiveBalance(t *testing.T) {
|
||||
defaultBalance := params.BeaconConfig().MaxDeposit * params.BeaconConfig().Gwei
|
||||
defaultBalance := params.BeaconConfig().MaxDepositInGwei
|
||||
|
||||
tests := []struct {
|
||||
a uint64
|
||||
|
||||
@@ -32,10 +32,8 @@ type BeaconChainConfig struct {
|
||||
// Deposit contract constants.
|
||||
DepositContractAddress []byte // DepositContractAddress is the address of the deposit contract in PoW chain.
|
||||
DepositContractTreeDepth uint64 // Depth of the Merkle trie of deposits in the validator deposit contract on the PoW chain.
|
||||
MaxDeposit uint64 // MaxDeposit is the maximal amount of ETH a validator can send to the deposit contract at once.
|
||||
MaxDepositInGwei uint64 // MaxDepositInGwei is the maximal amount of Gwei a validator can send to the deposit contract at once.
|
||||
MinDeposit uint64 // MinDeposit is the minimal amount of ETH a validator can send to the deposit contract at once.
|
||||
MinDepositinGwei uint64 // MinDepositinGwei is the maximal amount of Gwei a validator can send to the deposit contract at once.
|
||||
MinDepositInGwei uint64 // MinDepositInGwei is the maximal amount of Gwei a validator can send to the deposit contract at once.
|
||||
|
||||
// Initial value constants.
|
||||
GenesisForkVersion uint64 // GenesisForkVersion is used to track fork version between state transitions.
|
||||
@@ -100,10 +98,8 @@ var defaultBeaconConfig = &BeaconChainConfig{
|
||||
|
||||
// Deposit contract constants.
|
||||
DepositContractTreeDepth: 32,
|
||||
MaxDeposit: 32,
|
||||
MaxDepositInGwei: 32 * 1e9,
|
||||
MinDeposit: 1,
|
||||
MinDepositinGwei: 1 * 1e9,
|
||||
MinDepositInGwei: 1 * 1e9,
|
||||
|
||||
// Initial value constants.
|
||||
GenesisForkVersion: 0,
|
||||
@@ -159,9 +155,8 @@ var demoBeaconConfig = &BeaconChainConfig{
|
||||
|
||||
// Deposit contract constants.
|
||||
DepositContractTreeDepth: defaultBeaconConfig.DepositContractTreeDepth,
|
||||
MaxDeposit: defaultBeaconConfig.MaxDeposit,
|
||||
MaxDepositInGwei: defaultBeaconConfig.MaxDepositInGwei,
|
||||
MinDeposit: defaultBeaconConfig.MinDeposit,
|
||||
MinDepositInGwei: defaultBeaconConfig.MinDepositInGwei,
|
||||
|
||||
// Initial value constants.
|
||||
GenesisForkVersion: defaultBeaconConfig.GenesisForkVersion,
|
||||
@@ -187,7 +182,7 @@ var demoBeaconConfig = &BeaconChainConfig{
|
||||
|
||||
// Max operations per block constants.
|
||||
MaxExits: defaultBeaconConfig.MaxExits,
|
||||
MaxDeposits: defaultBeaconConfig.MaxDeposit,
|
||||
MaxDeposits: defaultBeaconConfig.MaxDeposits,
|
||||
MaxAttestations: defaultBeaconConfig.MaxAttestations,
|
||||
MaxProposerSlashings: defaultBeaconConfig.MaxProposerSlashings,
|
||||
MaxCasperSlashings: defaultBeaconConfig.MaxCasperSlashings,
|
||||
|
||||
Reference in New Issue
Block a user