diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index b3898e4289b2d975584cec6ca4ce11a871af9728..1287b3511d8ffd818e0959fbfc2ab0c6297f6c9c 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -35,6 +35,7 @@ - Return `baseFeePerGas` and `mixHash` field for `eth_getBlockBy*` RPCs. The former only when appropriate, the later with a default value. (!13159) - Support for the `eth_feeHistory` RPC. (!13259) +- Support `FaDeposit` delayed message. (!13532) ### Experimental diff --git a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml index bb2cd07527253fc7579a665822783a464d8c946f..bb20e801e7bf323500db33ab95ebb5a527b202da 100644 --- a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml +++ b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml @@ -1419,7 +1419,7 @@ let fee_history_encoding = (req "gasUsedRatio" (list float))) module Delayed_transaction = struct - type kind = Transaction | Deposit + type kind = Transaction | Deposit | Fa_deposit type t = { kind : kind; @@ -1444,6 +1444,12 @@ module Delayed_transaction = struct (constant "deposit") (function Deposit -> Some () | _ -> None) (function () -> Deposit); + case + (Tag 2) + ~title:"fa_deposit" + (constant "fa_deposit") + (function Fa_deposit -> Some () | _ -> None) + (function () -> Fa_deposit); ] let encoding : t Data_encoding.t = @@ -1453,7 +1459,8 @@ module Delayed_transaction = struct (fun (kind, hash, raw) -> {kind; hash; raw}) (tup3 encoding_kind hash_encoding (string' Hex)) - let of_rlp_content ?(transaction_tag = "\x03") hash rlp_content = + let of_rlp_content ?(transaction_tag = "\x03") ?(fa_deposit_tag = "\x04") hash + rlp_content = match rlp_content with | Rlp.(List [Value tag; content]) -> ( match (Bytes.to_string tag, content) with @@ -1468,6 +1475,11 @@ module Delayed_transaction = struct *) | tag, Rlp.Value raw_tx when tag = transaction_tag -> Some {kind = Transaction; hash; raw = Bytes.to_string raw_tx} + | tag, fa_deposit when tag = fa_deposit_tag -> + (* Delayed inbox item has tag 3, inbox::transaction has tag 4. Event + uses the inbox::transaction tag. *) + let raw = Rlp.encode fa_deposit |> Bytes.to_string in + Some {kind = Fa_deposit; hash; raw} | "\x02", deposit -> let raw = Rlp.encode deposit |> Bytes.to_string in Some {kind = Deposit; hash; raw} @@ -1477,7 +1489,10 @@ module Delayed_transaction = struct let to_rlp {kind; raw; hash} = let open Rlp in let tag = - (match kind with Transaction -> "\x03" | Deposit -> "\x02") + (match kind with + | Transaction -> "\x03" + | Deposit -> "\x02" + | Fa_deposit -> "\x04") |> Bytes.of_string in let hash = hash_to_bytes hash |> Bytes.of_string in @@ -1485,6 +1500,7 @@ module Delayed_transaction = struct match kind with | Transaction -> Value (Bytes.of_string raw) | Deposit -> decode_exn (Bytes.of_string raw) + | Fa_deposit -> decode_exn (Bytes.of_string raw) in let rlp = List [Value hash; List [Value tag; content]] in encode rlp @@ -1492,6 +1508,7 @@ module Delayed_transaction = struct let pp_kind fmt = function | Transaction -> Format.pp_print_string fmt "Transaction" | Deposit -> Format.pp_print_string fmt "Deposit" + | Fa_deposit -> Format.pp_print_string fmt "FA_Deposit" let pp fmt {raw; kind; _} = Format.fprintf fmt "%a: %a" pp_kind kind Hex.pp (Hex.of_string raw) diff --git a/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli b/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli index 5bf8ac2604835c680fc01085eedd3111dfb0e3f8..372b86092a6de8924da2a5e5ae4bc1847776e105 100644 --- a/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli +++ b/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli @@ -318,7 +318,7 @@ module Address : sig end module Delayed_transaction : sig - type kind = Transaction | Deposit + type kind = Transaction | Deposit | Fa_deposit type t = {kind : kind; hash : hash; raw : string} @@ -326,7 +326,12 @@ module Delayed_transaction : sig val pp : Format.formatter -> t -> unit - val of_rlp_content : ?transaction_tag:string -> hash -> Rlp.item -> t option + val of_rlp_content : + ?transaction_tag:string -> + ?fa_deposit_tag:string -> + hash -> + Rlp.item -> + t option val to_rlp : t -> bytes end diff --git a/etherlink/bin_node/lib_dev/evm_context.ml b/etherlink/bin_node/lib_dev/evm_context.ml index 03cf2cb6bcb1aa13597b660879b0148c2f471985..e23579d62dfe4eb338af1d3544dc8412b011181f 100644 --- a/etherlink/bin_node/lib_dev/evm_context.ml +++ b/etherlink/bin_node/lib_dev/evm_context.ml @@ -825,6 +825,7 @@ module State = struct ~none:[error_of_fmt "cannot parse delayed inbox item "] @@ Ethereum_types.Delayed_transaction.of_rlp_content ~transaction_tag:"\x01" + ~fa_deposit_tag:"\x03" hash rlp_item in