Skip to content

Commit

Permalink
Reorder evmc_message fields
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Sep 3, 2018
1 parent 4d86207 commit cfe7bd9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
34 changes: 19 additions & 15 deletions bindings/go/evmc/evmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@ struct extended_context
extern const struct evmc_host_interface evmc_go_host;
static struct evmc_result execute_wrapper(struct evmc_instance* instance, int64_t context_index, enum evmc_revision rev,
const struct evmc_address* destination, const struct evmc_address* sender, const struct evmc_uint256be* value,
const uint8_t* input_data, size_t input_size, const struct evmc_uint256be* code_hash, int64_t gas,
int32_t depth, enum evmc_call_kind kind, uint32_t flags, const uint8_t* code, size_t code_size)
static struct evmc_result execute_wrapper(struct evmc_instance* instance,
int64_t context_index, enum evmc_revision rev,
enum evmc_call_kind kind, uint32_t flags, int32_t depth, int64_t gas,
const struct evmc_address* destination, const struct evmc_address* sender,
const uint8_t* input_data, size_t input_size, const struct evmc_uint256be* value,
const uint8_t* code, size_t code_size, const struct evmc_uint256be* code_hash)
{
struct evmc_uint256be create2_salt = {};
struct evmc_message msg = {
kind,
flags,
depth,
gas,
*destination,
*sender,
*value,
input_data,
input_size,
*code_hash,
*value,
create2_salt,
gas,
depth,
kind,
flags,
*code_hash,
};
struct extended_context ctx = {{&evmc_go_host}, context_index};
Expand Down Expand Up @@ -195,8 +197,9 @@ func (instance *Instance) SetOption(name string, value string) (err error) {
}

func (instance *Instance) Execute(ctx HostContext, rev Revision,
destination common.Address, sender common.Address, value common.Hash, input []byte, codeHash common.Hash, gas int64,
depth int, kind CallKind, static bool, code []byte) (output []byte, gasLeft int64, err error) {
kind CallKind, static bool, depth int, gas int64,
destination common.Address, sender common.Address, input []byte, value common.Hash,
code []byte, codeHash common.Hash) (output []byte, gasLeft int64, err error) {

flags := C.uint32_t(0)
if static {
Expand All @@ -209,9 +212,10 @@ func (instance *Instance) Execute(ctx HostContext, rev Revision,
evmcSender := evmcAddress(sender)
evmcValue := evmcUint256be(value)
evmcCodeHash := evmcUint256be(codeHash)
result := C.execute_wrapper(instance.handle, C.int64_t(ctxId), uint32(rev), &evmcDestination, &evmcSender, &evmcValue,
bytesPtr(input), C.size_t(len(input)), &evmcCodeHash, C.int64_t(gas), C.int32_t(depth), C.enum_evmc_call_kind(kind),
flags, bytesPtr(code), C.size_t(len(code)))
result := C.execute_wrapper(instance.handle, C.int64_t(ctxId), uint32(rev),
C.enum_evmc_call_kind(kind), flags, C.int32_t(depth), C.int64_t(gas),
&evmcDestination, &evmcSender, bytesPtr(input), C.size_t(len(input)), &evmcValue,
bytesPtr(code), C.size_t(len(code)), &evmcCodeHash)
removeHostContext(ctxId)

output = C.GoBytes(unsafe.Pointer(result.output_data), C.int(result.output_size))
Expand Down
46 changes: 23 additions & 23 deletions include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,58 +70,58 @@ enum evmc_flags
*/
struct evmc_message
{
/** 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;

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

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

/** 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.
* 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.
* 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.
* The amount of Ether transferred with the message.
*/
struct evmc_uint256be code_hash;
struct evmc_uint256be value;

/**
* The optional value used in new contract address construction.
*
* Ignored unless kind is EVMC_CREATE2.
* Ignored unless kind is EVMC_CREATE2.
*/
struct evmc_uint256be create2_salt;

/** 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.
* The optional hash of the code of the destination account.
* The null hash MUST be used when not specified.
*/
uint32_t flags;
struct evmc_uint256be code_hash;
};


Expand Down

0 comments on commit cfe7bd9

Please sign in to comment.