diff --git a/Makefile b/Makefile index f7830eb85..e51cc86bc 100755 --- a/Makefile +++ b/Makefile @@ -329,6 +329,20 @@ localnet-stop: rm -rf build/node* rm -rf build/gentxs +localnet-keys: + . scripts/localterra/scripts/add_keys.sh + +localnet-init: localnet-clean localnet-build + +localnet-clean: + @rm -rfI $(HOME)/.terrad-local/ + +localnet-build: + @DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f scripts/localterra/docker-compose.yml build + +localnet-starts: + @STATE="" docker-compose -f scripts/localterra/docker-compose.yml up + .PHONY: localnet-start localnet-stop ############################################################################### diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 5abaf6abd..6b68bb289 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -3,6 +3,7 @@ package keepers import ( "path/filepath" + forward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router" forwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/keeper" forwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/types" icacontrollerkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/keeper" @@ -108,6 +109,7 @@ type AppKeepers struct { Ics20WasmHooks *ibchooks.WasmHooks IBCHooksWrapper *ibchooks.ICS4Middleware TransferStack ibctransfer.IBCModule + ForwardModule forward.AppModule // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -375,7 +377,7 @@ func NewAppKeepers( appCodec, appKeepers.keys[ibctransfertypes.StoreKey], appKeepers.GetSubspace(ibctransfertypes.ModuleName), - appKeepers.IBCHooksWrapper, + &appKeepers.ForwardKeeper, appKeepers.IBCKeeper.ChannelKeeper, &appKeepers.IBCKeeper.PortKeeper, appKeepers.AccountKeeper, @@ -383,6 +385,8 @@ func NewAppKeepers( scopedTransferKeeper, ) + appKeepers.ForwardKeeper.SetTransferKeeper(appKeepers.TransferKeeper) + wasmConfig, err := wasm.ReadWasmConfig(appOpts) if err != nil { panic("error while reading wasm config: " + err.Error()) @@ -471,6 +475,7 @@ func NewAppKeepers( appKeepers.ScopedIBCFeeKeeper = scopedIBCFeeKeeper appKeepers.ScopedWasmKeeper = scopedWasmKeeper + appKeepers.ForwardModule = forward.NewAppModule(&appKeepers.ForwardKeeper) // Create static IBC router, add transfer route, then set and seal it ibcRouter := appKeepers.newIBCRouter() appKeepers.IBCKeeper.SetRouter(ibcRouter) @@ -505,6 +510,7 @@ func initParamsKeeper( paramsKeeper.Subspace(wasmtypes.ModuleName) paramsKeeper.Subspace(dyncommtypes.ModuleName) paramsKeeper.Subspace(ibchooktypes.ModuleName) + paramsKeeper.Subspace(forwardtypes.ModuleName).WithKeyTable(forwardtypes.ParamKeyTable()) return paramsKeeper } diff --git a/app/modules.go b/app/modules.go index ccce4c13c..4f75f86af 100644 --- a/app/modules.go +++ b/app/modules.go @@ -45,6 +45,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + forward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router" + forwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/router/types" terraappparams "github.com/classic-terra/core/v2/app/params" @@ -117,6 +119,7 @@ var ( customfeegrant.AppModuleBasic{}, ibc.AppModuleBasic{}, ica.AppModuleBasic{}, + forward.AppModuleBasic{}, customupgrade.AppModuleBasic{}, customevidence.AppModuleBasic{}, transfer.AppModuleBasic{}, @@ -192,6 +195,7 @@ func appModules( wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), dyncomm.NewAppModule(appCodec, app.DyncommKeeper, app.StakingKeeper), ibchooks.NewAppModule(app.AccountKeeper), + app.ForwardModule, } } @@ -224,6 +228,7 @@ func simulationModules( treasury.NewAppModule(appCodec, app.TreasuryKeeper), wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), dyncomm.NewAppModule(appCodec, app.DyncommKeeper, app.StakingKeeper), + app.ForwardModule, } } @@ -248,6 +253,7 @@ func orderBeginBlockers() []string { ibchost.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, + forwardtypes.ModuleName, ibcfeetypes.ModuleName, ibchooktypes.ModuleName, // Terra Classic modules @@ -280,6 +286,7 @@ func orderEndBlockers() []string { ibchost.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, + forwardtypes.ModuleName, ibcfeetypes.ModuleName, ibchooktypes.ModuleName, // Terra Classic modules @@ -312,6 +319,7 @@ func orderInitGenesis() []string { ibchost.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, + forwardtypes.ModuleName, ibcfeetypes.ModuleName, ibchooktypes.ModuleName, // Terra Classic modules diff --git a/go.mod b/go.mod index 6cb7a7f92..19bc2e834 100644 --- a/go.mod +++ b/go.mod @@ -125,6 +125,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/runc v1.1.5 // indirect github.com/pelletier/go-toml/v2 v2.0.7 // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index aa79c8997..c7e1078fa 100644 --- a/go.sum +++ b/go.sum @@ -319,6 +319,7 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= @@ -329,6 +330,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/classic-terra/cometbft v0.34.29-terra.0 h1:HnRGt7tijI2n5zSVrg/xh1mYYm4Gb4QFlknq+dRP8Jw= @@ -368,11 +370,13 @@ github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/ github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= +github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= @@ -406,6 +410,7 @@ github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= +github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= @@ -442,6 +447,7 @@ github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m3 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= @@ -480,6 +486,7 @@ github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -536,6 +543,7 @@ github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= @@ -894,6 +902,7 @@ github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -902,6 +911,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= @@ -941,7 +951,10 @@ github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWEr github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= -github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= +github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= +github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= +github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1049,6 +1062,7 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= @@ -1059,6 +1073,7 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= @@ -1110,6 +1125,7 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= @@ -1149,6 +1165,8 @@ github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/X github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= +github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= @@ -1394,6 +1412,7 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1403,6 +1422,7 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1459,9 +1479,12 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/local.Dockerfile b/local.Dockerfile new file mode 100644 index 000000000..e1f06ac64 --- /dev/null +++ b/local.Dockerfile @@ -0,0 +1,45 @@ +FROM golang:1.20 AS go-builder + +ARG BUILDPLATFORM + +# Install minimum necessary dependencies, build Cosmos SDK, remove packages +RUN apt update +RUN apt install -y curl git build-essential +# debug: for live editting in the image +RUN apt install -y vim + +WORKDIR /code +COPY . /code/ + +RUN LEDGER_ENABLED=false make build + +RUN if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \ + WASMVM_URL="libwasmvm.x86_64.so"; \ + elif [ ${BUILDPLATFORM} = "linux/arm64" ]; then \ + WASMVM_URL="libwasmvm.aarch64.so"; \ + else \ + echo "Unsupported Build Platfrom ${BUILDPLATFORM}"; \ + exit 1; \ + fi; \ + cp /go/pkg/mod/github.com/classic-terra/wasmvm@v*/internal/api/${WASMVM_URL} /lib/${WASMVM_URL} + +FROM ubuntu:23.04 + +COPY --from=go-builder /code/build/terrad /usr/local/bin/terrad +COPY --from=go-builder /lib/${WASMVM_URL} /lib/${WASMVM_URL} + +RUN apt-get update \ + && apt-get install -y wget \ + && rm -rf /var/lib/apt/lists/* + +ENV HOME /terra +WORKDIR $HOME + +# rest server +EXPOSE 1317 +# grpc +EXPOSE 9090 +# tendermint p2p +EXPOSE 26656 +# tendermint rpc +EXPOSE 26657 diff --git a/scripts/localrelayer/Makefile b/scripts/localrelayer/Makefile new file mode 100644 index 000000000..511a88e34 --- /dev/null +++ b/scripts/localrelayer/Makefile @@ -0,0 +1,24 @@ +init: clean build + +build: + @DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f docker-compose.yml build + +start: + @docker-compose -f docker-compose.yml up + +startd: + @docker-compose -f docker-compose.yml up -d + +stop: + @docker-compose -f docker-compose.yml down -t 3 + +restart: stop + @docker-compose -f docker-compose.yml up --force-recreate + +restartd: stop + @docker-compose -f docker-compose.yml up --force-recreate -d + +clean: + @rm -rfI $(HOME)/.terrad-local-a/ + @rm -rfI $(HOME)/.terrad-local-b/ + @rm -rfI $(HOME)/.terrad-local-c/ diff --git a/scripts/localrelayer/README.md b/scripts/localrelayer/README.md new file mode 100644 index 000000000..72269cf29 --- /dev/null +++ b/scripts/localrelayer/README.md @@ -0,0 +1,173 @@ +# Localrelayer + +Localrelayer is a local testing environment composed of two LocalTerra instances connected by a relayer. + +![Architecture](./assets/architecture.png) + +## Endpoints + +| Chain ID | Component | Endpoint | +|------------------|------------|--------------------------| +| `localterra-a` | `RPC` | | +| `localterra-a` | `REST/LCD` | | +| `localterra-a` | `gRPC` | | +| `localterra-b` | `RPC` | | +| `localterra-b` | `REST/LCD` | | +| `localterra-b` | `gRPC` | | +| `-` | `hermes` | | + +## Accounts + +By default the following mnemonics are used: + +| Chain ID | Account | Mnemonic | +|------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `localterra-a` | `validator-a` | *family album bird seek tilt color pill danger message abuse manual tent almost ridge boost blast high comic core quantum spoon coconut oyster remove* | +| `localterra-a` | `relayer` | *black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken* | +| `localterra-b` | `validator-b` | *family album bird seek tilt color pill danger message abuse manual tent almost ridge boost blast high comic core quantum spoon coconut oyster remove* | +| `localterra-b` | `relayer` | *black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken* | + + +## Deploy + +Build a local docker image with current changes + +```bash +make build +``` + +Start the testing environment: + +```bash +make start +``` + +The command will: + +1. create a local docker network: + +```bash + ⠿ Network localrelayer_localterra Created +``` + +2. run the following containers: + +```bash + ⠿ Container localrelayer-localterra-b-1 Created + ⠿ Container localrelayer-localterra-a-1 Created + ⠿ Container localrelayer-hermes-1 Created +``` + +> If you don't want the logs, you can start in detached mode with the following command: +> +> `make startd` + +Check that everything is running: + +```bash +docker ps +``` + +Expected output: + +```bash +❯ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +318c89d3015f informalsystems/hermes:1.1.0 "/home/hermes/setup.…" About a minute ago Up 2 seconds 0.0.0.0:3000->3000/tcp localrelayer-hermes-1 +d90ec29c7a6f local:terra "/terra/setup.sh" About a minute ago Up 3 seconds 26656/tcp, 0.0.0.0:31317->1317/tcp, 0.0.0.0:39090->9090/tcp, 0.0.0.0:36657->26657/tcp localrelayer-localterra-b-1 +e36cead49a07 local:terra "/terra/setup.sh" About a minute ago Up 3 seconds 0.0.0.0:1317->1317/tcp, 0.0.0.0:9090->9090/tcp, 0.0.0.0:26657->26657/tcp, 26656/tcp localrelayer-localterra-a-1 +``` + +## Usage + +### Interact with chain + +Check `localterra-a` status: + +```bash +curl -s http://localhost:26657/status +``` + +Check `localterra-b` status: + +```bash +curl -s http://localhost:36657/status +``` + +### Hermes + +You can test that hermes is working by sending a test IBC transaction. + +Make sure `hermes` is running: + +```bash +❯ docker ps | grep hermes +``` + +Expected output: + +```bash +318c89d3015f informalsystems/hermes:1.1.0 "/home/hermes/setup.…" 23 minutes ago Up 22 minutes 0.0.0.0:3000->3000/tcp +``` + +Exec inside the container: + +```bash +docker exec -ti localrelayer-hermes-1 sh +``` + +Send a transaction: + +```bash +hermes tx ft-transfer --timeout-seconds 1000 \ + --dst-chain localterra-a \ + --src-chain localterra-b \ + --src-port transfer \ + --src-channel channel-0 \ + --amount 100 \ + --denom uluna +``` + +Expected output: + +```bash +2022-12-01T11:41:22.351909Z INFO ThreadId(01) using default configuration from '/root/.hermes/config.toml' +SUCCESS [ + IbcEventWithHeight { + event: SendPacket( + SendPacket { + packet: Packet { + sequence: Sequence( + 1, + ), + source_port: PortId( + "transfer", + ), + source_channel: ChannelId( + "channel-0", + ), + destination_port: PortId( + "transfer", + ), + destination_channel: ChannelId( + "channel-0", + ), + data: [123, 34, 97, 109, 111, 117, 110, 116, 34, 58, 34, 49, 48, 48, 34, 44, 34, 100, 101, 110, 111, 109, 34, 58, 34, 117, 111, 115, 109, 111, 34, 44, 34, 114, 101, 99, 101, 105, 118, 101, 114, 34, 58, 34, 111, 115, 109, 111, 49, 113, 118, 100, 101, 117, 52, 120, 51, 52, 114, 97, 112, 112, 51, 119, 99, 56, 102, 121, 109, 53, 103, 52, 119, 117, 51, 52, 51, 109, 115, 119, 120, 50, 101, 120, 107, 117, 103, 34, 44, 34, 115, 101, 110, 100, 101, 114, 34, 58, 34, 111, 115, 109, 111, 49, 113, 118, 100, 101, 117, 52, 120, 51, 52, 114, 97, 112, 112, 51, 119, 99, 56, 102, 121, 109, 53, 103, 52, 119, 117, 51, 52, 51, 109, 115, 119, 120, 50, 101, 120, 107, 117, 103, 34, 125], + timeout_height: Never, + timeout_timestamp: Timestamp { + time: Some( + Time( + 2022-12-01 11:57:59.365129852, + ), + ), + }, + }, + }, + ), + height: Height { + revision: 0, + height: 1607, + }, + }, +] +``` diff --git a/scripts/localrelayer/config/hermes/config.toml b/scripts/localrelayer/config/hermes/config.toml new file mode 100644 index 000000000..2e98de33e --- /dev/null +++ b/scripts/localrelayer/config/hermes/config.toml @@ -0,0 +1,146 @@ +[global] +log_level = 'info' + +[mode.clients] +enabled = true +refresh = true +misbehaviour = true + +[mode.connections] +enabled = true + +[mode.channels] +enabled = true + +[mode.packets] +enabled = true +clear_interval = 100 +clear_on_start = true +tx_confirmation = true + +[rest] +enabled = true +host = '0.0.0.0' +port = 3000 + +[telemetry] +enabled = true +host = '0.0.0.0' +port = 3001 + +[[chains]] +id = 'localterra-b' +type = 'CosmosSdk' +rpc_addr = 'http://localterra-b:26657' +grpc_addr = 'http://localterra-b:9090' +websocket_addr = 'ws://localterra-b:26657/websocket' +rpc_timeout = '10s' +account_prefix = 'terra' +key_name = 'localterra-b' +key_store_type = 'Test' +store_prefix = 'ibc' +default_gas = 100000 +max_gas = 4000000 +gas_multiplier = 1.1 +max_msg_num = 30 +max_tx_size = 2097152 +clock_drift = '5s' +max_block_time = '30s' +memo_prefix = '' +sequential_batch_tx = false + +[chains.trust_threshold] +numerator = '1' +denominator = '3' + +[chains.gas_price] +price = 0.1 +denom = 'uluna' + +[chains.packet_filter] +policy = 'allow' +list = [[ + 'transfer', + 'channel-*', +]] + +[chains.address_type] +derivation = 'cosmos' + +[[chains]] +id = 'localterra-c' +type = 'CosmosSdk' +rpc_addr = 'http://localterra-c:26657' +grpc_addr = 'http://localterra-c:9090' +websocket_addr = 'ws://localterra-c:26657/websocket' +rpc_timeout = '10s' +account_prefix = 'terra' +key_name = 'localterra-c' +key_store_type = 'Test' +store_prefix = 'ibc' +default_gas = 100000 +max_gas = 4000000 +gas_multiplier = 1.1 +max_msg_num = 30 +max_tx_size = 2097152 +clock_drift = '5s' +max_block_time = '30s' +memo_prefix = '' +sequential_batch_tx = false + +[chains.trust_threshold] +numerator = '1' +denominator = '3' + +[chains.gas_price] +price = 0.1 +denom = 'uluna' + +[chains.packet_filter] +policy = 'allow' +list = [[ + 'transfer', + 'channel-*', +]] + +[chains.address_type] +derivation = 'cosmos' + +[[chains]] +id = 'localterra-a' +type = 'CosmosSdk' +rpc_addr = 'http://localterra-a:26657' +grpc_addr = 'http://localterra-a:9090' +websocket_addr = 'ws://localterra-a:26657/websocket' +rpc_timeout = '10s' +account_prefix = 'terra' +key_name = 'localterra-a' +key_store_type = 'Test' +store_prefix = 'ibc' +default_gas = 100000 +max_gas = 400000 +gas_multiplier = 1.1 +max_msg_num = 30 +max_tx_size = 2097152 +clock_drift = '5s' +max_block_time = '30s' +memo_prefix = '' +sequential_batch_tx = false + +[chains.trust_threshold] +numerator = '1' +denominator = '3' + +[chains.gas_price] +price = 0.1 +denom = 'uluna' + +[chains.packet_filter] +policy = 'allow' +list = [[ + 'transfer', + 'channel-*', +]] + +[chains.address_type] +derivation = 'cosmos' diff --git a/scripts/localrelayer/docker-compose.yml b/scripts/localrelayer/docker-compose.yml new file mode 100644 index 000000000..497a52b69 --- /dev/null +++ b/scripts/localrelayer/docker-compose.yml @@ -0,0 +1,100 @@ +version: "3" + +services: + localterra-a: + image: local:terra + build: + context: ../../ + dockerfile: local.Dockerfile + volumes: + - ./scripts/setup_chain.sh:/terra/setup.sh + - $HOME/.terrad-local-a/:/terra/.terrad/ + entrypoint: + - /terra/setup.sh + environment: + - CHAIN_ID=localterra-a + - VALIDATOR_MONIKER=validator-a + - VALIDATOR_MNEMONIC=family album bird seek tilt color pill danger message abuse manual tent almost ridge boost blast high comic core quantum spoon coconut oyster remove + - FAUCET_MNEMONIC=increase bread alpha rigid glide amused approve oblige print asset idea enact lawn proof unfold jeans rabbit audit return chuckle valve rather cactus great + - RELAYER_MNEMONIC=black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken + ports: + - 26657:26657 + - 1317:1317 + - 9090:9090 + networks: + - localterra + + localterra-b: + image: local:terra + build: + context: ../../ + dockerfile: local.Dockerfile + volumes: + - ./scripts/setup_chain.sh:/terra/setup.sh + - $HOME/.terrad-local-b/:/terra/.terrad/ + entrypoint: + - /terra/setup.sh + environment: + - CHAIN_ID=localterra-b + - VALIDATOR_MONIKER=validator-b + - VALIDATOR_MNEMONIC=family album bird seek tilt color pill danger message abuse manual tent almost ridge boost blast high comic core quantum spoon coconut oyster remove + - FAUCET_MNEMONIC=increase bread alpha rigid glide amused approve oblige print asset idea enact lawn proof unfold jeans rabbit audit return chuckle valve rather cactus great + - RELAYER_MNEMONIC=black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken + ports: + # Can't use the same ports + - 36657:26657 + - 31317:1317 + - 39090:9090 + networks: + - localterra + + localterra-c: + image: local:terra + build: + context: ../../ + dockerfile: local.Dockerfile + volumes: + - ./scripts/setup_chain.sh:/terra/setup.sh + - $HOME/.terrad-local-c/:/terra/.terrad/ + entrypoint: + - /terra/setup.sh + environment: + - CHAIN_ID=localterra-c + - VALIDATOR_MONIKER=validator-c + - VALIDATOR_MNEMONIC=family album bird seek tilt color pill danger message abuse manual tent almost ridge boost blast high comic core quantum spoon coconut oyster remove + - FAUCET_MNEMONIC=increase bread alpha rigid glide amused approve oblige print asset idea enact lawn proof unfold jeans rabbit audit return chuckle valve rather cactus great + - RELAYER_MNEMONIC=black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken + ports: + # Can't use the same ports + - 46657:26657 + - 41317:1317 + - 49090:9090 + networks: + - localterra + + hermes: + image: informalsystems/hermes:1.1.0 + user: root:root + volumes: + - ./scripts/setup_hermes.sh:/home/hermes/setup.sh + - ./config/hermes/config.toml:/root/.hermes/config.toml + entrypoint: + - /home/hermes/setup.sh + environment: + - CHAIN_A_ID=localterra-a + - CHAIN_A_MNEMONIC=black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken + - CHAIN_B_ID=localterra-b + - CHAIN_B_MNEMONIC=black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken + - CHAIN_C_ID=localterra-c + - CHAIN_C_MNEMONIC=black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken + ports: + - 3000:3000 + depends_on: + - localterra-a + - localterra-b + - localterra-c + networks: + - localterra + +networks: + localterra: diff --git a/scripts/localrelayer/scripts/setup_chain.sh b/scripts/localrelayer/scripts/setup_chain.sh new file mode 100755 index 000000000..99c31342d --- /dev/null +++ b/scripts/localrelayer/scripts/setup_chain.sh @@ -0,0 +1,91 @@ +#!/bin/sh +set -e pipefail + +DEFAULT_CHAIN_ID="localterra" +DEFAULT_VALIDATOR_MONIKER="validator" +DEFAULT_VALIDATOR_MNEMONIC="bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort" +DEFAULT_FAUCET_MNEMONIC="increase bread alpha rigid glide amused approve oblige print asset idea enact lawn proof unfold jeans rabbit audit return chuckle valve rather cactus great" +DEFAULT_RELAYER_MNEMONIC="black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken" + +# Override default values with environment variables +CHAIN_ID=${CHAIN_ID:-$DEFAULT_CHAIN_ID} +VALIDATOR_MONIKER=${VALIDATOR_MONIKER:-$DEFAULT_VALIDATOR_MONIKER} +VALIDATOR_MNEMONIC=${VALIDATOR_MNEMONIC:-$DEFAULT_VALIDATOR_MNEMONIC} +FAUCET_MNEMONIC=${FAUCET_MNEMONIC:-$DEFAULT_FAUCET_MNEMONIC} +RELAYER_MNEMONIC=${RELAYER_MNEMONIC:-$DEFAULT_RELAYER_MNEMONIC} + +TERRA_HOME=$HOME/.terrad +CONFIG_FOLDER=$TERRA_HOME/config + +install_prerequisites () { + wget -qO /usr/local/bin/dasel https://github.com/TomWright/dasel/releases/latest/download/dasel_linux_amd64 + chmod a+x /usr/local/bin/dasel + dasel --version +} + +edit_genesis () { + + GENESIS=$CONFIG_FOLDER/genesis.json + + # Update staking module + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.staking.params.bond_denom' + + # Update crisis module + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.crisis.constant_fee.denom' + + # Udpate gov module + dasel put -t string -f $GENESIS -v '60s' '.app_state.gov.voting_params.voting_period' + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.gov.deposit_params.min_deposit.[0].denom' + + # Update mint module + dasel put -t string -f $GENESIS -v "uluna" '.app_state.mint.params.mint_denom' + + # Update txfee basedenom + dasel put -t string -f $GENESIS -v "uluna" '.app_state.txfees.basedenom' + + # Update wasm permission (Nobody or Everybody) + dasel put -t string -f $GENESIS -v "Everybody" '.app_state.wasm.params.code_upload_access.permission' +} + +add_genesis_accounts () { + + # Validator + echo "⚖️ Add validator account" + echo $VALIDATOR_MNEMONIC | terrad keys add $VALIDATOR_MONIKER --recover --keyring-backend=test --home $TERRA_HOME + VALIDATOR_ACCOUNT=$(terrad keys show -a $VALIDATOR_MONIKER --keyring-backend test --home $TERRA_HOME) + terrad add-genesis-account $VALIDATOR_ACCOUNT 100000000000uluna,100000000000stake --home $TERRA_HOME + + # Faucet + echo "🚰 Add faucet account" + echo $FAUCET_MNEMONIC | terrad keys add faucet --recover --keyring-backend=test --home $TERRA_HOME + FAUCET_ACCOUNT=$(terrad keys show -a faucet --keyring-backend test --home $TERRA_HOME) + terrad add-genesis-account $FAUCET_ACCOUNT 100000000000uluna,100000000000stake --home $TERRA_HOME + + # Relayer + echo "🔗 Add relayer account" + echo $RELAYER_MNEMONIC | terrad keys add relayer --recover --keyring-backend=test --home $TERRA_HOME + RELAYER_ACCOUNT=$(terrad keys show -a relayer --keyring-backend test --home $TERRA_HOME) + terrad add-genesis-account $RELAYER_ACCOUNT 1000000000uluna,1000000000stake --home $TERRA_HOME + + terrad gentx $VALIDATOR_MONIKER 500000000uluna --keyring-backend=test --chain-id=$CHAIN_ID --home $TERRA_HOME + terrad collect-gentxs --home $TERRA_HOME +} + +edit_config () { + # Remove seeds + dasel put -t string -f $CONFIG_FOLDER/config.toml -v '' '.p2p.seeds' + + # Expose the rpc + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "tcp://0.0.0.0:26657" '.rpc.laddr' +} + +install_prerequisites +echo "Creating Terra home for $VALIDATOR_MONIKER" +echo $VALIDATOR_MNEMONIC | terrad init -o --chain-id=$CHAIN_ID --home $TERRA_HOME --recover $VALIDATOR_MONIKER +edit_genesis +add_genesis_accounts +edit_config + + +echo "🏁 Starting $CHAIN_ID..." +terrad start --home $TERRA_HOME diff --git a/scripts/localrelayer/scripts/setup_hermes.sh b/scripts/localrelayer/scripts/setup_hermes.sh new file mode 100755 index 000000000..bd24dc23d --- /dev/null +++ b/scripts/localrelayer/scripts/setup_hermes.sh @@ -0,0 +1,103 @@ +#!/bin/sh +set -e + +DEFAULT_CHAIN_A_ID="localterra-a" +DEFAULT_CHAIN_A_MNEMONIC="black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken" +DEFAULT_CHAIN_B_ID="localterra-b" +DEFAULT_CHAIN_B_MNEMONIC="black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken" +DEFAULT_CHAIN_C_ID="localterra-c" +DEFAULT_CHAIN_C_MNEMONIC="black frequent sponsor nice claim rally hunt suit parent size stumble expire forest avocado mistake agree trend witness lounge shiver image smoke stool chicken" + +CHAIN_A_MNEMONIC=${CHAIN_A_MNEMONIC:-$DEFAULT_CHAIN_A_MNEMONIC} +CHAIN_A_ID=${CHAIN_A_ID:-$DEFAULT_CHAIN_A_ID} +CHAIN_B_MNEMONIC=${CHAIN_B_MNEMONIC:-$DEFAULT_CHAIN_B_MNEMONIC} +CHAIN_B_ID=${CHAIN_B_ID:-$DEFAULT_CHAIN_B_ID} +CHAIN_C_MNEMONIC=${CHAIN_C_MNEMONIC:-$DEFAULT_CHAIN_C_MNEMONIC} +CHAIN_C_ID=${CHAIN_C_ID:-$DEFAULT_CHAIN_C_ID} + +install_prerequisites(){ + echo "🧰 Install prerequisites" + apt update + apt -y install curl +} + +add_keys(){ + + echo "🔑 Adding key for $CHAIN_A_ID" + mkdir -p /home/hermes/mnemonics/ + echo $CHAIN_A_MNEMONIC > /home/hermes/mnemonics/$CHAIN_A_ID + + hermes keys add \ + --hd-path "m/44'/330'/0'/0/0" \ + --chain $CHAIN_A_ID \ + --mnemonic-file /home/hermes/mnemonics/$CHAIN_A_ID \ + --key-name $CHAIN_A_ID \ + --overwrite + + echo "🔑 Adding key for $CHAIN_B_ID" + echo $CHAIN_B_MNEMONIC > /home/hermes/mnemonics/$CHAIN_B_ID + + hermes keys add \ + --hd-path "m/44'/330'/0'/0/0" \ + --chain $CHAIN_B_ID \ + --mnemonic-file /home/hermes/mnemonics/$CHAIN_B_ID \ + --key-name $CHAIN_B_ID \ + --overwrite + + echo "🔑 Adding key for $CHAIN_C_ID" + echo $CHAIN_C_MNEMONIC > /home/hermes/mnemonics/$CHAIN_C_ID + + hermes keys add \ + --hd-path "m/44'/330'/0'/0/0" \ + --chain $CHAIN_C_ID \ + --mnemonic-file /home/hermes/mnemonics/$CHAIN_C_ID \ + --key-name $CHAIN_C_ID \ + --overwrite +} + +create_channel(){ + echo "🥱 Waiting for $CHAIN_A_ID to start" + COUNTER=0 + until $(curl --output /dev/null --silent --head --fail http://$CHAIN_A_ID:26657/status); do + printf '.' + sleep 2 + done + + echo "🥱 Waiting for $CHAIN_B_ID to start" + COUNTER=0 + until $(curl --output /dev/null --silent --head --fail http://$CHAIN_B_ID:26657/status); do + printf '.' + sleep 5 + done + + echo "🥱 Waiting for $CHAIN_C_ID to start" + COUNTER=0 + until $(curl --output /dev/null --silent --head --fail http://$CHAIN_C_ID:26657/status); do + printf '.' + sleep 5 + done + + echo "📺 Creating channel $CHAIN_A_ID <> $CHAIN_B_ID" + hermes create channel \ + --a-chain $CHAIN_A_ID \ + --b-chain $CHAIN_B_ID \ + --a-port transfer \ + --b-port transfer \ + --new-client-connection --yes + + echo "📺 Creating channel $CHAIN_B_ID <> $CHAIN_C_ID" + hermes create channel \ + --a-chain $CHAIN_B_ID \ + --b-chain $CHAIN_C_ID \ + --a-port transfer \ + --b-port transfer \ + --new-client-connection --yes +} + +sleep 10 +install_prerequisites +add_keys +create_channel + +echo "✉️ Start Hermes" +hermes start diff --git a/scripts/localterra/README.md b/scripts/localterra/README.md new file mode 100644 index 000000000..a15b232d5 --- /dev/null +++ b/scripts/localterra/README.md @@ -0,0 +1,74 @@ +# LocalTerra + +LocalTerra is a complete Terra testnet containerized with Docker and orchestrated with a simple docker-compose file. LocalTerra comes preconfigured with opinionated, sensible defaults for a standard testing environment. + +LocalTerra comes in two flavors: + +1. No initial state: brand new testnet with no initial state. +2. With mainnet state: creates a testnet from a mainnet state export + +## Prerequisites + +Ensure you have docker and docker-compose installed: + +```sh +# Docker +sudo apt-get remove docker docker-engine docker.io +sudo apt-get update +sudo apt install docker.io -y + +# Docker compose +sudo apt install docker-compose -y +``` + +## 1. LocalTerra - No Initial State + +The following commands must be executed from the root folder of the Terra repository. + +1. Make any change to the terra code that you want to test + +2. Initialize LocalTerra: + +```bash +make localnet-init +``` + +The command: + +- Builds a local docker image with the latest changes +- Cleans the `$HOME/.terrad-local` folder + +3. Start LocalTerra: + +```bash +make localnet-start +``` + +> Note +> +> You can also start LocalTerra in detach mode with: +> +> `make localnet-startd` + +4. (optional) Add your validator wallet and 9 other preloaded wallets automatically: + +```bash +make localnet-keys +``` + +- These keys are added to your `--keyring-backend test` +- If the keys are already on your keyring, you will get an `"Error: aborted"` +- Ensure you use the name of the account as listed in the table below, as well as ensure you append the `--keyring-backend test` to your txs +- Example: `terrad tx bank send lo-test2 osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks --keyring-backend test --chain-id LocalTerra` + +5. You can stop chain, keeping the state with + +```bash +make localnet-stop +``` + +6. When you are done you can clean up the environment with: + +```bash +make localnet-clean +``` diff --git a/scripts/localterra/docker-compose.yml b/scripts/localterra/docker-compose.yml new file mode 100644 index 000000000..ec91225cd --- /dev/null +++ b/scripts/localterra/docker-compose.yml @@ -0,0 +1,21 @@ +version: "3" + +services: + terrad: + image: local:terra + build: + context: ../../ + dockerfile: local.Dockerfile + volumes: + - ./scripts/setup.sh:/terra/setup.sh + - $HOME/.terrad-local/:/terra/.terrad/ + entrypoint: + - /terra/setup.sh + command: + - $STATE + ports: + - 26657:26657 + - 1317:1317 + - 9090:9090 + - 9091:9091 + - 6060:6060 diff --git a/scripts/localterra/scripts/add_keys.sh b/scripts/localterra/scripts/add_keys.sh new file mode 100755 index 000000000..fc6aa9e72 --- /dev/null +++ b/scripts/localterra/scripts/add_keys.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort" | terrad keys add val --recover --keyring-backend test +echo "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius" | terrad keys add lo-test1 --recover --keyring-backend test +echo "quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty" | terrad keys add lo-test2 --recover --keyring-backend test +echo "symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb" | terrad keys add lo-test3 --recover --keyring-backend test +echo "bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty" | terrad keys add lo-test4 --recover --keyring-backend test +echo "second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal" | terrad keys add lo-test5 --recover --keyring-backend test +echo "spatial forest elevator battle also spoon fun skirt flight initial nasty transfer glory palm drama gossip remove fan joke shove label dune debate quick" | terrad keys add lo-test6 --recover --keyring-backend test +echo "noble width taxi input there patrol clown public spell aunt wish punch moment will misery eight excess arena pen turtle minimum grain vague inmate" | terrad keys add lo-test7 --recover --keyring-backend test +echo "cream sport mango believe inhale text fish rely elegant below earth april wall rug ritual blossom cherry detail length blind digital proof identify ride" | terrad keys add lo-test8 --recover --keyring-backend test +echo "index light average senior silent limit usual local involve delay update rack cause inmate wall render magnet common feature laundry exact casual resource hundred" | terrad keys add lo-test9 --recover --keyring-backend test +echo "prefer forget visit mistake mixture feel eyebrow autumn shop pair address airport diesel street pass vague innocent poem method awful require hurry unhappy shoulder" | terrad keys add lo-test10 --recover --keyring-backend test diff --git a/scripts/localterra/scripts/setup.sh b/scripts/localterra/scripts/setup.sh new file mode 100755 index 000000000..eeaff768b --- /dev/null +++ b/scripts/localterra/scripts/setup.sh @@ -0,0 +1,134 @@ +#!/bin/sh + +CHAIN_ID=localterra +TERRA_HOME=$HOME/.terrad +CONFIG_FOLDER=$TERRA_HOME/config +MONIKER=val +STATE='false' + +MNEMONIC="bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort" +POOLSMNEMONIC="traffic cool olive pottery elegant innocent aisle dial genuine install shy uncle ride federal soon shift flight program cave famous provide cute pole struggle" + +while getopts s flag +do + case "${flag}" in + s) STATE='true';; + esac +done + +install_prerequisites () { + wget -qO /usr/local/bin/dasel https://github.com/TomWright/dasel/releases/latest/download/dasel_linux_amd64 + chmod a+x /usr/local/bin/dasel + dasel --version +} + +edit_genesis () { + + GENESIS=$CONFIG_FOLDER/genesis.json + + # Update staking module + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.staking.params.bond_denom' + + # Update crisis module + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.crisis.constant_fee.denom' + + # Udpate gov module + dasel put -t string -f $GENESIS -v '60s' '.app_state.gov.voting_params.voting_period' + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.gov.deposit_params.min_deposit.[0].denom' + + # Update mint module + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.mint.params.mint_denom' + + # Update txfee basedenom + dasel put -t string -f $GENESIS -v 'uluna' '.app_state.txfees.basedenom' + + # Update wasm permission (Nobody or Everybody) + dasel put -t string -f $GENESIS -v 'Everybody' '.app_state.wasm.params.code_upload_access.permission' +} + +add_genesis_accounts () { + + terrad add-genesis-account terra1a7fgca0746t9kjz079s0m63eqkczfjp3luesac 100000000000uluna --home $TERRA_HOME + # note such large amounts are set for e2e tests on FE + terrad add-genesis-account terra192xhdwsnc44zz0dsnhf7sq7rhmtuklf7nupy53 9999999999999999999999999999999999999999999999999uluna --home $TERRA_HOME + terrad add-genesis-account terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra199vw7724lzkwz6lf2hsx04lrxfkz09tg8dlp6r 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra18wlvftxzj6zt0xugy2lr9nxzu402690ltaf4ss 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra1e8ryd9ezefuucd4mje33zdms9m2s90m57878v9 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra17tv2hvwpg0ukqgd2y5ct2w54fyan7z0zxrm2f9 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra1lkccuqgj6sjwjn8gsa9xlklqv4pmrqg9dx2fxc 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra1333veey879eeqcff8j3gfcgwt8cfrg9mq20v6f 100000000000uluna --home $TERRA_HOME + terrad add-genesis-account terra1fmcjjt6yc9wqup2r06urnrd928jhrde6gcld6n 1000000000000uluna --home $TERRA_HOME + + echo $MNEMONIC | terrad keys add $MONIKER --recover --keyring-backend=test --home $TERRA_HOME + echo $POOLSMNEMONIC | terrad keys add pools --recover --keyring-backend=test --home $TERRA_HOME + terrad gentx $MONIKER 500000000uluna --keyring-backend=test --chain-id=$CHAIN_ID --home $TERRA_HOME + + terrad collect-gentxs --home $TERRA_HOME +} + +edit_config () { + + # Remove seeds + dasel put -t string -f $CONFIG_FOLDER/config.toml -v '' '.p2p.seeds' + + # Expose the rpc + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "tcp://0.0.0.0:26657" '.rpc.laddr' + + # Expose pprof for debugging + # To make the change enabled locally, make sure to add 'EXPOSE 6060' to the root Dockerfile + # and rebuild the image. + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "0.0.0.0:6060" '.rpc.pprof_laddr' +} + +enable_cors () { + + # Enable cors on RPC + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "*" '.rpc.cors_allowed_origins.[]' + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "Accept-Encoding" '.rpc.cors_allowed_headers.[]' + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "DELETE" '.rpc.cors_allowed_methods.[]' + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "OPTIONS" '.rpc.cors_allowed_methods.[]' + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "PATCH" '.rpc.cors_allowed_methods.[]' + dasel put -t string -f $CONFIG_FOLDER/config.toml -v "PUT" '.rpc.cors_allowed_methods.[]' + + # Enable unsafe cors and swagger on the api + dasel put -t bool -f $CONFIG_FOLDER/app.toml -v "true" '.api.swagger' + dasel put -t bool -f $CONFIG_FOLDER/app.toml -v "true" '.api.enabled-unsafe-cors' + + # Enable cors on gRPC Web + dasel put -t bool -f $CONFIG_FOLDER/app.toml -v "true" '.grpc-web.enable-unsafe-cors' +} + +run_with_retries() { + cmd=$1 + success_msg=$2 + + substring='code: 0' + COUNTER=0 + + while [ $COUNTER -lt 15 ]; do + string=$(eval $cmd 2>&1) + echo $string + + if [ "$string" != "${string%"$substring"*}" ]; then + echo "$success_msg" + break + else + COUNTER=$((COUNTER+1)) + sleep 0.5 + fi + done +} + + echo $MNEMONIC | terrad init -o --chain-id=$CHAIN_ID --home $TERRA_HOME --recover $MONIKER + install_prerequisites + edit_genesis + add_genesis_accounts + edit_config + enable_cors + +terrad start --home $TERRA_HOME & + +wait diff --git a/tests/ibc-hooks/bytecode/counter.wasm b/tests/ibc-hooks/bytecode/counter.wasm new file mode 100644 index 000000000..e3dc79aab Binary files /dev/null and b/tests/ibc-hooks/bytecode/counter.wasm differ diff --git a/tests/ibc-hooks/bytecode/cw20_base.wasm b/tests/ibc-hooks/bytecode/cw20_base.wasm new file mode 100644 index 000000000..2fe4d034b Binary files /dev/null and b/tests/ibc-hooks/bytecode/cw20_base.wasm differ diff --git a/tests/ibc-hooks/bytecode/cw20_ics20.wasm b/tests/ibc-hooks/bytecode/cw20_ics20.wasm new file mode 100644 index 000000000..c4b11e4c4 Binary files /dev/null and b/tests/ibc-hooks/bytecode/cw20_ics20.wasm differ diff --git a/tests/ibc-hooks/bytecode/echo.wasm b/tests/ibc-hooks/bytecode/echo.wasm new file mode 100644 index 000000000..93e7814b9 Binary files /dev/null and b/tests/ibc-hooks/bytecode/echo.wasm differ diff --git a/tests/ibc-hooks/test_hooks.sh b/tests/ibc-hooks/test_hooks.sh new file mode 100755 index 000000000..f425644e1 --- /dev/null +++ b/tests/ibc-hooks/test_hooks.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail -o xtrace +shopt -s expand_aliases + +alias chainA="terrad --node http://localhost:26657 --chain-id localterra-a" +alias chainB="terrad --node http://localhost:36657 --chain-id localterra-b" + +# setup the keys +echo "bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort" | terrad --keyring-backend test keys add validator --recover || echo "key exists" +echo "increase bread alpha rigid glide amused approve oblige print asset idea enact lawn proof unfold jeans rabbit audit return chuckle valve rather cactus great" | terrad --keyring-backend test keys add faucet --recover || echo "key exists" + +VALIDATOR=$(terrad keys show validator --keyring-backend test -a) + +args="--keyring-backend test --gas 200000 --gas-prices 0.1uluna --gas-adjustment 1.3 --broadcast-mode block --yes" +TX_FLAGS=($args) + +# send money to the validator on both chains +chainA tx bank send faucet "$VALIDATOR" 1000000000uluna "${TX_FLAGS[@]}" +chainB tx bank send faucet "$VALIDATOR" 1000000000uluna "${TX_FLAGS[@]}" + + +args="--keyring-backend test --gas 2000000 --gas-prices 0.1uluna --gas-adjustment 1.3 --broadcast-mode block --yes" +TX_FLAGS=($args) +# store and instantiate the contract +chainA tx wasm store ./tests/ibc-hooks/bytecode/counter.wasm --from validator "${TX_FLAGS[@]}" +CONTRACT_ID=$(chainA query wasm list-code -o json | jq -r '.code_infos[-1].code_id') +chainA tx wasm instantiate "$CONTRACT_ID" '{"count": "0"}' --from validator --no-admin --label=counter "${TX_FLAGS[@]}" + +# get the contract address +export CONTRACT_ADDRESS=$(chainA query wasm list-contract-by-code "$CONTRACT_ID" -o json | jq -r '.contracts | [last][0]') + +denom=$(chainA query bank balances "$CONTRACT_ADDRESS" -o json | jq -r '.balances[0].denom') +balance=$(chainA query bank balances "$CONTRACT_ADDRESS" -o json | jq -r '.balances[0].amount') + +# send ibc transaction to execite the contract +MEMO='{"wasm":{"contract":"'"$CONTRACT_ADDRESS"'","msg": {"increment": {}} }}' +chainB tx ibc-transfer transfer transfer channel-0 $CONTRACT_ADDRESS 10uluna \ + --from validator --keyring-backend test -y \ + --memo "$MEMO" + +# wait for the ibc round trip +sleep 16 + +new_balance=$(chainA query bank balances "$CONTRACT_ADDRESS" -o json | jq -r '.balances[0].amount') +export ADDR_IN_CHAIN_A=$(chainA q ibchooks wasm-sender channel-0 "$VALIDATOR") +QUERY='{"get_total_funds": {}}' +funds=$(chainA query wasm contract-state smart "$CONTRACT_ADDRESS" "$QUERY" -o json | jq -c -r '.data') +# QUERY='{"get_count": {"addr": "'"$ADDR_IN_CHAIN_A"'"}}' +QUERY='{"get_count": {}}' +count=$(chainA query wasm contract-state smart "$CONTRACT_ADDRESS" "$QUERY" -o json | jq -r '.data') + +echo "funds: $funds, count: $count" +echo "denom: $denom, old balance: $balance, new balance: $new_balance" diff --git a/tests/ibc-hooks/test_pfm.sh b/tests/ibc-hooks/test_pfm.sh new file mode 100755 index 000000000..214dc54f1 --- /dev/null +++ b/tests/ibc-hooks/test_pfm.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail -o xtrace +shopt -s expand_aliases + +alias chainA="terrad --node http://localhost:26657 --chain-id localterra-a" +alias chainB="terrad --node http://localhost:36657 --chain-id localterra-b" +alias chainC="terrad --node http://localhost:46657 --chain-id localterra-c" + +# setup the keys +echo "bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort" | terrad --keyring-backend test keys add validator --recover || echo "key exists" +echo "increase bread alpha rigid glide amused approve oblige print asset idea enact lawn proof unfold jeans rabbit audit return chuckle valve rather cactus great" | terrad --keyring-backend test keys add faucet --recover || echo "key exists" +echo "organ aisle angle end rude robust travel genre team town devote program" | terrad --keyring-backend test keys add receiver --recover || echo "key exists" + +VALIDATOR=$(terrad keys show validator --keyring-backend test -a) +RECEIVER=$(terrad keys show receiver --keyring-backend test -a) + +args="--keyring-backend test --gas 200000 --gas-prices 0.1uluna --gas-adjustment 1.3 --broadcast-mode block --yes" +TX_FLAGS=($args) + +# send money to the validator on both chains +chainA tx bank send faucet "$VALIDATOR" 1000000000uluna "${TX_FLAGS[@]}" +chainB tx bank send faucet "$VALIDATOR" 1000000000uluna "${TX_FLAGS[@]}" +chainC tx bank send faucet "$VALIDATOR" 1000000000uluna "${TX_FLAGS[@]}" + +args="--keyring-backend test --gas 2000000 --gas-prices 0.1uluna --gas-adjustment 1.3 --broadcast-mode block --yes" +TX_FLAGS=($args) + +# query old bank balances +denom=$(chainC query bank balances "$RECEIVER" -o json | jq -r '.balances[0].denom') +balance=$(chainC query bank balances "$RECEIVER" -o json | jq -r '.balances[0].amount') + +# send ibc transaction to execute the pfm +MEMO='{"forward":{"receiver":"'"$RECEIVER"'","port":"transfer","channel":"channel-1" }}' +chainA tx ibc-transfer transfer transfer channel-0 $RECEIVER 100uluna \ + --from validator --keyring-backend test -y \ + --memo "$MEMO" + +# wait for the ibc round trip +sleep 30 + +# query new bank balances +new_balance=$(chainC query bank balances "$RECEIVER" -o json | jq -r '.balances[0].amount') +# export ADDR_IN_CHAIN_A=$(chainC q ibchooks wasm-sender channel-0 "$VALIDATOR") + +echo "denom: $denom, old balance: $balance, new balance: $new_balance"