From 16a573ed9ba04517c52b29d32ab20571275bb669 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Wed, 25 Jul 2018 17:36:30 +0200 Subject: [PATCH] evmc_message::salt renamed to create2_salt --- evmc | 2 +- libaleth-interpreter/VMCalls.cpp | 4 ++-- libevm/ExtVMFace.cpp | 2 +- libevm/ExtVMFace.h | 1 + test/unittests/libevm/VMTest.cpp | 10 ++++++++++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/evmc b/evmc index 0c32ac1df08..318b3ee12e4 160000 --- a/evmc +++ b/evmc @@ -1 +1 @@ -Subproject commit 0c32ac1df082203f7c7301786dea18bb01404c87 +Subproject commit 318b3ee12e485b0d46eb4a84a397a0c4d5562ffc diff --git a/libaleth-interpreter/VMCalls.cpp b/libaleth-interpreter/VMCalls.cpp index 479fa8dd0d1..f797bf3bf15 100644 --- a/libaleth-interpreter/VMCalls.cpp +++ b/libaleth-interpreter/VMCalls.cpp @@ -140,10 +140,10 @@ void VM::caseCreate() msg.input_data = &m_mem[off]; msg.input_size = size; - msg.salt = toEvmC(salt); + msg.create2_salt = toEvmC(salt); msg.sender = m_message->destination; msg.depth = m_message->depth + 1; - msg.kind = m_OP == Instruction::CREATE ? EVMC_CREATE : EVMC_CREATE2; // FIXME: In EVM-C move the kind to the top. + msg.kind = m_OP == Instruction::CREATE ? EVMC_CREATE : EVMC_CREATE2; // FIXME: In EVMC move the kind to the top. msg.value = toEvmC(endowment); evmc_result result; diff --git a/libevm/ExtVMFace.cpp b/libevm/ExtVMFace.cpp index a50416e3382..6f8cbf1fd0b 100644 --- a/libevm/ExtVMFace.cpp +++ b/libevm/ExtVMFace.cpp @@ -154,7 +154,7 @@ void create(evmc_result* o_result, ExtVMFace& _env, evmc_message const* _msg) no u256 gas = _msg->gas; u256 value = fromEvmC(_msg->value); bytesConstRef init = {_msg->input_data, _msg->input_size}; - u256 salt = fromEvmC(_msg->salt); + u256 salt = fromEvmC(_msg->create2_salt); Instruction opcode = _msg->kind == EVMC_CREATE ? Instruction::CREATE : Instruction::CREATE2; // ExtVM::create takes the sender address from .myAddress. diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 487b0e53b37..0ce22d31be1 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -264,6 +264,7 @@ class ExtVMFace: public evmc_context bytesConstRef data; ///< Current input data. bytes code; ///< Current code that is executing. h256 codeHash; ///< SHA3 hash of the executing code + u256 salt; ///< Values used in new address construction by CREATE2 SubState sub; ///< Sub-band VM state (suicides, refund counter, logs). unsigned depth = 0; ///< Depth of the present call. bool isCreate = false; ///< Is this a CREATE call? diff --git a/test/unittests/libevm/VMTest.cpp b/test/unittests/libevm/VMTest.cpp index 6dd0f711970..9ec3b44c524 100644 --- a/test/unittests/libevm/VMTest.cpp +++ b/test/unittests/libevm/VMTest.cpp @@ -212,5 +212,15 @@ BOOST_AUTO_TEST_CASE(AlethInterpreterCreate2isForbiddenInStaticCall) testCreate2isForbiddenInStaticCall(); } +BOOST_AUTO_TEST_CASE(AlethInterpreterCreate2DirectExec) +{ + ExtVM extVm(state, envInfo, *se, address, address, address, value, gasPrice, ref(inputData), + ref(code), sha3(code), depth, isCreate, staticCall); + + vm->exec(gas, extVm, OnOpFunc{}); + + BOOST_REQUIRE(state.addressHasCode(expectedAddress)); +} + BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()