mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 20:22:02 +00:00
Delete legacy payload reconstruction (#6213)
* Delete legacy payload reconstruction * Delete unneeded failing test * Merge remote-tracking branch 'origin/unstable' into remove-more-ethers * Merge remote-tracking branch 'origin/unstable' into remove-more-ethers * Cleanups
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
use crate::engine_api::{
|
||||
json_structures::{
|
||||
JsonForkchoiceUpdatedV1Response, JsonPayloadStatusV1, JsonPayloadStatusV1Status,
|
||||
},
|
||||
ExecutionBlock, PayloadAttributes, PayloadId, PayloadStatusV1, PayloadStatusV1Status,
|
||||
};
|
||||
use crate::engines::ForkchoiceState;
|
||||
use crate::EthersTransaction;
|
||||
use crate::{
|
||||
engine_api::{
|
||||
json_structures::{
|
||||
JsonForkchoiceUpdatedV1Response, JsonPayloadStatusV1, JsonPayloadStatusV1Status,
|
||||
},
|
||||
ExecutionBlock, PayloadAttributes, PayloadId, PayloadStatusV1, PayloadStatusV1Status,
|
||||
},
|
||||
ExecutionBlockWithTransactions,
|
||||
};
|
||||
use eth2::types::BlobsBundle;
|
||||
use kzg::{Kzg, KzgCommitment, KzgProof};
|
||||
use parking_lot::Mutex;
|
||||
@@ -89,17 +86,13 @@ impl<E: EthSpec> Block<E> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_execution_block_with_tx(&self) -> Option<ExecutionBlockWithTransactions<E>> {
|
||||
pub fn as_execution_payload(&self) -> Option<ExecutionPayload<E>> {
|
||||
match self {
|
||||
Block::PoS(payload) => Some(payload.clone().try_into().unwrap()),
|
||||
Block::PoW(block) => Some(
|
||||
ExecutionPayload::Bellatrix(ExecutionPayloadBellatrix {
|
||||
block_hash: block.block_hash,
|
||||
..Default::default()
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
Block::PoS(payload) => Some(payload.clone()),
|
||||
Block::PoW(block) => Some(ExecutionPayload::Bellatrix(ExecutionPayloadBellatrix {
|
||||
block_hash: block.block_hash,
|
||||
..Default::default()
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,20 +248,17 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
|
||||
.map(|block| block.as_execution_block(self.terminal_total_difficulty))
|
||||
}
|
||||
|
||||
pub fn execution_block_with_txs_by_hash(
|
||||
pub fn execution_payload_by_hash(
|
||||
&self,
|
||||
hash: ExecutionBlockHash,
|
||||
) -> Option<ExecutionBlockWithTransactions<E>> {
|
||||
) -> Option<ExecutionPayload<E>> {
|
||||
self.block_by_hash(hash)
|
||||
.and_then(|block| block.as_execution_block_with_tx())
|
||||
.and_then(|block| block.as_execution_payload())
|
||||
}
|
||||
|
||||
pub fn execution_block_with_txs_by_number(
|
||||
&self,
|
||||
number: u64,
|
||||
) -> Option<ExecutionBlockWithTransactions<E>> {
|
||||
pub fn execution_payload_by_number(&self, number: u64) -> Option<ExecutionPayload<E>> {
|
||||
self.block_by_number(number)
|
||||
.and_then(|block| block.as_execution_block_with_tx())
|
||||
.and_then(|block| block.as_execution_payload())
|
||||
}
|
||||
|
||||
pub fn move_to_block_prior_to_terminal_block(&mut self) -> Result<(), String> {
|
||||
|
||||
@@ -83,12 +83,10 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
.ok_or_else(|| "missing/invalid params[1] value".to_string())
|
||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?;
|
||||
if full_tx {
|
||||
Ok(serde_json::to_value(
|
||||
ctx.execution_block_generator
|
||||
.read()
|
||||
.execution_block_with_txs_by_hash(hash),
|
||||
)
|
||||
.unwrap())
|
||||
Err((
|
||||
"full_tx support has been removed".to_string(),
|
||||
BAD_PARAMS_ERROR_CODE,
|
||||
))
|
||||
} else {
|
||||
Ok(serde_json::to_value(
|
||||
ctx.execution_block_generator
|
||||
@@ -556,40 +554,25 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
|
||||
let mut response = vec![];
|
||||
for block_num in start..(start + count) {
|
||||
let maybe_block = ctx
|
||||
let maybe_payload = ctx
|
||||
.execution_block_generator
|
||||
.read()
|
||||
.execution_block_with_txs_by_number(block_num);
|
||||
.execution_payload_by_number(block_num);
|
||||
|
||||
match maybe_block {
|
||||
Some(block) => {
|
||||
let transactions = Transactions::<E>::new(
|
||||
block
|
||||
.transactions()
|
||||
.iter()
|
||||
.map(|transaction| VariableList::new(transaction.rlp().to_vec()))
|
||||
.collect::<Result<_, _>>()
|
||||
.map_err(|e| {
|
||||
(
|
||||
format!("failed to deserialize transaction: {:?}", e),
|
||||
GENERIC_ERROR_CODE,
|
||||
)
|
||||
})?,
|
||||
)
|
||||
.map_err(|e| {
|
||||
(
|
||||
format!("failed to deserialize transactions: {:?}", e),
|
||||
GENERIC_ERROR_CODE,
|
||||
)
|
||||
})?;
|
||||
|
||||
response.push(Some(JsonExecutionPayloadBodyV1::<E> {
|
||||
transactions,
|
||||
withdrawals: block
|
||||
.withdrawals()
|
||||
.ok()
|
||||
.map(|withdrawals| VariableList::from(withdrawals.clone())),
|
||||
}));
|
||||
match maybe_payload {
|
||||
Some(payload) => {
|
||||
assert!(
|
||||
!payload.fork_name().electra_enabled(),
|
||||
"payload bodies V1 is not supported for Electra blocks"
|
||||
);
|
||||
let payload_body = ExecutionPayloadBodyV1 {
|
||||
transactions: payload.transactions().clone(),
|
||||
withdrawals: payload.withdrawals().ok().cloned(),
|
||||
};
|
||||
let json_payload_body = JsonExecutionPayloadBody::V1(
|
||||
JsonExecutionPayloadBodyV1::<E>::from(payload_body),
|
||||
);
|
||||
response.push(Some(json_payload_body));
|
||||
}
|
||||
None => response.push(None),
|
||||
}
|
||||
@@ -611,63 +594,28 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
|
||||
let mut response = vec![];
|
||||
for block_num in start..(start + count) {
|
||||
let maybe_block = ctx
|
||||
let maybe_payload = ctx
|
||||
.execution_block_generator
|
||||
.read()
|
||||
.execution_block_with_txs_by_number(block_num);
|
||||
|
||||
match maybe_block {
|
||||
Some(block) => {
|
||||
let transactions = Transactions::<E>::new(
|
||||
block
|
||||
.transactions()
|
||||
.iter()
|
||||
.map(|transaction| VariableList::new(transaction.rlp().to_vec()))
|
||||
.collect::<Result<_, _>>()
|
||||
.map_err(|e| {
|
||||
(
|
||||
format!("failed to deserialize transaction: {:?}", e),
|
||||
GENERIC_ERROR_CODE,
|
||||
)
|
||||
})?,
|
||||
)
|
||||
.map_err(|e| {
|
||||
(
|
||||
format!("failed to deserialize transactions: {:?}", e),
|
||||
GENERIC_ERROR_CODE,
|
||||
)
|
||||
})?;
|
||||
.execution_payload_by_number(block_num);
|
||||
|
||||
match maybe_payload {
|
||||
Some(payload) => {
|
||||
// TODO(electra): add testing for:
|
||||
// deposit_requests
|
||||
// withdrawal_requests
|
||||
// consolidation_requests
|
||||
response.push(Some(JsonExecutionPayloadBodyV2::<E> {
|
||||
transactions,
|
||||
withdrawals: block
|
||||
.withdrawals()
|
||||
.ok()
|
||||
.map(|withdrawals| VariableList::from(withdrawals.clone())),
|
||||
deposit_requests: block.deposit_requests().ok().map(
|
||||
|deposit_requests| VariableList::from(deposit_requests.clone()),
|
||||
),
|
||||
withdrawal_requests: block.withdrawal_requests().ok().map(
|
||||
|withdrawal_requests| {
|
||||
VariableList::from(withdrawal_requests.clone())
|
||||
},
|
||||
),
|
||||
consolidation_requests: block.consolidation_requests().ok().map(
|
||||
|consolidation_requests| {
|
||||
VariableList::from(
|
||||
consolidation_requests
|
||||
.clone()
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
},
|
||||
),
|
||||
}));
|
||||
let payload_body = ExecutionPayloadBodyV2 {
|
||||
transactions: payload.transactions().clone(),
|
||||
withdrawals: payload.withdrawals().ok().cloned(),
|
||||
deposit_requests: payload.deposit_requests().ok().cloned(),
|
||||
withdrawal_requests: payload.withdrawal_requests().ok().cloned(),
|
||||
consolidation_requests: payload.consolidation_requests().ok().cloned(),
|
||||
};
|
||||
let json_payload_body = JsonExecutionPayloadBody::V2(
|
||||
JsonExecutionPayloadBodyV2::<E>::from(payload_body),
|
||||
);
|
||||
response.push(Some(json_payload_body));
|
||||
}
|
||||
None => response.push(None),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user