diff --git a/Makefile b/Makefile index b6620291..2051efe5 100644 --- a/Makefile +++ b/Makefile @@ -213,9 +213,12 @@ create-connection: @echo "Creating Defund -> Osmosis Connection" hermes -c ./network/hermes/config.toml create connection defund osmosis -init: kill-dev +init: @echo "Initializing both blockchains..." ./network/init.sh + @echo "Optimizing network" + ./testnet/private/update_configs.sh + @echo "Starting up network" ./network/start.sh init-rly: @@ -224,6 +227,8 @@ init-rly: ./network/relayer/restore-keys.sh start: + @echo "Optimizing network" + ./testnet/private/update_configs.sh @echo "Starting up network" ./network/start.sh @@ -243,12 +248,12 @@ install-all: ./network/ts-relayer/install.sh kill-dev: - @echo "Killing defundd, osmosis, hermes, ts-relayer and removing previous data" + @echo "Killing defundd, osmosis, hermes, ts-relayer (node processses) and removing previous data" -@rm -rf ./network/data -@killall defundd 2>/dev/null -@killall node 2>/dev/null - -@killall osmosis 2>/dev/null - -@killall rly 2>/dev/null + -@killall hermes 2>/dev/null +# -@killall rly 2>/dev/null ############################################################################### ### Test ### diff --git a/app/app.go b/app/app.go index c7dab200..7ab8f0dd 100644 --- a/app/app.go +++ b/app/app.go @@ -176,8 +176,8 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, etfmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - icatypes.ModuleName: nil, brokermoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + icatypes.ModuleName: nil, // this line is used by starport scaffolding # stargate/app/maccPerms } ) @@ -308,9 +308,9 @@ func New( // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - scopedBrokerKeeper := app.CapabilityKeeper.ScopeToModule(brokermoduletypes.ModuleName) scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + scopedBrokerKeeper := app.CapabilityKeeper.ScopeToModule(brokermoduletypes.ModuleName) scopedETFKeeper := app.CapabilityKeeper.ScopeToModule(etfmoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/scopedKeeper @@ -372,8 +372,7 @@ func New( app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, ) transferModule := transfer.NewAppModule(app.TransferKeeper) - var transferStack porttypes.IBCModule - transferStack = transfer.NewIBCModule(app.TransferKeeper) + transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.SubModuleName), @@ -399,7 +398,7 @@ func New( ) queryModule := querymodule.NewAppModule(appCodec, app.QueryKeeper, app.AccountKeeper) - app.BrokerKeeper = brokermodulekeeper.NewKeeper(appCodec, keys[brokermoduletypes.StoreKey], app.ICAControllerKeeper, scopedBrokerKeeper, app.TransferKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, app.QueryKeeper, app.EtfKeeper, app.BankKeeper) + app.BrokerKeeper = brokermodulekeeper.NewKeeper(appCodec, keys[brokermoduletypes.StoreKey], app.GetSubspace(brokermoduletypes.ModuleName), app.ICAControllerKeeper, scopedBrokerKeeper, app.TransferKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, app.QueryKeeper, app.EtfKeeper, app.BankKeeper) brokerModule := brokermodule.NewAppModule(appCodec, app.BrokerKeeper, app.TransferKeeper) brokerIBCModule := brokermodule.NewIBCModule(app.BrokerKeeper, app.EtfKeeper) @@ -418,8 +417,6 @@ func New( &stakingKeeper, govRouter, ) - transferStack = etfmodule.NewIBCMiddleware(transferStack, app.EtfKeeper) - app.EtfKeeper = *etfmodulekeeper.NewKeeper( appCodec, keys[etfmoduletypes.StoreKey], @@ -437,13 +434,16 @@ func New( ) etfModule := etfmodule.NewAppModule(appCodec, app.EtfKeeper, app.AccountKeeper, app.BankKeeper, app.QueryKeeper, app.BrokerKeeper) + // finish transfer stack + transferStack := etfmodule.NewIBCMiddleware(transferIBCModule, app.EtfKeeper) + // Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() ibcRouter. - AddRoute(brokermoduletypes.ModuleName, icaControllerIBCModule). + AddRoute(ibctransfertypes.ModuleName, transferStack). AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule). AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(ibctransfertypes.ModuleName, transferStack) + AddRoute(brokermoduletypes.ModuleName, icaControllerIBCModule) app.IBCKeeper.SetRouter(ibcRouter) // this line is used by starport scaffolding # stargate/app/keeperDefinition @@ -730,6 +730,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(querymoduletypes.ModuleName) paramsKeeper.Subspace(icacontrollertypes.SubModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(brokermoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/app/config.go b/app/config.go new file mode 100644 index 00000000..daf5a7b0 --- /dev/null +++ b/app/config.go @@ -0,0 +1,25 @@ +package app + +import ( + "time" + + tmcfg "github.com/tendermint/tendermint/config" +) + +func SetTendermintConfigs(config *tmcfg.Config) { + config.P2P.MaxNumInboundPeers = 100 + config.P2P.MaxNumOutboundPeers = 100 + config.P2P.SendRate = 20480000 + config.P2P.RecvRate = 20480000 + config.P2P.MaxPacketMsgPayloadSize = 10240 + config.P2P.FlushThrottleTimeout = 10 * time.Millisecond + // Mempool configs + config.Mempool.Size = 5000 + config.Mempool.MaxTxsBytes = 10737418240 + config.Mempool.MaxTxBytes = 2048576 + // Consensus Configs + config.Consensus.TimeoutPrevote = 250 * time.Millisecond + config.Consensus.TimeoutPrecommit = 250 * time.Millisecond + config.Consensus.TimeoutCommit = 250 * time.Millisecond + config.Consensus.SkipTimeoutCommit = true +} diff --git a/cmd/defundd/init.go b/cmd/defundd/init.go new file mode 100644 index 00000000..6b109522 --- /dev/null +++ b/cmd/defundd/init.go @@ -0,0 +1,158 @@ +package main + +import ( + "bufio" + "encoding/json" + "fmt" + "os" + "path/filepath" + + "github.com/cosmos/go-bip39" + "github.com/defund-labs/defund/app" + "github.com/pkg/errors" + "github.com/spf13/cobra" + cfg "github.com/tendermint/tendermint/config" + "github.com/tendermint/tendermint/libs/cli" + tmos "github.com/tendermint/tendermint/libs/os" + tmrand "github.com/tendermint/tendermint/libs/rand" + "github.com/tendermint/tendermint/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/input" + "github.com/cosmos/cosmos-sdk/server" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/genutil" +) + +const ( + // FlagOverwrite defines a flag to overwrite an existing genesis JSON file. + FlagOverwrite = "overwrite" + + // FlagSeed defines a flag to initialize the private validator key from a specific seed. + FlagRecover = "recover" +) + +type printInfo struct { + Moniker string `json:"moniker" yaml:"moniker"` + ChainID string `json:"chain_id" yaml:"chain_id"` + NodeID string `json:"node_id" yaml:"node_id"` + GenTxsDir string `json:"gentxs_dir" yaml:"gentxs_dir"` + AppMessage json.RawMessage `json:"app_message" yaml:"app_message"` +} + +func newPrintInfo(moniker, chainID, nodeID, genTxsDir string, appMessage json.RawMessage) printInfo { + return printInfo{ + Moniker: moniker, + ChainID: chainID, + NodeID: nodeID, + GenTxsDir: genTxsDir, + AppMessage: appMessage, + } +} + +func displayInfo(info printInfo) error { + out, err := json.MarshalIndent(info, "", " ") + if err != nil { + return err + } + + _, err = fmt.Fprintf(os.Stderr, "%s\n", string(sdk.MustSortJSON(out))) + + return err +} + +// InitCmd returns a command that initializes all files needed for Tendermint +// and the respective application. +func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { + cmd := &cobra.Command{ + Use: "init [moniker]", + Short: "Initialize private validator, p2p, genesis, and application configuration files", + Long: `Initialize validators's and node's configuration files.`, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + cdc := clientCtx.Codec + + serverCtx := server.GetServerContextFromCmd(cmd) + config := serverCtx.Config + + app.SetTendermintConfigs(config) + + config.SetRoot(clientCtx.HomeDir) + + chainID, _ := cmd.Flags().GetString(flags.FlagChainID) + if chainID == "" { + chainID = fmt.Sprintf("test-chain-%v", tmrand.Str(6)) + } + + // Get bip39 mnemonic + var mnemonic string + recover, _ := cmd.Flags().GetBool(FlagRecover) + if recover { + inBuf := bufio.NewReader(cmd.InOrStdin()) + value, err := input.GetString("Enter your bip39 mnemonic", inBuf) + if err != nil { + return err + } + + mnemonic = value + if !bip39.IsMnemonicValid(mnemonic) { + return errors.New("invalid mnemonic") + } + } + + nodeID, _, err := genutil.InitializeNodeValidatorFilesFromMnemonic(config, mnemonic) + if err != nil { + return err + } + + config.Moniker = args[0] + + genFile := config.GenesisFile() + overwrite, _ := cmd.Flags().GetBool(FlagOverwrite) + + if !overwrite && tmos.FileExists(genFile) { + return fmt.Errorf("genesis.json file already exists: %v", genFile) + } + + appState, err := json.MarshalIndent(mbm.DefaultGenesis(cdc), "", " ") + if err != nil { + return errors.Wrap(err, "Failed to marshall default genesis state") + } + + genDoc := &types.GenesisDoc{} + if _, err := os.Stat(genFile); err != nil { + if !os.IsNotExist(err) { + return err + } + } else { + genDoc, err = types.GenesisDocFromFile(genFile) + if err != nil { + return errors.Wrap(err, "Failed to read genesis doc from file") + } + } + + genDoc.ChainID = chainID + genDoc.Validators = nil + genDoc.AppState = appState + + if err = genutil.ExportGenesisFile(genDoc, genFile); err != nil { + return errors.Wrap(err, "Failed to export gensis file") + } + + toPrint := newPrintInfo(config.Moniker, chainID, nodeID, "", appState) + + cfg.WriteConfigFile(filepath.Join(config.RootDir, "config", "config.toml"), config) + return displayInfo(toPrint) + }, + } + + cmd.Flags().String(cli.HomeFlag, defaultNodeHome, "node's home directory") + cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file") + cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating") + cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") + + return cmd +} diff --git a/go.mod b/go.mod index d81c3fb4..f6e5adad 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,14 @@ go 1.18 require ( github.com/cosmos/cosmos-sdk v0.45.9 + github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/ibc-go/v4 v4.0.1 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/osmosis-labs/osmosis/v8 v8.0.1 + github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 github.com/spf13/cast v1.5.0 @@ -40,7 +42,6 @@ require ( github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect github.com/confio/ics23/go v0.7.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect - github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.3 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect @@ -55,6 +56,7 @@ require ( github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect @@ -67,6 +69,7 @@ require ( github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect @@ -91,7 +94,6 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.13.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect diff --git a/go.sum b/go.sum index 949bf545..d390016c 100644 --- a/go.sum +++ b/go.sum @@ -408,6 +408,7 @@ github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASx github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -635,6 +636,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqC github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2yq6j8bu0wa+9w14EEthWU= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0 h1:kr3j8iIMR4ywO/O0rvksXaJvauGGCMg2zAZIiNZ9uIQ= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0/go.mod h1:ummNFgdgLhhX7aIiy35vVmQNS0rWXknfPE0qe6fmFXg= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= diff --git a/network/init.sh b/network/init.sh index 3dd19f29..34c6990e 100755 --- a/network/init.sh +++ b/network/init.sh @@ -45,11 +45,12 @@ $BINARY gentx val 7000000000ufetf --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAIN $BINARY collect-gentxs --home $CHAIN_DIR/$CHAINID_1 echo "Changing defaults and ports in app.toml and config.toml files..." -sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAINID_1/config/config.toml -sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAINID_1/config/config.toml sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAINID_1/config/config.toml +sed -i -e 's/cors_allowed_origins = []/cors_allowed_origins = [*]/g' $CHAIN_DIR/$CHAINID_1/config/config.toml sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml +sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml +sed -i -e 's/enable-unsafe-cors = false/enable-unsafe-cors = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml echo "Changing Genesis File" # Change crisis fee denom to fake detf @@ -67,3 +68,8 @@ echo -E "${contents}" > ./network/data/defund/config/genesis.json # Change brokers in broker in genesis file to blank so it will run broker function contents="$(jq '.app_state.broker.brokers = []' ./network/data/defund/config/genesis.json)" && \ echo -E "${contents}" > ./network/data/defund/config/genesis.json +# Change base denoms in genesis file +contents="$(jq '.app_state.broker.params.base_denoms.AtomTrace.path = "transfer/channel-0/transfer/channel-0"' ./network/data/defund/config/genesis.json)" && \ +echo -E "${contents}" > ./network/data/defund/config/genesis.json +contents="$(jq '.app_state.broker.params.base_denoms.OsmoTrace.path = "transfer/channel-0"' ./network/data/defund/config/genesis.json)" && \ +echo -E "${contents}" > ./network/data/defund/config/genesis.json diff --git a/network/relayer/config/config.yaml b/network/relayer/config/config.yaml index dad909d2..4b41055f 100644 --- a/network/relayer/config/config.yaml +++ b/network/relayer/config/config.yaml @@ -1,39 +1,35 @@ global: api-listen-addr: :5183 - timeout: 60s + timeout: 10s memo: "" light-cache-size: 20 chains: - defund: - type: cosmos - value: - key: defund - chain-id: defund - rpc-addr: http://localhost:26657 - account-prefix: defund - keyring-backend: test - block-timeout: 6s - gas-adjustment: 1.2 - gas-prices: 0.01ufetf - debug: true - timeout: 60s - output-format: json - sign-mode: direct - osmosis: - type: cosmos - value: - key: osmo - chain-id: osmo-test-4 - rpc-addr: http://46.166.172.232:26657 - account-prefix: osmo - keyring-backend: test - gas-adjustment: 1.2 - block-timeout: 6s - gas-prices: 0.01uosmo - debug: true - timeout: 60s - output-format: json - sign-mode: direct + - type: cosmos + value: + key: defund + chain-id: defund + rpc-addr: https://localhost:26657 + account-prefix: defund + keyring-backend: test + gas-adjustment: 1.2 + gas-prices: 0.01ufetf + debug: true + timeout: 20s + output-format: json + sign-mode: direct + - type: cosmos + value: + key: osmo + chain-id: osmo-test-4 + rpc-addr: https://rpc-test.osmosis.zone:443 + account-prefix: osmo + keyring-backend: test + gas-adjustment: 1.2 + gas-prices: 0.01uosmo + debug: true + timeout: 20s + output-format: json + sign-mode: direct paths: defundosmosis: src: @@ -42,8 +38,8 @@ paths: connection-id: connection-0 dst: chain-id: osmo-test-4 - client-id: 07-tendermint-2320 - connection-id: connection-1865 + client-id: 07-tendermint-2517 + connection-id: connection-2030 src-channel-filter: rule: "" channel-list: [] diff --git a/network/relayer/keys/defund/keyring-test/dcade2a6524043feda8e01e2773c8d29d4815889.address b/network/relayer/keys/defund/keyring-test/dcade2a6524043feda8e01e2773c8d29d4815889.address deleted file mode 100644 index c9d08dcd..00000000 --- a/network/relayer/keys/defund/keyring-test/dcade2a6524043feda8e01e2773c8d29d4815889.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMi0wNy0zMSAyMzoxMjoyMi43MzIyMTAzIC0wNTAwIENEVCBtPSswLjA5NTUzNTgwMSIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjgxOTIsInAycyI6ImxzSzUyblotXzZrZTkwZDAifQ.WIWqjnH0rVxplKxqLxCmJQfJWUuQA8yvB9TZmYxCBpjQhll_8jF3Qw.S22oBJh4C02dn9L6.VPcPWY2CngFzUsId6TefUKqM-t6dDv0H7pGSbtuXDe-Ql98XEZ1qi5qZZpl8wqdjJYb1f20_BkA2957Qo6G3Yv2Oc6D49Ej-MDTjOMYf9bd4a0FZ6K4eBYFNzGO_ptXOlTBauPQuEdEl_xIfDTjqgRsPYtmxlNB_NxCO2tUdO4WreTkQIl6Czzcr_yPzkByjskyqTP3vCMPcUbZHBaFzz4rDYfmsCndIjspbprFCczU-L1dfYMs.O2HBFCf-9JoTSeSKtzLDwQ \ No newline at end of file diff --git a/network/relayer/keys/defund/keyring-test/defund.info b/network/relayer/keys/defund/keyring-test/defund.info deleted file mode 100644 index 983a18b7..00000000 --- a/network/relayer/keys/defund/keyring-test/defund.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMi0wNy0zMSAyMzoxMjoyMi43MjY2NzYxIC0wNTAwIENEVCBtPSswLjA5MDAwMTcwMSIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjgxOTIsInAycyI6ImxFcWoxMTVWbXcwMnM0cjUifQ.WovUiuI5SSVBQVqmXxp3LKgnPsx2HvG2ktiJxsbihhZTqmr8UMaoTA.yC-3mUpUU8-alXz9.7iXSF-t3qrnYg8BCC34I3iDgwommKDh0grBfNJRA9sZMCrGE93H-ZAqs15M9UjAqHFN344gvaD9n5_zlCURItV9ojEkGPrTAoSPUzGHThb44U75tVvodKD116AKI-6H2THi78klN8nm2SWLCOs3xamuIxpajyGEzGv0CzMuuaW8XiJ8TTWo6o-jpVtIx7lQQNtwzN1JNgMT-_hTkGdVc0BLGiAORAdvI3pDTnjl2cROLzwJk89_ResZXPKKGVqAYSGXT40bHMhnD0JgW4FLVt1KGamZFo56ToKZPwM3U6Z3grumaeXb_lhOOdpVc6xMhOSVI8Kc2-sNYgZG64RmMB37gbeaU0S5wavO704Y.q6sr3qcTdkZLJSc6BlsDFA \ No newline at end of file diff --git a/network/relayer/keys/osmo-test-4/keyring-test/f357f7ee4b8afdeb079742b2d00a4180b9f75d02.address b/network/relayer/keys/osmo-test-4/keyring-test/f357f7ee4b8afdeb079742b2d00a4180b9f75d02.address deleted file mode 100644 index d1921aa4..00000000 --- a/network/relayer/keys/osmo-test-4/keyring-test/f357f7ee4b8afdeb079742b2d00a4180b9f75d02.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMi0wNy0zMSAyMzoxMjoyNy44NTA0MDE3IC0wNTAwIENEVCBtPSswLjEwNjM5NzIwMSIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjgxOTIsInAycyI6IkQ5ejBLeVBBeXgxM2VQZHMifQ.x4LuU8gT8PnYB2o_dllZ2bsM-xE0Vomlj5FMjWo4nN74JZIpYRXs5A.isHl5ElK_j1pl5bl.-wPoBTJ_JCszgV1MetbTdzPDKfg9PRNQZe_1kf-l9jtbAaCLoQg3-01_VdlxaNKFzxdHSN6eQoIImNSMiqIUMjwOSWiYzcfzvNq5hqBbjGnkxHlp_16b_IHq1E-ccGvIkheuj90KAv7KWtwdPPhkpL0AKh7dbJ5idaQ3iLCw63idc082CAzkpb6YUpBKx4NMLhhnvJnNnQSu5MLojIYoDSpl6DT5Lyp7PuIi53WvgZCwrg.riAAY3L2Xhg-kntgiJyQYQ \ No newline at end of file diff --git a/network/relayer/keys/osmo-test-4/keyring-test/osmo.info b/network/relayer/keys/osmo-test-4/keyring-test/osmo.info deleted file mode 100644 index 0acb13c6..00000000 --- a/network/relayer/keys/osmo-test-4/keyring-test/osmo.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMi0wNy0zMSAyMzoxMjoyNy44NDQ5MzE5IC0wNTAwIENEVCBtPSswLjEwMDkyNzQwMSIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjgxOTIsInAycyI6IkdhTkRhQjc4T3ROQm9vU1IifQ.p58Plg61t4OrH7v8JDhYzXsC08ZhySir2tQqlEXq7TOludMf1wptjw._Ov7er6vSAt3JtA8.EbYAYgYaR-iSoV7EBCW_id8TvXBEYW__iuTPjNjaOOY1yZFnHAKTEfWdJoQNFx8GOvsXPuntl_Fpv9Ukf4zfnQvwcXNuKPlIbuB9dumAVdw8-upqi_dwvxeapU_3IllhiHfqr9WlxM0C-l-_xNsNZ2DfU2u8UmN9Dy_i8ikr2sQhQgzJ4ftcx3I9JJ4T-zALXL12TeX68reM0Kq9aZBERaUS-ULnyOGsfeHaZEYSZHBgBfnXCMXArQxkqOYdC-VeI37JbtRHs2ANSdlcSCk6JndRWLr-NuD9K-Sup57UVhLVjoMuhSqzCaXTA9sIc3aVrb3tH1KpZVv5XCDB_6irbj4WwVg63Pk.bQ8TUag4ldP3eAh0HpKVqQ \ No newline at end of file diff --git a/network/start.sh b/network/start.sh index 432b9cbf..31e7e29a 100755 --- a/network/start.sh +++ b/network/start.sh @@ -6,4 +6,4 @@ CHAINID_1=defund echo "Starting $CHAINID_1 in $CHAIN_DIR..." echo "Creating log file at $CHAIN_DIR/$CHAINID_1.log" -$BINARY start --log_level trace --log_format json --home $CHAIN_DIR/$CHAINID_1 --pruning=nothing > $CHAIN_DIR/$CHAINID_1.log 2>&1 & \ No newline at end of file +$BINARY start --log_level debug --log_format json --home $CHAIN_DIR/$CHAINID_1 --pruning=nothing > $CHAIN_DIR/$CHAINID_1.log 2>&1 & \ No newline at end of file diff --git a/network/ts-relayer/install.sh b/network/ts-relayer/install.sh index a883d7ae..a318599a 100755 --- a/network/ts-relayer/install.sh +++ b/network/ts-relayer/install.sh @@ -2,5 +2,7 @@ cd $HOME git clone https://github.com/defund-labs/ts-relayer -cd ts-relayer && npm run build --location=global +cd ts-relayer +npm install +npm run build --location=global npm link \ No newline at end of file diff --git a/proto/broker/genesis.proto b/proto/broker/genesis.proto index 58e0dab8..ea77d7db 100644 --- a/proto/broker/genesis.proto +++ b/proto/broker/genesis.proto @@ -4,11 +4,13 @@ package defundlabs.defund.broker; // this line is used by starport scaffolding # genesis/proto/import import "gogoproto/gogo.proto"; import "broker/broker.proto"; +import "broker/params.proto"; option go_package = "github.com/defund-labs/defund/x/broker/types"; // GenesisState defines the broker module's genesis state. message GenesisState { repeated Broker brokers = 1 [(gogoproto.nullable) = false]; + Params params = 2 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } \ No newline at end of file diff --git a/proto/broker/params.proto b/proto/broker/params.proto new file mode 100644 index 00000000..a2fe251e --- /dev/null +++ b/proto/broker/params.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package defundlabs.defund.broker; + +import "gogoproto/gogo.proto"; +import "ibc/applications/transfer/v1/transfer.proto"; + +option go_package = "github.com/defund-labs/defund/x/broker/types"; + +message BaseDenoms{ + ibc.applications.transfer.v1.DenomTrace AtomTrace = 1; + ibc.applications.transfer.v1.DenomTrace OsmoTrace = 2; +} + +// Params defines the parameters for the broker module. +message Params { + // set the base denoms + BaseDenoms base_denoms = 1; +} \ No newline at end of file diff --git a/proto/etf/fund.proto b/proto/etf/fund.proto index 7e759feb..ff853e3c 100644 --- a/proto/etf/fund.proto +++ b/proto/etf/fund.proto @@ -8,6 +8,11 @@ import "google/protobuf/timestamp.proto"; option go_package = "github.com/defund-labs/defund/x/etf/types"; +message BaseDenom { + string onDefund = 1; + string onBroker = 2; +} + message FundPrice { string id = 1; int64 height = 2; @@ -20,6 +25,10 @@ message FundPrice { string symbol = 5; } +message Balances { + repeated cosmos.base.v1beta1.Coin balances = 1; +} + message Holding { string token = 1; int64 percent = 2; @@ -45,13 +54,14 @@ message Fund { (gogoproto.nullable) = true ]; int64 rebalance = 7; - string baseDenom = 8; + BaseDenom baseDenom = 8; cosmos.base.v1beta1.Coin startingPrice = 9 [ (gogoproto.moretags) = "yaml:\"starting_price\"", (gogoproto.nullable) = true ]; string creator = 10; int64 lastRebalanceHeight = 11; + map balances = 12; } message Redeem { diff --git a/testnet/private/update_configs.sh b/testnet/private/update_configs.sh new file mode 100755 index 00000000..325b93fd --- /dev/null +++ b/testnet/private/update_configs.sh @@ -0,0 +1,48 @@ +#!/bin/bash +CONFIG_PATH="./network/data/defund/config/config.toml" + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sed -i 's/max_num_inbound_peers =.*/max_num_inbound_peers = 150/g' $CONFIG_PATH + sed -i 's/max_num_outbound_peers =.*/max_num_outbound_peers = 150/g' $CONFIG_PATH + sed -i 's/max_packet_msg_payload_size =.*/max_packet_msg_payload_size = 10240/g' $CONFIG_PATH + sed -i 's/send_rate =.*/send_rate = 20480000/g' $CONFIG_PATH + sed -i 's/recv_rate =.*/recv_rate = 20480000/g' $CONFIG_PATH + sed -i 's/max_txs_bytes =.*/max_txs_bytes = 10737418240/g' $CONFIG_PATH + sed -i 's/^size =.*/size = 5000/g' $CONFIG_PATH + sed -i 's/max_tx_bytes =.*/max_tx_bytes = 2048576/g' $CONFIG_PATH + sed -i 's/timeout_prevote =.*/timeout_prevote = "100ms"/g' $CONFIG_PATH + sed -i 's/timeout_precommit =.*/timeout_precommit = "100ms"/g' $CONFIG_PATH + sed -i 's/timeout_commit =.*/timeout_commit = "100ms"/g' $CONFIG_PATH + sed -i 's/skip_timeout_commit =.*/skip_timeout_commit = true/g' $CONFIG_PATH +elif [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' 's/max_num_inbound_peers =.*/max_num_inbound_peers = 150/g' $CONFIG_PATH + sed -i '' 's/max_num_outbound_peers =.*/max_num_outbound_peers = 150/g' $CONFIG_PATH + sed -i '' 's/max_packet_msg_payload_size =.*/max_packet_msg_payload_size = 10240/g' $CONFIG_PATH + sed -i '' 's/send_rate =.*/send_rate = 20480000/g' $CONFIG_PATH + sed -i '' 's/recv_rate =.*/recv_rate = 20480000/g' $CONFIG_PATH + sed -i '' 's/max_txs_bytes =.*/max_txs_bytes = 10737418240/g' $CONFIG_PATH + sed -i '' 's/^size =.*/size = 5000/g' $CONFIG_PATH + sed -i '' 's/max_tx_bytes =.*/max_tx_bytes = 2048576/g' $CONFIG_PATH + sed -i '' 's/timeout_prevote =.*/timeout_prevote = "100ms"/g' $CONFIG_PATH + sed -i '' 's/timeout_precommit =.*/timeout_precommit = "100ms"/g' $CONFIG_PATH + sed -i '' 's/timeout_commit =.*/timeout_commit = "100ms"/g' $CONFIG_PATH + sed -i '' 's/skip_timeout_commit =.*/skip_timeout_commit = true/g' $CONFIG_PATH +else + printf "Platform not supported, please ensure that the following values are set in your config.toml:\n" + printf "### Mempool Configuration Option ###\n" + printf "\t size = 5000\n" + printf "\t max_txs_bytes = 10737418240\n" + printf "\t max_tx_bytes = 2048576\n" + printf "### P2P Configuration Options ###\n" + printf "\t max_num_inbound_peers = 150\n" + printf "\t max_num_outbound_peers = 150\n" + printf "\t max_packet_msg_payload_size = 10240\n" + printf "\t send_rate = 20480000\n" + printf "\t recv_rate = 20480000\n" + printf "### Consensus Configuration Options ###\n" + printf "\t timeout_prevote = \"100ms\"\n" + printf "\t timeout_precommit = \"100ms\"\n" + printf "\t timeout_commit = \"100ms\"\n" + printf "\t skip_timeout_commit = true\n" + exit 1 +fi \ No newline at end of file diff --git a/tests/etf/create-fund.sh b/tests/etf/create-fund.sh index 3e1756dc..54af929a 100755 --- a/tests/etf/create-fund.sh +++ b/tests/etf/create-fund.sh @@ -1,3 +1,3 @@ #!/bin/bash -defundd tx etf create-fund test test test "uosmo" "osmosis" "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2:33:osmosis:1,uosmo:34:osmosis:1,ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4:33:osmosis:4" 6 5000000 --from defund --keyring-backend test --home ./network/data/defund --gas auto -y +defundd tx etf create-fund test test test "uosmo" "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2:33:osmosis:1:spot,uosmo:34:osmosis:1:spot,ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4:33:osmosis:4:spot" 100 5000000 --from demowallet1 --keyring-backend test --home ./network/data/defund --gas auto -y diff --git a/testutil/keeper/broker.go b/testutil/keeper/broker.go index ea4d28a5..c3a18f91 100644 --- a/testutil/keeper/broker.go +++ b/testutil/keeper/broker.go @@ -41,6 +41,7 @@ func BrokerKeeper(db *dbm.MemDB, t testing.TB) (*keeper.Keeper, sdk.Context) { k := keeper.NewKeeper( codec.NewProtoCodec(registry), storeKey, + a.GetSubspace(types.ModuleName), a.ICAControllerKeeper, scopedBrokerKeeper, a.TransferKeeper, diff --git a/testutil/keeper/etf.go b/testutil/keeper/etf.go index e3b1d8c1..f90ddeb6 100644 --- a/testutil/keeper/etf.go +++ b/testutil/keeper/etf.go @@ -13,6 +13,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + icacontrollerkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/keeper" + icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types" "github.com/defund-labs/defund/app" "github.com/defund-labs/defund/x/etf/keeper" "github.com/defund-labs/defund/x/etf/types" @@ -31,11 +33,13 @@ func EtfKeeper(db *dbm.MemDB, t testing.TB) (*keeper.Keeper, sdk.Context) { storeKey := sdk.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) storeKeyAcc := sdk.NewKVStoreKey(authtypes.StoreKey) + storeKeyIcaC := sdk.NewKVStoreKey(icacontrollertypes.StoreKey) stateStore := store.NewCommitMultiStore(db) stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) stateStore.MountStoreWithDB(storeKeyAcc, sdk.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(storeKeyIcaC, sdk.StoreTypeIAVL, db) require.NoError(t, stateStore.LoadLatestVersion()) registry := codectypes.NewInterfaceRegistry() @@ -51,6 +55,12 @@ func EtfKeeper(db *dbm.MemDB, t testing.TB) (*keeper.Keeper, sdk.Context) { a.AccountKeeper = authkeeper.NewAccountKeeper( codec.NewProtoCodec(registry), storeKeyAcc, a.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, ) + a.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( + codec.NewProtoCodec(registry), storeKeyIcaC, a.GetSubspace(icacontrollertypes.SubModuleName), + a.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee + a.IBCKeeper.ChannelKeeper, &a.IBCKeeper.PortKeeper, + a.ScopedICAControllerKeeper, a.MsgServiceRouter(), + ) k := keeper.NewKeeper( codec.NewProtoCodec(registry), diff --git a/vue/.env b/vue/.env index 8c58c743..b1298fc0 100644 --- a/vue/.env +++ b/vue/.env @@ -1,6 +1,6 @@ VUE_APP_ADDRESS_PREFIX="defund" -VUE_APP_API_COSMOS="https://api-1.defund.nodes.guru" -VUE_APP_API_TENDERMINT="https://rpc-1.defund.nodes.guru" -VUE_APP_WS_TENDERMINT="wss://rpc-1.defund.nodes.guru/websocket" +VUE_APP_API_COSMOS="http://localhost:26657" +VUE_APP_API_TENDERMINT="http://localhost:1317" +VUE_APP_WS_TENDERMINT="ws://localhost:26657/websocket" VUE_APP_DEFUND_USERS_API="https://users.defund.app/users/" VUE_APP_DEFUND_FAUCET_API="https://faucet.defund.app" \ No newline at end of file diff --git a/vue/package-lock.json b/vue/package-lock.json index c9013362..c7f777ff 100644 --- a/vue/package-lock.json +++ b/vue/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@starport/template", + "name": "defundfrontend", "version": "0.3.5", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@starport/template", + "name": "defundfrontend", "version": "0.3.5", "hasInstallScript": true, "dependencies": { @@ -19,6 +19,7 @@ "axios": "^0.27.2", "buffer": "^6.0.3", "core-js": "^3.18.2", + "defund-labs-defund-client-ts": "file:../ts-client", "dotenv": "^16.0.1", "firebase": "^9.8.2", "flat": "^5.0.2", @@ -48,6 +49,22 @@ "vite-plugin-env-compatible": "^1.1.1" } }, + "../ts-client": { + "name": "defund-labs-defund-client-ts", + "version": "0.0.1", + "license": "Apache-2.0", + "dependencies": { + "@cosmjs/launchpad": "0.27.0", + "@cosmjs/proto-signing": "0.27.0", + "@cosmjs/stargate": "0.27.0", + "buffer": "^6.0.3" + }, + "peerDependencies": { + "@cosmjs/launchpad": "0.27.0", + "@cosmjs/proto-signing": "0.27.0", + "@cosmjs/stargate": "0.27.0" + } + }, "node_modules/@babel/parser": { "version": "7.17.9", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.9.tgz", @@ -2341,6 +2358,10 @@ "node": ">= 0.4" } }, + "node_modules/defund-labs-defund-client-ts": { + "resolved": "../ts-client", + "link": true + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -6855,6 +6876,15 @@ "object-keys": "^1.0.12" } }, + "defund-labs-defund-client-ts": { + "version": "file:../ts-client", + "requires": { + "@cosmjs/launchpad": "0.27.0", + "@cosmjs/proto-signing": "0.27.0", + "@cosmjs/stargate": "0.27.0", + "buffer": "^6.0.3" + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", diff --git a/vue/package.json b/vue/package.json index f329e1af..2d51712b 100644 --- a/vue/package.json +++ b/vue/package.json @@ -1,5 +1,5 @@ { - "author": "Tendermint, Inc \u003chello@tendermint.com\u003e", + "author": "Defund Labs", "dependencies": { "@cosmjs/launchpad": "0.27.0", "@cosmjs/proto-signing": "0.27.0", @@ -28,7 +28,7 @@ "vuetify": "^3.0.0-beta.1", "vuex": "^4.0.2" }, - "description": "A Vue 3 boilerplate project utilizing @starport/vue and @starport/vuex", + "description": "Defund Labs HQ Web App", "devDependencies": { "@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-dynamic-import-vars": "^1.4.1", @@ -41,8 +41,8 @@ "vite-plugin-dynamic-import": "^0.1.1", "vite-plugin-env-compatible": "^1.1.1" }, - "name": "@starport/template", - "private": true, + "name": "defundfrontend", + "private": false, "scripts": { "build": "vite build", "dev": "vite", diff --git a/vue/src/App.vue b/vue/src/App.vue index c1eb8032..61dbe486 100644 --- a/vue/src/App.vue +++ b/vue/src/App.vue @@ -1,7 +1,6 @@