fix(rpc): add missing v2 handler (#2261)

This commit is contained in:
Matthias Seitz
2023-04-15 02:31:30 +02:00
committed by GitHub
parent adad6d31b4
commit adc01a8fd1

View File

@@ -79,6 +79,9 @@ where
Ok(rx.await??)
}
/// Sends a message to the beacon consensus engine to update the fork choice _without_
/// withdrawals.
///
/// See also <https://github.com/ethereum/execution-apis/blob/8db51dcd2f4bdfbd9ad6e4a7560aac97010ad063/src/engine/specification.md#engine_forkchoiceUpdatedV1>
///
/// Caution: This should not accept the `withdrawals` field
@@ -103,6 +106,31 @@ where
Ok(rx.await??)
}
/// Sends a message to the beacon consensus engine to update the fork choice _with_ withdrawals,
/// but only _after_ shanghai.
///
/// See also <https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#engine_forkchoiceupdatedv2>
pub async fn fork_choice_updated_v2(
&self,
state: ForkchoiceState,
payload_attrs: Option<PayloadAttributes>,
) -> EngineApiResult<ForkchoiceUpdated> {
if let Some(ref attrs) = payload_attrs {
self.validate_withdrawals_presence(
EngineApiMessageVersion::V2,
attrs.timestamp.as_u64(),
attrs.withdrawals.is_some(),
)?;
}
let (tx, rx) = oneshot::channel();
self.to_beacon_consensus.send(BeaconEngineMessage::ForkchoiceUpdated {
state,
payload_attrs,
tx,
})?;
Ok(rx.await??)
}
/// Returns the most recent version of the payload that is available in the corresponding
/// payload build process at the time of receiving this call.
///