From 41284af8e4ea9047894a5003ab40b83f1b72dd73 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Tue, 24 Dec 2024 12:15:09 +0100 Subject: [PATCH] EVM Node: Call `Random.self_init ()` from the binary Libraries should not setup runtime components like the `Random` state. This is commonly viewed as a bad practice: what if two libraries setup the same components differently? Or, we can imagine tests wanting to set up a reproducible `Random` state, instead of relying on `/dev/urandom`. As a consequence, we move the `Random.self_init` call in `bin_node` main module, as it is done for instance for the Octez node. --- etherlink/bin_node/lib_dev/services.ml | 2 -- etherlink/bin_node/main.ml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/etherlink/bin_node/lib_dev/services.ml b/etherlink/bin_node/lib_dev/services.ml index cd33631651f8..5f13e2147098 100644 --- a/etherlink/bin_node/lib_dev/services.ml +++ b/etherlink/bin_node/lib_dev/services.ml @@ -191,8 +191,6 @@ let subscriptions : to be sent multiple times. *) Stdlib.Hashtbl.create 10 -let () = Random.self_init () - let encode_id bytes = let id_hex = Hex.of_bytes bytes |> Hex.show in let buf = Buffer.create (String.length id_hex) in diff --git a/etherlink/bin_node/main.ml b/etherlink/bin_node/main.ml index cafd3ad70b9f..4002d0810bcb 100644 --- a/etherlink/bin_node/main.ml +++ b/etherlink/bin_node/main.ml @@ -2425,6 +2425,7 @@ let handle_error = function Stdlib.exit 1 let () = + Random.self_init () ; let _ = Tezos_clic.( setup_formatter -- GitLab