matter-labs / foundry-zksync

Fork of Foundry tailored for zkSync environment
Apache License 2.0
299 stars 130 forks source link

feat: Add paymaster parameters to broadcasting flow #596

Closed Jrigada closed 1 month ago

Jrigada commented 1 month ago

Motivation

Paymaster integration was not working with scripts and also a user without balance or with very little one could not take advantage of the paymaster paying for the fees due to some misplaced validation when calculating the gas params.

Solution

Add paymaster data to the script flow, refactor validation when calculating gas parameters, and improve testing by adding a test case where a transaction fails when executed by a user without balance, in contrast to the original test where a user with zero balance successfully uses the paymaster.

Notes

To be able to achieve the paymaster functionality we needed to update the zksync-web3-rs crate. With the last change in the way the crate handles the RLP encoding I was getting errors in the signature of the transaction. For now I am using a fork with the previous state of the encoding. Here is the changes I did, which are very minor.

Examples

Using Testnet Paymaster

image

Using custom paymaster on local node

image