Skip to content

Commit e9c294b

Browse files
committed
feat: simplified pin-params.sh
The pin-params.sh with the fancy "last 3 versions" magic removed, it - verifies that you have a single version of the params in /var/tmp/filecoin-proof-parameters - posts them to cluster via `ipfs-cluster-ctl` - publishes the new cid to proofs.filecoin.io via `npx dnslink-dnsimple` you need to install `ipfs-cluster-ctl` and a reasonable verion of node.js >= v10 at a guess. see: https://dist.ipfs.io/#ipfs-cluster-ctl see: https://www.npmjs.com/package/dnslink-dnsimple License: MIT Signed-off-by: Oli Evans <oli@tableflip.io>
1 parent e5fdeb9 commit e9c294b

File tree

1 file changed

+8
-36
lines changed

1 file changed

+8
-36
lines changed

scripts/pin-params.sh

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -Eeuo pipefail
33

44
# pin-params.sh
55
#
6-
# - Add the directory of params to the local ipfs node
6+
# - Post the directory of params to cluster.ipfs.io
77
# - Grab the CID for the previous params from proofs.filecoin.io
88
# - Add the old params as a `prev` dir to the new params dir to keep them around.
99
# - Pin the new cid on cluster
@@ -54,48 +54,20 @@ else
5454
fi
5555

5656
CLUSTER_HOST="/dnsaddr/cluster.ipfs.io"
57-
CLUSTER_PRIMARY="/dns4/cluster0.fsn.dwebops.pub/udp/4001/quic/p2p/QmUEMvxS2e7iDrereVYc5SWPauXPyNwxcy9BXZrC1QTcHE"
5857
CLUSTER_PIN_NAME="filecoin-proof-parameters-$VERSION"
5958
DNSLINK_DOMAIN="proofs.filecoin.io"
6059

61-
# Pin to ipfs
62-
ROOT_CID=$(ipfs add --quieter --recursive $INPUT_DIR)
63-
echo "ok! root cid is $ROOT_CID"
64-
65-
echo "linking to previous version..."
66-
# trim off the /ipfs prefix, so it's consistent with the other vars
67-
PREV_CID=$(ipfs dns $DNSLINK_DOMAIN | cut -c 7-)
68-
69-
# Add a `prev` dir to the new params dir that links back to the older params
70-
LINKED_CID=$(ipfs object patch add-link $ROOT_CID prev $PREV_CID)
71-
72-
# guard against multiple runs with no change...
73-
# if we remove the `prev` dir from the last published PREV_CID and it matches
74-
# the current ROOT_DIR, then dont nest it inside itself again.
75-
if ipfs object stat $PREV_CID/prev > /dev/null; then
76-
PREV_ROOT_CID=$(ipfs object patch rm-link $PREV_CID prev)
77-
if [[ $PREV_ROOT_CID == "$ROOT_CID" ]]; then
78-
LINKED_CID=$PREV_CID
79-
echo "linked cid is already published, re-using $PREV_CID"
80-
echo "continuing to ensure $PREV_CID is pinned to cluster"
81-
fi
82-
fi
83-
84-
echo "ok! linked cid is $LINKED_CID"
85-
echo "pinning linked cid to cluster..."
86-
87-
# Connect to cluster to speed up discovery
88-
ipfs swarm connect $CLUSTER_PRIMARY
89-
90-
# Ask cluster to fetch the linked cid from us
91-
ipfs-cluster-ctl \
60+
# Pin to cluster
61+
ROOT_CID=$(ipfs-cluster-ctl \
9262
--host $CLUSTER_HOST \
9363
--basic-auth $CLUSTER_TOKEN \
94-
pin add $LINKED_CID \
64+
add --quieter \
9565
--name $CLUSTER_PIN_NAME \
96-
--wait
66+
--recursive $INPUT_DIR )
67+
68+
echo "ok! root cid is $ROOT_CID"
9769

9870
# Publist the new cid to the dnslink
99-
npx dnslink-dnsimple --domain proofs.filecoin.io --link "/ipfs/$LINKED_CID"
71+
npx dnslink-dnsimple --domain $DNSLINK_DOMAIN --link "/ipfs/$ROOT_CID"
10072

10173
echo "done!"

0 commit comments

Comments
 (0)