fix: remove non reentrant#1553
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
📝 WalkthroughWalkthroughThis PR systematically removes reentrancy guard protections ( ChangesReentrancy Guard Removal
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/enclave-contracts/contracts/Enclave.sol (1)
1156-1163:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPreserve
claimRewardsreturn value to avoid ABI breakage.Removing the return value changes externally observable behavior; existing integrators decoding
uint256can break at runtime. Keep the return for backward compatibility.Suggested compatibility fix
- function claimRewards(uint256[] calldata e3Ids) external { + function claimRewards( + uint256[] calldata e3Ids + ) external returns (uint256 totalClaimed) { uint256 len = e3Ids.length; - uint256 totalClaimed; for (uint256 i = 0; i < len; i++) { totalClaimed += _claimReward(e3Ids[i], msg.sender); } require(totalClaimed > 0, NothingToClaim()); + return totalClaimed; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/enclave-contracts/contracts/Enclave.sol` around lines 1156 - 1163, The claimRewards function removed its uint256 return value causing an ABI break; restore the original external signature to return uint256 and return totalClaimed at the end while keeping the existing logic (accumulate totalClaimed via _claimReward(e3Ids[i], msg.sender) and the require(totalClaimed > 0, NothingToClaim()) check) so callers continue receiving the claimed amount.packages/enclave-contracts/contracts/registry/BondingRegistry.sol (1)
444-464:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
bondLicensestill hasnonReentrantmodifier - inconsistent with PR goal.This function retains the
nonReentrantmodifier (line 446) while other similar functions (claimExits,distributeRewards,withdrawSlashedFunds) have had it removed. This appears inconsistent with the PR's stated objective of removing reentrancy guards.If the intent is to keep
nonReentranthere due to the externalsafeTransferFromcall followed by state updates, the same logic should apply to other functions. Otherwise, remove it for consistency.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/enclave-contracts/contracts/registry/BondingRegistry.sol` around lines 444 - 464, The bondLicense function still has the nonReentrant modifier which is inconsistent with the PR's removal of reentrancy guards; remove the nonReentrant modifier from the bondLicense function signature (function bondLicense(uint256 amount) external ...) so its declaration matches other functions like claimExits/distributeRewards/withdrawSlashedFunds, and verify that the safeTransferFrom -> operators[msg.sender].licenseBond state update sequence in bondLicense remains safe without the modifier (no additional imports/guards need to be left behind).
🧹 Nitpick comments (1)
packages/enclave-contracts/contracts/token/EnclaveTicketToken.sol (1)
51-58: ⚡ Quick winInconsistent:
ReentrancyGuardstill inherited but only partially used.The contract still inherits
ReentrancyGuard(line 57) and imports it (lines 26-27), butnonReentrantis removed frompayoutandrescueERC20while retained ondepositFor,depositFrom, andwithdrawTo.If the PR goal is to remove reentrancy guards, this should be done consistently. If some functions genuinely need the guard while others don't, document why.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/enclave-contracts/contracts/token/EnclaveTicketToken.sol` around lines 51 - 58, The contract EnclaveTicketToken inconsistently retains ReentrancyGuard inheritance and import while only applying nonReentrant to some functions (depositFor, depositFrom, withdrawTo) but not to payout and rescueERC20; either remove the ReentrancyGuard import and the ERC20Wrapper/ReentrancyGuard inheritance entirely and strip nonReentrant from the remaining functions, or consistently apply the guard by adding nonReentrant to payout and rescueERC20 and keep the import and inheritance; make the choice and update the contract declaration and imports accordingly, and if you intentionally keep mixed usage, add a short comment next to each function (depositFor, depositFrom, withdrawTo, payout, rescueERC20) documenting why it does or does not require nonReentrant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/enclave-contracts/contracts/Enclave.sol`:
- Around line 1156-1163: The claimRewards function removed its uint256 return
value causing an ABI break; restore the original external signature to return
uint256 and return totalClaimed at the end while keeping the existing logic
(accumulate totalClaimed via _claimReward(e3Ids[i], msg.sender) and the
require(totalClaimed > 0, NothingToClaim()) check) so callers continue receiving
the claimed amount.
In `@packages/enclave-contracts/contracts/registry/BondingRegistry.sol`:
- Around line 444-464: The bondLicense function still has the nonReentrant
modifier which is inconsistent with the PR's removal of reentrancy guards;
remove the nonReentrant modifier from the bondLicense function signature
(function bondLicense(uint256 amount) external ...) so its declaration matches
other functions like claimExits/distributeRewards/withdrawSlashedFunds, and
verify that the safeTransferFrom -> operators[msg.sender].licenseBond state
update sequence in bondLicense remains safe without the modifier (no additional
imports/guards need to be left behind).
---
Nitpick comments:
In `@packages/enclave-contracts/contracts/token/EnclaveTicketToken.sol`:
- Around line 51-58: The contract EnclaveTicketToken inconsistently retains
ReentrancyGuard inheritance and import while only applying nonReentrant to some
functions (depositFor, depositFrom, withdrawTo) but not to payout and
rescueERC20; either remove the ReentrancyGuard import and the
ERC20Wrapper/ReentrancyGuard inheritance entirely and strip nonReentrant from
the remaining functions, or consistently apply the guard by adding nonReentrant
to payout and rescueERC20 and keep the import and inheritance; make the choice
and update the contract declaration and imports accordingly, and if you
intentionally keep mixed usage, add a short comment next to each function
(depositFor, depositFrom, withdrawTo, payout, rescueERC20) documenting why it
does or does not require nonReentrant.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7d5a104c-b68e-4bb2-8575-cbca64c77bb1
📒 Files selected for processing (13)
packages/enclave-contracts/artifacts/contracts/Enclave.sol/Enclave.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/ISlashingManager.sol/ISlashingManager.jsonpackages/enclave-contracts/artifacts/contracts/registry/CiphernodeRegistryOwnable.sol/CiphernodeRegistryOwnable.jsonpackages/enclave-contracts/artifacts/contracts/token/EnclaveTicketToken.sol/EnclaveTicketToken.jsonpackages/enclave-contracts/contracts/E3RefundManager.solpackages/enclave-contracts/contracts/Enclave.solpackages/enclave-contracts/contracts/registry/BondingRegistry.solpackages/enclave-contracts/contracts/registry/CiphernodeRegistryOwnable.solpackages/enclave-contracts/contracts/slashing/SlashingManager.solpackages/enclave-contracts/contracts/token/EnclaveTicketToken.sol
Summary by CodeRabbit
Release Notes
claimRewardsfunction to no longer return a value.