rust-ethereum / evm

Pure Rust implementation of Ethereum Virtual Machine
Apache License 2.0
1.16k stars 355 forks source link

Allow specifying the caller in `set_code` function #291

Closed Agusrodri closed 2 months ago

Agusrodri commented 2 months ago

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:

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: https://github.com/moondance-labs/tanssi/pull/571 [Frontier fork] Customize origin for contract deployment: https://github.com/moondance-labs/frontier/pull/1 [evm fork] Modify set_code to make it fallible: https://github.com/moondance-labs/evm/pull/1

girazoki commented 2 months ago

@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