|
1 | | -# How to run |
| 1 | +# How to Run |
2 | 2 |
|
3 | | -### Build Bulletin |
4 | | -``` |
5 | | -git clone https://github.com/paritytech/polkadot-bulletin-chain.git |
6 | | -cd polkadot-bulletin-chain |
7 | | -cargo build --release -p polkadot-bulletin-chain |
8 | | -``` |
9 | 3 |
|
10 | | -### Download Zombienet |
11 | | -``` |
12 | | -cd polkadot-bulletin-chain - make sure we are within the folder |
| 4 | +```shell |
| 5 | +cd polkadot-bulletin-chain # make you are inside the project directory for the following steps |
13 | 6 | ``` |
14 | 7 |
|
15 | | -#### Linux |
16 | | -``` |
17 | | -wget https://github.com/paritytech/zombienet/releases/download/v1.3.133/zombienet-linux-x64 |
18 | | -chmod +x zombienet-linux-x64 |
19 | | -``` |
| 8 | +## Download Zombienet |
20 | 9 |
|
21 | | -#### Mac OS |
22 | | -`zombienet-macos-arm64` or `zombienet-macos-x64` |
| 10 | +```shell |
| 11 | +OS="$(uname -s)" |
| 12 | +ARCH="$(uname -m)" |
23 | 13 |
|
24 | | -``` |
25 | | -curl -L -o zombienet-macos-arm64 https://github.com/paritytech/zombienet/releases/download/v1.3.133/zombienet-macos-arm64 |
26 | | -chmod +x zombienet-macos-arm64 |
27 | | -``` |
| 14 | +if [ "$OS" = "Linux" ]; then |
| 15 | + zb_os=linux |
| 16 | +else |
| 17 | + zb_os=macos |
| 18 | +fi |
28 | 19 |
|
29 | | -### Run Kubo locally |
| 20 | +if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then |
| 21 | + zb_arch=arm64 |
| 22 | +else |
| 23 | + zb_arch=x64 |
| 24 | +fi |
30 | 25 |
|
31 | | -#### Either locally |
32 | | -``` |
33 | | -wget https://dist.ipfs.tech/kubo/v0.38.1/kubo_v0.38.1_linux-amd64.tar.gz |
34 | | -tar -xvzf kubo_v0.38.1_linux-amd64.tar.gz |
35 | | -cd kubo |
36 | | -sudo bash install.sh |
37 | | -ipfs version |
38 | | -ipfs init |
39 | | -ipfs daemon & # run in background |
| 26 | +zb_bin="zombienet-${zb_os}-${zb_arch}" |
| 27 | + |
| 28 | +wget "https://github.com/paritytech/zombienet/releases/download/v1.3.133/${zb_bin}" |
| 29 | +chmod +x "${zb_bin}" |
40 | 30 | ``` |
41 | 31 |
|
42 | | -#### Or use docker (uses 172.17.0.1 or host.docker.internal for swarm connect) |
| 32 | +## Run Kubo |
| 33 | + |
| 34 | +#### Execute Locally |
43 | 35 |
|
| 36 | +```shell |
| 37 | +wget https://dist.ipfs.tech/kubo/v0.38.1/kubo_v0.38.1_darwin-arm64.tar.gz |
| 38 | +tar -xvzf kubo_v0.38.1_darwin-arm64.tar.gz |
| 39 | +./kubo/ipfs version |
| 40 | +./kubo/ipfs init |
| 41 | +./kubo/ipfs daemon & # run in the background |
44 | 42 | ``` |
| 43 | + |
| 44 | +#### Use Docker |
| 45 | + |
| 46 | +* Use `172.17.0.1` or `host.docker.internal` for swarm connections |
| 47 | + |
| 48 | +```shell |
45 | 49 | docker pull ipfs/kubo:latest |
46 | | -docker run -d --name ipfs-node -v ipfs-data:/data/ipfs -p 4001:4001 -p 8080:8080 -p 5001:5001 ipfs/kubo:latest |
| 50 | +docker run -d --name ipfs-node -v ipfs-data:/data/ipfs -p 4001:4001 -p 8080:8080 -p 5001:5001 ipfs/kubo:latest |
47 | 51 | docker logs -f ipfs-node |
48 | 52 | ``` |
49 | 53 |
|
50 | | -## Run Bulletin solochain with `--ipfs-server` |
51 | | -``` |
| 54 | +## Run Bulletin Solochain with `--ipfs-server` |
| 55 | + |
| 56 | +```shell |
52 | 57 | # Bulletin Solochain |
53 | | -POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain ./zombienet-linux-x64 -p native spawn ./zombienet/bulletin-polkadot-local.toml |
54 | 58 |
|
55 | | -# Connect nodes |
56 | | -ipfs swarm connect /ip4/127.0.0.1/tcp/10001/ws/p2p/12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm |
| 59 | +```shell |
| 60 | +# cd polkadot-bulletin-chain # make you are in this directory |
| 61 | +cargo build --release -p polkadot-bulletin-chain |
| 62 | +
|
| 63 | +POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain \ |
| 64 | + ./$(ls zombienet-*-*) -p native spawn ./zombienet/bulletin-polkadot-local.toml |
| 65 | +
|
| 66 | +### Connect IPFS Nodes |
| 67 | +
|
| 68 | +```shell |
| 69 | +# Uses Kubo |
| 70 | +./kubo/ipfs swarm connect /ip4/127.0.0.1/tcp/10001/ws/p2p/12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm |
57 | 71 | # connect 12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm success |
58 | | -ipfs swarm connect /ip4/127.0.0.1/tcp/12347/ws/p2p/12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby |
| 72 | + |
| 73 | +./kubo/ipfs swarm connect /ip4/127.0.0.1/tcp/12347/ws/p2p/12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby |
59 | 74 | # connect 12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby success |
| 75 | +``` |
60 | 76 |
|
61 | | -# Or docker (change 127.0.0.1 -> 172.17.0.1) |
| 77 | +```shell |
| 78 | +# Uses Docker (replace 127.0.0.1 with 172.17.0.1) |
62 | 79 | docker exec -it ipfs-node ipfs swarm connect /ip4/172.17.0.1/tcp/10001/ws/p2p/12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm |
63 | 80 | docker exec -it ipfs-node ipfs swarm connect /ip4/172.17.0.1/tcp/12347/ws/p2p/12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby |
| 81 | +``` |
64 | 82 |
|
65 | | -# Or run script which reconnects every 2 seconds |
| 83 | +```shell |
| 84 | +# Runs a script that reconnects every 2 seconds |
| 85 | +# Defaults to Docker; use 'local' to use the local Kubo instance |
66 | 86 | ./scripts/ipfs-reconnect-solo.sh |
67 | 87 | ``` |
68 | 88 |
|
69 | | -## Run Bulletin (Westend) parachain with `--ipfs-server` |
| 89 | +## Run Bulletin (Westend) Parachain with `--ipfs-server` |
| 90 | + |
| 91 | +### Prerequisites |
| 92 | + |
| 93 | +```shell |
| 94 | +mkdir -p ~/local_bridge_testing/bin |
| 95 | + |
| 96 | +# Ensures `polkadot` and `polkadot-parachain` exist |
| 97 | +git clone https://github.com/paritytech/polkadot-sdk.git |
| 98 | +# TODO: unless not merged: https://github.com/paritytech/polkadot-sdk/pull/10370 |
| 99 | +git reset --hard origin/bko-bulletin-para-support |
| 100 | +cd polkadot-sdk |
| 101 | + |
| 102 | +cargo build -p polkadot -r |
| 103 | +ls -la target/release/polkadot |
| 104 | +cp target/release/polkadot ~/local_bridge_testing/bin |
| 105 | +cp target/release/polkadot-prepare-worker ~/local_bridge_testing/bin |
| 106 | +cp target/release/polkadot-execute-worker ~/local_bridge_testing/bin |
| 107 | +~/local_bridge_testing/bin/polkadot --version |
| 108 | +# polkadot 1.20.2-165ba47dc91 or higher |
| 109 | + |
| 110 | +cargo build -p polkadot-parachain-bin -r |
| 111 | +ls -la target/release/polkadot-parachain |
| 112 | +cp target/release/polkadot-parachain ~/local_bridge_testing/bin |
| 113 | +~/local_bridge_testing/bin/polkadot-parachain --version |
| 114 | +# polkadot-parachain 1.20.2-165ba47dc91 or higher |
70 | 115 | ``` |
71 | | -# Bulletin parachain (Westend) |
| 116 | + |
| 117 | +### Launch Parachain |
| 118 | + |
| 119 | +```shell |
| 120 | +# Bulletin Parachain (Westend) |
72 | 121 | ./scripts/create_bulletin_westend_spec.sh |
73 | | -POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain ./zombienet-linux-x64 -p native spawn ./zombienet/bulletin-westend-local.toml |
| 122 | +POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \ |
| 123 | + POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ |
| 124 | + ./$(ls zombienet-*-*) -p native spawn ./zombienet/bulletin-westend-local.toml |
| 125 | +``` |
| 126 | + |
| 127 | +### Connect IPFS Nodes |
| 128 | + |
| 129 | +```shell |
| 130 | +# Uses Kubo |
| 131 | +./kubo/ipfs swarm connect /ip4/127.0.0.1/tcp/10001/ws/p2p/12D3KooWJKVVNYByvML4Pgx1GWAYryYo6exA68jQX9Mw3AJ6G5gQ |
| 132 | +# connect 12D3KooWJKVVNYByvML4Pgx1GWAYryYo6exA68jQX9Mw3AJ6G5gQ success |
74 | 133 |
|
75 | | -# For docker (change 127.0.0.1 -> 172.17.0.1) |
| 134 | +./kubo/ipfs swarm connect /ip4/127.0.0.1/tcp/12347/ws/p2p/12D3KooWJ8sqAYtMBX3z3jy2iM98XGLFVzVfUPtmgDzxXSPkVpZZ |
| 135 | +# connect 12D3KooWJ8sqAYtMBX3z3jy2iM98XGLFVzVfUPtmgDzxXSPkVpZZ success |
| 136 | +``` |
| 137 | + |
| 138 | +```shell |
| 139 | +# Uses Docker (replace 127.0.0.1 with 172.17.0.1) |
76 | 140 | docker exec -it ipfs-node ipfs swarm connect /ip4/172.17.0.1/tcp/10001/ws/p2p/12D3KooWJKVVNYByvML4Pgx1GWAYryYo6exA68jQX9Mw3AJ6G5gQ |
77 | 141 | docker exec -it ipfs-node ipfs swarm connect /ip4/172.17.0.1/tcp/12347/ws/p2p/12D3KooWJ8sqAYtMBX3z3jy2iM98XGLFVzVfUPtmgDzxXSPkVpZZ |
| 142 | +``` |
78 | 143 |
|
79 | | -# Or run script which reconnects every 2 seconds |
| 144 | +```shell |
| 145 | +# Runs a script that reconnects every 2 seconds |
| 146 | +# Defaults to Docker; use 'local' to use the local Kubo instance |
80 | 147 | ./scripts/ipfs-reconnect-westend.sh |
81 | 148 | ``` |
82 | 149 |
|
83 | | -## Trigger authorize, store and IPFS get |
84 | | -``` |
85 | | -# cd polkadot-bulletin-chain - make sure we are here |
| 150 | +## Trigger Authorize, Store and IPFS Get |
| 151 | + |
| 152 | +```shell |
| 153 | +# cd polkadot-bulletin-chain # make you are in this directory |
86 | 154 | cd examples |
87 | 155 | npm install @polkadot/api @polkadot/keyring @polkadot/util-crypto @polkadot/util multiformats ipfs-http-client ipfs-unixfs |
88 | 156 | ``` |
89 | 157 |
|
90 | | -### Example for simple authorizing and store |
91 | | -``` |
| 158 | +### Example for Simple Authorizing and Store |
| 159 | + |
| 160 | +```shell |
92 | 161 | node authorize_and_store.js |
93 | 162 | ``` |
94 | 163 |
|
95 | | -### Example for multipart / chunked content / big files |
96 | | -The code stores one file, splits into chunks and then uploads those chunks to the Bulletin. |
97 | | -It collects all the partial CIDs for each chunk and saves them as a custom metadata JSON file in the Bulletin. |
| 164 | +### Example for Multipart / Chunked Content / Big Files |
| 165 | + |
| 166 | +The code stores one file, splits it into chunks, and then uploads those chunks to Bulletin. |
| 167 | + |
| 168 | +It collects all the partial CIDs for each chunk and saves them as a custom metadata JSON file in Bulletin. |
98 | 169 |
|
99 | 170 | Now we have two examples: |
100 | 171 | 1. **Manual reconstruction** — return the metadata and chunk CIDs, then reconstruct the original file manually. |
101 | 172 | 2. **IPFS DAG feature** — |
102 | 173 | * converts the metadata into a DAG-PB descriptor, |
103 | 174 | * stores it directly in IPFS, |
104 | 175 | * and allows fetching the entire file using a single root CID from an IPFS HTTP gateway (for example: `http://localhost:8080/ipfs/QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ`). |
105 | | -``` |
| 176 | + |
| 177 | +```shell |
106 | 178 | node store_chunked_data.js |
107 | 179 | ``` |
0 commit comments