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

Commit

Permalink
EIP-1344: CHAINID opcode implementation in aleth-interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Jul 30, 2019
1 parent f5332dc commit 7351dbc
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion evmc
Submodule evmc updated 66 files
+15 −5 .bumpversion.cfg
+44 −0 CHANGELOG.md
+21 −18 CMakeLists.txt
+2 −0 Cargo.toml
+1 −1 Doxyfile
+10 −9 README.md
+19 −16 appveyor.yml
+1 −1 bindings/go/evmc/evmc_test.go
+3 −0 bindings/rust/evmc-declare-tests/.gitignore
+18 −0 bindings/rust/evmc-declare-tests/Cargo.toml
+29 −0 bindings/rust/evmc-declare-tests/src/lib.rs
+3 −0 bindings/rust/evmc-declare/.gitignore
+27 −0 bindings/rust/evmc-declare/Cargo.toml
+385 −0 bindings/rust/evmc-declare/src/lib.rs
+2 −2 bindings/rust/evmc-sys/Cargo.toml
+2 −0 bindings/rust/evmc-sys/build.rs
+27 −0 bindings/rust/evmc-sys/src/lib.rs
+2 −2 bindings/rust/evmc-vm/Cargo.toml
+159 −0 bindings/rust/evmc-vm/src/container.rs
+659 −67 bindings/rust/evmc-vm/src/lib.rs
+37 −0 bindings/rust/evmc-vm/src/types.rs
+112 −62 circle.yml
+3 −1 cmake/Config.cmake.in
+18 −0 cmake/EVMC.cmake
+3 −3 cmake/Hunter/init.cmake
+2 −2 cmake/cable/CableBuildType.cmake
+34 −16 cmake/cable/CableCompilerSettings.cmake
+75 −90 cmake/cable/HunterGate.cmake
+11 −24 cmake/cable/bootstrap.cmake
+2 −0 docs/EVMC.md
+7 −0 docs/VM_Guide.md
+3 −18 examples/CMakeLists.txt
+4 −2 examples/example-rust-vm/Cargo.toml
+25 −51 examples/example-rust-vm/src/lib.rs
+1 −1 examples/example.c
+12 −10 examples/example_host.cpp
+16 −0 examples/example_precompiles_vm/CMakeLists.txt
+127 −0 examples/example_precompiles_vm/example_precompiles_vm.cpp
+20 −0 examples/example_vm/CMakeLists.txt
+2 −11 examples/example_vm/example_vm.c
+0 −0 examples/example_vm/example_vm.h
+7 −0 examples/use_evmc_in_cmake/CMakeLists.txt
+83 −38 include/evmc/evmc.h
+334 −10 include/evmc/evmc.hpp
+5 −2 include/evmc/helpers.h
+48 −16 include/evmc/helpers.hpp
+1 −0 include/evmc/instructions.h
+64 −13 include/evmc/loader.h
+3 −1 lib/instructions/CMakeLists.txt
+260 −0 lib/instructions/instruction_metrics.c
+260 −0 lib/instructions/instruction_names.c
+3 −1 lib/loader/CMakeLists.txt
+122 −16 lib/loader/loader.c
+16 −14 test/integration/cmake_package/CMakeLists.txt
+5 −0 test/integration/compilation/compilation_test.c
+10 −0 test/integration/compilation/compilation_test.cxx
+2 −1 test/unittests/CMakeLists.txt
+282 −8 test/unittests/test_cpp.cpp
+50 −0 test/unittests/test_deprecated.cpp
+17 −37 test/unittests/test_helpers.cpp
+146 −22 test/unittests/test_instructions.cpp
+407 −32 test/unittests/test_loader.cpp
+24 −17 test/vmtester/CMakeLists.txt
+66 −20 test/vmtester/tests.cpp
+16 −14 test/vmtester/vmtester.cpp
+1 −1 test/vmtester/vmtester.hpp
14 changes: 14 additions & 0 deletions libaleth-interpreter/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,20 @@ void VM::interpretCases()
}
NEXT


CASE(CHAINID)
{
ON_OP();

if (m_rev < EVMC_ISTANBUL)
throwBadInstruction();

updateIOGas();

m_SPP[0] = fromEvmC(m_context->host->get_chain_id(m_context));
}
NEXT

CASE(POP)
{
ON_OP();
Expand Down
2 changes: 1 addition & 1 deletion libaleth-interpreter/VMConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ namespace eth
&&NUMBER, \
&&DIFFICULTY, \
&&GASLIMIT, \
&&INVALID, \
&&CHAINID, \
&&INVALID, \
&&INVALID, \
&&INVALID, \
Expand Down
5 changes: 5 additions & 0 deletions libevm/ExtVMFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ evmc_bytes32 EvmCHost::get_block_hash(int64_t _number) noexcept
return toEvmC(m_extVM.blockHash(_number));
}

evmc_bytes32 EvmCHost::get_chain_id() noexcept
{
return toEvmC(m_extVM.envInfo().chainID());
}

evmc::result EvmCHost::create(evmc_message const& _msg) noexcept
{
u256 gas = _msg.gas;
Expand Down
2 changes: 2 additions & 0 deletions libevm/ExtVMFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ class EvmCHost : public evmc::Host

evmc_bytes32 get_block_hash(int64_t _blockNumber) noexcept override;

evmc_bytes32 get_chain_id() noexcept override;

void emit_log(const evmc_address& _addr, const uint8_t* _data, size_t _dataSize,
const evmc_bytes32 _topics[], size_t _numTopics) noexcept override;

Expand Down
20 changes: 20 additions & 0 deletions test/unittests/libevm/VMTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,13 @@ class LegacyVMChainIDTestFixture : public ChainIDTestFixture
LegacyVMChainIDTestFixture() : ChainIDTestFixture{new LegacyVM} {}
};

class AlethInterpreterChainIDTestFixture : public ChainIDTestFixture
{
public:
AlethInterpreterChainIDTestFixture() : ChainIDTestFixture{new EVMC{evmc_create_interpreter()}}
{}
};

} // namespace

BOOST_FIXTURE_TEST_SUITE(LegacyVMSuite, TestOutputHelperFixture)
Expand Down Expand Up @@ -937,4 +944,17 @@ BOOST_AUTO_TEST_CASE(AlethInterpreterSstoreEip1283Case17)

BOOST_AUTO_TEST_SUITE_END()

BOOST_FIXTURE_TEST_SUITE(AlethInterpreterChainIDSuite, AlethInterpreterChainIDTestFixture)

BOOST_AUTO_TEST_CASE(AlethInterpreterChainIDworksInIstanbul)
{
testChainIDWorksInIstanbul();
}

BOOST_AUTO_TEST_CASE(AlethInterpreterChainIDisInvalidBeforeIstanbul)
{
testChainIDisInvalidBeforeIstanbul();
}
BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 7351dbc

Please sign in to comment.