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

Add a test for the Creator Contract #856

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ jobs:
~/tests/EIPTests/BlockchainTests/
- download_execution_tests:
repo: ipsilon/tests
rev: eof-calls-20240321
rev: fix-error-names
legacy: false
- run:
name: "State tests (EOF)"
Expand Down
2 changes: 1 addition & 1 deletion evmc
Submodule evmc updated 40 files
+1 −1 .bumpversion.cfg
+1 −7 CMakeLists.txt
+2 −0 bindings/go/evmc/evmc.go
+2 −0 bindings/go/evmc/host.c
+17 −0 bindings/go/evmc/host.go
+8 −0 bindings/go/evmc/host_test.go
+0 −23 bindings/java/.gitignore
+0 −35 bindings/java/CMakeLists.txt
+0 −54 bindings/java/Makefile
+0 −42 bindings/java/build.gradle
+0 −147 bindings/java/c/evmc-vm.c
+0 −505 bindings/java/c/host.c
+0 −31 bindings/java/c/host.h
+0 −7 bindings/java/java/build.gradle
+0 −15 bindings/java/java/src/main/java/org/ethereum/evmc/EvmcLoaderException.java
+0 −193 bindings/java/java/src/main/java/org/ethereum/evmc/EvmcVm.java
+0 −96 bindings/java/java/src/main/java/org/ethereum/evmc/Host.java
+0 −175 bindings/java/java/src/main/java/org/ethereum/evmc/HostContext.java
+0 −266 bindings/java/java/src/test/java/org/ethereum/evmc/EvmcTest.java
+0 −76 bindings/java/java/src/test/java/org/ethereum/evmc/TestHostContext.java
+0 −81 bindings/java/java/src/test/java/org/ethereum/evmc/TestMessage.java
+0 −2 bindings/java/settings.gradle
+0 −4 bindings/java/wrapper.gradle
+1 −1 bindings/rust/evmc-declare-tests/Cargo.toml
+2 −2 bindings/rust/evmc-declare/Cargo.toml
+2 −2 bindings/rust/evmc-sys/Cargo.toml
+1 −1 bindings/rust/evmc-sys/build.rs
+2 −2 bindings/rust/evmc-vm/Cargo.toml
+4 −0 bindings/rust/evmc-vm/src/container.rs
+113 −0 bindings/rust/evmc-vm/src/lib.rs
+5 −0 bindings/rust/evmc-vm/src/types.rs
+0 −23 circle.yml
+1 −1 docs/EVMC.md
+1 −1 examples/example-rust-vm/Cargo.toml
+1 −1 examples/example-rust-vm/src/lib.rs
+1 −1 go.mod
+38 −17 include/evmc/evmc.h
+1 −1 test/gomod/README
+1 −1 test/gomod/use_evmc_test.go
+6 −2 tools/vmtester/tests.cpp
2 changes: 1 addition & 1 deletion lib/evmone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if(CABLE_COMPILER_GNULIKE)
target_compile_options(
evmone PRIVATE
-fno-exceptions
$<$<CXX_COMPILER_ID:GNU>:-Wstack-usage=2800>
$<$<CXX_COMPILER_ID:GNU>:-Wstack-usage=2900>
)
if(NOT SANITIZE MATCHES undefined)
# RTTI can be disabled except for UBSan which checks vptr integrity.
Expand Down
27 changes: 27 additions & 0 deletions lib/evmone/advanced_instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ inline TermResult impl(AdvancedExecutionState& state) noexcept
return CoreFn(state.stack.top_item, state.gas_left, state);
}

template <Opcode Op,
Result CoreFn(StackTop, int64_t, ExecutionState&, code_iterator&) noexcept = core::impl<Op>>
inline Result impl(AdvancedExecutionState& state, code_iterator pos) noexcept
{
// Stack height adjustment may be omitted.
return CoreFn(state.stack.top_item, state.gas_left, state, pos);
}

template <Opcode Op,
TermResult CoreFn(StackTop, int64_t, ExecutionState&, code_iterator) noexcept = core::impl<Op>>
inline TermResult impl(AdvancedExecutionState& state, code_iterator pos) noexcept
{
// Stack height adjustment may be omitted.
return CoreFn(state.stack.top_item, state.gas_left, state, pos);
}

template <Opcode Op,
code_iterator CoreFn(StackTop, ExecutionState&, code_iterator) noexcept = core::impl<Op>>
inline code_iterator impl(AdvancedExecutionState& state, code_iterator pos) noexcept
Expand All @@ -87,6 +103,14 @@ inline code_iterator impl(AdvancedExecutionState& state, code_iterator pos) noex
template <code_iterator InstrFn(AdvancedExecutionState&, code_iterator)>
const Instruction* op(const Instruction* /*instr*/, AdvancedExecutionState& state) noexcept;

/// Wraps the generic instruction implementation to advanced instruction function signature.
template <Result InstrFn(AdvancedExecutionState&, code_iterator) noexcept>
const Instruction* op(const Instruction* instr, AdvancedExecutionState& state) noexcept;

/// Wraps the generic instruction implementation to advanced instruction function signature.
template <TermResult InstrFn(AdvancedExecutionState&, code_iterator) noexcept>
const Instruction* op(const Instruction* instr, AdvancedExecutionState& state) noexcept;

namespace
{
using advanced::op;
Expand Down Expand Up @@ -286,6 +310,9 @@ constexpr std::array<instruction_exec_fn, 256> instruction_implementations = [](
table[OP_DUPN] = op_undefined;
table[OP_SWAPN] = op_undefined;
table[OP_EXCHANGE] = op_undefined;
table[OP_EOFCREATE] = op_undefined;
table[OP_TXCREATE] = op_undefined;
table[OP_RETURNCONTRACT] = op_undefined;

return table;
}();
Expand Down
34 changes: 31 additions & 3 deletions lib/evmone/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,30 @@ struct Position
state.status = result.status;
return nullptr;
}
/// @}

[[release_inline]] inline code_iterator invoke(
Result (*instr_fn)(StackTop, int64_t, ExecutionState&, code_iterator&) noexcept, Position pos,
int64_t& gas, ExecutionState& state) noexcept
{
const auto result = instr_fn(pos.stack_top, gas, state, pos.code_it);
gas = result.gas_left;
if (result.status != EVMC_SUCCESS)
{
state.status = result.status;
return nullptr;
}
return pos.code_it;
}

[[release_inline]] inline code_iterator invoke(
TermResult (*instr_fn)(StackTop, int64_t, ExecutionState&, code_iterator) noexcept,
Position pos, int64_t& gas, ExecutionState& state) noexcept
{
const auto result = instr_fn(pos.stack_top, gas, state, pos.code_it);
gas = result.gas_left;
state.status = result.status;
return nullptr;
}

/// A helper to invoke the instruction implementation of the given opcode Op.
template <Opcode Op>
Expand Down Expand Up @@ -358,8 +381,13 @@ evmc_result execute(
const auto gas_refund = (state.status == EVMC_SUCCESS) ? state.gas_refund : 0;

assert(state.output_size != 0 || state.output_offset == 0);
const auto result = evmc::make_result(state.status, gas_left, gas_refund,
state.output_size != 0 ? &state.memory[state.output_offset] : nullptr, state.output_size);
const auto result =
(state.deploy_container.has_value() ?
evmc::make_result(state.status, gas_left, gas_refund,
state.deploy_container->data(), state.deploy_container->size()) :
evmc::make_result(state.status, gas_left, gas_refund,
state.output_size != 0 ? &state.memory[state.output_offset] : nullptr,
state.output_size));

if (INTX_UNLIKELY(tracer != nullptr))
tracer->notify_execution_end(result);
Expand Down
3 changes: 3 additions & 0 deletions lib/evmone/baseline_instruction_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ constexpr auto legacy_cost_tables = []() noexcept {
tables[EVMC_PRAGUE][OP_EXTCALL] = instr::undefined;
tables[EVMC_PRAGUE][OP_EXTSTATICCALL] = instr::undefined;
tables[EVMC_PRAGUE][OP_EXTDELEGATECALL] = instr::undefined;
tables[EVMC_PRAGUE][OP_EOFCREATE] = instr::undefined;
tables[EVMC_PRAGUE][OP_TXCREATE] = instr::undefined;
tables[EVMC_PRAGUE][OP_RETURNCONTRACT] = instr::undefined;
return tables;
}();

Expand Down
Loading