Skip to content

IPFS example with Kubo #72

@bkontur

Description

@bkontur

Relates to: #33
PR: #71

How to run

Install Kubo

wget https://dist.ipfs.tech/kubo/v0.38.0/kubo_v0.38.0_linux-amd64.tar.gz
tar -xvzf kubo_v0.38.0_linux-amd64.tar.gz
cd kubo
sudo bash install.sh
ipfs version
ipfs init
ipfs daemon

Output:

Initializing daemon...
Kubo version: 0.38.0
Repo version: 18
System version: amd64/linux
Golang version: go1.25.1
PeerID: 12D3KooWKZcts5N54ukoNujKXMz6J84A6cn2mtBzxaEsU8uB6uDz
2025/10/08 13:25:25 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 7168 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details.
Swarm listening on 127.0.0.1:4001 (TCP+UDP)
Swarm listening on 172.17.0.1:4001 (TCP+UDP)
Swarm listening on 192.168.3.242:4001 (TCP+UDP)
Swarm listening on 192.168.4.241:4001 (TCP+UDP)
Swarm listening on [::1]:4001 (TCP+UDP)
Run 'ipfs id' to inspect announced and discovered multiaddrs of this node.
RPC API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
Gateway server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready

Download zombienet

wget https://github.com/paritytech/zombienet/releases/download/v1.3.133/zombienet-linux-x64
chmod +x zombienet-linux-x64

Build Bulletin

git clone https://github.com/paritytech/polkadot-bulletin-chain.git
cd polkadot-bulletin-chain
git checkout -b bko-examples --track origin/bko-examples
cargo build --release -p polkadot-bulletin-chain

Download Zombienet

# cd polkadot-bulletin-chain - make sure we are here
wget https://github.com/paritytech/zombienet/releases/download/v1.3.133/zombienet-linux-x64

Run Bulletin

POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain ./zombienet-linux-x64 -p native spawn ./zombienet/bulletin-polkadot-local.toml

IPFS swarm connect of Bulletin nodes with --ipfs-server

ipfs swarm connect /ip4/127.0.0.1/tcp/10001/ws/p2p/12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm
# connect 12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm success
ipfs swarm connect /ip4/127.0.0.1/tcp/12347/ws/p2p/12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby
# connect 12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby success
ipfs swarm peers 

Trigger authorize, store and IPFS get

# cd polkadot-bulletin-chain - make sure we are here
cd examples
npm install @polkadot/api @polkadot/keyring @polkadot/util-crypto @polkadot/util multiformats ipfs-http-client
node authorize_and_store.js

Problem does not return data - just hangs on the last command and timeouts after some time

node authorize_and_store.js
(node:532180) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///tmp/testet/authorize_and_store.js is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /tmp/testet/package.json.
(Use `node --trace-warnings ...` to show where the warning was created)
2025-10-08 13:48:28        REGISTRY: Unknown signed extensions ValidateSigned, BridgeRejectObsoleteHeadersAndMessages found, treating them as no-effect
2025-10-08 13:48:28        API/INIT: RPC methods not decorated: chainHead_v1_body, chainHead_v1_call, chainHead_v1_continue, chainHead_v1_follow, chainHead_v1_header, chainHead_v1_stopOperation, chainHead_v1_storage, chainHead_v1_unfollow, chainHead_v1_unpin, chainSpec_v1_chainName, chainSpec_v1_genesisHash, chainSpec_v1_properties, transactionWatch_v1_submitAndWatch, transactionWatch_v1_unwatch, transaction_v1_broadcast, transaction_v1_stop
Doing authorization...
Transaction authorizeAccount result: 0x248835f504be082bcdf92ec89874f795fd4dd2f99547f4bbcf25e4e1814ba06d
Authorized!
Storing data...
Storing data: Hello, Bulletin remote3 - Wed Oct 08 2025 13:48:36 GMT+0000 (Coordinated Universal Time)
Transaction store result: 0x1d2ae0a5b2e8e8d7e58d5d313aeefed2cf667f6bb7c6e1bdbb82a50db87e12af
Stored data with CID:  CID(bafk2bzacecyfddy3sbswudtwnrjqrtnoryo5gv4v6gcmuseylkma5icb45zls)
Reading content... cid:  CID(bafk2bzacecyfddy3sbswudtwnrjqrtnoryo5gv4v6gcmuseylkma5icb45zls)
Trying to get cid:  CID(bafk2bzacecyfddy3sbswudtwnrjqrtnoryo5gv4v6gcmuseylkma5icb45zls)

TypeError: fetch failed
    at node:internal/deps/undici/undici:13510:13
    at async Client.fetch (/tmp/testet/node_modules/ipfs-utils/src/http.js:140:22)
    at async Object.get (file:///tmp/testet/node_modules/ipfs-http-client/src/block/get.js:14:17)
    at async read_from_ipfs (file:///tmp/testet/authorize_and_store.js:60:19)
    at async main (file:///tmp/testet/authorize_and_store.js:104:19) {
  [cause]: HeadersTimeoutError: Headers Timeout Error
      at FastTimer.onParserTimeout [as _onTimeout] (node:internal/deps/undici/undici:6249:32)
      at Timeout.onTick [as _onTimeout] (node:internal/deps/undici/undici:2210:17)
      at listOnTimeout (node:internal/timers:588:17)
      at process.processTimers (node:internal/timers:523:7) {
    code: 'UND_ERR_HEADERS_TIMEOUT'
  }
}

More info for investigation

bkontur@toaster1:~/kubo$ ipfs id 12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm
{
	"ID": "12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm",
	"PublicKey": "CAESINW/Sj/M5xewOIvMJ0nrwUitmWmyP0XuG2Bf1Yd4V2rE",
	"Addresses": [
		"/p2p/12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm"
	],
	"AgentVersion": "",
	"Protocols": [
		"/ipfs/bitswap/1.2.0",
		"/ipfs/ping/1.0.0"
	]
}

bkontur@toaster1:~/kubo$ ipfs id 12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby
{
	"ID": "12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby",
	"PublicKey": "CAESIOzBtYcn8/ErMZSIGp7LneCyjOeyByMNjpMP4bznXiVs",
	"Addresses": [
		"/p2p/12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby"
	],
	"AgentVersion": "",
	"Protocols": [
		"/ipfs/bitswap/1.2.0",
		"/ipfs/ping/1.0.0"
	]
}

bkontur@toaster1:~/kubo$ ipfs bitswap stat
bitswap status
	blocks received: 3
	blocks sent: 0
	data received: 3884
	data sent: 0
	dup blocks received: 0
	dup data received: 0
	wantlist [1 keys]
		bafk2bzacecyfddy3sbswudtwnrjqrtnoryo5gv4v6gcmuseylkma5icb45zls
	partners [4]

Some logs from the Bulletin

cat /tmp/zombie-eaab4f737f4a74587da5d38d18d98feb_-457541-yTugVRRbG0gJ/alice.log | grep bit

2025-10-08 13:31:36.033 DEBUG tokio-runtime-worker sub-libp2p::bitswap: starting bitswap server
2025-10-08 13:44:53.343 DEBUG tokio-runtime-worker sub-libp2p::bitswap: handle bitswap request from PeerId("12D3KooWKZcts5N54ukoNujKXMz6J84A6cn2mtBzxaEsU8uB6uDz") for [(Cid(bafk2bzaceaicq5fdo5ojy2idfgrkx26pbiyfcqceaj7nn3gspsrupwyluldou), Have)]
2025-10-08 13:44:53.343 TRACE tokio-runtime-worker sub-libp2p::bitswap: found cid Cid(bafk2bzaceaicq5fdo5ojy2idfgrkx26pbiyfcqceaj7nn3gspsrupwyluldou), hash 0x102874a3775c9c690329a2abebcf0a30514044027ed6ecd27ca347db0ba2c6ea

And nothing else, if I run node authorize_and_store.js multiple times (generates different CID all the time), Then ipfs bitswap stat changes and I see wantlist [1 keys] with the CID, but the logs does not change, I can see just first request in the Bulletin node - looks like it stopped processing Bitswap or something.

Nodejs code

import { create } from 'ipfs-http-client';

// Connect to a local IPFS node or Infura/IPFS gateway
const ipfs = create({
    url: 'http://127.0.0.1:5001', // Local IPFS API
});

console.log('Trying to get cid: ', cid);
const block = await ipfs.block.get(cid);
console.log('Received block: ', block);

Direct IPFS commands

ipfs block get bafk2bzacebkeungwf4uyjgxawfawxcathvgq4rfud5vnhsmm4wg6jhdz4zgri
^C
Error: context canceled
bkontur@toaster1:~/kubo$ ipfs block get /ipfs/bafk2bzacebkeungwf4uyjgxawfawxcathvgq4rfud5vnhsmm4wg6jhdz4zgri
^C
Error: context canceled

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions