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

Extended bytecodes without using Ethereum ones #155

Open
ajlopez opened this issue Dec 20, 2019 · 0 comments
Open

Extended bytecodes without using Ethereum ones #155

ajlopez opened this issue Dec 20, 2019 · 0 comments

Comments

@ajlopez
Copy link
Contributor

ajlopez commented Dec 20, 2019

We could add new opcodes to Ethereum Virtual Machine, but these new bytecodes could collision with future bytecodes of Ethereum. And the insertion of these new opcodes is problematic in Solidity programs. We could use support more than one virtual machine, but deployment and alignment with existing Ethereum ecosystem could be difficult to maintain.

This improvement proposal describe a minimal hack to allow the inclusion of new bytecodes.

In a Solidity source code, we could add:

assembly {
    log1(constant1, constant2, constant3)
}

The constant3 is the topic of these log instruction (log1 has ONE topic), Usually, the topic is the hash of the full signature of an event. If we employ a topic with many zeroes, like 0x72736b ("rsk" in hexadecimal), we could ensure that the collision with a valid topic is really minimal.

Then, constant1 could have the new extended bytecode, arbitrarily defined in our code base.

constant2 could specify additional data for that bytecode, if needed.

Alternatively, we could use:

assembly {
    log2(constant1, constant2, constant3, constant4)
}

where:

  • constant3 is the special constant that indicates our extension.
  • constant4 is the new bytecode (this is the second topic of log2)
  • constant1 constant2 are additional data for that bytecode

The implementation of these feature is a light modification to virtual machine code, that should not impact in performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant