feat(sync): beacon consensus engine (#1845)

This commit is contained in:
Roman Krasiuk
2023-03-23 20:18:19 +02:00
committed by GitHub
parent 84af91737d
commit ce40bea46e
27 changed files with 1918 additions and 1141 deletions

View File

@@ -1,4 +1,5 @@
use reth_primitives::{Bytes, H256, U256};
use reth_beacon_consensus::BeaconEngineError;
use reth_primitives::{H256, U256};
use thiserror::Error;
/// The Engine API result type
@@ -10,39 +11,8 @@ pub const UNKNOWN_PAYLOAD_CODE: i32 = -38001;
pub const REQUEST_TOO_LARGE_CODE: i32 = -38004;
/// Error returned by [`EngineApi`][crate::EngineApi]
#[derive(Error, PartialEq, Debug)]
#[derive(Error, Debug)]
pub enum EngineApiError {
/// Invalid payload extra data.
#[error("Invalid payload extra data: {0}")]
PayloadExtraData(Bytes),
/// Invalid payload base fee.
#[error("Invalid payload base fee: {0}")]
PayloadBaseFee(U256),
/// Invalid payload block hash.
#[error("Invalid payload block hash. Execution: {execution}. Consensus: {consensus}")]
PayloadBlockHash {
/// The block hash computed from the payload.
execution: H256,
/// The block hash provided with the payload.
consensus: H256,
},
/// Invalid payload block hash.
#[error("Invalid payload timestamp: {invalid}. Latest: {latest}")]
PayloadTimestamp {
/// The payload timestamp.
invalid: u64,
/// Latest available timestamp.
latest: u64,
},
/// Failed to recover transaction signer.
#[error("Failed to recover signer for payload transaction: {hash:?}")]
PayloadSignerRecovery {
/// The hash of the failed transaction
hash: H256,
},
/// Received pre-merge payload.
#[error("Received pre-merge payload.")]
PayloadPreMerge,
/// Unknown payload requested.
#[error("Unknown payload")]
PayloadUnknown,
@@ -75,16 +45,10 @@ pub enum EngineApiError {
/// Consensus terminal block hash.
consensus: H256,
},
/// Forkchoice zero hash head received.
#[error("Received zero hash as forkchoice head")]
ForkchoiceEmptyHead,
/// Chain spec merge terminal total difficulty is not set
#[error("The merge terminal total difficulty is not known")]
UnknownMergeTerminalTotalDifficulty,
/// Encountered decoding error.
/// Beacon consensus engine error.
#[error(transparent)]
Decode(#[from] reth_rlp::DecodeError),
/// API encountered an internal error.
ConsensusEngine(#[from] BeaconEngineError),
/// Encountered an internal error.
#[error(transparent)]
Internal(#[from] reth_interfaces::Error),
Internal(Box<dyn std::error::Error + Send + Sync>),
}