Inspect bytecode of onchain contracts #295

Closed
opened 2021-02-10 20:00:40 +09:00 by gorbak25 · 2 comments
gorbak25 commented 2021-02-10 20:00:40 +09:00 (Migrated from gitlab.com)

In order for #197 to be fully useful and enable the creation of an easy and good DEFI ecosystem we need the ability to:

  • Clone an existing contract(same bytecode, init called again by the contract)
  • Obtain the bytecode of our contract
  • Obtain the bytecode of an already deployed contract

In order for this to become possible we need a "GetBytecode" opcode/helpers. Right now this functionality isn't present at all in Sophia:
e2ef95d6fd/src/aeso_ast_infer_types.erl (L436)

I propose adding 2 new functions for the iris hardfork:

Contract.code
Chain.code_of(...)

where Chain.code_of(Contract.address) === Contract.code

Use-cases which will become possible by introducing this:

  1. Inspecting the hash of the bytecode of an external contract against a whitelist
  2. Cloning an existing contract Chain.create_contract(Chain.code_of(address_to_be_cloned), init_args)
  3. Creating a copy of yourself Chain.create_contract(Contract.code, init_args)
    etc...
In order for #197 to be fully useful and enable the creation of an easy and good DEFI ecosystem we need the ability to: - Clone an existing contract(same bytecode, init called again by the contract) - Obtain the bytecode of our contract - Obtain the bytecode of an already deployed contract In order for this to become possible we need a "GetBytecode" opcode/helpers. Right now this functionality isn't present at all in Sophia: https://github.com/aeternity/aesophia/blob/e2ef95d6fda9a1f4e3a03f54c1e55a92903b1f21/src/aeso_ast_infer_types.erl#L436 I propose adding 2 new functions for the iris hardfork: ``` Contract.code Chain.code_of(...) ``` where `Chain.code_of(Contract.address) === Contract.code` Use-cases which will become possible by introducing this: 1. Inspecting the hash of the bytecode of an external contract against a whitelist 2. Cloning an existing contract `Chain.create_contract(Chain.code_of(address_to_be_cloned), init_args)` 3. Creating a copy of yourself `Chain.create_contract(Contract.code, init_args)` etc...
zxq9 commented 2021-02-11 20:43:35 +09:00 (Migrated from gitlab.com)

Created by: nikita-fuchs

Fully agree. Do we have the staff to exactly specify the right gas costs for these operations?

*Created by: nikita-fuchs* Fully agree. Do we have the staff to exactly specify the right gas costs for these operations?
gorbak25 commented 2021-02-14 07:59:57 +09:00 (Migrated from gitlab.com)

@UlfNorell Could you give us a time estimate for this task?

@UlfNorell Could you give us a time estimate for this task?
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#295
No description provided.