Skip to content

Commit

Permalink
update header name to consensus block value
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Oct 1, 2023
1 parent 33254e7 commit 8a674dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ pub enum BeaconBlockResponseType<T: EthSpec> {
pub struct BeaconBlockResponse<T: EthSpec, Payload: AbstractExecPayload<T>> {
pub block: BeaconBlock<T, Payload>,
pub state: BeaconState<T>,
pub execution_block_value: Option<Uint256>,
pub execution_payload_value: Option<Uint256>,
pub consensus_block_value: Option<u64>,
}

Expand Down Expand Up @@ -4610,7 +4610,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
bls_to_execution_changes,
} = partial_beacon_block;

let (inner_block, execution_block_value) = match &state {
let (inner_block, execution_payload_value) = match &state {
BeaconState::Base(_) => (
BeaconBlock::Base(BeaconBlockBase {
slot,
Expand Down Expand Up @@ -4656,7 +4656,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
BeaconState::Merge(_) => {
let block_proposal_contents =
block_contents.ok_or(BlockProductionError::MissingExecutionPayload)?;
let execution_block_value = block_proposal_contents.block_value().to_owned();
let execution_payload_value = block_proposal_contents.block_value().to_owned();

(
BeaconBlock::Merge(BeaconBlockMerge {
Expand All @@ -4681,13 +4681,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
},
}),
execution_block_value,
execution_payload_value,
)
}
BeaconState::Capella(_) => {
let block_proposal_contents =
block_contents.ok_or(BlockProductionError::MissingExecutionPayload)?;
let execution_block_value = block_proposal_contents.block_value().to_owned();
let execution_payload_value = block_proposal_contents.block_value().to_owned();

(
BeaconBlock::Capella(BeaconBlockCapella {
Expand All @@ -4713,7 +4713,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
bls_to_execution_changes: bls_to_execution_changes.into(),
},
}),
execution_block_value,
execution_payload_value,
)
}
};
Expand Down Expand Up @@ -4788,7 +4788,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Ok(BeaconBlockResponse {
block,
state,
execution_block_value: Some(execution_block_value),
execution_payload_value: Some(execution_payload_value),
consensus_block_value: Some(consensus_block_value),
})
}
Expand Down
10 changes: 5 additions & 5 deletions beacon_node/http_api/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use warp::{
};

use crate::version::{
add_consensus_payload_value_header, add_consensus_version_header,
add_consensus_block_value_header, add_consensus_version_header,
add_execution_payload_blinded_header, add_execution_payload_value_header,
fork_versioned_response, inconsistent_fork_rejection,
};
Expand Down Expand Up @@ -184,7 +184,7 @@ pub async fn determine_and_produce_block_ssz<T: BeaconChainTypes>(
(
block_response.block.as_ssz_bytes(),
fork_name,
block_response.execution_block_value,
block_response.execution_payload_value,
false,
)
}
Expand All @@ -198,7 +198,7 @@ pub async fn determine_and_produce_block_ssz<T: BeaconChainTypes>(
(
block_response.block.as_ssz_bytes(),
fork_name,
block_response.execution_block_value,
block_response.execution_payload_value,
true,
)
}
Expand Down Expand Up @@ -237,10 +237,10 @@ pub fn generate_json_response_v3<
.map(|res| add_consensus_version_header(res, fork_name))
.map(|res| add_execution_payload_blinded_header(res, blinded_payload_flag))
.map(|res| {
add_execution_payload_value_header(res, beacon_block_response.execution_block_value)
add_execution_payload_value_header(res, beacon_block_response.execution_payload_value)
})
.map(|res| {
add_consensus_payload_value_header(res, beacon_block_response.consensus_block_value)
add_consensus_block_value_header(res, beacon_block_response.consensus_block_value)
})
}

Expand Down
6 changes: 3 additions & 3 deletions beacon_node/http_api/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::api_types::fork_versioned_response::ExecutionOptimisticFinalizedForkVersionedResponse;
use crate::api_types::EndpointVersion;
use eth2::{
CONSENSUS_PAYLOAD_VALUE_HEADER, CONSENSUS_VERSION_HEADER, EXECUTION_PAYLOAD_BLINDED_HEADER,
CONSENSUS_BLOCK_VALUE_HEADER, CONSENSUS_VERSION_HEADER, EXECUTION_PAYLOAD_BLINDED_HEADER,
EXECUTION_PAYLOAD_VALUE_HEADER,
};
use serde::Serialize;
Expand Down Expand Up @@ -84,13 +84,13 @@ pub fn add_execution_payload_value_header<T: Reply>(
}

/// Add the `Eth-Execution-Payload-Value` header to a response.
pub fn add_consensus_payload_value_header<T: Reply>(
pub fn add_consensus_block_value_header<T: Reply>(
reply: T,
consensus_payload_value: Option<u64>,
) -> Response {
reply::with_header(
reply,
CONSENSUS_PAYLOAD_VALUE_HEADER,
CONSENSUS_BLOCK_VALUE_HEADER,
consensus_payload_value.unwrap_or_default().to_string(),
)
.into_response()
Expand Down
2 changes: 1 addition & 1 deletion common/eth2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub const V3: EndpointVersion = EndpointVersion(3);
pub const CONSENSUS_VERSION_HEADER: &str = "Eth-Consensus-Version";
pub const EXECUTION_PAYLOAD_BLINDED_HEADER: &str = "Eth-Execution-Payload-Blinded";
pub const EXECUTION_PAYLOAD_VALUE_HEADER: &str = "Eth-Execution-Payload-Value";
pub const CONSENSUS_PAYLOAD_VALUE_HEADER: &str = "Eth-Consensus-Payload-Value";
pub const CONSENSUS_BLOCK_VALUE_HEADER: &str = "Eth-Consensus-Block-Value";

#[derive(Debug)]
pub enum Error {
Expand Down

0 comments on commit 8a674dd

Please sign in to comment.