github.com/core-coin/go-core/v2@v2.1.9/README.md (about) 1 ## Go Core 2 3 CORE protocol — Official Golang implementation. 4 5 The stable releases and the unstable master branch of the automated builds are both accessible in binary packages at [CORE website > downloads](https://coreblockchain.net/download). 6 7 ## Source Building 8 9 To build `gocore`, it is necessary to download a Go (version 1.14 or later) and C/C++ compiler. Any package manager is capable of installing these onto your device. Once installed, run 10 11 ### To build gocore on Linux or Mac 12 13 ```shell 14 make gocore 15 ``` 16 17 or, to build the full suite of utilities: 18 19 ```shell 20 make all 21 ``` 22 23 ### To build or run on Windows 24 25 **Note: It is important to note that gocore requires mingw to run and be built on Windows.** 26 27 To install mingw: 28 ```shell 29 choco install mingw 30 ``` 31 32 ## ICAN network prefixes 33 34 CORE Client implements ICAN-based addresses with the following formats: 35 36 Name | Prefix | Length | Format 37 --- | --- | --- | --- 38 Mainnet | CB | 44 | hh!kk!hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh! 39 Testnets | AB | 44 | hh!kk!hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh! 40 Privatenets | CE | 44 | hh!kk!hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh! 41 42 ## Executables 43 44 Bellow, find the wrappers and executables in the `cmd` directory that the go-core project entails. 45 46 Command | Description 47 --- | --- 48 gocore | The main Core CLI client that provides the network with a point of entrance (mainnet, testnet, or private net), running as a full node (default), archive node (that maintains all historical states), or a light node (live data recollection). Capable of being utilized by other processes as a gateway into the CORE network via JSON RPC endpoints exposed on top of HTTP, WebSocket, and/or IPC transports. To access command-line options, type `gocore --help`. 49 abigen | Generator of the source code capable of converting definitions of CORE contracts into user-friendly, compatible, and secure Go packages. Working with basic CORE contract ABIs, it offers enhanced features when accompanied by the contract bytecode. Additionally, it accommodates Ylem source files, simplifying the development process considerably. 50 bootnode | This streamlined rendition of our CORE client implementation solely engages in the network node discovery protocol, abstaining from executing any of the more advanced application protocols. It serves as a nimble bootstrap node, facilitating the discovery of peers within private networks. 51 cvm | An iteration tailored for developers, the CVM (CORE Virtual Machine) utility possesses the ability to execute bytecode snippets within a customizable environment and mode of execution, whose primary function is to enable precise, isolated debugging of CVM opcodes. 52 gocorerpctest | A developer utility tool designed to bolster our core/rpc-test test suite, ensuring adherence to the fundamental specifications outlined in the CORE JSON RPC standards. 53 rlpdump | A specialized developer tool that transforms binary RLP (Recursive Length Prefix) dumps — utilized by the CORE protocol in both network and consensus contexts — into a more intuitive, user-friendly hierarchical format. 54 55 ### Full node on the main CORE network 56 57 The prevalent scenario encountered involves individuals seeking basic interaction with the CORE network. This includes tasks such as setting up accounts, conducting fund transfers, and deploying or engaging with contracts. In this specific situation, there's no interest in delving into extensive historical data from years past. Therefore, a swift fast-sync to the present state of the network suffices. To initiate this process: 58 59 ```shell 60 $ gocore console 61 ``` 62 63 Executing this directive will: 64 * Initiate `gocore` in rapid synchronization mode (which is the default setting, but adjustable using the `--syncmode` parameter). This mode entails downloading more data in exchange for bypassing the processing of the complete historical record of the CORE network, a task demanding significant CPU resources. 65 * Launch gocore's integrated interactive JavaScript console (accessed via the appended `console` subcommand). Through this interface, you gain the ability to call upon all official `web3` methods as well as gocore's proprietary management APIs. It's worth noting that this tool is discretionary, and if omitted, you can always link it to a currently active gocore instance using the command `gocore attach`. 66 67 ### A Full node on the Devín network (PoW) 68 69 For developers delving into CORE contract development, it's advisable to initially explore the process without the involvement of actual currency. Familiarity with the system is key before committing real resources. Rather than connecting to the primary network, consider affiliating your node with the test network known as Devín. This environment mirrors the main network in functionality but operates exclusively with simulated play-Core funds. This approach provides a secure space for developers to experiment and refine their contract-building skills without any financial risk. By engaging with the Devín test network, you're working in an environment that faithfully replicates the main network's capabilities, using play-Core as your testing currency. This way, you can gain proficiency and confidence in CORE contract creation before venturing into live transactions. 70 71 ```shell 72 $ gocore --devin console 73 ``` 74 75 Equally significant within the Devín network, the `console` subcommand retains its identical significance as previously outlined. Should you have overlooked the explanations provided here, we encourage you to refer back to the preceding content for a comprehensive understanding. 76 77 Let’s describe the `--devin` flag while reconfiguring your gocore instance: 78 79 * When opting for gocore, it veers from the standard data directory path, residing a level deeper within a devin subdirectory (such as `~/core/devin` on Linux, as opposed to the default `~/core`). It's essential to bear in mind that on both OSX and Linux platforms, this configuration necessitates the specification of a custom endpoint when attaching to a running devin node. This deviation arises because the default behavior of `gocore attach` is to seek a connection with a production node endpoint. 80 * Furthermore, instead of interfacing with the primary Core network, the client seamlessly integrates with the test network. This transition entails a shift in P2P bootnodes, network IDs, and genesis states, ensuring a distinct environment tailored for testing and development purposes. 81 82 ### Configuration 83 84 Instead of burdening the `gocore` binary with an array of flags, there's an alternative approach. You can provide a configuration file using the following syntax: 85 86 ```shell 87 $ gocore --config /path/to/your_config.toml 88 ``` 89 90 For a visual reference on how the file's structure should be, consider using the `dumpconfig` subcommand. This enables you to export your current configuration effortlessly, even incorporating your preferred flags: 91 92 ```shell 93 $ gocore --your-favourite-flags dumpconfig 94 ``` 95 96 #### Docker quick start 97 98 Swiftly initiating Core on your system can be effortlessly achieved through Docker. Execute the following command: 99 100 ```shell 101 docker run -d --name core-node -v /Users/robocop/core-coin:/root \ 102 -p 8545:8545 -p 30300:30300 \ 103 core-coin/client-go 104 ``` 105 106 This command not only initiates gocore in fast-sync mode with a 1GB DB memory allocation, mirroring the earlier approach, but also establishes a lasting volume in your home directory for preserving your blockchain data. Furthermore, it facilitates the mapping of default ports. 107 108 It's crucial to remember to include `--rpcaddr 0.0.0.0` if you intend to access RPC from other containers or hosts. By default, gocore is bound to the local interface, restricting external accessibility to RPC endpoints. 109 110 ### Programmatically interfacing gocore nodes 111 112 For developers, transitioning from manual console interaction to programmatic interfacing with gocore nodes is a natural progression. To facilitate this shift, gocore offers built-in support for APIs based on JSON-RPC, as well as specific gocore APIs. These interfaces can be accessed through HTTP, WebSockets, and IPC. The IPC interface is activated by default, granting access to the complete range of gocore APIs. 113 114 On the other hand, the HTTP and WS interfaces require manual activation and provide a limited subset of APIs due to security considerations. These interfaces can be toggled on or off and customized to suit your requirements. 115 116 If you opt for HTTP-based JSON-RPC API, you have a variety of options to configure: 117 118 * `--rpc` Enables the HTTP-RPC server. 119 * `--rpcaddr` Specifies the interface on which the HTTP-RPC server listens (default: `localhost`). 120 * `--rpcport` Sets the port for the HTTP-RPC server (default: `8545`). 121 * `--rpcapi` Defines the APIs accessible via the HTTP-RPC interface (default: `xcb,net,web3`). 122 * `--rpccorsdomain` Designates a comma-separated list of domains from which cross-origin requests are accepted (subject to browser enforcement). 123 * `--ws` Activates the WS-RPC server. 124 * `--wsaddr` Specifies the interface for the WS-RPC server to listen on (default: `localhost`). 125 * `--wsport` Sets the port for the WS-RPC server (default: `8546`). 126 * `--wsapi` Specifies the APIs accessible through the WS-RPC interface (default: `xcb,net,web3`). 127 * `--wsorigins` Indicates origins from which websocket requests are accepted. 128 * `--ipcdisable` Disables the IPC-RPC server. 129 * `--ipcapi` Specifies the APIs accessible via the IPC-RPC interface (default: `admin,debug,xcb,miner,net,personal,txpool,web3`). 130 * `--ipcpath` Specifies the filename for the IPC socket/pipe within the datadir (explicit paths require escaping). 131 132 To establish connections via HTTP, WS, or IPC to a gocore node configured with these flags, you'll need to leverage the capabilities of your programming environment (libraries, tools, etc.) and communicate using JSON-RPC on all transports. 133 134 Importantly, you can reuse the same connection for multiple requests. It's crucial, however, to be mindful of the security implications of exposing an HTTP/WS-based transport, as there are active attempts by malicious actors to compromise CORE nodes with accessible APIs. 135 136 Additionally, be aware that all browser tabs have access to locally running web servers, potentially opening avenues for malicious web pages to exploit locally available APIs. 137 138 ### Private Network Operation 139 140 Establishing and managing your private network requires a more hands-on approach, as many configurations typically handled automatically in official networks must now be set up manually. 141 142 #### Defining the private genesis state 143 144 The initial step involves crafting the genesis state for your network, a crucial consensus point that all nodes must acknowledge and concur upon. This involves creating a concise JSON file (let's name it `genesis.json`): 145 146 ```json 147 { 148 "config": { 149 "networkId": "<arbitrary positive integer>" 150 }, 151 "alloc": {}, 152 "corebase": "ce450000000000000000000000000000000000000000", 153 "difficulty": "0x20000", 154 "extraData": "", 155 "energyLimit": "0x2fefd8", 156 "nonce": "0x0000000000000047", 157 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 158 "timestamp": "0x00" 159 } 160 ``` 161 162 While the provided fields suffice for most cases, it's advisable to alter the `nonce` to a random value to thwart potential connections from unknown remote nodes. If you wish to pre-fund specific accounts for streamlined testing, generate the accounts and populate the `alloc` field with their respective addresses: 163 164 ```json 165 { 166 "alloc": { 167 "ce180000000000000000000000000000000000000001": { 168 "balance": "111111111" 169 }, 170 "ce880000000000000000000000000000000000000002": { 171 "balance": "222222222" 172 } 173 } 174 } 175 ``` 176 177 After defining the genesis state in the provided JSON file, it's imperative to initialize every gocore node with this configuration before commencing operations to ensure all blockchain parameters are accurately configured: 178 179 ```shell 180 $ gocore init path/to/genesis.json 181 ``` 182 183 #### Setting Up the Meeting Point 184 185 After initializing all the nodes you intend to run with the desired genesis state, the next step is to launch a bootstrap node that others can utilize for discovering one another within your network or even over the internet. The preferred method is to configure and activate a dedicated bootnode: 186 187 ```shell 188 $ bootnode --genkey=boot.key 189 $ bootnode --nodekey=boot.key 190 ``` 191 192 With the bootnode now active, it will present an `enode` URL for other nodes to connect to and exchange peer details. Remember to substitute the IP address details displayed (most likely [::]) with your externally accessible IP to obtain the actual `enode` URL. 193 194 *Note: While you could potentially utilize a fully-fledged gocore node as a bootnode, it's considered the less recommended approach.* 195 196 #### Launching Your Member Nodes 197 198 With the bootnode up and externally reachable (you can verify its accessibility with `telnet <ip> <port>`), initiate each subsequent gocore node directed towards the bootnode for peer discovery through the `--bootnodes` flag. It's also advisable to keep the data directory of your private network distinct, so be sure to specify a custom `--datadir` flag. 199 200 ```shell 201 $ gocore --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above> 202 ``` 203 204 *Note: Since your network will be completely isolated from the main and test networks, you'll also need to configure a miner to process transactions and generate new blocks for you.* 205 206 #### Running a Private Miner 207 208 In a private network context, a single CPU miner instance suffices for practical purposes as it can generate a steady flow of blocks at the appropriate intervals without requiring substantial resources (consider running on a single thread, multiple threads are unnecessary). To initiate a gocore instance for mining, run it with your customary flags, extended by: 209 210 ```shell 211 $ gocore <usual-flags> --mine --miner.threads=1 --corebase=ce450000000000000000000000000000000000000000 212 ``` 213 214 This will commence mining blocks and transactions on a single CPU thread, attributing all earnings to the account specified by `--corebase`. Further adjustments to the mining process can be made by altering the default energy limit blocks converge to (`--targetenergylimit`) and the price at which transactions are accepted (`--energyprice`). 215 216 #### Initiating the Transaction 217 218 Here's a guide on how to execute a transaction using the go-core client. 219 220 - Launch the go-core Client 221 222 `./gocore --verbosity 2 --nat any console` 223 224 - Retrieve the Latest Transaction for Nonce [0x0] (0 for the first; 1 for the second; and so on) 225 (Note: Transactions with the same nonce but a higher fee may serve as replacements) 226 227 `web3.xcb.getTransactionCount("cb…")` 228 229 > Expected result: a number 230 231 - Compose the Transaction 232 233 (Note: web3.toOre(1) represents the value in Cores) 234 235 `var tx = {nonce: '0x0', energy: 21000, energyPrice: 1000000000, to : "cb…", value: web3.toOre(1), from: "cb…"}` 236 237 > Expected result: undefined 238 239 - Unlock the Account 240 241 `personal.unlockAccount("cb…")` 242 243 > Enter Passphrase or leave it blank. 244 > Expected result: true 245 246 - Sign the Transaction with the Private Key 247 248 `var txSigned = xcb.signTransaction(tx)` 249 250 > Expected result: undefined 251 252 - Obtain the Raw Transaction for future broadcasting 253 254 `txSigned.raw` 255 256 > Expected result: Raw transaction 257 258 - Broadcast the Transaction (while online) 259 260 `xcb.sendRawTransaction(txSigned.raw)` 261 262 ## Issue Labels 263 264 ### Priority 265 266 Label | Meaning (SLA) 267 --- | --- 268 P1 Urgent | The current release + potentially immediate hotfix 269 P2 High | The next release 270 P3 Medium | Within the next 3 releases 271 P4 Low | Anything outside the next 3 releases 272 273 ### Severity 274 275 Label | Impact 276 --- | --- 277 S1 Critical | Outage, broken feature with no workaround 278 S2 High | Broken feature, workaround too complex & unacceptable 279 S3 Moderate | Broken feature, workaround acceptable 280 S4 Low | Functionality inconvenience or cosmetic issue 281 S5 Note | Note about feature and/or code 282 283 ## Contribution 284 285 We greatly appreciate your interest in lending a hand to enhance the source code! We extend a warm welcome to contributions from individuals across the internet, and value even the tiniest of adjustments! 286 287 If you're inclined to make a contribution to go-core, kindly commence by forking the repository, effecting the necessary fixes, committing your changes, and subsequently dispatching a pull request. This allows our maintainers to scrutinize and integrate your alterations into the primary codebase. However, if you plan to propose more intricate modifications, we recommend reaching out to the core developers first via the [Core ◆ Talk](https://coretalk.space) forum. This step ensures that your proposed changes align with the overarching philosophy of the project, and also grants you the opportunity to receive early feedback. This can streamline both your efforts and our subsequent review and integration procedures. 288 289 We kindly request that your contributions align with our coding principles: 290 291 * Code should conform to the established [Go formatting](https://golang.org/doc/effective_go.html#formatting) standards, as outlined in the official Go guidelines (i.e. it should be formatted using [gofmt](https://golang.org/cmd/gofmt)). 292 * Code must be thoroughly documented, adhering to the official [Go commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. 293 * Pull requests should be established based on, and directed towards, the `master` branch. 294 * Commit messages ought to be prefixed with the package(s) they pertain to. 295 * For instance, "xcb, rpc: implement optional trace configurations." 296 297 ## Security Declaration 298 299 Please report suspected security vulnerabilities in private following the [Security manual](https://dev.coreblockchain.net/docs/bug). Do NOT create publicly viewable issues for suspected security vulnerabilities. For more information, please look into [Security recommendations](SECURITY.md). 300 301 ## License 302 303 Licensed under the [CORE License](LICENSE). 304 305 ## Community 306 307 [![Developer Portal](https://img.shields.io/badge/Developer-dev.coreblockchain.cc-46b549)](https://dev.coreblockchain.net/) 308 [![Core ◆ Talk](https://img.shields.io/badge/Core%20%E2%97%86%20Talk-Protocol%20and%20Client-green)](https://coretalk.space)