bradleystachurski / mana

Ethereum full node implementation written in Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mana-Ethereum

CircleCI Waffle.io - Columns and their card countGitter chat

Mana-Ethereum is an open-source Ethereum blockchain client built using Elixir. Elixir runs on the Erlang Virtual Machine, which is used for distributed systems and offers massive scalability and high visibility. These properties make Elixir a perfect candidate for blockchain network development.

In the current Ethereum ecosystem, a majority of active nodes on the network are Geth or Parity nodes. Mana-Ethereum provides an additional open-source alternative. Our aim is to create an open, well-documented implementation that closely matches the protocols described in the Ethereum yellow paper.

Mana-Ethereum is currently in development. See the Project Status for more information.

Dependencies

  • Elixir ~> 1.7.2
  • Rust ~> 1.26.0 (as a dependency of Rox)

Installation

  • Clone repo with submodules (to access the Ethereum common tests)
git clone --recurse-submodules https://github.com/poanetwork/mana.git
  • Go to the mana subdirectory cd mana

  • Run bin/setup

Running a node

Currently, peer-to-peer communication is incomplete, but if you would like to partially sync blocks, you can use an experimental script to sync with Infura. This script downloads blocks from Infura, runs the transactions inside them then verifies the block.

Running the sync_with_infura script

sync_with_infura pulls blocks from nodes hosted by Infura.io. You will need an Infura API key to run.

  1. Sign up with Infura.
  2. Create a new project.
  3. Copy your project API KEY.
  4. Paste your key into the dev.secret file for the blockchain app.
    1. Go to apps/blockchain/config/dev.secret.exs
    2. Paste your key to replace <your api key here> in the url string.
       config :ethereumex, url: "https://mainnet.infura.io/<your api key here>
    
  5. Save the file and return to the mana home directory.
  6. Run the script. mix run apps/blockchain/scripts/sync_with_infura.ex

If running properly, you will see a timestamp in hr/min/sec/millisec and a running list of Verified Blocks.

Infura sync issues

  • When running the script mainnet fails on block 179098 with a gas_used_mismatch and state_root_mismatch errors.
  • Ropsten fails on block 11 with a state_root_mismatch error as well.

Helpful debugging tools

When trying to debug why the sync_with_infura script is failing to verify a block, we have found etherscan to be very helpful. Take block 177610 for example,

We can look at the block information, and dive into the transaction information. From that page, the "Tools & Utilities" dropdown provides very helpful debugging tools. Two of the most valuable are Geth DebugTrace and Remix Debugger,

  • Geth DebugTrace allows us to compare each operation and its gas consumption against our implementation.

  • Remix Debugger allows us to compare the stack against our implementation's stack for each cycle of the virtual machine.

NOTE: for the Remix Debugger, you may want to add the block number at the top before pressing the play button.

To log the operation, gas consumption, and stack in our application, please see the EVM README's example setup.

Testing

Run:

mix test --exclude network

Tests tagged with network integrate with other nodes and cannot run unless another node is running in parallel. Use the --exclude network flag to exclude these tests.

If you want to only run Ethereum common tests, we currently have:

# Ethereum Virtual Machine tests
cd apps/evm && mix test test/evm_test.exs

# Ethereum Blockchain tests
cd apps/blockchain && mix test test/blockchain_test.exs

# Ethereum General State tests
cd apps/blockchain && mix test test/blockchain/state_test.exs

# Ethereum Transaction tests
cd apps/blockchain && mix test test/blockchain/transaction_test.exs

Test Status

Ethereum common tests are created for all clients to test against. We plan to progress through supported hard fork test protocols, and are currently working on the Homestead tests. See the common test documentation for more information.

Updating the Common test

The Ethereum common tests are in a submodule. To update you'll want to:

% cd ethereum_common_tests
% git checkout develop
% git pull

Project Status

Functionality Status
Encoding and Hashing The RLP encoding protocol and the Merkle Patricia Tree data structure are fully implemented.
Ethereum Virtual Machine Our EVM currently passes 100% of the common VM tests. We are still discovering subtle differences in our implementation such as the “vanishing Ether” issue. This component is for the most part complete.
Peer to Peer Networking Currently we can connect to one of the Ethereum bootnodes, get a list of peers, and add them to a list of known peers. We have fully implemented the modified kademlia DHT.

We can also successfully perform the encrypted handshake with peer nodes and derive secrets to frame the rest of the messages. We have not yet implemented the ability to send multi-frame packets. See Issue #97.
DEVp2p Protocol and Ethereum Wire Protocol These are partially implemented but need to be completed. See Issue #166 and Issue #167.

Documentation

To view module and reference documentation:

  1. Generate documentation. mix docs

  2. View the generated docs. open doc/index.html

License

License: LGPL v3.0

This project is licensed under the GNU Lesser General Public License v3.0. See the LICENSE file for details.

Contributing

See the CONTRIBUTING document for contribution, testing and pull request protocol.

References

Additional Ethereum Implementations

About

Ethereum full node implementation written in Elixir.

License:GNU General Public License v3.0


Languages

Language:Elixir 99.7%Language:Shell 0.3%