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

Pausable with reason string #5197

Open
Tracked by #5249
stuparm opened this issue Sep 13, 2024 · 2 comments
Open
Tracked by #5249

Pausable with reason string #5197

stuparm opened this issue Sep 13, 2024 · 2 comments

Comments

@stuparm
Copy link

stuparm commented Sep 13, 2024

🧐 Motivation
Currently, the Pausable.sol contract triggers the error EnforcedPause() when the contract is paused. However, this error does not convey any additional context (such as user instructions) that may be important when the contract is paused.

In the web3 space, communicating essential information during critical events, such as a contract hack, and guiding users on the necessary actions can be challenging. Often, platforms rely on Twitter or other social media to inform users. This is particularly difficult for protocols that are integrated into multiple dapps, as the origin of the user is often unknown.

📝 Details
I propose adding a string reason or string message parameter to the EnforcedPause error, which can be set when invoking the _pause() function.

This would provide more informative feedback when the contract is paused, helping users understand the situation and act accordingly.

    function _pause(string memory reason) internal virtual whenNotPaused {
        _paused = true;
        _reason = reason;
        emit Paused(_msgSender());
    }

// and then when error is thrown:
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause(_reason);
        }
    }
@Amxx
Copy link
Collaborator

Amxx commented Sep 16, 2024

Hello @stuparm

I'm curious what you think the extra parameters of reason should be, that is not already explicit enough in EnforcedPause(). Adding a string (or anything) has a cost. Isn't EnforcedPause explicit enough?

@stuparm
Copy link
Author

stuparm commented Sep 19, 2024

Hey @Amxx, my understanding is that a contract would typically be paused in the event of an incident or hack. In such cases, I believe it would be reasonable to incur additional costs to provide information to end users. One example I would return as an error string is the URL that leads to i.e. to incident status page, where users can stay updated on the hack’s status.
I’ve noticed many (d)apps do this by linking to their websites, but not all dapps have dedicated sites, especially protocols integrated into other applications.

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

No branches or pull requests

2 participants