mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-03 01:37:39 +00:00
Fix block v3 reward encodings (#5049)
* Fix block v3 reward encodings * Use crates.io version
This commit is contained in:
parent
4a65d28b3b
commit
7e948eec9d
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2341,9 +2341,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethereum_serde_utils"
|
name = "ethereum_serde_utils"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f8cb04ea380a33e9c269fa5f8df6f2d63dee19728235f3e639e7674e038686a"
|
checksum = "de4d5951468846963c24e8744c133d44f39dff2cd3a233f6be22b370d08a524f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ethereum-types 0.14.1",
|
"ethereum-types 0.14.1",
|
||||||
"hex",
|
"hex",
|
||||||
|
@ -511,13 +511,17 @@ impl<E: EthSpec> BeaconBlockResponseWrapper<E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn consensus_block_value(&self) -> u64 {
|
pub fn consensus_block_value_gwei(&self) -> u64 {
|
||||||
match self {
|
match self {
|
||||||
BeaconBlockResponseWrapper::Full(resp) => resp.consensus_block_value,
|
BeaconBlockResponseWrapper::Full(resp) => resp.consensus_block_value,
|
||||||
BeaconBlockResponseWrapper::Blinded(resp) => resp.consensus_block_value,
|
BeaconBlockResponseWrapper::Blinded(resp) => resp.consensus_block_value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn consensus_block_value_wei(&self) -> Uint256 {
|
||||||
|
Uint256::from(self.consensus_block_value_gwei()) * 1_000_000_000
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_blinded(&self) -> bool {
|
pub fn is_blinded(&self) -> bool {
|
||||||
matches!(self, BeaconBlockResponseWrapper::Blinded(_))
|
matches!(self, BeaconBlockResponseWrapper::Blinded(_))
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ pub fn build_response_v3<T: BeaconChainTypes>(
|
|||||||
.fork_name(&chain.spec)
|
.fork_name(&chain.spec)
|
||||||
.map_err(inconsistent_fork_rejection)?;
|
.map_err(inconsistent_fork_rejection)?;
|
||||||
let execution_payload_value = block_response.execution_payload_value();
|
let execution_payload_value = block_response.execution_payload_value();
|
||||||
let consensus_block_value = block_response.consensus_block_value();
|
let consensus_block_value = block_response.consensus_block_value_wei();
|
||||||
let execution_payload_blinded = block_response.is_blinded();
|
let execution_payload_blinded = block_response.is_blinded();
|
||||||
|
|
||||||
let metadata = ProduceBlockV3Metadata {
|
let metadata = ProduceBlockV3Metadata {
|
||||||
|
@ -93,7 +93,7 @@ pub fn add_execution_payload_value_header<T: Reply>(
|
|||||||
/// Add the `Eth-Consensus-Block-Value` header to a response.
|
/// Add the `Eth-Consensus-Block-Value` header to a response.
|
||||||
pub fn add_consensus_block_value_header<T: Reply>(
|
pub fn add_consensus_block_value_header<T: Reply>(
|
||||||
reply: T,
|
reply: T,
|
||||||
consensus_payload_value: u64,
|
consensus_payload_value: Uint256,
|
||||||
) -> Response {
|
) -> Response {
|
||||||
reply::with_header(
|
reply::with_header(
|
||||||
reply,
|
reply,
|
||||||
|
@ -1554,9 +1554,10 @@ pub struct ProduceBlockV3Metadata {
|
|||||||
)]
|
)]
|
||||||
pub consensus_version: ForkName,
|
pub consensus_version: ForkName,
|
||||||
pub execution_payload_blinded: bool,
|
pub execution_payload_blinded: bool,
|
||||||
|
#[serde(with = "serde_utils::u256_dec")]
|
||||||
pub execution_payload_value: Uint256,
|
pub execution_payload_value: Uint256,
|
||||||
#[serde(with = "serde_utils::quoted_u64")]
|
#[serde(with = "serde_utils::u256_dec")]
|
||||||
pub consensus_block_value: u64,
|
pub consensus_block_value: Uint256,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: EthSpec> FullBlockContents<T> {
|
impl<T: EthSpec> FullBlockContents<T> {
|
||||||
@ -1707,7 +1708,7 @@ impl TryFrom<&HeaderMap> for ProduceBlockV3Metadata {
|
|||||||
})?;
|
})?;
|
||||||
let consensus_block_value =
|
let consensus_block_value =
|
||||||
parse_required_header(headers, CONSENSUS_BLOCK_VALUE_HEADER, |s| {
|
parse_required_header(headers, CONSENSUS_BLOCK_VALUE_HEADER, |s| {
|
||||||
s.parse::<u64>()
|
s.parse::<Uint256>()
|
||||||
.map_err(|e| format!("invalid {CONSENSUS_BLOCK_VALUE_HEADER}: {e:?}"))
|
.map_err(|e| format!("invalid {CONSENSUS_BLOCK_VALUE_HEADER}: {e:?}"))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user