Skip to content

Conversation

alexggh
Copy link

@alexggh alexggh commented Oct 2, 2025

Depends on: paritytech/polkadot-sdk#9909
Fixes: #324

There are a few problems with the way we currently do calls:

  1. We are not correctly setting the origin, fixed it by using ecx.tx.caller., when calling bare_call/bare_instantiate.
  2. Delegate calls don't work at all because we are using bare_call for all type of calls, and that does not allow setting any delegate call info.
  3. For prank/startPrank/stopPrank pallet revive does not have any ability to play with the caller/msg.sender.

For 1 and 2 I added a extra argument to bare_call/bare_instantiate and plumb its way through pallet_revive in paritytech/polkadot-sdk#9909

Signed-off-by: Alexandru Gheorghe <[email protected]>

fn fund_pranked_accounts(prank_enabled: bool, account: Address) {
// Fuzzed prank addresses have no balance, so they won't exist in revive, and
// calls will fail, this is not a problem when running in REVM.
Copy link
Collaborator

Choose a reason for hiding this comment

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

how is it done that account without funds can be used to trigger call in REVM - how is gas charged in this case?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, that's something I want to investigate.

trace::<Runtime, _, _>(|| {
let origin = OriginFor::<Runtime>::signed(AccountId::to_fallback_account_id(
&H160::from_slice(input.caller().as_slice()),
&H160::from_slice(ecx.tx.caller.as_slice()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

From this what I see zksync support pranks for origin and sender only on top level call. your solution looks better but requires pallet-revive modification.

Copy link
Author

Choose a reason for hiding this comment

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

This is how zksync sets it: https://github.com/matter-labs/foundry-zksync/blob/9a3a6b7fb65ea9fb9589c7e4b3a5416ad8c742fa/crates/zksync/core/src/vm/runner.rs#L292.

We do need pallet-revive modification no-matter what because we can control only origin with the current interface.

@alindima
Copy link

alindima commented Oct 6, 2025

For pranking, couldn't you use an approach like we do in Anvil? #332

Overriding the host functions that do the account recovery

@alexggh
Copy link
Author

alexggh commented Oct 6, 2025

For pranking, couldn't you use an approach like we do in Anvil? #332

Overriding the host functions that do the account recovery

Unless, I'm misunderstanding #332, these are two different things msg.sender and tx.orgin are already set by the host when calling into the smart-contracts VM, so overriding the host functions here wouldn't have any impact. Because the pallet-revive env will just set it to whatever it detects automatically.

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.

[Forge test] [Cheatcode support] Implement prank/startPrank/stopPrank
3 participants