Coder Social home page Coder Social logo

runtimeverification / solidity Goto Github PK

View Code? Open in Web Editor NEW
16.0 15.0 10.0 40.49 MB

Fork of the Solidity Compiler for compiling Solidity to IELE

License: GNU General Public License v3.0

CMake 0.88% C++ 67.27% Shell 1.82% Python 0.75% Batchfile 0.05% C 0.69% Solidity 28.18% Dockerfile 0.18% PowerShell 0.03% JavaScript 0.06% Nix 0.09%

solidity's Introduction

The Solidity to IELE Compiler

This is the Solidity to IELE compiler, a fork of the Solidity compiler targeting the IELE virtual machine (instead of the EVM).

To learn more about the supported Solidity features and the main differences between the IELE and EVM compilers, see README-IELE-SUPPORT.

Solidity is a statically typed, contract-oriented, high-level language for implementing smart contracts on the Ethereum platform.

Building

Prerequisites

Dependencies

For MacOS:

brew update
brew install boost
brew install cmake
brew install llvm@11
brew install libxml2
brew upgrade

For Ubuntu-based systems:

sudo apt-get update
sudo apt-get install build-essential cmake g++ gcc git libboost-all-dev unzip llvm-11 zlib1g-dev libz3-dev libxml2-utils

Please note that we have tested the compiler for the Ubuntu 20.04 and MacOS BigSur operation system.

Build the compiler

mkdir build
cd build
cmake ..
make

Usage

Use the compiler like this:

./build/solc/isolc --asm <solidity file>

Testing

To run the execution test suite, first start an IELE vm in separate terminal (this assumes the kiele exexcutable is found in the system's PATH):

kiele vm --port 9001

Then, start the iele-test-clientexecutable in a separate terminal:

iele-test-client <path to Solidity-to-IELE build directory>/ipcfile 9001

Note that, there is no need for an exisiting ipcfile, this command will create a fresh one. You may need to delete an existing ipcfile before you restart this script.

Also note that the iele-test-client executable can be found in "$(dirname `which kiele`)/../lib/kiele", assuming the kiele executable is in the system's PATH.

Finally, you can run the whole execution test suite with:

./build/test/soltest --no_result_code \
                     --report_sink=build/report.xml \
                     --report_level=detailed \
                     --report_format=XML \
                     --log_sink=build/log.xml \
                     --log_level=all \
                     --log_format=XML  \
                     `cat test/failing-exec-tests` \
                     `cat test/out-of-scope-exec-tests` \
                     `cat test/unimplemented-features-tests` \
                     -- \
                     --enforce-no-yul-ewasm \
                     --ipcpath build/ipcfile \
                     --testpath test

xmllint --xpath "//TestCase[@assertions_failed!=@expected_failures]" build/report.xml && false

The output of the last command should look like this for a successful run of the test suite:

XPath set is empty

Alternatively, you can run a specific test with:

./build/test/soltest --no_result_code -t <test name> -- --enforce-no-yul-ewasm --ipcpath build/ipcfile --testpath test

where <test name> is the name with which the test is registered in the test suite. For example, the test found in test/libsolidity/semanticTests/operators/shifts/shift_right.sol, is registered in the test suite with the name semanticTests/operators/shifts/shift_right.

solidity's People

Contributors

a3d4 avatar aarlt avatar arkpar avatar axic avatar bobsummerwill avatar bshastry avatar cameel avatar chfast avatar chriseth avatar christianparpart avatar cjentzsch avatar debris avatar denton-l avatar dwightguth avatar ekpyron avatar erak avatar federicobond avatar gavofyork avatar gluk256 avatar hrkrshnn avatar lefterisjp avatar leonardoalt avatar lianahus avatar marenz avatar mijovic avatar pirapira avatar subtly avatar theo25 avatar vor0220 avatar winsvega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solidity's Issues

Solidity Feature: MemberAccess

I'm not sure what this is, but I noticed several failures in visit(const MemberAccess ..., in the following unsupported case:

  if (dynamic_cast<const TypeType *>(
          memberAccess.expression().annotation().type.get())) {
    solAssert(false, "not implemented yet");
    return false;
  }

Update scripts/install_deps.sh

We have added some dependencies for the Solidity-to-IELE backend, such as llvm-5.0.0 and libxml2-utils. We need to update the install_deps.sh script to reflect those.

Solidity feature: assert

Quite a few contracts failed on the "non implemented yet" assertion inside appendInvalid.
I wasn't quite sure about what that should do, but by looking at who calls appendInvalid, it seems this should handle assertions.

Solidity feature: Mappings

  • mappings with integral keys with both finite and infinite keyspaces
  • mappings with hashed keyspaces
  • mappings with dynamically sized keyspaces (e.g. strings)
  • delete for mappings
  • copying of structs that have mapping members

Bugfixes (return statement + modifiers, inheritance etc.)

Tests failing because of the interaction of return with modifiers:

  • function_modifier_local_variables
  • function_modifier_multi_with_return
  • function_modifier_multiple_times_local_vars
  • return_does_not_skip_modifier

Tests failing because of inheritance and the way we pass args to base constructors:

  • pass_dynamic_arguments_to_the_base
  • pass_dynamic_arguments_to_the_base_base
  • pass_dynamic_arguments_to_the_base_base_with_gap

this

Support the this keyword (evaluates to the address of the current contract)

Solidity feature: low-level `log`

This is in addition to what already implemented for #82.
It should be very similar to event, but all arguments have to be provided manually e.g. the contract ID is not added automatically but has to be provided as part of the call.

Julia IR Support?

I want to start a discussion between @theo25 and @axic about supporting the Julia IR for the compiler to IELE.

Right now the compiler is being modified to be able to emit IELE code directly from Solidity, but perhaps it makes more sense to emit IELE from Julia, and then have a separate step for lowering Solidity -> Julia.

@theo25 if the code for Solidity -> IELE has not gotten too far past the Julia fragment, do you think it's possible to "finish" the Solidity -> IELE compiler by actually finishing out the Solidity -> Julia compiler?

@axic how much work is needed here for Solidity -> Julia?

Scoping Activation

Seems we have a problem with variable scoping, as shown by test C99_scoping_activation (and possibly others, which will be added here as they are found),

For example, consider a call to the following function:

function g() pure public returns (uint x) {
  x = 7;
  {
      x = 3;
      uint x;
      return x; // This should return the new variable, i.e. 0
  }
}

Instead, we return 3. See C99_scoping_activation for more cases,

Need to run all C++ tests on every CI build of solidity

The Solidity repo has a bunch of tests already. We need to adapt the CI to run all of them and fail the build if we have any regressions, but not if tests that haven't been supported yet are failing. We've done this for the command line tests, but not for the tests written using Boost unit testing. We also need to integrate theses numbers into the summary of tests passing and failing (cf. #36)

Solidity feature: payable

functions and accessors without the payable modifier should throw an exception if they are passed funds.

Replacement for unimplemented features

We are not implementing several features of Solidity because they are EVM specific. Usually they are also insecure, as well, and in a few cases they have been deprecated. We need documentation that explains, for each feature, how a program with that feature should be implemented instead.

Solidity feature: accessors

		contract test {
			uint256 public data;
			function test() {
				data = 8;
			}
		}

Seems like a call to data() should return 8 (see simple_accessor in SolidityEndToEndTest,cpp)

Qualified imports and new

When you do a qualified import, it should rename the contract in the outputted iele code for all contracts in the file that contains the qualified import, in order to avoid name collision.

Recursive Structs

Solidity supports recursive structs under certain circumstances. We need to compile these correctly.

Solidity feature: Inheritance

Subfeatures:

  • inherited members
  • base constructors without arguments
  • base constructor arguments
  • super keyword
  • direct access to base class members.

Bug: `conditional_expression_tuples`

This fails because the tuples involved in the example are not handled correctly.
Since tuples seems to work fine in other examples, we may have a problem due to the interaction with the conditional expression.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.