diff --git a/.gitlab/ci/integration.yml b/.gitlab/ci/integration.yml index 7b71a7c3f7376a9a091ac85b90f2b07fd6c21c23..b6bf7215a6fd06b1d68d32db989dbeec406681c9 100644 --- a/.gitlab/ci/integration.yml +++ b/.gitlab/ci/integration.yml @@ -22,12 +22,10 @@ script:prepare_migration_test: extends: .test_template before_script: - last_proto_name=$(find src -name "proto_[0-9][0-9][0-9]_*" | awk -F'/' '{print $NF}' | sort -r | head -1) - - last_proto_version=$(echo $last_proto_name | cut -d'_' -f2) + - last_proto_version=$(echo $last_proto_name | cut -d'_' -f2 | bc) - new_proto_version=$(printf "%03d" $((last_proto_version + 1))) - - make script: - ./scripts/prepare_migration_test.sh manual "next_$new_proto_version" 1 - allow_failure: true # This test fails starting from 008 because bash thinks 008 is octal ############################################################ ## Stage: run OCaml integration tests ## diff --git a/.gitlab/ci/tezt.yml b/.gitlab/ci/tezt.yml index 0a6379bb2f2a52b98a2d68f224ff32739c577960..bd64717f0ad4ad8ca599f60e0100bb29cd259419 100644 --- a/.gitlab/ci/tezt.yml +++ b/.gitlab/ci/tezt.yml @@ -2,8 +2,6 @@ # we still get the artifact (CI timeouts cause artifacts to not be uploaded). tezt:main: extends: .test_template - before_script: - - make script: - dune exec tezt/tests/main.exe -- --color --log-buffer-size 5000 --log-file tezt.log --global-timeout 3300 --time artifacts: @@ -17,12 +15,8 @@ tezt:manual:migration: when: manual before_script: - export TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=Y - - curl -s https://api.github.com/repos/Phlogi/tezos-snapshots/releases/latest | jq -r ".assets[] | select(.name) | .browser_download_url" | grep roll | xargs wget -q - - block_hash=$(echo mainnet.roll.* | sed -r 's/mainnet\.roll\.[0-9_-]+\.(.*)\.[0-9]+\.chain\.xz/\1/g') - - cat mainnet.roll.* | xz -d -v -T0 > mainnet.rolling - - - make - - scripts/prepare_migration_test.sh auto mainnet.rolling "$block_hash" + - wget https://mainnet.xtz-shots.io/rolling -O mainnet.rolling + - scripts/prepare_migration_test.sh auto mainnet.rolling script: - dune exec ./tezt/manual_tests/main.exe -- migration --color --log-buffer-size 5000 --log-file tezt-migration.log artifacts: diff --git a/scripts/link_protocol.sh b/scripts/link_protocol.sh index d42556b2dc3552bd07d20582c65df3d74d802b89..a7637ecf6b8e31d02c47311a44468ff4c836e410 100755 --- a/scripts/link_protocol.sh +++ b/scripts/link_protocol.sh @@ -24,21 +24,21 @@ if [ ! -d "$1" ]; then exit 1 fi -new_version=$(basename $1 | awk -F'_' '{print $2}') -new_hash=$(basename $1 | awk -F'_' '{print $3}') -full_hash=$(jq .hash < $1/lib_protocol/TEZOS_PROTOCOL) +new_version=$(basename "$1" | awk -F'_' '{print $2}') +new_hash=$(basename "$1" | awk -F'_' '{print $3}') +full_hash=$(jq .hash <"$1"/lib_protocol/TEZOS_PROTOCOL) replacement=${new_version}-${new_hash} -if [[ -z "${new_version}" || -z "${new_hash}" || -z "${full_hash}" ]] ; then +if [[ -z "${new_version}" || -z "${new_hash}" || -z "${full_hash}" ]]; then echo "$usage" exit 1 fi # The pattern to look for is "00X-". # Once found it's either replaced or the line is duplicated and then replaced -old_version=$( printf '%03d' $((10#$new_version -1)) ) -old_dir=$(ls -d src/proto_${old_version}_*) -old_hash=$(basename $old_dir | awk -F'_' '{print $3}') -pattern=${old_version}-${old_hash} +old_version=$(printf '%03d' $((10#$new_version - 1))) +old_dir=$(ls -d src/proto_"${old_version}"_*) +old_hash=$(basename "$old_dir" | awk -F'_' '{print $3}') +pattern="${old_version}"-"${old_hash}" echo "Pattern to duplicate / substitute: $pattern" @@ -48,15 +48,14 @@ duplicate_and_replace() { REPLACEMENT=$2 shift 2 - for file in $* - do + for file in "$@"; do echo "Adding $replacement in: $file" awk '{ print if ($0 ~ PATTERN) { sub(PATTERN,REPLACEMENT) print - }}' PATTERN=$PATTERN REPLACEMENT=$REPLACEMENT "$file" > tmp_file + }}' PATTERN="$PATTERN" REPLACEMENT="$REPLACEMENT" "$file" >tmp_file mv tmp_file "$file" done } @@ -66,13 +65,10 @@ duplicate_and_replace_only_1_occ() { REPLACEMENT=$2 shift 2 - for file in $* - do + for file in "$@"; do echo "Adding $replacement in: $file (only one occurrence)" awk '{ - if ( prevlast !~ PATTERN\ - && last ~ PATTERN\ - && $0 !~ PATTERN) { + if (prevlast !~ PATTERN && last ~ PATTERN && $0 !~ PATTERN) { gsub(PATTERN,REPLACEMENT,last) print last } @@ -80,8 +76,8 @@ duplicate_and_replace_only_1_occ() { {prevlast = last} {last = $0} - }' PATTERN=$PATTERN REPLACEMENT=$REPLACEMENT "$file" > tmp_file - mv tmp_file "$file" + }' PATTERN="$PATTERN" REPLACEMENT="$REPLACEMENT" "$file" >tmp_file + mv tmp_file "$file" done } @@ -90,14 +86,13 @@ duplicate_and_replace_when_3_occ() { REPLACEMENT=$2 shift 2 - for file in $* - do + for file in "$@"; do echo "Adding $replacement in: $file (when 3 occurrences)" + #allow '\' to split line in literal + #shellcheck disable=SC1004 awk '{ - if ( prevprevlast ~ PATTERN\ - && prevlast ~ PATTERN\ - && last ~ PATTERN\ - && $0 !~ PATTERN) { + if (prevprevlast ~ PATTERN && prevlast ~ PATTERN\ + && last ~ PATTERN && $0 !~ PATTERN) { gsub(PATTERN, REPLACEMENT, prevprevlast) gsub(PATTERN, REPLACEMENT, prevlast) gsub(PATTERN, REPLACEMENT, last) @@ -110,36 +105,36 @@ duplicate_and_replace_when_3_occ() { {prevlast = last} {last = $0} - }' PATTERN=$PATTERN REPLACEMENT=$REPLACEMENT "$file" > tmp_file - mv tmp_file "$file" + }' PATTERN="$PATTERN" REPLACEMENT="$REPLACEMENT" "$file" >tmp_file + mv tmp_file "$file" done } # the minimum needed, although you can't bake -duplicate_and_replace ${pattern} ${replacement} active_protocol_versions +duplicate_and_replace "${pattern}" "${replacement}" active_protocol_versions # activate in client to bake and use RPCs -duplicate_and_replace_when_3_occ -${pattern} -${replacement} \ - src/bin_client/dune -duplicate_and_replace_only_1_occ -${pattern} -${replacement} \ - src/bin_client/dune -duplicate_and_replace -${pattern} -${replacement} \ - src/bin_client/tezos-client.opam +duplicate_and_replace_when_3_occ -"${pattern}" -"${replacement}" \ + src/bin_client/dune +duplicate_and_replace_only_1_occ -"${pattern}" -"${replacement}" \ + src/bin_client/dune +duplicate_and_replace -"${pattern}" -"${replacement}" \ + src/bin_client/tezos-client.opam # activate in node -duplicate_and_replace_when_3_occ -${pattern} -${replacement} \ - src/bin_node/dune -duplicate_and_replace_only_1_occ -${pattern} -${replacement} \ - src/bin_node/dune -duplicate_and_replace -${pattern} -${replacement} \ - src/bin_node/tezos-node.opam -duplicate_and_replace -${pattern} -${replacement} \ - src/bin_validation/{dune,tezos-validator.opam} +duplicate_and_replace_when_3_occ -"${pattern}" -"${replacement}" \ + src/bin_node/dune +duplicate_and_replace_only_1_occ -"${pattern}" -"${replacement}" \ + src/bin_node/dune +duplicate_and_replace -"${pattern}" -"${replacement}" \ + src/bin_node/tezos-node.opam +duplicate_and_replace -"${pattern}" -"${replacement}" \ + src/bin_validation/{dune,tezos-validator.opam} # activate in codec -duplicate_and_replace_when_3_occ -${pattern} -${replacement} \ - src/bin_codec/dune -duplicate_and_replace_only_1_occ -${pattern} -${replacement} \ - src/bin_codec/dune -duplicate_and_replace -${pattern} -${replacement} \ - src/bin_codec/tezos-codec.opam +duplicate_and_replace_when_3_occ -"${pattern}" -"${replacement}" \ + src/bin_codec/dune +duplicate_and_replace_only_1_occ -"${pattern}" -"${replacement}" \ + src/bin_codec/dune +duplicate_and_replace -"${pattern}" -"${replacement}" \ + src/bin_codec/tezos-codec.opam diff --git a/scripts/prepare_migration_test.sh b/scripts/prepare_migration_test.sh index 3d1c6be1b71dd1b887e8565a392419c83f1faa36..0ced3c36afa69bb4d6a52d245f2f24e565f4dc70 100755 --- a/scripts/prepare_migration_test.sh +++ b/scripts/prepare_migration_test.sh @@ -2,23 +2,24 @@ set -e -snapshot_protocol () { +snapshot_protocol() { f_proto_name="$1" f_proto_version="$2" f_proto_dir="$3" # snapshot protocol alpha into new directory echo " -Calling: ./scripts/snapshot_alpha $f_proto_name." - ./scripts/snapshot_alpha.sh "$f_proto_name" +Calling: ./scripts/snapshot_alpha ${f_proto_name}_${f_proto_version}" + ./scripts/snapshot_alpha.sh "${f_proto_name}_${f_proto_version}" + proto_dir=$(ls -d src/proto_"${proto_version}"_*/) # link new protocol for the shell and client echo " -Calling: ./scripts/link_protocol.sh $f_proto_dir." - ./scripts/link_protocol.sh $f_proto_dir +Calling: ./scripts/link_protocol.sh $proto_dir." + ./scripts/link_protocol.sh "$proto_dir" } -user_activated_upgrade () { +user_activated_upgrade() { f_proto_dir="$1" f_mig_level="$2" # activate the migration at a specific level @@ -27,48 +28,55 @@ Calling: ./scripts/user_activated_upgrade.sh $f_proto_dir $f_mig_level." ./scripts/user_activated_upgrade.sh "$f_proto_dir" "$f_mig_level" } -import_snapshot () { - f_snapshot_path="$1" +import_snapshot() { + f_path="$1" f_blockhash="$2" - - ! [ -z "$f_blockhash" ] && f_blockhash_opt="--block $f_blockhash" - - # The command ${snapshot%.(rolling|full|archive} did not worked for no - # found reason - context_dir="${f_snapshot_path%.rolling}" - context_dir="${context_dir%.full}" - context_dir="${context_dir%.archive}" - context_dir="$tmp_dir/tezos-node-${context_dir##*/}" - if [ -d "$context_dir" ] - then + if [ -d "$f_path" ]; then echo " +Using context found in ${f_path}" + context_dir="$f_path" + elif [ -f "$f_path" ]; then + context_dir="${f_path%.rolling}" + context_dir="${context_dir%.full}" + context_dir="${context_dir%.archive}" + context_dir="$tmp_dir/tezos-node-${context_dir##*/}" + if [ -d "$context_dir" ]; then + echo " Found existing context in directory ${context_dir} -If you want to re-import the context from ${f_snapshot_path} +If you want to re-import the context from ${f_path} please delete directory ${context_dir} The context in ${context_dir} will be used for the test." - else - echo " -Importing context from $f_snapshot_path into $context_dir." - ./tezos-node snapshot import "$f_snapshot_path" --data-dir "$context_dir" $f_blockhash_opt + else + echo " +Importing context from ${f_path} into ${context_dir}. +" + if [ -n "$f_blockhash" ]; then + ./tezos-node snapshot import "$f_path" \ + --data-dir "$context_dir" \ + --block "$f_blockhash" + else + ./tezos-node snapshot import "$f_path" \ + --data-dir "$context_dir" + fi + fi fi } -generate_identities (){ +generate_identities() { f_context_dir="$1" ./tezos-node identity generate --data-dir "$f_context_dir" } -patch_yes_node () { +patch_yes_node() { echo " Patching the code to obtain a yes-node." - patch -p1 < ./scripts/yes-node.patch + patch -p1 <./scripts/yes-node.patch } -create_yes_wallet () { +create_yes_wallet() { yes_wallet="$tmp_dir/yes-wallet" - if [ -d "$yes_wallet" ] - then + if [ -d "$yes_wallet" ]; then echo " Found existing yes-wallet in directory ${yes_wallet}. The yes-wallet in ${yes_wallet} will be used for the test @@ -83,12 +91,12 @@ Creating a yes-wallet in directory ${yes_wallet}." echo "You can now bake for foundation{1..8}." } +# SCRIPT START + #setting tmp dir -if ! [[ -z "$TMP" ]] -then +if [ -n "$TMP" ]; then tmp_dir="$TMP" -elif ! [[ -z "$TMPDIR" ]] -then +elif [ -n "$TMPDIR" ]; then tmp_dir="$TMPDIR" else tmp_dir="/tmp" @@ -161,47 +169,51 @@ in the imported chain is . " # manual or auto mode -# -if ! ( [[ $1 == "manual" ]] || [[ $1 == "auto" ]] ) || [ $# -lt 2 ] -then +if ! { [ "$1" == "manual" ] || [ "$1" == "auto" ]; } || [ $# -lt 2 ]; then echo "$usage" - echo "$manual" exit 1 else mode="$1" fi #set variable related to protocol, in particular \$proto_version and \$pred_proto_version -if [[ "$2" =~ ^[a-z]+_[0-9][0-9][0-9]$ ]] -then - proto_name="$2" - proto_version=$(echo "$proto_name" | cut -d'_' -f2) +if [[ "$2" =~ ^[a-z]+_[0-9][0-9][0-9]$ ]]; then + proto_name_version="$2" + + proto_name=$(echo "$proto_name_version" | cut -d'_' -f1) + proto_version=$(echo "$proto_name_version" | cut -d'_' -f2 | bc) + + pred_proto_version=$(printf "%03d" $((proto_version - 1))) + + # This line could be merged to previous assignment but it's need because + # bash consider "008" to be octal + proto_version=$(printf "%03d" "$proto_version") proto_dir="src/proto_${proto_version}_*/" - pred_proto_version=$(printf "%03d" $((10#$proto_version -1))) else - pred_proto_name=$(find src -name "proto_[0-9][0-9][0-9]_*" | awk -F'/' '{print $NF}' | sort -r | head -1) - pred_proto_version=$(echo $pred_proto_name | cut -d'_' -f2) + pred_proto_name_version=$(find src -name "proto_[0-9][0-9][0-9]_*" | awk -F'/' '{print $NF}' | sort -r | head -1) + pred_proto_version=$(echo "$pred_proto_name_version" | cut -d'_' -f2 | bc) - proto_version=($pred_proto_version +1) + proto_version=$(printf "%03d" $((pred_proto_version + 1))) + + # This line could be merged to previous assignment but it's need because + # bash consider "008" to be octal + pred_proto_version=$(printf "%03d" "$pred_proto_version") proto_dir="src/proto_alpha/" fi # now calls correct scripts and renaming -if ! [ -z "$proto_name" ] -then +if [ -n "$proto_name" ]; then snapshot_protocol "$proto_name" "$proto_version" "$proto_dir" fi echo " Setting environment for $mode test" -if [[ $mode == "auto" ]] -then +if [[ $mode == "auto" ]]; then #set \$path - if ! [ -z "$proto_name" ] - then + if [ -n "$proto_name" ]; then snapshot_path="$3" blockhash="$4" else @@ -210,8 +222,8 @@ then fi # check if path exists - if ! [ -f "$snapshot_path" ] - then + if ! { [ -z "$snapshot_path" ] || [ -e "$snapshot_path" ]; }; then + echo "missing correct path for $snapshot_path" echo "$usage" exit 1 fi @@ -220,22 +232,30 @@ then make - if ! [ -z "$proto_name" ] - then - full_hash=$(jq .hash < ${proto_dir}/lib_protocol/TEZOS_PROTOCOL) - sed -i.old -e 's/^let protocol = .*/let protocol = '$full_hash'/' ./tezt/manual_tests/migration.ml + if [ -n "$proto_name" ]; then + full_hash=$(jq .hash <${proto_dir}/lib_protocol/TEZOS_PROTOCOL) + short_hash=$(echo "${full_hash:1}" | head -c 8 | tr '[:upper:]' '[:lower:]') fi import_snapshot "$snapshot_path" "$blockhash" + + find ./tezt/manual_tests/ -name "migration_*_*.ml" | + while IFS= read -r file; do + if [ -n "$proto_name" ]; then + sed -i.old -e 's/^let protocol_hash = .*/let protocol_hash = '"$full_hash"'/' "$file" + sed -i.old -e 's/^let protocol_tag = .*/let protocol_tag = "'"$short_hash"'"/' "$file" + fi + sed -i.old -e 's;^let mainnet_context = .*;let mainnet_context = "'"${context_dir}"'";' "$file" + done + [ -f "$context_dir/identity.json" ] && rm "$context_dir/identity.json" - sed -i.old -e 's;^let context = .*;let context = "'"$context_dir"'";' ./tezt/manual_tests/migration.ml # remove files generated by sed find . -name '*.old' -exec rm {} \; echo " Use the following commands to run the test: -$ dune exec ./tezt/manual_tests/main.exe -- --keep-temp migration +$ dune exec ./tezt/manual_tests/main.exe -- --keep-temp ${short_hash} After the test ends, note down the path of the temporary files $tmp_dir/tezt-XXXXXX, where XXXXXX are six random decimal figures. @@ -250,14 +270,13 @@ $ ./tezos-client -d $tmp_dir/tezt-XXXXXX/yes-wallet bake for foundation1 --minim In order to re-run the migration test, kill any node that may be running and use the command for running the test above (the script needs not to be run again). -Please adapt the test file ./tezt/manual_tests/migration.ml to your specific -needs." +Please create a test file +./tezt/manual_tests/migration_${pred_proto_version}_${proto_version}.ml to your +specific needs." -elif [[ "$mode" == "manual" ]] -then +elif [[ "$mode" == "manual" ]]; then #set \$level \$path - if ! [ -z $proto_name ] - then + if [ -n "$proto_name" ]; then mig_level=$3 snapshot_path=$4 blockhash=$5 @@ -268,20 +287,25 @@ then fi # check if \$level is set - if [ -z $mig_level ] - then - echo $usage + if [ -z "$mig_level" ]; then + echo "$usage" exit 1 fi - user_activated_upgrade $proto_dir $mig_level + user_activated_upgrade $proto_dir "$mig_level" - pred_full_hash=$(jq -r .hash < src/proto_${pred_proto_version}_*/lib_protocol/TEZOS_PROTOCOL) - pred_short_hash=$(echo $pred_full_hash | head -c 8) + # This if-then-else is to remove when 008 is the active protocol anymore as + # we wont need to migrate from 008 anymore + if [[ ${pred_proto_version#00} = 8 ]] + then + pred_full_hash=$(jq -r .hash < src/proto_008_PtEdo2Zk/lib_protocol/TEZOS_PROTOCOL) + else + pred_full_hash=$(jq -r .hash --data-dir $ ./tezos-node identity generate --data-dir " fi - echo " Use the following commands to start the node with the imported context: $ test_directory=\$(mktemp -d -t \"${context_dir##*/}-XXXX\") && cp -r \"$context_dir/.\" \"\$test_directory\" $ ./tezos-node run --connections 0 --data-dir \"\$test_directory\" --rpc-addr localhost & -Then bake blocks until the chain reaches level $level with: +Then bake blocks until the chain reaches level $mig_level with: $ ./tezos-client -d $yes_wallet bake for foundation1 --minimal-timestamp In order to re-run the migration test, kill the node and delete spurious fil diff --git a/scripts/snapshot_alpha.sh b/scripts/snapshot_alpha.sh index aedc86ab845f5d8ea0a17b639f4db5ce8b512964..46745a60839e6a086c3f6d62ddfcc27ce6e22b3c 100755 --- a/scripts/snapshot_alpha.sh +++ b/scripts/snapshot_alpha.sh @@ -13,17 +13,17 @@ script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" cd "$script_dir"/.. current=$1 -label=$(echo $current | cut -d'_' -f1) -version=$(echo $current | cut -d'_' -f2) +label=$(echo "$current" | cut -d'_' -f1) +version=$(echo "$current" | cut -d'_' -f2) -if ! ( [[ "$label" =~ ^[a-z]+$ ]] && [[ "$version" =~ ^[0-9][0-9][0-9]$ ]] ); then +if ! { [[ "$label" =~ ^[a-z]+$ ]] && [[ "$version" =~ ^[0-9][0-9][0-9]$ ]]; }; then echo "Wrong protocol version." echo echo "$usage" exit 1 fi -if [ -d src/proto_${version} ] ; then +if [ -d src/proto_"${version}" ]; then echo "Error: you should remove the directory 'src/proto_${version}'" exit 1 fi @@ -34,10 +34,11 @@ if [ -d docs/${version} ] ; then fi # create a temporary directory until the hash is known -# this is equivalent to `cp src/proto_alpha/ src/proto_${version}` but only for versioned files +# this is equivalent to `cp src/proto_alpha/ src/proto_${version}` but only for +# versioned files mkdir /tmp/tezos_proto_snapshot git archive HEAD src/proto_alpha/ | tar -x -C /tmp/tezos_proto_snapshot -mv /tmp/tezos_proto_snapshot/src/proto_alpha src/proto_${version} +mv /tmp/tezos_proto_snapshot/src/proto_alpha src/proto_"${version}" rm -rf /tmp/tezos_proto_snapshot mkdir /tmp/tezos_proto_doc_snapshot @@ -47,18 +48,18 @@ rm -rf /tmp/tezos_proto_doc_snapshot # set current version -sed -i.old.old -e 's/let version_value = "alpha_current"/let version_value = "'${current}'"/' \ - src/proto_${version}/lib_protocol/raw_context.ml +sed -i.old.old -e 's/let version_value = "alpha_current"/let version_value = "'"${current}"'"/' \ + src/proto_"${version}"/lib_protocol/raw_context.ml -long_hash=$(./tezos-protocol-compiler -hash-only src/proto_${version}/lib_protocol) -short_hash=$(echo $long_hash | head -c 8) +long_hash=$(./tezos-protocol-compiler -hash-only src/proto_"${version}"/lib_protocol) +short_hash=$(echo "$long_hash" | head -c 8) -if [ -d src/proto_${version}_${short_hash} ] ; then +if [ -d src/proto_"${version}"_"${short_hash}" ]; then echo "Error: you should remove the directory 'src/proto_${version}_${short_hash}'" exit 1 fi -mv src/proto_${version} src/proto_${version}_${short_hash} +mv src/proto_"${version}" src/proto_"${version}"_"${short_hash}" # fix versionned links (in labels, references, and paths) in docs cd docs/${version} @@ -71,30 +72,37 @@ sed -i.old -e s/_alpha:/_${version}:/g \ cd ../.. # move daemons to a tmp directory to avoid editing lib_protocol -cd src/proto_${version}_${short_hash} -daemons=$(ls | grep -v lib_protocol) +cd src/proto_"$version"_"$short_hash" + +shopt -s extglob +daemons=$(ls -d !(lib_protocol)) mkdir tmp +# word splitting in needed to list all directory +#shellcheck disable=SC2086 mv $daemons tmp cd tmp # rename main_*.ml{,i} files of the binaries -for file in $(find . -name main_\*.ml -or -name main_\*.mli) -do - mv "$file" $(echo "$file" | sed s/_alpha/_${version}_${short_hash}/g) -done - +find . -name main_\*.ml -or -name main_\*.mli | + while IFS= read -r file; do + mv "$file" "${file/_alpha/_${version}_${short_hash}}" + done # rename .opam files -for file in $(find . -name \*.opam) -do - mv "$file" $(echo "$file" | sed s/alpha/${version}-${short_hash}/g) -done +find . -name \*alpha\*.opam | + while IFS= read -r file; do + mv "$file" "${file/alpha/${version}-${short_hash}}" + done # fix content of dune and opam files -sed -i.old -e s/_alpha/_${version}_${short_hash}/g \ - -e s/-alpha/-${version}-${short_hash}/g \ +# word splitting in needed to list all file +#shellcheck disable=SC2046 +sed -i.old -e s/_alpha/_"${version}"_"${short_hash}"/g \ + -e s/-alpha/-"${version}"-"${short_hash}"/g \ $(find . -name dune -or -name \*.opam) +# word splitting in needed to list all file +#shellcheck disable=SC2086 mv $daemons .. cd .. rmdir tmp @@ -102,29 +110,36 @@ rmdir tmp cd lib_protocol # replace fake hash with real hash, this file doesn't influence the hash -sed -i.old -e 's/"hash": "[^"]*",/"hash": "'$long_hash'",/' \ +sed -i.old -e 's/"hash": "[^"]*",/"hash": "'"${long_hash}"'",/' \ TEZOS_PROTOCOL -sed -i.old -e s/protocol_alpha/protocol_${version}_${short_hash}/ \ - -e s/protocol-alpha/protocol-${version}-${short_hash}/ \ +# word splitting in needed to list all file +#shellcheck disable=SC2046 +sed -i.old -e s/protocol_alpha/protocol_"${version}"_"${short_hash}"/ \ + -e s/protocol-alpha/protocol-"${version}"-"${short_hash}"/ \ + -e s/protocol-functor-alpha/protocol-functor-"${version}"-"${short_hash}"/ \ $(find . -type f) -sed -i.old -e s/-alpha/-${version}-${short_hash}/ \ - -e s/_alpha/_${version}_${short_hash}/ \ +# word splitting in needed to list all file +#shellcheck disable=SC2046 +sed -i.old -e s/-alpha/-"${version}"-"${short_hash}"/ \ + -e s/_alpha/_"${version}"_"${short_hash}"/ \ $(find . -type f -name dune) # replace fist the template call with underscore version, # then the other occurrences with dash version -sed -i.old -e 's/"alpha"/"'${version}_${short_hash}'"/' \ - -e 's/alpha/'${version}-${short_hash}'/' \ +# word splitting in needed to list all file +#shellcheck disable=SC2046 +sed -i.old -e 's/"alpha"/"'"${version}"_"${short_hash}"'"/' \ + -e 's/alpha/'"${version}"-"${short_hash}"'/' \ $(find . -name \*.opam) -for file in $(find . -name \*.opam) -do - mv "$file" $(echo "$file" | sed s/alpha/${version}-${short_hash}/g) -done +find . -name \*alpha\*.opam | + while IFS= read -r file; do + mv "$file" "${file/alpha/${version}-${short_hash}}" + done -dune exec ../../lib_protocol_compiler/replace.exe ../../lib_protocol_compiler/dune_protocol.template dune.inc ../../lib_protocol_compiler/final_protocol_versions ${version}_${short_hash} +dune exec ../../lib_protocol_compiler/replace.exe ../../lib_protocol_compiler/dune_protocol.template dune.inc ../../lib_protocol_compiler/final_protocol_versions "${version}"_"${short_hash}" cd ../../.. @@ -132,9 +147,9 @@ cd ../../.. find . -name '*.old' -exec rm {} \; if [ -z "$SILENCE_REMINDER" ]; then - echo "Generated src/proto_${version}_${short_hash}. Don't forget to:" - echo "" - echo " ./scripts/update_unit_test.sh" - echo " ./scripts/update_integration_test.sh" - echo " ./scripts/update_opam_test.sh" + echo "Generated src/proto_${version}_${short_hash}. Don't forget to:" + echo "" + echo " ./scripts/update_unit_test.sh" + echo " ./scripts/update_integration_test.sh" + echo " ./scripts/update_opam_test.sh" fi diff --git a/scripts/snapshot_alpha_and_link.sh b/scripts/snapshot_alpha_and_link.sh index 24239da5bebeb151585402dc8434eaba4be5c974..bb0586be433ea025dbfd662acc21513e914de7aa 100755 --- a/scripts/snapshot_alpha_and_link.sh +++ b/scripts/snapshot_alpha_and_link.sh @@ -14,41 +14,46 @@ script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" cd "$script_dir"/.. if [ -z "$2" ]; then - echo "$usage" - exit 1 + echo "$usage" + exit 1 fi version_number="$1" name="$2" echo "snapshot_alpha.sh ${name}_${version_number}" -SILENCE_REMINDER=yes $script_dir/snapshot_alpha.sh ${name}_${version_number} +SILENCE_REMINDER=yes "$script_dir"/snapshot_alpha.sh "${name}"_"${version_number}" -dir=$(ls -d src/proto_${version_number}_*) +dir=$(ls -d src/proto_"${version_number}"_*) if [ -z "$dir" ]; then - echo "Failed to find where the protocol was snapshotted." - exit 1 + echo "Failed to find where the protocol was snapshotted." + exit 1 fi -short_hash=$(basename $dir | awk -F'_' '{print $3}') +short_hash=$(basename "$dir" | awk -F'_' '{print $3}') if [ -z "$short_hash" ]; then - echo "Failed to extract protocol short hash from directory name: $dir" - exit 1 + echo "Failed to extract protocol short hash from directory name: $dir" + exit 1 fi echo "update_unit_test.sh" -$script_dir/update_unit_test.sh +"$script_dir"/update_unit_test.sh echo "update_integration_test.sh" -$script_dir/update_integration_test.sh +"$script_dir"/update_integration_test.sh echo "update_opam_test.sh" -$script_dir/update_opam_test.sh +"$script_dir"/update_opam_test.sh echo "link_protocol.sh src/proto_${version_number}_${short_hash}" -$script_dir/link_protocol.sh src/proto_${version_number}_${short_hash} +"$script_dir"/link_protocol.sh src/proto_"${version_number}"_"${short_hash}" + +# activate in snapshoted protocol in +full_hash=$(jq .hash <"$dir"/lib_protocol/TEZOS_PROTOCOL | cut -d "\"" -f 2) +echo "add protocol to final protocol version" +echo "${full_hash}" >>src/lib_protocol_compiler/final_protocol_versions echo "Done. You can now commit everything." echo "Don't forget to: git add src/proto_${version_number}_${short_hash}" diff --git a/scripts/user_activated_upgrade.sh b/scripts/user_activated_upgrade.sh index 6c72b1ec3f2004066068dc16172aa53ff37a41e0..65bb0cbee3b35f4860f29e1a2b1bbc52be076cc7 100755 --- a/scripts/user_activated_upgrade.sh +++ b/scripts/user_activated_upgrade.sh @@ -34,29 +34,40 @@ fi if [[ $1 =~ ^.*/proto_[0-9]{3}_.*$ ]] then - version=$(echo "$1" | sed 's/.*proto_\([0-9]\{3\}\)_.*/\1/') - pred=$(printf "%03d" $((10#$version -1))) - pred_full_hash=$(jq -r .hash < src/proto_${pred}_*/lib_protocol/TEZOS_PROTOCOL) - pred_short_hash=$(echo $pred_full_hash | head -c 8) - - full_hash=$(jq -r .hash < $1/lib_protocol/TEZOS_PROTOCOL) + version=$(echo "$1" | sed 's/.*proto_\([0-9]\{3\}\)_.*/\1/' | bc) + pred_version=$(printf "%03d" $((version - 1))) + # This if-then-else is to remove when 008 is the active protocol anymore as + # we wont need to migrate from 008 anymore + if [[ ${pred_version#00} = 8 ]] + then + pred_full_hash=$(jq -r .hash < src/proto_008_PtEdo2Zk/lib_protocol/TEZOS_PROTOCOL) + else + pred_full_hash=$(jq -r .hash < src/proto_${pred_version}_*/lib_protocol/TEZOS_PROTOCOL) + fi + pred_short_hash=$(echo "$pred_full_hash" | head -c 8) + + full_hash=$(jq -r .hash < "$1"/lib_protocol/TEZOS_PROTOCOL) else pred_version_dir=$(find src -name "proto_00*" -printf '%P\n' | sort -r | head -1) - pred=$(echo $pred_version_dir | cut -d'_' -f2) - pred_full_hash=$(jq -r .hash < src/proto_${pred}_*/lib_protocol/TEZOS_PROTOCOL) - pred_short_hash=$(echo $pred_full_hash | head -c 8) + pred_version=$(echo "$pred_version_dir" | cut -d'_' -f2 | bc) + + version=$(printf "%03d" $((pred_version + 1))) - version=$((pred +1)) + # This line could be merged to previous assignment but it's need because + # bash consider "008" to be octal + pred_version=$(printf "%03d" "$pred_version") + pred_full_hash=$(jq -r .hash < src/proto_"${pred_version}"_*/lib_protocol/TEZOS_PROTOCOL) + pred_short_hash=$(echo "$pred_full_hash" | head -c 8) full_hash=$(jq -r .hash < src/proto_alpha/lib_protocol/TEZOS_PROTOCOL) fi level=$2 -if (( $level > 28082 )); then +if (( level > 28082 )); then # we are on a real network and we need a yes-node and yes-wallet to bake # replace existing upgrades - awk -v level=$level -v full_hash=$full_hash ' + awk -v level="$level" -v full_hash="$full_hash" ' BEGIN{found=0}{ if (!found && $0 ~ "~user_activated_upgrades") {found=1; printf " ~user_activated_upgrades:\n [ (%dl, \"%s\") ]\n", level, full_hash} @@ -72,16 +83,16 @@ else { else # we are in sandbox # add upgrade to the sandbox - awk -v level=$level -v full_hash=$full_hash ' + awk -v level="$level" -v full_hash="$full_hash" ' { print if ($0 ~ "~alias:\"sandbox\"") { printf " ~user_activated_upgrades:\n [ (%dl, \"%s\") ]\n", level, full_hash } }' src/bin_node/node_config_file.ml > tmp_file mv tmp_file src/bin_node/node_config_file.ml - sed -i.old "s/\$bin_dir\/..\/proto_alpha\/parameters\/sandbox-parameters.json/\$bin_dir\/..\/proto_${pred}_${pred_short_hash}\/parameters\/sandbox-parameters.json/" src/bin_client/tezos-init-sandboxed-client.sh - sed -i.old "s/activate_alpha()/activate_${pred}_${pred_short_hash}()/" src/bin_client/tezos-init-sandboxed-client.sh - sed -i.old "s/tezos-activate-alpha/tezos-activate-${pred}-${pred_short_hash}/" src/bin_client/tezos-init-sandboxed-client.sh + sed -i.old "s/\$bin_dir\/..\/proto_alpha\/parameters\/sandbox-parameters.json/\$bin_dir\/..\/proto_${pred_version}_${pred_short_hash}\/parameters\/sandbox-parameters.json/" src/bin_client/tezos-init-sandboxed-client.sh + sed -i.old "s/activate_alpha()/activate_${pred_version}_${pred_short_hash}()/" src/bin_client/tezos-init-sandboxed-client.sh + sed -i.old "s/tezos-activate-alpha/tezos-activate-${pred_version}-${pred_short_hash}/" src/bin_client/tezos-init-sandboxed-client.sh sed -i.old "s/activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK/activate protocol $pred_full_hash/" src/bin_client/tezos-init-sandboxed-client.sh rm src/bin_client/tezos-init-sandboxed-client.sh.old echo "The sandbox will now switch to $full_hash at level $level." diff --git a/src/lib_shell/validator.ml b/src/lib_shell/validator.ml index b9260878d92f56e3431cfaf99f203597782a01b7..5ce6a72b20fb2dd55b135d325e322ef82a829ff7 100644 --- a/src/lib_shell/validator.ml +++ b/src/lib_shell/validator.ml @@ -103,41 +103,48 @@ let validate_block v ?(force = false) ?chain_id bytes operations = | None -> failwith "Cannot parse block header." | Some block -> - if not (Clock_drift.is_not_too_far_in_the_future block.shell.timestamp) - then failwith "Block in the future." - else - ( match chain_id with - | None -> ( - Distributed_db.read_block_header v.db block.shell.predecessor + fail_unless + ( force + || Clock_drift.is_not_too_far_in_the_future block.shell.timestamp ) + (Validation_errors.Future_block_header + { + block = hash; + time = Systime_os.now (); + block_time = block.shell.timestamp; + }) + >>=? fun () -> + ( match chain_id with + | None -> ( + Distributed_db.read_block_header v.db block.shell.predecessor + >>= function + | None -> + failwith + "Unknown predecessor (%a), cannot inject the block." + Block_hash.pp_short + block.shell.predecessor + | Some (chain_id, _bh) -> + Lwt.return (get v chain_id) ) + | Some chain_id -> ( + Lwt.return (get v chain_id) + >>=? fun nv -> + if force then return nv + else + Distributed_db.Block_header.known + (Chain_validator.chain_db nv) + block.shell.predecessor >>= function - | None -> + | true -> + return nv + | false -> failwith "Unknown predecessor (%a), cannot inject the block." Block_hash.pp_short - block.shell.predecessor - | Some (chain_id, _bh) -> - Lwt.return (get v chain_id) ) - | Some chain_id -> ( - Lwt.return (get v chain_id) - >>=? fun nv -> - if force then return nv - else - Distributed_db.Block_header.known - (Chain_validator.chain_db nv) - block.shell.predecessor - >>= function - | true -> - return nv - | false -> - failwith - "Unknown predecessor (%a), cannot inject the block." - Block_hash.pp_short - block.shell.predecessor ) ) - >>=? fun nv -> - let validation = - Chain_validator.validate_block nv ~force hash block operations - in - return (hash, validation) + block.shell.predecessor ) ) + >>=? fun nv -> + let validation = + Chain_validator.validate_block nv ~force hash block operations + in + return (hash, validation) let shutdown {active_chains; block_validator; _} = let chain_validator_jobs = diff --git a/src/lib_shell_services/validation_errors.ml b/src/lib_shell_services/validation_errors.ml index 57cff413db8f3dab11e61a0c65f09ef41f5aac56..69d319fde2c6fc42a3eceee93eb519a88dc6d021 100644 --- a/src/lib_shell_services/validation_errors.ml +++ b/src/lib_shell_services/validation_errors.ml @@ -87,7 +87,7 @@ let () = ~pp:(fun ppf (block, block_time, time) -> Format.fprintf ppf - "Future block header (block: %a, block_time: %a, time: %a)" + "Received a block (%a) in the future: Current time: %a, Block time: %a." Block_hash.pp block Time.System.pp_hum diff --git a/src/proto_alpha/lib_client/dune b/src/proto_alpha/lib_client/dune index a4887b4a3f18eee0f600f15ad47158c3d6d782cd..9e08c5bd32c72510bc8d0ca0a8ea9e2fcac1574c 100644 --- a/src/proto_alpha/lib_client/dune +++ b/src/proto_alpha/lib_client/dune @@ -17,6 +17,7 @@ -open Tezos_client_base -open Tezos_protocol_alpha -open Tezos_protocol_alpha_parameters + -open Tezos_protocol_plugin_alpha -open Tezos_rpc))) (rule diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index c98807e07d6e5283db3e7b3374d69675ef37226e..709bb78811a438b65c12fada2f142e86348eea04 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -504,7 +504,7 @@ let () = module Protocol = Protocol_client_context.Lifted_protocol module Block_services = Protocol_client_context.Alpha_block_services - let directory = Tezos_protocol_plugin_alpha.Plugin.RPC.rpc_services + let directory = Plugin.RPC.rpc_services let init = mem_init diff --git a/src/proto_alpha/lib_client/proxy.ml b/src/proto_alpha/lib_client/proxy.ml index 0d2ddf8f32bca4fe68f610150d9a405e0c14b67e..20dcedf6e6876ac7ebc73963da0365cc9aa24511 100644 --- a/src/proto_alpha/lib_client/proxy.ml +++ b/src/proto_alpha/lib_client/proxy.ml @@ -131,7 +131,7 @@ let () = let protocol_hash = Protocol.hash - let directory = Tezos_protocol_plugin_alpha.Plugin.RPC.rpc_services + let directory = Plugin.RPC.rpc_services let hash = Protocol_client_context.Alpha_block_services.hash diff --git a/src/proto_alpha/lib_plugin/dune b/src/proto_alpha/lib_plugin/dune index a45df7a6bbf86819f6b619481161ad587e56fa7f..33d1a889f1debbb00fe0ca14fe8ce87aa5df263c 100644 --- a/src/proto_alpha/lib_plugin/dune +++ b/src/proto_alpha/lib_plugin/dune @@ -18,7 +18,8 @@ (modules Registerer) (flags (:standard -open Tezos_base__TzPervasives -open Tezos_protocol_plugin_alpha - -open Tezos_shell))) + -open Tezos_shell + -open Tezos_protocol_plugin_alpha))) (rule (alias runtest_lint) diff --git a/src/proto_alpha/lib_plugin/registerer.ml b/src/proto_alpha/lib_plugin/registerer.ml index 2c9c465a125aee8040492268f903b92cfc7d609b..8824909c91c6f72ba31d00852ac9d0455ac79882 100644 --- a/src/proto_alpha/lib_plugin/registerer.ml +++ b/src/proto_alpha/lib_plugin/registerer.ml @@ -23,5 +23,4 @@ (* *) (*****************************************************************************) -let () = - Prevalidator_filters.register (module Tezos_protocol_plugin_alpha.Plugin) +let () = Prevalidator_filters.register (module Plugin) diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index ef48542ef60c7b21c591cedc0e27f250ee3ab5b1..b42bd0df8890c33ce4f7db80d924f87f05f24cde 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -71,6 +71,10 @@ let inject_block ?node ?hooks ~data client = let path = ["injection"; "block"] in Client.rpc ?node ?hooks ~data POST path client +let get_metadata ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = ["chains"; chain; "blocks"; block; "metadata"] in + Client.rpc ?node ?hooks GET path client + module Proto_alpha = struct let get_constants ?node ?hooks ?(chain = "main") ?(block = "head") client = let path = ["chains"; chain; "blocks"; block; "context"; "constants"] in @@ -411,7 +415,347 @@ module Proto_alpha = struct end end -module Proto_007 = struct +module Proto_008_edo = struct + let get_constants ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = ["chains"; chain; "blocks"; block; "context"; "constants"] in + Client.rpc ?node ?hooks GET path client + + let get_constants_errors ?node ?hooks ?(chain = "main") ?(block = "head") + client = + let path = + ["chains"; chain; "blocks"; block; "context"; "constants"; "errors"] + in + Client.rpc ?node ?hooks GET path client + + let get_baking_rights ?node ?hooks ?(chain = "main") ?(block = "head") + ?delegate client = + let path = + ["chains"; chain; "blocks"; block; "helpers"; "baking_rights"] + in + let query_string = Option.map (fun d -> [("delegate", d)]) delegate in + Client.rpc ?node ?hooks ?query_string GET path client + + let get_current_level ?node ?hooks ?(chain = "main") ?(block = "head") + ?(offset = 0) client = + let path = + ["chains"; chain; "blocks"; block; "helpers"; "current_level"] + in + let query_string = [("offset", string_of_int offset)] in + Client.rpc ?node ?hooks ~query_string GET path client + + let get_endorsing_rights ?node ?hooks ?(chain = "main") ?(block = "head") + ?delegate client = + let path = + ["chains"; chain; "blocks"; block; "helpers"; "endorsing_rights"] + in + let query_string = Option.map (fun d -> [("delegate", d)]) delegate in + Client.rpc ?node ?hooks ?query_string GET path client + + let get_levels_in_current_cycle ?node ?hooks ?(chain = "main") + ?(block = "head") client = + let path = + ["chains"; chain; "blocks"; block; "helpers"; "levels_in_current_cycle"] + in + Client.rpc ?node ?hooks GET path client + + module Contract = struct + let spawn_get_all ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = ["chains"; chain; "blocks"; block; "context"; "contracts"] in + Client.spawn_rpc ?node ?hooks GET path client + + let get_all ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = ["chains"; chain; "blocks"; block; "context"; "contracts"] in + let* contracts = Client.rpc ?node ?hooks GET path client in + return (JSON.as_list contracts |> List.map JSON.as_string) + + let spawn_get ?node ?hooks ?(chain = "main") ?(block = "head") ~contract_id + client = + let path = + ["chains"; chain; "blocks"; block; "context"; "contracts"; contract_id] + in + Client.spawn_rpc ?node ?hooks GET path client + + let get ?node ?hooks ?(chain = "main") ?(block = "head") ~contract_id + client = + let path = + ["chains"; chain; "blocks"; block; "context"; "contracts"; contract_id] + in + Client.rpc ?node ?hooks GET path client + + let sub_path ~chain ~block ~contract_id field = + [ "chains"; + chain; + "blocks"; + block; + "context"; + "contracts"; + contract_id; + field ] + + let spawn_get_sub ?node ?hooks ~chain ~block ~contract_id field client = + let path = sub_path ~chain ~block ~contract_id field in + Client.spawn_rpc ?node ?hooks GET path client + + let get_sub ?node ?hooks ~chain ~block ~contract_id field client = + let path = sub_path ~chain ~block ~contract_id field in + Client.rpc ?node ?hooks GET path client + + let spawn_get_balance ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + spawn_get_sub ?node ?hooks ~chain ~block ~contract_id "balance" client + + let get_balance ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + get_sub ?node ?hooks ~chain ~block ~contract_id "balance" client + + let spawn_big_map_get ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id ~data client = + let path = sub_path ~chain ~block ~contract_id "big_map_get" in + Client.spawn_rpc ?node ?hooks ~data POST path client + + let big_map_get ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id ~data client = + let path = sub_path ~chain ~block ~contract_id "big_map_get" in + Client.rpc ?node ?hooks ~data POST path client + + let spawn_get_counter ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + spawn_get_sub ?node ?hooks ~chain ~block ~contract_id "counter" client + + let get_counter ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + get_sub ?node ?hooks ~chain ~block ~contract_id "counter" client + + let spawn_get_delegate ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + spawn_get_sub ?node ?hooks ~chain ~block ~contract_id "delegate" client + + let get_delegate ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + get_sub ?node ?hooks ~chain ~block ~contract_id "delegate" client + + let spawn_get_entrypoints ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + spawn_get_sub + ?node + ?hooks + ~chain + ~block + ~contract_id + "entrypoints" + client + + let get_entrypoints ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + get_sub ?node ?hooks ~chain ~block ~contract_id "entrypoints" client + + let spawn_get_manager_key ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + spawn_get_sub + ?node + ?hooks + ~chain + ~block + ~contract_id + "manager_key" + client + + let get_manager_key ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + get_sub ?node ?hooks ~chain ~block ~contract_id "manager_key" client + + let spawn_get_script ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + spawn_get_sub ?node ?hooks ~chain ~block ~contract_id "script" client + + let get_script ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + get_sub ?node ?hooks ~chain ~block ~contract_id "script" client + + let spawn_get_storage ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + spawn_get_sub ?node ?hooks ~chain ~block ~contract_id "storage" client + + let get_storage ?node ?hooks ?(chain = "main") ?(block = "head") + ~contract_id client = + get_sub ?node ?hooks ~chain ~block ~contract_id "storage" client + end + + module Delegate = struct + let spawn_get_all ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = ["chains"; chain; "blocks"; block; "context"; "delegates"] in + Client.spawn_rpc ?node ?hooks GET path client + + let get_all ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = ["chains"; chain; "blocks"; block; "context"; "delegates"] in + let* contracts = Client.rpc ?node ?hooks GET path client in + return (JSON.as_list contracts |> List.map JSON.as_string) + + let spawn_get ?node ?hooks ?(chain = "main") ?(block = "head") ~pkh client + = + let path = + ["chains"; chain; "blocks"; block; "context"; "delegates"; pkh] + in + Client.spawn_rpc ?node ?hooks GET path client + + let get ?node ?hooks ?(chain = "main") ?(block = "head") ~pkh client = + let path = + ["chains"; chain; "blocks"; block; "context"; "delegates"; pkh] + in + Client.rpc ?node ?hooks GET path client + + let sub_path ~chain ~block ~pkh field = + ["chains"; chain; "blocks"; block; "context"; "delegates"; pkh; field] + + let spawn_get_sub ?node ?hooks ~chain ~block ~pkh field client = + let path = sub_path ~chain ~block ~pkh field in + Client.spawn_rpc ?node ?hooks GET path client + + let get_sub ?node ?hooks ~chain ~block ~pkh field client = + let path = sub_path ~chain ~block ~pkh field in + Client.rpc ?node ?hooks GET path client + + let spawn_get_balance ?node ?hooks ?(chain = "main") ?(block = "head") ~pkh + client = + spawn_get_sub ?node ?hooks ~chain ~block ~pkh "balance" client + + let get_balance ?node ?hooks ?(chain = "main") ?(block = "head") ~pkh + client = + get_sub ?node ?hooks ~chain ~block ~pkh "balance" client + + let spawn_get_deactivated ?node ?hooks ?(chain = "main") ?(block = "head") + ~pkh client = + spawn_get_sub ?node ?hooks ~chain ~block ~pkh "deactivated" client + + let get_deactivated ?node ?hooks ?(chain = "main") ?(block = "head") ~pkh + client = + get_sub ?node ?hooks ~chain ~block ~pkh "deactivated" client + + let spawn_get_delegated_balance ?node ?hooks ?(chain = "main") + ?(block = "head") ~pkh client = + spawn_get_sub ?node ?hooks ~chain ~block ~pkh "delegated_balance" client + + let get_delegated_balance ?node ?hooks ?(chain = "main") ?(block = "head") + ~pkh client = + get_sub ?node ?hooks ~chain ~block ~pkh "delegated_balance" client + + let spawn_get_delegated_contracts ?node ?hooks ?(chain = "main") + ?(block = "head") ~pkh client = + spawn_get_sub + ?node + ?hooks + ~chain + ~block + ~pkh + "delegated_contracts" + client + + let get_delegated_contracts ?node ?hooks ?(chain = "main") + ?(block = "head") ~pkh client = + get_sub ?node ?hooks ~chain ~block ~pkh "delegated_contracts" client + + let spawn_get_frozen_balance ?node ?hooks ?(chain = "main") + ?(block = "head") ~pkh client = + spawn_get_sub ?node ?hooks ~chain ~block ~pkh "frozen_balance" client + + let get_frozen_balance ?node ?hooks ?(chain = "main") ?(block = "head") + ~pkh client = + get_sub ?node ?hooks ~chain ~block ~pkh "frozen_balance" client + + let spawn_get_frozen_balance_by_cycle ?node ?hooks ?(chain = "main") + ?(block = "head") ~pkh client = + spawn_get_sub + ?node + ?hooks + ~chain + ~block + ~pkh + "frozen_balance_by_cycle" + client + + let get_frozen_balance_by_cycle ?node ?hooks ?(chain = "main") + ?(block = "head") ~pkh client = + get_sub ?node ?hooks ~chain ~block ~pkh "frozen_balance_by_cycle" client + + let spawn_get_grace_period ?node ?hooks ?(chain = "main") ?(block = "head") + ~pkh client = + spawn_get_sub ?node ?hooks ~chain ~block ~pkh "grace_period" client + + let get_grace_period ?node ?hooks ?(chain = "main") ?(block = "head") ~pkh + client = + get_sub ?node ?hooks ~chain ~block ~pkh "grace_period" client + + let spawn_get_staking_balance ?node ?hooks ?(chain = "main") + ?(block = "head") ~pkh client = + spawn_get_sub ?node ?hooks ~chain ~block ~pkh "staking_balance" client + + let get_staking_balance ?node ?hooks ?(chain = "main") ?(block = "head") + ~pkh client = + get_sub ?node ?hooks ~chain ~block ~pkh "staking_balance" client + + let spawn_get_voting_power ?node ?hooks ?(chain = "main") ?(block = "head") + ~pkh client = + spawn_get_sub ?node ?hooks ~chain ~block ~pkh "voting_power" client + + let get_voting_power ?node ?hooks ?(chain = "main") ?(block = "head") ~pkh + client = + get_sub ?node ?hooks ~chain ~block ~pkh "voting_power" client + end + + module Votes = struct + let sub_path ~chain ~block sub = + ["chains"; chain; "blocks"; block; "votes"; sub] + + let get_ballot_list ?node ?hooks ?(chain = "main") ?(block = "head") client + = + let path = sub_path ~chain ~block "ballot_list" in + Client.rpc ?node ?hooks GET path client + + let get_ballots ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = sub_path ~chain ~block "ballots" in + Client.rpc ?node ?hooks GET path client + + let get_current_period ?node ?hooks ?(chain = "main") ?(block = "head") + client = + let path = sub_path ~chain ~block "current_period" in + Client.rpc ?node ?hooks GET path client + + let get_successor_period ?node ?hooks ?(chain = "main") ?(block = "head") + client = + let path = sub_path ~chain ~block "successor_period" in + Client.rpc ?node ?hooks GET path client + + let get_current_period_kind ?node ?hooks ?(chain = "main") + ?(block = "head") client = + let path = sub_path ~chain ~block "current_period_kind" in + Client.rpc ?node ?hooks GET path client + + let get_current_proposal ?node ?hooks ?(chain = "main") ?(block = "head") + client = + let path = sub_path ~chain ~block "current_proposal" in + Client.rpc ?node ?hooks GET path client + + let get_current_quorum ?node ?hooks ?(chain = "main") ?(block = "head") + client = + let path = sub_path ~chain ~block "current_quorum" in + Client.rpc ?node ?hooks GET path client + + let get_listings ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = sub_path ~chain ~block "listings" in + Client.rpc ?node ?hooks GET path client + + let get_proposals ?node ?hooks ?(chain = "main") ?(block = "head") client = + let path = sub_path ~chain ~block "proposals" in + Client.rpc ?node ?hooks GET path client + + let get_total_voting_power ?node ?hooks ?(chain = "main") ?(block = "head") + client = + let path = sub_path ~chain ~block "total_voting_power" in + Client.rpc ?node ?hooks GET path client + end +end + +module Proto_007_delphi = struct let get_constants ?node ?hooks ?(chain = "main") ?(block = "head") client = let path = ["chains"; chain; "blocks"; block; "context"; "constants"] in Client.rpc ?node ?hooks GET path client diff --git a/tezt/lib_tezos/RPC.mli b/tezt/lib_tezos/RPC.mli index 7be333cc6174000c4ff8a8e4d2b2905aad978017..01b7497b36271ccf425946ad94628066f5a140ba 100644 --- a/tezt/lib_tezos/RPC.mli +++ b/tezt/lib_tezos/RPC.mli @@ -104,6 +104,15 @@ val preapply_block : Client.t -> JSON.t Lwt.t +(** Call RPC /chain/[chain]/blocks/[block]/metadata *) +val get_metadata : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + module Proto_alpha : sig (** Call RPC /chain/[chain]/blocks/[block]/context/constants *) val get_constants : @@ -677,7 +686,580 @@ module Proto_alpha : sig end end -module Proto_007 : sig +module Proto_008_edo : sig + (** Call RPC /chain/[chain]/blocks/[block]/context/constants *) + val get_constants : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/constants/errors *) + val get_constants_errors : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/helpers/baking_rights *) + val get_baking_rights : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + ?delegate:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/helpers/current_level *) + val get_current_level : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + ?offset:int -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/helpers/endorsing_rights *) + val get_endorsing_rights : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + ?delegate:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/helpers/levels_in_current_cycle *) + val get_levels_in_current_cycle : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + module Contract : sig + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts *) + val get_all : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + string list Lwt.t + + (** Same as [get_all], but do not wait for the process to exit. *) + val spawn_get_all : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id] *) + val get : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get], but do not wait for the process to exit. *) + val spawn_get : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/balance *) + val get_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_balance], but do not wait for the process to exit. *) + val spawn_get_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/big_map_get *) + val big_map_get : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + data:JSON.u -> + Client.t -> + JSON.t Lwt.t + + (** Same as [big_map_get], but do not wait for the process to exit. *) + val spawn_big_map_get : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + data:JSON.u -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/counter *) + val get_counter : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_counter], but do not wait for the process to exit. *) + val spawn_get_counter : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/delegate *) + val get_delegate : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_delegate], but do not wait for the process to exit. *) + val spawn_get_delegate : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/entrypoints *) + val get_entrypoints : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_entrypoints], but do not wait for the process to exit. *) + val spawn_get_entrypoints : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/manager_key *) + val get_manager_key : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_manager_key], but do not wait for the process to exit. *) + val spawn_get_manager_key : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/script *) + val get_script : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_script], but do not wait for the process to exit. *) + val spawn_get_script : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/contracts/[contract_id]/storage *) + val get_storage : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_storage], but do not wait for the process to exit. *) + val spawn_get_storage : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + contract_id:string -> + Client.t -> + Process.t + end + + module Delegate : sig + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates *) + val get_all : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + string list Lwt.t + + (** Same as [get_all], but do not wait for the process to exit. *) + val spawn_get_all : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh] *) + val get : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get], but do not wait for the process to exit. *) + val spawn_get : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/balance *) + val get_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_balance], but do not wait for the process to exit. *) + val spawn_get_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/deactivated *) + val get_deactivated : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_deactivated], but do not wait for the process to exit. *) + val spawn_get_deactivated : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/delegated_balance *) + val get_delegated_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_delegated_balance], but do not wait for the process to exit. *) + val spawn_get_delegated_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/delegated_contracts *) + val get_delegated_contracts : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_delegated_contracts], but do not wait for the process to exit. *) + val spawn_get_delegated_contracts : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/frozen_balance *) + val get_frozen_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_frozen_balance], but do not wait for the process to exit. *) + val spawn_get_frozen_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/frozen_balance_by_cycle *) + val get_frozen_balance_by_cycle : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_frozen_balance_by_cycle], but do not wait for the process to exit. *) + val spawn_get_frozen_balance_by_cycle : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/grace_period *) + val get_grace_period : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_grace_period], but do not wait for the process to exit. *) + val spawn_get_grace_period : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/staking_balance *) + val get_staking_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_staking_balance], but do not wait for the process to exit. *) + val spawn_get_staking_balance : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + + (** Call RPC /chain/[chain]/blocks/[block]/context/delegates/[pkh]/voting_power *) + val get_voting_power : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + JSON.t Lwt.t + + (** Same as [get_voting_power], but do not wait for the process to exit. *) + val spawn_get_voting_power : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + pkh:string -> + Client.t -> + Process.t + end + + module Votes : sig + (** Call RPC /chain/[chain]/blocks/[block]/votes/ballot_list *) + val get_ballot_list : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/ballots *) + val get_ballots : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/current_period *) + val get_current_period : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/successor_period *) + val get_successor_period : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/current_period_kind *) + val get_current_period_kind : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/current_proposal *) + val get_current_proposal : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/current_quorum *) + val get_current_quorum : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/listings *) + val get_listings : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/proposals *) + val get_proposals : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + + (** Call RPC /chain/[chain]/blocks/[block]/votes/total_voting_power *) + val get_total_voting_power : + ?node:Node.t -> + ?hooks:Process.hooks -> + ?chain:string -> + ?block:string -> + Client.t -> + JSON.t Lwt.t + end +end + +module Proto_007_delphi : sig (** Call RPC /chain/[chain]/blocks/[block]/context/constants *) val get_constants : ?node:Node.t -> diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 7e24ae2138089b8068036bcf9a19759948eaf650..664866062f960690e2caecd12d2a3ecccc541a10 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -272,7 +272,7 @@ let activate_protocol ?node ~protocol ?fitness ?key ?timestamp ?timestamp_delay |> Process.check let spawn_bake_for ?node ?protocol ?(key = Constant.bootstrap1.alias) - ?(minimal_timestamp = true) ?mempool ?force ?context_path client = + ?(minimal_timestamp = true) ?mempool ?(force = false) ?context_path client = spawn_command ?node client @@ -286,7 +286,7 @@ let spawn_bake_for ?node ?protocol ?(key = Constant.bootstrap1.alias) ~none:[] ~some:(fun mempool_json -> ["--mempool"; mempool_json]) mempool - @ (match force with None | Some false -> [] | Some true -> ["--force"]) + @ if force then ["--force"] else [] @ Option.fold ~none:[] ~some:(fun path -> ["--context"; path]) context_path ) @@ -518,6 +518,169 @@ let spawn_migrate_mockup ~next_protocol client = let migrate_mockup ~next_protocol client = spawn_migrate_mockup ~next_protocol client |> Process.check +let spawn_sapling_generate_key ?node ?(unencrypted = false) ?(force = false) + ~name client = + spawn_command + ?node + client + ( ["sapling"; "gen"; "key"; name] + @ (if unencrypted then ["--unencrypted"] else []) + @ if force then ["--force"] else [] ) + +let sapling_generate_key ?node ?unencrypted ?force ~name client = + spawn_sapling_generate_key ?node ?unencrypted ?force ~name client + |> Process.check + +let spawn_sapling_use_key ?node ?memo_size ~account ~contract client = + spawn_command + ?node + client + ( ["sapling"; "use"; "key"; account; "for"; "contract"; contract] + @ Option.fold + ~none:[] + ~some:(fun size -> ["--memo-size"; string_of_int size]) + memo_size ) + +let sapling_use_key ?node ?memo_size ~account ~contract client = + spawn_sapling_use_key ?node ?memo_size ~account ~contract client + |> Process.check + +let spawn_sapling_generate_address ?node ~account client = + spawn_command ?node client ["sapling"; "gen"; "address"; account] + +let sapling_generate_address ?node ~account client = + spawn_sapling_generate_address ?node ~account client |> Process.check + +let spawn_sapling_shield ?node ?(wait = "none") ?burn_cap ~amount ~source + ~target ~contract client = + spawn_command + ?node + client + ( ["--wait"; wait] + @ [ "sapling"; + "shield"; + string_of_int amount; + "from"; + source; + "to"; + target; + "using"; + contract ] + @ Option.fold + ~none:[] + ~some:(fun burn_cap -> ["--burn-cap"; string_of_int burn_cap]) + burn_cap ) + +let sapling_shield ?node ?wait ?burn_cap ~amount ~source ~target ~contract + client = + spawn_sapling_shield + ?node + ?wait + ?burn_cap + ~source + ~amount + ~target + ~contract + client + |> Process.check + +let spawn_sapling_unshield ?node ?(wait = "none") ?burn_cap ~amount ~source + ~target ~contract client = + spawn_command + ?node + client + ( ["--wait"; wait] + @ [ "sapling"; + "unshield"; + string_of_int amount; + "from"; + source; + "to"; + target; + "using"; + contract ] + @ Option.fold + ~none:[] + ~some:(fun burn_cap -> ["--burn-cap"; string_of_int burn_cap]) + burn_cap ) + +let sapling_unshield ?node ?wait ?burn_cap ~amount ~source ~target ~contract + client = + spawn_sapling_unshield + ?node + ?wait + ?burn_cap + ~source + ~amount + ~target + ~contract + client + |> Process.check + +let spawn_sapling_get_balance ?node ~account ~contract client = + spawn_command + ?node + client + ["sapling"; "get"; "balance"; "for"; account; "in"; "contract"; contract] + +let sapling_get_balance ?node ~account ~contract client = + spawn_sapling_get_balance ?node ~account ~contract client |> Process.check + +let spawn_sapling_forge_transaction ?node ~amount ~source ~target ~contract + client = + spawn_command + ?node + client + [ "sapling"; + "forge"; + "transaction"; + string_of_int amount; + "from"; + source; + "to"; + target; + "using"; + contract ] + +let sapling_forge_transaction ?node ~amount ~source ~target ~contract client = + spawn_sapling_forge_transaction + ?node + ~amount + ~source + ~target + ~contract + client + |> Process.check + +let spawn_sapling_submit_transaction ?node ?(wait = "none") ?burn_cap ~account + ~contract client = + spawn_command + ?node + client + ( ["--wait"; wait] + @ [ "sapling"; + "submit"; + "sapling_transaction"; + "from"; + account; + "using"; + contract ] + @ Option.fold + ~none:[] + ~some:(fun burn_cap -> ["--burn-cap"; string_of_int burn_cap]) + burn_cap ) + +let sapling_submit_transaction ?node ?wait ?burn_cap ~account ~contract client + = + spawn_sapling_submit_transaction + ?node + ?wait + ?burn_cap + ~account + ~contract + client + |> Process.check + let init ?path ?admin_path ?name ?color ?base_dir ?node () = let client = create ?path ?admin_path ?name ?color ?base_dir ?node () in let* () = diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 2e61105c937903ce8c52f53eaf39cfa2eb36c73f..67af70182acf0f8aeb4da8a4b2f8712f24f77546 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -336,7 +336,9 @@ val spawn_submit_ballot : ?key:string -> ?wait:string -> proto_hash:string -> ballot -> t -> Process.t (** Run [tezos-client originate contract alias transferring amount from src - running prg]. Returns the originated contract hash *) + running prg]. Returns the originated contract hash. + + Default [wait] is "none". *) val originate_contract : ?node:Node.t -> ?wait:string -> @@ -393,6 +395,161 @@ val migrate_mockup : next_protocol:Protocol.t -> t -> unit Lwt.t (** Same as [migrate_mockup], but do not wait for the process to exit. *) val spawn_migrate_mockup : next_protocol:Protocol.t -> t -> Process.t +(** Run [tezos-client sapling gen key name]. + + Default [unencrypted] is false and default [force] is false. *) +val sapling_generate_key : + ?node:Node.t -> + ?unencrypted:bool -> + ?force:bool -> + name:string -> + t -> + unit Lwt.t + +(** Same as [sapling_generate_key], but do not wait for the process to exit. *) +val spawn_sapling_generate_key : + ?node:Node.t -> + ?unencrypted:bool -> + ?force:bool -> + name:string -> + t -> + Process.t + +(** Run [tezos-client sapling use key account for contract contract]. *) +val sapling_use_key : + ?node:Node.t -> + ?memo_size:int -> + account:string -> + contract:string -> + t -> + unit Lwt.t + +(** Same as [sapling_use_key], but do not wait for the process to exit. *) +val spawn_sapling_use_key : + ?node:Node.t -> + ?memo_size:int -> + account:string -> + contract:string -> + t -> + Process.t + +(** Run [tezos-client gen address account]. *) +val sapling_generate_address : + ?node:Node.t -> account:string -> t -> unit Lwt.t + +(** Same as [sapling_generate_address], but do not wait for the process to + exit. *) +val spawn_sapling_generate_address : + ?node:Node.t -> account:string -> t -> Tezt.Process.t + +(** Run [tezos-client sapling shield amount from source to target using + contract]. + + Default [wait] is "none". *) +val sapling_shield : + ?node:Node.t -> + ?wait:string -> + ?burn_cap:int -> + amount:int -> + source:string -> + target:string -> + contract:string -> + t -> + unit Lwt.t + +(** Same as [sapling_shield], but do not wait for the process to exit. *) +val spawn_sapling_shield : + ?node:Node.t -> + ?wait:string -> + ?burn_cap:int -> + amount:int -> + source:string -> + target:string -> + contract:string -> + t -> + Process.t + +(** Run [tezos-client sapling unshield amount from source to target using + contract]. + + Default [wait] is "none". *) +val sapling_unshield : + ?node:Node.t -> + ?wait:string -> + ?burn_cap:int -> + amount:int -> + source:string -> + target:string -> + contract:string -> + t -> + unit Lwt.t + +(** Same as [sapling_unshield], but do not wait for the process to exit. *) +val spawn_sapling_unshield : + ?node:Node.t -> + ?wait:string -> + ?burn_cap:int -> + amount:int -> + source:string -> + target:string -> + contract:string -> + t -> + Process.t + +(** Run [tezos-client get balance for account in contract contract].*) +val sapling_get_balance : + ?node:Node.t -> account:string -> contract:string -> t -> unit Lwt.t + +(** Same as [sapling_get_balance], but do not wait for the process to exit. *) +val spawn_sapling_get_balance : + ?node:Node.t -> account:string -> contract:string -> t -> Process.t + +(** Run [tezos-client forge transaction amount from source to target using + contract]. *) +val sapling_forge_transaction : + ?node:Node.t -> + amount:int -> + source:string -> + target:string -> + contract:string -> + t -> + unit Lwt.t + +(** Same as [sapling_forge_transaction], but do not wait for the process to + exit. *) +val spawn_sapling_forge_transaction : + ?node:Node.t -> + amount:int -> + source:string -> + target:string -> + contract:string -> + t -> + Process.t + +(** Run [tezos-client sapling submit sapling_transaction from account using + contract]. + + Default [wait] is "none". *) +val sapling_submit_transaction : + ?node:Node.t -> + ?wait:string -> + ?burn_cap:int -> + account:string -> + contract:string -> + t -> + unit Lwt.t + +(** Same as [sapling_submit_transaction], but do not wait for the process to + exit. *) +val spawn_sapling_submit_transaction : + ?node:Node.t -> + ?wait:string -> + ?burn_cap:int -> + account:string -> + contract:string -> + t -> + Process.t + (** {2 High-Level Functions} *) (** Create a client with mode [Client] and import all secret keys diff --git a/tezt/lib_tezos/node.ml b/tezt/lib_tezos/node.ml index e78c78a5b594db81998d7e1262fa9f60a8660538..c1ec20043ce1cde762c1e7bb8bcf9bbc7efed78e 100644 --- a/tezt/lib_tezos/node.ml +++ b/tezt/lib_tezos/node.ml @@ -33,6 +33,7 @@ type argument = | Bootstrap_threshold of int | Synchronisation_threshold of int | Connections of int + | Sync_latency of int | Private_mode | Peer of string @@ -55,6 +56,8 @@ let make_argument = function ["--synchronisation-threshold"; string_of_int x] | Connections x -> ["--connections"; string_of_int x] + | Sync_latency x -> + ["--sync-latency"; string_of_int x] | Private_mode -> ["--private-mode"] | Peer x -> diff --git a/tezt/lib_tezos/node.mli b/tezt/lib_tezos/node.mli index cf7664eb5dd25a0cbd8fb62fec12568ff93751a9..abaf89e883ebf8ac2c54cb7da9c5e4cc53fcff15 100644 --- a/tezt/lib_tezos/node.mli +++ b/tezt/lib_tezos/node.mli @@ -61,6 +61,7 @@ type argument = | Bootstrap_threshold of int (** [--bootstrap-threshold] (deprecated) *) | Synchronisation_threshold of int (** [--synchronisation-threshold] *) | Connections of int (** [--connections] *) + | Sync_latency of int (** [--sync-latency] *) | Private_mode (** [--private-mode] *) | Peer of string (** [--peer] *) diff --git a/tezt/manual_tests/main.ml b/tezt/manual_tests/main.ml index 3a1cdd15ad95a98a5368d23becc676ebfda56cc0..f78b9181630b34085b74dc4ddf39c87e484d683e 100644 --- a/tezt/manual_tests/main.ml +++ b/tezt/manual_tests/main.ml @@ -28,6 +28,7 @@ as functions to be called here. *) let () = - Migration.register () ; + Migration_mainnet_alpha.register () ; + Migration_007_008.register () ; (* Test.run () should be the last statement, don't register afterwards! *) Test.run () diff --git a/tezt/manual_tests/migration_007_008.ml b/tezt/manual_tests/migration_007_008.ml new file mode 100644 index 0000000000000000000000000000000000000000..43a51963b510630169569706141c06152b270bf6 --- /dev/null +++ b/tezt/manual_tests/migration_007_008.ml @@ -0,0 +1,273 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2020 Metastate AG *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Migration_utils + +let get_sapling_found ~account ~contract client = + let proc = Client.spawn_sapling_get_balance ~account ~contract client in + let* balance = + Lwt_stream.find + (fun line -> line =~ rex "Total Sapling funds .*") + (Lwt_io.read_lines (Process.stdout proc)) + in + return + Option.( + map + (fun balance -> balance =~* rex "Total Sapling funds ([\\d\\.]+)") + balance + |> join) + +let get_generated_sapling_address ~account client = + let proc = Client.spawn_sapling_generate_address ~account client in + let* address_opt = + Lwt_stream.find + (fun line -> line =~ rex "zet\\w+$") + (Lwt_io.read_lines (Process.stdout proc)) + in + return @@ Option.get address_opt + +let get_prior_value _node client = + let* level_before = RPC.Proto_007_delphi.get_current_level client in + return JSON.(level_before |-> "voting_period" |> as_int) + +let test node client voting_period_before = + let* current_level_json = RPC.Proto_007_delphi.get_current_level client in + let current_level = JSON.(current_level_json |-> "level" |> as_int) in + (* Test that the current_level RPC behaves as before even if the two following + fields are removed from the internal representation. *) + let* level_after = RPC.Proto_007_delphi.get_current_level client in + let level_level_position_after = + JSON.(level_after |-> "level_position" |> as_int) + in + let voting_period = JSON.(level_after |-> "voting_period" |> as_int) in + Log.info "test voting period info" ; + if voting_period <> voting_period_before + 1 then + Test.fail + "unexpected voting period %d expected %d in level" + voting_period + (voting_period_before + 1) ; + let voting_period_position = + JSON.(level_after |-> "voting_period_position" |> as_int) + in + if voting_period_position <> 0 then + Test.fail + "unexpected voting period position %d expected %d level" + voting_period_position + 0 ; + (* Test that votes/current_period returns the expected json *) + let* period = RPC.Proto_008_edo.Votes.get_current_period client in + let position = JSON.(period |-> "position" |> as_int) in + if voting_period_position <> 0 then + Test.fail + "unexpected voting period position %d expected %d in period" + position + 0 ; + let remaining = JSON.(period |-> "remaining" |> as_int) in + let* constants = RPC.Proto_008_edo.get_constants client in + let blocks_per_voting_period = + JSON.(constants |-> "blocks_per_voting_period" |> as_int) + in + if remaining <> blocks_per_voting_period - 1 then + Test.fail + "unexpected remaining %d expected %d in period" + remaining + (blocks_per_voting_period - 1) ; + let index = JSON.(period |-> "voting_period" |-> "index" |> as_int) in + if index <> voting_period_before + 1 then + Test.fail + "unexpected index %d expected %d in period" + index + (voting_period_before + 1) ; + let start_position = + JSON.(period |-> "voting_period" |-> "start_position" |> as_int) + in + if start_position <> level_level_position_after then + Test.fail + "unexpected start_position %d expected %d in period" + start_position + level_level_position_after ; + let kind = JSON.(period |-> "voting_period" |-> "kind" |> as_string) in + if kind <> "proposal" then + Test.fail "unexpected kind %s expected %s in period" kind "proposal" ; + (* Test that votes/current_kind behaves like before *) + let* kind = RPC.Proto_008_edo.Votes.get_current_period_kind client in + let kind = JSON.as_string kind in + if kind <> "proposal" then + Test.fail + "unexpected kind %s expected %s in current period kind" + kind + "proposal" ; + (* Test that successor period returns almost the same info as above. + It would be more interesting to run it at the end of a voting period. *) + let* period = RPC.Proto_008_edo.Votes.get_successor_period client in + let position = JSON.(period |-> "position" |> as_int) in + if position <> 1 then + Test.fail "unexpected position %d expected %d in succ period" position 1 ; + let remaining = JSON.(period |-> "remaining" |> as_int) in + let* constants = RPC.Proto_008_edo.get_constants client in + let blocks_per_voting_period = + JSON.(constants |-> "blocks_per_voting_period" |> as_int) + in + if remaining <> blocks_per_voting_period - 2 then + Test.fail + "unexpected remaining %d expected %d in succ period" + remaining + (blocks_per_voting_period - 2) ; + let index = JSON.(period |-> "voting_period" |-> "index" |> as_int) in + if index <> voting_period_before + 1 then + Test.fail + "unexpected index %d expected %d in succ period" + index + (voting_period_before + 1) ; + let start_position = + JSON.(period |-> "voting_period" |-> "start_position" |> as_int) + in + if start_position <> level_level_position_after then + Test.fail + "unexpected start_position %d expected %d in succ period" + start_position + level_level_position_after ; + let kind = JSON.(period |-> "voting_period" |-> "kind" |> as_string) in + if kind <> "proposal" then + Test.fail "unexpected kind %s expected %s in succ period" kind "proposal" ; + Log.info "test metadata" ; + (* metadata change appears only on first block of new protocol *) + let* () = bake_with_foundation client in + let* metadata = RPC.get_metadata client in + let metadata_level = JSON.(metadata |-> "level") in + assert (level_after <> metadata_level) ; + let metadata_kind = JSON.(metadata |-> "voting_period_kind" |> as_string) in + if metadata_kind <> kind then + Test.fail + "unexpected period kind %s expected %s in metadata" + metadata_kind + kind ; + let level_info = JSON.(metadata |-> "level_info") in + if JSON.(unannotate level_info = `Null) then + Test.fail "missing value level_info in metadata" ; + let voting_period_info = JSON.(metadata |-> "voting_period_info") in + if JSON.(unannotate voting_period_info = `Null) then + Test.fail "missing value voting_period_info in metadata" ; + (* originate a sapling contract and validate a transactions *) + let contract = "sapling" in + let alice = "alice" in + let bob = "bob" in + let* _hash = + Client.originate_contract + ~alias:contract + ~amount:(Tez.of_int 0) + ~src:"foundation1" + ~prg:"./src/proto_alpha/lib_protocol/test/contracts/sapling_contract.tz" + ~init:"{ }" + ~burn_cap:(Tez.of_int 3) + client + in + let* () = bake_with_foundation client in + let* _wait_block = Node.wait_for_level node (current_level + 1) in + let* () = + Client.sapling_generate_key + ~unencrypted:true + ~force:true + ~name:alice + client + in + let* () = + Client.sapling_use_key ~memo_size:8 ~account:alice ~contract client + in + let* () = + Client.sapling_generate_key ~unencrypted:true ~force:true ~name:bob client + in + let* () = + Client.sapling_use_key ~memo_size:8 ~account:bob ~contract client + in + let* alice_address = get_generated_sapling_address ~account:alice client in + let* () = + Client.sapling_shield + ~burn_cap:2 + ~amount:10 + ~source:"foundation1" + ~target:alice_address + ~contract + client + in + let* () = bake_with_foundation client in + let* _wait_block = Node.wait_for_level node (current_level + 2) in + let* alice_balance = get_sapling_found ~account:alice ~contract client in + assert (Option.get alice_balance |> int_of_string = 10) ; + let* bob_address = get_generated_sapling_address ~account:bob client in + let* () = + Client.sapling_forge_transaction + ~amount:10 + ~source:alice + ~target:bob_address + ~contract + client + in + let* () = + Client.sapling_submit_transaction + ~burn_cap:1 + ~account:"foundation2" + ~contract + client + in + let* () = bake_with_foundation client in + let* _wait_block = Node.wait_for_level node (current_level + 3) in + let* bob_balance = get_sapling_found ~account:bob ~contract client in + assert (Option.get bob_balance |> int_of_string = 10) ; + let* () = + Client.sapling_unshield + ~burn_cap:1 + ~amount:10 + ~source:bob + ~target:"foundation3" + ~contract + client + in + let* () = bake_with_foundation client in + let* _wait_block = Node.wait_for_level node (current_level + 4) in + unit + +let mainnet_context = "~/tezos-node-test" + +let test_migration_007_008 = + Test.register + ~__FILE__ + ~title:"stiching test" + ~tags: + [ "node"; + "user_activated"; + "protocol"; + Protocol.(tag Edo); + "migration"; + "stiching" ] + @@ fun () -> + template_test_migration + ~migrate_at_end_of_cycle:true + ~specific_test:(get_prior_value, test) + ~context:mainnet_context + ~current_protocol:Protocol.Delphi + Protocol.(hash Edo) + +let register () = test_migration_007_008 diff --git a/tezt/manual_tests/migration_mainnet_alpha.ml b/tezt/manual_tests/migration_mainnet_alpha.ml new file mode 100644 index 0000000000000000000000000000000000000000..870122e33d605dab4db39bede0dcff5af1c8b52f --- /dev/null +++ b/tezt/manual_tests/migration_mainnet_alpha.ml @@ -0,0 +1,56 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2020 Metastate AG *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Migration_utils + +let mainnet_context = "~/tezos-node-test" + +let current_protocol = Protocol.Delphi + +let protocol_hash = Protocol.(hash Alpha) + +let protocol_tag = Protocol.(tag Alpha) + +let test_migration ~long = + Test.register + ~__FILE__ + ~title:"stiching test" + ~tags: + [ "node"; + "user_activated"; + "protocol"; + protocol_tag; + "migration"; + "stiching"; + (if long then "long" else "short") ] + @@ fun () -> + template_test_migration + ~migrate_at_end_of_cycle:long + ~bake_until_new_cycle:long + ~context:mainnet_context + ~current_protocol + protocol_hash + +let register () = test_migration ~long:false diff --git a/tezt/manual_tests/migration.ml b/tezt/manual_tests/migration_utils.ml similarity index 56% rename from tezt/manual_tests/migration.ml rename to tezt/manual_tests/migration_utils.ml index ba04dc208636cfe892559db379ad0f12c17fa69d..00472ee5856943a3a0f7dc589e6d994fd06b50db 100644 --- a/tezt/manual_tests/migration.ml +++ b/tezt/manual_tests/migration_utils.ml @@ -23,39 +23,39 @@ (* *) (*****************************************************************************) -let update_config_with_user_activated config_file level protocol = - let user_activated = - Ezjsonm.( - dict - [ ( "genesis", - dict - [ ("timestamp", string "2018-06-30T16:07:32Z"); - ( "block", - string "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2" - ); - ( "protocol", - string "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P" - ) ] ); - ("chain_name", string "TEZOS_MAINNET"); - ("old_chain_name", string "TEZOS_BETANET_2018-06-30T16:07:32Z"); - ("incompatible_chain_name", string "INCOMPATIBLE"); - ("sandboxed_chain_name", string "SANDBOXED_TEZOS_MAINNET"); - ( "user_activated_upgrades", - list - dict - [ [ ("level", int level); - ("replacement_protocol", string (Protocol.hash protocol)) ] - ] ) ]) - in - let config_json = JSON.parse_file config_file in - let config_json = - Ezjsonm.update - (JSON.unannotate config_json) - ["network"] - (Some user_activated) - in - with_open_out config_file (fun chan -> - Ezjsonm.value_to_channel ~minify:false chan config_json) +let get_current_level ~current_protocol ?node client = + match current_protocol with + | Protocol.Alpha -> + RPC.Proto_alpha.get_current_level ?node client + | Protocol.Delphi -> + RPC.Proto_007_delphi.get_current_level ?node client + | Protocol.Edo -> + RPC.Proto_008_edo.get_current_level ?node client + | _ -> + let open Protocol in + Test.fail + "wrong current protocol %s. Only %s, %s, %s are accepted protocol" + (name current_protocol) + (name Alpha) + (name Delphi) + (name Edo) + +let get_levels_in_current_cycle ~current_protocol ?node client = + match current_protocol with + | Protocol.Alpha -> + RPC.Proto_alpha.get_levels_in_current_cycle ?node client + | Protocol.Delphi -> + RPC.Proto_007_delphi.get_levels_in_current_cycle ?node client + | Protocol.Edo -> + RPC.Proto_008_edo.get_levels_in_current_cycle ?node client + | _ -> + let open Protocol in + Test.fail + "wrong current protocol %s. Only %s, %s, %s are accepted protocol" + (name current_protocol) + (name Alpha) + (name Delphi) + (name Edo) let rec bake_with_foundation ?(foundation_index = [1; 2; 3; 4; 5; 6; 7; 8]) client = @@ -66,24 +66,26 @@ let rec bake_with_foundation ?(foundation_index = [1; 2; 3; 4; 5; 6; 7; 8]) let foundation = List.nth foundation_index index in let proc = Client.spawn_bake_for + ~force:true + ~minimal_timestamp:true ~key:("foundation" ^ string_of_int foundation) client in let* res = Process.wait proc in if res != Unix.WEXITED 0 then - let* has_correct_error = + let* baker_has_no_slot = Lwt_stream.find (fun stderr_bake -> stderr_bake =~ rex "No\\sslot\\sfound\\sat\\slevel\\s[0-9]+") (Lwt_io.read_lines (Process.stderr proc)) in - if Option.is_some has_correct_error then + if Option.is_some baker_has_no_slot then let foundation_index = List.filter (( <> ) foundation) foundation_index in bake_with_foundation ~foundation_index client - else unit - else unit + else Process.check proc + else Process.check proc let create_yes_wallet () = let yes_wallet = Temp.dir "yes-wallet" in @@ -95,29 +97,78 @@ let create_yes_wallet () = json_to_file (sk_list_json alias_pkh_pk_list) (yes_wallet // "secret_keys") ; yes_wallet -(* This test checks the migration of a protocol with a context imported from a - snapshot. See the tezos online documentation to have an in-depth explanation - of that test and how to use it. The documentation can be found at this - address: https://tezos.gitlab.io/developer/proposal_testing.html *) -let migration ?yes_node_path ?yes_wallet context protocol = - Test.register - ~__FILE__ - ~title:"migration test" - ~tags:["node"; "activate"; "user_activated"; "protocol"; "migration"] - @@ fun () -> +let next_name = ref 1 + +let fresh_index () = + let index = !next_name in + incr next_name ; index + +let prepare_yes_wallet ~yes_wallet run_index = + Log.info "Creating yes-wallet dir" ; + match yes_wallet with + | Some yes_wallet -> + let base_dir = Temp.dir ("yes_wallet" ^ string_of_int run_index) in + let* () = Process.run "cp" ["-R"; yes_wallet ^ "/."; base_dir] in + Lwt.return base_dir + | None -> + Lwt.return @@ create_yes_wallet () + +let copy_context context run_index = Log.info "Copying context into a temporary directory" ; - let data_dir = Temp.dir "tezos-node-test" in + let data_dir = Temp.dir ("node" ^ string_of_int run_index) in let* () = Process.run "cp" ["-R"; context ^ "/."; data_dir] in + return data_dir + +let update_config_with_user_activated config_file level protocol = + let user_activated = + Ezjsonm.( + dict + [ ( "genesis", + dict + [ ("timestamp", string "2018-06-30T16:07:32Z"); + ( "block", + string "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2" + ); + ( "protocol", + string "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P" + ) ] ); + ("chain_name", string "TEZOS_MAINNET"); + ("old_chain_name", string "TEZOS_BETANET_2018-06-30T16:07:32Z"); + ("incompatible_chain_name", string "INCOMPATIBLE"); + ("sandboxed_chain_name", string "SANDBOXED_TEZOS_MAINNET"); + ( "user_activated_upgrades", + list + dict + [ [ ("level", int level); + ("replacement_protocol", string protocol) ] ] ) ]) + in + let config_json = JSON.parse_file config_file in + let config_json = + Ezjsonm.update + (JSON.unannotate config_json) + ["network"] + (Some user_activated) + in + with_open_out config_file (fun chan -> + Ezjsonm.value_to_channel ~minify:false chan config_json) + +let prepare_node_and_client ?yes_node_path ?(migrate_at_end_of_cycle = false) + ~base_dir ~data_dir ~current_protocol protocol = let* node = Node.init ~rpc_port:19731 ~net_port:18731 ~data_dir [Connections 0] in let* client = Client.init ~node () in - (* Starting on protocol 007 before migration *) - let* json = RPC.Proto_007.get_current_level ~node client in + let* json = get_current_level ~current_protocol ~node client in let level = JSON.(json |-> "level" |> as_int) in + let* migration_level = + if migrate_at_end_of_cycle then + let* json = get_levels_in_current_cycle ~current_protocol client in + let last_block_of_cycle = JSON.(json |-> "last" |> as_int) in + return last_block_of_cycle + else return (level + 1) + in let* () = Node.terminate node in Log.info "Updating node config with user_activated_upgrade" ; - let migration_level = level + 1 in update_config_with_user_activated (data_dir ^ "/config.json") migration_level @@ -128,47 +179,43 @@ let migration ?yes_node_path ?yes_wallet context protocol = ~rpc_port:19731 ~net_port:18731 ~data_dir - [] + [Connections 0; Synchronisation_threshold 0; Sync_latency 65535] in - let* () = Node.run node [Connections 0] in + let* () = Node.run node [] in let* () = Node.wait_for_ready node in - Log.info "Creating yes-wallet dir" ; - let* base_dir = - match yes_wallet with - | Some yes_wallet -> - let base_dir = Temp.dir "client" in - let* () = Process.run "cp" ["-R"; yes_wallet ^ "/."; base_dir] in - Lwt.return base_dir - | None -> - Lwt.return @@ create_yes_wallet () - in let client = Client.create ~base_dir ~node () in - Log.info "Bake and wait until migration is finished" ; - let* () = bake_with_foundation client in + return (node, client, migration_level) + +let migrate node client ~migration_level ~current_protocol = + Log.info "Bake and wait until migrate is finished" ; + let* json = get_current_level ~current_protocol ~node client in + let level_level_before = JSON.(json |-> "level" |> as_int) in + let* () = + repeat (migration_level - level_level_before) (fun () -> + bake_with_foundation client) + in let* _until_mig = Node.wait_for_level node migration_level in - let (get_current_level, get_levels_in_current_cycle) = - match protocol with - | Protocol.Carthage -> - ( RPC.Proto_007.get_current_level, - RPC.Proto_007.get_levels_in_current_cycle ) - | Edo | Delphi | Alpha -> - ( RPC.Proto_alpha.get_current_level, - RPC.Proto_alpha.get_levels_in_current_cycle ) + unit + +let bake_until_next_cycle ~current_protocol node client = + let* json = get_current_level ~current_protocol ~node client in + let level_before = JSON.(json |-> "level" |> as_int) in + let* levels_in_current_cycle = + get_levels_in_current_cycle ~current_protocol ~node client in - let* levels_in_current_cycle = get_levels_in_current_cycle client in let last_block_of_cycle = JSON.(levels_in_current_cycle |-> "last" |> as_int) in - let* prev_level = get_current_level client in + let* prev_level = get_current_level ~current_protocol ~node client in let prev_cycle = JSON.(prev_level |-> "cycle" |> as_int) in Log.info "Bake until new cycle" ; let* () = repeat - (last_block_of_cycle - migration_level + 1) + (last_block_of_cycle - level_before + 1) (fun () -> bake_with_foundation client) in let* _until_end_of_cycle = Node.wait_for_level node last_block_of_cycle in - let* after_level = get_current_level client in + let* after_level = get_current_level ~current_protocol ~node client in let after_cycle = JSON.(after_level |-> "cycle" |> as_int) in if prev_cycle + 1 <> after_cycle then Test.fail @@ -177,8 +224,34 @@ let migration ?yes_node_path ?yes_wallet context protocol = after_cycle else unit -let protocol = Protocol.Alpha +type 'a get_prior_value = Node.t -> Client.t -> 'a Lwt.t -let context = "~/tezos-node-test" +type 'a migration_test = Node.t -> Client.t -> 'a -> unit Lwt.t -let register () = migration context protocol +let template_test_migration ?yes_node_path ?yes_wallet ?migrate_at_end_of_cycle + ?(bake_until_new_cycle = false) ?specific_test ~context ~current_protocol + protocol_hash = + let run_index = fresh_index () in + let* data_dir = copy_context context run_index in + let* base_dir = prepare_yes_wallet ~yes_wallet run_index in + let* (node, client, migration_level) = + prepare_node_and_client + ?yes_node_path + ?migrate_at_end_of_cycle + ~data_dir + ~base_dir + ~current_protocol + protocol_hash + in + let* () = + match specific_test with + | Some (get_prior_value, test) -> + let* prior_value = get_prior_value node client in + let* () = migrate ~current_protocol node client ~migration_level in + test node client prior_value + | None -> + migrate ~current_protocol ~migration_level node client + in + if bake_until_new_cycle then + bake_until_next_cycle ~current_protocol node client + else unit diff --git a/tezt/manual_tests/migration_utils.mli b/tezt/manual_tests/migration_utils.mli new file mode 100644 index 0000000000000000000000000000000000000000..dcb7627ef4109c05393003427cdbb783814ebf55 --- /dev/null +++ b/tezt/manual_tests/migration_utils.mli @@ -0,0 +1,70 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2020 Metastate AG *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Tezt_tezos + +(** [bake_with_foundation client] try to bake with a randomly picked foundation + account. If the picked foundation account has no slot in the list then retry + with another account until a block have been baked. + + Default [foundation_index] is [1; 2; 3; 4; 5; 6; 7; 8]. + *) +val bake_with_foundation : ?foundation_index:int list -> Client.t -> unit Lwt.t + +(** Used to return a value of current protocol before migration that the + specific test might need. It can return unit if no prior value is needed. *) +type 'a get_prior_value = Node.t -> Client.t -> 'a Lwt.t + +(** A specific test for the new protocol after migration, that will be passed + the result returned from [get_prior_value]. *) +type 'a migration_test = Node.t -> Client.t -> 'a -> unit Lwt.t + +(** This template test checks the migrate of a protocol with a context imported + from a snapshot. See the tezos online documentation to have an in-depth + explanation of that test and how to use it. The documentation can be found at + this address: https://tezos.gitlab.io/developer/proposal_testing.html + + When [migrate_at_end_of_cycle] is set the test can be really long if the + used snapshot is not near the end of a period. Please in that case bake until + close to the end of a period prior to run this test, so you can reuse the + context easily. + + This function is to be used to easily create test for specific migration + (ex: see [Migration_007_008.register]). + + To define a new specific migration test please define two functions in the + [?specific_test] argument. The [get_prior_value] function will be run right + after starting the node. To run that function at a specific level, please + prepare the context to be at that level. *) +val template_test_migration : + ?yes_node_path:string -> + ?yes_wallet:string -> + ?migrate_at_end_of_cycle:bool -> + ?bake_until_new_cycle:bool -> + ?specific_test:'a get_prior_value * 'a migration_test -> + context:string -> + current_protocol:Protocol.t -> + string -> + unit Lwt.t diff --git a/tezt/tests/RPC_test.ml b/tezt/tests/RPC_test.ml index ce5c9ebc3d5e965200f26ed6fb422ce6149f0b56..1ddacd01e6d682fc63f079bebb006ef944cc971a 100644 --- a/tezt/tests/RPC_test.ml +++ b/tezt/tests/RPC_test.ml @@ -257,26 +257,36 @@ let test_contracts_alpha client = (* Test the contracts RPC for protocol 007. *) let test_contracts_007 client = let test_implicit_contract contract_id = - let* _ = RPC.Proto_007.Contract.get ~hooks ~contract_id client in - let* _ = RPC.Proto_007.Contract.get_balance ~hooks ~contract_id client in - let* _ = RPC.Proto_007.Contract.get_counter ~hooks ~contract_id client in + let* _ = RPC.Proto_007_delphi.Contract.get ~hooks ~contract_id client in let* _ = - RPC.Proto_007.Contract.get_manager_key ~hooks ~contract_id client + RPC.Proto_007_delphi.Contract.get_balance ~hooks ~contract_id client + in + let* _ = + RPC.Proto_007_delphi.Contract.get_counter ~hooks ~contract_id client + in + let* _ = + RPC.Proto_007_delphi.Contract.get_manager_key ~hooks ~contract_id client in unit in - let* contracts = RPC.Proto_007.Contract.get_all ~hooks client in + let* contracts = RPC.Proto_007_delphi.Contract.get_all ~hooks client in Log.info "Test implicit baker contract" ; let bootstrap = List.hd contracts in let* () = test_implicit_contract bootstrap in let* _ = - RPC.Proto_007.Contract.get_delegate ~hooks ~contract_id:bootstrap client + RPC.Proto_007_delphi.Contract.get_delegate + ~hooks + ~contract_id:bootstrap + client in Log.info "Test un-allocated implicit contract" ; let unallocated_implicit = "tz1c5BVkpwCiaPHJBzyjg7UHpJEMPTYA1bHG" in assert (not @@ List.mem unallocated_implicit contracts) ; let* _ = - RPC.Proto_007.Contract.get ~hooks ~contract_id:unallocated_implicit client + RPC.Proto_007_delphi.Contract.get + ~hooks + ~contract_id:unallocated_implicit + client in Log.info "Test non-delegated implicit contract" ; let simple_implicit = "simple" in @@ -305,10 +315,10 @@ let test_contracts_007 client = ~contract_id:simple_implicit_key.public_key_hash client |> Process.check ~expect_failure:true) - [ RPC.Proto_007.Contract.spawn_get_delegate; - RPC.Proto_007.Contract.spawn_get_entrypoints; - RPC.Proto_007.Contract.spawn_get_script; - RPC.Proto_007.Contract.spawn_get_storage ] + [ RPC.Proto_007_delphi.Contract.spawn_get_delegate; + RPC.Proto_007_delphi.Contract.spawn_get_entrypoints; + RPC.Proto_007_delphi.Contract.spawn_get_script; + RPC.Proto_007_delphi.Contract.spawn_get_storage ] in Log.info "Test delegated implicit contract" ; let delegated_implicit = "delegated" in @@ -330,7 +340,7 @@ let test_contracts_007 client = let* () = Client.bake_for client in let* () = test_implicit_contract delegated_implicit_key.public_key_hash in let* _ = - RPC.Proto_007.Contract.get_delegate + RPC.Proto_007_delphi.Contract.get_delegate ~hooks ~contract_id:delegated_implicit_key.public_key_hash client @@ -346,19 +356,27 @@ let test_contracts_007 client = ~contract_id:delegated_implicit_key.public_key_hash client |> Process.check ~expect_failure:true) - [ RPC.Proto_007.Contract.spawn_get_entrypoints; - RPC.Proto_007.Contract.spawn_get_script; - RPC.Proto_007.Contract.spawn_get_storage ] + [ RPC.Proto_007_delphi.Contract.spawn_get_entrypoints; + RPC.Proto_007_delphi.Contract.spawn_get_script; + RPC.Proto_007_delphi.Contract.spawn_get_storage ] in let test_originated_contract contract_id = - let* _ = RPC.Proto_007.Contract.get ~hooks ~contract_id client in - let* _ = RPC.Proto_007.Contract.get_balance ~hooks ~contract_id client in + let* _ = RPC.Proto_007_delphi.Contract.get ~hooks ~contract_id client in + let* _ = + RPC.Proto_007_delphi.Contract.get_balance ~hooks ~contract_id client + in let* () = - RPC.Proto_007.Contract.spawn_get_counter ~hooks ~contract_id client + RPC.Proto_007_delphi.Contract.spawn_get_counter + ~hooks + ~contract_id + client |> Process.check ~expect_failure:true in let* () = - RPC.Proto_007.Contract.spawn_get_manager_key ~hooks ~contract_id client + RPC.Proto_007_delphi.Contract.spawn_get_manager_key + ~hooks + ~contract_id + client |> Process.check ~expect_failure:true in let big_map_key = @@ -366,17 +384,21 @@ let test_contracts_007 client = "{ \"key\": { \"int\": \"0\" }, \"type\": { \"prim\": \"int\" } }" in let* _ = - RPC.Proto_007.Contract.big_map_get + RPC.Proto_007_delphi.Contract.big_map_get ~hooks ~contract_id ~data:big_map_key client in let* _ = - RPC.Proto_007.Contract.get_entrypoints ~hooks ~contract_id client + RPC.Proto_007_delphi.Contract.get_entrypoints ~hooks ~contract_id client + in + let* _ = + RPC.Proto_007_delphi.Contract.get_script ~hooks ~contract_id client + in + let* _ = + RPC.Proto_007_delphi.Contract.get_storage ~hooks ~contract_id client in - let* _ = RPC.Proto_007.Contract.get_script ~hooks ~contract_id client in - let* _ = RPC.Proto_007.Contract.get_storage ~hooks ~contract_id client in unit in (* A smart contract without any big map or entrypoints *) @@ -411,7 +433,7 @@ let test_contracts_007 client = } }" in let* _ = - RPC.Proto_007.Contract.big_map_get + RPC.Proto_007_delphi.Contract.big_map_get ~hooks ~contract_id:originated_contract_advanced ~data:unique_big_map_key @@ -422,7 +444,7 @@ let test_contracts_007 client = "{ \"key\": { \"string\": \"dup\" }, \"type\": { \"prim\": \"string\" } }" in let* _ = - RPC.Proto_007.Contract.big_map_get + RPC.Proto_007_delphi.Contract.big_map_get ~hooks ~contract_id:originated_contract_advanced ~data:duplicate_big_map_key @@ -535,89 +557,106 @@ let test_delegates_alpha client = (* Test the delegates RPC for protocol 007. *) let test_delegates_007 client = - let* contracts = RPC.Proto_007.Contract.get_all client in + let* contracts = RPC.Proto_007_delphi.Contract.get_all client in Log.info "Test implicit baker contract" ; let bootstrap = List.hd contracts in - let* _ = RPC.Proto_007.Delegate.get ~hooks ~pkh:bootstrap client in - let* _ = RPC.Proto_007.Delegate.get_balance ~hooks ~pkh:bootstrap client in + let* _ = RPC.Proto_007_delphi.Delegate.get ~hooks ~pkh:bootstrap client in let* _ = - RPC.Proto_007.Delegate.get_deactivated ~hooks ~pkh:bootstrap client + RPC.Proto_007_delphi.Delegate.get_balance ~hooks ~pkh:bootstrap client in let* _ = - RPC.Proto_007.Delegate.get_delegated_balance ~hooks ~pkh:bootstrap client + RPC.Proto_007_delphi.Delegate.get_deactivated ~hooks ~pkh:bootstrap client in let* _ = - RPC.Proto_007.Delegate.get_delegated_contracts ~hooks ~pkh:bootstrap client + RPC.Proto_007_delphi.Delegate.get_delegated_balance + ~hooks + ~pkh:bootstrap + client in let* _ = - RPC.Proto_007.Delegate.get_frozen_balance ~hooks ~pkh:bootstrap client + RPC.Proto_007_delphi.Delegate.get_delegated_contracts + ~hooks + ~pkh:bootstrap + client in let* _ = - RPC.Proto_007.Delegate.get_frozen_balance_by_cycle + RPC.Proto_007_delphi.Delegate.get_frozen_balance ~hooks ~pkh:bootstrap client in let* _ = - RPC.Proto_007.Delegate.get_grace_period ~hooks ~pkh:bootstrap client + RPC.Proto_007_delphi.Delegate.get_frozen_balance_by_cycle + ~hooks + ~pkh:bootstrap + client in let* _ = - RPC.Proto_007.Delegate.get_staking_balance ~hooks ~pkh:bootstrap client + RPC.Proto_007_delphi.Delegate.get_grace_period ~hooks ~pkh:bootstrap client + in + let* _ = + RPC.Proto_007_delphi.Delegate.get_staking_balance + ~hooks + ~pkh:bootstrap + client in Log.info "Test with a PKH that is not a registered baker contract" ; let unregistered_baker = "tz1c5BVkpwCiaPHJBzyjg7UHpJEMPTYA1bHG" in assert (not @@ List.mem unregistered_baker contracts) ; let* _ = - RPC.Proto_007.Delegate.spawn_get ~hooks ~pkh:unregistered_baker client + RPC.Proto_007_delphi.Delegate.spawn_get + ~hooks + ~pkh:unregistered_baker + client |> Process.check ~expect_failure:true in let* _ = - RPC.Proto_007.Delegate.spawn_get_balance + RPC.Proto_007_delphi.Delegate.spawn_get_balance ~hooks ~pkh:unregistered_baker client |> Process.check ~expect_failure:true in let* _ = - RPC.Proto_007.Delegate.get_deactivated + RPC.Proto_007_delphi.Delegate.get_deactivated ~hooks ~pkh:unregistered_baker client in let* _ = - RPC.Proto_007.Delegate.spawn_get_delegated_balance + RPC.Proto_007_delphi.Delegate.spawn_get_delegated_balance ~hooks ~pkh:unregistered_baker client |> Process.check ~expect_failure:true in let* _ = - RPC.Proto_007.Delegate.get_delegated_contracts + RPC.Proto_007_delphi.Delegate.get_delegated_contracts ~hooks ~pkh:unregistered_baker client in let* _ = - RPC.Proto_007.Delegate.get_frozen_balance + RPC.Proto_007_delphi.Delegate.get_frozen_balance ~hooks ~pkh:unregistered_baker client in let* _ = - RPC.Proto_007.Delegate.get_frozen_balance_by_cycle + RPC.Proto_007_delphi.Delegate.get_frozen_balance_by_cycle ~hooks ~pkh:unregistered_baker client in let* _ = - RPC.Proto_007.Delegate.spawn_get_grace_period + RPC.Proto_007_delphi.Delegate.spawn_get_grace_period ~hooks ~pkh:unregistered_baker client |> Process.check ~expect_failure:true in let* _ = - RPC.Proto_007.Delegate.get_staking_balance + RPC.Proto_007_delphi.Delegate.get_staking_balance ~hooks ~pkh:unregistered_baker client @@ -669,13 +708,13 @@ let test_votes_007 client = let* () = Client.submit_proposals ~proto_hash client in let* () = Client.bake_for client in (* RPC calls *) - let* _ = RPC.Proto_007.Votes.get_ballot_list ~hooks client in - let* _ = RPC.Proto_007.Votes.get_ballots ~hooks client in - let* _ = RPC.Proto_007.Votes.get_current_period_kind ~hooks client in - let* _ = RPC.Proto_007.Votes.get_current_proposal ~hooks client in - let* _ = RPC.Proto_007.Votes.get_current_quorum ~hooks client in - let* _ = RPC.Proto_007.Votes.get_listings ~hooks client in - let* _ = RPC.Proto_007.Votes.get_proposals ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_ballot_list ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_ballots ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_current_period_kind ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_current_proposal ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_current_quorum ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_listings ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_proposals ~hooks client in (* bake to testing vote period and submit some ballots *) let* () = Client.bake_for client in let* () = Client.bake_for client in @@ -684,13 +723,13 @@ let test_votes_007 client = let* () = Client.submit_ballot ~key:"bootstrap3" ~proto_hash Pass client in let* () = Client.bake_for client in (* RPC calls again *) - let* _ = RPC.Proto_007.Votes.get_ballot_list ~hooks client in - let* _ = RPC.Proto_007.Votes.get_ballots ~hooks client in - let* _ = RPC.Proto_007.Votes.get_current_period_kind ~hooks client in - let* _ = RPC.Proto_007.Votes.get_current_proposal ~hooks client in - let* _ = RPC.Proto_007.Votes.get_current_quorum ~hooks client in - let* _ = RPC.Proto_007.Votes.get_listings ~hooks client in - let* _ = RPC.Proto_007.Votes.get_proposals ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_ballot_list ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_ballots ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_current_period_kind ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_current_proposal ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_current_quorum ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_listings ~hooks client in + let* _ = RPC.Proto_007_delphi.Votes.get_proposals ~hooks client in unit (* Test the various other RPCs for protocol Alpha. *) @@ -704,11 +743,11 @@ let test_others_alpha client = (* Test the various other RPCs for protocol 007. *) let test_others_007 client = - let* _ = RPC.Proto_007.get_constants ~hooks client in - let* _ = RPC.Proto_007.get_baking_rights ~hooks client in - let* _ = RPC.Proto_007.get_current_level ~hooks client in - let* _ = RPC.Proto_007.get_endorsing_rights ~hooks client in - let* _ = RPC.Proto_007.get_levels_in_current_cycle ~hooks client in + let* _ = RPC.Proto_007_delphi.get_constants ~hooks client in + let* _ = RPC.Proto_007_delphi.get_baking_rights ~hooks client in + let* _ = RPC.Proto_007_delphi.get_current_level ~hooks client in + let* _ = RPC.Proto_007_delphi.get_endorsing_rights ~hooks client in + let* _ = RPC.Proto_007_delphi.get_levels_in_current_cycle ~hooks client in unit let register () =