Before starting, ensure that you have the following tools installed on your development machine:
- Install
babylondcli tool. Please refer to babylond - Use the
babylond keys add <keyName>command to Generate some accounts. Some accounts display in the below example.- Account
callerto run the task. - Account
operatorto run the offchain node - Account
aggregatorto run the aggregator node - Account
uploaderto run the reward coordinator node - Account
monitorto run the monitor node
- Account
Note: babylond keyring backend types:
- os: Use the operating system's secure storage (e.g. keychain for macOS, libsecret for Linux). This is the default.
- file: Use the file system to store keys
- test: Use memory to store keys, mainly for testing purposes
when use the key, need to set the
keyringBackend.
- Activate the above accounts, so transfer some native token to these accounts.
- Golang
- Redis (required for running the aggregator)
- Download the satlayer cli from satlayer-cli repo. And run the readme to build and install.
- Some official contract address can be found in the official contract readme doc.
- Read the bvs-squaring contract readme doc.
- Deploy the bvs-squaring contract on Babylon testnet.
- Get the deployed contract address as bvsAddress.
# everyone can register bvs, so everyone account can register bvs
satlayer directory reg-bvs <userKeyName> <bvsAddress>After run the above command, will output the bvsHash string. The BVSHash will be used in the following hello-world-bvs Run section.
# register operator to delegate manager
# the approverAddress is the witness of the operator
# the operatorAddress not be the operator account、the staker account
# If operator does not want a approver, you can set the approverAddress as 0
satlayer delegation reg-operator <operatorKeyName> <approverAddress>
# register operator to directory manager
satlayer directory reg-operator <operatorKeyName>Tips: If you don't want to run reward, you can skip these steps.
This step commands only strategy manager can do.
# set the delegation manager
satlayer strategy set-delegation-manager <userKeyName> <delegationManagerAddress>
# set the strategy whitelist
satlayer strategy set-strategy-whitelist <userKeyName> <strategyWhitelistAddress>This step commands need staker account.
# delegate staker to operator
# This approver key is the one used when the operator was registered
# If the operator approver address is 0, you can skip the approverKeyName
satlayer delegation delegate-to <stakerKeyName> <operatorAddress> [approverKeyName]
# increase token allowance to delegation manager
satlayer chain increase-token-allowance <stakerKeyName> <cw20TokenAddress> <delegationManagerAddress> <amount>
# deposit into strategy
satlayer strategy deposit-strategy <stakerKeyName> <strategyAddress> <cw20TokenAddress> <amount>this step commands need uploader account.
- First, the reward coordinator contract owner need set the uploader address to be submitter address.
- Second, keep the uploader account have enough cw20 token balance to upload reward.
- Third, uploader need call
IncreaseTokenAllowanceto approve the reward Coordinator contract transfer Cw20 token.
# increase token allowance to reward coordinator
satlayer chain increase-token-allowance <uploaderKeyName> <cw20TokenAddress> <rewardCoordinatorAddress> <amount>The BVS program follows a structured flow where tasks are initiated, processed off-chain, aggregated, and finally rewarded. The following steps outline the complete process for running the demo.
To set up and run the demo, follow these steps:
- Ensure you have a running Redis server.
-
The TaskMonitor continuously tracks and updates the status of ongoing BVS tasks:
-
Modify the
env.tomlfile located in thetaskdirectory under the[owner]section to match your local machine and bvsHash. -
just run
cd task
go run main.go monitor- build run
cd task
go build -o task-cli .
./task-cli monitor-
The Aggregator collects and pushes the processed results, ensuring they are available for further use.
-
Modify the
env.tomlfile located in theaggregatordirectory if you want to use a different database, host port or account.[app]section to set the aggregator host and port.[database]section to match your Redis server configuration.[owner]section to match your account in local machine.
-
just run
cd aggregator
go run main.go- build run
cd aggregator
go build -o aggregator-cli .
./aggregator-cliIf you want to run more than one aggregator, please modify the env.toml file, and then, in new terminal run the above commands.
-
The Offchain Node performs the core BVS computations off-chain, ensuring results are processed securely and efficiently:
-
Modify the
env.tomlfile located in thebvs_offchaindirectory under the[owner]section to match your local machine and[aggregator]section to match your aggregator node. -
just run
cd bvs_offchain
go run main.go- build run
cd bvs_offchain
go build -o offchain-cli .
./offchain-cli-
The Reward Uploader calculates and uploads the rewards based on the validated tasks。This step is optional.
-
Modify the
env.tomlfile located in thebvs_offchaindirectory under the[owner]section to match your local machine -
just run
cd reward_uploader
go run main.go- build run
cd reward_uploader
go build -o uploader-cli .
./uploader-cliThe TaskCaller sends new BVS tasks to the system and begins the monitoring process:
- just run
cd task
go run main.go caller- build run
cd task
go build -o task-cli .
./task-cli caller