Skip to content

feat: Introduce ByteCode format #121

Closed
@rakita

Description

@rakita

With a restriction that contacts can not start with 0xEF and with the possibility that in future we will have different ByteCode for EVM Object Format, it makes sense to introduce support for it into the revm. https://eips.ethereum.org/EIPS/eip-3541

The biggest benefit atm would be introducing ByteCode type that will contain jumptable and gas blocks and with that we would skip the needed analysis of the contract. This is a fairly big speed-u for some use cases noticed in the foundry as fuzzing tests call a lot of contracts with not much execution and analysis, in that case, is taking a lot of time.

The proposal is to introduce enum ByteCode that would somehow return: code, code_size and jumptable.

Basically replace this input with ByteCode:


and propagate change wherever needed.
ByteCode should set these fields in the contract:

and do the same for database struct:

To fully circle the story with EVM Object Format, CREATE and CREATE2 will need to return 0xEF type format in bytes that would get transformed to ByteCode for evm usage here:

// EIP-3541: Reject new contract code starting with the 0xEF byte
if SPEC::enabled(LONDON) && !code.is_empty() && code.get(0) == Some(&0xEF) {
self.data.subroutine.checkpoint_revert(checkpoint);
return (Return::CreateContractWithEF, ret, interp.gas, b);
}

But this is a consensus rule and out of scope for this feat, we should just continue using legacy ByteCode here. If needed we could in Inspector create_end transform that into ByteCode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions