Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

seal: code_hash queries #2346

Closed
pepyakin opened this issue Apr 23, 2019 · 4 comments
Closed

seal: code_hash queries #2346

pepyakin opened this issue Apr 23, 2019 · 4 comments
Labels
J0-enhancement An additional feature request. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder

Comments

@pepyakin
Copy link
Contributor

It might be useful to allow contracts to query their own code_hash. One thing that this would allow is to create contracts with identical codes.

Another possibility is to allow contracts to query code_hash of another contract specified by some address.

These two are not required for MVP and they are also not interdependent and can be delivered separately.

@pepyakin pepyakin added this to the As-and-when milestone Apr 23, 2019
@pepyakin pepyakin added the J0-enhancement An additional feature request. label Apr 24, 2019
@gui1117
Copy link
Contributor

gui1117 commented May 22, 2019

Another possibility is to allow contracts to query code_hash of another contract specified by some address.

This is interesting for a contract to be able to trust another contract. For example a cookie-contract that is only writtable by a erc20 contract. The account will say to erc20 hello I want to use you and this is my cooke-contract, and erc20 will store the data he wants to store in this one and trusting by its code_hash.

Although this mecanism is not entirely needed due to CREATE2 properties because the address of a contract contains the code_hash, user and input_data so user can just say hello use this contract, it has been created by him with that input.
But we might not want to rely on CREATE2 properties.

@pepyakin
Copy link
Contributor Author

Good point on CREATE2. However, I believe that code_hash query still provide at least some benefits:

  1. As I mentioned in the first comment, code_hash query of the caller gives an ability to create instances with the same code that the caller has. Otherwise, the caller would have to have code_hash embedded as a literal but this might be not feasible.
  2. Proofing that a contract has a certain address becomes more straightforward: you don't have to provide the caller address and data used to compute the address, you just compare hashes.
  3. A code_hash query can tell whether a given address is a regular account (i.e. its code_hash is null) whereas CREATE2 can only proof that a particular address is a contract.

@pepyakin pepyakin changed the title srml-contract: code_hash queries seal: code_hash queries Jul 1, 2020
@athei athei removed this from the Ideas milestone Jul 23, 2020
@athei athei added U3-nice_to_have Issue is worth doing eventually. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder labels Mar 22, 2021
@athei athei removed the U3-nice_to_have Issue is worth doing eventually. label Mar 25, 2021
@stale
Copy link

stale bot commented Jul 7, 2021

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jul 7, 2021
@pepyakin pepyakin removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jul 8, 2021
@athei
Copy link
Member

athei commented Apr 1, 2022

Closed by #10933

@athei athei closed this as completed Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder
Projects
Status: Done
Development

No branches or pull requests

4 participants