Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hook allowlist #951

Merged
merged 25 commits into from
Jun 24, 2024
Merged

feat: hook allowlist #951

merged 25 commits into from
Jun 24, 2024

Conversation

PaulRBerg
Copy link
Member

@PaulRBerg PaulRBerg commented Jun 21, 2024

refactor: delete renounce hook
test: improve test function names
test: update renounce and withdraw hook tests
refactor: rename "SablierV2Recipient" to "SablierRecipient"
feat: isAllowedToHook
feat: allowToHook
test: rename recipient hooks mocks
refactor: remove try/ catch in hooks
refactor: rename "_allowed" to "_allowedToHook"
test: update cancel and withdraw tests
@PaulRBerg PaulRBerg changed the title Feat/hook allowlist feat: hook allowlist Jun 21, 2024
Copy link
Member

@smol-ninja smol-ninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preliminary review.

script/DeployCore2.s.sol Outdated Show resolved Hide resolved
script/DeployDeterministicCore2.s.sol Outdated Show resolved Hide resolved
src/abstracts/SablierV2Lockup.sol Outdated Show resolved Hide resolved
src/abstracts/SablierV2Lockup.sol Outdated Show resolved Hide resolved
Copy link
Member

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work PRB, and thank you for moving so fast.

I have reviewed only src so far, I've not looked at tests.

I have some questions regarding the decisions made on the implementation (maybe they will be answered in the upcoming discussion you'll open):

  • Since the contracts which the hook is called on must be allowed by Sablier, why not generalize it and allow both sender/recipient calls. Thus, instead of ISablierRecipient to have a ISablierLockupHookImplementer interface?
    • If we keep the current name, why not rename it to ISablierLockupRecipient? we might have a different recipient interface for future contracts
  • Merge Adminable and allow hook logic into a single contract, so that Adminable contract can be used accros all Sablier future contracts.
    • If we do this, it would be better to have in allowToHook function an address param instead of an interface
  • Why not return a bool in hook functions and check it?

src/libraries/Errors.sol Outdated Show resolved Hide resolved
@PaulRBerg
Copy link
Member Author

Thanks for the kind words, @andreivladbrg.

I will respond to your questions in the separate discussion thread.

@smol-ninja
Copy link
Member

smol-ninja commented Jun 22, 2024

@andreivladbrg about your question: Why not return a bool in hook functions and check it?

This answer from stack overflow put it really well

Screenshot 2024-06-22 at 11 42 56

@andreivladbrg
Copy link
Member

@andreivladbrg about your question: Why not return a bool in hook functions and check it?

fair enough, thanks for sharing

Copy link
Member

@smol-ninja smol-ninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreivladbrg @PaulRBerg I left some comments. LMK if all looks good (you can reach with emoji). If yes I will make those changes.

src/interfaces/ISablierRecipient.sol Outdated Show resolved Hide resolved
src/interfaces/ISablierRecipient.sol Outdated Show resolved Hide resolved
src/interfaces/ISablierRecipient.sol Outdated Show resolved Hide resolved
src/interfaces/ISablierRecipient.sol Outdated Show resolved Hide resolved
src/abstracts/SablierV2Lockup.sol Outdated Show resolved Hide resolved
src/abstracts/SablierV2Lockup.sol Outdated Show resolved Hide resolved
src/libraries/Errors.sol Outdated Show resolved Hide resolved
Copy link
Member

@smol-ninja smol-ninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed tests. Left feedback below. Addressed them in 02fcc7e.

test/integration/fuzz/lockup/cancel.t.sol Outdated Show resolved Hide resolved
@smol-ninja
Copy link
Member

Can we all please give it a final review and approve the PR so that it can be merged? cc @PaulRBerg @andreivladbrg

@PaulRBerg
Copy link
Member Author

The PR looks good to me now. Thanks both for your contributions.

Let's squash and merge!

@smol-ninja smol-ninja merged commit abf7154 into staging Jun 24, 2024
9 checks passed
@smol-ninja smol-ninja deleted the feat/hook-allowlist branch June 24, 2024 20:07
@andreivladbrg andreivladbrg mentioned this pull request Jul 2, 2024
andreivladbrg added a commit that referenced this pull request Jul 3, 2024
* refactor: delete sender withdraw hooks

refactor: delete renounce hook
test: improve test function names
test: update renounce and withdraw hook tests

* refactor: rename hooks

* refactor: get rid of "hooks" directory

* feat: add marker "IS_SABLIER_RECIPIENT"

refactor: rename "SablierV2Recipient" to "SablierRecipient"

* feat: hook allowlist

feat: isAllowedToHook
feat: allowToHook
test: rename recipient hooks mocks

* feat: check allowlist when running hooks

refactor: remove try/ catch in hooks
refactor: rename "_allowed" to "_allowedToHook"
test: update cancel and withdraw tests

* build: update precompiles

* fix: remove stale dir in prepare-artifacts script

* docs: update withdraw natspec

* chore: address PR feedback

* feat: include function selector in the return value of hook calls

* fix: redundant dev notes, use interface selector

* test: fix bugs

* feat: replace IS_SABLIER_RECIPIENT with IERC165-supportsInterface

* refactor: remove local import from Errors

* docs: polish natspec

* refactor: rename recipient interface

* refactor: change param type to "address"

* build: update precompiles

* refactor: remove unneeded address casting

* docs: polish natspec

* chore: update count map in Base script

* chore: update benchmarks

* docs: mention allowlist contract in Security doc

* docs: update wording

---------

Co-authored-by: andreivladbrg <andreivladbrg@gmail.com>
Co-authored-by: smol-ninja <shubhamy2015@gmail.com>
andreivladbrg added a commit that referenced this pull request Jul 3, 2024
* refactor: delete sender withdraw hooks

refactor: delete renounce hook
test: improve test function names
test: update renounce and withdraw hook tests

* refactor: rename hooks

* refactor: get rid of "hooks" directory

* feat: add marker "IS_SABLIER_RECIPIENT"

refactor: rename "SablierV2Recipient" to "SablierRecipient"

* feat: hook allowlist

feat: isAllowedToHook
feat: allowToHook
test: rename recipient hooks mocks

* feat: check allowlist when running hooks

refactor: remove try/ catch in hooks
refactor: rename "_allowed" to "_allowedToHook"
test: update cancel and withdraw tests

* build: update precompiles

* fix: remove stale dir in prepare-artifacts script

* docs: update withdraw natspec

* chore: address PR feedback

* feat: include function selector in the return value of hook calls

* fix: redundant dev notes, use interface selector

* test: fix bugs

* feat: replace IS_SABLIER_RECIPIENT with IERC165-supportsInterface

* refactor: remove local import from Errors

* docs: polish natspec

* refactor: rename recipient interface

* refactor: change param type to "address"

* build: update precompiles

* refactor: remove unneeded address casting

* docs: polish natspec

* chore: update count map in Base script

* chore: update benchmarks

* docs: mention allowlist contract in Security doc

* docs: update wording

---------

Co-authored-by: andreivladbrg <andreivladbrg@gmail.com>
Co-authored-by: smol-ninja <shubhamy2015@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants