Blogs & Articles: Orbital Data Freighting With Blockstream Satellite đ 3 years ago
- Category: Blogs & Articles | grubles on Medium
- Author(s): grubles
- Published: 9th February 2021 17:05
Blockstream Satellite is a service which provides a broadcast of Bitcoin blockchain data, Lightning Network gossip data, and usersâ custom data via a network of geosynchronous satellites. The one-way transmission provides a degree of privacy that is unique in the communications industry and is free to use for anyone who has the hardware able to receive the transmission.
While people can use the service to send arbitrary small pieces of data like text messages or pictures, it also creates an opportunity to mass-broadcast bigger, more important chunks of data to a global-scale coverage area.
Below, weâve provided a guide on how you can broadcast larger files (such as software packages) over the Blockstream Satellite API, using the Bitcoin Satellite source code as an example. And with the recent Satellite API price decrease, broadcasting data via satellite is cheaper than ever. It currently costs around $0.30-$0.40 per megabyte to broadcast now, which is #unfairlycheap.
Connecting the disconnected
Many people around the world live in regions with poor or no internet infrastructure at all. Those who have access to an internet connection may be limited by data caps. A large US ISP recently instated a 1.2 TB data cap on its customers. The initial block download for Bitcoin is 300GB+.
Some people have the only option of using filtered/censored internet connections which make some websites completely unreachable. If Bitcoin is to be used around the world, then itâs important for people to run their own nodes so they can verify the Bitcoin data themselves instead of trusting third parties.
As weâve witnessed recently, relying on a centralized hosting service can result in the service shutting down access to code. Ideally, access to source code should be decentralized with no single point of failure. Especially so for a project like Bitcoin Core.
Donât trust. Verify.
âProof-of-work has the nice property that it can be relayed through untrusted middlemen.ââââSatoshi Nakamoto
Using Blockstream Satellite, itâs possible to discreetly receive the source code for a Bitcoin Core node, build the software from the source code, and then sync the Bitcoin blockchain all using only the Blockstream Satellite downlink.
There is no trust required for receiving the Bitcoin blockchain data from Blockstream since the proof of work headers are authenticatable even over very low bandwidth means such as SMS via 1â833-BLK-HASH.
The only required items are ubiquitous FOSS dependencies (such as gcc, boost, etc.) along with widely available hardware (you can purchase parts kits from the Blockstream Store). Receiving source code via Satellite is exceptionally privacy-preserving, and can also work for other software projects!
The aim here is to remove anything that isnât required to build bitcoind. So by stripping unnecessary parts of the Bitcoin Satellite code tarball, we can compress it to a roughly 2.8 MB archive. This archive can then be split into separate Satellite API transmissions and received by users all over the world. Once received, the split archive can be reassembled and then decompressed. The user can then proceed to building the node software and begin syncing the Bitcoin transaction history via Blockstream Satellite. Verifying the authenticity of the source code is important, so a trusted developer could sign the minimal tarball and distribute those keys via satellite as well.
Example tutorial
An example is pretty straightforward. The process is basically to delete as much unnecessary data from the code tarball, recompress it, split it into broadcastable chunks, then beam them up to space! Users can then receive the chunks, reassemble them into a single file, then decompress that file. From there, they can build bitcoind as they would normally and begin to sync a full node from scratch using the Blockstream Satellite downlink.
Note that this demo is for the Bitcoin Satellite source code. Other projects may not have as much prunable data and may cost more BTC to broadcast. However, the same method of splitting the data into smaller pieces for reassembly after receiving applies.
Download the Bitcoin Satellite archive
wget https://github.com/Blockstream/bitcoinsatellite/releases/tag/v0.19.1-satellite0.2.0
du -sh v0.19.1-satellite0.2.0.tar.gz
Note the archive is 9.4Â MB.
Extract the Bitcoin Satellite archive
tar zxvf v0.19.1-satellite0.2.0.tar.gz
Prune unneeded data
The following directories arenât really needed to build bitcoind . Leave src/qt if you want to build the GUI.
cd bitcoinsatellite-0.19.1-satellite0.2.0/
rm -rf build_msvc/ ci/ share/ src/qt/ test/ contrib/ doc/ docker/
cd ../
Compress the pruned Bitcoin Satellite directory
tar cvf bitcoinsatellite.tar bitcoinsatellite-0.19.1-satellite0.2.0/
xz -z -9 -e bitcoinsatellite.tar
Resulting compressed archive is 3471768 bytes (3.4Â MB).
Or, use zpaq for a smaller cheaper to broadcast archive. The only caveat is users will need to install zpaq. However, zpaq is available in the default Ubuntu and Fedora repositories so itâs just an apt or dnf away.
zpaq add bs.zpaq bitcoinsatellite.tar -m5
Resulting archive is 2876209 bytes (2.88 MB), which is 595559 bytes (0.59 MB)Â smaller!
Every byte counts when using the Satellite API since youâre paying in BTC!
Split the archive into individual parts
The Satellite API has a 1 MB per transmission upload limit, so we have to split our 2.88 MB archive into smaller parts using the split command.
split -b 800K blocksat.zpaq bs_part_
This splits the zpaq archive into parts about 800KB each to leave some room for the Satellite API protocol overhead. We can now upload and pay for their global transmissions using Lightning! The blocksat_part_ is the prefix used to label the individual parts of the blocksat.zpaq file.
ls -la
-rw-rw-r-- 1 user user 819200 Nov 18 19:20 blocksat_part_aa
-rw-rw-r-- 1 user user 819200 Nov 18 19:20 blocksat_part_ab
-rw-rw-r-- 1 user user 819200 Nov 18 19:20 blocksat_part_ac
-rw-rw-r-- 1 user user 416510 Nov 18 19:20 blocksat_part_ad
Broadcasting the compressed archive files
As the sender, weâll need to install blocksat-cli and c-lightning . This is the utility that is used for, among other things, sending and receiving data over the Satellite API. c-lightning is the Lightning Network node that weâll be using to pay for the data broadcasts. Build instructions for c-lightning are here.
Installing blocksat-cli is easy. Full instructions are available but itâs mostly a matter of using pip to install it.
pip3 install --user blocksat-cli
Now use blocksat-cli to send each file. There are two ways to do this. The first way is the manual way where blocksat-cli will prompt you for the bid you would like to set for your broadcast order, and then prompt you with a Lightning invoice that you have to manually pay.
blocksat-cli api send --plaintext -f blocksat_part_aa
blocksat-cli api send --plaintext -f blocksat_part_ab
blocksat-cli api send --plaintext -f blocksat_part_ac
blocksat-cli api send --plaintext -f blocksat_part_ad
The less time-consuming way is to set the bid (total amount of millisatoshis) in a command flag and use blocksat-cli âs built-in feature that letâs you automatically pay for Lightning invoices using c-lightning.
blocksat-cli api send --plaintext -f blocksat_part_aa --bid <your bid> --invoice-exec "lightning-cli pay {}"
blocksat-cli api send --plaintext -f blocksat_part_ab --bid <your bid> --invoice-exec "lightning-cli pay {}"
blocksat-cli api send --plaintext -f blocksat_part_ac --bid <your bid> --invoice-exec "lightning-cli pay {}"
blocksat-cli api send --plaintext -f blocksat_part_ad --bid <your bid> --invoice-exec "lightning-cli pay {}"
Optionally, you can choose to apply Forward Error Correction (FEC) to your broadcast. Since users of Blockstream Satellite are all over the globe in different geographical regions, some may not receive the data you broadcast due to local weather conditions or due to receiving a poor signal.
FEC can increase the chances of your data being received by users around the world. To apply it to your broadcasted files, add the --fec flag to the blocksat-cli api send commands above.
Now simply pay the Lightning invoice for each file and they will be sent to the Blockstream Satellite network and broadcasted globally!
Reassembling the split archive and decompressing
On the receiving end, itâs just a matter of concatenating the individual parts into one single file, and using zpaq to extract the archive. From there we can build the bitcoind binary and begin syncing our new full node straight from Blockstream Satellite (assuming the receiver hardware and blocksat-cli are configured correctly).
First make sure youâre running the blocksat-cli API app for receiving Satellite APIÂ data.
blocksat-cli api listen --plaintext
In the downloads/ directory, concatenate the individual parts of the archive together.
cat blocksat_part_a* > blocksat.zpaq
Then extract the reassembled .zpaq archive!
zpaq x blocksat.zpaq
zpaq v7.15 journaling archiver, compiled Mar 22 2020
bs.zpaq: 1 versions, 1 files, 231 fragments, 2.874110 MB
Extracting 22.753280 MB in 1 files -threads 32
[1..231] -> 16695296
> bitcoinsatellite.tar
188.905 seconds (all OK)
Thatâs it! Weâve completed a broadcast and received the source code archive. From there, itâs just a matter of following the build instructions in build-unix.md , assuming youâve obtained the build dependencies.
To learn more about Blockstream Satellite and the Satellite API, here are some links to reading material and documentation:
- https://blockstream.com/satellite/
- https://github.com/Blockstream/satellite
- https://blockstream.com/satellite/#satellite_network-coverage
- https://help.blockstream.com/hc/en-us/categories/900000061466-Blockstream-Satellite/
Purchase a Blockstream Satellite Kit (out of stock currently):
Also be sure to join the Telegram group which doubles as a Satellite APIÂ feed!
Orbital Data Freighting With Blockstream Satellite was originally published in Blockstream Engineering Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.