Skip to content

Commit

Permalink
update wasm client 50 (#27)
Browse files Browse the repository at this point in the history
* feat: fix scripts run node

* feat: save state

* fix: push wasm code gov

* feat: add store wasm code

* test: use correct version go.mod

* fix: store wasm code 50

* update relayer hyperspace raw scripts

* feat: use notional fork to handle decode grandpa url

* change the name of creatae clients file

* chore: change delay period to 10

* fix type url grandpa not registered

* chore: add hyperspace and cwgranpda wasm file

* feat: update make file

* docs: add how to reproduce the error

* fix miss chain-id

* feat: add scripts to config and start relayer

* fix: correcting go sum

* deps: update go version

* test: setup relayer with sdk 50

* setup gas auto

* update script test-upgrade

---------

Co-authored-by: kienn6034 <[email protected]>
  • Loading branch information
hoank101 and duvbell authored May 19, 2024
1 parent ece78ce commit 5c751ce
Show file tree
Hide file tree
Showing 30 changed files with 436 additions and 138 deletions.
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,28 @@ init-deps:
@echo "Installing dependencies"
bash ./scripts/upgrade/init-deps.sh

localnet-pica: clean-testing-data
@echo "Starting localnet"
bash ./scripts/upgrade/setup-old-picad-node.sh
localnet-pica:
@echo "Starting test"
rm -rf screenlog.0
-@pkill picad 2>/dev/null
bash ./scripts/run-node.sh picad
bash ./scripts/50/store-wasm-code.sh

localnet-picasso:
@echo "Starting localnet"
bash ./scripts/upgrade/setup-polkadot-node.sh
bash ./scripts/relayer_hyperspace/run-picasso.sh

relayer-start:
relayer-create-clients:
@echo "Starting relayer"
bash ./scripts/upgrade/setup-relayer.sh
bash ./scripts/relayer_hyperspace/create-clients.sh

pica-upgrade:
@echo "Starting upgrade"
bash ./scripts/upgrade/upgrade.


relayer-test-cleanup:
@echo "Cleaning up"
./scripts/relayer_hyperspace/cleanup.sh
###############################################################################
### Integration Tests ###
###############################################################################
Expand All @@ -225,4 +230,3 @@ init-test-framework: clean-testing-data install
test-ibc-hooks:
@echo "Testing ibc-hooks..."
./scripts/tests/ibc-hooks/increment.sh

2 changes: 0 additions & 2 deletions app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func NewContextForApp(app composable.ComposableApp) sdk.Context {

func setup(withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*composable.ComposableApp, composable.GenesisState) {
db := dbm.NewMemDB()
encCdc := composable.MakeEncodingConfig()
app := composable.NewComposableApp(
log.NewNopLogger(),
db,
Expand All @@ -71,7 +70,6 @@ func setup(withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*composa
map[int64]bool{},
composable.DefaultNodeHome,
invCheckPeriod,
encCdc,
EmptyAppOptions{},
opts,
nil,
Expand Down
6 changes: 3 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
&appKeepers.TransferKeeper,
appKeepers.BankKeeper,
&appKeepers.IbcTransferMiddlewareKeeper,
authorityAddress,
govModAddress,
)

appKeepers.TxBoundaryKeepper = txBoundaryKeeper.NewKeeper(
appCodec,
appKeepers.keys[txBoundaryTypes.StoreKey],
authorityAddress,
govModAddress,
)

appKeepers.PfmKeeper = pfmkeeper.NewKeeper(
Expand Down Expand Up @@ -488,7 +488,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[wasm08types.StoreKey]),
&appKeepers.IBCKeeper.ClientKeeper,
authorityAddress,
govModAddress,
vm,
bApp.GRPCQueryRouter(),
)
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,9 @@ replace (
github.com/cosmos/cosmos-sdk => github.com/notional-labs/cosmos-sdk v0.50.5-patch-validators-trim-tag

github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 => github.com/notional-labs/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0-20240508031447-347412725653
github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240515182009-f733fca17f8a
//github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 => github.com/notional-labs/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0-20240504082418-e4d8c9cb7044
github.com/cosmos/ibc-go/v8 => github.com/notional-labs/ibc-go/v8 v8.0.0-20240504081627-8ee51f5d7278
github.com/cosmos/ibc-go/v8 => github.com/notional-labs/ibc-go/v8 v8.0.0-alpha.1.0.20240515181700-c058e14324e8

// use cosmos-compatible protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,6 @@ github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0 h1:nKP2+Rzlz2iyvTosY5mvP+
github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0/go.mod h1:D3Q380FpWRFtmUQWLosPxachi6w24Og2t5u/Tww5wtY=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092650-57fcdb9a9a9d h1:F4mhR61RZU4KJ38n5CeZrnNINU/KxMfP1sKfk5fTlHA=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092650-57fcdb9a9a9d/go.mod h1:u2FXNcSxzzn5IwjWBA51HKMwiYMRK6/G35VmSJULhP0=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
Expand Down Expand Up @@ -1387,8 +1385,10 @@ github.com/notional-labs/cosmos-sdk v0.50.5-patch-validators-trim-tag h1:lnMn2O2
github.com/notional-labs/cosmos-sdk v0.50.5-patch-validators-trim-tag/go.mod h1:oV/k6GJgXV9QPoM2fsYDPPsyPBgQbdotv532O6Mz1OQ=
github.com/notional-labs/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0-20240508031447-347412725653 h1:P7Chh5O10Jtv+vvfaVpG72fv5LKVWQLEtCKQrMtbBdw=
github.com/notional-labs/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0-20240508031447-347412725653/go.mod h1:NS+Ooc0vOyr1mAgAbt/HS8Dpes2dV7/YgOc+WxD63O4=
github.com/notional-labs/ibc-go/v8 v8.0.0-20240504081627-8ee51f5d7278 h1:/NOkBq9mYJIGHWKEYbz2qOSQETw6hBPGzS4/64ZcUsk=
github.com/notional-labs/ibc-go/v8 v8.0.0-20240504081627-8ee51f5d7278/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8=
github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240515182009-f733fca17f8a h1:gKpmopVqbasJ7bjCbIh2ZKNJQgnXOYajj6aSclU5eQs=
github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240515182009-f733fca17f8a/go.mod h1:u2FXNcSxzzn5IwjWBA51HKMwiYMRK6/G35VmSJULhP0=
github.com/notional-labs/ibc-go/v8 v8.0.0-alpha.1.0.20240515181700-c058e14324e8 h1:RkivXDi3NoRZEjdbO0ueSykCnb7FPaBR0F8sWn5DlFM=
github.com/notional-labs/ibc-go/v8 v8.0.0-alpha.1.0.20240515181700-c058e14324e8/go.mod h1:x024D7fnWnTL6wNeoHbe0+JSjDaoQ3CNvJY8o9F4imE=
github.com/nunnatsa/ginkgolinter v0.9.0 h1:Sm0zX5QfjJzkeCjEp+t6d3Ha0jwvoDjleP9XCsrEzOA=
github.com/nunnatsa/ginkgolinter v0.9.0/go.mod h1:FHaMLURXP7qImeH6bvxWJUpyH+2tuqe5j4rW1gxJRmI=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
57 changes: 57 additions & 0 deletions kien-note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Running the test

## How did i build the `hyperspace` and `cw-grandpa` binaries
Go to the `ComposableFi/composable-ibc`, and building it in the master branch

https://github.com/ComposableFi/composable-ibc/tree/master/hyperspace

## How to reproduce the case

1. Build the `picad` binary
```bash
make install
```

2. Run the localnet pica with `wasmClient` deployed
```bash
make localnet-pica
```

3. Run the localnet picasso
```bash
make localnet-picasso`
```

4. Run create clients
```bash
make relayer-create-clients
```


# Current issue
## Client State decode into 08-wasm
`6981`
### Logging msg at ValidateBasic on cosmos side on v47
add this log at ValidateBasic() function, at modules/core/02-client/types/msgs/go

```go
fmt.Printf("msg.ClientState : %v\n", msg.ClientState)
clientState, err := UnpackClientState(msg.ClientState)
if err != nil {
return err
}
```
then, i get this value, basically, it says the clientState constructed from hyperspace is `08-wasm`
```
msg.ClientState : &Any{TypeUrl:/ibc.lightclients.wasm.v1.ClientState,Value:[10 204 1 10 40 47 105 98 99 46 108 105 103 104 116 99 108 105 101 110 116 115 46 103 114 97 110 100 112 97 46 118 49 46 67 108 105 101 110 116 83 116 97 116 101 18 159 1 10 32 146 240 69 84 49 1 104 67 240 92 67 123 199 101 70 152 115 0 205 47 91 76 8 16 108 92 254 197 173 59 35 206 16 67 24 5 40 2 48 167 16 56 20 66 36 10 32 199 203 131 204 79 173 68 214 92 44 140 240 46 150 66 83 144 154 219 206 75 174 118 245 90 177 194 134 163 255 44 194 16 1 66 36 10 32 20 164 40 156 190 217 24 43 102 84 102 53 144 50 192 109 195 183 142 183 238 104 52 237 95 167 180 159 149 51 85 167 16 1 66 36 10 32 184 160 36 189 114 208 123 150 110 8 135 7 155 93 135 60 197 160 19 53 186 39 222 219 43 141 20 36 169 95 136 128 16 1 18 32 157 80 86 242 181 81 33 48 148 160 59 120 141 184 2 116 68 81 117 186 231 140 143 237 227 139 242 90 45 220 132 188 26 5 8 167 16 16 20],XXX_unrecognized:[]}
```
### Logging it at v50
`hyperspace`
```
msg.ClientState : &Any{TypeUrl:/ibc.lightclients.grandpa.v1.ClientState,Value:[10 32 106 46 120 116 154 178 37 115 118 3 65 47 241 205 37 168 10 129 250 125 20 121 236 81 77 119 185 185 155 72 122 11 16 17 40 2 48 167 16 56 1 66 36 10 32 199 203 131 204 79 173 68 214 92 44 140 240 46 150 66 83 144 154 219 206 75 174 118 245 90 177 194 134 163 255 44 194 16 1 66 36 10 32 20 164 40 156 190 217 24 43 102 84 102 53 144 50 192 109 195 183 142 183 238 104 52 237 95 167 180 159 149 51 85 167 16 1 66 36 10 32 184 160 36 189 114 208 123 150 110 8 135 7 155 93 135 60 197 160 19 53 186 39 222 219 43 141 20 36 169 95 136 128 16 1 66 36 10 32 140 4 179 243 122 62 235 12 208 118 154 107 153 87 196 106 60 118 44 155 224 91 89 26 250 8 121 224 61 159 194 212 16 1],XXX_unrecognized:[]}
7 changes: 0 additions & 7 deletions kien-todo.md

This file was deleted.

14 changes: 13 additions & 1 deletion scripts/08-wasm/ics10_grandpa_cw.wasm.json

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions scripts/50/migrate-wasm-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
KEY=mykey
DENOM="ppica"
HOME_DIR="mytestnet"
CHAINID="centauri-dev"
BINARY=picad
WASM_CONTRACT_PATH="/Users/kien6034/notional/projects/composable-ibc/target/wasm32-unknown-unknown/release/ics10_grandpa_cw.wasm"

# Create a proposale to store wasm code
$BINARY tx ibc-wasm store-code $WASM_CONTRACT_PATH --title "migrate new contract" --summary "none" --from $KEY --keyring-backend test --home $HOME_DIR --deposit 10000000000${DENOM} --gas 20002152622 --fees 20020166${DENOM} -y

# Fetch proposal id
sleep 6
$BINARY query gov proposals -o json > tmp-proposals.json
PROPOSAL_ID=$(jq -r '.proposals[-1].id' tmp-proposals.json)
echo "Proposal ID is: $PROPOSAL_ID"
rm -rf tmp-proposals.json

# Validator vote yes
$BINARY tx gov vote $PROPOSAL_ID yes --from $KEY --fees 100000${DENOM} --keyring-backend test --home $HOME_DIR --chain-id $CHAINID -y

#Voting time is 20s, check in localnode.sh
sleep 20

# Check the status
$BINARY query gov proposal $PROPOSAL_ID -o json > tmp-proposal.json
STATUS=$(jq -r '.proposal.status' tmp-proposal.json)
echo "Proposal status is: $STATUS"

# Query newly wasm checksums
CHECKSUM=$($BINARY query ibc-wasm checksums -o json | jq -r '.checksums[-1]')



##### Migrate the contract
33 changes: 33 additions & 0 deletions scripts/50/store-wasm-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
KEY=mykey
DENOM="ppica"
HOME_DIR="mytestnet"
CHAINID="centauri-dev"
BINARY=picad
WASM_CONTRACT_PATH="$PWD/bin/ics10_grandpa_cw.wasm"

# Wait for chain to start
echo "Waiting for chain to start..."
sleep 10
# Create a proposale to store wasm code
$BINARY tx ibc-wasm store-code $WASM_CONTRACT_PATH --title "store new wasm code" --summary "none" --from $KEY --keyring-backend test --chain-id $CHAINID --home $HOME_DIR --deposit 10000000000${DENOM} --gas 20002152622 --fees 20020166${DENOM} -y

# Fetch proposal id
sleep 6
$BINARY query gov proposals -o json > /tmp/proposals.json
PROPOSAL_ID=$(jq -r '.proposals[-1].id' /tmp/proposals.json)
echo "Proposal ID is: $PROPOSAL_ID"

# Validator vote yes
$BINARY tx gov vote $PROPOSAL_ID yes --from $KEY --fees 100000${DENOM} --keyring-backend test --home $HOME_DIR --chain-id $CHAINID -y

#Voting time is 20s, check in localnode.sh
sleep 20

# Check the status
$BINARY query gov proposal $PROPOSAL_ID -o json > /tmp/proposal.json
STATUS=$(jq -r '.proposal.status' /tmp/proposal.json)
echo "Proposal status is: $STATUS"

# Query wasm checksums
$BINARY query ibc-wasm checksums
78 changes: 78 additions & 0 deletions scripts/localnode-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
BINARY=$1
CHAINID="localpica"
MONIKER="localtestnet"
KEYALGO="secp256k1"
KEYRING="test"
LOGLEVEL="info"
CONTINUE=${CONTINUE:-"false"}
# to trace evm
#TRACE="--trace"
TRACE=""

KEY="test0"
KEY1="test1"
KEY2="test2"

HOME_DIR=mytestnet
DENOM=${2:-ppica}


if [ "$CONTINUE" == "true" ]; then
echo "\n ->> continuing from previous state"
$BINARY start --home $HOME_DIR --log_level debug
exit 0
fi


# remove existing daemon
rm -rf $HOME_DIR

$BINARY config keyring-backend $KEYRING
$BINARY config chain-id $CHAINID
# if $KEY exists it should be deleted

$BINARY init $CHAINID --chain-id $CHAINID --default-denom $DENOM --home $HOME_DIR >/dev/null 2>&1


echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry" | $BINARY keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover --home $HOME_DIR

$BINARY keys add $KEY1 --keyring-backend $KEYRING --home $HOME_DIR
$BINARY keys add $KEY2 --keyring-backend $KEYRING --home $HOME_DIR
$BINARY keys add $KEY3 --keyring-backend $KEYRING --home $HOME_DIR


update_test_genesis () {
# update_test_genesis '.consensus_params["block"]["max_gas"]="100000000"'
cat $HOME_DIR/config/genesis.json | jq "$1" > $HOME_DIR/config/tmp_genesis.json && mv $HOME_DIR/config/tmp_genesis.json $HOME_DIR/config/genesis.json
}

# Allocate genesis accounts (cosmos formatted addresses)
$BINARY add-genesis-account $KEY 100000000000000000000000000$DENOM --keyring-backend $KEYRING --home $HOME_DIR
$BINARY add-genesis-account $KEY1 100000000000000000000000000$DENOM --keyring-backend $KEYRING --home $HOME_DIR
$BINARY add-genesis-account $KEY2 100000000000000000000000000$DENOM --keyring-backend $KEYRING --home $HOME_DIR
$BINARY add-genesis-account $KEY3 100000000000000000000000000$DENOM --keyring-backend $KEYRING --home $HOME_DIR


# Sign genesis transaction
$BINARY gentx $KEY 1000000000000000000000$DENOM --keyring-backend $KEYRING --chain-id $CHAINID --home $HOME_DIR

update_test_genesis '.app_state["gov"]["params"]["voting_period"]="5s"'
update_test_genesis '.app_state["mint"]["params"]["mint_denom"]="'$DENOM'"'
update_test_genesis '.app_state["gov"]["params"]["min_deposit"]=[{"denom":"'$DENOM'","amount": "100"}]'
update_test_genesis '.app_state["crisis"]["constant_fee"]={"denom":"'$DENOM'","amount":"1000"}'
update_test_genesis '.app_state["staking"]["params"]["bond_denom"]="'$DENOM'"'

# sed -i 's/timeout_commit = "5s"/timeout_commit = "500ms"/' $HOME_DIR/config/config.toml

echo "updating.."
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "500ms"/' $HOME_DIR/config/config.toml

# Collect genesis tx
$BINARY collect-gentxs --home $HOME_DIR

# Run this to ensure everything worked and that the genesis file is setup correctly
$BINARY validate-genesis --home $HOME_DIR

$BINARY start --rpc.unsafe --rpc.laddr tcp://0.0.0.0:26657 --pruning=nothing --minimum-gas-prices=0.000ppica --home $HOME_DIR

21 changes: 21 additions & 0 deletions scripts/relayer_hyperspace/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

echo "kill composable node"
pkill -f picad
rm -rf mytestnet


echo "Cleanign up devnet-picasso containers..."
# The image name you want to stop containers for
IMAGE_NAME="composablefi/devnet-picasso"

# Find the container ID(s) for containers running this image
CONTAINER_IDS=$(docker ps --filter "ancestor=$IMAGE_NAME" --format "{{.ID}}")

# Stop the container(s)
for ID in $CONTAINER_IDS; do
echo "Stopping container $ID..."
docker stop $ID
done

echo "Cleanup complete."
13 changes: 13 additions & 0 deletions scripts/relayer_hyperspace/config-chain-a.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type = "parachain"
name = "picasso_dev"
para_id = 2000
parachain_rpc_url = "ws://127.0.0.1:9988"
relay_chain_rpc_url = "ws://127.0.0.1:9944"
client_id = "08-wasm-0"
connection_id = "connection-0"
commitment_prefix = "0x6962632f"
private_key = "//Alice"
ss58_version = 49
channel_whitelist = [["channel-0", "transfer"], ["channel-0", "transfer"]]
finality_protocol = "Grandpa"
key_type = "sr25519"
20 changes: 20 additions & 0 deletions scripts/relayer_hyperspace/config-chain-b.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type = "cosmos"
name = "centauri"
rpc_url = "http://127.0.0.1:26657/"
grpc_url = "http://127.0.0.1:9090/"
websocket_url = "ws://127.0.0.1:26657/websocket"
chain_id = "centauri-dev"
client_id = "07-tendermint-1"
connection_id = "connection-0"
account_prefix = "pica"
fee_denom = "ppica"
fee_amount = "9223372036854776"
gas_limit = 9223372036854775806
store_prefix = "ibc"
max_tx_size = 20000000
wasm_code_id = "9d5056f2b551213094a03b788db80274445175bae78c8fede38bf25a2ddc84bc"
channel_whitelist = [["channel-0", "transfer"], ["channel-0", "transfer"]]
mnemonic = "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"
skip_optional_client_updates = false
max_packets_to_process = 50
skip_tokens_list = []
1 change: 1 addition & 0 deletions scripts/relayer_hyperspace/config-core.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prometheus_endpoint = "https://127.0.0.1"
Loading

0 comments on commit 5c751ce

Please sign in to comment.