mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 03:12:41 +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:
@@ -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