CL-EL withdrawals harmonization using Gwei units (#3884)
This commit is contained in:
parent
5b77c5c0f2
commit
51088725fb
@ -333,8 +333,8 @@ pub struct JsonWithdrawal {
|
|||||||
#[serde(with = "eth2_serde_utils::u64_hex_be")]
|
#[serde(with = "eth2_serde_utils::u64_hex_be")]
|
||||||
pub validator_index: u64,
|
pub validator_index: u64,
|
||||||
pub address: Address,
|
pub address: Address,
|
||||||
#[serde(with = "eth2_serde_utils::u256_hex_be")]
|
#[serde(with = "eth2_serde_utils::u64_hex_be")]
|
||||||
pub amount: Uint256,
|
pub amount: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Withdrawal> for JsonWithdrawal {
|
impl From<Withdrawal> for JsonWithdrawal {
|
||||||
@ -343,21 +343,18 @@ impl From<Withdrawal> for JsonWithdrawal {
|
|||||||
index: withdrawal.index,
|
index: withdrawal.index,
|
||||||
validator_index: withdrawal.validator_index,
|
validator_index: withdrawal.validator_index,
|
||||||
address: withdrawal.address,
|
address: withdrawal.address,
|
||||||
amount: Uint256::from((withdrawal.amount as u128) * 1000000000u128),
|
amount: withdrawal.amount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<JsonWithdrawal> for Withdrawal {
|
impl From<JsonWithdrawal> for Withdrawal {
|
||||||
fn from(jw: JsonWithdrawal) -> Self {
|
fn from(jw: JsonWithdrawal) -> Self {
|
||||||
// This comparison is done to avoid a scenario where the EE gives us too large a number and we
|
|
||||||
// panic when attempting to cast to a `u64`.
|
|
||||||
let amount = std::cmp::max(jw.amount / 1000000000, Uint256::from(u64::MAX));
|
|
||||||
Self {
|
Self {
|
||||||
index: jw.index,
|
index: jw.index,
|
||||||
validator_index: jw.validator_index,
|
validator_index: jw.validator_index,
|
||||||
address: jw.address,
|
address: jw.address,
|
||||||
amount: amount.as_u64(),
|
amount: jw.amount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user