Skip to content

Commit a76885d

Browse files
committed
chore: document reentrancy risk vector
Signed-off-by: Tomás Migone <[email protected]>
1 parent 456c9eb commit a76885d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/contracts/contracts/staking/Staking.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,6 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M
819819
require(isIndexerOrOperator, "!auth");
820820
}
821821

822-
823822
// -- Rewards Distribution --
824823

825824
// Process non-zero-allocation rewards tracking
@@ -844,6 +843,8 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M
844843
}
845844

846845
// Close the allocation
846+
// Note that this breaks CEI pattern. We update after the rewards distribution logic as it expects the allocation
847+
// to still be active. There shouldn't be reentrancy risk here as all internal calls are to trusted contracts.
847848
__allocations[_allocationID].closedAtEpoch = alloc.closedAtEpoch;
848849

849850
emit AllocationClosed(

packages/horizon/contracts/staking/HorizonStakingExtension.sol

+2
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ contract HorizonStakingExtension is HorizonStakingBase, IHorizonStakingExtension
376376
}
377377

378378
// Close the allocation
379+
// Note that this breaks CEI pattern. We update after the rewards distribution logic as it expects the allocation
380+
// to still be active. There shouldn't be reentrancy risk here as all internal calls are to trusted contracts.
379381
__DEPRECATED_allocations[_allocationID].closedAtEpoch = alloc.closedAtEpoch;
380382

381383
emit AllocationClosed(

0 commit comments

Comments
 (0)