Run BSP Node
Run & Build BSP Agent from Source
Install bsp-agent
Next, we’re going to install the agent that can transform the specimens to AVRO encoded blocks, prove that their data contains what is encoded and upload them to an object store.
Clone the covalenthq/bsp-agent repo in a separate terminal and build.
Create envrc file
- Add a
.envrc
file to~/bsp-agent
and add the private key to your operator account address. (See below on how to do this for this workshop) - Here we set up the required env vars for the bsp-agent. Other variables that are not secrets are passed as flags. Add the entire line below to the .envrc file with the replaced keys, rpc url and ipfs service token, and save the file.
direnv allow
allow direnv to catch the exported constant and enable it with the direnv allow command.
NOTE: You should see something like this if the env variables have been correctly exported and ready to use. If you don’t see this prompt in the terminal please enable/install direnv using the instructions on install dependencies page of this guide.
Make sure that you replace $PROOF_CHAIN_CONTRACT_ADDR with the new copied “proof-chain” contract address in the command below for the --proof-chain-address
flag and create a bin directory at ~/bsp-agent
to store the block-specimens binary files with
NOTE: Moonbeam Proof-Chain Address: 0x7487b04899c2572A223A8c6eC9bA919e27BBCd36
Assuming the ipfs-pinner is running (last section) at the default http://127.0.0.1:3001/
, we can now start the bsp-agent
:
Each of the agent’s flags and their functions are described below (some may have been taken out for simplifying this workshop)
--redis-url
- this flag tells the agent where to find the bsp messages, at which stream topic key (replication) and what the consumer group is named with the field after # which in this case is replicate, additionally one can provide a password to the redis instance here but we recommend by adding the line below to the .envrc
export REDIS_PWD=your-redis-pwd
--codec-path
- tells the bsp agent the relative path to the AVRO .avsc files in the repo, since the agent ships with the corresponding avsc files this remains fixed for the time being
--binary-file-path
- tells the bsp if local copies of the block-replica objects being created are to be stored in a given local directory. Please make sure the path (& directory) pre-exists before passing this flag.
--block-divisor
- allows the operator to configure the number of block specimens being created, the block number divisible only by this number will be extracted, packed, encoded, uploaded and proofed.
--proof-chain-address
- specifies the address of the proof-chain contract that has been deployed to the Moonbeam network.
--consumer-timeout
- specifies when the agent stops accepting new msgs from the pending queue for encode, proof and upload.
--log-folder
- specifies the location (folder) where the log files have to be placed. In case of error (like permission errors), the logs are not recorded in files.
--ipfs-pinner-server
- specifies the http url where ipfs-pinner server is listening. By default, it is http://127.0.0.1:3001
bsp-agent
command above fails with a message about permission issues to access ~/.ipfs/*
, run sudo chmod -R 700 ~/.ipfs
and try again.If all the cli-flags are administered correctly (either in the makefile or the go run command) you should be able to see something like this from logs
If you see the above log, you’re successfully running the entire block specimen producer workflow. The BSP-agent is reading messages from the redis streams topic, encoding, compressing, proving and uploading it to the gcp bucket in segments of multiple blocks at a time.
If however, that doesn’t happen and the agent fails and isn’t able to complete the workflow, fear not! It will automatically fail and the messages will be persisted in the stream where they were being read from! So when you restart correctly the same messages will be reprocessed till full success.
Sample Systemd Service Units
If the block specimen stack is running successfully and producing block specimens, Congrats! As a way to manage the services, you might want to use systemd.
We next provide sample systemd service files, so that any crash in one of the components would restart that component, rather than the system halting. Don’t forget to replace the placeholders with actual values in these sample files.
BSP-Geth - Service Unit File
Lighthouse - Service Unit File
IPFS-Pinner - Service Unit File
BSP-Agent - Service Unit File
Support
If you need any assistance with the onboarding process or have technical and operational concerns please contact Rodrigo or Krish in the Covalent Network Discord.