From 826401e25e3c347aa9a778bcef18c6fe68176dcc Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Mon, 26 Aug 2024 11:43:46 +0200 Subject: [PATCH] EVM Node: Have RPC mode fetches current number from the store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `eth_blockNumber` is one of the two RPCs that is available to users from the sequencer so-called relays. Because these relays are key components of our infrastructure, I proposed in a previous changeset to optimize its implementation, but I am now convinced that this change has a potential drawback that is not worth the performance gains: load balancing inconsistency. That is, with the current implementation, it is technically possible for two nodes running in RPC mode for the same data dir to return inconsistent result to the `eth_blockNumber` RPC. Imagine that for any reason, node B is lagging a bit behind wrt. consuming its blueprints stream. In this case, node A can return N, and directly after node B can return N-1 for instance. If we rely on the default implementation, the result is fetched from the on-disk state, which makes it not possible (as far as I can tell) to see this scenario when `eth_blockNumber` is not greater or equal than its previous result, even with a load balancer setup. --- etherlink/bin_node/lib_dev/rpc.ml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index 4c191ffb01bc..0af885ac6088 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -271,11 +271,7 @@ module Make (Base : sig val keep_alive : bool end) = -struct - include Services_backend_sig.Make (MakeBackend (Base)) (Base.Executor) - - let current_block_number () = Lwt_result.return Base.ctxt.current_block_number -end + Services_backend_sig.Make (MakeBackend (Base)) (Base.Executor) let install_finalizer_rpc server_public_finalizer = let open Lwt_syntax in -- GitLab