Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit f338757

Browse files
committed
Merge branch 'release/1.7'
2 parents 9567534 + 4afe855 commit f338757

File tree

8 files changed

+29
-36
lines changed

8 files changed

+29
-36
lines changed

evmc

Submodule evmc updated from 7ecb310 to 4ee8ff8

libaleth-interpreter/VM.cpp

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
namespace
1010
{
11-
void destroy(evmc_instance* _instance)
11+
void destroy(evmc_vm* _instance)
1212
{
1313
(void)_instance;
1414
}
1515

16-
evmc_capabilities_flagset getCapabilities(evmc_instance* _instance) noexcept
16+
evmc_capabilities_flagset getCapabilities(evmc_vm* _instance) noexcept
1717
{
1818
(void)_instance;
1919
return EVMC_CAPABILITY_EVM1;
@@ -24,7 +24,7 @@ void delete_output(const evmc_result* result)
2424
delete[] result->output_data;
2525
}
2626

27-
evmc_result execute(evmc_instance* _instance, evmc_context* _context, evmc_revision _rev,
27+
evmc_result execute(evmc_vm* _instance, evmc_host_context* _context, evmc_revision _rev,
2828
const evmc_message* _msg, uint8_t const* _code, size_t _codeSize) noexcept
2929
{
3030
(void)_instance;
@@ -100,23 +100,17 @@ evmc_result execute(evmc_instance* _instance, evmc_context* _context, evmc_revis
100100
}
101101
} // namespace
102102

103-
extern "C" evmc_instance* evmc_create_interpreter() noexcept
103+
extern "C" evmc_vm* evmc_create_interpreter() noexcept
104104
{
105105
// TODO: Allow creating multiple instances with different configurations.
106-
static evmc_instance s_instance{
107-
EVMC_ABI_VERSION,
108-
"interpreter",
109-
aleth_version,
110-
::destroy,
111-
::execute,
112-
getCapabilities,
113-
nullptr, // set_tracer
106+
static evmc_vm s_vm{
107+
EVMC_ABI_VERSION, "interpreter", aleth_version, ::destroy, ::execute, getCapabilities,
114108
nullptr, // set_option
115109
};
116110
static bool metricsInited = dev::eth::VM::initMetrics();
117111
(void)metricsInited;
118112

119-
return &s_instance;
113+
return &s_vm;
120114
}
121115

122116

@@ -176,17 +170,16 @@ uint64_t VM::decodeJumpvDest(const byte* const _code, uint64_t& _pc, byte _voff)
176170
//
177171
// set current SP to SP', adjust SP' per _removed and _added items
178172
//
179-
void VM::adjustStack(int _removed, int _added)
173+
void VM::adjustStack(int _required, int _change)
180174
{
181175
m_SP = m_SPP;
182176

183177
// adjust stack and check bounds
184-
m_SPP += _removed;
185-
if (m_stackEnd < m_SPP)
186-
throwBadStack(_removed, _added);
187-
m_SPP -= _added;
178+
if (m_stackEnd < m_SP + _required)
179+
throwBadStack(_required, _change);
180+
m_SPP -= _change;
188181
if (m_SPP < m_stack)
189-
throwBadStack(_removed, _added);
182+
throwBadStack(_required, _change);
190183
}
191184

192185
uint64_t VM::gasForMem(u512 const& _size)
@@ -234,7 +227,7 @@ void VM::fetchInstruction()
234227
{
235228
m_OP = Instruction(m_code[m_PC]);
236229
auto const metric = (*m_metrics)[static_cast<size_t>(m_OP)];
237-
adjustStack(metric.num_stack_arguments, metric.num_stack_returned_items);
230+
adjustStack(metric.stack_height_required, metric.stack_height_change);
238231

239232
// FEES...
240233
m_runGas = metric.gas_cost;
@@ -254,7 +247,7 @@ evmc_tx_context const& VM::getTxContext()
254247
//
255248
// interpreter entry point
256249

257-
owning_bytes_ref VM::exec(evmc_context* _context, evmc_revision _rev, const evmc_message* _msg,
250+
owning_bytes_ref VM::exec(evmc_host_context* _context, evmc_revision _rev, const evmc_message* _msg,
258251
uint8_t const* _code, size_t _codeSize)
259252
{
260253
m_context = _context;

libaleth-interpreter/VM.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ class VM
5151

5252
VM() = default;
5353

54-
owning_bytes_ref exec(evmc_context* _context, evmc_revision _rev, const evmc_message* _msg,
54+
owning_bytes_ref exec(evmc_host_context* _context, evmc_revision _rev, const evmc_message* _msg,
5555
uint8_t const* _code, size_t _codeSize);
5656

5757
uint64_t m_io_gas = 0;
5858
private:
59-
evmc_context* m_context = nullptr;
59+
evmc_host_context* m_context = nullptr;
6060
evmc_revision m_rev = EVMC_FRONTIER;
6161
std::array<evmc_instruction_metrics, 256>* m_metrics = nullptr;
6262
evmc_message const* m_message = nullptr;

libaleth-interpreter/VMCalls.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ void VM::throwDisallowedStateChange()
5353
// throwBadStack is called from fetchInstruction() -> adjustStack()
5454
// its the only exception that can happen before ON_OP() log is done for an opcode case in VM.cpp
5555
// so the call to m_onFail is needed here
56-
void VM::throwBadStack(int _removed, int _added)
56+
void VM::throwBadStack(int _required, int _change)
5757
{
5858
bigint size = m_stackEnd - m_SPP;
59-
if (size < _removed)
60-
BOOST_THROW_EXCEPTION(StackUnderflow() << RequirementError((bigint)_removed, size));
59+
if (size < _required)
60+
BOOST_THROW_EXCEPTION(StackUnderflow() << RequirementError((bigint)_required, size));
6161
else
62-
BOOST_THROW_EXCEPTION(OutOfStack() << RequirementError((bigint)(_added - _removed), size));
62+
BOOST_THROW_EXCEPTION(OutOfStack() << RequirementError((bigint)_change, size));
6363
}
6464

6565
void VM::throwRevertInstruction(owning_bytes_ref&& _output)

libaleth-interpreter/interpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
extern "C" {
1111
#endif
1212

13-
EVMC_EXPORT struct evmc_instance* evmc_create_interpreter() EVMC_NOEXCEPT;
13+
EVMC_EXPORT struct evmc_vm* evmc_create_interpreter() EVMC_NOEXCEPT;
1414

1515
#if __cplusplus
1616
}

libevm/EVMC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ evmc_revision toRevision(EVMSchedule const& _schedule) noexcept
3232
}
3333
} // namespace
3434

35-
EVMC::EVMC(evmc_instance* _instance) noexcept : evmc::vm(_instance)
35+
EVMC::EVMC(evmc_vm* _vm) noexcept : evmc::VM(_vm)
3636
{
37-
assert(_instance != nullptr);
37+
assert(_vm != nullptr);
3838
assert(is_abi_compatible());
3939

4040
// Set the options.

libevm/EVMC.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace dev
1111
namespace eth
1212
{
1313
/// The wrapper implementing the VMFace interface with a EVMC VM as a backend.
14-
class EVMC : public evmc::vm, public VMFace
14+
class EVMC : public evmc::VM, public VMFace
1515
{
1616
public:
17-
explicit EVMC(evmc_instance* _instance) noexcept;
17+
explicit EVMC(evmc_vm* _vm) noexcept;
1818

1919
owning_bytes_ref exec(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _onOp) final;
2020
};

libevm/VMFactory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ void setVMKind(const std::string& _name)
6464
g_evmcDll.reset();
6565

6666
evmc_loader_error_code ec;
67-
evmc_instance *instance = evmc_load_and_create(_name.c_str(), &ec);
68-
assert(ec == EVMC_LOADER_SUCCESS || instance == nullptr);
67+
evmc_vm* vm = evmc_load_and_create(_name.c_str(), &ec);
68+
assert(ec == EVMC_LOADER_SUCCESS || vm == nullptr);
6969

7070
switch (ec)
7171
{
@@ -86,7 +86,7 @@ void setVMKind(const std::string& _name)
8686
"loading " + _name + " failed"));
8787
}
8888

89-
g_evmcDll.reset(new EVMC{instance});
89+
g_evmcDll.reset(new EVMC{vm});
9090

9191
cnote << "Loaded EVMC module: " << g_evmcDll->name() << " " << g_evmcDll->version() << " ("
9292
<< _name << ")";

0 commit comments

Comments
 (0)