From ba7976b7c0151f7654365cb924ab7ad4d4ecb2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 2 Jul 2025 14:17:29 +0200 Subject: [PATCH] Tezlink/Kernel: increment counter after successfully applying an operation --- etherlink/kernel_latest/kernel/src/block.rs | 2 +- .../kernel_latest/tezos_execution/src/account_storage.rs | 8 ++++++++ etherlink/kernel_latest/tezos_execution/src/lib.rs | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/etherlink/kernel_latest/kernel/src/block.rs b/etherlink/kernel_latest/kernel/src/block.rs index f7af9894a467..1b4801ca7e81 100644 --- a/etherlink/kernel_latest/kernel/src/block.rs +++ b/etherlink/kernel_latest/kernel/src/block.rs @@ -1147,7 +1147,7 @@ mod tests { // Bootstrap 1 transfer 35 mutez to bootstrap 2 let transfer = make_transaction_operation( 0, - 1, + 2, 0, 0, src.clone(), diff --git a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs index 284e7447d80a..5f7846461862 100644 --- a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs +++ b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs @@ -138,6 +138,14 @@ impl TezlinkImplicitAccount { store_bin(counter, host, &path) } + /// Set the **counter** for the Tezlink account to the successor of the current value. + pub fn increment_counter( + &mut self, + host: &mut impl Runtime, + ) -> Result<(), tezos_storage::error::Error> { + self.set_counter(host, &Narith(self.counter(host)?.0 + 1u64)) + } + pub fn manager( &self, host: &impl Runtime, diff --git a/etherlink/kernel_latest/tezos_execution/src/lib.rs b/etherlink/kernel_latest/tezos_execution/src/lib.rs index c6cfa4697b12..ca837eb02d4d 100644 --- a/etherlink/kernel_latest/tezos_execution/src/lib.rs +++ b/etherlink/kernel_latest/tezos_execution/src/lib.rs @@ -145,6 +145,7 @@ fn reveal( // Set the public key as the manager account.set_manager_public_key(host, public_key)?; + account.increment_counter(host)?; log!(host, Debug, "Reveal operation succeed"); @@ -249,6 +250,7 @@ pub fn transfer( } }; + src_account.increment_counter(host)?; Ok(Ok(success)) } -- GitLab