├── Compile_Mainnet.md ├── LICENSE ├── README.md └── Rebuilding_Mainnet.md /Compile_Mainnet.md: -------------------------------------------------------------------------------- 1 | # Build a Mainnet node for Debian, Ubuntu, or MacOS 2 | 3 | *** 4 | ***As of late 2020 these directions are obsolete. 5 | Please refer to http://doc.tzalpha.net/introduction/howtoget.html#build-from-sources instead.*** 6 | *** 7 | 8 | ## Notice 9 | 10 | These directions are for a quick build of a mainnet server. Nothing is done here to harden the security of the server. Since the tezos code is complex and communicating with potentially malicious peers, consider that anything on the server could be exposed or exploited. 11 | 12 | This procedure is thoroughly tested on **Debian** 9.4. It is reported to work on **Ubuntu** 18.04 and 16.04 as well; look for special notes below though. It also works on **MacOS** 10.13.5 if you skip directly to the step for installing opam. 13 | 14 | These steps are reported to work on **Raspberry Pi** 3B and 3B+ running Ubuntu 18.04 as well. An external hard drive is required. 15 | 16 | ### Changelog 17 | 18 | + 2020-01-13: Make Opam installation directions more general, allowing for Opam 2.0.5 19 | + 2018-08-31: Added libhidapi-dev as a system package dependency. 20 | 21 | ## Steps 22 | 23 | Login to new Debian or Ubuntu system and update its base packages. (In the following, replace "192.155.xxx.xxx" with the actual IP address of your server). 24 | 25 | ``` 26 | ssh root@192.155.xxx.xxx 27 | apt-get update 28 | apt-get dist-upgrade -y 29 | ``` 30 | 31 | Create a user account for building and running tezos. The `tezos` is name is arbitrary; pick your favorite -- just don't build and run services as root. If you already have a user account you can use that instead. Note that the `make build-deps` step requires sudo rights when it first runs, to install some system packages via apt-get. 32 | 33 | ``` 34 | adduser tezos 35 | adduser tezos sudo 36 | reboot 37 | ssh tezos@192.155.xxx.xxx 38 | ``` 39 | 40 | If you are on **Ubuntu 16**, do this to be able to install bubblewrap and latest version of git. Everyone else, ignore this. 41 | 42 | ``` 43 | sudo add-apt-repository ppa:ansible/bubblewrap 44 | sudo add-apt-repository ppa:git-core/ppa 45 | sudo apt-get update 46 | ``` 47 | 48 | Similarly, if you are on **Debian 9**, do this to upgrade git to version 2.18.0. You need the debian "stretch-backports" source enabled to do this. If the following command fails, see the "Add backports to your sources.list" section at https://backports.debian.org/Instructions/ and follow the steps there; then try this again. 49 | 50 | ``` 51 | sudo apt-get -t stretch-backports install git 52 | ``` 53 | 54 | If you are on **Centos 7.5** some of the system package names are different. Use this instead of the `apt-get` just below: 55 | 56 | ``` 57 | sudo yum install epel-release 58 | sudo yum install bzip2 screen wget rsync gcc m4 make unzip patch libev-devel libev hidapi-devel gmp-devel bubblewrap git 59 | ``` 60 | 61 | If you are on **Arch Linux/Manjaro** the above applies with `pacman`: 62 | 63 | ``` 64 | sudo pacman -Syu 65 | sudo pacman -S patch unzip make gcc m4 git g++ aspcud bubblewrap curl bzip2 rsync libevdev gmp pkgconf hidapi 66 | ``` 67 | 68 | 69 | Install the system packages needed to start building tezos binaries. The actual build scripts will install more packages. 70 | 71 | ``` 72 | sudo apt-get install -y patch unzip make gcc m4 git g++ aspcud bubblewrap curl bzip2 rsync libev-dev libgmp-dev pkg-config libhidapi-dev 73 | ``` 74 | 75 | (If you're on **MacOS**, you can start here.) 76 | 77 | Install OPAM utility needed to build the OCaml code. Version 2.0.x of opam is required. 78 | See https://opam.ocaml.org/doc/Install.html for alternative installation steps. 79 | 80 | ### Opam installation: 81 | 82 | If asked, just accept the default of installing to /usr/local/bin. 83 | Installing there depends on the 'tezos' user having sudo rights as we arranged above. 84 | ``` 85 | sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version 2.0.5 86 | ``` 87 | 88 | ### Opam installation, alternative manual method for MacOS and other: 89 | 90 | Visit https://github.com/ocaml/opam/releases/. 91 | Find the newest stable 2.0.x release (2.0.5 works at the time of writing, January 2020) and download the binary executable for your architecture. 92 | Move that executable file to /usr/local/bin/opam and use `chmod a+x` to make it executable. 93 | 94 | ### Opam setup 95 | 96 | Now that opam is installed, initialize it. (Allow it to update .profile, etc, at your own discretion). 97 | 98 | ``` 99 | opam init --bare 100 | eval $(opam env) 101 | ``` 102 | 103 | If you are running in the **Windows 10 Linux Subsystem** you may need to add `--disable-sandboxing` to the call to `opam init` above. Otherwise you may be blocked by `brwap` errors as bubblewrap does not currently work in that environment. 104 | 105 | Note that the `make build-deps` step below builds a local opam environment within the build directory, so we no longer need to set up a switch as we did before. 106 | 107 | Get the mainnet source code. 108 | ``` 109 | git clone -b mainnet https://gitlab.com/tezos/tezos.git 110 | cd tezos 111 | ``` 112 | 113 | Install OCaml dependencies (and some system package dependencies too). An error message about "No repository tezos found" is normal when running this step for the first time; you can ignore that error. If you see an error like "Could not update repository "tezos": Commit found, but unreachable: enable uploadpack.allowReachableSHA1InWant on server" then you need to start over and install a newer version of git. See above about upgrading git in Ubuntu 16 and Debian 9. 114 | ``` 115 | make build-deps 116 | ``` 117 | 118 | Compile the binaries. Since the build-deps step above created an \_opam directory with an opam switch for tezos, update the environment again before compiling to be sure we've got the right opam configuration. 119 | ``` 120 | eval $(opam env) 121 | make 122 | ``` 123 | 124 | Configure the node identity. In the mainnet the "difficulty" used in generating the node identity must be at least 26. That is the default now in the `identity generate` command. 125 | 126 | ``` 127 | ./tezos-node identity generate 26. 128 | ``` 129 | 130 | Run the node. (I also like to run the node inside a `screen(1)` session (without `nohup` or `&`) so that the process persists in the foreground and I can detach and come back to it later in another ssh session.)\ 131 | 132 | ``` 133 | nohup ./tezos-node run --rpc-addr 127.0.0.1:8732 & 134 | ``` 135 | 136 | The node will take a while to sync, bringing in the blockchain data from the peers. To see its progress you can run the following command which shows the head block known so far and will exit when the node is fully synced: 137 | 138 | ``` 139 | ./tezos-client bootstrapped 140 | ``` 141 | 142 | Look for the `timestamp` value in the output from that. When that value gets to within a minute or so of the current date and time then your node is synced. The expected network/chain_id value is `NetXdQprcVkpaWU`. 143 | 144 | ### Faster bootstrap 145 | 146 | It's possible to start up your node with a copy of the chain data that is (typically) just a few days old. 147 | See the directions at https://tezosshots.com/. 148 | 149 | ## To activate a donation account 150 | 151 | ``` 152 | ./tezos-client add address my_account 153 | ./tezos-client activate fundraiser account my_account with 154 | ``` 155 | 156 | The `my_account` name/alias above is arbitrary, but conventional. 157 | 158 | Note: you can also import your private key info, but that is not necessary in order to claim the donation account: 159 | 160 | ``` 161 | ./tezos-client import fundraiser secret key my_account 162 | ``` 163 | 164 | Also: if your goal is only to activate your Tezos account and claim the tez from the fundraiser, it’s much easier to just use stephenandrews online utility at https://stephenandrews.github.io/activatez/ . 165 | 166 | ## Baking on Mainnet 167 | 168 | See [the Tezos baking howto](https://gist.github.com/dakk/bdf6efe42ae920acc660b20080a506dd) by @dakk. 169 | 170 | ## Workarounds when things won't build or run 171 | 172 | In the top code directory, ~/tezos, run `eval $(opam env)`. Then try again. 173 | 174 | After doing `eval $(opam env)`, do `opam update && opam upgrade`. Then try again. 175 | 176 | Sometimes it helps to remove the entire ~/.opam directory and start over again from the `opam init` step. Slow, but it gives a clean start for OPAM packages. Note that if you are building alphanet or other from the same user, this also wipes out the OPAM context for that work too. 177 | 178 | ``` 179 | rm -rf ~/.opam 180 | ``` 181 | 182 | The `make build-deps` step pins many packages to particular versions. If you want a clean start short of removing ~/.opam, you can remove all those pins: 183 | 184 | ``` 185 | opam pin list -s | xargs opam pin remove 186 | ``` 187 | 188 | If you get 0 connections, verify that your node identity was built with sufficient difficulty: 189 | 190 | ``` 191 | ./tezos-node identity check 192 | ``` 193 | 194 | ### Fix issue in macOS 195 | On macOS `make build-deps` sometimes fails since it cannot build OCaml compiler. You may get the following error 196 | ```bash 197 | <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 198 | [ocaml-base-compiler.4.08.1] found in cache 199 | 200 | <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 201 | [ERROR] The compilation of ocaml-base-compiler failed at 202 | "/Users/ameten/.opam/opam-init/hooks/sandbox.sh build ./configure 203 | --prefix=/Users/ameten/.opam/4.08.1 CC=cc ASPP=cc -c". 204 | ∗ installed base-bigarray.base 205 | ∗ installed base-threads.base 206 | ∗ installed base-unix.base 207 | 208 | #=== ERROR while compiling ocaml-base-compiler.4.08.1 =========================# 209 | # context 2.0.5 | macos/x86_64 | | https://opam.ocaml.org#b679cc38 210 | # path ~/.opam/4.08.1/.opam-switch/build/ocaml-base-compiler.4.08.1 211 | # command ~/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/Users/ameten/.opam/4.08.1 CC=cc ASPP=cc -c 212 | # exit-code 65 213 | # env-file ~/.opam/log/ocaml-base-compiler-5420-ffb3fd.env 214 | # output-file ~/.opam/log/ocaml-base-compiler-5420-ffb3fd.out 215 | ### output ### 216 | # /Users/ameten/.opam/opam-init/hooks/sandbox.sh: line 9: cd: /Users/ameten/.ccache: No such file or directory 217 | # sandbox-exec: empty subpath pattern 218 | 219 | 220 | 221 | <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 222 | ┌─ The following actions failed 223 | │ λ build ocaml-base-compiler 4.08.1 224 | └─ 225 | ┌─ The following changes have been performed (the rest was aborted) 226 | │ ∗ install base-bigarray base 227 | │ ∗ install base-threads base 228 | │ ∗ install base-unix base 229 | └─ 230 | # Run eval $(opam env) to update the current shell environment 231 | Switch initialisation failed: clean up? ('n' will leave the switch partially 232 | installed) [Y/n] Y 233 | ``` 234 | Sandbox executable complains that there is not place to store compiler cache. You don't have `/Users/username/.ccache` on your system. 235 | Install `ccache` using your favourite package manager. Command for Homebrew: 236 | ```bash 237 | brew install ccache 238 | ``` 239 | If `ccache` is installed, but you don't have `/Users/username/.ccache`, run the following command to create the directory: 240 | ```bash 241 | ccache -C 242 | ``` 243 | When you have `/Users/username/.ccache` you should be able to install OCaml compiler using `opam`. 244 | ```bash 245 | opam switch create 4.08.1 246 | ``` 247 | Once you have OCaml compiler in `opam`, you should be able to run `make build-deps` although it will install its own OCaml compiler. 248 | 249 | ## Rebuilding 250 | 251 | To rebuild with the latest Mainnet code you can move or remove the "tezos" directory and start again from the `git clone` step. As an alternative you can update in place as follows. 252 | 253 | ``` 254 | git fetch 255 | git reset --hard origin/mainnet 256 | git clean -dxf 257 | eval $(opam env) 258 | make build-deps 259 | make 260 | ``` 261 | 262 | Details here:https://github.com/Blindripper/FAQ/blob/patch-1/Rebuilding_Mainnet.md 263 | 264 | ## References 265 | 266 | Baking info: https://gist.github.com/dakk/bdf6efe42ae920acc660b20080a506dd 267 | 268 | Docker images: https://hub.docker.com/r/tezos/tezos/tags/ 269 | 270 | Docker script: https://gitlab.com/tezos/tezos/blob/mainnet/docs/introduction/howtoget.rst 271 | Copy to mainnet.sh and run as usual. 272 | 273 | Korean version : https://blog.naver.com/justmustone/221310459511 274 | 275 | Korean version : Raspberry Pi 3 https://blog.naver.com/justmustone/221310583691 276 | 277 | ## About 278 | Written by @fredcy with help from the [tech chat room](https://riot.im/app/#/room/#freenode_#tezos:matrix.org) and others. 279 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Tezos Community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Frequently Asked Questions 2 | 3 | This repo comprises a wiki with a Tezos FAQ. 4 | 5 | To view, click the [Wiki](https://github.com/tezoscommunity/faq/wiki) link above. 6 | Or proceed directly to the [Tezos Technical FAQ](https://github.com/tezoscommunity/faq/wiki/Tezos-Technical-FAQ). 7 | -------------------------------------------------------------------------------- /Rebuilding_Mainnet.md: -------------------------------------------------------------------------------- 1 | To upgrade a Tezos Mainnet server to newly released code it is possible to build from scratch as always. 2 | 3 | But to save time it is also possible to upgrade in place. Here is what I did: 4 | 5 | # Re-compiling Mainnet without a full rebuild 6 | 7 | Copy the entire Tezos build tree to a new place. That way we leave the current one around as a backup. 8 | Also, the currently running binaries are not disturbed. This assumes that `~/tezos` is the current build directory. 9 | You could ignore this and work right in the original build directory if you don't care about such a backup. 10 | 11 | ``` 12 | cd 13 | rsync -av tezos/ tezos2 14 | ``` 15 | 16 | Move to the new build directory where we'll do the rebuild. 17 | 18 | ``` 19 | cd tezos2 20 | eval $(opam env) 21 | ``` 22 | 23 | Clean up a bit, removing much of the code that we built before but leaving the opam info. 24 | 25 | ``` 26 | make clean 27 | git clean -f 28 | ``` 29 | 30 | Get the new code and build it. This assumes that we are on the 'mainnet' branch already. Do `git checkout mainnet` first if not. 31 | 32 | ``` 33 | git fetch 34 | git pull 35 | make 36 | ``` 37 | 38 | # Notes 39 | 40 | Several old binaries are gone: tezos-alpha-baker, tezos-alpha-endoser, and tezos-alpha-accuser. Each now has a pair of replacements, one for the first protocol and one for the new second protocol: tezos-accuser-001-PtCJ7pwo, tezos-baker-001-PtCJ7pwo, tezos-endorser-001-PtCJ7pwo, tezos-accuser-002-PsYLVpVv, tezos-baker-002-PsYLVpVv, tezos-endorser-002-PsYLVpVv. 41 | 42 | The new binaries make use of the same node and client state data as before, in ~/.tezos-node and ~/.tezos-client (by default). 43 | --------------------------------------------------------------------------------