diff --git a/etherlink/bin_node/lib_dev/services.ml b/etherlink/bin_node/lib_dev/services.ml index 9be4bfc6cade6fcb6928ccab112c7b0e4e5bca65..b1eb512a046ba051d479f6b96e33254bfafdfe72 100644 --- a/etherlink/bin_node/lib_dev/services.ml +++ b/etherlink/bin_node/lib_dev/services.ml @@ -644,7 +644,7 @@ let dispatch_request (rpc : Configuration.rpc) (config : Configuration.t) Tx_pool_events.invalid_transaction ~transaction:tx_raw in rpc_error (Rpc_errors.transaction_rejected err None) - | Ok (Either.Left transaction_object) -> ( + | Ok transaction_object -> ( let* (Qty balance) = Backend_rpc.balance transaction_object.from @@ -668,10 +668,6 @@ let dispatch_request (rpc : Configuration.rpc) (config : Configuration.t) | Error reason -> rpc_error (Rpc_errors.transaction_rejected reason None)) - | Ok (Either.Right _) -> - rpc_error - (Rpc_errors.internal_error - "Transaction validation in the kernel is deprecated") in build_with_input ~f module_ parameters | Eth_call.Method -> diff --git a/etherlink/bin_node/lib_dev/simulation.ml b/etherlink/bin_node/lib_dev/simulation.ml index de5643672d7340f6702e0add280ccf104f0c77f9..101a40e2380bbd4bc3da11c367950946c5187d71 100644 --- a/etherlink/bin_node/lib_dev/simulation.ml +++ b/etherlink/bin_node/lib_dev/simulation.ml @@ -179,8 +179,12 @@ let chunk_tag = "\003" (** Tag indicating simulation is an evaluation *) let evaluation_tag = "\000" -(** Tag indicating simulation is a validation *) -let validation_tag = "\001" +(** Tag indicating simulation is a validation + + This tag can no longer be used, but if you plan to add another tag + please avoid using this one to avoid mistakes. +*) +let _validation_tag = "\001" (** [add_tag tag bytes] prefixes bytes by the given tag *) let add_tag tag bytes = tag ^ Bytes.to_string bytes |> String.to_bytes @@ -203,37 +207,10 @@ let encode call = in return @@ List.map encode_message messages -let encode_tx tx = - let open Result_syntax in - let* messages = - Bytes.of_string tx |> add_tag validation_tag |> split_in_messages - in - return @@ List.map encode_message messages - type execution_result = {value : hash option; gas_used : quantity option} type call_result = (execution_result, hash) result -type validation_result = (transaction_object, address) Either.t - -let validation_result_encoding = - let open Data_encoding in - union - [ - case - ~title:"Transaction object" - Json_only - transaction_object_encoding - (function Either.Left obj -> Some obj | _ -> None) - (fun obj -> Left obj); - case - ~title:"Address" - Json_only - address_encoding - (function Either.Right addr -> Some addr | _ -> None) - (fun addr -> Right addr); - ] - type 'a simulation_result = ('a, string) result module Encodings = struct @@ -311,9 +288,6 @@ module Encodings = struct data directory of the rollup node.") module type RLP_DECODING = sig - val decode_validation_result : - Rlp.item -> (transaction_object, address) Either.t tzresult - val decode_call_result : Rlp.item -> (execution_result, hash) result tzresult @@ -357,16 +331,6 @@ module Encodings = struct in Rlp.decode_result decode_execution_result decode_revert v - let decode_validation_result = - let open Result_syntax in - function - | Rlp.Value address -> return (Either.Right (decode_address address)) - | rlp -> - error_with - "The simulation returned an ill-encoded validation result: %a" - Rlp.pp - rlp - let simulation_result_from_rlp decode_payload bytes = let open Result_syntax in let decode_error_msg = function @@ -392,12 +356,6 @@ module Encodings = struct module V1 = struct include V0 - let decode_validation_result bytes = - let open Result_syntax in - try return (Either.Left (transaction_object_from_rlp_item None bytes)) - with _ -> - error_with "The simulation returned an ill-encoded validation result" - let simulation_result_from_rlp decode_payload bytes = let bytes = Bytes.sub bytes 1 (Bytes.length bytes - 1) in simulation_result_from_rlp decode_payload bytes @@ -448,8 +406,3 @@ let gas_estimation bytes = let module Encodings = (val Encodings.Rlp_decoding.select_rlp_decodings bytes) in Encodings.simulation_result_from_rlp Encodings.decode_call_result bytes - -let is_tx_valid bytes = - let module Encodings = (val Encodings.Rlp_decoding.select_rlp_decodings bytes) - in - Encodings.simulation_result_from_rlp Encodings.decode_validation_result bytes diff --git a/etherlink/bin_node/lib_dev/validate.ml b/etherlink/bin_node/lib_dev/validate.ml index 2cc736bf9eb51cefdbb6c73a71ff8995da7cfecd..6734e623b0084d6aca3842467ce03897e177ac91 100644 --- a/etherlink/bin_node/lib_dev/validate.ml +++ b/etherlink/bin_node/lib_dev/validate.ml @@ -120,7 +120,7 @@ let valid_transaction_object ~backend_rpc ~decode ~hash tx_raw = Transaction.to_transaction_object ~hash transaction in let** () = validate backend_rpc transaction ~caller:transaction_object.from in - return (Ok (Either.Left transaction_object)) + return (Ok transaction_object) let is_tx_valid ((module Backend_rpc : Services_backend_sig.S) as backend_rpc) tx_raw = diff --git a/etherlink/bin_node/lib_dev/validate.mli b/etherlink/bin_node/lib_dev/validate.mli index dce0286c06e5146b35bef5693dc35445306f356a..ea31ba87b2864854a7ea7eb18426c54e745fc747 100644 --- a/etherlink/bin_node/lib_dev/validate.mli +++ b/etherlink/bin_node/lib_dev/validate.mli @@ -6,9 +6,8 @@ (*****************************************************************************) (** [is_tx_valid backend_rpc tx_raw] validates the transaction - [tx_raw]. If the transaction is not yet supported by the node - validation, we fallback to [backend_rpc.is_tx_valid]. *) + [tx_raw]. *) val is_tx_valid : (module Services_backend_sig.S) -> string -> - Simulation.validation_result Simulation.simulation_result tzresult Lwt.t + (Ethereum_types.transaction_object, string) result tzresult Lwt.t