diff --git a/buildkite/scripts/docker-artifact.sh b/buildkite/scripts/docker-artifact.sh index 884463e4504..f410b734beb 100755 --- a/buildkite/scripts/docker-artifact.sh +++ b/buildkite/scripts/docker-artifact.sh @@ -17,9 +17,9 @@ if [[ -n $CODA_BUILD_ROSETTA ]]; then # Could also cache-from opam-deps but we would need to get that automatically building nightly or at least when src/opam.export changes # build-deps is updated by manually running scripts/build-rosetta-stages.sh which always builds + pushes each stage scripts/release-docker.sh --service "coda-rosetta" --version "dev-${CODA_VERSION}"\ - --extra-args "--build-arg DUNE_PROFILE=dev --build-arg CODA_BRANCH=${CODA_GIT_BRANCH} --cache-from gcr.io/o1labs-192920/coda-rosetta-opam-deps:develop" + --extra-args "--build-arg DUNE_PROFILE=dev --build-arg MINA_BRANCH=${CODA_GIT_BRANCH} --cache-from gcr.io/o1labs-192920/mina-rosetta-opam-deps:develop" # Also build with the standard DUNE_PROFILE, and use the dev profile as a cache. # This means it will use the opam-deps stage from the previous step, but make a new builder stage because the DUNE_PROFILE arg changed scripts/release-docker.sh --service "coda-rosetta" --version "${CODA_VERSION}"\ - --extra-args "--build-arg CODA_BRANCH=${CODA_GIT_BRANCH} --cache-from gcr.io/o1labs-192920/coda-rosetta-opam-deps:develop" + --extra-args "--build-arg MINA_BRANCH=${CODA_GIT_BRANCH} --cache-from gcr.io/o1labs-192920/mina-rosetta-opam-deps:develop" fi diff --git a/dockerfiles/Dockerfile-rosetta b/dockerfiles/Dockerfile-rosetta index d9f5d8750dd..5a342218f10 100644 --- a/dockerfiles/Dockerfile-rosetta +++ b/dockerfiles/Dockerfile-rosetta @@ -139,24 +139,24 @@ RUN git clone \ ################################################################################################# # The "opam-deps" Stage # - Continues from the build-deps image -# - Installs all opam dependencies and pins from coda's github -# - Includes the entire coda codebase and submodules in "${CODA_DIR}" (must be writable by opam user) +# - Installs all opam dependencies and pins from mina's github +# - Includes the entire mina codebase and submodules in "${MINA_DIR}" (must be writable by opam user) # - Largely mirrors/replaces ./scripts/setup-opam.sh ################################################################################################# FROM build-deps AS opam-deps # location of repo used for pins and external package commits -ARG CODA_DIR=coda +ARG MINA_DIR=mina # branch to checkout on first clone (this will be the only availible branch in the container) # can also be a tagged release # TODO: change this to two distinct variables, one for opam/dependency clone -# and a distinct one for the coda codebase in the next stage +# and a distinct one for the mina codebase in the next stage ARG OPAM_BRANCH=develop # location of external packages -ARG EXTERNAL_PKG_DIR=$CODA_DIR/src/external +ARG EXTERNAL_PKG_DIR=$MINA_DIR/src/external -# don't keep sources, to force reinstall of pinned packages from Coda sources +# don't keep sources, to force reinstall of pinned packages from Mina sources # and to keep Docker image reasonable size ENV OPAMKEEPBUILDDIR false ENV OPAMREUSEBUILDDIR false @@ -167,9 +167,9 @@ RUN git clone \ --depth 1 \ --shallow-submodules \ --recurse-submodules \ - https://github.com/MinaProtocol/mina ${HOME}/${CODA_DIR} + https://github.com/MinaProtocol/mina ${HOME}/${MINA_DIR} -WORKDIR $HOME/$CODA_DIR +WORKDIR $HOME/$MINA_DIR ENV OPAMYES 1 # TODO: handle this opam work without cloning the full repository (directly pull src/opam.export) @@ -207,7 +207,7 @@ RUN eval $(opam config env) \ ################################################################################################# # The "builder" Stage -# - builds coda and any other binaries required to run a node +# - builds mina and any other binaries required to run a node # - should not include any data related to joining a specific network, only the node software itself ################################################################################################# FROM opam-deps AS builder @@ -218,24 +218,24 @@ ARG DUNE_PROFILE=testnet_postake_medium_curves # branch to checkout on first clone (this will be the only availible branch in the container) # can also be a tagged release # TODO: change this to two distinct variables, one for opam/dependency clone -# and a distinct one for the coda codebase in the next stage -ARG CODA_BRANCH=develop +# and a distinct one for the mina codebase in the next stage +ARG MINA_BRANCH=develop # location of repo used for pins and external package commits -ARG CODA_DIR=coda +ARG MINA_DIR=mina ENV PATH "$PATH:/usr/lib/go/bin:$HOME/.cargo/bin" # git will clone into an empty dir, but this also helps us set the workdir in advance -RUN cd $HOME && rm -rf $HOME/${CODA_DIR} \ +RUN cd $HOME && rm -rf $HOME/${MINA_DIR} \ && git clone \ - -b "${CODA_BRANCH}" \ + -b "${MINA_BRANCH}" \ --depth 1 \ --shallow-submodules \ --recurse-submodules \ - https://github.com/MinaProtocol/mina ${HOME}/${CODA_DIR} + https://github.com/MinaProtocol/mina ${HOME}/${MINA_DIR} -WORKDIR $HOME/${CODA_DIR} +WORKDIR $HOME/${MINA_DIR} # Build libp2p_helper and clear go module caches # Could maybe also delete go during this step / build it as part of the deps stage? @@ -265,7 +265,7 @@ RUN eval $(opam config env) \ && mv _build/default/src/app $HOME/app \ && rm -rf _build -# TODO: consider making a coda-rosetta package with the minimum coda binaries/configs for rosetta. +# TODO: consider making a mina-rosetta package with the minimum mina binaries/configs for rosetta. # Right now make deb is overkill #RUN eval $(opam config env) && make deb @@ -276,8 +276,8 @@ RUN eval $(opam config env) \ FROM debian:buster-slim AS production ARG POSTGRES_DATA_DIR=/data/postgresql -ARG CODA_DAEMON_PORT=10101 -ARG CODA_CONFIG_DIR=/root/.coda-config +ARG MINA_DAEMON_PORT=10101 +ARG MINA_CONFIG_DIR=/root/.mina-config # Sample public key for use in dev profile / demo mode genesis block ARG PK=B62qrPN5Y5yq8kGE3FbVKbGTdTAJNdtNtB5sNVpxyRwWGcDEhpMzc8g @@ -303,30 +303,30 @@ RUN apt-get -y update \ # Make all directories for configuration and empty s3 cache dirs RUN mkdir -p /tmp/s3_cache_dir \ - && mkdir -p /tmp/coda_cache_dir \ + && mkdir -p /tmp/mina_cache_dir \ && mkdir -p ${POSTGRES_DATA_DIR} \ && chown postgres ${POSTGRES_DATA_DIR} -COPY --from=builder /home/opam/app/* /coda-bin/ -COPY --from=builder /home/opam/coda/src/app /app -COPY --from=builder /home/opam/coda/src/app/rosetta/config.json /data/config.json +COPY --from=builder /home/opam/app/* /mina-bin/ +COPY --from=builder /home/opam/mina/src/app /app +COPY --from=builder /home/opam/mina/src/app/rosetta/config.json /data/config.json # all s3-cached files will be downloaded as needed at runtime # Uncomment these to optimize start up time at the expense of image size # COPY --from=builder /tmp/s3_cache_dir /tmp/s3_cache_dir -# COPY --from=builder /tmp/coda_cache_dir /tmp/coda_cache_dir +# COPY --from=builder /tmp/mina_cache_dir /tmp/mina_cache_dir -# Set up coda config dir with demo mode keys and genesis -COPY --from=builder /home/opam/demo-genesis ${CODA_CONFIG_DIR}/demo-genesis -COPY --from=builder /home/opam/coda/src/app/rosetta/demo-config.json ${CODA_CONFIG_DIR}/daemon.json +# Set up mina config dir with demo mode keys and genesis +COPY --from=builder /home/opam/demo-genesis ${MINA_CONFIG_DIR}/demo-genesis +COPY --from=builder /home/opam/mina/src/app/rosetta/demo-config.json ${MINA_CONFIG_DIR}/daemon.json -RUN mkdir -p --mode=700 ${CODA_CONFIG_DIR}/wallets/store/ \ - && echo "$PK" > ${CODA_CONFIG_DIR}/wallets/store/$PK.pub \ +RUN mkdir -p --mode=700 ${MINA_CONFIG_DIR}/wallets/store/ \ + && echo "$PK" > ${MINA_CONFIG_DIR}/wallets/store/$PK.pub \ && echo '{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"8jGuTAxw3zxtWasVqcD1H6rEojHLS1yJmG3aHHd","pwsalt":"AiUCrMJ6243h3TBmZ2rqt3Voim1Y","pwdiff":[134217728,6],"ciphertext":"DbAy736GqEKWe9NQWT4yaejiZUo9dJ6rsK7cpS43APuEf5AH1Qw6xb1s35z8D2akyLJBrUr6m"}' \ - > ${CODA_CONFIG_DIR}/wallets/store/${PK} \ - && chmod go-rwx ${CODA_CONFIG_DIR}/wallets/store/${PK} + > ${MINA_CONFIG_DIR}/wallets/store/${PK} \ + && chmod go-rwx ${MINA_CONFIG_DIR}/wallets/store/${PK} USER postgres @@ -348,6 +348,6 @@ USER root WORKDIR /app/rosetta EXPOSE 3087 -EXPOSE $CODA_DAEMON_PORT +EXPOSE $MINA_DAEMON_PORT ENTRYPOINT ["bash", "./docker-start.sh"] diff --git a/scripts/build-and-test-rosetta-from-git.sh b/scripts/build-and-test-rosetta-from-git.sh index fe709067e27..aec03dd1c21 100755 --- a/scripts/build-and-test-rosetta-from-git.sh +++ b/scripts/build-and-test-rosetta-from-git.sh @@ -1,15 +1,20 @@ +#!/bin/bash + GITBRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD) TAG=$(echo ${GITBRANCH} | sed 's!/!-!; s!_!-!g') -docker pull gcr.io/o1labs-192920/coda-rosetta-opam-deps:${TAG} +docker pull gcr.io/o1labs-192920/mina-rosetta-opam-deps:${TAG} cat dockerfiles/Dockerfile-rosetta | docker build \ --target production \ - -t gcr.io/o1labs-192920/coda-rosetta:${TAG} \ - --cache-from gcr.io/o1labs-192920/coda-rosetta-opam-deps:${TAG} \ + --force-rm \ + --cache-from gcr.io/o1labs-192920/mina-rosetta-opam-deps:${TAG} \ + -t gcr.io/o1labs-192920/mina-rosetta:${TAG} \ --build-arg "DUNE_PROFILE=dev" \ - --build-arg "CODA_BRANCH=${GITBRANCH}" - + --build-arg "OPAM_BRANCH=${GITBRANCH}" \ + --build-arg "MINA_BRANCH=${GITBRANCH}" - + -docker run -it --entrypoint=./docker-test-start.sh gcr.io/o1labs-192920/coda-rosetta:${TAG} +docker run -it --entrypoint=./docker-test-start.sh gcr.io/o1labs-192920/mina-rosetta:${TAG} -[[ $? -eq 0 ]] && docker push gcr.io/o1labs-192920/coda-rosetta:${TAG} || echo "Tests failed, not pushing" +[[ $? -eq 0 ]] && docker push gcr.io/o1labs-192920/mina-rosetta:${TAG} || echo "Tests failed, not pushing" diff --git a/src/app/replayer/replayer.ml b/src/app/replayer/replayer.ml index 5aeb4a60478..c7389864dd8 100644 --- a/src/app/replayer/replayer.ml +++ b/src/app/replayer/replayer.ml @@ -29,6 +29,9 @@ let create_ledger accounts = Ledger.create_new_account_exn ledger acct_id acct ) ; ledger +let json_ledger_hash_of_ledger ledger = + Ledger_hash.to_yojson @@ Ledger.merkle_root ledger + let create_output target_state_hash target_proof ledger = let target_ledger = Ledger.to_list ledger in {target_state_hash; target_proof; target_ledger} @@ -245,13 +248,14 @@ let run_user_command ~logger ~pool ~ledger (cmd : Sql.User_command.t) = cmd.nonce cmd.global_slot cmd.sequence_no ; let%bind body = body_of_sql_user_cmd pool cmd in let%map fee_payer_pk = pk_of_pk_id pool cmd.fee_payer_id in + let memo = Signed_command_memo.of_string cmd.memo in let payload = Signed_command_payload.create ~fee:(Currency.Fee.of_uint64 @@ Unsigned.UInt64.of_int64 cmd.fee) ~fee_token:(Token_id.of_uint64 @@ Unsigned.UInt64.of_int64 cmd.fee_token) ~fee_payer_pk ~nonce:(Unsigned.UInt32.of_int64 cmd.nonce) - ~valid_until:None ~memo:Signed_command_memo.dummy ~body + ~valid_until:None ~memo ~body in (* when applying the transaction, there's a check that the fee payer and signer keys are the same; since this transaction was accepted, we know @@ -314,6 +318,20 @@ let main ~input_file ~output_file ~archive_uri () = State_hash.to_yojson input.target_state_hash |> unquoted_string_of_yojson in + [%log info] "Loading global slots" ; + let%bind global_slots = + match%bind + Caqti_async.Pool.use + (fun db -> Sql.Global_slots.run db state_hash) + pool + with + | Ok slots -> + return (Int64.Set.of_list slots) + | Error msg -> + [%log error] "Error getting global slots" + ~metadata:[("error", `String (Caqti_error.show msg))] ; + exit 1 + in [%log info] "Loading user command ids" ; let%bind user_cmd_ids = match%bind @@ -364,8 +382,13 @@ let main ~input_file ~output_file ~archive_uri () = id (Caqti_error.show msg) () ) in let unsorted_internal_cmds = List.concat unsorted_internal_cmds_list in + (* filter out internal commands in blocks not along chain from target state hash *) + let filtered_internal_cmds = + List.filter unsorted_internal_cmds ~f:(fun cmd -> + Int64.Set.mem global_slots cmd.global_slot ) + in let sorted_internal_cmds = - List.sort unsorted_internal_cmds ~compare:(fun ic1 ic2 -> + List.sort filtered_internal_cmds ~compare:(fun ic1 ic2 -> let tuple (ic : Sql.Internal_command.t) = (ic.global_slot, ic.sequence_no, ic.secondary_sequence_no) in @@ -392,8 +415,13 @@ let main ~input_file ~output_file ~archive_uri () = (Caqti_error.show msg) () ) in let unsorted_user_cmds = List.concat unsorted_user_cmds_list in + (* filter out user commands in blocks not along chain from target state hash *) + let filtered_user_cmds = + List.filter unsorted_user_cmds ~f:(fun cmd -> + Int64.Set.mem global_slots cmd.global_slot ) + in let sorted_user_cmds = - List.sort unsorted_user_cmds ~compare:(fun uc1 uc2 -> + List.sort filtered_user_cmds ~compare:(fun uc1 uc2 -> let tuple (uc : Sql.User_command.t) = (uc.global_slot, uc.sequence_no) in @@ -401,24 +429,33 @@ let main ~input_file ~output_file ~archive_uri () = in (* apply commands in global slot, sequence order *) let rec apply_commands (internal_cmds : Sql.Internal_command.t list) - (user_cmds : Sql.User_command.t list) = + (user_cmds : Sql.User_command.t list) ~last_global_slot = + let log_on_slot_change curr_global_slot = + if Int64.( > ) curr_global_slot last_global_slot then + [%log info] "Applied all commands at global slot %Ld, ledger hash" + ~metadata:[("ledger_hash", json_ledger_hash_of_ledger ledger)] + last_global_slot + in let combine_or_run_internal_cmds (ic : Sql.Internal_command.t) (ics : Sql.Internal_command.t list) = match ics with | ic2 :: ics2 - when Int.equal ic.sequence_no ic2.sequence_no + when Int64.equal ic.global_slot ic2.global_slot + && Int.equal ic.sequence_no ic2.sequence_no && String.equal ic.type_ "fee_transfer" && String.equal ic.type_ ic2.type_ -> (* combining situation 2 - two fee transfer commands with same sequence number - *) + two fee transfer commands with same global slot, sequence number + *) + log_on_slot_change ic.global_slot ; let%bind () = apply_combined_fee_transfer ~logger ~pool ~ledger ic ic2 in - apply_commands ics2 user_cmds + apply_commands ics2 user_cmds ~last_global_slot:ic.global_slot | _ -> + log_on_slot_change ic.global_slot ; let%bind () = run_internal_command ~logger ~pool ~ledger ic in - apply_commands ics user_cmds + apply_commands ics user_cmds ~last_global_slot:ic.global_slot in (* choose command with least global slot, sequence number TODO: check for gaps? @@ -432,11 +469,13 @@ let main ~input_file ~output_file ~archive_uri () = | [], [] -> Deferred.unit | [], uc :: ucs -> + log_on_slot_change uc.global_slot ; let%bind () = run_user_command ~logger ~pool ~ledger uc in - apply_commands [] ucs + apply_commands [] ucs ~last_global_slot:uc.global_slot | ic :: _, uc :: ucs when cmp_ic_uc ic uc > 0 -> + log_on_slot_change uc.global_slot ; let%bind () = run_user_command ~logger ~pool ~ledger uc in - apply_commands internal_cmds ucs + apply_commands internal_cmds ucs ~last_global_slot:uc.global_slot | ic :: ics, [] -> combine_or_run_internal_cmds ic ics | ic :: ics, uc :: _ when cmp_ic_uc ic uc < 0 -> @@ -447,7 +486,14 @@ let main ~input_file ~output_file ~archive_uri () = slot %Ld and sequence number %d" ic.global_slot ic.sequence_no () in - let%bind () = apply_commands sorted_internal_cmds sorted_user_cmds in + [%log info] "At genesis, ledger hash" + ~metadata:[("ledger_hash", json_ledger_hash_of_ledger ledger)] ; + let%bind () = + apply_commands sorted_internal_cmds sorted_user_cmds + ~last_global_slot:0L + in + [%log info] "After applying all commands, ledger hash" + ~metadata:[("ledger_hash", json_ledger_hash_of_ledger ledger)] ; [%log info] "Writing output to $output_file" ~metadata:[("output_file", `String output_file)] ; let output = diff --git a/src/app/replayer/sql.ml b/src/app/replayer/sql.ml index 5d89c28b3b6..d56606622d5 100644 --- a/src/app/replayer/sql.ml +++ b/src/app/replayer/sql.ml @@ -2,6 +2,31 @@ open Core_kernel +module Global_slots = struct + (* find all global slots in blocks, working back from block with given state hash *) + let query = + Caqti_request.collect Caqti_type.string Caqti_type.int64 + {| + WITH RECURSIVE chain AS ( + + SELECT id,parent_id,global_slot FROM blocks b WHERE b.state_hash = ? + + UNION ALL + + SELECT b.id,b.parent_id,b.global_slot FROM blocks b + + INNER JOIN chain + + ON b.id = chain.parent_id + ) + + SELECT global_slot FROM chain c + |} + + let run (module Conn : Caqti_async.CONNECTION) state_hash = + Conn.collect_list query state_hash +end + (* build query to find all blocks back to genesis block, starting with the block containing the specified state hash; for each such block, find ids of all (user or internal) commands in that block *) @@ -52,6 +77,7 @@ module User_command = struct ; fee_token: int64 ; token: int64 ; amount: int64 option + ; memo: string ; nonce: int64 ; global_slot: int64 ; sequence_no: int } @@ -62,12 +88,12 @@ module User_command = struct Ok ( (t.type_, t.fee_payer_id, t.source_id, t.receiver_id) , (t.fee, t.fee_token, t.token, t.amount) - , (t.nonce, t.global_slot, t.sequence_no) ) + , (t.memo, t.nonce, t.global_slot, t.sequence_no) ) in let decode ( (type_, fee_payer_id, source_id, receiver_id) , (fee, fee_token, token, amount) - , (nonce, global_slot, sequence_no) ) = + , (memo, nonce, global_slot, sequence_no) ) = Ok { type_ ; fee_payer_id @@ -77,6 +103,7 @@ module User_command = struct ; fee_token ; token ; amount + ; memo ; nonce ; global_slot ; sequence_no } @@ -85,14 +112,14 @@ module User_command = struct Caqti_type.( tup3 (tup4 string int int int) (tup4 int64 int64 int64 (option int64)) - (tup3 int64 int64 int)) + (tup4 string int64 int64 int)) in Caqti_type.custom ~encode ~decode rep let query = Caqti_request.collect Caqti_type.int typ {| - SELECT type,fee_payer_id, source_id,receiver_id,fee,fee_token,token,amount,nonce,global_slot,sequence_no,status FROM + SELECT type,fee_payer_id, source_id,receiver_id,fee,fee_token,token,amount,memo,nonce,global_slot,sequence_no,status FROM (SELECT * FROM user_commands WHERE id = ?) AS uc diff --git a/src/app/rosetta/README.md b/src/app/rosetta/README.md index 6a58dfd6d18..a27d1faa9a8 100644 --- a/src/app/rosetta/README.md +++ b/src/app/rosetta/README.md @@ -10,6 +10,15 @@ Implementation of the [Rosetta API](https://www.rosetta-api.org/) for Coda. - Handles case where there are multiple blocks at the same height - "Failed transactions" decode into operations and reconcile properly +## How to build your own docker image + +Checkout the "rosetta-stable" branch of the mina repository and then run the following: + +`cat dockerfiles/Dockerfile-rosetta | docker build -t mina-rosetta:stable --build-arg "MINA_BRANCH=rosetta-stable" -` + +This creates an image (mina-rosetta:stable) based on the most up-to-date changes that support rosetta. This image +can be used as a drop-in replacement for `gcr.io/o1labs-192920/coda-rosetta:debug-v1.1` in any of the below commands for testing. + ## How to Run As there is not currently a live network, the best way to run Rosetta is to run it against a sandbox node. Rosetta is best run using the official docker images provided here that run the Coda daemon, an archive node, and the rosetta process for you. See [Reproduce agent and rosetta-cli Validation](#reproduce-agent-and-rosetta-cli-validation) below for details. diff --git a/src/app/rosetta/docker-demo-start.sh b/src/app/rosetta/docker-demo-start.sh index f250fe011d7..1c6c3d824fd 100755 --- a/src/app/rosetta/docker-demo-start.sh +++ b/src/app/rosetta/docker-demo-start.sh @@ -6,11 +6,11 @@ function cleanup { CODE=${1:-0} echo "Killing archive.exe" - kill $(ps aux | egrep '_build/default/src/app/.*archive.exe' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/.*archive.exe' | grep -v grep | awk '{ print $2 }') || true echo "Killing coda.exe" - kill $(ps aux | egrep '_build/default/src/app/.*coda.exe' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/.*coda.exe' | grep -v grep | awk '{ print $2 }') || true echo "Killing rosetta.exe" - kill $(ps aux | egrep '_build/default/src/app/rosetta' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/rosetta' | grep -v grep | awk '{ print $2 }') || true exit $CODE } @@ -28,7 +28,7 @@ sleep 3 # archive echo "========================= STARTING ARCHIVE PROCESS ===========================" -/coda-bin/archive/archive.exe run \ +/mina-bin/archive/archive.exe run \ -postgres-uri $PG_CONN \ -server-port 3086 \ -log-level fatal \ @@ -42,23 +42,25 @@ PK=${PK:-B62qrPN5Y5yq8kGE3FbVKbGTdTAJNdtNtB5sNVpxyRwWGcDEhpMzc8g} SNARK_PK=${SNARK_PK:-B62qiWSQiF5Q9CsAHgjMHoEEyR2kJnnCvN9fxRps2NXULU15EeXbzPf} genesis_time=$(date -d '2019-01-30 20:00:00.000000Z' '+%s') now_time=$(date +%s) + export CODA_TIME_OFFSET=$(( $now_time - $genesis_time )) export CODA_PRIVKEY_PASS="" -export CODA_LIBP2P_HELPER_PATH=/coda-bin/libp2p_helper -CODA_CONFIG_DIR=/root/.coda-config +export CODA_LIBP2P_HELPER_PATH=/mina-bin/libp2p_helper + +MINA_CONFIG_DIR=/root/.coda-config -# CODA_CONFIG_DIR is exposed by the dockerfile and contains demo mode essentials +# MINA_CONFIG_DIR is exposed by the dockerfile and contains demo mode essentials echo "========================= STARTING DAEMON ===========================" -/coda-bin/cli/src/coda.exe daemon \ +/mina-bin/cli/src/coda.exe daemon \ -archive-address 3086 \ -background \ - -block-producer-key "$CODA_CONFIG_DIR/wallets/store/$PK" \ - -config-dir "$CODA_CONFIG_DIR" \ - -config-file "$CODA_CONFIG_DIR/daemon.json" \ + -block-producer-key "$MINA_CONFIG_DIR/wallets/store/$PK" \ + -config-dir "$MINA_CONFIG_DIR" \ + -config-file "$MINA_CONFIG_DIR/daemon.json" \ -demo-mode \ -disable-telemetry \ -external-ip 127.0.0.1 \ - -external-port "${CODA_DAEMON_PORT:-10101}" \ + -external-port "${MINA_DAEMON_PORT:-10101}" \ -insecure-rest-server \ -log-level debug \ -log-json \ @@ -78,7 +80,7 @@ sleep 3 # rosetta echo "========================= STARTING ROSETTA API on PORT 3087 ===========================" -/coda-bin/rosetta/rosetta.exe \ +/mina-bin/rosetta/rosetta.exe \ -archive-uri $PG_CONN \ -graphql-uri http://localhost:3085/graphql \ -log-level debug \ diff --git a/src/app/rosetta/docker-start.sh b/src/app/rosetta/docker-start.sh index 72cdd3b338a..4921575a4f1 100755 --- a/src/app/rosetta/docker-start.sh +++ b/src/app/rosetta/docker-start.sh @@ -5,11 +5,11 @@ set -eou pipefail function cleanup { echo "Killing archive.exe" - kill $(ps aux | egrep '/coda-bin/.*archive.exe' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/.*archive.exe' | grep -v grep | awk '{ print $2 }') || true echo "Killing coda.exe" - kill $(ps aux | egrep '/coda-bin/.*coda.exe' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/.*coda.exe' | grep -v grep | awk '{ print $2 }') || true echo "Killing rosetta.exe" - kill $(ps aux | egrep '/coda-bin/rosetta' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/rosetta' | grep -v grep | awk '{ print $2 }') || true echo "Stopping postgres" pg_ctlcluster 11 main stop exit @@ -27,7 +27,7 @@ pg_ctlcluster 11 main start sleep 3 # archive -/coda-bin/archive/archive.exe run \ +/mina-bin/archive/archive.exe run \ -postgres-uri $PG_CONN \ -server-port 3086 & @@ -35,26 +35,27 @@ sleep 3 sleep 3 export CODA_PRIVKEY_PASS="" -export CODA_CONFIG_FILE=${CODA_CONFIG_FILE:=/data/config.json} +export CODA_LIBP2P_HELPER_PATH=/mina-bin/libp2p_helper + +export MINA_CONFIG_FILE=${MINA_CONFIG_FILE:=/data/config.json} export PEER_ID=${PEER_ID:=/ip4/34.74.175.158/tcp/10001/ipfs/12D3KooWAFFq2yEQFFzhU5dt64AWqawRuomG9hL8rSmm5vxhAsgr/} -export CODA_PORT=${CODA_DAEMON_PORT:=10101} -DEFAULT_FLAGS="-generate-genesis-proof true -peer ${PEER_ID} -archive-address 0.0.0.0:3086 -insecure-rest-server -log-level debug -external-port ${CODA_PORT}" -export CODA_FLAGS=${CODA_FLAGS:=$DEFAULT_FLAGS} -export CODA_LIBP2P_HELPER_PATH=/coda-bin/libp2p_helper -PK=${CODA_PK:=ZsMSUuKL9zLAF7sMn951oakTFRCCDw9rDfJgqJ55VMtPXaPa5vPwntQRFJzsHyeh8R8} +export MINA_PORT=${MINA_DAEMON_PORT:=10101} +DEFAULT_FLAGS="-generate-genesis-proof true -peer ${PEER_ID} -archive-address 0.0.0.0:3086 -insecure-rest-server -log-level debug -external-port ${MINA_PORT}" +export MINA_FLAGS=${MINA_FLAGS:=$DEFAULT_FLAGS} +PK=${MINA_PK:=ZsMSUuKL9zLAF7sMn951oakTFRCCDw9rDfJgqJ55VMtPXaPa5vPwntQRFJzsHyeh8R8} -echo "CODA Flags: $CODA_FLAGS -config-file ${CODA_CONFIG_FILE}" +echo "MINA Flags: $MINA_FLAGS -config-file ${MINA_CONFIG_FILE}" # Daemon w/ mounted config file, initial file is phase 3 config.json -/coda-bin/cli/src/coda.exe daemon \ - -config-file ${CODA_CONFIG_FILE} \ - ${CODA_FLAGS} $@ & +/mina-bin/cli/src/coda.exe daemon \ + -config-file ${MINA_CONFIG_FILE} \ + ${MINA_FLAGS} $@ & # wait for it to settle sleep 3 # rosetta -/coda-bin/rosetta/rosetta.exe \ +/mina-bin/rosetta/rosetta.exe \ -archive-uri $PG_CONN \ -graphql-uri http://localhost:3085/graphql \ -log-level debug \ diff --git a/src/app/rosetta/docker-test-start.sh b/src/app/rosetta/docker-test-start.sh index 66e9c4abb0b..53e1abb5644 100755 --- a/src/app/rosetta/docker-test-start.sh +++ b/src/app/rosetta/docker-test-start.sh @@ -6,13 +6,13 @@ function cleanup { CODE=${1:-0} echo "Killing archive.exe" - kill $(ps aux | egrep '_build/default/src/app/.*archive.exe' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/.*archive.exe' | grep -v grep | awk '{ print $2 }') || true echo "Killing coda.exe" - kill $(ps aux | egrep '_build/default/src/app/.*coda.exe' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/.*coda.exe' | grep -v grep | awk '{ print $2 }') || true echo "Killing agent.exe" - kill $(ps aux | egrep '_build/default/src/app/rosetta/test-agent/agent.exe' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/rosetta/test-agent/agent.exe' | grep -v grep | awk '{ print $2 }') || true echo "Killing rosetta.exe" - kill $(ps aux | egrep '_build/default/src/app/rosetta' | grep -v grep | awk '{ print $2 }') || true + kill $(ps aux | egrep '/mina-bin/rosetta' | grep -v grep | awk '{ print $2 }') || true exit $CODE } @@ -28,7 +28,7 @@ pg_ctlcluster 11 main start sleep 3 # archive -/coda-bin/archive/archive.exe run \ +/mina-bin/archive/archive.exe run \ -postgres-uri $PG_CONN \ -log-json \ -server-port 3086 & @@ -42,17 +42,17 @@ genesis_time=$(date -d '2019-01-30 20:00:00.000000Z' '+%s') now_time=$(date +%s) export CODA_TIME_OFFSET=$(( $now_time - $genesis_time )) export CODA_PRIVKEY_PASS="" -export CODA_LIBP2P_HELPER_PATH=/coda-bin/libp2p_helper -CODA_CONFIG_DIR=/root/.coda-config +export CODA_LIBP2P_HELPER_PATH=/mina-bin/libp2p_helper +MINA_CONFIG_DIR=/root/.coda-config -# CODA_CONFIG_DIR is exposed by the dockerfile and contains demo mode essentials -/coda-bin/cli/src/coda.exe daemon \ +# MINA_CONFIG_DIR is exposed by the dockerfile and contains demo mode essentials +/mina-bin/cli/src/coda.exe daemon \ -seed \ -demo-mode \ - -block-producer-key "$CODA_CONFIG_DIR/wallets/store/$PK" \ + -block-producer-key "MINA_CONFIG_DIR/wallets/store/$PK" \ -run-snark-worker $PK \ - -config-file "$CODA_CONFIG_DIR/daemon.json" \ - -config-dir "$CODA_CONFIG_DIR" \ + -config-file "$MINA_CONFIG_DIR/daemon.json" \ + -config-dir "$MINA_CONFIG_DIR" \ -insecure-rest-server \ -external-ip 127.0.0.1 \ -archive-address 3086 \ @@ -63,7 +63,7 @@ CODA_CONFIG_DIR=/root/.coda-config sleep 3 # rosetta -/coda-bin/rosetta/rosetta.exe \ +/mina-bin/rosetta/rosetta.exe \ -archive-uri $PG_CONN \ -graphql-uri http://localhost:3085/graphql \ -log-level debug \ @@ -74,7 +74,7 @@ sleep 3 sleep 3 # test agent -/coda-bin/rosetta/test-agent/agent.exe \ +/mina-bin/rosetta/test-agent/agent.exe \ -graphql-uri http://localhost:3085/graphql \ -rosetta-uri http://localhost:3087/ \ -log-level Trace \