Skip to content

Conversation

@alexggh
Copy link

@alexggh alexggh commented Oct 2, 2025

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

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.
  4. For mock* cheatcodes pallet revive does not have the ability to intercept the flows.

In this pr I ended up adding a series of hooks in pallet-revive which allows to intercept and control the flow, the interface is described here https://github.com/paritytech/polkadot-sdk/pull/9909/files#diff-62436392e75447324001e88786b55d2966415fdd7e6cf6319708c8d48a980c2fR31 and implemented in this PR.

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.

Copy link
Author

Choose a reason for hiding this comment

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

So, I did some digging, it seems to be because for revive we want to charge the storage deposit from the pranked accounts, I can probably add some hook in there:
https://github.com/paritytech/polkadot-sdk/blob/c61e227f2c59fa0ce7df5f977dad4076ff470f00/substrate/frame/revive/src/lib.rs#L1308

But, I also don't think the funding is such a bad solution.

Signed-off-by: Alexandru Gheorghe <[email protected]>
@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.

Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
@alexggh alexggh changed the title add vm.prank/startPrank/stopPrank support add prank* and mock* cheatcodes family support Oct 8, 2025
@alexggh alexggh marked this pull request as ready for review October 8, 2025 15:52
Signed-off-by: Alexandru Gheorghe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants