ethereum / py-evm

A Python implementation of the Ethereum Virtual Machine
https://py-evm.readthedocs.io/en/latest/
MIT License
2.26k stars 649 forks source link

Code Merklization #1958

Closed pipermerriam closed 3 years ago

pipermerriam commented 4 years ago

What is wrong?

https://eips.ethereum.org/EIPS/eip-2926

EIP-2027, aka Code Merklization is coming down the EIP pipeline. It would be nice to have a basic implementation of it.

How can it be fixed

Implement a stand-alone API for merklizing code. I'd recommend something loosely using the following structure:

from typing import NamedTuple

class MerklizedCode(NamedTuple):
    code_hash: Hash32  # keccak(...)
    code_root: Hash32  # the actual merkle root
    code_length: int
    version: int
    chunks: Tuple[[Tuple[bytes, int], ...]

def merklize_code(code: bytes) -> MerklizedCode:
    ...

The MerklizedCode class above is just a suggestion after a quick perusal of the spec.

voith commented 4 years ago

I’d like to give this a shot.

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 100.0 DAI (100.0 USD @ $1.0/DAI) attached to it.

pipermerriam commented 4 years ago

@voith I made https://gitcoin.co/issue/ethereum/py-evm/1958/100023968 for you if you want it.

Also, something to think about but I don't want it to get in the way of simplicity. Whatever way you end up implementing the binary trie here will probably be informative for our upcoming need for a more full featured binary trie implementation that can be used with the main Ethereum state.

voith commented 4 years ago

Hey @pipermerriam, I'm not interested in the bounty. I can see that there are two more people interested in the bounty. Feel free to approve them. My progress will be slow as I have a day job. In any case, I will independently explore this issue. I want to help out with the overall implementation of the binary Trie.

pipermerriam commented 4 years ago

@voith we aren't in a rush for this and the bounty was just intended to be bonus. I'll close the bounty. You're free to run with this at your own pace.

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 100.0 DAI (100.0 USD @ $1.0/DAI) attached to this issue has been cancelled by the bounty submitter

pipermerriam commented 4 years ago

@developerfred and @jimn2k and @hhio618 I appreciate your interest in working on this issue. We really do value 3rd party contributors and I'm always interested in getting you compensated for work. We also try to avoid "mercenary" style contributions who's core motivation is the bounty. If any of your are truly interested in collaborating on a solid implementation of something like the binary trie implementation or code merklization I'd encourage you to jump in and open a pull request, or find another "Good First Issue" in one of our repositories. I won't make any commitments about compensation levels but I can commit to paying what I can for quality work.

voith commented 4 years ago

Thanks, @pipermerriam. I've been reading research done around the witness spec. I want to get the broader picture before I start implementing it.

developerfred commented 4 years ago

@developerfred and @jimn2k and @hhio618 I appreciate your interest in working on this issue. We really do value 3rd party contributors and I'm always interested in getting you compensated for work. We also try to avoid "mercenary" style contributions who's core motivation is the bounty. If any of your are truly interested in collaborating on a solid implementation of something like the binary trie implementation or code merklization I'd encourage you to jump in and open a pull request, or find another "Good First Issue" in one of our repositories. I won't make any commitments about compensation levels but I can commit to paying what I can for quality work.

I want this, thanks for the opportunity

junning-tong commented 3 years ago

Hi @pipermerriam I wrote a simple implementation https://gist.github.com/junning-tong/6a28319d5e742037758470a053b575ca

Is anyone else working on this? If not, I'd like to refine my current implementation and start adding test cases.

voith commented 3 years ago

@junning-tong I never managed to get to it. So go ahead, it's all yours!

pipermerriam commented 3 years ago

You are welcome to work on it, but it's likely to not be the direction the protocol takes. Verkle Tries are the current direction that we're looking to go.