Skip to content

Commit 3e641c1

Browse files
committed
[Build] Package sapling params in repo/release
Since we no longer require the sprout params, we can package the sapling params inside the source repository (and the release binaries) until such time that the client has the ability to fetch these params directly from the P2P network. Overview of the changes here per-OS: - macOS release binaries will use the params that are bundled into the `.app` bundle - Windows installer `.exe` will automatically install the params into the appdata directory. - linux PPA/Snap/Copr installs will automatically install the params into the appropriate directory (either `$SNAP_USER_COMMON/.pivx-params` or `/usr/local/share` - Linux tarballs include a bash shell script that can be run to install the params files into `$HOME/.pivx-params` Note: Windows users that choose to use the `.zip` binary package will need to manually copy the params files to the appropriate `AppData` directory on their own (to be documented later)
1 parent 564dce8 commit 3e641c1

File tree

13 files changed

+214
-11
lines changed

13 files changed

+214
-11
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ jobs:
431431
432432
if [ "${{ matrix.config.unit_tests }}" = "true" ] || [ "${{ matrix.config.functional_tests }}" = "true" ]; then
433433
echo ::group::Params
434-
util/fetch-params.sh $PARAMS_DIR
434+
./params/install-params.sh $PARAMS_DIR
435435
echo ::endgroup::
436436
fi
437437

Makefile.am

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SUBDIRS = src
77
if ENABLE_MAN
88
SUBDIRS += doc/man
99
endif
10+
SUBDIRS += params
1011
.PHONY: deploy FORCE
1112

1213
export PYTHONPATH
@@ -53,7 +54,7 @@ DIST_CARGO = \
5354
$(top_srcdir)/Cargo.lock \
5455
$(top_srcdir)/Cargo.toml \
5556
$(top_srcdir)/rust-toolchain \
56-
$(top_srcdir)/util/fetch-params.sh
57+
$(top_srcdir)/params/install-params.sh
5758

5859
BIN_CHECKS=$(top_srcdir)/contrib/devtools/symbol-check.py \
5960
$(top_srcdir)/contrib/devtools/security-check.py
@@ -73,6 +74,9 @@ OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_FANCY_PLIST) $(OSX_INSTALLER_ICONS) \
7374
$(top_srcdir)/contrib/macdeploy/detached-sig-apply.sh \
7475
$(top_srcdir)/contrib/macdeploy/detached-sig-create.sh
7576

77+
SPEND_PARAMS = $(top_srcdir)/params/sapling-spend.params
78+
OUTPUT_PARAMS = $(top_srcdir)/params/sapling-output.params
79+
7680
COVERAGE_INFO = baseline.info \
7781
test_pivx_filtered.info total_coverage.info \
7882
baseline_filtered.info functional_test.info functional_test_filtered.info \
@@ -114,9 +118,18 @@ $(OSX_APP)/Contents/Resources/Base.lproj/InfoPlist.strings:
114118
$(MKDIR_P) $(@D)
115119
echo '{ CFBundleDisplayName = "$(PACKAGE_NAME)"; CFBundleName = "$(PACKAGE_NAME)"; }' > $@
116120

121+
$(OSX_APP)/Contents/Resources/sapling-spend.params: $(SPEND_PARAMS)
122+
$(MKDIR_P) $(@D)
123+
$(INSTALL_DATA) $< $@
124+
125+
$(OSX_APP)/Contents/Resources/sapling-output.params: $(OUTPUT_PARAMS)
126+
$(MKDIR_P) $(@D)
127+
$(INSTALL_DATA) $< $@
128+
117129
OSX_APP_BUILT=$(OSX_APP)/Contents/PkgInfo $(OSX_APP)/Contents/Resources/empty.lproj \
118130
$(OSX_APP)/Contents/Resources/bitcoin.icns $(OSX_APP)/Contents/Info.plist \
119-
$(OSX_APP)/Contents/MacOS/PIVX-Qt $(OSX_APP)/Contents/Resources/Base.lproj/InfoPlist.strings
131+
$(OSX_APP)/Contents/MacOS/PIVX-Qt $(OSX_APP)/Contents/Resources/Base.lproj/InfoPlist.strings \
132+
$(OSX_APP)/Contents/Resources/sapling-spend.params $(OSX_APP)/Contents/Resources/sapling-output.params
120133

121134
osx_volname:
122135
echo $(OSX_VOLNAME) >$@

build-aux/snap/snapcraft.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ parts:
175175
fi
176176
./autogen.sh
177177
if [ $DEPENDS = 1 ]; then
178-
./configure --prefix=`pwd`/depends/${HOST} --with-params-dir=${SNAP_USER_COMMON}/${PARAMSDIR}
178+
./configure --prefix=`pwd`/depends/${HOST}
179179
else
180-
./configure --with-incompatible-bdb --with-params-dir=${SNAP_USER_COMMON}/${PARAMSDIR}
180+
./configure --with-incompatible-bdb
181181
fi
182182
echo "-----------------------------------------------"
183183
echo "+++++++++++++++++++++++++++++++++++++++++++++++"
@@ -231,19 +231,20 @@ parts:
231231
echo "CONFIG FILE" # create .pivx folder and copy example config - !!!warning!!!: do not copy as pivx.conf
232232
echo "+++++++++++++++++++++++++++++++++++++++++++++++"
233233
mkdir -p ${SNAP_USER_COMMON}/.${DATADIR}
234+
mkdir -p ${SNAP_USER_COMMON}/${PARAMSDIR}
234235
if [ $COPYCONF = 1 ]; then
235236
cp ${SNAPCRAFT_PART_BUILD}/contrib/debian/manpages/${CONF}.conf.5 ${SNAP_USER_COMMON}/.${DATADIR}/${CONF}-example.conf
236237
else
237238
echo "COPY CONFIG FILE disabled, skipping"
238239
fi
240+
cp ${SNAPCRAFT_PART_BUILD}/params/*.params ${SNAP_USER_COMMON}/${PARAMSDIR}/
239241
echo "-----------------------------------------------"
240242
echo "+++++++++++++++++++++++++++++++++++++++++++++++"
241243
echo "RUN TESTS" # if tests fail to pass, build and release will fail
242244
echo "+++++++++++++++++++++++++++++++++++++++++++++++"
243245
cd ${SNAPCRAFT_PART_BUILD}
244246
if [ ! $SNAPCRAFT_ARCH_TRIPLET = "s390x-linux-gnu" ]; then
245247
if [ $RUNTESTS = 1 ]; then
246-
${SNAPCRAFT_PROJECT_DIR}/util/fetch-params.sh ${SNAP_USER_COMMON}/${PARAMSDIR}
247248
make check
248249
else
249250
echo "RUN TESTS disabled, skipping"
@@ -300,6 +301,7 @@ parts:
300301
- libdb++-dev
301302
stage-packages:
302303
- libxkbcommon0
304+
- libxcb-xinerama0
303305
- ttf-ubuntu-font-family
304306
- dmz-cursor-theme
305307
- light-themes
@@ -324,6 +326,8 @@ parts:
324326
- libpgm-5.2-0
325327
- libprotobuf10
326328
- libqrencode3
329+
- libqt5core5a
330+
- libqt5dbus5
327331
- libqt5charts5
328332
- libqt5test5
329333
- libsodium23

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ case $host in
599599
fi
600600

601601
AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"])
602+
AX_CHECK_LINK_FLAG([[-framework CoreFoundation]], [LDFLAGS="$LDFLAGS -framework CoreFoundation"], [AC_MSG_ERROR([could not find CoreFoundation framework])])
602603
CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0"
603604
OBJCXXFLAGS="$CXXFLAGS"
604605
;;
@@ -1485,7 +1486,7 @@ AC_SUBST(HAVE_BUILTIN_PREFETCH)
14851486
AC_SUBST(HAVE_MM_PREFETCH)
14861487
AC_SUBST(HAVE_STRONG_GETAUXVAL)
14871488
AC_SUBST(HAVE_WEAK_GETAUXVAL)
1488-
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
1489+
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile params/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
14891490
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
14901491
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
14911492
AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py])

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ script: |
184184
find ${DISTNAME}/bin -type f -executable -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg
185185
#find ${DISTNAME}/lib -type f -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg
186186
cp ../doc/README.md ${DISTNAME}/
187+
cp ../params/install-params.sh ${DISTNAME}/
187188
find ${DISTNAME} -not -name "*.dbg" | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}.tar.gz
188189
find ${DISTNAME} -name "*.dbg" | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}-debug.tar.gz
189190
cd ../../

contrib/gitian-descriptors/gitian-osx.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ script: |
162162
find . -name "lib*.la" -delete
163163
find . -name "lib*.a" -delete
164164
rm -rf ${DISTNAME}/lib/pkgconfig
165+
cp ../params/install-params.sh ${DISTNAME}/
165166
find ${DISTNAME} | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}.tar.gz
166167
cd ../../
167168
done

doc/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Unpack the files into a directory and run:
1616
- `bin/pivx-qt` (GUI) or
1717
- `bin/pivxd` (headless)
1818

19+
If this is the first time running PIVX Core (since v5.0.0), you'll need to install the sapling params by running the included `install-params.sh` script, which copies the two params files to `$HOME/.pivx-params`
20+
1921
### Windows
2022

2123
Unpack the files into a directory, and then run pivx-qt.exe.

params/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist_data_DATA =
2+
3+
dist_data_DATA+=sapling-output.params sapling-spend.params

params/install-params.sh

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2015-2020 The Zcash developers
4+
# Copyright (c) 2020 The PIVX developers
5+
# Distributed under the MIT software license, see the accompanying
6+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
7+
8+
export LC_ALL=C.UTF-8
9+
10+
set -eu
11+
12+
if [ -n "${1:-}" ]; then
13+
PARAMS_DIR="$1"
14+
else
15+
if [[ "$OSTYPE" == "darwin"* ]]; then
16+
PARAMS_DIR="$HOME/Library/Application Support/PIVXParams"
17+
else
18+
PARAMS_DIR="$HOME/.pivx-params"
19+
fi
20+
fi
21+
22+
SAPLING_SPEND_NAME='sapling-spend.params'
23+
SAPLING_OUTPUT_NAME='sapling-output.params'
24+
25+
SHA256CMD="$(command -v sha256sum || echo shasum)"
26+
SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')"
27+
28+
pushd () {
29+
command pushd "$@" > /dev/null
30+
}
31+
32+
popd () {
33+
command popd > /dev/null
34+
}
35+
36+
function install_params {
37+
local filename="$1"
38+
local output="$2"
39+
local expectedhash="$3"
40+
41+
# if the params don't exist in the current directory, assume we're running from release tarballs
42+
if ! [ -f "$filename" ]
43+
then
44+
filename="share/$filename"
45+
fi
46+
47+
if ! [ -f "$output" ]
48+
then
49+
"$SHA256CMD" $SHA256ARGS -c <<EOF
50+
$expectedhash $filename
51+
EOF
52+
53+
# Check the exit code of the shasum command:
54+
CHECKSUM_RESULT=$?
55+
if [ $CHECKSUM_RESULT -eq 0 ]; then
56+
cp -v "$filename" "$output"
57+
else
58+
echo "Failed to verify parameter checksums!" >&2
59+
exit 1
60+
fi
61+
fi
62+
}
63+
64+
# Use flock to prevent parallel execution.
65+
function lock() {
66+
local lockfile=/tmp/install_params.lock
67+
if [[ "$OSTYPE" == "darwin"* ]]; then
68+
if shlock -f ${lockfile} -p $$; then
69+
return 0
70+
else
71+
return 1
72+
fi
73+
else
74+
# create lock file
75+
eval "exec 200>$lockfile"
76+
# acquire the lock
77+
flock -n 200 \
78+
&& return 0 \
79+
|| return 1
80+
fi
81+
}
82+
83+
function exit_locked_error {
84+
echo "Only one instance of install-params.sh can be run at a time." >&2
85+
exit 1
86+
}
87+
88+
function main() {
89+
90+
lock install-params.sh \
91+
|| exit_locked_error
92+
93+
cat <<EOF
94+
PIVX - install-params.sh
95+
96+
This script will install the PIVX zkSNARK parameters and verify their
97+
integrity with sha256sum.
98+
99+
If they already exist locally, it will exit now and do nothing else.
100+
EOF
101+
102+
# Now create PARAMS_DIR and insert a README if necessary:
103+
if ! [ -d "$PARAMS_DIR" ]
104+
then
105+
mkdir -p "$PARAMS_DIR"
106+
README_PATH="$PARAMS_DIR/README"
107+
cat >> "$README_PATH" <<EOF
108+
This directory stores common PIVX zkSNARK parameters. Note that it is
109+
distinct from the daemon's -datadir argument because the parameters are
110+
large and may be shared across multiple distinct -datadir's such as when
111+
setting up test networks.
112+
EOF
113+
114+
# This may be the first time the user's run this script, so give
115+
# them some info:
116+
cat <<EOF
117+
If the files are already present and have the correct
118+
sha256sum, nothing else is done.
119+
120+
Creating params directory. For details about this directory, see:
121+
$README_PATH
122+
123+
EOF
124+
fi
125+
126+
if [ -d ".git" ] || [ -f autogen.sh ]
127+
then
128+
echo "Installing from source repo or dist tarball"
129+
pushd params
130+
fi
131+
132+
# Sapling parameters:
133+
install_params "$SAPLING_SPEND_NAME" "$PARAMS_DIR/$SAPLING_SPEND_NAME" "8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13"
134+
install_params "$SAPLING_OUTPUT_NAME" "$PARAMS_DIR/$SAPLING_OUTPUT_NAME" "2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4"
135+
136+
popd
137+
}
138+
139+
main
140+
rm -f /tmp/install_params.lock
141+
exit 0

params/sapling-output.params

3.43 MB
Binary file not shown.

0 commit comments

Comments
 (0)