From 257b0f9eac995f99633384799b2d27f4f104a209 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:45:40 +0100 Subject: [PATCH 01/79] lets start From d28769cb493dcca1915b715790e26ef81048318a Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:45:52 +0100 Subject: [PATCH 02/79] del num transfers from memo --- x/hub-genesis/keeper/memo.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/x/hub-genesis/keeper/memo.go b/x/hub-genesis/keeper/memo.go index ad252578..e3002e19 100644 --- a/x/hub-genesis/keeper/memo.go +++ b/x/hub-genesis/keeper/memo.go @@ -34,7 +34,6 @@ func (w IBCModule) createMemo(ctx types.Context, denom string, n int) (string, e m := memo{} m.Data.Denom = d - m.Data.TotalNumTransfers = uint64(n) bz, err := json.Marshal(m) if err != nil { @@ -47,7 +46,5 @@ func (w IBCModule) createMemo(ctx types.Context, denom string, n int) (string, e type memo struct { Data struct { Denom banktypes.Metadata `json:"denom"` - // How many transfers in total will be sent in the transfer genesis period - TotalNumTransfers uint64 `json:"total_num_transfers"` } `json:"genesis_transfer"` } From e304a7d9227ca772f02e7b101996da8ac9b5cc1c Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:48:32 +0100 Subject: [PATCH 03/79] TODO: disable transfers when genesis transfers have not yet all been successfully acked From b1767c87188dbbf7118ae57f1eb932d184ef3ca8 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:39:28 +0100 Subject: [PATCH 04/79] pause and think --- go.mod | 51 ++++++----- go.sum | 106 +++++++++++++---------- proto/hub-genesis/state.proto | 6 +- x/hub-genesis/keeper/genesis.go | 1 - x/hub-genesis/keeper/ibc_module.go | 15 +++- x/hub-genesis/keeper/ics4_wrapper.go | 33 +++++-- x/hub-genesis/keeper/sequence_numbers.go | 40 +++++++++ 7 files changed, 167 insertions(+), 85 deletions(-) create mode 100644 x/hub-genesis/keeper/sequence_numbers.go diff --git a/go.mod b/go.mod index a430df55..3ffdd4ab 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/dymensionxyz/dymension-rdk -go 1.22.2 +go 1.22.4 require ( cosmossdk.io/errors v1.0.1 @@ -11,8 +11,9 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v6 v6.2.1 github.com/dymensionxyz/dymint v1.1.3-rc04 + github.com/dymensionxyz/gerr-cosmos v0.1.2 github.com/gogo/protobuf v1.3.3 - github.com/golang/protobuf v1.5.3 + github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/libp2p/go-libp2p v0.33.1 @@ -20,23 +21,23 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tendermint/tendermint v0.34.29 github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b golang.org/x/exp v0.0.0-20240213143201-ec583247a57a - google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe - google.golang.org/grpc v1.61.0 - google.golang.org/protobuf v1.32.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.33.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - cloud.google.com/go v0.111.0 // indirect - cloud.google.com/go/compute v1.23.3 // indirect + cloud.google.com/go v0.112.1 // indirect + cloud.google.com/go/compute v1.25.1 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.5 // indirect - cloud.google.com/go/storage v1.30.1 // indirect + cloud.google.com/go/iam v1.1.6 // indirect + cloud.google.com/go/storage v1.38.0 // indirect code.cloudfoundry.org/go-diodes v0.0.0-20220725190411-383eb6634c40 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -84,6 +85,7 @@ require ( github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect + github.com/danwt/gerr v0.1.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/deckarep/golang-set v1.8.0 // indirect @@ -101,7 +103,7 @@ require ( github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/ethereum/go-ethereum v1.12.0 // indirect - github.com/felixge/httpsnoop v1.0.2 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/filecoin-project/go-jsonrpc v0.3.1 // indirect github.com/flynn/noise v1.1.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect @@ -110,7 +112,7 @@ require ( 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 - github.com/go-logr/logr v1.3.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-stack/stack v1.8.1 // indirect @@ -118,7 +120,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/glog v1.1.2 // indirect + github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.2 // indirect @@ -129,9 +131,9 @@ require ( github.com/google/orderedcode v0.0.1 // indirect github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect github.com/google/s2a-go v0.1.7 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/googleapis/gax-go/v2 v2.12.2 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect @@ -254,9 +256,11 @@ require ( github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.8 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/otel v1.19.0 // indirect - go.opentelemetry.io/otel/metric v1.19.0 // indirect - go.opentelemetry.io/otel/trace v1.19.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/dig v1.17.1 // indirect go.uber.org/fx v1.20.1 // indirect go.uber.org/mock v0.4.0 // indirect @@ -265,18 +269,19 @@ require ( golang.org/x/crypto v0.22.0 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.24.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect + golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gonum.org/v1/gonum v0.13.0 // indirect - google.golang.org/api v0.149.0 // indirect + google.golang.org/api v0.169.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 2539d738..8453c165 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.111.0 h1:YHLKNupSD1KqjDbQ3+LVdQ81h/UJbJyZG203cEfnQgM= -cloud.google.com/go v0.111.0/go.mod h1:0mibmpKP1TyOOFYQY5izo0LnT+ecvOQ0Sg3OdmMiNRU= +cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= +cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -75,8 +75,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk= -cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI= +cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU= +cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -116,8 +116,8 @@ cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y97 cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v1.1.5 h1:1jTsCu4bcsNsE4iiqNT5SHwrDRCfRmIaaaVFhRveTJI= -cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8= +cloud.google.com/go/iam v1.1.6 h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc= +cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI= cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= @@ -179,8 +179,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM= -cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E= +cloud.google.com/go/storage v1.38.0 h1:Az68ZRGlnNTpIBbLjSMIV2BDcwwXYlRlQzis0llkpJg= +cloud.google.com/go/storage v1.38.0/go.mod h1:tlUADB0mAb9BgYls9lq+8MGkfzOXuLrnHXlpHmvFJoY= cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= @@ -470,6 +470,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= 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/danwt/gerr v0.1.5 h1:5s3G3cnftZG7Rq0+k+taMVteTmwKU66/g47kH6hY1js= +github.com/danwt/gerr v0.1.5/go.mod h1:tIj6P8ZPBLAbr64HdWqKHGUXbWJT6HenD08Fn98oAnE= github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -515,10 +517,10 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= -github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/cli v24.0.2+incompatible h1:QdqR7znue1mtkXIJ+ruQMGQhpw2JzMJLRXp6zpzF6tM= github.com/docker/cli v24.0.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +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/docker v24.0.2+incompatible h1:eATx+oLz9WdNVkQrr0qjQ8HvRJ4bOOxfzEo8R+dA3cg= github.com/docker/docker v24.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= @@ -543,6 +545,8 @@ github.com/dymensionxyz/dymint v1.1.3-rc04 h1:RqDF8bxB73mYmxHKnVNGeTnTsZihAwV6AE github.com/dymensionxyz/dymint v1.1.3-rc04/go.mod h1:e04A2OxeowtxMC9jl4JJj/7fmcYrHEWVIbYAlEd/Byo= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 h1:vmAdUGUc4rTIiO3Phezr7vGq+0uPDVKSA4WAe8+yl6w= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3/go.mod h1:LfPv2O1HXMgETpka81Pg3nXy+U/7urq8dn85ZnSXK5Y= +github.com/dymensionxyz/gerr-cosmos v0.1.2 h1:4NiB9psF6swnWTCDYnHgHKtVEaRHuuNRuqvPGDw1BI8= +github.com/dymensionxyz/gerr-cosmos v0.1.2/go.mod h1:tXIhx3WdryAnYRISC3Weh+2xeXwaf1l4Yb1zjDUsT7k= github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20231219183151-4504d4995913 h1:sR3nGYRlktL2Xfj5pcOhgG2bvlBOZ14meqdu2TKkSCU= github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20231219183151-4504d4995913/go.mod h1:1OxbaT/pFRO5h+Dpze8hdHQ63R0ke55XTs6b6NwLLkw= github.com/dymensionxyz/rpc v1.3.1 h1:7EXWIobaBes5zldRvTIg7TmNsEKjicrWA/OjCc0NaGs= @@ -578,8 +582,8 @@ github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+ne github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= -github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/filecoin-project/go-jsonrpc v0.3.1 h1:qwvAUc5VwAkooquKJmfz9R2+F8znhiqcNHYjEp/NM10= github.com/filecoin-project/go-jsonrpc v0.3.1/go.mod h1:jBSvPTl8V1N7gSTuCR4bis8wnQnIjHbRPpROol6iQKM= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= @@ -634,8 +638,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= @@ -688,8 +692,8 @@ github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= +github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -725,8 +729,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -803,8 +807,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -821,8 +825,8 @@ github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99 github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas= -github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= +github.com/googleapis/gax-go/v2 v2.12.2 h1:mhN09QQW1jEWeMF74zGR81R30z4VJzjZsfkUhuHF+DA= +github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -1441,8 +1445,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -1453,8 +1458,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 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/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= @@ -1561,14 +1566,18 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= -go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= -go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= -go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= -go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= -go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= -go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= -go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= +go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -1775,8 +1784,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2014,8 +2023,9 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= @@ -2076,8 +2086,8 @@ google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.149.0 h1:b2CqT6kG+zqJIVKRQ3ELJVLN1PwHZ6DJ3dW8yl82rgY= -google.golang.org/api v0.149.0/go.mod h1:Mwn1B7JTXrzXtnvmzQE2BD6bYZQ8DShKZDZbeN9I7qI= +google.golang.org/api v0.169.0 h1:QwWPy71FgMWqJN/l6jVlFHUa29a7dcUy02I8o799nPY= +google.golang.org/api v0.169.0/go.mod h1:gpNOiMA2tZ4mf5R9Iwf4rK/Dcz0fbdIgWYWVoxmsyLg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -2202,12 +2212,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrqK/Optxxp2pmVh+fmJ97slxSRyzUg= -google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:0poefMBYvYbs7g5UkjS6HcxBPaTRAmznle9jnxYoAI8= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= +google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -2252,8 +2262,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= -google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -2270,8 +2280,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/proto/hub-genesis/state.proto b/proto/hub-genesis/state.proto index a00cd60d..e5895dae 100644 --- a/proto/hub-genesis/state.proto +++ b/proto/hub-genesis/state.proto @@ -12,11 +12,9 @@ message State { reserved 2; // accounts on the Hub to fund with some bootstrapping transfers repeated GenesisAccount genesis_accounts = 3 [(gogoproto.nullable) = false]; + // the sequence numbers of all transfers for genesis accounts for which an ack has not yet come back + repeated uint64 GenesisTransferSeqs = 4 [(gogoproto.nullable) = false]; } -/* - -TODO: the below is copy pasted, clean up - */ // GenesisAccount is a struct for the genesis account for the rollapp message GenesisAccount { diff --git a/x/hub-genesis/keeper/genesis.go b/x/hub-genesis/keeper/genesis.go index b40f3689..9444f7ae 100644 --- a/x/hub-genesis/keeper/genesis.go +++ b/x/hub-genesis/keeper/genesis.go @@ -16,6 +16,5 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { genesis := types.DefaultGenesisState() genesis.Params = k.GetParams(ctx) genesis.State = k.GetState(ctx) - return genesis } diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 6ed52b7a..b60eb89a 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -5,6 +5,7 @@ import ( "time" errorsmod "cosmossdk.io/errors" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -73,7 +74,17 @@ func (w IBCModule) OnChanOpenConfirm( l.Info("Sent all genesis transfers.") - return nil + return w.IBCModule.OnChanOpenConfirm(ctx, portID, channelID) +} + +func (w IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + w.k.delSequenceNumber(ctx, packet.Sequence) + return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) } func (w IBCModule) mintAndTransfer( @@ -111,7 +122,7 @@ func (w IBCModule) mintAndTransfer( Memo: memo, } - err = w.transfer(skipContext(ctx), &m) + err = w.transfer(skipAuthorizationCheckContext(ctx), &m) if err != nil { return errorsmod.Wrap(err, "transfer") } diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index 49c9bbeb..6767a5e8 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -8,31 +8,35 @@ import ( transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" + "github.com/dymensionxyz/gerr-cosmos/gerrc" ) type ctxKeySkip struct{} -// skipContext returns a context which can be passed to ibc SendPacket +// skipAuthorizationCheckContext returns a context which can be passed to ibc SendPacket // if passed, the memo guard will not check that call -func skipContext(ctx sdk.Context) sdk.Context { +func skipAuthorizationCheckContext(ctx sdk.Context) sdk.Context { return ctx.WithValue(ctxKeySkip{}, true) } -func skip(ctx sdk.Context) bool { +func skipAuthorizationCheck(ctx sdk.Context) bool { val, ok := ctx.Value(ctxKeySkip{}).(bool) return ok && val } type ICS4Wrapper struct { porttypes.ICS4Wrapper + k Keeper } -func NewICS4Wrapper(next porttypes.ICS4Wrapper) *ICS4Wrapper { - return &ICS4Wrapper{next} +func NewICS4Wrapper(next porttypes.ICS4Wrapper, k Keeper) *ICS4Wrapper { + return &ICS4Wrapper{next, k} } // SendPacket prevents anyone from sending a packet with the memo // The app should be wired to allow the middleware to circumvent this +// It also prevents anyone from sending a transfer before all the genesis transfers +// have had successull acks come back. func (w ICS4Wrapper) SendPacket( ctx sdk.Context, chanCap *capabilitytypes.Capability, @@ -42,10 +46,25 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { + if !w.k.genesisIsFinished(ctx) { + return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") + } + var transfer transfertypes.FungibleTokenPacketData _ = transfertypes.ModuleCdc.UnmarshalJSON(data, &transfer) - if !skip(ctx) && memoHasKey(transfer.GetMemo()) { - return 0, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "cannot use transfer genesis memo") + + if memoHasKey(transfer.GetMemo()) { + if !skipAuthorizationCheck(ctx) { + return 0, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "cannot use transfer genesis memo") + } + + // record the sequence number because we need to tick them off as they get acked + + seq, err := w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + if err != nil { + return seq, err + } + return seq, w.k.saveSequenceNumber(ctx, seq) } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) } diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go new file mode 100644 index 00000000..ece6be48 --- /dev/null +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "encoding/binary" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func seqNumKey(seq uint64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, seq) + + var key []byte + key = append(key, []byte("seqnums/")...) + key = append(key, bz...) + return key +} + +func seqCntKey() []byte { + var key []byte + key = append(key, []byte("seqcnt")...) + return key +} + +func (k Keeper) saveSequenceNumber(ctx sdk.Context, seq uint64) error { + store := ctx.KVStore(k.storeKey) + ctx.KVStore(k.storeKey).Set(seqNumKey(seq), []byte{}) + cntBz := store.Get(seqCntKey()) + cnt := binary.BigEndian.Uint64(cntBz) + cnt++ + if !ok +} + +func (k Keeper) delSequenceNumber(ctx sdk.Context, seq uint64) error { + store := ctx.KVStore(k.storeKey). + store.Set(seqNumKey(seq), nil) +} + +func (k Keeper) genesisIsFinished(ctx sdk.Context) bool { +} From 813e05bbd7e45d8f5cd30662fca8bdabcaa5bdee Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:55:19 +0100 Subject: [PATCH 05/79] partially done with the seq saving --- x/hub-genesis/keeper/ics4_wrapper.go | 9 ++++++- x/hub-genesis/keeper/keeper.go | 5 ++++ x/hub-genesis/keeper/sequence_numbers.go | 32 ++++++++++-------------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index 6767a5e8..f92926a9 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -46,6 +46,13 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { + /* + Rethinking how this can work: + - block transfers if the genesis accounts list is not empty, that means they weren't all sent + - record the highest seq num, always + - on a transfer attempt, check for any of those seq nums, save the result when it's good, to amortize + */ + if !w.k.genesisIsFinished(ctx) { return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } @@ -64,7 +71,7 @@ func (w ICS4Wrapper) SendPacket( if err != nil { return seq, err } - return seq, w.k.saveSequenceNumber(ctx, seq) + return seq, w.k.saveLastSequenceNumber(ctx, seq) } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) } diff --git a/x/hub-genesis/keeper/keeper.go b/x/hub-genesis/keeper/keeper.go index 01706011..261bf6f3 100644 --- a/x/hub-genesis/keeper/keeper.go +++ b/x/hub-genesis/keeper/keeper.go @@ -13,6 +13,10 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) +type ChannelKeeper interface { + GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte +} + type ( Keeper struct { cdc codec.BinaryCodec @@ -20,6 +24,7 @@ type ( paramstore paramtypes.Subspace accountKeeper types.AuthAccountKeeper + channelKeeper ChannelKeeper } ) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index ece6be48..16b8eaa7 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -16,25 +16,19 @@ func seqNumKey(seq uint64) []byte { return key } -func seqCntKey() []byte { - var key []byte - key = append(key, []byte("seqcnt")...) - return key -} - -func (k Keeper) saveSequenceNumber(ctx sdk.Context, seq uint64) error { - store := ctx.KVStore(k.storeKey) - ctx.KVStore(k.storeKey).Set(seqNumKey(seq), []byte{}) - cntBz := store.Get(seqCntKey()) - cnt := binary.BigEndian.Uint64(cntBz) - cnt++ - if !ok -} - -func (k Keeper) delSequenceNumber(ctx sdk.Context, seq uint64) error { - store := ctx.KVStore(k.storeKey). - store.Set(seqNumKey(seq), nil) +// NOTE: assumes monotically increasing +func (k Keeper) saveLastSequenceNumber(ctx sdk.Context, seq uint64) { + seqBz := make([]byte, 8) + binary.BigEndian.PutUint64(seqBz, seq) + ctx.KVStore(k.storeKey).Set([]byte("seqnum"), seqBz) } -func (k Keeper) genesisIsFinished(ctx sdk.Context) bool { +func (k Keeper) genesisIsFinished(ctx sdk.Context, port, channel string) bool { + seqBz := ctx.KVStore(k.storeKey).Get([]byte("seqnum")) + seq := binary.BigEndian.Uint64(seqBz) + bz := k.channelKeeper.GetPacketCommitment(ctx, port, channel, seq) + if len(bz) == 0 { + // TODO: need to loop through all of them and save a convenience value + } + return false } From d4f60a361659e0219660f4342e2ff6a9f52a40ae Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:43:22 +0100 Subject: [PATCH 06/79] adding a panic but Ill rip it out --- x/hub-genesis/keeper/ibc_module.go | 12 ------ x/hub-genesis/keeper/ics4_wrapper.go | 20 ++++------ x/hub-genesis/keeper/sequence_numbers.go | 47 +++++++++++++++--------- 3 files changed, 37 insertions(+), 42 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index b60eb89a..00086a36 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -5,8 +5,6 @@ import ( "time" errorsmod "cosmossdk.io/errors" - channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" - sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" @@ -77,16 +75,6 @@ func (w IBCModule) OnChanOpenConfirm( return w.IBCModule.OnChanOpenConfirm(ctx, portID, channelID) } -func (w IBCModule) OnAcknowledgementPacket( - ctx sdk.Context, - packet channeltypes.Packet, - acknowledgement []byte, - relayer sdk.AccAddress, -) error { - w.k.delSequenceNumber(ctx, packet.Sequence) - return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) -} - func (w IBCModule) mintAndTransfer( ctx sdk.Context, n int, diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index f92926a9..36f947bb 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -33,10 +33,9 @@ func NewICS4Wrapper(next porttypes.ICS4Wrapper, k Keeper) *ICS4Wrapper { return &ICS4Wrapper{next, k} } -// SendPacket prevents anyone from sending a packet with the memo -// The app should be wired to allow the middleware to circumvent this -// It also prevents anyone from sending a transfer before all the genesis transfers -// have had successull acks come back. +// SendPacket does two things: +// 1. It stops anyone from sending a packet with the special memo. Only the module itself is allowed to do so. +// 2. It stops anyone from sending a regular transfer until the genesis phase is finished. func (w ICS4Wrapper) SendPacket( ctx sdk.Context, chanCap *capabilitytypes.Capability, @@ -46,14 +45,7 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { - /* - Rethinking how this can work: - - block transfers if the genesis accounts list is not empty, that means they weren't all sent - - record the highest seq num, always - - on a transfer attempt, check for any of those seq nums, save the result when it's good, to amortize - */ - - if !w.k.genesisIsFinished(ctx) { + if !w.k.genesisIsFinished(ctx, sourcePort, sourceChannel) { return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } @@ -65,13 +57,15 @@ func (w ICS4Wrapper) SendPacket( return 0, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "cannot use transfer genesis memo") } + // this is a genesis transfer, we record the sequence number // record the sequence number because we need to tick them off as they get acked seq, err := w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) if err != nil { return seq, err } - return seq, w.k.saveLastSequenceNumber(ctx, seq) + w.k.saveLastSequenceNumber(ctx, seq) + return seq, nil } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) } diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 16b8eaa7..c7b628ba 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -2,33 +2,46 @@ package keeper import ( "encoding/binary" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + hubgentypes "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" ) -func seqNumKey(seq uint64) []byte { - bz := make([]byte, 8) - binary.BigEndian.PutUint64(bz, seq) - - var key []byte - key = append(key, []byte("seqnums/")...) - key = append(key, bz...) - return key +func seqNumKey(port, channel string) []byte { + return []byte(fmt.Sprintf("seqnum/%s/%s", port, channel)) } -// NOTE: assumes monotically increasing -func (k Keeper) saveLastSequenceNumber(ctx sdk.Context, seq uint64) { +// NOTE: assumes monotonically increasing +func (k Keeper) saveLastSequenceNumber(ctx sdk.Context, port, channel string, seq uint64) { + if existing := k.getLastSequenceNumber(ctx, port, channel); seq < existing { + /* + Proof that this will never happen: + All transfers + */ + panic( + fmt.Sprintf( + "%s: a higher sequence number has already been set: existing: %d: new: %d: port: %s, channel: %s", hubgentypes.ModuleName, existing, seq, port, channel)) + } seqBz := make([]byte, 8) binary.BigEndian.PutUint64(seqBz, seq) - ctx.KVStore(k.storeKey).Set([]byte("seqnum"), seqBz) + ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) +} + +// NOTE: assumes monotonically increasing +func (k Keeper) getLastSequenceNumber(ctx sdk.Context, port, channel string) uint64 { + bz := ctx.KVStore(k.storeKey).Get(seqNumKey(port, channel)) + return sdk.BigEndianToUint64(bz) } func (k Keeper) genesisIsFinished(ctx sdk.Context, port, channel string) bool { - seqBz := ctx.KVStore(k.storeKey).Get([]byte("seqnum")) - seq := binary.BigEndian.Uint64(seqBz) - bz := k.channelKeeper.GetPacketCommitment(ctx, port, channel, seq) - if len(bz) == 0 { - // TODO: need to loop through all of them and save a convenience value + for seq := range k.getLastSequenceNumber(ctx, port, channel) + 1 { + bz := k.channelKeeper.GetPacketCommitment(ctx, port, channel, seq) + if len(bz) != 0 { + // there is still a sequence number for which we didn't get an ack back yet + // so we still need to wait some more. + return false + } } - return false + return true } From 673f879313830d2e9e3ab16c4bb04616342ee800 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:43:31 +0100 Subject: [PATCH 07/79] removes panic --- x/hub-genesis/keeper/sequence_numbers.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index c7b628ba..95fa1611 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -5,7 +5,6 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - hubgentypes "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" ) func seqNumKey(port, channel string) []byte { @@ -14,15 +13,6 @@ func seqNumKey(port, channel string) []byte { // NOTE: assumes monotonically increasing func (k Keeper) saveLastSequenceNumber(ctx sdk.Context, port, channel string, seq uint64) { - if existing := k.getLastSequenceNumber(ctx, port, channel); seq < existing { - /* - Proof that this will never happen: - All transfers - */ - panic( - fmt.Sprintf( - "%s: a higher sequence number has already been set: existing: %d: new: %d: port: %s, channel: %s", hubgentypes.ModuleName, existing, seq, port, channel)) - } seqBz := make([]byte, 8) binary.BigEndian.PutUint64(seqBz, seq) ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) From 0a9d82e41486688067e54d445e927269a16816cb Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:47:51 +0100 Subject: [PATCH 08/79] time to test --- x/hub-genesis/keeper/ics4_wrapper.go | 2 +- x/hub-genesis/keeper/sequence_numbers.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index 36f947bb..540af3fa 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -64,7 +64,7 @@ func (w ICS4Wrapper) SendPacket( if err != nil { return seq, err } - w.k.saveLastSequenceNumber(ctx, seq) + w.k.saveLastSequenceNumber(ctx, sourcePort, sourceChannel, seq) return seq, nil } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 95fa1611..d7b9cb99 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -18,12 +18,15 @@ func (k Keeper) saveLastSequenceNumber(ctx sdk.Context, port, channel string, se ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) } -// NOTE: assumes monotonically increasing func (k Keeper) getLastSequenceNumber(ctx sdk.Context, port, channel string) uint64 { bz := ctx.KVStore(k.storeKey).Get(seqNumKey(port, channel)) return sdk.BigEndianToUint64(bz) } +// genesisIsFinished returns if the genesis bridge protocol phase is finished. It is finished +// when all genesis transfers sent from the RA to the Hub have been acked. After this you're +// allowed to send regular transfers. The first regular transfer received on the Hub marks +// the end of the protocol from the Hub's perspective. func (k Keeper) genesisIsFinished(ctx sdk.Context, port, channel string) bool { for seq := range k.getLastSequenceNumber(ctx, port, channel) + 1 { bz := k.channelKeeper.GetPacketCommitment(ctx, port, channel, seq) From b03db02f8f76ae126ba8ed78ad60e5b0e62ca9c9 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:33:27 +0100 Subject: [PATCH 09/79] ready to test --- go.mod | 2 +- proto/hub-genesis/state.proto | 4 +- x/hub-genesis/keeper/sequence_numbers.go | 8 +++ x/hub-genesis/types/state.pb.go | 83 ++++++++++++++++++------ 4 files changed, 74 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 3ffdd4ab..fd22beb7 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,6 @@ require ( golang.org/x/exp v0.0.0-20240213143201-ec583247a57a google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.33.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -282,6 +281,7 @@ require ( google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/proto/hub-genesis/state.proto b/proto/hub-genesis/state.proto index e5895dae..132a4eda 100644 --- a/proto/hub-genesis/state.proto +++ b/proto/hub-genesis/state.proto @@ -12,8 +12,8 @@ message State { reserved 2; // accounts on the Hub to fund with some bootstrapping transfers repeated GenesisAccount genesis_accounts = 3 [(gogoproto.nullable) = false]; - // the sequence numbers of all transfers for genesis accounts for which an ack has not yet come back - repeated uint64 GenesisTransferSeqs = 4 [(gogoproto.nullable) = false]; + // is the genesis transfer phase finished? True when acks received for all transfers. + bool finished = 4; } // GenesisAccount is a struct for the genesis account for the rollapp diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index d7b9cb99..63519af3 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -28,6 +28,12 @@ func (k Keeper) getLastSequenceNumber(ctx sdk.Context, port, channel string) uin // allowed to send regular transfers. The first regular transfer received on the Hub marks // the end of the protocol from the Hub's perspective. func (k Keeper) genesisIsFinished(ctx sdk.Context, port, channel string) bool { + state := k.GetState(ctx) + if state.GetFinished() { + return true + } + // This operation may not be super cheap, but once the genesis phase is finished, it won't be necessary. + // Much simpler than using a map to check off each seq num. for seq := range k.getLastSequenceNumber(ctx, port, channel) + 1 { bz := k.channelKeeper.GetPacketCommitment(ctx, port, channel, seq) if len(bz) != 0 { @@ -36,5 +42,7 @@ func (k Keeper) genesisIsFinished(ctx sdk.Context, port, channel string) bool { return false } } + state.Finished = true + k.SetState(ctx, state) return true } diff --git a/x/hub-genesis/types/state.pb.go b/x/hub-genesis/types/state.pb.go index 6e9206fe..84ba7022 100644 --- a/x/hub-genesis/types/state.pb.go +++ b/x/hub-genesis/types/state.pb.go @@ -28,6 +28,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type State struct { // accounts on the Hub to fund with some bootstrapping transfers GenesisAccounts []GenesisAccount `protobuf:"bytes,3,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` + // is the genesis transfer phase finished? + Finished bool `protobuf:"varint,4,opt,name=finished,proto3" json:"finished,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -70,6 +72,13 @@ func (m *State) GetGenesisAccounts() []GenesisAccount { return nil } +func (m *State) GetFinished() bool { + if m != nil { + return m.Finished + } + return false +} + // GenesisAccount is a struct for the genesis account for the rollapp type GenesisAccount struct { // amount of coins to be sent to the genesis address @@ -133,26 +142,27 @@ func init() { func init() { proto.RegisterFile("hub-genesis/state.proto", fileDescriptor_1ad65c2fe0d953ab) } var fileDescriptor_1ad65c2fe0d953ab = []byte{ - // 305 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x41, 0x4f, 0xfa, 0x30, - 0x18, 0xc6, 0x57, 0xe0, 0xcf, 0x1f, 0x47, 0xa2, 0x64, 0x9a, 0x38, 0x39, 0x54, 0x82, 0x17, 0x2e, - 0xb4, 0x01, 0x0f, 0xc6, 0xa3, 0x78, 0x30, 0xe1, 0x08, 0x9e, 0xbc, 0x90, 0xae, 0x6b, 0x46, 0x23, - 0xeb, 0xbb, 0xec, 0xed, 0x0c, 0xf8, 0x29, 0xfc, 0x58, 0x1c, 0x39, 0x7a, 0x32, 0x06, 0xbe, 0x88, - 0x19, 0x9b, 0x51, 0x12, 0x4f, 0x7d, 0xdf, 0x3e, 0xbf, 0x3e, 0x7d, 0xf2, 0xb8, 0xe7, 0xf3, 0x2c, - 0xe8, 0x47, 0xca, 0x28, 0xd4, 0xc8, 0xd1, 0x0a, 0xab, 0x58, 0x92, 0x82, 0x05, 0xef, 0x34, 0x85, - 0xc5, 0x42, 0x24, 0x09, 0x9b, 0x67, 0xc1, 0xac, 0x04, 0xda, 0x67, 0x11, 0x44, 0xb0, 0xd7, 0x79, - 0x3e, 0x15, 0x68, 0x9b, 0x4a, 0xc0, 0x18, 0x90, 0x07, 0x02, 0x15, 0x7f, 0x19, 0x04, 0xca, 0x8a, - 0x01, 0x97, 0xa0, 0x4d, 0xa1, 0x77, 0xb5, 0xfb, 0x6f, 0x9a, 0x3b, 0x7b, 0x8f, 0x6e, 0xab, 0x74, - 0x9a, 0x09, 0x29, 0x21, 0x33, 0x16, 0xfd, 0x6a, 0xa7, 0xda, 0x6b, 0x0e, 0xaf, 0xd8, 0x1f, 0xdf, - 0xb1, 0x87, 0xe2, 0xbc, 0x2b, 0xd8, 0x51, 0x6d, 0xfd, 0x71, 0xe9, 0x4c, 0x4e, 0xa2, 0x83, 0x5b, - 0x1c, 0xd7, 0x1a, 0xa4, 0x55, 0x19, 0xd7, 0x1a, 0x95, 0x56, 0xb5, 0x2b, 0xdd, 0xe3, 0xc3, 0x47, - 0xde, 0x8d, 0x5b, 0x17, 0x71, 0x3e, 0xf9, 0xa4, 0x43, 0x7a, 0xcd, 0xe1, 0x05, 0x2b, 0xd2, 0xb2, - 0x3c, 0x2d, 0x2b, 0xd3, 0xb2, 0x7b, 0xd0, 0xa6, 0xf4, 0x2f, 0x71, 0xcf, 0x77, 0xff, 0x8b, 0x30, - 0x4c, 0x15, 0xa2, 0x5f, 0xe9, 0x90, 0xde, 0xd1, 0xe4, 0x7b, 0x1d, 0x4d, 0xd7, 0x5b, 0x4a, 0x36, - 0x5b, 0x4a, 0x3e, 0xb7, 0x94, 0xbc, 0xed, 0xa8, 0xb3, 0xd9, 0x51, 0xe7, 0x7d, 0x47, 0x9d, 0xa7, - 0xdb, 0x48, 0xdb, 0x79, 0x16, 0x30, 0x09, 0x31, 0x0f, 0x57, 0xb1, 0x32, 0xa8, 0xc1, 0x2c, 0x57, - 0xaf, 0x3f, 0x4b, 0x3f, 0x0d, 0x9f, 0xf9, 0x92, 0xff, 0x6e, 0xdd, 0xae, 0x12, 0x85, 0x41, 0x7d, - 0xdf, 0xd5, 0xf5, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x32, 0x13, 0x75, 0x6d, 0x91, 0x01, 0x00, + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xbf, 0x4e, 0xc3, 0x30, + 0x18, 0xc4, 0xe3, 0x36, 0x94, 0xe0, 0x4a, 0x50, 0x05, 0x24, 0x42, 0x07, 0x13, 0x95, 0x25, 0x4b, + 0x6d, 0xb5, 0x0c, 0x88, 0x91, 0x32, 0x20, 0x75, 0x6c, 0x99, 0x58, 0x2a, 0x27, 0x31, 0x89, 0x45, + 0x63, 0x47, 0xb1, 0x83, 0x5a, 0x76, 0x76, 0x1e, 0xab, 0x63, 0x47, 0x26, 0x84, 0x9a, 0x17, 0x41, + 0x69, 0xc2, 0x9f, 0x4a, 0x4c, 0xfe, 0xce, 0xdf, 0x4f, 0x77, 0x3a, 0x1b, 0x9e, 0xc6, 0xb9, 0xdf, + 0x8f, 0x98, 0x60, 0x8a, 0x2b, 0xa2, 0x34, 0xd5, 0x0c, 0xa7, 0x99, 0xd4, 0xd2, 0x3e, 0xce, 0xe4, + 0x7c, 0x4e, 0xd3, 0x14, 0xc7, 0xb9, 0x3f, 0xab, 0x81, 0xee, 0x49, 0x24, 0x23, 0xb9, 0xdd, 0x93, + 0x72, 0xaa, 0xd0, 0x2e, 0x0a, 0xa4, 0x4a, 0xa4, 0x22, 0x3e, 0x55, 0x8c, 0x3c, 0x0f, 0x7c, 0xa6, + 0xe9, 0x80, 0x04, 0x92, 0x8b, 0x6a, 0xdf, 0x7b, 0x05, 0x70, 0x6f, 0x5a, 0x5a, 0xdb, 0xf7, 0xb0, + 0x53, 0x5b, 0xcd, 0x68, 0x10, 0xc8, 0x5c, 0x68, 0xe5, 0x34, 0xdd, 0xa6, 0xd7, 0x1e, 0x5e, 0xe0, + 0x7f, 0xf2, 0xf0, 0x5d, 0x75, 0xde, 0x54, 0xec, 0xc8, 0x5c, 0x7d, 0x9c, 0x1b, 0x93, 0xa3, 0x68, + 0xe7, 0x56, 0xd9, 0x5d, 0x68, 0x3d, 0x72, 0xc1, 0x55, 0xcc, 0x42, 0xc7, 0x74, 0x81, 0x67, 0x4d, + 0x7e, 0xf4, 0xd8, 0xb4, 0x40, 0xa7, 0x31, 0x36, 0xad, 0x46, 0xa7, 0xd9, 0x0b, 0xe0, 0xe1, 0xae, + 0xa1, 0x7d, 0x05, 0x5b, 0x34, 0x29, 0x27, 0x07, 0xb8, 0xc0, 0x6b, 0x0f, 0xcf, 0x70, 0x55, 0x05, + 0x97, 0x55, 0x70, 0x5d, 0x05, 0xdf, 0x4a, 0x2e, 0xea, 0xec, 0x1a, 0xb7, 0x1d, 0xb8, 0x4f, 0xc3, + 0x30, 0x63, 0x4a, 0x39, 0x0d, 0x17, 0x78, 0x07, 0x93, 0x6f, 0x39, 0x9a, 0xae, 0x36, 0x08, 0xac, + 0x37, 0x08, 0x7c, 0x6e, 0x10, 0x78, 0x2b, 0x90, 0xb1, 0x2e, 0x90, 0xf1, 0x5e, 0x20, 0xe3, 0xe1, + 0x3a, 0xe2, 0x3a, 0xce, 0x7d, 0x1c, 0xc8, 0x84, 0x84, 0xcb, 0x84, 0x09, 0xc5, 0xa5, 0x58, 0x2c, + 0x5f, 0x7e, 0x45, 0x3f, 0x0b, 0x9f, 0xc8, 0x82, 0xfc, 0xfd, 0x12, 0xbd, 0x4c, 0x99, 0xf2, 0x5b, + 0xdb, 0x87, 0xbc, 0xfc, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x79, 0xf9, 0x87, 0xae, 0x01, 0x00, 0x00, } @@ -176,6 +186,16 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Finished { + i-- + if m.Finished { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } if len(m.GenesisAccounts) > 0 { for iNdEx := len(m.GenesisAccounts) - 1; iNdEx >= 0; iNdEx-- { { @@ -256,6 +276,9 @@ func (m *State) Size() (n int) { n += 1 + l + sovState(uint64(l)) } } + if m.Finished { + n += 2 + } return n } @@ -343,6 +366,26 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Finished", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Finished = bool(v != 0) default: iNdEx = preIndex skippy, err := skipState(dAtA[iNdEx:]) From 21a4eba9570818224a71dc4a5fa5c199f2f45c9f Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:33:36 +0100 Subject: [PATCH 10/79] pb --- x/gasless/types/gasless.pb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/gasless/types/gasless.pb.go b/x/gasless/types/gasless.pb.go index de00202c..4fee92a8 100644 --- a/x/gasless/types/gasless.pb.go +++ b/x/gasless/types/gasless.pb.go @@ -8,8 +8,8 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" From a3e56d74a4c3c07653256c0d3650fe5e2d0a840c Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:44:03 +0100 Subject: [PATCH 11/79] adds missing channel keeper --- x/hub-genesis/keeper/keeper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/hub-genesis/keeper/keeper.go b/x/hub-genesis/keeper/keeper.go index 261bf6f3..ed517c11 100644 --- a/x/hub-genesis/keeper/keeper.go +++ b/x/hub-genesis/keeper/keeper.go @@ -33,6 +33,7 @@ func NewKeeper( storeKey storetypes.StoreKey, ps paramtypes.Subspace, accountKeeper types.AuthAccountKeeper, + channelKeeper ChannelKeeper, ) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -45,6 +46,7 @@ func NewKeeper( storeKey: storeKey, paramstore: ps, accountKeeper: accountKeeper, + channelKeeper: channelKeeper, } } From 3864b740c282320a441746777c77c620051aad83 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:46:27 +0100 Subject: [PATCH 12/79] fix tests --- testutil/app/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/testutil/app/app.go b/testutil/app/app.go index f6151beb..a8e20c86 100644 --- a/testutil/app/app.go +++ b/testutil/app/app.go @@ -444,6 +444,7 @@ func NewRollapp( keys[hubgentypes.StoreKey], app.GetSubspace(hubgentypes.ModuleName), app.AccountKeeper, + app.IBCKeeper.ChannelKeeper, ) app.GaslessKeeper = gaslesskeeper.NewKeeper( From b32a3e1e0012b8aecf309dff2468c627a20b98bb Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:13:45 +0100 Subject: [PATCH 13/79] address leftover comments --- x/hub-genesis/keeper/ibc_module.go | 25 +++++++------------------ x/hub-genesis/keeper/memo.go | 2 +- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 00086a36..3aebe591 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -59,42 +59,31 @@ func (w IBCModule) OnChanOpenConfirm( srcAddr := srcAccount.GetAddress().String() for i, a := range state.GetGenesisAccounts() { - if err := w.mintAndTransfer(ctx, len(state.GetGenesisAccounts()), a, srcAddr, portID, channelID); err != nil { + if err := w.mintAndTransfer(ctx, a, srcAddr, portID, channelID); err != nil { // there is no feasible way to recover panic(fmt.Errorf("mint and transfer: %w", err)) } l.Info("Sent genesis transfer.", "index", i, "receiver", a.GetAddress(), "coin", a) } - state.GenesisAccounts = nil - - w.k.SetState(ctx, state) - l.Info("Sent all genesis transfers.") return w.IBCModule.OnChanOpenConfirm(ctx, portID, channelID) } -func (w IBCModule) mintAndTransfer( - ctx sdk.Context, - n int, - a types.GenesisAccount, - srcAddr string, - portID string, - channelID string, -) error { - coin := a.GetAmount() +func (w IBCModule) mintAndTransfer(ctx sdk.Context, account types.GenesisAccount, srcAddr string, portID string, channelID string) error { + coin := account.GetAmount() err := w.mintCoins(ctx, types.ModuleName, sdk.Coins{coin}) if err != nil { return errorsmod.Wrap(err, "mint coins") } // NOTE: for simplicity we don't optimize to avoid sending duplicate metadata - // we assume the hub will deduplicate. We expect to eventually get a timeout + // we assume the hub will deduplicate. We expect to eventually get account timeout // or commit anyway, so the packet will be cleared up. // (Actually, since transfers may arrive out of order, we must include the // denom metadata anyway). - memo, err := w.createMemo(ctx, a.Amount.Denom, n) + memo, err := w.createMemo(ctx, account.Amount.Denom) if err != nil { return errorsmod.Wrap(err, "create memo") } @@ -102,9 +91,9 @@ func (w IBCModule) mintAndTransfer( m := transfertypes.MsgTransfer{ SourcePort: portID, SourceChannel: channelID, - Token: a.Amount, + Token: account.Amount, Sender: srcAddr, - Receiver: a.GetAddress(), + Receiver: account.GetAddress(), TimeoutHeight: clienttypes.Height{}, TimeoutTimestamp: uint64(ctx.BlockTime().Add(transferTimeout).UnixNano()), Memo: memo, diff --git a/x/hub-genesis/keeper/memo.go b/x/hub-genesis/keeper/memo.go index e3002e19..ed59cbb7 100644 --- a/x/hub-genesis/keeper/memo.go +++ b/x/hub-genesis/keeper/memo.go @@ -26,7 +26,7 @@ func memoHasKey(memo string) bool { // createMemo creates a memo to go with the transfer. It's used by the hub to confirm // that the transfer originated from the chain itself, rather than a user of the chain. // It may also contain token metadata. -func (w IBCModule) createMemo(ctx types.Context, denom string, n int) (string, error) { +func (w IBCModule) createMemo(ctx types.Context, denom string) (string, error) { d, ok := w.getDenom(ctx, denom) if !ok { return "", errors.Wrap(sdkerrors.ErrNotFound, "get denom metadata") From 5030b496d56a630817372e26d4a91fd089b3b40e Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:10:23 +0100 Subject: [PATCH 14/79] gonna just use an index From b86c1d8809647f98a27da56e7cc65ddbd0387d4f Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:26:48 +0100 Subject: [PATCH 15/79] need to just do the logic now --- x/hub-genesis/keeper/ibc_module.go | 17 +++++++++++++++++ x/hub-genesis/keeper/ics4_wrapper.go | 12 +++++------- x/hub-genesis/keeper/sequence_numbers.go | 11 ++++++++++- x/hub-genesis/types/codec.go | 5 ++++- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 3aebe591..67015b10 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -9,6 +9,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" ) @@ -106,3 +107,19 @@ func (w IBCModule) mintAndTransfer(ctx sdk.Context, account types.GenesisAccount return nil } + +func (w IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + var data transfertypes.FungibleTokenPacketData + if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { + var ack channeltypes.Acknowledgement + if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { + w.k.ackSeqNum(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence, ack.Success()) + } + } + return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) +} diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index 540af3fa..ce5f5d5d 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -45,10 +45,6 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { - if !w.k.genesisIsFinished(ctx, sourcePort, sourceChannel) { - return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") - } - var transfer transfertypes.FungibleTokenPacketData _ = transfertypes.ModuleCdc.UnmarshalJSON(data, &transfer) @@ -57,15 +53,17 @@ func (w ICS4Wrapper) SendPacket( return 0, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "cannot use transfer genesis memo") } - // this is a genesis transfer, we record the sequence number - // record the sequence number because we need to tick them off as they get acked + // This is a genesis transfer, we record the sequence number. + // Record the sequence number because we need to tick them off as they get acked. seq, err := w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) if err != nil { return seq, err } - w.k.saveLastSequenceNumber(ctx, sourcePort, sourceChannel, seq) + w.k.saveSeqNum(ctx, sourcePort, sourceChannel, seq) return seq, nil + } else if !w.k.genesisIsFinished(ctx, sourcePort, sourceChannel) { + return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) } diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 63519af3..698a64bf 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -7,17 +7,26 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +/* +Whenever a genesis transfer is sent, we record the sequence number. We do not allow transfers until +all acks have been received with success. +*/ + func seqNumKey(port, channel string) []byte { return []byte(fmt.Sprintf("seqnum/%s/%s", port, channel)) } // NOTE: assumes monotonically increasing -func (k Keeper) saveLastSequenceNumber(ctx sdk.Context, port, channel string, seq uint64) { +func (k Keeper) saveSeqNum(ctx sdk.Context, port, channel string, seq uint64) { seqBz := make([]byte, 8) binary.BigEndian.PutUint64(seqBz, seq) ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) } +// ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer +func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, success bool) { +} + func (k Keeper) getLastSequenceNumber(ctx sdk.Context, port, channel string) uint64 { bz := ctx.KVStore(k.storeKey).Get(seqNumKey(port, channel)) return sdk.BigEndianToUint64(bz) diff --git a/x/hub-genesis/types/codec.go b/x/hub-genesis/types/codec.go index 7f623149..40a57b96 100644 --- a/x/hub-genesis/types/codec.go +++ b/x/hub-genesis/types/codec.go @@ -17,4 +17,7 @@ func init() { amino.Seal() } -var amino = codec.NewLegacyAmino() +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) From 35f4804e9c056268f98e46617d6377c3947a4de6 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:31:05 +0100 Subject: [PATCH 16/79] pre regen proto --- proto/hub-genesis/state.proto | 8 +- x/hub-genesis/keeper/sequence_numbers.go | 10 +- x/hub-genesis/types/state.pb.go | 184 ++++++++++++++++++----- 3 files changed, 159 insertions(+), 43 deletions(-) diff --git a/proto/hub-genesis/state.proto b/proto/hub-genesis/state.proto index 132a4eda..a4f0e662 100644 --- a/proto/hub-genesis/state.proto +++ b/proto/hub-genesis/state.proto @@ -12,8 +12,12 @@ message State { reserved 2; // accounts on the Hub to fund with some bootstrapping transfers repeated GenesisAccount genesis_accounts = 3 [(gogoproto.nullable) = false]; - // is the genesis transfer phase finished? True when acks received for all transfers. - bool finished = 4; + // the sequence numbers of outbound genesis transfers for which an ack has not yet been received + repeated uint64 unacked_seq_nums = 4[(gogoproto.nullable) = false]; + // the number size of unacked_seq_nums + uint64 num_unacked_seq_nums = 5; + // are outboundTransfersEnabled? This is only true if the genesis protocol has finished + bool outboundTransfersEnabled = 6; } // GenesisAccount is a struct for the genesis account for the rollapp diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 698a64bf..d76a1aa6 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -16,15 +16,23 @@ func seqNumKey(port, channel string) []byte { return []byte(fmt.Sprintf("seqnum/%s/%s", port, channel)) } -// NOTE: assumes monotonically increasing func (k Keeper) saveSeqNum(ctx sdk.Context, port, channel string, seq uint64) { seqBz := make([]byte, 8) binary.BigEndian.PutUint64(seqBz, seq) ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) } +func (k Keeper) delSeqNum(ctx sdk.Context, port, channel string, seq uint64) { + seqBz := make([]byte, 8) + binary.BigEndian.PutUint64(seqBz, seq) + ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) +} + // ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, success bool) { + if !success { + panic(fmt.Sprintf("genesis transfer unsuccessful, port: %s, channel: %s: seq: %d", port, channel, seq)) + } } func (k Keeper) getLastSequenceNumber(ctx sdk.Context, port, channel string) uint64 { diff --git a/x/hub-genesis/types/state.pb.go b/x/hub-genesis/types/state.pb.go index 84ba7022..8a886345 100644 --- a/x/hub-genesis/types/state.pb.go +++ b/x/hub-genesis/types/state.pb.go @@ -27,9 +27,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // State holds the state of the genesis event type State struct { // accounts on the Hub to fund with some bootstrapping transfers - GenesisAccounts []GenesisAccount `protobuf:"bytes,3,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` - // is the genesis transfer phase finished? - Finished bool `protobuf:"varint,4,opt,name=finished,proto3" json:"finished,omitempty"` + GenesisAccounts []GenesisAccount `protobuf:"bytes,3,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` + UnackedSeqNums []uint64 `protobuf:"varint,4,rep,packed,name=unacked_seq_nums,json=unackedSeqNums,proto3" json:"unacked_seq_nums,omitempty"` + NumUnackedSeqNums uint64 `protobuf:"varint,5,opt,name=num_unacked_seq_nums,json=numUnackedSeqNums,proto3" json:"num_unacked_seq_nums,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -72,11 +72,18 @@ func (m *State) GetGenesisAccounts() []GenesisAccount { return nil } -func (m *State) GetFinished() bool { +func (m *State) GetUnackedSeqNums() []uint64 { if m != nil { - return m.Finished + return m.UnackedSeqNums } - return false + return nil +} + +func (m *State) GetNumUnackedSeqNums() uint64 { + if m != nil { + return m.NumUnackedSeqNums + } + return 0 } // GenesisAccount is a struct for the genesis account for the rollapp @@ -142,28 +149,30 @@ func init() { func init() { proto.RegisterFile("hub-genesis/state.proto", fileDescriptor_1ad65c2fe0d953ab) } var fileDescriptor_1ad65c2fe0d953ab = []byte{ - // 321 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xbf, 0x4e, 0xc3, 0x30, - 0x18, 0xc4, 0xe3, 0x36, 0x94, 0xe0, 0x4a, 0x50, 0x05, 0x24, 0x42, 0x07, 0x13, 0x95, 0x25, 0x4b, - 0x6d, 0xb5, 0x0c, 0x88, 0x91, 0x32, 0x20, 0x75, 0x6c, 0x99, 0x58, 0x2a, 0x27, 0x31, 0x89, 0x45, - 0x63, 0x47, 0xb1, 0x83, 0x5a, 0x76, 0x76, 0x1e, 0xab, 0x63, 0x47, 0x26, 0x84, 0x9a, 0x17, 0x41, - 0x69, 0xc2, 0x9f, 0x4a, 0x4c, 0xfe, 0xce, 0xdf, 0x4f, 0x77, 0x3a, 0x1b, 0x9e, 0xc6, 0xb9, 0xdf, - 0x8f, 0x98, 0x60, 0x8a, 0x2b, 0xa2, 0x34, 0xd5, 0x0c, 0xa7, 0x99, 0xd4, 0xd2, 0x3e, 0xce, 0xe4, - 0x7c, 0x4e, 0xd3, 0x14, 0xc7, 0xb9, 0x3f, 0xab, 0x81, 0xee, 0x49, 0x24, 0x23, 0xb9, 0xdd, 0x93, - 0x72, 0xaa, 0xd0, 0x2e, 0x0a, 0xa4, 0x4a, 0xa4, 0x22, 0x3e, 0x55, 0x8c, 0x3c, 0x0f, 0x7c, 0xa6, - 0xe9, 0x80, 0x04, 0x92, 0x8b, 0x6a, 0xdf, 0x7b, 0x05, 0x70, 0x6f, 0x5a, 0x5a, 0xdb, 0xf7, 0xb0, - 0x53, 0x5b, 0xcd, 0x68, 0x10, 0xc8, 0x5c, 0x68, 0xe5, 0x34, 0xdd, 0xa6, 0xd7, 0x1e, 0x5e, 0xe0, - 0x7f, 0xf2, 0xf0, 0x5d, 0x75, 0xde, 0x54, 0xec, 0xc8, 0x5c, 0x7d, 0x9c, 0x1b, 0x93, 0xa3, 0x68, - 0xe7, 0x56, 0xd9, 0x5d, 0x68, 0x3d, 0x72, 0xc1, 0x55, 0xcc, 0x42, 0xc7, 0x74, 0x81, 0x67, 0x4d, - 0x7e, 0xf4, 0xd8, 0xb4, 0x40, 0xa7, 0x31, 0x36, 0xad, 0x46, 0xa7, 0xd9, 0x0b, 0xe0, 0xe1, 0xae, - 0xa1, 0x7d, 0x05, 0x5b, 0x34, 0x29, 0x27, 0x07, 0xb8, 0xc0, 0x6b, 0x0f, 0xcf, 0x70, 0x55, 0x05, - 0x97, 0x55, 0x70, 0x5d, 0x05, 0xdf, 0x4a, 0x2e, 0xea, 0xec, 0x1a, 0xb7, 0x1d, 0xb8, 0x4f, 0xc3, - 0x30, 0x63, 0x4a, 0x39, 0x0d, 0x17, 0x78, 0x07, 0x93, 0x6f, 0x39, 0x9a, 0xae, 0x36, 0x08, 0xac, - 0x37, 0x08, 0x7c, 0x6e, 0x10, 0x78, 0x2b, 0x90, 0xb1, 0x2e, 0x90, 0xf1, 0x5e, 0x20, 0xe3, 0xe1, - 0x3a, 0xe2, 0x3a, 0xce, 0x7d, 0x1c, 0xc8, 0x84, 0x84, 0xcb, 0x84, 0x09, 0xc5, 0xa5, 0x58, 0x2c, - 0x5f, 0x7e, 0x45, 0x3f, 0x0b, 0x9f, 0xc8, 0x82, 0xfc, 0xfd, 0x12, 0xbd, 0x4c, 0x99, 0xf2, 0x5b, - 0xdb, 0x87, 0xbc, 0xfc, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x79, 0xf9, 0x87, 0xae, 0x01, 0x00, - 0x00, + // 358 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0x31, 0x6f, 0xe2, 0x30, + 0x14, 0x8e, 0x49, 0xe0, 0x38, 0x23, 0x71, 0xb9, 0x1c, 0xd2, 0xe5, 0x18, 0x72, 0x11, 0x5d, 0xb2, + 0x60, 0x0b, 0x3a, 0x54, 0x1d, 0x4b, 0x87, 0x4a, 0x0c, 0x1d, 0xa0, 0x5d, 0xba, 0x44, 0x4e, 0x62, + 0x85, 0x08, 0x6c, 0x87, 0x38, 0xae, 0xa0, 0xbf, 0xa2, 0x3f, 0x0b, 0x75, 0x62, 0xec, 0x54, 0x55, + 0xf0, 0x47, 0xaa, 0x90, 0x54, 0x2d, 0x6a, 0x27, 0xbf, 0xe7, 0xef, 0xfb, 0xde, 0x7b, 0xfa, 0x3e, + 0xf8, 0x77, 0xa6, 0x82, 0x7e, 0x4c, 0x39, 0x95, 0x89, 0xc4, 0x32, 0x27, 0x39, 0x45, 0x69, 0x26, + 0x72, 0x61, 0xfd, 0xc9, 0xc4, 0x62, 0x41, 0xd2, 0x14, 0xcd, 0x54, 0xe0, 0x57, 0x84, 0x6e, 0x27, + 0x16, 0xb1, 0x38, 0xe0, 0xb8, 0xa8, 0x4a, 0x6a, 0xd7, 0x09, 0x85, 0x64, 0x42, 0xe2, 0x80, 0x48, + 0x8a, 0xef, 0x07, 0x01, 0xcd, 0xc9, 0x00, 0x87, 0x22, 0xe1, 0x25, 0xde, 0x7b, 0x02, 0xb0, 0x3e, + 0x2d, 0x46, 0x5b, 0x37, 0xd0, 0xac, 0x46, 0xf9, 0x24, 0x0c, 0x85, 0xe2, 0xb9, 0xb4, 0x75, 0x57, + 0xf7, 0x5a, 0xc3, 0x13, 0xf4, 0xcd, 0x3e, 0x74, 0x55, 0xbe, 0x17, 0x25, 0x77, 0x64, 0x6c, 0x5e, + 0xfe, 0x6b, 0x93, 0x5f, 0xf1, 0xd1, 0xaf, 0xb4, 0x10, 0x34, 0x15, 0x27, 0xe1, 0x9c, 0x46, 0xbe, + 0xa4, 0x4b, 0x9f, 0x2b, 0x26, 0x6d, 0xc3, 0xd5, 0x3d, 0xa3, 0x12, 0xb4, 0x2b, 0x74, 0x4a, 0x97, + 0xd7, 0x8a, 0x49, 0x0b, 0xc3, 0x0e, 0x57, 0xcc, 0xff, 0xa2, 0xa9, 0xbb, 0xc0, 0x33, 0x26, 0xbf, + 0xb9, 0x62, 0xb7, 0x47, 0x82, 0xb1, 0xd1, 0x04, 0x66, 0x6d, 0x6c, 0x34, 0x6b, 0xa6, 0xde, 0x0b, + 0x61, 0xfb, 0xf8, 0x2a, 0xeb, 0x0c, 0x36, 0x08, 0x2b, 0x2a, 0x1b, 0xb8, 0xc0, 0x6b, 0x0d, 0xff, + 0xa1, 0xd2, 0x0f, 0x54, 0xf8, 0x81, 0x2a, 0x3f, 0xd0, 0xa5, 0x48, 0x78, 0x75, 0x4f, 0x45, 0xb7, + 0x6c, 0xf8, 0x83, 0x44, 0x51, 0x46, 0xa5, 0xb4, 0x6b, 0x2e, 0xf0, 0x7e, 0x4e, 0xde, 0xdb, 0xd1, + 0x74, 0xb3, 0x73, 0xc0, 0x76, 0xe7, 0x80, 0xd7, 0x9d, 0x03, 0x1e, 0xf7, 0x8e, 0xb6, 0xdd, 0x3b, + 0xda, 0xf3, 0xde, 0xd1, 0xee, 0xce, 0xe3, 0x24, 0x9f, 0xa9, 0x00, 0x85, 0x82, 0xe1, 0x68, 0xcd, + 0x28, 0x97, 0x89, 0xe0, 0xab, 0xf5, 0xc3, 0x47, 0xd3, 0xcf, 0xa2, 0x39, 0x5e, 0xe1, 0xcf, 0xb9, + 0xe6, 0xeb, 0x94, 0xca, 0xa0, 0x71, 0x48, 0xe3, 0xf4, 0x2d, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x34, + 0x48, 0x78, 0xf3, 0x01, 0x00, 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -186,15 +195,28 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Finished { + if m.NumUnackedSeqNums != 0 { + i = encodeVarintState(dAtA, i, uint64(m.NumUnackedSeqNums)) i-- - if m.Finished { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + dAtA[i] = 0x28 + } + if len(m.UnackedSeqNums) > 0 { + dAtA2 := make([]byte, len(m.UnackedSeqNums)*10) + var j1 int + for _, num := range m.UnackedSeqNums { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintState(dAtA, i, uint64(j1)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.GenesisAccounts) > 0 { for iNdEx := len(m.GenesisAccounts) - 1; iNdEx >= 0; iNdEx-- { @@ -276,8 +298,15 @@ func (m *State) Size() (n int) { n += 1 + l + sovState(uint64(l)) } } - if m.Finished { - n += 2 + if len(m.UnackedSeqNums) > 0 { + l = 0 + for _, e := range m.UnackedSeqNums { + l += sovState(uint64(e)) + } + n += 1 + sovState(uint64(l)) + l + } + if m.NumUnackedSeqNums != 0 { + n += 1 + sovState(uint64(m.NumUnackedSeqNums)) } return n } @@ -367,10 +396,86 @@ func (m *State) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UnackedSeqNums = append(m.UnackedSeqNums, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.UnackedSeqNums) == 0 { + m.UnackedSeqNums = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UnackedSeqNums = append(m.UnackedSeqNums, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field UnackedSeqNums", wireType) + } + case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Finished", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NumUnackedSeqNums", wireType) } - var v int + m.NumUnackedSeqNums = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowState @@ -380,12 +485,11 @@ func (m *State) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.NumUnackedSeqNums |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.Finished = bool(v != 0) default: iNdEx = preIndex skippy, err := skipState(dAtA[iNdEx:]) From 1a139b6e1a68039f37145cc71c8734121d9fa68a Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:31:55 +0100 Subject: [PATCH 17/79] regen proto --- proto/hub-genesis/state.proto | 2 +- x/hub-genesis/types/state.pb.go | 100 +++++++++++++++++++++++--------- 2 files changed, 74 insertions(+), 28 deletions(-) diff --git a/proto/hub-genesis/state.proto b/proto/hub-genesis/state.proto index a4f0e662..70d657a8 100644 --- a/proto/hub-genesis/state.proto +++ b/proto/hub-genesis/state.proto @@ -13,7 +13,7 @@ message State { // accounts on the Hub to fund with some bootstrapping transfers repeated GenesisAccount genesis_accounts = 3 [(gogoproto.nullable) = false]; // the sequence numbers of outbound genesis transfers for which an ack has not yet been received - repeated uint64 unacked_seq_nums = 4[(gogoproto.nullable) = false]; + repeated uint64 unacked_seq_nums = 4 [(gogoproto.nullable) = false]; // the number size of unacked_seq_nums uint64 num_unacked_seq_nums = 5; // are outboundTransfersEnabled? This is only true if the genesis protocol has finished diff --git a/x/hub-genesis/types/state.pb.go b/x/hub-genesis/types/state.pb.go index 8a886345..2e3ba917 100644 --- a/x/hub-genesis/types/state.pb.go +++ b/x/hub-genesis/types/state.pb.go @@ -27,9 +27,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // State holds the state of the genesis event type State struct { // accounts on the Hub to fund with some bootstrapping transfers - GenesisAccounts []GenesisAccount `protobuf:"bytes,3,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` - UnackedSeqNums []uint64 `protobuf:"varint,4,rep,packed,name=unacked_seq_nums,json=unackedSeqNums,proto3" json:"unacked_seq_nums,omitempty"` - NumUnackedSeqNums uint64 `protobuf:"varint,5,opt,name=num_unacked_seq_nums,json=numUnackedSeqNums,proto3" json:"num_unacked_seq_nums,omitempty"` + GenesisAccounts []GenesisAccount `protobuf:"bytes,3,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` + // the sequence numbers of outbound genesis transfers for which an ack has not yet been received + UnackedSeqNums []uint64 `protobuf:"varint,4,rep,packed,name=unacked_seq_nums,json=unackedSeqNums,proto3" json:"unacked_seq_nums,omitempty"` + // the number size of unacked_seq_nums + NumUnackedSeqNums uint64 `protobuf:"varint,5,opt,name=num_unacked_seq_nums,json=numUnackedSeqNums,proto3" json:"num_unacked_seq_nums,omitempty"` + // are outboundTransfersEnabled? This is only true if the genesis protocol has finished + OutboundTransfersEnabled bool `protobuf:"varint,6,opt,name=outboundTransfersEnabled,proto3" json:"outboundTransfersEnabled,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -86,6 +90,13 @@ func (m *State) GetNumUnackedSeqNums() uint64 { return 0 } +func (m *State) GetOutboundTransfersEnabled() bool { + if m != nil { + return m.OutboundTransfersEnabled + } + return false +} + // GenesisAccount is a struct for the genesis account for the rollapp type GenesisAccount struct { // amount of coins to be sent to the genesis address @@ -149,30 +160,32 @@ func init() { func init() { proto.RegisterFile("hub-genesis/state.proto", fileDescriptor_1ad65c2fe0d953ab) } var fileDescriptor_1ad65c2fe0d953ab = []byte{ - // 358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0x31, 0x6f, 0xe2, 0x30, - 0x14, 0x8e, 0x49, 0xe0, 0x38, 0x23, 0x71, 0xb9, 0x1c, 0xd2, 0xe5, 0x18, 0x72, 0x11, 0x5d, 0xb2, - 0x60, 0x0b, 0x3a, 0x54, 0x1d, 0x4b, 0x87, 0x4a, 0x0c, 0x1d, 0xa0, 0x5d, 0xba, 0x44, 0x4e, 0x62, - 0x85, 0x08, 0x6c, 0x87, 0x38, 0xae, 0xa0, 0xbf, 0xa2, 0x3f, 0x0b, 0x75, 0x62, 0xec, 0x54, 0x55, - 0xf0, 0x47, 0xaa, 0x90, 0x54, 0x2d, 0x6a, 0x27, 0xbf, 0xe7, 0xef, 0xfb, 0xde, 0x7b, 0xfa, 0x3e, - 0xf8, 0x77, 0xa6, 0x82, 0x7e, 0x4c, 0x39, 0x95, 0x89, 0xc4, 0x32, 0x27, 0x39, 0x45, 0x69, 0x26, - 0x72, 0x61, 0xfd, 0xc9, 0xc4, 0x62, 0x41, 0xd2, 0x14, 0xcd, 0x54, 0xe0, 0x57, 0x84, 0x6e, 0x27, - 0x16, 0xb1, 0x38, 0xe0, 0xb8, 0xa8, 0x4a, 0x6a, 0xd7, 0x09, 0x85, 0x64, 0x42, 0xe2, 0x80, 0x48, - 0x8a, 0xef, 0x07, 0x01, 0xcd, 0xc9, 0x00, 0x87, 0x22, 0xe1, 0x25, 0xde, 0x7b, 0x02, 0xb0, 0x3e, - 0x2d, 0x46, 0x5b, 0x37, 0xd0, 0xac, 0x46, 0xf9, 0x24, 0x0c, 0x85, 0xe2, 0xb9, 0xb4, 0x75, 0x57, - 0xf7, 0x5a, 0xc3, 0x13, 0xf4, 0xcd, 0x3e, 0x74, 0x55, 0xbe, 0x17, 0x25, 0x77, 0x64, 0x6c, 0x5e, - 0xfe, 0x6b, 0x93, 0x5f, 0xf1, 0xd1, 0xaf, 0xb4, 0x10, 0x34, 0x15, 0x27, 0xe1, 0x9c, 0x46, 0xbe, - 0xa4, 0x4b, 0x9f, 0x2b, 0x26, 0x6d, 0xc3, 0xd5, 0x3d, 0xa3, 0x12, 0xb4, 0x2b, 0x74, 0x4a, 0x97, - 0xd7, 0x8a, 0x49, 0x0b, 0xc3, 0x0e, 0x57, 0xcc, 0xff, 0xa2, 0xa9, 0xbb, 0xc0, 0x33, 0x26, 0xbf, - 0xb9, 0x62, 0xb7, 0x47, 0x82, 0xb1, 0xd1, 0x04, 0x66, 0x6d, 0x6c, 0x34, 0x6b, 0xa6, 0xde, 0x0b, - 0x61, 0xfb, 0xf8, 0x2a, 0xeb, 0x0c, 0x36, 0x08, 0x2b, 0x2a, 0x1b, 0xb8, 0xc0, 0x6b, 0x0d, 0xff, - 0xa1, 0xd2, 0x0f, 0x54, 0xf8, 0x81, 0x2a, 0x3f, 0xd0, 0xa5, 0x48, 0x78, 0x75, 0x4f, 0x45, 0xb7, - 0x6c, 0xf8, 0x83, 0x44, 0x51, 0x46, 0xa5, 0xb4, 0x6b, 0x2e, 0xf0, 0x7e, 0x4e, 0xde, 0xdb, 0xd1, - 0x74, 0xb3, 0x73, 0xc0, 0x76, 0xe7, 0x80, 0xd7, 0x9d, 0x03, 0x1e, 0xf7, 0x8e, 0xb6, 0xdd, 0x3b, - 0xda, 0xf3, 0xde, 0xd1, 0xee, 0xce, 0xe3, 0x24, 0x9f, 0xa9, 0x00, 0x85, 0x82, 0xe1, 0x68, 0xcd, - 0x28, 0x97, 0x89, 0xe0, 0xab, 0xf5, 0xc3, 0x47, 0xd3, 0xcf, 0xa2, 0x39, 0x5e, 0xe1, 0xcf, 0xb9, - 0xe6, 0xeb, 0x94, 0xca, 0xa0, 0x71, 0x48, 0xe3, 0xf4, 0x2d, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x34, - 0x48, 0x78, 0xf3, 0x01, 0x00, 0x00, + // 389 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x31, 0x8f, 0xd3, 0x30, + 0x14, 0x8e, 0x93, 0x5c, 0x29, 0x3e, 0xe9, 0x08, 0xe1, 0x24, 0xc2, 0x0d, 0x21, 0x3a, 0x96, 0x2c, + 0x67, 0xeb, 0x8e, 0x01, 0xc1, 0xc6, 0x21, 0x84, 0x74, 0x03, 0x43, 0x7a, 0x2c, 0x2c, 0x91, 0x9d, + 0x98, 0x34, 0x6a, 0x6d, 0xa7, 0x79, 0x36, 0x6a, 0xf9, 0x01, 0xcc, 0xfc, 0xac, 0x8e, 0x1d, 0x99, + 0x10, 0x6a, 0xff, 0x08, 0x4a, 0x13, 0x04, 0x15, 0xdc, 0xe4, 0xf7, 0xfc, 0x7d, 0xdf, 0xb3, 0xbe, + 0xcf, 0x0f, 0x3f, 0x9e, 0x5a, 0x7e, 0x51, 0x09, 0x25, 0xa0, 0x06, 0x0a, 0x86, 0x19, 0x41, 0x9a, + 0x56, 0x1b, 0x1d, 0x3e, 0x6a, 0xf5, 0x7c, 0xce, 0x9a, 0x86, 0x4c, 0x2d, 0xcf, 0x07, 0xc2, 0xd9, + 0x69, 0xa5, 0x2b, 0xbd, 0xc7, 0x69, 0x57, 0xf5, 0xd4, 0xb3, 0xb8, 0xd0, 0x20, 0x35, 0x50, 0xce, + 0x40, 0xd0, 0xcf, 0x97, 0x5c, 0x18, 0x76, 0x49, 0x0b, 0x5d, 0xab, 0x1e, 0x3f, 0xff, 0xea, 0xe2, + 0xa3, 0x49, 0x37, 0x3a, 0xbc, 0xc5, 0xc1, 0x30, 0x2a, 0x67, 0x45, 0xa1, 0xad, 0x32, 0x10, 0x79, + 0x89, 0x97, 0x1e, 0x5f, 0x3d, 0x23, 0xff, 0x79, 0x8f, 0xbc, 0xeb, 0xcf, 0xd7, 0x3d, 0xf7, 0xda, + 0x5f, 0xff, 0x78, 0xea, 0x64, 0x0f, 0xaa, 0x83, 0x5b, 0x08, 0x09, 0x0e, 0xac, 0x62, 0xc5, 0x4c, + 0x94, 0x39, 0x88, 0x45, 0xae, 0xac, 0x84, 0xc8, 0x4f, 0xbc, 0xd4, 0x1f, 0x04, 0x27, 0x03, 0x3a, + 0x11, 0x8b, 0xf7, 0x56, 0x42, 0x48, 0xf1, 0xa9, 0xb2, 0x32, 0xff, 0x47, 0x73, 0x94, 0xa0, 0xd4, + 0xcf, 0x1e, 0x2a, 0x2b, 0x3f, 0x1c, 0x0a, 0x5e, 0xe1, 0x48, 0x5b, 0xc3, 0xb5, 0x55, 0xe5, 0x6d, + 0xcb, 0x14, 0x7c, 0x12, 0x2d, 0xbc, 0x55, 0x8c, 0xcf, 0x45, 0x19, 0x8d, 0x12, 0x94, 0x8e, 0xb3, + 0x3b, 0xf1, 0x1b, 0x7f, 0x8c, 0x02, 0xf7, 0xc6, 0x1f, 0xbb, 0x81, 0x77, 0x5e, 0xe0, 0x93, 0x43, + 0x47, 0xe1, 0x0b, 0x3c, 0x62, 0xb2, 0xab, 0x22, 0x94, 0xa0, 0xf4, 0xf8, 0xea, 0x09, 0xe9, 0xb3, + 0x24, 0x5d, 0x96, 0x64, 0xc8, 0x92, 0xbc, 0xd1, 0xb5, 0x1a, 0xbc, 0x0c, 0xf4, 0x30, 0xc2, 0xf7, + 0x58, 0x59, 0xb6, 0x02, 0x20, 0x72, 0x13, 0x94, 0xde, 0xcf, 0x7e, 0xb7, 0xd7, 0x93, 0xf5, 0x36, + 0x46, 0x9b, 0x6d, 0x8c, 0x7e, 0x6e, 0x63, 0xf4, 0x6d, 0x17, 0x3b, 0x9b, 0x5d, 0xec, 0x7c, 0xdf, + 0xc5, 0xce, 0xc7, 0x97, 0x55, 0x6d, 0xa6, 0x96, 0x93, 0x42, 0x4b, 0x5a, 0xae, 0xa4, 0x50, 0x50, + 0x6b, 0xb5, 0x5c, 0x7d, 0xf9, 0xd3, 0x5c, 0xb4, 0xe5, 0x8c, 0x2e, 0xe9, 0xdf, 0x3b, 0x61, 0x56, + 0x8d, 0x00, 0x3e, 0xda, 0xff, 0xe4, 0xf3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x00, 0xaf, 0xa8, + 0x75, 0x2f, 0x02, 0x00, 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -195,6 +208,16 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.OutboundTransfersEnabled { + i-- + if m.OutboundTransfersEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } if m.NumUnackedSeqNums != 0 { i = encodeVarintState(dAtA, i, uint64(m.NumUnackedSeqNums)) i-- @@ -308,6 +331,9 @@ func (m *State) Size() (n int) { if m.NumUnackedSeqNums != 0 { n += 1 + sovState(uint64(m.NumUnackedSeqNums)) } + if m.OutboundTransfersEnabled { + n += 2 + } return n } @@ -490,6 +516,26 @@ func (m *State) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OutboundTransfersEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OutboundTransfersEnabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipState(dAtA[iNdEx:]) From 6612b8d955c4bcf948e71259a83d320d2ab0bbf3 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:39:14 +0100 Subject: [PATCH 18/79] just realised you cant use a cnter --- x/hub-genesis/keeper/sequence_numbers.go | 50 ++++++++++++++++++------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index d76a1aa6..8682cfd7 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -1,7 +1,6 @@ package keeper import ( - "encoding/binary" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,20 +11,40 @@ Whenever a genesis transfer is sent, we record the sequence number. We do not al all acks have been received with success. */ -func seqNumKey(port, channel string) []byte { - return []byte(fmt.Sprintf("seqnum/%s/%s", port, channel)) +func seqNumKey(port, channel string, seq uint64) []byte { + bz := []byte(fmt.Sprintf("seqnumval/%s/%s", port, channel)) + bz = append(bz, sdk.Uint64ToBigEndian(seq)...) + return bz +} + +func numUnackedSeqNumsKey(port, channel string) []byte { + bz := []byte(fmt.Sprintf("seqnumcnt/%s/%s", port, channel)) + return bz } func (k Keeper) saveSeqNum(ctx sdk.Context, port, channel string, seq uint64) { - seqBz := make([]byte, 8) - binary.BigEndian.PutUint64(seqBz, seq) - ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) + ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel, seq), []byte{}) + cnt := k.getNumUnackedSeqNums(ctx, port, channel) + cnt++ + k.saveNumUnackedSeqNums(ctx, port, channel, cnt) } func (k Keeper) delSeqNum(ctx sdk.Context, port, channel string, seq uint64) { - seqBz := make([]byte, 8) - binary.BigEndian.PutUint64(seqBz, seq) - ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel), seqBz) + ctx.KVStore(k.storeKey).Delete(seqNumKey(port, channel, seq)) +} + +func (k Keeper) hasSeqNum(ctx sdk.Context, port, channel string, seq uint64) bool { + return ctx.KVStore(k.storeKey).Has(seqNumKey(port, channel, seq)) +} + +func (k Keeper) saveNumUnackedSeqNums(ctx sdk.Context, port, channel string, cnt uint64) { + bz := sdk.Uint64ToBigEndian(cnt) + ctx.KVStore(k.storeKey).Set(numUnackedSeqNumsKey(port, channel), bz) +} + +func (k Keeper) getNumUnackedSeqNums(ctx sdk.Context, port, channel string) uint64 { + bz := ctx.KVStore(k.storeKey).Get(numUnackedSeqNumsKey(port, channel)) + return sdk.BigEndianToUint64(bz) } // ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer @@ -33,11 +52,18 @@ func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, suc if !success { panic(fmt.Sprintf("genesis transfer unsuccessful, port: %s, channel: %s: seq: %d", port, channel, seq)) } + if k.hasSeqNum(ctx, port, channel, seq) { + k.delSeqNum(ctx, port, channel, seq) + cnt := k.getNumUnackedSeqNums(ctx, port, channel) + cnt-- + k.saveNumUnackedSeqNums(ctx, port, channel, cnt) + } } -func (k Keeper) getLastSequenceNumber(ctx sdk.Context, port, channel string) uint64 { - bz := ctx.KVStore(k.storeKey).Get(seqNumKey(port, channel)) - return sdk.BigEndianToUint64(bz) +func (k Keeper) numUnackedSeqNums(ctx sdk.Context, port, channel string) uint64 { + if !success { + panic(fmt.Sprintf("genesis transfer unsuccessful, port: %s, channel: %s: seq: %d", port, channel, seq)) + } } // genesisIsFinished returns if the genesis bridge protocol phase is finished. It is finished From 5051341a7d8119d6178da957bf5e8c0585783206 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:43:46 +0100 Subject: [PATCH 19/79] ready for a test, then will have to do genesis --- x/hub-genesis/keeper/ics4_wrapper.go | 2 +- x/hub-genesis/keeper/sequence_numbers.go | 35 ++++++------------------ 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index ce5f5d5d..a5f40c67 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -62,7 +62,7 @@ func (w ICS4Wrapper) SendPacket( } w.k.saveSeqNum(ctx, sourcePort, sourceChannel, seq) return seq, nil - } else if !w.k.genesisIsFinished(ctx, sourcePort, sourceChannel) { + } else if !w.k.outboundTransfersEnabled(ctx) { return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 8682cfd7..99ceb6b6 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -57,35 +57,16 @@ func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, suc cnt := k.getNumUnackedSeqNums(ctx, port, channel) cnt-- k.saveNumUnackedSeqNums(ctx, port, channel, cnt) + if cnt == 0 { + // all acks have come back successfully + state := k.GetState(ctx) + state.OutboundTransfersEnabled = true + k.SetState(ctx, state) + } } } -func (k Keeper) numUnackedSeqNums(ctx sdk.Context, port, channel string) uint64 { - if !success { - panic(fmt.Sprintf("genesis transfer unsuccessful, port: %s, channel: %s: seq: %d", port, channel, seq)) - } -} - -// genesisIsFinished returns if the genesis bridge protocol phase is finished. It is finished -// when all genesis transfers sent from the RA to the Hub have been acked. After this you're -// allowed to send regular transfers. The first regular transfer received on the Hub marks -// the end of the protocol from the Hub's perspective. -func (k Keeper) genesisIsFinished(ctx sdk.Context, port, channel string) bool { +func (k Keeper) outboundTransfersEnabled(ctx sdk.Context) bool { state := k.GetState(ctx) - if state.GetFinished() { - return true - } - // This operation may not be super cheap, but once the genesis phase is finished, it won't be necessary. - // Much simpler than using a map to check off each seq num. - for seq := range k.getLastSequenceNumber(ctx, port, channel) + 1 { - bz := k.channelKeeper.GetPacketCommitment(ctx, port, channel, seq) - if len(bz) != 0 { - // there is still a sequence number for which we didn't get an ack back yet - // so we still need to wait some more. - return false - } - } - state.Finished = true - k.SetState(ctx, state) - return true + return state.OutboundTransfersEnabled } From f4b5d69e7b3e87042c0aa4985b22a1e754c825e8 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:44:08 +0100 Subject: [PATCH 20/79] lets test --- x/hub-genesis/keeper/sequence_numbers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 99ceb6b6..b21f1ed7 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -12,7 +12,7 @@ all acks have been received with success. */ func seqNumKey(port, channel string, seq uint64) []byte { - bz := []byte(fmt.Sprintf("seqnumval/%s/%s", port, channel)) + bz := []byte(fmt.Sprintf("seqnumval/%s/%s/", port, channel)) bz = append(bz, sdk.Uint64ToBigEndian(seq)...) return bz } From 0e97d27bbe0cfb3450bbb98082d988880fa57006 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:52:09 +0100 Subject: [PATCH 21/79] add an event --- x/hub-genesis/keeper/sequence_numbers.go | 12 +++++++++--- x/hub-genesis/types/events.go | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 x/hub-genesis/types/events.go diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index b21f1ed7..8e57d883 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -4,6 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" ) /* @@ -59,9 +60,7 @@ func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, suc k.saveNumUnackedSeqNums(ctx, port, channel, cnt) if cnt == 0 { // all acks have come back successfully - state := k.GetState(ctx) - state.OutboundTransfersEnabled = true - k.SetState(ctx, state) + k.enableOutboundTransfers(ctx) } } } @@ -70,3 +69,10 @@ func (k Keeper) outboundTransfersEnabled(ctx sdk.Context) bool { state := k.GetState(ctx) return state.OutboundTransfersEnabled } + +func (k Keeper) enableOutboundTransfers(ctx sdk.Context) { + state := k.GetState(ctx) + state.OutboundTransfersEnabled = true + ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeOutboundTransfersEnabled)) + k.SetState(ctx, state) +} diff --git a/x/hub-genesis/types/events.go b/x/hub-genesis/types/events.go new file mode 100644 index 00000000..19c58505 --- /dev/null +++ b/x/hub-genesis/types/events.go @@ -0,0 +1,5 @@ +package types + +const ( + EventTypeOutboundTransfersEnabled = "transfer_genesis_outbound_transfers_enabled" +) From 3618724486dd05695510d01c209174e27ec3e83c Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:56:12 +0100 Subject: [PATCH 22/79] pre del params --- x/hub-genesis/keeper/sequence_numbers.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 8e57d883..dd1996c7 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -66,6 +66,7 @@ func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, suc } func (k Keeper) outboundTransfersEnabled(ctx sdk.Context) bool { + k.Logger(ctx).With("module", types.ModuleName).Debug("outbound transfers enabled") state := k.GetState(ctx) return state.OutboundTransfersEnabled } From 85fe9c30c46da365b6f941f4ae804a2bde017c20 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:58:12 +0100 Subject: [PATCH 23/79] regen proto --- proto/hub-genesis/genesis.proto | 4 +- proto/hub-genesis/params.proto | 13 - proto/hub-genesis/query.proto | 16 -- x/hub-genesis/client/cli/query.go | 30 --- x/hub-genesis/keeper/grpc_query.go | 9 +- x/hub-genesis/keeper/params.go | 18 -- x/hub-genesis/types/genesis.pb.go | 80 +----- x/hub-genesis/types/query.pb.go | 379 ++--------------------------- x/hub-genesis/types/query.pb.gw.go | 65 ----- 9 files changed, 35 insertions(+), 579 deletions(-) delete mode 100644 proto/hub-genesis/params.proto delete mode 100644 x/hub-genesis/keeper/params.go diff --git a/proto/hub-genesis/genesis.proto b/proto/hub-genesis/genesis.proto index 3e226f34..31a8470c 100755 --- a/proto/hub-genesis/genesis.proto +++ b/proto/hub-genesis/genesis.proto @@ -2,14 +2,12 @@ syntax = "proto3"; package rollapp.hub_genesis; import "gogoproto/gogo.proto"; -import "hub-genesis/params.proto"; import "hub-genesis/state.proto"; option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; // GenesisState defines the hub-genesis module's genesis state. message GenesisState { - // params defines all the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; + reserved 1; State state = 2 [(gogoproto.nullable) = false]; } diff --git a/proto/hub-genesis/params.proto b/proto/hub-genesis/params.proto deleted file mode 100644 index 0f0ec61c..00000000 --- a/proto/hub-genesis/params.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; -package rollapp.hub_genesis; - -option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; - -import "gogoproto/gogo.proto"; - -// Params holds parameters for the hub-genesis module. -message Params { - option (gogoproto.goproto_stringer) = false; - reserved 1; -} - diff --git a/proto/hub-genesis/query.proto b/proto/hub-genesis/query.proto index 35b30535..a47afd78 100644 --- a/proto/hub-genesis/query.proto +++ b/proto/hub-genesis/query.proto @@ -3,19 +3,12 @@ package rollapp.hub_genesis; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "hub-genesis/params.proto"; import "hub-genesis/state.proto"; option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; // Query provides defines the gRPC querier service. service Query { - // Params returns the total set of hub-genesis parameters. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = - "/dymensionxyz/dymension-rdk/hub-genesis/params"; - } - // State returns the state of the genesis event. rpc State(QueryStateRequest) returns (QueryStateResponse) { option (google.api.http).get = @@ -23,15 +16,6 @@ service Query { } } -// QueryParamsRequest is the request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryParamsResponse { - // params defines the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; -} - // QueryStateRequest is the request type for the Query/State RPC method. message QueryStateRequest {} diff --git a/x/hub-genesis/client/cli/query.go b/x/hub-genesis/client/cli/query.go index b33b8d82..0140f826 100644 --- a/x/hub-genesis/client/cli/query.go +++ b/x/hub-genesis/client/cli/query.go @@ -22,42 +22,12 @@ func GetQueryCmd() *cobra.Command { } hubGenQueryCmd.AddCommand( - GetCmdQueryParams(), GetCmdQueryState(), ) return hubGenQueryCmd } -// GetCmdQueryParams implements a command to return the current hub-genesis -// parameters. -func GetCmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "Query the current hub-genesis parameters", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryParamsRequest{} - res, err := queryClient.Params(context.Background(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(&res.Params) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - // GetCmdQueryState implements a command to return the current hub-genesis // state. func GetCmdQueryState() *cobra.Command { diff --git a/x/hub-genesis/keeper/grpc_query.go b/x/hub-genesis/keeper/grpc_query.go index 0f1e37a4..712d015c 100644 --- a/x/hub-genesis/keeper/grpc_query.go +++ b/x/hub-genesis/keeper/grpc_query.go @@ -20,15 +20,8 @@ func NewQuerier(k Keeper) Querier { return Querier{Keeper: k} } -// Params returns params of the hub-genesis module. -func (q Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - params := q.Keeper.GetParams(ctx) - - return &types.QueryParamsResponse{Params: params}, nil -} - func (q Querier) State(goCtx context.Context, request *types.QueryStateRequest) (*types.QueryStateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // TODO: return &types.QueryStateResponse{State: q.Keeper.GetState(ctx)}, nil } diff --git a/x/hub-genesis/keeper/params.go b/x/hub-genesis/keeper/params.go deleted file mode 100644 index b7dd1bbf..00000000 --- a/x/hub-genesis/keeper/params.go +++ /dev/null @@ -1,18 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" -) - -// GetParams returns the total set of minting parameters. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - k.paramstore.GetParamSet(ctx, ¶ms) - return params -} - -// SetParams sets the total set of minting parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) -} diff --git a/x/hub-genesis/types/genesis.pb.go b/x/hub-genesis/types/genesis.pb.go index 5cb6727f..2432ac9b 100644 --- a/x/hub-genesis/types/genesis.pb.go +++ b/x/hub-genesis/types/genesis.pb.go @@ -25,9 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the hub-genesis module's genesis state. type GenesisState struct { - // params defines all the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - State State `protobuf:"bytes,2,opt,name=state,proto3" json:"state"` + State State `protobuf:"bytes,2,opt,name=state,proto3" json:"state"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -63,13 +61,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - func (m *GenesisState) GetState() State { if m != nil { return m.State @@ -84,22 +75,20 @@ func init() { func init() { proto.RegisterFile("hub-genesis/genesis.proto", fileDescriptor_6deac3d79fd587fe) } var fileDescriptor_6deac3d79fd587fe = []byte{ - // 231 bytes of a gzipped FileDescriptorProto + // 204 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x28, 0x4d, 0xd2, 0x4d, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x87, 0xd2, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x45, 0xf9, 0x39, 0x39, 0x89, 0x05, 0x05, 0x7a, 0x19, 0xa5, 0x49, 0xf1, 0x50, 0x29, - 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xbc, 0x3e, 0x88, 0x05, 0x51, 0x2a, 0x25, 0x81, 0x6c, - 0x4a, 0x41, 0x62, 0x51, 0x62, 0x2e, 0xd4, 0x10, 0x29, 0x71, 0x64, 0x99, 0xe2, 0x92, 0xc4, 0x92, - 0x54, 0x88, 0x84, 0x52, 0x23, 0x23, 0x17, 0x8f, 0x3b, 0x44, 0x3c, 0x18, 0x24, 0x2c, 0x64, 0xc9, - 0xc5, 0x06, 0xd1, 0x29, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x7e, 0xbd, - 0x00, 0xb0, 0x12, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x84, 0xcc, 0xb8, 0x58, - 0xc1, 0x46, 0x4b, 0x30, 0x81, 0x75, 0x4a, 0x61, 0xd5, 0x09, 0xb6, 0x05, 0xaa, 0x11, 0xa2, 0xdc, - 0x29, 0xf8, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, - 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x2c, 0xd3, 0x33, 0x4b, - 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x53, 0x2a, 0x73, 0x53, 0xf3, 0x8a, 0x33, 0xf3, - 0xf3, 0x2a, 0x2a, 0xab, 0x10, 0x1c, 0xdd, 0xa2, 0x94, 0x6c, 0xfd, 0x0a, 0x7d, 0x64, 0xef, 0x95, - 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xfd, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xd3, - 0x81, 0x05, 0x3c, 0x5a, 0x01, 0x00, 0x00, + 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xbc, 0x3e, 0x88, 0x05, 0x51, 0x2a, 0x25, 0x8e, 0x6c, + 0x4a, 0x71, 0x49, 0x62, 0x49, 0x2a, 0x44, 0x42, 0xc9, 0x87, 0x8b, 0xc7, 0x1d, 0x22, 0x1c, 0x0c, + 0x12, 0x15, 0x32, 0xe3, 0x62, 0x05, 0x4b, 0x4b, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x49, 0xe9, + 0x61, 0xb1, 0x43, 0x0f, 0xac, 0xd4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x88, 0x72, 0x2f, + 0x16, 0x0e, 0x46, 0x01, 0x26, 0xa7, 0xe0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, + 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, + 0x88, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xa9, 0xcc, + 0x4d, 0xcd, 0x2b, 0xce, 0xcc, 0xcf, 0xab, 0xa8, 0xac, 0x42, 0x70, 0x74, 0x8b, 0x52, 0xb2, 0xf5, + 0x2b, 0xf4, 0x91, 0x1d, 0x5a, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0xa9, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0x29, 0x7b, 0x08, 0xad, 0x0a, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -132,16 +121,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -162,8 +141,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) l = m.State.Size() n += 1 + l + sovGenesis(uint64(l)) return n @@ -204,39 +181,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) diff --git a/x/hub-genesis/types/query.pb.go b/x/hub-genesis/types/query.pb.go index a1a82d10..f8733b8a 100644 --- a/x/hub-genesis/types/query.pb.go +++ b/x/hub-genesis/types/query.pb.go @@ -29,89 +29,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryParamsRequest is the request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_361b89f8abfb35e2, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is the response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // params defines the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_361b89f8abfb35e2, []int{1} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - // QueryStateRequest is the request type for the Query/State RPC method. type QueryStateRequest struct { } @@ -120,7 +37,7 @@ func (m *QueryStateRequest) Reset() { *m = QueryStateRequest{} } func (m *QueryStateRequest) String() string { return proto.CompactTextString(m) } func (*QueryStateRequest) ProtoMessage() {} func (*QueryStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_361b89f8abfb35e2, []int{2} + return fileDescriptor_361b89f8abfb35e2, []int{0} } func (m *QueryStateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -159,7 +76,7 @@ func (m *QueryStateResponse) Reset() { *m = QueryStateResponse{} } func (m *QueryStateResponse) String() string { return proto.CompactTextString(m) } func (*QueryStateResponse) ProtoMessage() {} func (*QueryStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_361b89f8abfb35e2, []int{3} + return fileDescriptor_361b89f8abfb35e2, []int{1} } func (m *QueryStateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -196,8 +113,6 @@ func (m *QueryStateResponse) GetState() State { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "rollapp.hub_genesis.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "rollapp.hub_genesis.QueryParamsResponse") proto.RegisterType((*QueryStateRequest)(nil), "rollapp.hub_genesis.QueryStateRequest") proto.RegisterType((*QueryStateResponse)(nil), "rollapp.hub_genesis.QueryStateResponse") } @@ -205,30 +120,25 @@ func init() { func init() { proto.RegisterFile("hub-genesis/query.proto", fileDescriptor_361b89f8abfb35e2) } var fileDescriptor_361b89f8abfb35e2 = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xb1, 0x4e, 0x3a, 0x31, - 0x1c, 0xc7, 0xaf, 0xe4, 0x0f, 0x43, 0xff, 0x93, 0x85, 0x44, 0x72, 0x9a, 0xd3, 0xdc, 0x20, 0x2c, - 0x5c, 0x0d, 0x46, 0x12, 0x56, 0x66, 0x07, 0x84, 0xcd, 0xc5, 0xf4, 0xa4, 0x39, 0x2e, 0x42, 0x5b, - 0xae, 0xbd, 0x84, 0x73, 0xf4, 0x05, 0x34, 0xe1, 0x41, 0x7c, 0x0d, 0x46, 0x12, 0x17, 0x27, 0x63, - 0xc0, 0x07, 0x31, 0xb4, 0x25, 0x42, 0x40, 0x71, 0x83, 0xfe, 0xbe, 0xbf, 0xef, 0xe7, 0x73, 0xbd, - 0x83, 0x87, 0xfd, 0x34, 0xac, 0x45, 0x94, 0x51, 0x19, 0x4b, 0x3c, 0x4a, 0x69, 0x92, 0x05, 0x22, - 0xe1, 0x8a, 0xa3, 0x62, 0xc2, 0x07, 0x03, 0x22, 0x44, 0xd0, 0x4f, 0xc3, 0x5b, 0x1b, 0x70, 0x4b, - 0x11, 0x8f, 0xb8, 0x9e, 0xe3, 0xe5, 0x2f, 0x13, 0x75, 0x8f, 0x23, 0xce, 0xa3, 0x01, 0xc5, 0x44, - 0xc4, 0x98, 0x30, 0xc6, 0x15, 0x51, 0x31, 0x67, 0xd2, 0x4e, 0xcb, 0xeb, 0x04, 0x41, 0x12, 0x32, - 0x5c, 0x4d, 0x36, 0xd8, 0x52, 0x11, 0x45, 0xcd, 0xc0, 0x2f, 0x41, 0x74, 0xbd, 0x54, 0x69, 0xeb, - 0x74, 0x87, 0x8e, 0x52, 0x2a, 0x95, 0xdf, 0x86, 0xc5, 0x8d, 0x53, 0x29, 0x38, 0x93, 0x14, 0x35, - 0x61, 0xc1, 0xb4, 0x96, 0xc1, 0x29, 0xa8, 0xfe, 0xaf, 0x1f, 0x05, 0x3b, 0xcc, 0x03, 0xb3, 0xd4, - 0xfa, 0x37, 0x7d, 0x3f, 0x71, 0x3a, 0x76, 0xc1, 0x2f, 0xc2, 0x03, 0xdd, 0xd8, 0x5d, 0xb2, 0x57, - 0x98, 0x2b, 0x0b, 0xb7, 0x87, 0x96, 0xd2, 0x80, 0x79, 0x6d, 0x68, 0x21, 0xee, 0x4e, 0x88, 0x5e, - 0xb1, 0x0c, 0x13, 0xaf, 0xbf, 0xe4, 0x60, 0x5e, 0xd7, 0xa1, 0x09, 0x80, 0x05, 0x63, 0x81, 0x2a, - 0x3b, 0xb7, 0xb7, 0x1f, 0xd9, 0xad, 0xee, 0x0f, 0x1a, 0x3f, 0xbf, 0xf1, 0xf8, 0xfa, 0x39, 0xc9, - 0x9d, 0xa3, 0x00, 0xf7, 0xb2, 0x21, 0x65, 0x32, 0xe6, 0x6c, 0x9c, 0x3d, 0x7c, 0xff, 0xa9, 0x25, - 0xbd, 0x7b, 0xbc, 0xfd, 0x26, 0xd0, 0x13, 0x80, 0x79, 0xad, 0x8d, 0xce, 0x7e, 0x66, 0xad, 0xdf, - 0x8f, 0x5b, 0xd9, 0x9b, 0xb3, 0x4a, 0x97, 0x5a, 0x09, 0xa3, 0xda, 0x5f, 0x95, 0xf4, 0x8d, 0xb5, - 0xba, 0xd3, 0xb9, 0x07, 0x66, 0x73, 0x0f, 0x7c, 0xcc, 0x3d, 0xf0, 0xbc, 0xf0, 0x9c, 0xd9, 0xc2, - 0x73, 0xde, 0x16, 0x9e, 0x73, 0xd3, 0x8c, 0x62, 0xd5, 0x4f, 0xc3, 0xe0, 0x8e, 0x0f, 0x7f, 0xab, - 0x1c, 0x6f, 0x94, 0xaa, 0x4c, 0x50, 0x19, 0x16, 0xf4, 0x87, 0x75, 0xf1, 0x15, 0x00, 0x00, 0xff, - 0xff, 0x4a, 0x6a, 0xbc, 0x50, 0xef, 0x02, 0x00, 0x00, + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x28, 0x4d, 0xd2, + 0x4d, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0xca, 0xcf, 0xc9, 0x49, 0x2c, 0x28, 0xd0, 0xcb, 0x28, 0x4d, + 0x8a, 0x87, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, + 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, 0x79, 0x79, + 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0x14, 0x1b, 0x8a, 0x4b, 0x12, 0x4b, + 0x52, 0x21, 0x12, 0x4a, 0xc2, 0x5c, 0x82, 0x81, 0x20, 0x0b, 0x83, 0x41, 0x62, 0x41, 0xa9, 0x85, + 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0x3e, 0x5c, 0x42, 0xc8, 0x82, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, + 0x42, 0x66, 0x5c, 0xac, 0x60, 0x9d, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x52, 0x7a, 0x58, + 0x1c, 0xa7, 0x07, 0xd6, 0xe2, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x44, 0xb9, 0xd1, 0x4c, + 0x46, 0x2e, 0x56, 0xb0, 0x71, 0x42, 0xfd, 0x8c, 0x5c, 0xac, 0x60, 0x05, 0x42, 0x6a, 0x58, 0x35, + 0x63, 0xb8, 0x44, 0x4a, 0x9d, 0xa0, 0x3a, 0x88, 0xe3, 0x94, 0x4c, 0x9b, 0x2e, 0x3f, 0x99, 0xcc, + 0xa4, 0x2f, 0xa4, 0xab, 0x9f, 0x52, 0x99, 0x9b, 0x9a, 0x57, 0x9c, 0x99, 0x9f, 0x57, 0x51, 0x59, + 0x85, 0xe0, 0xe8, 0x16, 0xa5, 0x64, 0xeb, 0x63, 0x04, 0x82, 0x53, 0xf0, 0x89, 0x47, 0x72, 0x8c, + 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, + 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, + 0xe7, 0xe2, 0x33, 0xb2, 0x02, 0xc5, 0xd0, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xd0, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x08, 0x19, 0x55, 0xd6, 0xd7, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -243,8 +153,6 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Params returns the total set of hub-genesis parameters. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // State returns the state of the genesis event. State(ctx context.Context, in *QueryStateRequest, opts ...grpc.CallOption) (*QueryStateResponse, error) } @@ -257,15 +165,6 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/rollapp.hub_genesis.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) State(ctx context.Context, in *QueryStateRequest, opts ...grpc.CallOption) (*QueryStateResponse, error) { out := new(QueryStateResponse) err := c.cc.Invoke(ctx, "/rollapp.hub_genesis.Query/State", in, out, opts...) @@ -277,8 +176,6 @@ func (c *queryClient) State(ctx context.Context, in *QueryStateRequest, opts ... // QueryServer is the server API for Query service. type QueryServer interface { - // Params returns the total set of hub-genesis parameters. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // State returns the state of the genesis event. State(context.Context, *QueryStateRequest) (*QueryStateResponse, error) } @@ -287,9 +184,6 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} func (*UnimplementedQueryServer) State(ctx context.Context, req *QueryStateRequest) (*QueryStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method State not implemented") } @@ -298,24 +192,6 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/rollapp.hub_genesis.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_State_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryStateRequest) if err := dec(in); err != nil { @@ -338,10 +214,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "rollapp.hub_genesis.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, { MethodName: "State", Handler: _Query_State_Handler, @@ -351,62 +223,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "hub-genesis/query.proto", } -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *QueryStateRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -474,26 +290,6 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - func (m *QueryStateRequest) Size() (n int) { if m == nil { return 0 @@ -520,139 +316,6 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryStateRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/hub-genesis/types/query.pb.gw.go b/x/hub-genesis/types/query.pb.gw.go index 16c5d1a9..609f1662 100644 --- a/x/hub-genesis/types/query.pb.gw.go +++ b/x/hub-genesis/types/query.pb.gw.go @@ -33,24 +33,6 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_State_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryStateRequest var metadata runtime.ServerMetadata @@ -75,29 +57,6 @@ func local_request_Query_State_0(ctx context.Context, marshaler runtime.Marshale // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_State_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -162,26 +121,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_State_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -206,13 +145,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dymensionxyz", "dymension-rdk", "hub-genesis", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_State_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dymensionxyz", "dymension-rdk", "hub-genesis", "state"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - forward_Query_State_0 = runtime.ForwardResponseMessage ) From bec0a648bb0bae07df34326fe39f9bc47a5f79d9 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:58:28 +0100 Subject: [PATCH 24/79] regen proto --- x/hub-genesis/types/params.pb.go | 265 ------------------------------- 1 file changed, 265 deletions(-) delete mode 100644 x/hub-genesis/types/params.pb.go diff --git a/x/hub-genesis/types/params.pb.go b/x/hub-genesis/types/params.pb.go deleted file mode 100644 index 4344d68e..00000000 --- a/x/hub-genesis/types/params.pb.go +++ /dev/null @@ -1,265 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: hub-genesis/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params holds parameters for the hub-genesis module. -type Params struct { -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_a8d0b00d1bcc9c95, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Params)(nil), "rollapp.hub_genesis.Params") -} - -func init() { proto.RegisterFile("hub-genesis/params.proto", fileDescriptor_a8d0b00d1bcc9c95) } - -var fileDescriptor_a8d0b00d1bcc9c95 = []byte{ - // 172 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0x28, 0x4d, 0xd2, - 0x4d, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0xca, 0xcf, 0xc9, 0x49, 0x2c, 0x28, 0xd0, 0xcb, 0x28, - 0x4d, 0x8a, 0x87, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, - 0xa5, 0x4a, 0x22, 0x5c, 0x6c, 0x01, 0x60, 0xad, 0x56, 0x2c, 0x33, 0x16, 0xc8, 0x33, 0x78, 0xb1, - 0x70, 0x30, 0x0a, 0x30, 0x39, 0x05, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, - 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, - 0x94, 0x65, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x4a, 0x65, 0x6e, - 0x6a, 0x5e, 0x71, 0x66, 0x7e, 0x5e, 0x45, 0x65, 0x15, 0x82, 0xa3, 0x5b, 0x94, 0x92, 0xad, 0x5f, - 0xa1, 0x8f, 0xec, 0xb8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x8d, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x0e, 0xf1, 0x3f, 0x16, 0xb8, 0x00, 0x00, 0x00, -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) From c9d7e8943124fd2195340e99e52e4c2088b66e3f Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:00:07 +0100 Subject: [PATCH 25/79] I can actually do it easier and use a map only for the repeats --- x/hub-genesis/keeper/genesis.go | 2 -- x/hub-genesis/keeper/grpc_query.go | 1 - x/hub-genesis/types/params.go | 37 ------------------------------ 3 files changed, 40 deletions(-) delete mode 100644 x/hub-genesis/types/params.go diff --git a/x/hub-genesis/keeper/genesis.go b/x/hub-genesis/keeper/genesis.go index 9444f7ae..3a6ba0c1 100644 --- a/x/hub-genesis/keeper/genesis.go +++ b/x/hub-genesis/keeper/genesis.go @@ -7,14 +7,12 @@ import ( // InitGenesis new hub-genesis genesis. func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { - k.SetParams(ctx, genState.Params) k.SetState(ctx, genState.State) } // ExportGenesis returns a GenesisState for a given context and keeper. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { genesis := types.DefaultGenesisState() - genesis.Params = k.GetParams(ctx) genesis.State = k.GetState(ctx) return genesis } diff --git a/x/hub-genesis/keeper/grpc_query.go b/x/hub-genesis/keeper/grpc_query.go index 712d015c..0ab067e8 100644 --- a/x/hub-genesis/keeper/grpc_query.go +++ b/x/hub-genesis/keeper/grpc_query.go @@ -22,6 +22,5 @@ func NewQuerier(k Keeper) Querier { func (q Querier) State(goCtx context.Context, request *types.QueryStateRequest) (*types.QueryStateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO: return &types.QueryStateResponse{State: q.Keeper.GetState(ctx)}, nil } diff --git a/x/hub-genesis/types/params.go b/x/hub-genesis/types/params.go deleted file mode 100644 index 06d6554d..00000000 --- a/x/hub-genesis/types/params.go +++ /dev/null @@ -1,37 +0,0 @@ -package types - -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "gopkg.in/yaml.v2" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable for hub_genesis module. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -func NewParams() Params { - return Params{} -} - -func DefaultParams() Params { - return NewParams() -} - -// String implements the Stringer interface. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} - -// ParamSetPairs implements params.ParamSet. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - -// Validate checks that the parameters have valid values. -func (p Params) Validate() error { - return nil -} From 6bdb0e320ac039380fd80c883aa316f332c3b984 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:08:06 +0100 Subject: [PATCH 26/79] simply delete teh acks --- proto/hub-genesis/state.proto | 2 - x/hub-genesis/types/state.pb.go | 161 +++++--------------------------- 2 files changed, 25 insertions(+), 138 deletions(-) diff --git a/proto/hub-genesis/state.proto b/proto/hub-genesis/state.proto index 70d657a8..820d042f 100644 --- a/proto/hub-genesis/state.proto +++ b/proto/hub-genesis/state.proto @@ -12,8 +12,6 @@ message State { reserved 2; // accounts on the Hub to fund with some bootstrapping transfers repeated GenesisAccount genesis_accounts = 3 [(gogoproto.nullable) = false]; - // the sequence numbers of outbound genesis transfers for which an ack has not yet been received - repeated uint64 unacked_seq_nums = 4 [(gogoproto.nullable) = false]; // the number size of unacked_seq_nums uint64 num_unacked_seq_nums = 5; // are outboundTransfersEnabled? This is only true if the genesis protocol has finished diff --git a/x/hub-genesis/types/state.pb.go b/x/hub-genesis/types/state.pb.go index 2e3ba917..34f8f038 100644 --- a/x/hub-genesis/types/state.pb.go +++ b/x/hub-genesis/types/state.pb.go @@ -28,8 +28,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type State struct { // accounts on the Hub to fund with some bootstrapping transfers GenesisAccounts []GenesisAccount `protobuf:"bytes,3,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` - // the sequence numbers of outbound genesis transfers for which an ack has not yet been received - UnackedSeqNums []uint64 `protobuf:"varint,4,rep,packed,name=unacked_seq_nums,json=unackedSeqNums,proto3" json:"unacked_seq_nums,omitempty"` // the number size of unacked_seq_nums NumUnackedSeqNums uint64 `protobuf:"varint,5,opt,name=num_unacked_seq_nums,json=numUnackedSeqNums,proto3" json:"num_unacked_seq_nums,omitempty"` // are outboundTransfersEnabled? This is only true if the genesis protocol has finished @@ -76,13 +74,6 @@ func (m *State) GetGenesisAccounts() []GenesisAccount { return nil } -func (m *State) GetUnackedSeqNums() []uint64 { - if m != nil { - return m.UnackedSeqNums - } - return nil -} - func (m *State) GetNumUnackedSeqNums() uint64 { if m != nil { return m.NumUnackedSeqNums @@ -160,32 +151,31 @@ func init() { func init() { proto.RegisterFile("hub-genesis/state.proto", fileDescriptor_1ad65c2fe0d953ab) } var fileDescriptor_1ad65c2fe0d953ab = []byte{ - // 389 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x31, 0x8f, 0xd3, 0x30, - 0x14, 0x8e, 0x93, 0x5c, 0x29, 0x3e, 0xe9, 0x08, 0xe1, 0x24, 0xc2, 0x0d, 0x21, 0x3a, 0x96, 0x2c, - 0x67, 0xeb, 0x8e, 0x01, 0xc1, 0xc6, 0x21, 0x84, 0x74, 0x03, 0x43, 0x7a, 0x2c, 0x2c, 0x91, 0x9d, - 0x98, 0x34, 0x6a, 0x6d, 0xa7, 0x79, 0x36, 0x6a, 0xf9, 0x01, 0xcc, 0xfc, 0xac, 0x8e, 0x1d, 0x99, - 0x10, 0x6a, 0xff, 0x08, 0x4a, 0x13, 0x04, 0x15, 0xdc, 0xe4, 0xf7, 0xfc, 0x7d, 0xdf, 0xb3, 0xbe, - 0xcf, 0x0f, 0x3f, 0x9e, 0x5a, 0x7e, 0x51, 0x09, 0x25, 0xa0, 0x06, 0x0a, 0x86, 0x19, 0x41, 0x9a, - 0x56, 0x1b, 0x1d, 0x3e, 0x6a, 0xf5, 0x7c, 0xce, 0x9a, 0x86, 0x4c, 0x2d, 0xcf, 0x07, 0xc2, 0xd9, - 0x69, 0xa5, 0x2b, 0xbd, 0xc7, 0x69, 0x57, 0xf5, 0xd4, 0xb3, 0xb8, 0xd0, 0x20, 0x35, 0x50, 0xce, - 0x40, 0xd0, 0xcf, 0x97, 0x5c, 0x18, 0x76, 0x49, 0x0b, 0x5d, 0xab, 0x1e, 0x3f, 0xff, 0xea, 0xe2, - 0xa3, 0x49, 0x37, 0x3a, 0xbc, 0xc5, 0xc1, 0x30, 0x2a, 0x67, 0x45, 0xa1, 0xad, 0x32, 0x10, 0x79, - 0x89, 0x97, 0x1e, 0x5f, 0x3d, 0x23, 0xff, 0x79, 0x8f, 0xbc, 0xeb, 0xcf, 0xd7, 0x3d, 0xf7, 0xda, - 0x5f, 0xff, 0x78, 0xea, 0x64, 0x0f, 0xaa, 0x83, 0x5b, 0x08, 0x09, 0x0e, 0xac, 0x62, 0xc5, 0x4c, - 0x94, 0x39, 0x88, 0x45, 0xae, 0xac, 0x84, 0xc8, 0x4f, 0xbc, 0xd4, 0x1f, 0x04, 0x27, 0x03, 0x3a, - 0x11, 0x8b, 0xf7, 0x56, 0x42, 0x48, 0xf1, 0xa9, 0xb2, 0x32, 0xff, 0x47, 0x73, 0x94, 0xa0, 0xd4, - 0xcf, 0x1e, 0x2a, 0x2b, 0x3f, 0x1c, 0x0a, 0x5e, 0xe1, 0x48, 0x5b, 0xc3, 0xb5, 0x55, 0xe5, 0x6d, - 0xcb, 0x14, 0x7c, 0x12, 0x2d, 0xbc, 0x55, 0x8c, 0xcf, 0x45, 0x19, 0x8d, 0x12, 0x94, 0x8e, 0xb3, - 0x3b, 0xf1, 0x1b, 0x7f, 0x8c, 0x02, 0xf7, 0xc6, 0x1f, 0xbb, 0x81, 0x77, 0x5e, 0xe0, 0x93, 0x43, - 0x47, 0xe1, 0x0b, 0x3c, 0x62, 0xb2, 0xab, 0x22, 0x94, 0xa0, 0xf4, 0xf8, 0xea, 0x09, 0xe9, 0xb3, - 0x24, 0x5d, 0x96, 0x64, 0xc8, 0x92, 0xbc, 0xd1, 0xb5, 0x1a, 0xbc, 0x0c, 0xf4, 0x30, 0xc2, 0xf7, - 0x58, 0x59, 0xb6, 0x02, 0x20, 0x72, 0x13, 0x94, 0xde, 0xcf, 0x7e, 0xb7, 0xd7, 0x93, 0xf5, 0x36, - 0x46, 0x9b, 0x6d, 0x8c, 0x7e, 0x6e, 0x63, 0xf4, 0x6d, 0x17, 0x3b, 0x9b, 0x5d, 0xec, 0x7c, 0xdf, - 0xc5, 0xce, 0xc7, 0x97, 0x55, 0x6d, 0xa6, 0x96, 0x93, 0x42, 0x4b, 0x5a, 0xae, 0xa4, 0x50, 0x50, - 0x6b, 0xb5, 0x5c, 0x7d, 0xf9, 0xd3, 0x5c, 0xb4, 0xe5, 0x8c, 0x2e, 0xe9, 0xdf, 0x3b, 0x61, 0x56, - 0x8d, 0x00, 0x3e, 0xda, 0xff, 0xe4, 0xf3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x00, 0xaf, 0xa8, - 0x75, 0x2f, 0x02, 0x00, 0x00, + // 374 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xb1, 0xae, 0xd3, 0x30, + 0x14, 0x86, 0xe3, 0x36, 0xb7, 0x14, 0x5f, 0x09, 0x4a, 0xb8, 0x12, 0xe1, 0x0e, 0x21, 0x2a, 0x4b, + 0x96, 0xda, 0x6a, 0x19, 0x10, 0x6c, 0x14, 0x21, 0xa4, 0x0e, 0x0c, 0x69, 0x59, 0x58, 0x22, 0x3b, + 0x31, 0x69, 0xd4, 0xda, 0x4e, 0x73, 0x6c, 0xd4, 0xf2, 0x14, 0x3c, 0x56, 0xc7, 0x4e, 0x88, 0x09, + 0xa1, 0xf6, 0x45, 0x50, 0x9a, 0x20, 0xa8, 0xc4, 0x9d, 0x7c, 0x8e, 0xff, 0x4f, 0xc7, 0x3e, 0xff, + 0x8f, 0x9f, 0x2c, 0x2d, 0x1f, 0xe5, 0x42, 0x09, 0x28, 0x80, 0x82, 0x61, 0x46, 0x90, 0xb2, 0xd2, + 0x46, 0x7b, 0x8f, 0x2b, 0xbd, 0x5e, 0xb3, 0xb2, 0x24, 0x4b, 0xcb, 0x93, 0x16, 0xb8, 0xbd, 0xc9, + 0x75, 0xae, 0xcf, 0x3a, 0xad, 0xab, 0x06, 0xbd, 0x0d, 0x52, 0x0d, 0x52, 0x03, 0xe5, 0x0c, 0x04, + 0xfd, 0x32, 0xe6, 0xc2, 0xb0, 0x31, 0x4d, 0x75, 0xa1, 0x1a, 0x7d, 0xf8, 0x1d, 0xe1, 0xab, 0x79, + 0x3d, 0xda, 0x5b, 0xe0, 0x41, 0x3b, 0x2a, 0x61, 0x69, 0xaa, 0xad, 0x32, 0xe0, 0x77, 0xc3, 0x6e, + 0x74, 0x3d, 0x79, 0x4e, 0xfe, 0xf3, 0x1e, 0x79, 0xdf, 0x9c, 0x6f, 0x1a, 0x76, 0xea, 0xee, 0x7f, + 0x3e, 0x73, 0xe2, 0x87, 0xf9, 0xc5, 0x2d, 0x78, 0x14, 0xdf, 0x28, 0x2b, 0x13, 0xab, 0x58, 0xba, + 0x12, 0x59, 0x02, 0x62, 0x93, 0x28, 0x2b, 0xc1, 0xbf, 0x0a, 0x51, 0xe4, 0xc6, 0x8f, 0x94, 0x95, + 0x1f, 0x1b, 0x69, 0x2e, 0x36, 0x1f, 0xac, 0x04, 0xef, 0x35, 0xf6, 0xb5, 0x35, 0x5c, 0x5b, 0x95, + 0x2d, 0x2a, 0xa6, 0xe0, 0xb3, 0xa8, 0xe0, 0x9d, 0x62, 0x7c, 0x2d, 0x32, 0xbf, 0x17, 0xa2, 0xa8, + 0x1f, 0xdf, 0xa9, 0xcf, 0xdc, 0x3e, 0x1a, 0x74, 0x66, 0x6e, 0xbf, 0x33, 0xe8, 0x0e, 0x53, 0xfc, + 0xe0, 0xf2, 0x87, 0xde, 0x4b, 0xdc, 0x63, 0xb2, 0xae, 0x7c, 0x14, 0xa2, 0xe8, 0x7a, 0xf2, 0x94, + 0x34, 0xde, 0x90, 0xda, 0x1b, 0xd2, 0x7a, 0x43, 0xde, 0xea, 0x42, 0xb5, 0xcb, 0xb4, 0xb8, 0xe7, + 0xe3, 0x7b, 0x2c, 0xcb, 0x2a, 0x01, 0xe0, 0x77, 0x42, 0x14, 0xdd, 0x8f, 0xff, 0xb4, 0xd3, 0xf9, + 0xfe, 0x18, 0xa0, 0xc3, 0x31, 0x40, 0xbf, 0x8e, 0x01, 0xfa, 0x76, 0x0a, 0x9c, 0xc3, 0x29, 0x70, + 0x7e, 0x9c, 0x02, 0xe7, 0xd3, 0xab, 0xbc, 0x30, 0x4b, 0xcb, 0x49, 0xaa, 0x25, 0xcd, 0x76, 0x52, + 0x28, 0x28, 0xb4, 0xda, 0xee, 0xbe, 0xfe, 0x6d, 0x46, 0x55, 0xb6, 0xa2, 0x5b, 0xfa, 0x6f, 0xc6, + 0x66, 0x57, 0x0a, 0xe0, 0xbd, 0x73, 0x32, 0x2f, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xa3, + 0xee, 0xe8, 0xff, 0x01, 0x00, 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -223,24 +213,6 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if len(m.UnackedSeqNums) > 0 { - dAtA2 := make([]byte, len(m.UnackedSeqNums)*10) - var j1 int - for _, num := range m.UnackedSeqNums { - for num >= 1<<7 { - dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j1++ - } - dAtA2[j1] = uint8(num) - j1++ - } - i -= j1 - copy(dAtA[i:], dAtA2[:j1]) - i = encodeVarintState(dAtA, i, uint64(j1)) - i-- - dAtA[i] = 0x22 - } if len(m.GenesisAccounts) > 0 { for iNdEx := len(m.GenesisAccounts) - 1; iNdEx >= 0; iNdEx-- { { @@ -321,13 +293,6 @@ func (m *State) Size() (n int) { n += 1 + l + sovState(uint64(l)) } } - if len(m.UnackedSeqNums) > 0 { - l = 0 - for _, e := range m.UnackedSeqNums { - l += sovState(uint64(e)) - } - n += 1 + sovState(uint64(l)) + l - } if m.NumUnackedSeqNums != 0 { n += 1 + sovState(uint64(m.NumUnackedSeqNums)) } @@ -421,82 +386,6 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.UnackedSeqNums = append(m.UnackedSeqNums, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthState - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.UnackedSeqNums) == 0 { - m.UnackedSeqNums = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.UnackedSeqNums = append(m.UnackedSeqNums, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field UnackedSeqNums", wireType) - } case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field NumUnackedSeqNums", wireType) From e01338122080a7fcc70e9d6e2253f8ad09b76ae8 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:09:18 +0100 Subject: [PATCH 27/79] regen proto --- proto/hub-genesis/state.proto | 4 +- x/hub-genesis/types/state.pb.go | 71 ++++++++++++++++----------------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/proto/hub-genesis/state.proto b/proto/hub-genesis/state.proto index 820d042f..b3c80ab2 100644 --- a/proto/hub-genesis/state.proto +++ b/proto/hub-genesis/state.proto @@ -12,8 +12,8 @@ message State { reserved 2; // accounts on the Hub to fund with some bootstrapping transfers repeated GenesisAccount genesis_accounts = 3 [(gogoproto.nullable) = false]; - // the number size of unacked_seq_nums - uint64 num_unacked_seq_nums = 5; + // the number of genesis transfers for which an ack has not yet been received + uint64 num_unacked_transfers = 5; // are outboundTransfersEnabled? This is only true if the genesis protocol has finished bool outboundTransfersEnabled = 6; } diff --git a/x/hub-genesis/types/state.pb.go b/x/hub-genesis/types/state.pb.go index 34f8f038..f7157d66 100644 --- a/x/hub-genesis/types/state.pb.go +++ b/x/hub-genesis/types/state.pb.go @@ -28,8 +28,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type State struct { // accounts on the Hub to fund with some bootstrapping transfers GenesisAccounts []GenesisAccount `protobuf:"bytes,3,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` - // the number size of unacked_seq_nums - NumUnackedSeqNums uint64 `protobuf:"varint,5,opt,name=num_unacked_seq_nums,json=numUnackedSeqNums,proto3" json:"num_unacked_seq_nums,omitempty"` + // the number of genesis transfers for which an ack has not yet been received + NumUnackedTransfers uint64 `protobuf:"varint,5,opt,name=num_unacked_transfers,json=numUnackedTransfers,proto3" json:"num_unacked_transfers,omitempty"` // are outboundTransfersEnabled? This is only true if the genesis protocol has finished OutboundTransfersEnabled bool `protobuf:"varint,6,opt,name=outboundTransfersEnabled,proto3" json:"outboundTransfersEnabled,omitempty"` } @@ -74,9 +74,9 @@ func (m *State) GetGenesisAccounts() []GenesisAccount { return nil } -func (m *State) GetNumUnackedSeqNums() uint64 { +func (m *State) GetNumUnackedTransfers() uint64 { if m != nil { - return m.NumUnackedSeqNums + return m.NumUnackedTransfers } return 0 } @@ -151,31 +151,30 @@ func init() { func init() { proto.RegisterFile("hub-genesis/state.proto", fileDescriptor_1ad65c2fe0d953ab) } var fileDescriptor_1ad65c2fe0d953ab = []byte{ - // 374 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xb1, 0xae, 0xd3, 0x30, - 0x14, 0x86, 0xe3, 0x36, 0xb7, 0x14, 0x5f, 0x09, 0x4a, 0xb8, 0x12, 0xe1, 0x0e, 0x21, 0x2a, 0x4b, - 0x96, 0xda, 0x6a, 0x19, 0x10, 0x6c, 0x14, 0x21, 0xa4, 0x0e, 0x0c, 0x69, 0x59, 0x58, 0x22, 0x3b, - 0x31, 0x69, 0xd4, 0xda, 0x4e, 0x73, 0x6c, 0xd4, 0xf2, 0x14, 0x3c, 0x56, 0xc7, 0x4e, 0x88, 0x09, - 0xa1, 0xf6, 0x45, 0x50, 0x9a, 0x20, 0xa8, 0xc4, 0x9d, 0x7c, 0x8e, 0xff, 0x4f, 0xc7, 0x3e, 0xff, - 0x8f, 0x9f, 0x2c, 0x2d, 0x1f, 0xe5, 0x42, 0x09, 0x28, 0x80, 0x82, 0x61, 0x46, 0x90, 0xb2, 0xd2, - 0x46, 0x7b, 0x8f, 0x2b, 0xbd, 0x5e, 0xb3, 0xb2, 0x24, 0x4b, 0xcb, 0x93, 0x16, 0xb8, 0xbd, 0xc9, - 0x75, 0xae, 0xcf, 0x3a, 0xad, 0xab, 0x06, 0xbd, 0x0d, 0x52, 0x0d, 0x52, 0x03, 0xe5, 0x0c, 0x04, - 0xfd, 0x32, 0xe6, 0xc2, 0xb0, 0x31, 0x4d, 0x75, 0xa1, 0x1a, 0x7d, 0xf8, 0x1d, 0xe1, 0xab, 0x79, - 0x3d, 0xda, 0x5b, 0xe0, 0x41, 0x3b, 0x2a, 0x61, 0x69, 0xaa, 0xad, 0x32, 0xe0, 0x77, 0xc3, 0x6e, - 0x74, 0x3d, 0x79, 0x4e, 0xfe, 0xf3, 0x1e, 0x79, 0xdf, 0x9c, 0x6f, 0x1a, 0x76, 0xea, 0xee, 0x7f, - 0x3e, 0x73, 0xe2, 0x87, 0xf9, 0xc5, 0x2d, 0x78, 0x14, 0xdf, 0x28, 0x2b, 0x13, 0xab, 0x58, 0xba, - 0x12, 0x59, 0x02, 0x62, 0x93, 0x28, 0x2b, 0xc1, 0xbf, 0x0a, 0x51, 0xe4, 0xc6, 0x8f, 0x94, 0x95, - 0x1f, 0x1b, 0x69, 0x2e, 0x36, 0x1f, 0xac, 0x04, 0xef, 0x35, 0xf6, 0xb5, 0x35, 0x5c, 0x5b, 0x95, - 0x2d, 0x2a, 0xa6, 0xe0, 0xb3, 0xa8, 0xe0, 0x9d, 0x62, 0x7c, 0x2d, 0x32, 0xbf, 0x17, 0xa2, 0xa8, - 0x1f, 0xdf, 0xa9, 0xcf, 0xdc, 0x3e, 0x1a, 0x74, 0x66, 0x6e, 0xbf, 0x33, 0xe8, 0x0e, 0x53, 0xfc, - 0xe0, 0xf2, 0x87, 0xde, 0x4b, 0xdc, 0x63, 0xb2, 0xae, 0x7c, 0x14, 0xa2, 0xe8, 0x7a, 0xf2, 0x94, - 0x34, 0xde, 0x90, 0xda, 0x1b, 0xd2, 0x7a, 0x43, 0xde, 0xea, 0x42, 0xb5, 0xcb, 0xb4, 0xb8, 0xe7, - 0xe3, 0x7b, 0x2c, 0xcb, 0x2a, 0x01, 0xe0, 0x77, 0x42, 0x14, 0xdd, 0x8f, 0xff, 0xb4, 0xd3, 0xf9, - 0xfe, 0x18, 0xa0, 0xc3, 0x31, 0x40, 0xbf, 0x8e, 0x01, 0xfa, 0x76, 0x0a, 0x9c, 0xc3, 0x29, 0x70, - 0x7e, 0x9c, 0x02, 0xe7, 0xd3, 0xab, 0xbc, 0x30, 0x4b, 0xcb, 0x49, 0xaa, 0x25, 0xcd, 0x76, 0x52, - 0x28, 0x28, 0xb4, 0xda, 0xee, 0xbe, 0xfe, 0x6d, 0x46, 0x55, 0xb6, 0xa2, 0x5b, 0xfa, 0x6f, 0xc6, - 0x66, 0x57, 0x0a, 0xe0, 0xbd, 0x73, 0x32, 0x2f, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xa3, - 0xee, 0xe8, 0xff, 0x01, 0x00, 0x00, + // 366 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x41, 0x6f, 0xda, 0x30, + 0x14, 0xc7, 0x63, 0x08, 0x8c, 0x19, 0x69, 0x43, 0x61, 0xd3, 0x32, 0x0e, 0x59, 0xc4, 0x2e, 0xb9, + 0x60, 0x0b, 0x76, 0x98, 0xb6, 0xdb, 0x98, 0xaa, 0x4a, 0x1c, 0x03, 0xbd, 0xf4, 0x12, 0xd9, 0x89, + 0x1b, 0x22, 0x88, 0x1d, 0xc5, 0x76, 0x05, 0xfd, 0x14, 0xfd, 0x58, 0x1c, 0x39, 0xb6, 0x97, 0xaa, + 0x82, 0x2f, 0x52, 0x85, 0x04, 0x51, 0xa4, 0xf6, 0xe4, 0xf7, 0xde, 0xef, 0xaf, 0x67, 0xfb, 0xff, + 0x87, 0xdf, 0xe6, 0x9a, 0x0e, 0x62, 0xc6, 0x99, 0x4c, 0x24, 0x96, 0x8a, 0x28, 0x86, 0xb2, 0x5c, + 0x28, 0x61, 0x75, 0x73, 0xb1, 0x5c, 0x92, 0x2c, 0x43, 0x73, 0x4d, 0x83, 0x4a, 0xd0, 0xfb, 0x12, + 0x8b, 0x58, 0x1c, 0x38, 0x2e, 0xaa, 0x52, 0xda, 0x73, 0x42, 0x21, 0x53, 0x21, 0x31, 0x25, 0x92, + 0xe1, 0xdb, 0x21, 0x65, 0x8a, 0x0c, 0x71, 0x28, 0x12, 0x5e, 0xf2, 0xfe, 0x23, 0x80, 0x8d, 0x69, + 0xb1, 0xda, 0x9a, 0xc1, 0x4e, 0xb5, 0x2a, 0x20, 0x61, 0x28, 0x34, 0x57, 0xd2, 0xae, 0xbb, 0x75, + 0xaf, 0x3d, 0xfa, 0x89, 0xde, 0xb8, 0x0f, 0x5d, 0x96, 0xe7, 0xbf, 0x52, 0x3b, 0x36, 0x37, 0x4f, + 0x3f, 0x0c, 0xff, 0x73, 0x7c, 0x36, 0x95, 0xd6, 0x08, 0x7e, 0xe5, 0x3a, 0x0d, 0x34, 0x27, 0xe1, + 0x82, 0x45, 0x81, 0xca, 0x09, 0x97, 0x37, 0x2c, 0x97, 0x76, 0xc3, 0x05, 0x9e, 0xe9, 0x77, 0xb9, + 0x4e, 0xaf, 0x4a, 0x36, 0x3b, 0x22, 0xeb, 0x2f, 0xb4, 0x85, 0x56, 0x54, 0x68, 0x7e, 0x1a, 0x5e, + 0x70, 0x42, 0x97, 0x2c, 0xb2, 0x9b, 0x2e, 0xf0, 0x5a, 0xfe, 0xbb, 0x7c, 0x62, 0xb6, 0x40, 0xa7, + 0x36, 0x31, 0x5b, 0xb5, 0x4e, 0xbd, 0x1f, 0xc2, 0x4f, 0xe7, 0x8f, 0xb4, 0x7e, 0xc3, 0x26, 0x49, + 0x8b, 0xca, 0x06, 0x2e, 0xf0, 0xda, 0xa3, 0xef, 0xa8, 0xb4, 0x07, 0x15, 0xf6, 0xa0, 0xca, 0x1e, + 0xf4, 0x5f, 0x24, 0xbc, 0xfa, 0x4f, 0x25, 0xb7, 0x6c, 0xf8, 0x81, 0x44, 0x51, 0xce, 0xa4, 0xb4, + 0x6b, 0x2e, 0xf0, 0x3e, 0xfa, 0xc7, 0x76, 0x3c, 0xdd, 0xec, 0x1c, 0xb0, 0xdd, 0x39, 0xe0, 0x79, + 0xe7, 0x80, 0xfb, 0xbd, 0x63, 0x6c, 0xf7, 0x8e, 0xf1, 0xb0, 0x77, 0x8c, 0xeb, 0x3f, 0x71, 0xa2, + 0xe6, 0x9a, 0xa2, 0x50, 0xa4, 0x38, 0x5a, 0xa7, 0x8c, 0xcb, 0x44, 0xf0, 0xd5, 0xfa, 0xee, 0xd4, + 0x0c, 0xf2, 0x68, 0x81, 0x57, 0xf8, 0x75, 0xcc, 0x6a, 0x9d, 0x31, 0x49, 0x9b, 0x87, 0x70, 0x7e, + 0xbd, 0x04, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x9c, 0x26, 0xdd, 0x02, 0x02, 0x00, 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -208,8 +207,8 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x30 } - if m.NumUnackedSeqNums != 0 { - i = encodeVarintState(dAtA, i, uint64(m.NumUnackedSeqNums)) + if m.NumUnackedTransfers != 0 { + i = encodeVarintState(dAtA, i, uint64(m.NumUnackedTransfers)) i-- dAtA[i] = 0x28 } @@ -293,8 +292,8 @@ func (m *State) Size() (n int) { n += 1 + l + sovState(uint64(l)) } } - if m.NumUnackedSeqNums != 0 { - n += 1 + sovState(uint64(m.NumUnackedSeqNums)) + if m.NumUnackedTransfers != 0 { + n += 1 + sovState(uint64(m.NumUnackedTransfers)) } if m.OutboundTransfersEnabled { n += 2 @@ -388,9 +387,9 @@ func (m *State) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumUnackedSeqNums", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NumUnackedTransfers", wireType) } - m.NumUnackedSeqNums = 0 + m.NumUnackedTransfers = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowState @@ -400,7 +399,7 @@ func (m *State) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumUnackedSeqNums |= uint64(b&0x7F) << shift + m.NumUnackedTransfers |= uint64(b&0x7F) << shift if b < 0x80 { break } From 2108e1bcf5cffa42439d9883327f8485ee0813d6 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:09:22 +0100 Subject: [PATCH 28/79] pre simplify store From 02c6c4eafe0e0d468a8cd86524a52e3c2f64f6ba Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:12:35 +0100 Subject: [PATCH 29/79] adds canonical channel --- proto/hub-genesis/state.proto | 11 +- x/hub-genesis/keeper/sequence_numbers.go | 5 - x/hub-genesis/types/state.pb.go | 341 +++++++++++++++++++++-- 3 files changed, 325 insertions(+), 32 deletions(-) diff --git a/proto/hub-genesis/state.proto b/proto/hub-genesis/state.proto index b3c80ab2..6404bc8a 100644 --- a/proto/hub-genesis/state.proto +++ b/proto/hub-genesis/state.proto @@ -15,7 +15,16 @@ message State { // the number of genesis transfers for which an ack has not yet been received uint64 num_unacked_transfers = 5; // are outboundTransfersEnabled? This is only true if the genesis protocol has finished - bool outboundTransfersEnabled = 6; + bool outbound_transfers_enabled = 6; + // the canonical transfer port and channel for the hub + PortAndChannel hub_port_and_channel= 7; +} + +message PortAndChannel { + // port + string port = 1; + // channel + string channel = 2; } // GenesisAccount is a struct for the genesis account for the rollapp diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index dd1996c7..f6d26178 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -18,11 +18,6 @@ func seqNumKey(port, channel string, seq uint64) []byte { return bz } -func numUnackedSeqNumsKey(port, channel string) []byte { - bz := []byte(fmt.Sprintf("seqnumcnt/%s/%s", port, channel)) - return bz -} - func (k Keeper) saveSeqNum(ctx sdk.Context, port, channel string, seq uint64) { ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel, seq), []byte{}) cnt := k.getNumUnackedSeqNums(ctx, port, channel) diff --git a/x/hub-genesis/types/state.pb.go b/x/hub-genesis/types/state.pb.go index f7157d66..bf25ca94 100644 --- a/x/hub-genesis/types/state.pb.go +++ b/x/hub-genesis/types/state.pb.go @@ -31,7 +31,9 @@ type State struct { // the number of genesis transfers for which an ack has not yet been received NumUnackedTransfers uint64 `protobuf:"varint,5,opt,name=num_unacked_transfers,json=numUnackedTransfers,proto3" json:"num_unacked_transfers,omitempty"` // are outboundTransfersEnabled? This is only true if the genesis protocol has finished - OutboundTransfersEnabled bool `protobuf:"varint,6,opt,name=outboundTransfersEnabled,proto3" json:"outboundTransfersEnabled,omitempty"` + OutboundTransfersEnabled bool `protobuf:"varint,6,opt,name=outbound_transfers_enabled,json=outboundTransfersEnabled,proto3" json:"outbound_transfers_enabled,omitempty"` + // the canonical transfer port and channel for the hub + HubPortAndChannel *PortAndChannel `protobuf:"bytes,7,opt,name=hub_port_and_channel,json=hubPortAndChannel,proto3" json:"hub_port_and_channel,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -88,6 +90,67 @@ func (m *State) GetOutboundTransfersEnabled() bool { return false } +func (m *State) GetHubPortAndChannel() *PortAndChannel { + if m != nil { + return m.HubPortAndChannel + } + return nil +} + +type PortAndChannel struct { + // port + Port string `protobuf:"bytes,1,opt,name=port,proto3" json:"port,omitempty"` + // channel + Channel string `protobuf:"bytes,2,opt,name=channel,proto3" json:"channel,omitempty"` +} + +func (m *PortAndChannel) Reset() { *m = PortAndChannel{} } +func (m *PortAndChannel) String() string { return proto.CompactTextString(m) } +func (*PortAndChannel) ProtoMessage() {} +func (*PortAndChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_1ad65c2fe0d953ab, []int{1} +} +func (m *PortAndChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PortAndChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PortAndChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PortAndChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_PortAndChannel.Merge(m, src) +} +func (m *PortAndChannel) XXX_Size() int { + return m.Size() +} +func (m *PortAndChannel) XXX_DiscardUnknown() { + xxx_messageInfo_PortAndChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_PortAndChannel proto.InternalMessageInfo + +func (m *PortAndChannel) GetPort() string { + if m != nil { + return m.Port + } + return "" +} + +func (m *PortAndChannel) GetChannel() string { + if m != nil { + return m.Channel + } + return "" +} + // GenesisAccount is a struct for the genesis account for the rollapp type GenesisAccount struct { // amount of coins to be sent to the genesis address @@ -100,7 +163,7 @@ func (m *GenesisAccount) Reset() { *m = GenesisAccount{} } func (m *GenesisAccount) String() string { return proto.CompactTextString(m) } func (*GenesisAccount) ProtoMessage() {} func (*GenesisAccount) Descriptor() ([]byte, []int) { - return fileDescriptor_1ad65c2fe0d953ab, []int{1} + return fileDescriptor_1ad65c2fe0d953ab, []int{2} } func (m *GenesisAccount) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -145,36 +208,42 @@ func (m *GenesisAccount) GetAddress() string { func init() { proto.RegisterType((*State)(nil), "rollapp.hub_genesis.State") + proto.RegisterType((*PortAndChannel)(nil), "rollapp.hub_genesis.PortAndChannel") proto.RegisterType((*GenesisAccount)(nil), "rollapp.hub_genesis.GenesisAccount") } func init() { proto.RegisterFile("hub-genesis/state.proto", fileDescriptor_1ad65c2fe0d953ab) } var fileDescriptor_1ad65c2fe0d953ab = []byte{ - // 366 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x41, 0x6f, 0xda, 0x30, - 0x14, 0xc7, 0x63, 0x08, 0x8c, 0x19, 0x69, 0x43, 0x61, 0xd3, 0x32, 0x0e, 0x59, 0xc4, 0x2e, 0xb9, - 0x60, 0x0b, 0x76, 0x98, 0xb6, 0xdb, 0x98, 0xaa, 0x4a, 0x1c, 0x03, 0xbd, 0xf4, 0x12, 0xd9, 0x89, - 0x1b, 0x22, 0x88, 0x1d, 0xc5, 0x76, 0x05, 0xfd, 0x14, 0xfd, 0x58, 0x1c, 0x39, 0xb6, 0x97, 0xaa, - 0x82, 0x2f, 0x52, 0x85, 0x04, 0x51, 0xa4, 0xf6, 0xe4, 0xf7, 0xde, 0xef, 0xaf, 0x67, 0xfb, 0xff, - 0x87, 0xdf, 0xe6, 0x9a, 0x0e, 0x62, 0xc6, 0x99, 0x4c, 0x24, 0x96, 0x8a, 0x28, 0x86, 0xb2, 0x5c, - 0x28, 0x61, 0x75, 0x73, 0xb1, 0x5c, 0x92, 0x2c, 0x43, 0x73, 0x4d, 0x83, 0x4a, 0xd0, 0xfb, 0x12, - 0x8b, 0x58, 0x1c, 0x38, 0x2e, 0xaa, 0x52, 0xda, 0x73, 0x42, 0x21, 0x53, 0x21, 0x31, 0x25, 0x92, - 0xe1, 0xdb, 0x21, 0x65, 0x8a, 0x0c, 0x71, 0x28, 0x12, 0x5e, 0xf2, 0xfe, 0x23, 0x80, 0x8d, 0x69, - 0xb1, 0xda, 0x9a, 0xc1, 0x4e, 0xb5, 0x2a, 0x20, 0x61, 0x28, 0x34, 0x57, 0xd2, 0xae, 0xbb, 0x75, - 0xaf, 0x3d, 0xfa, 0x89, 0xde, 0xb8, 0x0f, 0x5d, 0x96, 0xe7, 0xbf, 0x52, 0x3b, 0x36, 0x37, 0x4f, - 0x3f, 0x0c, 0xff, 0x73, 0x7c, 0x36, 0x95, 0xd6, 0x08, 0x7e, 0xe5, 0x3a, 0x0d, 0x34, 0x27, 0xe1, - 0x82, 0x45, 0x81, 0xca, 0x09, 0x97, 0x37, 0x2c, 0x97, 0x76, 0xc3, 0x05, 0x9e, 0xe9, 0x77, 0xb9, - 0x4e, 0xaf, 0x4a, 0x36, 0x3b, 0x22, 0xeb, 0x2f, 0xb4, 0x85, 0x56, 0x54, 0x68, 0x7e, 0x1a, 0x5e, - 0x70, 0x42, 0x97, 0x2c, 0xb2, 0x9b, 0x2e, 0xf0, 0x5a, 0xfe, 0xbb, 0x7c, 0x62, 0xb6, 0x40, 0xa7, - 0x36, 0x31, 0x5b, 0xb5, 0x4e, 0xbd, 0x1f, 0xc2, 0x4f, 0xe7, 0x8f, 0xb4, 0x7e, 0xc3, 0x26, 0x49, - 0x8b, 0xca, 0x06, 0x2e, 0xf0, 0xda, 0xa3, 0xef, 0xa8, 0xb4, 0x07, 0x15, 0xf6, 0xa0, 0xca, 0x1e, - 0xf4, 0x5f, 0x24, 0xbc, 0xfa, 0x4f, 0x25, 0xb7, 0x6c, 0xf8, 0x81, 0x44, 0x51, 0xce, 0xa4, 0xb4, - 0x6b, 0x2e, 0xf0, 0x3e, 0xfa, 0xc7, 0x76, 0x3c, 0xdd, 0xec, 0x1c, 0xb0, 0xdd, 0x39, 0xe0, 0x79, - 0xe7, 0x80, 0xfb, 0xbd, 0x63, 0x6c, 0xf7, 0x8e, 0xf1, 0xb0, 0x77, 0x8c, 0xeb, 0x3f, 0x71, 0xa2, - 0xe6, 0x9a, 0xa2, 0x50, 0xa4, 0x38, 0x5a, 0xa7, 0x8c, 0xcb, 0x44, 0xf0, 0xd5, 0xfa, 0xee, 0xd4, - 0x0c, 0xf2, 0x68, 0x81, 0x57, 0xf8, 0x75, 0xcc, 0x6a, 0x9d, 0x31, 0x49, 0x9b, 0x87, 0x70, 0x7e, - 0xbd, 0x04, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x9c, 0x26, 0xdd, 0x02, 0x02, 0x00, 0x00, + // 433 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xcd, 0x26, 0x6e, 0x1a, 0xb6, 0x52, 0x09, 0xdb, 0x22, 0x4c, 0x0e, 0xc6, 0x0a, 0x97, 0x5c, + 0xba, 0x56, 0xc3, 0x01, 0x21, 0x21, 0xa4, 0xb6, 0x42, 0x48, 0x3d, 0x21, 0x37, 0x5c, 0xb8, 0x58, + 0xbb, 0xf6, 0x62, 0x5b, 0x8d, 0x77, 0x2c, 0xef, 0x2e, 0x6a, 0xf8, 0x0a, 0x7e, 0x85, 0xbf, 0xe8, + 0xb1, 0x47, 0x4e, 0x08, 0x25, 0x3f, 0x82, 0xec, 0xb5, 0xa1, 0x96, 0xe8, 0xc9, 0x33, 0xf3, 0xde, + 0xcc, 0xf3, 0xce, 0x1b, 0xfc, 0x2c, 0x33, 0xfc, 0x24, 0x15, 0x52, 0xa8, 0x5c, 0x05, 0x4a, 0x33, + 0x2d, 0x68, 0x59, 0x81, 0x06, 0x72, 0x54, 0xc1, 0x7a, 0xcd, 0xca, 0x92, 0x66, 0x86, 0x47, 0x2d, + 0x61, 0x76, 0x9c, 0x42, 0x0a, 0x0d, 0x1e, 0xd4, 0x91, 0xa5, 0xce, 0xbc, 0x18, 0x54, 0x01, 0x2a, + 0xe0, 0x4c, 0x89, 0xe0, 0xeb, 0x29, 0x17, 0x9a, 0x9d, 0x06, 0x31, 0xe4, 0xd2, 0xe2, 0xf3, 0x1f, + 0x43, 0xbc, 0x77, 0x55, 0x8f, 0x26, 0x2b, 0x3c, 0x6d, 0x47, 0x45, 0x2c, 0x8e, 0xc1, 0x48, 0xad, + 0xdc, 0x91, 0x3f, 0x5a, 0x1c, 0x2c, 0x5f, 0xd2, 0xff, 0xe8, 0xd1, 0x0f, 0xf6, 0x7b, 0x66, 0xb9, + 0xe7, 0xce, 0xed, 0xaf, 0x17, 0x83, 0xf0, 0x71, 0xda, 0xab, 0x2a, 0xb2, 0xc4, 0x4f, 0xa5, 0x29, + 0x22, 0x23, 0x59, 0x7c, 0x2d, 0x92, 0x48, 0x57, 0x4c, 0xaa, 0x2f, 0xa2, 0x52, 0xee, 0x9e, 0x8f, + 0x16, 0x4e, 0x78, 0x24, 0x4d, 0xf1, 0xc9, 0x62, 0xab, 0x0e, 0x22, 0x6f, 0xf1, 0x0c, 0x8c, 0xe6, + 0x60, 0xe4, 0xbd, 0x86, 0x48, 0x48, 0xc6, 0xd7, 0x22, 0x71, 0xc7, 0x3e, 0x5a, 0x4c, 0x42, 0xb7, + 0x63, 0xfc, 0x6d, 0x7b, 0x6f, 0x71, 0xb2, 0xc2, 0xc7, 0xf5, 0x6f, 0x96, 0x50, 0xe9, 0x88, 0xc9, + 0x24, 0x8a, 0x33, 0x26, 0xa5, 0x58, 0xbb, 0xfb, 0x3e, 0x7a, 0xf0, 0x2d, 0x1f, 0xa1, 0xd2, 0x67, + 0x32, 0xb9, 0xb0, 0xd4, 0xf0, 0x49, 0x66, 0x78, 0xbf, 0x74, 0xe9, 0x4c, 0xd0, 0x74, 0x78, 0xe9, + 0x4c, 0x86, 0xd3, 0xd1, 0xfc, 0x1d, 0x3e, 0xec, 0xa3, 0x84, 0x60, 0xa7, 0xd6, 0x73, 0x91, 0x8f, + 0x16, 0x8f, 0xc2, 0x26, 0x26, 0x2e, 0xde, 0xef, 0xa4, 0x87, 0x4d, 0xb9, 0x4b, 0xe7, 0x31, 0x3e, + 0xec, 0x2f, 0x8f, 0xbc, 0xc6, 0x63, 0x56, 0xd4, 0x51, 0x33, 0xe1, 0x60, 0xf9, 0x9c, 0x5a, 0xdb, + 0x68, 0x6d, 0x1b, 0x6d, 0x6d, 0xa3, 0x17, 0x90, 0xcb, 0x76, 0xcf, 0x2d, 0xbd, 0x16, 0x61, 0x49, + 0x52, 0x09, 0xa5, 0x3a, 0x91, 0x36, 0x3d, 0xbf, 0xba, 0xdd, 0x7a, 0xe8, 0x6e, 0xeb, 0xa1, 0xdf, + 0x5b, 0x0f, 0x7d, 0xdf, 0x79, 0x83, 0xbb, 0x9d, 0x37, 0xf8, 0xb9, 0xf3, 0x06, 0x9f, 0xdf, 0xa4, + 0xb9, 0xce, 0x0c, 0xa7, 0x31, 0x14, 0x41, 0xb2, 0x29, 0x84, 0x54, 0x39, 0xc8, 0x9b, 0xcd, 0xb7, + 0x7f, 0xc9, 0x49, 0x95, 0x5c, 0x07, 0x37, 0xc1, 0xfd, 0xf3, 0xd3, 0x9b, 0x52, 0x28, 0x3e, 0x6e, + 0x8e, 0xe6, 0xd5, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x96, 0x91, 0xc3, 0xaf, 0x9a, 0x02, 0x00, + 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -197,6 +266,18 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.HubPortAndChannel != nil { + { + size, err := m.HubPortAndChannel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintState(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } if m.OutboundTransfersEnabled { i-- if m.OutboundTransfersEnabled { @@ -229,6 +310,43 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PortAndChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PortAndChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PortAndChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Channel) > 0 { + i -= len(m.Channel) + copy(dAtA[i:], m.Channel) + i = encodeVarintState(dAtA, i, uint64(len(m.Channel))) + i-- + dAtA[i] = 0x12 + } + if len(m.Port) > 0 { + i -= len(m.Port) + copy(dAtA[i:], m.Port) + i = encodeVarintState(dAtA, i, uint64(len(m.Port))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *GenesisAccount) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -298,6 +416,27 @@ func (m *State) Size() (n int) { if m.OutboundTransfersEnabled { n += 2 } + if m.HubPortAndChannel != nil { + l = m.HubPortAndChannel.Size() + n += 1 + l + sovState(uint64(l)) + } + return n +} + +func (m *PortAndChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Port) + if l > 0 { + n += 1 + l + sovState(uint64(l)) + } + l = len(m.Channel) + if l > 0 { + n += 1 + l + sovState(uint64(l)) + } return n } @@ -424,6 +563,156 @@ func (m *State) Unmarshal(dAtA []byte) error { } } m.OutboundTransfersEnabled = bool(v != 0) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HubPortAndChannel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.HubPortAndChannel == nil { + m.HubPortAndChannel = &PortAndChannel{} + } + if err := m.HubPortAndChannel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipState(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthState + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PortAndChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PortAndChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PortAndChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Port = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Channel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipState(dAtA[iNdEx:]) From 549d435b4d7e751a1be1b6a413fad5c4d36a0a44 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:16:32 +0100 Subject: [PATCH 30/79] need to sort the port and channel --- x/hub-genesis/keeper/ibc_module.go | 9 ++++++ x/hub-genesis/keeper/sequence_numbers.go | 41 +++++------------------- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 67015b10..4ad47dac 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -56,6 +56,15 @@ func (w IBCModule) OnChanOpenConfirm( state := w.k.GetState(ctx) + state.HubPortAndChannel = &types.PortAndChannel{ + Port: portID, + Channel: channelID, + } + + state.NumUnackedTransfers = uint64(len(state.GetGenesisAccounts())) + + w.k.SetState(ctx, state) + srcAccount := w.k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) srcAddr := srcAccount.GetAddress().String() diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index f6d26178..608186c6 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -20,44 +20,26 @@ func seqNumKey(port, channel string, seq uint64) []byte { func (k Keeper) saveSeqNum(ctx sdk.Context, port, channel string, seq uint64) { ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel, seq), []byte{}) - cnt := k.getNumUnackedSeqNums(ctx, port, channel) - cnt++ - k.saveNumUnackedSeqNums(ctx, port, channel, cnt) } func (k Keeper) delSeqNum(ctx sdk.Context, port, channel string, seq uint64) { ctx.KVStore(k.storeKey).Delete(seqNumKey(port, channel, seq)) } -func (k Keeper) hasSeqNum(ctx sdk.Context, port, channel string, seq uint64) bool { - return ctx.KVStore(k.storeKey).Has(seqNumKey(port, channel, seq)) -} - -func (k Keeper) saveNumUnackedSeqNums(ctx sdk.Context, port, channel string, cnt uint64) { - bz := sdk.Uint64ToBigEndian(cnt) - ctx.KVStore(k.storeKey).Set(numUnackedSeqNumsKey(port, channel), bz) -} - -func (k Keeper) getNumUnackedSeqNums(ctx sdk.Context, port, channel string) uint64 { - bz := ctx.KVStore(k.storeKey).Get(numUnackedSeqNumsKey(port, channel)) - return sdk.BigEndianToUint64(bz) -} - // ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, success bool) { if !success { panic(fmt.Sprintf("genesis transfer unsuccessful, port: %s, channel: %s: seq: %d", port, channel, seq)) } - if k.hasSeqNum(ctx, port, channel, seq) { - k.delSeqNum(ctx, port, channel, seq) - cnt := k.getNumUnackedSeqNums(ctx, port, channel) - cnt-- - k.saveNumUnackedSeqNums(ctx, port, channel, cnt) - if cnt == 0 { - // all acks have come back successfully - k.enableOutboundTransfers(ctx) - } + k.delSeqNum(ctx, port, channel, seq) + state := k.GetState(ctx) + state.NumUnackedTransfers-- + if state.NumUnackedTransfers == 0 { + // all acks have come back successfully + state.OutboundTransfersEnabled = true + ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeOutboundTransfersEnabled)) } + k.SetState(ctx, state) } func (k Keeper) outboundTransfersEnabled(ctx sdk.Context) bool { @@ -65,10 +47,3 @@ func (k Keeper) outboundTransfersEnabled(ctx sdk.Context) bool { state := k.GetState(ctx) return state.OutboundTransfersEnabled } - -func (k Keeper) enableOutboundTransfers(ctx sdk.Context) { - state := k.GetState(ctx) - state.OutboundTransfersEnabled = true - ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeOutboundTransfersEnabled)) - k.SetState(ctx, state) -} From 4a1fa4da510eb1500724f993847304c4670779c0 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:21:17 +0100 Subject: [PATCH 31/79] ready for another test --- x/hub-genesis/keeper/ibc_module.go | 6 +++++- x/hub-genesis/keeper/ics4_wrapper.go | 7 ++++++- x/hub-genesis/keeper/sequence_numbers.go | 18 +++++++++--------- x/hub-genesis/types/state.go | 4 ++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 4ad47dac..89cf4a6e 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -123,11 +123,15 @@ func (w IBCModule) OnAcknowledgementPacket( acknowledgement []byte, relayer sdk.AccAddress, ) error { + state := w.k.GetState(ctx) + if !state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { + return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) + } var data transfertypes.FungibleTokenPacketData if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { - w.k.ackSeqNum(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence, ack.Success()) + w.k.ackSeqNum(ctx, packet.Sequence, ack.Success()) } } return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index a5f40c67..f6031ab7 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -45,6 +45,11 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { + state := w.k.GetState(ctx) + if !state.IsCanonicalHubTransferChannel(sourcePort, sourceChannel) { + return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + } + var transfer transfertypes.FungibleTokenPacketData _ = transfertypes.ModuleCdc.UnmarshalJSON(data, &transfer) @@ -60,7 +65,7 @@ func (w ICS4Wrapper) SendPacket( if err != nil { return seq, err } - w.k.saveSeqNum(ctx, sourcePort, sourceChannel, seq) + w.k.saveSeqNum(ctx, seq) return seq, nil } else if !w.k.outboundTransfersEnabled(ctx) { return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 608186c6..56fc5a96 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -12,26 +12,26 @@ Whenever a genesis transfer is sent, we record the sequence number. We do not al all acks have been received with success. */ -func seqNumKey(port, channel string, seq uint64) []byte { - bz := []byte(fmt.Sprintf("seqnumval/%s/%s/", port, channel)) +func seqNumKey(seq uint64) []byte { + bz := []byte(fmt.Sprintf("seqnumval/")) bz = append(bz, sdk.Uint64ToBigEndian(seq)...) return bz } -func (k Keeper) saveSeqNum(ctx sdk.Context, port, channel string, seq uint64) { - ctx.KVStore(k.storeKey).Set(seqNumKey(port, channel, seq), []byte{}) +func (k Keeper) saveSeqNum(ctx sdk.Context, seq uint64) { + ctx.KVStore(k.storeKey).Set(seqNumKey(seq), []byte{}) } -func (k Keeper) delSeqNum(ctx sdk.Context, port, channel string, seq uint64) { - ctx.KVStore(k.storeKey).Delete(seqNumKey(port, channel, seq)) +func (k Keeper) delSeqNum(ctx sdk.Context, seq uint64) { + ctx.KVStore(k.storeKey).Delete(seqNumKey(seq)) } // ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer -func (k Keeper) ackSeqNum(ctx sdk.Context, port, channel string, seq uint64, success bool) { +func (k Keeper) ackSeqNum(ctx sdk.Context, seq uint64, success bool) { if !success { - panic(fmt.Sprintf("genesis transfer unsuccessful, port: %s, channel: %s: seq: %d", port, channel, seq)) + panic(fmt.Sprintf("genesis transfer unsuccessful seq: %d", seq)) } - k.delSeqNum(ctx, port, channel, seq) + k.delSeqNum(ctx, seq) state := k.GetState(ctx) state.NumUnackedTransfers-- if state.NumUnackedTransfers == 0 { diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index 852e392b..da6b01da 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -17,3 +17,7 @@ func (s State) Validate() error { } return nil } + +func (s State) IsCanonicalHubTransferChannel(port, channel string) bool { + return s.HubPortAndChannel.Port == port && s.HubPortAndChannel.Channel == channel +} From f230a086c500ed3df9d44dbb750d35b53306d0af Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:23:44 +0100 Subject: [PATCH 32/79] need to do genesis --- proto/hub-genesis/genesis.proto | 1 + x/hub-genesis/types/genesis.pb.go | 134 +++++++++++++++++++++++++++--- 2 files changed, 124 insertions(+), 11 deletions(-) diff --git a/proto/hub-genesis/genesis.proto b/proto/hub-genesis/genesis.proto index 31a8470c..4c2f9372 100755 --- a/proto/hub-genesis/genesis.proto +++ b/proto/hub-genesis/genesis.proto @@ -10,4 +10,5 @@ option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; message GenesisState { reserved 1; State state = 2 [(gogoproto.nullable) = false]; + repeated uint64 unacked_transfer_seq_nums = 3 [(gogoproto.nullable) = false]; } diff --git a/x/hub-genesis/types/genesis.pb.go b/x/hub-genesis/types/genesis.pb.go index 2432ac9b..554cfc28 100644 --- a/x/hub-genesis/types/genesis.pb.go +++ b/x/hub-genesis/types/genesis.pb.go @@ -25,7 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the hub-genesis module's genesis state. type GenesisState struct { - State State `protobuf:"bytes,2,opt,name=state,proto3" json:"state"` + State State `protobuf:"bytes,2,opt,name=state,proto3" json:"state"` + UnackedTransferSeqNums []uint64 `protobuf:"varint,3,rep,packed,name=unacked_transfer_seq_nums,json=unackedTransferSeqNums,proto3" json:"unacked_transfer_seq_nums,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,6 +69,13 @@ func (m *GenesisState) GetState() State { return State{} } +func (m *GenesisState) GetUnackedTransferSeqNums() []uint64 { + if m != nil { + return m.UnackedTransferSeqNums + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "rollapp.hub_genesis.GenesisState") } @@ -75,20 +83,23 @@ func init() { func init() { proto.RegisterFile("hub-genesis/genesis.proto", fileDescriptor_6deac3d79fd587fe) } var fileDescriptor_6deac3d79fd587fe = []byte{ - // 204 bytes of a gzipped FileDescriptorProto + // 255 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x28, 0x4d, 0xd2, 0x4d, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x87, 0xd2, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x45, 0xf9, 0x39, 0x39, 0x89, 0x05, 0x05, 0x7a, 0x19, 0xa5, 0x49, 0xf1, 0x50, 0x29, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xbc, 0x3e, 0x88, 0x05, 0x51, 0x2a, 0x25, 0x8e, 0x6c, - 0x4a, 0x71, 0x49, 0x62, 0x49, 0x2a, 0x44, 0x42, 0xc9, 0x87, 0x8b, 0xc7, 0x1d, 0x22, 0x1c, 0x0c, - 0x12, 0x15, 0x32, 0xe3, 0x62, 0x05, 0x4b, 0x4b, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x49, 0xe9, - 0x61, 0xb1, 0x43, 0x0f, 0xac, 0xd4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x88, 0x72, 0x2f, - 0x16, 0x0e, 0x46, 0x01, 0x26, 0xa7, 0xe0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, - 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, - 0x88, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xa9, 0xcc, - 0x4d, 0xcd, 0x2b, 0xce, 0xcc, 0xcf, 0xab, 0xa8, 0xac, 0x42, 0x70, 0x74, 0x8b, 0x52, 0xb2, 0xf5, - 0x2b, 0xf4, 0x91, 0x1d, 0x5a, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0xa9, 0x31, 0x20, - 0x00, 0x00, 0xff, 0xff, 0x29, 0x7b, 0x08, 0xad, 0x0a, 0x01, 0x00, 0x00, + 0x4a, 0x71, 0x49, 0x62, 0x49, 0x2a, 0x44, 0x42, 0xa9, 0x97, 0x91, 0x8b, 0xc7, 0x1d, 0x22, 0x1e, + 0x0c, 0x12, 0x16, 0x32, 0xe3, 0x62, 0x05, 0xcb, 0x4b, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x49, + 0xe9, 0x61, 0xb1, 0x44, 0x0f, 0xac, 0xd4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x88, 0x72, + 0x21, 0x7b, 0x2e, 0xc9, 0xd2, 0xbc, 0xc4, 0xe4, 0xec, 0xd4, 0x94, 0xf8, 0x92, 0xa2, 0xc4, 0xbc, + 0xe2, 0xb4, 0xd4, 0xa2, 0xf8, 0xe2, 0xd4, 0xc2, 0xf8, 0xbc, 0xd2, 0xdc, 0x62, 0x09, 0x66, 0x05, + 0x66, 0x0d, 0x16, 0xa8, 0x7a, 0x31, 0xa8, 0xb2, 0x10, 0xa8, 0xaa, 0xe0, 0xd4, 0x42, 0xbf, 0xd2, + 0xdc, 0x62, 0x2f, 0x16, 0x0e, 0x46, 0x01, 0x26, 0xa7, 0xe0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, + 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, + 0x3c, 0x96, 0x63, 0x88, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, + 0x4f, 0xa9, 0xcc, 0x4d, 0xcd, 0x2b, 0xce, 0xcc, 0xcf, 0xab, 0xa8, 0xac, 0x42, 0x70, 0x74, 0x8b, + 0x52, 0xb2, 0xf5, 0x2b, 0xf4, 0x91, 0xbd, 0x5a, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, + 0xab, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x27, 0x7b, 0xfd, 0xfc, 0x4c, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -111,6 +122,24 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.UnackedTransferSeqNums) > 0 { + dAtA2 := make([]byte, len(m.UnackedTransferSeqNums)*10) + var j1 int + for _, num := range m.UnackedTransferSeqNums { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintGenesis(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x1a + } { size, err := m.State.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -143,6 +172,13 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.State.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.UnackedTransferSeqNums) > 0 { + l = 0 + for _, e := range m.UnackedTransferSeqNums { + l += sovGenesis(uint64(e)) + } + n += 1 + sovGenesis(uint64(l)) + l + } return n } @@ -214,6 +250,82 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UnackedTransferSeqNums = append(m.UnackedTransferSeqNums, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.UnackedTransferSeqNums) == 0 { + m.UnackedTransferSeqNums = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UnackedTransferSeqNums = append(m.UnackedTransferSeqNums, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field UnackedTransferSeqNums", wireType) + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) From 59fea0f1a20aa071547843dbfcf0d659fb2d3ed3 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:26:37 +0100 Subject: [PATCH 33/79] need to impl genesis --- x/hub-genesis/keeper/genesis.go | 4 ++++ x/hub-genesis/keeper/sequence_numbers.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/x/hub-genesis/keeper/genesis.go b/x/hub-genesis/keeper/genesis.go index 3a6ba0c1..80ebcb2a 100644 --- a/x/hub-genesis/keeper/genesis.go +++ b/x/hub-genesis/keeper/genesis.go @@ -8,11 +8,15 @@ import ( // InitGenesis new hub-genesis genesis. func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { k.SetState(ctx, genState.State) + for _, seq := range genState.UnackedTransferSeqNums { + k.saveSeqNum(ctx, seq) + } } // ExportGenesis returns a GenesisState for a given context and keeper. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { genesis := types.DefaultGenesisState() genesis.State = k.GetState(ctx) + genesis.UnackedTransferSeqNums = k.getAllSeqNums(ctx) return genesis } diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 56fc5a96..90fda994 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -26,6 +26,14 @@ func (k Keeper) delSeqNum(ctx sdk.Context, seq uint64) { ctx.KVStore(k.storeKey).Delete(seqNumKey(seq)) } +// returns all seq nums, only intended for genesis export +func (k Keeper) getAllSeqNums(ctx sdk.Context) []uint64 { + state := k.GetState(ctx) + n := state.NumUnackedTransfers + ret := make([]uint64, n) + // TODO: +} + // ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer func (k Keeper) ackSeqNum(ctx sdk.Context, seq uint64, success bool) { if !success { From 6b104e970ca6e9c6fcca127d9a62adbcef4c6848 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:35:06 +0100 Subject: [PATCH 34/79] impl the iterator --- x/hub-genesis/keeper/ibc_module.go | 7 +++++-- x/hub-genesis/keeper/sequence_numbers.go | 13 +++++++++++-- x/hub-genesis/types/state.go | 4 ++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 89cf4a6e..db18ffcd 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -50,12 +50,15 @@ func (w IBCModule) OnChanOpenConfirm( err := w.IBCModule.OnChanOpenConfirm(ctx, portID, channelID) if err != nil { - l.Error("Next middleware.", "err", err) return err } state := w.k.GetState(ctx) + if state.CanonicalHubTransferChannelHasBeenSet() { + return nil + } + state.HubPortAndChannel = &types.PortAndChannel{ Port: portID, Channel: channelID, @@ -78,7 +81,7 @@ func (w IBCModule) OnChanOpenConfirm( l.Info("Sent all genesis transfers.") - return w.IBCModule.OnChanOpenConfirm(ctx, portID, channelID) + return nil } func (w IBCModule) mintAndTransfer(ctx sdk.Context, account types.GenesisAccount, srcAddr string, portID string, channelID string) error { diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 90fda994..82c2acb2 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -12,8 +12,11 @@ Whenever a genesis transfer is sent, we record the sequence number. We do not al all acks have been received with success. */ +var UnackedTransferSeqNumsPrefix = []byte("unacked_seqs") + func seqNumKey(seq uint64) []byte { - bz := []byte(fmt.Sprintf("seqnumval/")) + bz := make([]byte, len(UnackedTransferSeqNumsPrefix)) + copy(bz, UnackedTransferSeqNumsPrefix) bz = append(bz, sdk.Uint64ToBigEndian(seq)...) return bz } @@ -31,7 +34,13 @@ func (k Keeper) getAllSeqNums(ctx sdk.Context) []uint64 { state := k.GetState(ctx) n := state.NumUnackedTransfers ret := make([]uint64, n) - // TODO: + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, UnackedTransferSeqNumsPrefix) + defer iterator.Close() // nolint: errcheck + for ; iterator.Valid(); iterator.Next() { + ret = append(ret, sdk.BigEndianToUint64(iterator.Key())) + } + return ret } // ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index da6b01da..0d09dc52 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -21,3 +21,7 @@ func (s State) Validate() error { func (s State) IsCanonicalHubTransferChannel(port, channel string) bool { return s.HubPortAndChannel.Port == port && s.HubPortAndChannel.Channel == channel } + +func (s State) CanonicalHubTransferChannelHasBeenSet() bool { + return s.HubPortAndChannel.Port != "" || s.HubPortAndChannel.Channel != "" +} From a31d08ae3b061d2d3850ff69aa47c9ac6edfb088 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:45:43 +0100 Subject: [PATCH 35/79] adds back params for now --- proto/hub-genesis/params.proto | 13 ++ x/hub-genesis/keeper/keeper.go | 7 - x/hub-genesis/types/genesis.go | 21 ++- x/hub-genesis/types/params.go | 37 +++++ x/hub-genesis/types/params.pb.go | 265 +++++++++++++++++++++++++++++++ 5 files changed, 328 insertions(+), 15 deletions(-) create mode 100644 proto/hub-genesis/params.proto create mode 100644 x/hub-genesis/types/params.go create mode 100644 x/hub-genesis/types/params.pb.go diff --git a/proto/hub-genesis/params.proto b/proto/hub-genesis/params.proto new file mode 100644 index 00000000..0f0ec61c --- /dev/null +++ b/proto/hub-genesis/params.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package rollapp.hub_genesis; + +option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; + +import "gogoproto/gogo.proto"; + +// Params holds parameters for the hub-genesis module. +message Params { + option (gogoproto.goproto_stringer) = false; + reserved 1; +} + diff --git a/x/hub-genesis/keeper/keeper.go b/x/hub-genesis/keeper/keeper.go index ed517c11..01706011 100644 --- a/x/hub-genesis/keeper/keeper.go +++ b/x/hub-genesis/keeper/keeper.go @@ -13,10 +13,6 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -type ChannelKeeper interface { - GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte -} - type ( Keeper struct { cdc codec.BinaryCodec @@ -24,7 +20,6 @@ type ( paramstore paramtypes.Subspace accountKeeper types.AuthAccountKeeper - channelKeeper ChannelKeeper } ) @@ -33,7 +28,6 @@ func NewKeeper( storeKey storetypes.StoreKey, ps paramtypes.Subspace, accountKeeper types.AuthAccountKeeper, - channelKeeper ChannelKeeper, ) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -46,7 +40,6 @@ func NewKeeper( storeKey: storeKey, paramstore: ps, accountKeeper: accountKeeper, - channelKeeper: channelKeeper, } } diff --git a/x/hub-genesis/types/genesis.go b/x/hub-genesis/types/genesis.go index 68a905ea..5fa1b04f 100644 --- a/x/hub-genesis/types/genesis.go +++ b/x/hub-genesis/types/genesis.go @@ -1,28 +1,33 @@ package types +import ( + errorsmod "cosmossdk.io/errors" + "github.com/dymensionxyz/gerr-cosmos/gerrc" +) + // NewGenesisState creates a new GenesisState object. -func NewGenesisState(params Params, state State) *GenesisState { +func NewGenesisState(state State) *GenesisState { return &GenesisState{ - Params: params, - State: state, + State: state, } } // DefaultGenesisState creates a default GenesisState object. func DefaultGenesisState() *GenesisState { - return NewGenesisState(DefaultParams(), State{}) + return NewGenesisState(State{}) } // ValidateGenesis validates the provided genesis state to ensure the // expected invariants holds. func ValidateGenesis(data GenesisState) error { - if err := data.Params.Validate(); err != nil { - return err - } - if err := data.State.Validate(); err != nil { return err } + nSeqsExpected := data.State.NumUnackedTransfers + nSeqsHave := uint64(len(data.UnackedTransferSeqNums)) + if nSeqsExpected != nSeqsHave { + return errorsmod.Wrapf(gerrc.ErrInvalidArgument, "got different number of unacked transfers than expected: expect: %d, actual: %d", nSeqsExpected, nSeqsHave) + } return nil } diff --git a/x/hub-genesis/types/params.go b/x/hub-genesis/types/params.go new file mode 100644 index 00000000..06d6554d --- /dev/null +++ b/x/hub-genesis/types/params.go @@ -0,0 +1,37 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable for hub_genesis module. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func NewParams() Params { + return Params{} +} + +func DefaultParams() Params { + return NewParams() +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +// ParamSetPairs implements params.ParamSet. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate checks that the parameters have valid values. +func (p Params) Validate() error { + return nil +} diff --git a/x/hub-genesis/types/params.pb.go b/x/hub-genesis/types/params.pb.go new file mode 100644 index 00000000..4344d68e --- /dev/null +++ b/x/hub-genesis/types/params.pb.go @@ -0,0 +1,265 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: hub-genesis/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params holds parameters for the hub-genesis module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_a8d0b00d1bcc9c95, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "rollapp.hub_genesis.Params") +} + +func init() { proto.RegisterFile("hub-genesis/params.proto", fileDescriptor_a8d0b00d1bcc9c95) } + +var fileDescriptor_a8d0b00d1bcc9c95 = []byte{ + // 172 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0x28, 0x4d, 0xd2, + 0x4d, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0xca, 0xcf, 0xc9, 0x49, 0x2c, 0x28, 0xd0, 0xcb, 0x28, + 0x4d, 0x8a, 0x87, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, + 0xa5, 0x4a, 0x22, 0x5c, 0x6c, 0x01, 0x60, 0xad, 0x56, 0x2c, 0x33, 0x16, 0xc8, 0x33, 0x78, 0xb1, + 0x70, 0x30, 0x0a, 0x30, 0x39, 0x05, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, + 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, + 0x94, 0x65, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x4a, 0x65, 0x6e, + 0x6a, 0x5e, 0x71, 0x66, 0x7e, 0x5e, 0x45, 0x65, 0x15, 0x82, 0xa3, 0x5b, 0x94, 0x92, 0xad, 0x5f, + 0xa1, 0x8f, 0xec, 0xb8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x8d, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x0e, 0xf1, 0x3f, 0x16, 0xb8, 0x00, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) From 38146aa02c802d67196e4645337e62a66b965073 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:47:45 +0100 Subject: [PATCH 36/79] try to bring back params for now --- proto/hub-genesis/query.proto | 16 ++ x/hub-genesis/types/query.pb.go | 379 +++++++++++++++++++++++++++-- x/hub-genesis/types/query.pb.gw.go | 65 +++++ 3 files changed, 439 insertions(+), 21 deletions(-) diff --git a/proto/hub-genesis/query.proto b/proto/hub-genesis/query.proto index a47afd78..35b30535 100644 --- a/proto/hub-genesis/query.proto +++ b/proto/hub-genesis/query.proto @@ -3,12 +3,19 @@ package rollapp.hub_genesis; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "hub-genesis/params.proto"; import "hub-genesis/state.proto"; option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; // Query provides defines the gRPC querier service. service Query { + // Params returns the total set of hub-genesis parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = + "/dymensionxyz/dymension-rdk/hub-genesis/params"; + } + // State returns the state of the genesis event. rpc State(QueryStateRequest) returns (QueryStateResponse) { option (google.api.http).get = @@ -16,6 +23,15 @@ service Query { } } +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [ (gogoproto.nullable) = false ]; +} + // QueryStateRequest is the request type for the Query/State RPC method. message QueryStateRequest {} diff --git a/x/hub-genesis/types/query.pb.go b/x/hub-genesis/types/query.pb.go index f8733b8a..a1a82d10 100644 --- a/x/hub-genesis/types/query.pb.go +++ b/x/hub-genesis/types/query.pb.go @@ -29,6 +29,89 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_361b89f8abfb35e2, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_361b89f8abfb35e2, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + // QueryStateRequest is the request type for the Query/State RPC method. type QueryStateRequest struct { } @@ -37,7 +120,7 @@ func (m *QueryStateRequest) Reset() { *m = QueryStateRequest{} } func (m *QueryStateRequest) String() string { return proto.CompactTextString(m) } func (*QueryStateRequest) ProtoMessage() {} func (*QueryStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_361b89f8abfb35e2, []int{0} + return fileDescriptor_361b89f8abfb35e2, []int{2} } func (m *QueryStateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -76,7 +159,7 @@ func (m *QueryStateResponse) Reset() { *m = QueryStateResponse{} } func (m *QueryStateResponse) String() string { return proto.CompactTextString(m) } func (*QueryStateResponse) ProtoMessage() {} func (*QueryStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_361b89f8abfb35e2, []int{1} + return fileDescriptor_361b89f8abfb35e2, []int{3} } func (m *QueryStateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -113,6 +196,8 @@ func (m *QueryStateResponse) GetState() State { } func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "rollapp.hub_genesis.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "rollapp.hub_genesis.QueryParamsResponse") proto.RegisterType((*QueryStateRequest)(nil), "rollapp.hub_genesis.QueryStateRequest") proto.RegisterType((*QueryStateResponse)(nil), "rollapp.hub_genesis.QueryStateResponse") } @@ -120,25 +205,30 @@ func init() { func init() { proto.RegisterFile("hub-genesis/query.proto", fileDescriptor_361b89f8abfb35e2) } var fileDescriptor_361b89f8abfb35e2 = []byte{ - // 287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x28, 0x4d, 0xd2, - 0x4d, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, - 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0xca, 0xcf, 0xc9, 0x49, 0x2c, 0x28, 0xd0, 0xcb, 0x28, 0x4d, - 0x8a, 0x87, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, - 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, 0x79, 0x79, - 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0x14, 0x1b, 0x8a, 0x4b, 0x12, 0x4b, - 0x52, 0x21, 0x12, 0x4a, 0xc2, 0x5c, 0x82, 0x81, 0x20, 0x0b, 0x83, 0x41, 0x62, 0x41, 0xa9, 0x85, - 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0x3e, 0x5c, 0x42, 0xc8, 0x82, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, - 0x42, 0x66, 0x5c, 0xac, 0x60, 0x9d, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x52, 0x7a, 0x58, - 0x1c, 0xa7, 0x07, 0xd6, 0xe2, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x44, 0xb9, 0xd1, 0x4c, - 0x46, 0x2e, 0x56, 0xb0, 0x71, 0x42, 0xfd, 0x8c, 0x5c, 0xac, 0x60, 0x05, 0x42, 0x6a, 0x58, 0x35, - 0x63, 0xb8, 0x44, 0x4a, 0x9d, 0xa0, 0x3a, 0x88, 0xe3, 0x94, 0x4c, 0x9b, 0x2e, 0x3f, 0x99, 0xcc, - 0xa4, 0x2f, 0xa4, 0xab, 0x9f, 0x52, 0x99, 0x9b, 0x9a, 0x57, 0x9c, 0x99, 0x9f, 0x57, 0x51, 0x59, - 0x85, 0xe0, 0xe8, 0x16, 0xa5, 0x64, 0xeb, 0x63, 0x04, 0x82, 0x53, 0xf0, 0x89, 0x47, 0x72, 0x8c, - 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, - 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, - 0xe7, 0xe2, 0x33, 0xb2, 0x02, 0xc5, 0xd0, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xd0, - 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x08, 0x19, 0x55, 0xd6, 0xd7, 0x01, 0x00, 0x00, + // 361 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xb1, 0x4e, 0x3a, 0x31, + 0x1c, 0xc7, 0xaf, 0xe4, 0x0f, 0x43, 0xff, 0x93, 0x85, 0x44, 0x72, 0x9a, 0xd3, 0xdc, 0x20, 0x2c, + 0x5c, 0x0d, 0x46, 0x12, 0x56, 0x66, 0x07, 0x84, 0xcd, 0xc5, 0xf4, 0xa4, 0x39, 0x2e, 0x42, 0x5b, + 0xae, 0xbd, 0x84, 0x73, 0xf4, 0x05, 0x34, 0xe1, 0x41, 0x7c, 0x0d, 0x46, 0x12, 0x17, 0x27, 0x63, + 0xc0, 0x07, 0x31, 0xb4, 0x25, 0x42, 0x40, 0x71, 0x83, 0xfe, 0xbe, 0xbf, 0xef, 0xe7, 0x73, 0xbd, + 0x83, 0x87, 0xfd, 0x34, 0xac, 0x45, 0x94, 0x51, 0x19, 0x4b, 0x3c, 0x4a, 0x69, 0x92, 0x05, 0x22, + 0xe1, 0x8a, 0xa3, 0x62, 0xc2, 0x07, 0x03, 0x22, 0x44, 0xd0, 0x4f, 0xc3, 0x5b, 0x1b, 0x70, 0x4b, + 0x11, 0x8f, 0xb8, 0x9e, 0xe3, 0xe5, 0x2f, 0x13, 0x75, 0x8f, 0x23, 0xce, 0xa3, 0x01, 0xc5, 0x44, + 0xc4, 0x98, 0x30, 0xc6, 0x15, 0x51, 0x31, 0x67, 0xd2, 0x4e, 0xcb, 0xeb, 0x04, 0x41, 0x12, 0x32, + 0x5c, 0x4d, 0x36, 0xd8, 0x52, 0x11, 0x45, 0xcd, 0xc0, 0x2f, 0x41, 0x74, 0xbd, 0x54, 0x69, 0xeb, + 0x74, 0x87, 0x8e, 0x52, 0x2a, 0x95, 0xdf, 0x86, 0xc5, 0x8d, 0x53, 0x29, 0x38, 0x93, 0x14, 0x35, + 0x61, 0xc1, 0xb4, 0x96, 0xc1, 0x29, 0xa8, 0xfe, 0xaf, 0x1f, 0x05, 0x3b, 0xcc, 0x03, 0xb3, 0xd4, + 0xfa, 0x37, 0x7d, 0x3f, 0x71, 0x3a, 0x76, 0xc1, 0x2f, 0xc2, 0x03, 0xdd, 0xd8, 0x5d, 0xb2, 0x57, + 0x98, 0x2b, 0x0b, 0xb7, 0x87, 0x96, 0xd2, 0x80, 0x79, 0x6d, 0x68, 0x21, 0xee, 0x4e, 0x88, 0x5e, + 0xb1, 0x0c, 0x13, 0xaf, 0xbf, 0xe4, 0x60, 0x5e, 0xd7, 0xa1, 0x09, 0x80, 0x05, 0x63, 0x81, 0x2a, + 0x3b, 0xb7, 0xb7, 0x1f, 0xd9, 0xad, 0xee, 0x0f, 0x1a, 0x3f, 0xbf, 0xf1, 0xf8, 0xfa, 0x39, 0xc9, + 0x9d, 0xa3, 0x00, 0xf7, 0xb2, 0x21, 0x65, 0x32, 0xe6, 0x6c, 0x9c, 0x3d, 0x7c, 0xff, 0xa9, 0x25, + 0xbd, 0x7b, 0xbc, 0xfd, 0x26, 0xd0, 0x13, 0x80, 0x79, 0xad, 0x8d, 0xce, 0x7e, 0x66, 0xad, 0xdf, + 0x8f, 0x5b, 0xd9, 0x9b, 0xb3, 0x4a, 0x97, 0x5a, 0x09, 0xa3, 0xda, 0x5f, 0x95, 0xf4, 0x8d, 0xb5, + 0xba, 0xd3, 0xb9, 0x07, 0x66, 0x73, 0x0f, 0x7c, 0xcc, 0x3d, 0xf0, 0xbc, 0xf0, 0x9c, 0xd9, 0xc2, + 0x73, 0xde, 0x16, 0x9e, 0x73, 0xd3, 0x8c, 0x62, 0xd5, 0x4f, 0xc3, 0xe0, 0x8e, 0x0f, 0x7f, 0xab, + 0x1c, 0x6f, 0x94, 0xaa, 0x4c, 0x50, 0x19, 0x16, 0xf4, 0x87, 0x75, 0xf1, 0x15, 0x00, 0x00, 0xff, + 0xff, 0x4a, 0x6a, 0xbc, 0x50, 0xef, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -153,6 +243,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + // Params returns the total set of hub-genesis parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // State returns the state of the genesis event. State(ctx context.Context, in *QueryStateRequest, opts ...grpc.CallOption) (*QueryStateResponse, error) } @@ -165,6 +257,15 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/rollapp.hub_genesis.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) State(ctx context.Context, in *QueryStateRequest, opts ...grpc.CallOption) (*QueryStateResponse, error) { out := new(QueryStateResponse) err := c.cc.Invoke(ctx, "/rollapp.hub_genesis.Query/State", in, out, opts...) @@ -176,6 +277,8 @@ func (c *queryClient) State(ctx context.Context, in *QueryStateRequest, opts ... // QueryServer is the server API for Query service. type QueryServer interface { + // Params returns the total set of hub-genesis parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // State returns the state of the genesis event. State(context.Context, *QueryStateRequest) (*QueryStateResponse, error) } @@ -184,6 +287,9 @@ type QueryServer interface { type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} func (*UnimplementedQueryServer) State(ctx context.Context, req *QueryStateRequest) (*QueryStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method State not implemented") } @@ -192,6 +298,24 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rollapp.hub_genesis.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_State_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryStateRequest) if err := dec(in); err != nil { @@ -214,6 +338,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "rollapp.hub_genesis.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, { MethodName: "State", Handler: _Query_State_Handler, @@ -223,6 +351,62 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "hub-genesis/query.proto", } +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *QueryStateRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -290,6 +474,26 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryStateRequest) Size() (n int) { if m == nil { return 0 @@ -316,6 +520,139 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryStateRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/hub-genesis/types/query.pb.gw.go b/x/hub-genesis/types/query.pb.gw.go index 609f1662..16c5d1a9 100644 --- a/x/hub-genesis/types/query.pb.gw.go +++ b/x/hub-genesis/types/query.pb.gw.go @@ -33,6 +33,24 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_State_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryStateRequest var metadata runtime.ServerMetadata @@ -57,6 +75,29 @@ func local_request_Query_State_0(ctx context.Context, marshaler runtime.Marshale // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_State_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -121,6 +162,26 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_State_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -145,9 +206,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dymensionxyz", "dymension-rdk", "hub-genesis", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_State_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dymensionxyz", "dymension-rdk", "hub-genesis", "state"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_State_0 = runtime.ForwardResponseMessage ) From d2daabdf2c2ac25e6da45f226e5304d8ad33e820 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:50:05 +0100 Subject: [PATCH 37/79] confirms installable --- x/hub-genesis/keeper/grpc_query.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x/hub-genesis/keeper/grpc_query.go b/x/hub-genesis/keeper/grpc_query.go index 0ab067e8..f622d18b 100644 --- a/x/hub-genesis/keeper/grpc_query.go +++ b/x/hub-genesis/keeper/grpc_query.go @@ -20,6 +20,11 @@ func NewQuerier(k Keeper) Querier { return Querier{Keeper: k} } +// Params returns params of the hub-genesis module. +func (q Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + return &types.QueryParamsResponse{}, nil +} + func (q Querier) State(goCtx context.Context, request *types.QueryStateRequest) (*types.QueryStateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) return &types.QueryStateResponse{State: q.Keeper.GetState(ctx)}, nil From 48d533cb76359aa50aa2073d435a7e746d3b6a06 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:12:59 +0100 Subject: [PATCH 38/79] fix testapp --- testutil/app/app.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/testutil/app/app.go b/testutil/app/app.go index a8e20c86..e6db4a53 100644 --- a/testutil/app/app.go +++ b/testutil/app/app.go @@ -417,12 +417,14 @@ func NewRollapp( ), ) + genesisTransfersMemoBlocker := hubgenkeeper.NewICS4Wrapper(app.IBCKeeper.ChannelKeeper) + // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCKeeper.ChannelKeeper, + genesisTransfersMemoBlocker, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, @@ -438,6 +440,16 @@ func NewRollapp( app.TransferKeeper, denommetadatamoduletypes.NewMultiDenommetadataHooks(), ) + transferStack = hubgenkeeper.NewIBCModule( + transferStack, + func(ctx sdk.Context, transfer *ibctransfertypes.MsgTransfer) error { + _, err := app.TransferKeeper.Transfer(sdk.WrapSDKContext(ctx), transfer) + return err + }, + app.HubGenesisKeeper, + app.BankKeeper.GetDenomMetaData, + app.BankKeeper.MintCoins, + ) app.HubGenesisKeeper = hubgenkeeper.NewKeeper( appCodec, @@ -739,10 +751,11 @@ func (app *App) ModuleAccountAddrs() map[string]bool { } // BlockedModuleAccountAddrs returns all the app's blocked module account -// addresses. +// addresses. A true value means blocked. Absent or false means not blocked. func (app *App) BlockedModuleAccountAddrs() map[string]bool { modAccAddrs := app.ModuleAccountAddrs() delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + delete(modAccAddrs, authtypes.NewModuleAddress(hubgentypes.ModuleName).String()) return modAccAddrs } From e6a066d311f7189888bc439b15c8329e0fc698b8 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:54:19 +0100 Subject: [PATCH 39/79] ready to test --- testutil/app/app.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/testutil/app/app.go b/testutil/app/app.go index e6db4a53..bf87c84c 100644 --- a/testutil/app/app.go +++ b/testutil/app/app.go @@ -417,7 +417,14 @@ func NewRollapp( ), ) - genesisTransfersMemoBlocker := hubgenkeeper.NewICS4Wrapper(app.IBCKeeper.ChannelKeeper) + app.HubGenesisKeeper = hubgenkeeper.NewKeeper( + appCodec, + keys[hubgentypes.StoreKey], + app.GetSubspace(hubgentypes.ModuleName), + app.AccountKeeper, + ) + + genesisTransfersMemoBlocker := hubgenkeeper.NewICS4Wrapper(app.IBCKeeper.ChannelKeeper, app.HubGenesisKeeper) // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( @@ -451,14 +458,6 @@ func NewRollapp( app.BankKeeper.MintCoins, ) - app.HubGenesisKeeper = hubgenkeeper.NewKeeper( - appCodec, - keys[hubgentypes.StoreKey], - app.GetSubspace(hubgentypes.ModuleName), - app.AccountKeeper, - app.IBCKeeper.ChannelKeeper, - ) - app.GaslessKeeper = gaslesskeeper.NewKeeper( appCodec, app.keys[gaslesstypes.StoreKey], From 6151749f304476b3d634bb4c46e7f481542d7fce Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:22:17 +0100 Subject: [PATCH 40/79] fix nil deref --- x/hub-genesis/types/state.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index 0d09dc52..354cbdeb 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -1,6 +1,8 @@ package types import ( + "reflect" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -19,9 +21,9 @@ func (s State) Validate() error { } func (s State) IsCanonicalHubTransferChannel(port, channel string) bool { - return s.HubPortAndChannel.Port == port && s.HubPortAndChannel.Channel == channel + return s.CanonicalHubTransferChannelHasBeenSet() && s.HubPortAndChannel.Port == port && s.HubPortAndChannel.Channel == channel } func (s State) CanonicalHubTransferChannelHasBeenSet() bool { - return s.HubPortAndChannel.Port != "" || s.HubPortAndChannel.Channel != "" + return s.HubPortAndChannel != nil && !reflect.ValueOf(s.GetHubPortAndChannel).IsZero() } From 479bab2bead23b72a5b8894b7a5553bcbfabe1d7 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:36:16 +0100 Subject: [PATCH 41/79] adds back params for now --- proto/hub-genesis/genesis.proto | 4 +- x/hub-genesis/client/cli/query.go | 30 +++++++++++ x/hub-genesis/keeper/genesis.go | 2 + x/hub-genesis/keeper/params.go | 18 +++++++ x/hub-genesis/types/genesis.go | 10 ++-- x/hub-genesis/types/genesis.pb.go | 84 +++++++++++++++++++++++++------ 6 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 x/hub-genesis/keeper/params.go diff --git a/proto/hub-genesis/genesis.proto b/proto/hub-genesis/genesis.proto index 4c2f9372..e6e57214 100755 --- a/proto/hub-genesis/genesis.proto +++ b/proto/hub-genesis/genesis.proto @@ -2,13 +2,15 @@ syntax = "proto3"; package rollapp.hub_genesis; import "gogoproto/gogo.proto"; +import "hub-genesis/params.proto"; import "hub-genesis/state.proto"; option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; // GenesisState defines the hub-genesis module's genesis state. message GenesisState { - reserved 1; + // params defines all the parameters of the module. + Params params = 1 [ (gogoproto.nullable) = false ]; State state = 2 [(gogoproto.nullable) = false]; repeated uint64 unacked_transfer_seq_nums = 3 [(gogoproto.nullable) = false]; } diff --git a/x/hub-genesis/client/cli/query.go b/x/hub-genesis/client/cli/query.go index 0140f826..b33b8d82 100644 --- a/x/hub-genesis/client/cli/query.go +++ b/x/hub-genesis/client/cli/query.go @@ -22,12 +22,42 @@ func GetQueryCmd() *cobra.Command { } hubGenQueryCmd.AddCommand( + GetCmdQueryParams(), GetCmdQueryState(), ) return hubGenQueryCmd } +// GetCmdQueryParams implements a command to return the current hub-genesis +// parameters. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the current hub-genesis parameters", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryParamsRequest{} + res, err := queryClient.Params(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + // GetCmdQueryState implements a command to return the current hub-genesis // state. func GetCmdQueryState() *cobra.Command { diff --git a/x/hub-genesis/keeper/genesis.go b/x/hub-genesis/keeper/genesis.go index 80ebcb2a..cda36f5e 100644 --- a/x/hub-genesis/keeper/genesis.go +++ b/x/hub-genesis/keeper/genesis.go @@ -7,6 +7,7 @@ import ( // InitGenesis new hub-genesis genesis. func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { + k.SetParams(ctx, genState.Params) k.SetState(ctx, genState.State) for _, seq := range genState.UnackedTransferSeqNums { k.saveSeqNum(ctx, seq) @@ -16,6 +17,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { // ExportGenesis returns a GenesisState for a given context and keeper. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { genesis := types.DefaultGenesisState() + genesis.Params = k.GetParams(ctx) genesis.State = k.GetState(ctx) genesis.UnackedTransferSeqNums = k.getAllSeqNums(ctx) return genesis diff --git a/x/hub-genesis/keeper/params.go b/x/hub-genesis/keeper/params.go new file mode 100644 index 00000000..b7dd1bbf --- /dev/null +++ b/x/hub-genesis/keeper/params.go @@ -0,0 +1,18 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" +) + +// GetParams returns the total set of minting parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramstore.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams sets the total set of minting parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/hub-genesis/types/genesis.go b/x/hub-genesis/types/genesis.go index 5fa1b04f..1a3cc1ca 100644 --- a/x/hub-genesis/types/genesis.go +++ b/x/hub-genesis/types/genesis.go @@ -6,20 +6,24 @@ import ( ) // NewGenesisState creates a new GenesisState object. -func NewGenesisState(state State) *GenesisState { +func NewGenesisState(params Params, state State) *GenesisState { return &GenesisState{ - State: state, + Params: params, + State: state, } } // DefaultGenesisState creates a default GenesisState object. func DefaultGenesisState() *GenesisState { - return NewGenesisState(State{}) + return NewGenesisState(DefaultParams(), State{}) } // ValidateGenesis validates the provided genesis state to ensure the // expected invariants holds. func ValidateGenesis(data GenesisState) error { + if err := data.Params.Validate(); err != nil { + return err + } if err := data.State.Validate(); err != nil { return err } diff --git a/x/hub-genesis/types/genesis.pb.go b/x/hub-genesis/types/genesis.pb.go index 554cfc28..ec91b51f 100644 --- a/x/hub-genesis/types/genesis.pb.go +++ b/x/hub-genesis/types/genesis.pb.go @@ -25,6 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the hub-genesis module's genesis state. type GenesisState struct { + // params defines all the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` State State `protobuf:"bytes,2,opt,name=state,proto3" json:"state"` UnackedTransferSeqNums []uint64 `protobuf:"varint,3,rep,packed,name=unacked_transfer_seq_nums,json=unackedTransferSeqNums,proto3" json:"unacked_transfer_seq_nums,omitempty"` } @@ -62,6 +64,13 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func (m *GenesisState) GetState() State { if m != nil { return m.State @@ -83,23 +92,25 @@ func init() { func init() { proto.RegisterFile("hub-genesis/genesis.proto", fileDescriptor_6deac3d79fd587fe) } var fileDescriptor_6deac3d79fd587fe = []byte{ - // 255 bytes of a gzipped FileDescriptorProto + // 282 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x28, 0x4d, 0xd2, 0x4d, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x87, 0xd2, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x45, 0xf9, 0x39, 0x39, 0x89, 0x05, 0x05, 0x7a, 0x19, 0xa5, 0x49, 0xf1, 0x50, 0x29, - 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xbc, 0x3e, 0x88, 0x05, 0x51, 0x2a, 0x25, 0x8e, 0x6c, - 0x4a, 0x71, 0x49, 0x62, 0x49, 0x2a, 0x44, 0x42, 0xa9, 0x97, 0x91, 0x8b, 0xc7, 0x1d, 0x22, 0x1e, - 0x0c, 0x12, 0x16, 0x32, 0xe3, 0x62, 0x05, 0xcb, 0x4b, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x49, - 0xe9, 0x61, 0xb1, 0x44, 0x0f, 0xac, 0xd4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x88, 0x72, - 0x21, 0x7b, 0x2e, 0xc9, 0xd2, 0xbc, 0xc4, 0xe4, 0xec, 0xd4, 0x94, 0xf8, 0x92, 0xa2, 0xc4, 0xbc, - 0xe2, 0xb4, 0xd4, 0xa2, 0xf8, 0xe2, 0xd4, 0xc2, 0xf8, 0xbc, 0xd2, 0xdc, 0x62, 0x09, 0x66, 0x05, - 0x66, 0x0d, 0x16, 0xa8, 0x7a, 0x31, 0xa8, 0xb2, 0x10, 0xa8, 0xaa, 0xe0, 0xd4, 0x42, 0xbf, 0xd2, - 0xdc, 0x62, 0x2f, 0x16, 0x0e, 0x46, 0x01, 0x26, 0xa7, 0xe0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, - 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, - 0x3c, 0x96, 0x63, 0x88, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, - 0x4f, 0xa9, 0xcc, 0x4d, 0xcd, 0x2b, 0xce, 0xcc, 0xcf, 0xab, 0xa8, 0xac, 0x42, 0x70, 0x74, 0x8b, - 0x52, 0xb2, 0xf5, 0x2b, 0xf4, 0x91, 0xbd, 0x5a, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, - 0xab, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x27, 0x7b, 0xfd, 0xfc, 0x4c, 0x01, 0x00, 0x00, + 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xbc, 0x3e, 0x88, 0x05, 0x51, 0x2a, 0x25, 0x81, 0x6c, + 0x4a, 0x41, 0x62, 0x51, 0x62, 0x2e, 0xd4, 0x10, 0x29, 0x71, 0x64, 0x99, 0xe2, 0x92, 0xc4, 0x92, + 0x54, 0x88, 0x84, 0xd2, 0x21, 0x46, 0x2e, 0x1e, 0x77, 0x88, 0x78, 0x30, 0x48, 0x58, 0xc8, 0x92, + 0x8b, 0x0d, 0xa2, 0x53, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x5a, 0x0f, 0x8b, 0xfd, 0x7a, + 0x01, 0x60, 0x25, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x35, 0x08, 0x99, 0x71, 0xb1, + 0x82, 0x8d, 0x96, 0x60, 0x02, 0xeb, 0x94, 0xc2, 0xaa, 0x13, 0x6c, 0x0b, 0x54, 0x23, 0x44, 0xb9, + 0x90, 0x3d, 0x97, 0x64, 0x69, 0x5e, 0x62, 0x72, 0x76, 0x6a, 0x4a, 0x7c, 0x49, 0x51, 0x62, 0x5e, + 0x71, 0x5a, 0x6a, 0x51, 0x7c, 0x71, 0x6a, 0x61, 0x7c, 0x5e, 0x69, 0x6e, 0xb1, 0x04, 0xb3, 0x02, + 0xb3, 0x06, 0x0b, 0x54, 0xbd, 0x18, 0x54, 0x59, 0x08, 0x54, 0x55, 0x70, 0x6a, 0xa1, 0x5f, 0x69, + 0x6e, 0xb1, 0x53, 0xf0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, + 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa6, + 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xa7, 0x54, 0xe6, 0xa6, 0xe6, 0x15, + 0x67, 0xe6, 0xe7, 0x55, 0x54, 0x56, 0x21, 0x38, 0xba, 0x45, 0x29, 0xd9, 0xfa, 0x15, 0xfa, 0xc8, + 0xe1, 0x53, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x20, 0x63, 0x40, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x63, 0x8d, 0x1f, 0x86, 0x9b, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -150,6 +161,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -170,6 +191,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) l = m.State.Size() n += 1 + l + sovGenesis(uint64(l)) if len(m.UnackedTransferSeqNums) > 0 { @@ -217,6 +240,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) From 034e28f40c6bc8a9edfdd43ea1f34ddd5411b33c Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:37:27 +0100 Subject: [PATCH 42/79] restore unneedded diff --- x/gasless/types/gasless.pb.go | 2 +- x/hub-genesis/keeper/grpc_query.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/x/gasless/types/gasless.pb.go b/x/gasless/types/gasless.pb.go index 4fee92a8..de00202c 100644 --- a/x/gasless/types/gasless.pb.go +++ b/x/gasless/types/gasless.pb.go @@ -8,8 +8,8 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" diff --git a/x/hub-genesis/keeper/grpc_query.go b/x/hub-genesis/keeper/grpc_query.go index f622d18b..0f1e37a4 100644 --- a/x/hub-genesis/keeper/grpc_query.go +++ b/x/hub-genesis/keeper/grpc_query.go @@ -22,7 +22,10 @@ func NewQuerier(k Keeper) Querier { // Params returns params of the hub-genesis module. func (q Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - return &types.QueryParamsResponse{}, nil + ctx := sdk.UnwrapSDKContext(c) + params := q.Keeper.GetParams(ctx) + + return &types.QueryParamsResponse{Params: params}, nil } func (q Querier) State(goCtx context.Context, request *types.QueryStateRequest) (*types.QueryStateResponse, error) { From 9433bf5795d8d14f66cd18cbc83161be328bfe25 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:40:11 +0100 Subject: [PATCH 43/79] renames and tweaks --- x/hub-genesis/keeper/genesis.go | 4 ++-- x/hub-genesis/keeper/ibc_module.go | 4 ++-- x/hub-genesis/keeper/ics4_wrapper.go | 2 +- x/hub-genesis/keeper/sequence_numbers.go | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/x/hub-genesis/keeper/genesis.go b/x/hub-genesis/keeper/genesis.go index cda36f5e..805a592c 100644 --- a/x/hub-genesis/keeper/genesis.go +++ b/x/hub-genesis/keeper/genesis.go @@ -10,7 +10,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { k.SetParams(ctx, genState.Params) k.SetState(ctx, genState.State) for _, seq := range genState.UnackedTransferSeqNums { - k.saveSeqNum(ctx, seq) + k.saveUnackedTransferSeqNum(ctx, seq) } } @@ -19,6 +19,6 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { genesis := types.DefaultGenesisState() genesis.Params = k.GetParams(ctx) genesis.State = k.GetState(ctx) - genesis.UnackedTransferSeqNums = k.getAllSeqNums(ctx) + genesis.UnackedTransferSeqNums = k.getAllUnackedTransferSeqNums(ctx) return genesis } diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index db18ffcd..1435c2e4 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -92,7 +92,7 @@ func (w IBCModule) mintAndTransfer(ctx sdk.Context, account types.GenesisAccount } // NOTE: for simplicity we don't optimize to avoid sending duplicate metadata - // we assume the hub will deduplicate. We expect to eventually get account timeout + // we assume the hub will deduplicate. We expect to eventually get a timeout // or commit anyway, so the packet will be cleared up. // (Actually, since transfers may arrive out of order, we must include the // denom metadata anyway). @@ -134,7 +134,7 @@ func (w IBCModule) OnAcknowledgementPacket( if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { - w.k.ackSeqNum(ctx, packet.Sequence, ack.Success()) + w.k.ackTransferSeqNum(ctx, packet.Sequence, ack.Success()) } } return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index f6031ab7..c9faae75 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -65,7 +65,7 @@ func (w ICS4Wrapper) SendPacket( if err != nil { return seq, err } - w.k.saveSeqNum(ctx, seq) + w.k.saveUnackedTransferSeqNum(ctx, seq) return seq, nil } else if !w.k.outboundTransfersEnabled(ctx) { return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 82c2acb2..1ccb80c1 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -21,16 +21,16 @@ func seqNumKey(seq uint64) []byte { return bz } -func (k Keeper) saveSeqNum(ctx sdk.Context, seq uint64) { +func (k Keeper) saveUnackedTransferSeqNum(ctx sdk.Context, seq uint64) { ctx.KVStore(k.storeKey).Set(seqNumKey(seq), []byte{}) } -func (k Keeper) delSeqNum(ctx sdk.Context, seq uint64) { +func (k Keeper) delUnackeTransferSeqNum(ctx sdk.Context, seq uint64) { ctx.KVStore(k.storeKey).Delete(seqNumKey(seq)) } // returns all seq nums, only intended for genesis export -func (k Keeper) getAllSeqNums(ctx sdk.Context) []uint64 { +func (k Keeper) getAllUnackedTransferSeqNums(ctx sdk.Context) []uint64 { state := k.GetState(ctx) n := state.NumUnackedTransfers ret := make([]uint64, n) @@ -43,12 +43,12 @@ func (k Keeper) getAllSeqNums(ctx sdk.Context) []uint64 { return ret } -// ackSeqNum handles the inbound acknowledgement of an outbound genesis transfer -func (k Keeper) ackSeqNum(ctx sdk.Context, seq uint64, success bool) { +// ackTransferSeqNum handles the inbound acknowledgement of an outbound genesis transfer +func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, success bool) { if !success { panic(fmt.Sprintf("genesis transfer unsuccessful seq: %d", seq)) } - k.delSeqNum(ctx, seq) + k.delUnackeTransferSeqNum(ctx, seq) state := k.GetState(ctx) state.NumUnackedTransfers-- if state.NumUnackedTransfers == 0 { From bd17c1470bafbcf2441ffa6868e376eb92aebc21 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:41:33 +0100 Subject: [PATCH 44/79] tweaks, going to add a test for genesis --- x/hub-genesis/keeper/sequence_numbers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 1ccb80c1..5f800faf 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -25,7 +25,7 @@ func (k Keeper) saveUnackedTransferSeqNum(ctx sdk.Context, seq uint64) { ctx.KVStore(k.storeKey).Set(seqNumKey(seq), []byte{}) } -func (k Keeper) delUnackeTransferSeqNum(ctx sdk.Context, seq uint64) { +func (k Keeper) delUnackedTransferSeqNum(ctx sdk.Context, seq uint64) { ctx.KVStore(k.storeKey).Delete(seqNumKey(seq)) } @@ -48,7 +48,7 @@ func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, success bool) { if !success { panic(fmt.Sprintf("genesis transfer unsuccessful seq: %d", seq)) } - k.delUnackeTransferSeqNum(ctx, seq) + k.delUnackedTransferSeqNum(ctx, seq) state := k.GetState(ctx) state.NumUnackedTransfers-- if state.NumUnackedTransfers == 0 { From 1f22ecf5ecb0e30fd656dd33c7284ecc531bc749 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:46:30 +0100 Subject: [PATCH 45/79] simplify and make sure to handle empty genesis transfers case --- x/hub-genesis/keeper/ibc_module.go | 8 +++++++- x/hub-genesis/keeper/ics4_wrapper.go | 2 +- x/hub-genesis/keeper/sequence_numbers.go | 13 ++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 1435c2e4..486d6f1d 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -79,7 +79,13 @@ func (w IBCModule) OnChanOpenConfirm( l.Info("Sent genesis transfer.", "index", i, "receiver", a.GetAddress(), "coin", a) } - l.Info("Sent all genesis transfers.") + l.Info("Sent all genesis transfers.", "n", len(state.GetGenesisAccounts())) + + if len(state.GetGenesisAccounts()) == 0 { + // we want to handle the case where the rollapp doesn't have genesis transfers + // normally we would enable outbound transfers on an ack, but in this case we won't have an ack + w.k.enableOutboundTransfers(ctx) + } return nil } diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index c9faae75..1b779890 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -67,7 +67,7 @@ func (w ICS4Wrapper) SendPacket( } w.k.saveUnackedTransferSeqNum(ctx, seq) return seq, nil - } else if !w.k.outboundTransfersEnabled(ctx) { + } else if !state.OutboundTransfersEnabled { return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 5f800faf..08b0ed24 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -53,14 +53,17 @@ func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, success bool) { state.NumUnackedTransfers-- if state.NumUnackedTransfers == 0 { // all acks have come back successfully - state.OutboundTransfersEnabled = true - ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeOutboundTransfersEnabled)) + k.enableOutboundTransfers(ctx) } k.SetState(ctx, state) } -func (k Keeper) outboundTransfersEnabled(ctx sdk.Context) bool { - k.Logger(ctx).With("module", types.ModuleName).Debug("outbound transfers enabled") +func (k Keeper) enableOutboundTransfers(ctx sdk.Context) { state := k.GetState(ctx) - return state.OutboundTransfersEnabled + state.OutboundTransfersEnabled = true + k.SetState(ctx, state) + ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeOutboundTransfersEnabled)) + k.Logger(ctx).With("module", types.ModuleName).Debug("outbound transfers enabled") +} + } From bdf4f632c78e52a40432c0da58c37c593c3c6449 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:50:10 +0100 Subject: [PATCH 46/79] simplification --- x/hub-genesis/types/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index 354cbdeb..b72ac7df 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -25,5 +25,5 @@ func (s State) IsCanonicalHubTransferChannel(port, channel string) bool { } func (s State) CanonicalHubTransferChannelHasBeenSet() bool { - return s.HubPortAndChannel != nil && !reflect.ValueOf(s.GetHubPortAndChannel).IsZero() + return !reflect.ValueOf(s.HubPortAndChannel).IsZero() } From 3872a7afe35442c9abb864a0fb035c4da2247e29 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:53:19 +0100 Subject: [PATCH 47/79] need to test genesis export/import an edges --- x/hub-genesis/keeper/ibc_module.go | 2 ++ x/hub-genesis/keeper/ics4_wrapper.go | 5 +++-- x/hub-genesis/keeper/sequence_numbers.go | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 486d6f1d..9e9a59e5 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -56,6 +56,8 @@ func (w IBCModule) OnChanOpenConfirm( state := w.k.GetState(ctx) if state.CanonicalHubTransferChannelHasBeenSet() { + // We only set the canonical channel in this function, so if it's already been set, we don't need + // to send the transfers again. return nil } diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index 1b779890..ae3711a8 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -34,8 +34,9 @@ func NewICS4Wrapper(next porttypes.ICS4Wrapper, k Keeper) *ICS4Wrapper { } // SendPacket does two things: -// 1. It stops anyone from sending a packet with the special memo. Only the module itself is allowed to do so. -// 2. It stops anyone from sending a regular transfer until the genesis phase is finished. +// 1. It stops anyone from sending a packet with the special memo. Only the module itself is allowed to do so. +// 2. It stops anyone from sending a regular transfer until the genesis phase is finished. To help with this, +// it tracks all acks which arrive from genesis transfers. func (w ICS4Wrapper) SendPacket( ctx sdk.Context, chanCap *capabilitytypes.Capability, diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 08b0ed24..26f41196 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -65,5 +65,3 @@ func (k Keeper) enableOutboundTransfers(ctx sdk.Context) { ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeOutboundTransfersEnabled)) k.Logger(ctx).With("module", types.ModuleName).Debug("outbound transfers enabled") } - -} From 8716eac6a975e7fbd712b2144a272cadfc25f0d2 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:56:25 +0100 Subject: [PATCH 48/79] adds a todo for the missing issue --- x/hub-genesis/types/state.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index b72ac7df..d3fdc2b5 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -12,6 +12,7 @@ func (s State) Validate() error { if err := a.GetAmount().Validate(); err != nil { return errorsmod.Wrap(err, "amount") } + // TODO: validate to make sure no ibc denom attac possible https://github.com/dymensionxyz/dymension-rdk/issues/462 _, err := sdk.AccAddressFromBech32(a.GetAddress()) if err != nil { return errorsmod.Wrap(err, "address from bech 32") From c72e968a0c39bf1c957bf7656c80cd986df9070c Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 09:58:02 +0100 Subject: [PATCH 49/79] fix genesis test --- x/hub-genesis/keeper/genesis_test.go | 14 +++++++++----- x/hub-genesis/keeper/sequence_numbers.go | 8 ++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/x/hub-genesis/keeper/genesis_test.go b/x/hub-genesis/keeper/genesis_test.go index 002ae5e5..bb56a255 100644 --- a/x/hub-genesis/keeper/genesis_test.go +++ b/x/hub-genesis/keeper/genesis_test.go @@ -5,21 +5,25 @@ import ( "testing" testkeepers "github.com/dymensionxyz/dymension-rdk/testutil/keepers" - "github.com/dymensionxyz/dymension-rdk/testutil/nullify" "github.com/dymensionxyz/dymension-rdk/testutil/utils" "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { - genesisState := &types.GenesisState{} app := utils.Setup(t, false) k, ctx := testkeepers.NewTestHubGenesisKeeperFromApp(app) - k.InitGenesis(ctx, genesisState) + expect := &types.GenesisState{ + State: types.State{ + NumUnackedTransfers: 2, + }, + UnackedTransferSeqNums: []uint64{42, 43}, + } + k.InitGenesis(ctx, expect) got := k.ExportGenesis(ctx) require.NotNil(t, got) - nullify.Fill(&genesisState) - nullify.Fill(got) + require.ElementsMatch(t, expect.UnackedTransferSeqNums, got.UnackedTransferSeqNums) + require.Equal(t, expect.State.NumUnackedTransfers, got.State.NumUnackedTransfers) } diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 26f41196..134a904c 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -21,6 +21,10 @@ func seqNumKey(seq uint64) []byte { return bz } +func seqNumFromKey(key []byte) uint64 { + return sdk.BigEndianToUint64(key[len(UnackedTransferSeqNumsPrefix):]) +} + func (k Keeper) saveUnackedTransferSeqNum(ctx sdk.Context, seq uint64) { ctx.KVStore(k.storeKey).Set(seqNumKey(seq), []byte{}) } @@ -33,12 +37,12 @@ func (k Keeper) delUnackedTransferSeqNum(ctx sdk.Context, seq uint64) { func (k Keeper) getAllUnackedTransferSeqNums(ctx sdk.Context) []uint64 { state := k.GetState(ctx) n := state.NumUnackedTransfers - ret := make([]uint64, n) + ret := make([]uint64, 0, n) store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, UnackedTransferSeqNumsPrefix) defer iterator.Close() // nolint: errcheck for ; iterator.Valid(); iterator.Next() { - ret = append(ret, sdk.BigEndianToUint64(iterator.Key())) + ret = append(ret, seqNumFromKey(iterator.Key())) } return ret } From 89284041ab464812dc53447fde9b9ee04d06fc72 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:09:00 +0100 Subject: [PATCH 50/79] fix test setup --- testutil/app/app.go | 4 ++-- x/hub-genesis/keeper/protocol_test.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 x/hub-genesis/keeper/protocol_test.go diff --git a/testutil/app/app.go b/testutil/app/app.go index bf87c84c..663a08de 100644 --- a/testutil/app/app.go +++ b/testutil/app/app.go @@ -424,14 +424,14 @@ func NewRollapp( app.AccountKeeper, ) - genesisTransfersMemoBlocker := hubgenkeeper.NewICS4Wrapper(app.IBCKeeper.ChannelKeeper, app.HubGenesisKeeper) + genesisTransfersBlocker := hubgenkeeper.NewICS4Wrapper(app.IBCKeeper.ChannelKeeper, app.HubGenesisKeeper) // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - genesisTransfersMemoBlocker, + genesisTransfersBlocker, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, diff --git a/x/hub-genesis/keeper/protocol_test.go b/x/hub-genesis/keeper/protocol_test.go new file mode 100644 index 00000000..7b46f54d --- /dev/null +++ b/x/hub-genesis/keeper/protocol_test.go @@ -0,0 +1,13 @@ +package keeper + +import ( + "testing" + + testkeepers "github.com/dymensionxyz/dymension-rdk/testutil/keepers" + "github.com/dymensionxyz/dymension-rdk/testutil/utils" +) + +func TestProtocol(t *testing.T) { + app := utils.Setup(t, false) + k, ctx := testkeepers.NewTestHubGenesisKeeperFromApp(app) +} From 172d50385335cd9c18b0a69d0021ebbff8203a41 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:10:57 +0100 Subject: [PATCH 51/79] gonna refac stuf to the keeper --- x/hub-genesis/keeper/protocol_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/x/hub-genesis/keeper/protocol_test.go b/x/hub-genesis/keeper/protocol_test.go index 7b46f54d..d399b7ed 100644 --- a/x/hub-genesis/keeper/protocol_test.go +++ b/x/hub-genesis/keeper/protocol_test.go @@ -8,6 +8,14 @@ import ( ) func TestProtocol(t *testing.T) { - app := utils.Setup(t, false) - k, ctx := testkeepers.NewTestHubGenesisKeeperFromApp(app) + /* + Cases: + 1. Transfers are enabled if genesis accounts is zero + */ + + t.Run("transfers are enabled immediately if there are no genesis accounts", func(t *testing.T) { + app := utils.Setup(t, false) + k, ctx := testkeepers.NewTestHubGenesisKeeperFromApp(app) + k.on + }) } From c87ad27088e997137283a4011a50a62fba1bd6b1 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:12:01 +0100 Subject: [PATCH 52/79] del protocols test --- x/hub-genesis/keeper/protocol_test.go | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 x/hub-genesis/keeper/protocol_test.go diff --git a/x/hub-genesis/keeper/protocol_test.go b/x/hub-genesis/keeper/protocol_test.go deleted file mode 100644 index d399b7ed..00000000 --- a/x/hub-genesis/keeper/protocol_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package keeper - -import ( - "testing" - - testkeepers "github.com/dymensionxyz/dymension-rdk/testutil/keepers" - "github.com/dymensionxyz/dymension-rdk/testutil/utils" -) - -func TestProtocol(t *testing.T) { - /* - Cases: - 1. Transfers are enabled if genesis accounts is zero - */ - - t.Run("transfers are enabled immediately if there are no genesis accounts", func(t *testing.T) { - app := utils.Setup(t, false) - k, ctx := testkeepers.NewTestHubGenesisKeeperFromApp(app) - k.on - }) -} From 97b0d24112aa4acd5d82a1716e9b6c3f7c718969 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:48:52 +0100 Subject: [PATCH 53/79] dump ack --- x/hub-genesis/keeper/ibc_module.go | 40 ++++++++++++------------ x/hub-genesis/keeper/sequence_numbers.go | 10 +++--- x/hub-genesis/types/state.go | 7 +++++ 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 9e9a59e5..a51f8bd3 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -61,34 +61,31 @@ func (w IBCModule) OnChanOpenConfirm( return nil } - state.HubPortAndChannel = &types.PortAndChannel{ - Port: portID, - Channel: channelID, - } + state.SetCanonicalTransferChannel(portID, channelID) state.NumUnackedTransfers = uint64(len(state.GetGenesisAccounts())) w.k.SetState(ctx, state) - srcAccount := w.k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) - srcAddr := srcAccount.GetAddress().String() - - for i, a := range state.GetGenesisAccounts() { - if err := w.mintAndTransfer(ctx, a, srcAddr, portID, channelID); err != nil { - // there is no feasible way to recover - panic(fmt.Errorf("mint and transfer: %w", err)) - } - l.Info("Sent genesis transfer.", "index", i, "receiver", a.GetAddress(), "coin", a) - } - - l.Info("Sent all genesis transfers.", "n", len(state.GetGenesisAccounts())) - if len(state.GetGenesisAccounts()) == 0 { // we want to handle the case where the rollapp doesn't have genesis transfers // normally we would enable outbound transfers on an ack, but in this case we won't have an ack w.k.enableOutboundTransfers(ctx) + } else { + srcAccount := w.k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) + srcAddr := srcAccount.GetAddress().String() + + for i, a := range state.GetGenesisAccounts() { + if err := w.mintAndTransfer(ctx, a, srcAddr, portID, channelID); err != nil { + // there is no feasible way to recover + panic(fmt.Errorf("mint and transfer: %w", err)) + } + l.Info("Sent genesis transfer.", "index", i, "receiver", a.GetAddress(), "coin", a) + } } + l.Info("Sent all genesis transfers.", "n", len(state.GetGenesisAccounts())) + return nil } @@ -135,14 +132,17 @@ func (w IBCModule) OnAcknowledgementPacket( relayer sdk.AccAddress, ) error { state := w.k.GetState(ctx) - if !state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { + if state.OutboundTransfersEnabled || // we're done already, this is not an ack for a genesis transfer + !state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not related to genesis protocol with the hub return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) } var data transfertypes.FungibleTokenPacketData - if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { + if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { // it's a transfer var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { - w.k.ackTransferSeqNum(ctx, packet.Sequence, ack.Success()) + w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) + } else { + panic(fmt.Errorf("must get ack from in OnAcknowledgementPacket: %w", err)) } } return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 134a904c..20e13e77 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -4,6 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" ) @@ -48,9 +49,10 @@ func (k Keeper) getAllUnackedTransferSeqNums(ctx sdk.Context) []uint64 { } // ackTransferSeqNum handles the inbound acknowledgement of an outbound genesis transfer -func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, success bool) { - if !success { - panic(fmt.Sprintf("genesis transfer unsuccessful seq: %d", seq)) +func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, ack channeltypes.Acknowledgement) { + if !ack.Success() { + res := ack.Response.(*channeltypes.Acknowledgement_Error) + panic(fmt.Sprintf("genesis transfer unsuccessful seq: %d: err: %s", seq, res.Error)) } k.delUnackedTransferSeqNum(ctx, seq) state := k.GetState(ctx) @@ -67,5 +69,5 @@ func (k Keeper) enableOutboundTransfers(ctx sdk.Context) { state.OutboundTransfersEnabled = true k.SetState(ctx, state) ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeOutboundTransfersEnabled)) - k.Logger(ctx).With("module", types.ModuleName).Debug("outbound transfers enabled") + k.Logger(ctx).With("module", types.ModuleName).Debug("Enabled outbound transfers.") } diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index d3fdc2b5..70ad11d8 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -28,3 +28,10 @@ func (s State) IsCanonicalHubTransferChannel(port, channel string) bool { func (s State) CanonicalHubTransferChannelHasBeenSet() bool { return !reflect.ValueOf(s.HubPortAndChannel).IsZero() } + +func (s State) SetCanonicalTransferChannel(port, channel string) { + s.HubPortAndChannel = &PortAndChannel{ + Port: port, + Channel: channel, + } +} From 66c8012b6760ca25d822c6343675c58af6238c57 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:01:22 +0100 Subject: [PATCH 54/79] gonna test again --- x/hub-genesis/keeper/ics4_wrapper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index ae3711a8..771c9955 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -8,6 +8,7 @@ import ( transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" + "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" "github.com/dymensionxyz/gerr-cosmos/gerrc" ) @@ -69,6 +70,7 @@ func (w ICS4Wrapper) SendPacket( w.k.saveUnackedTransferSeqNum(ctx, seq) return seq, nil } else if !state.OutboundTransfersEnabled { + w.k.Logger(ctx).With("module", types.ModuleName).Debug("Transfer rejected: outbound transfers are disabled.") return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) From df87f2b823c7ff8378368f011fe9464520991a52 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:23:33 +0100 Subject: [PATCH 55/79] need to fix wiring --- x/hub-genesis/keeper/ics4_wrapper.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index 771c9955..ce8ba923 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -47,6 +47,7 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { + w.k.Logger("") state := w.k.GetState(ctx) if !state.IsCanonicalHubTransferChannel(sourcePort, sourceChannel) { return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) From 59c8f0235d815f85e0a1b8f8fb6c5b766c1c30eb Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:26:16 +0100 Subject: [PATCH 56/79] adds debug --- x/hub-genesis/keeper/ics4_wrapper.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index ce8ba923..d6e1a347 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -47,7 +47,8 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { - w.k.Logger("") + w.k.Logger(ctx).With("module", types.ModuleName).Debug("ICS4 Wrapper: send packet.") + state := w.k.GetState(ctx) if !state.IsCanonicalHubTransferChannel(sourcePort, sourceChannel) { return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) From 788e3224f52beb16896a1f56ee2bbf0978642ce8 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:33:21 +0100 Subject: [PATCH 57/79] fix state pointers --- x/hub-genesis/keeper/ics4_wrapper.go | 9 +++++++-- x/hub-genesis/types/state.go | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index d6e1a347..a150e602 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -10,6 +10,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" "github.com/dymensionxyz/gerr-cosmos/gerrc" + "github.com/tendermint/tendermint/libs/log" ) type ctxKeySkip struct{} @@ -34,6 +35,10 @@ func NewICS4Wrapper(next porttypes.ICS4Wrapper, k Keeper) *ICS4Wrapper { return &ICS4Wrapper{next, k} } +func (w ICS4Wrapper) logger(ctx sdk.Context) log.Logger { + return w.k.Logger(ctx).With("module", types.ModuleName, "component", "ics4 middleware") +} + // SendPacket does two things: // 1. It stops anyone from sending a packet with the special memo. Only the module itself is allowed to do so. // 2. It stops anyone from sending a regular transfer until the genesis phase is finished. To help with this, @@ -47,7 +52,7 @@ func (w ICS4Wrapper) SendPacket( timeoutTimestamp uint64, data []byte, ) (sequence uint64, err error) { - w.k.Logger(ctx).With("module", types.ModuleName).Debug("ICS4 Wrapper: send packet.") + l := w.logger(ctx) state := w.k.GetState(ctx) if !state.IsCanonicalHubTransferChannel(sourcePort, sourceChannel) { @@ -72,7 +77,7 @@ func (w ICS4Wrapper) SendPacket( w.k.saveUnackedTransferSeqNum(ctx, seq) return seq, nil } else if !state.OutboundTransfersEnabled { - w.k.Logger(ctx).With("module", types.ModuleName).Debug("Transfer rejected: outbound transfers are disabled.") + l.Debug("Transfer rejected: outbound transfers are disabled.") return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index 70ad11d8..3d549c9e 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (s State) Validate() error { +func (s *State) Validate() error { for _, a := range s.GetGenesisAccounts() { if err := a.GetAmount().Validate(); err != nil { return errorsmod.Wrap(err, "amount") @@ -21,15 +21,15 @@ func (s State) Validate() error { return nil } -func (s State) IsCanonicalHubTransferChannel(port, channel string) bool { +func (s *State) IsCanonicalHubTransferChannel(port, channel string) bool { return s.CanonicalHubTransferChannelHasBeenSet() && s.HubPortAndChannel.Port == port && s.HubPortAndChannel.Channel == channel } -func (s State) CanonicalHubTransferChannelHasBeenSet() bool { +func (s *State) CanonicalHubTransferChannelHasBeenSet() bool { return !reflect.ValueOf(s.HubPortAndChannel).IsZero() } -func (s State) SetCanonicalTransferChannel(port, channel string) { +func (s *State) SetCanonicalTransferChannel(port, channel string) { s.HubPortAndChannel = &PortAndChannel{ Port: port, Channel: channel, From 6f81db2b8b335cc67cde45c8fea6bdaccb0b3f71 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:35:32 +0100 Subject: [PATCH 58/79] try again --- x/hub-genesis/keeper/ibc_module.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index a51f8bd3..6eecacf8 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -12,6 +12,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" + "github.com/tendermint/tendermint/libs/log" ) const ( @@ -36,6 +37,10 @@ func NewIBCModule(next porttypes.IBCModule, t Transfer, k Keeper, d GetDenomMeta return &IBCModule{next, k, t, d, m} } +func (w IBCModule) logger(ctx sdk.Context) log.Logger { + return w.k.Logger(ctx).With("module", types.ModuleName, "component", "ibc module") +} + // OnChanOpenConfirm will send any unsent genesis account transfers over the channel. // It is ASSUMED that the channel is for the Hub. This can be ensured by not exposing // the sequencer API until after genesis is complete. @@ -131,6 +136,7 @@ func (w IBCModule) OnAcknowledgementPacket( acknowledgement []byte, relayer sdk.AccAddress, ) error { + l := w.logger(ctx) state := w.k.GetState(ctx) if state.OutboundTransfersEnabled || // we're done already, this is not an ack for a genesis transfer !state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not related to genesis protocol with the hub @@ -141,6 +147,7 @@ func (w IBCModule) OnAcknowledgementPacket( var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) + l.Debug("Got ack", "seq", packet.Sequence) } else { panic(fmt.Errorf("must get ack from in OnAcknowledgementPacket: %w", err)) } From 3b13f2be73ca427a7546c98ed77f0663b62a98b7 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:43:57 +0100 Subject: [PATCH 59/79] try again --- x/hub-genesis/keeper/ibc_module.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 6eecacf8..e1922b9b 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -137,19 +137,19 @@ func (w IBCModule) OnAcknowledgementPacket( relayer sdk.AccAddress, ) error { l := w.logger(ctx) + l.Debug("ack", "seq", packet.Sequence, "src port", packet.SourcePort, "src chan", packet.SourceChannel) state := w.k.GetState(ctx) - if state.OutboundTransfersEnabled || // we're done already, this is not an ack for a genesis transfer - !state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not related to genesis protocol with the hub - return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) - } - var data transfertypes.FungibleTokenPacketData - if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { // it's a transfer - var ack channeltypes.Acknowledgement - if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { - w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) - l.Debug("Got ack", "seq", packet.Sequence) - } else { - panic(fmt.Errorf("must get ack from in OnAcknowledgementPacket: %w", err)) + if !state.OutboundTransfersEnabled && // still in genesis protocol + state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not some other unrelated channel + var data transfertypes.FungibleTokenPacketData + if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { // it's a transfer + var ack channeltypes.Acknowledgement + if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { + w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) + l.Debug("Got ack", "seq", packet.Sequence) + } else { + panic(fmt.Errorf("must get ack from in OnAcknowledgementPacket: %w", err)) + } } } return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) From 063958f7526cb8e6808f118498d9f4f916af40c7 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:56:13 +0100 Subject: [PATCH 60/79] test --- x/hub-genesis/keeper/ibc_module.go | 10 +++++++++- x/hub-genesis/keeper/sequence_numbers.go | 9 +++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index e1922b9b..7dc956ab 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -67,6 +67,9 @@ func (w IBCModule) OnChanOpenConfirm( } state.SetCanonicalTransferChannel(portID, channelID) + if !state.CanonicalHubTransferChannelHasBeenSet() { // TODO: remove + panic("why tho") + } state.NumUnackedTransfers = uint64(len(state.GetGenesisAccounts())) @@ -141,11 +144,16 @@ func (w IBCModule) OnAcknowledgementPacket( state := w.k.GetState(ctx) if !state.OutboundTransfersEnabled && // still in genesis protocol state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not some other unrelated channel + l.Debug("in the ack processing") // TODO: del var data transfertypes.FungibleTokenPacketData if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { // it's a transfer var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { - w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) + err := w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) + if err != nil { + l.Error("Processing ack from transfer.", "err", err) + return err + } l.Debug("Got ack", "seq", packet.Sequence) } else { panic(fmt.Errorf("must get ack from in OnAcknowledgementPacket: %w", err)) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 20e13e77..691b269c 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -1,11 +1,11 @@ package keeper import ( - "fmt" - + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" + "github.com/dymensionxyz/gerr-cosmos/gerrc" ) /* @@ -49,10 +49,10 @@ func (k Keeper) getAllUnackedTransferSeqNums(ctx sdk.Context) []uint64 { } // ackTransferSeqNum handles the inbound acknowledgement of an outbound genesis transfer -func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, ack channeltypes.Acknowledgement) { +func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, ack channeltypes.Acknowledgement) error { if !ack.Success() { res := ack.Response.(*channeltypes.Acknowledgement_Error) - panic(fmt.Sprintf("genesis transfer unsuccessful seq: %d: err: %s", seq, res.Error)) + return errorsmod.Wrapf(gerrc.ErrUnknown, "ack is not success: %s", res.Error) } k.delUnackedTransferSeqNum(ctx, seq) state := k.GetState(ctx) @@ -62,6 +62,7 @@ func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, ack channeltypes. k.enableOutboundTransfers(ctx) } k.SetState(ctx, state) + return nil } func (k Keeper) enableOutboundTransfers(ctx sdk.Context) { From 8ba70e3b1cefa7c8ba0e8003207bd2c1a7db6b92 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:00:59 +0100 Subject: [PATCH 61/79] need to check state usages --- x/hub-genesis/keeper/ibc_module.go | 1 - x/hub-genesis/keeper/sequence_numbers.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 7dc956ab..23be9d2d 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -144,7 +144,6 @@ func (w IBCModule) OnAcknowledgementPacket( state := w.k.GetState(ctx) if !state.OutboundTransfersEnabled && // still in genesis protocol state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not some other unrelated channel - l.Debug("in the ack processing") // TODO: del var data transfertypes.FungibleTokenPacketData if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { // it's a transfer var ack channeltypes.Acknowledgement diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 691b269c..c45b1dad 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -57,11 +57,11 @@ func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, ack channeltypes. k.delUnackedTransferSeqNum(ctx, seq) state := k.GetState(ctx) state.NumUnackedTransfers-- + k.SetState(ctx, state) if state.NumUnackedTransfers == 0 { // all acks have come back successfully k.enableOutboundTransfers(ctx) } - k.SetState(ctx, state) return nil } From b01b829c368d524ffd95e6d055972bc9c125eb22 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:02:50 +0100 Subject: [PATCH 62/79] lfg --- x/hub-genesis/keeper/ibc_module.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 23be9d2d..81e6e884 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -67,9 +67,6 @@ func (w IBCModule) OnChanOpenConfirm( } state.SetCanonicalTransferChannel(portID, channelID) - if !state.CanonicalHubTransferChannelHasBeenSet() { // TODO: remove - panic("why tho") - } state.NumUnackedTransfers = uint64(len(state.GetGenesisAccounts())) From 4465c2248981877a24373b802b6e755567ccf3f2 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:07:27 +0100 Subject: [PATCH 63/79] typo --- x/hub-genesis/types/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/hub-genesis/types/state.go b/x/hub-genesis/types/state.go index 3d549c9e..cddef429 100644 --- a/x/hub-genesis/types/state.go +++ b/x/hub-genesis/types/state.go @@ -12,7 +12,7 @@ func (s *State) Validate() error { if err := a.GetAmount().Validate(); err != nil { return errorsmod.Wrap(err, "amount") } - // TODO: validate to make sure no ibc denom attac possible https://github.com/dymensionxyz/dymension-rdk/issues/462 + // TODO: validate to make sure no ibc denom attack possible https://github.com/dymensionxyz/dymension-rdk/issues/462 _, err := sdk.AccAddressFromBech32(a.GetAddress()) if err != nil { return errorsmod.Wrap(err, "address from bech 32") From b452d70771c975bf4c3cbb7fd26d30758ed53d5f Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:07:31 +0100 Subject: [PATCH 64/79] confirms working From 9075081b20a8a2f183c85ac040a45a0b2b4a7535 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:12:04 +0100 Subject: [PATCH 65/79] simplify --- x/hub-genesis/keeper/ics4_wrapper.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index a150e602..f82cc9cc 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -55,30 +55,27 @@ func (w ICS4Wrapper) SendPacket( l := w.logger(ctx) state := w.k.GetState(ctx) - if !state.IsCanonicalHubTransferChannel(sourcePort, sourceChannel) { - return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + if !state.OutboundTransfersEnabled { + l.Debug("Transfer rejected: outbound transfers are disabled.") + return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } var transfer transfertypes.FungibleTokenPacketData _ = transfertypes.ModuleCdc.UnmarshalJSON(data, &transfer) - if memoHasKey(transfer.GetMemo()) { + saveSeq := false + if memoHasKey(transfer.GetMemo()) && state.IsCanonicalHubTransferChannel(sourcePort, sourceChannel) { if !skipAuthorizationCheck(ctx) { return 0, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "cannot use transfer genesis memo") } - // This is a genesis transfer, we record the sequence number. // Record the sequence number because we need to tick them off as they get acked. + saveSeq = true + } - seq, err := w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) - if err != nil { - return seq, err - } + seq, err := w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + if saveSeq && err == nil { w.k.saveUnackedTransferSeqNum(ctx, seq) - return seq, nil - } else if !state.OutboundTransfersEnabled { - l.Debug("Transfer rejected: outbound transfers are disabled.") - return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } - return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + return seq, err } From dbac79ef142c4e7a1eac567ebe27963785b7535a Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:12:27 +0100 Subject: [PATCH 66/79] need to test blocker From 3719e6ddb858190623690bc505486dc43dbfc954 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:13:15 +0100 Subject: [PATCH 67/79] remove bogus logs --- x/hub-genesis/keeper/ibc_module.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 81e6e884..694717ff 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -137,7 +137,6 @@ func (w IBCModule) OnAcknowledgementPacket( relayer sdk.AccAddress, ) error { l := w.logger(ctx) - l.Debug("ack", "seq", packet.Sequence, "src port", packet.SourcePort, "src chan", packet.SourceChannel) state := w.k.GetState(ctx) if !state.OutboundTransfersEnabled && // still in genesis protocol state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not some other unrelated channel @@ -150,7 +149,6 @@ func (w IBCModule) OnAcknowledgementPacket( l.Error("Processing ack from transfer.", "err", err) return err } - l.Debug("Got ack", "seq", packet.Sequence) } else { panic(fmt.Errorf("must get ack from in OnAcknowledgementPacket: %w", err)) } From 4252489bea43dd5107580194d5f81ad120fa9333 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:27:38 +0100 Subject: [PATCH 68/79] fix wrappers --- x/hub-genesis/keeper/ibc_module.go | 2 +- x/hub-genesis/keeper/ics4_wrapper.go | 28 +++++++++++----------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 694717ff..66cfea8c 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -122,7 +122,7 @@ func (w IBCModule) mintAndTransfer(ctx sdk.Context, account types.GenesisAccount Memo: memo, } - err = w.transfer(skipAuthorizationCheckContext(ctx), &m) + err = w.transfer(allowSpecialMemoCtx(ctx), &m) if err != nil { return errorsmod.Wrap(err, "transfer") } diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index f82cc9cc..a8945d38 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -15,13 +15,13 @@ import ( type ctxKeySkip struct{} -// skipAuthorizationCheckContext returns a context which can be passed to ibc SendPacket +// allowSpecialMemoCtx returns a context which can be passed to ibc SendPacket // if passed, the memo guard will not check that call -func skipAuthorizationCheckContext(ctx sdk.Context) sdk.Context { +func allowSpecialMemoCtx(ctx sdk.Context) sdk.Context { return ctx.WithValue(ctxKeySkip{}, true) } -func skipAuthorizationCheck(ctx sdk.Context) bool { +func allowSpecialMemo(ctx sdk.Context) bool { val, ok := ctx.Value(ctxKeySkip{}).(bool) return ok && val } @@ -55,26 +55,20 @@ func (w ICS4Wrapper) SendPacket( l := w.logger(ctx) state := w.k.GetState(ctx) - if !state.OutboundTransfersEnabled { - l.Debug("Transfer rejected: outbound transfers are disabled.") - return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") - } - var transfer transfertypes.FungibleTokenPacketData _ = transfertypes.ModuleCdc.UnmarshalJSON(data, &transfer) + specialMemo := memoHasKey(transfer.GetMemo()) - saveSeq := false - if memoHasKey(transfer.GetMemo()) && state.IsCanonicalHubTransferChannel(sourcePort, sourceChannel) { - if !skipAuthorizationCheck(ctx) { - return 0, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "cannot use transfer genesis memo") - } - // This is a genesis transfer, we record the sequence number. - // Record the sequence number because we need to tick them off as they get acked. - saveSeq = true + if specialMemo && !allowSpecialMemo(ctx) { + return 0, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "cannot use transfer genesis memo") + } + if !(specialMemo || state.OutboundTransfersEnabled) { + l.Debug("Transfer rejected: outbound transfers are disabled.") + return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } seq, err := w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) - if saveSeq && err == nil { + if specialMemo && err == nil { w.k.saveUnackedTransferSeqNum(ctx, seq) } return seq, err From 5587dc19a22f5ef3e050f5fdf81d89d0ce09dd2a Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:32:43 +0100 Subject: [PATCH 69/79] done From 40a790bfee4f6a686e9d7fd06b7e13fc1e0d3961 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:41:06 +0100 Subject: [PATCH 70/79] golangcilint --- x/hub-genesis/keeper/sequence_numbers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index c45b1dad..4a510aed 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -51,7 +51,10 @@ func (k Keeper) getAllUnackedTransferSeqNums(ctx sdk.Context) []uint64 { // ackTransferSeqNum handles the inbound acknowledgement of an outbound genesis transfer func (k Keeper) ackTransferSeqNum(ctx sdk.Context, seq uint64, ack channeltypes.Acknowledgement) error { if !ack.Success() { - res := ack.Response.(*channeltypes.Acknowledgement_Error) + res, ok := ack.Response.(*channeltypes.Acknowledgement_Error) + if !ok { + return errorsmod.WithType(gerrc.ErrInvalidArgument, ack) + } return errorsmod.Wrapf(gerrc.ErrUnknown, "ack is not success: %s", res.Error) } k.delUnackedTransferSeqNum(ctx, seq) From 3f4c6fe321a42efc393bc5b07df5a041e446888d Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:32:25 +0100 Subject: [PATCH 71/79] use keeper interfaces --- testutil/app/app.go | 8 ++----- x/hub-genesis/keeper/ibc_module.go | 31 +++++++++++++++------------- x/hub-genesis/keeper/ics4_wrapper.go | 6 +----- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/testutil/app/app.go b/testutil/app/app.go index 663a08de..024f24eb 100644 --- a/testutil/app/app.go +++ b/testutil/app/app.go @@ -449,13 +449,9 @@ func NewRollapp( ) transferStack = hubgenkeeper.NewIBCModule( transferStack, - func(ctx sdk.Context, transfer *ibctransfertypes.MsgTransfer) error { - _, err := app.TransferKeeper.Transfer(sdk.WrapSDKContext(ctx), transfer) - return err - }, + app.TransferKeeper, app.HubGenesisKeeper, - app.BankKeeper.GetDenomMetaData, - app.BankKeeper.MintCoins, + app.BankKeeper, ) app.GaslessKeeper = gaslesskeeper.NewKeeper( diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 66cfea8c..d5be6921 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "fmt" "time" @@ -21,20 +22,22 @@ const ( type IBCModule struct { porttypes.IBCModule - k Keeper - transfer Transfer - getDenom GetDenomMetaData - mintCoins MintCoins + k Keeper + transfer TransferKeeper + bank BankKeeper } -type ( - Transfer func(ctx sdk.Context, transfer *transfertypes.MsgTransfer) error - GetDenomMetaData func(ctx sdk.Context, denom string) (banktypes.Metadata, bool) - MintCoins func(ctx sdk.Context, moduleName string, amt sdk.Coins) error -) +type TransferKeeper interface { + Transfer(goCtx context.Context, msg *transfertypes.MsgTransfer) (*transfertypes.MsgTransferResponse, error) +} -func NewIBCModule(next porttypes.IBCModule, t Transfer, k Keeper, d GetDenomMetaData, m MintCoins) *IBCModule { - return &IBCModule{next, k, t, d, m} +type BankKeeper interface { + GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error +} + +func NewIBCModule(next porttypes.IBCModule, t TransferKeeper, k Keeper, bank BankKeeper) *IBCModule { + return &IBCModule{next, k, t, bank} } func (w IBCModule) logger(ctx sdk.Context) log.Logger { @@ -96,7 +99,7 @@ func (w IBCModule) OnChanOpenConfirm( func (w IBCModule) mintAndTransfer(ctx sdk.Context, account types.GenesisAccount, srcAddr string, portID string, channelID string) error { coin := account.GetAmount() - err := w.mintCoins(ctx, types.ModuleName, sdk.Coins{coin}) + err := w.bank.MintCoins(ctx, types.ModuleName, sdk.Coins{coin}) if err != nil { return errorsmod.Wrap(err, "mint coins") } @@ -122,11 +125,11 @@ func (w IBCModule) mintAndTransfer(ctx sdk.Context, account types.GenesisAccount Memo: memo, } - err = w.transfer(allowSpecialMemoCtx(ctx), &m) + res, err := w.transfer.Transfer(sdk.WrapSDKContext(allowSpecialMemoCtx(ctx)), &m) if err != nil { return errorsmod.Wrap(err, "transfer") } - + w.k.saveUnackedTransferSeqNum(ctx, res.Sequence) return nil } diff --git a/x/hub-genesis/keeper/ics4_wrapper.go b/x/hub-genesis/keeper/ics4_wrapper.go index a8945d38..f60378a3 100644 --- a/x/hub-genesis/keeper/ics4_wrapper.go +++ b/x/hub-genesis/keeper/ics4_wrapper.go @@ -67,9 +67,5 @@ func (w ICS4Wrapper) SendPacket( return 0, errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis phase not finished") } - seq, err := w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) - if specialMemo && err == nil { - w.k.saveUnackedTransferSeqNum(ctx, seq) - } - return seq, err + return w.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) } From d2bcfff98e3274fe76b684d83196c0604d17e7a1 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 13:59:09 +0100 Subject: [PATCH 72/79] expand comment --- x/hub-genesis/keeper/sequence_numbers.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/hub-genesis/keeper/sequence_numbers.go b/x/hub-genesis/keeper/sequence_numbers.go index 4a510aed..2184a702 100644 --- a/x/hub-genesis/keeper/sequence_numbers.go +++ b/x/hub-genesis/keeper/sequence_numbers.go @@ -11,6 +11,8 @@ import ( /* Whenever a genesis transfer is sent, we record the sequence number. We do not allow transfers until all acks have been received with success. + +We use an O(1) access pattern, because we don't place a limit on the number of genesis accounts. */ var UnackedTransferSeqNumsPrefix = []byte("unacked_seqs") From eebb279ff148bb1f867ca8b97f82b218401c7e95 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 13:59:13 +0100 Subject: [PATCH 73/79] remove else --- x/hub-genesis/keeper/ibc_module.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index d5be6921..26071f8a 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -79,17 +79,18 @@ func (w IBCModule) OnChanOpenConfirm( // we want to handle the case where the rollapp doesn't have genesis transfers // normally we would enable outbound transfers on an ack, but in this case we won't have an ack w.k.enableOutboundTransfers(ctx) - } else { - srcAccount := w.k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) - srcAddr := srcAccount.GetAddress().String() - - for i, a := range state.GetGenesisAccounts() { - if err := w.mintAndTransfer(ctx, a, srcAddr, portID, channelID); err != nil { - // there is no feasible way to recover - panic(fmt.Errorf("mint and transfer: %w", err)) - } - l.Info("Sent genesis transfer.", "index", i, "receiver", a.GetAddress(), "coin", a) + return nil + } + + srcAccount := w.k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) + srcAddr := srcAccount.GetAddress().String() + + for i, a := range state.GetGenesisAccounts() { + if err := w.mintAndTransfer(ctx, a, srcAddr, portID, channelID); err != nil { + // there is no feasible way to recover + panic(fmt.Errorf("mint and transfer: %w", err)) } + l.Info("Sent genesis transfer.", "index", i, "receiver", a.GetAddress(), "coin", a) } l.Info("Sent all genesis transfers.", "n", len(state.GetGenesisAccounts())) From e24b7398a9404b4c6e0f69aaa052f265f5c50e7d Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:03:05 +0100 Subject: [PATCH 74/79] flatter function --- x/hub-genesis/keeper/ibc_module.go | 42 +++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/x/hub-genesis/keeper/ibc_module.go b/x/hub-genesis/keeper/ibc_module.go index 26071f8a..3302d553 100644 --- a/x/hub-genesis/keeper/ibc_module.go +++ b/x/hub-genesis/keeper/ibc_module.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "errors" "fmt" "time" @@ -13,6 +14,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" + "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/tendermint/tendermint/libs/log" ) @@ -142,21 +144,31 @@ func (w IBCModule) OnAcknowledgementPacket( ) error { l := w.logger(ctx) state := w.k.GetState(ctx) - if !state.OutboundTransfersEnabled && // still in genesis protocol - state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { // not some other unrelated channel - var data transfertypes.FungibleTokenPacketData - if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil { // it's a transfer - var ack channeltypes.Acknowledgement - if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err == nil { - err := w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) - if err != nil { - l.Error("Processing ack from transfer.", "err", err) - return err - } - } else { - panic(fmt.Errorf("must get ack from in OnAcknowledgementPacket: %w", err)) - } - } + + if !state.IsCanonicalHubTransferChannel(packet.SourcePort, packet.SourceChannel) { + return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) + } + + if state.OutboundTransfersEnabled { + return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) + } + + var data transfertypes.FungibleTokenPacketData + err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data) + if err != nil { + return err + } + + var ack channeltypes.Acknowledgement + err = types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack) + if err != nil { + return err + } + + err = w.k.ackTransferSeqNum(ctx, packet.Sequence, ack) + if err != nil { + l.Error("Processing ack from transfer.", "err", err) + return errorsmod.Wrap(errors.Join(err, gerrc.ErrUnknown), "ack transfer seq num") } return w.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) } From 4b2921a5a8a44b2b4ac855698374ce58300ed0fc Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:04:25 +0100 Subject: [PATCH 75/79] tidy --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index fd22beb7..3ffdd4ab 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( golang.org/x/exp v0.0.0-20240213143201-ec583247a57a google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.33.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -281,7 +282,6 @@ require ( google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect - google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect From 1af7677333ff7ac436686032b647130954a37e03 Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:08:08 +0100 Subject: [PATCH 76/79] fixes test regression --- x/hub-genesis/keeper/memo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/hub-genesis/keeper/memo.go b/x/hub-genesis/keeper/memo.go index ed59cbb7..9e3f5066 100644 --- a/x/hub-genesis/keeper/memo.go +++ b/x/hub-genesis/keeper/memo.go @@ -27,7 +27,7 @@ func memoHasKey(memo string) bool { // that the transfer originated from the chain itself, rather than a user of the chain. // It may also contain token metadata. func (w IBCModule) createMemo(ctx types.Context, denom string) (string, error) { - d, ok := w.getDenom(ctx, denom) + d, ok := w.bank.GetDenomMetaData(ctx, denom) if !ok { return "", errors.Wrap(sdkerrors.ErrNotFound, "get denom metadata") } From 76e83982238a512bc89e8073482e165cca36de6d Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:13:31 +0100 Subject: [PATCH 77/79] use main go.mod go.sum --- go.mod | 5 +++-- go.sum | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 3ffdd4ab..608a9d30 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v6 v6.2.1 github.com/dymensionxyz/dymint v1.1.3-rc04 - github.com/dymensionxyz/gerr-cosmos v0.1.2 + github.com/dymensionxyz/sdk-utils v0.1.1 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.1 @@ -85,7 +85,7 @@ require ( github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect - github.com/danwt/gerr v0.1.5 // indirect + github.com/danwt/gerr v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/deckarep/golang-set v1.8.0 // indirect @@ -101,6 +101,7 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect + github.com/dymensionxyz/gerr-cosmos v1.0.0 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/ethereum/go-ethereum v1.12.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect diff --git a/go.sum b/go.sum index 8453c165..a5f50785 100644 --- a/go.sum +++ b/go.sum @@ -470,8 +470,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= 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/danwt/gerr v0.1.5 h1:5s3G3cnftZG7Rq0+k+taMVteTmwKU66/g47kH6hY1js= -github.com/danwt/gerr v0.1.5/go.mod h1:tIj6P8ZPBLAbr64HdWqKHGUXbWJT6HenD08Fn98oAnE= +github.com/danwt/gerr v1.0.0 h1:v3Do0h1r+uctQQVYJfOTCo8uigp8oIaY4OL/wUU8LzI= +github.com/danwt/gerr v1.0.0/go.mod h1:tIj6P8ZPBLAbr64HdWqKHGUXbWJT6HenD08Fn98oAnE= github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -545,12 +545,14 @@ github.com/dymensionxyz/dymint v1.1.3-rc04 h1:RqDF8bxB73mYmxHKnVNGeTnTsZihAwV6AE github.com/dymensionxyz/dymint v1.1.3-rc04/go.mod h1:e04A2OxeowtxMC9jl4JJj/7fmcYrHEWVIbYAlEd/Byo= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 h1:vmAdUGUc4rTIiO3Phezr7vGq+0uPDVKSA4WAe8+yl6w= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3/go.mod h1:LfPv2O1HXMgETpka81Pg3nXy+U/7urq8dn85ZnSXK5Y= -github.com/dymensionxyz/gerr-cosmos v0.1.2 h1:4NiB9psF6swnWTCDYnHgHKtVEaRHuuNRuqvPGDw1BI8= -github.com/dymensionxyz/gerr-cosmos v0.1.2/go.mod h1:tXIhx3WdryAnYRISC3Weh+2xeXwaf1l4Yb1zjDUsT7k= +github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc= +github.com/dymensionxyz/gerr-cosmos v1.0.0/go.mod h1:n+0olxPogzWqFKba45mCpvrHLGmeS8W9UZjggHnWk6c= github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20231219183151-4504d4995913 h1:sR3nGYRlktL2Xfj5pcOhgG2bvlBOZ14meqdu2TKkSCU= github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20231219183151-4504d4995913/go.mod h1:1OxbaT/pFRO5h+Dpze8hdHQ63R0ke55XTs6b6NwLLkw= github.com/dymensionxyz/rpc v1.3.1 h1:7EXWIobaBes5zldRvTIg7TmNsEKjicrWA/OjCc0NaGs= github.com/dymensionxyz/rpc v1.3.1/go.mod h1:f+WpX8ysy8wt95iGc6auYlHcnHj2bUkhiRVkkKNys8c= +github.com/dymensionxyz/sdk-utils v0.1.1 h1:QX/4S0t+wUhbRlAw34fz2kEF+RP1D+tEVQ/S5QRa5X0= +github.com/dymensionxyz/sdk-utils v0.1.1/go.mod h1:5fmenxP75quS5D1gPynbmh5qE6vla64Kks2O/hM+gi4= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= From 7f483ce7566fc9a7efbde8ef8962121b253a9b8c Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:13:39 +0100 Subject: [PATCH 78/79] tidy --- go.mod | 3 +-- go.sum | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 608a9d30..b1f0e384 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v6 v6.2.1 github.com/dymensionxyz/dymint v1.1.3-rc04 - github.com/dymensionxyz/sdk-utils v0.1.1 + github.com/dymensionxyz/gerr-cosmos v1.0.0 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.1 @@ -101,7 +101,6 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect - github.com/dymensionxyz/gerr-cosmos v1.0.0 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/ethereum/go-ethereum v1.12.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect diff --git a/go.sum b/go.sum index a5f50785..343c3600 100644 --- a/go.sum +++ b/go.sum @@ -551,8 +551,6 @@ github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20231219183151-4504d4995913 h1:s github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20231219183151-4504d4995913/go.mod h1:1OxbaT/pFRO5h+Dpze8hdHQ63R0ke55XTs6b6NwLLkw= github.com/dymensionxyz/rpc v1.3.1 h1:7EXWIobaBes5zldRvTIg7TmNsEKjicrWA/OjCc0NaGs= github.com/dymensionxyz/rpc v1.3.1/go.mod h1:f+WpX8ysy8wt95iGc6auYlHcnHj2bUkhiRVkkKNys8c= -github.com/dymensionxyz/sdk-utils v0.1.1 h1:QX/4S0t+wUhbRlAw34fz2kEF+RP1D+tEVQ/S5QRa5X0= -github.com/dymensionxyz/sdk-utils v0.1.1/go.mod h1:5fmenxP75quS5D1gPynbmh5qE6vla64Kks2O/hM+gi4= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= From 12b8ff9b41ea19486d3307e4d71c151408f77eeb Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:15:22 +0100 Subject: [PATCH 79/79] tidy --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 608a9d30..f7465d0f 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v6 v6.2.1 github.com/dymensionxyz/dymint v1.1.3-rc04 + github.com/dymensionxyz/gerr-cosmos v1.0.0 github.com/dymensionxyz/sdk-utils v0.1.1 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.4 @@ -101,7 +102,6 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect - github.com/dymensionxyz/gerr-cosmos v1.0.0 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/ethereum/go-ethereum v1.12.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect