diff --git a/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.mligo b/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.mligo index ee54065fca05004f039b31a9e473c07f298960f7..80c7e468430ecbd41805d184b98ecd2ba8e5898d 100644 --- a/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.mligo +++ b/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.mligo @@ -42,21 +42,18 @@ let main {transaction; evm_rollup} store : return = let chunks = chunk_bytes transaction in let n_chunks : nat = List.length chunks in let operations = - if n_chunks = 1n then - [Tezos.transaction (Other transaction) 0mutez evm_rollup] - else - // First message to announce the chunk bytes - let new_chunk_payload = Bytes.concat 0x00 (bytes n_chunks) in - let announce = - Tezos.transaction (Other new_chunk_payload) 0mutez evm_rollup - in - let chunks = - List.fold_left (fun (acc, chunk) -> + // First message to announce the chunk bytes + let new_chunk_payload = Bytes.concat 0x00 (bytes n_chunks) in + let announce = + Tezos.transaction (Other new_chunk_payload) 0mutez evm_rollup + in + let chunks = + List.fold_left (fun (acc, chunk) -> let chunk_payload = Bytes.concat 0x01 chunk in Tezos.transaction (Other chunk_payload) 0mutez evm_rollup :: acc) - [] chunks - in - announce :: chunks + [] chunks + in + announce :: chunks in // Burn the tez let burn_contract = diff --git a/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.tz b/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.tz index a1d9cfa7c17f1f4af51255ae3be6545b4d45b628..f18fc1e7537a62696b37e38c078179913e0d1eab 100644 --- a/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.tz +++ b/etherlink/tezos_contracts/chunked_delayed_transaction_bridge.tz @@ -58,57 +58,46 @@ PAIR ; LEFT (list bytes) } } } ; SWAP ; + DIG 3 ; DIG 5 ; - DROP 2 ; + DROP 3 ; DUP ; SIZE ; - PUSH nat 1 ; - DUP 2 ; - COMPARE ; - EQ ; - IF { DROP 2 ; - NIL operation ; - SWAP ; - PUSH mutez 0 ; - DIG 3 ; - RIGHT (pair bytes (ticket (pair nat (option bytes)))) ; - LEFT bytes ; - TRANSFER_TOKENS } - { DIG 3 ; - DROP ; - BYTES ; - PUSH bytes 0x00 ; - PAIR ; - DUP 3 ; - PUSH mutez 0 ; - DIG 2 ; - UNPAIR ; - CONCAT ; - RIGHT (pair bytes (ticket (pair nat (option bytes)))) ; - LEFT bytes ; - TRANSFER_TOKENS ; - NIL operation ; - DIG 2 ; - ITER { SWAP ; - DUP 4 ; - PUSH mutez 0 ; - DIG 3 ; - PUSH bytes 0x01 ; - CONCAT ; - RIGHT (pair bytes (ticket (pair nat (option bytes)))) ; - LEFT bytes ; - TRANSFER_TOKENS ; - CONS } ; - DIG 2 ; - DROP ; - SWAP } ; - CONS ; + BYTES ; + PUSH bytes 0x00 ; + PAIR ; + DUP 3 ; + PUSH mutez 0 ; + DIG 2 ; + UNPAIR ; + CONCAT ; + RIGHT (pair bytes (ticket (pair nat (option bytes)))) ; + LEFT bytes ; + TRANSFER_TOKENS ; + NIL operation ; + DIG 2 ; + ITER { SWAP ; + DUP 4 ; + PUSH mutez 0 ; + DIG 3 ; + PUSH bytes 0x01 ; + CONCAT ; + RIGHT (pair bytes (ticket (pair nat (option bytes)))) ; + LEFT bytes ; + TRANSFER_TOKENS ; + CONS } ; + DIG 2 ; + DROP ; PUSH address "tz1burnburnburnburnburnburnburjAYjjX" ; CONTRACT unit ; IF_NONE { PUSH string "Invalid burn address" ; FAILWITH } {} ; PUSH mutez 1000000 ; UNIT ; TRANSFER_TOKENS ; + DIG 3 ; + DIG 2 ; + DIG 3 ; + CONS ; + DIG 2 ; CONS ; PAIR } } } - diff --git a/etherlink/tezt/lib/contract_path.ml b/etherlink/tezt/lib/contract_path.ml index 085a530c2b09f9aa49047e9cd642c04a435f2294..db7a6c2a91818f409bd33e6898a7c6000c09c229 100644 --- a/etherlink/tezt/lib/contract_path.ml +++ b/etherlink/tezt/lib/contract_path.ml @@ -19,10 +19,17 @@ let withdrawal_abi_path () = let fa_withdrawal_abi_path () = Base.(project_root // "etherlink/tezos_contracts/fa_withdrawal.abi") -let delayed_path () = - Base.( - project_root - // "etherlink/tezos_contracts/chunked_delayed_transaction_bridge.tz") +let delayed_path ~kernel = + (* The path to the delayed transaction bridge depends on the version + of the kernel. The versions which don't support chunking must use + "delayed_transaction_bridge.tz", the versions which do support + chunking must use "chunked_delayed_transaction_bridge.tz" *) + let contract_basename = + match kernel with + | Kernel.Latest -> "chunked_delayed_transaction_bridge" + | Mainnet | Ghostnet -> "delayed_transaction_bridge" + in + Base.(project_root // sf "etherlink/tezos_contracts/%s.tz" contract_basename) let ticket_router_tester_path () = Base.( diff --git a/etherlink/tezt/lib/setup.ml b/etherlink/tezt/lib/setup.ml index 02c063463b6e721f55aecfecfacd21793cd33038..186d8593e2b7fc6b3ca22263951f975804cfe0b3 100644 --- a/etherlink/tezt/lib/setup.ml +++ b/etherlink/tezt/lib/setup.ml @@ -40,14 +40,14 @@ let uses _protocol = Constant.smart_rollup_installer; ] -let setup_l1_contracts ?(dictator = Constant.bootstrap2) client = +let setup_l1_contracts ?(dictator = Constant.bootstrap2) ~kernel client = (* Originates the delayed transaction bridge. *) let* delayed_transaction_bridge = Client.originate_contract ~alias:"evm-seq-delayed-bridge" ~amount:Tez.zero ~src:Constant.bootstrap1.public_key_hash - ~prg:(delayed_path ()) + ~prg:(delayed_path ~kernel) ~burn_cap:Tez.one client in @@ -193,7 +193,9 @@ let setup_sequencer ?next_wasm_runtime ?block_storage_sqlite3 else none in let client = Client.with_dal_node client ?dal_node in - let* l1_contracts = setup_l1_contracts client in + let* l1_contracts = + setup_l1_contracts ~kernel:(Kernel.of_use kernel) client + in let sc_rollup_node = Sc_rollup_node.create ~default_operator:Constant.bootstrap1.public_key_hash diff --git a/etherlink/tezt/lib/setup.mli b/etherlink/tezt/lib/setup.mli index 84834c3b7401673b195aadfb4f1a77f36ec74d57..2fcdd88ad4e533401c2e34706cb2baeb914ee9c3 100644 --- a/etherlink/tezt/lib/setup.mli +++ b/etherlink/tezt/lib/setup.mli @@ -33,9 +33,10 @@ type sequencer_setup = { (** [uses protocol] returns the list of dependencies for the tests. *) val uses : Protocol.t -> Uses.t list -(** [setup_l1_contracts ~dictator client] setups the necessary contracts for the - rollup. *) -val setup_l1_contracts : ?dictator:Account.key -> Client.t -> l1_contracts Lwt.t +(** [setup_l1_contracts ~dictator ~kernel client] setups the necessary + contracts for the rollup. *) +val setup_l1_contracts : + ?dictator:Account.key -> kernel:Kernel.t -> Client.t -> l1_contracts Lwt.t (** [run_new_rpc_endpoint node] starts a new rpc node following the setup. *) val run_new_rpc_endpoint : Evm_node.t -> Evm_node.t Lwt.t