Remove code hash from evmc_message

This commit is contained in:
Paweł Bylica 2018-09-03 16:32:16 +02:00
parent cf43fe0f66
commit 9a2d07e595
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
4 changed files with 4 additions and 14 deletions

View File

@ -36,7 +36,7 @@ static struct evmc_result execute_wrapper(struct evmc_instance* instance,
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)
const uint8_t* code, size_t code_size)
{
struct evmc_uint256be create2_salt = {};
struct evmc_message msg = {
@ -50,7 +50,6 @@ static struct evmc_result execute_wrapper(struct evmc_instance* instance,
input_size,
*value,
create2_salt,
*code_hash,
};
struct extended_context ctx = {{&evmc_go_host}, context_index};
@ -199,7 +198,7 @@ func (instance *Instance) SetOption(name string, value string) (err error) {
func (instance *Instance) Execute(ctx HostContext, rev Revision,
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) {
code []byte) (output []byte, gasLeft int64, err error) {
flags := C.uint32_t(0)
if static {
@ -211,11 +210,10 @@ func (instance *Instance) Execute(ctx HostContext, rev Revision,
evmcDestination := evmcAddress(destination)
evmcSender := evmcAddress(sender)
evmcValue := evmcUint256be(value)
evmcCodeHash := evmcUint256be(codeHash)
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)
bytesPtr(code), C.size_t(len(code)))
removeHostContext(ctxId)
output = C.GoBytes(unsafe.Pointer(result.output_data), C.int(result.output_size))

View File

@ -19,7 +19,6 @@ int main()
// EVM bytecode goes here. This is one of the examples.
const uint8_t code[] = "\x30\x60\x00\x52\x59\x60\x00\xf3";
const size_t code_size = sizeof(code);
const struct evmc_uint256be code_hash = {.bytes = {1, 2, 3}};
const uint8_t input[] = "Hello World!";
const struct evmc_uint256be value = {{1, 0}};
const struct evmc_address addr = {{0, 1, 2}};
@ -31,7 +30,6 @@ int main()
msg.value = value;
msg.input_data = input;
msg.input_size = sizeof(input);
msg.code_hash = code_hash;
msg.gas = gas;
msg.depth = 0;
struct evmc_result result = evmc_execute(vm, ctx, EVMC_HOMESTEAD, &msg, code, code_size);

View File

@ -116,12 +116,6 @@ struct evmc_message
* Ignored unless kind is EVMC_CREATE2.
*/
struct evmc_uint256be create2_salt;
/**
* The optional hash of the code of the destination account.
* The null hash MUST be used when not specified.
*/
struct evmc_uint256be code_hash;
};

View File

@ -16,7 +16,7 @@ static_assert(sizeof(evmc_uint256be) == 32, "evmc_uint256be is too big");
static_assert(sizeof(evmc_address) == 20, "evmc_address is too big");
static_assert(sizeof(evmc_result) <= 64, "evmc_result does not fit cache line");
static_assert(sizeof(evmc_instance) <= 64, "evmc_instance does not fit cache line");
static_assert(offsetof(evmc_message, code_hash) % 8 == 0, "evmc_message.code_hash not aligned");
static_assert(offsetof(evmc_message, value) % 8 == 0, "evmc_message.value not aligned");
// Check enums match int size.
// On GCC/clang the underlying type should be unsigned int, on MSVC int