Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Other Changes: * Update README with installation instructions
- Loading branch information
1 parent
3b132b9
commit 10190d3
Showing
11 changed files
with
200 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,65 @@ | ||
Elipticoin Blacksmith Node | ||
Ellipticoin Blacksmith Node | ||
========== | ||
|
||
Elipticoin is a Ethereum-like blockchain that's optimized for sustainability and | ||
developer happiness. [Stakers](https://en.wikipedia.org/wiki/Proof-of-stake) run | ||
blacksmith nodes to form consensus on transactions on the network in return for | ||
staking rewards. This is the reference implementation of a | ||
blacksmith node written in Elixir and Rust. | ||
Ellipticoin is a developer friendly scalable Ethereum side-chain. Blacksmith | ||
nodes forge transactions to keep the network secure. They are authenticated via [proof | ||
of | ||
burn](https://www.masonforest.com/blockchain/ethereum/ellipticoin/2018/05/29/the-ellipticoin-proof-of-burn-algorithm.html) | ||
which has similar economic incentives to proof of work except instead of | ||
burning energy they burn tokens on the parent chain. | ||
|
||
You can access the Elipticoin network using the [reference wallet](https://www.npmjs.com/package/ec-wallet). | ||
You can install the [reference wallet](https://www.npmjs.com/package/ec-wallet) to use the Ellipticoin network itself. | ||
|
||
|
||
Running a Blacksmith Node: | ||
========================== | ||
|
||
Using docker-compose | ||
----- | ||
1. Clone the repo: `git clone https://github.com/ellipticoin/ellipticoin-blacksmith-node && cd ellipticoin-blacksmith-node` | ||
2. Install Docker | ||
2. Update `ETHEREUM_PRIVATE_KEY` in `config/docker.env` | ||
3. Run `docker-compose up` | ||
|
||
From a binary release | ||
----- | ||
|
||
1. Create an `Ubuntu 18.04` VPS/Droplet (or another type of VPS and create a | ||
PR!) | ||
2. Download the appropriate release for your system and extract it: | ||
```` | ||
$ cd /usr/local | ||
$ wget blacksmith.tar.gz | ||
$ tar -xf blacksmith.tar.gz | ||
$ rm blacksmith.tar.gz | ||
```` | ||
3. Run `sh ./releases/0.1.0/commands/install_deps.sh` to install the required dependencies. | ||
4. Allow all postgres connections from localhost: | ||
|
||
Edit: /etc/postgresql/10/main/pg_hba.conf | ||
|
||
Change the line: | ||
```` | ||
local all postgres peer | ||
```` | ||
to | ||
```` | ||
local all postgres trust | ||
```` | ||
5. Restart postgres: `sudo service postgresql restart` | ||
|
||
6. Create the blacksmith's db: `createdb -U postgres blacksmith` | ||
7. Update `ETHEREUM_PRIVATE_KEY` and anything else you'd like to customize in | ||
`/usr/local/etc/config.exs` | ||
|
||
9. Run the blacksmith node in the forground to check if everything is set up correctly: `blacksmith foreground` | ||
|
||
10. If everything looks to be working you can kill the node and start it again in the background: `blacksmith start` | ||
|
||
From Source | ||
----- | ||
1. Clone the repo: `git clone https://github.com/ellipticoin/ellipticoin-blacksmith-node && cd ellipticoin-blacksmith-node` | ||
2. Update `ETHEREUM_PRIVATE_KEY` and anything else you'd like to customize in | ||
`config/dev.secret.exs` and `config/dev.exs` | ||
3. Run: `mix dep.get` | ||
4. Run: `mix run --no-halt` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
defmodule Blacksmith.ReleaseTasks do | ||
@start_apps [ | ||
:crypto, | ||
:ssl, | ||
:postgrex, | ||
:ecto, | ||
:ecto_sql | ||
] | ||
|
||
@repos Application.get_env(:blacksmith, :ecto_repos, []) | ||
|
||
def migrate(_argv) do | ||
start_services() | ||
|
||
run_migrations() | ||
|
||
stop_services() | ||
end | ||
|
||
defp start_services do | ||
IO.puts("Starting dependencies..") | ||
# Start apps necessary for executing migrations | ||
Enum.each(@start_apps, &Application.ensure_all_started/1) | ||
|
||
# Start the Repo(s) for app | ||
IO.puts("Starting repos..") | ||
|
||
Enum.each(@repos, & &1.start_link(pool_size: 2)) | ||
end | ||
|
||
defp stop_services do | ||
IO.puts("Success!") | ||
:init.stop() | ||
end | ||
|
||
defp run_migrations do | ||
Enum.each(@repos, &run_migrations_for/1) | ||
end | ||
|
||
defp run_migrations_for(repo) do | ||
app = Keyword.get(repo.config, :otp_app) | ||
IO.puts("Running migrations for #{app}") | ||
migrations_path = priv_path_for(repo, "migrations") | ||
Ecto.Migrator.run(repo, migrations_path, :up, all: true) | ||
end | ||
|
||
defp priv_path_for(repo, filename) do | ||
app = Keyword.get(repo.config, :otp_app) | ||
|
||
repo_underscore = | ||
repo | ||
|> Module.split() | ||
|> List.last() | ||
|> Macro.underscore() | ||
|
||
priv_dir = "#{:code.priv_dir(app)}" | ||
|
||
Path.join([priv_dir, repo_underscore, filename]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/env sh | ||
|
||
LINUX_DEPS="build-essential automake autoconf autogen libncurses-dev libgmp-dev libtinfo-dev libncursesw5-dev libncurses5-dev libtool gcc curl postgresql redis-server openssl" | ||
DARWIN_DEPS="automake autoconf autogen libgmp-dev postgresql redis" | ||
|
||
fancy_echo() { | ||
local fmt="$1"; shift | ||
|
||
# shellcheck disable=SC2059 | ||
printf "\\n$fmt\\n" "$@" | ||
} | ||
|
||
install_linux_deps() { | ||
local flavor=`grep "^ID=" /etc/os-release | cut -d"=" -f 2` | ||
case $flavor in | ||
debian|ubuntu) | ||
sudo apt-get update && sudo apt-get update && sudo apt-get install -y $LINUX_DEPS libgmp-dev erlang-dev | ||
;; | ||
fedora|centos) | ||
sudo yum install $LINUX_DEPS gmp-devel | ||
;; | ||
*) | ||
fancy_echo "Unrecognized distribution $flavor" | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
install_darwin_deps(){ | ||
fancy_echo "Installing dependencies via brew" | ||
brew install $DARWIN_DEPS | ||
} | ||
|
||
install_deps() { | ||
local sys=`uname -s` | ||
echo $sys | ||
case $sys in | ||
Linux*) | ||
install_linux_deps | ||
;; | ||
Darwin*) | ||
install_darwin_deps | ||
;; | ||
*) | ||
fancy_echo "Unknown system" | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
set -e | ||
install_deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
release_ctl eval --mfa "Blacksmith.ReleaseTasks.migrate/1" --argv -- "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
use Mix.Config | ||
|
||
config :blacksmith, :ethereum_private_key, "wss://rinkeby.infura.io/ws" | ||
config :blacksmith, base_contracts_path: "./base_contracts" | ||
config :blacksmith, port: String.to_integer(System.get_env("PORT") || "4045") | ||
config :blacksmith, port: 4045 | ||
|
||
config :blacksmith, | ||
staking_contract_address: | ||
(System.get_env("STAKING_CONTRACT_ADDRESS") || "") |> Base.decode16!(case: :mixed) | ||
"756d0ABF6235AB135126fe772CDaE195C3DECc0e" |> Base.decode16!(case: :mixed) | ||
|
||
config :ethereumex, :web3_url, System.get_env("WEB3_URL") | ||
config :ethereumex, :web3_url, "wss://rinkeby.infura.io/ws" | ||
config :ethereumex, :client_type, :websocket | ||
config :blacksmith, private_key: (System.get_env("ETHEREUM_PRIVATE_KEY") || "") |> Base.decode16!() | ||
config :blacksmith, ethereum_private_key: "1274EA29DC71B4B2E6439FDD109545E8C1585E2B16BCD45236FE20FBF919A70D" |> Base.decode16!() | ||
|
||
config :blacksmith, :redis_url, System.get_env("REDIS_URL") | ||
config :blacksmith, :redis_url, "redis://localhost:6379/" | ||
config :blacksmith, Blacksmith.Repo, | ||
username: System.get_env("POSTGRES_USER"), | ||
password: System.get_env("POSTGRES_PASS"), | ||
database: System.get_env("POSTGRES_DB"), | ||
hostname: System.get_env("POSTGRES_HOST"), | ||
username: "postgres", | ||
password: "", | ||
database: "blacksmith", | ||
hostname: "localhost", | ||
pool_size: 15 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.