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

refactor 08-wasm #18

Merged
merged 4 commits into from
Apr 1, 2024
Merged
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
39 changes: 32 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package app

import (
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
"fmt"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -43,7 +47,7 @@ import (

"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/app/upgrades/v6_5_0"
"github.com/notional-labs/composable/v6/app/upgrades/v7_0_0"
"github.com/notional-labs/composable/v6/app/upgrades/v7_0_1"

// bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"cosmossdk.io/x/evidence"
Expand Down Expand Up @@ -148,7 +152,7 @@ var (
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v6_5_0.Upgrade, v7_0_0.Upgrade}
Upgrades = []upgrades.Upgrade{v6_5_0.Upgrade, v7_0_1.Upgrade}
Forks = []upgrades.Fork{}
)

Expand Down Expand Up @@ -195,7 +199,6 @@ var (
vesting.AppModuleBasic{},
tendermint.AppModuleBasic{},
mint.AppModuleBasic{},
wasm08.AppModuleBasic{},
wasm.AppModuleBasic{},
router.AppModuleBasic{},
ica.AppModuleBasic{},
Expand All @@ -207,6 +210,7 @@ var (
stakingmiddleware.AppModuleBasic{},
ibctransfermiddleware.AppModuleBasic{},
circuit.AppModuleBasic{},
wasm08.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -382,8 +386,8 @@ func NewComposableApp(
icqModule,
ibcHooksModule,
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
wasm08.NewAppModule(app.Wasm08Keeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
wasm08.NewAppModule(app.Wasm08Keeper),
routerModule,
transfermiddlewareModule,
txBoundaryModule,
Expand Down Expand Up @@ -433,11 +437,11 @@ func NewComposableApp(
paramstypes.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasmtypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
wasm08types.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -469,11 +473,11 @@ func NewComposableApp(
icqtypes.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasmtypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
wasm08types.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -509,11 +513,11 @@ func NewComposableApp(
group.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasmtypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
wasm08types.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down Expand Up @@ -780,3 +784,24 @@ func (app *ComposableApp) setupUpgradeHandlers() {
)
}
}

// AutoCliOpts returns the autocli options for the app.
func (app *ComposableApp) AutoCliOpts() autocli.AppOptions {
modules := make(map[string]appmodule.AppModule, 0)
for _, m := range app.mm.Modules {
if moduleWithName, ok := m.(module.HasName); ok {
moduleName := moduleWithName.Name()
if appModule, ok := moduleWithName.(appmodule.AppModule); ok {
modules[moduleName] = appModule
}
}
}

return autocli.AppOptions{
Modules: modules,
ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.mm.Modules),
AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()),
ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
}
}
9 changes: 5 additions & 4 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
)

// use same VM for wasm
appKeepers.Wasm08Keeper = wasm08Keeper.NewKeeper(
appKeepers.Wasm08Keeper = wasm08Keeper.NewKeeperWithVM(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[wasm08types.StoreKey]),
govModAddress,
wasmDir,
&appKeepers.IBCKeeper.ClientKeeper,
bApp.GRPCQueryRouter())
"centauri1hj5fveer5cjtn4wd6wstzugjfdxzl0xpzxlwgs",
wasmer,
bApp.GRPCQueryRouter(),
)

appKeepers.Ics20WasmHooks.ContractKeeper = &appKeepers.WasmKeeper

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v7_0_0
package v7_0_1

import (
store "cosmossdk.io/store/types"
Expand All @@ -10,7 +10,7 @@ import (

const (
// UpgradeName defines the on-chain upgrade name for the composable upgrade.
UpgradeName = "v7_0_0"
UpgradeName = "v7_0_1"
)

var Upgrade = upgrades.Upgrade{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v7_0_0
package v7_0_1

import (
"context"
Expand Down
32 changes: 31 additions & 1 deletion cmd/centaurid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"errors"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"io"
"os"

Expand Down Expand Up @@ -50,6 +51,21 @@ var ChainID string
// main function.
func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
encodingConfig := app.MakeEncodingConfig()

tempApp := app.NewComposableApp(
log.NewNopLogger(),
dbm.NewMemDB(),
nil,
true,
map[int64]bool{},
app.DefaultNodeHome,
5,
encodingConfig,
EmptyAppOptions{},
nil,
nil,
)

initClientCtx := client.Context{}.
WithCodec(encodingConfig.Marshaler).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
Expand Down Expand Up @@ -91,6 +107,15 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {

initRootCmd(rootCmd, encodingConfig)

autoCliOpts := tempApp.AutoCliOpts()
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx = initClientCtx

if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}

return rootCmd, encodingConfig
}

Expand Down Expand Up @@ -244,12 +269,13 @@ func txCommand() *cobra.Command {
authcmd.GetSignCommand(),
authcmd.GetSignBatchCommand(),
authcmd.GetMultiSignCommand(),
authcmd.GetMultiSignBatchCmd(),
authcmd.GetValidateSignaturesCommand(),
flags.LineBreak,
authcmd.GetBroadcastCommand(),
authcmd.GetEncodeCommand(),
authcmd.GetDecodeCommand(),
flags.LineBreak,
authcmd.GetSimulateCmd(),
)

return cmd
Expand Down Expand Up @@ -352,3 +378,7 @@ func genesisCommand(txConfig client.TxConfig, basicManager module.BasicManager,
}
return cmd
}

type EmptyAppOptions struct{}

func (EmptyAppOptions) Get(_ string) interface{} { return nil }
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require github.com/cometbft/cometbft-db v0.11.0 // indirect
require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.1 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.1
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/tools/confix v0.1.1 // indirect
cosmossdk.io/x/circuit v0.1.0
Expand Down Expand Up @@ -364,7 +364,7 @@ replace (
// TODO: check wasm vm compatibility with grandpa contract
github.com/CosmWasm/wasmvm => github.com/CosmWasm/wasmvm v1.5.2

github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240330020027-fa949b150972
// github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240330020027-fa949b150972

// use cosmos-compatible protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ 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/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg=
github.com/cosmos/ibc-go/v8 v8.0.0/go.mod h1:C6IiJom0F3cIQCD5fKwVPDrDK9j/xTu563AWuOmXois=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
Expand Down Expand Up @@ -1401,8 +1403,6 @@ github.com/nishanths/exhaustive v0.9.5 h1:TzssWan6orBiLYVqewCG8faud9qlFntJE30ACp
github.com/nishanths/exhaustive v0.9.5/go.mod h1:IbwrGdVMizvDcIxPYGVdQn5BqWJaOwpCvg4RGb8r/TA=
github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240330020027-fa949b150972 h1:nrxV6i6FBnMUwmx3Aqun7111xfOCFEIO9oetf5EVxEM=
github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240330020027-fa949b150972/go.mod h1:u2FXNcSxzzn5IwjWBA51HKMwiYMRK6/G35VmSJULhP0=
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
4 changes: 3 additions & 1 deletion scripts/localnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rm -rf $HOME_DIR
pkill centaurid

# check DENOM is set. If not, set to upica
DENOM=${2:-upica}
DENOM=${2:-ppica}
echo "denom: $DENOM"
COMMISSION_RATE=0.01
COMMISSION_MAX_RATE=0.02
Expand Down Expand Up @@ -64,6 +64,8 @@ $BINARY add-genesis-account $KEY "1000000000000000000000${DENOM}" --keyring-back
$BINARY add-genesis-account $KEY1 "1000000000000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR
$BINARY add-genesis-account $KEY2 "1000000000000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR

$BINARY add-genesis-account centauri1hj5fveer5cjtn4wd6wstzugjfdxzl0xpzxlwgs "1000000000000000000000${DENOM}" --keyring-backend $KEYRING --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": "1000000"}]'
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ HOME=mytestnet
ROOT=$(pwd)
DENOM=upica
CHAIN_ID=localpica
SOFTWARE_UPGRADE_NAME="v7_0_0"
SOFTWARE_UPGRADE_NAME="v7_0_1"
ADDITIONAL_PRE_SCRIPTS=""
ADDITIONAL_AFTER_SCRIPTS=""

Expand Down Expand Up @@ -93,7 +93,7 @@ run_upgrade () {

# Get upgrade height, 12 block after (6s)
STATUS_INFO=($(./_build/old/centaurid status --home $HOME | jq -r '.NodeInfo.network,.SyncInfo.latest_block_height'))
UPGRADE_HEIGHT=$((STATUS_INFO[1] + 20))
UPGRADE_HEIGHT=$((STATUS_INFO[1] + 50))
echo "UPGRADE_HEIGHT = $UPGRADE_HEIGHT"

tar -cf ./_build/new/centaurid.tar -C ./_build/new centaurid
Expand Down
25 changes: 21 additions & 4 deletions scripts/testnode.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

KEY="mykey"
CHAINID="test-1"
CHAINID="localpica"
MONIKER="localtestnet"
KEYALGO="secp256k1"
KEYRING="test"
Expand All @@ -10,6 +10,10 @@ LOGLEVEL="info"
#TRACE="--trace"
TRACE=""

HOME_DIR=~/.banksy
DENOM=${2:-ppica}


# remove existing daemon
rm -rf ~/.banksy*

Expand All @@ -21,12 +25,25 @@ echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor

centaurid init $MONIKER --chain-id $CHAINID > /dev/null 2>&1

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)
centaurid genesis add-genesis-account $KEY 100000000000000000000000000stake --keyring-backend $KEYRING
centaurid genesis add-genesis-account $KEY 100000000000000000000000000ppica --keyring-backend $KEYRING
centaurid add-genesis-account centauri1hj5fveer5cjtn4wd6wstzugjfdxzl0xpzxlwgs "1000000000000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR


# Sign genesis transaction
centaurid genesis gentx $KEY 1000000000000000000000stake --keyring-backend $KEYRING --chain-id $CHAINID
centaurid genesis gentx $KEY 1000000000000000000000ppica --keyring-backend $KEYRING --chain-id $CHAINID

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

# Collect genesis tx
centaurid collect-gentxs

Expand All @@ -42,4 +59,4 @@ fi
sed -i'' -e 's/max_body_bytes = /max_body_bytes = 1/g' ~/.banksy/config/config.toml

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
centaurid start --pruning=nothing --minimum-gas-prices=0.0001stake --rpc.laddr tcp://0.0.0.0:26657
centaurid start --pruning=nothing --minimum-gas-prices=0.0001ppica --rpc.laddr tcp://0.0.0.0:26657
13 changes: 1 addition & 12 deletions scripts/upload_contracts.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
#!/bin/bash

KEY="mykey"
CHAINID="test-1"
KEYALGO="secp256k1"
KEYRING="test"

# validate dependencies are installed
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; }

# remove existing daemon
rm -rf ~/.centauri*

~/go/bin/centaurid config keyring-backend $KEYRING
~/go/bin/centaurid config chain-id $CHAINID

# if $KEY exists it should be deleted
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" | ~/go/bin/centaurid keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover


~/go/bin/centaurid tx 08-wasm push-wasm contracts/ics10_grandpa_cw.wasm --from mykey --keyring-backend test --gas 902152622 --fees 920166stake -y
./_build/old/centaurid tx 08-wasm push-wasm contracts/ics10_grandpa_cw.wasm --from=mykey --gas 10002152622 --fees 10020166upica --keyring-backend test --chain-id=localpica -y
11 changes: 11 additions & 0 deletions scripts/upload_contracts_new.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

KEY="mykey"
KEYALGO="secp256k1"
KEYRING="test"

# validate dependencies are installed
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; }

centaurid tx ibc-wasm store-code contracts/ics10_grandpa_cw.wasm --from=mykey --title test --summary test --gas 10002152622 --fees 10020166ppica --deposit 100000000ppica --keyring-backend test --chain-id=localpica -y
centaurid tx gov vote 1 yes --from=mykey --gas 10002152622 --fees 10020166ppica --keyring-backend test --chain-id=localpica -y
Loading