Given the limitation of smart contracts, they are not self-executing, and require an external force to trigger their functions. Relay is a service to drive LSD to properly process its own internal states, such as dealing with delegating, undelegating, distributing rewards and calculating the rate between LST and the original coin. We introduce era
concept to define how often the smart contract should be called. Most of the time, an era is 24 hours long.
Security is the our first priority when developing Stack, We are thrilled to say that the new era process is permissionless, showcasing the decentralized nature of the Cosmos LSD Stack, allowing anyone to trigger the beginning of a new era. Each step in the process includes sufficient condition checks to prevent the contract from re-processing transactions or prematurely moving to subsequent steps. The new era process will be triggered when a pool meets the conditions for starting a new era (i.e., reaching the time to start the next era).
The relay solution for chains only support ICS-27 protocol differs from those support Native CosmWasm, therefore we provide two proper relay types.
Neutron(ICS-27) LSD Relay
Relay methods
era_update
Transfer the tokens at an era on the neutron chain to the account on the original chain through ICA and interchain transactions.
era_stake
Handles staking, unstaking, and withdrawal transactions on the original chain.
era_withdraw_collect
Collects rewards from the previous era into the pool ICA account in preparation for restake.
era_restake
Restake rewards generated in the previous era.
era_active
Handles the data changes caused by new stakes or unstakes in the new era process, calculates the new era’s rate, and initiates the new era.
redeem_token_for_share
The delegations are not transfered to pool ica account immediately when user stake LSM. We call this mehtod to redeem the delegations.
Install Build Tools
Install make
, gcc
and git
sudo apt update
sudo apt install -y make gcc git build-essential
Install go
by following the official docs. Remember to set your $PATH
environment variable, for example:
cd $HOME
wget -O go1.22.0.linux-amd64.tar.gz https://go.dev/dl/go1.22.0.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.0.linux-amd64.tar.gz && rm go1.22.0.linux-amd64.tar.gz
echo 'export GOROOT=/usr/local/go' >> $HOME/.bashrc
echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
echo 'export GO111MODULE=on' >> $HOME/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bashrc && . $HOME/.bashrc
go version
Install relay service
$ git clone https://github.com/stafiprotocol/neutron-lsd-relay.git
$ cd neutron-lsd-relay
$ make install
Create relay working directory and config file
$ mkdir -p ~/cosmos-neutron-stack
$ cp config.template.toml ~/cosmos-neutron-stack/config.toml
Config neutron relay service
Update config (config.toml) by your favorite editor according to Relay Config
endpointList = ["http://127.0.0.1:26657"]
gasPrice = "0.005untrn"
taskTicker = 60 # seconds
poolAddr = "cosmos1hvuhdvwnsuj487xdcsv4yntn3hlxsmlmp602z4jkq95c20fsp3cshuzjhg"
stakeManager = "neutron1rjr282qjnaeamsps4aspw8gmz4nynjpq6zurxfnppdcknpwdnxgs8rqm8y"
runForEntrustedPool = false
keyringDir = "/home/<your_user_name>/cosmos-neutron-stack/keyring"
keyringBackend = "file"
keyName = "demowallet1"
Add or Import account
You can simply create a new account to submit transactions on neutron
$ neutron-lsd-relay keys add stafi-relay-1 \
--keyring-backend=file --keyring-dir=~/cosmos-neutron-stack/keyring
Enter keyring passphrase (attempt 1/3):
- address: neutron1c4ceejzxucas3sp5nvum4f8kr7pdun6wdw3y06
name: stafi-relay-1
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Au3RxMxljL7CagnKcN/4j63KPRJjuCYhseeimwLVK9/3"}'
type: local
**Important** write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.
youth stairs bronze tree melt coast grass table help lock road gospel quote explain usage retreat present now tragic course balance easy curtain this
Or you can import an exist account, let’s say you have just exported from neutrond
via neutrond keys --home=$HOME_1 --keyring-backend=test export demowallet1 > demowallet1.privatekey
, you can import it to relay:
$ neutron-lsd-relay keys import demowallet1 demowallet1.privatekey \
--keyring-backend=file --keyring-dir=~/cosmos-neutron-stack/keyring
Enter passphrase to decrypt your key:
Enter keyring passphrase (attempt 1/3):
Re-enter keyring passphrase:
$ neutron-lsd-relay keys list \
--keyring-backend=file --keyring-dir=~/cosmos-neutron-stack/keyring
Enter keyring passphrase (attempt 1/3):
- address: neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2
name: demowallet1
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/MdHVpitzHNSdD1Zw3kY+L5PEIPyd9l6sD5i4aIfXp9"}'
type: local
⚠️Please make sure the account have enough NEUTRON funds, since relay will send transaction to StakeManager contract.
Start relay services
$ neutron-lsd-relay start --base-path=~/cosmos-neutron-stack
config path: /home/ubuntu/cosmos-neutron-stack/config.toml
load config success
log level: info
all logs are output in the /home/ubuntu/cosmos-neutron-stack/log_data directory
INFO[2024-02-23T12:02:30+08:00] cfg: &{EndpointList:[http://127.0.0.1:26657] TaskTicker:60 PoolAddr:cosmos1hvuhdvwnsuj487xdcsv4yntn3hlxsmlmp602z4jkq95c20fsp3cshuzjhg StakeManager:neutron1rjr282qjnaeamsps4aspw8gmz4nynjpq6zurxfnppdcknpwdnxgs8rqm8y GasPrice:0.005untrn LogFilePath:/home/ubuntu/cosmos-neutron-stack/log_data KeyringDir:/home/ubuntu/cosmos-neutron-stack/keyring KeyringBackend:file KeyName:demowallet1 RunForEntrustedPool:false}
INFO[2024-02-23T12:02:30+08:00] task starting...
Enter keyring passphrase (attempt 1/3):
INFO[2024-02-23T12:02:36+08:00] start handlers
INFO[2024-02-23T12:02:36+08:00] success action=NewEraUpdate newEra=84 pool=cosmos1hvuhdvwnsuj487xdcsv4yntn3hlxsmlmp602z4jkq95c20fsp3cshuzjhg targetEra=4647 txHash=010C675FFB313F7FD8B986D1A49688D510C61E9F3D804F4D2D5FF94AFCD13447
Config
config | description | example value | recommended value |
---|---|---|---|
endpointList | endpoint list | [“http://127.0.0.1:26657”] | |
gasPrice | gas price | 0.005untrn | |
taskTicker | sleep duration in seconds | 60 | |
poolAddr | generally required, but omitted if runForEntrustedPool is true | cosmos1hvuhdvw…huzjhg | |
stakeManagerAddr | neutron1rjr282…8rqm8y | ||
keyringDir | keyring dir | ./keys | |
keyringBackend | keyring backend | file | |
keyName | key name | ||
runForEntrustedPool | set this config to true only if you are one of the entrusted voters who are responsible to relay data for entrusted LSD pools | false | false |
Native CosmWasm LSD Relay
Coming Soon, Stay tuned