Skip to content

Commit

Permalink
Using async icq for osmosis price feeder to reduce the need for price…
Browse files Browse the repository at this point in the history
… provider
  • Loading branch information
trinitys7 committed Sep 29, 2024
1 parent 29d7a7e commit 8011763
Show file tree
Hide file tree
Showing 27 changed files with 372 additions and 28 deletions.
2 changes: 1 addition & 1 deletion scripts/mesh/testibc/config_band.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
global:
api-listen-addr: :5183
api-listen-addr: :5184
timeout: 10s
memo: ""
light-cache-size: 20
Expand Down
57 changes: 57 additions & 0 deletions scripts/mesh/testibc/config_osmosis_local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
global:
api-listen-addr: :5184
timeout: 10s
memo: ""
light-cache-size: 20
chains:
consumer:
type: cosmos
value:
key-directory: scripts/relayer/keys/chain-1
key: key1
chain-id: chain-1
rpc-addr: http://localhost:26657
account-prefix: mesh
keyring-backend: test
gas-adjustment: 1.2
gas-prices: 0.01stake
min-gas-amount: 1000000
max-gas-amount: 0
debug: false
timeout: 20s
block-timeout: ""
output-format: json
sign-mode: direct
extra-codecs: []
coin-type: 118
signing-algorithm: ""
broadcast-mode: batch
min-loop-duration: 0s
extension-options: []
feegrants: null
osmo:
type: cosmos
value:
key-directory: scripts/relayer/keys/osmo
key: testnet
chain-id: osmo
rpc-addr: http://localhost:26677
account-prefix: osmo
keyring-backend: test
gas-adjustment: 1.2
gas-prices: 0.005uosmo
min-gas-amount: 200000
max-gas-amount: 0
debug: false
timeout: 20s
block-timeout: ""
output-format: json
sign-mode: direct
extra-codecs: []
coin-type: 118
signing-algorithm: ""
broadcast-mode: batch
min-loop-duration: 0s
extension-options: []
feegrants: null
paths: {}
57 changes: 57 additions & 0 deletions scripts/mesh/testibc/config_osmosis_testnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
global:
api-listen-addr: :5184
timeout: 10s
memo: ""
light-cache-size: 20
chains:
consumer:
type: cosmos
value:
key-directory: scripts/relayer/keys/chain-1
key: key1
chain-id: chain-1
rpc-addr: http://localhost:26657
account-prefix: mesh
keyring-backend: test
gas-adjustment: 1.2
gas-prices: 0.01stake
min-gas-amount: 1000000
max-gas-amount: 0
debug: false
timeout: 20s
block-timeout: ""
output-format: json
sign-mode: direct
extra-codecs: []
coin-type: 118
signing-algorithm: ""
broadcast-mode: batch
min-loop-duration: 0s
extension-options: []
feegrants: null
osmo:
type: cosmos
value:
key-directory: scripts/relayer/keys/osmo-test-5
key: testnet
chain-id: osmo-test-5
rpc-addr: https://rpc.testnet.osmosis.zone:443
account-prefix: osmo
keyring-backend: test
gas-adjustment: 1.2
gas-prices: 0.005uosmo
min-gas-amount: 200000
max-gas-amount: 0
debug: false
timeout: 20s
block-timeout: ""
output-format: json
sign-mode: direct
extra-codecs: []
coin-type: 118
signing-algorithm: ""
broadcast-mode: batch
min-loop-duration: 0s
extension-options: []
feegrants: null
paths: {}
84 changes: 84 additions & 0 deletions scripts/mesh/testibc/osmosis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
set -xeu

killall osmosisd || true
sleep 3
rm -rf $HOME/.osmosisd
home=$HOME/.osmosisd
chainid=osmo

osmosisd init localnet --chain-id $chainid --home $home

# Create accounts
osmosisd keys add val1 --keyring-backend test --home $home
osmosisd keys add test1 --keyring-backend test --home $home

cat $home/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="uosmo"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

val1=$(osmosisd keys show val1 --keyring-backend test --home=$home -a)
test1=$(osmosisd keys show test1 --keyring-backend test --home=$home -a)
osmosisd add-genesis-account $val1 1000000000000uosmo,10000000000000000000stake --keyring-backend test --home=$home
osmosisd add-genesis-account $test1 1000000000uosmo --keyring-backend test --home=$home

cat $home/config/genesis.json | jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="uosmo"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["gov"]["params"]["voting_period"]="40s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["gov"]["params"]["expedited_voting_period"]="30s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["interchainquery"]["params"]["allow_queries"]=["/osmosis.twap.v1beta1.Query/ArithmeticTwapToNow"]' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

# update staking genesis
cat $home/config/genesis.json | jq '.app_state["staking"]["params"]["unbonding_time"]="240s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

# update crisis variable to uosmo
cat $home/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="uosmo"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json


# update epochs genesis
cat $home/config/genesis.json | jq '.app_state["epochs"]["epochs"][1]["duration"]="60s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

# update poolincentives genesis
cat $home/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][0]="120s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][1]="180s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][2]="240s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["poolincentives"]["params"]["minted_denom"]="uosmo"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

# update incentives genesis
cat $home/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][0]="1s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][1]="120s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][2]="180s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][3]="240s"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["incentives"]["params"]["distr_epoch_identifier"]="day"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

# update mint genesis
cat $home/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uosmo"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json
cat $home/config/genesis.json | jq '.app_state["mint"]["params"]["epoch_identifier"]="day"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

# update gamm genesis
cat $home/config/genesis.json | jq '.app_state["gamm"]["params"]["pool_creation_fee"][0]["denom"]="uosmo"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

# update cl genesis
cat $home/config/genesis.json | jq '.app_state["concentratedliquidity"]["params"]["is_permissionless_pool_creation_enabled"]=true' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

cat $home/config/genesis.json | jq '.app_state["txfees"]["basedenom"] = "uosmo"' > $home/config/tmp_genesis.json && mv $home/config/tmp_genesis.json $home/config/genesis.json

osmosisd gentx val1 500000000000uosmo --keyring-backend test --chain-id $chainid --home=$home

osmosisd collect-gentxs --home=$home

VALIDATOR_APP_TOML=$home/config/app.toml

sed -i -E 's|tcp://localhost:1317|tcp://localhost:1337|g' $VALIDATOR_APP_TOML
sed -i -E 's|localhost:9090|localhost:9290|g' $VALIDATOR_APP_TOML
sed -i -E 's|localhost:9091|localhost:9291|g' $VALIDATOR_APP_TOML
sed -i -E 's|tcp://0.0.0.0:10337|tcp://0.0.0.0:12337|g' $VALIDATOR_APP_TOML

VALIDATOR_CONFIG=$home/config/config.toml
sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26678|g' $VALIDATOR_CONFIG
sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26677|g' $VALIDATOR_CONFIG
sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26676|g' $VALIDATOR_CONFIG
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR_CONFIG

screen -S osmosis -t osmosis -d -m osmosisd start --home=$home

sleep 10
osmosisd tx gamm create-pool --pool-file ./scripts/mesh/testibc/pool.json --from val1 --keyring-backend test --node http://localhost:26677 --chain-id osmo --fees 10000uosmo -y --gas auto --gas-adjustment 1.5
sleep 7
osmosisd q gamm num-pools --node http://localhost:26677
7 changes: 7 additions & 0 deletions scripts/mesh/testibc/pool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"weights": "10uosmo,2stake",
"initial-deposit": "1000000uosmo,200000stake",
"swap-fee": "0.01",
"exit-fee": "0",
"future-governor": ""
}
2 changes: 1 addition & 1 deletion scripts/mesh/testibc/rly_band.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ rly tx channel demo-band --src-port wasm.$price_feed --dst-port oracle --order u

sleep 5

screen -S relayer -t relayer -d -m rly start demo-band --home ./scripts/relayer --debug-addr localhost:5184
screen -S relayer -t relayer -d -m rly start demo-band --home ./scripts/relayer
sleep 5
64 changes: 64 additions & 0 deletions scripts/mesh/testibc/rly_osmosis_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
rly config init --home ./scripts/relayer

cp ./scripts/mesh/testibc/config_osmosis_local.yaml ./scripts/relayer/config/config.yaml

rly keys add consumer key1 --home ./scripts/relayer

rly_wallet_1=$(rly keys show consumer key1 --home ./scripts/relayer)

rly keys add osmo testnet --home ./scripts/relayer
rly_wallet_2=$(rly keys show osmo testnet --home ./scripts/relayer)

meshconsumerd tx bank send test1 --keyring-backend test $rly_wallet_1 10000000stake --node http://localhost:26657 --fees 200000stake -y --home $HOME/.meshd/chain1/node1 --chain-id chain-1
osmosisd tx bank send test1 --keyring-backend test $rly_wallet_2 10000000uosmo --node http://localhost:26677 --fees 100000uosmo -y --home $HOME/.osmosisd --chain-id osmo

sleep 7

rly paths new chain-1 osmo demo-osmo --home ./scripts/relayer

sleep 5

rly tx clients demo-osmo --home ./scripts/relayer

sleep 10

rly tx connection demo-osmo --home ./scripts/relayer

sleep 10

home1=$HOME/.meshd/chain1/node1/
chainid1=chain-1
node1=tcp://127.0.0.1:26657
test1=$(meshconsumerd keys show test1 --keyring-backend test -a --home=$home1)
val1=$(meshconsumerd keys show val1 --keyring-backend test -a --home=$home1)
meshconsumerd tx wasm store ./tests/testdata/mesh_osmosis_price_feed.wasm.gz --node $node1 --from $val1 --home=$home1 --chain-id $chainid1 --keyring-backend test --fees 1stake -y --gas 10059023
sleep 7

connection_id=$(yq -r '.paths.demo-osmo.dst.connection-id' ./scripts/relayer/config/config.yaml)
echo "connection_id: $connection_id"
init_osmosis_price_feed=$(cat <<EOF
{
"trading_pair": {
"pool_id": 1,
"base_asset": "stake",
"quote_asset": "uosmo"
},
"epoch_in_secs": 30,
"price_info_ttl_in_secs": 60
}
EOF
)
meshconsumerd tx wasm instantiate 1 "$init_osmosis_price_feed" --node $node1 --label contract-pricefeed --admin $val1 --from $val1 --home=$home1 --chain-id $chainid1 --keyring-backend test --fees 1stake -y --gas 3059023
sleep 7

price_feed=$(meshconsumerd q wasm list-contract-by-code 1 --node $node1 --output json | jq -r '.contracts[-1]' )
echo "price feed contract: $price_feed"


rly tx channel demo-osmo --src-port wasm.$price_feed --dst-port icqhost --order unordered --version icq-1 --home ./scripts/relayer

sleep 5

screen -S relayer-osmo -t relayer-osmo -d -m rly start demo-osmo --home ./scripts/relayer
sleep 5
71 changes: 71 additions & 0 deletions scripts/mesh/testibc/rly_osmosis_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
rly config init --home ./scripts/relayer

cp ./scripts/mesh/testibc/config_osmosis_testnet.yaml ./scripts/relayer/config/config.yaml

rly keys add consumer key1 --home ./scripts/relayer

rly_wallet_1=$(rly keys show consumer key1 --home ./scripts/relayer)

rly keys add osmo testnet --home ./scripts/relayer
rly_wallet_2=$(rly keys show osmo testnet --home ./scripts/relayer)

meshconsumerd tx bank send test1 --keyring-backend test $rly_wallet_1 10000000stake --node http://localhost:26657 --fees 200000stake -y --home $HOME/.meshd/chain1/node1 --chain-id chain-1

osmo_balance=$(osmosisd q bank balances $rly_wallet_2 -o json --node https://rpc.testnet.osmosis.zone | jq -r '.balances[0].amount')

if [ "$(echo "$osmo_balance < 40000000" | bc)" -eq 1 ]; then
echo "please request osmo token for ${rly_wallet_2} in https://faucet.testnet.osmosis.zone/"
echo "waiting to fund accounts. Press to continue..."
read -r answer
fi

sleep 3

rly paths new chain-1 osmo-test-5 demo-osmo --home ./scripts/relayer

sleep 5

rly tx clients demo-osmo --home ./scripts/relayer --override

sleep 10

rly tx connection demo-osmo --home ./scripts/relayer

sleep 10

home1=$HOME/.meshd/chain1/node1/
chainid1=chain-1
node1=tcp://127.0.0.1:26657
test1=$(meshconsumerd keys show test1 --keyring-backend test -a --home=$home1)
val1=$(meshconsumerd keys show val1 --keyring-backend test -a --home=$home1)
meshconsumerd tx wasm store ./tests/testdata/mesh_osmosis_price_feed.wasm.gz --node $node1 --from $val1 --home=$home1 --chain-id $chainid1 --keyring-backend test --fees 1stake -y --gas 10059023
sleep 7

connection_id=$(yq -r '.paths.demo-osmo.dst.connection-id' ./scripts/relayer/config/config.yaml)
echo "connection_id: $connection_id"
init_osmosis_price_feed=$(cat <<EOF
{
"trading_pair": {
"pool_id": 3,
"base_asset": "ibc/8E2FEFCBD754FA3C97411F0126B9EC76191BAA1B3959CB73CECF396A4037BBF0",
"quote_asset": "uosmo"
},
"epoch_in_secs": 30,
"price_info_ttl_in_secs": 60
}
EOF
)
meshconsumerd tx wasm instantiate 1 "$init_osmosis_price_feed" --node $node1 --label contract-pricefeed --admin $val1 --from $val1 --home=$home1 --chain-id $chainid1 --keyring-backend test --fees 1stake -y --gas 3059023
sleep 7

price_feed=$(meshconsumerd q wasm list-contract-by-code 1 --node $node1 --output json | jq -r '.contracts[-1]' )
echo "price feed contract: $price_feed"


rly tx channel demo-osmo --src-port wasm.$price_feed --dst-port icqhost --order unordered --version icq-1 --home ./scripts/relayer --override

sleep 5

screen -S relayer-osmo -t relayer-osmo -d -m rly start demo-osmo --home ./scripts/relayer
sleep 5
Loading

0 comments on commit 8011763

Please sign in to comment.