Skip to content

Conversation

daanporon
Copy link
Contributor

@daanporon daanporon commented Apr 4, 2025

!! BLOCKED

Our Besu node needs to be updated for Cancun support
We need PUSH0 (Shangai) and Transient storage TSTORE, TLOAD (Shanghai)

Summary by Sourcery

Update SmartAccount contract to be compatible with Account Abstraction (AA) version 0.8.0, including changes to import paths, signature validation, and adding new deposit-related functions.

New Features:

  • Add methods to check, deposit, and withdraw funds from the EntryPoint
  • Implement a more flexible initialization process for the SmartAccount

Enhancements:

  • Update signature validation to work with eth_signTypedData_v4
  • Modify execute method to be more flexible with access control
  • Refactor internal initialization method

Build:

  • Update Solidity compiler version from 0.8.27 to 0.8.28

Chores:

  • Update Account Abstraction dependency import paths
  • Remove specific commit pinning for Account Abstraction dependency

Copy link

sourcery-ai bot commented Apr 4, 2025

Reviewer's Guide by Sourcery

This pull request updates the Account Abstraction package to version 0.8.0 and makes necessary adjustments to the SmartAccount contract to align with the new version. The changes include updating import paths, modifying signature validation logic, adding deposit management functions, and adjusting access control for the execute function.

Sequence diagram for execute function

sequenceDiagram
  participant User
  participant SmartAccount
  participant EntryPoint

  User->>SmartAccount: execute(dest, value, func)
  activate SmartAccount
  SmartAccount->>SmartAccount: _requireForExecute()
  alt msg.sender == EntryPoint || msg.sender == owner
    SmartAccount->>SmartAccount: _call(dest, value, func)
    SmartAccount-->>User: TransactionExecuted(dest, value, func)
  else
    SmartAccount-->>User: Revert("account: not Owner or EntryPoint")
  end
  deactivate SmartAccount
Loading

Sequence diagram for deposit management

sequenceDiagram
    participant User
    participant SmartAccount
    participant EntryPoint

    User->>SmartAccount: addDeposit()
    activate SmartAccount
    SmartAccount->>EntryPoint: depositTo{value: msg.value}(address(this))
    activate EntryPoint
    EntryPoint-->>SmartAccount: Deposit
    deactivate EntryPoint
    SmartAccount-->>User: Deposit added
    deactivate SmartAccount

    User->>SmartAccount: withdrawDepositTo(withdrawAddress, amount)
    activate SmartAccount
    SmartAccount->>EntryPoint: withdrawTo(withdrawAddress, amount)
    activate EntryPoint
    EntryPoint-->>SmartAccount: Withdrawal
    deactivate EntryPoint
    SmartAccount-->>User: Withdrawal complete
    deactivate SmartAccount
Loading

Updated class diagram for SmartAccount

classDiagram
  class SmartAccount {
    address owner
    address _entryPoint
    constructor(address anOwner, address entryPointAddress)
    function initialize(address anOwner)
    function _initialize(address anOwner)
    function execute(address dest, uint256 value, bytes calldata func)
    function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds) external returns (uint256 validationData)
    function _requireForExecute() internal view
    function setOwner(address newOwner) external
    function setEntryPoint(address newEntryPoint) external
    function getDeposit() public view returns (uint256)
    function addDeposit() public payable
    function withdrawDepositTo(address payable withdrawAddress, uint256 amount) public
    receive() external payable
  }
  SmartAccount --|> BaseAccount : extends
  SmartAccount --|> TokenCallbackHandler : extends
  SmartAccount --|> UUPSUpgradeable : extends
  SmartAccount --|> Initializable : extends
  note for SmartAccount "Updated to AA 0.8.0"
Loading

File-Level Changes

Change Details Files
Updated the Account Abstraction package version and adjusted import paths.
  • Updated the Account Abstraction package to version 0.8.0.
  • Modified the import path for TokenCallbackHandler to reflect the new package structure.
contracts/SmartAccount.sol
Modified signature validation logic in validateUserOp function.
  • Removed the hashing of the userOpHash using MessageHashUtils.toEthSignedMessageHash.
  • Directly used the userOpHash in ECDSA.recover for signature verification.
contracts/SmartAccount.sol
Adjusted access control for the execute function.
  • Replaced _requireFromEntryPointOrOwner() with _requireForExecute() to enforce access control.
  • Made _requireForExecute virtual and overridable.
contracts/SmartAccount.sol
Added deposit management functions.
  • Added getDeposit() to check the current account deposit in the entry point.
  • Added addDeposit() to allow depositing more funds for the account in the entry point.
  • Added withdrawDepositTo() to allow withdrawing funds from the account's deposit to a specified address, restricted to the owner.
contracts/SmartAccount.sol
Updated the Solidity compiler version.
  • Updated the Solidity compiler version in foundry.toml from 0.8.27 to 0.8.28.
foundry.toml
Removed explicit dependency pinning for the Account Abstraction package in foundry.toml.
  • Removed the account-abstraction entry from the dependencies section in foundry.toml.
foundry.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the feat label Apr 4, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @daanporon - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the signature validation logic into a separate function for better readability.
  • It might be worth adding some events for the deposit/withdrawal functions.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@daanporon daanporon marked this pull request as draft April 4, 2025 12:47
Copy link

github-actions bot commented Apr 4, 2025

📦 Packages

Package Install
Template Set bun add @settlemint/settlemint/[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant