Automation for pinning Status Sticker Packs https://hub.docker.com/r/statusteam/auto-sticker-pinner
Go to file
Artur Marud 6be664effe
Added possibility to configure public gateway by env variables and changed default gw to gateway.ipfs.io (#1)
Signed-off-by: Artur Marud <artur@status.im>
2022-05-20 12:27:58 +02:00
.dockerignore add Dockerfile 2020-06-17 22:55:47 +02:00
.gitignore add gitignore suited for python 2020-06-08 12:45:00 +02:00
Dockerfile fix loading of abi.json in Docker 2020-06-17 23:14:45 +02:00
README.md update known issues 2020-07-27 14:19:49 +02:00
abi.json add initial experiments 2020-06-08 12:45:38 +02:00
contract.py return parsed packs 2020-06-09 18:59:27 +02:00
ipfs.py update known issues 2020-07-27 14:19:49 +02:00
log.py drop timestamp from log format 2020-06-17 23:21:25 +02:00
main.py add more granular pinning status checking 2020-07-27 14:04:02 +02:00
pack.py Added possibility to configure public gateway by env variables and changed default gw to gateway.ipfs.io (#1) 2022-05-20 12:27:58 +02:00
pin.py add more granular pinning status checking 2020-07-27 14:04:02 +02:00
requirements.txt use specific ipfshttpclient version 2020-06-17 10:10:22 +02:00
watch.py fix event watching based on goerli tests 2020-06-17 17:14:11 +02:00

README.md

Description

This is an automation written in Python for pinning Status Sticker Packs to our IPFS cluster.

In simple terms it talks to a go-ethereum node over RPC and waits for specific Ethereum Contract events to detect new Sticker Packs being added. When it detects such an event it talks to the IPFS cluster to pin the pack metadata and all the images.

Requirements

This software assumes availability of two endpoints:

  • http://localhost:8545 - Geth RPC Admin API
  • /dns/localhost/tcp/9094/http - IPFS Cluster Admin API

You can specify those with --geth-addr and --ipfs-addr respectively.

Usage

The simplest way to use it is to just run it:

./main.py
INFO - Connecting to Geth RPC: http://localhost:8545
INFO - Connecting to IPFS Cluster: /dns/localhost/tcp/9094/http
INFO - Watching for events: ContenthashChanged,Register

Here's the available options:

Usage: main.py [options]

Utility for pinning images from Status Sticker packs.

Options:
  -h, --help            show this help message and exit
  -p, --pin-all         If all packs should be pinned on start.
  -g GETH_ADDR, --geth-addr=GETH_ADDR
                        IPFS Cluster API URL.
  -i IPFS_ADDR, --ipfs-addr=IPFS_ADDR
                        IPFS Cluster API MultiAddress.
  -e EVENTS, --events=EVENTS
                        Contract events to watch for.
  -c CONTRACT, --contract=CONTRACT
                        Sticker Pack contract address.
  -I LOG_LEVEL, --log-level=LOG_LEVEL
                        Level of logging.

Example: ./main.py --pin-all=true --events=ContenthashChanged

Details

This software:

  1. Connects to Geth Admin RCP API
  2. Connects to IPFS Admin API
  3. Pins all currently existing Sticker Packs to IPFS (Optional)
  4. Listens via the synced Geth node for Sticker Pack contract events
  5. On ContenthashChanged or Register events it:
  • Extracts contenthash from their arguments
  • Pins the Sticker Pack metadata file
  • Extracts from the metadata file image hashes
  • Pins the Sticker pack images to the IPFS cluster

Docker Image

You can build a Docker image with:

docker build -t statusteam/auto-sticker-pinner:latest .

Known Issues

  • Currently IPFS Cluster API does not expose any info about possible pinning errors
    • We run GET /pin/{chash} to check if it was pinned as an alternative
  • Checking pin status for a cluster returns multiple statuses
    • We check if all of them are of certain type, and ignore other mixed states