github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/README.md (about) 1 # go-u2u 2 3 Golang implementation of Unicorn Ultra Distributed Network followed by this [Whitepaper](https://uniultra.xyz/docs/UnicornUltraWhitepaper.pdf) based on various open-source and documentations: 4 - [Hashgraph](https://arxiv.org/pdf/1907.02900.pdf) 5 - [Hashgraph Sharding](https://www.mdpi.com/2076-3417/13/15/8726) 6 - [TEE Directed Acyclic Graph](https://www.mdpi.com/2079-9292/12/11/2393) 7 - [Lachesis](https://arxiv.org/abs/2108.01900) 8 - [Delegated Proof-of-Stake](https://www.mdpi.com/1099-4300/25/9/1320) 9 - [Proof-of-Elapsed-Time](https://ieeexplore.ieee.org/document/9472787) 10 - [Ethereum](https://github.com/ethereum/go-ethereum) 11 - [Hedera](https://github.com/hashgraph/hedera-services) 12 - [Opera](https://github.com/Fantom-foundation/go-opera) 13 - [Erigon](https://github.com/ledgerwatch/erigon) 14 15 ## Building the source 16 17 Building `u2u` requires both a Go (version 1.14 or later) and a C compiler. You can install 18 them using your favourite package manager. Once the dependencies are installed, run 19 20 ```shell 21 make u2u 22 ``` 23 The build output is ```build/u2u``` executable. 24 25 ## Running `u2u` 26 27 Going through all the possible command line flags is out of scope here, 28 but we've enumerated a few common parameter combos to get you up to speed quickly 29 on how you can run your own `u2u` instance. 30 31 ### Launching a network 32 33 Launching `u2u` readonly (non-validator) node for network specified by the genesis file: 34 35 ```shell 36 $ u2u --genesis file.g 37 ``` 38 39 ### Configuration 40 41 As an alternative to passing the numerous flags to the `u2u` binary, you can also pass a 42 configuration file via: 43 44 ```shell 45 $ u2u --config /path/to/your_config.toml 46 ``` 47 48 To get an idea how the file should look like you can use the `dumpconfig` subcommand to 49 export your existing configuration: 50 51 ```shell 52 $ u2u --your-favourite-flags dumpconfig 53 ``` 54 55 #### Validator 56 57 New validator private key may be created with `u2u validator new` command. 58 59 To launch a validator, you have to use `--validator.id` and `--validator.pubkey` flags to enable events emitter. 60 61 ```shell 62 $ u2u --nousb --validator.id YOUR_ID --validator.pubkey 0xYOUR_PUBKEY 63 ``` 64 65 `u2u` will prompt you for a password to decrypt your validator private key. Optionally, you can 66 specify password with a file using `--validator.password` flag. 67 68 #### Participation in discovery 69 70 Optionally you can specify your public IP to straighten connectivity of the network. 71 Ensure your TCP/UDP p2p port (5050 by default) isn't blocked by your firewall. 72 73 ```shell 74 $ u2u --nat extip:1.2.3.4 75 ``` 76 77 ## Dev 78 79 ### Running testnet 80 81 The network is specified only by its genesis file, so running a testnet node is equivalent to 82 using a testnet genesis file instead of a mainnet genesis file: 83 ```shell 84 $ u2u --genesis /path/to/testnet.g # launch node 85 ``` 86 87 It may be convenient to use a separate datadir for your testnet node to avoid collisions with other networks: 88 ```shell 89 $ u2u --genesis /path/to/testnet.g --datadir /path/to/datadir # launch node 90 $ u2u --datadir /path/to/datadir account new # create new account 91 $ u2u --datadir /path/to/datadir attach # attach to IPC 92 ``` 93 94 ### Testing 95 96 Client has extensive unit-testing. Use the Go tool to run tests: 97 ```shell 98 go test ./... 99 ``` 100 101 If everything goes well, it should output something along these lines: 102 ``` 103 ok github.com/unicornultrafoundation/go-u2u/app 0.033s 104 ? github.com/unicornultrafoundation/go-u2u/cmd/cmdtest [no test files] 105 ok github.com/unicornultrafoundation/go-u2u/cmd/u2u 13.890s 106 ? github.com/unicornultrafoundation/go-u2u/cmd/u2u/metrics [no test files] 107 ? github.com/unicornultrafoundation/go-u2u/cmd/u2u/tracing [no test files] 108 ? github.com/unicornultrafoundation/go-u2u/crypto [no test files] 109 ? github.com/unicornultrafoundation/go-u2u/debug [no test files] 110 ? github.com/unicornultrafoundation/go-u2u/ethapi [no test files] 111 ? github.com/unicornultrafoundation/go-u2u/eventcheck [no test files] 112 ? github.com/unicornultrafoundation/go-u2u/eventcheck/basiccheck [no test files] 113 ? github.com/unicornultrafoundation/go-u2u/eventcheck/gaspowercheck [no test files] 114 ? github.com/unicornultrafoundation/go-u2u/eventcheck/heavycheck [no test files] 115 ? github.com/unicornultrafoundation/go-u2u/eventcheck/parentscheck [no test files] 116 ok github.com/unicornultrafoundation/go-u2u/evmcore 6.322s 117 ? github.com/unicornultrafoundation/go-u2u/gossip [no test files] 118 ? github.com/unicornultrafoundation/go-u2u/gossip/emitter [no test files] 119 ok github.com/unicornultrafoundation/go-u2u/gossip/filters 1.250s 120 ? github.com/unicornultrafoundation/go-u2u/gossip/gasprice [no test files] 121 ? github.com/unicornultrafoundation/go-u2u/gossip/occuredtxs [no test files] 122 ? github.com/unicornultrafoundation/go-u2u/gossip/piecefunc [no test files] 123 ok github.com/unicornultrafoundation/go-u2u/integration 21.640s 124 ``` 125 126 Also it is tested with [fuzzing](./FUZZING.md). 127 128 129 ### Operating a private network (fakenet) 130 131 Fakenet is a private network optimized for your private testing. 132 It'll generate a genesis containing N validators with equal stakes. 133 To launch a validator in this network, all you need to do is specify a validator ID you're willing to launch. 134 135 Pay attention that validator's private keys are deterministically generated in this network, so you must use it only for private testing. 136 137 Maintaining your own private network is more involved as a lot of configurations taken for 138 granted in the official networks need to be manually set up. 139 140 To run the fakenet with just one validator (which will work practically as a PoA blockchain), use: 141 ```shell 142 $ u2u --fakenet 1/1 143 ``` 144 145 To run the fakenet with 5 validators, run the command for each validator: 146 ```shell 147 $ u2u --fakenet 1/5 # first node, use 2/5 for second node 148 ``` 149 150 If you have to launch a non-validator node in fakenet, use 0 as ID: 151 ```shell 152 $ u2u --fakenet 0/5 153 ``` 154 155 After that, you have to connect your nodes. Either connect them statically or specify a bootnode: 156 ```shell 157 $ u2u --fakenet 1/5 --bootnodes "enode://verylonghex@1.2.3.4:5050" 158 ``` 159 160 ### Running the demo 161 162 For the testing purposes, the full demo may be launched using: 163 ```shell 164 cd demo/ 165 ./start.sh # start the u2u processes 166 ./stop.sh # stop the demo 167 ./clean.sh # erase the chain data 168 ``` 169 Check README.md in the demo directory for more information.