github.com/digdeepmining/go-atheios@v1.5.13-0.20180902133602-d5687a2e6f43/README.md (about) 1 ## atheios Go 2 3 Official golang implementation of the atheios protocol. 4 5 [![API Reference]( 6 https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667 7 )](https://godoc.org/github.com/atheioschain/go-atheios) 8 9 Automated builds are available for stable releases and the unstable master branch. 10 Binary archives are published at [releases](https://github.com/atheioschain/go-atheios/releases) page. 11 12 ## Building the source 13 14 For prerequisites and detailed build instructions please read the [Ethereum's Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum) on their wiki. 15 16 *Note*: Keep in mind that atheios aims to be 100% compatible with Ethereum, so mostly all the documentation you can find on Ethereum wiki, will apply for sure to atheios. 17 18 Building gath requires both a Go and a C compiler (version 1.7 or later). You can install them using your favourite package manager. Once the dependencies are installed, run 19 20 make gath 21 22 or, to build the full suite of utilities: 23 24 make all 25 26 ## Executables 27 28 The go-atheios project comes with several wrappers/executables found in the `cmd` directory. 29 30 | Command | Description | 31 |:----------:|-------------| 32 | **`gath`** | Our main atheios CLI client. It is the entry point into the atheios 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 atheios network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `gath --help` and the [CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) for command line options | 33 | `abigen` | Source code generator to convert atheios 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 [Ethereum Native DApps](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. | 34 | `bootnode` | Stripped down version of our atheios 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. | 35 | `disasm` | Bytecode disassembler to convert EVM (Ethereum Virtual Machine) bytecode into more user friendly assembly-like opcodes (e.g. `echo "6001" | disasm`). For details on the individual opcodes, please see pages 22-30 of the [Ethereum Yellow Paper](http://gavwood.com/paper.pdf). | 36 | `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 insolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug`). | 37 | `gathrpctest` | Developer utility tool to support our [atheios/rpc-test](https://github.com/atheioschain/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/atheioschain/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/atheioschain/rpc-tests/blob/master/README.md) for details. | 38 | `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/atheioschain/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`). | 39 40 ## Running gath 41 42 Going through all the possible command line flags is out of scope here (please consult 43 [Ethereum CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)), but we've 44 enumerated a few common parameter combos to get you up to speed quickly on how you can run your 45 own gath instance. 46 47 ### Full node on the main atheios network 48 49 By far the most common scenario is people wanting to simply interact with the atheios network: 50 create accounts; transfer funds; deploy and interact with contracts. For this particular use-case 51 the user doesn't care about years-old historical data, so we can fast-sync quickly to the current 52 state of the network. To do so: 53 54 ``` 55 $ gath --fast --cache=512 console 56 ``` 57 58 This command will: 59 60 * Start gath in fast sync mode (`--fast`), causing it to download more data in exchange for avoiding 61 processing the entire history of the Ethereum network, which is very CPU intensive. 62 * Bump the memory allowance of the database to 512MB (`--cache=512`), which can help significantly in 63 sync times especially for HDD users. This flag is optional and you can set it as high or as low as 64 you'd like, though we'd recommend the 512MB - 2GB range. 65 * Start up gath's built-in interactive [JavaScript console](https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console), 66 (via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API) 67 as well as gath's own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs). 68 This too is optional and if you leave it out you can always attach to an already running gath instance 69 with `gath --attach`. 70 71 ### Full node on the atheios test network 72 73 Transitioning towards developers, if you'd like to play around with creating Ethereum contracts, you 74 almost certainly would like to do that without any real money involved until you get the hang of the 75 entire system. In other words, instead of attaching to the main network, you want to join the **test** 76 network with your node, which is fully equivalent to the main network, but with play-Ether only. 77 78 ``` 79 $ gath --testnet --fast --cache=512 console 80 ``` 81 82 The `--fast`, `--cache` flags and `console` subcommand have the exact same meaning as above and they 83 are equially useful on the testnet too. Please see above for their explanations if you've skipped to 84 here. 85 86 Specifying the `--testnet` flag however will reconfigure your gath instance a bit: 87 88 * Instead of using the default data directory (`~/.atheios` on Linux for example), gath will nest 89 itself one level deeper into a `testnet` subfolder (`~/.atheios/testnet` on Linux). 90 * Instead of connecting the main atheios network, the client will connect to the test network, 91 which uses different P2P bootnodes, different network IDs and genesis states. 92 93 *Note: Although there are some internal protective measures to prevent transactions from crossing 94 over between the main network and test network (different starting nonces), you should make sure to 95 always use separate accounts for play-money and real-money. Unless you manually move accounts, gath 96 will by default correctly separate the two networks and will not make any accounts available between 97 them.* 98 99 #### Docker quick start 100 101 One of the quickest ways to get atheios up and running on your machine is by using Docker: 102 103 ``` 104 docker run -d --name atheios-node -v /Users/alice/atheios:/root \ 105 -p 8696:8696 -p 30696:30696 \ 106 atheios/gath --fast --cache=512 107 ``` 108 109 This will start gath in fast sync mode with a DB memory allowance of 512MB 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. 110 111 Gath is available on Docker Hub here: https://hub.docker.com/r/atheios/gath/ 112 113 ### Programatically interfacing gath nodes 114 115 As a developer, sooner rather than later you'll want to start interacting with gath and the atheios 116 network via your own programs and not manually through the console. To aid this, gath has built in 117 support for a JSON-RPC based APIs ([standard APIs](https://github.com/ethereum/wiki/wiki/JSON-RPC) and 118 [gath specific APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs)). These can be 119 exposed via HTTP, WebSockets and IPC (unix sockets on unix based platroms, and named pipes on Windows). 120 121 The IPC interface is enabled by default and exposes all the APIs supported by gath, whereas the HTTP 122 and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons. 123 These can be turned on/off and configured as you'd expect. 124 125 HTTP based JSON-RPC API options: 126 127 * `--rpc` Enable the HTTP-RPC server 128 * `--rpcaddr` HTTP-RPC server listening interface (default: "localhost") 129 * `--rpcport` HTTP-RPC server listening port (default: 8696) 130 * `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3") 131 * `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced) 132 * `--ws` Enable the WS-RPC server 133 * `--wsaddr` WS-RPC server listening interface (default: "localhost") 134 * `--wsport` WS-RPC server listening port (default: 8697) 135 * `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3") 136 * `--wsorigins` Origins from which to accept websockets requests 137 * `--ipcdisable` Disable the IPC-RPC server 138 * `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3") 139 * `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it) 140 141 You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect 142 via HTTP, WS or IPC to a gath node configured with the above flags and you'll need to speak [JSON-RPC](http://www.jsonrpc.org/specification) 143 on all transports. You can reuse the same connection for multiple requests! 144 145 **Note: Please understand the security implications of opening up an HTTP/WS based transport before 146 doing so! Hackers on the internet are actively trying to subvert Ethereum nodes with exposed APIs! 147 Further, all browser tabs can access locally running webservers, so malicious webpages could try to 148 subvert locally available APIs!** 149 150 ### Operating a private network 151 152 Maintaining your own private network is more involved as a lot of configurations taken for granted in 153 the official networks need to be manually set up. 154 155 #### Defining the private genesis state 156 157 First, you'll need to create the genesis state of your networks, which all nodes need to be aware of 158 and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`): 159 160 ```json 161 { 162 "alloc" : {}, 163 "coinbase" : "0x0000000000000000000000000000000000000000", 164 "difficulty" : "0x20000", 165 "extraData" : "", 166 "gasLimit" : "0x2fefd8", 167 "nonce" : "0x0000000000000042", 168 "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", 169 "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", 170 "timestamp" : "0x00" 171 } 172 ``` 173 174 The above fields should be fine for most purposes, although we'd recommend changing the `nonce` to 175 some random value so you prevent unknown remote nodes from being able to connect to you. If you'd 176 like to pre-fund some accounts for easier testing, you can populate the `alloc` field with account 177 configs: 178 179 ```json 180 "alloc": { 181 "0x0000000000000000000000000000000000000001": {"balance": "111111111"}, 182 "0x0000000000000000000000000000000000000002": {"balance": "222222222"} 183 } 184 ``` 185 186 With the genesis state defined in the above JSON file, you'll need to initialize **every** gath node 187 with it prior to starting it up to ensure all blockchain parameters are correctly set: 188 189 ``` 190 $ gath init path/to/genesis.json 191 ``` 192 193 #### Creating the rendezvous point 194 195 With all nodes that you want to run initialized to the desired genesis state, you'll need to start a 196 bootstrap node that others can use to find each other in your network and/or over the internet. The 197 clean way is to configure and run a dedicated bootnode: 198 199 ``` 200 $ bootnode --genkey=boot.key 201 $ bootnode --nodekey=boot.key 202 ``` 203 204 With the bootnode online, it will display an [`enode` URL](https://github.com/ethereum/wiki/wiki/enode-url-format) 205 that other nodes can use to connect to it and exchange peer information. Make sure to replace the 206 displayed IP address information (most probably `[::]`) with your externally accessible IP to get the 207 actual `enode` URL. 208 209 *Note: You could also use a full fledged gath node as a bootnode, but it's the less recommended way.* 210 211 #### Starting up your member nodes 212 213 With the bootnode operational and externally reachable (you can try `telnet <ip> <port>` to ensure 214 it's indeed reachable), start every subsequent gath node pointed to the bootnode for peer discovery 215 via the `--bootnodes` flag. It will probably also be desirable to keep the data directory of your 216 private network separated, so do also specify a custom `--datadir` flag. 217 218 ``` 219 $ gath --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above> 220 ``` 221 222 *Note: Since your network will be completely cut off from the main and test networks, you'll also 223 need to configure a miner to process transactions and create new blocks for you.* 224 225 ## Contribution 226 227 Thank you for considering to help out with the source code! We welcome contributions from 228 anyone on the internet, and are grateful for even the smallest of fixes! 229 230 If you'd like to contribute to go-atheios, please fork, fix, commit and send a pull request 231 for the maintainers to review and merge into the main code base. If you wish to submit more 232 complex changes though, please check up with the core devs first on [our Discord channel](https://discord.gg/HF6vEGF) 233 to ensure those changes are in line with the general philosophy of the project and/or get some 234 early feedback which can make both your efforts much lighter as well as our review and merge 235 procedures quick and simple. 236 237 Please make sure your contributions adhere to our coding guidelines: 238 239 * 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/)). 240 * Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. 241 * Pull requests need to be based on and opened against the `master` branch. 242 * Commit messages should be prefixed with the package(s) they modify. 243 * E.g. "eth, rpc: make trace configs optional" 244 245 Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide) 246 for more details on configuring your environment, managing project dependencies and testing procedures. 247 248 ## License 249 250 The go-atheios library (i.e. all code outside of the `cmd` directory) is licensed under the 251 [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also 252 included in our repository in the `COPYING.LESSER` file. 253 254 The go-atheios binaries (i.e. all code inside of the `cmd` directory) is licensed under the 255 [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included 256 in our repository in the `COPYING` file.