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: Initial support for custom paymaster #591

Merged
merged 7 commits into from
Sep 26, 2024

Conversation

Jrigada
Copy link
Contributor

@Jrigada Jrigada commented Sep 24, 2024

Motivation

We're enhancing our ZKSync specific capabilities by implementing paymaster functionality. This allows for sponsored transactions, improving user experience by enabling third parties to cover gas fees on behalf of users. More info about paymaster here as well as some examples.

Solution

  1. Added new cheatcode zkUsePaymaster
  2. Extended Cheatcodes inspector struct with paymaster_params
  3. Updated CheatcodeTracerContext to include paymaster data
  4. Added new test

Testing Approach

  1. New tests in Paymaster.t.sol:
    • testCallWithPaymaster: Verifies paymaster usage in function calls
    • testCreateWithPaymaster: Tests paymaster usage in contract creation
    • testFailPaymasterBalanceDoesNotUpdate: Highlights an issue with observing paymaster balance changes

Note

  • Balance changes of the paymaster contract are not observable from within the test environment. It seems the VM does not report back the modified L2BASETOKEN slot of the paymaster contract. As far as I observed the intended way of testing the paymaster usage is checking the user balance and that is what we are doing now in the test cases. Also to be sure while writing the tests we made sure the paymaster balance is decreasing inside its own contract, this is just not updated from the outer test contract.

Extra: We are depending on a third party dependency until this issue is resolved.

crates/cheatcodes/src/inspector.rs Outdated Show resolved Hide resolved
crates/forge/tests/fixtures/zk/MyPaymaster.sol Outdated Show resolved Hide resolved
crates/forge/tests/fixtures/zk/Paymaster.t.sol Outdated Show resolved Hide resolved
crates/forge/tests/fixtures/zk/Paymaster.t.sol Outdated Show resolved Hide resolved
crates/forge/tests/it/zk/paymaster.rs Show resolved Hide resolved
crates/forge/tests/it/zk/paymaster.rs Outdated Show resolved Hide resolved
@Jrigada Jrigada requested a review from Karrq September 25, 2024 18:19
crates/zksync/core/src/lib.rs Show resolved Hide resolved
crates/forge/tests/it/zk/paymaster.rs Outdated Show resolved Hide resolved
elfedy
elfedy previously approved these changes Sep 25, 2024
crates/zksync/core/src/lib.rs Show resolved Hide resolved
@Jrigada Jrigada merged commit 22871de into main Sep 26, 2024
11 checks passed
@Jrigada Jrigada deleted the feat-jrigada-paymaster-initial-support branch September 26, 2024 14:01
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