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(cheatcodes): include trace information about setting account code in EIP7702 transaction #9800

Open
tinchoabbate opened this issue Jan 31, 2025 · 3 comments
Labels
A-cheatcodes Area: cheatcodes Cmd-forge-script Command: forge script T-feature Type: feature

Comments

@tinchoabbate
Copy link

Component

Forge

Describe the feature you would like

In a forge test that uses the vm.signAndAttachDelegation (or vm.attachDelegation) cheatcode, it'd be helpful if the test's trace somehow showed the account's code being set. Right now the process is opaque for the devs, and it's unclear whether the account's code was updated or not.

For example, right now if I do:

vm.signAndAttachDelegation(address(delegateContract), bob.privateKey);
address(0).call("");

Then the trace shows:

├─ [0] VM::signAndAttachDelegation(DelegateContractV1: [0x8Ad159a275AEE56fb2334DBb69036E9c7baCEe9b], 25733205992525344549959058604562080613152606839721263039386232180585134200482 [2.573e76])
│   └─ ← [Return] (1, 0x30326dccdd7ff594b3bfa85acdb7a472414233bcfef3db1a3aeaa453d10891b9, 0x76aee582915fbaf1cc3105cd7c1f37d4dbb13eaf64117fd9e6447fb50d281a2f, 0, 0x8Ad159a275AEE56fb2334DBb69036E9c7baCEe9b)
├─ [0] 0x0000000000000000000000000000000000000000::fallback()
│   └─ ← [Stop] 

But there's nothing in the call to address(0) that signals the call has 7702 data attached and that it's setting code to an account.

Additional context

No response

@tinchoabbate tinchoabbate added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Jan 31, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jan 31, 2025
@zerosnacks
Copy link
Member

zerosnacks commented Jan 31, 2025

Definitively in support of adding this, good idea

cc @evchip

@zerosnacks zerosnacks added A-cheatcodes Area: cheatcodes Cmd-forge-script Command: forge script labels Jan 31, 2025
@zerosnacks zerosnacks changed the title Include trace information about setting account code in EIP7702 transaction feat(cheatcodes): include trace information about setting account code in EIP7702 transaction Jan 31, 2025
@zerosnacks zerosnacks removed the T-needs-triage Type: this issue needs to be labelled label Jan 31, 2025
@evchip
Copy link
Contributor

evchip commented Jan 31, 2025

Thanks @tinchoabbate, I'll look into this.

@evchip
Copy link
Contributor

evchip commented Feb 1, 2025

@tinchoabbate thanks for reporting this. You're right that the delegation code write isn't visible in traces because we currently write directly to state rather than executing through the EVM.

@zerosnacks I propose we modify attachDelegation and signAndAttachDelegation to simulate a type-4 EIP-7702 transaction (in addition to the current state write) specifically to generate proper traces. This would give visibility into the delegation process while maintaining current test behavior.

Happy to implement this if the approach sounds reasonable. Let me know if you'd prefer a different solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes Cmd-forge-script Command: forge script T-feature Type: feature
Projects
Status: Todo
Development

No branches or pull requests

3 participants