From 89ffec4b8d5cf3584c75c2564fab18a73d013a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 24 Jul 2024 09:56:31 +0200 Subject: [PATCH 01/15] Etherlink/Sequencer/Tests: add enable_dal to setup This is to allow to write tests behaving differently when the DAL feature-flag is enabled. --- etherlink/tezt/tests/evm_sequencer.ml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 93cd7b940afc..dc6b87074679 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -83,6 +83,7 @@ type sequencer_setup = { l1_contracts : l1_contracts; boot_sector : string; kernel : Uses.t; + enable_dal : bool; } let setup_l1_contracts ?(dictator = Constant.bootstrap2) client = @@ -362,6 +363,7 @@ let setup_sequencer ?sequencer_rpc_port ?sequencer_private_rpc_port sc_rollup_node; boot_sector = output; kernel; + enable_dal; } let send_transaction (transaction : unit -> 'a Lwt.t) sequencer : 'a Lwt.t = @@ -2686,9 +2688,7 @@ let test_delayed_transfer_timeout = sc_rollup_node; sequencer; proxy; - observer = _; - boot_sector = _; - kernel = _; + _; } _protocol -> (* Kill the sequencer *) @@ -2846,9 +2846,7 @@ let test_delayed_transfer_timeout_fails_l1_levels = sc_rollup_node; sequencer; proxy; - observer = _; - boot_sector = _; - kernel = _; + _; } _protocol -> (* Kill the sequencer *) @@ -3106,9 +3104,7 @@ let test_delayed_inbox_flushing = sc_rollup_node; sequencer; proxy; - observer = _; - boot_sector = _; - kernel = _; + _; } _protocol -> (* Kill the sequencer *) -- GitLab From 81d9afec67f0246498bd0148272404128600e6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 24 Jul 2024 15:14:43 +0200 Subject: [PATCH 02/15] Etherlink/Sequencer/Tests: increase timeouts for DAL latency This is a preparation for DAL integration in Etherlink. We need to increase the timeouts in order to wait enough blocks for the blueprints to be sent through the DAL. The added latency is: - possibly one block for the rollup node to inject on the DAL, - 8 blocks of lag to let DAL attesters attest the DAL slot (this is a DAL protocol parameter called "attestation_lag"), - 1 extra block before the slot can be imported Moreover, in !13883, the sequencer sends at most one blueprint per L1 level on the DAL so, to catch up, a proxy EVM node which is N L2 levels behind the sequencer needs N extra L1 levels. Since the tests relevant to the DAL usually have a sequencer 5 levels ahead, we increase the timeouts by 15 levels (from 5 to 20). --- etherlink/tezt/lib/helpers.ml | 2 +- etherlink/tezt/tests/evm_sequencer.ml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/etherlink/tezt/lib/helpers.ml b/etherlink/tezt/lib/helpers.ml index d63fdc2c0ffc..d928493ffe11 100644 --- a/etherlink/tezt/lib/helpers.ml +++ b/etherlink/tezt/lib/helpers.ml @@ -195,7 +195,7 @@ let sequencer_upgrade ~sc_rollup_address ~sequencer_admin in Client.bake_for_and_wait ~keys:[] client -let bake_until ?__LOC__ ?(timeout_in_blocks = 5) ?(timeout = 30.) ~bake +let bake_until ?__LOC__ ?(timeout_in_blocks = 20) ?(timeout = 30.) ~bake ~result_f () = let res = ref None in let rec go counter_block = diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index dc6b87074679..3faf54663a30 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -3242,7 +3242,7 @@ let test_timestamp_from_the_future = ~tags:["evm"; "sequencer"; "block"; "timestamp"] ~title:"Timestamp from the future are refused" ~use_dal:ci_enabled_dal_registration - @@ fun {sequencer; proxy; sc_rollup_node; client; _} _protocol -> + @@ fun {sequencer; proxy; sc_rollup_node; client; enable_dal; _} _protocol -> (* In this test the time between blocks is 1 second. *) (* Producing a block 4:50 minutes after the L1 timestamp will be accepted. We @@ -3264,8 +3264,11 @@ let test_timestamp_from_the_future = Tezos_base.Time.Protocol.(add current_l1_timestamp 330L |> to_notation) in let*@ (_ : int) = produce_block ~timestamp:refused_timestamp sequencer in + (* We wait more in case of DAL because 5 blocks are not enough to + send the blueprint through the DAL. *) + let number_of_blocks_to_wait = if enable_dal then 20 else 5 in let* _ = - repeat 5 (fun () -> + repeat number_of_blocks_to_wait (fun () -> let* _l1_lvl = next_rollup_node_level ~sc_rollup_node ~client in unit) in -- GitLab From 9c346b34580298fbf966c0fb7d55bbfb0166c476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 24 Jul 2024 18:16:24 +0200 Subject: [PATCH 03/15] Increase timeouts in seconds too --- etherlink/tezt/tests/evm_sequencer.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 3faf54663a30..e434130809f6 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -753,14 +753,16 @@ let test_publish_blueprints = ~tags:["evm"; "sequencer"; "data"] ~title:"Sequencer publishes the blueprints to L1" ~use_dal:ci_enabled_dal_registration - @@ fun {sequencer; proxy; client; sc_rollup_node; _} _protocol -> + @@ fun {sequencer; proxy; client; sc_rollup_node; enable_dal; _} _protocol -> let* _ = repeat 5 (fun () -> let*@ _ = produce_block sequencer in unit) in - let* () = Evm_node.wait_for_blueprint_injected ~timeout:5. sequencer 5 in + (* Wait more to avoid flakiness, in particular with DAL *) + let timeout = if enable_dal then 50. else 5. in + let* () = Evm_node.wait_for_blueprint_injected ~timeout sequencer 5 in (* At this point, the evm node should called the batcher endpoint to publish all the blueprints. Stopping the node is then not a problem. *) -- GitLab From 6e9d30df86584104066046f153b9ccb8e814062e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 10 Jul 2024 15:41:58 +0200 Subject: [PATCH 04/15] Etherlink/Kernel: import blueprint from the DAL --- etherlink/kernel_evm/kernel/src/dal.rs | 113 +++++++++++++++++++ etherlink/kernel_evm/kernel/src/inbox.rs | 13 ++- etherlink/kernel_evm/kernel/src/lib.rs | 1 + etherlink/kernel_evm/kernel/src/parsing.rs | 2 +- etherlink/kernel_evm/kernel/src/stage_one.rs | 6 +- 5 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 etherlink/kernel_evm/kernel/src/dal.rs diff --git a/etherlink/kernel_evm/kernel/src/dal.rs b/etherlink/kernel_evm/kernel/src/dal.rs new file mode 100644 index 000000000000..4fc25b9d68f6 --- /dev/null +++ b/etherlink/kernel_evm/kernel/src/dal.rs @@ -0,0 +1,113 @@ +use crate::configuration::DalConfiguration; +use crate::parsing::{ + Input::ModeSpecific, InputResult::Input, SequencerInput::SequencerBlueprint, + SequencerParsingContext, +}; +use crate::storage::read_l1_level; +use anyhow::Ok; +use rlp::{DecoderError, PayloadInfo}; +use tezos_evm_logging::{log, Level::*}; +use tezos_smart_rollup_host::dal_parameters::RollupDalParameters; +use tezos_smart_rollup_host::metadata::RAW_ROLLUP_ADDRESS_SIZE; + +use tezos_smart_rollup_host::runtime::Runtime; + +// Import all the pages of a DAL slot and concatenate them. +fn import_dal_slot( + host: &mut Host, + params: &RollupDalParameters, + published_level: i32, + slot_index: u8, +) -> Option> { + // Without this the rollup node hangs. + if published_level < 0 { + return None; + }; + let page_size = params.page_size as usize; + let slot_size = params.slot_size as usize; + let mut slot: Vec = vec![0u8; slot_size]; + let number_of_pages = (params.slot_size / params.page_size) as i16; + let mut page_start = 0usize; + for page_index in 0..number_of_pages { + let imported_page_len = host + .reveal_dal_page( + published_level, + slot_index, + page_index, + &mut slot[page_start..page_start + page_size], + ) + .unwrap_or(0); + if imported_page_len == page_size { + page_start += imported_page_len + } else { + return None; + } + } + Some(slot) +} + +// data is assumed to be one RLP object followed by some padding. +// this function returns the length of the RLP object, including its +// length prefix +fn rlp_length(data: &[u8]) -> Result { + let PayloadInfo { + header_len, + value_len, + } = PayloadInfo::from(data)?; + Result::Ok(header_len + value_len) +} + +pub fn fetch_and_parse_sequencer_blueprints_from_dal( + host: &mut Host, + smart_rollup_address: [u8; RAW_ROLLUP_ADDRESS_SIZE], + dal: DalConfiguration, + parsing_context: &mut SequencerParsingContext, +) -> anyhow::Result<()> { + let params = host.reveal_dal_parameters(); + let attestation_lag = params.attestation_lag as i32; + let level = read_l1_level(host).unwrap_or_default() as i32; + let published_level = level - attestation_lag - 1; + for slot_index in dal.slot_indices { + if let Some(slot) = import_dal_slot(host, ¶ms, published_level, slot_index) { + log!( + host, + Info, + "DAL slot at level {} and index {} successfully imported", + published_level, + slot_index + ); + + // DAL slots are padded with zeros to have a constant + // size, we need to remove this padding before parsing the + // slot as a blueprint chunk. + + // The expected format is: + + // 0 (1B) / rollup_address (RAW_ROLLUP_ADDRESS_SIZE B) / blueprint tag (1B) / blueprint chunk (variable) / padding + + // To remove the padding we need to measure the length of + // the RLP-encoded blueprint chunk which starts at + // position 2 + RAW_ROLLUP_ADDRESS_SIZE + if let Result::Ok(chunk_length) = + rlp_length(&slot[2 + RAW_ROLLUP_ADDRESS_SIZE..]) + { + // Padding removal + let slot = &slot[0..2 + RAW_ROLLUP_ADDRESS_SIZE + chunk_length]; + let res = crate::parsing::InputResult::parse_external( + slot, + &smart_rollup_address, + parsing_context, + ); + if let Input(ModeSpecific(SequencerBlueprint(chunk))) = res { + log!( + host, + Info, + "DAL slot successfully parsed as a blueprint chunk" + ); + crate::blueprint_storage::store_sequencer_blueprint(host, chunk)? + } + } + } + } + Ok(()) +} diff --git a/etherlink/kernel_evm/kernel/src/inbox.rs b/etherlink/kernel_evm/kernel/src/inbox.rs index 80f1d17b2e67..226f1f1c0a9d 100644 --- a/etherlink/kernel_evm/kernel/src/inbox.rs +++ b/etherlink/kernel_evm/kernel/src/inbox.rs @@ -6,7 +6,8 @@ // SPDX-License-Identifier: MIT use crate::blueprint_storage::store_sequencer_blueprint; -use crate::configuration::{fetch_limits, TezosContracts}; +use crate::configuration::{fetch_limits, DalConfiguration, TezosContracts}; +use crate::dal::fetch_and_parse_sequencer_blueprints_from_dal; use crate::delayed_inbox::DelayedInbox; use crate::parsing::{ Input, InputResult, Parsable, ProxyInput, SequencerInput, SequencerParsingContext, @@ -620,6 +621,7 @@ pub enum StageOneStatus { Skipped, } +#[allow(clippy::too_many_arguments)] pub fn read_sequencer_inbox( host: &mut Host, smart_rollup_address: [u8; 20], @@ -628,6 +630,7 @@ pub fn read_sequencer_inbox( sequencer: PublicKey, delayed_inbox: &mut DelayedInbox, enable_fa_bridge: bool, + dal: Option, ) -> Result { // The mutable variable is used to retrieve the information of whether the // inbox was empty or not. As we consume all the inbox in one go, if the @@ -642,6 +645,14 @@ pub fn read_sequencer_inbox( .maximum_allowed_ticks .saturating_sub(TICKS_FOR_BLUEPRINT_INTERCEPT), }; + if let Some(dal_config) = dal { + fetch_and_parse_sequencer_blueprints_from_dal( + host, + smart_rollup_address, + dal_config, + &mut parsing_context, + )?; + }; loop { // Checks there will be enough ticks to handle at least another chunk of // full size. If it is not the case, asks for reboot. diff --git a/etherlink/kernel_evm/kernel/src/lib.rs b/etherlink/kernel_evm/kernel/src/lib.rs index 80fe70a16b47..c700f33f8ac3 100644 --- a/etherlink/kernel_evm/kernel/src/lib.rs +++ b/etherlink/kernel_evm/kernel/src/lib.rs @@ -45,6 +45,7 @@ mod block_in_progress; mod blueprint; mod blueprint_storage; mod configuration; +mod dal; mod delayed_inbox; mod error; mod event; diff --git a/etherlink/kernel_evm/kernel/src/parsing.rs b/etherlink/kernel_evm/kernel/src/parsing.rs index 6823ad4ab3ff..93f5249a2aa0 100644 --- a/etherlink/kernel_evm/kernel/src/parsing.rs +++ b/etherlink/kernel_evm/kernel/src/parsing.rs @@ -397,7 +397,7 @@ impl InputResult { /// // External message structure : // FRAMING_PROTOCOL_TARGETTED 21B / MESSAGE_TAG 1B / DATA - fn parse_external( + pub fn parse_external( input: &[u8], smart_rollup_address: &[u8], context: &mut Mode::Context, diff --git a/etherlink/kernel_evm/kernel/src/stage_one.rs b/etherlink/kernel_evm/kernel/src/stage_one.rs index 2664a2d8b5ad..c3a49fa675d0 100644 --- a/etherlink/kernel_evm/kernel/src/stage_one.rs +++ b/etherlink/kernel_evm/kernel/src/stage_one.rs @@ -105,11 +105,6 @@ fn fetch_sequencer_blueprints( dal: Option, enable_fa_bridge: bool, ) -> Result { - if let Some(_dal_config) = dal { - log!(host, Info, "Revealing DAL parameters"); - let params = host.reveal_dal_parameters(); - log!(host, Info, "DAL params: {:?}", params); - }; match read_sequencer_inbox( host, smart_rollup_address, @@ -118,6 +113,7 @@ fn fetch_sequencer_blueprints( sequencer, delayed_inbox, enable_fa_bridge, + dal, )? { StageOneStatus::Done => { // Check if there are timed-out transactions in the delayed inbox -- GitLab From b5eaab54e599e6f98f7f0ddc8ea8b5c7d3e358a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 21 Jun 2024 16:29:31 +0200 Subject: [PATCH 05/15] Etherlink/Node: allow to request rollup node to inject on DAL --- etherlink/bin_node/lib_dev/rollup_services.ml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/etherlink/bin_node/lib_dev/rollup_services.ml b/etherlink/bin_node/lib_dev/rollup_services.ml index 0f87dfd7ead9..ae6403a59e68 100644 --- a/etherlink/bin_node/lib_dev/rollup_services.ml +++ b/etherlink/bin_node/lib_dev/rollup_services.ml @@ -153,6 +153,22 @@ let batcher_injection : (list string)) (open_root / "local" / "batcher" / "injection") +let dal_injection = + let input_encoding = + Data_encoding.( + obj2 + (req "slot_content" Data_encoding.Variable.string) + (req "slot_index" uint8)) + in + Tezos_rpc.Service.post_service + ~description:"Inject the given slot in the DAL queue" + ~query:Tezos_rpc.Query.empty + ~input: + Data_encoding.( + def "dal_slot" ~description:"Slot to inject" input_encoding) + ~output:Data_encoding.unit + (open_root / "local" / "dal" / "injection") + let simulation : ( [`POST], unit, @@ -269,6 +285,24 @@ let publish : in return_unit +let publish_on_dal : + rollup_node_endpoint:Uri.t -> + slot_index:int -> + string -> + unit tzresult Lwt.t = + fun ~rollup_node_endpoint ~slot_index inputs -> + let open Lwt_result_syntax in + let* _answer = + call_service + ~keep_alive:false + ~base:rollup_node_endpoint + dal_injection + () + () + (inputs, slot_index) + in + return_unit + let durable_state_subkeys : ( [`GET], unit, -- GitLab From 1c1a6eef2ae687160d567e1d1e08baa1245e35ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 21 Jun 2024 16:35:05 +0200 Subject: [PATCH 06/15] Etherlink/Node: sequencer publishes on the DAL once per level --- .../bin_node/lib_dev/blueprints_publisher.ml | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/etherlink/bin_node/lib_dev/blueprints_publisher.ml b/etherlink/bin_node/lib_dev/blueprints_publisher.ml index 8e4e60927b16..da77ed155027 100644 --- a/etherlink/bin_node/lib_dev/blueprints_publisher.ml +++ b/etherlink/bin_node/lib_dev/blueprints_publisher.ml @@ -28,6 +28,7 @@ type state = { (** Do not try to catch-up if [cooldown] is not equal to 0 *) enable_dal : bool; dal_slots : int list option; + mutable dal_last_used : Z.t; } module Types = struct @@ -98,7 +99,7 @@ module Worker = struct let current = current_cooldown worker in if on_cooldown worker then set_cooldown worker (current - 1) else () - let publish self payload level = + let publish self payload level ~use_dal = let open Lwt_result_syntax in let rollup_node_endpoint = rollup_node_endpoint self in (* We do not check if we succeed or not: this will be done when new L2 @@ -107,7 +108,25 @@ module Worker = struct let*! res = (* We do not check if we succeed or not: this will be done when new L2 heads come from the rollup node. *) - Rollup_services.publish ~keep_alive:false ~rollup_node_endpoint payload + match (state self, payload) with + | ( { + enable_dal = true; + dal_slots = Some (slot_index :: _); + dal_last_used; + _; + }, + [`External payload] ) + when use_dal && dal_last_used < level -> + (state self).dal_last_used <- level ; + Rollup_services.publish_on_dal + ~rollup_node_endpoint + ~slot_index + payload + | _ -> + Rollup_services.publish + ~keep_alive:false + ~rollup_node_endpoint + payload in let*! () = match res with @@ -155,7 +174,7 @@ module Worker = struct let* () = List.iter_es (fun (Ethereum_types.Qty current, payload) -> - publish worker payload current) + publish worker payload current ~use_dal:false) blueprints in @@ -224,6 +243,7 @@ module Handlers = struct keep_alive; enable_dal = Option.is_some dal_slots; dal_slots; + dal_last_used = Z.zero; } let on_request : @@ -233,7 +253,7 @@ module Handlers = struct let open Lwt_result_syntax in match request with | Publish {level; payload} -> - let* () = Worker.publish self payload level in + let* () = Worker.publish self payload level ~use_dal:true in return_unit | New_rollup_node_block rollup_block_lvl -> ( let* () = -- GitLab From d9272f2d4d19e96364e356a87ec00bca6d36973f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 23 Jul 2024 15:11:33 +0200 Subject: [PATCH 07/15] Etherlink/Sequencer/BP Publisher: events to distinguish channel This commit add events to distinguish if the blueprint is published on the DAL or the inbox. --- .../bin_node/lib_dev/blueprint_events.ml | 20 +++++++++++++++++++ .../bin_node/lib_dev/blueprint_events.mli | 10 ++++++++++ .../bin_node/lib_dev/blueprints_publisher.ml | 2 ++ 3 files changed, 32 insertions(+) diff --git a/etherlink/bin_node/lib_dev/blueprint_events.ml b/etherlink/bin_node/lib_dev/blueprint_events.ml index c00ff3c2c9db..79f0ccb14933 100644 --- a/etherlink/bin_node/lib_dev/blueprint_events.ml +++ b/etherlink/bin_node/lib_dev/blueprint_events.ml @@ -44,6 +44,22 @@ let blueprint_injection = ~level:Info ("level", Data_encoding.n) +let blueprint_injection_on_inbox = + declare_1 + ~section + ~name:"blueprint_injection_on_inbox" + ~msg:"Injection on the shared inbox a blueprint for level {level}" + ~level:Debug + ("level", Data_encoding.n) + +let blueprint_injection_on_DAL = + declare_1 + ~section + ~name:"blueprint_injection_on_DAL" + ~msg:"Injection on the DAL a blueprint for level {level}" + ~level:Debug + ("level", Data_encoding.n) + let blueprint_injection_failure = declare_2 ~section @@ -107,6 +123,10 @@ let publisher_shutdown () = emit publisher_shutdown () let blueprint_injected level = emit blueprint_injection level +let blueprint_injected_on_inbox level = emit blueprint_injection_on_inbox level + +let blueprint_injected_on_DAL level = emit blueprint_injection_on_DAL level + let blueprint_injection_failed level trace = emit blueprint_injection_failure (level, trace) diff --git a/etherlink/bin_node/lib_dev/blueprint_events.mli b/etherlink/bin_node/lib_dev/blueprint_events.mli index cc76270dc7a0..7b70c0e15fe2 100644 --- a/etherlink/bin_node/lib_dev/blueprint_events.mli +++ b/etherlink/bin_node/lib_dev/blueprint_events.mli @@ -25,6 +25,16 @@ val blueprint_applied : Z.t * Ethereum_types.block_hash -> unit Lwt.t [level] has been forwarded to a rollup node *) val blueprint_injected : Z.t -> unit Lwt.t +(** [blueprint_injected_on_inbox level] advertizes that a blueprint + for level [level] has been forwarded to a rollup node for + injection on the shared inbox *) +val blueprint_injected_on_inbox : Z.t -> unit Lwt.t + +(** [blueprint_injected_on_DAL level] advertizes that a blueprint + for level [level] has been forwarded to a rollup node for + injection on the DAL *) +val blueprint_injected_on_DAL : Z.t -> unit Lwt.t + (** [blueprint_injection_failed level trace] advertizes that a blueprint could not be injected for level [level]. *) val blueprint_injection_failed : Z.t -> tztrace -> unit Lwt.t diff --git a/etherlink/bin_node/lib_dev/blueprints_publisher.ml b/etherlink/bin_node/lib_dev/blueprints_publisher.ml index da77ed155027..eb874ce94b6d 100644 --- a/etherlink/bin_node/lib_dev/blueprints_publisher.ml +++ b/etherlink/bin_node/lib_dev/blueprints_publisher.ml @@ -118,11 +118,13 @@ module Worker = struct [`External payload] ) when use_dal && dal_last_used < level -> (state self).dal_last_used <- level ; + let*! () = Blueprint_events.blueprint_injected_on_DAL level in Rollup_services.publish_on_dal ~rollup_node_endpoint ~slot_index payload | _ -> + let*! () = Blueprint_events.blueprint_injected_on_inbox level in Rollup_services.publish ~keep_alive:false ~rollup_node_endpoint -- GitLab From dde9f41906fa69530e52a1a8f8b6801b8f9cd225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 23 Jul 2024 17:47:54 +0200 Subject: [PATCH 08/15] Etherlink/Sequencer/DAL/Tests: add a DAL-specific test --- etherlink/tezt/tests/evm_sequencer.ml | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index e434130809f6..7a90a5248484 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -775,6 +775,81 @@ let test_publish_blueprints = let* () = Lwt_unix.sleep 2. in check_head_consistency ~left:sequencer ~right:proxy () +(* This test is similar to test_publish_blueprints but it also checks + that all 5 blueprints sent from the sequencer were published on the + DAL (and none on the inbox). *) +let test_publish_blueprints_on_dal = + register_all + ~time_between_blocks:Nothing + ~tags:["evm"; "sequencer"; "data"] + ~title:"Sequencer publishes the blueprints to the DAL" + (* We want this test in the CI so we put no extra tags when DAL + is active to avoid having the [ci_disabled] or [slow] tag. *) + ~use_dal:(Register_both {extra_tags_with = []; extra_tags_without = []}) + @@ fun {sequencer; proxy; client; sc_rollup_node; enable_dal; _} _protocol -> + let number_of_blueprints = 5 in + + let number_of_blueprints_sent_to_inbox = ref 0 in + let number_of_blueprints_sent_to_dal = ref 0 in + + let count_event event counter = + Evm_node.wait_for sequencer event (fun _level -> + incr counter ; + (* We return None here to keep the loop running *) + None) + in + + let inbox_counter_p = + count_event + "blueprint_injection_on_inbox.v0" + number_of_blueprints_sent_to_inbox + in + + let dal_counter_p = + count_event "blueprint_injection_on_DAL.v0" number_of_blueprints_sent_to_dal + in + + let* _ = + repeat number_of_blueprints (fun () -> + let*@ _ = produce_block sequencer in + unit) + in + + (* Wait more to avoid flakiness, in particular with DAL *) + let timeout = if enable_dal then 50. else 5. in + let* () = + Evm_node.wait_for_blueprint_injected ~timeout sequencer number_of_blueprints + in + + (* At this point, the evm node should called the batcher endpoint to publish + all the blueprints. Stopping the node is then not a problem. *) + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in + + (* We have unfortunately noticed that the test can be flaky. Sometimes, + the following RPC is done before the proxy being initialised, even though + we wait for it. The source of flakiness is unknown but happens very rarely, + we put a small sleep to make the least flaky possible. *) + let* () = Lwt_unix.sleep 2. in + let* () = check_head_consistency ~left:sequencer ~right:proxy () in + let expected_nb_of_bp_on_dal, expected_nb_of_bp_on_inbox = + if enable_dal then (number_of_blueprints, 0) else (0, number_of_blueprints) + in + Check.(expected_nb_of_bp_on_dal = !number_of_blueprints_sent_to_dal) + ~__LOC__ + Check.int + ~error_msg: + "Wrong number of blueprints published on the DAL; Expected %L, got %R." ; + Check.(expected_nb_of_bp_on_inbox = !number_of_blueprints_sent_to_inbox) + ~__LOC__ + Check.int + ~error_msg: + "Wrong number of blueprints published on the inbox; Expected %L, got %R." ; + Lwt.cancel dal_counter_p ; + Lwt.cancel inbox_counter_p ; + unit + let test_sequencer_too_ahead = let max_blueprints_ahead = 5 in register_all @@ -4827,6 +4902,7 @@ let () = test_remove_sequencer protocols ; test_persistent_state protocols ; test_publish_blueprints protocols ; + test_publish_blueprints_on_dal protocols ; test_sequencer_too_ahead protocols ; test_resilient_to_rollup_node_disconnect protocols ; test_can_fetch_smart_rollup_address protocols ; -- GitLab From 0a764bd9de35e5d279aace4fac7ee1ecce223a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 10 Jul 2024 11:14:44 +0200 Subject: [PATCH 09/15] Etherlink/Tests: when looking for outbox, allow to set the depth --- etherlink/tezt/lib/helpers.ml | 9 ++++++--- etherlink/tezt/lib/helpers.mli | 11 ++++++++--- etherlink/tezt/tests/evm_rollup.ml | 3 +++ etherlink/tezt/tests/evm_sequencer.ml | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/etherlink/tezt/lib/helpers.ml b/etherlink/tezt/lib/helpers.ml index d928493ffe11..24015afc7243 100644 --- a/etherlink/tezt/lib/helpers.ml +++ b/etherlink/tezt/lib/helpers.ml @@ -327,7 +327,8 @@ let l1_timestamp client = |> Tezos_base.Time.Protocol.of_notation_exn) let find_and_execute_withdrawal ~withdrawal_level ~commitment_period - ~challenge_window ~evm_node ~sc_rollup_node ~sc_rollup_address ~client = + ~challenge_window ~evm_node ~sc_rollup_node ~sc_rollup_address ~client + ?(outbox_lookup_depth = 10) () = (* Bake enough levels to have a commitment and cement it. *) let* _ = repeat @@ -340,8 +341,10 @@ let find_and_execute_withdrawal ~withdrawal_level ~commitment_period (* Construct and execute the outbox proof. *) let find_outbox level = let rec aux level' = - if level' > level + 10 then - Test.fail "Looked for an outbox for 10 levels, stopping the loop" + if level' > level + outbox_lookup_depth then + Test.fail + "Looked for an outbox for %d levels, stopping the loop" + outbox_lookup_depth else let* outbox = Sc_rollup_node.RPC.call sc_rollup_node diff --git a/etherlink/tezt/lib/helpers.mli b/etherlink/tezt/lib/helpers.mli index b732b4927045..7e9306ef179d 100644 --- a/etherlink/tezt/lib/helpers.mli +++ b/etherlink/tezt/lib/helpers.mli @@ -201,9 +201,12 @@ val default_bootstrap_account_balance : Wei.t val l1_timestamp : Client.t -> Tezos_base.Time.Protocol.t Lwt.t (** [find_and_execute_withdrawal ~withdrawal_level ~commitment_period ~challenge_window - ~evm_node ~sc_rollup_node ~sc_rollup_address ~client] bakes enough levels to have - a commitment and cement it, then constructs outbox proof - and executes the outbox message *) + ~evm_node ~sc_rollup_node ~sc_rollup_address ~client ?outbox_lookup_depth ()] bakes + enough levels to have a commitment and cement it, then constructs outbox proof and + executes the outbox message. + + Only the [outbox_lookup_depth] (defaults to 10) last levels are + scanned for an outbox message. *) val find_and_execute_withdrawal : withdrawal_level:int -> commitment_period:int -> @@ -212,4 +215,6 @@ val find_and_execute_withdrawal : sc_rollup_node:Sc_rollup_node.t -> sc_rollup_address:string -> client:Client.t -> + ?outbox_lookup_depth:int -> + unit -> int Lwt.t diff --git a/etherlink/tezt/tests/evm_rollup.ml b/etherlink/tezt/tests/evm_rollup.ml index e16470954c0c..1a3c8e582dfe 100644 --- a/etherlink/tezt/tests/evm_rollup.ml +++ b/etherlink/tezt/tests/evm_rollup.ml @@ -2354,6 +2354,7 @@ let withdraw ~commitment_period ~challenge_window ~amount_wei ~sender ~receiver ~sc_rollup_node ~sc_rollup_address ~client + () in unit @@ -5711,6 +5712,7 @@ let test_outbox_size_limit_resilience ~slow = ~sc_rollup_node ~sc_rollup_address ~client + () in let* balance = Client.get_balance_for @@ -5729,6 +5731,7 @@ let test_outbox_size_limit_resilience ~slow = ~sc_rollup_node ~sc_rollup_address ~client + () in let* balance = Client.get_balance_for diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 7a90a5248484..d40761f11b2a 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -1766,6 +1766,7 @@ let test_fa_withdrawal_is_included = ~sc_rollup_node ~sc_rollup_address ~client + () in let* _ = next_rollup_node_level ~sc_rollup_node ~client in -- GitLab From 9c5b56291e9baaf1fb3b9d4c6a810feef99773dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Thu, 27 Jun 2024 15:42:02 +0200 Subject: [PATCH 10/15] Etherlink/DAL/Tests: increase default timeouts --- etherlink/tezt/lib/helpers.ml | 4 ++-- etherlink/tezt/lib/helpers.mli | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/etherlink/tezt/lib/helpers.ml b/etherlink/tezt/lib/helpers.ml index 24015afc7243..479275b786e4 100644 --- a/etherlink/tezt/lib/helpers.ml +++ b/etherlink/tezt/lib/helpers.ml @@ -195,7 +195,7 @@ let sequencer_upgrade ~sc_rollup_address ~sequencer_admin in Client.bake_for_and_wait ~keys:[] client -let bake_until ?__LOC__ ?(timeout_in_blocks = 20) ?(timeout = 30.) ~bake +let bake_until ?__LOC__ ?(timeout_in_blocks = 200) ?(timeout = 600.) ~bake ~result_f () = let res = ref None in let rec go counter_block = @@ -328,7 +328,7 @@ let l1_timestamp client = let find_and_execute_withdrawal ~withdrawal_level ~commitment_period ~challenge_window ~evm_node ~sc_rollup_node ~sc_rollup_address ~client - ?(outbox_lookup_depth = 10) () = + ?(outbox_lookup_depth = 100) () = (* Bake enough levels to have a commitment and cement it. *) let* _ = repeat diff --git a/etherlink/tezt/lib/helpers.mli b/etherlink/tezt/lib/helpers.mli index 7e9306ef179d..6f89db189671 100644 --- a/etherlink/tezt/lib/helpers.mli +++ b/etherlink/tezt/lib/helpers.mli @@ -131,8 +131,8 @@ val sequencer_upgrade : (** [bake_until ?__LOC__ ?timeout_in_blocks ?timeout ~bake ~result_f ()] bakes using function [bake] until the function [result_f] returns a value or fails if: - - it takes more than [timeout] sec, 30. by default. - - it takes more than [timeout_in_blocks] blocks to bake, 5 by default. + - it takes more than [timeout] sec, 600. by default. + - it takes more than [timeout_in_blocks] blocks to bake, 200 by default. *) val bake_until : ?__LOC__:string -> @@ -205,7 +205,7 @@ val l1_timestamp : Client.t -> Tezos_base.Time.Protocol.t Lwt.t enough levels to have a commitment and cement it, then constructs outbox proof and executes the outbox message. - Only the [outbox_lookup_depth] (defaults to 10) last levels are + Only the [outbox_lookup_depth] (defaults to 100) last levels are scanned for an outbox message. *) val find_and_execute_withdrawal : withdrawal_level:int -> -- GitLab From 999864eb0e26c79e4a52d491370be162b4581e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Thu, 27 Jun 2024 15:42:02 +0200 Subject: [PATCH 11/15] Etherlink/DAL/Tests: localize all calls to bake_until_sync --- etherlink/tezt/tests/evm_rollup.ml | 4 + etherlink/tezt/tests/evm_sequencer.ml | 176 ++++++++++++++++++++------ 2 files changed, 139 insertions(+), 41 deletions(-) diff --git a/etherlink/tezt/tests/evm_rollup.ml b/etherlink/tezt/tests/evm_rollup.ml index 1a3c8e582dfe..add06a3a6d89 100644 --- a/etherlink/tezt/tests/evm_rollup.ml +++ b/etherlink/tezt/tests/evm_rollup.ml @@ -4889,6 +4889,7 @@ let test_migrate_proxy_to_sequencer_future = let*@ _ = Rpc.produce_block sequencer_node in let* () = bake_until_sync + ~__LOC__ ~sc_rollup_node ~client ~sequencer:sequencer_node @@ -4914,6 +4915,7 @@ let test_migrate_proxy_to_sequencer_future = in let* () = bake_until_sync + ~__LOC__ ~sc_rollup_node ~client ~sequencer:sequencer_node @@ -5049,6 +5051,7 @@ let test_migrate_proxy_to_sequencer_past = let*@ _ = Rpc.produce_block sequencer_node in let* () = bake_until_sync + ~__LOC__ ~sc_rollup_node ~client ~sequencer:sequencer_node @@ -5074,6 +5077,7 @@ let test_migrate_proxy_to_sequencer_past = in let* () = bake_until_sync + ~__LOC__ ~sc_rollup_node ~client ~sequencer:sequencer_node diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index d40761f11b2a..934a76ecdf87 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -766,7 +766,9 @@ let test_publish_blueprints = (* At this point, the evm node should called the batcher endpoint to publish all the blueprints. Stopping the node is then not a problem. *) - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in (* We have unfortunately noticed that the test can be flaky. Sometimes, the following RPC is done before the proxy being initialised, even though @@ -860,7 +862,9 @@ let test_sequencer_too_ahead = ~use_dal:ci_enabled_dal_registration @@ fun {sequencer; sc_rollup_node; proxy; client; sc_rollup_address; _} _protocol -> - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* () = Sc_rollup_node.terminate sc_rollup_node in let* () = repeat (max_blueprints_ahead + 1) (fun () -> @@ -882,7 +886,9 @@ let test_sequencer_too_ahead = let* () = Sc_rollup_node.run sc_rollup_node sc_rollup_address [] and* () = Evm_node.wait_for_rollup_node_follower_connection_acquired sequencer and* () = Evm_node.wait_for_rollup_node_follower_connection_acquired proxy in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* _ = repeat 2 (fun () -> let* _ = next_rollup_node_level ~sc_rollup_node ~client in @@ -941,7 +947,9 @@ let test_resilient_to_rollup_node_disconnect = in (* Produce some L1 blocks so that the rollup node publishes the blueprints. *) - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let*@ rollup_node_head = Rpc.get_block_by_number ~block:"latest" proxy in Check.( @@ -1032,6 +1040,7 @@ let test_resilient_to_rollup_node_disconnect = the blueprints. *) let* () = bake_until_sync + ~__LOC__ ~timeout_in_blocks:(catchup_cooldown * 3) ~sc_rollup_node ~client @@ -1294,7 +1303,9 @@ let test_delayed_transfer_is_included = ~sc_rollup_node ~client in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* () = check_delayed_inbox_is_empty ~sc_rollup_node in let* sender_balance_next = Eth_cli.balance ~account:sender ~endpoint in let* receiver_balance_next = Eth_cli.balance ~account:receiver ~endpoint in @@ -1361,7 +1372,9 @@ let test_largest_delayed_transfer_is_included = ~sc_rollup_node ~client in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* () = check_delayed_inbox_is_empty ~sc_rollup_node in unit @@ -1415,7 +1428,9 @@ let test_delayed_deposit_is_included = ~sc_rollup_node ~client in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* () = check_delayed_inbox_is_empty ~sc_rollup_node in let* receiver_balance_next = Eth_cli.balance ~account:receiver.address ~endpoint @@ -1523,7 +1538,9 @@ let test_delayed_fa_deposit_is_included = ~sc_rollup_node ~client in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* () = check_delayed_inbox_is_empty ~sc_rollup_node in let* zero_ticket_hash = ticket_hash l1_contracts.ticket_router_tester 0 in @@ -1591,7 +1608,9 @@ let test_delayed_fa_deposit_is_ignored_if_feature_disabled = in let* () = check_delayed_inbox_is_empty ~sc_rollup_node in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* zero_ticket_hash = ticket_hash l1_contracts.ticket_router_tester 0 in @@ -1687,7 +1706,9 @@ let test_fa_withdrawal_is_included = ~sc_rollup_node ~client in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* () = check_delayed_inbox_is_empty ~sc_rollup_node in (* Check that deposit is successful *) @@ -1730,7 +1751,9 @@ let test_fa_withdrawal_is_included = () in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in (* Check that tickets are gone *) let* ticket_balance_after_withdraw = @@ -1807,7 +1830,9 @@ let test_delayed_deposit_from_init_rollup_node = let* receiver_balance_prev = Eth_cli.balance ~account:receiver ~endpoint:(Evm_node.endpoint sequencer) in - let* () = bake_until_sync ~sc_rollup_node ~sequencer ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~sequencer ~proxy ~client () + in (* We don't care about this sequencer. *) let* () = Evm_node.terminate sequencer in (* Send the deposit to delayed inbox, no sequencer will be listening to the @@ -1847,7 +1872,13 @@ let test_delayed_deposit_from_init_rollup_node = unit and* _hash = Evm_node.wait_for_block_producer_tx_injected new_sequencer in let* () = - bake_until_sync ~sc_rollup_node ~proxy ~sequencer:new_sequencer ~client () + bake_until_sync + ~__LOC__ + ~sc_rollup_node + ~proxy + ~sequencer:new_sequencer + ~client + () in let* () = check_delayed_inbox_is_empty ~sc_rollup_node in let* receiver_balance_next = @@ -1877,7 +1908,9 @@ let test_init_from_rollup_node_data_dir = let*@ _ = produce_block sequencer in unit) in - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* () = Evm_node.terminate sequencer and* () = Evm_node.terminate observer in let evm_node' = @@ -1906,7 +1939,13 @@ let test_init_from_rollup_node_data_dir = let*@ _ = produce_block evm_node' in let* () = - bake_until_sync ~sc_rollup_node ~client ~sequencer:evm_node' ~proxy () + bake_until_sync + ~__LOC__ + ~sc_rollup_node + ~client + ~sequencer:evm_node' + ~proxy + () in let* () = check_head_consistency ~left:evm_node' ~right:proxy () in @@ -1946,7 +1985,9 @@ let test_init_from_rollup_node_with_delayed_inbox = } _protocol -> (* a sequencer is needed to produce an initial block *) - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* () = Evm_node.terminate sequencer in (* deposit *) @@ -1987,7 +2028,13 @@ let test_init_from_rollup_node_with_delayed_inbox = let*@ _ = produce_block evm_node' in let* () = - bake_until_sync ~sc_rollup_node ~client ~sequencer:evm_node' ~proxy () + bake_until_sync + ~__LOC__ + ~sc_rollup_node + ~client + ~sequencer:evm_node' + ~proxy + () in let* () = check_head_consistency ~left:evm_node' ~right:proxy () in @@ -2093,7 +2140,9 @@ let test_get_balance_block_param = (* Now we will create another observer initialized from the rollup node, in order to test the block parameter "earliest". "Earliest" on the current sequencer will be block [0] which is not really robust to test. *) - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* _ = repeat 2 (fun _ -> let* _ = next_rollup_node_level ~sc_rollup_node ~client in @@ -2166,7 +2215,9 @@ let test_get_block_by_number_block_param = repeat Int32.(to_int observer_offset) @@ fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client in - let* () = bake_until_sync ~sc_rollup_node ~proxy ~sequencer ~client () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + in let* _ = repeat 2 (fun _ -> let* _ = next_rollup_node_level ~sc_rollup_node ~client in @@ -2534,7 +2585,8 @@ let test_self_upgrade_kernel = unit) in - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () and* _upgrade_info = Evm_node.wait_for_pending_upgrade sequencer in let* () = @@ -2553,7 +2605,9 @@ let test_self_upgrade_kernel = unit) and* _ = Evm_node.wait_for_successful_upgrade sequencer and* _ = Evm_node.wait_for_successful_upgrade observer in - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* () = check_head_consistency @@ -2695,7 +2749,9 @@ let test_upgrade_kernel_auto_sync = let*@ _ = produce_block ~timestamp:"2020-01-01T00:00:05Z" sequencer in unit) in - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* () = check_head_consistency @@ -2714,7 +2770,9 @@ let test_upgrade_kernel_auto_sync = unit) and* _upgrade = Evm_node.wait_for_successful_upgrade sequencer in - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* () = check_head_consistency @@ -2832,7 +2890,9 @@ let test_forced_blueprint_takes_pred_timestamp = (* The head timestamp will be high enough that we don't use the L1 timestamp for the forced blueprint and just take the same timestamp. *) let*@ (_ : int) = produce_block ~timestamp:"2020-01-01T00:04:00Z" sequencer in - let* () = bake_until_sync ~sc_rollup_node ~client ~proxy ~sequencer () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~proxy ~sequencer () + in (* Make a delayed transaction and force it by creating L1 blocks. *) let raw_transfer = "f86d80843b9aca00825b0494b53dc01974176e5dff2298c5a94343c2585e3c54880de0b6b3a764000080820a96a07a3109107c6bd1d555ce70d6253056bc18996d4aff4d4ea43ff175353f49b2e3a05f9ec9764dc4a3c3ab444debe2c3384070de9014d44732162bb33ee04da187ef" @@ -2882,7 +2942,9 @@ let test_forced_blueprint_takes_l1_timestamp = } _protocol -> let*@ (_ : int) = produce_block ~timestamp:"2020-01-01T00:00:00Z" sequencer in - let* () = bake_until_sync ~sc_rollup_node ~client ~proxy ~sequencer () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~proxy ~sequencer () + in (* Make a delayed transaction and force it by creating L1 blocks. *) let raw_transfer = "f86d80843b9aca00825b0494b53dc01974176e5dff2298c5a94343c2585e3c54880de0b6b3a764000080820a96a07a3109107c6bd1d555ce70d6253056bc18996d4aff4d4ea43ff175353f49b2e3a05f9ec9764dc4a3c3ab444debe2c3384070de9014d44732162bb33ee04da187ef" @@ -3004,7 +3066,9 @@ let test_force_kernel_upgrade_too_early = } _protocol -> (* Wait for the sequencer to publish its genesis block. *) - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* proxy = Evm_node.init ~mode:(Proxy {finalized_view = false}) @@ -3068,7 +3132,9 @@ let test_force_kernel_upgrade = } _protocol -> (* Wait for the sequencer to publish its genesis block. *) - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* proxy = Evm_node.init ~mode:(Proxy {finalized_view = false}) @@ -3141,7 +3207,9 @@ let test_external_transaction_to_delayed_inbox_fails = @@ fun {client; sequencer; proxy; sc_rollup_node; _} _protocol -> let* () = Evm_node.wait_for_blueprint_injected ~timeout:5. sequencer 0 in (* Bake a couple more levels for the blueprint to be final *) - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let raw_tx, _ = read_tx_from_file () |> List.hd in let*@ tx_hash = Rpc.send_raw_transaction ~raw_tx proxy in (* Bake enough levels to make sure the transaction would be processed @@ -3333,7 +3401,9 @@ let test_timestamp_from_the_future = (* The sequencer will accept it anyway, but we need to check that the rollup node accepts it. *) let*@ (_ : int) = produce_block ~timestamp:accepted_timestamp sequencer in - let* () = bake_until_sync ~sc_rollup_node ~client ~proxy ~sequencer () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~proxy ~sequencer () + in (* Producing a block 5:30 minutes after the L1 timetamp will be accepted by the sequencer and not the rollup node. *) @@ -3393,7 +3463,9 @@ let test_sequencer_upgrade = _protocol -> (* produce an initial block *) let*@ _lvl = produce_block sequencer in - let* () = bake_until_sync ~proxy ~sequencer ~sc_rollup_node ~client () in + let* () = + bake_until_sync ~__LOC__ ~proxy ~sequencer ~sc_rollup_node ~client () + in let* () = check_head_consistency ~left:proxy @@ -3623,7 +3695,9 @@ let test_sequencer_can_catch_up_on_event = let* _ = produce_block sequencer in unit) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in let* _ = produce_block sequencer in let*@ last_produced_block = Rpc.block_number sequencer in let* () = @@ -3720,7 +3794,9 @@ let test_sequencer_dont_read_level_twice = (* If the logic of the sequencer is correct (i.e., it does not process the deposit twice), then it is possible for the rollup node to apply them. *) - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in unit @@ -3985,7 +4061,9 @@ let test_reset = repeat reset_level (fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in Log.info "Stopping the rollup node, then produce %d more blocks " (reset_level + after_reset_level) ; @@ -4047,7 +4125,9 @@ let test_reset = repeat after_reset_level (fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in (* Check sequencer is at the expected level *) let*@ sequencer_level = Rpc.block_number sequencer in Check.( @@ -4075,7 +4155,9 @@ let test_preimages_endpoint = _; } _protocol -> - let* () = bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy () in + let* () = + bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + in let* () = Evm_node.terminate sequencer in (* Prepares the sequencer without [preimages-dir], to force the use of preimages endpoint. *) @@ -4197,7 +4279,9 @@ let test_replay_rpc = repeat 2 (fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in let blockNumber = match blockNumber with | Some blockNumber -> blockNumber @@ -4244,7 +4328,9 @@ let test_trace_transaction = repeat 2 (fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in (* Check tracing without options works *) let* trace_result = Rpc.trace_transaction ~transaction_hash sequencer in (match trace_result with @@ -4294,7 +4380,9 @@ let test_trace_transaction_on_invalid_transaction = ~tags:["evm"; "rpc"; "trace"; "fail"] ~title:"debug_traceTransaction fails on invalid transactions" @@ fun {sc_rollup_node; sequencer; client; proxy; _} _protocol -> - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in (* Check tracing without options works *) let* trace_result = Rpc.trace_transaction @@ -4410,7 +4498,9 @@ let test_trace_transaction_call = repeat 2 (fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in (* We will first trace with every options enabled, and check that we have the logs as complete as possible. We call the function `set` from the contract, @@ -4430,7 +4520,9 @@ let test_trace_transaction_call = repeat 2 (fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in (* We will use the receipt to check that the results from the trace are consistent with the result from the transaction once applied in the block. *) @@ -4468,7 +4560,9 @@ let test_trace_transaction_call = repeat 2 (fun () -> next_evm_level ~evm_node:sequencer ~sc_rollup_node ~client) in - let* () = bake_until_sync ~sequencer ~sc_rollup_node ~proxy ~client () in + let* () = + bake_until_sync ~__LOC__ ~sequencer ~sc_rollup_node ~proxy ~client () + in let*@ transaction_receipt = Rpc.get_transaction_receipt ~tx_hash:transaction_hash sequencer in -- GitLab From 364f1678f3de22408404416b5986d2db5645c0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Thu, 27 Jun 2024 15:42:02 +0200 Subject: [PATCH 12/15] Etherlink/DAL/Tests: increase some timeouts in tests --- etherlink/tezt/tests/evm_sequencer.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 934a76ecdf87..a2d95f3bdeac 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -2750,7 +2750,14 @@ let test_upgrade_kernel_auto_sync = unit) in let* () = - bake_until_sync ~__LOC__ ~sc_rollup_node ~client ~sequencer ~proxy () + bake_until_sync + ~__LOC__ + ~sc_rollup_node + ~client + ~sequencer + ~proxy + ~timeout_in_blocks:2000 + () in let* () = -- GitLab From 687e4fb172230bfacf8bbbcd8615ec0c1cf3a276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 10 Jul 2024 11:30:51 +0200 Subject: [PATCH 13/15] WIP: increase timeouts --- etherlink/tezt/lib/evm_node.ml | 17 +++++++++++++++-- etherlink/tezt/lib/helpers.ml | 6 +++++- etherlink/tezt/tests/evm_sequencer.ml | 18 ++++++++++++++---- tezt/lib_tezos/sc_rollup_node.ml | 5 ++++- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/etherlink/tezt/lib/evm_node.ml b/etherlink/tezt/lib/evm_node.ml index 409cf36dbc9e..d67cbdd65c60 100644 --- a/etherlink/tezt/lib/evm_node.ml +++ b/etherlink/tezt/lib/evm_node.ml @@ -216,6 +216,7 @@ let resolve_or_timeout ?(timeout = 30.) evm_node ~name promise = | None -> Test.fail "Timeout waiting for %s of %s" name evm_node.name let wait_for_event ?timeout evm_node ~event f = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in resolve_or_timeout ?timeout evm_node ~name:event @@ wait_for evm_node event f let raise_terminated_when_none ?where evm_node ~event promise = @@ -226,10 +227,12 @@ let raise_terminated_when_none ?where evm_node ~event promise = raise (Terminated_before_event {daemon = evm_node.name; event; where}) let wait_for_event_listener ?timeout evm_node ~event promise = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in resolve_or_timeout ?timeout evm_node ~name:event @@ raise_terminated_when_none evm_node ~event promise let wait_for_ready ?timeout evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in match evm_node.status with | Running {session_state = {ready = true; _}; _} -> unit | Not_running | Running {session_state = {ready = false; _}; _} -> @@ -239,6 +242,7 @@ let wait_for_ready ?timeout evm_node = wait_for_event_listener ?timeout evm_node ~event:event_ready_name promise let wait_for_blueprint_injected ?timeout evm_node level = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in match evm_node.status with | Running {session_state = {ready = true; _}; _} when is_sequencer evm_node -> let current_level = evm_node.persistent_state.last_injected_level in @@ -261,6 +265,7 @@ let wait_for_blueprint_injected ?timeout evm_node level = failwith "EVM node is not ready" let wait_for_blueprint_applied ?timeout evm_node level = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in match evm_node.status with | Running {session_state = {ready = true; _}; _} when can_apply_blueprint evm_node -> @@ -292,6 +297,7 @@ let wait_for_invalid_kernel ?timeout evm_node = @@ Fun.const (Some ()) let wait_for_pending_upgrade ?timeout evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in wait_for_event ?timeout evm_node ~event:"pending_upgrade.v0" @@ JSON.( fun json -> @@ -300,6 +306,7 @@ let wait_for_pending_upgrade ?timeout evm_node = Some (root_hash, timestamp)) let wait_for_successful_upgrade ?timeout evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in wait_for_event ?timeout evm_node ~event:"applied_upgrade.v0" @@ JSON.( fun json -> @@ -308,10 +315,12 @@ let wait_for_successful_upgrade ?timeout evm_node = Some (root_hash, level)) let wait_for_block_producer_locked ?timeout evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in wait_for_event ?timeout evm_node ~event:"block_producer_locked.v0" @@ Fun.const (Some ()) let wait_for_block_producer_tx_injected ?timeout evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in wait_for_event ?timeout evm_node @@ -321,6 +330,7 @@ let wait_for_block_producer_tx_injected ?timeout evm_node = Some hash let wait_for_retrying_connect ?timeout evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in wait_for_event ?timeout evm_node ~event:"retrying_connect.v0" @@ Fun.const (Some ()) @@ -333,6 +343,7 @@ let delayed_transaction_kind_of_string = function | s -> Test.fail "%s is neither a transaction or deposit" s let wait_for_rollup_node_follower_connection_acquired ?timeout evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in wait_for_event ?timeout evm_node @@ -399,6 +410,7 @@ let parse_evm_event_kind : type a. a evm_event_kind -> JSON.t -> a option = let wait_for_evm_event ?timeout event ?(check = parse_evm_event_kind event) evm_node = + let timeout = Some (Float.max 300. @@ Option.value timeout ~default:0.) in wait_for_event ?timeout evm_node ~event:"evm_events_new_event.v0" @@ JSON.( fun json -> @@ -431,8 +443,9 @@ let wait_for_rollup_node_ahead evm_node = let level = json |> as_int in Some level -let wait_for_tx_pool_add_transaction ?timeout evm_node = - wait_for_event ?timeout evm_node ~event:"tx_pool_add_transaction.v0" +let wait_for_tx_pool_add_transaction ?(timeout = 60.) evm_node = + let timeout = Float.max 300. timeout in + wait_for_event ~timeout evm_node ~event:"tx_pool_add_transaction.v0" @@ JSON.as_string_opt let create ?(path = Uses.path Constant.octez_evm_node) ?name ?runner diff --git a/etherlink/tezt/lib/helpers.ml b/etherlink/tezt/lib/helpers.ml index 479275b786e4..b530042981bc 100644 --- a/etherlink/tezt/lib/helpers.ml +++ b/etherlink/tezt/lib/helpers.ml @@ -53,7 +53,7 @@ let hex_256_of_int n = Printf.sprintf "%064x" n let next_rollup_node_level ~sc_rollup_node ~client = let* () = Client.bake_for_and_wait ~keys:[] client in - Sc_rollup_node.wait_sync ~timeout:30. sc_rollup_node + Sc_rollup_node.wait_sync ~timeout:500. sc_rollup_node let produce_block ?(wait_on_blueprint_applied = true) ?timestamp evm_node = match Evm_node.mode evm_node with @@ -197,6 +197,10 @@ let sequencer_upgrade ~sc_rollup_address ~sequencer_admin let bake_until ?__LOC__ ?(timeout_in_blocks = 200) ?(timeout = 600.) ~bake ~result_f () = + ignore timeout_in_blocks ; + ignore timeout ; + let timeout_in_blocks = max timeout_in_blocks 20 in + let timeout = Float.max timeout 120. in let res = ref None in let rec go counter_block = let* opt = result_f () in diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index a2d95f3bdeac..8f5dabf3f334 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -367,7 +367,9 @@ let setup_sequencer ?sequencer_rpc_port ?sequencer_private_rpc_port } let send_transaction (transaction : unit -> 'a Lwt.t) sequencer : 'a Lwt.t = - let wait_for = Evm_node.wait_for_tx_pool_add_transaction sequencer in + let wait_for = + Evm_node.wait_for_tx_pool_add_transaction ~timeout:60. sequencer + in (* Send the transaction but doesn't wait to be mined. *) let transaction = transaction () in let* _ = wait_for in @@ -1071,7 +1073,7 @@ let test_can_fetch_blueprint = unit) in - let* () = Evm_node.wait_for_blueprint_injected ~timeout:5. sequencer 5 in + let* () = Evm_node.wait_for_blueprint_injected ~timeout:50. sequencer 5 in let* blueprints = fold number_of_blocks [] (fun i acc -> @@ -2141,7 +2143,15 @@ let test_get_balance_block_param = order to test the block parameter "earliest". "Earliest" on the current sequencer will be block [0] which is not really robust to test. *) let* () = - bake_until_sync ~__LOC__ ~sc_rollup_node ~proxy ~sequencer ~client () + bake_until_sync + ~timeout_in_blocks:180 + ~timeout:500. + ~__LOC__ + ~sc_rollup_node + ~proxy + ~sequencer + ~client + () in let* _ = repeat 2 (fun _ -> @@ -2171,7 +2181,7 @@ let test_get_balance_block_param = observer_partial_history sc_rollup_node in - let* () = Evm_node.run observer_partial_history in + let* () = Evm_node.run observer_partial_history ~wait:true in (* Transfer funds again to the address. *) let*@ level = Rpc.block_number sequencer in let* _tx_hash = diff --git a/tezt/lib_tezos/sc_rollup_node.ml b/tezt/lib_tezos/sc_rollup_node.ml index ac81240c1323..426266c37b37 100644 --- a/tezt/lib_tezos/sc_rollup_node.ml +++ b/tezt/lib_tezos/sc_rollup_node.ml @@ -504,7 +504,10 @@ let unsafe_wait_sync ?timeout sc_node = in wait_for_level ?timeout sc_node node_level -let wait_sync sc_node ~timeout = unsafe_wait_sync sc_node ~timeout +let wait_sync sc_node ~timeout = + ignore timeout ; + let timeout = Float.max timeout 180. in + unsafe_wait_sync sc_node ~timeout let handle_event sc_node {name; value; timestamp = _} = match name with -- GitLab From 40910491e1d9624741c08ba0b51bbe23a538d7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 10 Jul 2024 11:31:47 +0200 Subject: [PATCH 14/15] Add run.sh --- run.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 000000000000..f6bc9bd348f7 --- /dev/null +++ b/run.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +rm -rf /tmp/tezt-* + +cpt=2 + +function run { + name=$1 + cpt=$((cpt + 1)) + + time timeout 300 dune exec etherlink/tezt/tests/main.exe -- alpha latest /ci_disabled /flaky dal --only 1 --keep-temp --match "$name" --verbose &> log + + echo "=========================" + if [ "$(grep -c '\[SUCCESS\]' log)" -eq "1" ]; then + echo "$cpt: $name : SUCCESS" + tail -n 4 log + else + echo "$cpt: $name : FAILURE" + grep -i error log + grep "Temporary files can be found in" log + tmp=$(grep "Temporary files can be found in" log | cut -d ":" -f 4) + grep -i panic "$tmp/sc-rollup-node*/kernel.log" + echo + echo "logs:" + head log + echo "..." + tail log + fi + echo "=========================" +} + +run "Remove sequencer via sequencer admin contract" +run "Sequencer state is persistent across runs" +run "Sequencer publishes the blueprints to L1" +run "Sequencer can return the smart rollup address on demand" +run "Sequencer can provide blueprints on demand" +run "Send a transaction to the delayed inbox" +run "Send a deposit to the delayed inbox" +run "RPC method produceBlock" +run "RPC method getBalance uses block parameter" +run "RPC method getBlockByNumber uses block parameter" +run "Supports extended block parameter" +run "Delayed transaction is included" +run "Delayed deposit is included" +run "Largest possible delayed transaction is included" +run "Delayed inbox is populated at init from rollup node" +run "Sequencer is reimbursed for DA fees" +run "Rollup-node kernel upgrade is applied to the sequencer state." +run "EVM Kernel can upgrade to itself" +run "Force kernel upgrade" +run "Force kernel upgrade fail too early" +run "Sending an external transaction to the delayed inbox fails" +run "Delayed transaction timeout" +run "Delayed transaction timeout considers l1 level" +run "Delayed inbox flushing" +run "No automatic block production" +run "Non increasing timestamp are forbidden" +run "Evm node don\'t read the same level twice" +run "Checks the stage one reboots when reading too much chunks in a single L1 level" +run "Checks the sequencer doesn\'t produce blueprint bigger than the given maximum number of chunks and count delayed transactions size in the blueprint" +run "try to reset sequencer and observer state using the command." +run "Sequencer use remote server to get preimages" +run "Sequencer checks the smart rollup address" +run "Evm node can catchup event from the rollup node" +run "Runs two sequencers, one diverge and stop" + +run "Init evm node sequencer data dir from a rollup node data dir" +run "Evm node can catchup event from the rollup node" +run "Rollup-node kernel upgrade is applied to the sequencer state." +run "Runs two sequencers, one diverge and stop" -- GitLab From bb7cd8d566e4ac1c54edf7e8881dbae327abcb63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 10 Jul 2024 11:31:18 +0200 Subject: [PATCH 15/15] DEBUG --- .../bin_node/lib_dev/blueprint_events.ml | 2 +- .../bin_node/lib_dev/blueprints_publisher.ml | 15 +++++++++++--- etherlink/tezt/lib/helpers.ml | 14 ++++++++++++- etherlink/tezt/tests/evm_sequencer.ml | 20 ++++++++++++++++++- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/etherlink/bin_node/lib_dev/blueprint_events.ml b/etherlink/bin_node/lib_dev/blueprint_events.ml index 79f0ccb14933..bbedda261317 100644 --- a/etherlink/bin_node/lib_dev/blueprint_events.ml +++ b/etherlink/bin_node/lib_dev/blueprint_events.ml @@ -41,7 +41,7 @@ let blueprint_injection = ~section ~name:"blueprint_injection" ~msg:"Injecting a blueprint for level {level}" - ~level:Info + ~level:Notice ("level", Data_encoding.n) let blueprint_injection_on_inbox = diff --git a/etherlink/bin_node/lib_dev/blueprints_publisher.ml b/etherlink/bin_node/lib_dev/blueprints_publisher.ml index eb874ce94b6d..de3db9d28cb3 100644 --- a/etherlink/bin_node/lib_dev/blueprints_publisher.ml +++ b/etherlink/bin_node/lib_dev/blueprints_publisher.ml @@ -101,6 +101,7 @@ module Worker = struct let publish self payload level ~use_dal = let open Lwt_result_syntax in + Format.eprintf "#### call publish with level %a@." Z.pp_print level ; let rollup_node_endpoint = rollup_node_endpoint self in (* We do not check if we succeed or not: this will be done when new L2 heads come from the rollup node. *) @@ -132,16 +133,24 @@ module Worker = struct in let*! () = match res with - | Ok _ -> Blueprint_events.blueprint_injected level + | Ok _ -> + Format.eprintf "#### call publish -> ok@." ; + Blueprint_events.blueprint_injected level | Error trace -> + Format.eprintf "#### call publish -> error@." ; (* We have failed to inject the blueprint. This is probably the sign that the rollup node is down. It will be injected again once the rollup node lag increases to [max_blueprints_lag]. *) Blueprint_events.blueprint_injection_failed level trace in match rollup_is_lagging_behind self with - | No_lag | Needs_republish -> return_unit - | Needs_lock -> Tx_pool.lock_transactions () + | No_lag | Needs_republish -> + Format.eprintf "#### call publish => No_lag | Needs_republish @." ; + + return_unit + | Needs_lock -> + Format.eprintf "#### call publish => Needs_lock @." ; + Tx_pool.lock_transactions () let catch_up worker = let open Lwt_result_syntax in diff --git a/etherlink/tezt/lib/helpers.ml b/etherlink/tezt/lib/helpers.ml index b530042981bc..ec5de8d2e53c 100644 --- a/etherlink/tezt/lib/helpers.ml +++ b/etherlink/tezt/lib/helpers.ml @@ -216,6 +216,9 @@ let bake_until ?__LOC__ ?(timeout_in_blocks = 200) ?(timeout = 600.) ~bake still false." timeout_in_blocks else + let () = + Format.eprintf "## bake (counter_block: %d)@." counter_block + in let* _ = bake () in go (counter_block + 1) in @@ -235,8 +238,17 @@ let bake_until_sync ?__LOC__ ?timeout_in_blocks ?timeout ~sc_rollup_node ~proxy let* proxy_level_opt = Rpc.block_number_opt proxy in let*@ sequencer_level = Rpc.block_number sequencer in match proxy_level_opt with - | Error _ | Ok None -> Lwt.return_none + | Error _ | Ok None -> + Format.eprintf + "#### sequencer_level: %ld, NO proxy_level@." + sequencer_level ; + + Lwt.return_none | Ok (Some proxy_level) -> + Format.eprintf + "#### sequencer_level: %ld, proxy_level: %ld@." + sequencer_level + proxy_level ; if sequencer_level < proxy_level then Test.fail ~loc:__LOC__ diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 8f5dabf3f334..03bdf8b927f4 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -370,13 +370,19 @@ let send_transaction (transaction : unit -> 'a Lwt.t) sequencer : 'a Lwt.t = let wait_for = Evm_node.wait_for_tx_pool_add_transaction ~timeout:60. sequencer in + Format.eprintf "### AAA@." ; (* Send the transaction but doesn't wait to be mined. *) let transaction = transaction () in + Format.eprintf "### BBB@." ; let* _ = wait_for in + Format.eprintf "### CCC@." ; (* Once the transaction is in the transaction pool the next block will include it. *) let*@ _ = produce_block sequencer in + Format.eprintf "### DDD@." ; (* Resolve the transaction send to make sure it was included. *) - transaction + let* s = transaction in + Format.eprintf "### EEE@." ; + return s let send_raw_transaction_to_delayed_inbox ?(wait_for_next_level = true) ?(amount = Tez.one) ?expect_failure ~sc_rollup_node ~client ~l1_contracts @@ -2121,6 +2127,7 @@ let test_get_balance_block_param = @@ fun {sequencer; sc_rollup_node; proxy; client; _} _protocol -> (* Transfer funds to a random address. *) let address = "0xB7A97043983f24991398E5a82f63F4C58a417185" in + Format.eprintf "## X1@." ; let* _tx_hash = send_transaction (Eth_cli.transaction_send @@ -2130,11 +2137,14 @@ let test_get_balance_block_param = ~endpoint:(Evm_node.endpoint sequencer)) sequencer in + Format.eprintf "## X2@." ; (* Check the balance on genesis block and latest block. *) let*@ balance_genesis = Rpc.get_balance ~address ~block:(Number 0) sequencer in + Format.eprintf "## X3@." ; let*@ balance_now = Rpc.get_balance ~address ~block:Latest sequencer in + Format.eprintf "## X4@." ; Check.((balance_genesis = Wei.of_eth_int 0) Wei.typ) ~error_msg:(sf "%s should have no funds at genesis, but got %%L" address) ; Check.((balance_now = Wei.of_eth_int 10) Wei.typ) @@ -2142,6 +2152,7 @@ let test_get_balance_block_param = (* Now we will create another observer initialized from the rollup node, in order to test the block parameter "earliest". "Earliest" on the current sequencer will be block [0] which is not really robust to test. *) + Format.eprintf "## X5@." ; let* () = bake_until_sync ~timeout_in_blocks:180 @@ -2153,11 +2164,13 @@ let test_get_balance_block_param = ~client () in + Format.eprintf "## X6@." ; let* _ = repeat 2 (fun _ -> let* _ = next_rollup_node_level ~sc_rollup_node ~client in unit) in + Format.eprintf "## X7@." ; let observer_partial_history = let name = "observer_partial_history" in Evm_node.create @@ -2173,6 +2186,7 @@ let test_get_balance_block_param = ~data_dir:(Temp.dir name) (Evm_node.endpoint sequencer) in + Format.eprintf "## X8@." ; let* () = Process.check @@ Evm_node.spawn_init_config observer_partial_history in @@ -2181,9 +2195,11 @@ let test_get_balance_block_param = observer_partial_history sc_rollup_node in + Format.eprintf "## X9@." ; let* () = Evm_node.run observer_partial_history ~wait:true in (* Transfer funds again to the address. *) let*@ level = Rpc.block_number sequencer in + Format.eprintf "## X10@." ; let* _tx_hash = send_transaction (Eth_cli.transaction_send @@ -2193,11 +2209,13 @@ let test_get_balance_block_param = ~endpoint:(Evm_node.endpoint sequencer)) sequencer in + Format.eprintf "## X11@." ; let* () = Evm_node.wait_for_blueprint_applied observer_partial_history (Int32.to_int level + 1) in + Format.eprintf "## X12@." ; (* Observer does not know block 0. *) let*@? (_error : Rpc.error) = Rpc.get_balance ~address ~block:(Number 0) observer_partial_history -- GitLab