Skip to content

Commit

Permalink
Merge branch 'btcz:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelusCH authored Dec 8, 2021
2 parents bc36bfe + 8a82569 commit b9588c3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/deprecation.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Deprecation policy:
// * Shut down 16 weeks' worth of blocks after the estimated release block height.
// * A warning is shown during the 2 weeks' worth of blocks prior to shut down.
static const int APPROX_RELEASE_HEIGHT = 775000;
static const int APPROX_RELEASE_HEIGHT = 925000;
static const int WEEKS_UNTIL_DEPRECATION = 16;
static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + (WEEKS_UNTIL_DEPRECATION * 7 * 24 * 24);

Expand Down
101 changes: 64 additions & 37 deletions zcutil/fetch-params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,64 @@ SPROUT_VKEY_NAME='sprout-verifying.key'
SAPLING_SPEND_NAME='sapling-spend.params'
SAPLING_OUTPUT_NAME='sapling-output.params'
SAPLING_SPROUT_GROTH16_NAME='sprout-groth16.params'
SPROUT_URL="https://download.z.cash/downloads"
SPROUT_URL="https://d.btcz.rocks"
SPROUT_IPFS="/ipfs/QmZKKx7Xup7LiAtFRhYsE1M7waXcv9ir9eCECyXAFGxhEo"

SHA256CMD="$(command -v sha256sum || echo shasum)"
SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')"

ARIA2CMD="$(command -v aria2c || echo '')"
WGETCMD="$(command -v wget || echo '')"
IPFSCMD="$(command -v ipfs || echo '')"
CURLCMD="$(command -v curl || echo '')"

# fetch methods can be disabled with ZC_DISABLE_SOMETHING=1
ZC_DISABLE_ARIA2="${ZC_DISABLE_ARIA2:-}"
ZC_DISABLE_WGET="${ZC_DISABLE_WGET:-}"
ZC_DISABLE_IPFS="${ZC_DISABLE_IPFS:-}"
ZC_DISABLE_CURL="${ZC_DISABLE_CURL:-}"

function fetch_aria2 {
if [ -z "$ARIA2CMD" ] || ! [ -z "$ZC_DISABLE_ARIA2" ]; then
return 1
fi

local filename="$1"
local dlname="$(basename "$2")"

cat <<EOF
Retrieving (aria2): $SPROUT_URL/$filename
EOF

aria2c \
--out="$dlname" \
--continue=true \
--max-tries=3 \
--retry-wait=2 \
--split=4 \
--max-connection-per-server=4 \
--timeout=90 \
--auto-save-interval=5 \
--always-resume=false \
--allow-overwrite=true \
--download-result=full \
--summary-interval=10 \
"$SPROUT_URL/$filename" || \
{ echo -e "\n\nResume failed, downloading $filename from scratch.\n\n" \
&& aria2c \
--out="$dlname" \
--continue=false \
--remove-control-file=true \
--max-tries=3 \
--timeout=30 \
--always-resume=false \
--allow-overwrite=true \
--download-result=full \
--summary-interval=10 \
"$SPROUT_URL/$filename"
}
}

function fetch_wget {
if [ -z "$WGETCMD" ] || ! [ -z "$ZC_DISABLE_WGET" ]; then
return 1
Expand All @@ -37,16 +80,23 @@ function fetch_wget {
local dlname="$2"

cat <<EOF
Retrieving (wget): $SPROUT_URL/$filename
EOF

wget \
--progress=dot:giga \
--output-document="$dlname" \
--continue \
--retry-connrefused --waitretry=3 --timeout=30 \
"$SPROUT_URL/$filename"
--continue --tries=3 \
--retry-connrefused --waitretry=3 --timeout=90 \
"$SPROUT_URL/$filename" || \
{ echo -e "\n\nResume failed, downloading $filename from scratch.\n\n" \
&& wget \
--progress=dot:giga \
--output-document="$dlname" \
--tries=3 \
--retry-connrefused --waitretry=3 --timeout=30 \
"$SPROUT_URL/$filename"
}
}

function fetch_ipfs {
Expand All @@ -58,7 +108,6 @@ function fetch_ipfs {
local dlname="$2"

cat <<EOF
Retrieving (ipfs): $SPROUT_IPFS/$filename
EOF

Expand All @@ -74,7 +123,6 @@ function fetch_curl {
local dlname="$2"

cat <<EOF
Retrieving (curl): $SPROUT_URL/$filename
EOF

Expand All @@ -87,14 +135,12 @@ EOF

function fetch_failure {
cat >&2 <<EOF
Failed to fetch the Zcash zkSNARK parameters!
Try installing one of the following programs and make sure you're online:
* aria2
* ipfs
* wget
* curl
EOF
exit 1
}
Expand All @@ -107,27 +153,13 @@ function fetch_params {

if ! [ -f "$output" ]
then
for i in 1 2
do
for method in wget ipfs curl failure; do
if "fetch_$method" "${filename}.part.${i}" "${dlname}.part.${i}"; then
echo "Download of part ${i} successful!"
break
fi
done
done

for i in 1 2
do
if ! [ -f "${dlname}.part.${i}" ]
then
fetch_failure
for method in aria2 wget ipfs curl failure; do
if "fetch_$method" "$filename" "$dlname"; then
echo "Download successful!"
break
fi
done

cat "${dlname}.part.1" "${dlname}.part.2" > "${dlname}"
rm "${dlname}.part.1" "${dlname}.part.2"

"$SHA256CMD" $SHA256ARGS -c <<EOF
$expectedhash $dlname
EOF
Expand Down Expand Up @@ -174,10 +206,9 @@ function main() {

cat <<EOF
Zcash - fetch-params.sh
BitcoinZ uses the same zkSNARK parameters generated by ZCash.
This script will fetch the Zcash zkSNARK parameters and verify their
integrity with sha256sum.
If they already exist locally, it will exit now and do nothing else.
EOF

Expand All @@ -196,15 +227,11 @@ EOF
# This may be the first time the user's run this script, so give
# them some info, especially about bandwidth usage:
cat <<EOF
The complete parameters are currently just under 1.7GB in size, so plan
accordingly for your bandwidth constraints. If the Sprout parameters are
already present the additional Sapling parameters required are just under
800MB in size. If the files are already present and have the correct
sha256sum, no networking is used.
The parameters are currently just under 911MB in size, so plan accordingly
for your bandwidth constraints. If the files are already present and
have the correct sha256sum, no networking is used.
Creating params directory. For details about this directory, see:
$README_PATH
EOF
fi

Expand Down

0 comments on commit b9588c3

Please sign in to comment.