From cf365104313ed72d09c65767c5082aab712af1a9 Mon Sep 17 00:00:00 2001 From: Vincent Botbol Date: Mon, 18 Jun 2018 16:50:23 +0200 Subject: [PATCH] Docker: update docker configuration and fix wallet names --- scripts/alphanet.sh | 1 + scripts/ci/create_docker_image.minimal.sh | 3 +- scripts/docker/entrypoint.inc.sh | 35 ++++++++++--------- scripts/docker/entrypoint.sh | 4 ++- .../lib_delegate/client_baking_endorsement.ml | 2 +- .../lib_delegate/client_baking_forge.ml | 2 +- .../lib_delegate/client_baking_nonces.ml | 2 +- 7 files changed, 28 insertions(+), 21 deletions(-) diff --git a/scripts/alphanet.sh b/scripts/alphanet.sh index 326d55e31..e3694fd20 100755 --- a/scripts/alphanet.sh +++ b/scripts/alphanet.sh @@ -59,6 +59,7 @@ services: links: - node volumes: + - node_data:/var/run/tezos/node:ro - client_data:/var/run/tezos/client restart: on-failure diff --git a/scripts/ci/create_docker_image.minimal.sh b/scripts/ci/create_docker_image.minimal.sh index 3c9d5023b..6be330a7e 100755 --- a/scripts/ci/create_docker_image.minimal.sh +++ b/scripts/ci/create_docker_image.minimal.sh @@ -33,7 +33,8 @@ cp -a "$build_dir"/hidapi-$hidapi_version-r0.apk \ mkdir -p "$tmp_dir"/bin mkdir -p "$tmp_dir"/scripts container=$(docker create $build_image_name) -for bin in tezos-client tezos-admin-client tezos-node; do +for bin in tezos-client tezos-admin-client tezos-node \ + tezos-alpha-baker tezos-alpha-endorser tezos-alpha-accuser; do docker cp -L $container:/home/opam/tezos/$bin "$tmp_dir"/bin done cp -a "$script_dir"/docker/entrypoint.sh "$tmp_dir"/bin/ diff --git a/scripts/docker/entrypoint.inc.sh b/scripts/docker/entrypoint.inc.sh index ac7244fed..5f91b4ee2 100644 --- a/scripts/docker/entrypoint.inc.sh +++ b/scripts/docker/entrypoint.inc.sh @@ -43,18 +43,18 @@ wait_for_the_node_to_be_bootstraped() { launch_node() { - mkdir -p "$node_dir" + mkdir -p "$node_data_dir" - if [ ! -f "$node_dir/config.json" ]; then + if [ ! -f "$node_data_dir/config.json" ]; then echo "Configuring the node..." "$node" config init \ - --data-dir "$node_dir" \ + --data-dir "$node_data_dir" \ --rpc-addr ":$NODE_RPC_PORT" \ "$@" else echo "Updating the node configuration..." "$node" config update \ - --data-dir "$node_dir" \ + --data-dir "$node_data_dir" \ --rpc-addr ":$NODE_RPC_PORT" \ "$@" fi @@ -76,16 +76,15 @@ launch_node() { fi if [ "$local_data_version" != "$image_version" ]; then echo "Removing outdated chain data..." - if [ -f "$node_dir/identities.json" ]; then \ - mv "$node_dir/identities.json" /tmp + if [ -f "$node_data_dir/identities.json" ]; then \ + mv "$node_data_dir/identities.json" /tmp fi rm -rf "$node_dir"/* - rm -rf "$client_dir/blockss" - rm -rf "$client_dir/noncess" - rm -rf "$client_dir/endorsementss" - rm -rf "$client_dir/endorsed_levels" + rm -rf "$client_dir/baking" + rm -rf "$client_dir/nonces" + rm -rf "$client_dir/endorsements" if [ -f "/tmp/identities.json" ]; then \ - mv /tmp/identities.json "$node_dir/" + mv /tmp/identities.json "$node_data_dir/" fi cp "/usr/local/share/tezos/alphanet_version" \ "$node_dir/alphanet_version" @@ -94,28 +93,32 @@ launch_node() { # Generate a new identity if not present - if [ ! -f "$node_dir/identity.json" ]; then + if [ ! -f "$node_data_dir/identity.json" ]; then echo "Generating a new node identity..." "$node" identity generate 24. \ - --data-dir "$node_dir" + --data-dir "$node_data_dir" fi configure_client # Launching the node - exec "$node" run --data-dir "$node_dir" + exec "$node" run --data-dir "$node_data_dir" } launch_baker() { configure_client wait_for_the_node_to_be_bootstraped - exec "$client" launch daemon --baking "$@" + exec "$baker" --base-dir "$client_dir" \ + --addr "$NODE_HOST" --port "$NODE_RPC_PORT" \ + launch with context "$node_data_dir/context/" } launch_endorser() { configure_client wait_for_the_node_to_be_bootstraped - exec "$client" launch daemon --endorsement "$@" + exec "$endorser" --base-dir "$client_dir" \ + --addr "$NODE_HOST" --port "$NODE_RPC_PORT" \ + launch } diff --git a/scripts/docker/entrypoint.sh b/scripts/docker/entrypoint.sh index f17db5463..9d95d53b1 100755 --- a/scripts/docker/entrypoint.sh +++ b/scripts/docker/entrypoint.sh @@ -12,9 +12,12 @@ bin_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" node="/usr/local/bin/tezos-node" client="/usr/local/bin/tezos-client" admin_client="/usr/local/bin/tezos-admin-client" +baker="/usr/local/bin/tezos-alpha-baker" +endorser="/usr/local/bin/tezos-alpha-endorser" client_dir="$DATA_DIR/client" node_dir="$DATA_DIR/node" +node_data_dir="$node_dir/data" . "$bin_dir/entrypoint.inc.sh" @@ -49,4 +52,3 @@ Available commands: EOF ;; esac - diff --git a/src/proto_alpha/lib_delegate/client_baking_endorsement.ml b/src/proto_alpha/lib_delegate/client_baking_endorsement.ml index 7e9888198..89905992f 100644 --- a/src/proto_alpha/lib_delegate/client_baking_endorsement.ml +++ b/src/proto_alpha/lib_delegate/client_baking_endorsement.ml @@ -12,7 +12,7 @@ open Alpha_context include Logging.Make(struct let name = "client.endorsement" end) -module State = Daemon_state.Make(struct let name = "endorsements" end) +module State = Daemon_state.Make(struct let name = "endorsement" end) let get_signing_slots cctxt ?(chain = `Main) block delegate level = Alpha_services.Delegate.Endorsing_rights.get cctxt diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index ab3789b2b..2bb213ffc 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -348,7 +348,7 @@ let forge_block cctxt ?(chain = `Main) block (** Worker *) -module State = Daemon_state.Make(struct let name = "baking" end) +module State = Daemon_state.Make(struct let name = "block" end) let previously_baked_level cctxt pkh new_lvl = State.get cctxt pkh >>=? function diff --git a/src/proto_alpha/lib_delegate/client_baking_nonces.ml b/src/proto_alpha/lib_delegate/client_baking_nonces.ml index 10bcd829b..8d861d0ee 100644 --- a/src/proto_alpha/lib_delegate/client_baking_nonces.ml +++ b/src/proto_alpha/lib_delegate/client_baking_nonces.ml @@ -21,7 +21,7 @@ let encoding : t Data_encoding.t = (req "block" Block_hash.encoding) (req "nonce" Nonce.encoding)) -let name = "nonces" +let name = "nonce" let load (wallet : #Client_context.wallet) = wallet#load ~default:[] name encoding