Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Running ganache with the modified VM

anvacaru edited this page May 24, 2019 · 6 revisions

Prerequisites:

  • Node
  • Npm

Installing KEVM-VM

  • Follow the instructions from the evm-semantics Readme.md and build the LLVM backend
  • To build the kevm-vm use the following command in the evm-semantics repo
    $ make build-node

Note: For more debug information, you need to build K with the flag -Dproject.build.type=Debug

$ mvn package -Dproject.build.type=Debug -DskipTests

Building Ganache and EthereumJS-VM:

  • Clone the required repositories and initialize them:
    1. ganache-cli [email protected]:trufflesuite/ganache-cli.git
      1. cd ganache-cli && npm install && cd ../
    2. ganache-core [email protected]:trufflesuite/ganache-core.git
      1. cd ganache-core && npm install && cd ../
    3. modified ethereumjs-vm [email protected]:runtimeverification/ethereumjs-vm.git
      1. cd ethereumjs-vm && npm install
      2. generate the protobuf file
      $ protoc --js_out=import_style=commonjs,binary:. lib/proto/msg.proto
  • Link together the repositories
    $ cd ethereumjs-vm/
    $ npm link
    $ cd ../ganache-core/
    $ npm link ethereumjs-vm
    $ npm link
    $ cd ../ganache-cli/
    $ npm link ganache-core
  • Build the cli executable
    $ cd ganache-cli
    $ npm build

Getting the test files:

  • clone openzeppelin-solidity repo [email protected]:OpenZeppelin/openzeppelin-solidity.git

  • install the dependencies and compile the contracts

    $ cd openzeppelin-solidity/
    $ npm install
    $ node_modules/.bin/truffle compile 
  • download and place this simplified test file anywhere in the openzeppelin-solidity/test folder (optional)

Running ganache-cli with the modified VM:

  • Open a terminal and launch the cli.js executable which was built earlier in ganache-cli

  • Open a second terminal and launch the kevm-vm instance with the arguments for port 8080 and address 127.0.0.1

  • Open a third terminal in which you send a truffle test command

    $ cd openzeppelin-solidity/
    $ node_modules/.bin/truffle test /path/to/test/file

Troubleshooting

If the following error is received while building the kevm-vm

/usr/lib/llvm-6.0/bin/ld.lld: error: undefined symbol: output_file
>>> referenced by finish_rewriting.ll
>>>               /tmp/finish_rewriting-babbff.o:(finish_rewriting)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:243: recipe for target '.build/vm/kevm-vm' failed
make: *** [.build/vm/kevm-vm] Error 1

You have to:

  • fetch the latest commit for the llvm-backend:
    $ cd k/llvm-backend/src/main/native/llvm-backend/
    $ git fetch; git checkout vm
  • rebuild K, evm-semantics llvm build and kevm-vm