Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: osmosis price feed icq #194

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
- [ValidatorAddress](#osmosis.meshsecurity.v1beta1.ValidatorAddress)

- [osmosis/meshsecurity/v1beta1/tx.proto](#osmosis/meshsecurity/v1beta1/tx.proto)
- [MsgSetPriceFeedContract](#osmosis.meshsecurity.v1beta1.MsgSetPriceFeedContract)
- [MsgSetPriceFeedContractResponse](#osmosis.meshsecurity.v1beta1.MsgSetPriceFeedContractResponse)
- [MsgSetVirtualStakingMaxCap](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCap)
- [MsgSetVirtualStakingMaxCapResponse](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCapResponse)

Expand Down Expand Up @@ -287,6 +289,33 @@ ValidatorAddress payload data to be used with the scheduler



<a name="osmosis.meshsecurity.v1beta1.MsgSetPriceFeedContract"></a>

### MsgSetPriceFeedContract
MsgSetPriceFeedContract sets the price feed contract to the chain
to trigger handle epoch task


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `authority` | [string](#string) | | Authority is the address that controls the module (defaults to x/gov unless overwritten). |
| `contract` | [string](#string) | | Contract is the address of the price feed smart contract. |






<a name="osmosis.meshsecurity.v1beta1.MsgSetPriceFeedContractResponse"></a>

### MsgSetPriceFeedContractResponse
MsgSetPriceFeedContractResponse returns result data.






<a name="osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCap"></a>

### MsgSetVirtualStakingMaxCap
Expand Down Expand Up @@ -329,6 +358,7 @@ Msg defines the wasm Msg service.
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `SetVirtualStakingMaxCap` | [MsgSetVirtualStakingMaxCap](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCap) | [MsgSetVirtualStakingMaxCapResponse](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCapResponse) | SetVirtualStakingMaxCap creates or updates a maximum cap limit for virtual staking coins | |
| `SetPriceFeedContract` | [MsgSetPriceFeedContract](#osmosis.meshsecurity.v1beta1.MsgSetPriceFeedContract) | [MsgSetPriceFeedContractResponse](#osmosis.meshsecurity.v1beta1.MsgSetPriceFeedContractResponse) | SetPriceFeedContract sets the price feed contract to the chain to trigger handle epoch task | |

<!-- end services -->

Expand Down
21 changes: 21 additions & 0 deletions proto/osmosis/meshsecurity/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ service Msg {
// staking coins
rpc SetVirtualStakingMaxCap(MsgSetVirtualStakingMaxCap)
returns (MsgSetVirtualStakingMaxCapResponse);
// SetPriceFeedContract sets the price feed contract to the chain
// to trigger handle epoch task
rpc SetPriceFeedContract(MsgSetPriceFeedContract)
returns (MsgSetPriceFeedContractResponse);
}

// MsgSetVirtualStakingMaxCap creates or updates a maximum cap limit for virtual
Expand All @@ -37,3 +41,20 @@ message MsgSetVirtualStakingMaxCap {

// MsgSetVirtualStakingMaxCap returns result data.
message MsgSetVirtualStakingMaxCapResponse {}

// MsgSetPriceFeedContract sets the price feed contract to the chain
// to trigger handle epoch task
message MsgSetPriceFeedContract {
option (amino.name) = "meshsecurity/MsgSetPriceFeedContract";
option (cosmos.msg.v1.signer) = "authority";

// Authority is the address that controls the module (defaults to x/gov unless
// overwritten).
string authority = 1;

// Contract is the address of the price feed smart contract.
string contract = 2;
}

// MsgSetPriceFeedContractResponse returns result data.
message MsgSetPriceFeedContractResponse {}
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": ""
}
3 changes: 1 addition & 2 deletions scripts/mesh/testibc/rly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ rly tx channel demo --src-port wasm.$converter --dst-port wasm.$ext_staking --or

sleep 5

echo "abcxyz"
# screen -S relayer -t relayer -d -m rly start demo
screen -S relayer -t relayer -d -m rly start demo
sleep 5
5 changes: 3 additions & 2 deletions scripts/mesh/testibc/rly_band.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ init_band_price_feed=$(cat <<EOF
"prepare_gas": "40000",
"execute_gas": "300000",
"minimum_sources": 2,
"epoch_in_secs": 30,
"price_info_ttl_in_secs": 60
}
EOF
Expand All @@ -66,7 +67,7 @@ echo "price feed contract: $price_feed"

rly tx channel demo-band --src-port wasm.$price_feed --dst-port oracle --order unordered --version bandchain-1 --home ./scripts/relayer --override

sleep 5
sleep 7

screen -S relayer -t relayer -d -m rly start demo-band --home ./scripts/relayer --debug-addr localhost:5184
screen -S relayer-band -t relayer-band -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
Loading
Loading