Extract go-fil-proofs

This commit is contained in:
Łukasz Magiera 2019-08-28 18:42:22 +02:00
parent cd6aa9ad77
commit c87d9dc4b4
10 changed files with 19 additions and 134 deletions

6
.gitmodules vendored
View File

@ -4,6 +4,6 @@
[submodule "extern/go-sectorbuilder"] [submodule "extern/go-sectorbuilder"]
path = extern/go-sectorbuilder path = extern/go-sectorbuilder
url = https://github.com/filecoin-project/go-sectorbuilder url = https://github.com/filecoin-project/go-sectorbuilder
[submodule "extern/proofs/rust-fil-proofs"] [submodule "extern/go-fil-proofs"]
path = extern/proofs/rust-fil-proofs path = extern/go-fil-proofs
url = git@github.com:filecoin-project/rust-fil-proofs.git url = git@github.com:filecoin-project/go-fil-proofs.git

View File

@ -41,9 +41,9 @@ CLEAN+=build/.sector-builder-install
## PROOFS ## PROOFS
PROOFS_PATH:=extern/proofs/ PROOFS_PATH:=extern/go-fil-proofs/
PROOFS_DEPS:=bin/paramcache bin/paramfetch misc/parameters.json PROOFS_DEPS:=bin/paramcache bin/paramfetch misc/parameters.json
PROOFS_DEPS:=$(addprefix $(SECTOR_BUILDER_PATH),$(SECTOR_BUILDER_DEPS)) PROOFS_DEPS:=$(addprefix $(PROOFS_PATH),$(PROOFS_DEPS))
$(PROOFS_DEPS): build/.proofs-install ; $(PROOFS_DEPS): build/.proofs-install ;
@ -55,6 +55,16 @@ MODULES+=$(PROOFS_PATH)
BUILD_DEPS+=build/.proofs-install BUILD_DEPS+=build/.proofs-install
CLEAN+=build/.proofs-install CLEAN+=build/.proofs-install
PARAM_SECTOR_SIZES:=1024 268435456
PARAM_SECTOR_SIZES:=$(addprefix params-,$(PARAM_SECTOR_SIZES))
$(PARAM_SECTOR_SIZES): extern/go-fil-proofs/bin/paramfetch extern/go-fil-proofs/misc/parameters.json
./extern/go-fil-proofs/bin/paramfetch -z $(subst params-,,$@) --verbose --json=./extern/go-fil-proofs/misc/parameters.json
.PHONY: $(PARAM_SECTOR_SIZES)
paramcache: extern/go-fil-proofs/bin/paramcache
RUST_LOG=info ./extern/go-fil-proofs/bin/paramcache
# end git modules # end git modules
$(MODULES): build/.update-modules ; $(MODULES): build/.update-modules ;
@ -82,6 +92,8 @@ pond: build
clean: clean:
rm -rf $(CLEAN) rm -rf $(CLEAN)
-$(MAKE) -C $(BLS_PATH) clean -$(MAKE) -C $(BLS_PATH) clean
-$(MAKE) -C $(SECTOR_BUILDER_PATH) clean
-$(MAKE) -C $(PROOFS_PATH) clean
.PHONY: clean .PHONY: clean
dist-clean: dist-clean:

View File

@ -5,6 +5,6 @@ package build
const UnixfsChunkSize uint64 = 1 << 20 const UnixfsChunkSize uint64 = 1 << 20
const UnixfsLinksPerLevel = 1024 const UnixfsLinksPerLevel = 1024
const SectorSize = 16 << 20 const SectorSize = 268435456
// TODO: Move other important consts here // TODO: Move other important consts here

1
extern/go-fil-proofs vendored Submodule

@ -0,0 +1 @@
Subproject commit 5201fa9a47494a673da4322dffdf20b7bc335acb

View File

@ -1,14 +0,0 @@
DEPS:=bin/paramcache bin/paramfetch misc/parameters.json
all: $(DEPS)
.PHONY: all
$(DEPS): .install-fil-proofs ;
.install-fil-proofs: bls-signatures
./install-proofs
@touch $@
clean:
rm -rf $(DEPS) .install-bls
.PHONY: clean

View File

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
set -Eeo pipefail
# shellcheck source=install-shared.bash
source "$(dirname "${BASH_SOURCE[0]}")/install-shared.bash"
subm_dir="rust-fil-proofs"
git submodule update --init --recursive ${subm_dir}
if download_release_tarball tarball_path "${subm_dir}"; then
tmp_dir=$(mktemp -d)
tar -C "$tmp_dir" -xzf "$tarball_path"
mkdir -p bin
mkdir -p misc
cp -R "${tmp_dir}/bin/*" bin
cp -R "${tmp_dir}/misc/*" misc
else
echo "failed to find or obtain precompiled assets for ${subm_dir}, falling back to local build"
build_from_source "${subm_dir}"
mkdir -p bin
mkdir -p misc
find "${subm_dir}" -type f -name parameters.json -exec mv -- "{}" ./misc/ \;
find "${subm_dir}" -type f -name paramcache -exec cp -- "{}" ./bin/ \;
find "${subm_dir}" -type f -name paramfetch -exec cp -- "{}" ./bin/ \;
fi

View File

@ -1,82 +0,0 @@
#!/usr/bin/env bash
download_release_tarball() {
__resultvar=$1
__submodule_path=$2
__repo_name=$(echo "$__submodule_path" | cut -d '/' -f 2)
__release_name="${__repo_name}-$(uname)"
__release_sha1=$(git rev-parse @:"${__submodule_path}")
__release_tag="${__release_sha1:0:16}"
__release_tag_url="https://api.github.com/repos/filecoin-project/${__repo_name}/releases/tags/${__release_tag}"
echo "acquiring release @ ${__release_tag}"
__release_response=$(curl \
--retry 3 \
--location "$__release_tag_url")
__release_url=$(echo "$__release_response" | jq -r ".assets[] | select(.name | contains(\"${__release_name}\")) | .url")
if [[ -z "$__release_url" ]]; then
(>&2 echo "failed to download release (tag URL: ${__release_tag_url}, response: ${__release_response})")
return 1
fi
__tar_path="/tmp/${__release_name}_$(basename "${__release_url}").tar.gz"
if [[ ! -f "${__tar_path}" ]]; then
__asset_url=$(curl \
--head \
--retry 3 \
--header "Accept:application/octet-stream" \
--location \
--output /dev/null \
-w "%{url_effective}" \
"$__release_url")
curl --retry 3 --output "${__tar_path}" "$__asset_url"
if [[ $? -ne "0" ]]; then
(>&2 echo "failed to download release asset (tag URL: ${__release_tag_url}, asset URL: ${__asset_url})")
return 1
fi
fi
eval $__resultvar="'$__tar_path'"
}
build_from_source() {
__submodule_path=$1
__submodule_sha1=$(git rev-parse @:"${__submodule_path}")
__submodule_sha1_truncated="${__submodule_sha1:0:16}"
echo "building from source @ ${__submodule_sha1_truncated}"
if ! [ -x "$(command -v cargo)" ]; then
(>&2 echo 'Error: cargo is not installed.')
(>&2 echo 'Install Rust toolchain to resolve this problem.')
exit 1
fi
if ! [ -x "$(command -v rustup)" ]; then
(>&2 echo 'Error: rustup is not installed.')
(>&2 echo 'Install Rust toolchain installer to resolve this problem.')
exit 1
fi
if ! pushd "$__submodule_path"; then
(>&2 echo 'Error: could not cd into submodule')
exit 1
fi
cargo --version
cargo update
if [[ -f "./build-release.sh" ]]; then
./build-release.sh "$(cat rust-toolchain)"
else
cargo build --release --all
fi
popd || exit 1
}

View File

@ -1 +0,0 @@
Subproject commit 8ef99ff867bd0c60acbaae6b4fe4214066936c78