...
 
Commits (4)
  • Romain's avatar
    Doc: multinetwork node · 41e5c806
    Romain authored
    41e5c806
  • Romain's avatar
    318c9f26
  • Daniel Grove's avatar
    Tooling, CI, Makefile: Dockerfiles and Make · 324e955c
    Daniel Grove authored
    The previous configuration of building with Docker used a lot of
    'magic' and required a fair bit of traversal between the shell scripts
    to understand what was happening and where. Most of it could be solved
    by using Docker Multi-staged Builds but to not constantly break the
    cache when just dealing with final artifacts I've split out the builder
    Dockerfile from the main Dockerfile. I've also broken out the commands
    run into individual make commands while trying to keep the original
    shell script API mostly intact.
    
    Running `./scripts/create_docker_image.sh` will work as it originally
    did just with the modifications necessary to align the script to also
    use the same underlying commands that are in make. I would have removed
    the script completely and adjusted the build pipelines, but the Makefile
    has an initial requirement of having `opam` installed which might not be
    the case for all users or the base build system.
    
    Othewise you can now just `make docker-image` but this will use the make
    bindings. It might be a good idea in the future to make your own Docker
    "building" image that can just use make within GitLabs CI system, but I
    think that was out of scope of this change.
    324e955c
  • Adrian Brink's avatar
    RPC Docs: Add 006 constant changes · a331cf31
    Adrian Brink authored
    a331cf31
ARG BASE_IMAGE
ARG BASE_IMAGE_VERSION
ARG BASE_IMAGE_VERSION_NON_MIN
ARG BUILD_IMAGE
ARG BUILD_IMAGE_VERSION
FROM ${BUILD_IMAGE}:${BUILD_IMAGE_VERSION} as builder
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION} as intermediate
# Pull in built binaries
COPY --chown=tezos:nogroup --from=builder /home/tezos/tezos/tezos-baker-* /home/tezos/bin/
COPY --chown=tezos:nogroup --from=builder /home/tezos/tezos/tezos-endorser-* /home/tezos/bin/
COPY --chown=tezos:nogroup --from=builder /home/tezos/tezos/tezos-accuser-* /home/tezos/bin/
COPY --chown=tezos:nogroup --from=builder /home/tezos/tezos/tezos-client /home/tezos/bin/
COPY --chown=tezos:nogroup --from=builder /home/tezos/tezos/tezos-admin-client /home/tezos/bin/
COPY --chown=tezos:nogroup --from=builder /home/tezos/tezos/tezos-node /home/tezos/bin/
COPY --chown=tezos:nogroup --from=builder /home/tezos/tezos/tezos-signer /home/tezos/bin/
# Add entrypoint scripts
COPY --chown=tezos:nogroup scripts/docker/entrypoint.* /home/tezos/bin/
# Add scripts
COPY --chown=tezos:nogroup scripts/alphanet_version scripts/alphanet.sh src/bin_client/bash-completion.sh active_protocol_versions /home/tezos/scripts/
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION} as debug
RUN sudo apk --no-cache add vim
ENV EDITOR=/usr/bin/vi
COPY --chown=tezos:nogroup --from=intermediate /home/tezos/bin/ /usr/local/bin/
COPY --chown=tezos:nogroup --from=intermediate /home/tezos/scripts/ /usr/local/share/tezos/
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION_NON_MIN} as stripper
COPY --chown=tezos:nogroup --from=intermediate /home/tezos/bin/tezos-* /home/tezos/bin/
RUN strip /home/tezos/bin/tezos*
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION} as bare
COPY --chown=tezos:nogroup --from=stripper /home/tezos/bin/ /usr/local/bin/
COPY --chown=tezos:nogroup --from=intermediate /home/tezos/scripts/ /usr/local/share/tezos
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION} as minimal
COPY --chown=tezos:nogroup --from=stripper /home/tezos/bin/ /usr/local/bin/
COPY --chown=tezos:nogroup --from=intermediate /home/tezos/scripts/ /usr/local/share/tezos
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
......@@ -7,6 +7,18 @@ active_protocol_directories := $(shell tr -- - _ < active_protocol_versions)
current_opam_version := $(shell opam --version)
include scripts/version.sh
DOCKER_IMAGE_NAME := tezos
DOCKER_IMAGE_VERSION := latest
DOCKER_BUILD_IMAGE_NAME := $(DOCKER_IMAGE_NAME)_build
DOCKER_BUILD_IMAGE_VERSION := latest
DOCKER_BARE_IMAGE_NAME := $(DOCKER_IMAGE_NAME)-bare
DOCKER_BARE_IMAGE_VERSION := latest
DOCKER_DEBUG_IMAGE_NAME := $(DOCKER_IMAGE_NAME)-debug
DOCKER_DEBUG_IMAGE_VERSION := latest
DOCKER_DEPS_IMAGE_NAME := registry.gitlab.com/tezos/opam-repository
DOCKER_DEPS_IMAGE_VERSION := ${opam_repository_tag}
DOCKER_DEPS_MINIMAL_IMAGE_VERSION := minimal--${opam_repository_tag}
ifeq ($(filter ${opam_version}.%,${current_opam_version}),)
$(error Unexpected opam version (found: ${current_opam_version}, expected: ${opam_version}.*))
endif
......@@ -122,9 +134,51 @@ build-deps:
build-dev-deps:
@./scripts/install_build_deps.sh --dev
.PHONY: docker-image-build
docker-image-build:
@docker build \
-t $(DOCKER_BUILD_IMAGE_NAME):$(DOCKER_BUILD_IMAGE_VERSION) \
-f build.Dockerfile \
--build-arg BASE_IMAGE=$(DOCKER_DEPS_IMAGE_NAME) \
--build-arg BASE_IMAGE_VERSION=$(DOCKER_DEPS_IMAGE_VERSION) \
.
.PHONY: docker-image-debug
docker-image-debug:
docker build \
-t $(DOCKER_DEBUG_IMAGE_NAME):$(DOCKER_DEBUG_IMAGE_VERSION) \
--build-arg BASE_IMAGE=$(DOCKER_DEPS_IMAGE_NAME) \
--build-arg BASE_IMAGE_VERSION=$(DOCKER_DEPS_MINIMAL_IMAGE_VERSION) \
--build-arg BUILD_IMAGE=$(DOCKER_BUILD_IMAGE_NAME) \
--build-arg BUILD_IMAGE_VERSION=$(DOCKER_BUILD_IMAGE_VERSION) \
--target=debug \
.
.PHONY: docker-image-bare
docker-image-bare:
@docker build \
-t $(DOCKER_BARE_IMAGE_NAME):$(DOCKER_BARE_IMAGE_VERSION) \
--build-arg=BASE_IMAGE=$(DOCKER_DEPS_IMAGE_NAME) \
--build-arg=BASE_IMAGE_VERSION=$(DOCKER_DEPS_MINIMAL_IMAGE_VERSION) \
--build-arg=BASE_IMAGE_VERSION_NON_MIN=$(DOCKER_DEPS_IMAGE_VERSION) \
--build-arg BUILD_IMAGE=$(DOCKER_BUILD_IMAGE_NAME) \
--build-arg BUILD_IMAGE_VERSION=$(DOCKER_BUILD_IMAGE_VERSION) \
--target=bare \
.
.PHONY: docker-image-minimal
docker-image-minimal:
@docker build \
-t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) \
--build-arg=BASE_IMAGE=$(DOCKER_DEPS_IMAGE_NAME) \
--build-arg=BASE_IMAGE_VERSION=$(DOCKER_DEPS_MINIMAL_IMAGE_VERSION) \
--build-arg=BASE_IMAGE_VERSION_NON_MIN=$(DOCKER_DEPS_IMAGE_VERSION) \
--build-arg BUILD_IMAGE=$(DOCKER_BUILD_IMAGE_NAME) \
--build-arg BUILD_IMAGE_VERSION=$(DOCKER_BUILD_IMAGE_VERSION) \
.
.PHONY: docker-image
docker-image:
@./scripts/create_docker_image.sh
docker-image: docker-image-build docker-image-debug docker-image-bare docker-image-minimal
.PHONY: install
install:
......
ARG BASE_IMAGE=registry.gitlab.com/tezos/opam-repository
ARG BASE_IMAGE_VERSION
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION}
WORKDIR /home/tezos
RUN mkdir -p /home/tezos/tezos/scripts
COPY --chown=tezos:nogroup Makefile tezos
COPY --chown=tezos:nogroup active_protocol_versions tezos
COPY --chown=tezos:nogroup scripts/version.sh tezos/scripts/
COPY --chown=tezos:nogroup src tezos/src
COPY --chown=tezos:nogroup vendors tezos/vendors
RUN opam exec -- make -C tezos all build-test
......@@ -116,6 +116,7 @@ in the :ref:`introduction <howtoget>`.
user/snapshots
user/various
user/glossary
user/multinetwork
.. toctree::
:maxdepth: 2
......
......@@ -39,7 +39,8 @@ The formula to calculate baking and endorsing rewards was improved
in order to provide more accurate results.
The formula was further modified in order to make it more resistant
to certain types of attacks.
to certain types of attacks. A full explanation can be found
`here <https://blog.nomadic-labs.com/a-new-reward-formula-for-carthage.html>`_.
Accounts
--------
......@@ -142,14 +143,32 @@ Annotations are enforced to only contain valid JSON.
Changes to RPCs
---------------
The RPC ``baking_rights`` is the only one affected, its behavior is
improved and compatible with the old one.
In Babylon the argument ``max_priority`` causes the RPC to return the
rights up to ``max_priority`` excluded, for example setting
Below you can find all the RPC changes.
Baking_rights
~~~~~~~~~~~~~
In Babylon the argument ``max_priority`` causes the RPC to return
the rights up to ``max_priority`` excluded, for example setting
``max_priority=0`` returns the empty list.
In Carthage the value of ``max_priority`` is included, for example
``max_priority=0`` returns the rights of priority zero.
Block_reward
~~~~~~~~~~~~
This constant is accessed by calling ``/chains/main/blocks/head/constants``,
which returns a JSON object where the field ``block_reward`` was renamed to
``baking_reward_per_endorsement`` and its value was changed from a single
value to a list of values.
Endorsement_reward
~~~~~~~~~~~~~~~~~~
This constant is accessed by calling ``/chains/main/blocks/head/constants``,
which returns a JSON object where the value of the field ``endorsement_reward``
was changed from a single value to a list of values.
Changes to the binary format of operations
------------------------------------------
......
Multinetwork Node
=================
Tezos is run on several networks, such as Mainnet (the main network)
and various :ref:`Test Networks<test-networks>`. Some users may also want to run
their own networks for various reasons. Networks differ in various ways:
- they start from their own genesis block;
- they have different names so that nodes know not to talk to other networks;
- they may run (or have run) different protocols;
- protocols may run with different constants (for instance, test networks move faster);
- they have different bootstrap peers (nodes that new nodes connect to initially);
- they may have had user-activated upgrades or user-activated protocol overrides
to change the protocol without going through the voting process.
The current ``master`` branch is capable of connecting to multiple networks,
including Mainnet and the test networks Zeronet, Babylonnet and Carthagenet. By contrast,
the ``mainnet`` branch is only capable of connecting to Mainnet,
the ``babylonnet`` branch is only capable of connecting to Babylonnet,
and so on. The goal is to remove the need for such branches.
Currently, the multinetwork node has not been released, but we hope that
the next major Mainnet release is nothing but a tag on ``master``, or maybe
a very small branch.
By default, the multinetwork node connects to Mainnet.
To connect to other networks, you can either
`Select Network From Command-Line`_ or `Set Network in Configuration File`_.
You can also configure the node to connect to `Custom Networks`_.
Select Network From Command-Line
--------------------------------
The simplest way to select the network to connect to is to use the new ``--network``
option. For instance, to run Babylonnet::
tezos-node run --data-dir ~/tezos-babylonnet --network babylonnet
The ``--data-dir`` option is not mandatory, but it is a good idea to prevent
accidentally running, say, a Mainnet data directory with the Babylonnet network.
Note that this ``--network`` option must be given everytime you restart your node.
It also must be given with the ``snapshot export`` and ``snapshot import`` commands.
One way to avoid this is to `Set Network in Configuration File`_.
The ``--network`` option can be used with the following built-in networks:
- ``mainnet`` (this is the default)
- ``sandbox``
- ``zeronet``
- ``alphanet`` (deprecated)
- ``babylonnet``
- ``carthagenet``
Set Network in Configuration File
---------------------------------
Instead of using ``--network`` you can set the network in the configuration file.
Here is an example configuration file to run Carthagenet::
{
"p2p": {},
"network": "Carthagenet"
}
You can specify any built-in network from the list in `Select Network From Command-Line`_,
but its name must be capitalized.
(The ``p2p`` field is unrelated, but it is mandatory, although it can be empty.)
To use this configuration file, run the node with ``--config-file FILENAME``
where ``FILENAME`` is the name of this file. Alternatively, put the file in your
data directory with the name ``config.json``. By default, this is
``~/.tezos-node/config.json``.
Custom Networks
---------------
If the network you want to connect to is not in the list of built-in networks,
you can configure a custom network in the configuration file.
Here is an example configuration file for Mainnet::
{
"p2p": {},
"network": {
"genesis": {
"timestamp": "2018-06-30T16:07:32Z",
"block": "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2",
"protocol": "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"
},
"chain_name": "TEZOS_MAINNET",
"old_chain_name": "TEZOS_BETANET_2018-06-30T16:07:32Z",
"incompatible_chain_name": "INCOMPATIBLE",
"sandboxed_chain_name": "SANDBOXED_TEZOS_MAINNET",
"user_activated_upgrades": [
{
"level": 28082,
"replacement_protocol": "PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt"
},
{
"level": 204761,
"replacement_protocol": "PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP"
}
],
"user_activated_protocol_overrides": [
{
"replaced_protocol": "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",
"replacement_protocol": "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS"
}
],
"default_bootstrap_peers": [ "boot.tzbeta.net" ]
}
}
This is equivalent to using ``--network Mainnet``, or ``"network": "Mainnet"`` in the
configuration file (or to doing nothing, as Mainnet is the default).
- ``genesis`` is the description of the genesis block, i.e. the first block of the chain.
Inspect the genesis block using ``tezos-client rpc get /chains/main/blocks/0``
to find these values.
- ``chain_name`` is the name of the network (nodes only talk to other nodes which use
the same network name).
- ``old_chain_name`` is usually the same as ``chain_name``, except for networks
which were renamed.
- ``incompatible_chain_name`` is a name which must be different than ``chain_name``
and ``old_chain_name``. It is thus ensured to be incompatible. It is used for testing
purposes.
- ``sandboxed_chain_name`` is the name of the network in sandbox mode. It can be the same
as ``chain_name`` but it is safer to pick a different name.
- ``user_activated_upgrades`` is the list of past user-activated upgrades.
Each item has a field ``level``, which is the level at which the protocol must
be changed, and a field ``replacement_protocol``, which is the hash of the protocol
to switch to.
- ``user_activated_protocol_overrides`` is the list of past user-activated protocol
overrides. Each item has a field ``replaced_protocol`` and a field ``replacement_protocol``.
Both are protocol hashes. If ``replaced_protocol`` is to be activated using on-chain
voting, ``replacement_protocol`` is activated instead.
- ``default_bootstrap_peers`` is the list of addresses of default bootstrap peers.
They are only used if ``p2p.bootstrap_peers`` is not present in the configuration file,
and ``--no-bootstrap-peers`` is not given on the command-line.
Development
-----------
The list of built-in networks is in ``src/bin_node/node_config_file.ml``.
Edit the ``builtin_blockchain_networks_with_tags`` variable in this file to
add or remove built-in networks.
To be able to connect to multiple networks without having to download the protocols,
and to provide all the relevant baker / endorser / accuser binaries, all current and
past protocols are compiled and linked. This means that if you patch the client commands
for a protocol, you should patch the other protocols as well (at least the ones which
are still in use).
......@@ -9,38 +9,23 @@ cd "$src_dir"
. "$script_dir"/version.sh
tmp_dir=$(mktemp -dt tezos.opam.tezos.XXXXXXXX)
cleanup () {
set +e
echo Cleaning up...
rm -rf "$tmp_dir"
rm -rf Dockerfile
}
trap cleanup EXIT INT
image_name="${1:-tezos_build}"
image_version="${2:-latest}"
base_image="${3-${image_name}_deps:${image_version}}"
mkdir -p "$tmp_dir"/tezos/scripts
cp -a Makefile "$tmp_dir"/tezos
cp -a active_protocol_versions "$tmp_dir"/tezos
cp -a scripts/version.sh "$tmp_dir"/tezos/scripts/
cp -a src "$tmp_dir"/tezos
cp -a vendors "$tmp_dir"/tezos
cat <<EOF > "$tmp_dir"/Dockerfile
FROM $base_image
COPY --chown=tezos:nogroup tezos tezos
RUN opam exec -- make -C tezos all build-test
EOF
base_image="${3-${image_name}_deps}"
base_image_version="${4:-latest}"
echo
echo "### Building tezos..."
echo
docker build -t "$image_name:$image_version" "$tmp_dir"
docker build \
-t "$image_name:$image_version" \
-f build.Dockerfile \
--build-arg="BASE_IMAGE=$base_image" \
--build-arg="BASE_IMAGE_VERSION=${base_image_version}" \
--build-arg="BASE_IMAGE_VERSION=${base_image_version}" \
--build-arg="BUILD_IMAGE_VERSION=${base_image_version}" \
"$src_dir"
echo
echo "### Successfully build docker image: $image_name:$image_version"
......
#! /bin/sh
set -e
set -ex
ci_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
script_dir="$(dirname "$ci_dir")"
......@@ -9,85 +9,54 @@ cd "$src_dir"
. "$script_dir"/version.sh
tmp_dir=$(mktemp -dt tezos.opam.tezos.XXXXXXXX)
image_name="${1:-tezos}"
image_version="${2:-latest}"
build_image="${3:-registry.gitlab.com/tezos/opam-repository:${opam_repository_tag}}"
base_image="${4-registry.gitlab.com/tezos/opam-repository:minimal--${opam_repository_tag}}"
cleanup () {
set +e
echo Cleaning up...
rm -rf "$tmp_dir"
if ! [ -z "$container" ]; then docker rm $container; fi
}
trap cleanup EXIT INT
mkdir -p "$tmp_dir"/bin
mkdir -p "$tmp_dir"/scripts
container=$(docker create $build_image)
versioned_daemons="$(sed "s/^\(.*\)$/tezos-baker-\1 tezos-endorser-\1 tezos-accuser-\1/g" "active_protocol_versions")"
for bin in tezos-client tezos-admin-client tezos-node $versioned_daemons tezos-signer; do
docker cp -L $container:/home/tezos/tezos/$bin "$tmp_dir"/bin
done
cp -a "$script_dir"/docker/entrypoint.sh "$tmp_dir"/bin/
cp -a "$script_dir"/docker/entrypoint.inc.sh "$tmp_dir"/bin/
cp "$script_dir"/alphanet.sh "$tmp_dir"/scripts/
cp "$script_dir"/alphanet_version "$tmp_dir"/scripts/
cp "$src_dir"/src/bin_client/bash-completion.sh "$tmp_dir"/scripts/
cp "$src_dir"/active_protocol_versions "$tmp_dir"/scripts/
build_image="${3:-registry.gitlab.com/tezos/opam-repository}"
base_image="${4-registry.gitlab.com/tezos/opam-repository}"
base_version="${5-minimal--${opam_repository_tag}}"
echo
echo "### Building minimal docker images..."
echo
cat > "$tmp_dir"/Dockerfile <<EOF
FROM $base_image
RUN sudo apk --no-cache add vim
ENV EDITOR=/usr/bin/vi
COPY bin/* /usr/local/bin/
COPY scripts/* /usr/local/share/tezos/
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
EOF
docker build -t "$image_name-debug:$image_version" "$tmp_dir"
docker build \
-t "$image_name-debug:$image_version" \
--build-arg "BASE_IMAGE=$base_image" \
--build-arg "BASE_IMAGE_VERSION=$base_version" \
--build-arg "BASE_IMAGE_VERSION_NON_MIN=$opam_repository_tag" \
--build-arg="BUILD_IMAGE=${build_image}" \
--build-arg="BUILD_IMAGE_VERSION=${image_version}" \
--target=debug \
"$src_dir"
echo
echo "### Successfully build docker image: $image_name-debug:$image_version"
echo
echo "Stripping tezos binaries from debugging symbols"
strip "$tmp_dir"/bin/tezos*
cat > "$tmp_dir"/Dockerfile <<EOF
FROM $base_image
COPY bin/* /usr/local/bin/
COPY scripts/* /usr/local/share/tezos/
docker build \
-t "$image_name-bare:$image_version" \
--build-arg "BASE_IMAGE=$base_image" \
--build-arg "BASE_IMAGE_VERSION=$base_version" \
--build-arg="BUILD_IMAGE=${build_image}" \
--build-arg="BUILD_IMAGE_VERSION=${image_version}" \
--build-arg "BASE_IMAGE_VERSION_NON_MIN=$opam_repository_tag" \
--target=bare \
"$src_dir"
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
EOF
docker build -t "$image_name:$image_version" "$tmp_dir"
echo
echo "### Successfully build docker image: $image_name:$image_version"
echo "### Successfully build docker image: $image_name-bare:$image_version"
echo
cat > "$tmp_dir"/Dockerfile <<EOF
FROM $base_image
COPY bin/* /usr/local/bin/
COPY scripts/* /usr/local/share/tezos/
EOF
docker build -t "$image_name-bare:$image_version" "$tmp_dir"
docker build \
-t "$image_name:$image_version" \
--build-arg "BASE_IMAGE=$base_image" \
--build-arg "BASE_IMAGE_VERSION=$base_version" \
--build-arg="BUILD_IMAGE=${build_image}" \
--build-arg="BUILD_IMAGE_VERSION=${image_version}" \
--build-arg "BASE_IMAGE_VERSION_NON_MIN=$opam_repository_tag" \
"$src_dir"
echo
echo "### Successfully build docker image: $image_name-bare:$image_version"
echo "### Successfully build docker image: $image_name:$image_version"
echo
......@@ -17,9 +17,9 @@ build_image_name="${image_name}_build"
"$script_dir"/ci/create_docker_image.build.sh \
"$build_image_name" "$image_version" \
"$build_deps_image_name:$build_deps_image_version"
"$build_deps_image_name" "$build_deps_image_version"
"$script_dir"/ci/create_docker_image.minimal.sh \
"$image_name" "$image_version" \
"$build_image_name:$image_version" \
"$build_deps_image_name:minimal--$build_deps_image_version"
"$build_image_name" \
"$build_deps_image_name" "minimal--$build_deps_image_version"