Allow specifying the caller in set_code
function
#291
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: 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