github.com/shyftnetwork/go-empyrean@v1.8.3-0.20191127201940-fbfca9338f04/README.md (about) 1 2 ## Go Empyrean 3 4 [![API Reference](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667)](https://godoc.org/github.com/ShyftNetwork/go-empyrean) 5 [![Go Report Card](https://goreportcard.com/badge/github.com/ShyftNetwork/go-empyrean)](https://goreportcard.com/report/github.com/ShyftNetwork/go-empyrean) 6 [![Build Status](https://travis-ci.org/ShyftNetwork/go-empyrean.svg?branch=development)](https://travis-ci.org/ShyftNetwork/shyft_go-ethereum) 7 [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ShyftNetwork/go-empyrean?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 8 9 go-empyrean is based on a fork of go-ethereum. Much of the functionality and process for starting go-empyrean is the same as that for a regular ethereum node - as reflected in the notes detailed under the heading Go Ethereum below. Documentation for changes and enhancements added by Shyft is detailed under the section Shyft Notes below. 10 11 ## SHYFT NOTES 12 13 https://shyftnetwork.github.io/go-empyrean/#setup 14 15 #### Tag Release Command 16 17 `gren release --tags=v0.8.2 --data-source=prs --override` 18 19 #### Dependencies 20 21 - go 1.10 22 - postgres 10 23 24 To install go please review the installation docs [here](https://golang.org/doc/install), but ensure you download version 1.10. If you would like to install go with a script please check out this repo [here](https://github.com/canha/golang-tools-install-script). 25 26 To install postgres please review the installation docs [here](https://www.postgresql.org/docs/10/static/tutorial-install.html). 27 28 #### Govendor and Packages/Dependencies 29 30 > Download Go Vendor 31 32 ```shell 33 go get -u github.com/kardianos/govendor 34 ``` 35 36 > To run govendor globally, have this in your bash_profile file: 37 38 ```shell 39 export GOPATH=$HOME/go 40 export PATH=$PATH:$HOME/go/bin 41 ``` 42 43 > Then go_empyrean will need to be cloned to this directory: 44 45 ```shell 46 $GOPATH/src/github.com/ShyftNetwork/ 47 ``` 48 49 Geth uses govendor to manage packages/dependencies: [Go Vendor](https://github.com/kardianos/govendor) 50 51 This has some more information: [Ethereum Wiki](https://github.com/ShyftNetwork/go-empyrean/wiki/Developers'-Guide) 52 53 To add a new dependency, run govendor fetch <import-path> , and commit the changes to git. Then the deps will be accessible on other machines that pull from git. 54 55 >GOPATH is not strictly necessary however, for govendor it is much easier to use gopath as go will look for binaries in this directory ($GOPATH/bin). To set up GOPATH, read the govendor section. 56 57 58 #### Running Locally 59 60 To begin running locally, please ensure you have correctly installed go 1.10 and postgres (make sure postgres is running). 61 Once cloned, in a terminal window run the following command: 62 63 Before running any CLI options ensure you run **`make geth`** in the root directory. 64 65 ``./shyft-config/shyft-geth.sh --setup`` This sets up postgres and the shyft chain db 66 67 ``./shyft-config/shyft-geth.sh --start`` This starts GETH 68 69 At this point you should see GETH running in the terminal and if you opened your postgres instance you should see data being populated into the tables. It might look something similiar to the image below. 70 71 To stop Geth, **`crtl+C`** in the terminal window, if you proceed with the start script mentioned above the Shyft chain will begin from the last block height, if you wish to start the chain fresh from genesis follow the below steps: 72 73 ``./shyft-config/shyft-geth.sh --reset`` This drops postgres and chaindb data 74 75 ``./shyft-config/shyft-geth.sh --start`` Starts GETH 76 77 To see transactions being submitted on the network see the sendTransactions command in the CLI section of this readme. 78 79 #####SHH/Whisper 80 The shyft go_empyrean node, unlike go ethereum starts the SHH whisper client by default. This is to facilitate broadcast messaging from the shyft js bridge to each of the mining nodes. 81 82 To disable the whisper client a startup flag --disablewhisper is provided, which must be passed into the command line when starting up geth. 83 84 ``` 85 geth --disablewhisper 86 87 ``` 88 89 To overwrite the default whisper variables, the following flags are also provided: 90 91 --shh.maxmessagesize - sets the maximum message size fir the whisper client (integer) -(default: 1048576) --shh.maxmessagesize=128 92 --shh.pow - the minimum POW accepted for processing whisper messages (float64 - default: 0.2) --shh.pow=0.3 93 --shh.restrict-light - restrictions connections between two whisper light clients (boolean - default: true) --shh.restrict-light 94 95 To authenticate whisper messages a call is made to a smart contract that has a predetermined address on the blockchain. 96 Upon starting up a geth node if a user wishes to use this functionality they should ensure 97 that the WhisperSignersContract variable in config.toml contains the contract address for authentication of Whisper Signers. 98 99 The authentication of WhisperSigner's broadcast messages relies on automatically generated go contract bindings using the 100 the abigen cmd line utility. Should the contract be changed or modified these bindings will need to be regenerated. 101 Steps for regenerating are as follows: 102 103 ```$xslt 104 1. Generate the abi for the subject contract and save it at ./generated_bindings/contract_abis/whispersigner_abi.json. 105 106 2. Run the following command to regenerate the contract bindings: 107 108 ./build/bin/abigen --sol ./shyft-config/shyft-cli/web3/validSignersDeploy/ValidSigners.sol --pkg shyft_contracts --out generated_bindings/whisper_signer_binding.go 109 110 ``` 111 112 It should be noted that the authentication currently relies on a smart contract boolean returning function [isValidSigner(bool)], 113 that for a given signature address returns true if the contract or contract owner has a public key matching the signature. 114 115 #### Docker Images 116 117 Two sets of Docker Images are available for ShyftGeth, the Postgresql Database, and the Shyft Blockchain Explorer, which can be used for local development and testnet connection. The development settings are included in docker-compose.yml, the testnet settings are included in docker-compose.production.yml. To launch these containers you will need to have docker-compose installed on your computer. Installation instructions for docker-compose are available [here](https://docs.docker.com/install/). 118 119 **To build the images for the first time please run the following command:** 120 121 `./shyft-geth --setup # clears persisted directories prior to docker build` 122 123 `docker-compose up --build` 124 125 If you would like to reinitialize/rebuild the docker images you can run the above mentioned command as well. 126 127 To launch ShyftGeth, PG, the ShyftBlock Explorer Api and UI anytime after initial build - issue the following commands from the root of the project directory: 128 129 `./shyft-geth --setup # clears persisted directories prior to docker build` 130 131 **`docker-compose up`** 132 133 To stop/pause mining - enter: 134 135 **`docker-compose stop`** 136 137 And then just issue `docker-compose up` to continue mining. 138 139 #### Docker Postgresql - DB Connection 140 From your local machine you can view the database by connecting to the database in the container at 141 **``127.0.0.1:8001``** 142 143 Use the following credentials: 144 145 >``User: 'postgres'`` 146 147 >``Password: 'docker'`` 148 149 >``Database: 'shyftdb'`` 150 151 #### Docker Block Explorer Api 152 To access the shyftBlockExplorer open a browser and visit 153 154 **``http://localhost:3000``** 155 156 To rebuild any one of the services- issue the following commands: 157 158 Services: 159 160 - ShyftGeth 161 - Postgres Instance 162 - Shyft Explorer API 163 - Shyft Example Explorer UI 164 165 **`` 166 docker-compose up -d --no-deps --build <docker compose file service name> 167 ``** 168 169 ie. for shyftBlockExplorerApi: 170 171 **``docker-compose up -d --no-deps --build shyft_block_api``** 172 173 The Postgresql Database Container will persist the database data to the directory ``./pg-data`` _. So if you do want to reinitialize the database you should delete this directory as well as the blockchain data directories ``(./shyftData ./privatenet)`` prior to launching the docker containers. There is a shell script available to delete these folders to run it execute the following command: 174 175 **``./shyft-config/shyft-cli/resetShyftGeth``** 176 177 Blockchain data is persisted to **``./ethash/.ethash and ./shyftData__``**. If you would like to reset the test blockchain you will need to delete the **``__./ethash ./shyftData & ./privatenet__``** directories. 178 179 The docker container for the ShyftBlockExplorerApi utilizes govendor to minimize its image size. **If you would like the docker image for this container to reflect any uncommitted changes which may have occurred in the go-empyrean repository, ie. changes with respect to go-empyrean core (ie. cryptographic functions and database). Prior to launching the docker containers you should rebuild the vendor directory for the shyftBlockExplorerApi - by executing the following steps:** 180 181 Remove existing shyftBlockExplorerApi vendor.json and vendored components: 182 183 **``rm -rf shyftBlockExplorerApi/vendor``** 184 185 reinitialize vendor.json 186 187 **``cd shyftBlockExplorerApi && govendor init``** 188 189 rebuild vendor.json using latest uncommitted changes 190 191 **``govendor add +external``** 192 193 Due to a bug in govendor and it not being able to pull in some dependencies that are c-header files 194 you should execute the following commands - see these issues - which whilst closed 195 appears to have not been fixed: https://github.com/kardianos/govendor/issues/124 && https://github.com/kardianos/govendor/issues/61 196 197 **``govendor remove github.com/ShyftNetwork/go-empyrean/crypto/secp256k1/^``** 198 199 **``govendor fetch github.com/ShyftNetwork/go-empyrean/crypto/secp256k1/^``** 200 201 NB: The Shyft Geth docker image size is 1+ GB so make sure you have adequate space on your disk drive/ 202 203 #### Shyft BlockExplorer API 204 205 In order to store the block explorer database, a custom folder was created `./shyft_schema` that contains all the necessary functions to read and write to the explorer database. 206 207 The main functions exist in `./core/shyft_database_util.go` and `./core/shyft_get_utils.go` 208 209 To run the block explorer rest api that queries the postgres instance and returns a json body, open a new terminal window, navigate to the root directory of the project and run the following command: 210 211 **``go run blockExplorerApi/*.go``** 212 213 This will start a go server on port 8080 and allow you to either run the pre-existing block explorer or query the api endpoints. Its important to note, that if you have nothing in your postgres database the API will return nothing. 214 215 #### Shyft Block Explorer UI 216 217 To demonstrate the ability to create your own block explorer, a custom folder was created `./shyftBlockExplorerUI` that contains an example block explorer using react! 218 219 To run the Block Explorer UI, ensure that you have the API running as mentioned above. Then run the following command in a terminal: 220 221 ``cd shyftBlockExplorerUI`` 222 223 ``npm install`` 224 225 ``npm run start`` 226 227 This will start a development server on ``port 3000`` and spin up an example block explorer that uses the API to query the postgres database. 228 229 _TODO_ 230 231 - Find better dependency management solution that pulls in c header files without manual intervention 232 - Reduce size of the ShytfGeth docker container which is responsible for mining and running the blockchain 233 - Adjust docker scripts and ports to facilitate sending of test transactions 234 - Modify Docker scripts to facilitate hot reloading during development 235 236 #### CLI 237 238 Run `./shyft-geth` with one of the following flags: 239 240 - `--setup` - Setups postgres and the shyft chain db. 241 - `--start` - Starts geth. 242 - `--reset` - Drops postgress and chain db, and reinstantiates both. 243 - `--js [web3 filename]` - Executes web3 calls with a passed file name. If the file name is `sendTransactions.js`, `./shyft-geth --js sendTransactions`. 244 245 #### Chain Rollbacks 246 247 For development and testing purposes only, until a formal messaging system has been incorporated within go-empyrean, an endpoint is available and freely accessible to trigger a chain and postgresql database rollback. 248 249 To trigger a chain/pg database rollback the following command should be executed: 250 251 ``` 252 curl <node ip address>:8081/rollback_blocks/<block hashheader to rollback to> 253 254 ie. curl localhost:8081/rollback_blocks/0x6c7db5b09bda0277b480aece97d2efac70838cad4fe6ae45f68410c8cd7cd640 255 ``` 256 257 ## Go Ethereum 258 259 Official golang implementation of the Ethereum protocol. 260 261 Automated builds are available for stable releases and the unstable master branch. 262 Binary archives are published at https://geth.ethereum.org/downloads/. 263 264 ## Building the source 265 266 For prerequisites and detailed build instructions please read the 267 [Installation Instructions](https://github.com/empyrean/go-ethereum/wiki/Building-Ethereum) 268 on the wiki. 269 270 Building geth requires both a Go (version 1.9 or later) and a C compiler. 271 You can install them using your favourite package manager. 272 Once the dependencies are installed, run 273 274 make geth 275 276 or, to build the full suite of utilities: 277 278 make all 279 280 ## Executables 281 282 The go-ethereum project comes with several wrappers/executables found in the `cmd` directory. 283 284 | Command | Description | 285 |:----------:|-------------| 286 | **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI Wiki page](https://github.com/ShyftNetwork/go-empyrean/wiki/Command-Line-Options) for command line options. | 287 | `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) with expanded functionality if the contract bytecode is also available. However it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://github.com/ShyftNetwork/go-empyrean/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. | 288 | `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. | 289 | `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug`). | 290 | `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details. | 291 | `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). | 292 | `swarm` | Swarm daemon and tools. This is the entrypoint for the Swarm network. `swarm --help` for command line options and subcommands. See [Swarm README](https://github.com/ShyftNetwork/go-empyrean/tree/master/swarm) for more information. | 293 | `puppeth` | a CLI wizard that aids in creating a new Ethereum network. | 294 295 ## Running geth 296 297 Going through all the possible command line flags is out of scope here (please consult our 298 [CLI Wiki page](https://github.com/empyrean/go-ethereum/wiki/Command-Line-Options)), but we've 299 enumerated a few common parameter combos to get you up to speed quickly on how you can run your 300 own Geth instance. 301 302 ### Full node on the main Ethereum network 303 304 By far the most common scenario is people wanting to simply interact with the Ethereum network: 305 create accounts; transfer funds; deploy and interact with contracts. For this particular use-case 306 the user doesn't care about years-old historical data, so we can fast-sync quickly to the current 307 state of the network. To do so: 308 309 ``` 310 $ geth console 311 ``` 312 313 This command will: 314 315 * Start geth in fast sync mode (default, can be changed with the `--syncmode` flag), causing it to 316 download more data in exchange for avoiding processing the entire history of the Ethereum network, 317 which is very CPU intensive. 318 * Start up Geth's built-in interactive [JavaScript console](https://github.com/ShyftNetwork/go-empyrean/wiki/JavaScript-Console), 319 (via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API) 320 as well as Geth's own [management APIs](https://github.com/ShyftNetwork/go-empyrean/wiki/Management-APIs). 321 This tool is optional and if you leave it out you can always attach to an already running Geth instance 322 with `geth attach`. 323 324 ### Full node on the Ethereum test network 325 326 Transitioning towards developers, if you'd like to play around with creating Ethereum contracts, you 327 almost certainly would like to do that without any real money involved until you get the hang of the 328 entire system. In other words, instead of attaching to the main network, you want to join the **test** 329 network with your node, which is fully equivalent to the main network, but with play-Ether only. 330 331 ``` 332 $ geth --testnet console 333 ``` 334 335 The `console` subcommand have the exact same meaning as above and they are equally useful on the 336 testnet too. Please see above for their explanations if you've skipped to here. 337 338 Specifying the `--testnet` flag however will reconfigure your Geth instance a bit: 339 340 - Instead of using the default data directory (`~/.ethereum` on Linux for example), Geth will nest 341 itself one level deeper into a `testnet` subfolder (`~/.ethereum/testnet` on Linux). Note, on OSX 342 and Linux this also means that attaching to a running testnet node requires the use of a custom 343 endpoint since `geth attach` will try to attach to a production node endpoint by default. E.g. 344 `geth attach <datadir>/testnet/geth.ipc`. Windows users are not affected by this. 345 - Instead of connecting the main Ethereum network, the client will connect to the test network, 346 which uses different P2P bootnodes, different network IDs and genesis states. 347 348 _Note: Although there are some internal protective measures to prevent transactions from crossing 349 over between the main network and test network, you should make sure to always use separate accounts 350 for play-money and real-money. Unless you manually move accounts, Geth will by default correctly 351 separate the two networks and will not make any accounts available between them._ 352 353 ### Full node on the Rinkeby test network 354 355 The above test network is a cross client one based on the ethash proof-of-work consensus algorithm. As such, it has certain extra overhead and is more susceptible to reorganization attacks due to the network's low difficulty / security. Go Ethereum also supports connecting to a proof-of-authority based test network called [_Rinkeby_](https://www.rinkeby.io) (operated by members of the community). This network is lighter, more secure, but is only supported by go-ethereum. 356 357 ``` 358 $ geth --rinkeby console 359 ``` 360 361 ### Configuration 362 363 As an alternative to passing the numerous flags to the `geth` binary, you can also pass a configuration file via: 364 365 ``` 366 $ geth --config /path/to/your_config.toml 367 ``` 368 369 To get an idea how the file should look like you can use the `dumpconfig` subcommand to export your existing configuration: 370 371 ``` 372 $ geth --your-favourite-flags dumpconfig 373 ``` 374 375 _Note: This works only with geth v1.6.0 and above._ 376 377 #### Docker quick start 378 379 One of the quickest ways to get Ethereum up and running on your machine is by using Docker: 380 381 ``` 382 docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \ 383 -p 8545:8545 -p 30303:30303 \ 384 ethereum/client-go 385 ``` 386 387 This will start geth in fast-sync mode with a DB memory allowance of 1GB just as the above command does. It will also create a persistent volume in your home directory for saving your blockchain as well as map the default ports. There is also an `alpine` tag available for a slim version of the image. 388 389 Do not forget `--rpcaddr 0.0.0.0`, if you want to access RPC from other containers and/or hosts. By default, `geth` binds to the local interface and RPC endpoints is not accessible from the outside. 390 391 ### Programatically interfacing Geth nodes 392 393 As a developer, sooner rather than later you'll want to start interacting with Geth and the Ethereum 394 network via your own programs and not manually through the console. To aid this, Geth has built-in 395 support for a JSON-RPC based APIs ([standard APIs](https://github.com/ethereum/wiki/wiki/JSON-RPC) and 396 [Geth specific APIs](https://github.com/empyrean/go-ethereum/wiki/Management-APIs)). These can be 397 exposed via HTTP, WebSockets and IPC (unix sockets on unix based platforms, and named pipes on Windows). 398 399 The IPC interface is enabled by default and exposes all the APIs supported by Geth, whereas the HTTP 400 and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons. 401 These can be turned on/off and configured as you'd expect. 402 403 HTTP based JSON-RPC API options: 404 405 - `--rpc` Enable the HTTP-RPC server 406 - `--rpcaddr` HTTP-RPC server listening interface (default: "localhost") 407 - `--rpcport` HTTP-RPC server listening port (default: 8545) 408 - `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3") 409 - `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced) 410 - `--ws` Enable the WS-RPC server 411 - `--wsaddr` WS-RPC server listening interface (default: "localhost") 412 - `--wsport` WS-RPC server listening port (default: 8546) 413 - `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3") 414 - `--wsorigins` Origins from which to accept websockets requests 415 - `--ipcdisable` Disable the IPC-RPC server 416 - `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3") 417 - `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it) 418 419 You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect 420 via HTTP, WS or IPC to a Geth node configured with the above flags and you'll need to speak [JSON-RPC](https://www.jsonrpc.org/specification) 421 on all transports. You can reuse the same connection for multiple requests! 422 423 **Note: Please understand the security implications of opening up an HTTP/WS based transport before 424 doing so! Hackers on the internet are actively trying to subvert Ethereum nodes with exposed APIs! 425 Further, all browser tabs can access locally running webservers, so malicious webpages could try to 426 subvert locally available APIs!** 427 428 ### Operating a private network 429 430 Maintaining your own private network is more involved as a lot of configurations taken for granted in 431 the official networks need to be manually set up. 432 433 #### Defining the private genesis state 434 435 First, you'll need to create the genesis state of your networks, which all nodes need to be aware of 436 and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`): 437 438 ```json 439 { 440 "config": { 441 "chainId": 0, 442 "homesteadBlock": 0, 443 "eip155Block": 0, 444 "eip158Block": 0 445 }, 446 "alloc": {}, 447 "coinbase": "0x0000000000000000000000000000000000000000", 448 "difficulty": "0x20000", 449 "extraData": "", 450 "gasLimit": "0x2fefd8", 451 "nonce": "0x0000000000000042", 452 "mixhash": 453 "0x0000000000000000000000000000000000000000000000000000000000000000", 454 "parentHash": 455 "0x0000000000000000000000000000000000000000000000000000000000000000", 456 "timestamp": "0x00" 457 } 458 ``` 459 460 The above fields should be fine for most purposes, although we'd recommend changing the `nonce` to 461 some random value so you prevent unknown remote nodes from being able to connect to you. If you'd 462 like to pre-fund some accounts for easier testing, you can populate the `alloc` field with account 463 configs: 464 465 ```json 466 "alloc": { 467 "0x0000000000000000000000000000000000000001": {"balance": "111111111"}, 468 "0x0000000000000000000000000000000000000002": {"balance": "222222222"} 469 } 470 ``` 471 472 With the genesis state defined in the above JSON file, you'll need to initialize **every** Geth node 473 with it prior to starting it up to ensure all blockchain parameters are correctly set: 474 475 ``` 476 $ geth init path/to/genesis.json 477 ``` 478 479 #### Creating the rendezvous point 480 481 With all nodes that you want to run initialized to the desired genesis state, you'll need to start a 482 bootstrap node that others can use to find each other in your 483 network and/or over the internet. The 484 clean way is to configure and run a dedicated bootnode: 485 486 ``` 487 $ bootnode --genkey=boot.key 488 $ bootnode --nodekey=boot.key 489 ``` 490 491 With the bootnode online, it will display an [`enode` URL](https://github.com/ethereum/wiki/wiki/enode-url-format) 492 that other nodes can use to connect to it and exchange peer information. Make sure to replace the 493 displayed IP address information (most probably `[::]`) with your externally accessible IP to get the 494 actual `enode` URL. 495 496 _Note: You could also use a full fledged Geth node as a bootnode, but it's the less recommended way._ 497 498 #### Starting up your member nodes 499 500 With the bootnode operational and externally reachable (you can try `telnet <ip> <port>` to ensure 501 it's indeed reachable), start every subsequent Geth node pointed to the bootnode for peer discovery 502 via the `--bootnodes` flag. It will probably also be desirable to keep the data directory of your 503 private network separated, so do also specify a custom `--datadir` flag. 504 505 ``` 506 $ geth --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above> 507 ``` 508 509 _Note: Since your network will be completely cut off from the main and test networks, you'll also 510 need to configure a miner to process transactions and create new blocks for you._ 511 512 #### Running a private miner 513 514 Mining on the public Ethereum network is a complex task as it's only feasible using GPUs, requiring 515 an OpenCL or CUDA enabled `ethminer` instance. For information on such a setup, please consult the 516 [EtherMining subreddit](https://www.reddit.com/r/EtherMining/) and the [Genoil miner](https://github.com/Genoil/cpp-ethereum) 517 repository. 518 519 In a private network setting however, a single CPU miner instance is more than enough for practical 520 purposes as it can produce a stable stream of blocks at the correct intervals without needing heavy 521 resources (consider running on a single thread, no need for multiple ones either). To start a Geth 522 instance for mining, run it with all your usual flags, extended by: 523 524 ``` 525 $ geth <usual-flags> --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000 526 ``` 527 528 Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to 529 the account specified by `--etherbase`. You can further tune the mining by changing the default gas 530 limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`). 531 532 ## SHYFT NOTES 533 534 #### CLI 535 536 Run `./shyft-config/shyft-geth` with one of the following flags: 537 538 - `--setup` - Setups postgres and the shyft chain db. 539 - `--start` - Starts geth. 540 - `--reset` - Drops postgress and chain db, and reinstantiates both. 541 - `--js [web3 filename]` - Executes web3 calls with a passed file name. If the file name is `sendTransactions.js`, `./shyft-geth --js sendTransactions`. 542 543 #### Docker Images 544 545 Docker Images are available for ShyftGeth and the Postgresql Database which can be used for development and testing. To launch these containers you will need to have docker-compose installed on your computer. Installation instructions for docker-compose are available [here](https://docs.docker.com/install/). 546 547 To launch ShyftGeth, PG, the ShyftBlock Explorer Api and UI - issue the following command from the root of the project directory: 548 549 `docker-compose up` 550 551 If you would like to reinitialize/rebuild the docker images you can issue the following command: 552 553 `docker-compose up --build` 554 555 To rebuild any one of the services - issue the following commands: 556 557 ``` 558 docker-compose up -d --no-deps --build <docker compose file service name> 559 560 # ie. for shyftBlockExplorerApi: 561 # docker-compose up -d --no-deps --build shyft_block_api 562 ``` 563 __The Postgresql Database Container will persist the database data to a folder in the root of the project directory - pg-data" __. So if you do want to reinitialize the database you should delete this docker container prior to launching the docker containers. To delete this docker volume and have it recreated you should input the following command: 564 565 ```docker volume rm go-empyrean_pg-data``` 566 567 From your local machine you can view the database by connecting to the database in the container at 127.0.0.1:8001. To access the shyftBlockExplorer open a browser and visit http://localhost:3000 568 569 __Blockchain data is persisted to ./ethash/.ethash__ and ./shyftData. If you would like to reset the test blockchain you will need to delete the ./ethash and ./shyftData directories. 570 571 The docker container for the ShyftBlockExplorerApi utilizes govendor to minimize its image size. __If you would like the docker image for this container to reflect any uncommitted changes which may have occurred in the go-empyrean repository, ie. changes with respect to go-empyrean core (ie. cryptographic functions and database). Prior to launching the docker containers you should rebuild the vendor directory for the shyftBlockExplorerApi - by executing the following steps:__ 572 573 ``` 574 # remove existing shyftBlockExplorerApi vendor.json and vendored components: 575 576 rm -rf shyftBlockExplorerApi/vendor 577 578 # reinitialize vendor.json 579 580 cd shyftBlockExplorerApi && govendor init 581 582 # rebuild vendor.json using latest uncommitted changes 583 584 govendor add -tree -uncommitted +external 585 586 # due to a bug in govendor and it not being able to pull in some dependencies that are c-header files 587 # you should execute the following commands - see these issues - which whilst closed 588 # appears to have not been fixed: https://github.com/kardianos/govendor/issues/124 && https://github.com/kardianos/govendor/issues/61 589 590 govendor remove github.com/ShyftNetwork/go-empyrean/crypto/secp256k1/^ 591 govendor fetch github.com/ShyftNetwork/go-empyrean/crypto/secp256k1/^ 592 593 ``` 594 595 NB: The Shyft Geth docker image size is 1+ GB so make sure you have adequate space on your disk drive/ 596 597 _TODO_ 598 599 - Find better dependency management solution that pulls in c header files without manual intervention 600 - Reduce size of the ShytfGeth docker container which is responsible for mining and running the blockchain 601 - Adjust docker scripts and ports to facilitate sending of test transactions 602 - Modify Docker scripts to facilitate hot reloading during development 603 604 ## Contribution 605 606 If you'd like to contribute to go-empyrean, please fork, fix, commit and send a pull request against the `development` branch. 607 608 We have a list of issues available on github. 609 610 For general communication, we communicate on [our gitter channel](https://gitter.im/ShyftNetwork/go-empyrean). 611 612 Please make sure your contributions adhere to our coding guidelines: 613 614 - Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). 615 - Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. 616 - Pull requests need to be based on and opened against the `development` branch. 617 618 619 ## License 620 621 The go-ethereum library (i.e. all code outside of the `cmd` directory) is licensed under the 622 [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also 623 included in our repository in the `COPYING.LESSER` file. 624 625 The go-ethereum binaries (i.e. all code inside of the `cmd` directory) is licensed under the 626 [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included 627 in our repository in the `COPYING` file.