Skip to content

Conversation

alexggh
Copy link
Contributor

@alexggh alexggh commented Oct 2, 2025

Needed for: paritytech/foundry-polkadot#334.

In foundry-polkadot we need the ability to be able to manipulate the msg.sender and the tx.origin that a solidity contract sees cheatcode documentation.

Currently all create/call methods use the bare_instantiate/bare_call to run things in pallet-revive, the caller then normally gets set automatically, based on what is the call stack, but for forge test we need to be able to manipulate, so that we can set it to custom values.

Additionally, for delegate_call, bare_call is used, so there is no way to specify we are dealing with a delegate call, so the call is not working correcly.

For both this paths, we need a way to inject this information into the execution environment, hence I added an optional structure that we can populate from foundry. I'm open to other better ideas.

Signed-off-by: Alexandru Gheorghe <[email protected]>
Comment on lines +112 to +118
pub struct InjectExecEnv<T: frame_system::Config> {
pub caller: OriginFor<T>,
pub delegated_caller: Option<OriginFor<T>>,
pub callee: H160,

pub first_call_only: bool,
}
Copy link
Member

Choose a reason for hiding this comment

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

Please don't add top level items. It is cluttered enough already. Should go into a separate cheat_code module where we bundle all the things just needed for cheat codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree.

gas_limit,
DepositLimit::Balance(storage_deposit_limit),
data,
None,
Copy link
Member

Choose a reason for hiding this comment

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

Adding new arguments here is really annoying. This is why I added a more general ExecConfig here: #9803

Let's wait for this PR and then you can include your structure into ExecConfig.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice I think I can work with that, I have the luxury of being able to point foundry at a branch, so I will work on adapting this PR on top of yours.

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.

2 participants