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.
@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
What does it do?
Adds a new
caller
parameter toset_code
function. This change, allows to manage several behaviors inside each custom implementation ofset_code
, like applying a filter to control which addresses can deploy a contract via inner calls of typeCALL(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 inset_code()
as we control the CREATE deployments inpallet-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 inset_code()
, as this creation will take place inside the substack, and we can't control that behavior frompallet-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: 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