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

Allow specifying the caller in set_code function #291

Merged

Conversation

Agusrodri
Copy link
Contributor

What does it do?

Adds a new caller parameter to set_code function. This change, allows to manage several behaviors inside each custom implementation of set_code, like applying a filter to control which addresses can deploy a contract via inner calls of type CALL(CREATE).

To give more context, in Tanssi and our corresponding forks (of both Frontier and evm), we have implemented such use case. More specifically we have two filters implemented in Frontier:

  • CreateOrigin: this filter acts when an account is trying to deploy a contract via CREATE method, which is the direct way of creating contracts. In this case, we don't need the caller to be present in set_code() as we control the CREATE deployments in pallet-evm directly.

  • CreateInnerOrigin: this filter is applied when an account is trying to deploy a contract via a CALL method, that internally contains a CREATE. In this case, we need the caller to be present in set_code(), as this creation will take place inside the substack, and we can't control that behavior from pallet-evm.

Also, a good aspect of this change, is that it doesn't break any existing behavior nor compatibility inside the evm.

Implementation PRs (Tanssi and forks)

[Tanssi] Contract deployment customization in frontier template: moondance-labs/tanssi#571
[Frontier fork] Customize origin for contract deployment: moondance-labs/frontier#1
[evm fork] Modify set_code to make it fallible: moondance-labs#1

@girazoki
Copy link

@koushiro @sorpaas what do you think about this? it allows us to filter addresses that are able to deploy contracts with just a very small change which should not have any effect in the rest of the codebase

Copy link
Member

@sorpaas sorpaas left a comment

Choose a reason for hiding this comment

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

Generally this LGTM but a grumble on SetCodeOrigin.

&mut self,
address: H160,
code: Vec<u8>,
caller: Option<H160>,
Copy link
Member

Choose a reason for hiding this comment

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

We should be specific here.

Rename this parameter to origin, and add a new enum SetCodeOrigin with two variants (Transaction, Subcall(caller)).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @sorpaas, thanks for your review! I already implemented the changes in bc0a9f9.

Let me know if something else is needed :)

@sorpaas sorpaas merged commit 7e7163b into rust-ethereum:master Jun 25, 2024
3 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.

3 participants