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: impl hardhat_impersonateAccount and hardhat_stopImpersonationAccount #125

Merged

Conversation

grw-ms
Copy link
Contributor

@grw-ms grw-ms commented Sep 19, 2023

What 💻

  • Adds a field impersonated_account: Option<Address> to node; in run_l2_tx method, adjust the tx to have initiator = impersonated account if set. This requires setting self.system_contracts = SystemContracts::from_options(&Options::BuiltInWithoutSecurity) to disable signature verification
  • Adds hardhat_impersonateAccount and hardhat_stopImpersonationAccount RPCs

Why ✋

  • Allow user to send transactions from arbitrary addresses, useful for testing

Evidence 📷

Screenshot 2023-09-19 at 16 55 19

Notes 📝

  • Any suggestions for better tests? We don't have any test for send_raw_transaction- I tried a bit to write one but was quite hard, just re-used apply_txs

@grw-ms grw-ms requested a review from a team as a code owner September 19, 2023 14:57
src/node.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
@AntonD3
Copy link
Collaborator

AntonD3 commented Sep 20, 2023

And actually, it will be impossible to simulate a call from a contract, because of this check: https://github.com/matter-labs/era-system-contracts/blob/main/bootloader/bootloader.yul#L2097. If we want to support such functionality we need to mark the impersonated account as an account here https://github.com/matter-labs/era-system-contracts/blob/main/contracts/ContractDeployer.sol#L25 . WDYT @MexicanAce ?
Update: the problem is even bigger because it's impossible to initiate transactions from not account

src/node.rs Outdated Show resolved Hide resolved
@MexicanAce
Copy link
Collaborator

Update: the problem is even bigger because it's impossible to initiate transactions from not account

Decided to hold off on addressing this functionality in a follow-up PR

Copy link
Collaborator

@MexicanAce MexicanAce left a comment

Choose a reason for hiding this comment

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

LGTM

@MexicanAce MexicanAce merged commit e2f07b2 into matter-labs:main Sep 21, 2023
8 checks passed
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.

4 participants