matter-labs / era-contracts

Smart Contract Submodule For zkSync Era
MIT License
476 stars 339 forks source link

L2StandardERC20 not being initialized correctly #3

Open 0xnakato opened 1 year ago

0xnakato commented 1 year ago

Hello, I'm testing the ERC20 permit feature with USDC and DAI on the zkSync Era testnet. However, a permit signature created with the token name will not work and returns the error Invalid signature.

And it looks like the bridge token contract is not correctly initialized the ERC20PermitUpgradeable and only ERC20Upgradeable is initialized.

https://github.com/matter-labs/era-contracts/blob/main/zksync/contracts/bridge/L2StandardERC20.sol#L82

The DOMAIN_SEPARATOR() of the testnet DAI token will return 0x630ae2e0feb87df0136547b778ed1ad7bb1fdc555ac24d3a61b55432a339fe12 which is the exact value of the uninitialized domain separator.

Example codes to generate the same/uninitialized domain separator https://gist.github.com/0xnakato/2c803385ac4c47c0455d6d0de105538f

vladbochok commented 1 year ago

Hello @0xnakato, thank you for reporting the issue!
We are aware of it and plan to implement the fix in the upcoming upgrade.

ShubhSensei commented 1 year ago

Hey @vladbochok, can i work on this issue?

thekera404 commented 8 months ago

Hey @vladbochok, can i work on this issue?

etherbiln commented 6 months ago

I recommend checking the following @0xnakato

Ensure that the domain separator is correctly set during the initialization of your contract. Verify that the data you’re signing is correctly formed according to the EIP-712 standard. Make sure the account used to sign the data is the same as the account used in the permit function