11use async_trait:: async_trait;
22use eth1:: http:: RpcError ;
3+ use reqwest:: StatusCode ;
34use serde:: { Deserialize , Serialize } ;
45
56pub const LATEST_TAG : & str = "latest" ;
67
78use crate :: engines:: ForkChoiceState ;
9+ pub use json_structures:: TransitionConfigurationV1 ;
810pub use types:: { Address , EthSpec , ExecutionBlockHash , ExecutionPayload , Hash256 , Uint256 } ;
911
12+ pub mod auth;
1013pub mod http;
1114pub mod json_structures;
1215
@@ -15,6 +18,7 @@ pub type PayloadId = [u8; 8];
1518#[ derive( Debug ) ]
1619pub enum Error {
1720 Reqwest ( reqwest:: Error ) ,
21+ Auth ( auth:: Error ) ,
1822 BadResponse ( String ) ,
1923 RequestFailed ( String ) ,
2024 InvalidExecutePayloadResponse ( & ' static str ) ,
@@ -27,11 +31,19 @@ pub enum Error {
2731 ExecutionHeadBlockNotFound ,
2832 ParentHashEqualsBlockHash ( ExecutionBlockHash ) ,
2933 PayloadIdUnavailable ,
34+ TransitionConfigurationMismatch ,
3035}
3136
3237impl From < reqwest:: Error > for Error {
3338 fn from ( e : reqwest:: Error ) -> Self {
34- Error :: Reqwest ( e)
39+ if matches ! (
40+ e. status( ) ,
41+ Some ( StatusCode :: UNAUTHORIZED ) | Some ( StatusCode :: FORBIDDEN )
42+ ) {
43+ Error :: Auth ( auth:: Error :: InvalidToken )
44+ } else {
45+ Error :: Reqwest ( e)
46+ }
3547 }
3648}
3749
@@ -41,6 +53,12 @@ impl From<serde_json::Error> for Error {
4153 }
4254}
4355
56+ impl From < auth:: Error > for Error {
57+ fn from ( e : auth:: Error ) -> Self {
58+ Error :: Auth ( e)
59+ }
60+ }
61+
4462/// A generic interface for an execution engine API.
4563#[ async_trait]
4664pub trait EngineApi {
@@ -71,6 +89,11 @@ pub trait EngineApi {
7189 forkchoice_state : ForkChoiceState ,
7290 payload_attributes : Option < PayloadAttributes > ,
7391 ) -> Result < ForkchoiceUpdatedResponse , Error > ;
92+
93+ async fn exchange_transition_configuration_v1 (
94+ & self ,
95+ transition_configuration : TransitionConfigurationV1 ,
96+ ) -> Result < TransitionConfigurationV1 , Error > ;
7497}
7598
7699#[ derive( Clone , Copy , Debug , PartialEq ) ]
0 commit comments