From 13b5ffd9679fbd3d3879911ff5d781aa2db82f66 Mon Sep 17 00:00:00 2001 From: xtep-1 Date: Wed, 2 Sep 2026 14:33:23 +0100 Subject: [PATCH] fix: enter reentrancy guard before validation --- contracts/tholos-v2/src/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/contracts/tholos-v2/src/lib.rs b/contracts/tholos-v2/src/lib.rs index 9f2fccc..5e961d0 100644 --- a/contracts/tholos-v2/src/lib.rs +++ b/contracts/tholos-v2/src/lib.rs @@ -961,6 +961,7 @@ impl TholosV2 { /// the new assertion id. Emits `Asserted`. pub fn assert_outcome(env: Env, asserter: Address, outcome: bool) -> Result { asserter.require_auth(); + Self::enter_reentrancy_guard(&env)?; Self::require_not_paused(&env)?; let policy: PolicySnapshotV2 = env @@ -975,7 +976,6 @@ impl TholosV2 { // not-yet-incremented id. let id = Self::create_pending_assertion(&env, asserter.clone(), outcome)?; - Self::enter_reentrancy_guard(&env)?; token::Client::new(&env, &policy.token).transfer( &asserter, env.current_contract_address(), @@ -1039,7 +1039,6 @@ impl TholosV2 { assertion.final_outcome = Some(assertion.outcome); assertion.finalizer = Some(caller.clone()); Self::set_assertion(&env, id, &assertion); - Self::enter_reentrancy_guard(&env)?; let token_client = token::Client::new(&env, &assertion.policy.token); if reward > 0 { @@ -1072,6 +1071,7 @@ impl TholosV2 { /// Emits `Disputed`. pub fn dispute(env: Env, disputer: Address, id: u64) -> Result<(), Error> { disputer.require_auth(); + Self::enter_reentrancy_guard(&env)?; let mut assertion: AssertionV2 = env .storage() @@ -1138,7 +1138,6 @@ impl TholosV2 { }; Self::set_resolution(&env, id, &resolution, &policy); - Self::enter_reentrancy_guard(&env)?; token::Client::new(&env, &policy.token).transfer( &disputer, env.current_contract_address(), @@ -1185,7 +1184,7 @@ impl TholosV2 { commitment: BytesN<32>, ) -> Result<(), Error> { voter.require_auth(); - + Self::enter_reentrancy_guard(&env)?; let assertion: AssertionV2 = env .storage() .persistent() @@ -1280,7 +1279,6 @@ impl TholosV2 { resolution.eligible_total = new_total; Self::set_resolution(&env, id, &resolution, &assertion.policy); - Self::enter_reentrancy_guard(&env)?; token::Client::new(&env, &assertion.policy.token).transfer( &voter, env.current_contract_address(), @@ -1973,7 +1971,7 @@ impl TholosV2 { ) -> Result { owner.require_auth(); Self::check_reentrancy_guard(&env)?; - + Self::enter_reentrancy_guard(&env)?; let assertion: AssertionV2 = env .storage() .persistent() @@ -2015,7 +2013,6 @@ impl TholosV2 { .ok_or(Error::SettlementArithmeticOverflow)?; Self::set_resolution(&env, id, &resolution, &assertion.policy); - Self::enter_reentrancy_guard(&env)?; token::Client::new(&env, &assertion.policy.token).transfer( &env.current_contract_address(), &destination,