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

Message type - match EVMC #61

Closed
mratsim opened this issue Jun 30, 2018 · 2 comments
Closed

Message type - match EVMC #61

mratsim opened this issue Jun 30, 2018 · 2 comments
Assignees

Comments

@mratsim
Copy link
Contributor

mratsim commented Jun 30, 2018

It would probably best to match EVMC fields rather than Py-EVM to ease interface with EVM-C and eWASM in the future.

EVMC Message type - https://github.com/ethereum/evmc/blob/master/include/evmc/evmc.h

/**
 * Big-endian 256-bit integer.
 *
 * 32 bytes of data representing big-endian 256-bit integer. I.e. bytes[0] is
 * the most significant byte, bytes[31] is the least significant byte.
 * This type is used to transfer to/from the VM values interpreted by the user
 * as both 256-bit integers and 256-bit hashes.
 */
struct evmc_uint256be
{
    /** The 32 bytes of the big-endian integer or hash. */
    uint8_t bytes[32];
};

/** Big-endian 160-bit hash suitable for keeping an Ethereum address. */
struct evmc_address
{
    /** The 20 bytes of the hash. */
    uint8_t bytes[20];
};

/** The kind of call-like instruction. */
enum evmc_call_kind
{
    EVMC_CALL = 0,         /**< Request CALL. */
    EVMC_DELEGATECALL = 1, /**< Request DELEGATECALL. The value param ignored. */
    EVMC_CALLCODE = 2,     /**< Request CALLCODE. */
    EVMC_CREATE = 3        /**< Request CREATE. Semantic of some params changes. */
};

/** The flags for ::evmc_message. */
enum evmc_flags
{
    EVMC_STATIC = 1 /**< Static call mode. */
};

/**
 * The message describing an EVM call,
 * including a zero-depth calls from a transaction origin.
 */
struct evmc_message
{
    /** The destination of the message. */
    struct evmc_address destination;

    /** The sender of the message. */
    struct evmc_address sender;

    /**
     * The amount of Ether transferred with the message.
     */
    struct evmc_uint256be value;

    /**
     * The message input data.
     *
     *  This MAY be NULL.
     */
    const uint8_t* input_data;

    /**
     * The size of the message input data.
     *
     *  If input_data is NULL this MUST be 0.
     */
    size_t input_size;

    /**
     * The optional hash of the code of the destination account.
     *  The null hash MUST be used when not specified.
     */
    struct evmc_uint256be code_hash;

    /** The amount of gas for message execution. */
    int64_t gas;

    /** The call depth. */
    int32_t depth;

    /** The kind of the call. For zero-depth calls ::EVMC_CALL SHOULD be used. */
    enum evmc_call_kind kind;

    /**
     * Additional flags modifying the call execution behavior.
     *  In the current version the only valid values are ::EVMC_STATIC or 0.
     */
    uint32_t flags;
};

Current Nim type for Messages https://github.com/status-im/nimbus/blob/6f28d1186675f648e0587f44e730b9dc23291bab/nimbus/vm_types.nim#L53-L89

@mratsim
Copy link
Contributor Author

mratsim commented Aug 9, 2018

@chfast is adding the EVMC interface to Geth in ethereum/go-ethereum#17050.

This means that we could build Geth with Nimbus backend and be much more confident about having a rock solid VM implementation.

@mratsim
Copy link
Contributor Author

mratsim commented Aug 21, 2018

closing in favor of #114

@mratsim mratsim closed this as completed Aug 21, 2018
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

3 participants