From f283c0400f246160001a13eef90254b4a24f2f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 30 Jul 2025 01:34:26 +0200 Subject: [PATCH 1/2] Tezlink/Kernel/Transfer: increment counter This is a bugfix. Co-authored-by: Brahima Dibassi --- etherlink/kernel_latest/tezos_execution/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/etherlink/kernel_latest/tezos_execution/src/lib.rs b/etherlink/kernel_latest/tezos_execution/src/lib.rs index 26f86ad98269..808f7f2dbcff 100644 --- a/etherlink/kernel_latest/tezos_execution/src/lib.rs +++ b/etherlink/kernel_latest/tezos_execution/src/lib.rs @@ -100,6 +100,7 @@ fn reveal( // Set the public key as the manager account.set_manager_public_key(host, public_key)?; + // TODO : Counter Increment should be done after successful validation (see issue #8031) account.increment_counter(host)?; log!(host, Debug, "Reveal operation succeed"); @@ -149,7 +150,7 @@ pub fn transfer( }; // Delegate to appropriate handler - match dest { + let success = match dest { Contract::Implicit(dest_key_hash) => { if parameter.is_some() { return Ok(Err(TransferError::NonSmartContractExecutionCall.into())); @@ -213,7 +214,10 @@ pub fn transfer( Err(err) => Ok(Err(err.into())), } } - } + }; + // TODO : Counter Increment should be done after successful validation (see issue #8031) + src_account.increment_counter(host)?; + success } /// Prepares balance updates when accounting fees in the format expected by the Tezos operation. -- GitLab From a2d814195822029c569c62e43ecaa953c3bae0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 30 Jul 2025 01:04:29 +0200 Subject: [PATCH 2/2] Tezlink/Kernel/Transfer/Tests: test counter is incremented --- .../kernel_latest/tezos_execution/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/etherlink/kernel_latest/tezos_execution/src/lib.rs b/etherlink/kernel_latest/tezos_execution/src/lib.rs index 808f7f2dbcff..fbdbd6907c92 100644 --- a/etherlink/kernel_latest/tezos_execution/src/lib.rs +++ b/etherlink/kernel_latest/tezos_execution/src/lib.rs @@ -848,6 +848,11 @@ mod tests { }); assert_eq!(receipt, expected_receipt); + assert_eq!( + account.counter(&host).unwrap(), + 0.into(), + "Counter should not have been incremented" + ); } // Test an invalid operation where the provided public key is inconsistent for the source @@ -1073,6 +1078,13 @@ mod tests { // Verify that source and destination balances changed assert_eq!(source.balance(&host).unwrap(), 5_u64.into()); assert_eq!(destination.balance(&host).unwrap(), 80_u64.into()); + + // Verify that the source's counter has been incremented + assert_eq!( + source.counter(&host).unwrap(), + 1.into(), + "Counter should have been incremented" + ); } // Bootstrap 1 successfully transfers 30 mutez to itself @@ -1302,5 +1314,10 @@ mod tests { assert_eq!(destination.balance(&host).unwrap(), 50_u64.into()); assert_eq!(receipt, expected_receipt); + assert_eq!( + source.counter(&host).unwrap(), + 0.into(), + "Counter should not have been incremented" + ); } } -- GitLab