Skip to content

Commit

Permalink
blockchain app content (#335)
Browse files Browse the repository at this point in the history
* blockchain app content

* review changes
  • Loading branch information
andogro committed Aug 15, 2018
1 parent 3ab849d commit 0559b20
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 93 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Ethereum common tests are created for all clients to test against. We plan to pr
- [ ] Byzantium
- [ ] Constantinople: View the community [Constantinople Project Tracker](https://github.com/ethereum/pm/issues/53).


# Project Status

| Functionality | Status |
Expand Down
25 changes: 0 additions & 25 deletions apps/blockchain/LICENSE.md

This file was deleted.

62 changes: 5 additions & 57 deletions apps/blockchain/README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,17 @@
# Exthereum Blockchain [![CircleCI](https://circleci.com/gh/exthereum/blockchain.svg?style=svg)](https://circleci.com/gh/exthereum/blockchain)
# Mana-Ethereum Blockchain [![CircleCI](https://circleci.com/gh/exthereum/blockchain.svg?style=svg)](https://circleci.com/gh/exthereum/blockchain)

Elixir implementation of Ethereum's Blockchain.
An Elixir implementation of the Ethereum Blockchain.
This includes functionality to build and verify a chain of Ethereum blocks that may be advertised from any peer.
We complete the resultant state of the blocktree and form a canonical blockchain based on difficulty.

Exthereum's blocks are specified in a variety of sections throughout [the yellow paper](https://ethereum.github.io/yellowpaper/paper.pdf),
but it's best to start looking under Section 4.3.
Mana-Ethereum's blocks are specified in a variety of sections throughout [the yellow paper](https://ethereum.github.io/yellowpaper/paper.pdf). Blocks, State and Transactions begin in section 4.

## Installation

```bash
export "CFLAGS=-I/usr/local/include -L/usr/local/lib"
cd deps/libsecp256k1 && rebar compile
mix compile
```
Installation is handled through the bin/setup procedure in the [Mana-Ethereum README](https://github.com/poanetwork/mana).

## Debugging

To debug a given run of the blockchain, you can set breakpoints on contract addresses by
setting the `BREAKPOINT` environment variable and specifying a contract address to break on. E.g.

```bash
BREAKPOINT=bc1ffc1620da1468624a596cb841d35e6b2f1fb6 iex -S mix

...

00:04:18.739 [warn] Debugger has been enabled. Set breakpoint #1 on contract address 0xbc1ffc1620da1468624a596cb841d35e6b2f1fb6.

...

-- Breakpoint #1 triggered with conditions contract address 0xbc1ffc1620da1468624a596cb841d35e6b2f1fb6 (start) --

gas: 277888 | pc: 0 | memory: 0 | words: 0 | # stack: 0

----> [ 0] push2
[ 1] 0
[ 2] 4
[ 3] dup1
[ 4] push2
[ 5] 0
[ 6] 14
[ 7] push1
[ 8] 0
[ 9] codecopy

Enter a debug command or type `h` for help.

>>
```

## Contributing

1. [Fork it!](https://github.com/exthereum/blockchain/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## Author

Geoffrey Hayes (@hayesgm)
Ayrat Badykov (@ayrat555)
Mason Fischer (@masonforest)

## License
See the [CONTRIBUTING](CONTRIBUTING.md) document for contribution, testing and pull request protocol.

Exthereum's Blockchain is released under the MIT License.
See the LICENSE file for further details.
10 changes: 9 additions & 1 deletion apps/blockchain/lib/blockchain.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
defmodule Blockchain do
@moduledoc """
Documentation for Blockchain.
The Blockchain application is responsible for Ethereum blockchain processes and capabilities as defined in the [Ethereum yellow paper](https://ethereum.github.io/yellowpaper/paper.pdf)
Application functionality includes:
* Block encoding
* Adding blocks to the block tree to form a consistent blockchain
* Chain specific information
* Genesis block generation
* Transaction serialization
* Contract creation and message calls
"""
end
2 changes: 1 addition & 1 deletion apps/blockchain/lib/blockchain/account.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Blockchain.Account do
@moduledoc """
Represents the state of an account,
Represents the account state,
as defined in Section 4.1 of the Yellow Paper.
"""

Expand Down
4 changes: 0 additions & 4 deletions apps/blockchain/lib/blockchain/application.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
defmodule Blockchain.Application do
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
@moduledoc false

use Application
Expand Down Expand Up @@ -32,8 +30,6 @@ defmodule Blockchain.Application do
# worker(Blockchain.Worker, [arg1, arg2, arg3]),
]

# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Blockchain.Supervisor]
Supervisor.start_link(children, opts)
end
Expand Down
4 changes: 2 additions & 2 deletions apps/blockchain/lib/blockchain/block.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Blockchain.Block do
@moduledoc """
This module effectively encodes a Block, the heart of the blockchain.
This module effectively encodes a block, the heart of the blockchain.
A chain is formed when blocks point to previous blocks,
either as a parent or an ommer (uncle).
For more information, see Section 4.3 of the Yellow Paper.
Expand Down Expand Up @@ -491,7 +491,7 @@ defmodule Blockchain.Block do

@doc """
Set the difficulty of a new block based on Eq.(39), better defined
in Block.Header`.
in `Block.Header`.
# TODO: Validate these results
Expand Down
13 changes: 13 additions & 0 deletions apps/blockchain/lib/blockchain/bloom.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
defmodule Blockchain.Bloom do
@moduledoc """
When a block is generated or verified, the contract addresses and fields from the generated logs are added to a bloom filter. This is included in the block header.
_From Yellow Paper 4.3.1. Transaction Receipt_: The transaction receipt (R) is a tuple of four items comprising the post-transaction state:
- _Ru:_ the cumulative gas used in the block containing the transaction receipt immediately after the transaction has happened
- _Rl:_ the set of logs created through execution of the transaction
- _Rb_: the *bloom filter* composed from information in those logs
- _Rz_: the status code of the transaction.
"""
alias ExthCrypto.Hash.Keccak

use Bitwise
Expand Down
3 changes: 1 addition & 2 deletions apps/blockchain/lib/math_helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ defmodule Blockchain.MathHelper do
alias Blockchain.Transaction

@doc """
Caluclates the amount which should be refunded based on the current transactions
final usage. This includes the remaining gas plus refunds from clearing storage.
Calculates the amount amount of gas to refund based on the final usage of the current transaction. This includes the remaining gas plus refunds from clearing storage.
The specs calls for capping the refund at half of the total amount of gas used.
Expand Down
2 changes: 1 addition & 1 deletion apps/blockchain/lib/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Blockchain.Test do
@moduledoc """
Helper functions related to testing the Blockchain.
NOTE: Remember to recompile test after updading chain configs.
NOTE: Remember to recompile test after updating chain configs.
"""

@chain Blockchain.Chain.load_chain(:ropsten)
Expand Down

0 comments on commit 0559b20

Please sign in to comment.