Skip to content

Commit

Permalink
Add quotes to u64 in types
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Sep 18, 2020
1 parent b6768fe commit a3e2281
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions consensus/types/src/aggregate_and_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tree_hash_derive::TreeHash;
#[serde(bound = "T: EthSpec")]
pub struct AggregateAndProof<T: EthSpec> {
/// The index of the validator that created the attestation.
#[serde(with = "serde_utils::quoted_u64")]
pub aggregator_index: u64,
/// The aggregate attestation.
pub aggregate: Attestation<T>,
Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/attestation_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use tree_hash_derive::TreeHash;
)]
pub struct AttestationData {
pub slot: Slot,
#[serde(with = "serde_utils::quoted_u64")]
pub index: u64,

// LMD GHOST vote
Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/attestation_duty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ pub struct AttestationDuty {
/// The total number of attesters in the committee.
pub committee_len: usize,
/// The committee count at `attestation_slot`.
#[serde(with = "serde_utils::quoted_u64")]
pub committees_at_slot: u64,
}
1 change: 1 addition & 0 deletions consensus/types/src/beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tree_hash_derive::TreeHash;
#[serde(bound = "T: EthSpec")]
pub struct BeaconBlock<T: EthSpec> {
pub slot: Slot,
#[serde(with = "serde_utils::quoted_u64")]
pub proposer_index: u64,
pub parent_root: Hash256,
pub state_root: Hash256,
Expand Down
38 changes: 38 additions & 0 deletions consensus/types/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,41 +446,70 @@ mod tests {
#[serde(default)]
pub struct YamlConfig {
// ChainSpec
#[serde(with = "serde_utils::quoted_u64")]
far_future_epoch: u64,
#[serde(with = "serde_utils::quoted_u64")]
base_rewards_per_epoch: u64,
#[serde(with = "serde_utils::quoted_u64")]
deposit_contract_tree_depth: u64,
max_committees_per_slot: usize,
target_committee_size: usize,
#[serde(with = "serde_utils::quoted_u64")]
min_per_epoch_churn_limit: u64,
#[serde(with = "serde_utils::quoted_u64")]
churn_limit_quotient: u64,
shuffle_round_count: u8,
#[serde(with = "serde_utils::quoted_u64")]
min_genesis_active_validator_count: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_genesis_time: u64,
#[serde(with = "serde_utils::quoted_u64")]
genesis_delay: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_deposit_amount: u64,
#[serde(with = "serde_utils::quoted_u64")]
max_effective_balance: u64,
#[serde(with = "serde_utils::quoted_u64")]
ejection_balance: u64,
#[serde(with = "serde_utils::quoted_u64")]
effective_balance_increment: u64,
#[serde(with = "serde_utils::quoted_u64")]
hysteresis_quotient: u64,
#[serde(with = "serde_utils::quoted_u64")]
hysteresis_downward_multiplier: u64,
#[serde(with = "serde_utils::quoted_u64")]
hysteresis_upward_multiplier: u64,
#[serde(with = "serde_utils::quoted_u64")]
genesis_slot: u64,
#[serde(with = "serde_utils::bytes_4_hex")]
genesis_fork_version: [u8; 4],
#[serde(with = "serde_utils::u8_hex")]
bls_withdrawal_prefix: u8,
#[serde(with = "serde_utils::quoted_u64")]
seconds_per_slot: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_attestation_inclusion_delay: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_seed_lookahead: u64,
#[serde(with = "serde_utils::quoted_u64")]
max_seed_lookahead: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_epochs_to_inactivity_penalty: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_validator_withdrawability_delay: u64,
#[serde(with = "serde_utils::quoted_u64")]
shard_committee_period: u64,
#[serde(with = "serde_utils::quoted_u64")]
base_reward_factor: u64,
#[serde(with = "serde_utils::quoted_u64")]
whistleblower_reward_quotient: u64,
#[serde(with = "serde_utils::quoted_u64")]
proposer_reward_quotient: u64,
#[serde(with = "serde_utils::quoted_u64")]
inactivity_penalty_quotient: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_slashing_penalty_quotient: u64,
#[serde(with = "serde_utils::quoted_u64")]
safe_slots_to_update_justified: u64,

#[serde(with = "serde_utils::u32_hex")]
Expand All @@ -502,12 +531,16 @@ pub struct YamlConfig {
justification_bits_length: u32,
max_validators_per_committee: u32,
genesis_epoch: Epoch,
#[serde(with = "serde_utils::quoted_u64")]
slots_per_epoch: u64,
#[serde(with = "serde_utils::quoted_u64")]
epochs_per_eth1_voting_period: u64,
slots_per_historical_root: usize,
epochs_per_historical_vector: usize,
epochs_per_slashings_vector: usize,
#[serde(with = "serde_utils::quoted_u64")]
historical_roots_limit: u64,
#[serde(with = "serde_utils::quoted_u64")]
validator_registry_limit: u64,
max_proposer_slashings: u32,
max_attester_slashings: u32,
Expand All @@ -516,10 +549,15 @@ pub struct YamlConfig {
max_voluntary_exits: u32,

// Validator
#[serde(with = "serde_utils::quoted_u64")]
eth1_follow_distance: u64,
#[serde(with = "serde_utils::quoted_u64")]
target_aggregators_per_committee: u64,
#[serde(with = "serde_utils::quoted_u64")]
random_subnets_per_validator: u64,
#[serde(with = "serde_utils::quoted_u64")]
epochs_per_random_subnet_subscription: u64,
#[serde(with = "serde_utils::quoted_u64")]
seconds_per_eth1_block: u64,
deposit_contract_address: Address,
}
Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/deposit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tree_hash_derive::TreeHash;
pub struct DepositData {
pub pubkey: PublicKeyBytes,
pub withdrawal_credentials: Hash256,
#[serde(with = "serde_utils::quoted_u64")]
pub amount: u64,
pub signature: SignatureBytes,
}
Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/deposit_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tree_hash_derive::TreeHash;
pub struct DepositMessage {
pub pubkey: PublicKeyBytes,
pub withdrawal_credentials: Hash256,
#[serde(with = "serde_utils::quoted_u64")]
pub amount: u64,
}

Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/eth1_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use tree_hash_derive::TreeHash;
)]
pub struct Eth1Data {
pub deposit_root: Hash256,
#[serde(with = "serde_utils::quoted_u64")]
pub deposit_count: u64,
pub block_hash: Hash256,
}
Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/free_attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ use serde_derive::Serialize;
pub struct FreeAttestation {
pub data: AttestationData,
pub signature: Signature,
#[serde(with = "serde_utils::quoted_u64")]
pub validator_index: u64,
}
2 changes: 2 additions & 0 deletions consensus/types/src/pending_attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ use tree_hash_derive::TreeHash;
pub struct PendingAttestation<T: EthSpec> {
pub aggregation_bits: BitList<T::MaxValidatorsPerCommittee>,
pub data: AttestationData,
#[serde(with = "serde_utils::quoted_u64")]
pub inclusion_delay: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub proposer_index: u64,
}

Expand Down
3 changes: 2 additions & 1 deletion consensus/types/src/subnet_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::ops::{Deref, DerefMut};

#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct SubnetId(u64);
#[serde(transparent)]
pub struct SubnetId(#[serde(with = "serde_utils::quoted_u64")] u64);

impl SubnetId {
pub fn new(id: u64) -> Self {
Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/voluntary_exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tree_hash_derive::TreeHash;
pub struct VoluntaryExit {
/// Earliest epoch when voluntary exit can be processed.
pub epoch: Epoch,
#[serde(with = "serde_utils::quoted_u64")]
pub validator_index: u64,
}

Expand Down

0 comments on commit a3e2281

Please sign in to comment.