-
Notifications
You must be signed in to change notification settings - Fork 27
Build a zeronet node on Debian 9
[If you want to build for Betanet, you can skip this and go to Build a Betanet node on Debian 9.]
These directions are for a quick build of a development and testing server, ideally on a throw-away VPS or the like. 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.
Login to new Debian 9 system and update its base packages.
ssh root@192.155.xxx.xxx
apt-get update
apt-get upgrade -y
Create a user account for building and running tezos.
adduser tezos
adduser tezos sudo
su - tezos
Install debian packages needed to start building tezos binaries. The actual build scripts will install more packages.
(Note: bubblewrap
is a recent addition to the list of packages.)
sudo apt-get install -y patch unzip make gcc m4 git g++ aspcud bubblewrap
(If you're on a Mac, you can start here.)
Install OPAM utility needed to build the OCaml code. As of 2018-06-26, version 2.0.0~rc3 of opam is required. See https://opam.ocaml.org/blog/opam-2-0-0-rc3/ for alternative installation steps.
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
wget https://github.com/ocaml/opam/releases/download/2.0.0-rc3/opam-2.0.0-rc3-x86_64-linux
sudo mv opam-2.0.0-rc3-x86_64-linux /usr/local/bin/opam
sudo chmod a+x /usr/local/bin/opam
Now that opam is installed, initialize it. When the following runs, allow it to update your .profile and, if asked, also allow to "add a hook to opam's init scripts". The init step will take quite a while to complete.
opam init
eval $(opam env)
(As of 2018-06-26, 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.)
Get the zeronet source code.
git clone -b zeronet https://gitlab.com/tezos/tezos.git
cd tezos
Install OCaml dependencies (and some system package dependencies too). If prompted about installing the depext
package, agree. If this fails, see the Workaround section below.
make build-deps
Compile the binaries.
make
Configure the node identity.
[2018-07-02: In the betanet the "difficulty" used in generating the node identity must be at least 26. That is default now in the identity generate
command.]
./tezos-node identity generate
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.)
[2018-07-02: Updated rpc address to allow for local access only.]
nohup ./tezos-node run --rpc-addr 127.0.0.1:8732 --connections 10 &
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:
./tezos-client rpc get /chains/main/blocks/head
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.
See http://doc.tzalpha.net/introduction/zeronet.html. Visit https://faucet.tzalpha.net/ and download a tzXXXX.json file (for some long XXXX
hash). Send that file to the tezos server. Create an identity from it:
./tezos-client activate account my_account1 with ~/tzXXXX.json
This creates an identity account with a balance. It can delegate to itself, but cannot delegate elsewhere. We'll make this the baking identity.
./tezos-client register key my_account1 as delegate
Download again from the faucet site, this time getting tzYYYY.json. Create a new account from that
./tezos-client activate account my_account2 with ~/tzYYYY.json
Accounts created this way via activate account
have an "implicit contract" [?] and cannot delegate elsewhere. So we need to create yet another account, transfer the my_account2 funds to it, and then delegate from that third account to our baking identity.
./tezos-client originate account my_account3 for my_account2 transferring $balance from my_account2 --fee 0 --delegate my_account1 --delegatable
If the make build-deps
step refuses to complete without error, sometimes it works to install the packages manually.
opam install astring base biniou cmdliner cohttp cohttp-lwt cohttp-lwt-unix conduit conduit-lwt conduit-lwt-unix cppo_ocamlbuild cpuid cstruct cstruct-lwt ezjsonm fieldslib fmt hex ipaddr irmin js_of_ocaml js_of_ocaml-compiler jsonm logs lwt mtime nocrypto ocaml-migrate-parsetree ocb-stubblr ocp-ocamlres ocplib-endian ocplib-json-typed ppx_ast ppx_core ppx_deriving ppx_driver ppx_fields_conv ppx_metaquot ppx_optcomp ppx_sexp_conv ppx_tools_versioned ppx_type_conv stdio topkg uri uutf yojson base64 cppo easy-format magic-mime ocaml-compiler-libs ppx_derivers ppx_traverse_builtins re result sexplib stringext
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.
rm -rf ~/.opam
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:
opam pin list -s | xargs opam pin remove
If you encounter an error about the opam depext plugin not being installed, you can install it manually and try again:
opam install depext
To rebuild with the latest zeronet 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.
git fetch
git reset --hard origin/zeronet
git clean -dxf
make build-deps
make