Skip to content

ERC7579DelayedExecutor - Refactored validation & executing logic#152

Closed
gonzaotc wants to merge 10 commits into
feature/erc7579-executorsfrom
feature/erc7579-executors-refactor-canExecute
Closed

ERC7579DelayedExecutor - Refactored validation & executing logic#152
gonzaotc wants to merge 10 commits into
feature/erc7579-executorsfrom
feature/erc7579-executors-refactor-canExecute

Conversation

@gonzaotc

@gonzaotc gonzaotc commented May 13, 2025

Copy link
Copy Markdown
Contributor

Refactor to #121 with some objetives:

  • Validations were previously divided and duplicated across canExecute and _execute, which were causing inconsistencies if they didn't match. See Add ERC7579 Executor modules #121 (comment)

  • The functions _execute, _schedule, _cancel were performing validations, while in this approach they're low-level functions that assume prior validation. I think is good to divide validation from the actual executing logic.

  • More specific error throwing, where _validateExecutionRequest can determine the priority order of errors to throw for different requirement conditions. See Add ERC7579 Executor modules #121 (comment). Additionally, this approach allows to revert with appropriate errors before executing, which results in gas savings for unauthorized callers. See Add ERC7579 Executor modules #121 (comment)

  • Scheduling was available even if the module wasn't installed. See Add ERC7579 Executor modules #121 (comment)

In this approach, the purposes of each function are very specific and any of them can be overrided for customization:

  • public execute: allows external calling, calls internal validation and execution.
  • internal _validateExecutionRequest: validates execution requirements.
  • internal _execute: low-level execution.

@gonzaotc
gonzaotc requested a review from a team as a code owner May 13, 2025 23:54
@gonzaotc
gonzaotc requested a review from ernestognw May 13, 2025 23:54
Comment thread contracts/account/modules/ERC7579DelayedExecutor.sol Outdated
@gonzaotc
gonzaotc requested a review from ernestognw May 14, 2025 21:24
@gonzaotc gonzaotc changed the title Refactored DelayedExecutor.canExecute Refactored validation & executing logic May 14, 2025
Comment thread contracts/account/modules/ERC7579DelayedExecutor.sol Outdated
Comment thread contracts/account/modules/ERC7579Executor.sol Outdated
@gonzaotc
gonzaotc requested a review from ernestognw May 14, 2025 23:59
Comment thread contracts/account/modules/ERC7579Executor.sol Outdated
Comment on lines +56 to +57
) internal view virtual {
require(msg.sender == account, ERC7579UnauthorizedExecution());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would insist the issue with require statements is that developers can't remove them! The original canExecute intentionally returns bool to follow the pattern of condition || super.canExecute(), which allows to workaround a require(canSchedule(...)) error. I would rather keep that pattern in the new _validateExecutionRequest

Suggested change
) internal view virtual {
require(msg.sender == account, ERC7579UnauthorizedExecution());
) internal view virtual returns (bool) {
return msg.sender == account;

Comment thread contracts/account/modules/ERC7579Executor.sol Outdated
Comment thread contracts/account/modules/ERC7579DelayedExecutor.sol Outdated
bytes calldata executionCalldata,
bytes32 salt
) internal view virtual {
require(_config[account].installed, ERC7579ExecutorModuleNotInstalled());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would insist on keeping this case as a no-op. It's a valid use case to extend and allow scheduling on contracts that haven't installed the module. For example, a factory contract could deploy accounts with create2 and install this module with pre-scheduled payments (ie. subscriptions). In that case it becomes impossible to build that case on top of this contract

Comment thread contracts/account/modules/ERC7579DelayedExecutor.sol Outdated
Comment thread contracts/account/modules/ERC7579DelayedExecutor.sol
Comment thread contracts/account/modules/ERC7579DelayedExecutor.sol
@gonzaotc
gonzaotc marked this pull request as draft May 15, 2025 22:03
@gonzaotc gonzaotc changed the title Refactored validation & executing logic ERC7579DelayedExecutor - Refactored validation & executing logic May 15, 2025
@gonzaotc gonzaotc closed this May 19, 2025
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.

2 participants