Repository navigation
refactor: deduplicate membership lookup in automated claim target - #195
Open
franrolotti wants to merge 1 commit into
Open
franrolotti wants to merge 1 commit into
franrolotti wants to merge 1 commit into
Conversation
…er list _executeAutomatedClaimTarget copied the whole member array across an external call just to find one index. Read it with the O(1) SavingCircles.memberIndex getter instead (now part of ISavingCircles), and drop the redundant NotMember pre-check since isMemberWithdrawable and withdrawFor already reject non-members. A non-member target now fails with NotWithdrawable instead of NotMember.
Contributor
Coverage Report
Coverage by file
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #168
What
AutomaticSavingCircles._executeAutomatedClaimTargetcalledgetCircleMembers(copying the whole member array across an external call) only to find one member's index, then re-resolved membership again insideisMemberWithdrawableandwithdrawFor.SavingCircles.memberIndex, an O(1) mapping lookup, instead of fetching the array.memberIndexalready existed onSavingCircles; it is now declared inISavingCircles(addsoverride/@inheritdoc, no logic or storage change).NotMemberpre-check:isMemberWithdrawableandwithdrawForalready reject non-members._getMemberIndexhelper.The batch/view paths (
getEligibleAutomatedClaims, the eligible count) really do iterate every member, so they are unchanged.Behavior change
A non-member target (an address can opt in to automatic claims without being a member) now fails with
NotWithdrawableinstead ofNotMember. This is visible in theAutomatedClaimFailedevent reason, so worth a look if an indexer or the frontend keys off it. Covered by a new test. Nothing can be claimed for a non-member either way.memberIndexreturns 0 for non-members, indistinguishable from the first member, which is why the eligibility check is what rejects them. This is documented on the interface.Gas
forge snapshotonAutomaticSavingCircles.t.sol, before -> after:BatchExecuteAutomatedClaims_ContinuesWhenOneTargetFailsClaimCheckerPayload_ClaimsForEligibleMembersAcrossAllCirclesPerformUpkeep_ClaimsForEligibleMembersAcrossAllCirclesSmall on purpose: the test circles have only a few members, and the saved work grows with member count.
Deployment note
AutomaticSavingCirclesis not upgradeable and points atSavingCirclesvia constructor, so this needs a redeploy of the automation contract, and the target network'sSavingCirclesmust already exposememberIndex(uint256,address).Test plan
forge fmt --checkforge test(all suites pass; 38 inAutomaticSavingCircles, 1 new)