From 83ae12a1b4719f073ccc3db473ac3a05cf51ac54 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Sun, 11 Oct 2020 23:58:12 +0000 Subject: [PATCH] Fix epoch, slot, and effective balance quoting (#1756) ## Issue Addressed Resolves #1717 ## Proposed Changes Add quoting for epochs, slots, and `effective_balance` ## Additional Info --- book/src/api-bn.md | 12 ++++++------ consensus/types/src/slot_epoch.rs | 4 ++-- consensus/types/src/validator.rs | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/book/src/api-bn.md b/book/src/api-bn.md index d957e4376..5492b22fa 100644 --- a/book/src/api-bn.md +++ b/book/src/api-bn.md @@ -52,7 +52,7 @@ application/json" "canonical": true, "header": { "message": { - "slot": 3199, + "slot": "3199", "proposer_index": "19077", "parent_root": "0xf1934973041c5896d0d608e52847c3cd9a5f809c59c64e76f6020e3d7cd0c7cd", "state_root": "0xe8e468f9f5961655dde91968f66480868dab8d4147de9498111df2b7e4e6fe60", @@ -81,12 +81,12 @@ curl -X GET "http://localhost:5052/eth/v1/beacon/states/head/validators/1" -H " "validator": { "pubkey": "0x873e73ee8b3e4fcf1d2fb0f1036ba996ac9910b5b348f6438b5f8ef50857d4da9075d0218a9d1b99a9eae235a39703e1", "withdrawal_credentials": "0x00b8cdcf79ba7e74300a07e9d8f8121dd0d8dd11dcfd6d3f2807c45b426ac968", - "effective_balance": 32000000000, + "effective_balance": "32000000000", "slashed": false, - "activation_eligibility_epoch": 0, - "activation_epoch": 0, - "exit_epoch": 18446744073709552000, - "withdrawable_epoch": 18446744073709552000 + "activation_eligibility_epoch": "0", + "activation_epoch": "0", + "exit_epoch": "18446744073709551615", + "withdrawable_epoch": "18446744073709551615" } } } diff --git a/consensus/types/src/slot_epoch.rs b/consensus/types/src/slot_epoch.rs index ffb88c7ee..4804b14e4 100644 --- a/consensus/types/src/slot_epoch.rs +++ b/consensus/types/src/slot_epoch.rs @@ -27,12 +27,12 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, Sub, SubAssi #[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] -pub struct Slot(u64); +pub struct Slot(#[serde(with = "serde_utils::quoted_u64")] u64); #[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] -pub struct Epoch(u64); +pub struct Epoch(#[serde(with = "serde_utils::quoted_u64")] u64); impl_common!(Slot); impl_common!(Epoch); diff --git a/consensus/types/src/validator.rs b/consensus/types/src/validator.rs index 064e4442b..e80fb8522 100644 --- a/consensus/types/src/validator.rs +++ b/consensus/types/src/validator.rs @@ -14,6 +14,7 @@ use tree_hash_derive::TreeHash; pub struct Validator { pub pubkey: PublicKeyBytes, pub withdrawal_credentials: Hash256, + #[serde(with = "serde_utils::quoted_u64")] pub effective_balance: u64, pub slashed: bool, pub activation_eligibility_epoch: Epoch,