Skip to content

Commit

Permalink
Add check if msg is bypass (#76)
Browse files Browse the repository at this point in the history
* add bypass

* add more check fee

* lint

* nit

* nit

* add check subset denom

* nit

* ante

* ictest

* lint

* update docs

* nit

* nit

* nit

* nit

* nit

* nit

---------

Co-authored-by: vuong <[email protected]>
  • Loading branch information
GNaD13 and vuong177 authored Sep 22, 2023
1 parent 8275992 commit 3ef7b78
Show file tree
Hide file tree
Showing 19 changed files with 324 additions and 237 deletions.
2 changes: 1 addition & 1 deletion sample_pool.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"weights": "1ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E,1ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878",
"initial-deposit": "500000000000ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E,1000000000000ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878",
"initial-deposit": "500000000000ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E,100000000000ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878",
"swap-fee": "0.01",
"exit-fee": "0",
"future-governor": "168h"
Expand Down
106 changes: 77 additions & 29 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,106 @@

## Setup

```
# Deploy chains
Run Feeabs node
```
./scripts/node_start/runnode_custom.sh c
./scripts/node_start/runnode_osmosis.sh
```
Run Osmosis node
```
./scripts/node_start/runnode_osmosis.sh c
```
Run Gaia node
```
./scripts/node_start/runnode_gaia.sh c
```
# Run relayer
./scripts/run_relayer.sh
# Create an osmosis pool
./scripts/create_pool.sh
# Deploy contract and create relayer channel
./scripts/deploy_and_channel.sh
Run Feeabs - Osmosis relayer
```
./scripts/run_relayer_feeabs_osmo.sh
```
Run Feeabs - Gaia relayer
```
./scripts/run_relayer_feeabs_gaia.sh
```
Run Osmosis - Gaia relayer
```
./scripts/run_relayer_osmo_gaia.sh
```
# Setup IBC channel
Run the following command to setup IBC channel
```
hermes --config scripts/relayer_hermes/config_feeabs_osmosis.toml create channel --a-chain testing --b-chain feeappd-t1 --a-port transfer --b-port transfer --new-client-connection --yes
hermes --config scripts/relayer_hermes/config_feeabs_osmosis.toml create channel --a-chain testing --b-chain feeappd-t1 --a-port icqhost --b-port feeabs --new-client-connection --yes
hermes --config scripts/relayer_hermes/config_feeabs_gaia.toml create channel --a-chain gaiad-t1 --b-chain feeappd-t1 --a-port transfer --b-port transfer --new-client-connection --yes
hermes --config scripts/relayer_hermes/config_osmosis_gaia.toml create channel --a-chain gaiad-t1 --b-chain testing --a-port transfer --b-port transfer --new-client-connection --yes
```

## Test
After running, the channel map should like this
```
feeabs - osmo: channel-0 channel-0
feeabs - osmo: (feeabs - icqhost) channel-1 channel-1
feeabs - gaia: channel-2 channel-0
osmo - gaia: channel-2 channel-1
```

# Create an osmosis pool
Get Osmosis testing address
```
feeappd tx feeabs queryomosis --from feeacc --keyring-backend test --chain-id feeappd-t1 --yes
# Wait for about 10 sec
feeappd q feeabs osmo-spot-price
export VALIDATOR=$(osmosisd keys show validator1 -a --keyring-backend test)
export OWNER=$(osmosisd keys show deployer -a --keyring-backend test)
```

The result looks like this
Transfer token from Feeabs and Gaia to Osmosis
```
feeappd tx ibc-transfer transfer transfer channel-0 "$VALIDATOR" 1000000000000stake --from feeacc --keyring-backend test --chain-id feeappd-t1 --yes --fees 5000stake
gaiad tx ibc-transfer transfer transfer channel-1 "$VALIDATOR" 1000000000000uatom --from gnad --keyring-backend test --chain-id gaiad-t1 --yes --fees 5000stake
```

Create pool
```
base_asset: osmo
quote_asset: stake
spot_price: "2.000000000000000000"
cat > sample_pool.json <<EOF
{
"weights": "1ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E,1ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878",
"initial-deposit": "500000000000ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E,100000000000ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878",
"swap-fee": "0.01",
"exit-fee": "0",
"future-governor": "168h"
}
EOF
osmosisd tx gamm create-pool --pool-file sample_pool.json --from validator1 --keyring-backend=test --home=$HOME/.osmosisd --chain-id testing --yes --fees 5000stake --gas 400000
```

# Deploy Osmosis contract
```./scripts/ibc_swap/deploy_osmosis_contract.sh```


## Gov proposal

```
feeappd tx gov submit-legacy-proposal param-change scripts/proposal.json --from myaccount --keyring-backend test --chain-id feeappd-t1 --yes --gas 400000
feeappd tx gov submit-legacy-proposal param-change scripts/proposal.json --from feeacc --keyring-backend test --chain-id feeappd-t1 --yes --fees 5000stake --gas 400000
feeappd tx gov vote 1 yes --from test --keyring-backend test --chain-id feeappd-t1 --yes
feeappd tx gov vote 1 yes --from feeapp1 --keyring-backend test --chain-id feeappd-t1 --yes --fees 5000stake
feeappd tx gov submit-legacy-proposal add-hostzone-config scripts/host_zone_gaia.json --from myaccount --keyring-backend test --chain-id feeappd-t1 --yes
feeappd tx gov submit-legacy-proposal add-hostzone-config scripts/host_zone_gaia.json --from feeacc --keyring-backend test --chain-id feeappd-t1 --yes --fees 5000stake --gas 400000
feeappd tx gov vote 2 yes --from test --keyring-backend test --chain-id feeappd-t1 --yes
feeappd tx gov vote 2 yes --from feeapp1 --keyring-backend test --chain-id feeappd-t1 --yes --fees 5000stake
```

## Fund module account
Fund token to feeabs module account for pay fee. Normally, we would use gov to fund feeabs from community pool
```
feeappd tx gov submit-proposal param-change scripts/proposal_query.json --from myaccount --keyring-backend test --chain-id feeappd-t1 --yes
feeappd tx gov vote 1 yes --from feeapp1 --keyring-backend test --chain-id feeappd-t1 --yes
feeappd tx gov submit-proposal add-hostzone-config scripts/host_zone_query.json --from myaccount --keyring-backend test --chain-id feeappd-t1 --yes
feeappd tx gov vote 2 yes --from feeapp1 --keyring-backend test --chain-id feeappd-t1 --yes
feeappd tx bank send feeacc feeabs1hq6049htg8dh9swl5cw6uqqqcasxttdv4ynj83 5000000stake --keyring-backend test --chain-id feeappd-t1 --yes --fees 5000stake
```

## Test
```
{ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518 ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878 channel-0 osmo1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrqvlx82r 1 true true channel-1}
B834FA96EB41DB72C1DFA61DAE0000C76065ADAC
0ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518
feeappd tx feeabs query-osmosis-twap --from feeacc --keyring-backend test --chain-id feeappd-t1 --yes --fees 5000stake
# Wait for about 10 sec
feeappd q feeabs osmo-arithmetic-twap ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E
```

The result response twap of ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E (uatom)
Now you can pay fees using ```ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E```
1
5 changes: 0 additions & 5 deletions scripts/check-generated.sh

This file was deleted.

30 changes: 0 additions & 30 deletions scripts/deploy_and_channel.sh

This file was deleted.

29 changes: 0 additions & 29 deletions scripts/deploy_local.sh

This file was deleted.

Binary file removed scripts/fee_abstraction.wasm
Binary file not shown.
12 changes: 0 additions & 12 deletions scripts/host_zone.json

This file was deleted.

18 changes: 0 additions & 18 deletions scripts/host_zone_query.json

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/host_zone_uosmo.json

This file was deleted.

60 changes: 60 additions & 0 deletions scripts/ibc_swap/deploy_osmosis_contract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

CHANNEL_ID="channel-0"
export VALIDATOR=$(osmosisd keys show validator1 -a --keyring-backend test )
echo $VALIDATOR=$(osmosisd keys show validator1 -a --keyring-backend test )

export OWNER=$(osmosisd keys show deployer -a --keyring-backend test )
echo $OWNER=$(osmosisd keys show deployer -a --keyring-backend test )


#store the SetupCrosschainRegistry
osmosisd tx wasm store scripts/bytecode/crosschain_registry.wasm --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --gas 10000000 --fees 25000stake --yes
sleep 5

# instantiate
INIT_SWAPREGISTRY='{"owner":"'$OWNER'"}'
osmosisd tx wasm instantiate 1 "$INIT_SWAPREGISTRY" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --label "test" --no-admin --yes --fees 5000stake
SWAPREGISTRY_ADDRESS=osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9
sleep 5

# execute
EXE_MSG='{"modify_chain_channel_links": {"operations": [{"operation": "set","source_chain": "feeappd-t1","destination_chain": "osmosis","channel_id": "channel-0"},{"operation": "set","source_chain": "osmosis","destination_chain": "feeappd-t1","channel_id": "channel-0"},{"operation": "set","source_chain": "feeappd-t1","destination_chain": "gaiad-t1","channel_id": "channel-2"},{"operation": "set","source_chain": "gaiad-t1","destination_chain": "feeappd-t1","channel_id": "channel-0"},{"operation": "set","source_chain": "osmosis","destination_chain": "gaiad-t1","channel_id": "channel-2"},{"operation": "set","source_chain": "gaiad-t1","destination_chain": "osmosis","channel_id": "channel-1"}]}}'
osmosisd tx wasm execute osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9 "$EXE_MSG" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --yes --fees 5000stake
sleep 5
PREFIX='{"modify_bech32_prefixes": {"operations": [{"operation": "set", "chain_name": "feeappd-t1", "prefix": "feeabs"},{"operation": "set", "chain_name": "osmosis", "prefix": "osmo"},{"operation": "set", "chain_name": "gaiad-t1", "prefix": "cosmos"}]}}'
osmosisd tx wasm execute osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9 "$PREFIX" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --yes --fees 5000stake
sleep 5
FEEABS_PFM='{"propose_pfm":{"chain": "feeappd-t1"}}'
osmosisd tx wasm execute osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9 "$FEEABS_PFM" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --yes --fees 5000stake
sleep 5
GAIA_PFM='{"propose_pfm":{"chain": "gaiad-t1"}}'
osmosisd tx wasm execute osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9 "$GAIA_PFM" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --yes --fees 5000stake
sleep 5

# Store the swaprouter contract
osmosisd tx wasm store scripts/bytecode/swaprouter.wasm --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --gas 10000000 --fees 25000stake --yes
sleep 5

# Instantiate the swaprouter contract
INIT_SWAPROUTER='{"owner":"'$OWNER'"}'
osmosisd tx wasm instantiate 2 "$INIT_SWAPROUTER" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --label "test" --no-admin --yes --fees 5000stake
sleep 5
SWAPROUTER_ADDRESS=osmo1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrqvlx82r
echo $SWAPROUTER_ADDRESS

# Configure the swaprouter
CONFIG_SWAPROUTER='{"set_route":{"input_denom":"ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E","output_denom":"ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878","pool_route":[{"pool_id":"1","token_out_denom":"ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878"}]}}'
osmosisd tx wasm execute $SWAPROUTER_ADDRESS "$CONFIG_SWAPROUTER" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing -y --fees 5000stake
sleep 5

# Store the crosschainswap contract
osmosisd tx wasm store scripts/bytecode/crosschain_swaps.wasm --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --gas 10000000 --fees 25000stake --yes
sleep 10

# Instantiate the crosschainswap contract
INIT_CROSSCHAIN_SWAPS='{"swap_contract":"'$SWAPROUTER_ADDRESS'","governor": "'$OWNER'"}'
osmosisd tx wasm instantiate 3 "$INIT_CROSSCHAIN_SWAPS" --keyring-backend=test --home=$HOME/.osmosisd --from deployer --chain-id testing --label "test" --no-admin --yes --fees 5000stake
sleep 5
CROSSCHAIN_SWAPS_ADDRESS=osmo17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs5yczr8
1
51 changes: 0 additions & 51 deletions scripts/ibc_swap/test.json

This file was deleted.

Loading

0 comments on commit 3ef7b78

Please sign in to comment.