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

Use evmone for testing. #7010

Merged
merged 13 commits into from
Aug 8, 2019
Merged

Use evmone for testing. #7010

merged 13 commits into from
Aug 8, 2019

Conversation

chriseth
Copy link
Contributor

No description provided.


evmc::result call(const evmc_message& msg) noexcept final
{
// TODO: Improve C API for result creation.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess most of the tests are failing because this is not yet implemented.

@chriseth chriseth force-pushed the useevmone branch 2 times, most recently from 39ff71c to 6b43716 Compare June 26, 2019 21:22
@stackenbotten
Copy link

There was an error when running chk_coding_style for commit 6b43716743cec6d8abb17ebc3605f4ee6083b79b:

Error: Trailing whitespace found:
 evmc/CHANGELOG.md:30: Disallow implicit conversion from C   `evmc::result` to `evmc_result` 
 evmc/CHANGELOG.md:31: causing unintendent premature releasing of resources. 
 evmc/CHANGELOG.md:44:- Added: 
 evmc/CHANGELOG.md:94: Integration of EVMC as a CMake subproject is easier because 
 evmc/cmake/cable/README.md:57:Start by including this file in your main `CMakeLists.txt` from the Cable 
 evmc/cmake/cable/README.md:58:submodule/subtree or any other location. The `bootstrap.cmake` must be included 
 evmc/docs/Host_Guide.md:10:The implementation can be done in object-oriented manner. 
 evmc/docs/Host_Guide.md:13:Moreover, each of the methods has a pointer to ::evmc_context 
 evmc/docs/Host_Guide.md:14:as a parameter. The context is owned entirely by the Host allowing a Host instance 
 evmc/docs/Host_Guide.md:22: function in particular VM implementation. The EVMC recommends to name the 
 evmc/docs/Host_Guide.md:24: Invoking the create function will give you the VM instance (::evmc_instance). 
 evmc/docs/Host_Guide.md:26: 
 evmc/docs/Host_Guide.md:27:2. If you are interested in loading VMs dynamically (i.e. to use DLLs) 
 evmc/docs/Host_Guide.md:29: 
 evmc/docs/Host_Guide.md:30:3. The ::evmc_instance contains information about the VM like 
 evmc/docs/Host_Guide.md:33: 
 evmc/docs/Host_Guide.md:39: 
 evmc/docs/Host_Guide.md:42: 

Please check that your changes are working as intended.

@stackenbotten
Copy link

There was an error when running chk_coding_style for commit df93960d23a2ac9ff09d1bf96a61e72f10b1ae26:

Error: Trailing whitespace found:
 evmc/CHANGELOG.md:30: Disallow implicit conversion from C   `evmc::result` to `evmc_result` 
 evmc/CHANGELOG.md:31: causing unintendent premature releasing of resources. 
 evmc/CHANGELOG.md:44:- Added: 
 evmc/CHANGELOG.md:94: Integration of EVMC as a CMake subproject is easier because 
 evmc/cmake/cable/README.md:57:Start by including this file in your main `CMakeLists.txt` from the Cable 
 evmc/cmake/cable/README.md:58:submodule/subtree or any other location. The `bootstrap.cmake` must be included 
 evmc/docs/Host_Guide.md:10:The implementation can be done in object-oriented manner. 
 evmc/docs/Host_Guide.md:13:Moreover, each of the methods has a pointer to ::evmc_context 
 evmc/docs/Host_Guide.md:14:as a parameter. The context is owned entirely by the Host allowing a Host instance 
 evmc/docs/Host_Guide.md:22: function in particular VM implementation. The EVMC recommends to name the 
 evmc/docs/Host_Guide.md:24: Invoking the create function will give you the VM instance (::evmc_instance). 
 evmc/docs/Host_Guide.md:26: 
 evmc/docs/Host_Guide.md:27:2. If you are interested in loading VMs dynamically (i.e. to use DLLs) 
 evmc/docs/Host_Guide.md:29: 
 evmc/docs/Host_Guide.md:30:3. The ::evmc_instance contains information about the VM like 
 evmc/docs/Host_Guide.md:33: 
 evmc/docs/Host_Guide.md:39: 
 evmc/docs/Host_Guide.md:42: 

Please check that your changes are working as intended.

@stackenbotten
Copy link

There was an error when running chk_coding_style for commit cf03187111f120c07f256f639edc762a898e4364:

Error: Trailing whitespace found:
 evmc/CHANGELOG.md:30: Disallow implicit conversion from C   `evmc::result` to `evmc_result` 
 evmc/CHANGELOG.md:31: causing unintendent premature releasing of resources. 
 evmc/CHANGELOG.md:44:- Added: 
 evmc/CHANGELOG.md:94: Integration of EVMC as a CMake subproject is easier because 
 evmc/cmake/cable/README.md:57:Start by including this file in your main `CMakeLists.txt` from the Cable 
 evmc/cmake/cable/README.md:58:submodule/subtree or any other location. The `bootstrap.cmake` must be included 
 evmc/docs/Host_Guide.md:10:The implementation can be done in object-oriented manner. 
 evmc/docs/Host_Guide.md:13:Moreover, each of the methods has a pointer to ::evmc_context 
 evmc/docs/Host_Guide.md:14:as a parameter. The context is owned entirely by the Host allowing a Host instance 
 evmc/docs/Host_Guide.md:22: function in particular VM implementation. The EVMC recommends to name the 
 evmc/docs/Host_Guide.md:24: Invoking the create function will give you the VM instance (::evmc_instance). 
 evmc/docs/Host_Guide.md:26: 
 evmc/docs/Host_Guide.md:27:2. If you are interested in loading VMs dynamically (i.e. to use DLLs) 
 evmc/docs/Host_Guide.md:29: 
 evmc/docs/Host_Guide.md:30:3. The ::evmc_instance contains information about the VM like 
 evmc/docs/Host_Guide.md:33: 
 evmc/docs/Host_Guide.md:39: 
 evmc/docs/Host_Guide.md:42: 

Please check that your changes are working as intended.

@stackenbotten
Copy link

There was an error when running chk_coding_style for commit 512418a9ec7d7cc6b1d977afc239cc57025779bf:

Error: Trailing whitespace found:
 evmc/CHANGELOG.md:30: Disallow implicit conversion from C   `evmc::result` to `evmc_result` 
 evmc/CHANGELOG.md:31: causing unintendent premature releasing of resources. 
 evmc/CHANGELOG.md:44:- Added: 
 evmc/CHANGELOG.md:94: Integration of EVMC as a CMake subproject is easier because 
 evmc/cmake/cable/README.md:57:Start by including this file in your main `CMakeLists.txt` from the Cable 
 evmc/cmake/cable/README.md:58:submodule/subtree or any other location. The `bootstrap.cmake` must be included 
 evmc/docs/Host_Guide.md:10:The implementation can be done in object-oriented manner. 
 evmc/docs/Host_Guide.md:13:Moreover, each of the methods has a pointer to ::evmc_context 
 evmc/docs/Host_Guide.md:14:as a parameter. The context is owned entirely by the Host allowing a Host instance 
 evmc/docs/Host_Guide.md:22: function in particular VM implementation. The EVMC recommends to name the 
 evmc/docs/Host_Guide.md:24: Invoking the create function will give you the VM instance (::evmc_instance). 
 evmc/docs/Host_Guide.md:26: 
 evmc/docs/Host_Guide.md:27:2. If you are interested in loading VMs dynamically (i.e. to use DLLs) 
 evmc/docs/Host_Guide.md:29: 
 evmc/docs/Host_Guide.md:30:3. The ::evmc_instance contains information about the VM like 
 evmc/docs/Host_Guide.md:33: 
 evmc/docs/Host_Guide.md:39: 
 evmc/docs/Host_Guide.md:42: 

Please check that your changes are working as intended.

@stackenbotten
Copy link

There was an error when running chk_coding_style for commit 6f3fae70358710d03b40924b3527c53340a5e828:

Error: Trailing whitespace found:
 evmc/CHANGELOG.md:30: Disallow implicit conversion from C   `evmc::result` to `evmc_result` 
 evmc/CHANGELOG.md:31: causing unintendent premature releasing of resources. 
 evmc/CHANGELOG.md:44:- Added: 
 evmc/CHANGELOG.md:94: Integration of EVMC as a CMake subproject is easier because 
 evmc/cmake/cable/README.md:57:Start by including this file in your main `CMakeLists.txt` from the Cable 
 evmc/cmake/cable/README.md:58:submodule/subtree or any other location. The `bootstrap.cmake` must be included 
 evmc/docs/Host_Guide.md:10:The implementation can be done in object-oriented manner. 
 evmc/docs/Host_Guide.md:13:Moreover, each of the methods has a pointer to ::evmc_context 
 evmc/docs/Host_Guide.md:14:as a parameter. The context is owned entirely by the Host allowing a Host instance 
 evmc/docs/Host_Guide.md:22: function in particular VM implementation. The EVMC recommends to name the 
 evmc/docs/Host_Guide.md:24: Invoking the create function will give you the VM instance (::evmc_instance). 
 evmc/docs/Host_Guide.md:26: 
 evmc/docs/Host_Guide.md:27:2. If you are interested in loading VMs dynamically (i.e. to use DLLs) 
 evmc/docs/Host_Guide.md:29: 
 evmc/docs/Host_Guide.md:30:3. The ::evmc_instance contains information about the VM like 
 evmc/docs/Host_Guide.md:33: 
 evmc/docs/Host_Guide.md:39: 
 evmc/docs/Host_Guide.md:42: 

Please check that your changes are working as intended.

@stackenbotten
Copy link

There was an error when running chk_coding_style for commit 9ab1168906e804229953befef9e8f1eb45071a15:

Error: Trailing whitespace found:
 evmc/CHANGELOG.md:30: Disallow implicit conversion from C   `evmc::result` to `evmc_result` 
 evmc/CHANGELOG.md:31: causing unintendent premature releasing of resources. 
 evmc/CHANGELOG.md:44:- Added: 
 evmc/CHANGELOG.md:94: Integration of EVMC as a CMake subproject is easier because 
 evmc/cmake/cable/README.md:57:Start by including this file in your main `CMakeLists.txt` from the Cable 
 evmc/cmake/cable/README.md:58:submodule/subtree or any other location. The `bootstrap.cmake` must be included 
 evmc/docs/Host_Guide.md:10:The implementation can be done in object-oriented manner. 
 evmc/docs/Host_Guide.md:13:Moreover, each of the methods has a pointer to ::evmc_context 
 evmc/docs/Host_Guide.md:14:as a parameter. The context is owned entirely by the Host allowing a Host instance 
 evmc/docs/Host_Guide.md:22: function in particular VM implementation. The EVMC recommends to name the 
 evmc/docs/Host_Guide.md:24: Invoking the create function will give you the VM instance (::evmc_instance). 
 evmc/docs/Host_Guide.md:26: 
 evmc/docs/Host_Guide.md:27:2. If you are interested in loading VMs dynamically (i.e. to use DLLs) 
 evmc/docs/Host_Guide.md:29: 
 evmc/docs/Host_Guide.md:30:3. The ::evmc_instance contains information about the VM like 
 evmc/docs/Host_Guide.md:33: 
 evmc/docs/Host_Guide.md:39: 
 evmc/docs/Host_Guide.md:42: 

Please check that your changes are working as intended.

test/ExecutionFramework.cpp Outdated Show resolved Hide resolved
test/ExecutionFramework.cpp Outdated Show resolved Hide resolved
test/ExecutionFramework.cpp Outdated Show resolved Hide resolved
test/ExecutionFramework.cpp Outdated Show resolved Hide resolved
test/ExecutionFramework.cpp Outdated Show resolved Hide resolved
test/ExecutionFramework.cpp Outdated Show resolved Hide resolved
@@ -50,25 55,294 @@ string getIPCSocketPath()
return ipcPath;
}

evmc::vm& getVM()
{
static unique_ptr<evmc::vm> theVM;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just do static evmc::vm theVM = ...;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then I cannot try different locations for libevmone.so

@chriseth
Copy link
Contributor Author

The way evmc is included is still not satisfactory for me. Since it is "just a wrapper", I'm thinking of stripping everything that is not needed and just adding the 4 header files and single .c file into the project.

@chriseth chriseth force-pushed the useevmone branch 3 times, most recently from d8e102b to 05e68c5 Compare June 27, 2019 20:47
@chriseth
Copy link
Contributor Author

Test failure count is down to 36.

One is a weird failure in the auction registrar.

Then we have a bunch of gas cost test failures - those are probably still quite some work. I would suspect this is related to https://github.com/ethereum/solidity/pull/7010/files#diff-e4cd21bbaea28071e286e4adfd6ec79aR97

Finally, we have some failures related to the precompiled contracts. We probably do not want to implement everything, so this boils down to implementing some crude "simulated" version of each precompile and modifying the test expectations, I would assume.

Anyone feel free to continue working on this until Monday :)

@chriseth
Copy link
Contributor Author

Another reason for the gas test failures is that EVMHost maybe has to compute the data gas. @chfast - do you have any insight into this?

@chfast
Copy link
Member

chfast commented Jun 27, 2019

Another reason for the gas test failures is that EVMHost maybe has to compute the data gas. @chfast - do you have any insight into this?

Host is responsible for counting refunds, unfortunately.

@chriseth
Copy link
Contributor Author

@chfast is there a complete implementation somewhere?

@chfast
Copy link
Member

chfast commented Jul 3, 2019

@chfast is there a complete implementation somewhere?

In Aleth:

In geth:

Yes, we already know this should be handled by the VM, but that requires the ABI break so it will not be changed in EVMC 6.

@chriseth
Copy link
Contributor Author

Phew. Now the only thing left to do is clean everything up and implement the required test vectors for the snark precompiles.

@bshastry
Copy link
Contributor

bshastry commented Aug 7, 2019

Selectively disabled failing check for ASan builds.

@chriseth
Copy link
Contributor Author

chriseth commented Aug 7, 2019

Also had a local change in the dockerfile that was not pushed upstream.

tar -xf /tmp/aleth.tar.gz -C /usr
wget -q -O /tmp/evmone.tar.gz "${EVMONE_URL}"; \
test "$(shasum /tmp/evmone.tar.gz)" = "$EVMONE_HASH /tmp/evmone.tar.gz"; \
tar -xf /tmp/evmone.tar.gz -C /usr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment: Later in the dockerfile, a static build of evmone is installed at the same destination /usr from source. The subsequent overwriting should not be a problem since the tarball is presumably packed with the shared library version which the static build does not install.

(
cd /usr/
wget -q https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-linux-x86_64.tar.gz -O - | tar xz
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed since the docker image should contain evmone now.

CMakeLists.txt Outdated
@@ -13,6 13,7 @@ eth_policy()
set(PROJECT_VERSION "0.5.11")
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline can be removed?

@chriseth chriseth force-pushed the useevmone branch 2 times, most recently from f0e26ef to 44ff050 Compare August 7, 2019 15:50
Copy link
Member

@ekpyron ekpyron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked everything in every detail, but generally this looks good - mainly some minor comments!
The precompile stuff I haven't checked at all, though.


To run a basic set of tests that require neither ``aleth`` nor ``libz3``, run
``./scripts/soltest.sh --no-ipc --no-smt``.
Some tests require the ``libevmone.so`` library, others require ``libz3``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this PR, but "others require libz3" doesn't really feel correct here... first of all it's not enough to have libz3 at runtime as for libevmone, but it must have been present at build time already, secondly it must be a correct version of z3 and thirdly it could also be cvc4... But we can change this separately, no need to let this block this PR.

`Github <https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-linux-x86_64.tar.gz>`_
and either place it in the project root path or inside the ``deps`` folder.

If you do not have libz3 installed on your system, you should disable the SMT tests:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More like "If you did not build against libz3 or cvc4" actually, but yeah, as above.

libdevcore/CommonData.h Show resolved Hide resolved
result.create_address = message.destination;
destination.code = bytes(result.output_data, result.output_data result.output_size);
destination.codeHash = convertToEVMC(keccak256(destination.code));
result.gas_left -= eth::GasCosts::createDataGas * result.output_size;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... this logic now probably results in parts of our gas tests basically being tested against our own gas calculation, right? But ok, it's probably fine...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, no way around this, unfortunately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand: Most of the gas calculation is done by evmone itself, we mainly only do storage gas and data cas.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I mentioned it here: this is going to be changed and EVM will calculate these, but we need to break EVMC ABI first.

test/EVMHost.h Outdated Show resolved Hide resolved
test/contracts/AuctionRegistrar.cpp Show resolved Hide resolved
// we disable it if we are compiling an ASan test binary. The
// DISABLE_CHECK_FOR_ASAN_BUILD macro is defined if
// -DSANITIZE=address is passed as a compile time cmake option.
#ifndef DISABLE_CHECK_FOR_ASAN_BUILD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have gone with just calling this ASAN_BUILD... and we still want to run the test, even though it takes a long time? We could also move the #ifndef around the whole test to avoid having to wait for it for 60 seconds...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to define own macro. There is a way to check if you are building with ASan: https://clang.llvm.org/docs/AddressSanitizer.html#conditional-compilation-with-has-feature-address-sanitizer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bshastry noted that this is not cross-compiler. Does asan exist on non-llvm compilers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work for cross-compilation - the code will be instrumented for the target architecture (if that's a concern).

ASan is also supported with GCC. The same basic flags are used, but the runtime library is different I believe. In case of GCC the __SANITIZE_ADDRESS__ macro is defined: https://gcc.gnu.org/onlinedocs/gcc-4.8.0/cpp/Common-Predefined-Macros.html.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to use the compiler-internal check for now. It's fine for the test to fail on gcc.

@chriseth
Copy link
Contributor Author

chriseth commented Aug 8, 2019

The tests are not run properly, because the docker image currently only contains libevmone.a and not libevmone.so.

@chriseth
Copy link
Contributor Author

chriseth commented Aug 8, 2019

The above is fixed by #7203

@chriseth chriseth merged commit 18ffe3b into develop Aug 8, 2019
@ekpyron ekpyron deleted the useevmone branch August 8, 2019 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants