diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index ae5cee53cbe1b3034a913280d4e697d52737d66d..a3714c22eb02fa861b9a7ef3e07b969a02175864 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -2,6 +2,12 @@ ## Unreleased +### Breaking changes + +- The default snapshot filename has been changed from + `evm-snapshot--` to + `evm--snapshot--`. (!16946) + ### Configuration changes - Observer `--init-from-snapshot` now also accepts a path to an existing @@ -15,6 +21,10 @@ ### Storage changes +- Adds support for the `%h` variable in the `snapshot export` and `run observer + --init-from-snapshot` commands, to generalize over the current history mode + of the node. (!16946) + ## Version 0.18 (2025-02-24) This releases notably includes support for executing the Calypso kernel diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index b09cc73ef9facb039c3efd0fa0e20e82dc73a4cc..aabe9e19725171df8c9e066040ca22f9b1f985ae 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -103,7 +103,7 @@ let () = (function Invalid_snapshot_provider name -> Some name | _ -> None) (fun name -> Invalid_snapshot_provider name) -let interpolate_snapshot_provider rollup_address network provider = +let interpolate_snapshot_provider rollup_address network history_mode provider = let open Result_syntax in let percent = ('%', "%") in let rollup_address_short = @@ -117,11 +117,22 @@ let interpolate_snapshot_provider rollup_address network provider = let network = ('n', Format.asprintf "%a" Configuration.pp_supported_network network) in + let history_mode = + ( 'h', + Configuration.string_of_history_mode_info history_mode + |> String.lowercase_ascii ) + in try return (Misc.interpolate provider - [percent; rollup_address_short; rollup_address_long; network]) + [ + percent; + rollup_address_short; + rollup_address_long; + network; + history_mode; + ]) with _ -> tzfail (Invalid_snapshot_provider provider) let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync @@ -151,7 +162,12 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync | None -> Result.return_none | Some network -> Option.map_e - (interpolate_snapshot_provider smart_rollup_address network) + (interpolate_snapshot_provider + smart_rollup_address + network + (Option.value + ~default:Configuration.default_history_mode + config.history_mode)) init_from_snapshot in let* _loaded = diff --git a/etherlink/bin_node/lib_dev/snapshots.ml b/etherlink/bin_node/lib_dev/snapshots.ml index 5e2f104f08cb8443c94084d744f8ceb387e32e0b..45750b9fda6ed9767122e4830d5ec2e1a40d68a8 100644 --- a/etherlink/bin_node/lib_dev/snapshots.ml +++ b/etherlink/bin_node/lib_dev/snapshots.ml @@ -162,21 +162,33 @@ end open Snapshot_utils.Make (Header) -let interpolate_snapshot_file current_level rollup_address filename = +let interpolate_snapshot_file current_level rollup_address history_mode filename + = let percent = ('%', "%") in let rollup_address_short = ('r', Address.to_short_b58check rollup_address) in let rollup_address_long = ('R', Address.to_b58check rollup_address) in let current_level = ('l', Format.asprintf "%a" Ethereum_types.pp_quantity current_level) in + let history_mode = + ( 'h', + Configuration.string_of_history_mode_info history_mode + |> String.lowercase_ascii ) + in try Ok (Misc.interpolate filename - [percent; rollup_address_short; rollup_address_long; current_level]) + [ + percent; + rollup_address_short; + rollup_address_long; + current_level; + history_mode; + ]) with _ -> Result_syntax.tzfail (Invalid_snapshot_file filename) -let default_snapshot_file = "evm-snapshot-%r-%l" +let default_snapshot_file = "evm-%h-snapshot-%r-%l" let export ?snapshot_file ~compression ~data_dir () = let open Lwt_result_syntax in @@ -225,7 +237,11 @@ let export ?snapshot_file ~compression ~data_dir () = | None, (No | After) -> default_snapshot_file ^ ".uncompressed" in let*? dest_file = - interpolate_snapshot_file current_level rollup_address snapshot_file + interpolate_snapshot_file + current_level + rollup_address + history_mode + snapshot_file in let*! () = Lwt_utils_unix.create_dir (Filename.dirname dest_file) in create stdlib_reader writer header ~files ~dest:dest_file ; diff --git a/etherlink/bin_node/main.ml b/etherlink/bin_node/main.ml index e0dced0ed1d67ecd5779c08f56e04cec6a0a1a46..8e3dc856c948eb9643b551b74562975723f62391 100644 --- a/etherlink/bin_node/main.ml +++ b/etherlink/bin_node/main.ml @@ -515,7 +515,8 @@ let init_from_snapshot_arg = built-in provider `https://snapshotter-sandbox.nomadic-labs.eu`. %r is \ replaced by the short form of the Smart Rollup address, %R by the \ complete Smart Rollup address, %n by the network (given by the argument \ - --network), and %% by %. Also accepts a path to an existing snapshot." + --network), %h by the history mode used by the node, and %% by %. Also \ + accepts a path to an existing snapshot." ~default: "https://snapshotter-sandbox.nomadic-labs.eu/etherlink-%n/evm-snapshot-%r-latest.gz" ~placeholder:"snapshot url" @@ -818,9 +819,10 @@ let snapshot_file_arg = ~doc: "Path to the snapshot file to create, with string interpolation. %r is \ replaced by the short form of the Smart Rollup address, %R by the \ - complete Smart Rollup address, %l by the current head of the node, and \ - %% by %. Default is located in the current directory, and the filename \ - is based on the snapshot information." + complete Smart Rollup address, %l by the current head of the node, %h \ + by the history mode used by the node, and %% by %. Default is located \ + in the current directory, and the filename is based on the snapshot \ + information." Params.string let websocket_checks config = diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out index 8f2763f294dc71d9db1f7611f06feb1943318126..6611970b34b6a7ce92da95c8fc9161556f465bd9 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out @@ -26,7 +26,7 @@ Snapshots commands: [--uncompressed] Export a snapshot of the EVM node. --data-dir : The path to the EVM node data directory - -s --snapshot-file : Path to the snapshot file to create, with string interpolation. %r is replaced by the short form of the Smart Rollup address, %R by the complete Smart Rollup address, %l by the current head of the node, and %% by %. Default is located in the current directory, and the filename is based on the snapshot information. + -s --snapshot-file : Path to the snapshot file to create, with string interpolation. %r is replaced by the short form of the Smart Rollup address, %R by the complete Smart Rollup address, %l by the current head of the node, %h by the history mode used by the node, and %% by %. Default is located in the current directory, and the filename is based on the snapshot information. --compress-on-the-fly: Produce a compressed snapshot on the fly. The rollup node will use less disk space to produce the snapshot but will lock the rollup node (if running) for a longer time. Without this option, producing a snaphsot requires the available disk space to be around the size of the data dir. --uncompressed: Produce an uncompressed snapshot. @@ -245,7 +245,7 @@ Miscellaneous commands: --initial-kernel : Path to the EVM kernel used to launch the PVM, it will be loaded from storage afterward --dont-track-rollup-node: Disable tracking the head of the rollup node. Tracking the state of a rollup node allows to confirm the blocks received from the upstream EVM node. --no-sync: Disable tracking the head of the EVM node endpoint - --init-from-snapshot [snapshot url]: Automatically download and import a recent snapshot for supported networks on fresh data directories. If no snapshot provider is given e.g. `--init-from-snapshot` with no argument, then it uses the default built-in provider `https://snapshotter-sandbox.nomadic-labs.eu`. %r is replaced by the short form of the Smart Rollup address, %R by the complete Smart Rollup address, %n by the network (given by the argument --network), and %% by %. Also accepts a path to an existing snapshot. + --init-from-snapshot [snapshot url]: Automatically download and import a recent snapshot for supported networks on fresh data directories. If no snapshot provider is given e.g. `--init-from-snapshot` with no argument, then it uses the default built-in provider `https://snapshotter-sandbox.nomadic-labs.eu`. %r is replaced by the short form of the Smart Rollup address, %R by the complete Smart Rollup address, %n by the network (given by the argument --network), %h by the history mode used by the node, and %% by %. Also accepts a path to an existing snapshot. --network : The network the EVM node will be connecting to. Can be `mainnet` or `testnet`. If set, additional sanity checks are performed on the node’s startup. octez-evm-node experimental run rpc [--data-dir ]