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

Implement seal_set_code_hash and add example contract #1185

Closed
4 tasks
cmichi opened this issue Mar 15, 2022 · 0 comments · Fixed by #1203
Closed
4 tasks

Implement seal_set_code_hash and add example contract #1185

cmichi opened this issue Mar 15, 2022 · 0 comments · Fixed by #1203
Labels
A-examples [examples] Work item A-ink_env [ink_env] work item E-mentor-available A mentor for this issue is available good first issue Good for newcomers

Comments

@cmichi
Copy link
Collaborator

cmichi commented Mar 15, 2022

I've marked this issues as a good first one since the task is something that can be done mostly analog to already existing code.

ink! interfaces with Substrate's contracts pallet via an API. The API functions are named with the prefix seal_ ‒ so e.g. seal_call. From time to time new API functions are added. One recently added one is seal_set_code_hash, you can find it here: https://github.com/paritytech/substrate/blob/master/frame/contracts/src/wasm/runtime.rs#L1976-L2011. It was added in paritytech/substrate#10567.

While the contracts pallet side has been implemented we are missing a possibility to invoke this function from ink!.

ToDo

  • Add a new function ink_env::set_code_hash.
    Take a look at the file env/src/api.rs, it should be possible to take one of the functions there (e.g. is_contract) and implement this new function analog.
  • You will have to add seal_set_code_hash in this file: https://github.com/paritytech/ink/blob/master/crates/env/src/engine/on_chain/ext.rs#L341. Add it as an __unstable__ function there.
  • You can ignore off-chain testing for now and add an unimplemented!("off-chain environment does not yet support …"); there.
  • Add an example which illustrates how this new function can be used to write an upgradeable smart contract.
@cmichi cmichi added good first issue Good for newcomers A-examples [examples] Work item A-ink_env [ink_env] work item E-mentor-available A mentor for this issue is available labels Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-examples [examples] Work item A-ink_env [ink_env] work item E-mentor-available A mentor for this issue is available good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant