diff --git a/.gas-snapshot b/.gas-snapshot index aa23632..ef938ca 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,169 +1,172 @@ -DenyHelperPalmeraModuleTest:testAddToList() (gas: 404709) -DenyHelperPalmeraModuleTest:testDropFromList() (gas: 415502) -DenyHelperPalmeraModuleTest:testEnableAllowlist() (gas: 90558) -DenyHelperPalmeraModuleTest:testEnableDenylist() (gas: 90225) -DenyHelperPalmeraModuleTest:testGetPrevUserList() (gas: 415871) -DenyHelperPalmeraModuleTest:testIfAfterAddtoListtheLengthisCorrect() (gas: 404379) -DenyHelperPalmeraModuleTest:testRevertAddToDuplicateAddress() (gas: 411841) -DenyHelperPalmeraModuleTest:testRevertAddToListInvalidAddress() (gas: 297709) -DenyHelperPalmeraModuleTest:testRevertAddToListZeroAddress() (gas: 108095) -DenyHelperPalmeraModuleTest:testRevertIfCallAnotherSafeNotRegistered() (gas: 6748447) -DenyHelperPalmeraModuleTest:testRevertIfDenyHelpersDisabled() (gas: 235798) -DenyHelperPalmeraModuleTest:testRevertIfInvalidAddressProvidedForAllowList() (gas: 417424) -DenyHelperPalmeraModuleTest:testRevertIfInvalidAddressProvidedForDenyList() (gas: 417078) -DenyHelperPalmeraModuleTest:testRevertIfListEmptyForAllowList() (gas: 226569) -DenyHelperPalmeraModuleTest:testRevertIfListEmptyForDenyList() (gas: 226385) -DenyHelperPalmeraModuleTest:testRevertInvalidRootSafe() (gas: 403902) -DenyHelperPalmeraModuleTest:testRevertInvalidSafe() (gas: 187500) -EventsChekers:testEventWhenAddSafe() (gas: 1335206) -EventsChekers:testEventWhenAddToList() (gas: 986470) -EventsChekers:testEventWhenDisconnectSafe() (gas: 1328961) -EventsChekers:testEventWhenDropFromList() (gas: 993855) -EventsChekers:testEventWhenExecutionOnBehalf() (gas: 1890774) -EventsChekers:testEventWhenPromoteRootSafe() (gas: 2032117) -EventsChekers:testEventWhenRegisterRootOrg() (gas: 732308) -EventsChekers:testEventWhenRegisterRootSafe() (gas: 1341662) -EventsChekers:testEventWhenRemoveSafe() (gas: 1390107) -EventsChekers:testEventWhenRemoveWholeTree() (gas: 2542702) -EventsChekers:testEventWhenUpdateNewLimit() (gas: 1373392) -EventsChekers:testEventWhenUpdateSuper() (gas: 2450584) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_ROOT_SAFE_and_Target_Root_SameTree_2_levels() (gas: 2574080) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SameTree() (gas: 1946646) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_SAFE_LEAD_as_EOA_is_TARGETS_LEAD() (gas: 1872012) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD() (gas: 3820526) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_SUPER_SAFE_as_SAFE_is_TARGETS_LEAD_SameTree() (gas: 2585080) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES() (gas: 2514040) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Inverse_WAY() (gas: 2695800) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Straight_way() (gas: 2695647) -ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Straight_way_from_superSafe() (gas: 2698364) -ExecTransactionOnBehalf:testCannot_ExecTransactionOnBehalf_Wrapper_ExecTransactionOnBehalf_ChildSafe_over_RootSafe_With_SAFE() (gas: 3306476) -ExecTransactionOnBehalf:testReentrancyAttack() (gas: 6555896) -ExecTransactionOnBehalf:testRevertInvalidAddressProvidedExecTransactionOnBehalfScenarioOne() (gas: 1751060) -ExecTransactionOnBehalf:testRevertInvalidSafeExecTransactionOnBehalf() (gas: 1742597) -ExecTransactionOnBehalf:testRevertInvalidSignatureExecOnBehalf() (gas: 1865119) -ExecTransactionOnBehalf:testRevertOrgNotRegisteredExecTransactionOnBehalfScenarioThree() (gas: 1758031) -ExecTransactionOnBehalf:testRevertSuperSafeExecOnBehalf() (gas: 3034249) -ExecTransactionOnBehalf:testRevertZeroAddressProvidedExecTransactionOnBehalfScenarioTwo() (gas: 1740320) -ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_INVALID_SIGNATURES() (gas: 2444491) -ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Inverse_WAY_incomplete() (gas: 2606045) -ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Straight_way_incomplete() (gas: 2606240) -ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_WRONG_SIGNATURES() (gas: 2428272) -Hierarchies:testAddSafe() (gas: 1701435) -Hierarchies:testAddSubSafe() (gas: 2319338) -Hierarchies:testCreateSafeThreeTiersTree() (gas: 2304655) +DenyHelperPalmeraModuleTest:testAddToList() (gas: 404557) +DenyHelperPalmeraModuleTest:testDropFromList() (gas: 415382) +DenyHelperPalmeraModuleTest:testEnableAllowlist() (gas: 90454) +DenyHelperPalmeraModuleTest:testEnableDenylist() (gas: 90165) +DenyHelperPalmeraModuleTest:testGetPrevUserList() (gas: 415707) +DenyHelperPalmeraModuleTest:testIfAfterAddtoListtheLengthisCorrect() (gas: 404227) +DenyHelperPalmeraModuleTest:testRevertAddToDuplicateAddress() (gas: 411757) +DenyHelperPalmeraModuleTest:testRevertAddToListInvalidAddress() (gas: 297649) +DenyHelperPalmeraModuleTest:testRevertAddToListZeroAddress() (gas: 108023) +DenyHelperPalmeraModuleTest:testRevertIfCallAnotherSafeNotRegistered() (gas: 6748151) +DenyHelperPalmeraModuleTest:testRevertIfDenyHelpersDisabled() (gas: 235726) +DenyHelperPalmeraModuleTest:testRevertIfInvalidAddressProvidedForAllowList() (gas: 417308) +DenyHelperPalmeraModuleTest:testRevertIfInvalidAddressProvidedForDenyList() (gas: 417006) +DenyHelperPalmeraModuleTest:testRevertIfListEmptyForAllowList() (gas: 226465) +DenyHelperPalmeraModuleTest:testRevertIfListEmptyForDenyList() (gas: 226325) +DenyHelperPalmeraModuleTest:testRevertInvalidRootSafe() (gas: 403628) +DenyHelperPalmeraModuleTest:testRevertInvalidSafe() (gas: 186648) +EventsChekers:testEventWhenAddSafe() (gas: 1334777) +EventsChekers:testEventWhenAddToList() (gas: 986201) +EventsChekers:testEventWhenDisconnectSafe() (gas: 1328414) +EventsChekers:testEventWhenDropFromList() (gas: 993574) +EventsChekers:testEventWhenExecutionOnBehalf() (gas: 1890189) +EventsChekers:testEventWhenPromoteRootSafe() (gas: 2031412) +EventsChekers:testEventWhenRegisterRootOrg() (gas: 732083) +EventsChekers:testEventWhenRegisterRootSafe() (gas: 1341268) +EventsChekers:testEventWhenRemoveSafe() (gas: 1389596) +EventsChekers:testEventWhenRemoveWholeTree() (gas: 2542056) +EventsChekers:testEventWhenUpdateNewLimit() (gas: 1372903) +EventsChekers:testEventWhenUpdateSuper() (gas: 2449891) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_ROOT_SAFE_and_Target_Root_SameTree_2_levels() (gas: 2573447) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SameTree() (gas: 1946217) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_SAFE_LEAD_as_EOA_is_TARGETS_LEAD() (gas: 1871605) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD() (gas: 3819489) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_SUPER_SAFE_as_SAFE_is_TARGETS_LEAD_SameTree() (gas: 2584447) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES() (gas: 2513407) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Inverse_WAY() (gas: 2695123) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Straight_way() (gas: 2694970) +ExecTransactionOnBehalf:testCan_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Straight_way_from_superSafe() (gas: 2697687) +ExecTransactionOnBehalf:testCannot_ExecTransactionOnBehalf_Wrapper_ExecTransactionOnBehalf_ChildSafe_over_RootSafe_With_SAFE() (gas: 3305589) +ExecTransactionOnBehalf:testReentrancyAttack() (gas: 6555389) +ExecTransactionOnBehalf:testRevertInvalidAddressProvidedExecTransactionOnBehalfScenarioOne() (gas: 1750631) +ExecTransactionOnBehalf:testRevertInvalidSafeExecTransactionOnBehalf() (gas: 1742157) +ExecTransactionOnBehalf:testRevertInvalidSignatureExecOnBehalf() (gas: 1864690) +ExecTransactionOnBehalf:testRevertOrgNotRegisteredExecTransactionOnBehalfScenarioThree() (gas: 1757602) +ExecTransactionOnBehalf:testRevertSuperSafeExecOnBehalf() (gas: 3033400) +ExecTransactionOnBehalf:testRevertZeroAddressProvidedExecTransactionOnBehalfScenarioTwo() (gas: 1739891) +ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_INVALID_SIGNATURES() (gas: 2443858) +ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Inverse_WAY_incomplete() (gas: 2605390) +ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_RIGHTS_SIGNATURES_signed_one_by_one_Straight_way_incomplete() (gas: 2605585) +ExecTransactionOnBehalf:testRevert_ExecTransactionOnBehalf_as_EOA_is_NOT_ROLE_with_WRONG_SIGNATURES() (gas: 2427639) +Hierarchies:testAddMultipleSafesAndCheckIndexIncrement() (gas: 2778700) +Hierarchies:testAddSafe() (gas: 1701028) +Hierarchies:testAddSafeAndCheckIndexIncrement() (gas: 1704517) +Hierarchies:testAddSubSafe() (gas: 2318897) +Hierarchies:testCreateSafeThreeTiersTree() (gas: 2304082) Hierarchies:testExpectInvalidSafeId() (gas: 15018) -Hierarchies:testExpectSafeNotRegistered() (gas: 17428) -Hierarchies:testIsSuperSafe() (gas: 2931230) -Hierarchies:testOrgFourTiersTreeSuperSafeRoles() (gas: 2921274) -Hierarchies:testRegisterRootOrg() (gas: 361089) -Hierarchies:testRevertIfTryInvalidLimit() (gas: 1749395) -Hierarchies:testRevertIfTryNotRootSafe() (gas: 4399997) -Hierarchies:testRevertSafeAlreadyRegisteredAddSafe() (gas: 2333075) -Hierarchies:testRevertUpdateSuperIfCallerIsNotSafe() (gas: 1653395) -Hierarchies:testRevertUpdateSuperIfCallerNotPartofTheOrg() (gas: 3101855) -Hierarchies:testRevertUpdateSuperInvalidSafeId() (gas: 1672439) -Hierarchies:testRevertifExceedMaxDepthTreeLimit() (gas: 5818178) -Hierarchies:testRevertifExceedMaxDepthTreeLimitAndUpdateSuper() (gas: 7979872) -Hierarchies:testRevertifUpdateDepthTreeLimitAndUpdateSuperToAnotherOrg() (gas: 12362499) -Hierarchies:testRevertifUpdateLimitAndExceedMaxDepthTreeLimit() (gas: 10769308) -Hierarchies:testRevertifUpdateLimitAndExceedMaxDepthTreeLimitAndUpdateSuper() (gas: 12996277) -Hierarchies:testRevertifUpdateSuperToAnotherOrg() (gas: 7316217) -Hierarchies:testTreeOrgsTreeMember() (gas: 3772316) -Hierarchies:testUpdateSuper() (gas: 3652293) -ModifySafeOwners:testCan_AddOwnerWithThreshold_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 2437850) -ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_EOA_is_TARGETS_LEAD() (gas: 1841996) -ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_SAFE_is_TARGETS_LEAD() (gas: 3256690) -ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_as_EOA_is_TARGETS_LEAD() (gas: 3183439) -ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD() (gas: 3256968) -ModifySafeOwners:testCan_AddOwnerWithThreshold_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 2448755) -ModifySafeOwners:testCan_RemoveOwner_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 2394019) -ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_EOA_is_TARGETS_LEAD() (gas: 1809082) -ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_SAFE_is_TARGETS_LEAD() (gas: 3216799) -ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_as_EOA_is_TARGETS_LEAD() (gas: 1813480) -ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD() (gas: 2545634) -ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD_DifferentTree() (gas: 3198843) -ModifySafeOwners:testCan_RemoveOwner_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 2404842) -ModifySafeOwners:testRevertInvalidThresholdAddOwnerWithThreshold() (gas: 1889660) -ModifySafeOwners:testRevertInvalidThresholdRemoveOwner() (gas: 1860737) -ModifySafeOwners:testRevertOwnerAlreadyExistsAddOwnerWithThreshold() (gas: 1795452) -ModifySafeOwners:testRevertOwnerNotFoundRemoveOwner() (gas: 496391) -ModifySafeOwners:testRevertRootSafeToAttemptTo_AddOwnerWithThreshold_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 3043566) -ModifySafeOwners:testRevertRootSafeToAttemptTo_AddOwnerWithThreshold_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 4472412) -ModifySafeOwners:testRevertRootSafeToAttemptTo_removeOwner_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 3045009) -ModifySafeOwners:testRevertRootSafeToAttemptTo_removeOwner_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 4473426) -ModifySafeOwners:testRevertRootSafesAttemptToAddToExternalSafeOrg() (gas: 3032883) -ModifySafeOwners:testRevertRootSafesToAttemptToRemoveFromExternalOrg() (gas: 3046243) +Hierarchies:testExpectSafeNotRegistered() (gas: 17384) +Hierarchies:testIsSuperSafe() (gas: 2930601) +Hierarchies:testOrgFourTiersTreeSuperSafeRoles() (gas: 2920425) +Hierarchies:testRegisterRootOrg() (gas: 360914) +Hierarchies:testRegisterRootOrgAndCheckIndexIncrement() (gas: 2293153) +Hierarchies:testRevertIfTryInvalidLimit() (gas: 1749098) +Hierarchies:testRevertIfTryNotRootSafe() (gas: 4398939) +Hierarchies:testRevertSafeAlreadyRegisteredAddSafe() (gas: 2332535) +Hierarchies:testRevertUpdateSuperIfCallerIsNotSafe() (gas: 1653142) +Hierarchies:testRevertUpdateSuperIfCallerNotPartofTheOrg() (gas: 3101217) +Hierarchies:testRevertUpdateSuperInvalidSafeId() (gas: 1672116) +Hierarchies:testRevertifExceedMaxDepthTreeLimit() (gas: 5816709) +Hierarchies:testRevertifExceedMaxDepthTreeLimitAndUpdateSuper() (gas: 7978050) +Hierarchies:testRevertifUpdateDepthTreeLimitAndUpdateSuperToAnotherOrg() (gas: 12359637) +Hierarchies:testRevertifUpdateLimitAndExceedMaxDepthTreeLimit() (gas: 10766688) +Hierarchies:testRevertifUpdateLimitAndExceedMaxDepthTreeLimitAndUpdateSuper() (gas: 12993447) +Hierarchies:testRevertifUpdateSuperToAnotherOrg() (gas: 7314407) +Hierarchies:testTreeOrgsTreeMember() (gas: 3771534) +Hierarchies:testUpdateSuper() (gas: 3651300) +ModifySafeOwners:testCan_AddOwnerWithThreshold_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 2437277) +ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_EOA_is_TARGETS_LEAD() (gas: 1841611) +ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_SAFE_is_TARGETS_LEAD() (gas: 3255942) +ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_as_EOA_is_TARGETS_LEAD() (gas: 3182735) +ModifySafeOwners:testCan_AddOwnerWithThreshold_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD() (gas: 3256220) +ModifySafeOwners:testCan_AddOwnerWithThreshold_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 2448182) +ModifySafeOwners:testCan_RemoveOwner_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 2393402) +ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_EOA_is_TARGETS_LEAD() (gas: 1808653) +ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_MODIFY_OWNERS_ONLY_as_SAFE_is_TARGETS_LEAD() (gas: 3216007) +ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_as_EOA_is_TARGETS_LEAD() (gas: 1813051) +ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD() (gas: 2544995) +ModifySafeOwners:testCan_RemoveOwner_SAFE_LEAD_as_SAFE_is_TARGETS_LEAD_DifferentTree() (gas: 3198095) +ModifySafeOwners:testCan_RemoveOwner_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 2404225) +ModifySafeOwners:testRevertInvalidThresholdAddOwnerWithThreshold() (gas: 1889319) +ModifySafeOwners:testRevertInvalidThresholdRemoveOwner() (gas: 1860264) +ModifySafeOwners:testRevertOwnerAlreadyExistsAddOwnerWithThreshold() (gas: 1795067) +ModifySafeOwners:testRevertOwnerNotFoundRemoveOwner() (gas: 496197) +ModifySafeOwners:testRevertRootSafeToAttemptTo_AddOwnerWithThreshold_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 3042906) +ModifySafeOwners:testRevertRootSafeToAttemptTo_AddOwnerWithThreshold_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 4471442) +ModifySafeOwners:testRevertRootSafeToAttemptTo_removeOwner_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SAFE() (gas: 3044305) +ModifySafeOwners:testRevertRootSafeToAttemptTo_removeOwner_SUPER_SAFE_as_SAFE_is_TARGETS_SUPER_SAFE() (gas: 4472412) +ModifySafeOwners:testRevertRootSafesAttemptToAddToExternalSafeOrg() (gas: 3032223) +ModifySafeOwners:testRevertRootSafesToAttemptToRemoveFromExternalOrg() (gas: 3045539) ModifySafeOwners:testRevertSafeNotRegisteredAddOwnerWithThreshold_EOA_Caller() (gas: 935280) -ModifySafeOwners:testRevertSafeNotRegisteredAddOwnerWithThreshold_SAFE_Caller() (gas: 939146) -ModifySafeOwners:testRevertSafeNotRegisteredRemoveOwner_EOA_Caller() (gas: 504383) -ModifySafeOwners:testRevertSafeNotRegisteredRemoveOwner_SAFE_Caller() (gas: 508613) -ModifySafeOwners:testRevertZeroAddressAddOwnerWithThreshold() (gas: 1673402) -ModifySafeOwners:testRevertZeroAddressProvidedRemoveOwner() (gas: 3080343) -PalmeraGuardTest:testCanPromoteToRoot_As_ROOTSAFE_TARGET_SUPER_SAFE() (gas: 2503230) -PalmeraGuardTest:testCanRemoveWholeTree() (gas: 4044631) -PalmeraGuardTest:testCanRemoveWholeTreeFourthLevel() (gas: 3130944) -PalmeraGuardTest:testCannotDisablePalmeraGuardAfterRemoveSafe() (gas: 1888696) -PalmeraGuardTest:testCannotDisablePalmeraGuardIfGuardEnabled() (gas: 1792778) -PalmeraGuardTest:testCannotDisablePalmeraModuleAfterRemoveSafe() (gas: 1826382) -PalmeraGuardTest:testCannotDisablePalmeraModuleIfGuardEnabled() (gas: 1782819) -PalmeraGuardTest:testCannotDisconnectSafe_As_ROOTSAFE_TARGET_ITSELF_If_Have_children() (gas: 1742583) -PalmeraGuardTest:testCannotDisconnectSafe_As_ROOTSAFE_TARGET_ROOTSAFE_SAME_TREE() (gas: 2332575) -PalmeraGuardTest:testCannotDisconnectSafe_As_RootSafe_As_DifferentTree() (gas: 4680166) -PalmeraGuardTest:testCannotDisconnectSafe_As_SafeLead_As_EOA() (gas: 2383586) -PalmeraGuardTest:testCannotDisconnectSafe_As_SafeLead_As_SAFE() (gas: 2786548) -PalmeraGuardTest:testCannotDisconnectSafe_As_SuperSafe_As_DifferentTree() (gas: 4651568) -PalmeraGuardTest:testCannotDisconnectSafe_As_SuperSafe_As_SameTree() (gas: 2424124) -PalmeraGuardTest:testCannotPromoteToRoot_As_ROOTSAFE_TARGET_SUPER_SAFE_ANOTHER_ORG() (gas: 4647252) -PalmeraGuardTest:testCannotPromoteToRoot_As_ROOTSAFE_TARGET_SUPER_SAFE_ANOTHER_TREE() (gas: 4560917) -PalmeraGuardTest:testCannotPromoteToRoot_As_ROOTSAFE_TARGET_safe_SAFE() (gas: 2433622) -PalmeraGuardTest:testCannotReplayAttackDisconnectedSafe() (gas: 1710223) -PalmeraGuardTest:testCannotReplayAttackRemoveSafe() (gas: 1783925) -PalmeraGuardTest:testCannotReplayAttackRemoveWholeTree() (gas: 3124422) +ModifySafeOwners:testRevertSafeNotRegisteredAddOwnerWithThreshold_SAFE_Caller() (gas: 939135) +ModifySafeOwners:testRevertSafeNotRegisteredRemoveOwner_EOA_Caller() (gas: 504339) +ModifySafeOwners:testRevertSafeNotRegisteredRemoveOwner_SAFE_Caller() (gas: 508569) +ModifySafeOwners:testRevertZeroAddressAddOwnerWithThreshold() (gas: 1673061) +ModifySafeOwners:testRevertZeroAddressProvidedRemoveOwner() (gas: 3079507) +PalmeraGuardTest:testCanPromoteToRoot_As_ROOTSAFE_TARGET_SUPER_SAFE() (gas: 2502665) +PalmeraGuardTest:testCanRemoveWholeTree() (gas: 4043485) +PalmeraGuardTest:testCanRemoveWholeTreeFourthLevel() (gas: 3130034) +PalmeraGuardTest:testCannotDisablePalmeraGuardAfterRemoveSafe() (gas: 1888289) +PalmeraGuardTest:testCannotDisablePalmeraGuardIfGuardEnabled() (gas: 1792393) +PalmeraGuardTest:testCannotDisablePalmeraModuleAfterRemoveSafe() (gas: 1825975) +PalmeraGuardTest:testCannotDisablePalmeraModuleIfGuardEnabled() (gas: 1782434) +PalmeraGuardTest:testCannotDisconnectSafe_As_ROOTSAFE_TARGET_ITSELF_If_Have_children() (gas: 1742242) +PalmeraGuardTest:testCannotDisconnectSafe_As_ROOTSAFE_TARGET_ROOTSAFE_SAME_TREE() (gas: 2332032) +PalmeraGuardTest:testCannotDisconnectSafe_As_RootSafe_As_DifferentTree() (gas: 4679042) +PalmeraGuardTest:testCannotDisconnectSafe_As_SafeLead_As_EOA() (gas: 2382999) +PalmeraGuardTest:testCannotDisconnectSafe_As_SafeLead_As_SAFE() (gas: 2785961) +PalmeraGuardTest:testCannotDisconnectSafe_As_SuperSafe_As_DifferentTree() (gas: 4650444) +PalmeraGuardTest:testCannotDisconnectSafe_As_SuperSafe_As_SameTree() (gas: 2423559) +PalmeraGuardTest:testCannotPromoteToRoot_As_ROOTSAFE_TARGET_SUPER_SAFE_ANOTHER_ORG() (gas: 4646150) +PalmeraGuardTest:testCannotPromoteToRoot_As_ROOTSAFE_TARGET_SUPER_SAFE_ANOTHER_TREE() (gas: 4559903) +PalmeraGuardTest:testCannotPromoteToRoot_As_ROOTSAFE_TARGET_safe_SAFE() (gas: 2433035) +PalmeraGuardTest:testCannotReplayAttackDisconnectedSafe() (gas: 1709882) +PalmeraGuardTest:testCannotReplayAttackRemoveSafe() (gas: 1783540) +PalmeraGuardTest:testCannotReplayAttackRemoveWholeTree() (gas: 3123573) PalmeraGuardTest:testDisablePalmeraGuard() (gas: 133480) PalmeraGuardTest:testDisablePalmeraModule() (gas: 104728) -PalmeraGuardTest:testDisconnectSafeBeforeToRemoveSafe_One_Level() (gas: 2303201) -PalmeraGuardTest:testDisconnectSafeBeforeToRemoveSafe_Two_Level() (gas: 2932360) -PalmeraGuardTest:testDisconnectSafe_As_ROOTSAFE_TARGET_ITSELF_If_Not_Have_children() (gas: 1904860) -PalmeraGuardTest:testDisconnectSafe_As_ROOTSAFE_TARGET_ROOT_SAFE() (gas: 2394819) -PalmeraGuardTest:testDisconnectSafe_As_ROOTSAFE_TARGET_SUPERSAFE_SAME_TREE() (gas: 1706722) -PalmeraGuardTestFallbackAndReceive:testFallbackFunctionNonExistentFunction() (gas: 5738) -PalmeraGuardTestFallbackAndReceive:testFallbackFunctionSendETHWithInvalidData() (gas: 15353) -PalmeraGuardTestFallbackAndReceive:testReceiveFunctionSendETHWithoutData() (gas: 15405) -PalmeraModuleTestFallbackAndReceive:testFallbackFunctionSendETHWithInvalidData() (gas: 16469) -PalmeraModuleTestFallbackAndReceive:testReceiveFunctionSendETHWithoutData() (gas: 15381) +PalmeraGuardTest:testDisconnectSafeBeforeToRemoveSafe_One_Level() (gas: 2302658) +PalmeraGuardTest:testDisconnectSafeBeforeToRemoveSafe_Two_Level() (gas: 2931599) +PalmeraGuardTest:testDisconnectSafe_As_ROOTSAFE_TARGET_ITSELF_If_Not_Have_children() (gas: 1904475) +PalmeraGuardTest:testDisconnectSafe_As_ROOTSAFE_TARGET_ROOT_SAFE() (gas: 2394210) +PalmeraGuardTest:testDisconnectSafe_As_ROOTSAFE_TARGET_SUPERSAFE_SAME_TREE() (gas: 1706337) +PalmeraGuardTestFallbackAndReceive:testFallbackFunctionNonExistentFunction() (gas: 5702) +PalmeraGuardTestFallbackAndReceive:testFallbackFunctionSendETHWithInvalidData() (gas: 15317) +PalmeraGuardTestFallbackAndReceive:testReceiveFunctionSendETHWithoutData() (gas: 15357) +PalmeraModuleTestFallbackAndReceive:testFallbackFunctionSendETHWithInvalidData() (gas: 16389) +PalmeraModuleTestFallbackAndReceive:testReceiveFunctionSendETHWithoutData() (gas: 15333) PalmeraRoleDeployTest:testSetUserRoles() (gas: 32281) PalmeraRoleDeployTest:testSetupRolesCapabilities() (gas: 157726) PalmeraRolesTest:testCan_PalmeraModule_Setup_RoleContract() (gas: 18152) -PalmeraRolesTest:testCan_ROOT_SAFE_SetRole_ROOT_SAFE_When_RegisterOrg() (gas: 261534) -PalmeraRolesTest:testCan_ROOT_SAFE_SetRole_SAFE_LEAD_to_EAO() (gas: 1755898) -PalmeraRolesTest:testCan_ROOT_SAFE_SetRole_SAFE_LEAD_to_SAFE() (gas: 2193262) -PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_ROOT_SAFE_to_EAO() (gas: 1680920) -PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_ROOT_SAFE_to_EOA_DifferentTree_Safe() (gas: 3013752) -PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_SUPER_SAFE_to_EAO() (gas: 1680827) -PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_SUPER_SAFE_to_SAFE() (gas: 2304690) -PalmeraRolesTest:testCannot_SUPER_SAFE_SetRole_SAFE_LEAD_to_EAO() (gas: 1680276) -PalmeraRolesTestFallbackAndReceive:testFallbackFunctionNonExistentFunction() (gas: 5963) -PalmeraRolesTestFallbackAndReceive:testFallbackFunctionSendETHWithInvalidData() (gas: 15578) -PalmeraRolesTestFallbackAndReceive:testReceiveFunctionSendETHWithoutData() (gas: 15405) -TestDeploy:testDeploy() (gas: 6284229) +PalmeraRolesTest:testCan_ROOT_SAFE_SetRole_ROOT_SAFE_When_RegisterOrg() (gas: 261381) +PalmeraRolesTest:testCan_ROOT_SAFE_SetRole_SAFE_LEAD_to_EAO() (gas: 1755513) +PalmeraRolesTest:testCan_ROOT_SAFE_SetRole_SAFE_LEAD_to_SAFE() (gas: 2192877) +PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_ROOT_SAFE_to_EAO() (gas: 1680579) +PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_ROOT_SAFE_to_EOA_DifferentTree_Safe() (gas: 3013136) +PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_SUPER_SAFE_to_EAO() (gas: 1680486) +PalmeraRolesTest:testCannot_ROOT_SAFE_SetRole_SUPER_SAFE_to_SAFE() (gas: 2304117) +PalmeraRolesTest:testCannot_SUPER_SAFE_SetRole_SAFE_LEAD_to_EAO() (gas: 1679935) +PalmeraRolesTestFallbackAndReceive:testFallbackFunctionNonExistentFunction() (gas: 5927) +PalmeraRolesTestFallbackAndReceive:testFallbackFunctionSendETHWithInvalidData() (gas: 15542) +PalmeraRolesTestFallbackAndReceive:testReceiveFunctionSendETHWithoutData() (gas: 15357) +TestDeploy:testDeploy() (gas: 6114694) TestDeploySafe:testTransferFundsSafe() (gas: 109281) TestEnableGuard:testEnablePalmeraGuard() (gas: 120836) TestEnableGuard:testEnablePalmeraModule() (gas: 122054) TestEnableModule:testEnablePalmeraModule() (gas: 122115) TestEnableModule:testNewSafeWithPalmeraModule() (gas: 469426) -TestPalmeraSafe:testAuthorityAddress() (gas: 10847) -TestPalmeraSafe:testCan_RemoveSafe_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SameTree() (gas: 3026108) -TestPalmeraSafe:testCan_RemoveSafe_SUPER_SAFE_as_SAFE_is_SUPER_SAFE_SameTree() (gas: 2411689) -TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_not_root_of_target() (gas: 1687260) -TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_not_super_safe_of_target() (gas: 2310553) -TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_root_of_target() (gas: 1684535) -TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_super_safe_of_target() (gas: 2305833) -TestPalmeraSafe:testCannot_RemoveSafe_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_DifferentOrg() (gas: 4606073) -TestPalmeraSafe:testCannot_RemoveSafe_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_DifferentTree() (gas: 3095870) -TestPalmeraSafe:testCannot_RemoveSafe_SUPER_SAFE_as_SAFE_is_not_TARGET_SUPER_SAFE_DifferentTree() (gas: 4615551) -TestPalmeraSafe:testCannot_RemoveSafe_SUPER_SAFE_as_SAFE_is_not_TARGET_SUPER_SAFE_SameTree() (gas: 2952210) -TestPalmeraSafe:testDisableDenyHelperList() (gas: 2669150) -TestPalmeraSafe:testRemoveSafeAndCheckDisables() (gas: 1787735) -TestPalmeraSafe:testRevertAuthForRegisterOrgTx() (gas: 14145) -TestPalmeraSafe:testRevertSuperSafeExecOnBehalfIsDenyList() (gas: 2528844) -TestPalmeraSafe:testRevertSuperSafeExecOnBehalfIsNotAllowList() (gas: 2437859) \ No newline at end of file +TestPalmeraSafe:testAuthorityAddress() (gas: 10825) +TestPalmeraSafe:testCan_RemoveSafe_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_SameTree() (gas: 3025328) +TestPalmeraSafe:testCan_RemoveSafe_SUPER_SAFE_as_SAFE_is_SUPER_SAFE_SameTree() (gas: 2411116) +TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_not_root_of_target() (gas: 1686875) +TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_not_super_safe_of_target() (gas: 2309980) +TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_root_of_target() (gas: 1684150) +TestPalmeraSafe:testCan_hasNotPermissionOverTarget_is_super_safe_of_target() (gas: 2305260) +TestPalmeraSafe:testCannot_RemoveSafe_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_DifferentOrg() (gas: 4604971) +TestPalmeraSafe:testCannot_RemoveSafe_ROOT_SAFE_as_SAFE_is_TARGETS_ROOT_DifferentTree() (gas: 3095154) +TestPalmeraSafe:testCannot_RemoveSafe_SUPER_SAFE_as_SAFE_is_not_TARGET_SUPER_SAFE_DifferentTree() (gas: 4614449) +TestPalmeraSafe:testCannot_RemoveSafe_SUPER_SAFE_as_SAFE_is_not_TARGET_SUPER_SAFE_SameTree() (gas: 2951452) +TestPalmeraSafe:testDisableDenyHelperList() (gas: 2668489) +TestPalmeraSafe:testRemoveSafeAndCheckDisables() (gas: 1787262) +TestPalmeraSafe:testRevertAuthForRegisterOrgTx() (gas: 14156) +TestPalmeraSafe:testRevertSuperSafeExecOnBehalfIsDenyList() (gas: 2528183) +TestPalmeraSafe:testRevertSuperSafeExecOnBehalfIsNotAllowList() (gas: 2437154) \ No newline at end of file diff --git a/libraries/DataTypes.sol b/libraries/DataTypes.sol index 125c96a..a1c5ba7 100644 --- a/libraries/DataTypes.sol +++ b/libraries/DataTypes.sol @@ -14,7 +14,7 @@ library DataTypes { } /// @dev typos of safes into Palmera Modules enum Tier { - safe, // 0 + SAFE, // 0 ROOT, // 1 REMOVED // 2 } diff --git a/script/DeployModuleWithMockedSafe.t.sol b/script/DeployModuleWithMockedSafe.t.sol index 033c018..eb2b812 100644 --- a/script/DeployModuleWithMockedSafe.t.sol +++ b/script/DeployModuleWithMockedSafe.t.sol @@ -12,19 +12,11 @@ import "@solenv/Solenv.sol"; contract DeployModuleWithMockedSafe is Script { function run() public { Solenv.config(); - address masterCopy = vm.envAddress("MASTER_COPY_ADDRESS"); - address proxyFactory = vm.envAddress("PROXY_FACTORY_ADDRESS"); address rolesAuthority = address(0xBEEF); uint256 maxTreeDepth = 50; vm.startBroadcast(); - MockedContract masterCopyMocked = new MockedContract(); - MockedContract proxyFactoryMocked = new MockedContract(); - PalmeraModule palmeraModule = new PalmeraModule( - address(masterCopyMocked), - address(proxyFactoryMocked), - rolesAuthority, - maxTreeDepth - ); + PalmeraModule palmeraModule = + new PalmeraModule(rolesAuthority, maxTreeDepth); vm.stopBroadcast(); } } diff --git a/script/DeployPalmeraEnv.s.sol b/script/DeployPalmeraEnv.s.sol index 667e751..19687d3 100644 --- a/script/DeployPalmeraEnv.s.sol +++ b/script/DeployPalmeraEnv.s.sol @@ -27,8 +27,6 @@ contract DeployPalmeraEnv is Script { // Deploy Safe contracts in any network Solenv.config(); - address masterCopy = vm.envAddress("MASTER_COPY_ADDRESS"); - address proxyFactory = vm.envAddress("PROXY_FACTORY_ADDRESS"); uint256 maxTreeDepth = 50; // Deploy PalmeraRoles: PalmeraModule is set as owner of PalmeraRoles authority @@ -36,12 +34,7 @@ contract DeployPalmeraEnv is Script { PalmeraRoles palmeraRoles = new PalmeraRoles(palmeraModulePredicted); console.log("PalmeraRoles deployed at: ", address(palmeraRoles)); - bytes memory args = abi.encode( - address(masterCopy), - address(proxyFactory), - address(palmeraRoles), - maxTreeDepth - ); + bytes memory args = abi.encode(address(palmeraRoles), maxTreeDepth); bytes memory bytecode = abi.encodePacked( vm.getCode("PalmeraModule.sol:PalmeraModule"), args diff --git a/src/DenyHelper.sol b/src/DenyHelper.sol index 730e6e0..f9f84e4 100644 --- a/src/DenyHelper.sol +++ b/src/DenyHelper.sol @@ -9,6 +9,8 @@ import {DataTypes} from "../libraries/DataTypes.sol"; import {Errors} from "../libraries/Errors.sol"; import {Events} from "../libraries/Events.sol"; +/// @title ValidAddress +/// @dev Helper contract to check if an address is valid abstract contract ValidAddress is Context { /// @dev Modifier for Valid if wallet is Zero Address or Not /// @param to Address to check diff --git a/src/Helpers.sol b/src/Helpers.sol index 983b5b3..f8993f8 100644 --- a/src/Helpers.sol +++ b/src/Helpers.sol @@ -111,7 +111,7 @@ abstract contract Helpers is DenyHelper, SignatureDecoder, ReentrancyGuard { bytes calldata data, Enum.Operation operation, uint256 _nonce - ) public view returns (bytes32) { + ) external view returns (bytes32) { return keccak256( encodeTransactionData( org, superSafe, targetSafe, to, value, data, operation, _nonce @@ -152,9 +152,9 @@ abstract contract Helpers is DenyHelper, SignatureDecoder, ReentrancyGuard { uint256 count = signatures.length / 65; bytes memory concatenatedSignatures; - for (uint256 j = 0; j < owners.length; j++) { + for (uint256 j = 0; j < owners.length; ++j) { address currentOwner = owners[j]; - for (uint256 i = 0; i < count; i++) { + for (uint256 i = 0; i < count; ++i) { // Inline 'signatureSplit' logic here (r, s, v extraction) (uint8 v, bytes32 r, bytes32 s) = signatureSplit(signatures, i); diff --git a/src/PalmeraGuard.sol b/src/PalmeraGuard.sol index 0f19091..1a5bfc7 100644 --- a/src/PalmeraGuard.sol +++ b/src/PalmeraGuard.sol @@ -38,6 +38,7 @@ contract PalmeraGuard is BaseGuard, Context { revert("This contract does not accept ETH"); } + /// @notice Instance of Base Guard Safe Interface function checkTransaction( address, uint256, @@ -52,6 +53,8 @@ contract PalmeraGuard is BaseGuard, Context { address ) external {} + /// @notice Instance of Base Guard Safe Interface + /// @dev Check if the transaction is allowed, based of have the rights to execute it. function checkAfterExecution(bytes32, bool) external view { address caller = _msgSender(); // if it does, check if try to disable guard and revert if it does. diff --git a/src/PalmeraModule.sol b/src/PalmeraModule.sol index fbfe75f..8bf5f52 100644 --- a/src/PalmeraModule.sol +++ b/src/PalmeraModule.sol @@ -32,9 +32,6 @@ contract PalmeraModule is Auth, Helpers { uint256 public indexId; /// @dev Max Depth Tree Limit uint256 public maxDepthTreeLimit; - /// @dev Safe contracts - address public immutable masterCopy; - address public immutable proxyFactory; /// @dev RoleAuthority address public rolesAuthority; /// @dev Array of Orgs (based on Hash (On-chain Organisation) of the Org) @@ -92,19 +89,13 @@ contract PalmeraModule is Auth, Helpers { _; } - constructor( - address masterCopyAddress, - address proxyFactoryAddress, - address authorityAddress, - uint256 maxDepthTreeLimitInitial - ) Auth(address(0), Authority(authorityAddress)) { - if ( - (authorityAddress == address(0)) || !masterCopyAddress.isContract() - || !proxyFactoryAddress.isContract() - ) revert Errors.InvalidAddressProvided(); + constructor(address authorityAddress, uint256 maxDepthTreeLimitInitial) + Auth(address(0), Authority(authorityAddress)) + { + if (authorityAddress == address(0)) { + revert Errors.InvalidAddressProvided(); + } - masterCopy = masterCopyAddress; - proxyFactory = proxyFactoryAddress; rolesAuthority = authorityAddress; /// Index of Safes starts in 1 Always indexId = 1; @@ -223,9 +214,9 @@ contract PalmeraModule is Auth, Helpers { revert Errors.OwnerAlreadyExists(); } - bytes memory data = abi.encodeWithSelector( - ISafe.addOwnerWithThreshold.selector, ownerAdded, threshold - ); + bytes memory data = + abi.encodeCall(ISafe.addOwnerWithThreshold, (ownerAdded, threshold)); + /// Execute transaction from target safe _executeModuleTransaction(targetSafe, data); } @@ -262,8 +253,8 @@ contract PalmeraModule is Auth, Helpers { revert Errors.OwnerNotFound(); } - bytes memory data = abi.encodeWithSelector( - ISafe.removeOwner.selector, prevOwner, ownerRemoved, threshold + bytes memory data = abi.encodeCall( + ISafe.removeOwner, (prevOwner, ownerRemoved, threshold) ); /// Execute transaction from target safe @@ -375,14 +366,13 @@ contract PalmeraModule is Auth, Helpers { /// Add to org root/safe DataTypes.Safe storage superSafeOrgSafe = safes[org][superSafe]; /// Add child to superSafe - safeId = indexId; + safeId = indexId++; superSafeOrgSafe.child.push(safeId); newSafe.safe = caller; newSafe.name = name; newSafe.superSafe = superSafe; indexSafe[org].push(safeId); - indexId++; /// Give Role SuperSafe RolesAuthority _authority = RolesAuthority(rolesAuthority); if ( @@ -517,7 +507,7 @@ contract PalmeraModule is Auth, Helpers { uint256 rootSafe = getSafeIdBySafe(org, caller); uint256[] memory _indexSafe = getTreeMember(rootSafe, indexSafe[org]); RolesAuthority _authority = RolesAuthority(rolesAuthority); - for (uint256 j = 0; j < _indexSafe.length; j++) { + for (uint256 j = 0; j < _indexSafe.length; ++j) { uint256 safe = _indexSafe[j]; DataTypes.Safe memory _safe = safes[org][safe]; // Revoke roles to safe @@ -751,7 +741,7 @@ contract PalmeraModule is Auth, Helpers { /// @param safe uint256 of the safe /// @return all the information about a safe function getSafeInfo(uint256 safe) - public + external view SafeIdRegistered(safe) returns ( @@ -881,7 +871,7 @@ contract PalmeraModule is Auth, Helpers { // Check if the Child Safe is was removed or not Exist and Return False if ( (childSafe.safe == address(0)) - || (childSafe.tier == DataTypes.Tier.safe) + || (childSafe.tier == DataTypes.Tier.SAFE) || (childSafe.tier == DataTypes.Tier.ROOT) ) { return false; @@ -889,6 +879,8 @@ contract PalmeraModule is Auth, Helpers { return (childSafe.superSafe == rootSafe); } + /// @notice Verify if the Safe is registered in any Org + /// @param safe address of the Safe function isSafeRegistered(address safe) public view returns (bool) { if ((safe == address(0)) || safe == Constants.SENTINEL_ADDRESS) { return false; @@ -917,7 +909,7 @@ contract PalmeraModule is Auth, Helpers { /// @param safe uint256 of the safe /// @return safe address function getSafeAddress(uint256 safe) - public + external view SafeIdRegistered(safe) returns (address) @@ -1013,7 +1005,7 @@ contract PalmeraModule is Auth, Helpers { if (isSafeRegistered(newRootSafe)) { revert Errors.SafeAlreadyRegistered(newRootSafe); } - safeId = indexId; + safeId = indexId++; safes[org][safeId] = DataTypes.Safe({ tier: DataTypes.Tier.ROOT, name: name, @@ -1023,7 +1015,6 @@ contract PalmeraModule is Auth, Helpers { superSafe: 0 }); indexSafe[org].push(safeId); - indexId++; /// Assign SUPER_SAFE Role + SAFE_ROOT Role RolesAuthority _authority = RolesAuthority(rolesAuthority); @@ -1046,8 +1037,7 @@ contract PalmeraModule is Auth, Helpers { delete safes[org][safe]; /// Disable Guard - bytes memory data = - abi.encodeWithSelector(ISafe.setGuard.selector, address(0)); + bytes memory data = abi.encodeCall(ISafe.setGuard, (address(0))); /// Execute transaction from target safe _executeModuleTransaction(_safe, data); @@ -1056,9 +1046,7 @@ contract PalmeraModule is Auth, Helpers { if (prevModule == address(0)) { revert Errors.PreviewModuleNotFound(_safe); } - data = abi.encodeWithSelector( - ISafe.disableModule.selector, prevModule, address(this) - ); + data = abi.encodeCall(ISafe.disableModule, (prevModule, address(this))); /// Execute transaction from target safe _executeModuleTransaction(_safe, data); @@ -1171,7 +1159,7 @@ contract PalmeraModule is Auth, Helpers { (getRootSafe(indexSafeByOrg[i]) == rootSafe) && (indexSafeByOrg[i] != rootSafe) ) { - index++; + ++index; } } indexTree = new uint256[](index); diff --git a/src/ReentrancyAttack.sol b/src/ReentrancyAttack.sol index 3662228..6c87a50 100644 --- a/src/ReentrancyAttack.sol +++ b/src/ReentrancyAttack.sol @@ -10,14 +10,19 @@ import {Constants} from "../libraries/Constants.sol"; /// @title Attacker /// @custom:security-contact general@palmeradao.xyz contract Attacker { + /// @notice Hash On-chain Organisation to Attack bytes32 public orgFromAttacker; + /// @notice Safe super address to Attack address public superSafeFromAttacker; + /// @notice Safe target address to Attack address public targetSafeFromAttacker; + /// @notice Data payload of the transaction to Attack bytes public dataFromAttacker; + /// @notice Packed signatures data (v, r, s) to Attack bytes public signaturesFromAttacker; - + /// @notice Owners of the Safe Multisig Wallet Attacker address[] public owners = new address[](2); - + /// @notice Instance of PalmeraModule PalmeraModule public palmeraModule; constructor(address payable _contractToAttackAddress) { diff --git a/test/EnableGuard.t.sol b/test/EnableGuard.t.sol index a151b81..272c67d 100644 --- a/test/EnableGuard.t.sol +++ b/test/EnableGuard.t.sol @@ -21,13 +21,9 @@ contract TestEnableGuard is Test { safeHelper = new SafeHelper(); safeAddr = safeHelper.setupSafeEnv(); // Init PalmeraModule - address masterCopy = safeHelper.safeMasterCopy(); - address safeFactory = address(safeHelper.safeFactory()); address rolesAuthority = address(0xBEEF); uint256 maxTreeDepth = 50; - palmeraModule = new PalmeraModule( - masterCopy, safeFactory, rolesAuthority, maxTreeDepth - ); + palmeraModule = new PalmeraModule(rolesAuthority, maxTreeDepth); palmeraGuard = new PalmeraGuard(payable(address(palmeraModule))); safeHelper.setPalmeraModule(address(palmeraModule)); safeHelper.setPalmeraGuard(address(palmeraGuard)); diff --git a/test/EnableModule.t.sol b/test/EnableModule.t.sol index d1f5cfc..41dbc37 100644 --- a/test/EnableModule.t.sol +++ b/test/EnableModule.t.sol @@ -18,13 +18,9 @@ contract TestEnableModule is Test { safeHelper = new SafeHelper(); safeAddr = safeHelper.setupSafeEnv(); // Init PalmeraModule - address masterCopy = safeHelper.safeMasterCopy(); - address safeFactory = address(safeHelper.safeFactory()); address rolesAuthority = address(0xBEEF); uint256 maxTreeDepth = 50; - palmeraModule = new PalmeraModule( - masterCopy, safeFactory, rolesAuthority, maxTreeDepth - ); + palmeraModule = new PalmeraModule(rolesAuthority, maxTreeDepth); safeHelper.setPalmeraModule(address(palmeraModule)); } diff --git a/test/Hierarchies.t.sol b/test/Hierarchies.t.sol index 9fd73e0..beba6f4 100644 --- a/test/Hierarchies.t.sol +++ b/test/Hierarchies.t.sol @@ -55,7 +55,7 @@ contract Hierarchies is DeployHelper { uint256 superSafe ) = palmeraModule.getSafeInfo(safeIdA1); - assertEq(uint256(tier), uint256(DataTypes.Tier.safe)); + assertEq(uint256(tier), uint256(DataTypes.Tier.SAFE)); assertEq(safeName, safeA1Name); assertEq(lead, address(0)); assertEq(safe, address(safeHelper.safeWallet())); @@ -264,7 +264,7 @@ contract Hierarchies is DeployHelper { uint256 superSafe ) = palmeraModule.getSafeInfo(safeA1Id); - assertEq(uint8(tier), uint8(DataTypes.Tier.safe)); + assertEq(uint8(tier), uint8(DataTypes.Tier.SAFE)); assertEq(name, safeA1Name); assertEq(lead, address(0)); assertEq(safe, safeA1Addr); @@ -276,7 +276,7 @@ contract Hierarchies is DeployHelper { (tier, name, lead, safe, child, superSafe) = palmeraModule.getSafeInfo(safeSubSafeA1Id); - assertEq(uint8(tier), uint8(DataTypes.Tier.safe)); + assertEq(uint8(tier), uint8(DataTypes.Tier.SAFE)); assertEq(name, subSafeA1Name); assertEq(lead, address(0)); assertEq(safe, safeSubSafeA1Addr); @@ -836,4 +836,159 @@ contract Hierarchies is DeployHelper { } } } + + // ! **************** Validate increment of IndexID ******************************* ! + + /// @notice Test Register Root Organisation and check index increment + function testRegisterRootOrgAndCheckIndexIncrement() public { + uint256 initialIndex = palmeraModule.indexId(); + + (uint256 rootId, uint256 safeIdA1) = + palmeraSafeBuilder.setupRootOrgAndOneSafe(orgName, safeA1Name); + + address rootAddr = palmeraModule.getSafeAddress(rootId); + + uint256 newIndex = palmeraModule.indexId(); + assertEq( + newIndex, + initialIndex + 2, + "IndexId should increment by 2 after setting up root and one safe" + ); + + initialIndex = palmeraModule.indexId(); + + address newRootSafe = safeHelper.newPalmeraSafe(3, 1); + safeHelper.updateSafeInterface(rootAddr); + + bool result = safeHelper.createRootSafeTx(newRootSafe, orgName); + assertEq(result, true); + + newIndex = palmeraModule.indexId(); + assertEq( + newIndex, + initialIndex + 1, + "IndexId should increment by 1 after adding a Root Safe" + ); + + assertEq(orgHash, keccak256(abi.encodePacked(orgName))); + ( + DataTypes.Tier tier, + string memory name, + address lead, + address safe, + uint256[] memory child, + uint256 superSafe + ) = palmeraModule.getSafeInfo(rootId); + assertEq(uint8(tier), uint8(DataTypes.Tier.ROOT)); + assertEq(name, orgName); + assertEq(lead, address(0)); + assertEq(safe, address(safeHelper.safeWallet())); + assertEq(superSafe, 0); + assertEq(child.length, 1); + assertEq(palmeraModule.isOrgRegistered(orgHash), true); + assertEq( + palmeraRolesContract.doesUserHaveRole( + safe, uint8(DataTypes.Role.ROOT_SAFE) + ), + true + ); + } + + /// @notice Test Add Safe and check index increment + function testAddSafeAndCheckIndexIncrement() public { + uint256 initialIndex = palmeraModule.indexId(); + + (uint256 rootId, uint256 safeIdA1) = + palmeraSafeBuilder.setupRootOrgAndOneSafe(orgName, safeA1Name); + + uint256 newIndex = palmeraModule.indexId(); + assertEq( + newIndex, + initialIndex + 2, + "IndexId should increment by 2 after setting up root and one safe" + ); + + ( + DataTypes.Tier tier, + string memory safeName, + address lead, + address safe, + uint256[] memory child, + uint256 superSafe + ) = palmeraModule.getSafeInfo(safeIdA1); + + assertEq(uint256(tier), uint256(DataTypes.Tier.SAFE)); + assertEq(safeName, safeA1Name); + assertEq(lead, address(0)); + assertEq(safe, address(safeHelper.safeWallet())); + assertEq(child.length, 0); + assertEq(superSafe, rootId); + + address safeAddr = palmeraModule.getSafeAddress(safeIdA1); + address rootAddr = palmeraModule.getSafeAddress(rootId); + + assertEq(palmeraModule.isRootSafeOf(rootAddr, safeIdA1), true); + assertEq( + palmeraRolesContract.doesUserHaveRole( + safeAddr, uint8(DataTypes.Role.SUPER_SAFE) + ), + false + ); + + assertEq( + palmeraRolesContract.doesUserHaveRole( + rootAddr, uint8(DataTypes.Role.SUPER_SAFE) + ), + true + ); + } + + /// @notice Test Add Multiple Safes and check index increment + function testAddMultipleSafesAndCheckIndexIncrement() public { + uint256 initialIndex = palmeraModule.indexId(); + + (uint256 rootId, uint256 safeIdA1) = + palmeraSafeBuilder.setupRootOrgAndOneSafe(orgName, safeA1Name); + + address safeA2Addr = safeHelper.newPalmeraSafe(3, 1); + address safeA3Addr = safeHelper.newPalmeraSafe(3, 1); + + vm.startPrank(safeA2Addr); + uint256 safeIdA2 = palmeraModule.addSafe(safeIdA1, "Safe A2"); + vm.stopPrank(); + assertEq( + uint256(3), + safeIdA2, + "SafeId should be 3 after adding a safe safeIdA2" + ); + assertEq( + safeIdA2, + safeIdA1 + 1, + "SafeId should increment by 1 after adding a safe" + ); + vm.startPrank(safeA3Addr); + uint256 safeIdA3 = palmeraModule.addSafe(safeIdA1, "Safe A3"); + vm.stopPrank(); + assertEq( + uint256(4), + safeIdA3, + "SafeId should be 4 after adding a safe safeIdA3" + ); + assertEq( + safeIdA3, + safeIdA2 + 1, + "SafeId should increment by 1 after adding a safe" + ); + uint256 newIndex = palmeraModule.indexId(); + assertEq( + uint256(5), + newIndex, + "IndexId should increment by 5 after adding 1 rootsafe and 3 safes" + ); + assertEq( + newIndex, + initialIndex + 4, + "IndexId should increment correctly after adding multiple safes" + ); + } } diff --git a/test/SkipStressTestStorage.sol b/test/SkipStressTestStorage.sol index 5762e48..5cd6689 100644 --- a/test/SkipStressTestStorage.sol +++ b/test/SkipStressTestStorage.sol @@ -49,7 +49,7 @@ contract SkipStressTestStorage is DeployHelper, SigningUtils { subSafeAid[0] = rootId; subSafeAid[1] = safeIdA1; - for (uint256 i = 2; i < 8100; i++) { + for (uint256 i = 2; i < 8100; ++i) { // Create a new Safe subSafeAaddr[i] = safeHelper.newPalmeraSafe(3, 1); // Start Prank @@ -229,10 +229,10 @@ contract SkipStressTestStorage is DeployHelper, SigningUtils { level[indexLevel] = 0; indexSafe = members.sub(1); uint256 structLevel = 1; - for (uint256 i = 0; i < safeWallets.div(members); i++) { + for (uint256 i = 0; i < safeWallets.div(members); ++i) { // SuperSafe of Iteration uint256 superSafe = subSafeAid[level[i]]; - for (uint256 j = 0; j < members; j++) { + for (uint256 j = 0; j < members; ++j) { // Create a new Safe subSafeAaddr[indexSafe] = safeHelper.newPalmeraSafe(3, 1); // Start Prank @@ -302,7 +302,7 @@ contract SkipStressTestStorage is DeployHelper, SigningUtils { if (exp == 0) { return result; } - for (uint256 i = 0; i < exp; i++) { + for (uint256 i = 0; i < exp; ++i) { result *= base; } } @@ -312,7 +312,7 @@ contract SkipStressTestStorage is DeployHelper, SigningUtils { pure returns (uint256 result) { - for (uint256 i = 1; i < level; i++) { + for (uint256 i = 1; i < level; ++i) { result += pod(base, i); } } diff --git a/test/helpers/DeployHelper.t.sol b/test/helpers/DeployHelper.t.sol index 73e8193..4685983 100644 --- a/test/helpers/DeployHelper.t.sol +++ b/test/helpers/DeployHelper.t.sol @@ -74,13 +74,10 @@ contract DeployHelper is Test { safeHelper.setPalmeraRoles(palmeraRolesDeployed); // Init PalmeraModule - address masterCopy = safeHelper.safeMasterCopy(); - address safeFactory = address(safeHelper.safeFactory()); uint256 maxTreeDepth = 50; - palmeraModule = new PalmeraModule( - masterCopy, safeFactory, address(palmeraRolesDeployed), maxTreeDepth - ); + palmeraModule = + new PalmeraModule(address(palmeraRolesDeployed), maxTreeDepth); palmeraModuleAddr = address(palmeraModule); // Deploy Guard Contract palmeraGuard = new PalmeraGuard(payable(palmeraModuleAddr));