@@ -11,7 +11,7 @@ import units.client.engine.model.ForkchoiceUpdatedRequest.ForkChoiceAttributes
1111import units .client .engine .model .PayloadStatus .{Syncing , Valid }
1212import units .client .engine .model .{* , given }
1313import units .eth .EthAddress
14- import units .{BlockHash , ClientError , JobResult }
14+ import units .{BlockHash , JobResult }
1515
1616import scala .concurrent .duration .{DurationInt , FiniteDuration }
1717
@@ -25,8 +25,8 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
2525 .flatMap {
2626 case ForkChoiceUpdatedResponse (ps @ PayloadState (Valid | Syncing , _, _), None ) => Right (ps.status)
2727 case ForkChoiceUpdatedResponse (PayloadState (_, _, Some (validationError)), _) =>
28- Left (ClientError ( s " Payload validation error: $validationError" ) )
29- case ForkChoiceUpdatedResponse (payloadState, _) => Left (ClientError ( s " Unexpected payload status ${payloadState.status}" ) )
28+ Left (s " Payload validation error: $validationError" )
29+ case ForkChoiceUpdatedResponse (payloadState, _) => Left (s " Unexpected payload status ${payloadState.status}" )
3030 }
3131 }
3232
@@ -53,11 +53,11 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
5353 case ForkChoiceUpdatedResponse (PayloadState (Valid , _, _), Some (payloadId)) =>
5454 Right (payloadId)
5555 case ForkChoiceUpdatedResponse (_, None ) =>
56- Left (ClientError ( s " Payload id for $lastBlockHash is not defined " ) )
56+ Left (s " Payload id for $lastBlockHash is not defined " )
5757 case ForkChoiceUpdatedResponse (PayloadState (_, _, Some (validationError)), _) =>
58- Left (ClientError ( s " Payload validation error for $lastBlockHash: $validationError" ) )
58+ Left (s " Payload validation error for $lastBlockHash: $validationError" )
5959 case ForkChoiceUpdatedResponse (payloadState, _) =>
60- Left (ClientError ( s " Unexpected payload status for $lastBlockHash: ${payloadState.status}" ) )
60+ Left (s " Unexpected payload status for $lastBlockHash: ${payloadState.status}" )
6161 }
6262 }
6363
@@ -69,11 +69,11 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
6969
7070 def newPayload (payload : JsObject , requestId : Int ): JobResult [Option [BlockHash ]] = {
7171 sendEngineRequest[NewPayloadRequest , PayloadState ](NewPayloadRequest (payload, requestId), BlockExecutionTimeout , requestId).flatMap {
72- case PayloadState (_, _, Some (validationError)) => Left (ClientError ( s " Payload validation error: $validationError" ) )
72+ case PayloadState (_, _, Some (validationError)) => Left (s " Payload validation error: $validationError" )
7373 case PayloadState (Valid , Some (latestValidHash), _) => Right (Some (latestValidHash))
7474 case PayloadState (Syncing , latestValidHash, _) => Right (latestValidHash)
75- case PayloadState (status, None , _) => Left (ClientError ( s " Latest valid hash is not defined at status $status" ) )
76- case PayloadState (status, _, _) => Left (ClientError ( s " Unexpected payload status: $status" ) )
75+ case PayloadState (status, None , _) => Left (s " Latest valid hash is not defined at status $status" )
76+ case PayloadState (status, _, _) => Left (s " Unexpected payload status: $status" )
7777 }
7878 }
7979
@@ -94,20 +94,20 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
9494 GetBlockByHashRequest (hash, fullTransactionObjects = false , requestId),
9595 NonBlockExecutionTimeout ,
9696 requestId
97- ).leftMap(err => ClientError ( s " Error getting block by hash $hash: $err" ) )
97+ ).leftMap(err => s " Error getting block by hash $hash: $err" )
9898 }
9999
100100 def getBlockByHashJson (hash : BlockHash , fullTransactionObjects : Boolean , requestId : Int ): JobResult [Option [JsObject ]] = {
101101 sendRequest[GetBlockByHashRequest , JsObject ](
102102 GetBlockByHashRequest (hash, fullTransactionObjects, requestId),
103103 NonBlockExecutionTimeout ,
104104 requestId
105- ).leftMap(err => ClientError ( s " Error getting block json by hash $hash: $err" ) )
105+ ).leftMap(err => s " Error getting block json by hash $hash: $err" )
106106 }
107107
108108 def getLastExecutionBlock (requestId : Int ): JobResult [EcBlock ] = for {
109109 lastEcBlockOpt <- getBlockByNumber(BlockNumber .Latest , requestId)
110- lastEcBlock <- Either .fromOption(lastEcBlockOpt, ClientError ( " Impossible: EC doesn't have blocks" ) )
110+ lastEcBlock <- Either .fromOption(lastEcBlockOpt, " Impossible: EC doesn't have blocks" )
111111 } yield lastEcBlock
112112
113113 def blockExists (hash : BlockHash , requestId : Int ): JobResult [Boolean ] =
@@ -116,11 +116,11 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
116116 override def simulate (blockStateCalls : Seq [BlockStateCall ], hash : BlockHash , requestId : Int ): JobResult [Seq [JsObject ]] =
117117 sendRequest[SimulateRequest , Seq [JsObject ]](SimulateRequest (blockStateCalls, hash, requestId), NonBlockExecutionTimeout , requestId)
118118 .flatMap(_.toRight(" Simulated block was empty" ))
119- .leftMap(err => ClientError ( s " Error simulating block: $err" ) )
119+ .leftMap(err => s " Error simulating block: $err" )
120120
121121 private def getBlockByNumberJson (number : String , requestId : Int ): JobResult [Option [JsObject ]] = {
122122 sendRequest[GetBlockByNumberRequest , JsObject ](GetBlockByNumberRequest (number, requestId), NonBlockExecutionTimeout , requestId)
123- .leftMap(err => ClientError ( s " Error getting block by number $number: $err" ) )
123+ .leftMap(err => s " Error getting block by number $number: $err" )
124124 }
125125
126126 override def getLogs (hash : BlockHash , addresses : List [EthAddress ], topics : List [String ], requestId : Int ): JobResult [List [GetLogsResponseEntry ]] =
@@ -129,13 +129,13 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
129129 NonBlockExecutionTimeout ,
130130 requestId
131131 )
132- .leftMap(err => ClientError ( s " Error getting block logs by hash $hash: $err" ) )
132+ .leftMap(err => s " Error getting block logs by hash $hash: $err" )
133133 .map(_.getOrElse(List .empty))
134134
135135 private def sendEngineRequest [A : Writes , B : Reads ](request : A , timeout : FiniteDuration , requestId : Int ): JobResult [B ] = {
136136 sendRequest(request, timeout, requestId) match {
137- case Right (response) => response.toRight(ClientError ( s " Unexpected engine API empty response " ) )
138- case Left (err) => Left (ClientError ( s " Engine API request error: $err" ) )
137+ case Right (response) => response.toRight(s " Unexpected engine API empty response " )
138+ case Left (err) => Left (s " Engine API request error: $err" )
139139 }
140140 }
141141}
0 commit comments