This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
Replies: 1 comment 1 reply
-
I think we should go with the first option:
A few questions:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Goal
Some of the appchain will want to only offer a reduced set of usable smart contracts for users to use.
To do so we want to enable the chain developers to whitelist some contracts so that only those can be deployed.
Solutions
Whitelist at the declare levelIn order to be deployed and executed, a contract must be declared before. If we only allow to declare a predefined list of contracts, those will be the only one declarable.
Problem: I can see a lot of usecase where the chain want only some contracts only be deployed once or only by some specific root users. This is not possible with this solution
Whitelist at the deploy levelThere is two types of deployment in Starknet. The account deployment and the regular contracts deployments.
The account deployment txs can easily be filtered because their payload contains the has class_hash of the contract to be deployed.
The regular deploy in the other hand is done through invoke transactions. Which are super generic, their core input is the calldata field, which is just a vec of Felt that can be interpreted in any imaginable way by the Account executing the Tx. So there is no generic way to filter that, in a chain which allows for account diversity.
Whitelist in the
BlockifierStateAdapter
One thing we can do tho is change our impl of
<BlockifierStateAdapter as State>::set_class_hash_at
so that it returns an error. The idea would be forBlockifierStateAdapter
to be instanciated with a field containing the address of the account executing the tx, and to call afn is_my_user_allowed_to_deploy_that_contract(ContractAddress, ClassHash) -> bool
method and return an error if not. The transaction execution will stop instantly.Whitelist the accounts
The chain maintainers can also opt for only allowing one (or a few) type of accounts to be deployed. This could allow them to indirectly control which contracts can be deployed. This can be done in two way:
Each of the tree solutions has it's pro an cons.
Implementation
Because this features drive us away from the canon Starknet impl, I think it should be hidden behind a feature flag.
The lib users will be free to combine different non-canon features for their own chain, by activating different set of those flags.
But because this is only an addition to the canon behavior, and because it will probably be used by multiple different appchains, it can live in the core madara repo.
What's next
We have to decide which solution, or solutions, we want to see implemented. Once done @ybensacq would like to take care of it. He has a great experience with Substrate and has done the research that lead to this discussion.
Beta Was this translation helpful? Give feedback.
All reactions