From fe4b9d2d756427384af318c38902810e85b56195 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Fri, 22 Dec 2023 13:42:08 +0900 Subject: [PATCH 01/11] bump cosmos-sdk to v0.50 --- go.mod | 165 ++++---- go.sum | 388 +++++++++++-------- proto/buf.gen.gogo.yaml | 4 +- proto/buf.lock | 4 +- proto/buf.yaml | 8 +- proto/opinit/opchild/v1/types.proto | 12 - proto/opinit/ophost/v1/tx.proto | 2 - x/opchild/abci.go | 10 +- x/opchild/ante/ante_test.go | 27 +- x/opchild/ante/fee_test.go | 43 +- x/opchild/ante/fee_utils.go | 5 +- x/opchild/client/cli/legacy_contents.go | 21 +- x/opchild/client/cli/query.go | 11 +- x/opchild/client/cli/query_test.go | 5 +- x/opchild/client/cli/tx.go | 43 +- x/opchild/client/cli/tx_test.go | 45 ++- x/opchild/genesis.go | 14 +- x/opchild/keeper/alias_functions.go | 49 +-- x/opchild/keeper/common_test.go | 92 +++-- x/opchild/keeper/compatibility_grpc_query.go | 7 +- x/opchild/keeper/genesis.go | 50 ++- x/opchild/keeper/genesis_test.go | 6 +- x/opchild/keeper/historical_info.go | 63 +-- x/opchild/keeper/historical_info_test.go | 28 +- x/opchild/keeper/keeper.go | 82 +++- x/opchild/keeper/msg_server.go | 163 +++++--- x/opchild/keeper/msg_server_test.go | 87 ++--- x/opchild/keeper/params.go | 45 +-- x/opchild/keeper/params_test.go | 11 +- x/opchild/keeper/querier.go | 34 +- x/opchild/keeper/querier_test.go | 3 +- x/opchild/keeper/sequence_test.go | 27 +- x/opchild/keeper/sequences.go | 80 ++-- x/opchild/keeper/staking.go | 23 +- x/opchild/keeper/staking_test.go | 12 +- x/opchild/keeper/val_state_change.go | 70 ++-- x/opchild/keeper/val_state_change_test.go | 11 +- x/opchild/keeper/validator.go | 192 ++++----- x/opchild/keeper/validator_test.go | 43 +- x/opchild/module.go | 47 ++- x/opchild/types/codec.go | 21 - x/opchild/types/errors.go | 2 + x/opchild/types/expected_keepers.go | 50 +-- x/opchild/types/exported.go | 10 +- x/opchild/types/genesis.go | 5 +- x/opchild/types/historical_info.go | 64 --- x/opchild/types/hook.go | 4 +- x/opchild/types/keys.go | 62 +-- x/opchild/types/params.go | 8 +- x/opchild/types/tx.go | 294 ++------------ x/opchild/types/types.pb.go | 335 +++------------- x/opchild/types/validator.go | 40 +- x/ophost/client/cli/query.go | 6 +- x/ophost/client/cli/tx.go | 47 +-- x/ophost/client/cli/tx_test.go | 153 ++++---- x/ophost/keeper/bridge.go | 153 +++----- x/ophost/keeper/bridge_test.go | 4 +- x/ophost/keeper/common_test.go | 73 ++-- x/ophost/keeper/genesis.go | 52 ++- x/ophost/keeper/keeper.go | 66 +++- x/ophost/keeper/msg_server.go | 126 ++++-- x/ophost/keeper/msg_server_test.go | 51 +-- x/ophost/keeper/output.go | 112 ++---- x/ophost/keeper/output_test.go | 38 +- x/ophost/keeper/params.go | 29 +- x/ophost/keeper/querier.go | 117 ++---- x/ophost/keeper/token_pair.go | 58 +-- x/ophost/keeper/token_pair_test.go | 4 +- x/ophost/keeper/withdrawal.go | 41 +- x/ophost/keeper/withdrawal_test.go | 13 +- x/ophost/module.go | 44 ++- x/ophost/types/auth.go | 2 +- x/ophost/types/bridge_config.go | 8 +- x/ophost/types/codec.go | 23 +- x/ophost/types/event.go | 2 + x/ophost/types/expected_keeper.go | 44 ++- x/ophost/types/genesis.go | 5 +- x/ophost/types/hooks.go | 16 +- x/ophost/types/keys.go | 83 +--- x/ophost/types/tx.go | 299 ++------------ x/ophost/types/tx.pb.go | 182 +++++---- 81 files changed, 2022 insertions(+), 2756 deletions(-) delete mode 100644 x/opchild/types/historical_info.go diff --git a/go.mod b/go.mod index 08cc9585..818c2432 100644 --- a/go.mod +++ b/go.mod @@ -1,148 +1,164 @@ module github.com/initia-labs/OPinit -go 1.19 +go 1.21 + +toolchain go1.21.5 require ( + cosmossdk.io/collections v0.4.0 + cosmossdk.io/core v0.11.0 cosmossdk.io/errors v1.0.0 - cosmossdk.io/math v1.1.2 - cosmossdk.io/simapp v0.0.0-20230831152633-2e9e5d6eea24 - github.com/cometbft/cometbft v0.37.2 - github.com/cometbft/cometbft-db v0.8.0 - github.com/cosmos/cosmos-proto v1.0.0-beta.2 - github.com/cosmos/cosmos-sdk v0.47.5 - github.com/cosmos/gogoproto v1.4.10 - github.com/cosmos/ibc-go/v7 v7.3.1 + cosmossdk.io/log v1.2.1 + cosmossdk.io/math v1.2.0 + cosmossdk.io/simapp v0.0.0-20231211060251-d8fb76d4c267 + cosmossdk.io/store v1.0.1 + cosmossdk.io/x/tx v0.12.0 + cosmossdk.io/x/upgrade v0.1.1 + github.com/cometbft/cometbft v0.38.2 + github.com/cosmos/cosmos-db v1.0.0 + github.com/cosmos/cosmos-proto v1.0.0-beta.3 + github.com/cosmos/cosmos-sdk v0.50.2 + github.com/cosmos/gogoproto v1.4.11 + github.com/cosmos/ibc-go/modules/capability v1.0.0 + github.com/cosmos/ibc-go/v8 v8.0.0 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.11.0 - google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 - google.golang.org/grpc v1.56.2 + golang.org/x/crypto v0.16.0 + google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a + google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v3 v3.0.1 - sigs.k8s.io/yaml v1.3.0 + sigs.k8s.io/yaml v1.4.0 ) require ( - cloud.google.com/go v0.110.4 // indirect - cloud.google.com/go/compute v1.20.1 // indirect + cloud.google.com/go v0.110.8 // indirect + cloud.google.com/go/compute v1.23.1 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.0 // indirect + cloud.google.com/go/iam v1.1.3 // indirect cloud.google.com/go/storage v1.30.1 // indirect - cosmossdk.io/api v0.3.1 // indirect - cosmossdk.io/core v0.5.1 // indirect + cosmossdk.io/api v0.7.2 // indirect + cosmossdk.io/client/v2 v2.0.0-beta.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/log v1.2.1 // indirect - cosmossdk.io/tools/rosetta v0.2.1 // indirect + cosmossdk.io/x/circuit v0.1.0 // indirect + cosmossdk.io/x/evidence v0.1.0 // indirect + cosmossdk.io/x/feegrant v0.1.0 // indirect + cosmossdk.io/x/nft v0.1.0 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect - github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.44.203 // indirect + github.com/DataDog/datadog-go v3.2.0+incompatible // indirect + github.com/DataDog/zstd v1.5.5 // indirect + github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect + github.com/bits-and-blooms/bitset v1.8.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/cockroachdb/errors v1.10.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v0.0.0-20231102162011-844f0582c2eb // indirect github.com/cockroachdb/redact v1.1.5 // indirect - github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect - github.com/confio/ics23/go v0.9.0 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cometbft/cometbft-db v0.9.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v0.20.0 // indirect + github.com/cosmos/iavl v1.0.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect - github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect - github.com/creachadair/taskgroup v0.4.2 // indirect + github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect - github.com/felixge/httpsnoop v1.0.2 // indirect + github.com/emicklei/dot v1.6.0 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/getsentry/sentry-go v0.23.0 // indirect + github.com/getsentry/sentry-go v0.25.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.1.0 // indirect + github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect - github.com/googleapis/gax-go/v2 v2.11.0 // indirect - github.com/gorilla/handlers v1.5.1 // indirect - github.com/gorilla/mux v1.8.0 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect + github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/gorilla/handlers v1.5.2 // indirect + github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.1 // indirect + github.com/hashicorp/go-getter v1.7.3 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-metrics v0.5.2 // indirect + github.com/hashicorp/go-plugin v1.5.2 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect + github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect - github.com/klauspost/compress v1.16.3 // indirect + github.com/klauspost/compress v1.17.4 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/linxGnu/grocksdb v1.7.16 // indirect + github.com/linxGnu/grocksdb v1.8.6 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect + github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect + github.com/oklog/run v1.1.0 // indirect + github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect - github.com/rakyll/statik v0.1.7 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.17.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.8.3 // indirect - github.com/rs/zerolog v1.30.0 // indirect + github.com/rs/zerolog v1.31.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect @@ -151,27 +167,28 @@ require ( github.com/subosito/gotenv v1.4.2 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tidwall/btree v1.6.0 // indirect + github.com/tidwall/btree v1.7.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect - github.com/zondax/hid v0.9.1 // indirect - github.com/zondax/ledger-go v0.14.1 // indirect - go.etcd.io/bbolt v1.3.7 // indirect + github.com/zondax/hid v0.9.2 // indirect + github.com/zondax/ledger-go v0.14.3 // indirect + go.etcd.io/bbolt v1.3.8 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/oauth2 v0.12.0 // indirect + golang.org/x/sync v0.5.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.126.0 // indirect + google.golang.org/api v0.128.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.6 // indirect - pgregory.net/rapid v0.5.5 // indirect + pgregory.net/rapid v1.1.0 // indirect ) replace ( diff --git a/go.sum b/go.sum index a2edd73f..8edbf95c 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,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.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= -cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= +cloud.google.com/go v0.110.8 h1:tyNdfIxjzaWctIiLYOTalaLKZ17SI44SKFW26QbOhME= +cloud.google.com/go v0.110.8/go.mod h1:Iz8AkXJf1qmxC3Oxoep8R1T36w8B92yU29PcBhHO5fk= 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= @@ -70,8 +70,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.20.1 h1:6aKEtlUiwEpJzM001l0yFkpXmUVXaN8W+fbkb2AZNbg= -cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute v1.23.1 h1:V97tBoDaZHb6leicZ1G6DLK2BAaZLJ/7+9BB/En3hR0= +cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3Xp1ixncW78= 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= @@ -111,8 +111,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.0 h1:67gSqaPukx7O8WLLHMa0PNs3EBGd2eE4d+psbO/CO94= -cloud.google.com/go/iam v1.1.0/go.mod h1:nxdHjaKfCr7fNYx/HJMM8LgiMugmveWlkatear5gVyk= +cloud.google.com/go/iam v1.1.3 h1:18tKG7DzydKWUnLjonWcJO6wjSCAtzh4GcRKlH/Hrzc= +cloud.google.com/go/iam v1.1.3/go.mod h1:3khUlaBXfPKKe7huYgEpDn6FtgRyMEqbkvBxrQyY5SE= 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= @@ -187,36 +187,56 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE= -cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw= -cosmossdk.io/core v0.5.1 h1:vQVtFrIYOQJDV3f7rw4pjjVqc1id4+mE0L9hHP66pyI= -cosmossdk.io/core v0.5.1/go.mod h1:KZtwHCLjcFuo0nmDc24Xy6CRNEL9Vl/MeimQ2aC7NLE= +cosmossdk.io/api v0.7.2 h1:BO3i5fvKMKvfaUiMkCznxViuBEfyWA/k6w2eAF6q1C4= +cosmossdk.io/api v0.7.2/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/client/v2 v2.0.0-beta.1 h1:XkHh1lhrLYIT9zKl7cIOXUXg2hdhtjTPBUfqERNA1/Q= +cosmossdk.io/client/v2 v2.0.0-beta.1/go.mod h1:JEUSu9moNZQ4kU3ir1DKD5eU4bllmAexrGWjmb9k8qU= +cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= +cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= +cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= cosmossdk.io/log v1.2.1/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= -cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= -cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= -cosmossdk.io/simapp v0.0.0-20230831152633-2e9e5d6eea24 h1:A+LHM41uss8WNJ+qZCdvCjtiG6UiIN7ZqmPZz6R25wc= -cosmossdk.io/simapp v0.0.0-20230831152633-2e9e5d6eea24/go.mod h1:1kVkzonF2p6SYsSMXXURz/kx50QWArqazCk1Myulu8g= -cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= -cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= +cosmossdk.io/math v1.2.0 h1:8gudhTkkD3NxOP2YyyJIYYmt6dQ55ZfJkDOaxXpy7Ig= +cosmossdk.io/math v1.2.0/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= +cosmossdk.io/simapp v0.0.0-20231211060251-d8fb76d4c267 h1:fLJ+ng4SiuEK7NhKPIAn7QlWNGPpFCzfdtEODUXDvEs= +cosmossdk.io/simapp v0.0.0-20231211060251-d8fb76d4c267/go.mod h1:ril3K+x7sdvOTVZsBv0PGDePO54m64HLDq1AmVEREl8= +cosmossdk.io/store v1.0.1 h1:XBDhCqlL+2MUgE8CHWwndKVJ4beX+TyaPIjB5SV62dM= +cosmossdk.io/store v1.0.1/go.mod h1:EFtENTqVTuWwitGW1VwaBct+yDagk7oG/axBMPH+FXs= +cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs= +cosmossdk.io/x/circuit v0.1.0/go.mod h1:YDzblVE8+E+urPYQq5kq5foRY/IzhXovSYXb4nwd39w= +cosmossdk.io/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk= +cosmossdk.io/x/evidence v0.1.0/go.mod h1:hTaiiXsoiJ3InMz1uptgF0BnGqROllAN8mwisOMMsfw= +cosmossdk.io/x/feegrant v0.1.0 h1:c7s3oAq/8/UO0EiN1H5BIjwVntujVTkYs35YPvvrdQk= +cosmossdk.io/x/feegrant v0.1.0/go.mod h1:4r+FsViJRpcZif/yhTn+E0E6OFfg4n0Lx+6cCtnZElU= +cosmossdk.io/x/nft v0.1.0 h1:VhcsFiEK33ODN27kxKLa0r/CeFd8laBfbDBwYqCyYCM= +cosmossdk.io/x/nft v0.1.0/go.mod h1:ec4j4QAO4mJZ+45jeYRnW7awLHby1JZANqe1hNZ4S3g= +cosmossdk.io/x/tx v0.12.0 h1:Ry2btjQdrfrje9qZ3iZeZSmDArjgxUJMMcLMrX4wj5U= +cosmossdk.io/x/tx v0.12.0/go.mod h1:qTth2coAGkwCwOCjqQ8EAQg+9udXNRzcnSbMgGKGEI0= +cosmossdk.io/x/upgrade v0.1.1 h1:aoPe2gNvH+Gwt/Pgq3dOxxQVU3j5P6Xf+DaUJTDZATc= +cosmossdk.io/x/upgrade v0.1.1/go.mod h1:MNLptLPcIFK9CWt7Ra//8WUZAxweyRDNcbs5nkOcQy0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -224,6 +244,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= +github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -236,16 +257,15 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.44.203 h1:pcsP805b9acL3wUqa4JR2vg1k2wnItkDYNvfmcy6F+U= -github.com/aws/aws-sdk-go v1.44.203/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= +github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -255,11 +275,16 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= +github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJSRsjzQ= +github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= +github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -298,22 +323,25 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+0VUU= -github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20231102162011-844f0582c2eb h1:6Po+YYKT5B5ZXN0wd2rwFBaebM0LufPf8p4zxOd48Kg= +github.com/cockroachdb/pebble v0.0.0-20231102162011-844f0582c2eb/go.mod h1:acMRUGd/BK8AUmQNK3spUCCGzFLZU2bSST3NMXSq2Kc= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= -github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= -github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= -github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo= -github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0= -github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= -github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= +github.com/cometbft/cometbft v0.38.2 h1:io0JCh5EPxINKN5ZMI5hCdpW3QVZRy+o8qWe3mlJa/8= +github.com/cometbft/cometbft v0.38.2/go.mod h1:PIi48BpzwlHqtV3mzwPyQgOyOnU94BNBimLS2ebBHOg= +github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M= +github.com/cometbft/cometbft-db v0.9.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -322,35 +350,34 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= -github.com/cosmos/cosmos-proto v1.0.0-beta.2 h1:X3OKvWgK9Gsejo0F1qs5l8Qn6xJV/AzgIWR2wZ8Nua8= -github.com/cosmos/cosmos-proto v1.0.0-beta.2/go.mod h1:+XRCLJ14pr5HFEHIUcn51IKXD1Fy3rkEQqt4WqmN4V0= -github.com/cosmos/cosmos-sdk v0.47.5 h1:n1+WjP/VM/gAEOx3TqU2/Ny734rj/MX1kpUnn7zVJP8= -github.com/cosmos/cosmos-sdk v0.47.5/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= +github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= +github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= +github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= +github.com/cosmos/cosmos-sdk v0.50.2 h1:u52xPZXLfeuR1HbGPCyOsMQvAbCtvoJbpfH5diBPVuc= +github.com/cosmos/cosmos-sdk v0.50.2/go.mod h1:n/WQqDh73qdtBmY9Op3sYgiBgTujSfGSd6CNh6GfqvQ= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= -github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= -github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= -github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38= -github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= -github.com/cosmos/ibc-go/v7 v7.3.1 h1:bil1IjnHdyWDASFYKfwdRiNtFP6WK3osW7QFEAgU4I8= -github.com/cosmos/ibc-go/v7 v7.3.1/go.mod h1:wvx4pPBofe5ZdMNV3OFRxSI4auEP5Qfqf8JXLLNV04g= +github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= +github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= +github.com/cosmos/iavl v1.0.0 h1:bw6t0Mv/mVCJvlMTOPHWLs5uUE3BRBfVWCRelOzl+so= +github.com/cosmos/iavl v1.0.0/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= +github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= +github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= +github.com/cosmos/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg= +github.com/cosmos/ibc-go/v8 v8.0.0/go.mod h1:C6IiJom0F3cIQCD5fKwVPDrDK9j/xTu563AWuOmXois= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= -github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= -github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= -github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= -github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= +github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= +github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJFxv2Li8= -github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -358,9 +385,10 @@ github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnG github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= @@ -372,7 +400,9 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -383,6 +413,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m 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= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/emicklei/dot v1.6.0 h1:vUzuoVE8ipzS7QkES4UfxdpCwdU2U97m2Pb2tQCoYRY= +github.com/emicklei/dot v1.6.0/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -395,25 +427,30 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -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/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= -github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX1eOyI= +github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -422,6 +459,7 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -436,6 +474,7 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= @@ -446,6 +485,7 @@ github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= +github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -461,8 +501,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= -github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= +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= @@ -521,17 +561,20 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -554,13 +597,14 @@ github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/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= -github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= -github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/enterprise-certificate-proxy v0.2.4 h1:uGy6JWR/uMIILU8wbf+OkstIrNiMjGpEIyhx8f6W7s4= +github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -570,37 +614,32 @@ 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.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= -github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= +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/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= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= -github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= -github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -608,13 +647,19 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= -github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.3 h1:bN2+Fw9XPFvOCjB0UOevFIMICZ7G2XSQHzfvLUyOM5E= +github.com/hashicorp/go-getter v1.7.3/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-metrics v0.5.2 h1:ErEYO2f//CjKsUDw4SmLzelsK6L3ZmOAR/4P9iS7ruY= +github.com/hashicorp/go-metrics v0.5.2/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= +github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= @@ -622,22 +667,25 @@ github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoD github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU= github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -646,6 +694,8 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= @@ -654,7 +704,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= +github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -684,8 +735,8 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY= -github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= +github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -707,8 +758,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.7.16 h1:Q2co1xrpdkr5Hx3Fp+f+f7fRGhQFQhvi/+226dtLmA8= -github.com/linxGnu/grocksdb v1.7.16/go.mod h1:JkS7pl5qWpGpuVb3bPqTz8nC12X3YtPZT+Xq7+QfQo4= +github.com/linxGnu/grocksdb v1.8.6 h1:O7I6SIGPrypf3f/gmrrLUBQDKfO8uOoYdWf4gLS06tc= +github.com/linxGnu/grocksdb v1.8.6/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -716,24 +767,24 @@ github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3v github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -772,22 +823,32 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= +github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= +github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= +github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -797,6 +858,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -804,15 +866,16 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc h1:8bQZVK1X6BJR/6nYUPxQEP+ReTsceJTKizeuwjWOPUA= +github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -820,8 +883,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= @@ -829,34 +893,32 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= +github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= -github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -872,8 +934,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= -github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -888,6 +950,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -930,9 +993,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= 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.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 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/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= @@ -941,15 +1004,16 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= -github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= +github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -963,13 +1027,13 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= -github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= -github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= +github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= +github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= -go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= +go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -986,11 +1050,15 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe 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= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -999,7 +1067,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -1007,8 +1074,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1020,8 +1087,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us= -golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1048,7 +1115,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= +golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1110,8 +1178,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1137,8 +1205,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.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= -golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= +golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= +golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= 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= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1153,7 +1221,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1185,6 +1254,7 @@ golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1228,6 +1298,7 @@ golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1251,13 +1322,14 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1269,8 +1341,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1296,6 +1368,7 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1337,7 +1410,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1396,8 +1470,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.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= -google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= +google.golang.org/api v0.128.0 h1:RjPESny5CnQRn9V6siglged+DZCgfu9l6mO9dkX9VOg= +google.golang.org/api v0.128.0/go.mod h1:Y611qgqaE92On/7g65MQgxYul3c0rEB894kniWLY750= 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.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1515,12 +1589,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-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIYWHqOUZ1pva5qK/rwbIhoXEUB9Lu8= -google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= -google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1:s5YSX+ZH5b5vS9rnpGymvIyMpLRJizowqDlOuyjXnTk= -google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA= +google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI= +google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a h1:myvhA4is3vrit1a6NZCWBIwN0kNEnX21DJOJX/NvIfI= +google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:SUBoKXbI1Efip18FClrQVGjWcyd0QZd8KkvdP34t7ww= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 h1:AB/lmRny7e2pLhFEYIbl5qkDAUt2h0ZRO4wGPhZf+ik= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405/go.mod h1:67X1fPuzjcrkymZzZV1vvkFeTn2Rvc6lYF9MYFGCcwE= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1562,8 +1636,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.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= 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= @@ -1614,8 +1688,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1626,12 +1700,12 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA= -pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= +pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= +pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml index 855ea251..e3cd0b1a 100644 --- a/proto/buf.gen.gogo.yaml +++ b/proto/buf.gen.gogo.yaml @@ -2,7 +2,7 @@ version: v1 plugins: - name: gocosmos out: .. - opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1/orm.proto=cosmossdk.io/orm - name: grpc-gateway out: .. - opt: logtostderr=true,allow_colon_final_segments=true \ No newline at end of file + opt: logtostderr=true,allow_colon_final_segments=true diff --git a/proto/buf.lock b/proto/buf.lock index 89f0d190..33ee1fbc 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -9,8 +9,8 @@ deps: - remote: buf.build owner: cosmos repository: cosmos-sdk - commit: 9d547dbea90f47afbe1898388fcebffb - digest: shake256:63237398fb2043153c81bbe91ce52a832bca02d4307334b62fcc9914ce6f12fea59388eb5102949255054973f7022f581e02f97ed1f69a6585d2d00fb1da5833 + commit: 5a6ab7bc14314acaa912d5e53aef1c2f + digest: shake256:02c00c73493720055f9b57553a35b5550023a3c1914123b247956288a78fb913aff70e66552777ae14d759467e119079d484af081264a5dd607a94d9fbc8116b - remote: buf.build owner: cosmos repository: gogo-proto diff --git a/proto/buf.yaml b/proto/buf.yaml index 5c1d249e..b8579c85 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -2,10 +2,10 @@ version: v1 name: buf.build/initia-labs/OPinit deps: - - buf.build/cosmos/cosmos-sdk - - buf.build/cosmos/cosmos-proto - - buf.build/cosmos/gogo-proto - - buf.build/googleapis/googleapis + - buf.build/cosmos/cosmos-sdk:v0.50.0 + - buf.build/cosmos/cosmos-proto:1935555c206d4afb9e94615dfd0fad31 + - buf.build/cosmos/gogo-proto:5e5b9fdd01804356895f8f79a6f1ddc1 + - buf.build/googleapis/googleapis:cc916c31859748a68fd229a3c8d7a2e8 breaking: use: diff --git a/proto/opinit/opchild/v1/types.proto b/proto/opinit/opchild/v1/types.proto index ad803575..b440c1d3 100644 --- a/proto/opinit/opchild/v1/types.proto +++ b/proto/opinit/opchild/v1/types.proto @@ -7,7 +7,6 @@ import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "tendermint/abci/types.proto"; -import "tendermint/types/types.proto"; option go_package = "github.com/initia-labs/OPinit/x/opchild/types"; option (gogoproto.equal_all) = true; @@ -37,17 +36,6 @@ message Params { ]; } -// HistoricalInfo contains header and validator information for a given block. -// It is stored as part of rollup module's state, which persists the `n` most -// recent HistoricalInfo -// (`n` is set by the rollup module's `historical_entries` parameter). -message HistoricalInfo { - option (gogoproto.equal) = false; - - tendermint.types.Header header = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - repeated Validator valset = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; -} - // Validator defines a validator, together with the total amount of the // Validator's bond shares and their exchange rate to coins. Slashing results in // a decrease in the exchange rate, allowing correct calculation of future diff --git a/proto/opinit/ophost/v1/tx.proto b/proto/opinit/ophost/v1/tx.proto index 46ded850..b460d01c 100644 --- a/proto/opinit/ophost/v1/tx.proto +++ b/proto/opinit/ophost/v1/tx.proto @@ -6,8 +6,6 @@ import "cosmos/base/v1beta1/coin.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/timestamp.proto"; import "opinit/ophost/v1/types.proto"; option go_package = "github.com/initia-labs/OPinit/x/ophost/types"; diff --git a/x/opchild/abci.go b/x/opchild/abci.go index d985d256..7db58f97 100644 --- a/x/opchild/abci.go +++ b/x/opchild/abci.go @@ -1,12 +1,12 @@ package opchild import ( + "context" "time" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/initia-labs/OPinit/x/opchild/keeper" "github.com/initia-labs/OPinit/x/opchild/types" @@ -14,15 +14,13 @@ import ( // BeginBlocker will persist the current header and validator set as a historical entry // and prune the oldest entry based on the HistoricalEntries parameter -func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) { +func BeginBlocker(ctx context.Context, k keeper.Keeper) error { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) - - k.TrackHistoricalInfo(ctx) + return k.TrackHistoricalInfo(ctx) } // Called every block, update validator set -func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate { +func EndBlocker(ctx context.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, error) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - return k.BlockValidatorUpdates(ctx) } diff --git a/x/opchild/ante/ante_test.go b/x/opchild/ante/ante_test.go index 7fbc77e8..f3065cff 100644 --- a/x/opchild/ante/ante_test.go +++ b/x/opchild/ante/ante_test.go @@ -1,15 +1,15 @@ package ante_test import ( + "context" "testing" "github.com/stretchr/testify/suite" - dbm "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - + "cosmossdk.io/log" "cosmossdk.io/simapp" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -43,8 +43,11 @@ func createTestApp(isCheckTx bool, tempDir string) (*simapp.SimApp, sdk.Context) app := simapp.NewSimApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, appOptions, ) - ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) - app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) + ctx := app.BaseApp.NewContext(isCheckTx) + err := app.AccountKeeper.Params.Set(ctx, authtypes.DefaultParams()) + if err != nil { + panic(err) + } return app, ctx } @@ -64,7 +67,11 @@ func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { } // CreateTestTx is a helper function to create a tx given multiple inputs. -func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { +func (suite *AnteTestSuite) CreateTestTx( + ctx context.Context, privs []cryptotypes.PrivKey, + accNums, accSeqs []uint64, + chainID string, signMode signing.SignMode, +) (xauthsigning.Tx, error) { // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. var sigsV2 []signing.SignatureV2 @@ -72,7 +79,7 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums [] sigV2 := signing.SignatureV2{ PubKey: priv.PubKey(), Data: &signing.SingleSignatureData{ - SignMode: suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), + SignMode: signMode, Signature: nil, }, Sequence: accSeqs[i], @@ -89,12 +96,14 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums [] sigsV2 = []signing.SignatureV2{} for i, priv := range privs { signerData := xauthsigning.SignerData{ + Address: sdk.AccAddress(priv.PubKey().Address()).String(), ChainID: chainID, AccountNumber: accNums[i], Sequence: accSeqs[i], + PubKey: priv.PubKey(), } sigV2, err := tx.SignWithPrivKey( - suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, + ctx, signMode, signerData, suite.txBuilder, priv, suite.clientCtx.TxConfig, accSeqs[i]) if err != nil { return nil, err diff --git a/x/opchild/ante/fee_test.go b/x/opchild/ante/fee_test.go index 97323071..74190ae9 100644 --- a/x/opchild/ante/fee_test.go +++ b/x/opchild/ante/fee_test.go @@ -3,9 +3,12 @@ package ante_test import ( "github.com/initia-labs/OPinit/x/opchild/ante" + "cosmossdk.io/math" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" ) var baseDenom = sdk.DefaultBondDenom @@ -24,7 +27,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // set price 0.5 base == 1 quote fc := ante.NewMempoolFeeChecker(TestAnteKeeper{ - minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.ZeroDec())), + minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyZeroDec())), }) // keys and addresses @@ -33,7 +36,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // msg and signatures // gas price 0.0005 msg := testdata.NewTestMsg(addr1) - feeAmount := sdk.NewCoins(sdk.NewCoin(baseDenom, sdk.NewInt(100))) + feeAmount := sdk.NewCoins(sdk.NewCoin(baseDenom, math.NewInt(100))) gasLimit := uint64(200_000) suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) @@ -41,11 +44,11 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { suite.txBuilder.SetGasLimit(gasLimit) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT) suite.Require().NoError(err) // Set high gas price so standard test fee fails - basePrice := sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(200).Quo(sdk.NewDec(100000))) + basePrice := sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000))) highGasPrice := []sdk.DecCoin{basePrice} suite.ctx = suite.ctx.WithMinGasPrices(highGasPrice) @@ -67,7 +70,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { suite.ctx = suite.ctx.WithIsCheckTx(true) // gas price = 0.0005 - basePrice = sdk.NewDecCoinFromDec(baseDenom, sdk.NewDecWithPrec(5, 4)) + basePrice = sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDecWithPrec(5, 4)) lowGasPrice := []sdk.DecCoin{basePrice} suite.ctx = suite.ctx.WithMinGasPrices(lowGasPrice) @@ -76,7 +79,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // set high base_min_gas_price to test should be failed fc = ante.NewMempoolFeeChecker(TestAnteKeeper{ - minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(200).Quo(sdk.NewDec(100000)))), + minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000)))), }) suite.txBuilder.SetFeeAmount(feeAmount) @@ -85,33 +88,33 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { } func (suite *AnteTestSuite) TestCombinedMinGasPrices() { - minGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(100))) - configMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(100))) + minGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100))) + configMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100))) combined := ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(sdk.NewDec(100))) + suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(100))) - configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(150))) + configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(150))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(sdk.NewDec(150))) + suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(150))) - minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(200))) + minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(sdk.NewDec(200))) + suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(200))) - configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(100)), sdk.NewDecCoinFromDec("test", sdk.NewDec(100))) + configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test", math.LegacyNewDec(100))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 2) - suite.Require().True(combined.AmountOf(baseDenom).Equal(sdk.NewDec(200))) - suite.Require().True(combined.AmountOf("test").Equal(sdk.NewDec(100))) + suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(200))) + suite.Require().True(combined.AmountOf("test").Equal(math.LegacyNewDec(100))) - minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, sdk.NewDec(100)), sdk.NewDecCoinFromDec("test2", sdk.NewDec(300))) + minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test2", math.LegacyNewDec(300))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 3) - suite.Require().True(combined.AmountOf(baseDenom).Equal(sdk.NewDec(100))) - suite.Require().True(combined.AmountOf("test").Equal(sdk.NewDec(100))) - suite.Require().True(combined.AmountOf("test2").Equal(sdk.NewDec(300))) + suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(100))) + suite.Require().True(combined.AmountOf("test").Equal(math.LegacyNewDec(100))) + suite.Require().True(combined.AmountOf("test2").Equal(math.LegacyNewDec(300))) } diff --git a/x/opchild/ante/fee_utils.go b/x/opchild/ante/fee_utils.go index f0ee9e8b..31105575 100644 --- a/x/opchild/ante/fee_utils.go +++ b/x/opchild/ante/fee_utils.go @@ -17,7 +17,7 @@ func CombinedMinGasPrices(minGasPrices sdk.DecCoins, configMinGasPrices sdk.DecC } // computeRequiredFees returns required fees -func computeRequiredFees(gas sdk.Gas, minGasPrices sdk.DecCoins) sdk.Coins { +func computeRequiredFees(gas uint64, minGasPrices sdk.DecCoins) sdk.Coins { // special case: if minGasPrices=[], requiredFees=[] requiredFees := make(sdk.Coins, len(minGasPrices)) @@ -25,9 +25,8 @@ func computeRequiredFees(gas sdk.Gas, minGasPrices sdk.DecCoins) sdk.Coins { if !minGasPrices.IsZero() { // Determine the required fees by multiplying each required minimum gas // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - glDec := sdk.NewDec(int64(gas)) for i, gp := range minGasPrices { - fee := gp.Amount.Mul(glDec) + fee := gp.Amount.MulInt64(int64(gas)) requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) } } diff --git a/x/opchild/client/cli/legacy_contents.go b/x/opchild/client/cli/legacy_contents.go index b4ef24d1..f812b248 100644 --- a/x/opchild/client/cli/legacy_contents.go +++ b/x/opchild/client/cli/legacy_contents.go @@ -8,6 +8,8 @@ import ( "github.com/spf13/cobra" + "cosmossdk.io/core/address" + upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/codec" @@ -16,17 +18,16 @@ import ( govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + "github.com/cosmos/ibc-go/v8/modules/core/exported" "github.com/initia-labs/OPinit/x/opchild/types" ) // NewLegacyContentParamChangeTxCmd returns a CLI command handler for creating // a parameter change legacy content validator transaction. -func NewLegacyContentParamChangeTxCmd() *cobra.Command { +func NewLegacyContentParamChangeTxCmd(ac address.Codec) *cobra.Command { return &cobra.Command{ Use: "param-change [proposal-file]", Args: cobra.ExactArgs(1), @@ -84,13 +85,17 @@ Where proposal.json contains: return err } + if err := msg.Validate(ac); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } } // NewLegacyContentSubmitUpdateClientCmd implements a command handler for submitting an update IBC client transaction. -func NewLegacyContentSubmitUpdateClientCmd() *cobra.Command { +func NewLegacyContentSubmitUpdateClientCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "update-client [subject-client-id] [substitute-client-id]", Args: cobra.ExactArgs(2), @@ -125,7 +130,7 @@ func NewLegacyContentSubmitUpdateClientCmd() *cobra.Command { return err } - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } @@ -140,7 +145,7 @@ func NewLegacyContentSubmitUpdateClientCmd() *cobra.Command { } // NewLegacyContentSubmitUpgradeCmd implements a command handler for submitting an upgrade IBC client transaction. -func NewLegacyContentSubmitUpgradeCmd() *cobra.Command { +func NewLegacyContentSubmitUpgradeCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "ibc-upgrade [name] [height] [path/to/upgraded_client_state.json] [flags]", Args: cobra.ExactArgs(3), @@ -213,7 +218,7 @@ func NewLegacyContentSubmitUpgradeCmd() *cobra.Command { return err } - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } diff --git a/x/opchild/client/cli/query.go b/x/opchild/client/cli/query.go index 6cd2c9f4..30f3885e 100644 --- a/x/opchild/client/cli/query.go +++ b/x/opchild/client/cli/query.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "cosmossdk.io/core/address" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" @@ -14,7 +15,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd() *cobra.Command { +func GetQueryCmd(vc address.Codec) *cobra.Command { opchildQueryCmd := &cobra.Command{ Use: types.ModuleName, Short: "Querying commands for the opchild module", @@ -24,7 +25,7 @@ func GetQueryCmd() *cobra.Command { } opchildQueryCmd.AddCommand( - GetCmdQueryValidator(), + GetCmdQueryValidator(vc), GetCmdQueryValidators(), GetCmdQueryParams(), ) @@ -33,7 +34,7 @@ func GetQueryCmd() *cobra.Command { } // GetCmdQueryValidator implements the validator query command. -func GetCmdQueryValidator() *cobra.Command { +func GetCmdQueryValidator(vc address.Codec) *cobra.Command { bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() cmd := &cobra.Command{ @@ -56,12 +57,12 @@ $ %s query opchild validator %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj } queryClient := types.NewQueryClient(clientCtx) - addr, err := sdk.ValAddressFromBech32(args[0]) + _, err = vc.StringToBytes(args[0]) if err != nil { return err } - params := &types.QueryValidatorRequest{ValidatorAddr: addr.String()} + params := &types.QueryValidatorRequest{ValidatorAddr: args[0]} res, err := queryClient.Validator(cmd.Context(), params) if err != nil { return err diff --git a/x/opchild/client/cli/query_test.go b/x/opchild/client/cli/query_test.go index 418ee219..68ed1a58 100644 --- a/x/opchild/client/cli/query_test.go +++ b/x/opchild/client/cli/query_test.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/client/flags" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/initia-labs/OPinit/x/opchild/client/cli" @@ -30,13 +31,15 @@ func (s *CLITestSuite) TestGetCmdQueryValidator() { for _, tc := range testCases { tc := tc s.Run(tc.name, func() { - cmd := cli.GetCmdQueryValidator() + cmd := cli.GetCmdQueryValidator(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix())) clientCtx := s.clientCtx out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) if tc.expectErr { s.Require().Error(err) s.Require().NotEqual("internal", err.Error()) } else { + s.Require().NoError(err) + var result types.Validator s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) } diff --git a/x/opchild/client/cli/tx.go b/x/opchild/client/cli/tx.go index 6c6049b0..9797051b 100644 --- a/x/opchild/client/cli/tx.go +++ b/x/opchild/client/cli/tx.go @@ -5,6 +5,7 @@ import ( "strconv" "strings" + "cosmossdk.io/core/address" "github.com/spf13/cobra" flag "github.com/spf13/pflag" @@ -17,7 +18,7 @@ import ( ) // GetTxCmd returns a root CLI command handler for all x/opchild transaction commands. -func GetTxCmd() *cobra.Command { +func GetTxCmd(ac address.Codec) *cobra.Command { opchildTxCmd := &cobra.Command{ Use: types.ModuleName, Short: "OPChild transaction subcommands", @@ -27,19 +28,19 @@ func GetTxCmd() *cobra.Command { } opchildTxCmd.AddCommand( - NewExecuteMessagesCmd(), - NewDepositCmd(), - NewWithdrawCmd(), - NewLegacyContentParamChangeTxCmd(), - NewLegacyContentSubmitUpdateClientCmd(), - NewLegacyContentSubmitUpgradeCmd(), + NewExecuteMessagesCmd(ac), + NewDepositCmd(ac), + NewWithdrawCmd(ac), + NewLegacyContentParamChangeTxCmd(ac), + NewLegacyContentSubmitUpdateClientCmd(ac), + NewLegacyContentSubmitUpgradeCmd(ac), ) return opchildTxCmd } // NewDepositCmd returns a CLI command handler for the transaction sending a deposit to an user account. -func NewDepositCmd() *cobra.Command { +func NewDepositCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "deposit [sequence] [from_l1] [to_l2] [amount]", Args: cobra.ExactArgs(4), @@ -60,11 +61,11 @@ func NewDepositCmd() *cobra.Command { return err } - from, err := sdk.AccAddressFromBech32(args[1]) + from, err := ac.StringToBytes(args[1]) if err != nil { return err } - to, err := sdk.AccAddressFromBech32(args[2]) + to, err := ac.StringToBytes(args[2]) if err != nil { return err } @@ -79,7 +80,7 @@ func NewDepositCmd() *cobra.Command { return err } - txf, msg, err := newBuildDepositMsg(clientCtx, txf, cmd.Flags(), sequence, from, to, amount, []byte(hookMsg)) + txf, msg, err := newBuildDepositMsg(clientCtx, ac, txf, cmd.Flags(), sequence, from, to, amount, []byte(hookMsg)) if err != nil { return err } @@ -95,7 +96,7 @@ func NewDepositCmd() *cobra.Command { } // NewWithdrawCmd returns a CLI command handler for the transaction sending a deposit to an user account. -func NewWithdrawCmd() *cobra.Command { +func NewWithdrawCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "withdraw [to_l1] [amount]", Short: "withdraw a token from L2 to L1", @@ -111,7 +112,7 @@ func NewWithdrawCmd() *cobra.Command { return err } - to, err := sdk.AccAddressFromBech32(args[0]) + to, err := ac.StringToBytes(args[0]) if err != nil { return err } @@ -120,7 +121,7 @@ func NewWithdrawCmd() *cobra.Command { return err } - txf, msg, err := newBuildWithdrawMsg(clientCtx, txf, cmd.Flags(), to, amount) + txf, msg, err := newBuildWithdrawMsg(clientCtx, ac, txf, cmd.Flags(), to, amount) if err != nil { return err } @@ -135,7 +136,7 @@ func NewWithdrawCmd() *cobra.Command { } // NewExecuteMessagesCmd returns a CLI command handler for transaction to administrating the system. -func NewExecuteMessagesCmd() *cobra.Command { +func NewExecuteMessagesCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "execute-messages [path/to/messages.json]", Short: "send a system administrating tx", @@ -181,6 +182,10 @@ Where proposal.json contains: return fmt.Errorf("invalid message: %w", err) } + if err := msg.Validate(ac); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } @@ -190,24 +195,24 @@ Where proposal.json contains: return cmd } -func newBuildWithdrawMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet, to sdk.AccAddress, amount sdk.Coin) (tx.Factory, *types.MsgInitiateTokenWithdrawal, error) { +func newBuildWithdrawMsg(clientCtx client.Context, ac address.Codec, txf tx.Factory, fs *flag.FlagSet, to sdk.AccAddress, amount sdk.Coin) (tx.Factory, *types.MsgInitiateTokenWithdrawal, error) { sender := clientCtx.GetFromAddress() msg := types.NewMsgInitiateTokenWithdrawal(sender, to, amount) - if err := msg.ValidateBasic(); err != nil { + if err := msg.Validate(ac); err != nil { return txf, nil, err } return txf, msg, nil } -func newBuildDepositMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet, +func newBuildDepositMsg(clientCtx client.Context, ac address.Codec, txf tx.Factory, fs *flag.FlagSet, sequence uint64, from, to sdk.AccAddress, amount sdk.Coin, hookMsg []byte, ) (tx.Factory, *types.MsgFinalizeTokenDeposit, error) { sender := clientCtx.GetFromAddress() msg := types.NewMsgFinalizeTokenDeposit(sender, from, to, amount, sequence, hookMsg) - if err := msg.ValidateBasic(); err != nil { + if err := msg.Validate(ac); err != nil { return txf, nil, err } diff --git a/x/opchild/client/cli/tx_test.go b/x/opchild/client/cli/tx_test.go index 0cc1da65..afa3036b 100644 --- a/x/opchild/client/cli/tx_test.go +++ b/x/opchild/client/cli/tx_test.go @@ -7,6 +7,8 @@ import ( "io" "testing" + "cosmossdk.io/core/address" + "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" "github.com/cosmos/gogoproto/proto" @@ -14,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -34,6 +37,7 @@ var PKs = simtestutil.CreateTestPubKeys(500) type CLITestSuite struct { suite.Suite + ac address.Codec kr keyring.Keyring encCfg testutilmod.TestEncodingConfig baseCtx client.Context @@ -42,13 +46,16 @@ type CLITestSuite struct { } func (s *CLITestSuite) SetupSuite() { + config := sdk.GetConfig() + config.SetBech32PrefixForAccount("init", "initpub") + s.ac = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) s.encCfg = testutilmod.MakeTestEncodingConfig(opchild.AppModuleBasic{}, bank.AppModuleBasic{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). WithTxConfig(s.encCfg.TxConfig). WithCodec(s.encCfg.Codec). - WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithClient(clitestutil.MockCometRPC{Client: rpcclientmock.Client{}}). WithAccountRetriever(client.MockAccountRetriever{}). WithOutput(io.Discard). WithChainID("test-chain") @@ -56,7 +63,7 @@ func (s *CLITestSuite) SetupSuite() { var outBuf bytes.Buffer ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ Value: bz, }) return s.baseCtx.WithClient(c) @@ -78,7 +85,7 @@ func (s *CLITestSuite) SetupSuite() { func (s *CLITestSuite) TestNewWithdrawCmd() { require := s.Require() - cmd := cli.NewWithdrawCmd() + cmd := cli.NewWithdrawCmd(addresscodec.NewBech32Codec("init")) consPrivKey := ed25519.GenPrivKey() consPubKeyBz, err := s.encCfg.Codec.MarshalInterfaceJSON(consPrivKey.PubKey()) @@ -100,7 +107,7 @@ func (s *CLITestSuite) TestNewWithdrawCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -112,7 +119,7 @@ func (s *CLITestSuite) TestNewWithdrawCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -139,7 +146,7 @@ func (s *CLITestSuite) TestNewWithdrawCmd() { func (s *CLITestSuite) TestNewDepositCmd() { require := s.Require() - cmd := cli.NewDepositCmd() + cmd := cli.NewDepositCmd(addresscodec.NewBech32Codec("init")) consPrivKey := ed25519.GenPrivKey() consPubKeyBz, err := s.encCfg.Codec.MarshalInterfaceJSON(consPrivKey.PubKey()) @@ -168,7 +175,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -182,7 +189,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -196,7 +203,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -210,7 +217,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -224,7 +231,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -239,7 +246,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -254,7 +261,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -281,7 +288,7 @@ func (s *CLITestSuite) TestNewDepositCmd() { func (s *CLITestSuite) TestNewExecuteMessagesCmd() { require := s.Require() - cmd := cli.NewExecuteMessagesCmd() + cmd := cli.NewExecuteMessagesCmd(addresscodec.NewBech32Codec("init")) consPrivKey := ed25519.GenPrivKey() consPubKeyBz, err := s.encCfg.Codec.MarshalInterfaceJSON(consPrivKey.PubKey()) @@ -306,8 +313,8 @@ func (s *CLITestSuite) TestNewExecuteMessagesCmd() { validMessages := `{"messages": [ { "@type": "/cosmos.bank.v1beta1.MsgSend", - "from_address": "cosmos12jea62yu8tmhzy7zage0fngyjvsskfygm99h6h", - "to_address": "cosmos15hqqzhye49577x45ekz24jhesvc442zzndx9my", + "from_address": "init12jea62yu8tmhzy7zage0fngyjvsskfyg4n9y34", + "to_address": "init15hqqzhye49577x45ekz24jhesvc442zzamxksx", "amount":[{"denom": "umin","amount": "10"}] } ]}` @@ -328,7 +335,7 @@ func (s *CLITestSuite) TestNewExecuteMessagesCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -339,7 +346,7 @@ func (s *CLITestSuite) TestNewExecuteMessagesCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -350,7 +357,7 @@ func (s *CLITestSuite) TestNewExecuteMessagesCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/opchild/genesis.go b/x/opchild/genesis.go index 5ab2392f..66049892 100644 --- a/x/opchild/genesis.go +++ b/x/opchild/genesis.go @@ -1,6 +1,8 @@ package opchild import ( + "context" + tmtypes "github.com/cometbft/cometbft/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -10,17 +12,15 @@ import ( ) // WriteValidators returns a slice of bonded genesis validators. -func WriteValidators(ctx sdk.Context, keeper *keeper.Keeper) (vals []tmtypes.GenesisValidator, returnErr error) { - keeper.IterateLastValidators(ctx, func(_ int64, validator types.ValidatorI) (stop bool) { +func WriteValidators(ctx context.Context, keeper *keeper.Keeper) (vals []tmtypes.GenesisValidator, err error) { + err = keeper.IterateLastValidators(ctx, func(validator types.ValidatorI, power int64) (stop bool, err error) { pk, err := validator.ConsPubKey() if err != nil { - returnErr = err - return true + return true, err } tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) if err != nil { - returnErr = err - return true + return true, err } vals = append(vals, tmtypes.GenesisValidator{ @@ -30,7 +30,7 @@ func WriteValidators(ctx sdk.Context, keeper *keeper.Keeper) (vals []tmtypes.Gen Name: validator.GetMoniker(), }) - return false + return false, nil }) return diff --git a/x/opchild/keeper/alias_functions.go b/x/opchild/keeper/alias_functions.go index a73f0722..27aaed44 100644 --- a/x/opchild/keeper/alias_functions.go +++ b/x/opchild/keeper/alias_functions.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,50 +11,26 @@ import ( // Validator Set // iterate through the validator set and perform the provided function -func (k Keeper) IterateValidators(ctx sdk.Context, fn func(index int64, validator types.ValidatorI) (stop bool)) { - store := ctx.KVStore(k.storeKey) - - iterator := sdk.KVStorePrefixIterator(store, types.ValidatorsKey) - defer iterator.Close() - - i := int64(0) - - for ; iterator.Valid(); iterator.Next() { - validator := types.MustUnmarshalValidator(k.cdc, iterator.Value()) - stop := fn(i, validator) // XXX is this safe will the validator unexposed fields be able to get written to? - - if stop { - break - } - i++ - } +func (k Keeper) IterateValidators(ctx context.Context, fn func(validator types.ValidatorI) (stop bool, err error)) error { + return k.Validators.Walk(ctx, nil, func(_ []byte, validator types.Validator) (stop bool, err error) { + return fn(validator) + }) } // iterate through the active validator set and perform the provided function -func (k Keeper) IterateLastValidators(ctx sdk.Context, fn func(index int64, validator types.ValidatorI) (stop bool)) { - iterator := k.LastValidatorsIterator(ctx) - defer iterator.Close() - - i := int64(0) - - for ; iterator.Valid(); iterator.Next() { - address := types.AddressFromLastValidatorPowerKey(iterator.Key()) - - validator, found := k.GetValidator(ctx, address) +func (k Keeper) IterateLastValidators(ctx context.Context, fn func(validator types.ValidatorI, power int64) (stop bool, err error)) error { + return k.IterateLastValidatorPowers(ctx, func(operator []byte, power int64) (stop bool, err error) { + validator, found := k.GetValidator(ctx, operator) if !found { - panic(fmt.Sprintf("validator record not found for address: %v\n", address)) + return true, fmt.Errorf("validator record not found for address: %v", sdk.ValAddress(operator)) } - stop := fn(i, validator) // XXX is this safe will the validator unexposed fields be able to get written to? - if stop { - break - } - i++ - } + return fn(validator, power) + }) } // Validator gets the Validator interface for a particular address -func (k Keeper) Validator(ctx sdk.Context, address sdk.ValAddress) types.ValidatorI { +func (k Keeper) Validator(ctx context.Context, address sdk.ValAddress) types.ValidatorI { val, found := k.GetValidator(ctx, address) if !found { return nil @@ -63,7 +40,7 @@ func (k Keeper) Validator(ctx sdk.Context, address sdk.ValAddress) types.Validat } // ValidatorByConsAddr gets the validator interface for a particular pubkey -func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) types.ValidatorI { +func (k Keeper) ValidatorByConsAddr(ctx context.Context, addr sdk.ConsAddress) types.ValidatorI { val, found := k.GetValidatorByConsAddr(ctx, addr) if !found { return nil diff --git a/x/opchild/keeper/common_test.go b/x/opchild/keeper/common_test.go index 07617100..9dba8569 100644 --- a/x/opchild/keeper/common_test.go +++ b/x/opchild/keeper/common_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "context" "encoding/binary" "fmt" "testing" @@ -8,36 +9,43 @@ import ( "github.com/stretchr/testify/require" - dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cometbft/cometbft/crypto/secp256k1" - "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" errors "cosmossdk.io/errors" + "cosmossdk.io/log" + "cosmossdk.io/math" + "cosmossdk.io/store" + "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/tx/signing" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + codecaddress "github.com/cosmos/cosmos-sdk/codec/address" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/std" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - testutilsims "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/gogoproto/proto" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" opchild "github.com/initia-labs/OPinit/x/opchild" opchildkeeper "github.com/initia-labs/OPinit/x/opchild/keeper" @@ -53,8 +61,6 @@ var ModuleBasics = module.NewBasicManager( ) var ( - valPubKeys = testutilsims.CreateTestPubKeys(5) - pubKeys = []crypto.PubKey{ secp256k1.GenPrivKey().PubKey(), secp256k1.GenPrivKey().PubKey(), @@ -87,7 +93,7 @@ var ( "test5", } - initiaSupply = sdk.NewInt(100_000_000_000) + initiaSupply = math.NewInt(100_000_000_000) ) type EncodingConfig struct { @@ -102,15 +108,21 @@ func MakeTestCodec(t testing.TB) codec.Codec { } func MakeEncodingConfig(_ testing.TB) EncodingConfig { - amino := codec.NewLegacyAmino() - interfaceRegistry := codectypes.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) - txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) + interfaceRegistry, _ := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + }, + }) + appCodec := codec.NewProtoCodec(interfaceRegistry) + legacyAmino := codec.NewLegacyAmino() + txConfig := tx.NewTxConfig(appCodec, tx.DefaultSignModes) std.RegisterInterfaces(interfaceRegistry) - std.RegisterLegacyAminoCodec(amino) + std.RegisterLegacyAminoCodec(legacyAmino) - ModuleBasics.RegisterLegacyAminoCodec(amino) + ModuleBasics.RegisterLegacyAminoCodec(legacyAmino) ModuleBasics.RegisterInterfaces(interfaceRegistry) interfaceRegistry.RegisterImplementations( @@ -120,9 +132,9 @@ func MakeEncodingConfig(_ testing.TB) EncodingConfig { return EncodingConfig{ InterfaceRegistry: interfaceRegistry, - Marshaler: marshaler, - TxConfig: txCfg, - Amino: amino, + Marshaler: appCodec, + TxConfig: txConfig, + Amino: legacyAmino, } } @@ -143,7 +155,7 @@ type TestFaucet struct { minterModuleName string } -func NewTestFaucet(t testing.TB, ctx sdk.Context, bankKeeper bankkeeper.Keeper, minterModuleName string, initiaSupply ...sdk.Coin) *TestFaucet { +func NewTestFaucet(t testing.TB, ctx context.Context, bankKeeper bankkeeper.Keeper, minterModuleName string, initiaSupply ...sdk.Coin) *TestFaucet { require.NotEmpty(t, initiaSupply) r := &TestFaucet{t: t, bankKeeper: bankKeeper, minterModuleName: minterModuleName} _, _, addr := keyPubAddr() @@ -153,10 +165,10 @@ func NewTestFaucet(t testing.TB, ctx sdk.Context, bankKeeper bankkeeper.Keeper, return r } -func (f *TestFaucet) Mint(parentCtx sdk.Context, addr sdk.AccAddress, amounts ...sdk.Coin) { +func (f *TestFaucet) Mint(parentCtx context.Context, addr sdk.AccAddress, amounts ...sdk.Coin) { amounts = sdk.Coins(amounts).Sort() require.NotEmpty(f.t, amounts) - ctx := parentCtx.WithEventManager(sdk.NewEventManager()) // discard all faucet related events + ctx := sdk.UnwrapSDKContext(parentCtx).WithEventManager(sdk.NewEventManager()) // discard all faucet related events err := f.bankKeeper.MintCoins(ctx, f.minterModuleName, amounts) require.NoError(f.t, err) err = f.bankKeeper.SendCoinsFromModuleToAccount(ctx, f.minterModuleName, addr, amounts) @@ -164,19 +176,19 @@ func (f *TestFaucet) Mint(parentCtx sdk.Context, addr sdk.AccAddress, amounts .. f.balance = f.balance.Add(amounts...) } -func (f *TestFaucet) Fund(parentCtx sdk.Context, receiver sdk.AccAddress, amounts ...sdk.Coin) { +func (f *TestFaucet) Fund(parentCtx context.Context, receiver sdk.AccAddress, amounts ...sdk.Coin) { require.NotEmpty(f.t, amounts) // ensure faucet is always filled if !f.balance.IsAllGTE(amounts) { f.Mint(parentCtx, f.sender, amounts...) } - ctx := parentCtx.WithEventManager(sdk.NewEventManager()) // discard all faucet related events + ctx := sdk.UnwrapSDKContext(parentCtx).WithEventManager(sdk.NewEventManager()) // discard all faucet related events err := f.bankKeeper.SendCoins(ctx, f.sender, receiver, amounts) require.NoError(f.t, err) f.balance = f.balance.Sub(amounts...) } -func (f *TestFaucet) NewFundedAccount(ctx sdk.Context, amounts ...sdk.Coin) sdk.AccAddress { +func (f *TestFaucet) NewFundedAccount(ctx context.Context, amounts ...sdk.Coin) sdk.AccAddress { _, _, addr := keyPubAddr() f.Fund(ctx, addr, amounts...) return addr @@ -189,16 +201,15 @@ type TestKeepers struct { BridgeHook *bridgeHook EncodingConfig EncodingConfig Faucet *TestFaucet - MultiStore sdk.CommitMultiStore } // createDefaultTestInput common settings for createTestInput -func createDefaultTestInput(t testing.TB) (sdk.Context, TestKeepers) { +func createDefaultTestInput(t testing.TB) (context.Context, TestKeepers) { return createTestInput(t, false) } // createTestInput encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default) -func createTestInput(t testing.TB, isCheckTx bool) (sdk.Context, TestKeepers) { +func createTestInput(t testing.TB, isCheckTx bool) (context.Context, TestKeepers) { return _createTestInput(t, isCheckTx, dbm.NewMemDB()) } @@ -222,15 +233,15 @@ func _createTestInput( t testing.TB, isCheckTx bool, db dbm.DB, -) (sdk.Context, TestKeepers) { - keys := sdk.NewKVStoreKeys( +) (context.Context, TestKeepers) { + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, opchildtypes.StoreKey, ) - ms := store.NewCommitMultiStore(db) + ms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) for _, v := range keys { ms.MountStoreWithDB(v, storetypes.StoreTypeIAVL, db) } - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) for _, v := range memKeys { ms.MountStoreWithDB(v, storetypes.StoreTypeMemory, db) } @@ -257,9 +268,10 @@ func _createTestInput( } accountKeeper := authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], // target store - authtypes.ProtoBaseAccount, // prototype + runtime.NewKVStoreService(keys[authtypes.StoreKey]), // target store + authtypes.ProtoBaseAccount, // prototype maccPerms, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.GetConfig().GetBech32AccountAddrPrefix(), authtypes.NewModuleAddress(opchildtypes.ModuleName).String(), ) @@ -270,10 +282,11 @@ func _createTestInput( bankKeeper := bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), accountKeeper, blockedAddrs, authtypes.NewModuleAddress(opchildtypes.ModuleName).String(), + ctx.Logger(), ) bankKeeper.SetParams(ctx, banktypes.DefaultParams()) @@ -283,12 +296,14 @@ func _createTestInput( bridgeHook := &bridgeHook{} opchildKeeper := opchildkeeper.NewKeeper( appCodec, - keys[opchildtypes.StoreKey], + runtime.NewKVStoreService(keys[opchildtypes.StoreKey]), accountKeeper, bankKeeper, bridgeHook.Hook, msgRouter, authtypes.NewModuleAddress(opchildtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) // set test legacy content handler @@ -301,18 +316,17 @@ func _createTestInput( opchildKeeper.SetParams(ctx, opchildParams) // register handlers to msg router - opchildtypes.RegisterMsgServer(msgRouter, opchildkeeper.NewMsgServerImpl(opchildKeeper)) + opchildtypes.RegisterMsgServer(msgRouter, opchildkeeper.NewMsgServerImpl(*opchildKeeper)) faucet := NewTestFaucet(t, ctx, bankKeeper, authtypes.Minter, initialTotalSupply()...) keepers := TestKeepers{ AccountKeeper: accountKeeper, BankKeeper: bankKeeper, - OPChildKeeper: opchildKeeper, + OPChildKeeper: *opchildKeeper, BridgeHook: bridgeHook, EncodingConfig: encodingConfig, Faucet: faucet, - MultiStore: ms, } return ctx, keepers } @@ -369,7 +383,7 @@ type bridgeHook struct { err error } -func (h *bridgeHook) Hook(ctx sdk.Context, sender sdk.AccAddress, msgBytes []byte) error { +func (h *bridgeHook) Hook(ctx context.Context, sender sdk.AccAddress, msgBytes []byte) error { if h.err == nil { h.msgBytes = msgBytes } diff --git a/x/opchild/keeper/compatibility_grpc_query.go b/x/opchild/keeper/compatibility_grpc_query.go index 7b14d242..2f682a79 100644 --- a/x/opchild/keeper/compatibility_grpc_query.go +++ b/x/opchild/keeper/compatibility_grpc_query.go @@ -6,6 +6,7 @@ import ( "context" "time" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" cosmostypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -28,7 +29,10 @@ var _ cosmostypes.QueryServer = CompatibilityQuerier{} // returns a first bond denom. func (q CompatibilityQuerier) Params(c context.Context, _ *cosmostypes.QueryParamsRequest) (*cosmostypes.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) - params := q.GetParams(ctx) + params, err := q.GetParams(ctx) + if err != nil { + return nil, err + } return &cosmostypes.QueryParamsResponse{Params: cosmostypes.Params{ UnbondingTime: unbondingTime, @@ -36,6 +40,7 @@ func (q CompatibilityQuerier) Params(c context.Context, _ *cosmostypes.QueryPara MaxEntries: maxEntries, HistoricalEntries: params.HistoricalEntries, BondDenom: bondDenom, + MinCommissionRate: math.LegacyZeroDec(), }}, nil } diff --git a/x/opchild/keeper/genesis.go b/x/opchild/keeper/genesis.go index a8536d5d..0b2e6017 100644 --- a/x/opchild/keeper/genesis.go +++ b/x/opchild/keeper/genesis.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "fmt" abci "github.com/cometbft/cometbft/abci/types" @@ -14,13 +15,15 @@ import ( // setting the indexes. In addition, it also sets any delegations found in // data. Finally, it updates the bonded validators. // Returns final validator set after applying all declaration and delegations -func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []abci.ValidatorUpdate) { +func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) (res []abci.ValidatorUpdate) { // We need to pretend to be "n blocks before genesis", where "n" is the // validator update delay, so that e.g. slashing periods are correctly // initialized for the validator set e.g. with a one-block offset - the // first TM block is at height 1, so state updates applied from // genesis.json are in block 0. - ctx = ctx.WithBlockHeight(1 - sdk.ValidatorUpdateDelay) + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx = sdkCtx.WithBlockHeight(1 - sdk.ValidatorUpdateDelay) + ctx = sdkCtx if err := k.SetParams(ctx, data.Params); err != nil { panic(err) @@ -38,7 +41,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []ab // don't need to run Tendermint updates if we exported if data.Exported { for _, lv := range data.LastValidatorPowers { - valAddr, err := sdk.ValAddressFromBech32(lv.Address) + valAddr, err := k.validatorAddressCodec.StringToBytes(lv.Address) if err != nil { panic(err) } @@ -75,27 +78,46 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []ab // ExportGenesis returns a GenesisState for a given context and keeper. The // GenesisState will contain the pool, params, validators, and bonds found in // the keeper. -func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - +func (k Keeper) ExportGenesis(ctx context.Context) *types.GenesisState { var lastValidatorPowers []types.LastValidatorPower - - k.IterateLastValidatorPowers(ctx, func(addr sdk.ValAddress, power int64) (stop bool) { - lastValidatorPowers = append(lastValidatorPowers, types.LastValidatorPower{Address: addr.String(), Power: power}) - return false + err := k.IterateLastValidatorPowers(ctx, func(addr []byte, power int64) (stop bool, err error) { + lastValidatorPowers = append(lastValidatorPowers, types.LastValidatorPower{Address: sdk.ValAddress(addr).String(), Power: power}) + return false, nil }) + if err != nil { + panic(err) + } var finalizedL1Sequences []uint64 - k.IterateFinalizedL1Sequences(ctx, func(l1Sequence uint64) bool { + err = k.IterateFinalizedL1Sequences(ctx, func(l1Sequence uint64) (bool, error) { finalizedL1Sequences = append(finalizedL1Sequences, l1Sequence) - return false + return false, nil }) + if err != nil { + panic(err) + } + + params, err := k.GetParams(ctx) + if err != nil { + panic(err) + } + + validators, err := k.GetAllValidators(ctx) + if err != nil { + panic(err) + } + + nextL2Sequence, err := k.GetNextL2Sequence(ctx) + if err != nil { + panic(err) + } return &types.GenesisState{ - Params: k.GetParams(ctx), + Params: params, LastValidatorPowers: lastValidatorPowers, - Validators: k.GetAllValidators(ctx), + Validators: validators, Exported: true, FinalizedL1Sequences: finalizedL1Sequences, - NextL2Sequence: k.GetNextL2Sequence(ctx), + NextL2Sequence: nextL2Sequence, } } diff --git a/x/opchild/keeper/genesis_test.go b/x/opchild/keeper/genesis_test.go index 376a279c..75764516 100644 --- a/x/opchild/keeper/genesis_test.go +++ b/x/opchild/keeper/genesis_test.go @@ -13,9 +13,11 @@ func Test_GenesisImportExport(t *testing.T) { ctx, input := createDefaultTestInput(t) input.OPChildKeeper.SetNextL2Sequence(ctx, 1) - seq := input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + seq, err := input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + require.NoError(t, err) require.Equal(t, uint64(1), seq) - seq = input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + seq, err = input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + require.NoError(t, err) require.Equal(t, uint64(2), seq) input.OPChildKeeper.RecordFinalizedL1Sequence(ctx, 1) diff --git a/x/opchild/keeper/historical_info.go b/x/opchild/keeper/historical_info.go index aadffe94..a1b398bf 100644 --- a/x/opchild/keeper/historical_info.go +++ b/x/opchild/keeper/historical_info.go @@ -1,44 +1,47 @@ package keeper import ( + "context" + "errors" + + "cosmossdk.io/collections" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" cosmostypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // GetHistoricalInfo gets the historical info at a given height -func (k Keeper) GetHistoricalInfo(ctx sdk.Context, height int64) (cosmostypes.HistoricalInfo, bool) { - store := ctx.KVStore(k.storeKey) - key := cosmostypes.GetHistoricalInfoKey(height) +func (k Keeper) GetHistoricalInfo(ctx context.Context, height int64) (*cosmostypes.HistoricalInfo, bool, error) { + historicalInfo, err := k.HistoricalInfos.Get(ctx, height) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + return nil, false, nil + } - value := store.Get(key) - if value == nil { - return cosmostypes.HistoricalInfo{}, false + return nil, false, err } - return cosmostypes.MustUnmarshalHistoricalInfo(k.cdc, value), true + return &historicalInfo, true, nil } // SetHistoricalInfo sets the historical info at a given height -func (k Keeper) SetHistoricalInfo(ctx sdk.Context, height int64, hi *cosmostypes.HistoricalInfo) { - store := ctx.KVStore(k.storeKey) - key := cosmostypes.GetHistoricalInfoKey(height) - value := k.cdc.MustMarshal(hi) - store.Set(key, value) +func (k Keeper) SetHistoricalInfo(ctx context.Context, height int64, hi *cosmostypes.HistoricalInfo) error { + return k.HistoricalInfos.Set(ctx, height, *hi) } // DeleteHistoricalInfo deletes the historical info at a given height -func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64) { - store := ctx.KVStore(k.storeKey) - key := cosmostypes.GetHistoricalInfoKey(height) - - store.Delete(key) +func (k Keeper) DeleteHistoricalInfo(ctx context.Context, height int64) error { + return k.HistoricalInfos.Remove(ctx, height) } // TrackHistoricalInfo saves the latest historical-info and deletes the oldest // heights that are below pruning height -func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { - entryNum := k.HistoricalEntries(ctx) +func (k Keeper) TrackHistoricalInfo(ctx context.Context) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + entryNum, err := k.HistoricalEntries(ctx) + if err != nil { + return err + } // Prune store to ensure we only have parameter-defined historical entries. // In most cases, this will involve removing a single historical entry. @@ -47,9 +50,11 @@ func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { // Since the entries to be deleted are always in a continuous range, we can iterate // over the historical entries starting from the most recent version to be pruned // and then return at the first empty entry. - for i := ctx.BlockHeight() - int64(entryNum); i >= 0; i-- { - _, found := k.GetHistoricalInfo(ctx, i) - if found { + for i := sdkCtx.BlockHeight() - int64(entryNum); i >= 0; i-- { + _, found, err := k.GetHistoricalInfo(ctx, i) + if err != nil { + return err + } else if found { k.DeleteHistoricalInfo(ctx, i) } else { break @@ -58,22 +63,26 @@ func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { // if there is no need to persist historicalInfo, return if entryNum == 0 { - return + return nil } // Create HistoricalInfo struct - lastVals := k.GetLastValidators(ctx) + lastVals, err := k.GetLastValidators(ctx) + if err != nil { + return err + } var lastCosmosVals cosmostypes.Validators for _, v := range lastVals { - lastCosmosVals = append(lastCosmosVals, cosmostypes.Validator{ + lastCosmosVals.Validators = append(lastCosmosVals.Validators, cosmostypes.Validator{ ConsensusPubkey: v.ConsensusPubkey, Tokens: math.NewInt(v.ConsensusPower() * sdk.DefaultPowerReduction.Int64()), Status: cosmostypes.Bonded, }) } + lastCosmosVals.ValidatorCodec = k.validatorAddressCodec - historicalEntry := cosmostypes.NewHistoricalInfo(ctx.BlockHeader(), lastCosmosVals, sdk.DefaultPowerReduction) + historicalEntry := cosmostypes.NewHistoricalInfo(sdkCtx.BlockHeader(), lastCosmosVals, sdk.DefaultPowerReduction) // Set latest HistoricalInfo at current height - k.SetHistoricalInfo(ctx, ctx.BlockHeight(), &historicalEntry) + return k.SetHistoricalInfo(ctx, sdkCtx.BlockHeight(), &historicalEntry) } diff --git a/x/opchild/keeper/historical_info_test.go b/x/opchild/keeper/historical_info_test.go index 62659b5a..77d3e7c5 100644 --- a/x/opchild/keeper/historical_info_test.go +++ b/x/opchild/keeper/historical_info_test.go @@ -5,34 +5,40 @@ import ( "github.com/stretchr/testify/require" + sdk "github.com/cosmos/cosmos-sdk/types" cosmostypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func Test_HistoricalInfo(t *testing.T) { ctx, input := createDefaultTestInput(t) + sdkCtx := sdk.UnwrapSDKContext(ctx) - params := input.OPChildKeeper.GetParams(ctx) + params, err := input.OPChildKeeper.GetParams(ctx) + require.NoError(t, err) params.HistoricalEntries = 2 input.OPChildKeeper.SetParams(ctx, params) - input.OPChildKeeper.TrackHistoricalInfo(ctx.WithBlockHeight(1)) - input.OPChildKeeper.TrackHistoricalInfo(ctx.WithBlockHeight(2)) - input.OPChildKeeper.TrackHistoricalInfo(ctx.WithBlockHeight(3)) + input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(1)) + input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(2)) + input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(3)) - _, found := input.OPChildKeeper.GetHistoricalInfo(ctx, 1) + _, found, err := input.OPChildKeeper.GetHistoricalInfo(ctx, 1) + require.NoError(t, err) require.False(t, found) - historicalInfo, found := input.OPChildKeeper.GetHistoricalInfo(ctx, 2) + historicalInfo, found, err := input.OPChildKeeper.GetHistoricalInfo(ctx, 2) + require.NoError(t, err) require.True(t, found) require.Equal(t, cosmostypes.HistoricalInfo{ - Header: ctx.WithBlockHeight(2).BlockHeader(), + Header: sdkCtx.WithBlockHeight(2).BlockHeader(), Valset: nil, - }, historicalInfo) + }, *historicalInfo) - historicalInfo, found = input.OPChildKeeper.GetHistoricalInfo(ctx, 3) + historicalInfo, found, err = input.OPChildKeeper.GetHistoricalInfo(ctx, 3) + require.NoError(t, err) require.True(t, found) require.Equal(t, cosmostypes.HistoricalInfo{ - Header: ctx.WithBlockHeight(3).BlockHeader(), + Header: sdkCtx.WithBlockHeight(3).BlockHeader(), Valset: nil, - }, historicalInfo) + }, *historicalInfo) } diff --git a/x/opchild/keeper/keeper.go b/x/opchild/keeper/keeper.go index fc600036..8e0b604a 100644 --- a/x/opchild/keeper/keeper.go +++ b/x/opchild/keeper/keeper.go @@ -1,20 +1,27 @@ package keeper import ( - "github.com/cometbft/cometbft/libs/log" + "context" + "fmt" + + "cosmossdk.io/collections" + "cosmossdk.io/core/address" + corestoretypes "cosmossdk.io/core/store" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + cosmostypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/initia-labs/OPinit/x/opchild/types" ) type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey + cdc codec.Codec + storeService corestoretypes.KVStoreService + authKeeper types.AccountKeeper bankKeeper types.BankKeeper bridgeHook types.BridgeHook @@ -28,31 +35,69 @@ type Keeper struct { // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/opchild module account. authority string + + validatorAddressCodec address.Codec + consensusAddressCodec address.Codec + + Schema collections.Schema + NextL2Sequence collections.Item[uint64] + Params collections.Item[types.Params] + FinalizedL1Sequence collections.Map[uint64, bool] + LastValidatorPowers collections.Map[[]byte, int64] + Validators collections.Map[[]byte, types.Validator] + ValidatorsByConsAddr collections.Map[[]byte, []byte] + HistoricalInfos collections.Map[int64, cosmostypes.HistoricalInfo] } func NewKeeper( - cdc codec.BinaryCodec, - key storetypes.StoreKey, + cdc codec.Codec, + storeService corestoretypes.KVStoreService, ak types.AccountKeeper, bk types.BankKeeper, bh types.BridgeHook, router *baseapp.MsgServiceRouter, authority string, -) Keeper { + validatorAddressCodec address.Codec, + consensusAddressCodec address.Codec, +) *Keeper { + + if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } + // ensure that authority is a valid AccAddress - if _, err := sdk.AccAddressFromBech32(authority); err != nil { + if _, err := ak.AddressCodec().StringToBytes(authority); err != nil { panic("authority is not a valid acc address") } - return Keeper{ - cdc: cdc, - storeKey: key, - authKeeper: ak, - bankKeeper: bk, - bridgeHook: bh, - router: router, - authority: authority, + sb := collections.NewSchemaBuilder(storeService) + + k := &Keeper{ + cdc: cdc, + storeService: storeService, + authKeeper: ak, + bankKeeper: bk, + bridgeHook: bh, + router: router, + authority: authority, + validatorAddressCodec: validatorAddressCodec, + consensusAddressCodec: consensusAddressCodec, + NextL2Sequence: collections.NewItem(sb, types.NextL2SequenceKey, "next_l2_sequence", collections.Uint64Value), + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + FinalizedL1Sequence: collections.NewMap(sb, types.FinalizedL1SequenceKey, "finalized_l1_sequence", collections.Uint64Key, collections.BoolValue), + LastValidatorPowers: collections.NewMap(sb, types.LastValidatorPowerPrefix, "last_validator_powers", collections.BytesKey, collections.Int64Value), + Validators: collections.NewMap(sb, types.ValidatorsPrefix, "validators", collections.BytesKey, codec.CollValue[types.Validator](cdc)), + ValidatorsByConsAddr: collections.NewMap(sb, types.ValidatorsByConsAddrPrefix, "validators_by_cons_addr", collections.BytesKey, collections.BytesValue), + HistoricalInfos: collections.NewMap(sb, types.HistoricalInfoPrefix, "historical_infos", collections.Int64Key, codec.CollValue[cosmostypes.HistoricalInfo](cdc)), } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + + return k } // GetAuthority returns the x/move module's authority. @@ -61,8 +106,9 @@ func (ak Keeper) GetAuthority() string { } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) +func (k Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", "x/"+types.ModuleName) } // Router returns the gov keeper's router diff --git a/x/opchild/keeper/msg_server.go b/x/opchild/keeper/msg_server.go index b0c614fe..bf28f828 100644 --- a/x/opchild/keeper/msg_server.go +++ b/x/opchild/keeper/msg_server.go @@ -1,6 +1,7 @@ package keeper import ( + "bytes" "context" "strconv" @@ -14,12 +15,6 @@ import ( "github.com/initia-labs/OPinit/x/opchild/types" ) -const ( - bridgeModuleName = "op_bridge" - bridgeFinalizeFunctionName = "finalize_token_bridge" - bridgeRegisterFunctionName = "register_token" -) - type MsgServer struct { Keeper } @@ -32,8 +27,8 @@ func NewMsgServerImpl(k Keeper) MsgServer { } // checkValidatorPermission checks if the sender is the one of validator -func (ms MsgServer) checkValidatorPermission(ctx sdk.Context, sender string) error { - addr, err := sdk.AccAddressFromBech32(sender) +func (ms MsgServer) checkValidatorPermission(ctx context.Context, sender string) error { + addr, err := ms.authKeeper.AddressCodec().StringToBytes(sender) if err != nil { return err } @@ -47,14 +42,18 @@ func (ms MsgServer) checkValidatorPermission(ctx sdk.Context, sender string) err } // checkBridgeExecutorPermission checks if the sender is the registered bridge executor to send messages -func (ms MsgServer) checkBridgeExecutorPermission(ctx sdk.Context, sender string) error { - senderAddr, err := sdk.AccAddressFromBech32(sender) +func (ms MsgServer) checkBridgeExecutorPermission(ctx context.Context, sender string) error { + senderAddr, err := ms.authKeeper.AddressCodec().StringToBytes(sender) if err != nil { return err } - bridgeExecutor := ms.BridgeExecutor(ctx) - if !bridgeExecutor.Equals(senderAddr) { + bridgeExecutor, err := ms.BridgeExecutor(ctx) + if err != nil { + return err + } + + if !bridgeExecutor.Equals(sdk.AccAddress(senderAddr)) { return errors.Wrapf(sdkerrors.ErrUnauthorized, "expected %s, got %s", bridgeExecutor, sender) } return nil @@ -64,33 +63,57 @@ func (ms MsgServer) checkBridgeExecutorPermission(ctx sdk.Context, sender string // The messages for Validator // ExecuteMessages implements a ExecuteMessages message handling -func (ms MsgServer) ExecuteMessages(context context.Context, req *types.MsgExecuteMessages) (*types.MsgExecuteMessagesResponse, error) { - ctx := sdk.UnwrapSDKContext(context) - authority := sdk.MustAccAddressFromBech32(ms.authority) +func (ms MsgServer) ExecuteMessages(ctx context.Context, req *types.MsgExecuteMessages) (*types.MsgExecuteMessagesResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } // permission check if err := ms.checkValidatorPermission(ctx, req.Sender); err != nil { return nil, err } - cachtCtx, writeCache := ctx.CacheContext() + sdkCtx := sdk.UnwrapSDKContext(ctx) + cacheCtx, writeCache := sdkCtx.CacheContext() messages, err := req.GetMsgs() if err != nil { return nil, err } + authority, err := ms.authKeeper.AddressCodec().StringToBytes(ms.authority) + if err != nil { + return nil, err + } + events := sdk.EmptyEvents() for _, msg := range messages { - signers := msg.GetSigners() - // assert that the rollup module account is the only signer for ExecuteMessages message - if !signers[0].Equals(authority) { - return nil, errors.Wrapf(types.ErrInvalidSigner, signers[0].String()) + // perform a basic validation of the message + if m, ok := msg.(sdk.HasValidateBasic); ok { + if err := m.ValidateBasic(); err != nil { + return nil, errors.Wrap(types.ErrInvalidExecuteMsg, err.Error()) + } + } + + signers, _, err := ms.cdc.GetMsgV1Signers(msg) + if err != nil { + return nil, err + } + if len(signers) != 1 { + return nil, types.ErrInvalidSigner + } + + // assert that the opchild module account is the only signer for ExecuteMessages message + if !bytes.Equal(signers[0], authority) { + return nil, errors.Wrapf(types.ErrInvalidSigner, sdk.AccAddress(signers[0]).String()) } handler := ms.Router().Handler(msg) + if handler == nil { + return nil, errors.Wrap(types.ErrUnroutableExecuteMsg, sdk.MsgTypeURL(msg)) + } var res *sdk.Result - res, err = handler(cachtCtx, msg) + res, err = handler(cacheCtx, msg) if err != nil { break } @@ -104,14 +127,23 @@ func (ms MsgServer) ExecuteMessages(context context.Context, req *types.MsgExecu writeCache() // TODO - merge events of MsgExecuteMessages itself - ctx.EventManager().EmitEvents(events) + sdkCtx.EventManager().EmitEvents(events) return &types.MsgExecuteMessagesResponse{}, nil } // ExecuteLegacyContents implements a ExecuteLegacyContents message handling -func (ms MsgServer) ExecuteLegacyContents(context context.Context, req *types.MsgExecuteLegacyContents) (*types.MsgExecuteLegacyContentsResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) ExecuteLegacyContents(ctx context.Context, req *types.MsgExecuteLegacyContents) (*types.MsgExecuteLegacyContentsResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } + + // permission check + if err := ms.checkValidatorPermission(ctx, req.Sender); err != nil { + return nil, err + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) for _, content := range req.GetContents() { // Ensure that the content has a respective handler if !ms.Keeper.legacyRouter.HasRoute(content.ProposalRoute()) { @@ -119,7 +151,7 @@ func (ms MsgServer) ExecuteLegacyContents(context context.Context, req *types.Ms } handler := ms.Keeper.legacyRouter.GetRoute(content.ProposalRoute()) - if err := handler(ctx, content); err != nil { + if err := handler(sdkCtx, content); err != nil { return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err) } } @@ -131,13 +163,17 @@ func (ms MsgServer) ExecuteLegacyContents(context context.Context, req *types.Ms // Authority messages // AddValidator implements adding a validator to the designated validator set -func (ms MsgServer) AddValidator(context context.Context, req *types.MsgAddValidator) (*types.MsgAddValidatorResponse, error) { +func (ms MsgServer) AddValidator(ctx context.Context, req *types.MsgAddValidator) (*types.MsgAddValidatorResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec(), ms.validatorAddressCodec); err != nil { + return nil, err + } + if ms.authority != req.Authority { return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(context) - valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + sdkCtx := sdk.UnwrapSDKContext(ctx) + valAddr, err := ms.Keeper.validatorAddressCodec.StringToBytes(req.ValidatorAddress) if err != nil { return nil, err } @@ -156,8 +192,8 @@ func (ms MsgServer) AddValidator(context context.Context, req *types.MsgAddValid return nil, types.ErrValidatorPubKeyExists } - cp := ctx.ConsensusParams() - if cp != nil && cp.Validator != nil { + cp := sdkCtx.ConsensusParams() + if cp.Validator != nil { pkType := pk.Type() hasKeyType := false for _, keyType := range cp.Validator.PubKeyTypes { @@ -184,7 +220,7 @@ func (ms MsgServer) AddValidator(context context.Context, req *types.MsgAddValid return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ + sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAddValidator, sdk.NewAttribute(types.AttributeKeyValidator, req.ValidatorAddress), @@ -195,13 +231,17 @@ func (ms MsgServer) AddValidator(context context.Context, req *types.MsgAddValid } // RemoveValidator implements removing a validator from the designated validator set -func (ms MsgServer) RemoveValidator(context context.Context, req *types.MsgRemoveValidator) (*types.MsgRemoveValidatorResponse, error) { +func (ms MsgServer) RemoveValidator(ctx context.Context, req *types.MsgRemoveValidator) (*types.MsgRemoveValidatorResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec(), ms.validatorAddressCodec); err != nil { + return nil, err + } + if ms.authority != req.Authority { return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(context) - valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + sdkCtx := sdk.UnwrapSDKContext(ctx) + valAddr, err := ms.Keeper.validatorAddressCodec.StringToBytes(req.ValidatorAddress) if err != nil { return nil, err } @@ -216,7 +256,7 @@ func (ms MsgServer) RemoveValidator(context context.Context, req *types.MsgRemov // then `val_state_change` will execute `k.RemoveValidator`. ms.Keeper.SetValidator(ctx, val) - ctx.EventManager().EmitEvents(sdk.Events{ + sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRemoveValidator, sdk.NewAttribute(types.AttributeKeyValidator, req.ValidatorAddress), @@ -227,12 +267,15 @@ func (ms MsgServer) RemoveValidator(context context.Context, req *types.MsgRemov } // UpdateParams implements updating the parameters -func (ms MsgServer) UpdateParams(context context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (ms MsgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } + if ms.authority != req.Authority { return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(context) if err := ms.SetParams(ctx, *req.Params); err != nil { return nil, err } @@ -242,13 +285,16 @@ func (ms MsgServer) UpdateParams(context context.Context, req *types.MsgUpdatePa } // SpendFeePool implements MsgServer interface. -func (ms MsgServer) SpendFeePool(context context.Context, req *types.MsgSpendFeePool) (*types.MsgSpendFeePoolResponse, error) { +func (ms MsgServer) SpendFeePool(ctx context.Context, req *types.MsgSpendFeePool) (*types.MsgSpendFeePoolResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } + if ms.authority != req.Authority { return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(context) - recipientAddr, err := sdk.AccAddressFromBech32(req.Recipient) + recipientAddr, err := ms.authKeeper.AddressCodec().StringToBytes(req.Recipient) if err != nil { return nil, err } @@ -265,8 +311,12 @@ func (ms MsgServer) SpendFeePool(context context.Context, req *types.MsgSpendFee // The messages for Bridge Executor // FinalizeTokenDeposit implements send a deposit from the upper layer to the recipient -func (ms MsgServer) FinalizeTokenDeposit(context context.Context, req *types.MsgFinalizeTokenDeposit) (*types.MsgFinalizeTokenDepositResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) FinalizeTokenDeposit(ctx context.Context, req *types.MsgFinalizeTokenDeposit) (*types.MsgFinalizeTokenDepositResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) coin := req.Amount // permission check @@ -275,16 +325,18 @@ func (ms MsgServer) FinalizeTokenDeposit(context context.Context, req *types.Msg } // check already finalized - if ok := ms.HasFinalizedL1Sequence(ctx, req.Sequence); ok { + if ok, err := ms.HasFinalizedL1Sequence(ctx, req.Sequence); err != nil { + return nil, err + } else if ok { return nil, types.ErrDepositAlreadyFinalized } - fromAddr, err := sdk.AccAddressFromBech32(req.From) + fromAddr, err := ms.authKeeper.AddressCodec().StringToBytes(req.From) if err != nil { return nil, err } - toAddr, err := sdk.AccAddressFromBech32(req.To) + toAddr, err := ms.authKeeper.AddressCodec().StringToBytes(req.To) if err != nil { return nil, err } @@ -312,7 +364,7 @@ func (ms MsgServer) FinalizeTokenDeposit(context context.Context, req *types.Msg // handle hook if len(req.Data) > 0 { - subCtx, commit := ctx.CacheContext() + subCtx, commit := sdkCtx.CacheContext() err = ms.bridgeHook(subCtx, fromAddr, req.Data) if err == nil { @@ -322,7 +374,7 @@ func (ms MsgServer) FinalizeTokenDeposit(context context.Context, req *types.Msg event = event.AppendAttributes(sdk.NewAttribute(types.AttributeKeyHookSuccess, "false")) } } - ctx.EventManager().EmitEvent(event) + sdkCtx.EventManager().EmitEvent(event) return &types.MsgFinalizeTokenDepositResponse{}, nil } @@ -331,17 +383,24 @@ func (ms MsgServer) FinalizeTokenDeposit(context context.Context, req *types.Msg // The messages for User // InitiateTokenWithdrawal implements creating a token from the upper layer -func (ms MsgServer) InitiateTokenWithdrawal(context context.Context, req *types.MsgInitiateTokenWithdrawal) (*types.MsgInitiateTokenWithdrawalResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) InitiateTokenWithdrawal(ctx context.Context, req *types.MsgInitiateTokenWithdrawal) (*types.MsgInitiateTokenWithdrawalResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) coin := req.Amount - senderAddr, err := sdk.AccAddressFromBech32(req.Sender) + senderAddr, err := ms.authKeeper.AddressCodec().StringToBytes(req.Sender) if err != nil { return nil, err } coins := sdk.NewCoins(coin) - l2Sequence := ms.IncreaseNextL2Sequence(ctx) + l2Sequence, err := ms.IncreaseNextL2Sequence(ctx) + if err != nil { + return nil, err + } if err := ms.bankKeeper.SendCoinsFromAccountToModule(ctx, senderAddr, types.ModuleName, coins); err != nil { return nil, err } @@ -349,7 +408,7 @@ func (ms MsgServer) InitiateTokenWithdrawal(context context.Context, req *types. return nil, err } - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdkCtx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeInitiateTokenWithdrawal, sdk.NewAttribute(types.AttributeKeyFrom, req.Sender), sdk.NewAttribute(types.AttributeKeyTo, req.To), diff --git a/x/opchild/keeper/msg_server_test.go b/x/opchild/keeper/msg_server_test.go index 62a7d3f4..75d8452b 100644 --- a/x/opchild/keeper/msg_server_test.go +++ b/x/opchild/keeper/msg_server_test.go @@ -46,13 +46,14 @@ func Test_MsgServer_ExecuteMessages(t *testing.T) { msg, err := types.NewMsgExecuteMessages(addrs[0], []sdk.Msg{addMsg, removeMsg}) require.NoError(t, err) - _, err = ms.ExecuteMessages(sdk.WrapSDKContext(ctx), msg) + _, err = ms.ExecuteMessages(ctx, msg) require.NoError(t, err) // apply validator updates input.OPChildKeeper.BlockValidatorUpdates(ctx) - vals := input.OPChildKeeper.GetAllValidators(ctx) + vals, err := input.OPChildKeeper.GetAllValidators(ctx) + require.NoError(t, err) require.Len(t, vals, 1) require.Equal(t, vals[0].Moniker, "val2") } @@ -81,15 +82,22 @@ func Test_MsgServer_ExecuteLegacyContents(t *testing.T) { msg, err := types.NewMsgExecuteLegacyContents(addrs[0], []govv1beta1.Content{&legacyContent}) require.NoError(t, err) - _, err = ms.ExecuteLegacyContents(sdk.WrapSDKContext(ctx), msg) + _, err = ms.ExecuteLegacyContents(ctx, msg) + require.NoError(t, err) + + // unauthorized executor + msg, err = types.NewMsgExecuteLegacyContents(addrs[1], []govv1beta1.Content{&legacyContent}) require.NoError(t, err) + _, err = ms.ExecuteLegacyContents(ctx, msg) + require.Error(t, err) + // legacy content with wrong message legacyContent.Message = "wrong message" msg, err = types.NewMsgExecuteLegacyContents(addrs[0], []govv1beta1.Content{&legacyContent}) require.NoError(t, err) - _, err = ms.ExecuteLegacyContents(sdk.WrapSDKContext(ctx), msg) + _, err = ms.ExecuteLegacyContents(ctx, msg) require.Error(t, err) } @@ -105,40 +113,28 @@ func Test_MsgServer_AddValidator(t *testing.T) { msg, err := types.NewMsgAddValidator("val1", authtypes.NewModuleAddress(types.ModuleName), valAddrs[0], valPubKeys[0]) require.NoError(t, err) - _, err = ms.AddValidator( - sdk.WrapSDKContext(ctx), - msg, - ) + _, err = ms.AddValidator(ctx, msg) require.NoError(t, err) // invalid signer msg, err = types.NewMsgAddValidator("val1", addrs[0], valAddrs[0], valPubKeys[0]) require.NoError(t, err) - _, err = ms.AddValidator( - sdk.WrapSDKContext(ctx), - msg, - ) + _, err = ms.AddValidator(ctx, msg) require.Error(t, err) // duplicate add validator msg, err = types.NewMsgAddValidator("val1", authtypes.NewModuleAddress(types.ModuleName), valAddrs[0], valPubKeys[1]) require.NoError(t, err) - _, err = ms.AddValidator( - sdk.WrapSDKContext(ctx), - msg, - ) + _, err = ms.AddValidator(ctx, msg) require.Error(t, err) // duplicate cons pubkey msg, err = types.NewMsgAddValidator("val1", authtypes.NewModuleAddress(types.ModuleName), valAddrs[1], valPubKeys[0]) require.NoError(t, err) - _, err = ms.AddValidator( - sdk.WrapSDKContext(ctx), - msg, - ) + _, err = ms.AddValidator(ctx, msg) require.Error(t, err) } @@ -159,7 +155,7 @@ func Test_MsgServer_RemoveValidator(t *testing.T) { require.NoError(t, err) _, err = ms.RemoveValidator( - sdk.WrapSDKContext(ctx), + ctx, msg, ) require.Error(t, err) @@ -169,7 +165,7 @@ func Test_MsgServer_RemoveValidator(t *testing.T) { require.NoError(t, err) _, err = ms.RemoveValidator( - sdk.WrapSDKContext(ctx), + ctx, msg, ) require.Error(t, err) @@ -179,7 +175,7 @@ func Test_MsgServer_RemoveValidator(t *testing.T) { require.NoError(t, err) _, err = ms.RemoveValidator( - sdk.WrapSDKContext(ctx), + ctx, msg, ) require.NoError(t, err) @@ -189,22 +185,25 @@ func Test_MsgServer_UpdateParams(t *testing.T) { ctx, input := createDefaultTestInput(t) ms := keeper.NewMsgServerImpl(input.OPChildKeeper) - params := ms.GetParams(ctx) + params, err := ms.GetParams(ctx) + require.NoError(t, err) params.MaxValidators = 1 params.HistoricalEntries = 1 params.BridgeExecutor = addrs[1].String() msg := types.NewMsgUpdateParams(authtypes.NewModuleAddress(types.ModuleName), ¶ms) - _, err := ms.UpdateParams(sdk.WrapSDKContext(ctx), msg) + _, err = ms.UpdateParams(ctx, msg) + require.NoError(t, err) + _params, err := ms.GetParams(ctx) require.NoError(t, err) - require.Equal(t, params, ms.GetParams(ctx)) + require.Equal(t, params, _params) // invalid signer msg = types.NewMsgUpdateParams(authtypes.NewModuleAddress("gov"), ¶ms) require.NoError(t, err) _, err = ms.UpdateParams( - sdk.WrapSDKContext(ctx), + ctx, msg, ) require.Error(t, err) @@ -215,7 +214,7 @@ func Test_MsgServer_SpendFeePool(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPChildKeeper) // fund fee pool - collectedFees := sdk.NewCoins(sdk.NewCoin(baseDenom, sdk.NewInt(100))) + collectedFees := sdk.NewCoins(sdk.NewCoin(baseDenom, math.NewInt(100))) input.Faucet.Fund(ctx, authtypes.NewModuleAddress(authtypes.FeeCollectorName), collectedFees...) beforeAmount := input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).Amount @@ -225,11 +224,11 @@ func Test_MsgServer_SpendFeePool(t *testing.T) { addrs[1], collectedFees, ) - _, err := ms.SpendFeePool(sdk.WrapSDKContext(ctx), msg) + _, err := ms.SpendFeePool(ctx, msg) require.NoError(t, err) afterAmount := input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).Amount - require.Equal(t, beforeAmount.Add(sdk.NewInt(100)), afterAmount) + require.Equal(t, beforeAmount.Add(math.NewInt(100)), afterAmount) } ///////////////////////////////////////// @@ -247,7 +246,7 @@ func Test_MsgServer_Withdraw(t *testing.T) { // valid msg := types.NewMsgInitiateTokenWithdrawal(account, addrs[1], sdk.NewCoin(denom, math.NewInt(100))) - _, err := ms.InitiateTokenWithdrawal(sdk.WrapSDKContext(ctx), msg) + _, err := ms.InitiateTokenWithdrawal(ctx, msg) require.NoError(t, err) } @@ -263,20 +262,20 @@ func Test_MsgServer_Deposit_NoHook(t *testing.T) { denom := "l2/" + hex.EncodeToString(bz[:]) // unauthorized deposit - msg := types.NewMsgFinalizeTokenDeposit(addrs[1], addrs[1], addrs[1], sdk.NewCoin(denom, sdk.NewInt(100)), 1, nil) - _, err := ms.FinalizeTokenDeposit(sdk.WrapSDKContext(ctx), msg) + msg := types.NewMsgFinalizeTokenDeposit(addrs[1], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, nil) + _, err := ms.FinalizeTokenDeposit(ctx, msg) require.Error(t, err) beforeBalance := input.BankKeeper.GetBalance(ctx, addrs[1], denom) - require.Equal(t, sdk.ZeroInt(), beforeBalance.Amount) + require.Equal(t, math.ZeroInt(), beforeBalance.Amount) // valid deposit - msg = types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, sdk.NewInt(100)), 1, nil) - _, err = ms.FinalizeTokenDeposit(sdk.WrapSDKContext(ctx), msg) + msg = types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, nil) + _, err = ms.FinalizeTokenDeposit(ctx, msg) require.NoError(t, err) afterBalance := input.BankKeeper.GetBalance(ctx, addrs[1], denom) - require.Equal(t, sdk.NewInt(100), afterBalance.Amount) + require.Equal(t, math.NewInt(100), afterBalance.Amount) } func Test_MsgServer_Deposit_HookSuccess(t *testing.T) { @@ -286,7 +285,7 @@ func Test_MsgServer_Deposit_HookSuccess(t *testing.T) { bz := sha3.Sum256([]byte("test_token")) denom := "l2/" + hex.EncodeToString(bz[:]) - require.Equal(t, sdk.ZeroInt(), input.BankKeeper.GetBalance(ctx, addrs[1], denom).Amount) + require.Equal(t, math.ZeroInt(), input.BankKeeper.GetBalance(ctx, addrs[1], denom).Amount) hookMsgBytes, err := json.Marshal("message bytes") require.NoError(t, err) @@ -295,12 +294,12 @@ func Test_MsgServer_Deposit_HookSuccess(t *testing.T) { input.BridgeHook.err = nil // valid deposit - msg := types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, sdk.NewInt(100)), 1, hookMsgBytes) - _, err = ms.FinalizeTokenDeposit(sdk.WrapSDKContext(ctx), msg) + msg := types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, hookMsgBytes) + _, err = ms.FinalizeTokenDeposit(ctx, msg) require.NoError(t, err) require.Equal(t, hookMsgBytes, input.BridgeHook.msgBytes) - for _, event := range ctx.EventManager().Events() { + for _, event := range sdk.UnwrapSDKContext(ctx).EventManager().Events() { if event.Type == types.EventTypeFinalizeTokenDeposit { for _, attr := range event.Attributes { if attr.Key == types.AttributeKeyHookSuccess { @@ -321,12 +320,12 @@ func Test_MsgServer_Deposit_HookFail(t *testing.T) { input.BridgeHook.err = errors.New("should be failed") // valid deposit - msg := types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, sdk.NewInt(100)), 1, []byte("invalid_message")) - _, err := ms.FinalizeTokenDeposit(sdk.WrapSDKContext(ctx), msg) + msg := types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, []byte("invalid_message")) + _, err := ms.FinalizeTokenDeposit(ctx, msg) require.NoError(t, err) require.Empty(t, input.BridgeHook.msgBytes) - for _, event := range ctx.EventManager().Events() { + for _, event := range sdk.UnwrapSDKContext(ctx).EventManager().Events() { if event.Type == types.EventTypeFinalizeTokenDeposit { for _, attr := range event.Attributes { if attr.Key == types.AttributeKeyHookSuccess { diff --git a/x/opchild/keeper/params.go b/x/opchild/keeper/params.go index 9174c47a..1f19db69 100644 --- a/x/opchild/keeper/params.go +++ b/x/opchild/keeper/params.go @@ -1,43 +1,40 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/initia-labs/OPinit/x/opchild/types" ) // BridgeExecutor returns params.BridgeExecutor -func (k Keeper) BridgeExecutor(ctx sdk.Context) sdk.AccAddress { - return sdk.MustAccAddressFromBech32(k.GetParams(ctx).BridgeExecutor) +func (k Keeper) BridgeExecutor(ctx context.Context) (sdk.AccAddress, error) { + params, err := k.GetParams(ctx) + if err != nil { + return nil, err + } + + return k.authKeeper.AddressCodec().StringToBytes(params.BridgeExecutor) } // SetParams sets the x/opchild module parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - if err := params.Validate(); err != nil { - return err - } - - store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(¶ms) - if err != nil { +func (k Keeper) SetParams(ctx context.Context, params types.Params) error { + if err := params.Validate(k.authKeeper.AddressCodec()); err != nil { return err } - store.Set(types.ParamsKey, bz) - - return nil + return k.Params.Set(ctx, params) } // GetParams sets the x/opchild module parameters. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKey) - if bz == nil { - return params - } - - k.cdc.MustUnmarshal(bz, ¶ms) - return params +func (k Keeper) GetParams(ctx context.Context) (params types.Params, err error) { + return k.Params.Get(ctx) } -func (k Keeper) MinGasPrices(ctx sdk.Context) sdk.DecCoins { - return k.GetParams(ctx).MinGasPrices +func (k Keeper) MinGasPrices(ctx context.Context) (sdk.DecCoins, error) { + params, err := k.GetParams(ctx) + if err != nil { + return nil, err + } + + return params.MinGasPrices, nil } diff --git a/x/opchild/keeper/params_test.go b/x/opchild/keeper/params_test.go index 792180a4..1a1a3e2e 100644 --- a/x/opchild/keeper/params_test.go +++ b/x/opchild/keeper/params_test.go @@ -10,11 +10,16 @@ import ( func Test_Params(t *testing.T) { ctx, input := createDefaultTestInput(t) - params := input.OPChildKeeper.GetParams(ctx) + params, err := input.OPChildKeeper.GetParams(ctx) + require.NoError(t, err) params.MinGasPrices = sdk.NewDecCoins() input.OPChildKeeper.SetParams(ctx, params) - require.True(t, input.OPChildKeeper.MinGasPrices(ctx).IsZero()) - require.Equal(t, addrs[0], input.OPChildKeeper.BridgeExecutor(ctx)) + minGasPrices, err := input.OPChildKeeper.MinGasPrices(ctx) + require.NoError(t, err) + require.True(t, minGasPrices.Empty()) + bridgeExecutor, err := input.OPChildKeeper.BridgeExecutor(ctx) + require.NoError(t, err) + require.Equal(t, addrs[0], bridgeExecutor) } diff --git a/x/opchild/keeper/querier.go b/x/opchild/keeper/querier.go index a620def4..514909a1 100644 --- a/x/opchild/keeper/querier.go +++ b/x/opchild/keeper/querier.go @@ -3,7 +3,6 @@ package keeper import ( "context" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" @@ -23,7 +22,7 @@ func NewQuerier(k Keeper) Querier { return Querier{k} } -func (q Querier) Validator(context context.Context, req *types.QueryValidatorRequest) (*types.QueryValidatorResponse, error) { +func (q Querier) Validator(ctx context.Context, req *types.QueryValidatorRequest) (*types.QueryValidatorResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -32,12 +31,11 @@ func (q Querier) Validator(context context.Context, req *types.QueryValidatorReq return nil, status.Error(codes.InvalidArgument, "validator address cannot be empty") } - valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr) + valAddr, err := q.validatorAddressCodec.StringToBytes(req.ValidatorAddr) if err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(context) validator, found := q.GetValidator(ctx, valAddr) if !found { return nil, status.Errorf(codes.NotFound, "validator %s not found", req.ValidatorAddr) @@ -46,30 +44,14 @@ func (q Querier) Validator(context context.Context, req *types.QueryValidatorReq return &types.QueryValidatorResponse{Validator: validator}, nil } -func (q Querier) Validators(context context.Context, req *types.QueryValidatorsRequest) (*types.QueryValidatorsResponse, error) { +func (q Querier) Validators(ctx context.Context, req *types.QueryValidatorsRequest) (*types.QueryValidatorsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - var validators types.Validators - ctx := sdk.UnwrapSDKContext(context) - - store := ctx.KVStore(q.storeKey) - valStore := prefix.NewStore(store, types.ValidatorsKey) - - pageRes, err := query.FilteredPaginate(valStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - val, err := types.UnmarshalValidator(q.cdc, value) - if err != nil { - return false, err - } - - if accumulate { - validators = append(validators, val) - } - - return true, nil + validators, pageRes, err := query.CollectionPaginate(ctx, q.Keeper.Validators, req.Pagination, func(_ []byte, validator types.Validator) (types.Validator, error) { + return validator, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -79,6 +61,10 @@ func (q Querier) Validators(context context.Context, req *types.QueryValidatorsR func (q Querier) Params(context context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(context) + params, err := q.GetParams(ctx) + if err != nil { + return nil, err + } - return &types.QueryParamsResponse{Params: q.GetParams(ctx)}, nil + return &types.QueryParamsResponse{Params: params}, nil } diff --git a/x/opchild/keeper/querier_test.go b/x/opchild/keeper/querier_test.go index 86dd1807..0e387788 100644 --- a/x/opchild/keeper/querier_test.go +++ b/x/opchild/keeper/querier_test.go @@ -47,7 +47,8 @@ func Test_QueryValidators(t *testing.T) { func Test_QueryParams(t *testing.T) { ctx, input := createDefaultTestInput(t) - params := input.OPChildKeeper.GetParams(ctx) + params, err := input.OPChildKeeper.GetParams(ctx) + require.NoError(t, err) params.MinGasPrices = sdk.NewDecCoins(sdk.NewInt64DecCoin("stake", 1)) input.OPChildKeeper.SetParams(ctx, params) diff --git a/x/opchild/keeper/sequence_test.go b/x/opchild/keeper/sequence_test.go index d399f4c1..b354dfa5 100644 --- a/x/opchild/keeper/sequence_test.go +++ b/x/opchild/keeper/sequence_test.go @@ -9,11 +9,13 @@ import ( func Test_FinalizedL1Sequence(t *testing.T) { ctx, input := createDefaultTestInput(t) - res := input.OPChildKeeper.HasFinalizedL1Sequence(ctx, 1) + res, err := input.OPChildKeeper.HasFinalizedL1Sequence(ctx, 1) + require.NoError(t, err) require.False(t, res) input.OPChildKeeper.RecordFinalizedL1Sequence(ctx, 1) - res = input.OPChildKeeper.HasFinalizedL1Sequence(ctx, 1) + res, err = input.OPChildKeeper.HasFinalizedL1Sequence(ctx, 1) + require.NoError(t, err) require.True(t, res) } @@ -24,32 +26,37 @@ func Test_IterateFinalizedL1Sequences(t *testing.T) { for _, v := range sequences { input.OPChildKeeper.RecordFinalizedL1Sequence(ctx, v) } - input.OPChildKeeper.IterateFinalizedL1Sequences(ctx, func(l1Sequence uint64) bool { + require.NoError(t, input.OPChildKeeper.IterateFinalizedL1Sequences(ctx, func(l1Sequence uint64) (bool, error) { require.Equal(t, sequences[0], l1Sequence) sequences = sequences[1:] - return false - }) + return false, nil + })) } func Test_SetAndSetNextL2Sequence(t *testing.T) { ctx, input := createDefaultTestInput(t) - seq := input.OPChildKeeper.GetNextL2Sequence(ctx) + seq, err := input.OPChildKeeper.GetNextL2Sequence(ctx) + require.NoError(t, err) require.Equal(t, uint64(1), seq) input.OPChildKeeper.SetNextL2Sequence(ctx, 1204) - seq = input.OPChildKeeper.GetNextL2Sequence(ctx) + seq, err = input.OPChildKeeper.GetNextL2Sequence(ctx) + require.NoError(t, err) require.Equal(t, uint64(1204), seq) } func Test_IncreaseNextL2Sequence(t *testing.T) { ctx, input := createDefaultTestInput(t) - seq := input.OPChildKeeper.GetNextL2Sequence(ctx) + seq, err := input.OPChildKeeper.GetNextL2Sequence(ctx) + require.NoError(t, err) require.Equal(t, uint64(1), seq) - seq = input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + seq, err = input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + require.NoError(t, err) require.Equal(t, uint64(1), seq) - seq = input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + seq, err = input.OPChildKeeper.IncreaseNextL2Sequence(ctx) + require.NoError(t, err) require.Equal(t, uint64(2), seq) } diff --git a/x/opchild/keeper/sequences.go b/x/opchild/keeper/sequences.go index f1ff9e57..163abaef 100644 --- a/x/opchild/keeper/sequences.go +++ b/x/opchild/keeper/sequences.go @@ -1,73 +1,53 @@ package keeper import ( - "encoding/binary" + "context" + "errors" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/initia-labs/OPinit/x/opchild/types" + "cosmossdk.io/collections" ) -func (k Keeper) RecordFinalizedL1Sequence(ctx sdk.Context, l1Sequence uint64) { - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.GetFinalizedL1SequenceKey(l1Sequence), []byte{1}) +func (k Keeper) RecordFinalizedL1Sequence(ctx context.Context, l1Sequence uint64) error { + return k.FinalizedL1Sequence.Set(ctx, l1Sequence, true) } -func (k Keeper) HasFinalizedL1Sequence(ctx sdk.Context, l1Sequence uint64) bool { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.GetFinalizedL1SequenceKey(l1Sequence)) - return len(bz) != 0 +func (k Keeper) HasFinalizedL1Sequence(ctx context.Context, l1Sequence uint64) (bool, error) { + return k.FinalizedL1Sequence.Has(ctx, l1Sequence) } -func (k Keeper) IterateFinalizedL1Sequences(ctx sdk.Context, cb func(l1Sequence uint64) bool) { - kvStore := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(kvStore, types.FinalizedL1SequenceKey) - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - l1Sequence := binary.BigEndian.Uint64(iterator.Key()) - - if cb(l1Sequence) { - break - } - } +func (k Keeper) IterateFinalizedL1Sequences(ctx context.Context, cb func(l1Sequence uint64) (stop bool, err error)) error { + return k.FinalizedL1Sequence.Walk(ctx, nil, func(l1sequence uint64, _ bool) (stop bool, err error) { + return cb(l1sequence) + }) } -func (k Keeper) SetNextL2Sequence(ctx sdk.Context, l2Sequence uint64) { - kvStore := ctx.KVStore(k.storeKey) - - _l2Sequence := [8]byte{} - binary.BigEndian.PutUint64(_l2Sequence[:], l2Sequence) - kvStore.Set(types.NextL2SequenceKey, _l2Sequence[:]) +func (k Keeper) SetNextL2Sequence(ctx context.Context, l2Sequence uint64) error { + return k.NextL2Sequence.Set(ctx, l2Sequence) } -func (k Keeper) GetNextL2Sequence(ctx sdk.Context) uint64 { - kvStore := ctx.KVStore(k.storeKey) +func (k Keeper) GetNextL2Sequence(ctx context.Context) (uint64, error) { + nextL2Sequence, err := k.NextL2Sequence.Get(ctx) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + return 1, nil + } - bz := kvStore.Get(types.NextL2SequenceKey) - if len(bz) == 0 { - return 1 + return 0, err } - return binary.BigEndian.Uint64(bz) + return nextL2Sequence, nil } -func (k Keeper) IncreaseNextL2Sequence(ctx sdk.Context) uint64 { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.NextL2SequenceKey) - - nextL2Sequence := uint64(1) - if len(bz) != 0 { - nextL2Sequence = binary.BigEndian.Uint64(bz) +func (k Keeper) IncreaseNextL2Sequence(ctx context.Context) (uint64, error) { + nextL2Sequence, err := k.GetNextL2Sequence(ctx) + if err != nil { + return 0, err } - // increase next l2 sequence - _nextL2Sequence := [8]byte{} - binary.BigEndian.PutUint64(_nextL2Sequence[:], nextL2Sequence+1) - kvStore.Set(types.NextL2SequenceKey, _nextL2Sequence[:]) + // increase NextL2Sequence + if err = k.NextL2Sequence.Set(ctx, nextL2Sequence+1); err != nil { + return 0, err + } - return nextL2Sequence + return nextL2Sequence, nil } diff --git a/x/opchild/keeper/staking.go b/x/opchild/keeper/staking.go index 15091905..25d6141e 100644 --- a/x/opchild/keeper/staking.go +++ b/x/opchild/keeper/staking.go @@ -1,25 +1,34 @@ package keeper import ( + "context" "time" - - sdk "github.com/cosmos/cosmos-sdk/types" ) // fake staking functions // MaxValidators - Maximum number of validators -func (k Keeper) MaxValidators(ctx sdk.Context) uint32 { - return k.GetParams(ctx).MaxValidators +func (k Keeper) MaxValidators(ctx context.Context) (uint32, error) { + params, err := k.GetParams(ctx) + if err != nil { + return 0, err + } + + return params.MaxValidators, nil } // HistoricalEntries = number of historical info entries // to persist in store -func (k Keeper) HistoricalEntries(ctx sdk.Context) uint32 { - return k.GetParams(ctx).HistoricalEntries +func (k Keeper) HistoricalEntries(ctx context.Context) (uint32, error) { + params, err := k.GetParams(ctx) + if err != nil { + return 0, err + } + + return params.HistoricalEntries, nil } // UnbondingTime - The time duration for unbonding -func (k Keeper) UnbondingTime(ctx sdk.Context) time.Duration { +func (k Keeper) UnbondingTime(ctx context.Context) time.Duration { return unbondingTime } diff --git a/x/opchild/keeper/staking_test.go b/x/opchild/keeper/staking_test.go index 2d035884..5802fcb6 100644 --- a/x/opchild/keeper/staking_test.go +++ b/x/opchild/keeper/staking_test.go @@ -10,22 +10,26 @@ import ( func Test_MaxValidators(t *testing.T) { ctx, input := createDefaultTestInput(t) - params := input.OPChildKeeper.GetParams(ctx) + params, err := input.OPChildKeeper.GetParams(ctx) + require.NoError(t, err) params.MaxValidators = 10 input.OPChildKeeper.SetParams(ctx, params) - maxValidators := input.OPChildKeeper.MaxValidators(ctx) + maxValidators, err := input.OPChildKeeper.MaxValidators(ctx) + require.NoError(t, err) require.Equal(t, uint32(10), maxValidators) } func Test_HistoricalEntries(t *testing.T) { ctx, input := createDefaultTestInput(t) - params := input.OPChildKeeper.GetParams(ctx) + params, err := input.OPChildKeeper.GetParams(ctx) + require.NoError(t, err) params.HistoricalEntries = 10 input.OPChildKeeper.SetParams(ctx, params) - entries := input.OPChildKeeper.HistoricalEntries(ctx) + entries, err := input.OPChildKeeper.HistoricalEntries(ctx) + require.NoError(t, err) require.Equal(t, uint32(10), entries) } diff --git a/x/opchild/keeper/val_state_change.go b/x/opchild/keeper/val_state_change.go index 1f733150..49d07865 100644 --- a/x/opchild/keeper/val_state_change.go +++ b/x/opchild/keeper/val_state_change.go @@ -2,10 +2,11 @@ package keeper import ( "bytes" + "context" "sort" + "cosmossdk.io/core/address" abci "github.com/cometbft/cometbft/abci/types" - gogotypes "github.com/cosmos/gogoproto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/initia-labs/OPinit/x/opchild/types" @@ -13,31 +14,39 @@ import ( // BlockValidatorUpdates calculates the ValidatorUpdates for the current block // Called in each EndBlock -func (k Keeper) BlockValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate { +func (k Keeper) BlockValidatorUpdates(ctx context.Context) ([]abci.ValidatorUpdate, error) { updates, err := k.ApplyAndReturnValidatorSetUpdates(ctx) if err != nil { - panic(err) + return nil, err } - return updates + return updates, nil } -func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) ([]abci.ValidatorUpdate, error) { +func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) ([]abci.ValidatorUpdate, error) { last, err := k.getLastValidatorsByAddr(ctx) if err != nil { return nil, err } updates := []abci.ValidatorUpdate{} - validators := k.GetValidators(ctx, k.MaxValidators(ctx)) + maxValidators, err := k.MaxValidators(ctx) + if err != nil { + return nil, err + } + + validators, err := k.GetValidators(ctx, maxValidators) + if err != nil { + return nil, err + } + for _, validator := range validators { - valAddr := validator.GetOperator() - valAddrStr, err := sdk.Bech32ifyAddressBytes(sdk.GetConfig().GetBech32ValidatorAddrPrefix(), valAddr) + valAddr, err := k.validatorAddressCodec.StringToBytes(validator.GetOperator()) if err != nil { return nil, err } - oldPowerBytes, found := last[valAddrStr] + oldPower, found := last[validator.GetOperator()] newPower := validator.ConsensusPower() // zero power validator removed from validator set @@ -45,25 +54,29 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) ([]abci.Valid continue } - newPowerBytes := k.cdc.MustMarshal(&gogotypes.Int64Value{Value: newPower}) - if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) { + if !found || oldPower != newPower { updates = append(updates, validator.ABCIValidatorUpdate()) k.SetLastValidatorPower(ctx, valAddr, newPower) } - delete(last, valAddrStr) + delete(last, validator.GetOperator()) } - noLongerBonded, err := sortNoLongerBonded(last) + noLongerBonded, err := sortNoLongerBonded(last, k.validatorAddressCodec) if err != nil { return nil, err } for _, valAddrBytes := range noLongerBonded { validator := k.mustGetValidator(ctx, sdk.ValAddress(valAddrBytes)) - k.RemoveValidator(ctx, validator.GetOperator()) - k.DeleteLastValidatorPower(ctx, validator.GetOperator()) + valAddr, err := k.validatorAddressCodec.StringToBytes(validator.GetOperator()) + if err != nil { + return nil, err + } + + k.RemoveValidator(ctx, valAddr) + k.DeleteLastValidatorPower(ctx, valAddr) updates = append(updates, validator.ABCIValidatorUpdateZero()) } @@ -72,40 +85,29 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) ([]abci.Valid // map of operator bech32-addresses to serialized power // We use bech32 strings here, because we can't have slices as keys: map[[]byte][]byte -type validatorsByAddr map[string][]byte +type validatorsByAddr map[string]int64 // get the last validator set -func (k Keeper) getLastValidatorsByAddr(ctx sdk.Context) (validatorsByAddr, error) { +func (k Keeper) getLastValidatorsByAddr(ctx context.Context) (validatorsByAddr, error) { last := make(validatorsByAddr) - iterator := k.LastValidatorsIterator(ctx) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - // extract the validator address from the key (prefix is 1-byte, addrLen is 1-byte) - valAddr := types.AddressFromLastValidatorPowerKey(iterator.Key()) - valAddrStr, err := sdk.Bech32ifyAddressBytes(sdk.GetConfig().GetBech32ValidatorAddrPrefix(), valAddr) - if err != nil { - return nil, err - } - - powerBytes := iterator.Value() - last[valAddrStr] = make([]byte, len(powerBytes)) - copy(last[valAddrStr], powerBytes) - } + k.IterateLastValidators(ctx, func(validator types.ValidatorI, power int64) (stop bool, err error) { + last[validator.GetOperator()] = power + return false, nil + }) return last, nil } // given a map of remaining validators to previous bonded power // returns the list of validators to be unbonded, sorted by operator address -func sortNoLongerBonded(last validatorsByAddr) ([][]byte, error) { +func sortNoLongerBonded(last validatorsByAddr, vc address.Codec) ([][]byte, error) { // sort the map keys for determinism noLongerBonded := make([][]byte, len(last)) index := 0 for valAddrStr := range last { - valAddrBytes, err := sdk.ValAddressFromBech32(valAddrStr) + valAddrBytes, err := vc.StringToBytes(valAddrStr) if err != nil { return nil, err } diff --git a/x/opchild/keeper/val_state_change_test.go b/x/opchild/keeper/val_state_change_test.go index 5b9d04db..275313e6 100644 --- a/x/opchild/keeper/val_state_change_test.go +++ b/x/opchild/keeper/val_state_change_test.go @@ -25,9 +25,12 @@ func Test_BlockValidatorUpdates(t *testing.T) { input.OPChildKeeper.SetValidator(ctx, val2) // apply val updates - updates := input.OPChildKeeper.BlockValidatorUpdates(ctx) + updates, err := input.OPChildKeeper.BlockValidatorUpdates(ctx) + require.NoError(t, err) valTmConsPubKey1, err := val1.TmConsPublicKey() + require.NoError(t, err) valTmConsPubKey2, err := val2.TmConsPublicKey() + require.NoError(t, err) require.Len(t, updates, 2) require.Contains(t, updates, abci.ValidatorUpdate{ PubKey: valTmConsPubKey1, @@ -39,12 +42,14 @@ func Test_BlockValidatorUpdates(t *testing.T) { }) // no changes - updates = input.OPChildKeeper.BlockValidatorUpdates(ctx) + updates, err = input.OPChildKeeper.BlockValidatorUpdates(ctx) + require.NoError(t, err) require.Equal(t, []abci.ValidatorUpdate{}, updates) // val2 removed val2.ConsPower = 0 input.OPChildKeeper.SetValidator(ctx, val2) - updates = input.OPChildKeeper.BlockValidatorUpdates(ctx) + updates, err = input.OPChildKeeper.BlockValidatorUpdates(ctx) + require.NoError(t, err) require.Equal(t, []abci.ValidatorUpdate{val2.ABCIValidatorUpdateZero()}, updates) } diff --git a/x/opchild/keeper/validator.go b/x/opchild/keeper/validator.go index f5732453..9b79f248 100644 --- a/x/opchild/keeper/validator.go +++ b/x/opchild/keeper/validator.go @@ -1,28 +1,28 @@ package keeper import ( + "context" + "errors" "fmt" - gogotypes "github.com/cosmos/gogoproto/types" + "cosmossdk.io/collections" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/initia-labs/OPinit/x/opchild/types" ) // get a single validator -func (k Keeper) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator types.Validator, found bool) { - store := ctx.KVStore(k.storeKey) - - value := store.Get(types.GetValidatorKey(addr)) - if value == nil { +func (k Keeper) GetValidator(ctx context.Context, addr sdk.ValAddress) (validator types.Validator, found bool) { + validator, err := k.Validators.Get(ctx, addr) + if errors.Is(err, collections.ErrNotFound) { return validator, false } - validator = types.MustUnmarshalValidator(k.cdc, value) return validator, true } -func (k Keeper) mustGetValidator(ctx sdk.Context, addr sdk.ValAddress) types.Validator { +func (k Keeper) mustGetValidator(ctx context.Context, addr sdk.ValAddress) types.Validator { validator, found := k.GetValidator(ctx, addr) if !found { panic(fmt.Sprintf("validator record not found for address: %X\n", addr)) @@ -32,182 +32,138 @@ func (k Keeper) mustGetValidator(ctx sdk.Context, addr sdk.ValAddress) types.Val } // get a single validator by consensus address -func (k Keeper) GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator types.Validator, found bool) { - store := ctx.KVStore(k.storeKey) - - opAddr := store.Get(types.GetValidatorByConsAddrKey(consAddr)) - if opAddr == nil { +func (k Keeper) GetValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (validator types.Validator, found bool) { + opAddr, err := k.ValidatorsByConsAddr.Get(ctx, consAddr) + if errors.Is(err, collections.ErrNotFound) { return validator, false } return k.GetValidator(ctx, opAddr) } -func (k Keeper) mustGetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) types.Validator { - validator, found := k.GetValidatorByConsAddr(ctx, consAddr) - if !found { - panic(fmt.Errorf("validator with consensus-Address %s not found", consAddr)) +// set the main record holding validator details +func (k Keeper) SetValidator(ctx context.Context, validator types.Validator) error { + valAddr, err := k.validatorAddressCodec.StringToBytes(validator.GetOperator()) + if err != nil { + return err } - return validator -} - -// set the main record holding validator details -func (k Keeper) SetValidator(ctx sdk.Context, validator types.Validator) { - store := ctx.KVStore(k.storeKey) - bz := types.MustMarshalValidator(k.cdc, &validator) - store.Set(types.GetValidatorKey(validator.GetOperator()), bz) + return k.Validators.Set(ctx, valAddr, validator) } // validator index -func (k Keeper) SetValidatorByConsAddr(ctx sdk.Context, validator types.Validator) error { +func (k Keeper) SetValidatorByConsAddr(ctx context.Context, validator types.Validator) error { consPk, err := validator.GetConsAddr() if err != nil { return err } - store := ctx.KVStore(k.storeKey) - store.Set(types.GetValidatorByConsAddrKey(consPk), validator.GetOperator()) - return nil + + valAddr, err := k.validatorAddressCodec.StringToBytes(validator.GetOperator()) + if err != nil { + return err + } + + return k.ValidatorsByConsAddr.Set(ctx, consPk, valAddr) } // remove the validator record and associated indexes // except for the bonded validator index which is only handled in ApplyAndReturnTendermintUpdates -// TODO, this function panics, and it's not good. -func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.ValAddress) { +func (k Keeper) RemoveValidator(ctx context.Context, address sdk.ValAddress) error { // first retrieve the old validator record validator, found := k.GetValidator(ctx, address) if !found { - return + return nil } valConsAddr, err := validator.GetConsAddr() if err != nil { - panic(err) + return err + } + + if err := k.Validators.Remove(ctx, address); err != nil { + return err + } + if err := k.ValidatorsByConsAddr.Remove(ctx, valConsAddr); err != nil { + return err } - // delete the old validator record - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetValidatorKey(address)) - store.Delete(types.GetValidatorByConsAddrKey(valConsAddr)) + return nil } // get groups of validators // get the set of all validators with no limits, used during genesis dump -func (k Keeper) GetAllValidators(ctx sdk.Context) (validators []types.Validator) { - store := ctx.KVStore(k.storeKey) - - iterator := sdk.KVStorePrefixIterator(store, types.ValidatorsKey) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - validator := types.MustUnmarshalValidator(k.cdc, iterator.Value()) +func (k Keeper) GetAllValidators(ctx context.Context) (validators []types.Validator, err error) { + k.Validators.Walk(ctx, nil, func(key []byte, validator types.Validator) (stop bool, err error) { validators = append(validators, validator) - } + return false, nil + }) - return validators + return validators, nil } // return a given amount of all the validators -func (k Keeper) GetValidators(ctx sdk.Context, maxRetrieve uint32) (validators []types.Validator) { - store := ctx.KVStore(k.storeKey) - validators = make([]types.Validator, maxRetrieve) - - iterator := sdk.KVStorePrefixIterator(store, types.ValidatorsKey) - defer iterator.Close() - - i := 0 - for ; iterator.Valid() && i < int(maxRetrieve); iterator.Next() { - validator := types.MustUnmarshalValidator(k.cdc, iterator.Value()) - validators[i] = validator - i++ - } +func (k Keeper) GetValidators(ctx context.Context, maxRetrieve uint32) (validators []types.Validator, err error) { + validators = make([]types.Validator, 0, maxRetrieve) + k.Validators.Walk(ctx, nil, func(key []byte, validator types.Validator) (stop bool, err error) { + validators = append(validators, validator) + return len(validators) == int(maxRetrieve), nil + }) - return validators[:i] // trim if the array length < maxRetrieve + return validators, nil } // Last Validator Index // Load the last validator power. // Returns zero if the operator was not a validator last block. -func (k Keeper) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) (power int64) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) GetLastValidatorPower(ctx context.Context, operator sdk.ValAddress) (int64, error) { + power, err := k.LastValidatorPowers.Get(ctx, operator) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + return 0, nil + } - bz := store.Get(types.GetLastValidatorPowerKey(operator)) - if bz == nil { - return 0 + return 0, err } - intV := gogotypes.Int64Value{} - k.cdc.MustUnmarshal(bz, &intV) - - return intV.GetValue() + return power, nil } // Set the last validator power. -func (k Keeper) SetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress, power int64) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&gogotypes.Int64Value{Value: power}) - store.Set(types.GetLastValidatorPowerKey(operator), bz) +func (k Keeper) SetLastValidatorPower(ctx context.Context, operator sdk.ValAddress, power int64) error { + return k.LastValidatorPowers.Set(ctx, operator, power) } // Delete the last validator power. -func (k Keeper) DeleteLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetLastValidatorPowerKey(operator)) -} - -// returns an iterator for the consensus validators in the last block -func (k Keeper) LastValidatorsIterator(ctx sdk.Context) (iterator sdk.Iterator) { - store := ctx.KVStore(k.storeKey) - iterator = sdk.KVStorePrefixIterator(store, types.LastValidatorPowerKey) - - return iterator +func (k Keeper) DeleteLastValidatorPower(ctx context.Context, operator sdk.ValAddress) error { + return k.LastValidatorPowers.Remove(ctx, operator) } // Iterate over last validator powers. -func (k Keeper) IterateLastValidatorPowers(ctx sdk.Context, handler func(operator sdk.ValAddress, power int64) (stop bool)) { - store := ctx.KVStore(k.storeKey) - - iter := sdk.KVStorePrefixIterator(store, types.LastValidatorPowerKey) - defer iter.Close() - - for ; iter.Valid(); iter.Next() { - addr := sdk.ValAddress(types.AddressFromLastValidatorPowerKey(iter.Key())) - intV := &gogotypes.Int64Value{} - - k.cdc.MustUnmarshal(iter.Value(), intV) - - if handler(addr, intV.GetValue()) { - break - } - } +func (k Keeper) IterateLastValidatorPowers(ctx context.Context, handler func(operator []byte, power int64) (stop bool, err error)) error { + return k.LastValidatorPowers.Walk(ctx, nil, handler) } // get the group of the bonded validators -func (k Keeper) GetLastValidators(ctx sdk.Context) (validators []types.Validator) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) GetLastValidators(ctx context.Context) (validators []types.Validator, err error) { + maxValidators, err := k.MaxValidators(ctx) + if err != nil { + return nil, err + } - // add the actual validator power sorted store - maxValidators := k.MaxValidators(ctx) - validators = make([]types.Validator, maxValidators) + validators = make([]types.Validator, 0, maxValidators) - iterator := sdk.KVStorePrefixIterator(store, types.LastValidatorPowerKey) - defer iterator.Close() + k.IterateLastValidatorPowers(ctx, func(operator []byte, power int64) (stop bool, err error) { + validators = append(validators, k.mustGetValidator(ctx, operator)) - i := 0 - for ; iterator.Valid(); iterator.Next() { // sanity check - if i >= int(maxValidators) { + if len(validators) > int(maxValidators) { panic("more validators than maxValidators found") } - address := types.AddressFromLastValidatorPowerKey(iterator.Key()) - validator := k.mustGetValidator(ctx, address) - - validators[i] = validator - i++ - } + return false, nil + }) - return validators[:i] // trim + return validators, nil } diff --git a/x/opchild/keeper/validator_test.go b/x/opchild/keeper/validator_test.go index 6636032f..25a8063f 100644 --- a/x/opchild/keeper/validator_test.go +++ b/x/opchild/keeper/validator_test.go @@ -18,21 +18,21 @@ func Test_GetValidator(t *testing.T) { require.NoError(t, err) // should be empty - _, found := input.OPChildKeeper.GetValidator(ctx, val.GetOperator()) + _, found := input.OPChildKeeper.GetValidator(ctx, valAddrs[1]) require.False(t, found) // set validator input.OPChildKeeper.SetValidator(ctx, val) - valAfter, found := input.OPChildKeeper.GetValidator(ctx, val.GetOperator()) + valAfter, found := input.OPChildKeeper.GetValidator(ctx, valAddrs[1]) require.True(t, found) require.Equal(t, val, valAfter) // remove validator - input.OPChildKeeper.RemoveValidator(ctx, val.GetOperator()) + input.OPChildKeeper.RemoveValidator(ctx, valAddrs[1]) // should be empty - _, found = input.OPChildKeeper.GetValidator(ctx, val.GetOperator()) + _, found = input.OPChildKeeper.GetValidator(ctx, valAddrs[1]) require.False(t, found) } @@ -59,7 +59,7 @@ func Test_GetValidatorByConsAddr(t *testing.T) { require.Equal(t, val, valAfter) // remove validator - input.OPChildKeeper.RemoveValidator(ctx, val.GetOperator()) + input.OPChildKeeper.RemoveValidator(ctx, valAddrs[1]) // should be empty _, found = input.OPChildKeeper.GetValidatorByConsAddr(ctx, consAddr) @@ -79,7 +79,8 @@ func Test_GetAllValidators(t *testing.T) { input.OPChildKeeper.SetValidator(ctx, val1) input.OPChildKeeper.SetValidator(ctx, val2) - vals := input.OPChildKeeper.GetAllValidators(ctx) + vals, err := input.OPChildKeeper.GetAllValidators(ctx) + require.NoError(t, err) require.Len(t, vals, 2) require.Contains(t, vals, val1) require.Contains(t, vals, val2) @@ -98,7 +99,8 @@ func Test_GetValidators(t *testing.T) { input.OPChildKeeper.SetValidator(ctx, val1) input.OPChildKeeper.SetValidator(ctx, val2) - vals := input.OPChildKeeper.GetValidators(ctx, 1) + vals, err := input.OPChildKeeper.GetValidators(ctx, 1) + require.NoError(t, err) require.Len(t, vals, 1) } @@ -112,43 +114,48 @@ func Test_LastValidatorPower(t *testing.T) { val2, err := types.NewValidator(valAddrs[2], valPubKeys[1], "validator2") require.NoError(t, err) - beforePower := input.OPChildKeeper.GetLastValidatorPower(ctx, val1.GetOperator()) + beforePower, err := input.OPChildKeeper.GetLastValidatorPower(ctx, valAddrs[1]) + require.NoError(t, err) require.Equal(t, int64(0), beforePower) // set validator with power index input.OPChildKeeper.SetValidator(ctx, val1) input.OPChildKeeper.SetValidator(ctx, val2) - input.OPChildKeeper.SetLastValidatorPower(ctx, val1.GetOperator(), 100) - input.OPChildKeeper.SetLastValidatorPower(ctx, val2.GetOperator(), 200) + input.OPChildKeeper.SetLastValidatorPower(ctx, valAddrs[1], 100) + input.OPChildKeeper.SetLastValidatorPower(ctx, valAddrs[2], 200) - afterPower := input.OPChildKeeper.GetLastValidatorPower(ctx, val1.GetOperator()) + afterPower, err := input.OPChildKeeper.GetLastValidatorPower(ctx, valAddrs[1]) + require.NoError(t, err) require.Equal(t, int64(100), afterPower) // iterate all powers - input.OPChildKeeper.IterateLastValidatorPowers(ctx, func(valAddr sdk.ValAddress, power int64) bool { - if valAddr.Equals(val1.GetOperator()) { + input.OPChildKeeper.IterateLastValidatorPowers(ctx, func(key []byte, power int64) (stop bool, err error) { + valAddr := sdk.ValAddress(key) + if valAddr.Equals(valAddrs[1]) { require.Equal(t, int64(100), power) } else { - require.Equal(t, val2.GetOperator(), val2.GetOperator()) + require.Equal(t, valAddrs[2], valAddr) require.Equal(t, int64(200), power) } - return false + return false, nil }) // get last validators from the power index - vals := input.OPChildKeeper.GetLastValidators(ctx) + vals, err := input.OPChildKeeper.GetLastValidators(ctx) + require.NoError(t, err) require.Len(t, vals, 2) require.Contains(t, vals, val1) require.Contains(t, vals, val2) // decrease max validator to 1 - params := input.OPChildKeeper.GetParams(ctx) + params, err := input.OPChildKeeper.GetParams(ctx) + require.NoError(t, err) params.MaxValidators = 1 input.OPChildKeeper.SetParams(ctx, params) // should panic if there is more than 1 validators require.Panics(t, func() { - _ = input.OPChildKeeper.GetLastValidators(ctx) + _, _ = input.OPChildKeeper.GetLastValidators(ctx) }) } diff --git a/x/opchild/module.go b/x/opchild/module.go index 48aabd3a..1747ccec 100644 --- a/x/opchild/module.go +++ b/x/opchild/module.go @@ -6,6 +6,8 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -24,12 +26,21 @@ import ( const ConsensusVersion = 1 var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} + _ module.HasABCIGenesis = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasConsensusVersion = AppModule{} + _ module.HasABCIEndBlock = AppModule{} + _ module.HasName = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) -// AppModuleBasic defines the basic application module used by the move module. -type AppModuleBasic struct{} +// AppModuleBasic defines the basic application module used by the opchild module. +type AppModuleBasic struct { + cdc codec.Codec +} func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { //nolint:staticcheck types.RegisterLegacyAminoCodec(amino) @@ -61,17 +72,17 @@ func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, config client return err } - return types.ValidateGenesis(&genState) + return types.ValidateGenesis(&genState, b.cdc.InterfaceRegistry().SigningContext().AddressCodec()) } // GetTxCmd returns the root tx command for the move module. func (b AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd() + return cli.GetTxCmd(b.cdc.InterfaceRegistry().SigningContext().AddressCodec()) } // GetQueryCmd returns no root query command for the move module. func (b AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() + return cli.GetQueryCmd(b.cdc.InterfaceRegistry().SigningContext().AddressCodec()) } // RegisterInterfaces implements InterfaceModule @@ -95,10 +106,11 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // NewAppModule creates a new AppModule object func NewAppModule( + cdc codec.Codec, k keeper.Keeper, ) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{}, + AppModuleBasic: AppModuleBasic{cdc}, keeper: k, } } @@ -119,9 +131,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - validators := am.keeper.InitGenesis(ctx, &genesisState) - - return validators + return am.keeper.InitGenesis(ctx, &genesisState) } // ExportGenesis returns the exported genesis state as raw bytes for the move @@ -132,13 +142,18 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // BeginBlock returns the begin blocker for the move module. -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - BeginBlocker(ctx, req, am.keeper) +func (am AppModule) BeginBlock(ctx context.Context) error { + return BeginBlocker(ctx, am.keeper) } // EndBlock returns the end blocker for the move module. It returns no validator // updates. -func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - EndBlocker(ctx, am.keeper) - return []abci.ValidatorUpdate{} +func (am AppModule) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error) { + return EndBlocker(ctx, am.keeper) } + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/opchild/types/codec.go b/x/opchild/types/codec.go index 6f2e4ade..aba33409 100644 --- a/x/opchild/types/codec.go +++ b/x/opchild/types/codec.go @@ -4,13 +4,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" - govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec" ) // RegisterLegacyAminoCodec registers the move types and interface @@ -44,20 +40,3 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - sdk.RegisterLegacyAminoCodec(amino) - - // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be - // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances - RegisterLegacyAminoCodec(authzcodec.Amino) - RegisterLegacyAminoCodec(govcodec.Amino) - RegisterLegacyAminoCodec(groupcodec.Amino) -} diff --git a/x/opchild/types/errors.go b/x/opchild/types/errors.go index a1efba47..e399a141 100644 --- a/x/opchild/types/errors.go +++ b/x/opchild/types/errors.go @@ -17,4 +17,6 @@ var ( ErrInvalidAmount = errorsmod.Register(ModuleName, 10, "invalid amount") ErrInvalidSequence = errorsmod.Register(ModuleName, 11, "invalid sequence") ErrZeroMaxValidators = errorsmod.Register(ModuleName, 12, "max validators must be non-zero") + ErrInvalidExecuteMsg = errorsmod.Register(ModuleName, 13, "invalid execute message") + ErrUnroutableExecuteMsg = errorsmod.Register(ModuleName, 14, "unroutable execute message") ) diff --git a/x/opchild/types/expected_keepers.go b/x/opchild/types/expected_keepers.go index beb75b13..2a5ef8ab 100644 --- a/x/opchild/types/expected_keepers.go +++ b/x/opchild/types/expected_keepers.go @@ -1,53 +1,55 @@ package types import ( + context "context" + + "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + AddressCodec() address.Codec + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI - IterateAccounts(ctx sdk.Context, process func(authtypes.AccountI) (stop bool)) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // only used for simulation - HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, acc authtypes.AccountI) + IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool)) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation + HasAccount(ctx context.Context, addr sdk.AccAddress) bool + SetAccount(ctx context.Context, acc sdk.AccountI) GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI + GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, authtypes.ModuleAccountI) + SetModuleAccount(context.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + LockedCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins + SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins - GetSupply(ctx sdk.Context, denom string) sdk.Coin + GetSupply(ctx context.Context, denom string) sdk.Coin - SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx context.Context, senderPool, recipientPool string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error - BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error + MintCoins(ctx context.Context, moduleName string, amounts sdk.Coins) error + BurnCoins(ctx context.Context, moduleName string, amounts sdk.Coins) error } // ValidatorSet expected properties for the set of all validators (noalias) type ValidatorSet interface { // iterate through validators by operator address, execute func for each validator - IterateValidators(sdk.Context, - func(index int64, validator ValidatorI) (stop bool)) + IterateValidators(context.Context, func(validator ValidatorI) (stop bool, err error)) error - Validator(sdk.Context, sdk.ValAddress) ValidatorI // get a particular validator by operator address - ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) ValidatorI // get a particular validator by consensus address + Validator(context.Context, sdk.ValAddress) ValidatorI // get a particular validator by operator address + ValidatorByConsAddr(context.Context, sdk.ConsAddress) ValidatorI // get a particular validator by consensus address // MaxValidators returns the maximum amount of bonded validators - MaxValidators(sdk.Context) uint32 + MaxValidators(context.Context) (uint32, error) } diff --git a/x/opchild/types/exported.go b/x/opchild/types/exported.go index b2cff271..fc619175 100644 --- a/x/opchild/types/exported.go +++ b/x/opchild/types/exported.go @@ -3,20 +3,22 @@ package types import ( tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + "cosmossdk.io/math" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) // DelegationI delegation bond for a delegated proof of stake system type DelegationI interface { - GetDelegatorAddr() sdk.AccAddress // delegator sdk.AccAddress for the bond - GetValidatorAddr() sdk.ValAddress // validator operator address - GetShares() sdk.Dec // amount of validator's shares held in this delegation + GetDelegatorAddr() string // delegator sdk.AccAddress for the bond + GetValidatorAddr() string // validator operator address + GetShares() math.LegacyDec // amount of validator's shares held in this delegation } // ValidatorI expected validator functions type ValidatorI interface { - GetOperator() sdk.ValAddress // operator address to receive/return validators coins + GetOperator() string // operator address to receive/return validators coins ConsPubKey() (cryptotypes.PubKey, error) // validation consensus pubkey (cryptotypes.PubKey) TmConsPublicKey() (tmprotocrypto.PublicKey, error) // validation consensus pubkey (Tendermint) GetConsAddr() (sdk.ConsAddress, error) // validation consensus address diff --git a/x/opchild/types/genesis.go b/x/opchild/types/genesis.go index 46e22e9a..011efc41 100644 --- a/x/opchild/types/genesis.go +++ b/x/opchild/types/genesis.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" + "cosmossdk.io/core/address" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -32,12 +33,12 @@ func DefaultGenesisState() *GenesisState { // ValidateGenesis performs basic validation of rollup genesis data returning an // error for any failed validation criteria. -func ValidateGenesis(data *GenesisState) error { +func ValidateGenesis(data *GenesisState, ac address.Codec) error { if err := validateGenesisStateValidators(data.Validators); err != nil { return err } - return data.Params.Validate() + return data.Params.Validate(ac) } func validateGenesisStateValidators(validators []Validator) error { diff --git a/x/opchild/types/historical_info.go b/x/opchild/types/historical_info.go deleted file mode 100644 index 62bf5b53..00000000 --- a/x/opchild/types/historical_info.go +++ /dev/null @@ -1,64 +0,0 @@ -package types - -import ( - "sort" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - - "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" -) - -// NewHistoricalInfo will create a historical information struct from header and valset -// it will first sort valset before inclusion into historical info -func NewHistoricalInfo(header tmproto.Header, valSet Validators) HistoricalInfo { - // Must sort in the same way that tendermint does - sort.SliceStable(valSet, func(i, j int) bool { - return ValidatorsByVotingPower(valSet).Less(i, j) - }) - - return HistoricalInfo{ - Header: header, - Valset: valSet, - } -} - -// MustUnmarshalHistoricalInfo wll unmarshal historical info and panic on error -func MustUnmarshalHistoricalInfo(cdc codec.BinaryCodec, value []byte) HistoricalInfo { - hi, err := UnmarshalHistoricalInfo(cdc, value) - if err != nil { - panic(err) - } - - return hi -} - -// UnmarshalHistoricalInfo will unmarshal historical info and return any error -func UnmarshalHistoricalInfo(cdc codec.BinaryCodec, value []byte) (hi HistoricalInfo, err error) { - err = cdc.Unmarshal(value, &hi) - return hi, err -} - -// ValidateBasic will ensure HistoricalInfo is not nil and sorted -func ValidateBasic(hi HistoricalInfo) error { - if len(hi.Valset) == 0 { - return errors.Wrap(ErrInvalidHistoricalInfo, "validator set is empty") - } - - if !sort.IsSorted(Validators(hi.Valset)) { - return errors.Wrap(ErrInvalidHistoricalInfo, "validator set is not sorted by address") - } - - return nil -} - -// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (hi HistoricalInfo) UnpackInterfaces(c codectypes.AnyUnpacker) error { - for i := range hi.Valset { - if err := hi.Valset[i].UnpackInterfaces(c); err != nil { - return err - } - } - return nil -} diff --git a/x/opchild/types/hook.go b/x/opchild/types/hook.go index 86199b7e..22afded5 100644 --- a/x/opchild/types/hook.go +++ b/x/opchild/types/hook.go @@ -1,7 +1,9 @@ package types import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) -type BridgeHook = func(ctx sdk.Context, sender sdk.AccAddress, msgBytes []byte) error +type BridgeHook = func(ctx context.Context, sender sdk.AccAddress, msgBytes []byte) error diff --git a/x/opchild/types/keys.go b/x/opchild/types/keys.go index 13983a38..3dfbe415 100644 --- a/x/opchild/types/keys.go +++ b/x/opchild/types/keys.go @@ -1,13 +1,5 @@ package types -import ( - "encoding/binary" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" - "github.com/cosmos/cosmos-sdk/types/kv" -) - const ( // ModuleName is the name of the opchild module // module addr: init1gz9n8jnu9fgqw7vem9ud67gqjk5q4m2w0aejne @@ -23,61 +15,15 @@ const ( var ( // Keys for store prefixes // Last* values are constant during a block. - LastValidatorPowerKey = []byte{0x11} // prefix for each key to a validator index, for bonded validators - ProposerKey = []byte{0x12} // key for the proposer operator address + LastValidatorPowerPrefix = []byte{0x11} // prefix for each key to a validator index, for bonded validators - ValidatorsKey = []byte{0x21} // prefix for each key to a validator - ValidatorsByConsAddrKey = []byte{0x22} // prefix for each key to a validator index, by pubkey + ValidatorsPrefix = []byte{0x21} // prefix for each key to a validator + ValidatorsByConsAddrPrefix = []byte{0x22} // prefix for each key to a validator index, by pubkey - HistoricalInfoKey = []byte{0x31} // prefix for the historical info - ValidatorUpdatesKey = []byte{0x32} // prefix for the end block validator updates key + HistoricalInfoPrefix = []byte{0x31} // prefix for the historical info ParamsKey = []byte{0x41} // prefix for parameters for module x/opchild NextL2SequenceKey = []byte{0x51} // key for the outbound sequence number FinalizedL1SequenceKey = []byte{0x62} // prefix for finalized deposit sequences ) - -// GetValidatorKey creates the key for the validator with address -// VALUE: opchild/Validator -func GetValidatorKey(operatorAddr sdk.ValAddress) []byte { - return append(ValidatorsKey, address.MustLengthPrefix(operatorAddr)...) -} - -// GetValidatorByConsAddrKey creates the key for the validator with pubkey -// VALUE: validator operator address ([]byte) -func GetValidatorByConsAddrKey(addr sdk.ConsAddress) []byte { - return append(ValidatorsByConsAddrKey, address.MustLengthPrefix(addr)...) -} - -// AddressFromValidatorsKey creates the validator operator address from ValidatorsKey -func AddressFromValidatorsKey(key []byte) []byte { - kv.AssertKeyAtLeastLength(key, 3) - return key[2:] // remove prefix bytes and address length -} - -// AddressFromLastValidatorPowerKey creates the validator operator address from LastValidatorPowerKey -func AddressFromLastValidatorPowerKey(key []byte) []byte { - kv.AssertKeyAtLeastLength(key, 3) - return key[2:] // remove prefix bytes and address length -} - -// GetLastValidatorPowerKey creates the bonded validator index key for an operator address -func GetLastValidatorPowerKey(operator sdk.ValAddress) []byte { - return append(LastValidatorPowerKey, address.MustLengthPrefix(operator)...) -} - -// GetHistoricalInfoKey returns a key prefix for indexing HistoricalInfo objects. -func GetHistoricalInfoKey(height uint64) []byte { - _height := [8]byte{} - binary.BigEndian.PutUint64(_height[:], height) - - return append(HistoricalInfoKey, _height[:]...) -} - -func GetFinalizedL1SequenceKey(sequence uint64) []byte { - _sequence := [8]byte{} - binary.BigEndian.PutUint64(_sequence[:], sequence) - - return append(FinalizedL1SequenceKey, _sequence[:]...) -} diff --git a/x/opchild/types/params.go b/x/opchild/types/params.go index cc14edd0..2b937694 100644 --- a/x/opchild/types/params.go +++ b/x/opchild/types/params.go @@ -1,13 +1,15 @@ package types import ( + "cosmossdk.io/core/address" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "gopkg.in/yaml.v3" ) var ( - DefaultMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDecWithPrec(15, 2))) // 0.15 + DefaultMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecWithPrec(15, 2))) // 0.15 ) // DefaultParams returns default move parameters @@ -40,8 +42,8 @@ func (p Params) String() string { } // Validate performs basic validation on move parameters -func (p Params) Validate() error { - if _, err := sdk.AccAddressFromBech32(p.BridgeExecutor); err != nil { +func (p Params) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(p.BridgeExecutor); err != nil { return err } if err := p.MinGasPrices.Validate(); err != nil { diff --git a/x/opchild/types/tx.go b/x/opchild/types/tx.go index 2acdbe4f..3a9f894f 100644 --- a/x/opchild/types/tx.go +++ b/x/opchild/types/tx.go @@ -3,13 +3,13 @@ package types import ( "fmt" + "cosmossdk.io/core/address" errors "cosmossdk.io/errors" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdktx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/gogoproto/proto" @@ -40,14 +40,7 @@ var ( _ sdk.Msg = &MsgFinalizeTokenDeposit{} _ sdk.Msg = &MsgInitiateTokenWithdrawal{} - _ legacytx.LegacyMsg = &MsgExecuteMessages{} - _ legacytx.LegacyMsg = &MsgExecuteLegacyContents{} - _ legacytx.LegacyMsg = &MsgAddValidator{} - _ legacytx.LegacyMsg = &MsgRemoveValidator{} - _ legacytx.LegacyMsg = &MsgUpdateParams{} - _ legacytx.LegacyMsg = &MsgSpendFeePool{} - _ legacytx.LegacyMsg = &MsgFinalizeTokenDeposit{} - _ legacytx.LegacyMsg = &MsgInitiateTokenWithdrawal{} + _, _ codectypes.UnpackInterfacesMessage = &MsgExecuteMessages{}, &MsgExecuteLegacyContents{} ) // should refer initiavm/precompile/modules/minlib/sources/coin.move @@ -79,60 +72,20 @@ func (msg *MsgExecuteMessages) GetMsgs() ([]sdk.Msg, error) { return sdktx.GetMsgs(msg.Messages, "sdk.MsgProposal") } -// Route implements the sdk.Msg interface. -func (msg MsgExecuteMessages) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgExecuteMessages) Type() string { - return TypeMsgExecuteMessages -} - -// ValidateBasic performs basic MsgExecuteMessages message validation. -func (msg MsgExecuteMessages) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { +// Validate performs basic MsgExecuteMessages message validation. +func (msg MsgExecuteMessages) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(msg.Sender); err != nil { return err } - msgs, err := msg.GetMsgs() - if err != nil { - return err - } // Check Msgs length is non nil. if len(msg.Messages) == 0 { return errors.Wrap(govtypes.ErrNoProposalMsgs, "Msgs length must be non-zero") } - for idx, msg := range msgs { - if err := msg.ValidateBasic(); err != nil { - return errors.Wrapf(govtypes.ErrInvalidProposalMsg, "msg: %d, err: %s", idx, err.Error()) - } - - signers := msg.GetSigners() - if len(signers) != 1 { - return govtypes.ErrInvalidSigner - } - } - return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgExecuteMessages) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgExecuteMessages) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (m MsgExecuteMessages) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, m.Messages) @@ -191,19 +144,9 @@ func (m *MsgExecuteLegacyContents) SetContents(contents []govv1beta1.Content) er return nil } -// Route implements the sdk.Msg interface. -func (msg MsgExecuteLegacyContents) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgExecuteLegacyContents) Type() string { - return TypeMsgExecuteLegacyContents -} - -// ValidateBasic performs basic MsgExecuteLegacyContents message validation. -func (msg MsgExecuteLegacyContents) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { +// Validate performs basic MsgExecuteLegacyContents message validation. +func (msg MsgExecuteLegacyContents) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(msg.Sender); err != nil { return err } @@ -222,21 +165,6 @@ func (msg MsgExecuteLegacyContents) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgExecuteLegacyContents) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgExecuteLegacyContents) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (c MsgExecuteLegacyContents) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { for _, anyContent := range c.Contents { @@ -272,24 +200,14 @@ func NewMsgAddValidator( }, nil } -// Route implements the sdk.Msg interface. -func (msg MsgAddValidator) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgAddValidator) Type() string { - return TypeMsgAddValidator -} - -// ValidateBasic performs basic MsgAddValidator message validation. -func (msg MsgAddValidator) ValidateBasic() error { +// Validate performs basic MsgAddValidator message validation. +func (msg MsgAddValidator) Validate(ac address.Codec, vc address.Codec) error { // note that unmarshaling from bech32 ensures both non-empty and valid - _, err := sdk.AccAddressFromBech32(msg.Authority) + _, err := ac.StringToBytes(msg.Authority) if err != nil { return sdkerrors.ErrInvalidAddress.Wrapf("invalid delegator address: %s", err) } - _, err = sdk.ValAddressFromBech32(msg.ValidatorAddress) + _, err = vc.StringToBytes(msg.ValidatorAddress) if err != nil { return sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err) } @@ -301,27 +219,6 @@ func (msg MsgAddValidator) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgAddValidator) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgAddValidator) GetSigners() []sdk.AccAddress { - // delegator is first signer so delegator pays fees - delegator, _ := sdk.AccAddressFromBech32(msg.Authority) - addrs := []sdk.AccAddress{delegator} - valAddr, _ := sdk.ValAddressFromBech32(msg.ValidatorAddress) - - valAccAddr := sdk.AccAddress(valAddr) - if !delegator.Equals(valAccAddr) { - addrs = append(addrs, valAccAddr) - } - - return addrs -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (msg MsgAddValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var pubKey cryptotypes.PubKey @@ -341,44 +238,19 @@ func NewMsgRemoveValidator( }, nil } -// Route implements the sdk.Msg interface. -func (msg MsgRemoveValidator) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgRemoveValidator) Type() string { - return TypeMsgRemoveValidator -} - -// ValidateBasic performs basic MsgRemoveValidator message validation. -func (msg MsgRemoveValidator) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { +// Validate performs basic MsgRemoveValidator message validation. +func (msg MsgRemoveValidator) Validate(ac, vc address.Codec) error { + if _, err := ac.StringToBytes(msg.Authority); err != nil { return err } - if _, err := sdk.ValAddressFromBech32(msg.ValidatorAddress); err != nil { + if _, err := vc.StringToBytes(msg.ValidatorAddress); err != nil { return err } return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgRemoveValidator) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgRemoveValidator) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - /* MsgInitiateTokenWithdrawal */ // NewMsgInitiateTokenWithdrawal creates a new MsgInitiateTokenWithdrawal instance. @@ -394,23 +266,13 @@ func NewMsgInitiateTokenWithdrawal( } } -// Route implements the sdk.Msg interface. -func (msg MsgInitiateTokenWithdrawal) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgInitiateTokenWithdrawal) Type() string { - return TypeMsgInitiateTokenWithdrawal -} - -// ValidateBasic performs basic MsgInitiateTokenWithdrawal message validation. -func (msg MsgInitiateTokenWithdrawal) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { +// Validate performs basic MsgInitiateTokenWithdrawal message validation. +func (msg MsgInitiateTokenWithdrawal) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(msg.Sender); err != nil { return err } - if _, err := sdk.AccAddressFromBech32(msg.To); err != nil { + if _, err := ac.StringToBytes(msg.To); err != nil { return err } @@ -421,21 +283,6 @@ func (msg MsgInitiateTokenWithdrawal) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgInitiateTokenWithdrawal) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgInitiateTokenWithdrawal) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - /* MsgFinalizeTokenDeposit */ // NewMsgFinalizeTokenDeposit creates a new MsgFinalizeTokenDeposit instance. @@ -455,27 +302,17 @@ func NewMsgFinalizeTokenDeposit( } } -// Route implements the sdk.Msg interface. -func (msg MsgFinalizeTokenDeposit) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgFinalizeTokenDeposit) Type() string { - return TypeMsgFinalizeTokenDeposit -} - -// ValidateBasic performs basic MsgFinalizeTokenDeposit message validation. -func (msg MsgFinalizeTokenDeposit) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { +// Validate performs basic MsgFinalizeTokenDeposit message validation. +func (msg MsgFinalizeTokenDeposit) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(msg.Sender); err != nil { return err } - if _, err := sdk.AccAddressFromBech32(msg.From); err != nil { + if _, err := ac.StringToBytes(msg.From); err != nil { return err } - if _, err := sdk.AccAddressFromBech32(msg.To); err != nil { + if _, err := ac.StringToBytes(msg.To); err != nil { return err } @@ -490,21 +327,6 @@ func (msg MsgFinalizeTokenDeposit) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgFinalizeTokenDeposit) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgFinalizeTokenDeposit) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - /* MsgUpdateParams */ // NewMsgUpdateParams returns a new MsgUpdateParams instance @@ -515,44 +337,19 @@ func NewMsgUpdateParams(authority sdk.AccAddress, params *Params) *MsgUpdatePara } } -// Route implements the sdk.Msg interface. -func (msg MsgUpdateParams) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgUpdateParams) Type() string { - return TypeMsgUpdateParams -} - -// ValidateBasic performs basic MsgUpdateParams message validation. -func (msg MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { +// Validate performs basic MsgUpdateParams message validation. +func (msg MsgUpdateParams) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(msg.Authority); err != nil { return err } - if err := msg.Params.Validate(); err != nil { + if err := msg.Params.Validate(ac); err != nil { return err } return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - /* MsgSpendFeePool */ // NewMsgSpendFeePool creates a new MsgSpendFeePool @@ -564,23 +361,13 @@ func NewMsgSpendFeePool(authority, recipient sdk.AccAddress, amount sdk.Coins) * } } -// Route implements the sdk.Msg interface. -func (msg MsgSpendFeePool) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgSpendFeePool) Type() string { - return TypeMsgSpendFeePool -} - -// ValidateBasic performs basic MsgSpendFeePool message validation. -func (msg MsgSpendFeePool) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { +// Validate performs basic MsgSpendFeePool message validation. +func (msg MsgSpendFeePool) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(msg.Authority); err != nil { return err } - if _, err := sdk.AccAddressFromBech32(msg.Recipient); err != nil { + if _, err := ac.StringToBytes(msg.Recipient); err != nil { return err } @@ -590,18 +377,3 @@ func (msg MsgSpendFeePool) ValidateBasic() error { return nil } - -// GetSignBytes returns the message bytes to sign over. -func (msg MsgSpendFeePool) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgSpendFeePool) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} diff --git a/x/opchild/types/types.pb.go b/x/opchild/types/types.pb.go index af3949d6..659b2de5 100644 --- a/x/opchild/types/types.pb.go +++ b/x/opchild/types/types.pb.go @@ -5,10 +5,9 @@ package types import ( fmt "fmt" - types3 "github.com/cometbft/cometbft/abci/types" - types1 "github.com/cometbft/cometbft/proto/tendermint/types" + types2 "github.com/cometbft/cometbft/abci/types" _ "github.com/cosmos/cosmos-proto" - types2 "github.com/cosmos/cosmos-sdk/codec/types" + types1 "github.com/cosmos/cosmos-sdk/codec/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" @@ -74,48 +73,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -// HistoricalInfo contains header and validator information for a given block. -// It is stored as part of rollup module's state, which persists the `n` most -// recent HistoricalInfo -// (`n` is set by the rollup module's `historical_entries` parameter). -type HistoricalInfo struct { - Header types1.Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` - Valset []Validator `protobuf:"bytes,2,rep,name=valset,proto3" json:"valset"` -} - -func (m *HistoricalInfo) Reset() { *m = HistoricalInfo{} } -func (m *HistoricalInfo) String() string { return proto.CompactTextString(m) } -func (*HistoricalInfo) ProtoMessage() {} -func (*HistoricalInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_2cc6df244b706d68, []int{1} -} -func (m *HistoricalInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HistoricalInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HistoricalInfo.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 *HistoricalInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_HistoricalInfo.Merge(m, src) -} -func (m *HistoricalInfo) XXX_Size() int { - return m.Size() -} -func (m *HistoricalInfo) XXX_DiscardUnknown() { - xxx_messageInfo_HistoricalInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_HistoricalInfo proto.InternalMessageInfo - // Validator defines a validator, together with the total amount of the // Validator's bond shares and their exchange rate to coins. Slashing results in // a decrease in the exchange rate, allowing correct calculation of future @@ -131,14 +88,14 @@ type Validator struct { OperatorAddress string `protobuf:"bytes,2,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty" yaml:"operator_address"` // consensus_pubkey is the consensus public key of the validator, // as a Protobuf Any. - ConsensusPubkey *types2.Any `protobuf:"bytes,3,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey,omitempty" yaml:"consensus_pubkey"` + ConsensusPubkey *types1.Any `protobuf:"bytes,3,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey,omitempty" yaml:"consensus_pubkey"` ConsPower int64 `protobuf:"varint,4,opt,name=cons_power,json=consPower,proto3" json:"cons_power,omitempty" yaml:"cons_power"` } func (m *Validator) Reset() { *m = Validator{} } func (*Validator) ProtoMessage() {} func (*Validator) Descriptor() ([]byte, []int) { - return fileDescriptor_2cc6df244b706d68, []int{2} + return fileDescriptor_2cc6df244b706d68, []int{1} } func (m *Validator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -171,14 +128,14 @@ var xxx_messageInfo_Validator proto.InternalMessageInfo // TODO: explore moving this to proto/cosmos/base to separate modules // from tendermint dependence type ValidatorUpdates struct { - Updates []types3.ValidatorUpdate `protobuf:"bytes,1,rep,name=updates,proto3" json:"updates"` + Updates []types2.ValidatorUpdate `protobuf:"bytes,1,rep,name=updates,proto3" json:"updates"` } func (m *ValidatorUpdates) Reset() { *m = ValidatorUpdates{} } func (m *ValidatorUpdates) String() string { return proto.CompactTextString(m) } func (*ValidatorUpdates) ProtoMessage() {} func (*ValidatorUpdates) Descriptor() ([]byte, []int) { - return fileDescriptor_2cc6df244b706d68, []int{3} + return fileDescriptor_2cc6df244b706d68, []int{2} } func (m *ValidatorUpdates) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -209,7 +166,6 @@ var xxx_messageInfo_ValidatorUpdates proto.InternalMessageInfo func init() { proto.RegisterType((*Params)(nil), "opinit.opchild.v1.Params") - proto.RegisterType((*HistoricalInfo)(nil), "opinit.opchild.v1.HistoricalInfo") proto.RegisterType((*Validator)(nil), "opinit.opchild.v1.Validator") proto.RegisterType((*ValidatorUpdates)(nil), "opinit.opchild.v1.ValidatorUpdates") } @@ -217,55 +173,51 @@ func init() { func init() { proto.RegisterFile("opinit/opchild/v1/types.proto", fileDescriptor_2cc6df244b706d68) } var fileDescriptor_2cc6df244b706d68 = []byte{ - // 766 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x54, 0xcf, 0x6f, 0xe3, 0x44, - 0x14, 0xb6, 0x9b, 0x55, 0x56, 0x99, 0xdd, 0x4d, 0x1b, 0x2b, 0x0b, 0x6e, 0xbb, 0x6b, 0x47, 0x3e, - 0x55, 0x0b, 0xb1, 0x95, 0x5d, 0x24, 0xa4, 0x70, 0x80, 0x1a, 0x0a, 0x45, 0x45, 0x6a, 0x64, 0x04, - 0x07, 0x2e, 0x66, 0x6c, 0x4f, 0x9d, 0x51, 0xe3, 0x19, 0xcb, 0x33, 0x09, 0xc9, 0x7f, 0x80, 0xb8, - 0xc0, 0x81, 0x03, 0xc7, 0x1c, 0x0b, 0xa7, 0x1e, 0xb8, 0xf1, 0x0f, 0x54, 0x9c, 0x2a, 0x4e, 0x9c, - 0x0c, 0xa4, 0x87, 0xf6, 0x9c, 0xbf, 0x00, 0xd9, 0x33, 0xf9, 0xd1, 0xf4, 0x92, 0xcc, 0x7b, 0xdf, - 0xf7, 0xde, 0x8c, 0xbf, 0xef, 0xcd, 0x80, 0x97, 0x34, 0xc5, 0x04, 0x73, 0x87, 0xa6, 0x61, 0x1f, - 0x0f, 0x22, 0x67, 0xd4, 0x71, 0xf8, 0x24, 0x45, 0xcc, 0x4e, 0x33, 0xca, 0xa9, 0xd6, 0x10, 0xb0, - 0x2d, 0x61, 0x7b, 0xd4, 0xd9, 0x6b, 0xc0, 0x04, 0x13, 0xea, 0x94, 0xbf, 0x82, 0xb5, 0x67, 0x84, - 0x94, 0x25, 0x94, 0x39, 0x01, 0x64, 0xc8, 0x19, 0x75, 0x02, 0xc4, 0x61, 0xc7, 0x09, 0x29, 0x26, - 0x12, 0xdf, 0x15, 0xb8, 0x5f, 0x46, 0x8e, 0x08, 0x24, 0xd4, 0x8c, 0x69, 0x4c, 0x45, 0xbe, 0x58, - 0x2d, 0x0a, 0x62, 0x4a, 0xe3, 0x01, 0x72, 0xca, 0x28, 0x18, 0x9e, 0x39, 0x90, 0x4c, 0x24, 0xb4, - 0xcf, 0x11, 0x89, 0x50, 0x96, 0x60, 0xc2, 0x1d, 0x18, 0x84, 0x78, 0xfd, 0xb8, 0x7b, 0x2f, 0xd6, - 0xc0, 0x32, 0xbf, 0x8e, 0x5a, 0xbf, 0x56, 0x40, 0xb5, 0x07, 0x33, 0x98, 0x30, 0xed, 0x23, 0x50, - 0x4f, 0xe0, 0xd8, 0x1f, 0xc1, 0x01, 0x8e, 0x20, 0xa7, 0x19, 0xd3, 0xd5, 0x96, 0x7a, 0xf0, 0xcc, - 0xdd, 0x9d, 0xe7, 0xe6, 0xf3, 0x09, 0x4c, 0x06, 0x5d, 0xeb, 0x3e, 0x6e, 0x79, 0xcf, 0x12, 0x38, - 0xfe, 0x7a, 0x19, 0x6b, 0x5f, 0x00, 0xad, 0x8f, 0x19, 0xa7, 0x19, 0x0e, 0xe1, 0xc0, 0x47, 0x84, - 0x67, 0x18, 0x31, 0x7d, 0xab, 0xec, 0xf2, 0x72, 0x9e, 0x9b, 0xbb, 0xa2, 0xcb, 0x43, 0x8e, 0xe5, - 0x35, 0x56, 0xc9, 0x23, 0x91, 0xd3, 0x7e, 0x54, 0x41, 0x3d, 0xc1, 0xc4, 0x8f, 0x61, 0xa1, 0x12, - 0x0e, 0x11, 0xd3, 0x2b, 0xad, 0xca, 0xc1, 0x93, 0xd7, 0x2f, 0x6c, 0x29, 0x57, 0xa1, 0xad, 0x2d, - 0xb5, 0xb5, 0x3f, 0x41, 0xe1, 0xc7, 0x14, 0x13, 0xf7, 0xe4, 0x2a, 0x37, 0x95, 0x79, 0x6e, 0x36, - 0xe5, 0x91, 0xd7, 0x3b, 0x58, 0xbf, 0xfd, 0x63, 0xbe, 0x13, 0x63, 0xde, 0x1f, 0x06, 0x76, 0x48, - 0x13, 0x29, 0xbb, 0xfc, 0x6b, 0xb3, 0xe8, 0x5c, 0x6a, 0x23, 0x7b, 0x31, 0xef, 0x69, 0x82, 0xc9, - 0x67, 0x90, 0xf5, 0xca, 0xed, 0xb5, 0x6f, 0xc1, 0x76, 0x90, 0xe1, 0x28, 0x46, 0x3e, 0x1a, 0xa3, - 0x70, 0xc8, 0x69, 0xa6, 0x3f, 0x6a, 0xa9, 0x07, 0x35, 0xf7, 0xfd, 0x79, 0x6e, 0xbe, 0x25, 0xf6, - 0xdb, 0x20, 0x58, 0x7f, 0xfd, 0xde, 0x6e, 0xca, 0xe3, 0x1e, 0x46, 0x51, 0x86, 0x18, 0xfb, 0x92, - 0x67, 0x98, 0xc4, 0x17, 0xb7, 0x97, 0xaf, 0x54, 0xaf, 0x2e, 0xe8, 0x47, 0x92, 0xdd, 0xdd, 0xff, - 0x65, 0x6a, 0x2a, 0x77, 0x53, 0x53, 0xfd, 0xe1, 0xf6, 0xf2, 0x55, 0x7d, 0x31, 0x80, 0xc2, 0x20, - 0xeb, 0x67, 0x15, 0xd4, 0x8f, 0x97, 0x32, 0x7d, 0x4e, 0xce, 0xa8, 0xf6, 0x01, 0xa8, 0xf6, 0x11, - 0x8c, 0x50, 0x56, 0x7a, 0xf5, 0xe4, 0xb5, 0x6e, 0xaf, 0xdc, 0xb6, 0xc5, 0xb7, 0x1c, 0x97, 0xb8, - 0x5b, 0x2b, 0x64, 0x11, 0x9b, 0xca, 0x12, 0xed, 0x43, 0x50, 0x1d, 0xc1, 0x01, 0x43, 0x5c, 0xdf, - 0x92, 0xba, 0x3e, 0x98, 0x6c, 0x7b, 0xe9, 0xee, 0xbd, 0x06, 0xa2, 0xac, 0xfb, 0xe8, 0x6e, 0x6a, - 0x2a, 0xd6, 0x1f, 0x5b, 0xa0, 0xb6, 0xa4, 0x69, 0xef, 0x82, 0xc7, 0x09, 0x25, 0xf8, 0x5c, 0x1e, - 0xa9, 0xe6, 0x6a, 0xf3, 0xdc, 0xac, 0x4b, 0x2f, 0x04, 0x60, 0x79, 0x0b, 0x8a, 0xf6, 0x29, 0xd8, - 0xa1, 0x29, 0xca, 0x8a, 0x4a, 0x1f, 0x0a, 0x79, 0xca, 0x79, 0xa9, 0xb9, 0xfb, 0xf3, 0xdc, 0x7c, - 0x5b, 0x94, 0x6d, 0x32, 0x2c, 0x6f, 0x7b, 0x91, 0x92, 0x92, 0x6a, 0x1c, 0xec, 0x84, 0x94, 0x30, - 0x44, 0xd8, 0x90, 0xf9, 0xe9, 0x30, 0x38, 0x47, 0x13, 0xbd, 0x52, 0x2a, 0xd2, 0xb4, 0xc5, 0xbd, - 0xb1, 0x17, 0xf7, 0xc6, 0x3e, 0x24, 0x13, 0xf7, 0xcd, 0xaa, 0xfb, 0x66, 0x9d, 0xf5, 0xe7, 0xca, - 0xb1, 0x30, 0x9b, 0xa4, 0x9c, 0xda, 0xbd, 0x61, 0x70, 0x82, 0x26, 0xde, 0xf6, 0x92, 0xda, 0x2b, - 0x99, 0xda, 0x7b, 0x00, 0x14, 0x29, 0x3f, 0xa5, 0xdf, 0x21, 0x31, 0x0a, 0x15, 0xf7, 0xf9, 0x3c, - 0x37, 0x1b, 0xab, 0xce, 0x02, 0xb3, 0xbc, 0x5a, 0x11, 0xf4, 0x8a, 0x75, 0xf7, 0xe9, 0xf7, 0x53, - 0x53, 0x91, 0x3e, 0x2b, 0x96, 0x0f, 0x76, 0x96, 0xe2, 0x7d, 0x95, 0x46, 0x90, 0x23, 0xa6, 0x1d, - 0x81, 0xc7, 0x43, 0xb1, 0xd4, 0xd5, 0xd2, 0x99, 0xd6, 0xba, 0xad, 0xc5, 0x0d, 0xb7, 0x37, 0x6a, - 0xd6, 0xdd, 0x59, 0xd4, 0x0a, 0x7b, 0xdc, 0xd3, 0xab, 0xff, 0x0c, 0xe5, 0x62, 0x66, 0xa8, 0x57, - 0x33, 0x43, 0xbd, 0x9e, 0x19, 0xea, 0xbf, 0x33, 0x43, 0xfd, 0xe9, 0xc6, 0x50, 0xae, 0x6f, 0x0c, - 0xe5, 0xef, 0x1b, 0x43, 0xf9, 0xa6, 0xbd, 0x76, 0x23, 0x0a, 0xff, 0x31, 0x6c, 0x0f, 0x60, 0xc0, - 0x9c, 0xd3, 0x5e, 0xf9, 0x0c, 0x8e, 0x97, 0x0f, 0x61, 0x39, 0x50, 0x41, 0xb5, 0x54, 0xf2, 0xcd, - 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x3f, 0x19, 0x74, 0x27, 0x05, 0x00, 0x00, + // 698 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x54, 0xb1, 0x6f, 0xd3, 0x4e, + 0x14, 0xb6, 0x9b, 0xaa, 0x55, 0xdc, 0x36, 0x6d, 0xac, 0xf4, 0xf7, 0x4b, 0x5b, 0x6a, 0x47, 0x9e, + 0xa2, 0x42, 0x6c, 0xa5, 0x45, 0x42, 0xca, 0x44, 0x0d, 0x85, 0xa1, 0x48, 0x8d, 0x8c, 0x60, 0x60, + 0x31, 0x67, 0xfb, 0x70, 0x4f, 0x8d, 0xef, 0x2c, 0xdf, 0x25, 0x24, 0xff, 0x01, 0x62, 0x81, 0x91, + 0xb1, 0x63, 0x61, 0xea, 0xc0, 0xc6, 0x3f, 0x50, 0x31, 0x55, 0x4c, 0x4c, 0x06, 0xd2, 0xa1, 0xcc, + 0xf9, 0x0b, 0x90, 0x7d, 0x97, 0xa4, 0x84, 0x25, 0xb9, 0xf7, 0xbe, 0xef, 0xbd, 0x7b, 0xfe, 0xee, + 0xbb, 0x53, 0xb6, 0x49, 0x8c, 0x30, 0x62, 0x16, 0x89, 0xfd, 0x63, 0xd4, 0x09, 0xac, 0x5e, 0xd3, + 0x62, 0x83, 0x18, 0x52, 0x33, 0x4e, 0x08, 0x23, 0x6a, 0x99, 0xc3, 0xa6, 0x80, 0xcd, 0x5e, 0x73, + 0xb3, 0x0c, 0x22, 0x84, 0x89, 0x95, 0xff, 0x72, 0xd6, 0xa6, 0xe6, 0x13, 0x1a, 0x11, 0x6a, 0x79, + 0x80, 0x42, 0xab, 0xd7, 0xf4, 0x20, 0x03, 0x4d, 0xcb, 0x27, 0x08, 0x0b, 0x7c, 0x83, 0xe3, 0x6e, + 0x1e, 0x59, 0x3c, 0x10, 0x50, 0x25, 0x24, 0x21, 0xe1, 0xf9, 0x6c, 0x35, 0x2e, 0x08, 0x09, 0x09, + 0x3b, 0xd0, 0xca, 0x23, 0xaf, 0xfb, 0xca, 0x02, 0x78, 0x20, 0xa0, 0x2d, 0x06, 0x71, 0x00, 0x93, + 0x08, 0x61, 0x66, 0x01, 0xcf, 0x47, 0x37, 0xc7, 0x35, 0x3e, 0x16, 0x94, 0x85, 0x36, 0x48, 0x40, + 0x44, 0xd5, 0xfb, 0x4a, 0x29, 0x02, 0x7d, 0xb7, 0x07, 0x3a, 0x28, 0x00, 0x8c, 0x24, 0xb4, 0x2a, + 0xd7, 0xe4, 0xfa, 0x8a, 0xbd, 0x31, 0x4a, 0xf5, 0xf5, 0x01, 0x88, 0x3a, 0x2d, 0xe3, 0x6f, 0xdc, + 0x70, 0x56, 0x22, 0xd0, 0x7f, 0x3e, 0x89, 0xd5, 0x27, 0x8a, 0x7a, 0x8c, 0x28, 0x23, 0x09, 0xf2, + 0x41, 0xc7, 0x85, 0x98, 0x25, 0x08, 0xd2, 0xea, 0x5c, 0xde, 0x65, 0x7b, 0x94, 0xea, 0x1b, 0xbc, + 0xcb, 0xbf, 0x1c, 0xc3, 0x29, 0x4f, 0x93, 0x07, 0x3c, 0xa7, 0xbe, 0x93, 0x95, 0x52, 0x84, 0xb0, + 0x1b, 0x82, 0x4c, 0x07, 0xe4, 0x43, 0x5a, 0x2d, 0xd4, 0x0a, 0xf5, 0xa5, 0xdd, 0x5b, 0xa6, 0x10, + 0x24, 0x53, 0xcf, 0x14, 0xea, 0x99, 0x0f, 0xa1, 0xff, 0x80, 0x20, 0x6c, 0x1f, 0x5e, 0xa4, 0xba, + 0x34, 0x4a, 0xf5, 0x8a, 0x18, 0xf9, 0x66, 0x07, 0xe3, 0xd3, 0x0f, 0xfd, 0x76, 0x88, 0xd8, 0x71, + 0xd7, 0x33, 0x7d, 0x12, 0x09, 0x61, 0xc5, 0x5f, 0x83, 0x06, 0x27, 0x42, 0x1b, 0xd1, 0x8b, 0x3a, + 0xcb, 0x11, 0xc2, 0x8f, 0x01, 0x6d, 0xe7, 0xdb, 0xab, 0x2f, 0x95, 0x55, 0x2f, 0x41, 0x41, 0x08, + 0x5d, 0xd8, 0x87, 0x7e, 0x97, 0x91, 0xa4, 0x3a, 0x5f, 0x93, 0xeb, 0x45, 0xfb, 0xde, 0x28, 0xd5, + 0xff, 0xe3, 0xfb, 0xcd, 0x10, 0x8c, 0x6f, 0x9f, 0x1b, 0x15, 0x31, 0xee, 0x7e, 0x10, 0x24, 0x90, + 0xd2, 0xa7, 0x2c, 0x41, 0x38, 0x3c, 0xbb, 0x3e, 0xdf, 0x91, 0x9d, 0x12, 0xa7, 0x1f, 0x08, 0x76, + 0x6b, 0xeb, 0xc3, 0xa9, 0x2e, 0xfd, 0x3e, 0xd5, 0xe5, 0xb7, 0xd7, 0xe7, 0x3b, 0xa5, 0xb1, 0xc5, + 0xf8, 0x01, 0x19, 0x5f, 0xe6, 0x94, 0xe2, 0x44, 0x6d, 0xf5, 0x8e, 0xb2, 0x18, 0x11, 0x8c, 0x4e, + 0x60, 0x92, 0x9f, 0x53, 0xd1, 0x56, 0x47, 0xa9, 0x5e, 0x12, 0x1f, 0xcd, 0x01, 0xc3, 0x19, 0x53, + 0xd4, 0x47, 0xca, 0x1a, 0x89, 0x61, 0x92, 0x55, 0xba, 0x80, 0xcf, 0x91, 0x1f, 0x4c, 0xd1, 0xde, + 0x1a, 0xa5, 0xfa, 0xff, 0xbc, 0x6c, 0x96, 0x61, 0x38, 0xab, 0xe3, 0x94, 0x98, 0x5d, 0x65, 0xca, + 0x9a, 0x4f, 0x30, 0x85, 0x98, 0x76, 0xa9, 0x1b, 0x77, 0xbd, 0x13, 0x38, 0xa8, 0x16, 0x6a, 0x72, + 0x7d, 0x69, 0xb7, 0x62, 0x72, 0x0b, 0x9a, 0x63, 0x0b, 0x9a, 0xfb, 0x78, 0x60, 0xef, 0x4d, 0xbb, + 0xcf, 0xd6, 0x19, 0x5f, 0xa7, 0xd2, 0xf8, 0xc9, 0x20, 0x66, 0xc4, 0x6c, 0x77, 0xbd, 0x43, 0x38, + 0x70, 0x56, 0x27, 0xd4, 0x76, 0xce, 0x54, 0xef, 0x2a, 0x4a, 0x96, 0x72, 0x63, 0xf2, 0x1a, 0x72, + 0xcd, 0x0b, 0xf6, 0xfa, 0x28, 0xd5, 0xcb, 0xd3, 0xce, 0x1c, 0x33, 0x9c, 0x62, 0x16, 0xb4, 0xb3, + 0x75, 0x6b, 0xf9, 0xcd, 0xa9, 0x2e, 0x09, 0x41, 0x25, 0xc3, 0x55, 0xd6, 0x26, 0xe2, 0x3d, 0x8b, + 0x03, 0xc0, 0x20, 0x55, 0x0f, 0x94, 0xc5, 0x2e, 0x5f, 0x56, 0xe5, 0xdc, 0x5a, 0x35, 0x73, 0x7a, + 0x59, 0xcc, 0xec, 0xb2, 0x98, 0x33, 0x35, 0x76, 0x31, 0xb3, 0x17, 0x3f, 0xbc, 0x71, 0x6d, 0x6b, + 0x3e, 0xdb, 0xc0, 0x3e, 0xba, 0xf8, 0xa5, 0x49, 0x67, 0x43, 0x4d, 0xbe, 0x18, 0x6a, 0xf2, 0xe5, + 0x50, 0x93, 0x7f, 0x0e, 0x35, 0xf9, 0xfd, 0x95, 0x26, 0x5d, 0x5e, 0x69, 0xd2, 0xf7, 0x2b, 0x4d, + 0x7a, 0xd1, 0xb8, 0x61, 0xbd, 0xec, 0x91, 0x40, 0xa0, 0xd1, 0x01, 0x1e, 0xb5, 0x8e, 0xda, 0xf9, + 0x8b, 0xd2, 0x9f, 0xbc, 0x29, 0xb9, 0x0b, 0xbd, 0x85, 0x5c, 0xc9, 0xbd, 0x3f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x02, 0x06, 0xae, 0x2b, 0x72, 0x04, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -360,53 +312,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *HistoricalInfo) 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 *HistoricalInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HistoricalInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Valset) > 0 { - for iNdEx := len(m.Valset) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Valset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *Validator) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -534,23 +439,6 @@ func (m *Params) Size() (n int) { return n } -func (m *HistoricalInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Header.Size() - n += 1 + l + sovTypes(uint64(l)) - if len(m.Valset) > 0 { - for _, e := range m.Valset { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - return n -} - func (m *Validator) Size() (n int) { if m == nil { return 0 @@ -750,123 +638,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } -func (m *HistoricalInfo) 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 ErrIntOverflowTypes - } - 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: HistoricalInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HistoricalInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Valset", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Valset = append(m.Valset, Validator{}) - if err := m.Valset[len(m.Valset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Validator) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -990,7 +761,7 @@ func (m *Validator) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.ConsensusPubkey == nil { - m.ConsensusPubkey = &types2.Any{} + m.ConsensusPubkey = &types1.Any{} } if err := m.ConsensusPubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1094,7 +865,7 @@ func (m *ValidatorUpdates) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Updates = append(m.Updates, types3.ValidatorUpdate{}) + m.Updates = append(m.Updates, types2.ValidatorUpdate{}) if err := m.Updates[len(m.Updates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/opchild/types/validator.go b/x/opchild/types/validator.go index 11495b19..ff965267 100644 --- a/x/opchild/types/validator.go +++ b/x/opchild/types/validator.go @@ -9,6 +9,7 @@ import ( tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "sigs.k8s.io/yaml" + "cosmossdk.io/core/address" "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -67,10 +68,13 @@ func (v Validator) GetMoniker() string { } // Validators is a collection of Validator -type Validators []Validator +type Validators struct { + Validators []Validator + ValidatorCodec address.Codec +} func (v Validators) String() (out string) { - for _, val := range v { + for _, val := range v.Validators { out += val.String() + "\n" } @@ -79,7 +83,7 @@ func (v Validators) String() (out string) { // ToSDKValidators - convenience function convert []Validator to []sdk.ValidatorI func (v Validators) ToSDKValidators() (validators []ValidatorI) { - for _, val := range v { + for _, val := range v.Validators { validators = append(validators, val) } @@ -93,17 +97,26 @@ func (v Validators) Sort() { // Implements sort interface func (v Validators) Len() int { - return len(v) + return len(v.Validators) } // Implements sort interface func (v Validators) Less(i, j int) bool { - return bytes.Compare(v[i].GetOperator().Bytes(), v[j].GetOperator().Bytes()) == -1 + vi, err := v.ValidatorCodec.StringToBytes(v.Validators[i].GetOperator()) + if err != nil { + panic(err) + } + vj, err := v.ValidatorCodec.StringToBytes(v.Validators[j].GetOperator()) + if err != nil { + panic(err) + } + + return bytes.Compare(vi, vj) == -1 } // Implements sort interface func (v Validators) Swap(i, j int) { - v[i], v[j] = v[j], v[i] + v.Validators[i], v.Validators[j] = v.Validators[j], v.Validators[i] } // ValidatorsByVotingPower implements sort.Interface for []Validator based on @@ -133,8 +146,8 @@ func (valz ValidatorsByVotingPower) Swap(i, j int) { // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (v Validators) UnpackInterfaces(c codectypes.AnyUnpacker) error { - for i := range v { - if err := v[i].UnpackInterfaces(c); err != nil { + for i := range v.Validators { + if err := v.Validators[i].UnpackInterfaces(c); err != nil { return err } } @@ -200,15 +213,8 @@ func (v *Validator) Equal(v2 *Validator) bool { v.ConsensusPubkey.Equal(v2.ConsensusPubkey) } -func (v Validator) GetOperator() sdk.ValAddress { - if v.OperatorAddress == "" { - return nil - } - addr, err := sdk.ValAddressFromBech32(v.OperatorAddress) - if err != nil { - panic(err) - } - return addr +func (v Validator) GetOperator() string { + return v.OperatorAddress } // ConsPubKey returns the validator PubKey as a cryptotypes.PubKey. diff --git a/x/ophost/client/cli/query.go b/x/ophost/client/cli/query.go index 0a469d70..c0418b76 100644 --- a/x/ophost/client/cli/query.go +++ b/x/ophost/client/cli/query.go @@ -1,13 +1,17 @@ package cli import ( + "cosmossdk.io/core/address" "github.com/cosmos/cosmos-sdk/client" + "github.com/initia-labs/OPinit/x/ophost/types" + "github.com/spf13/cobra" ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd() *cobra.Command { +// TODO implement query cmd +func GetQueryCmd(ac address.Codec) *cobra.Command { ophostQueryCmd := &cobra.Command{ Use: types.ModuleName, Short: "Querying commands for the ophost module", diff --git a/x/ophost/client/cli/tx.go b/x/ophost/client/cli/tx.go index c54c0f9d..0ea9f452 100644 --- a/x/ophost/client/cli/tx.go +++ b/x/ophost/client/cli/tx.go @@ -10,6 +10,8 @@ import ( "strings" "time" + "cosmossdk.io/core/address" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -20,7 +22,7 @@ import ( ) // GetTxCmd returns a root CLI command handler for all x/ophost transaction commands. -func GetTxCmd() *cobra.Command { +func GetTxCmd(ac address.Codec) *cobra.Command { ophostTxCmd := &cobra.Command{ Use: types.ModuleName, Short: "OPHost transaction subcommands", @@ -30,19 +32,19 @@ func GetTxCmd() *cobra.Command { } ophostTxCmd.AddCommand( - NewRecordBatchCmd(), - NewCreateBridge(), - NewProposeOutput(), - NewDeleteOutput(), - NewInitiateTokenDeposit(), - NewFinalizeTokenWithdrawal(), + NewRecordBatchCmd(ac), + NewCreateBridge(ac), + NewProposeOutput(ac), + NewDeleteOutput(ac), + NewInitiateTokenDeposit(ac), + NewFinalizeTokenWithdrawal(ac), ) return ophostTxCmd } // NewRecordBatchCmd returns a CLI command handler for transaction to submitting a batch record. -func NewRecordBatchCmd() *cobra.Command { +func NewRecordBatchCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "record-batch [bridge_id] [base64-encoded-batch-bytes]", Short: "send a batch-recording tx", @@ -64,7 +66,7 @@ func NewRecordBatchCmd() *cobra.Command { } msg := types.NewMsgRecordBatch(clientCtx.GetFromAddress(), bridgeId, batchBytes) - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } @@ -78,7 +80,7 @@ func NewRecordBatchCmd() *cobra.Command { } // NewCreateBridgeCmd returns a CLI command handler for transaction to creating a bridge. -func NewCreateBridge() *cobra.Command { +func NewCreateBridge(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "create-bridge [path/to/bridge-config.json]", Short: "send a bridge creating tx", @@ -132,6 +134,7 @@ func NewCreateBridge() *cobra.Command { return err } + fmt.Println("SIBONG", origConfig) config := types.BridgeConfig{ Challenger: origConfig.Challenger, Proposer: origConfig.Proposer, @@ -140,12 +143,12 @@ func NewCreateBridge() *cobra.Command { SubmissionStartTime: submissionStartTime, Metadata: []byte(origConfig.Metadata), } - if err = config.Validate(); err != nil { + if err = config.Validate(ac); err != nil { return err } msg := types.NewMsgCreateBridge(clientCtx.GetFromAddress(), config) - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } @@ -159,7 +162,7 @@ func NewCreateBridge() *cobra.Command { } // NewProposeOutput returns a CLI command handler for transaction to propose an output. -func NewProposeOutput() *cobra.Command { +func NewProposeOutput(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "propose-output [bridge-id] [l2-block-number] [output-root-hash]", Short: "send a output-proposing tx", @@ -186,7 +189,7 @@ func NewProposeOutput() *cobra.Command { } msg := types.NewMsgProposeOutput(clientCtx.GetFromAddress(), bridgeId, l2BlockNumber, outputBytes) - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } @@ -200,7 +203,7 @@ func NewProposeOutput() *cobra.Command { } // NewDeleteOutput returns a CLI command handler for transaction to remove an output. -func NewDeleteOutput() *cobra.Command { +func NewDeleteOutput(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "delete-output [bridge-id] [output-index]", Short: "send a output-proposing tx", @@ -222,7 +225,7 @@ func NewDeleteOutput() *cobra.Command { } msg := types.NewMsgDeleteOutput(clientCtx.GetFromAddress(), bridgeId, outputIndex) - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } @@ -236,7 +239,7 @@ func NewDeleteOutput() *cobra.Command { } // NewInitiateTokenDeposit returns a CLI command handler for transaction to initiate token deposit. -func NewInitiateTokenDeposit() *cobra.Command { +func NewInitiateTokenDeposit(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "initiate-token-deposit [bridge-id] [to] [amount] [data]", Short: "send a token deposit initiating tx", @@ -252,7 +255,7 @@ func NewInitiateTokenDeposit() *cobra.Command { return err } - to, err := sdk.AccAddressFromBech32(args[1]) + to, err := ac.StringToBytes(args[1]) if err != nil { return err } @@ -268,7 +271,7 @@ func NewInitiateTokenDeposit() *cobra.Command { } msg := types.NewMsgInitiateTokenDeposit(clientCtx.GetFromAddress(), bridgeId, to, amount, data) - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } @@ -282,7 +285,7 @@ func NewInitiateTokenDeposit() *cobra.Command { } // NewFinalizeTokenWithdrawal returns a CLI command handler for transaction to finalize token withdrawal. -func NewFinalizeTokenWithdrawal() *cobra.Command { +func NewFinalizeTokenWithdrawal(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "finalize-token-withdrawal [path/to/withdrawal-info.json]", Short: "send a token deposit initiating tx", @@ -332,7 +335,7 @@ func NewFinalizeTokenWithdrawal() *cobra.Command { } } - receiver, err := sdk.AccAddressFromBech32(withdrawalInfo.Receiver) + receiver, err := ac.StringToBytes(withdrawalInfo.Receiver) if err != nil { return err } @@ -375,7 +378,7 @@ func NewFinalizeTokenWithdrawal() *cobra.Command { storageRoot, latestBlockHash, ) - if err = msg.ValidateBasic(); err != nil { + if err = msg.Validate(ac); err != nil { return err } diff --git a/x/ophost/client/cli/tx_test.go b/x/ophost/client/cli/tx_test.go index b348d84f..a1ecb424 100644 --- a/x/ophost/client/cli/tx_test.go +++ b/x/ophost/client/cli/tx_test.go @@ -1,7 +1,6 @@ package cli_test import ( - "bytes" "fmt" "io" "os" @@ -12,16 +11,19 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" + "cosmossdk.io/core/address" + math "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - "github.com/cosmos/cosmos-sdk/x/bank" - sdk "github.com/cosmos/cosmos-sdk/types" testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/bank" "github.com/initia-labs/OPinit/x/ophost" "github.com/initia-labs/OPinit/x/ophost/client/cli" @@ -32,6 +34,7 @@ var PKs = simtestutil.CreateTestPubKeys(500) type CLITestSuite struct { suite.Suite + ac address.Codec kr keyring.Keyring encCfg testutilmod.TestEncodingConfig baseCtx client.Context @@ -40,43 +43,47 @@ type CLITestSuite struct { } func (s *CLITestSuite) SetupSuite() { + config := sdk.GetConfig() + config.SetBech32PrefixForAccount("init", "initpub") + s.ac = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) s.encCfg = testutilmod.MakeTestEncodingConfig(ophost.AppModuleBasic{}, bank.AppModuleBasic{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). WithTxConfig(s.encCfg.TxConfig). WithCodec(s.encCfg.Codec). - WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithClient(clitestutil.MockCometRPC{Client: rpcclientmock.Client{}}). WithAccountRetriever(client.MockAccountRetriever{}). WithOutput(io.Discard). WithChainID("test-chain") - var outBuf bytes.Buffer ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ Value: bz, }) return s.baseCtx.WithClient(c) } - s.clientCtx = ctxGen().WithOutput(&outBuf) + s.clientCtx = ctxGen() s.addrs = make([]sdk.AccAddress, 0) for i := 0; i < 3; i++ { - k, _, err := s.clientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - s.Require().NoError(err) + k, _, err := s.clientCtx.Keyring.NewMnemonic(fmt.Sprintf("NewValidator%d", i), keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + s.NoError(err) - pub, err := k.GetPubKey() - s.Require().NoError(err) - - newAddr := sdk.AccAddress(pub.Address()) - s.addrs = append(s.addrs, newAddr) + addr, err := k.GetAddress() + s.NoError(err) + s.addrs = append(s.addrs, addr) } } func (s *CLITestSuite) TestNewRecordBatchCmd() { require := s.Require() - cmd := cli.NewRecordBatchCmd() + cmd := cli.NewRecordBatchCmd(s.ac) + + addr0, err := s.ac.BytesToString(s.addrs[0]) + s.NoError(err) + fmt.Println(s.addrs[0].String()) testCases := []struct { name string @@ -90,10 +97,10 @@ func (s *CLITestSuite) TestNewRecordBatchCmd() { []string{ "0", "Ynl0ZXM=", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -102,10 +109,10 @@ func (s *CLITestSuite) TestNewRecordBatchCmd() { []string{ "1", "batch_bytes_should_be_base64_encoded", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -114,10 +121,10 @@ func (s *CLITestSuite) TestNewRecordBatchCmd() { []string{ "1", "Ynl0ZXM=", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -144,7 +151,10 @@ func (s *CLITestSuite) TestNewRecordBatchCmd() { func (s *CLITestSuite) TestNewCreateBridge() { require := s.Require() - cmd := cli.NewCreateBridge() + cmd := cli.NewCreateBridge(s.ac) + + addr0, err := s.ac.BytesToString(s.addrs[0]) + s.NoError(err) invalidConfig, err := os.CreateTemp("/tmp", "bridge_config") require.NoError(err) @@ -155,8 +165,8 @@ func (s *CLITestSuite) TestNewCreateBridge() { invalidConfig.WriteString(`{}`) validConfig.WriteString(`{ - "challenger": "cosmos1q6jhwnarkw2j5qqgx3qlu20k8nrdglft6qssy2", - "proposer": "cosmos1k2svyvm60r8rhnzr9vemk5f6fksvm6tyh2jj66", + "challenger": "init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g", + "proposer": "init1k2svyvm60r8rhnzr9vemk5f6fksvm6tyeujp3c", "submission_interval": "100s", "finalization_period": "1000s", "submission_start_time" : "2023-12-01T00:00:00Z", @@ -174,10 +184,10 @@ func (s *CLITestSuite) TestNewCreateBridge() { "invalid transaction (invalid bridge config)", []string{ invalidConfig.Name(), - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -185,10 +195,10 @@ func (s *CLITestSuite) TestNewCreateBridge() { "valid transaction", []string{ validConfig.Name(), - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -215,7 +225,10 @@ func (s *CLITestSuite) TestNewCreateBridge() { func (s *CLITestSuite) TestNewProposeOutput() { require := s.Require() - cmd := cli.NewProposeOutput() + cmd := cli.NewProposeOutput(s.ac) + + addr0, err := s.ac.BytesToString(s.addrs[0]) + s.NoError(err) testCases := []struct { name string @@ -230,10 +243,10 @@ func (s *CLITestSuite) TestNewProposeOutput() { "0", "1234", "12e297e695e451144fc44db083d6b3d56f0a5f920721e3efc90ec7662c7775d1", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -243,10 +256,10 @@ func (s *CLITestSuite) TestNewProposeOutput() { "1", "-1", "12e297e695e451144fc44db083d6b3d56f0a5f920721e3efc90ec7662c7775d1", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -256,10 +269,10 @@ func (s *CLITestSuite) TestNewProposeOutput() { "1", "1234", "2e297e695e451144fc44db083d6b3d56f0a5f920721e3efc90ec7662c7775d1", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -269,10 +282,10 @@ func (s *CLITestSuite) TestNewProposeOutput() { "1", "1234", "12e297e695e451144fc44db083d6b3d56f0a5f920721e3efc90ec7662c7775d1", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -299,7 +312,11 @@ func (s *CLITestSuite) TestNewProposeOutput() { func (s *CLITestSuite) TestNewDeleteOutput() { require := s.Require() - cmd := cli.NewDeleteOutput() + + cmd := cli.NewDeleteOutput(s.ac) + + addr0, err := s.ac.BytesToString(s.addrs[0]) + s.NoError(err) testCases := []struct { name string @@ -313,10 +330,10 @@ func (s *CLITestSuite) TestNewDeleteOutput() { []string{ "0", "1000", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -326,10 +343,10 @@ func (s *CLITestSuite) TestNewDeleteOutput() { "1", "-1", "2e297e695e451144fc44db083d6b3d56f0a5f920721e3efc90ec7662c7775d1", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -338,10 +355,10 @@ func (s *CLITestSuite) TestNewDeleteOutput() { []string{ "1", "2", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -368,7 +385,10 @@ func (s *CLITestSuite) TestNewDeleteOutput() { func (s *CLITestSuite) TestNewInitiateTokenDeposit() { require := s.Require() - cmd := cli.NewInitiateTokenDeposit() + cmd := cli.NewInitiateTokenDeposit(s.ac) + + addr0, err := s.ac.BytesToString(s.addrs[0]) + require.NoError(err) testCases := []struct { name string @@ -381,13 +401,13 @@ func (s *CLITestSuite) TestNewInitiateTokenDeposit() { "invalid transaction (invalid bridge-id)", []string{ "0", - "cosmos1q6jhwnarkw2j5qqgx3qlu20k8nrdglft6qssy2", + "init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g", "10000uatom", "", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -398,10 +418,10 @@ func (s *CLITestSuite) TestNewInitiateTokenDeposit() { "cosmos1q6jhwnarkw2j5qqgx3qlu20k8nrdglft6qssy3", "10000uatom", "", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -409,13 +429,13 @@ func (s *CLITestSuite) TestNewInitiateTokenDeposit() { "invalid transaction (invalid amount)", []string{ "0", - "cosmos1q6jhwnarkw2j5qqgx3qlu20k8nrdglft6qssy2", + "init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g", "invalid_amount", "", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -423,12 +443,12 @@ func (s *CLITestSuite) TestNewInitiateTokenDeposit() { "invalid transaction (invalid data)", []string{ "0", - "cosmos1q6jhwnarkw2j5qqgx3qlu20k8nrdglft6qssy2", + "init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g", "10000uatom", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -436,13 +456,13 @@ func (s *CLITestSuite) TestNewInitiateTokenDeposit() { "valid transaction", []string{ "1", - "cosmos1q6jhwnarkw2j5qqgx3qlu20k8nrdglft6qssy2", + "init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g", "10000uatom", "", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -469,7 +489,10 @@ func (s *CLITestSuite) TestNewInitiateTokenDeposit() { func (s *CLITestSuite) TestNewFinalizeTokenWithdrawal() { require := s.Require() - cmd := cli.NewFinalizeTokenWithdrawal() + cmd := cli.NewFinalizeTokenWithdrawal(s.ac) + + addr0, err := s.ac.BytesToString(s.addrs[0]) + s.NoError(err) invalidConfig, err := os.CreateTemp("/tmp", "withdrawal_info") require.NoError(err) @@ -483,7 +506,7 @@ func (s *CLITestSuite) TestNewFinalizeTokenWithdrawal() { "bridge_id": 1, "output_index": 2, "withdrawal_proofs": ["8e1fa5cd035b30e5d5818934dbc7491fe44f4ab15d30b3abcbc01d44edf25f18", "80d66720e75121fedc738e9847048466ac8d05626406fe3b438b1699dcbfa37e"], - "receiver": "cosmos1k2svyvm60r8rhnzr9vemk5f6fksvm6tyh2jj66", + "receiver": "init1k2svyvm60r8rhnzr9vemk5f6fksvm6tyeujp3c", "sequence": 3, "amount": "10000000uatom", "version": "5ca4f3850ccc331aaf8a257d6086e526a3b42a63e18cb11d020847985b31d188", @@ -503,10 +526,10 @@ func (s *CLITestSuite) TestNewFinalizeTokenWithdrawal() { "invalid transaction (invalid withdrawal info)", []string{ invalidConfig.Name(), - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, true, 0, &sdk.TxResponse{}, }, @@ -514,10 +537,10 @@ func (s *CLITestSuite) TestNewFinalizeTokenWithdrawal() { "valid transaction", []string{ validConfig.Name(), - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addrs[0]), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr0), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/ophost/keeper/bridge.go b/x/ophost/keeper/bridge.go index 6145b42e..8498139f 100644 --- a/x/ophost/keeper/bridge.go +++ b/x/ophost/keeper/bridge.go @@ -1,11 +1,10 @@ package keeper import ( - "encoding/binary" + "context" + "errors" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" + "cosmossdk.io/collections" "github.com/initia-labs/OPinit/x/ophost/types" ) @@ -14,143 +13,91 @@ import ( // BridgeConfig func (k Keeper) SetBridgeConfig( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig types.BridgeConfig, ) error { - bz, err := k.cdc.Marshal(&bridgeConfig) - if err != nil { - return err - } - - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.GetBridgeConfigKey(bridgeId), bz) - return nil + return k.BridgeConfigs.Set(ctx, bridgeId, bridgeConfig) } func (k Keeper) GetBridgeConfig( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, ) (bridgeConfig types.BridgeConfig, err error) { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.GetBridgeConfigKey(bridgeId)) - - if len(bz) == 0 { - err = errors.ErrKeyNotFound - return - } - - err = k.cdc.Unmarshal(bz, &bridgeConfig) - return + return k.BridgeConfigs.Get(ctx, bridgeId) } func (k Keeper) IterateBridgeConfig( - ctx sdk.Context, - cb func(bridgeId uint64, bridgeConfig types.BridgeConfig) bool, + ctx context.Context, + cb func(bridgeId uint64, bridgeConfig types.BridgeConfig) (stop bool, err error), ) error { - kvStore := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(kvStore, types.BridgeConfigKey) - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - key := iterator.Key() - val := iterator.Value() - - bridgeId := binary.BigEndian.Uint64(key) - - var bridgeConfig types.BridgeConfig - if err := k.cdc.Unmarshal(val, &bridgeConfig); err != nil { - return err - } - - if cb(bridgeId, bridgeConfig) { - break - } - } - - return nil + return k.BridgeConfigs.Walk(ctx, nil, cb) } //////////////////////////////////// // NextL1Sequence -func (k Keeper) SetNextL1Sequence(ctx sdk.Context, bridgeId, nextL1Sequence uint64) { - _nextL1Sequence := [8]byte{} - binary.BigEndian.PutUint64(_nextL1Sequence[:], nextL1Sequence) - - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.GetNextL1SequenceKey(bridgeId), _nextL1Sequence[:]) +func (k Keeper) SetNextL1Sequence(ctx context.Context, bridgeId, nextL1Sequence uint64) error { + return k.NextL1Sequences.Set(ctx, bridgeId, nextL1Sequence) } -func (k Keeper) GetNextL1Sequence(ctx sdk.Context, bridgeId uint64) uint64 { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.GetNextL1SequenceKey(bridgeId)) - if len(bz) == 0 { - return 1 +func (k Keeper) GetNextL1Sequence(ctx context.Context, bridgeId uint64) (uint64, error) { + nextSequence, err := k.NextL1Sequences.Get(ctx, bridgeId) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + nextSequence = 1 + } else { + return 0, err + } } - return binary.BigEndian.Uint64(bz) + return nextSequence, nil } -func (k Keeper) IncreaseNextL1Sequence(ctx sdk.Context, bridgeId uint64) uint64 { - kvStore := ctx.KVStore(k.storeKey) - - // load next bridge sequence - key := types.GetNextL1SequenceKey(bridgeId) - bz := kvStore.Get(key) - - nextL1Sequence := uint64(1) - if len(bz) != 0 { - nextL1Sequence = binary.BigEndian.Uint64(bz) +func (k Keeper) IncreaseNextL1Sequence(ctx context.Context, bridgeId uint64) (uint64, error) { + nextL1Sequence, err := k.GetNextL1Sequence(ctx, bridgeId) + if err != nil { + return 0, err } - // increase next bridge sequence - _nextL1Sequence := [8]byte{} - binary.BigEndian.PutUint64(_nextL1Sequence[:], nextL1Sequence+1) - kvStore.Set(key, _nextL1Sequence[:]) + // increase NextL1Sequence + if err = k.NextL1Sequences.Set(ctx, bridgeId, nextL1Sequence+1); err != nil { + return 0, err + } - return nextL1Sequence + return nextL1Sequence, err } //////////////////////////////////// // NextBridgeId -func (k Keeper) SetNextBridgeId(ctx sdk.Context, nextBridgeId uint64) { - _nextBridgeId := [8]byte{} - binary.BigEndian.PutUint64(_nextBridgeId[:], nextBridgeId) - - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.NextBridgeIdKey, _nextBridgeId[:]) +func (k Keeper) SetNextBridgeId(ctx context.Context, nextBridgeId uint64) error { + return k.NextBridgeId.Set(ctx, nextBridgeId) } -func (k Keeper) GetNextBridgeId(ctx sdk.Context) uint64 { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.NextBridgeIdKey) - if len(bz) == 0 { - return 1 +func (k Keeper) GetNextBridgeId(ctx context.Context) (uint64, error) { + nextBridgeId, err := k.NextBridgeId.Get(ctx) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + nextBridgeId = 1 + } else { + return 0, err + } } - return binary.BigEndian.Uint64(bz) + return nextBridgeId, nil } -func (k Keeper) IncreaseNextBridgeId(ctx sdk.Context) uint64 { - kvStore := ctx.KVStore(k.storeKey) - - // load next bridge id - key := types.NextBridgeIdKey - bz := kvStore.Get(key) - - nextBridgeId := uint64(1) - if len(bz) != 0 { - nextBridgeId = binary.BigEndian.Uint64(bz) +func (k Keeper) IncreaseNextBridgeId(ctx context.Context) (uint64, error) { + nextBridgeId, err := k.GetNextBridgeId(ctx) + if err != nil { + return 0, err } - // increase next bridge id - _nextBridgeId := [8]byte{} - binary.BigEndian.PutUint64(_nextBridgeId[:], nextBridgeId+1) - kvStore.Set(key, _nextBridgeId[:]) + // increase NextBridgeId + if err := k.NextBridgeId.Set(ctx, nextBridgeId+1); err != nil { + return 0, err + } - return nextBridgeId + return nextBridgeId, nil } diff --git a/x/ophost/keeper/bridge_test.go b/x/ophost/keeper/bridge_test.go index 4ce2a5ff..d6f0afa1 100644 --- a/x/ophost/keeper/bridge_test.go +++ b/x/ophost/keeper/bridge_test.go @@ -45,13 +45,13 @@ func Test_IterateBridgeConfig(t *testing.T) { require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 1, config1)) require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 2, config2)) - input.OPHostKeeper.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) bool { + input.OPHostKeeper.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) (stop bool, err error) { if bridgeId == 1 { require.Equal(t, config1, bridgeConfig) } else { require.Equal(t, config2, bridgeConfig) } - return false + return false, nil }) } diff --git a/x/ophost/keeper/common_test.go b/x/ophost/keeper/common_test.go index 32af27a6..160343df 100644 --- a/x/ophost/keeper/common_test.go +++ b/x/ophost/keeper/common_test.go @@ -1,39 +1,48 @@ package keeper_test import ( + "context" "encoding/binary" "testing" "time" "github.com/stretchr/testify/require" - dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cometbft/cometbft/crypto/secp256k1" - "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "cosmossdk.io/log" + "cosmossdk.io/math" + "cosmossdk.io/store" + "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/tx/signing" + + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + codecaddress "github.com/cosmos/cosmos-sdk/codec/address" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/std" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/gogoproto/proto" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" ophost "github.com/initia-labs/OPinit/x/ophost" ophostkeeper "github.com/initia-labs/OPinit/x/ophost/keeper" @@ -73,7 +82,7 @@ var ( "test5", } - initiaSupply = sdk.NewInt(100_000_000_000) + initiaSupply = math.NewInt(100_000_000_000) ) type EncodingConfig struct { @@ -88,22 +97,28 @@ func MakeTestCodec(t testing.TB) codec.Codec { } func MakeEncodingConfig(_ testing.TB) EncodingConfig { - amino := codec.NewLegacyAmino() - interfaceRegistry := codectypes.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) - txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) + interfaceRegistry, _ := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + }, + }) + appCodec := codec.NewProtoCodec(interfaceRegistry) + legacyAmino := codec.NewLegacyAmino() + txConfig := tx.NewTxConfig(appCodec, tx.DefaultSignModes) std.RegisterInterfaces(interfaceRegistry) - std.RegisterLegacyAminoCodec(amino) + std.RegisterLegacyAminoCodec(legacyAmino) - ModuleBasics.RegisterLegacyAminoCodec(amino) + ModuleBasics.RegisterLegacyAminoCodec(legacyAmino) ModuleBasics.RegisterInterfaces(interfaceRegistry) return EncodingConfig{ InterfaceRegistry: interfaceRegistry, - Marshaler: marshaler, - TxConfig: txCfg, - Amino: amino, + Marshaler: appCodec, + TxConfig: txConfig, + Amino: legacyAmino, } } @@ -170,7 +185,7 @@ type TestKeepers struct { BridgeHook *bridgeHook EncodingConfig EncodingConfig Faucet *TestFaucet - MultiStore sdk.CommitMultiStore + MultiStore storetypes.CommitMultiStore } // createDefaultTestInput common settings for createTestInput @@ -204,14 +219,14 @@ func _createTestInput( isCheckTx bool, db dbm.DB, ) (sdk.Context, TestKeepers) { - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, ophosttypes.StoreKey, ) - ms := store.NewCommitMultiStore(db) + ms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) for _, v := range keys { ms.MountStoreWithDB(v, storetypes.StoreTypeIAVL, db) } - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) for _, v := range memKeys { ms.MountStoreWithDB(v, storetypes.StoreTypeMemory, db) } @@ -238,9 +253,10 @@ func _createTestInput( } accountKeeper := authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], // target store - authtypes.ProtoBaseAccount, // prototype + runtime.NewKVStoreService(keys[authtypes.StoreKey]), // target store + authtypes.ProtoBaseAccount, // prototype maccPerms, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.GetConfig().GetBech32AccountAddrPrefix(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -251,10 +267,11 @@ func _createTestInput( bankKeeper := bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), accountKeeper, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ctx.Logger(), ) bankKeeper.SetParams(ctx, banktypes.DefaultParams()) @@ -264,7 +281,7 @@ func _createTestInput( bridgeHook := &bridgeHook{} ophostKeeper := ophostkeeper.NewKeeper( appCodec, - keys[ophosttypes.StoreKey], + runtime.NewKVStoreService(keys[ophosttypes.StoreKey]), accountKeeper, bankKeeper, bridgeHook, @@ -275,14 +292,14 @@ func _createTestInput( ophostKeeper.SetParams(ctx, ophostParams) // register handlers to msg router - ophosttypes.RegisterMsgServer(msgRouter, ophostkeeper.NewMsgServerImpl(ophostKeeper)) + ophosttypes.RegisterMsgServer(msgRouter, ophostkeeper.NewMsgServerImpl(*ophostKeeper)) faucet := NewTestFaucet(t, ctx, bankKeeper, authtypes.Minter, initialTotalSupply()...) keepers := TestKeepers{ AccountKeeper: accountKeeper, BankKeeper: bankKeeper, - OPHostKeeper: ophostKeeper, + OPHostKeeper: *ophostKeeper, BridgeHook: bridgeHook, EncodingConfig: encodingConfig, Faucet: faucet, @@ -299,7 +316,7 @@ type bridgeHook struct { } func (h *bridgeHook) BridgeCreated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig ophosttypes.BridgeConfig, ) error { @@ -314,7 +331,7 @@ func (h *bridgeHook) BridgeCreated( } func (h *bridgeHook) BridgeChallengerUpdated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig ophosttypes.BridgeConfig, ) error { @@ -329,7 +346,7 @@ func (h *bridgeHook) BridgeChallengerUpdated( } func (h *bridgeHook) BridgeProposerUpdated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig ophosttypes.BridgeConfig, ) error { diff --git a/x/ophost/keeper/genesis.go b/x/ophost/keeper/genesis.go index 43ba060c..a5cb3d1f 100644 --- a/x/ophost/keeper/genesis.go +++ b/x/ophost/keeper/genesis.go @@ -1,13 +1,16 @@ package keeper import ( - abci "github.com/cometbft/cometbft/abci/types" - + "cosmossdk.io/collections" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/initia-labs/OPinit/x/ophost/types" ) -func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []abci.ValidatorUpdate) { +func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { + if err := data.Params.Validate(); err != nil { + panic(err) + } + if err := k.SetParams(ctx, data.Params); err != nil { panic(err) } @@ -40,8 +43,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []ab } k.SetNextBridgeId(ctx, data.NextBridgeId) - - return res } // ExportGenesis returns a GenesisState for a given context and keeper. The @@ -50,37 +51,43 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []ab func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { var bridges []types.Bridge - k.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) bool { - nextL1Sequence := k.GetNextL1Sequence(ctx, bridgeId) - nextOutputIndex := k.GetNextOutputIndex(ctx, bridgeId) + k.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) (stop bool, err error) { + nextL1Sequence, err := k.GetNextL1Sequence(ctx, bridgeId) + if err != nil { + return true, err + } + + nextOutputIndex, err := k.GetNextOutputIndex(ctx, bridgeId) + if err != nil { + return true, err + } var proposals []types.WrappedOutput - if err := k.IterateOutputProposals(ctx, bridgeId, func(bridgeId, outputIndex uint64, output types.Output) bool { + if err := k.IterateOutputProposals(ctx, bridgeId, func(key collections.Pair[uint64, uint64], output types.Output) (stop bool, err error) { proposals = append(proposals, types.WrappedOutput{ - OutputIndex: outputIndex, + OutputIndex: key.K2(), OutputProposal: output, }) - return false + return false, nil }); err != nil { - panic(err) + return true, err } var provenWithdrawals [][]byte - if err := k.IterateProvenWithdrawals(ctx, bridgeId, func(bridgeId uint64, withdrawalHash [32]byte) bool { + if err := k.IterateProvenWithdrawals(ctx, bridgeId, func(bridgeId uint64, withdrawalHash [32]byte) (bool, error) { provenWithdrawals = append(provenWithdrawals, withdrawalHash[:]) - return false + return false, nil }); err != nil { - panic(err) + return true, err } var tokenPairs []types.TokenPair - if err := k.IterateTokenPair(ctx, bridgeId, func(bridgeId uint64, tokenPair types.TokenPair) bool { + if err := k.IterateTokenPair(ctx, bridgeId, func(bridgeId uint64, tokenPair types.TokenPair) (stop bool, err error) { tokenPairs = append(tokenPairs, tokenPair) - - return false + return false, nil }); err != nil { - panic(err) + return true, err } bridges = append(bridges, types.Bridge{ @@ -93,10 +100,13 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { Proposals: proposals, }) - return false + return false, nil }) - nextBridgeId := k.GetNextBridgeId(ctx) + nextBridgeId, err := k.GetNextBridgeId(ctx) + if err != nil { + panic(err) + } return &types.GenesisState{ Params: k.GetParams(ctx), diff --git a/x/ophost/keeper/keeper.go b/x/ophost/keeper/keeper.go index c325175a..67b14936 100644 --- a/x/ophost/keeper/keeper.go +++ b/x/ophost/keeper/keeper.go @@ -1,18 +1,21 @@ package keeper import ( - "github.com/cometbft/cometbft/libs/log" + "context" + + "cosmossdk.io/collections" + corestoretypes "cosmossdk.io/core/store" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/initia-labs/OPinit/x/ophost/types" ) type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey + cdc codec.Codec + storeService corestoretypes.KVStoreService authKeeper types.AccountKeeper bankKeeper types.BankKeeper @@ -21,29 +24,57 @@ type Keeper struct { // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. authority string + + Schema collections.Schema + NextBridgeId collections.Item[uint64] + Params collections.Item[types.Params] + BridgeConfigs collections.Map[uint64, types.BridgeConfig] + NextL1Sequences collections.Map[uint64, uint64] + TokenPairs collections.Map[collections.Pair[uint64, string], string] + OutputProposals collections.Map[collections.Pair[uint64, uint64], types.Output] + NextOutputIndexes collections.Map[uint64, uint64] + ProvenWithdrawals collections.Map[collections.Pair[uint64, []byte], bool] } func NewKeeper( - cdc codec.BinaryCodec, - key storetypes.StoreKey, + cdc codec.Codec, + storeService corestoretypes.KVStoreService, ak types.AccountKeeper, bk types.BankKeeper, bridgeHook types.BridgeHook, authority string, -) Keeper { +) *Keeper { // ensure that authority is a valid AccAddress - if _, err := sdk.AccAddressFromBech32(authority); err != nil { + if _, err := ak.AddressCodec().StringToBytes(authority); err != nil { panic("authority is not a valid acc address") } - return Keeper{ - cdc: cdc, - storeKey: key, - authKeeper: ak, - bankKeeper: bk, - bridgeHook: bridgeHook, - authority: authority, + sb := collections.NewSchemaBuilder(storeService) + + k := &Keeper{ + cdc: cdc, + storeService: storeService, + authKeeper: ak, + bankKeeper: bk, + bridgeHook: bridgeHook, + authority: authority, + NextBridgeId: collections.NewItem(sb, types.NextBridgeIdKey, "next_bridge_id", collections.Uint64Value), + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + BridgeConfigs: collections.NewMap(sb, types.BridgeConfigPrefix, "bridge_configs", collections.Uint64Key, codec.CollValue[types.BridgeConfig](cdc)), + NextL1Sequences: collections.NewMap(sb, types.NextL1SequencePrefix, "next_l1_sequences", collections.Uint64Key, collections.Uint64Value), + TokenPairs: collections.NewMap(sb, types.TokenPairPrefix, "token_pairs", collections.PairKeyCodec(collections.Uint64Key, collections.StringKey), collections.StringValue), + OutputProposals: collections.NewMap(sb, types.OutputProposalPrefix, "output_proposals", collections.PairKeyCodec(collections.Uint64Key, collections.Uint64Key), codec.CollValue[types.Output](cdc)), + NextOutputIndexes: collections.NewMap(sb, types.NextOutputIndexPrefix, "next_output_indexes", collections.Uint64Key, collections.Uint64Value), + ProvenWithdrawals: collections.NewMap(sb, types.ProvenWithdrawalPrefix, "proven_withdrawals", collections.PairKeyCodec(collections.Uint64Key, collections.BytesKey), collections.BoolValue), + } + + schema, err := sb.Build() + if err != nil { + panic(err) } + k.Schema = schema + + return k } // GetAuthority returns the x/move module's authority. @@ -52,6 +83,7 @@ func (ak Keeper) GetAuthority() string { } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) +func (k *Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", "x/"+types.ModuleName) } diff --git a/x/ophost/keeper/msg_server.go b/x/ophost/keeper/msg_server.go index bf0169a2..59cea8b5 100644 --- a/x/ophost/keeper/msg_server.go +++ b/x/ophost/keeper/msg_server.go @@ -31,8 +31,12 @@ func NewMsgServerImpl(k Keeper) MsgServer { // The messages for Batch Submitter // RecordBatch implements a RecordBatch message handling -func (ms MsgServer) RecordBatch(context context.Context, req *types.MsgRecordBatch) (*types.MsgRecordBatchResponse, error) { - sdk.UnwrapSDKContext(context).EventManager().EmitEvent( +func (ms MsgServer) RecordBatch(ctx context.Context, req *types.MsgRecordBatch) (*types.MsgRecordBatchResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } + + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent( sdk.NewEvent( types.EventTypeRecordBatch, sdk.NewAttribute(types.AttributeKeySubmitter, req.Submitter), @@ -45,19 +49,27 @@ func (ms MsgServer) RecordBatch(context context.Context, req *types.MsgRecordBat ///////////////////////////////////////////////////// // The messages for Bridge Creator -func (ms MsgServer) CreateBridge(context context.Context, req *types.MsgCreateBridge) (*types.MsgCreateBridgeResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) CreateBridge(ctx context.Context, req *types.MsgCreateBridge) (*types.MsgCreateBridgeResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } - bridgeId := ms.IncreaseNextBridgeId(ctx) - err := ms.SetBridgeConfig(ctx, bridgeId, req.Config) + bridgeId, err := ms.IncreaseNextBridgeId(ctx) if err != nil { return nil, err } + // store bridge config + if err := ms.SetBridgeConfig(ctx, bridgeId, req.Config); err != nil { + return nil, err + } + // create bridge account - ms.authKeeper.SetAccount(ctx, types.NewBridgeAccountWithAddress(types.BridgeAddress(bridgeId))) + bridgeAcc := types.NewBridgeAccountWithAddress(types.BridgeAddress(bridgeId)) + bridgeAcc.AccountNumber = ms.authKeeper.NextAccountNumber(ctx) + ms.authKeeper.SetAccount(ctx, bridgeAcc) - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypeCreateBridge, sdk.NewAttribute(types.AttributeKeyCreator, req.Creator), sdk.NewAttribute(types.AttributeKeyProposer, req.Config.Proposer), @@ -77,8 +89,11 @@ func (ms MsgServer) CreateBridge(context context.Context, req *types.MsgCreateBr }, nil } -func (ms MsgServer) ProposeOutput(context context.Context, req *types.MsgProposeOutput) (*types.MsgProposeOutputResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) ProposeOutput(ctx context.Context, req *types.MsgProposeOutput) (*types.MsgProposeOutputResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } proposer := req.Proposer bridgeId := req.BridgeId @@ -96,7 +111,10 @@ func (ms MsgServer) ProposeOutput(context context.Context, req *types.MsgPropose } // fetch next output index - outputIndex := ms.IncreaseNextOutputIndex(ctx, bridgeId) + outputIndex, err := ms.IncreaseNextOutputIndex(ctx, bridgeId) + if err != nil { + return nil, err + } // check this is first submission or not if outputIndex != 1 { @@ -113,13 +131,13 @@ func (ms MsgServer) ProposeOutput(context context.Context, req *types.MsgPropose // store output proposal if err := ms.SetOutputProposal(ctx, bridgeId, outputIndex, types.Output{ OutputRoot: outputRoot, - L1BlockTime: ctx.BlockTime(), + L1BlockTime: sdkCtx.BlockTime(), L2BlockNumber: l2BlockNumber, }); err != nil { return nil, err } - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdkCtx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeProposeOutput, sdk.NewAttribute(types.AttributeKeyProposer, proposer), sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), @@ -133,8 +151,10 @@ func (ms MsgServer) ProposeOutput(context context.Context, req *types.MsgPropose }, nil } -func (ms MsgServer) DeleteOutput(context context.Context, req *types.MsgDeleteOutput) (*types.MsgDeleteOutputResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) DeleteOutput(ctx context.Context, req *types.MsgDeleteOutput) (*types.MsgDeleteOutputResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } challenger := req.Challenger bridgeId := req.BridgeId @@ -153,7 +173,7 @@ func (ms MsgServer) DeleteOutput(context context.Context, req *types.MsgDeleteOu // delete output proposal ms.DeleteOutputProposal(ctx, bridgeId, outputIndex) - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypeDeleteOutput, sdk.NewAttribute(types.AttributeKeyChallenger, challenger), sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), @@ -163,17 +183,22 @@ func (ms MsgServer) DeleteOutput(context context.Context, req *types.MsgDeleteOu return &types.MsgDeleteOutputResponse{}, nil } -func (ms MsgServer) InitiateTokenDeposit(context context.Context, req *types.MsgInitiateTokenDeposit) (*types.MsgInitiateTokenDepositResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) InitiateTokenDeposit(ctx context.Context, req *types.MsgInitiateTokenDeposit) (*types.MsgInitiateTokenDepositResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } - sender, err := sdk.AccAddressFromBech32(req.Sender) + sender, err := ms.authKeeper.AddressCodec().StringToBytes(req.Sender) if err != nil { return nil, err } coin := req.Amount bridgeId := req.BridgeId - l1Sequence := ms.IncreaseNextL1Sequence(ctx, bridgeId) + l1Sequence, err := ms.IncreaseNextL1Sequence(ctx, bridgeId) + if err != nil { + return nil, err + } // send the funds to bridge address bridgeAddr := types.BridgeAddress(bridgeId) @@ -183,12 +208,14 @@ func (ms MsgServer) InitiateTokenDeposit(context context.Context, req *types.Msg // record token pairs l2Denom := types.L2Denom(bridgeId, coin.Denom) - if !ms.HasTokenPair(ctx, bridgeId, l2Denom) { + if ok, err := ms.HasTokenPair(ctx, bridgeId, l2Denom); err != nil { + return nil, err + } else if !ok { ms.SetTokenPair(ctx, bridgeId, l2Denom, coin.Denom) } // emit events for bridge executor - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypeInitiateTokenDeposit, sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), sdk.NewAttribute(types.AttributeKeyL1Sequence, strconv.FormatUint(l1Sequence, 10)), @@ -203,14 +230,16 @@ func (ms MsgServer) InitiateTokenDeposit(context context.Context, req *types.Msg return &types.MsgInitiateTokenDepositResponse{}, nil } -func (ms MsgServer) FinalizeTokenWithdrawal(context context.Context, req *types.MsgFinalizeTokenWithdrawal) (*types.MsgFinalizeTokenWithdrawalResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) FinalizeTokenWithdrawal(ctx context.Context, req *types.MsgFinalizeTokenWithdrawal) (*types.MsgFinalizeTokenWithdrawalResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } - sender, err := sdk.AccAddressFromBech32(req.Sender) + sender, err := ms.authKeeper.AddressCodec().StringToBytes(req.Sender) if err != nil { return nil, err } - receiver, err := sdk.AccAddressFromBech32(req.Receiver) + receiver, err := ms.authKeeper.AddressCodec().StringToBytes(req.Receiver) if err != nil { return nil, err } @@ -254,15 +283,17 @@ func (ms MsgServer) FinalizeTokenWithdrawal(context context.Context, req *types. seed := []byte{} seed = binary.BigEndian.AppendUint64(seed, bridgeId) seed = binary.BigEndian.AppendUint64(seed, req.Sequence) - seed = append(seed, sender[:]...) - seed = append(seed, receiver[:]...) + seed = append(seed, sender...) + seed = append(seed, receiver...) seed = append(seed, []byte(denom)...) seed = binary.BigEndian.AppendUint64(seed, amount.Uint64()) withdrawalHash = sha3.Sum256(seed) } - if ms.HasProvenWithdrawal(ctx, bridgeId, withdrawalHash) { + if ok, err := ms.HasProvenWithdrawal(ctx, bridgeId, withdrawalHash); err != nil { + return nil, err + } else if ok { return nil, types.ErrWithdrawalAlreadyFinalized } @@ -292,13 +323,13 @@ func (ms MsgServer) FinalizeTokenWithdrawal(context context.Context, req *types. return nil, err } - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypeFinalizeTokenWithdrawal, sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), sdk.NewAttribute(types.AttributeKeyOutputIndex, strconv.FormatUint(outputIndex, 10)), sdk.NewAttribute(types.AttributeKeyL2Sequence, strconv.FormatUint(l2Sequence, 10)), - sdk.NewAttribute(types.AttributeKeyFrom, sender.String()), - sdk.NewAttribute(types.AttributeKeyTo, receiver.String()), + sdk.NewAttribute(types.AttributeKeyFrom, sdk.AccAddress(sender).String()), + sdk.NewAttribute(types.AttributeKeyTo, sdk.AccAddress(receiver).String()), sdk.NewAttribute(types.AttributeKeyL1Denom, denom), sdk.NewAttribute(types.AttributeKeyL2Denom, types.L2Denom(bridgeId, denom)), sdk.NewAttribute(types.AttributeKeyAmount, amount.String()), @@ -307,8 +338,10 @@ func (ms MsgServer) FinalizeTokenWithdrawal(context context.Context, req *types. return &types.MsgFinalizeTokenWithdrawalResponse{}, nil } -func (ms MsgServer) UpdateProposer(context context.Context, req *types.MsgUpdateProposer) (*types.MsgUpdateProposerResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) UpdateProposer(ctx context.Context, req *types.MsgUpdateProposer) (*types.MsgUpdateProposerResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } bridgeId := req.BridgeId config, err := ms.GetBridgeConfig(ctx, bridgeId) @@ -330,11 +363,19 @@ func (ms MsgServer) UpdateProposer(context context.Context, req *types.MsgUpdate return nil, err } + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeUpdateProposer, + sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), + sdk.NewAttribute(types.AttributeKeyProposer, req.NewProposer), + )) + return &types.MsgUpdateProposerResponse{}, nil } -func (ms MsgServer) UpdateChallenger(context context.Context, req *types.MsgUpdateChallenger) (*types.MsgUpdateChallengerResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (ms MsgServer) UpdateChallenger(ctx context.Context, req *types.MsgUpdateChallenger) (*types.MsgUpdateChallengerResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } bridgeId := req.BridgeId config, err := ms.GetBridgeConfig(ctx, bridgeId) @@ -356,16 +397,25 @@ func (ms MsgServer) UpdateChallenger(context context.Context, req *types.MsgUpda return nil, err } + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeUpdateChallenger, + sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), + sdk.NewAttribute(types.AttributeKeyChallenger, req.NewChallenger), + )) + return &types.MsgUpdateChallengerResponse{}, nil } // UpdateParams implements updating the parameters -func (ms MsgServer) UpdateParams(context context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (ms MsgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { + return nil, err + } + if ms.authority != req.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", ms.authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(context) if err := ms.SetParams(ctx, *req.Params); err != nil { return nil, err } diff --git a/x/ophost/keeper/msg_server_test.go b/x/ophost/keeper/msg_server_test.go index 16ac9ed0..bfa5f2d2 100644 --- a/x/ophost/keeper/msg_server_test.go +++ b/x/ophost/keeper/msg_server_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" @@ -17,7 +18,7 @@ func Test_RecordBatch(t *testing.T) { ctx, input := createDefaultTestInput(t) ms := keeper.NewMsgServerImpl(input.OPHostKeeper) - _, err := ms.RecordBatch(sdk.WrapSDKContext(ctx), types.NewMsgRecordBatch(addrs[0], 1, []byte{1, 2, 3})) + _, err := ms.RecordBatch(ctx, types.NewMsgRecordBatch(addrs[0], 1, []byte{1, 2, 3})) require.NoError(t, err) } @@ -33,7 +34,7 @@ func Test_CreateBridge(t *testing.T) { SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - res, err := ms.CreateBridge(sdk.WrapSDKContext(ctx), types.NewMsgCreateBridge(addrs[0], config)) + res, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) require.NoError(t, err) require.Equal(t, uint64(1), res.BridgeId) @@ -54,7 +55,7 @@ func Test_ProposeOutput(t *testing.T) { SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - createRes, err := ms.CreateBridge(sdk.WrapSDKContext(ctx), types.NewMsgCreateBridge(addrs[0], config)) + createRes, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) @@ -62,11 +63,11 @@ func Test_ProposeOutput(t *testing.T) { ctx = ctx.WithBlockTime(blockTime) // unauthorized - _, err = ms.ProposeOutput(sdk.WrapSDKContext(ctx), types.NewMsgProposeOutput(addrs[1], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) + _, err = ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[1], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) require.Error(t, err) // valid - proposeRes, err := ms.ProposeOutput(sdk.WrapSDKContext(ctx), types.NewMsgProposeOutput(addrs[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) + proposeRes, err := ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) require.NoError(t, err) require.Equal(t, uint64(1), proposeRes.OutputIndex) @@ -92,23 +93,23 @@ func Test_DeleteOutput(t *testing.T) { Metadata: []byte{1, 2, 3}, } createReq := types.NewMsgCreateBridge(addrs[0], config) - createRes, err := ms.CreateBridge(sdk.WrapSDKContext(ctx), createReq) + createRes, err := ms.CreateBridge(ctx, createReq) require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) - proposeRes, err := ms.ProposeOutput(sdk.WrapSDKContext(ctx), types.NewMsgProposeOutput(addrs[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) + proposeRes, err := ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) require.NoError(t, err) require.Equal(t, uint64(1), proposeRes.OutputIndex) // unauthorized - _, err = ms.DeleteOutput(sdk.WrapSDKContext(ctx), types.NewMsgDeleteOutput(addrs[0], 1, 1)) + _, err = ms.DeleteOutput(ctx, types.NewMsgDeleteOutput(addrs[0], 1, 1)) require.Error(t, err) // valid - _, err = ms.DeleteOutput(sdk.WrapSDKContext(ctx), types.NewMsgDeleteOutput(addrs[1], 1, 1)) + _, err = ms.DeleteOutput(ctx, types.NewMsgDeleteOutput(addrs[1], 1, 1)) require.NoError(t, err) // should return error; deleted @@ -128,14 +129,14 @@ func Test_InitiateTokenDeposit(t *testing.T) { SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - createRes, err := ms.CreateBridge(sdk.WrapSDKContext(ctx), types.NewMsgCreateBridge(addrs[0], config)) + createRes, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) - amount := sdk.NewCoin(baseDenom, sdk.NewInt(100)) + amount := sdk.NewCoin(baseDenom, math.NewInt(100)) input.Faucet.Fund(ctx, addrs[1], amount) _, err = ms.InitiateTokenDeposit( - sdk.WrapSDKContext(ctx), + ctx, types.NewMsgInitiateTokenDeposit(addrs[1], 1, addrs[2], amount, []byte("messages")), ) require.NoError(t, err) @@ -155,11 +156,11 @@ func Test_FinalizeTokenWithdrawal(t *testing.T) { SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - _, err := ms.CreateBridge(sdk.WrapSDKContext(ctx), types.NewMsgCreateBridge(addrs[0], config)) + _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) require.NoError(t, err) // fund amount - amount := sdk.NewCoin("l1denom", sdk.NewInt(3_000_000)) + amount := sdk.NewCoin("l1denom", math.NewInt(3_000_000)) input.Faucet.Fund(ctx, types.BridgeAddress(1), amount) outputRoot := decodeHex(t, "d87b15f515e52e234f5ddca84627128ad842fa6c741d6b85d589a13bbdad3a89") @@ -175,11 +176,11 @@ func Test_FinalizeTokenWithdrawal(t *testing.T) { now := time.Now().UTC() ctx = ctx.WithBlockTime(now) - _, err = ms.ProposeOutput(sdk.WrapSDKContext(ctx), types.NewMsgProposeOutput(addrs[0], 1, 100, outputRoot)) + _, err = ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[0], 1, 100, outputRoot)) require.NoError(t, err) ctx = ctx.WithBlockTime(now.Add(time.Second * 60)) - _, err = ms.FinalizeTokenWithdrawal(sdk.WrapSDKContext(ctx), types.NewMsgFinalizeTokenWithdrawal( + _, err = ms.FinalizeTokenWithdrawal(ctx, types.NewMsgFinalizeTokenWithdrawal( 1, 1, 4, proofs, decodeHex(t, "0000000000000000000000000000000000000004"), decodeHex(t, "0000000000000000000000000000000000000001"), @@ -210,12 +211,12 @@ func Test_UpdateProposal(t *testing.T) { Metadata: []byte{1, 2, 3}, } - _, err := ms.CreateBridge(sdk.WrapSDKContext(ctx), types.NewMsgCreateBridge(addrs[0], config)) + _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) require.NoError(t, err) // gov signer msg := types.NewMsgUpdateProposer(authtypes.NewModuleAddress("gov"), 1, addrs[1]) - _, err = ms.UpdateProposer(sdk.WrapSDKContext(ctx), msg) + _, err = ms.UpdateProposer(ctx, msg) require.NoError(t, err) _config, err := ms.GetBridgeConfig(ctx, 1) require.NoError(t, err) @@ -236,7 +237,7 @@ func Test_UpdateProposal(t *testing.T) { require.NoError(t, err) _, err = ms.UpdateProposer( - sdk.WrapSDKContext(ctx), + ctx, msg, ) require.Error(t, err) @@ -255,12 +256,12 @@ func Test_UpdateChallenger(t *testing.T) { Metadata: []byte{1, 2, 3}, } - _, err := ms.CreateBridge(sdk.WrapSDKContext(ctx), types.NewMsgCreateBridge(addrs[0], config)) + _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) require.NoError(t, err) // gov signer msg := types.NewMsgUpdateChallenger(authtypes.NewModuleAddress("gov"), 1, addrs[2]) - _, err = ms.UpdateChallenger(sdk.WrapSDKContext(ctx), msg) + _, err = ms.UpdateChallenger(ctx, msg) require.NoError(t, err) _config, err := ms.GetBridgeConfig(ctx, 1) require.NoError(t, err) @@ -281,7 +282,7 @@ func Test_UpdateChallenger(t *testing.T) { require.NoError(t, err) _, err = ms.UpdateChallenger( - sdk.WrapSDKContext(ctx), + ctx, msg, ) require.Error(t, err) @@ -292,10 +293,10 @@ func Test_MsgServer_UpdateParams(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) params := ms.GetParams(ctx) - params.RegistrationFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) + params.RegistrationFee = sdk.NewCoins(sdk.NewCoin("foo", math.NewInt(100))) msg := types.NewMsgUpdateParams(authtypes.NewModuleAddress("gov"), ¶ms) - _, err := ms.UpdateParams(sdk.WrapSDKContext(ctx), msg) + _, err := ms.UpdateParams(ctx, msg) require.NoError(t, err) require.Equal(t, params, ms.GetParams(ctx)) @@ -304,7 +305,7 @@ func Test_MsgServer_UpdateParams(t *testing.T) { require.NoError(t, err) _, err = ms.UpdateParams( - sdk.WrapSDKContext(ctx), + ctx, msg, ) require.Error(t, err) diff --git a/x/ophost/keeper/output.go b/x/ophost/keeper/output.go index 1d41e08a..8e2d88da 100644 --- a/x/ophost/keeper/output.go +++ b/x/ophost/keeper/output.go @@ -1,11 +1,11 @@ package keeper import ( - "encoding/binary" + "context" + "errors" - "github.com/cosmos/cosmos-sdk/store/prefix" + "cosmossdk.io/collections" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" "github.com/initia-labs/OPinit/x/ophost/types" ) @@ -13,62 +13,23 @@ import ( //////////////////////////////////// // OutputProposal -func (k Keeper) SetOutputProposal(ctx sdk.Context, bridgeId, outputIndex uint64, outputProposal types.Output) error { - bz, err := k.cdc.Marshal(&outputProposal) - if err != nil { - return err - } - - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.GetOutputProposalKey(bridgeId, outputIndex), bz) - - return nil +func (k Keeper) SetOutputProposal(ctx context.Context, bridgeId, outputIndex uint64, outputProposal types.Output) error { + return k.OutputProposals.Set(ctx, collections.Join(bridgeId, outputIndex), outputProposal) } -func (k Keeper) GetOutputProposal(ctx sdk.Context, bridgeId, outputIndex uint64) (outputProposal types.Output, err error) { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.GetOutputProposalKey(bridgeId, outputIndex)) - if len(bz) == 0 { - err = errors.ErrKeyNotFound.Wrap("failed to fetch output_proposal") - return - } - - err = k.cdc.Unmarshal(bz, &outputProposal) - return +func (k Keeper) GetOutputProposal(ctx context.Context, bridgeId, outputIndex uint64) (outputProposal types.Output, err error) { + return k.OutputProposals.Get(ctx, collections.Join(bridgeId, outputIndex)) } -func (k Keeper) DeleteOutputProposal(ctx sdk.Context, bridgeId, outputIndex uint64) { - kvStore := ctx.KVStore(k.storeKey) - kvStore.Delete(types.GetOutputProposalKey(bridgeId, outputIndex)) +func (k Keeper) DeleteOutputProposal(ctx context.Context, bridgeId, outputIndex uint64) error { + return k.OutputProposals.Remove(ctx, collections.Join(bridgeId, outputIndex)) } -func (k Keeper) IterateOutputProposals(ctx sdk.Context, bridgeId uint64, cb func(bridgeId, outputIndex uint64, output types.Output) bool) error { - kvStore := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(kvStore, types.GetOutputProposalBridgePrefixKey(bridgeId)) - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - key := iterator.Key() - val := iterator.Value() - - outputIndex := binary.BigEndian.Uint64(key) - - var output types.Output - if err := k.cdc.Unmarshal(val, &output); err != nil { - return err - } - - if cb(bridgeId, outputIndex, output) { - break - } - } - - return nil +func (k Keeper) IterateOutputProposals(ctx context.Context, bridgeId uint64, cb func(key collections.Pair[uint64, uint64], output types.Output) (stop bool, err error)) error { + return k.OutputProposals.Walk(ctx, collections.NewPrefixedPairRange[uint64, uint64](bridgeId), cb) } -func (k Keeper) IsFinalized(ctx sdk.Context, bridgeId, outputIndex uint64) (bool, error) { +func (k Keeper) IsFinalized(ctx context.Context, bridgeId, outputIndex uint64) (bool, error) { output, err := k.GetOutputProposal(ctx, bridgeId, outputIndex) if err != nil { return false, err @@ -79,46 +40,39 @@ func (k Keeper) IsFinalized(ctx sdk.Context, bridgeId, outputIndex uint64) (bool return false, err } - return ctx.BlockTime().Unix() >= output.L1BlockTime.Add(bridgeConfig.FinalizationPeriod).Unix(), nil + return sdk.UnwrapSDKContext(ctx).BlockTime().Unix() >= output.L1BlockTime.Add(bridgeConfig.FinalizationPeriod).Unix(), nil } //////////////////////////////////// // NextOutputIndex -func (k Keeper) SetNextOutputIndex(ctx sdk.Context, bridgeId, nextOutputIndex uint64) { - _nextOutputIndex := [8]byte{} - binary.BigEndian.PutUint64(_nextOutputIndex[:], nextOutputIndex) - - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.GetNextOutputIndexKey(bridgeId), _nextOutputIndex[:]) +func (k Keeper) SetNextOutputIndex(ctx context.Context, bridgeId, nextOutputIndex uint64) error { + return k.NextOutputIndexes.Set(ctx, bridgeId, nextOutputIndex) } -func (k Keeper) GetNextOutputIndex(ctx sdk.Context, bridgeId uint64) uint64 { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.GetNextOutputIndexKey(bridgeId)) - if len(bz) == 0 { - return 1 +func (k Keeper) GetNextOutputIndex(ctx context.Context, bridgeId uint64) (uint64, error) { + nextOutputIndex, err := k.NextOutputIndexes.Get(ctx, bridgeId) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + nextOutputIndex = 1 + } else { + return 0, err + } } - return binary.BigEndian.Uint64(bz) + return nextOutputIndex, nil } -func (k Keeper) IncreaseNextOutputIndex(ctx sdk.Context, bridgeId uint64) uint64 { - kvStore := ctx.KVStore(k.storeKey) - - // load next output index - key := types.GetNextOutputIndexKey(bridgeId) - bz := kvStore.Get(key) - - nextOutputIndex := uint64(1) - if len(bz) != 0 { - nextOutputIndex = binary.BigEndian.Uint64(bz) +func (k Keeper) IncreaseNextOutputIndex(ctx context.Context, bridgeId uint64) (uint64, error) { + nextOutputIndex, err := k.GetNextOutputIndex(ctx, bridgeId) + if err != nil { + return 0, err } - // increase next output index - _nextOutputIndex := [8]byte{} - binary.BigEndian.PutUint64(_nextOutputIndex[:], nextOutputIndex+1) - kvStore.Set(key, _nextOutputIndex[:]) + // increase NextOutputIndex + if err := k.NextOutputIndexes.Set(ctx, bridgeId, nextOutputIndex+1); err != nil { + return 0, err + } - return nextOutputIndex + return nextOutputIndex, nil } diff --git a/x/ophost/keeper/output_test.go b/x/ophost/keeper/output_test.go index 07f9c266..762c4d45 100644 --- a/x/ophost/keeper/output_test.go +++ b/x/ophost/keeper/output_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "cosmossdk.io/collections" "github.com/initia-labs/OPinit/x/ophost/types" "github.com/stretchr/testify/require" ) @@ -58,9 +59,9 @@ func Test_IterateOutputProposal(t *testing.T) { err = input.OPHostKeeper.SetOutputProposal(ctx, 2, 1, output4) require.NoError(t, err) - input.OPHostKeeper.IterateOutputProposals(ctx, 1, func(bridgeId, outputIndex uint64, output types.Output) bool { - require.Equal(t, bridgeId, uint64(1)) - switch outputIndex { + input.OPHostKeeper.IterateOutputProposals(ctx, 1, func(key collections.Pair[uint64, uint64], output types.Output) (stop bool, err error) { + require.Equal(t, key.K1(), uint64(1)) + switch key.K2() { case 1: require.Equal(t, output1, output) case 2: @@ -71,7 +72,7 @@ func Test_IterateOutputProposal(t *testing.T) { require.Fail(t, "should not enter here") } - return false + return false, nil }) } @@ -105,12 +106,27 @@ func Test_IsFinalized(t *testing.T) { func Test_NextOutputIndex(t *testing.T) { ctx, input := createDefaultTestInput(t) - require.Equal(t, uint64(1), input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1)) - require.Equal(t, uint64(2), input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1)) - require.Equal(t, uint64(3), input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1)) - require.Equal(t, uint64(4), input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1)) + index, err := input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1) + require.NoError(t, err) + require.Equal(t, uint64(1), index) + index, err = input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1) + require.NoError(t, err) + require.Equal(t, uint64(2), index) + index, err = input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1) + require.NoError(t, err) + require.Equal(t, uint64(3), index) + index, err = input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1) + require.NoError(t, err) + require.Equal(t, uint64(4), index) - input.OPHostKeeper.SetNextOutputIndex(ctx, 1, 100) - require.Equal(t, uint64(100), input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1)) - require.Equal(t, uint64(101), input.OPHostKeeper.GetNextOutputIndex(ctx, 1)) + err = input.OPHostKeeper.SetNextOutputIndex(ctx, 1, 100) + require.NoError(t, err) + + index, err = input.OPHostKeeper.IncreaseNextOutputIndex(ctx, 1) + require.NoError(t, err) + require.Equal(t, uint64(100), index) + + index, err = input.OPHostKeeper.GetNextOutputIndex(ctx, 1) + require.NoError(t, err) + require.Equal(t, uint64(101), index) } diff --git a/x/ophost/keeper/params.go b/x/ophost/keeper/params.go index 6f2583b2..7318b9c5 100644 --- a/x/ophost/keeper/params.go +++ b/x/ophost/keeper/params.go @@ -1,39 +1,28 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/initia-labs/OPinit/x/ophost/types" ) // RegistrationFee returns params.RegistrationFee -func (k Keeper) RegistrationFee(ctx sdk.Context) sdk.Coins { +func (k Keeper) RegistrationFee(ctx context.Context) sdk.Coins { return k.GetParams(ctx).RegistrationFee } // SetParams sets the x/opchild module parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - if err := params.Validate(); err != nil { - return err - } - - store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(¶ms) - if err != nil { - return err - } - store.Set(types.ParamsKey, bz) - - return nil +func (k Keeper) SetParams(ctx context.Context, params types.Params) error { + return k.Params.Set(ctx, params) } // GetParams sets the x/opchild module parameters. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKey) - if bz == nil { - return params +func (k Keeper) GetParams(ctx context.Context) (params types.Params) { + params, err := k.Params.Get(ctx) + if err != nil { + panic(err) } - k.cdc.MustUnmarshal(bz, ¶ms) return params } diff --git a/x/ophost/keeper/querier.go b/x/ophost/keeper/querier.go index ebdbd7ce..b39c7cf7 100644 --- a/x/ophost/keeper/querier.go +++ b/x/ophost/keeper/querier.go @@ -2,10 +2,8 @@ package keeper import ( "context" - "encoding/binary" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/collections" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -24,9 +22,7 @@ func NewQuerier(k Keeper) Querier { return Querier{k} } -func (q Querier) Bridge(context context.Context, req *types.QueryBridgeRequest) (*types.QueryBridgeResponse, error) { - ctx := sdk.UnwrapSDKContext(context) - +func (q Querier) Bridge(ctx context.Context, req *types.QueryBridgeRequest) (*types.QueryBridgeResponse, error) { bridgeId := req.BridgeId config, err := q.GetBridgeConfig(ctx, bridgeId) if err != nil { @@ -40,32 +36,14 @@ func (q Querier) Bridge(context context.Context, req *types.QueryBridgeRequest) }, nil } -func (q Querier) Bridges(context context.Context, req *types.QueryBridgesRequest) (*types.QueryBridgesResponse, error) { - ctx := sdk.UnwrapSDKContext(context) - - var bridges []types.QueryBridgeResponse - - store := ctx.KVStore(q.storeKey) - bridgeStore := prefix.NewStore(store, types.BridgeConfigKey) - - pageRes, err := query.FilteredPaginate(bridgeStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - bridgeId := binary.BigEndian.Uint64(key) - var config types.BridgeConfig - if err := q.cdc.Unmarshal(value, &config); err != nil { - return false, err - } - - if accumulate { - bridges = append(bridges, types.QueryBridgeResponse{ - BridgeId: bridgeId, - BridgeAddr: types.BridgeAddress(bridgeId).String(), - BridgeConfig: config, - }) - } - - return true, nil +func (q Querier) Bridges(ctx context.Context, req *types.QueryBridgesRequest) (*types.QueryBridgesResponse, error) { + bridges, pageRes, err := query.CollectionPaginate(ctx, q.Keeper.BridgeConfigs, req.Pagination, func(bridgeId uint64, bridgeConfig types.BridgeConfig) (types.QueryBridgeResponse, error) { + return types.QueryBridgeResponse{ + BridgeId: bridgeId, + BridgeAddr: types.BridgeAddress(bridgeId).String(), + BridgeConfig: bridgeConfig, + }, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -76,7 +54,7 @@ func (q Querier) Bridges(context context.Context, req *types.QueryBridgesRequest }, nil } -func (q Querier) TokenPairByL1Denom(context context.Context, req *types.QueryTokenPairByL1DenomRequest) (*types.QueryTokenPairByL1DenomResponse, error) { +func (q Querier) TokenPairByL1Denom(_ context.Context, req *types.QueryTokenPairByL1DenomRequest) (*types.QueryTokenPairByL1DenomResponse, error) { l2Denom := types.L2Denom(req.BridgeId, req.L1Denom) return &types.QueryTokenPairByL1DenomResponse{ TokenPair: types.TokenPair{ @@ -86,8 +64,7 @@ func (q Querier) TokenPairByL1Denom(context context.Context, req *types.QueryTok }, nil } -func (q Querier) TokenPairByL2Denom(context context.Context, req *types.QueryTokenPairByL2DenomRequest) (*types.QueryTokenPairByL2DenomResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (q Querier) TokenPairByL2Denom(ctx context.Context, req *types.QueryTokenPairByL2DenomRequest) (*types.QueryTokenPairByL2DenomResponse, error) { l1Denom, err := q.GetTokenPair(ctx, req.BridgeId, req.L2Denom) if err != nil { return nil, err @@ -101,29 +78,13 @@ func (q Querier) TokenPairByL2Denom(context context.Context, req *types.QueryTok }, nil } -func (q Querier) TokenPairs(context context.Context, req *types.QueryTokenPairsRequest) (*types.QueryTokenPairsResponse, error) { - ctx := sdk.UnwrapSDKContext(context) - - var pairs []types.TokenPair - bridgeId := req.BridgeId - - store := ctx.KVStore(q.storeKey) - pairStore := prefix.NewStore(store, types.GetTokenPairBridgePrefixKey(bridgeId)) - - pageRes, err := query.FilteredPaginate(pairStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - l2Denom := string(key) - l1Denom := string(value) - - if accumulate { - pairs = append(pairs, types.TokenPair{ - L1Denom: l1Denom, - L2Denom: l2Denom, - }) - } - - return true, nil - }) - +func (q Querier) TokenPairs(ctx context.Context, req *types.QueryTokenPairsRequest) (*types.QueryTokenPairsResponse, error) { + pairs, pageRes, err := query.CollectionPaginate(ctx, q.Keeper.TokenPairs, req.Pagination, func(key collections.Pair[uint64, string], l1Denom string) (types.TokenPair, error) { + return types.TokenPair{ + L1Denom: l1Denom, + L2Denom: key.K2(), + }, nil + }, query.WithCollectionPaginationPairPrefix[uint64, string](req.BridgeId)) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -134,8 +95,7 @@ func (q Querier) TokenPairs(context context.Context, req *types.QueryTokenPairsR }, nil } -func (q Querier) OutputProposal(context context.Context, req *types.QueryOutputProposalRequest) (*types.QueryOutputProposalResponse, error) { - ctx := sdk.UnwrapSDKContext(context) +func (q Querier) OutputProposal(ctx context.Context, req *types.QueryOutputProposalRequest) (*types.QueryOutputProposalResponse, error) { output, err := q.GetOutputProposal(ctx, req.BridgeId, req.OutputIndex) if err != nil { return nil, err @@ -148,33 +108,14 @@ func (q Querier) OutputProposal(context context.Context, req *types.QueryOutputP }, nil } -func (q Querier) OutputProposals(context context.Context, req *types.QueryOutputProposalsRequest) (*types.QueryOutputProposalsResponse, error) { - ctx := sdk.UnwrapSDKContext(context) - - var outputs []types.QueryOutputProposalResponse - bridgeId := req.BridgeId - - store := ctx.KVStore(q.storeKey) - outputStore := prefix.NewStore(store, types.GetOutputProposalBridgePrefixKey(bridgeId)) - - pageRes, err := query.FilteredPaginate(outputStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - outputIndex := binary.BigEndian.Uint64(key) - var output types.Output - if err := q.cdc.Unmarshal(value, &output); err != nil { - return false, err - } - - if accumulate { - outputs = append(outputs, types.QueryOutputProposalResponse{ - BridgeId: bridgeId, - OutputIndex: outputIndex, - OutputProposal: output, - }) - } - - return true, nil - }) - +func (q Querier) OutputProposals(ctx context.Context, req *types.QueryOutputProposalsRequest) (*types.QueryOutputProposalsResponse, error) { + outputs, pageRes, err := query.CollectionPaginate(ctx, q.Keeper.OutputProposals, req.Pagination, func(key collections.Pair[uint64, uint64], outputProposal types.Output) (types.QueryOutputProposalResponse, error) { + return types.QueryOutputProposalResponse{ + BridgeId: req.BridgeId, + OutputIndex: key.K2(), + OutputProposal: outputProposal, + }, nil + }, query.WithCollectionPaginationPairPrefix[uint64, uint64](req.BridgeId)) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -185,8 +126,6 @@ func (q Querier) OutputProposals(context context.Context, req *types.QueryOutput }, nil } -func (q Querier) Params(context context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(context) - +func (q Querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { return &types.QueryParamsResponse{Params: q.GetParams(ctx)}, nil } diff --git a/x/ophost/keeper/token_pair.go b/x/ophost/keeper/token_pair.go index 6d837c8c..ade79b3d 100644 --- a/x/ophost/keeper/token_pair.go +++ b/x/ophost/keeper/token_pair.go @@ -1,64 +1,38 @@ package keeper import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" + "context" + + "cosmossdk.io/collections" "github.com/initia-labs/OPinit/x/ophost/types" ) -func (k Keeper) SetTokenPair(ctx sdk.Context, bridgeId uint64, l2Denom, l1Denom string) { - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.GetTokenPairKey(bridgeId, l2Denom), []byte(l1Denom)) +func (k Keeper) SetTokenPair(ctx context.Context, bridgeId uint64, l2Denom, l1Denom string) error { + return k.TokenPairs.Set(ctx, collections.Join(bridgeId, l2Denom), l1Denom) } -func (k Keeper) HasTokenPair(ctx sdk.Context, bridgeId uint64, l2Denom string) bool { - kvStore := ctx.KVStore(k.storeKey) - return kvStore.Has(types.GetTokenPairKey(bridgeId, l2Denom)) +func (k Keeper) HasTokenPair(ctx context.Context, bridgeId uint64, l2Denom string) (bool, error) { + return k.TokenPairs.Has(ctx, collections.Join(bridgeId, l2Denom)) } func (k Keeper) GetTokenPair( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, l2Denom string, ) (l1Denom string, err error) { - kvStore := ctx.KVStore(k.storeKey) - bz := kvStore.Get(types.GetTokenPairKey(bridgeId, l2Denom)) - if len(bz) == 0 { - err = errors.ErrKeyNotFound - return - } - - l1Denom = string(bz) - return + return k.TokenPairs.Get(ctx, collections.Join(bridgeId, l2Denom)) } func (k Keeper) IterateTokenPair( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, - cb func(bridgeId uint64, tokenPair types.TokenPair) bool, + cb func(bridgeId uint64, tokenPair types.TokenPair) (stop bool, err error), ) error { - kvStore := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(kvStore, types.GetTokenPairBridgePrefixKey(bridgeId)) - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - key := iterator.Key() - val := iterator.Value() - - l2Denom := string(key) - l1Denom := string(val) - - if cb(bridgeId, types.TokenPair{ - L2Denom: l2Denom, + return k.TokenPairs.Walk(ctx, collections.NewPrefixedPairRange[uint64, string](bridgeId), func(key collections.Pair[uint64, string], l1Denom string) (stop bool, err error) { + return cb(key.K1(), types.TokenPair{ L1Denom: l1Denom, - }) { - break - } - } - - return nil + L2Denom: key.K2(), + }) + }) } diff --git a/x/ophost/keeper/token_pair_test.go b/x/ophost/keeper/token_pair_test.go index 5d0ffeb2..763fb6c1 100644 --- a/x/ophost/keeper/token_pair_test.go +++ b/x/ophost/keeper/token_pair_test.go @@ -39,13 +39,13 @@ func Test_IterateTokenPair(t *testing.T) { input.OPHostKeeper.SetTokenPair(ctx, 1, tokenPair2.L2Denom, tokenPair2.L1Denom) input.OPHostKeeper.SetTokenPair(ctx, 2, tokenPair3.L2Denom, tokenPair3.L1Denom) - input.OPHostKeeper.IterateTokenPair(ctx, 1, func(bridgeId uint64, tokenPair types.TokenPair) bool { + input.OPHostKeeper.IterateTokenPair(ctx, 1, func(bridgeId uint64, tokenPair types.TokenPair) (stop bool, err error) { require.Equal(t, bridgeId, uint64(1)) if tokenPair.L1Denom == tokenPair1.L1Denom { require.Equal(t, tokenPair1, tokenPair) } else { require.Equal(t, tokenPair2, tokenPair) } - return false + return false, nil }) } diff --git a/x/ophost/keeper/withdrawal.go b/x/ophost/keeper/withdrawal.go index b77d9efd..b9e9ba9b 100644 --- a/x/ophost/keeper/withdrawal.go +++ b/x/ophost/keeper/withdrawal.go @@ -1,42 +1,27 @@ package keeper import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/initia-labs/OPinit/x/ophost/types" + "context" + + "cosmossdk.io/collections" ) -func (k Keeper) RecordProvenWithdrawal(ctx sdk.Context, bridgeId uint64, withdrawalHash [32]byte) { - kvStore := ctx.KVStore(k.storeKey) - kvStore.Set(types.GetProvenWithdrawalKey(bridgeId, withdrawalHash), []byte{1}) +func (k Keeper) RecordProvenWithdrawal(ctx context.Context, bridgeId uint64, withdrawalHash [32]byte) error { + return k.ProvenWithdrawals.Set(ctx, collections.Join(bridgeId, withdrawalHash[:]), true) } -func (k Keeper) HasProvenWithdrawal(ctx sdk.Context, bridgeId uint64, withdrawalHash [32]byte) bool { - kvStore := ctx.KVStore(k.storeKey) - return kvStore.Has(types.GetProvenWithdrawalKey(bridgeId, withdrawalHash)) +func (k Keeper) HasProvenWithdrawal(ctx context.Context, bridgeId uint64, withdrawalHash [32]byte) (bool, error) { + return k.ProvenWithdrawals.Has(ctx, collections.Join(bridgeId, withdrawalHash[:])) } func (k Keeper) IterateProvenWithdrawals( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, - cb func(bridgeId uint64, withdrawalHash [32]byte) bool, + cb func(bridgeId uint64, withdrawalHash [32]byte) (bool, error), ) error { - kvStore := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(kvStore, types.GetProvenWithdrawalPrefixKey(bridgeId)) - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - key := iterator.Key() - + return k.ProvenWithdrawals.Walk(ctx, collections.NewPrefixedPairRange[uint64, []byte](bridgeId), func(key collections.Pair[uint64, []byte], value bool) (stop bool, err error) { withdrawalHash := [32]byte{} - copy(withdrawalHash[:], key) - - if cb(bridgeId, withdrawalHash) { - break - } - } - - return nil + copy(withdrawalHash[:], key.K2()) + return cb(bridgeId, withdrawalHash) + }) } diff --git a/x/ophost/keeper/withdrawal_test.go b/x/ophost/keeper/withdrawal_test.go index 132a4cac..33ce1693 100644 --- a/x/ophost/keeper/withdrawal_test.go +++ b/x/ophost/keeper/withdrawal_test.go @@ -13,15 +13,20 @@ func Test_ProvenWithdrawal(t *testing.T) { input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{4, 5, 6}) input.OPHostKeeper.RecordProvenWithdrawal(ctx, 2, [32]byte{7, 8, 9}) - require.True(t, input.OPHostKeeper.HasProvenWithdrawal(ctx, 1, [32]byte{1, 2, 3})) - require.True(t, input.OPHostKeeper.HasProvenWithdrawal(ctx, 1, [32]byte{4, 5, 6})) + found, err := input.OPHostKeeper.HasProvenWithdrawal(ctx, 1, [32]byte{1, 2, 3}) + require.NoError(t, err) + require.True(t, found) - input.OPHostKeeper.IterateProvenWithdrawals(ctx, 1, func(bridgeId uint64, withdrawalHash [32]byte) bool { + found, err = input.OPHostKeeper.HasProvenWithdrawal(ctx, 1, [32]byte{4, 5, 6}) + require.NoError(t, err) + require.True(t, found) + + input.OPHostKeeper.IterateProvenWithdrawals(ctx, 1, func(bridgeId uint64, withdrawalHash [32]byte) (bool, error) { require.Equal(t, uint64(1), bridgeId) if withdrawalHash != [32]byte{1, 2, 3} { require.Equal(t, [32]byte{4, 5, 6}, withdrawalHash) } - return false + return false, nil }) } diff --git a/x/ophost/module.go b/x/ophost/module.go index 87dc03d1..6bedceb6 100644 --- a/x/ophost/module.go +++ b/x/ophost/module.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -23,12 +23,19 @@ import ( const ConsensusVersion = 1 var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasConsensusVersion = AppModule{} + _ module.HasName = AppModule{} + + _ appmodule.AppModule = AppModule{} ) -// AppModuleBasic defines the basic application module used by the move module. -type AppModuleBasic struct{} +// AppModuleBasic defines the basic application module used by the ophost module. +type AppModuleBasic struct { + cdc codec.Codec +} func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { //nolint:staticcheck types.RegisterLegacyAminoCodec(amino) @@ -60,17 +67,17 @@ func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, config client return err } - return types.ValidateGenesis(&genState) + return types.ValidateGenesis(&genState, b.cdc.InterfaceRegistry().SigningContext().AddressCodec()) } // GetTxCmd returns the root tx command for the move module. func (b AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd() + return cli.GetTxCmd(b.cdc.InterfaceRegistry().SigningContext().AddressCodec()) } // GetQueryCmd returns no root query command for the move module. func (b AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() + return cli.GetQueryCmd(b.cdc.InterfaceRegistry().SigningContext().AddressCodec()) } // RegisterInterfaces implements InterfaceModule @@ -94,10 +101,11 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // NewAppModule creates a new AppModule object func NewAppModule( + cdc codec.Codec, k keeper.Keeper, ) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{}, + AppModuleBasic: AppModuleBasic{cdc}, keeper: k, } } @@ -112,13 +120,11 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} // InitGenesis performs genesis initialization for the move module. It returns // no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - validators := am.keeper.InitGenesis(ctx, &genesisState) - - return validators + am.keeper.InitGenesis(ctx, &genesisState) } // ExportGenesis returns the exported genesis state as raw bytes for the move @@ -128,12 +134,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw return cdc.MustMarshalJSON(gs) } -// BeginBlock returns the begin blocker for the move module. -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { -} +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} -// EndBlock returns the end blocker for the move module. It returns no validator -// updates. -func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/ophost/types/auth.go b/x/ophost/types/auth.go index c128437b..060ca8fd 100644 --- a/x/ophost/types/auth.go +++ b/x/ophost/types/auth.go @@ -11,7 +11,7 @@ import ( ) var ( - _ authtypes.AccountI = (*BridgeAccount)(nil) + _ sdk.AccountI = (*BridgeAccount)(nil) _ authtypes.GenesisAccount = (*BridgeAccount)(nil) ) diff --git a/x/ophost/types/bridge_config.go b/x/ophost/types/bridge_config.go index 804c383b..ae389936 100644 --- a/x/ophost/types/bridge_config.go +++ b/x/ophost/types/bridge_config.go @@ -1,15 +1,15 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/core/address" ) -func (config BridgeConfig) Validate() error { - if _, err := sdk.AccAddressFromBech32(config.Challenger); err != nil { +func (config BridgeConfig) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(config.Challenger); err != nil { return err } - if _, err := sdk.AccAddressFromBech32(config.Proposer); err != nil { + if _, err := ac.StringToBytes(config.Proposer); err != nil { return err } diff --git a/x/ophost/types/codec.go b/x/ophost/types/codec.go index 0c7f26eb..df313e13 100644 --- a/x/ophost/types/codec.go +++ b/x/ophost/types/codec.go @@ -4,13 +4,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" - govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" - groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec" ) // RegisterLegacyAminoCodec registers the move types and interface @@ -45,7 +41,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { // auth account registration registry.RegisterImplementations( - (*authtypes.AccountI)(nil), + (*sdk.AccountI)(nil), &BridgeAccount{}, ) registry.RegisterImplementations( @@ -55,20 +51,3 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - sdk.RegisterLegacyAminoCodec(amino) - - // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be - // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances - RegisterLegacyAminoCodec(authzcodec.Amino) - RegisterLegacyAminoCodec(govcodec.Amino) - RegisterLegacyAminoCodec(groupcodec.Amino) -} diff --git a/x/ophost/types/event.go b/x/ophost/types/event.go index d834529a..3dc35b37 100644 --- a/x/ophost/types/event.go +++ b/x/ophost/types/event.go @@ -7,6 +7,8 @@ const ( EventTypeDeleteOutput = "delete_output" EventTypeInitiateTokenDeposit = "initiate_token_deposit" EventTypeFinalizeTokenWithdrawal = "finalize_token_withdrawal" + EventTypeUpdateProposer = "update_proposer" + EventTypeUpdateChallenger = "update_challenger" AttributeKeySubmitter = "submitter" AttributeKeyCreator = "creator" diff --git a/x/ophost/types/expected_keeper.go b/x/ophost/types/expected_keeper.go index d1092629..b6886b05 100644 --- a/x/ophost/types/expected_keeper.go +++ b/x/ophost/types/expected_keeper.go @@ -1,40 +1,42 @@ package types import ( + "context" + + "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + AddressCodec() address.Codec + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + NextAccountNumber(ctx context.Context) uint64 - IterateAccounts(ctx sdk.Context, process func(authtypes.AccountI) (stop bool)) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // only used for simulation - HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, acc authtypes.AccountI) + IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool)) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + HasAccount(ctx context.Context, addr sdk.AccAddress) bool + SetAccount(ctx context.Context, acc sdk.AccountI) GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI - - // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, authtypes.ModuleAccountI) + GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI + SetModuleAccount(context.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + LockedCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins + SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins - GetSupply(ctx sdk.Context, denom string) sdk.Coin + GetSupply(ctx context.Context, denom string) sdk.Coin - SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx context.Context, senderPool, recipientPool string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error - BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error + MintCoins(ctx context.Context, moduleName string, amounts sdk.Coins) error + BurnCoins(ctx context.Context, moduleName string, amounts sdk.Coins) error } diff --git a/x/ophost/types/genesis.go b/x/ophost/types/genesis.go index 39a80209..1dad4228 100644 --- a/x/ophost/types/genesis.go +++ b/x/ophost/types/genesis.go @@ -1,6 +1,7 @@ package types import ( + "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -24,9 +25,9 @@ func DefaultGenesisState() *GenesisState { // ValidateGenesis performs basic validation of rollup genesis data returning an // error for any failed validation criteria. -func ValidateGenesis(data *GenesisState) error { +func ValidateGenesis(data *GenesisState, ac address.Codec) error { for _, bridge := range data.Bridges { - if err := bridge.BridgeConfig.Validate(); err != nil { + if err := bridge.BridgeConfig.Validate(ac); err != nil { return err } diff --git a/x/ophost/types/hooks.go b/x/ophost/types/hooks.go index c2900dff..3fcef965 100644 --- a/x/ophost/types/hooks.go +++ b/x/ophost/types/hooks.go @@ -1,22 +1,20 @@ package types -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) +import "context" type BridgeHook interface { BridgeCreated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig BridgeConfig, ) error BridgeChallengerUpdated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig BridgeConfig, ) error BridgeProposerUpdated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig BridgeConfig, ) error @@ -31,7 +29,7 @@ func NewBridgeHooks(hooks ...BridgeHook) BridgeHooks { var _ BridgeHook = BridgeHooks{} func (hooks BridgeHooks) BridgeCreated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig BridgeConfig, ) error { @@ -45,7 +43,7 @@ func (hooks BridgeHooks) BridgeCreated( } func (hooks BridgeHooks) BridgeChallengerUpdated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig BridgeConfig, ) error { @@ -59,7 +57,7 @@ func (hooks BridgeHooks) BridgeChallengerUpdated( } func (hooks BridgeHooks) BridgeProposerUpdated( - ctx sdk.Context, + ctx context.Context, bridgeId uint64, bridgeConfig BridgeConfig, ) error { diff --git a/x/ophost/types/keys.go b/x/ophost/types/keys.go index 1602f990..9fc9a87c 100644 --- a/x/ophost/types/keys.go +++ b/x/ophost/types/keys.go @@ -1,9 +1,5 @@ package types -import ( - "encoding/binary" -) - const ( // ModuleName is the name of the ophost module ModuleName = "ophost" @@ -20,82 +16,15 @@ var ( // Keys for store prefixes NextBridgeIdKey = []byte{0x11} - BridgeConfigKey = []byte{0x21} - NextL1SequenceKey = []byte{0x22} + BridgeConfigPrefix = []byte{0x21} + NextL1SequencePrefix = []byte{0x22} - TokenPairKey = []byte{0x31} + TokenPairPrefix = []byte{0x31} - OutputProposalKey = []byte{0x41} - NextOutputIndexKey = []byte{0x42} + OutputProposalPrefix = []byte{0x41} + NextOutputIndexPrefix = []byte{0x42} - ProvenWithdrawalKey = []byte{0x51} + ProvenWithdrawalPrefix = []byte{0x51} ParamsKey = []byte{0x61} ) - -// GetBridgeConfigKey creates the key for the bridge config with bridge id -func GetBridgeConfigKey(bridgeId uint64) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - return append(BridgeConfigKey, _bridgeId[:]...) -} - -// GetNextL1SequenceKey creates the key for the next bridge sequence with bridge id -func GetNextL1SequenceKey(bridgeId uint64) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - return append(NextL1SequenceKey, _bridgeId[:]...) -} - -// GetTokenPairBridgePrefixKey creates the prefix key for the token pair info with bridge id -func GetTokenPairBridgePrefixKey(bridgeId uint64) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - return append(TokenPairKey, _bridgeId[:]...) -} - -// GetTokenPairKey creates the key for the token pair info with bridge id and l2Denom -func GetTokenPairKey(bridgeId uint64, l2Denom string) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - return append(append(TokenPairKey, _bridgeId[:]...), []byte(l2Denom)...) -} - -func GetOutputProposalBridgePrefixKey(bridgeId uint64) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - - return append(OutputProposalKey, _bridgeId[:]...) -} - -// GetOutputProposalKey creates the key for the output proposal with bridge id and outputIndex. -func GetOutputProposalKey(bridgeId, outputIndex uint64) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - - _outputIndex := [8]byte{} - binary.BigEndian.PutUint64(_outputIndex[:], outputIndex) - - return append(append(OutputProposalKey, _bridgeId[:]...), _outputIndex[:]...) -} - -// GetNextOutputIndexKey creates the key for the next output index with bridge id. -func GetNextOutputIndexKey(bridgeId uint64) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - return append(NextOutputIndexKey, _bridgeId[:]...) -} - -func GetProvenWithdrawalPrefixKey(bridgeId uint64) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - - return append(ProvenWithdrawalKey, _bridgeId[:]...) -} - -// GetProvenWithdrawalKey creates the key for the proven withdrawal with bridge id and withdrawal hash. -func GetProvenWithdrawalKey(bridgeId uint64, withdrawalHash [32]byte) []byte { - _bridgeId := [8]byte{} - binary.BigEndian.PutUint64(_bridgeId[:], bridgeId) - return append(append(ProvenWithdrawalKey, _bridgeId[:]...), withdrawalHash[:]...) -} diff --git a/x/ophost/types/tx.go b/x/ophost/types/tx.go index 235defac..2d369225 100644 --- a/x/ophost/types/tx.go +++ b/x/ophost/types/tx.go @@ -1,8 +1,8 @@ package types import ( + "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) // rollup message types @@ -28,16 +28,6 @@ var ( _ sdk.Msg = &MsgUpdateProposer{} _ sdk.Msg = &MsgUpdateChallenger{} _ sdk.Msg = &MsgUpdateParams{} - - _ legacytx.LegacyMsg = &MsgRecordBatch{} - _ legacytx.LegacyMsg = &MsgCreateBridge{} - _ legacytx.LegacyMsg = &MsgProposeOutput{} - _ legacytx.LegacyMsg = &MsgDeleteOutput{} - _ legacytx.LegacyMsg = &MsgFinalizeTokenWithdrawal{} - _ legacytx.LegacyMsg = &MsgInitiateTokenDeposit{} - _ legacytx.LegacyMsg = &MsgUpdateProposer{} - _ legacytx.LegacyMsg = &MsgUpdateChallenger{} - _ legacytx.LegacyMsg = &MsgUpdateParams{} ) /* MsgRecordBatch */ @@ -55,19 +45,9 @@ func NewMsgRecordBatch( } } -// Route implements the sdk.Msg interface. -func (msg MsgRecordBatch) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgRecordBatch) Type() string { - return TypeMsgRecordBatch -} - -// ValidateBasic performs basic MsgRecordBatch message validation. -func (msg MsgRecordBatch) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Submitter); err != nil { +// Validate performs basic MsgRecordBatch message validation. +func (msg MsgRecordBatch) Validate(accAddressCodec address.Codec) error { + if _, err := accAddressCodec.StringToBytes(msg.Submitter); err != nil { return err } @@ -78,21 +58,6 @@ func (msg MsgRecordBatch) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgRecordBatch) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgRecordBatch) GetSigners() []sdk.AccAddress { - submitterAddr, err := sdk.AccAddressFromBech32(msg.Submitter) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{submitterAddr} -} - /* MsgCreateBridge */ // NewMsgCreateBridge creates a new MsgCreateBridge instance. @@ -106,44 +71,19 @@ func NewMsgCreateBridge( } } -// Route implements the sdk.Msg interface. -func (msg MsgCreateBridge) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgCreateBridge) Type() string { - return TypeMsgCreateBridge -} - -// ValidateBasic performs basic MsgCreateBridge message validation. -func (msg MsgCreateBridge) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { +// Validate performs basic MsgCreateBridge message validation. +func (msg MsgCreateBridge) Validate(ac address.Codec) error { + if _, err := ac.StringToBytes(msg.Creator); err != nil { return err } - if err := msg.Config.Validate(); err != nil { + if err := msg.Config.Validate(ac); err != nil { return err } return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgCreateBridge) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgCreateBridge) GetSigners() []sdk.AccAddress { - creatorAddr, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{creatorAddr} -} - /* MsgProposeOutput */ // NewMsgProposeOutput creates a new MsgProposeOutput instance. @@ -162,19 +102,9 @@ func NewMsgProposeOutput( } } -// Route implements the sdk.Msg interface. -func (msg MsgProposeOutput) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgProposeOutput) Type() string { - return TypeMsgProposeOutput -} - -// ValidateBasic performs basic MsgProposeOutput message validation. -func (msg MsgProposeOutput) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Proposer) +// Validate performs basic MsgProposeOutput message validation. +func (msg MsgProposeOutput) Validate(accAddressCodec address.Codec) error { + _, err := accAddressCodec.StringToBytes(msg.Proposer) if err != nil { return err } @@ -190,19 +120,6 @@ func (msg MsgProposeOutput) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgProposeOutput) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgProposeOutput) GetSigners() []sdk.AccAddress { - proposer, _ := sdk.AccAddressFromBech32(msg.Proposer) - - return []sdk.AccAddress{proposer} -} - /* MsgDeleteOutput */ // NewMsgDeleteOutput creates a new MsgDeleteOutput instance. @@ -218,19 +135,9 @@ func NewMsgDeleteOutput( } } -// Route implements the sdk.Msg interface. -func (msg MsgDeleteOutput) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgDeleteOutput) Type() string { - return TypeMsgDeleteOutput -} - -// ValidateBasic performs basic MsgDeleteOutput message validation. -func (msg MsgDeleteOutput) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Challenger); err != nil { +// Validate performs basic MsgDeleteOutput message validation. +func (msg MsgDeleteOutput) Validate(accAddressCodec address.Codec) error { + if _, err := accAddressCodec.StringToBytes(msg.Challenger); err != nil { return err } @@ -245,21 +152,6 @@ func (msg MsgDeleteOutput) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgDeleteOutput) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgDeleteOutput) GetSigners() []sdk.AccAddress { - challengerAddr, err := sdk.AccAddressFromBech32(msg.Challenger) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{challengerAddr} -} - /* MsgInitiateTokenDeposit */ // NewMsgInitiateTokenDeposit creates a new MsgInitiateTokenDeposit instance. @@ -279,23 +171,13 @@ func NewMsgInitiateTokenDeposit( } } -// Route implements the sdk.Msg interface. -func (msg MsgInitiateTokenDeposit) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgInitiateTokenDeposit) Type() string { - return TypeMsgInitiateTokenDeposit -} - -// ValidateBasic performs basic MsgInitiateTokenDeposit message validation. -func (msg MsgInitiateTokenDeposit) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { +// Validate performs basic MsgInitiateTokenDeposit message validation. +func (msg MsgInitiateTokenDeposit) Validate(accAddressCodec address.Codec) error { + if _, err := accAddressCodec.StringToBytes(msg.Sender); err != nil { return err } - if _, err := sdk.AccAddressFromBech32(msg.To); err != nil { + if _, err := accAddressCodec.StringToBytes(msg.To); err != nil { return err } @@ -310,21 +192,6 @@ func (msg MsgInitiateTokenDeposit) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgInitiateTokenDeposit) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgInitiateTokenDeposit) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - /* MsgFinalizeTokenWithdrawal */ // NewMsgFinalizeTokenWithdrawal creates a new MsgFinalizeTokenWithdrawal @@ -356,23 +223,13 @@ func NewMsgFinalizeTokenWithdrawal( } } -// Route implements the sdk.Msg interface. -func (msg MsgFinalizeTokenWithdrawal) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgFinalizeTokenWithdrawal) Type() string { - return TypeMsgFinalizeTokenWithdrawal -} - -// ValidateBasic performs basic MsgFinalizeTokenWithdrawal message validation. -func (msg MsgFinalizeTokenWithdrawal) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { +// Validate performs basic MsgFinalizeTokenWithdrawal message validation. +func (msg MsgFinalizeTokenWithdrawal) Validate(accAddressCodec address.Codec) error { + if _, err := accAddressCodec.StringToBytes(msg.Sender); err != nil { return err } - if _, err := sdk.AccAddressFromBech32(msg.Receiver); err != nil { + if _, err := accAddressCodec.StringToBytes(msg.Receiver); err != nil { return err } @@ -417,21 +274,6 @@ func (msg MsgFinalizeTokenWithdrawal) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgFinalizeTokenWithdrawal) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgFinalizeTokenWithdrawal) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - /* MsgUpdateProposer */ // NewMsgUpdateProposer creates a new MsgUpdateProposer instance. @@ -447,19 +289,9 @@ func NewMsgUpdateProposer( } } -// Route implements the sdk.Msg interface. -func (msg MsgUpdateProposer) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgUpdateProposer) Type() string { - return TypeMsgUpdateProposer -} - -// ValidateBasic performs basic MsgUpdateProposer message validation. -func (msg MsgUpdateProposer) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { +// Validate performs basic MsgUpdateProposer message validation. +func (msg MsgUpdateProposer) Validate(accAddressCodec address.Codec) error { + if _, err := accAddressCodec.StringToBytes(msg.Authority); err != nil { return err } @@ -467,28 +299,13 @@ func (msg MsgUpdateProposer) ValidateBasic() error { return ErrInvalidBridgeId } - if _, err := sdk.AccAddressFromBech32(msg.NewProposer); err != nil { + if _, err := accAddressCodec.StringToBytes(msg.NewProposer); err != nil { return err } return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgUpdateProposer) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgUpdateProposer) GetSigners() []sdk.AccAddress { - authorityAddr, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{authorityAddr} -} - /* MsgUpdateChallenger */ // NewMsgUpdateChallenger creates a new MsgUpdateChallenger instance. @@ -504,19 +321,9 @@ func NewMsgUpdateChallenger( } } -// Route implements the sdk.Msg interface. -func (msg MsgUpdateChallenger) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgUpdateChallenger) Type() string { - return TypeMsgUpdateChallenger -} - -// ValidateBasic performs basic MsgUpdateChallenger message validation. -func (msg MsgUpdateChallenger) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { +// Validate performs basic MsgUpdateChallenger message validation. +func (msg MsgUpdateChallenger) Validate(accAddressCodec address.Codec) error { + if _, err := accAddressCodec.StringToBytes(msg.Authority); err != nil { return err } @@ -524,28 +331,13 @@ func (msg MsgUpdateChallenger) ValidateBasic() error { return ErrInvalidBridgeId } - if _, err := sdk.AccAddressFromBech32(msg.NewChallenger); err != nil { + if _, err := accAddressCodec.StringToBytes(msg.NewChallenger); err != nil { return err } return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgUpdateChallenger) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgUpdateChallenger) GetSigners() []sdk.AccAddress { - authorityAddr, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{authorityAddr} -} - /* MsgUpdateParams */ // NewMsgUpdateParams returns a new MsgUpdateParams instance @@ -556,19 +348,9 @@ func NewMsgUpdateParams(authority sdk.AccAddress, params *Params) *MsgUpdatePara } } -// Route implements the sdk.Msg interface. -func (msg MsgUpdateParams) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgUpdateParams) Type() string { - return TypeMsgUpdateParams -} - -// ValidateBasic performs basic MsgUpdateParams message validation. -func (msg MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { +// Validate performs basic MsgUpdateParams message validation. +func (msg MsgUpdateParams) Validate(accAddressCodec address.Codec) error { + if _, err := accAddressCodec.StringToBytes(msg.Authority); err != nil { return err } @@ -578,18 +360,3 @@ func (msg MsgUpdateParams) ValidateBasic() error { return nil } - -// GetSignBytes returns the message bytes to sign over. -func (msg MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} diff --git a/x/ophost/types/tx.pb.go b/x/ophost/types/tx.pb.go index 6b8bf122..03108bcc 100644 --- a/x/ophost/types/tx.pb.go +++ b/x/ophost/types/tx.pb.go @@ -7,7 +7,6 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/codec/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" @@ -17,7 +16,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" @@ -773,99 +771,97 @@ func init() { func init() { proto.RegisterFile("opinit/ophost/v1/tx.proto", fileDescriptor_d16af6eaf4088d05) } var fileDescriptor_d16af6eaf4088d05 = []byte{ - // 1464 bytes of a gzipped FileDescriptorProto + // 1440 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0xcd, 0x6f, 0x1b, 0x45, 0x14, 0xb7, 0xdd, 0x34, 0x89, 0xc7, 0xf9, 0xdc, 0xa4, 0x89, 0xb3, 0x2d, 0xde, 0x64, 0xa0, 0x90, - 0xa6, 0x89, 0x57, 0x0e, 0xa5, 0x48, 0x96, 0x7a, 0xe8, 0xa6, 0xa2, 0x1f, 0x92, 0x69, 0xb4, 0x80, - 0xf8, 0x10, 0x92, 0x35, 0xb6, 0xa7, 0xeb, 0x55, 0xed, 0x1d, 0xb3, 0x33, 0x4e, 0x1a, 0x24, 0x24, - 0xc4, 0x09, 0x71, 0x40, 0x9c, 0x38, 0xf7, 0x82, 0xc4, 0xb1, 0x07, 0xc4, 0xdf, 0x90, 0x0b, 0x52, - 0x85, 0x38, 0x70, 0x5a, 0x41, 0x7b, 0x28, 0x07, 0x4e, 0xbe, 0xf6, 0x82, 0x76, 0x66, 0xf6, 0xcb, - 0xf1, 0xa6, 0x21, 0xaa, 0xe0, 0x12, 0x65, 0xe6, 0xf7, 0x7b, 0x33, 0xef, 0xfd, 0xe6, 0xcd, 0xbc, - 0xe7, 0x05, 0x2b, 0xa4, 0x67, 0x3b, 0x36, 0xd3, 0x49, 0xaf, 0x4d, 0x28, 0xd3, 0xf7, 0x2a, 0x3a, - 0x7b, 0x50, 0xee, 0xb9, 0x84, 0x11, 0x65, 0x4e, 0x40, 0x65, 0x01, 0x95, 0xf7, 0x2a, 0xea, 0x3c, - 0xea, 0xda, 0x0e, 0xd1, 0xf9, 0x5f, 0x41, 0x52, 0x4b, 0x4d, 0x42, 0xbb, 0x84, 0xea, 0x0d, 0x44, - 0xb1, 0xbe, 0x57, 0x69, 0x60, 0x86, 0x2a, 0x7a, 0x93, 0xd8, 0x8e, 0xc4, 0x97, 0x25, 0xde, 0xa5, - 0x96, 0xbf, 0x78, 0x97, 0x5a, 0x12, 0x58, 0x11, 0x40, 0x9d, 0x8f, 0x74, 0x31, 0x90, 0xd0, 0xa2, - 0x45, 0x2c, 0x22, 0xe6, 0xfd, 0xff, 0x02, 0x03, 0x8b, 0x10, 0xab, 0x83, 0x75, 0x3e, 0x6a, 0xf4, - 0xef, 0xe9, 0xc8, 0x39, 0x90, 0x90, 0x36, 0x0c, 0x31, 0xbb, 0x8b, 0x29, 0x43, 0xdd, 0x9e, 0x24, - 0x5c, 0x38, 0x1a, 0xe5, 0x41, 0x0f, 0xcb, 0xfd, 0xe0, 0x20, 0x0b, 0x66, 0x6a, 0xd4, 0x32, 0x71, - 0x93, 0xb8, 0x2d, 0x03, 0xb1, 0x66, 0x5b, 0xb9, 0x03, 0xf2, 0xb4, 0xdf, 0xe8, 0xda, 0x8c, 0x61, - 0xb7, 0x98, 0x5d, 0xcd, 0xae, 0xe7, 0x8d, 0xcd, 0x81, 0xa7, 0xcd, 0x1d, 0xa0, 0x6e, 0xa7, 0x0a, - 0x43, 0x08, 0xfe, 0xfa, 0xd3, 0xd6, 0xa2, 0xf4, 0xfd, 0x7a, 0xab, 0xe5, 0x62, 0x4a, 0xdf, 0x63, - 0xae, 0xed, 0x58, 0x66, 0x64, 0xae, 0x54, 0x40, 0xbe, 0xe1, 0xda, 0x2d, 0x0b, 0xd7, 0xed, 0x56, - 0x31, 0xb7, 0x9a, 0x5d, 0x1f, 0x33, 0x16, 0xa3, 0xb5, 0x42, 0x08, 0x9a, 0x93, 0xe2, 0xff, 0xdb, - 0x2d, 0xe5, 0x6d, 0x50, 0x68, 0xf8, 0x7e, 0xd4, 0x1b, 0x07, 0x0c, 0xd3, 0xe2, 0x99, 0xd5, 0xec, - 0xfa, 0x94, 0xb1, 0x34, 0xf0, 0x34, 0x45, 0x1a, 0x45, 0x20, 0x34, 0x01, 0x1f, 0x19, 0xfe, 0xa0, - 0xba, 0xfe, 0xd5, 0xb3, 0x47, 0x1b, 0xd1, 0xde, 0xdf, 0x3c, 0x7b, 0xb4, 0x71, 0x4e, 0x06, 0x9d, - 0x8c, 0x10, 0x16, 0xc1, 0x52, 0x72, 0xc6, 0xc4, 0xb4, 0x47, 0x1c, 0x8a, 0xe1, 0x6f, 0x59, 0x30, - 0x5b, 0xa3, 0xd6, 0x8e, 0x8b, 0x11, 0xc3, 0x06, 0x77, 0x49, 0xb9, 0x01, 0x26, 0x9a, 0xfe, 0x98, - 0x04, 0x6a, 0x6c, 0x0c, 0x3c, 0x6d, 0x46, 0x38, 0x23, 0x81, 0x74, 0x2d, 0x02, 0x53, 0xc5, 0x04, - 0xe3, 0x4d, 0xe2, 0xdc, 0xb3, 0x2d, 0x2e, 0x43, 0x61, 0xbb, 0x54, 0x1e, 0x4e, 0xb1, 0xb2, 0xd8, - 0x6f, 0x87, 0xb3, 0x0c, 0xf5, 0xd0, 0xd3, 0x32, 0x03, 0x4f, 0x9b, 0x96, 0x1b, 0xf1, 0x59, 0xf8, - 0xe3, 0xb3, 0x47, 0x1b, 0x59, 0x53, 0xae, 0x54, 0x7d, 0xc3, 0x8f, 0x38, 0xd8, 0xc1, 0x8f, 0x77, - 0x29, 0x8a, 0x37, 0x1e, 0x02, 0xbc, 0x0a, 0x96, 0x87, 0xa6, 0x82, 0x88, 0x95, 0xf3, 0xf1, 0x13, - 0xf2, 0xe3, 0x1b, 0x8b, 0xce, 0x02, 0xfe, 0x9c, 0x03, 0x73, 0x35, 0x6a, 0xed, 0xba, 0xa4, 0x47, - 0x28, 0xbe, 0xdb, 0x67, 0xbd, 0x3e, 0x53, 0x6e, 0x82, 0xc9, 0x9e, 0x98, 0x08, 0x04, 0xb9, 0x3c, - 0xf0, 0xb4, 0x59, 0xe1, 0x67, 0x80, 0xa4, 0x2b, 0x12, 0x1a, 0x9f, 0x26, 0x39, 0x0c, 0x30, 0xdb, - 0xd9, 0xae, 0x37, 0x3a, 0xa4, 0x79, 0xbf, 0xee, 0xf4, 0xbb, 0x0d, 0xec, 0xf2, 0x04, 0x19, 0x33, - 0xd4, 0x81, 0xa7, 0x2d, 0x09, 0xc3, 0x21, 0x02, 0x34, 0xa7, 0x3b, 0xdb, 0x86, 0x3f, 0xf1, 0x2e, - 0x1f, 0xfb, 0x09, 0x46, 0x78, 0x24, 0x75, 0x97, 0x10, 0x56, 0x1c, 0x1b, 0x4e, 0xb0, 0x18, 0x08, - 0x4d, 0x20, 0x46, 0x26, 0x21, 0xac, 0x7a, 0xc9, 0x97, 0x3b, 0x74, 0xdf, 0xd7, 0x7b, 0x39, 0xd2, - 0x3b, 0xa1, 0x11, 0xbc, 0x06, 0x8a, 0xc3, 0x73, 0xa1, 0xe2, 0x6b, 0x60, 0x4a, 0x6e, 0x61, 0x3b, - 0x2d, 0xfc, 0x40, 0x8a, 0x2e, 0x7d, 0xba, 0xed, 0x4f, 0xc1, 0xe7, 0x22, 0x0d, 0x6f, 0xe0, 0x0e, - 0x66, 0x81, 0xec, 0x35, 0x00, 0x9a, 0x6d, 0xd4, 0xe9, 0x60, 0xc7, 0x0a, 0x85, 0xdf, 0x1a, 0x78, - 0xda, 0xbc, 0x4c, 0x90, 0x10, 0x4b, 0x97, 0x3e, 0xb6, 0xc0, 0x69, 0xc4, 0xaf, 0x0e, 0x39, 0x2e, - 0x94, 0x5f, 0x1e, 0x78, 0xda, 0x42, 0x42, 0x39, 0x8e, 0xc2, 0x44, 0x44, 0xd5, 0x0d, 0x5f, 0xbb, - 0xd8, 0xfe, 0x43, 0xd9, 0x1a, 0x8f, 0x14, 0xae, 0xf0, 0x6c, 0x8d, 0x4f, 0x85, 0xf7, 0xf3, 0x79, - 0x8e, 0x63, 0xb7, 0x1d, 0x9b, 0xd9, 0x88, 0xe1, 0xf7, 0xc9, 0x7d, 0xec, 0xdc, 0xc0, 0x3d, 0x42, - 0x6d, 0xa6, 0x5c, 0x07, 0xe3, 0x14, 0x3b, 0xad, 0x50, 0x9c, 0x4b, 0xd1, 0xed, 0x11, 0xf3, 0xe9, - 0xc2, 0x48, 0xc3, 0xd3, 0x88, 0xf2, 0x16, 0xc8, 0x31, 0xc2, 0xa5, 0xc8, 0x1b, 0x17, 0x07, 0x9e, - 0x96, 0x17, 0x5c, 0x46, 0xd2, 0x77, 0xcb, 0x31, 0xa2, 0xd4, 0xc0, 0x38, 0xea, 0x92, 0xbe, 0x23, - 0xf2, 0xaf, 0xb0, 0xbd, 0x52, 0x96, 0x54, 0xbf, 0x98, 0x94, 0x65, 0x31, 0x29, 0xef, 0x10, 0xdb, - 0x19, 0x7e, 0x09, 0x84, 0x59, 0xf0, 0x12, 0x88, 0x91, 0xb2, 0x09, 0xc6, 0x5a, 0x88, 0xa1, 0xe2, - 0x59, 0x9e, 0xcc, 0xc5, 0x43, 0x4f, 0xcb, 0x0e, 0x3c, 0xad, 0x20, 0x2c, 0x7c, 0x84, 0xf3, 0x33, - 0x26, 0x67, 0x55, 0xaf, 0x7e, 0xfd, 0x50, 0xcb, 0xfc, 0xf5, 0x50, 0xcb, 0xf8, 0x87, 0x22, 0x63, - 0xf7, 0x0f, 0xa4, 0x14, 0x1d, 0xc8, 0x28, 0x85, 0xe1, 0x35, 0xa0, 0xa5, 0x40, 0x61, 0x72, 0xab, - 0x60, 0x92, 0xe2, 0xcf, 0xfa, 0xd8, 0x69, 0xe2, 0xe0, 0x35, 0x09, 0xc6, 0xf0, 0xef, 0xb3, 0x40, - 0xad, 0x51, 0xeb, 0x1d, 0xdb, 0x41, 0x1d, 0xfb, 0x73, 0x61, 0xff, 0xa1, 0xcd, 0xda, 0x2d, 0x17, - 0xed, 0xa3, 0xce, 0x7f, 0x9c, 0x91, 0xca, 0x55, 0x30, 0xbf, 0x1f, 0x6e, 0xee, 0x97, 0x62, 0x72, - 0x8f, 0x16, 0xc7, 0x56, 0xcf, 0xac, 0x4f, 0x19, 0x79, 0x5f, 0x3f, 0x21, 0xd8, 0x5c, 0xc4, 0xd9, - 0xe5, 0x94, 0x97, 0x91, 0x66, 0x37, 0xc1, 0xa4, 0x8b, 0x9b, 0xd8, 0xde, 0xc3, 0x2e, 0x3f, 0xb1, - 0xc4, 0x0b, 0x1a, 0x20, 0xc7, 0xbc, 0xa0, 0x01, 0x45, 0xd1, 0x63, 0x6a, 0x8f, 0xf3, 0xd8, 0x17, - 0xa2, 0x85, 0x42, 0xdd, 0xa3, 0x23, 0x88, 0xa5, 0xdd, 0xc4, 0xcb, 0x49, 0xbb, 0x89, 0x3d, 0xec, - 0x52, 0x9b, 0x38, 0xc5, 0x49, 0x9e, 0x79, 0x4a, 0x54, 0x1a, 0x25, 0x00, 0xcd, 0x80, 0xa2, 0x5c, - 0x01, 0x80, 0x32, 0xc4, 0xb0, 0x78, 0x77, 0xf3, 0xdc, 0xe0, 0x5c, 0xf4, 0x82, 0x45, 0x18, 0x34, - 0xf3, 0x7c, 0xe0, 0xbf, 0xba, 0xfe, 0x19, 0x53, 0x46, 0x5c, 0x64, 0x49, 0x3b, 0xc0, 0xed, 0x62, - 0x67, 0x1c, 0x47, 0xa1, 0x59, 0x90, 0x43, 0x6e, 0x7b, 0x0b, 0xcc, 0x77, 0x10, 0xc3, 0x94, 0xc9, - 0x8a, 0xd0, 0x46, 0xb4, 0x5d, 0x2c, 0xf0, 0x05, 0x2e, 0x0c, 0x3c, 0xad, 0x28, 0x0b, 0xc6, 0x30, - 0x05, 0x9a, 0xb3, 0x62, 0x8e, 0x97, 0x8d, 0x5b, 0x88, 0xb6, 0xab, 0x95, 0xa1, 0xab, 0xb2, 0x16, - 0x5d, 0x95, 0x94, 0x7c, 0x86, 0xaf, 0x01, 0x98, 0x8e, 0x86, 0x2f, 0xda, 0xb7, 0x39, 0x30, 0x5f, - 0xa3, 0xd6, 0x07, 0xbd, 0x16, 0x62, 0x78, 0x37, 0x28, 0x8d, 0x77, 0x40, 0x1e, 0xf5, 0x59, 0x9b, - 0xb8, 0x36, 0x3b, 0x38, 0xda, 0x83, 0x85, 0xd0, 0x31, 0x3d, 0x58, 0xc8, 0x39, 0xcd, 0xbd, 0x32, - 0xc1, 0x94, 0x83, 0xf7, 0xeb, 0x61, 0x99, 0x17, 0xcf, 0x9b, 0x1e, 0x69, 0x1e, 0x47, 0xd3, 0x9d, - 0x28, 0x38, 0x78, 0x3f, 0x08, 0xa9, 0xfa, 0x3a, 0x6f, 0xcf, 0x42, 0xb7, 0x7c, 0x11, 0x17, 0x62, - 0xed, 0x4a, 0x50, 0x19, 0xe0, 0x79, 0xb0, 0x72, 0x44, 0x8f, 0x50, 0xad, 0xef, 0x73, 0x60, 0x21, - 0x44, 0x77, 0xa2, 0x6a, 0xf6, 0x3f, 0xeb, 0xf5, 0x11, 0x98, 0xf1, 0x15, 0x89, 0xd5, 0x67, 0xa1, - 0x58, 0x65, 0xe0, 0x69, 0xe7, 0x22, 0xc5, 0x4e, 0x52, 0xa3, 0xa7, 0x1d, 0xbc, 0x1f, 0x05, 0x76, - 0x62, 0xd5, 0x5e, 0x01, 0xe7, 0x47, 0xe8, 0x12, 0xea, 0xf6, 0x8b, 0x68, 0x28, 0xa4, 0xaa, 0xc8, - 0x45, 0x5d, 0xfa, 0x52, 0x35, 0xdb, 0x01, 0xe3, 0x3d, 0xbe, 0xaa, 0xec, 0x6e, 0x8b, 0x47, 0xbb, - 0x5b, 0xb1, 0xab, 0x31, 0x1f, 0x3d, 0x29, 0xc2, 0x02, 0x9a, 0xd2, 0x54, 0xf4, 0x57, 0xc9, 0x58, - 0x63, 0x2d, 0x42, 0xdc, 0x77, 0xd9, 0x22, 0xc4, 0xa7, 0x82, 0x50, 0xb7, 0x7f, 0x98, 0x00, 0x67, - 0x6a, 0xd4, 0x52, 0x3e, 0x06, 0x85, 0xf8, 0xaf, 0x9a, 0xd5, 0xa3, 0x1e, 0x25, 0x7f, 0x03, 0xa8, - 0xeb, 0x2f, 0x62, 0x84, 0x45, 0xee, 0x53, 0x30, 0x95, 0xf8, 0x85, 0xb0, 0x36, 0xd2, 0x32, 0x4e, - 0x51, 0x2f, 0xbd, 0x90, 0x12, 0xae, 0x5e, 0x07, 0xd3, 0xc9, 0x86, 0x1b, 0x8e, 0xb4, 0x4d, 0x70, - 0xd4, 0x8d, 0x17, 0x73, 0xe2, 0xee, 0x27, 0x3a, 0xcb, 0xd1, 0xee, 0xc7, 0x29, 0x29, 0xee, 0x8f, - 0x6a, 0xd1, 0x14, 0x06, 0x16, 0x47, 0xb6, 0x67, 0xa3, 0x97, 0x18, 0x45, 0x55, 0x2b, 0x27, 0xa6, - 0x86, 0xbb, 0x7e, 0x01, 0x96, 0xd3, 0xfa, 0x8a, 0xcd, 0x91, 0xab, 0xa5, 0xb0, 0xd5, 0x2b, 0xff, - 0x86, 0x1d, 0x6e, 0xdf, 0x00, 0x33, 0x43, 0x2f, 0xf8, 0xab, 0x23, 0xd7, 0x49, 0x92, 0xd4, 0xcb, - 0x27, 0x20, 0x85, 0x7b, 0xb4, 0xc1, 0xdc, 0x91, 0x77, 0xef, 0xe2, 0x31, 0x0b, 0x44, 0x34, 0x75, - 0xeb, 0x44, 0xb4, 0x78, 0x82, 0x24, 0x5e, 0x8a, 0xb5, 0xe3, 0xdc, 0xe4, 0x94, 0x94, 0x04, 0x19, - 0x75, 0x41, 0xd5, 0xb3, 0x5f, 0xfa, 0x3d, 0x84, 0x71, 0xe7, 0xf0, 0xcf, 0x52, 0xe6, 0xf0, 0x49, - 0x29, 0xfb, 0xf8, 0x49, 0x29, 0xfb, 0xc7, 0x93, 0x52, 0xf6, 0xbb, 0xa7, 0xa5, 0xcc, 0xe3, 0xa7, - 0xa5, 0xcc, 0xef, 0x4f, 0x4b, 0x99, 0x4f, 0x36, 0x2d, 0x9b, 0xb5, 0xfb, 0x8d, 0x72, 0x93, 0x74, - 0x75, 0x9b, 0x1f, 0xfc, 0x56, 0x07, 0x35, 0xa8, 0x7e, 0x77, 0x97, 0x7f, 0xcc, 0x78, 0x10, 0x7c, - 0xce, 0xe0, 0xdf, 0x32, 0x1a, 0xe3, 0xfc, 0x63, 0xc6, 0x9b, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, - 0x21, 0xf3, 0xd9, 0x24, 0xd2, 0x11, 0x00, 0x00, + 0xa6, 0x89, 0x2d, 0x87, 0x52, 0x24, 0x4b, 0x3d, 0x74, 0x53, 0xd1, 0x0f, 0xc9, 0x34, 0x5a, 0x40, + 0x7c, 0x08, 0xc9, 0x5a, 0xdb, 0xd3, 0xf5, 0xaa, 0xf6, 0x8e, 0xd9, 0x19, 0x27, 0x0d, 0x12, 0x12, + 0xe2, 0x84, 0x38, 0x20, 0x4e, 0x9c, 0x7b, 0x41, 0xe2, 0xd8, 0x03, 0xe2, 0x6f, 0xc8, 0x05, 0xa9, + 0x42, 0x1c, 0x38, 0xad, 0xa0, 0x3d, 0x94, 0x03, 0xa7, 0xbd, 0xf6, 0x82, 0x76, 0x66, 0x76, 0x76, + 0xd7, 0xf1, 0xa6, 0x21, 0xaa, 0xe0, 0x12, 0x65, 0xe6, 0xfd, 0xde, 0xbc, 0xf7, 0x7e, 0xf3, 0xe6, + 0xbd, 0xe7, 0x05, 0x2b, 0xb8, 0x6f, 0x3b, 0x36, 0xad, 0xe0, 0x7e, 0x07, 0x13, 0x5a, 0xd9, 0xab, + 0x56, 0xe8, 0x83, 0x72, 0xdf, 0xc5, 0x14, 0x2b, 0x73, 0x5c, 0x54, 0xe6, 0xa2, 0xf2, 0x5e, 0x55, + 0x9d, 0x37, 0x7b, 0xb6, 0x83, 0x2b, 0xec, 0x2f, 0x07, 0xa9, 0xa5, 0x16, 0x26, 0x3d, 0x4c, 0x2a, + 0x4d, 0x93, 0xa0, 0xca, 0x5e, 0xb5, 0x89, 0xa8, 0x59, 0xad, 0xb4, 0xb0, 0xed, 0x08, 0xf9, 0xb2, + 0x90, 0xf7, 0x88, 0x15, 0x1c, 0xde, 0x23, 0x96, 0x10, 0xac, 0x70, 0x41, 0x83, 0xad, 0x2a, 0x7c, + 0x21, 0x44, 0x8b, 0x16, 0xb6, 0x30, 0xdf, 0x0f, 0xfe, 0x13, 0xbb, 0x17, 0x8e, 0x7a, 0x7a, 0xd0, + 0x47, 0x42, 0x07, 0xfa, 0x59, 0x30, 0x53, 0x27, 0x96, 0x81, 0x5a, 0xd8, 0x6d, 0xeb, 0x26, 0x6d, + 0x75, 0x94, 0x3b, 0x20, 0x4f, 0x06, 0xcd, 0x9e, 0x4d, 0x29, 0x72, 0x8b, 0xd9, 0xd5, 0xec, 0x7a, + 0x5e, 0xdf, 0xf4, 0x3d, 0x6d, 0xee, 0xc0, 0xec, 0x75, 0x6b, 0x50, 0x8a, 0xe0, 0xaf, 0x3f, 0x6d, + 0x2d, 0x0a, 0xfb, 0xd7, 0xdb, 0x6d, 0x17, 0x11, 0xf2, 0x1e, 0x75, 0x6d, 0xc7, 0x32, 0x22, 0x75, + 0xa5, 0x0a, 0xf2, 0x4d, 0xd7, 0x6e, 0x5b, 0xa8, 0x61, 0xb7, 0x8b, 0xb9, 0xd5, 0xec, 0xfa, 0x98, + 0xbe, 0x18, 0x9d, 0x25, 0x45, 0xd0, 0x98, 0xe4, 0xff, 0xdf, 0x6e, 0x2b, 0x6f, 0x83, 0x42, 0x33, + 0xf0, 0xa3, 0xd1, 0x3c, 0xa0, 0x88, 0x14, 0xcf, 0xac, 0x66, 0xd7, 0xa7, 0xf4, 0x25, 0xdf, 0xd3, + 0x14, 0xa1, 0x14, 0x09, 0xa1, 0x01, 0xd8, 0x4a, 0x0f, 0x16, 0xb5, 0xf5, 0xaf, 0x9e, 0x3d, 0xda, + 0x88, 0x6c, 0x7f, 0xf3, 0xec, 0xd1, 0xc6, 0x39, 0x11, 0x74, 0x32, 0x42, 0x58, 0x04, 0x4b, 0xc9, + 0x1d, 0x03, 0x91, 0x3e, 0x76, 0x08, 0x82, 0xbf, 0x65, 0xc1, 0x6c, 0x9d, 0x58, 0x3b, 0x2e, 0x32, + 0x29, 0xd2, 0x99, 0x4b, 0xca, 0x0d, 0x30, 0xd1, 0x0a, 0xd6, 0x38, 0x64, 0x63, 0xc3, 0xf7, 0xb4, + 0x19, 0xee, 0x8c, 0x10, 0xa4, 0x73, 0x11, 0xaa, 0x2a, 0x06, 0x18, 0x6f, 0x61, 0xe7, 0x9e, 0x6d, + 0x31, 0x1a, 0x0a, 0xdb, 0xa5, 0xf2, 0x70, 0x9a, 0x94, 0xb9, 0xbd, 0x1d, 0x86, 0xd2, 0xd5, 0x43, + 0x4f, 0xcb, 0xf8, 0x9e, 0x36, 0x2d, 0x0c, 0xb1, 0x5d, 0xf8, 0xe3, 0xb3, 0x47, 0x1b, 0x59, 0x43, + 0x9c, 0x54, 0x7b, 0x23, 0x88, 0x38, 0xb4, 0x10, 0xc4, 0xbb, 0x14, 0xc5, 0x1b, 0x0f, 0x01, 0x5e, + 0x05, 0xcb, 0x43, 0x5b, 0x61, 0xc4, 0xca, 0xf9, 0xf8, 0x0d, 0x05, 0xf1, 0x8d, 0x45, 0x77, 0x01, + 0x7f, 0xce, 0x81, 0xb9, 0x3a, 0xb1, 0x76, 0x5d, 0xdc, 0xc7, 0x04, 0xdd, 0x1d, 0xd0, 0xfe, 0x80, + 0x2a, 0x37, 0xc1, 0x64, 0x9f, 0x6f, 0x84, 0x84, 0x5c, 0xf6, 0x3d, 0x6d, 0x96, 0xfb, 0x19, 0x4a, + 0xd2, 0x19, 0x91, 0xca, 0xa7, 0x49, 0x0e, 0x1d, 0xcc, 0x76, 0xb7, 0x1b, 0xcd, 0x2e, 0x6e, 0xdd, + 0x6f, 0x38, 0x83, 0x5e, 0x13, 0xb9, 0x2c, 0x41, 0xc6, 0x74, 0xd5, 0xf7, 0xb4, 0x25, 0xae, 0x38, + 0x04, 0x80, 0xc6, 0x74, 0x77, 0x5b, 0x0f, 0x36, 0xde, 0x65, 0xeb, 0x20, 0xc1, 0x30, 0x8b, 0xa4, + 0xe1, 0x62, 0x4c, 0x8b, 0x63, 0xc3, 0x09, 0x16, 0x13, 0x42, 0x03, 0xf0, 0x95, 0x81, 0x31, 0xad, + 0x5d, 0x0a, 0xe8, 0x96, 0xee, 0x07, 0x7c, 0x2f, 0x47, 0x7c, 0x27, 0x38, 0x82, 0xd7, 0x40, 0x71, + 0x78, 0x4f, 0x32, 0xbe, 0x06, 0xa6, 0x84, 0x09, 0xdb, 0x69, 0xa3, 0x07, 0x82, 0x74, 0xe1, 0xd3, + 0xed, 0x60, 0x0b, 0x3e, 0xe7, 0x69, 0x78, 0x03, 0x75, 0x11, 0x0d, 0x69, 0xaf, 0x03, 0xd0, 0xea, + 0x98, 0xdd, 0x2e, 0x72, 0x2c, 0x49, 0xfc, 0x96, 0xef, 0x69, 0xf3, 0x22, 0x41, 0xa4, 0x2c, 0x9d, + 0xfa, 0xd8, 0x01, 0xa7, 0x21, 0xbf, 0x36, 0xe4, 0x38, 0x67, 0x7e, 0xd9, 0xf7, 0xb4, 0x85, 0x04, + 0x73, 0x4c, 0x0a, 0x13, 0x11, 0xd5, 0x36, 0x02, 0xee, 0x62, 0xf6, 0x87, 0xb2, 0x35, 0x1e, 0x29, + 0x5c, 0x61, 0xd9, 0x1a, 0xdf, 0x92, 0xef, 0xf3, 0x79, 0x8e, 0xc9, 0x6e, 0x3b, 0x36, 0xb5, 0x4d, + 0x8a, 0xde, 0xc7, 0xf7, 0x91, 0x73, 0x03, 0xf5, 0x31, 0xb1, 0xa9, 0x72, 0x1d, 0x8c, 0x13, 0xe4, + 0xb4, 0x25, 0x39, 0x97, 0xa2, 0xd7, 0xc3, 0xf7, 0xd3, 0x89, 0x11, 0x8a, 0xa7, 0x21, 0xe5, 0x2d, + 0x90, 0xa3, 0x98, 0x51, 0x91, 0xd7, 0x2f, 0xfa, 0x9e, 0x96, 0xe7, 0x58, 0x8a, 0xd3, 0xad, 0xe5, + 0x28, 0x56, 0xea, 0x60, 0xdc, 0xec, 0xe1, 0x81, 0xc3, 0xf3, 0xaf, 0xb0, 0xbd, 0x52, 0x16, 0xd0, + 0xa0, 0x21, 0x94, 0x45, 0x43, 0x28, 0xef, 0x60, 0xdb, 0x19, 0xae, 0x04, 0x5c, 0x2d, 0xac, 0x04, + 0x7c, 0xa5, 0x6c, 0x82, 0xb1, 0xb6, 0x49, 0xcd, 0xe2, 0x59, 0x96, 0xcc, 0xc5, 0x43, 0x4f, 0xcb, + 0xfa, 0x9e, 0x56, 0xe0, 0x1a, 0x81, 0x84, 0xe1, 0x33, 0x06, 0x43, 0xd5, 0xae, 0x7e, 0xfd, 0x50, + 0xcb, 0xfc, 0xf5, 0x50, 0xcb, 0x04, 0x97, 0x22, 0x62, 0x0f, 0x2e, 0xa4, 0x14, 0x5d, 0xc8, 0x28, + 0x86, 0xe1, 0x35, 0xa0, 0xa5, 0x88, 0x64, 0x72, 0xab, 0x60, 0x92, 0xa0, 0xcf, 0x06, 0xc8, 0x69, + 0xa1, 0xb0, 0x9a, 0x84, 0x6b, 0xf8, 0xf7, 0x59, 0xa0, 0xd6, 0x89, 0xf5, 0x8e, 0xed, 0x98, 0x5d, + 0xfb, 0x73, 0xae, 0xff, 0xa1, 0x4d, 0x3b, 0x6d, 0xd7, 0xdc, 0x37, 0xbb, 0xff, 0x71, 0x46, 0x2a, + 0x57, 0xc1, 0xfc, 0xbe, 0x34, 0x1e, 0xb4, 0x53, 0x7c, 0x8f, 0x14, 0xc7, 0x56, 0xcf, 0xac, 0x4f, + 0xe9, 0xf9, 0x80, 0x3f, 0x4e, 0xd8, 0x5c, 0x84, 0xd9, 0x65, 0x90, 0x97, 0x91, 0x66, 0x37, 0xc1, + 0xa4, 0x8b, 0x5a, 0xc8, 0xde, 0x43, 0x2e, 0xbb, 0xb1, 0x44, 0x05, 0x0d, 0x25, 0xc7, 0x54, 0xd0, + 0x10, 0xa2, 0x54, 0x62, 0x6c, 0x8f, 0xb3, 0xd8, 0x17, 0xa2, 0x83, 0x24, 0xef, 0xd1, 0x15, 0xc4, + 0xd2, 0x6e, 0xe2, 0xe5, 0xa4, 0xdd, 0xc4, 0x1e, 0x72, 0x89, 0x8d, 0x9d, 0xe2, 0x24, 0xcb, 0x3c, + 0x25, 0x6a, 0x8d, 0x42, 0x00, 0x8d, 0x10, 0xa2, 0x5c, 0x01, 0x80, 0x50, 0x93, 0x22, 0x5e, 0x77, + 0xf3, 0x4c, 0xe1, 0x5c, 0x54, 0xc1, 0x22, 0x19, 0x34, 0xf2, 0x6c, 0x11, 0x54, 0xdd, 0xe0, 0x8e, + 0x09, 0xc5, 0xae, 0x69, 0x09, 0x3d, 0xc0, 0xf4, 0x62, 0x77, 0x1c, 0x97, 0x42, 0xa3, 0x20, 0x96, + 0x4c, 0xf7, 0x16, 0x98, 0xef, 0x9a, 0x14, 0x11, 0x2a, 0x3a, 0x42, 0xc7, 0x24, 0x9d, 0x62, 0x81, + 0x1d, 0x70, 0xc1, 0xf7, 0xb4, 0xa2, 0x68, 0x18, 0xc3, 0x10, 0x68, 0xcc, 0xf2, 0x3d, 0xd6, 0x36, + 0x6e, 0x99, 0xa4, 0x53, 0xab, 0x0e, 0x3d, 0x95, 0xb5, 0xe8, 0xa9, 0xa4, 0xe4, 0x33, 0x7c, 0x0d, + 0xc0, 0x74, 0xa9, 0xac, 0x68, 0xdf, 0xe6, 0xc0, 0x7c, 0x9d, 0x58, 0x1f, 0xf4, 0xdb, 0x26, 0x45, + 0xbb, 0x61, 0x6b, 0xbc, 0x03, 0xf2, 0xe6, 0x80, 0x76, 0xb0, 0x6b, 0xd3, 0x83, 0xa3, 0x33, 0x98, + 0x14, 0x1d, 0x33, 0x83, 0x49, 0xcc, 0x69, 0xde, 0x95, 0x01, 0xa6, 0x1c, 0xb4, 0xdf, 0x90, 0x6d, + 0x9e, 0x97, 0xb7, 0x4a, 0xc4, 0x79, 0x5c, 0x9a, 0xee, 0x44, 0xc1, 0x41, 0xfb, 0x61, 0x48, 0xb5, + 0xd7, 0xd9, 0x78, 0x26, 0xdd, 0x0a, 0x48, 0x5c, 0x88, 0x8d, 0x2b, 0x61, 0x67, 0x80, 0xe7, 0xc1, + 0xca, 0x11, 0x3e, 0x24, 0x5b, 0xdf, 0xe7, 0xc0, 0x82, 0x94, 0xee, 0x44, 0xdd, 0xec, 0x7f, 0xe6, + 0xeb, 0x23, 0x30, 0x13, 0x30, 0x12, 0xeb, 0xcf, 0x9c, 0xb1, 0xaa, 0xef, 0x69, 0xe7, 0x22, 0xc6, + 0x4e, 0xd2, 0xa3, 0xa7, 0x1d, 0xb4, 0x1f, 0x05, 0x76, 0x62, 0xd6, 0x5e, 0x01, 0xe7, 0x47, 0xf0, + 0x22, 0x79, 0xfb, 0x85, 0x0f, 0x14, 0x82, 0x55, 0xd3, 0x35, 0x7b, 0xe4, 0xa5, 0x72, 0xb6, 0x03, + 0xc6, 0xfb, 0xec, 0x54, 0x31, 0xdd, 0x16, 0x8f, 0x4e, 0xb7, 0xdc, 0xaa, 0x3e, 0x1f, 0x95, 0x14, + 0xae, 0x01, 0x0d, 0xa1, 0xca, 0xe7, 0xab, 0x64, 0xac, 0xb1, 0x11, 0x21, 0xee, 0xbb, 0x18, 0x11, + 0xe2, 0x5b, 0x61, 0xa8, 0xdb, 0x3f, 0x4c, 0x80, 0x33, 0x75, 0x62, 0x29, 0x1f, 0x83, 0x42, 0xfc, + 0x57, 0xcd, 0xea, 0x51, 0x8f, 0x92, 0xbf, 0x01, 0xd4, 0xf5, 0x17, 0x21, 0x64, 0x93, 0xfb, 0x14, + 0x4c, 0x25, 0x7e, 0x21, 0xac, 0x8d, 0xd4, 0x8c, 0x43, 0xd4, 0x4b, 0x2f, 0x84, 0xc8, 0xd3, 0x1b, + 0x60, 0x3a, 0x39, 0x70, 0xc3, 0x91, 0xba, 0x09, 0x8c, 0xba, 0xf1, 0x62, 0x4c, 0xdc, 0xfd, 0xc4, + 0x64, 0x39, 0xda, 0xfd, 0x38, 0x24, 0xc5, 0xfd, 0x51, 0x23, 0x9a, 0x42, 0xc1, 0xe2, 0xc8, 0xf1, + 0x6c, 0xf4, 0x11, 0xa3, 0xa0, 0x6a, 0xf5, 0xc4, 0x50, 0x69, 0xf5, 0x0b, 0xb0, 0x9c, 0x36, 0x57, + 0x6c, 0x8e, 0x3c, 0x2d, 0x05, 0xad, 0x5e, 0xf9, 0x37, 0x68, 0x69, 0xbe, 0x09, 0x66, 0x86, 0x2a, + 0xf8, 0xab, 0x23, 0xcf, 0x49, 0x82, 0xd4, 0xcb, 0x27, 0x00, 0x49, 0x1b, 0x1d, 0x30, 0x77, 0xa4, + 0xee, 0x5d, 0x3c, 0xe6, 0x80, 0x08, 0xa6, 0x6e, 0x9d, 0x08, 0x16, 0x4f, 0x90, 0x44, 0xa5, 0x58, + 0x3b, 0xce, 0x4d, 0x06, 0x49, 0x49, 0x90, 0x51, 0x0f, 0x54, 0x3d, 0xfb, 0x65, 0x30, 0x43, 0xe8, + 0x77, 0x0e, 0xff, 0x2c, 0x65, 0x0e, 0x9f, 0x94, 0xb2, 0x8f, 0x9f, 0x94, 0xb2, 0x7f, 0x3c, 0x29, + 0x65, 0xbf, 0x7b, 0x5a, 0xca, 0x3c, 0x7e, 0x5a, 0xca, 0xfc, 0xfe, 0xb4, 0x94, 0xf9, 0x64, 0xd3, + 0xb2, 0x69, 0x67, 0xd0, 0x2c, 0xb7, 0x70, 0xaf, 0x62, 0xb3, 0x8b, 0xdf, 0xea, 0x9a, 0x4d, 0x52, + 0xb9, 0xbb, 0xcb, 0x3e, 0x66, 0x3c, 0x08, 0x3f, 0x67, 0xb0, 0x6f, 0x19, 0xcd, 0x71, 0xf6, 0x31, + 0xe3, 0xcd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x41, 0x3c, 0x65, 0x96, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From a5af5418ad9d0c6cfe40048ba221166c70a37188 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Fri, 22 Dec 2023 13:44:58 +0900 Subject: [PATCH 02/11] bump go version to v1.21 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1ee2895..65e3d72c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Install openssl run: sudo apt-get install libssl-dev - uses: actions/checkout@v3 From 3ae8eef0593e8361df392296db3fe7e170aaa7bd Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Tue, 26 Dec 2023 12:36:04 +0900 Subject: [PATCH 03/11] remove legacy contents --- go.mod | 7 +- go.sum | 8 +- proto/opinit/opchild/v1/tx.proto | 21 - x/opchild/client/cli/legacy_contents.go | 233 ---------- x/opchild/client/cli/tx.go | 3 - x/opchild/keeper/common_test.go | 3 +- x/opchild/keeper/msg_server.go | 27 -- x/opchild/keeper/msg_server_test.go | 44 -- x/opchild/types/codec.go | 6 - x/opchild/types/tx.go | 96 +---- x/opchild/types/tx.pb.go | 541 ++++-------------------- x/ophost/keeper/common_test.go | 3 +- 12 files changed, 88 insertions(+), 904 deletions(-) delete mode 100644 x/opchild/client/cli/legacy_contents.go diff --git a/go.mod b/go.mod index 818c2432..743a419e 100644 --- a/go.mod +++ b/go.mod @@ -13,14 +13,11 @@ require ( cosmossdk.io/simapp v0.0.0-20231211060251-d8fb76d4c267 cosmossdk.io/store v1.0.1 cosmossdk.io/x/tx v0.12.0 - cosmossdk.io/x/upgrade v0.1.1 github.com/cometbft/cometbft v0.38.2 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.50.2 github.com/cosmos/gogoproto v1.4.11 - github.com/cosmos/ibc-go/modules/capability v1.0.0 - github.com/cosmos/ibc-go/v8 v8.0.0 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.7.0 @@ -47,6 +44,7 @@ require ( cosmossdk.io/x/evidence v0.1.0 // indirect cosmossdk.io/x/feegrant v0.1.0 // indirect cosmossdk.io/x/nft v0.1.0 // indirect + cosmossdk.io/x/upgrade v0.1.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -118,6 +116,7 @@ require ( github.com/hashicorp/go-metrics v0.5.2 // indirect github.com/hashicorp/go-plugin v1.5.2 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect + github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect @@ -147,6 +146,7 @@ require ( github.com/mtibben/percent v0.2.1 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect + github.com/onsi/ginkgo v1.16.4 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect github.com/pkg/errors v0.9.1 // indirect @@ -168,6 +168,7 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect diff --git a/go.sum b/go.sum index 8edbf95c..e2d7fe02 100644 --- a/go.sum +++ b/go.sum @@ -365,10 +365,6 @@ github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= github.com/cosmos/iavl v1.0.0 h1:bw6t0Mv/mVCJvlMTOPHWLs5uUE3BRBfVWCRelOzl+so= github.com/cosmos/iavl v1.0.0/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= -github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= -github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= -github.com/cosmos/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg= -github.com/cosmos/ibc-go/v8 v8.0.0/go.mod h1:C6IiJom0F3cIQCD5fKwVPDrDK9j/xTu563AWuOmXois= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= @@ -477,6 +473,7 @@ github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJ github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= @@ -1008,7 +1005,6 @@ github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= @@ -1277,6 +1273,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1400,6 +1397,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= diff --git a/proto/opinit/opchild/v1/tx.proto b/proto/opinit/opchild/v1/tx.proto index 82c005bf..4f6a20d1 100644 --- a/proto/opinit/opchild/v1/tx.proto +++ b/proto/opinit/opchild/v1/tx.proto @@ -22,10 +22,6 @@ service Msg { // ExecuteMessages defines a rpc handler method for MsgExecuteMessages. rpc ExecuteMessages(MsgExecuteMessages) returns (MsgExecuteMessagesResponse); - // ExecuteLegacyContents defines a rpc handler method for - // MsgExecuteLegacyContents. - rpc ExecuteLegacyContents(MsgExecuteLegacyContents) returns (MsgExecuteLegacyContentsResponse); - //////////////////////////// // Bridge Executor Messages @@ -74,23 +70,6 @@ message MsgExecuteMessages { // MsgExecuteMessagesResponse returns MsgExecuteMessages message result data message MsgExecuteMessagesResponse {} -// MsgExecuteLegacyContents is a message to execute legacy -// (gov) contents with validator permission. -message MsgExecuteLegacyContents { - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "opchild/MsgExecuteLegacyContents"; - - // Sender is the that actor that signed a messages - string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - - // contents are the arbitrary legacy (gov) contents to be executed. - repeated google.protobuf.Any contents = 2; -} - -// MsgExecuteLegacyContentsResponse returns MsgExecuteLegacyContents message -// result data -message MsgExecuteLegacyContentsResponse {} - ///////////////////////////// // Bridge Executor messages diff --git a/x/opchild/client/cli/legacy_contents.go b/x/opchild/client/cli/legacy_contents.go deleted file mode 100644 index f812b248..00000000 --- a/x/opchild/client/cli/legacy_contents.go +++ /dev/null @@ -1,233 +0,0 @@ -package cli - -import ( - "fmt" - "os" - "strconv" - "strings" - - "github.com/spf13/cobra" - - "cosmossdk.io/core/address" - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/version" - govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - "github.com/cosmos/ibc-go/v8/modules/core/exported" - - "github.com/initia-labs/OPinit/x/opchild/types" -) - -// NewLegacyContentParamChangeTxCmd returns a CLI command handler for creating -// a parameter change legacy content validator transaction. -func NewLegacyContentParamChangeTxCmd(ac address.Codec) *cobra.Command { - return &cobra.Command{ - Use: "param-change [proposal-file]", - Args: cobra.ExactArgs(1), - Short: "Submit a parameter change proposal", - Long: strings.TrimSpace( - fmt.Sprintf(`Submit a parameter proposal along with an initial deposit. -The proposal details must be supplied via a JSON file. For values that contains -objects, only non-empty fields will be updated. - -IMPORTANT: Currently parameter changes are evaluated but not validated, so it is -very important that any "value" change is valid (ie. correct type and within bounds) -for its respective parameter, eg. "MaxValidators" should be an integer and not a decimal. - -Proper vetting of a parameter change proposal should prevent this from happening -(no deposits should occur during the governance process), but it should be noted -regardless. - -Example: -$ %s tx gov submit-proposal param-change --from= - -Where proposal.json contains: - -{ - "title": "Staking Param Change", - "description": "Update max validators", - "changes": [ - { - "subspace": "staking", - "key": "MaxValidators", - "value": 105 - } - ] -} -`, - version.AppName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - proposal, err := paramscutils.ParseParamChangeProposalJSON(clientCtx.LegacyAmino, args[0]) - if err != nil { - return err - } - - from := clientCtx.GetFromAddress() - content := paramproposal.NewParameterChangeProposal( - proposal.Title, proposal.Description, proposal.Changes.ToParamChanges(), - ) - - msg, err := types.NewMsgExecuteLegacyContents(from, []govv1beta1.Content{content}) - if err != nil { - return err - } - - if err := msg.Validate(ac); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } -} - -// NewLegacyContentSubmitUpdateClientCmd implements a command handler for submitting an update IBC client transaction. -func NewLegacyContentSubmitUpdateClientCmd(ac address.Codec) *cobra.Command { - cmd := &cobra.Command{ - Use: "update-client [subject-client-id] [substitute-client-id]", - Args: cobra.ExactArgs(2), - Short: "Submit an update IBC client proposal", - Long: "Submit an update IBC client proposal along with an initial deposit.\n" + - "Please specify a subject client identifier you want to update..\n" + - "Please specify the substitute client the subject client will be updated to.", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - title, err := cmd.Flags().GetString(govcli.FlagTitle) //nolint:staticcheck // need this till full govv1 conversion. - if err != nil { - return err - } - - description, err := cmd.Flags().GetString(govcli.FlagDescription) //nolint:staticcheck // need this till full govv1 conversion. - if err != nil { - return err - } - - subjectClientID := args[0] - substituteClientID := args[1] - - content := ibcclienttypes.NewClientUpdateProposal(title, description, subjectClientID, substituteClientID) - - from := clientCtx.GetFromAddress() - msg, err := types.NewMsgExecuteLegacyContents(from, []govv1beta1.Content{content}) - if err != nil { - return err - } - - if err = msg.Validate(ac); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") //nolint:staticcheck // need this till full govv1 conversion. - cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") //nolint:staticcheck // need this till full govv1 conversion. - - return cmd -} - -// NewLegacyContentSubmitUpgradeCmd implements a command handler for submitting an upgrade IBC client transaction. -func NewLegacyContentSubmitUpgradeCmd(ac address.Codec) *cobra.Command { - cmd := &cobra.Command{ - Use: "ibc-upgrade [name] [height] [path/to/upgraded_client_state.json] [flags]", - Args: cobra.ExactArgs(3), - Short: "Submit an IBC upgrade proposal", - Long: "Submit an IBC client breaking upgrade proposal along with an initial deposit.\n" + - "The client state specified is the upgraded client state representing the upgraded chain\n" + - `Example Upgraded Client State JSON: -{ - "@type":"/ibc.lightclients.tendermint.v1.ClientState", - "chain_id":"testchain1", - "unbonding_period":"1814400s", - "latest_height":{"revision_number":"0","revision_height":"2"}, - "proof_specs":[{"leaf_spec":{"hash":"SHA256","prehash_key":"NO_HASH","prehash_value":"SHA256","length":"VAR_PROTO","prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"empty_child":null,"hash":"SHA256"},"max_depth":0,"min_depth":0},{"leaf_spec":{"hash":"SHA256","prehash_key":"NO_HASH","prehash_value":"SHA256","length":"VAR_PROTO","prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"empty_child":null,"hash":"SHA256"},"max_depth":0,"min_depth":0}], - "upgrade_path":["upgrade","upgradedIBCState"], -} - `, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - - title, err := cmd.Flags().GetString(govcli.FlagTitle) //nolint:staticcheck // need this till full govv1 conversion. - if err != nil { - return err - } - - description, err := cmd.Flags().GetString(govcli.FlagDescription) //nolint:staticcheck // need this till full govv1 conversion. - if err != nil { - return err - } - - name := args[0] - - height, err := strconv.ParseInt(args[1], 10, 64) - if err != nil { - return err - } - - plan := upgradetypes.Plan{ - Name: name, - Height: height, - } - - // attempt to unmarshal client state argument - var clientState exported.ClientState - clientContentOrFileName := args[2] - if err := cdc.UnmarshalInterfaceJSON([]byte(clientContentOrFileName), &clientState); err != nil { - - // check for file path if JSON input is not provided - contents, err := os.ReadFile(clientContentOrFileName) - if err != nil { - return fmt.Errorf("neither JSON input nor path to .json file for client state were provided: %w", err) - } - - if err := cdc.UnmarshalInterfaceJSON(contents, &clientState); err != nil { - return fmt.Errorf("error unmarshalling client state file: %w", err) - } - } - - content, err := ibcclienttypes.NewUpgradeProposal(title, description, plan, clientState) - if err != nil { - return err - } - - from := clientCtx.GetFromAddress() - msg, err := types.NewMsgExecuteLegacyContents(from, []govv1beta1.Content{content}) - if err != nil { - return err - } - - if err = msg.Validate(ac); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") //nolint:staticcheck // need this till full govv1 conversion. - cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") //nolint:staticcheck // need this till full govv1 conversion. - - return cmd -} diff --git a/x/opchild/client/cli/tx.go b/x/opchild/client/cli/tx.go index 9797051b..02a7e002 100644 --- a/x/opchild/client/cli/tx.go +++ b/x/opchild/client/cli/tx.go @@ -31,9 +31,6 @@ func GetTxCmd(ac address.Codec) *cobra.Command { NewExecuteMessagesCmd(ac), NewDepositCmd(ac), NewWithdrawCmd(ac), - NewLegacyContentParamChangeTxCmd(ac), - NewLegacyContentSubmitUpdateClientCmd(ac), - NewLegacyContentSubmitUpgradeCmd(ac), ) return opchildTxCmd diff --git a/x/opchild/keeper/common_test.go b/x/opchild/keeper/common_test.go index 9dba8569..9ecd0663 100644 --- a/x/opchild/keeper/common_test.go +++ b/x/opchild/keeper/common_test.go @@ -45,7 +45,6 @@ import ( govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" opchild "github.com/initia-labs/OPinit/x/opchild" opchildkeeper "github.com/initia-labs/OPinit/x/opchild/keeper" @@ -241,7 +240,7 @@ func _createTestInput( for _, v := range keys { ms.MountStoreWithDB(v, storetypes.StoreTypeIAVL, db) } - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + memKeys := storetypes.NewMemoryStoreKeys() for _, v := range memKeys { ms.MountStoreWithDB(v, storetypes.StoreTypeMemory, db) } diff --git a/x/opchild/keeper/msg_server.go b/x/opchild/keeper/msg_server.go index bf28f828..1824db80 100644 --- a/x/opchild/keeper/msg_server.go +++ b/x/opchild/keeper/msg_server.go @@ -132,33 +132,6 @@ func (ms MsgServer) ExecuteMessages(ctx context.Context, req *types.MsgExecuteMe return &types.MsgExecuteMessagesResponse{}, nil } -// ExecuteLegacyContents implements a ExecuteLegacyContents message handling -func (ms MsgServer) ExecuteLegacyContents(ctx context.Context, req *types.MsgExecuteLegacyContents) (*types.MsgExecuteLegacyContentsResponse, error) { - if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { - return nil, err - } - - // permission check - if err := ms.checkValidatorPermission(ctx, req.Sender); err != nil { - return nil, err - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - for _, content := range req.GetContents() { - // Ensure that the content has a respective handler - if !ms.Keeper.legacyRouter.HasRoute(content.ProposalRoute()) { - return nil, errors.Wrap(govtypes.ErrNoProposalHandlerExists, content.ProposalRoute()) - } - - handler := ms.Keeper.legacyRouter.GetRoute(content.ProposalRoute()) - if err := handler(sdkCtx, content); err != nil { - return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err) - } - } - - return &types.MsgExecuteLegacyContentsResponse{}, nil -} - ////////////////////////////////////////////// // Authority messages diff --git a/x/opchild/keeper/msg_server_test.go b/x/opchild/keeper/msg_server_test.go index 75d8452b..dd265e87 100644 --- a/x/opchild/keeper/msg_server_test.go +++ b/x/opchild/keeper/msg_server_test.go @@ -13,7 +13,6 @@ import ( testutilsims "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/initia-labs/OPinit/x/opchild/keeper" "github.com/initia-labs/OPinit/x/opchild/types" @@ -58,49 +57,6 @@ func Test_MsgServer_ExecuteMessages(t *testing.T) { require.Equal(t, vals[0].Moniker, "val2") } -func Test_MsgServer_ExecuteLegacyContents(t *testing.T) { - ctx, input := createDefaultTestInput(t) - - ms := keeper.NewMsgServerImpl(input.OPChildKeeper) - valPubKeys := testutilsims.CreateTestPubKeys(2) - - // register validator - val, err := types.NewValidator(valAddrs[0], valPubKeys[0], "val1") - require.NoError(t, err) - - input.OPChildKeeper.SetValidator(ctx, val) - - // apply validator updates - input.OPChildKeeper.BlockValidatorUpdates(ctx) - - // valid legacy content - legacyContent := testLegacyContent{ - Title: "title", - Description: "description", - Message: "test", - } - msg, err := types.NewMsgExecuteLegacyContents(addrs[0], []govv1beta1.Content{&legacyContent}) - require.NoError(t, err) - - _, err = ms.ExecuteLegacyContents(ctx, msg) - require.NoError(t, err) - - // unauthorized executor - msg, err = types.NewMsgExecuteLegacyContents(addrs[1], []govv1beta1.Content{&legacyContent}) - require.NoError(t, err) - - _, err = ms.ExecuteLegacyContents(ctx, msg) - require.Error(t, err) - - // legacy content with wrong message - legacyContent.Message = "wrong message" - msg, err = types.NewMsgExecuteLegacyContents(addrs[0], []govv1beta1.Content{&legacyContent}) - require.NoError(t, err) - - _, err = ms.ExecuteLegacyContents(ctx, msg) - require.Error(t, err) -} - ///////////////////////////////////////// // The messages for Authority diff --git a/x/opchild/types/codec.go b/x/opchild/types/codec.go index aba33409..c99a844b 100644 --- a/x/opchild/types/codec.go +++ b/x/opchild/types/codec.go @@ -6,14 +6,12 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) // RegisterLegacyAminoCodec registers the move types and interface func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgExecuteMessages{}, "opchild/MsgExecuteMessages") - legacy.RegisterAminoMsg(cdc, &MsgExecuteLegacyContents{}, "opchild/MsgExecuteLegacyContents") legacy.RegisterAminoMsg(cdc, &MsgAddValidator{}, "opchild/MsgAddValidator") legacy.RegisterAminoMsg(cdc, &MsgRemoveValidator{}, "opchild/MsgRemoveAddValidator") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "opchild/MsgUpdateParams") @@ -33,10 +31,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgFinalizeTokenDeposit{}, &MsgInitiateTokenWithdrawal{}, ) - registry.RegisterInterface( - "cosmos.gov.v1beta1.Content", - (*govv1beta1.Content)(nil), - ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/opchild/types/tx.go b/x/opchild/types/tx.go index 3a9f894f..2e56b712 100644 --- a/x/opchild/types/tx.go +++ b/x/opchild/types/tx.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - "cosmossdk.io/core/address" errors "cosmossdk.io/errors" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -11,14 +9,11 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdktx "github.com/cosmos/cosmos-sdk/types/tx" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/cosmos/gogoproto/proto" ) // rollup message types const ( - TypeMsgExecuteMessages = "execute_messages" - TypeMsgExecuteLegacyContents = "execute_legacy_contents" + TypeMsgExecuteMessages = "execute_messages" TypeMsgAddValidator = "add_validator" TypeMsgRemoveValidator = "remove_validator" @@ -32,7 +27,6 @@ const ( var ( _ sdk.Msg = &MsgExecuteMessages{} - _ sdk.Msg = &MsgExecuteLegacyContents{} _ sdk.Msg = &MsgAddValidator{} _ sdk.Msg = &MsgRemoveValidator{} _ sdk.Msg = &MsgUpdateParams{} @@ -40,7 +34,7 @@ var ( _ sdk.Msg = &MsgFinalizeTokenDeposit{} _ sdk.Msg = &MsgInitiateTokenWithdrawal{} - _, _ codectypes.UnpackInterfacesMessage = &MsgExecuteMessages{}, &MsgExecuteLegacyContents{} + _ codectypes.UnpackInterfacesMessage = &MsgExecuteMessages{} ) // should refer initiavm/precompile/modules/minlib/sources/coin.move @@ -91,92 +85,6 @@ func (m MsgExecuteMessages) UnpackInterfaces(unpacker codectypes.AnyUnpacker) er return sdktx.UnpackInterfaces(unpacker, m.Messages) } -/* MsgExecuteLegacyContents */ - -// NewMsgExecuteLegacyContents creates a new MsgExecuteLegacyContents instance. -func NewMsgExecuteLegacyContents( - sender sdk.AccAddress, //nolint:interfacer - contents []govv1beta1.Content, -) (*MsgExecuteLegacyContents, error) { - msg := &MsgExecuteLegacyContents{ - Sender: sender.String(), - } - - if err := msg.SetContents(contents); err != nil { - return nil, err - } - - return msg, nil -} - -// GetContents returns the contents of MsgExecuteLegacyContents. -func (m *MsgExecuteLegacyContents) GetContents() []govv1beta1.Content { - contents := make([]govv1beta1.Content, len(m.Contents)) - for i, content := range m.Contents { - content, ok := content.GetCachedValue().(govv1beta1.Content) - if !ok { - return nil - } - - contents[i] = content - } - - return contents -} - -// SetContents sets the contents for MsgExecuteLegacyContents. -func (m *MsgExecuteLegacyContents) SetContents(contents []govv1beta1.Content) error { - anys := make([]*codectypes.Any, len(contents)) - for i, content := range contents { - msg, ok := content.(proto.Message) - if !ok { - return fmt.Errorf("can't proto marshal %T", msg) - } - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return err - } - - anys[i] = any - } - - m.Contents = anys - return nil -} - -// Validate performs basic MsgExecuteLegacyContents message validation. -func (msg MsgExecuteLegacyContents) Validate(ac address.Codec) error { - if _, err := ac.StringToBytes(msg.Sender); err != nil { - return err - } - - // Check Msgs length is non nil. - if len(msg.Contents) == 0 { - return errors.Wrap(govtypes.ErrNoProposalMsgs, "Contents length must be non-zero") - } - - contents := msg.GetContents() - for idx, content := range contents { - if err := content.ValidateBasic(); err != nil { - return errors.Wrapf(govtypes.ErrInvalidProposalContent, "content: %d, err: %s", idx, err.Error()) - } - } - - return nil -} - -// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (c MsgExecuteLegacyContents) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - for _, anyContent := range c.Contents { - var content govv1beta1.Content - if err := unpacker.UnpackAny(anyContent, &content); err != nil { - return err - } - } - - return nil -} - /* MsgAddValidator */ // NewMsgAddValidator creates a new MsgAddValidator instance. diff --git a/x/opchild/types/tx.pb.go b/x/opchild/types/tx.pb.go index 7c4eac0c..c745c292 100644 --- a/x/opchild/types/tx.pb.go +++ b/x/opchild/types/tx.pb.go @@ -113,86 +113,6 @@ func (m *MsgExecuteMessagesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgExecuteMessagesResponse proto.InternalMessageInfo -// MsgExecuteLegacyContents is a message to execute legacy -// (gov) contents with validator permission. -type MsgExecuteLegacyContents struct { - // Sender is the that actor that signed a messages - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // contents are the arbitrary legacy (gov) contents to be executed. - Contents []*types.Any `protobuf:"bytes,2,rep,name=contents,proto3" json:"contents,omitempty"` -} - -func (m *MsgExecuteLegacyContents) Reset() { *m = MsgExecuteLegacyContents{} } -func (m *MsgExecuteLegacyContents) String() string { return proto.CompactTextString(m) } -func (*MsgExecuteLegacyContents) ProtoMessage() {} -func (*MsgExecuteLegacyContents) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{2} -} -func (m *MsgExecuteLegacyContents) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgExecuteLegacyContents) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgExecuteLegacyContents.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 *MsgExecuteLegacyContents) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgExecuteLegacyContents.Merge(m, src) -} -func (m *MsgExecuteLegacyContents) XXX_Size() int { - return m.Size() -} -func (m *MsgExecuteLegacyContents) XXX_DiscardUnknown() { - xxx_messageInfo_MsgExecuteLegacyContents.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgExecuteLegacyContents proto.InternalMessageInfo - -// MsgExecuteLegacyContentsResponse returns MsgExecuteLegacyContents message -// result data -type MsgExecuteLegacyContentsResponse struct { -} - -func (m *MsgExecuteLegacyContentsResponse) Reset() { *m = MsgExecuteLegacyContentsResponse{} } -func (m *MsgExecuteLegacyContentsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgExecuteLegacyContentsResponse) ProtoMessage() {} -func (*MsgExecuteLegacyContentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{3} -} -func (m *MsgExecuteLegacyContentsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgExecuteLegacyContentsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgExecuteLegacyContentsResponse.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 *MsgExecuteLegacyContentsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgExecuteLegacyContentsResponse.Merge(m, src) -} -func (m *MsgExecuteLegacyContentsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgExecuteLegacyContentsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgExecuteLegacyContentsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgExecuteLegacyContentsResponse proto.InternalMessageInfo - // MsgFinalizeTokenDeposit is a message to submit deposit funds from upper layer type MsgFinalizeTokenDeposit struct { // the sender address @@ -215,7 +135,7 @@ func (m *MsgFinalizeTokenDeposit) Reset() { *m = MsgFinalizeTokenDeposit func (m *MsgFinalizeTokenDeposit) String() string { return proto.CompactTextString(m) } func (*MsgFinalizeTokenDeposit) ProtoMessage() {} func (*MsgFinalizeTokenDeposit) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{4} + return fileDescriptor_1ee96a503651b6e4, []int{2} } func (m *MsgFinalizeTokenDeposit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,7 +172,7 @@ func (m *MsgFinalizeTokenDepositResponse) Reset() { *m = MsgFinalizeToke func (m *MsgFinalizeTokenDepositResponse) String() string { return proto.CompactTextString(m) } func (*MsgFinalizeTokenDepositResponse) ProtoMessage() {} func (*MsgFinalizeTokenDepositResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{5} + return fileDescriptor_1ee96a503651b6e4, []int{3} } func (m *MsgFinalizeTokenDepositResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -295,7 +215,7 @@ func (m *MsgInitiateTokenWithdrawal) Reset() { *m = MsgInitiateTokenWith func (m *MsgInitiateTokenWithdrawal) String() string { return proto.CompactTextString(m) } func (*MsgInitiateTokenWithdrawal) ProtoMessage() {} func (*MsgInitiateTokenWithdrawal) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{6} + return fileDescriptor_1ee96a503651b6e4, []int{4} } func (m *MsgInitiateTokenWithdrawal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -333,7 +253,7 @@ func (m *MsgInitiateTokenWithdrawalResponse) Reset() { *m = MsgInitiateT func (m *MsgInitiateTokenWithdrawalResponse) String() string { return proto.CompactTextString(m) } func (*MsgInitiateTokenWithdrawalResponse) ProtoMessage() {} func (*MsgInitiateTokenWithdrawalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{7} + return fileDescriptor_1ee96a503651b6e4, []int{5} } func (m *MsgInitiateTokenWithdrawalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -376,7 +296,7 @@ func (m *MsgAddValidator) Reset() { *m = MsgAddValidator{} } func (m *MsgAddValidator) String() string { return proto.CompactTextString(m) } func (*MsgAddValidator) ProtoMessage() {} func (*MsgAddValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{8} + return fileDescriptor_1ee96a503651b6e4, []int{6} } func (m *MsgAddValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -413,7 +333,7 @@ func (m *MsgAddValidatorResponse) Reset() { *m = MsgAddValidatorResponse func (m *MsgAddValidatorResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddValidatorResponse) ProtoMessage() {} func (*MsgAddValidatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{9} + return fileDescriptor_1ee96a503651b6e4, []int{7} } func (m *MsgAddValidatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,7 +375,7 @@ func (m *MsgRemoveValidator) Reset() { *m = MsgRemoveValidator{} } func (m *MsgRemoveValidator) String() string { return proto.CompactTextString(m) } func (*MsgRemoveValidator) ProtoMessage() {} func (*MsgRemoveValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{10} + return fileDescriptor_1ee96a503651b6e4, []int{8} } func (m *MsgRemoveValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -492,7 +412,7 @@ func (m *MsgRemoveValidatorResponse) Reset() { *m = MsgRemoveValidatorRe func (m *MsgRemoveValidatorResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveValidatorResponse) ProtoMessage() {} func (*MsgRemoveValidatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{11} + return fileDescriptor_1ee96a503651b6e4, []int{9} } func (m *MsgRemoveValidatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -534,7 +454,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{12} + return fileDescriptor_1ee96a503651b6e4, []int{10} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -571,7 +491,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{13} + return fileDescriptor_1ee96a503651b6e4, []int{11} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -616,7 +536,7 @@ func (m *MsgSpendFeePool) Reset() { *m = MsgSpendFeePool{} } func (m *MsgSpendFeePool) String() string { return proto.CompactTextString(m) } func (*MsgSpendFeePool) ProtoMessage() {} func (*MsgSpendFeePool) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{14} + return fileDescriptor_1ee96a503651b6e4, []int{12} } func (m *MsgSpendFeePool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -653,7 +573,7 @@ func (m *MsgSpendFeePoolResponse) Reset() { *m = MsgSpendFeePoolResponse func (m *MsgSpendFeePoolResponse) String() string { return proto.CompactTextString(m) } func (*MsgSpendFeePoolResponse) ProtoMessage() {} func (*MsgSpendFeePoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1ee96a503651b6e4, []int{15} + return fileDescriptor_1ee96a503651b6e4, []int{13} } func (m *MsgSpendFeePoolResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -685,8 +605,6 @@ var xxx_messageInfo_MsgSpendFeePoolResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgExecuteMessages)(nil), "opinit.opchild.v1.MsgExecuteMessages") proto.RegisterType((*MsgExecuteMessagesResponse)(nil), "opinit.opchild.v1.MsgExecuteMessagesResponse") - proto.RegisterType((*MsgExecuteLegacyContents)(nil), "opinit.opchild.v1.MsgExecuteLegacyContents") - proto.RegisterType((*MsgExecuteLegacyContentsResponse)(nil), "opinit.opchild.v1.MsgExecuteLegacyContentsResponse") proto.RegisterType((*MsgFinalizeTokenDeposit)(nil), "opinit.opchild.v1.MsgFinalizeTokenDeposit") proto.RegisterType((*MsgFinalizeTokenDepositResponse)(nil), "opinit.opchild.v1.MsgFinalizeTokenDepositResponse") proto.RegisterType((*MsgInitiateTokenWithdrawal)(nil), "opinit.opchild.v1.MsgInitiateTokenWithdrawal") @@ -704,75 +622,71 @@ func init() { func init() { proto.RegisterFile("opinit/opchild/v1/tx.proto", fileDescriptor_1ee96a503651b6e4) } var fileDescriptor_1ee96a503651b6e4 = []byte{ - // 1080 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x8f, 0xdb, 0x44, - 0x14, 0x8e, 0x93, 0x6d, 0xda, 0x9d, 0x16, 0xb5, 0x6b, 0x2d, 0xac, 0xd7, 0xa2, 0x49, 0xb0, 0x84, - 0x14, 0x42, 0x63, 0x6f, 0x52, 0xc1, 0x21, 0x27, 0x36, 0xa5, 0x2b, 0x41, 0x89, 0x58, 0xa5, 0xfc, - 0x90, 0x38, 0x50, 0x4d, 0xec, 0xa9, 0x33, 0xda, 0x78, 0xc6, 0x78, 0x26, 0x61, 0xcd, 0x05, 0xc4, - 0x05, 0xc4, 0x89, 0x3f, 0xa1, 0x07, 0x0e, 0x88, 0xd3, 0x1e, 0x38, 0x21, 0xfe, 0x80, 0x15, 0xa7, - 0x8a, 0x03, 0xe2, 0xb4, 0xc0, 0xee, 0x61, 0x39, 0xef, 0x95, 0x0b, 0xb2, 0x3d, 0x71, 0x1c, 0xc7, - 0xde, 0x74, 0xab, 0xc2, 0xa5, 0xdd, 0x79, 0xef, 0x7b, 0xcf, 0xef, 0xfb, 0xde, 0xcc, 0x9b, 0x09, - 0x50, 0xa9, 0x8b, 0x09, 0xe6, 0x06, 0x75, 0xcd, 0x21, 0x1e, 0x59, 0xc6, 0xa4, 0x65, 0xf0, 0x7d, - 0xdd, 0xf5, 0x28, 0xa7, 0xf2, 0x5a, 0xe4, 0xd3, 0x85, 0x4f, 0x9f, 0xb4, 0xd4, 0x35, 0xe8, 0x60, - 0x42, 0x8d, 0xf0, 0xdf, 0x08, 0xa5, 0x56, 0x4c, 0xca, 0x1c, 0xca, 0x8c, 0x01, 0x64, 0xc8, 0x98, - 0xb4, 0x06, 0x88, 0xc3, 0x96, 0x61, 0x52, 0x4c, 0x84, 0x7f, 0x43, 0xf8, 0x1d, 0x66, 0x07, 0xd9, - 0x1d, 0x66, 0x0b, 0xc7, 0x66, 0xe4, 0x78, 0x10, 0xae, 0x8c, 0x68, 0x21, 0x5c, 0xeb, 0x36, 0xb5, - 0x69, 0x64, 0x0f, 0xfe, 0x9a, 0x06, 0xd8, 0x94, 0xda, 0x23, 0x64, 0x84, 0xab, 0xc1, 0xf8, 0xa1, - 0x01, 0x89, 0x2f, 0x5c, 0x37, 0x33, 0x68, 0xf8, 0x2e, 0x12, 0xf9, 0xb4, 0xef, 0x24, 0x20, 0xf7, - 0x98, 0x7d, 0x77, 0x1f, 0x99, 0x63, 0x8e, 0x7a, 0x88, 0x31, 0x68, 0x23, 0x26, 0x6f, 0x81, 0x32, - 0x43, 0xc4, 0x42, 0x9e, 0x22, 0xd5, 0xa4, 0xfa, 0x6a, 0x57, 0xf9, 0xf5, 0xc7, 0xe6, 0xba, 0x28, - 0x64, 0xdb, 0xb2, 0x3c, 0xc4, 0xd8, 0x7d, 0xee, 0x61, 0x62, 0xf7, 0x05, 0x4e, 0xde, 0x02, 0x57, - 0x1c, 0x11, 0xad, 0x14, 0x6b, 0xa5, 0xfa, 0xd5, 0xf6, 0xba, 0x1e, 0x55, 0xa5, 0x4f, 0xab, 0xd2, - 0xb7, 0x89, 0xdf, 0x8f, 0x51, 0x9d, 0xc6, 0x97, 0xa7, 0x07, 0x0d, 0x11, 0xfe, 0xcd, 0xe9, 0x41, - 0x43, 0x9d, 0x96, 0xb8, 0x58, 0x8f, 0xf6, 0x22, 0x50, 0x17, 0xad, 0x7d, 0xc4, 0x5c, 0x4a, 0x18, - 0xd2, 0x0e, 0x24, 0xa0, 0xcc, 0xdc, 0xef, 0x20, 0x1b, 0x9a, 0xfe, 0x1d, 0x4a, 0x38, 0x22, 0xfc, - 0x29, 0xa9, 0x98, 0x22, 0xfa, 0x7c, 0x2a, 0x53, 0x54, 0x67, 0x2b, 0x45, 0xa5, 0xb6, 0x48, 0x65, - 0xbe, 0x2a, 0x4d, 0x03, 0xb5, 0x3c, 0x5f, 0x4c, 0xeb, 0xab, 0x12, 0xd8, 0xe8, 0x31, 0x7b, 0x07, - 0x13, 0x38, 0xc2, 0x9f, 0xa1, 0xf7, 0xe8, 0x1e, 0x22, 0x6f, 0x22, 0x97, 0x32, 0xcc, 0xe5, 0xed, - 0x14, 0xab, 0x57, 0xce, 0x8e, 0xaa, 0xcf, 0xf9, 0xd0, 0x19, 0x75, 0xb4, 0xc8, 0xae, 0x2d, 0xa5, - 0x79, 0x0b, 0xac, 0x3c, 0xf4, 0xa8, 0xa3, 0x14, 0x97, 0xc8, 0x12, 0xa2, 0xe4, 0x3a, 0x28, 0x72, - 0xaa, 0x94, 0x96, 0x60, 0x8b, 0x9c, 0xca, 0x3d, 0x50, 0x86, 0x0e, 0x1d, 0x13, 0xae, 0xac, 0xd4, - 0xa4, 0xfa, 0xd5, 0xf6, 0xa6, 0x2e, 0xa0, 0xc1, 0x39, 0xd0, 0xc5, 0x39, 0xd0, 0xef, 0x50, 0x4c, - 0xba, 0xea, 0xe1, 0x51, 0xb5, 0x30, 0xab, 0x3c, 0x0a, 0xd3, 0xbe, 0x3f, 0x3d, 0x68, 0x48, 0x7d, - 0x91, 0x44, 0x56, 0xc1, 0x15, 0x86, 0x3e, 0x19, 0x23, 0x62, 0x22, 0xe5, 0x52, 0x4d, 0xaa, 0xaf, - 0xf4, 0xe3, 0xb5, 0xfc, 0x02, 0x28, 0x0f, 0x11, 0xb6, 0x87, 0x5c, 0x29, 0x87, 0x1e, 0xb1, 0x92, - 0x6f, 0x82, 0x15, 0x0b, 0x72, 0xa8, 0x5c, 0xae, 0x49, 0xf5, 0x6b, 0xdd, 0xd5, 0xc3, 0xa3, 0xaa, - 0x14, 0x25, 0x0d, 0xcd, 0x1d, 0x23, 0xd5, 0xae, 0x6a, 0xa2, 0x5d, 0x59, 0x6a, 0x6b, 0x2f, 0x81, - 0x6a, 0x8e, 0x2b, 0x6e, 0xd6, 0x3f, 0x52, 0xb8, 0x45, 0xdf, 0x22, 0x98, 0x63, 0xc8, 0x23, 0xcc, - 0x87, 0x98, 0x0f, 0x2d, 0x0f, 0x7e, 0x0a, 0x47, 0x4f, 0xb1, 0x0b, 0x23, 0xc1, 0x8b, 0xff, 0xbb, - 0xe0, 0x9d, 0x76, 0x4a, 0x1d, 0x2d, 0xa1, 0x4e, 0x0e, 0x3d, 0xed, 0x0d, 0xa0, 0xe5, 0x7b, 0xa7, - 0x1a, 0xcd, 0xb5, 0x52, 0x9a, 0x6f, 0xa5, 0xf6, 0x53, 0x11, 0x5c, 0xef, 0x31, 0x7b, 0xdb, 0xb2, - 0x3e, 0x80, 0x23, 0x6c, 0x41, 0x4e, 0x3d, 0xf9, 0x6d, 0xb0, 0x0a, 0xc7, 0x7c, 0x48, 0x3d, 0xcc, - 0x7d, 0xa1, 0xdb, 0xad, 0xb3, 0xa3, 0xea, 0x0d, 0x51, 0xfc, 0xd4, 0x95, 0xbf, 0xd5, 0x67, 0xe1, - 0xb2, 0x02, 0x2e, 0x3b, 0x94, 0xe0, 0x3d, 0xe4, 0x45, 0x9a, 0xf6, 0xa7, 0x4b, 0xf9, 0x2e, 0x58, - 0x9b, 0x4c, 0x3f, 0xf9, 0x00, 0x46, 0xf1, 0x4b, 0x37, 0xfa, 0x8d, 0x38, 0x44, 0xd8, 0xe5, 0x1d, - 0x50, 0x76, 0xc7, 0x83, 0x3d, 0xe4, 0x8b, 0x2e, 0x64, 0xce, 0x8c, 0xae, 0xf2, 0xcb, 0x2c, 0xa3, - 0xe9, 0xf9, 0x2e, 0xa7, 0xfa, 0xee, 0x78, 0x70, 0x0f, 0xf9, 0x7d, 0x11, 0xdd, 0x69, 0x7f, 0xfd, - 0xa8, 0x5a, 0xf8, 0xfb, 0x51, 0xb5, 0x10, 0xb4, 0x61, 0x46, 0x20, 0xe8, 0xc4, 0x46, 0xa2, 0x13, - 0x49, 0xa1, 0xb4, 0xcd, 0x70, 0x50, 0x24, 0x4d, 0xf1, 0xbe, 0xfc, 0x2d, 0x1a, 0xf0, 0x7d, 0xe4, - 0xd0, 0x09, 0xfa, 0x6f, 0xa4, 0xcd, 0x14, 0xb0, 0x78, 0x51, 0x01, 0x3b, 0xcd, 0x45, 0xc2, 0xc9, - 0x2b, 0x21, 0xc5, 0x40, 0x5c, 0x09, 0x29, 0x6b, 0x4c, 0xfb, 0x67, 0x29, 0xdc, 0x4e, 0xef, 0xbb, - 0x16, 0xe4, 0x68, 0x17, 0x7a, 0xd0, 0x61, 0xcf, 0x94, 0x73, 0x0b, 0x94, 0xdd, 0x30, 0x6b, 0x48, - 0x34, 0x38, 0x73, 0x0b, 0x4f, 0x02, 0x3d, 0xfa, 0x6c, 0x5f, 0x00, 0xa3, 0xfb, 0x2e, 0xbf, 0xa1, - 0xc9, 0x52, 0x45, 0x43, 0x93, 0xa6, 0x19, 0xb3, 0xe8, 0xa0, 0xdc, 0x77, 0x11, 0xb1, 0x76, 0x10, - 0xda, 0xa5, 0x74, 0xf4, 0x4c, 0x99, 0xbd, 0x0e, 0x56, 0x3d, 0x64, 0x62, 0x17, 0x23, 0xc2, 0x97, - 0x76, 0x71, 0x06, 0x95, 0xfd, 0x78, 0x0a, 0x95, 0xc2, 0x3b, 0xf3, 0x9c, 0x29, 0xb4, 0x93, 0x39, - 0x85, 0x7e, 0xf8, 0xa3, 0x5a, 0xb7, 0x31, 0x1f, 0x8e, 0x07, 0xba, 0x49, 0x1d, 0xf1, 0xec, 0x11, - 0xff, 0x35, 0x99, 0xb5, 0x27, 0xde, 0x2d, 0x41, 0x06, 0x36, 0x3f, 0xb1, 0x96, 0x28, 0x9b, 0x94, - 0x4a, 0x28, 0x9b, 0x34, 0x4d, 0x95, 0x6d, 0x9f, 0x95, 0x41, 0xa9, 0xc7, 0x6c, 0xd9, 0x06, 0xd7, - 0xd3, 0xef, 0xa1, 0x97, 0x33, 0xda, 0xbb, 0xf8, 0x20, 0x51, 0x9b, 0x4f, 0x04, 0x8b, 0xe7, 0xa1, - 0x0f, 0x9e, 0xcf, 0x7e, 0xb3, 0xbc, 0x7a, 0x6e, 0x9e, 0x79, 0xb0, 0x7a, 0xfb, 0x02, 0xe0, 0xf8, - 0xd3, 0x13, 0xb0, 0x9e, 0xf9, 0xae, 0x68, 0x64, 0x27, 0xcb, 0xc2, 0xaa, 0xed, 0x27, 0xc7, 0xc6, - 0xdf, 0xfd, 0x1c, 0x6c, 0xe4, 0x5d, 0x91, 0x39, 0xe2, 0xe5, 0xc0, 0xd5, 0xd7, 0x2e, 0x04, 0x8f, - 0x0b, 0xf8, 0x18, 0x5c, 0x9b, 0xbb, 0x63, 0xb4, 0xec, 0x34, 0x49, 0x8c, 0xda, 0x58, 0x8e, 0x89, - 0xf3, 0xdb, 0xe0, 0x7a, 0x7a, 0xd6, 0xe6, 0x6c, 0x9e, 0x14, 0x2c, 0x6f, 0xf3, 0xe4, 0x4c, 0xb8, - 0x80, 0xc8, 0xdc, 0x74, 0xcb, 0x21, 0x92, 0xc4, 0xe4, 0x11, 0xc9, 0x9a, 0x33, 0x41, 0xfe, 0xb9, - 0x19, 0x93, 0x93, 0x3f, 0x89, 0xc9, 0xcb, 0x9f, 0x75, 0xda, 0xd4, 0x4b, 0x5f, 0x04, 0x67, 0xb8, - 0x7b, 0xef, 0xf0, 0xaf, 0x4a, 0xe1, 0xf0, 0xb8, 0x22, 0x3d, 0x3e, 0xae, 0x48, 0x7f, 0x1e, 0x57, - 0xa4, 0x6f, 0x4f, 0x2a, 0x85, 0xc7, 0x27, 0x95, 0xc2, 0xef, 0x27, 0x95, 0xc2, 0x47, 0xcd, 0xc4, - 0x40, 0xc0, 0x61, 0x67, 0x9b, 0x23, 0x38, 0x60, 0xc6, 0xbb, 0xbb, 0xe1, 0x8f, 0x9a, 0xfd, 0xf8, - 0x67, 0x4d, 0x38, 0x1b, 0x06, 0xe5, 0xf0, 0xae, 0xbd, 0xfd, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x06, 0x99, 0x52, 0x24, 0xbc, 0x0d, 0x00, 0x00, + // 1020 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0x8e, 0x93, 0x36, 0xbb, 0x9d, 0x5d, 0xd4, 0xad, 0x55, 0x51, 0xd7, 0x62, 0x93, 0x60, 0x09, + 0x29, 0x44, 0x1b, 0x7b, 0x13, 0x04, 0x87, 0x9c, 0x68, 0x60, 0x2b, 0xc1, 0x2a, 0xa2, 0xf2, 0xf2, + 0x43, 0xe2, 0xc0, 0x6a, 0x12, 0xcf, 0x3a, 0xa3, 0xc6, 0x33, 0xc6, 0x33, 0x09, 0x35, 0x17, 0x10, + 0x17, 0x10, 0x27, 0xfe, 0x84, 0x3d, 0x70, 0x40, 0x9c, 0x7a, 0xe0, 0x84, 0xf8, 0x03, 0x2a, 0x4e, + 0x2b, 0x0e, 0x88, 0x53, 0x81, 0xf6, 0x50, 0xce, 0x7b, 0xe1, 0xc0, 0x05, 0xd9, 0x33, 0x71, 0x9c, + 0xc4, 0x26, 0xbb, 0xa8, 0x70, 0x69, 0x33, 0xef, 0x7d, 0xf3, 0xfc, 0xde, 0xf7, 0xcd, 0xbc, 0x37, + 0x40, 0xa7, 0x3e, 0x26, 0x98, 0x5b, 0xd4, 0x1f, 0x0c, 0xf1, 0xc8, 0xb1, 0x26, 0x2d, 0x8b, 0x1f, + 0x99, 0x7e, 0x40, 0x39, 0x55, 0xb7, 0x84, 0xcf, 0x94, 0x3e, 0x73, 0xd2, 0xd2, 0xb7, 0xa0, 0x87, + 0x09, 0xb5, 0xe2, 0xbf, 0x02, 0xa5, 0x57, 0x06, 0x94, 0x79, 0x94, 0x59, 0x7d, 0xc8, 0x90, 0x35, + 0x69, 0xf5, 0x11, 0x87, 0x2d, 0x6b, 0x40, 0x31, 0x91, 0xfe, 0x1d, 0xe9, 0xf7, 0x98, 0x1b, 0x45, + 0xf7, 0x98, 0x2b, 0x1d, 0xbb, 0xc2, 0x71, 0x3f, 0x5e, 0x59, 0x62, 0x21, 0x5d, 0xdb, 0x2e, 0x75, + 0xa9, 0xb0, 0x47, 0xbf, 0xa6, 0x1b, 0x5c, 0x4a, 0xdd, 0x11, 0xb2, 0xe2, 0x55, 0x7f, 0xfc, 0xc0, + 0x82, 0x24, 0x94, 0xae, 0x9b, 0x19, 0x65, 0x84, 0x3e, 0x92, 0xf1, 0x8c, 0xaf, 0x15, 0xa0, 0xf6, + 0x98, 0x7b, 0xe7, 0x08, 0x0d, 0xc6, 0x1c, 0xf5, 0x10, 0x63, 0xd0, 0x45, 0x4c, 0xbd, 0x0d, 0xca, + 0x0c, 0x11, 0x07, 0x05, 0x9a, 0x52, 0x53, 0xea, 0x1b, 0x5d, 0xed, 0xa7, 0xef, 0x9a, 0xdb, 0x32, + 0x91, 0x3d, 0xc7, 0x09, 0x10, 0x63, 0xf7, 0x78, 0x80, 0x89, 0x6b, 0x4b, 0x9c, 0x7a, 0x1b, 0x5c, + 0xf5, 0xe4, 0x6e, 0xad, 0x58, 0x2b, 0xd5, 0xaf, 0xb5, 0xb7, 0x4d, 0x91, 0x95, 0x39, 0xcd, 0xca, + 0xdc, 0x23, 0xa1, 0x9d, 0xa0, 0x3a, 0x8d, 0xcf, 0x2e, 0x8e, 0x1b, 0x72, 0xfb, 0x97, 0x17, 0xc7, + 0x0d, 0x7d, 0x9a, 0xe2, 0x72, 0x3e, 0xc6, 0x73, 0x40, 0x5f, 0xb6, 0xda, 0x88, 0xf9, 0x94, 0x30, + 0x64, 0x7c, 0x5e, 0x02, 0x3b, 0x3d, 0xe6, 0xee, 0x63, 0x02, 0x47, 0xf8, 0x63, 0xf4, 0x36, 0x3d, + 0x44, 0xe4, 0x75, 0xe4, 0x53, 0x86, 0xb9, 0xba, 0xb7, 0x50, 0xc9, 0x8b, 0x8f, 0x4f, 0xab, 0xcf, + 0x84, 0xd0, 0x1b, 0x75, 0x0c, 0x61, 0x37, 0x56, 0x96, 0x76, 0x0b, 0xac, 0x3d, 0x08, 0xa8, 0xa7, + 0x15, 0x57, 0x50, 0x11, 0xa3, 0xd4, 0x3a, 0x28, 0x72, 0xaa, 0x95, 0x56, 0x60, 0x8b, 0x9c, 0xaa, + 0x3d, 0x50, 0x86, 0x1e, 0x1d, 0x13, 0xae, 0xad, 0xd5, 0x94, 0xfa, 0xb5, 0xf6, 0xae, 0x29, 0xa1, + 0xd1, 0x81, 0x31, 0xe5, 0x81, 0x31, 0x5f, 0xa3, 0x98, 0x74, 0xf5, 0x93, 0xd3, 0x6a, 0x61, 0x96, + 0xb9, 0xd8, 0x66, 0x7c, 0x73, 0x71, 0xdc, 0x50, 0x6c, 0x19, 0x44, 0xd5, 0xc1, 0x55, 0x86, 0x3e, + 0x1c, 0x23, 0x32, 0x40, 0xda, 0x7a, 0x4d, 0xa9, 0xaf, 0xd9, 0xc9, 0x5a, 0x7d, 0x16, 0x94, 0x87, + 0x08, 0xbb, 0x43, 0xae, 0x95, 0x63, 0x8f, 0x5c, 0xa9, 0x37, 0xc1, 0x9a, 0x03, 0x39, 0xd4, 0xae, + 0xd4, 0x94, 0xfa, 0xf5, 0xee, 0xc6, 0xc9, 0x69, 0x55, 0x11, 0x41, 0x63, 0x73, 0xc7, 0x5a, 0x90, + 0xa8, 0x9a, 0x92, 0x28, 0x8b, 0x6d, 0xe3, 0x79, 0x50, 0xcd, 0x71, 0x25, 0x62, 0xfd, 0xa5, 0xc4, + 0x5a, 0xbe, 0x41, 0x30, 0xc7, 0x90, 0x0b, 0xcc, 0x7b, 0x98, 0x0f, 0x9d, 0x00, 0x7e, 0x04, 0x47, + 0xff, 0xe2, 0xe4, 0x09, 0xc2, 0x8b, 0xff, 0x3b, 0xe1, 0x9d, 0xf6, 0x02, 0x3b, 0x46, 0x8a, 0x9d, + 0x9c, 0xf2, 0x8c, 0x57, 0x81, 0x91, 0xef, 0x9d, 0x72, 0x34, 0x27, 0xa5, 0x32, 0x2f, 0xa5, 0xf1, + 0x7d, 0x11, 0x6c, 0xf6, 0x98, 0xbb, 0xe7, 0x38, 0xef, 0xc2, 0x11, 0x76, 0x20, 0xa7, 0x81, 0xfa, + 0x26, 0xd8, 0x80, 0x63, 0x3e, 0xa4, 0x01, 0xe6, 0xa1, 0xe4, 0xed, 0xd6, 0xe3, 0xd3, 0xea, 0x0d, + 0x99, 0xfc, 0xd4, 0x95, 0x7f, 0xd4, 0x67, 0xdb, 0x55, 0x0d, 0x5c, 0xf1, 0x28, 0xc1, 0x87, 0x28, + 0x10, 0x9c, 0xda, 0xd3, 0xa5, 0x7a, 0x07, 0x6c, 0x4d, 0xa6, 0x9f, 0xbc, 0x0f, 0xc5, 0xfe, 0x95, + 0x07, 0xfd, 0x46, 0xb2, 0x45, 0xda, 0xd5, 0x7d, 0x50, 0xf6, 0xc7, 0xfd, 0x43, 0x14, 0x4a, 0x15, + 0x32, 0xfb, 0x44, 0x57, 0xfb, 0x71, 0x16, 0x71, 0x10, 0x84, 0x3e, 0xa7, 0xe6, 0xc1, 0xb8, 0x7f, + 0x17, 0x85, 0xb6, 0xdc, 0xdd, 0x69, 0x7f, 0xf1, 0xb0, 0x5a, 0xf8, 0xe3, 0x61, 0xb5, 0x10, 0xc9, + 0x30, 0x2b, 0x20, 0x52, 0x62, 0x27, 0xa5, 0x44, 0x9a, 0x28, 0x63, 0x37, 0x6e, 0x14, 0x69, 0x53, + 0x72, 0x2e, 0x7f, 0x16, 0x9d, 0xd0, 0x46, 0x1e, 0x9d, 0xa0, 0xff, 0x86, 0xda, 0x4c, 0x02, 0x8b, + 0x4f, 0x4b, 0x60, 0xa7, 0xb9, 0x5c, 0x70, 0xba, 0x77, 0x2e, 0x54, 0x20, 0x7b, 0xe7, 0x82, 0x35, + 0x29, 0xfb, 0x07, 0x25, 0x3e, 0x4e, 0xef, 0xf8, 0x0e, 0xe4, 0xe8, 0x00, 0x06, 0xd0, 0x63, 0x97, + 0x5a, 0x73, 0x0b, 0x94, 0xfd, 0x38, 0x6a, 0x5c, 0x68, 0x74, 0xe7, 0x96, 0x66, 0xa7, 0x29, 0x3e, + 0x6b, 0x4b, 0xa0, 0x18, 0x0c, 0xf9, 0x82, 0xa6, 0x53, 0x95, 0x82, 0xa6, 0x4d, 0xb3, 0xca, 0xc4, + 0x45, 0xb9, 0xe7, 0x23, 0xe2, 0xec, 0x23, 0x74, 0x40, 0xe9, 0xe8, 0x52, 0x2b, 0x7b, 0x05, 0x6c, + 0x04, 0x68, 0x80, 0x7d, 0x8c, 0x08, 0x5f, 0xa9, 0xe2, 0x0c, 0xaa, 0x86, 0x49, 0x17, 0x2a, 0xc5, + 0x73, 0xf2, 0x1f, 0xba, 0xd0, 0x7e, 0x66, 0x17, 0xfa, 0xf6, 0xd7, 0x6a, 0xdd, 0xc5, 0x7c, 0x38, + 0xee, 0x9b, 0x03, 0xea, 0xc9, 0xf7, 0x81, 0xfc, 0xd7, 0x64, 0xce, 0xa1, 0x1c, 0xf0, 0x51, 0x04, + 0x36, 0xdf, 0xb1, 0x56, 0x30, 0x9b, 0xa6, 0x4a, 0x32, 0x9b, 0x36, 0x4d, 0x99, 0x6d, 0xff, 0xb9, + 0x0e, 0x4a, 0x3d, 0xe6, 0xaa, 0x2e, 0xd8, 0x5c, 0x7c, 0x38, 0xbc, 0x90, 0x21, 0xef, 0xf2, 0xe4, + 0xd6, 0x9b, 0x4f, 0x04, 0x4b, 0xfa, 0xe1, 0x04, 0x6c, 0x67, 0x0e, 0xf7, 0x46, 0x76, 0x98, 0x2c, + 0xac, 0xde, 0x7e, 0x72, 0x6c, 0xf2, 0xdd, 0x4f, 0xc0, 0x4e, 0xde, 0x9c, 0xca, 0xa9, 0x20, 0x07, + 0xae, 0xbf, 0xfc, 0x54, 0xf0, 0x24, 0x81, 0x0f, 0xc0, 0xf5, 0xb9, 0x46, 0x6f, 0x64, 0x87, 0x49, + 0x63, 0xf4, 0xc6, 0x6a, 0x4c, 0x12, 0xdf, 0x05, 0x9b, 0x8b, 0x0d, 0x2f, 0x47, 0xc1, 0x05, 0x58, + 0x9e, 0x82, 0x39, 0x6d, 0x26, 0x2a, 0x64, 0xae, 0xc5, 0xe4, 0x14, 0x92, 0xc6, 0xe4, 0x15, 0x92, + 0x75, 0xd9, 0xa3, 0xf8, 0x73, 0x17, 0x3d, 0x27, 0x7e, 0x1a, 0x93, 0x17, 0x3f, 0xeb, 0xc8, 0xeb, + 0xeb, 0x9f, 0x46, 0x17, 0xa9, 0x7b, 0xf7, 0xe4, 0xf7, 0x4a, 0xe1, 0xe4, 0xac, 0xa2, 0x3c, 0x3a, + 0xab, 0x28, 0xbf, 0x9d, 0x55, 0x94, 0xaf, 0xce, 0x2b, 0x85, 0x47, 0xe7, 0x95, 0xc2, 0x2f, 0xe7, + 0x95, 0xc2, 0xfb, 0xcd, 0xd4, 0xad, 0xc4, 0xb1, 0xb2, 0xcd, 0x11, 0xec, 0x33, 0xeb, 0xad, 0x83, + 0xf8, 0x09, 0x7e, 0x94, 0x3c, 0xc2, 0xe3, 0x0b, 0xda, 0x2f, 0xc7, 0x03, 0xef, 0xa5, 0xbf, 0x03, + 0x00, 0x00, 0xff, 0xff, 0x69, 0x1b, 0x7c, 0x6b, 0x6a, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -789,9 +703,6 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // ExecuteMessages defines a rpc handler method for MsgExecuteMessages. ExecuteMessages(ctx context.Context, in *MsgExecuteMessages, opts ...grpc.CallOption) (*MsgExecuteMessagesResponse, error) - // ExecuteLegacyContents defines a rpc handler method for - // MsgExecuteLegacyContents. - ExecuteLegacyContents(ctx context.Context, in *MsgExecuteLegacyContents, opts ...grpc.CallOption) (*MsgExecuteLegacyContentsResponse, error) // FinalizeTokenDeposit defines a rpc handler method for MsgFinalizeTokenDeposit. FinalizeTokenDeposit(ctx context.Context, in *MsgFinalizeTokenDeposit, opts ...grpc.CallOption) (*MsgFinalizeTokenDepositResponse, error) // InitiateTokenWithdrawal defines a user facing l2 => l1 token transfer interface. @@ -824,15 +735,6 @@ func (c *msgClient) ExecuteMessages(ctx context.Context, in *MsgExecuteMessages, return out, nil } -func (c *msgClient) ExecuteLegacyContents(ctx context.Context, in *MsgExecuteLegacyContents, opts ...grpc.CallOption) (*MsgExecuteLegacyContentsResponse, error) { - out := new(MsgExecuteLegacyContentsResponse) - err := c.cc.Invoke(ctx, "/opinit.opchild.v1.Msg/ExecuteLegacyContents", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) FinalizeTokenDeposit(ctx context.Context, in *MsgFinalizeTokenDeposit, opts ...grpc.CallOption) (*MsgFinalizeTokenDepositResponse, error) { out := new(MsgFinalizeTokenDepositResponse) err := c.cc.Invoke(ctx, "/opinit.opchild.v1.Msg/FinalizeTokenDeposit", in, out, opts...) @@ -891,9 +793,6 @@ func (c *msgClient) SpendFeePool(ctx context.Context, in *MsgSpendFeePool, opts type MsgServer interface { // ExecuteMessages defines a rpc handler method for MsgExecuteMessages. ExecuteMessages(context.Context, *MsgExecuteMessages) (*MsgExecuteMessagesResponse, error) - // ExecuteLegacyContents defines a rpc handler method for - // MsgExecuteLegacyContents. - ExecuteLegacyContents(context.Context, *MsgExecuteLegacyContents) (*MsgExecuteLegacyContentsResponse, error) // FinalizeTokenDeposit defines a rpc handler method for MsgFinalizeTokenDeposit. FinalizeTokenDeposit(context.Context, *MsgFinalizeTokenDeposit) (*MsgFinalizeTokenDepositResponse, error) // InitiateTokenWithdrawal defines a user facing l2 => l1 token transfer interface. @@ -916,9 +815,6 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) ExecuteMessages(ctx context.Context, req *MsgExecuteMessages) (*MsgExecuteMessagesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ExecuteMessages not implemented") } -func (*UnimplementedMsgServer) ExecuteLegacyContents(ctx context.Context, req *MsgExecuteLegacyContents) (*MsgExecuteLegacyContentsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ExecuteLegacyContents not implemented") -} func (*UnimplementedMsgServer) FinalizeTokenDeposit(ctx context.Context, req *MsgFinalizeTokenDeposit) (*MsgFinalizeTokenDepositResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FinalizeTokenDeposit not implemented") } @@ -960,24 +856,6 @@ func _Msg_ExecuteMessages_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } -func _Msg_ExecuteLegacyContents_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgExecuteLegacyContents) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ExecuteLegacyContents(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/opinit.opchild.v1.Msg/ExecuteLegacyContents", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ExecuteLegacyContents(ctx, req.(*MsgExecuteLegacyContents)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_FinalizeTokenDeposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgFinalizeTokenDeposit) if err := dec(in); err != nil { @@ -1094,10 +972,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ExecuteMessages", Handler: _Msg_ExecuteMessages_Handler, }, - { - MethodName: "ExecuteLegacyContents", - Handler: _Msg_ExecuteLegacyContents_Handler, - }, { MethodName: "FinalizeTokenDeposit", Handler: _Msg_FinalizeTokenDeposit_Handler, @@ -1194,73 +1068,6 @@ func (m *MsgExecuteMessagesResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgExecuteLegacyContents) 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 *MsgExecuteLegacyContents) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgExecuteLegacyContents) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Contents) > 0 { - for iNdEx := len(m.Contents) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Contents[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgExecuteLegacyContentsResponse) 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 *MsgExecuteLegacyContentsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgExecuteLegacyContentsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func (m *MsgFinalizeTokenDeposit) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1747,34 +1554,6 @@ func (m *MsgExecuteMessagesResponse) Size() (n int) { return n } -func (m *MsgExecuteLegacyContents) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Contents) > 0 { - for _, e := range m.Contents { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgExecuteLegacyContentsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgFinalizeTokenDeposit) Size() (n int) { if m == nil { return 0 @@ -2138,172 +1917,6 @@ func (m *MsgExecuteMessagesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgExecuteLegacyContents) 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 ErrIntOverflowTx - } - 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: MsgExecuteLegacyContents: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExecuteLegacyContents: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Contents", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Contents = append(m.Contents, &types.Any{}) - if err := m.Contents[len(m.Contents)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgExecuteLegacyContentsResponse) 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 ErrIntOverflowTx - } - 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: MsgExecuteLegacyContentsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExecuteLegacyContentsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *MsgFinalizeTokenDeposit) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ophost/keeper/common_test.go b/x/ophost/keeper/common_test.go index 160343df..936fd0f3 100644 --- a/x/ophost/keeper/common_test.go +++ b/x/ophost/keeper/common_test.go @@ -42,7 +42,6 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" ophost "github.com/initia-labs/OPinit/x/ophost" ophostkeeper "github.com/initia-labs/OPinit/x/ophost/keeper" @@ -226,7 +225,7 @@ func _createTestInput( for _, v := range keys { ms.MountStoreWithDB(v, storetypes.StoreTypeIAVL, db) } - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + memKeys := storetypes.NewMemoryStoreKeys() for _, v := range memKeys { ms.MountStoreWithDB(v, storetypes.StoreTypeMemory, db) } From ab41e36f075f469763323d0640c89d7f4ebb7d34 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:44:47 +0900 Subject: [PATCH 04/11] remove legacy router --- x/opchild/keeper/common_test.go | 61 --------------------------------- x/opchild/keeper/keeper.go | 18 ---------- 2 files changed, 79 deletions(-) diff --git a/x/opchild/keeper/common_test.go b/x/opchild/keeper/common_test.go index 9ecd0663..e2064c47 100644 --- a/x/opchild/keeper/common_test.go +++ b/x/opchild/keeper/common_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "context" "encoding/binary" - "fmt" "testing" "time" @@ -14,7 +13,6 @@ import ( "github.com/cometbft/cometbft/crypto/secp256k1" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - errors "cosmossdk.io/errors" "cosmossdk.io/log" "cosmossdk.io/math" "cosmossdk.io/store" @@ -31,7 +29,6 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" @@ -42,7 +39,6 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" @@ -124,11 +120,6 @@ func MakeEncodingConfig(_ testing.TB) EncodingConfig { ModuleBasics.RegisterLegacyAminoCodec(legacyAmino) ModuleBasics.RegisterInterfaces(interfaceRegistry) - interfaceRegistry.RegisterImplementations( - (*govv1beta1.Content)(nil), - &testLegacyContent{}, - ) - return EncodingConfig{ InterfaceRegistry: interfaceRegistry, Marshaler: appCodec, @@ -305,11 +296,6 @@ func _createTestInput( authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) - // set test legacy content handler - govRouter := govv1beta1.NewRouter() - govRouter.AddRoute("test", NewTestLegacyContentHandler()) - opchildKeeper.SetLegacyRouter(govRouter) - opchildParams := opchildtypes.DefaultParams() opchildParams.BridgeExecutor = addrs[0].String() opchildKeeper.SetParams(ctx, opchildParams) @@ -330,53 +316,6 @@ func _createTestInput( return ctx, keepers } -type testLegacyContent struct { - Title string - Description string - Message string -} - -func (*testLegacyContent) ProtoMessage() {} -func (m *testLegacyContent) Reset() { *m = testLegacyContent{} } -func (c *testLegacyContent) GetTitle() string { - return c.Title -} -func (c *testLegacyContent) GetDescription() string { - return c.Description -} - -func (c *testLegacyContent) ProposalRoute() string { - return "test" -} -func (c *testLegacyContent) ProposalType() string { - return "test" -} -func (c *testLegacyContent) ValidateBasic() error { - return nil -} -func (c testLegacyContent) String() string { - return fmt.Sprintf(`Parameter Change Proposal: -Title: %s -Description: %s -Message: %s -`, c.Title, c.Description, c.Message) -} - -func NewTestLegacyContentHandler() govv1beta1.Handler { - return func(ctx sdk.Context, content govv1beta1.Content) error { - switch c := content.(type) { - case *testLegacyContent: - if c.Message != "test" { - return fmt.Errorf("message must be `test`") - } - return nil - - default: - return errors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized legacy content type: %T", c) - } - } -} - type bridgeHook struct { msgBytes []byte err error diff --git a/x/opchild/keeper/keeper.go b/x/opchild/keeper/keeper.go index 8e0b604a..7acc9832 100644 --- a/x/opchild/keeper/keeper.go +++ b/x/opchild/keeper/keeper.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" cosmostypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/initia-labs/OPinit/x/opchild/types" @@ -29,9 +28,6 @@ type Keeper struct { // Msg server router router *baseapp.MsgServiceRouter - // Legacy Proposal router - legacyRouter govv1beta1.Router - // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/opchild module account. authority string @@ -115,17 +111,3 @@ func (k Keeper) Logger(ctx context.Context) log.Logger { func (keeper Keeper) Router() *baseapp.MsgServiceRouter { return keeper.router } - -// SetLegacyRouter sets the legacy router for governance(validator operation) -func (keeper *Keeper) SetLegacyRouter(router govv1beta1.Router) { - // It is vital to seal the governance proposal router here as to not allow - // further handlers to be registered after the keeper is created since this - // could create invalid or non-deterministic behavior. - router.Seal() - keeper.legacyRouter = router -} - -// LegacyRouter returns the rollup keeper's legacy router -func (keeper Keeper) LegacyRouter() govv1beta1.Router { - return keeper.legacyRouter -} From c9a9fb4f4e8830160eb9d2f9170f0d6f739ddf8c Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:13:33 +0900 Subject: [PATCH 05/11] staticcheck && linter --- x/opchild/genesis.go | 2 +- x/opchild/keeper/genesis.go | 17 +++++++++++++---- x/opchild/keeper/historical_info.go | 4 +++- x/opchild/keeper/msg_server.go | 12 +++++++++--- x/opchild/keeper/val_state_change.go | 18 +++++++++++++----- x/opchild/keeper/validator.go | 12 ++++++------ x/opchild/types/validator.go | 12 ++++++------ x/ophost/keeper/genesis.go | 25 +++++++++++++++++++------ x/ophost/keeper/msg_server.go | 12 +++++++++--- x/ophost/keeper/msg_server_test.go | 4 ++-- x/ophost/keeper/querier_test.go | 16 +++++++--------- 11 files changed, 88 insertions(+), 46 deletions(-) diff --git a/x/opchild/genesis.go b/x/opchild/genesis.go index 66049892..34afba37 100644 --- a/x/opchild/genesis.go +++ b/x/opchild/genesis.go @@ -18,7 +18,7 @@ func WriteValidators(ctx context.Context, keeper *keeper.Keeper) (vals []tmtypes if err != nil { return true, err } - tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) + tmPk, err := cryptocodec.ToCmtPubKeyInterface(pk) if err != nil { return true, err } diff --git a/x/opchild/keeper/genesis.go b/x/opchild/keeper/genesis.go index 0b2e6017..159e6d94 100644 --- a/x/opchild/keeper/genesis.go +++ b/x/opchild/keeper/genesis.go @@ -30,7 +30,9 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) (res } for _, validator := range data.Validators { - k.SetValidator(ctx, validator) + if err := k.SetValidator(ctx, validator); err != nil { + panic(err) + } // Manually set indices for the first time if err := k.SetValidatorByConsAddr(ctx, validator); err != nil { @@ -46,7 +48,10 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) (res panic(err) } - k.SetLastValidatorPower(ctx, valAddr, lv.Power) + if err := k.SetLastValidatorPower(ctx, valAddr, lv.Power); err != nil { + panic(err) + } + validator, found := k.GetValidator(ctx, valAddr) if !found { @@ -67,10 +72,14 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) (res } for _, finalizedL1Sequence := range data.FinalizedL1Sequences { - k.RecordFinalizedL1Sequence(ctx, finalizedL1Sequence) + if err := k.RecordFinalizedL1Sequence(ctx, finalizedL1Sequence); err != nil { + panic(err) + } } - k.SetNextL2Sequence(ctx, data.NextL2Sequence) + if err := k.SetNextL2Sequence(ctx, data.NextL2Sequence); err != nil { + panic(err) + } return res } diff --git a/x/opchild/keeper/historical_info.go b/x/opchild/keeper/historical_info.go index a1b398bf..7c11a369 100644 --- a/x/opchild/keeper/historical_info.go +++ b/x/opchild/keeper/historical_info.go @@ -55,7 +55,9 @@ func (k Keeper) TrackHistoricalInfo(ctx context.Context) error { if err != nil { return err } else if found { - k.DeleteHistoricalInfo(ctx, i) + if err := k.DeleteHistoricalInfo(ctx, i); err != nil { + return err + } } else { break } diff --git a/x/opchild/keeper/msg_server.go b/x/opchild/keeper/msg_server.go index 1824db80..d40e0e89 100644 --- a/x/opchild/keeper/msg_server.go +++ b/x/opchild/keeper/msg_server.go @@ -188,7 +188,9 @@ func (ms MsgServer) AddValidator(ctx context.Context, req *types.MsgAddValidator return nil, err } - ms.SetValidator(ctx, validator) + if err := ms.SetValidator(ctx, validator); err != nil { + return nil, err + } if err = ms.SetValidatorByConsAddr(ctx, validator); err != nil { return nil, err } @@ -227,7 +229,9 @@ func (ms MsgServer) RemoveValidator(ctx context.Context, req *types.MsgRemoveVal // set validator consensus power `0`, // then `val_state_change` will execute `k.RemoveValidator`. - ms.Keeper.SetValidator(ctx, val) + if err := ms.Keeper.SetValidator(ctx, val); err != nil { + return nil, err + } sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -323,7 +327,9 @@ func (ms MsgServer) FinalizeTokenDeposit(ctx context.Context, req *types.MsgFina return nil, err } - ms.RecordFinalizedL1Sequence(ctx, req.Sequence) + if err := ms.RecordFinalizedL1Sequence(ctx, req.Sequence); err != nil { + return nil, err + } event := sdk.NewEvent( types.EventTypeFinalizeTokenDeposit, diff --git a/x/opchild/keeper/val_state_change.go b/x/opchild/keeper/val_state_change.go index 49d07865..0b3b47a1 100644 --- a/x/opchild/keeper/val_state_change.go +++ b/x/opchild/keeper/val_state_change.go @@ -57,7 +57,9 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) ([]abci.V if !found || oldPower != newPower { updates = append(updates, validator.ABCIValidatorUpdate()) - k.SetLastValidatorPower(ctx, valAddr, newPower) + if err := k.SetLastValidatorPower(ctx, valAddr, newPower); err != nil { + return nil, err + } } delete(last, validator.GetOperator()) @@ -75,8 +77,14 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) ([]abci.V return nil, err } - k.RemoveValidator(ctx, valAddr) - k.DeleteLastValidatorPower(ctx, valAddr) + if err := k.RemoveValidator(ctx, valAddr); err != nil { + return nil, err + } + + if err := k.DeleteLastValidatorPower(ctx, valAddr); err != nil { + return nil, err + } + updates = append(updates, validator.ABCIValidatorUpdateZero()) } @@ -91,12 +99,12 @@ type validatorsByAddr map[string]int64 func (k Keeper) getLastValidatorsByAddr(ctx context.Context) (validatorsByAddr, error) { last := make(validatorsByAddr) - k.IterateLastValidators(ctx, func(validator types.ValidatorI, power int64) (stop bool, err error) { + err := k.IterateLastValidators(ctx, func(validator types.ValidatorI, power int64) (stop bool, err error) { last[validator.GetOperator()] = power return false, nil }) - return last, nil + return last, err } // given a map of remaining validators to previous bonded power diff --git a/x/opchild/keeper/validator.go b/x/opchild/keeper/validator.go index 9b79f248..57ea496a 100644 --- a/x/opchild/keeper/validator.go +++ b/x/opchild/keeper/validator.go @@ -94,23 +94,23 @@ func (k Keeper) RemoveValidator(ctx context.Context, address sdk.ValAddress) err // get the set of all validators with no limits, used during genesis dump func (k Keeper) GetAllValidators(ctx context.Context) (validators []types.Validator, err error) { - k.Validators.Walk(ctx, nil, func(key []byte, validator types.Validator) (stop bool, err error) { + err = k.Validators.Walk(ctx, nil, func(key []byte, validator types.Validator) (stop bool, err error) { validators = append(validators, validator) return false, nil }) - return validators, nil + return validators, err } // return a given amount of all the validators func (k Keeper) GetValidators(ctx context.Context, maxRetrieve uint32) (validators []types.Validator, err error) { validators = make([]types.Validator, 0, maxRetrieve) - k.Validators.Walk(ctx, nil, func(key []byte, validator types.Validator) (stop bool, err error) { + err = k.Validators.Walk(ctx, nil, func(key []byte, validator types.Validator) (stop bool, err error) { validators = append(validators, validator) return len(validators) == int(maxRetrieve), nil }) - return validators, nil + return validators, err } // Last Validator Index @@ -154,7 +154,7 @@ func (k Keeper) GetLastValidators(ctx context.Context) (validators []types.Valid validators = make([]types.Validator, 0, maxValidators) - k.IterateLastValidatorPowers(ctx, func(operator []byte, power int64) (stop bool, err error) { + err = k.IterateLastValidatorPowers(ctx, func(operator []byte, power int64) (stop bool, err error) { validators = append(validators, k.mustGetValidator(ctx, operator)) // sanity check @@ -165,5 +165,5 @@ func (k Keeper) GetLastValidators(ctx context.Context) (validators []types.Valid return false, nil }) - return validators, nil + return validators, err } diff --git a/x/opchild/types/validator.go b/x/opchild/types/validator.go index ff965267..48e7787d 100644 --- a/x/opchild/types/validator.go +++ b/x/opchild/types/validator.go @@ -6,7 +6,7 @@ import ( "strings" abci "github.com/cometbft/cometbft/abci/types" - tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "sigs.k8s.io/yaml" "cosmossdk.io/core/address" @@ -227,16 +227,16 @@ func (v Validator) ConsPubKey() (cryptotypes.PubKey, error) { return pk, nil } -// TmConsPublicKey casts Validator.ConsensusPubkey to tmprotocrypto.PubKey. -func (v Validator) TmConsPublicKey() (tmprotocrypto.PublicKey, error) { +// TmConsPublicKey casts Validator.ConsensusPubkey to cmtprotocrypto.PubKey. +func (v Validator) TmConsPublicKey() (cmtprotocrypto.PublicKey, error) { pk, err := v.ConsPubKey() if err != nil { - return tmprotocrypto.PublicKey{}, err + return cmtprotocrypto.PublicKey{}, err } - tmPk, err := cryptocodec.ToTmProtoPublicKey(pk) + tmPk, err := cryptocodec.ToCmtProtoPublicKey(pk) if err != nil { - return tmprotocrypto.PublicKey{}, err + return cmtprotocrypto.PublicKey{}, err } return tmPk, nil diff --git a/x/ophost/keeper/genesis.go b/x/ophost/keeper/genesis.go index a5cb3d1f..85cfaf69 100644 --- a/x/ophost/keeper/genesis.go +++ b/x/ophost/keeper/genesis.go @@ -21,7 +21,9 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { panic(err) } - k.SetNextL1Sequence(ctx, bridgeId, bridge.NextL1Sequence) + if err := k.SetNextL1Sequence(ctx, bridgeId, bridge.NextL1Sequence); err != nil { + panic(err) + } for _, proposal := range bridge.Proposals { if err := k.SetOutputProposal(ctx, bridgeId, proposal.OutputIndex, proposal.OutputProposal); err != nil { @@ -29,20 +31,28 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { } } - k.SetNextOutputIndex(ctx, bridgeId, bridge.NextOutputIndex) + if err := k.SetNextOutputIndex(ctx, bridgeId, bridge.NextOutputIndex); err != nil { + panic(err) + } for _, provenWithdrawal := range bridge.ProvenWithdrawals { withdrawalHash := [32]byte{} copy(withdrawalHash[:], provenWithdrawal) - k.RecordProvenWithdrawal(ctx, bridgeId, withdrawalHash) + if err := k.RecordProvenWithdrawal(ctx, bridgeId, withdrawalHash); err != nil { + panic(err) + } } for _, tokenPair := range bridge.TokenPairs { - k.SetTokenPair(ctx, bridgeId, tokenPair.L2Denom, tokenPair.L1Denom) + if err := k.SetTokenPair(ctx, bridgeId, tokenPair.L2Denom, tokenPair.L1Denom); err != nil { + panic(err) + } } } - k.SetNextBridgeId(ctx, data.NextBridgeId) + if err := k.SetNextBridgeId(ctx, data.NextBridgeId); err != nil { + panic(err) + } } // ExportGenesis returns a GenesisState for a given context and keeper. The @@ -51,7 +61,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { var bridges []types.Bridge - k.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) (stop bool, err error) { + err := k.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) (stop bool, err error) { nextL1Sequence, err := k.GetNextL1Sequence(ctx, bridgeId) if err != nil { return true, err @@ -102,6 +112,9 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return false, nil }) + if err != nil { + panic(err) + } nextBridgeId, err := k.GetNextBridgeId(ctx) if err != nil { diff --git a/x/ophost/keeper/msg_server.go b/x/ophost/keeper/msg_server.go index 59cea8b5..c3cee9a1 100644 --- a/x/ophost/keeper/msg_server.go +++ b/x/ophost/keeper/msg_server.go @@ -171,7 +171,9 @@ func (ms MsgServer) DeleteOutput(ctx context.Context, req *types.MsgDeleteOutput } // delete output proposal - ms.DeleteOutputProposal(ctx, bridgeId, outputIndex) + if err := ms.DeleteOutputProposal(ctx, bridgeId, outputIndex); err != nil { + return nil, err + } sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypeDeleteOutput, @@ -211,7 +213,9 @@ func (ms MsgServer) InitiateTokenDeposit(ctx context.Context, req *types.MsgInit if ok, err := ms.HasTokenPair(ctx, bridgeId, l2Denom); err != nil { return nil, err } else if !ok { - ms.SetTokenPair(ctx, bridgeId, l2Denom, coin.Denom) + if err := ms.SetTokenPair(ctx, bridgeId, l2Denom, coin.Denom); err != nil { + return nil, err + } } // emit events for bridge executor @@ -314,7 +318,9 @@ func (ms MsgServer) FinalizeTokenWithdrawal(ctx context.Context, req *types.MsgF return nil, types.ErrFailedToVerifyWithdrawal.Wrap("invalid storage root proofs") } - ms.RecordProvenWithdrawal(ctx, bridgeId, withdrawalHash) + if err := ms.RecordProvenWithdrawal(ctx, bridgeId, withdrawalHash); err != nil { + return nil, err + } } // transfer asset to a user from the bridge account diff --git a/x/ophost/keeper/msg_server_test.go b/x/ophost/keeper/msg_server_test.go index bfa5f2d2..8e389ae7 100644 --- a/x/ophost/keeper/msg_server_test.go +++ b/x/ophost/keeper/msg_server_test.go @@ -225,7 +225,7 @@ func Test_UpdateProposal(t *testing.T) { // current proposer signer msg = types.NewMsgUpdateProposer(addrs[1], 1, addrs[2]) - _, err = ms.UpdateProposer(sdk.WrapSDKContext(ctx), msg) + _, err = ms.UpdateProposer(ctx, msg) require.NoError(t, err) _config, err = ms.GetBridgeConfig(ctx, 1) require.NoError(t, err) @@ -270,7 +270,7 @@ func Test_UpdateChallenger(t *testing.T) { // current challenger msg = types.NewMsgUpdateChallenger(addrs[2], 1, addrs[3]) - _, err = ms.UpdateChallenger(sdk.WrapSDKContext(ctx), msg) + _, err = ms.UpdateChallenger(ctx, msg) require.NoError(t, err) _config, err = ms.GetBridgeConfig(ctx, 1) require.NoError(t, err) diff --git a/x/ophost/keeper/querier_test.go b/x/ophost/keeper/querier_test.go index 4b6ca35b..117b36e0 100644 --- a/x/ophost/keeper/querier_test.go +++ b/x/ophost/keeper/querier_test.go @@ -6,8 +6,6 @@ import ( "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/initia-labs/OPinit/x/ophost/keeper" "github.com/initia-labs/OPinit/x/ophost/types" ) @@ -26,7 +24,7 @@ func Test_QueryBridge(t *testing.T) { require.NoError(t, err) q := keeper.NewQuerier(input.OPHostKeeper) - res, err := q.Bridge(sdk.WrapSDKContext(ctx), &types.QueryBridgeRequest{ + res, err := q.Bridge(ctx, &types.QueryBridgeRequest{ BridgeId: 1, }) @@ -60,7 +58,7 @@ func Test_QueryBridges(t *testing.T) { require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 2, config2)) q := keeper.NewQuerier(input.OPHostKeeper) - res, err := q.Bridges(sdk.WrapSDKContext(ctx), &types.QueryBridgesRequest{}) + res, err := q.Bridges(ctx, &types.QueryBridgesRequest{}) require.NoError(t, err) require.Equal(t, []types.QueryBridgeResponse{ @@ -85,14 +83,14 @@ func Test_QueryTokenPair(t *testing.T) { input.OPHostKeeper.SetTokenPair(ctx, 1, pair.L2Denom, pair.L1Denom) q := keeper.NewQuerier(input.OPHostKeeper) - res, err := q.TokenPairByL1Denom(sdk.WrapSDKContext(ctx), &types.QueryTokenPairByL1DenomRequest{ + res, err := q.TokenPairByL1Denom(ctx, &types.QueryTokenPairByL1DenomRequest{ BridgeId: 1, L1Denom: pair.L1Denom, }) require.NoError(t, err) require.Equal(t, pair, res.TokenPair) - res2, err := q.TokenPairByL2Denom(sdk.WrapSDKContext(ctx), &types.QueryTokenPairByL2DenomRequest{ + res2, err := q.TokenPairByL2Denom(ctx, &types.QueryTokenPairByL2DenomRequest{ BridgeId: 1, L2Denom: pair.L2Denom, }) @@ -114,7 +112,7 @@ func Test_QueryTokenPairs(t *testing.T) { input.OPHostKeeper.SetTokenPair(ctx, 1, pair2.L2Denom, pair2.L1Denom) q := keeper.NewQuerier(input.OPHostKeeper) - res, err := q.TokenPairs(sdk.WrapSDKContext(ctx), &types.QueryTokenPairsRequest{ + res, err := q.TokenPairs(ctx, &types.QueryTokenPairsRequest{ BridgeId: 1, }) @@ -134,7 +132,7 @@ func Test_QueryOutputProposal(t *testing.T) { require.NoError(t, input.OPHostKeeper.SetOutputProposal(ctx, 1, 1, output)) q := keeper.NewQuerier(input.OPHostKeeper) - res, err := q.OutputProposal(sdk.WrapSDKContext(ctx), &types.QueryOutputProposalRequest{ + res, err := q.OutputProposal(ctx, &types.QueryOutputProposalRequest{ BridgeId: 1, OutputIndex: 1, }) @@ -158,7 +156,7 @@ func Test_QueryOutputProposals(t *testing.T) { require.NoError(t, input.OPHostKeeper.SetOutputProposal(ctx, 1, 2, output2)) q := keeper.NewQuerier(input.OPHostKeeper) - res, err := q.OutputProposals(sdk.WrapSDKContext(ctx), &types.QueryOutputProposalsRequest{ + res, err := q.OutputProposals(ctx, &types.QueryOutputProposalsRequest{ BridgeId: 1, }) From 466679d1166fcb1f4eb84c98465c7d3832570b6e Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:18:04 +0900 Subject: [PATCH 06/11] remove redundant validate params --- x/opchild/keeper/params.go | 3 --- x/ophost/keeper/genesis.go | 4 ---- 2 files changed, 7 deletions(-) diff --git a/x/opchild/keeper/params.go b/x/opchild/keeper/params.go index 1f19db69..713e37bb 100644 --- a/x/opchild/keeper/params.go +++ b/x/opchild/keeper/params.go @@ -19,9 +19,6 @@ func (k Keeper) BridgeExecutor(ctx context.Context) (sdk.AccAddress, error) { // SetParams sets the x/opchild module parameters. func (k Keeper) SetParams(ctx context.Context, params types.Params) error { - if err := params.Validate(k.authKeeper.AddressCodec()); err != nil { - return err - } return k.Params.Set(ctx, params) } diff --git a/x/ophost/keeper/genesis.go b/x/ophost/keeper/genesis.go index 85cfaf69..8302a013 100644 --- a/x/ophost/keeper/genesis.go +++ b/x/ophost/keeper/genesis.go @@ -7,10 +7,6 @@ import ( ) func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { - if err := data.Params.Validate(); err != nil { - panic(err) - } - if err := k.SetParams(ctx, data.Params); err != nil { panic(err) } From e6fe984881b0bceec6d5b7fcb903eedc0d247950 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:59:55 +0900 Subject: [PATCH 07/11] receive string instead of address at message instantiate --- x/opchild/client/cli/tx.go | 34 +++++++++- x/opchild/keeper/common_test.go | 16 +++++ x/opchild/keeper/msg_server_test.go | 53 ++++++++++----- x/opchild/types/tx.go | 40 +++++------ x/ophost/client/cli/tx.go | 48 ++++++++++--- x/ophost/keeper/common_test.go | 8 +++ x/ophost/keeper/msg_server_test.go | 100 ++++++++++++++++------------ x/ophost/types/tx.go | 52 +++++++-------- 8 files changed, 234 insertions(+), 117 deletions(-) diff --git a/x/opchild/client/cli/tx.go b/x/opchild/client/cli/tx.go index 02a7e002..0df45b23 100644 --- a/x/opchild/client/cli/tx.go +++ b/x/opchild/client/cli/tx.go @@ -174,7 +174,12 @@ Where proposal.json contains: return err } - msg, err := types.NewMsgExecuteMessages(clientCtx.GetFromAddress(), msgs) + fromAddr, err := ac.BytesToString(clientCtx.GetFromAddress()) + if err != nil { + return err + } + + msg, err := types.NewMsgExecuteMessages(fromAddr, msgs) if err != nil { return fmt.Errorf("invalid message: %w", err) } @@ -194,8 +199,17 @@ Where proposal.json contains: func newBuildWithdrawMsg(clientCtx client.Context, ac address.Codec, txf tx.Factory, fs *flag.FlagSet, to sdk.AccAddress, amount sdk.Coin) (tx.Factory, *types.MsgInitiateTokenWithdrawal, error) { sender := clientCtx.GetFromAddress() + senderAddr, err := ac.BytesToString(sender) + if err != nil { + return txf, nil, err + } + + toAddr, err := ac.BytesToString(to) + if err != nil { + return txf, nil, err + } - msg := types.NewMsgInitiateTokenWithdrawal(sender, to, amount) + msg := types.NewMsgInitiateTokenWithdrawal(senderAddr, toAddr, amount) if err := msg.Validate(ac); err != nil { return txf, nil, err } @@ -207,8 +221,22 @@ func newBuildDepositMsg(clientCtx client.Context, ac address.Codec, txf tx.Facto sequence uint64, from, to sdk.AccAddress, amount sdk.Coin, hookMsg []byte, ) (tx.Factory, *types.MsgFinalizeTokenDeposit, error) { sender := clientCtx.GetFromAddress() + senderAddr, err := ac.BytesToString(sender) + if err != nil { + return txf, nil, err + } + + fromAddr, err := ac.BytesToString(from) + if err != nil { + return txf, nil, err + } + + toAddr, err := ac.BytesToString(to) + if err != nil { + return txf, nil, err + } - msg := types.NewMsgFinalizeTokenDeposit(sender, from, to, amount, sequence, hookMsg) + msg := types.NewMsgFinalizeTokenDeposit(senderAddr, fromAddr, toAddr, amount, sequence, hookMsg) if err := msg.Validate(ac); err != nil { return txf, nil, err } diff --git a/x/opchild/keeper/common_test.go b/x/opchild/keeper/common_test.go index e2064c47..83a69847 100644 --- a/x/opchild/keeper/common_test.go +++ b/x/opchild/keeper/common_test.go @@ -72,6 +72,14 @@ var ( sdk.AccAddress(pubKeys[4].Address()), } + addrsStr = []string{ + addrs[0].String(), + addrs[1].String(), + addrs[2].String(), + addrs[3].String(), + addrs[4].String(), + } + valAddrs = []sdk.ValAddress{ sdk.ValAddress(pubKeys[0].Address()), sdk.ValAddress(pubKeys[1].Address()), @@ -80,6 +88,14 @@ var ( sdk.ValAddress(pubKeys[4].Address()), } + valAddrsStr = []string{ + valAddrs[0].String(), + valAddrs[1].String(), + valAddrs[2].String(), + valAddrs[3].String(), + valAddrs[4].String(), + } + testDenoms = []string{ "test1", "test2", diff --git a/x/opchild/keeper/msg_server_test.go b/x/opchild/keeper/msg_server_test.go index dd265e87..5d3b75cf 100644 --- a/x/opchild/keeper/msg_server_test.go +++ b/x/opchild/keeper/msg_server_test.go @@ -36,13 +36,16 @@ func Test_MsgServer_ExecuteMessages(t *testing.T) { // apply validator updates input.OPChildKeeper.BlockValidatorUpdates(ctx) - addMsg, err := types.NewMsgAddValidator("val2", authtypes.NewModuleAddress(types.ModuleName), valAddrs[1], valPubKeys[1]) + moduleAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) require.NoError(t, err) - removeMsg, err := types.NewMsgRemoveValidator(authtypes.NewModuleAddress(types.ModuleName), valAddrs[0]) + addMsg, err := types.NewMsgAddValidator("val2", moduleAddr, valAddrsStr[1], valPubKeys[1]) require.NoError(t, err) - msg, err := types.NewMsgExecuteMessages(addrs[0], []sdk.Msg{addMsg, removeMsg}) + removeMsg, err := types.NewMsgRemoveValidator(moduleAddr, valAddrsStr[0]) + require.NoError(t, err) + + msg, err := types.NewMsgExecuteMessages(addrsStr[0], []sdk.Msg{addMsg, removeMsg}) require.NoError(t, err) _, err = ms.ExecuteMessages(ctx, msg) @@ -66,28 +69,31 @@ func Test_MsgServer_AddValidator(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPChildKeeper) valPubKeys := testutilsims.CreateTestPubKeys(2) - msg, err := types.NewMsgAddValidator("val1", authtypes.NewModuleAddress(types.ModuleName), valAddrs[0], valPubKeys[0]) + moduleAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) + require.NoError(t, err) + + msg, err := types.NewMsgAddValidator("val1", moduleAddr, valAddrsStr[0], valPubKeys[0]) require.NoError(t, err) _, err = ms.AddValidator(ctx, msg) require.NoError(t, err) // invalid signer - msg, err = types.NewMsgAddValidator("val1", addrs[0], valAddrs[0], valPubKeys[0]) + msg, err = types.NewMsgAddValidator("val1", addrsStr[0], valAddrsStr[0], valPubKeys[0]) require.NoError(t, err) _, err = ms.AddValidator(ctx, msg) require.Error(t, err) // duplicate add validator - msg, err = types.NewMsgAddValidator("val1", authtypes.NewModuleAddress(types.ModuleName), valAddrs[0], valPubKeys[1]) + msg, err = types.NewMsgAddValidator("val1", moduleAddr, valAddrsStr[0], valPubKeys[1]) require.NoError(t, err) _, err = ms.AddValidator(ctx, msg) require.Error(t, err) // duplicate cons pubkey - msg, err = types.NewMsgAddValidator("val1", authtypes.NewModuleAddress(types.ModuleName), valAddrs[1], valPubKeys[0]) + msg, err = types.NewMsgAddValidator("val1", moduleAddr, valAddrsStr[1], valPubKeys[0]) require.NoError(t, err) _, err = ms.AddValidator(ctx, msg) @@ -107,7 +113,7 @@ func Test_MsgServer_RemoveValidator(t *testing.T) { input.OPChildKeeper.SetValidator(ctx, val) // invalid signer - msg, err := types.NewMsgRemoveValidator(addrs[0], valAddrs[0]) + msg, err := types.NewMsgRemoveValidator(addrsStr[0], valAddrsStr[0]) require.NoError(t, err) _, err = ms.RemoveValidator( @@ -116,8 +122,11 @@ func Test_MsgServer_RemoveValidator(t *testing.T) { ) require.Error(t, err) + moduleAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) + require.NoError(t, err) + // remove not existing validator - msg, err = types.NewMsgRemoveValidator(authtypes.NewModuleAddress(types.ModuleName), valAddrs[1]) + msg, err = types.NewMsgRemoveValidator(moduleAddr, valAddrsStr[1]) require.NoError(t, err) _, err = ms.RemoveValidator( @@ -127,7 +136,7 @@ func Test_MsgServer_RemoveValidator(t *testing.T) { require.Error(t, err) // valid remove validator - msg, err = types.NewMsgRemoveValidator(authtypes.NewModuleAddress(types.ModuleName), valAddrs[0]) + msg, err = types.NewMsgRemoveValidator(moduleAddr, valAddrsStr[0]) require.NoError(t, err) _, err = ms.RemoveValidator( @@ -147,7 +156,10 @@ func Test_MsgServer_UpdateParams(t *testing.T) { params.HistoricalEntries = 1 params.BridgeExecutor = addrs[1].String() - msg := types.NewMsgUpdateParams(authtypes.NewModuleAddress(types.ModuleName), ¶ms) + moduleAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) + require.NoError(t, err) + + msg := types.NewMsgUpdateParams(moduleAddr, ¶ms) _, err = ms.UpdateParams(ctx, msg) require.NoError(t, err) _params, err := ms.GetParams(ctx) @@ -155,7 +167,10 @@ func Test_MsgServer_UpdateParams(t *testing.T) { require.Equal(t, params, _params) // invalid signer - msg = types.NewMsgUpdateParams(authtypes.NewModuleAddress("gov"), ¶ms) + govAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov")) + require.NoError(t, err) + + msg = types.NewMsgUpdateParams(govAddr, ¶ms) require.NoError(t, err) _, err = ms.UpdateParams( @@ -199,10 +214,12 @@ func Test_MsgServer_Withdraw(t *testing.T) { // fund asset account := input.Faucet.NewFundedAccount(ctx, sdk.NewCoin(denom, math.NewInt(1_000_000_000))) + accountAddr, err := input.AccountKeeper.AddressCodec().BytesToString(account) + require.NoError(t, err) // valid - msg := types.NewMsgInitiateTokenWithdrawal(account, addrs[1], sdk.NewCoin(denom, math.NewInt(100))) - _, err := ms.InitiateTokenWithdrawal(ctx, msg) + msg := types.NewMsgInitiateTokenWithdrawal(accountAddr, addrsStr[1], sdk.NewCoin(denom, math.NewInt(100))) + _, err = ms.InitiateTokenWithdrawal(ctx, msg) require.NoError(t, err) } @@ -218,7 +235,7 @@ func Test_MsgServer_Deposit_NoHook(t *testing.T) { denom := "l2/" + hex.EncodeToString(bz[:]) // unauthorized deposit - msg := types.NewMsgFinalizeTokenDeposit(addrs[1], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, nil) + msg := types.NewMsgFinalizeTokenDeposit(addrsStr[1], addrsStr[1], addrsStr[1], sdk.NewCoin(denom, math.NewInt(100)), 1, nil) _, err := ms.FinalizeTokenDeposit(ctx, msg) require.Error(t, err) @@ -226,7 +243,7 @@ func Test_MsgServer_Deposit_NoHook(t *testing.T) { require.Equal(t, math.ZeroInt(), beforeBalance.Amount) // valid deposit - msg = types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, nil) + msg = types.NewMsgFinalizeTokenDeposit(addrsStr[0], addrsStr[1], addrsStr[1], sdk.NewCoin(denom, math.NewInt(100)), 1, nil) _, err = ms.FinalizeTokenDeposit(ctx, msg) require.NoError(t, err) @@ -250,7 +267,7 @@ func Test_MsgServer_Deposit_HookSuccess(t *testing.T) { input.BridgeHook.err = nil // valid deposit - msg := types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, hookMsgBytes) + msg := types.NewMsgFinalizeTokenDeposit(addrsStr[0], addrsStr[1], addrsStr[1], sdk.NewCoin(denom, math.NewInt(100)), 1, hookMsgBytes) _, err = ms.FinalizeTokenDeposit(ctx, msg) require.NoError(t, err) require.Equal(t, hookMsgBytes, input.BridgeHook.msgBytes) @@ -276,7 +293,7 @@ func Test_MsgServer_Deposit_HookFail(t *testing.T) { input.BridgeHook.err = errors.New("should be failed") // valid deposit - msg := types.NewMsgFinalizeTokenDeposit(addrs[0], addrs[1], addrs[1], sdk.NewCoin(denom, math.NewInt(100)), 1, []byte("invalid_message")) + msg := types.NewMsgFinalizeTokenDeposit(addrsStr[0], addrsStr[1], addrsStr[1], sdk.NewCoin(denom, math.NewInt(100)), 1, []byte("invalid_message")) _, err := ms.FinalizeTokenDeposit(ctx, msg) require.NoError(t, err) require.Empty(t, input.BridgeHook.msgBytes) diff --git a/x/opchild/types/tx.go b/x/opchild/types/tx.go index 2e56b712..510e0ead 100644 --- a/x/opchild/types/tx.go +++ b/x/opchild/types/tx.go @@ -45,11 +45,11 @@ const MAX_TOKEN_SYMBOL_LENGTH = 128 // NewMsgExecuteMessages creates a new MsgExecuteMessages instance. func NewMsgExecuteMessages( - sender sdk.AccAddress, //nolint:interfacer + sender string, messages []sdk.Msg, ) (*MsgExecuteMessages, error) { msg := &MsgExecuteMessages{ - Sender: sender.String(), + Sender: sender, } anys, err := sdktx.SetMsgs(messages) @@ -90,8 +90,8 @@ func (m MsgExecuteMessages) UnpackInterfaces(unpacker codectypes.AnyUnpacker) er // NewMsgAddValidator creates a new MsgAddValidator instance. // Delegator address and validator address are the same. func NewMsgAddValidator( - moniker string, authority sdk.AccAddress, - valAddr sdk.ValAddress, pubKey cryptotypes.PubKey, //nolint:interfacer + moniker string, authority string, + valAddr string, pubKey cryptotypes.PubKey, ) (*MsgAddValidator, error) { var pkAny *codectypes.Any if pubKey != nil { @@ -102,8 +102,8 @@ func NewMsgAddValidator( } return &MsgAddValidator{ Moniker: moniker, - Authority: authority.String(), - ValidatorAddress: valAddr.String(), + Authority: authority, + ValidatorAddress: valAddr, Pubkey: pkAny, }, nil } @@ -137,12 +137,12 @@ func (msg MsgAddValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err // NewMsgRemoveValidator creates a new MsgRemoveValidator instance. func NewMsgRemoveValidator( - authority sdk.AccAddress, - valAddr sdk.ValAddress, //nolint:interfacer + authority string, + valAddr string, ) (*MsgRemoveValidator, error) { return &MsgRemoveValidator{ - Authority: authority.String(), - ValidatorAddress: valAddr.String(), + Authority: authority, + ValidatorAddress: valAddr, }, nil } @@ -163,13 +163,13 @@ func (msg MsgRemoveValidator) Validate(ac, vc address.Codec) error { // NewMsgInitiateTokenWithdrawal creates a new MsgInitiateTokenWithdrawal instance. func NewMsgInitiateTokenWithdrawal( - sender sdk.AccAddress, - to sdk.AccAddress, + sender string, + to string, amount sdk.Coin, ) *MsgInitiateTokenWithdrawal { return &MsgInitiateTokenWithdrawal{ - Sender: sender.String(), - To: to.String(), + Sender: sender, + To: to, Amount: amount, } } @@ -195,15 +195,15 @@ func (msg MsgInitiateTokenWithdrawal) Validate(ac address.Codec) error { // NewMsgFinalizeTokenDeposit creates a new MsgFinalizeTokenDeposit instance. func NewMsgFinalizeTokenDeposit( - sender, from, to sdk.AccAddress, + sender, from, to string, amount sdk.Coin, sequence uint64, data []byte, ) *MsgFinalizeTokenDeposit { return &MsgFinalizeTokenDeposit{ - Sender: sender.String(), - From: from.String(), - To: to.String(), + Sender: sender, + From: from, + To: to, Amount: amount, Sequence: sequence, Data: data, @@ -238,9 +238,9 @@ func (msg MsgFinalizeTokenDeposit) Validate(ac address.Codec) error { /* MsgUpdateParams */ // NewMsgUpdateParams returns a new MsgUpdateParams instance -func NewMsgUpdateParams(authority sdk.AccAddress, params *Params) *MsgUpdateParams { +func NewMsgUpdateParams(authority string, params *Params) *MsgUpdateParams { return &MsgUpdateParams{ - Authority: authority.String(), + Authority: authority, Params: params, } } diff --git a/x/ophost/client/cli/tx.go b/x/ophost/client/cli/tx.go index 0ea9f452..6c51d022 100644 --- a/x/ophost/client/cli/tx.go +++ b/x/ophost/client/cli/tx.go @@ -65,7 +65,12 @@ func NewRecordBatchCmd(ac address.Codec) *cobra.Command { return err } - msg := types.NewMsgRecordBatch(clientCtx.GetFromAddress(), bridgeId, batchBytes) + fromAddr, err := ac.BytesToString(clientCtx.GetFromAddress()) + if err != nil { + return err + } + + msg := types.NewMsgRecordBatch(fromAddr, bridgeId, batchBytes) if err = msg.Validate(ac); err != nil { return err } @@ -147,7 +152,12 @@ func NewCreateBridge(ac address.Codec) *cobra.Command { return err } - msg := types.NewMsgCreateBridge(clientCtx.GetFromAddress(), config) + fromAddr, err := ac.BytesToString(clientCtx.GetFromAddress()) + if err != nil { + return err + } + + msg := types.NewMsgCreateBridge(fromAddr, config) if err = msg.Validate(ac); err != nil { return err } @@ -188,7 +198,12 @@ func NewProposeOutput(ac address.Codec) *cobra.Command { return err } - msg := types.NewMsgProposeOutput(clientCtx.GetFromAddress(), bridgeId, l2BlockNumber, outputBytes) + fromAddr, err := ac.BytesToString(clientCtx.GetFromAddress()) + if err != nil { + return err + } + + msg := types.NewMsgProposeOutput(fromAddr, bridgeId, l2BlockNumber, outputBytes) if err = msg.Validate(ac); err != nil { return err } @@ -224,7 +239,12 @@ func NewDeleteOutput(ac address.Codec) *cobra.Command { return err } - msg := types.NewMsgDeleteOutput(clientCtx.GetFromAddress(), bridgeId, outputIndex) + fromAddr, err := ac.BytesToString(clientCtx.GetFromAddress()) + if err != nil { + return err + } + + msg := types.NewMsgDeleteOutput(fromAddr, bridgeId, outputIndex) if err = msg.Validate(ac); err != nil { return err } @@ -255,7 +275,8 @@ func NewInitiateTokenDeposit(ac address.Codec) *cobra.Command { return err } - to, err := ac.StringToBytes(args[1]) + toAddr := args[1] + _, err = ac.StringToBytes(toAddr) if err != nil { return err } @@ -270,7 +291,12 @@ func NewInitiateTokenDeposit(ac address.Codec) *cobra.Command { return err } - msg := types.NewMsgInitiateTokenDeposit(clientCtx.GetFromAddress(), bridgeId, to, amount, data) + fromAddr, err := ac.BytesToString(clientCtx.GetFromAddress()) + if err != nil { + return err + } + + msg := types.NewMsgInitiateTokenDeposit(fromAddr, bridgeId, toAddr, amount, data) if err = msg.Validate(ac); err != nil { return err } @@ -335,7 +361,8 @@ func NewFinalizeTokenWithdrawal(ac address.Codec) *cobra.Command { } } - receiver, err := ac.StringToBytes(withdrawalInfo.Receiver) + receiver := withdrawalInfo.Receiver + _, err = ac.StringToBytes(receiver) if err != nil { return err } @@ -365,12 +392,17 @@ func NewFinalizeTokenWithdrawal(ac address.Codec) *cobra.Command { return err } + fromAddr, err := ac.BytesToString(clientCtx.GetFromAddress()) + if err != nil { + return err + } + msg := types.NewMsgFinalizeTokenWithdrawal( withdrawalInfo.BridgeId, withdrawalInfo.OutputIndex, withdrawalInfo.Sequence, withdrawalProofs, - clientCtx.GetFromAddress(), + fromAddr, receiver, amount, version, diff --git a/x/ophost/keeper/common_test.go b/x/ophost/keeper/common_test.go index 936fd0f3..8ec9143e 100644 --- a/x/ophost/keeper/common_test.go +++ b/x/ophost/keeper/common_test.go @@ -73,6 +73,14 @@ var ( sdk.AccAddress(pubKeys[4].Address()), } + addrsStr = []string{ + addrs[0].String(), + addrs[1].String(), + addrs[2].String(), + addrs[3].String(), + addrs[4].String(), + } + testDenoms = []string{ "test1", "test2", diff --git a/x/ophost/keeper/msg_server_test.go b/x/ophost/keeper/msg_server_test.go index 8e389ae7..7c0d6477 100644 --- a/x/ophost/keeper/msg_server_test.go +++ b/x/ophost/keeper/msg_server_test.go @@ -18,7 +18,7 @@ func Test_RecordBatch(t *testing.T) { ctx, input := createDefaultTestInput(t) ms := keeper.NewMsgServerImpl(input.OPHostKeeper) - _, err := ms.RecordBatch(ctx, types.NewMsgRecordBatch(addrs[0], 1, []byte{1, 2, 3})) + _, err := ms.RecordBatch(ctx, types.NewMsgRecordBatch(addrsStr[0], 1, []byte{1, 2, 3})) require.NoError(t, err) } @@ -27,14 +27,14 @@ func Test_CreateBridge(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) config := types.BridgeConfig{ - Challenger: addrs[0].String(), - Proposer: addrs[0].String(), + Challenger: addrsStr[0], + Proposer: addrsStr[0], SubmissionInterval: time.Second * 10, FinalizationPeriod: time.Second * 60, SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - res, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) + res, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrsStr[0], config)) require.NoError(t, err) require.Equal(t, uint64(1), res.BridgeId) @@ -48,14 +48,14 @@ func Test_ProposeOutput(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) config := types.BridgeConfig{ - Challenger: addrs[0].String(), - Proposer: addrs[0].String(), + Challenger: addrsStr[0], + Proposer: addrsStr[0], SubmissionInterval: time.Second * 10, FinalizationPeriod: time.Second * 60, SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - createRes, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) + createRes, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrsStr[0], config)) require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) @@ -63,11 +63,11 @@ func Test_ProposeOutput(t *testing.T) { ctx = ctx.WithBlockTime(blockTime) // unauthorized - _, err = ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[1], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) + _, err = ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrsStr[1], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) require.Error(t, err) // valid - proposeRes, err := ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) + proposeRes, err := ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrsStr[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) require.NoError(t, err) require.Equal(t, uint64(1), proposeRes.OutputIndex) @@ -85,14 +85,14 @@ func Test_DeleteOutput(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) config := types.BridgeConfig{ - Proposer: addrs[0].String(), - Challenger: addrs[1].String(), + Proposer: addrsStr[0], + Challenger: addrsStr[1], SubmissionInterval: time.Second * 10, FinalizationPeriod: time.Second * 60, SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - createReq := types.NewMsgCreateBridge(addrs[0], config) + createReq := types.NewMsgCreateBridge(addrsStr[0], config) createRes, err := ms.CreateBridge(ctx, createReq) require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) @@ -100,16 +100,16 @@ func Test_DeleteOutput(t *testing.T) { blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) - proposeRes, err := ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) + proposeRes, err := ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrsStr[0], 1, 100, []byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})) require.NoError(t, err) require.Equal(t, uint64(1), proposeRes.OutputIndex) // unauthorized - _, err = ms.DeleteOutput(ctx, types.NewMsgDeleteOutput(addrs[0], 1, 1)) + _, err = ms.DeleteOutput(ctx, types.NewMsgDeleteOutput(addrsStr[0], 1, 1)) require.Error(t, err) // valid - _, err = ms.DeleteOutput(ctx, types.NewMsgDeleteOutput(addrs[1], 1, 1)) + _, err = ms.DeleteOutput(ctx, types.NewMsgDeleteOutput(addrsStr[1], 1, 1)) require.NoError(t, err) // should return error; deleted @@ -122,14 +122,14 @@ func Test_InitiateTokenDeposit(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) config := types.BridgeConfig{ - Proposer: addrs[0].String(), - Challenger: addrs[1].String(), + Proposer: addrsStr[0], + Challenger: addrsStr[1], SubmissionInterval: time.Second * 10, FinalizationPeriod: time.Second * 60, SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - createRes, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) + createRes, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrsStr[0], config)) require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) @@ -137,7 +137,7 @@ func Test_InitiateTokenDeposit(t *testing.T) { input.Faucet.Fund(ctx, addrs[1], amount) _, err = ms.InitiateTokenDeposit( ctx, - types.NewMsgInitiateTokenDeposit(addrs[1], 1, addrs[2], amount, []byte("messages")), + types.NewMsgInitiateTokenDeposit(addrsStr[1], 1, addrsStr[2], amount, []byte("messages")), ) require.NoError(t, err) require.True(t, input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).IsZero()) @@ -149,14 +149,14 @@ func Test_FinalizeTokenWithdrawal(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) config := types.BridgeConfig{ - Proposer: addrs[0].String(), - Challenger: addrs[1].String(), + Proposer: addrsStr[0], + Challenger: addrsStr[1], SubmissionInterval: time.Second * 10, FinalizationPeriod: time.Second * 60, SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) + _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrsStr[0], config)) require.NoError(t, err) // fund amount @@ -176,14 +176,18 @@ func Test_FinalizeTokenWithdrawal(t *testing.T) { now := time.Now().UTC() ctx = ctx.WithBlockTime(now) - _, err = ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrs[0], 1, 100, outputRoot)) + _, err = ms.ProposeOutput(ctx, types.NewMsgProposeOutput(addrsStr[0], 1, 100, outputRoot)) require.NoError(t, err) ctx = ctx.WithBlockTime(now.Add(time.Second * 60)) + addr04, err := input.AccountKeeper.AddressCodec().BytesToString(decodeHex(t, "0000000000000000000000000000000000000004")) + require.NoError(t, err) + addr01, err := input.AccountKeeper.AddressCodec().BytesToString(decodeHex(t, "0000000000000000000000000000000000000001")) + require.NoError(t, err) _, err = ms.FinalizeTokenWithdrawal(ctx, types.NewMsgFinalizeTokenWithdrawal( 1, 1, 4, proofs, - decodeHex(t, "0000000000000000000000000000000000000004"), - decodeHex(t, "0000000000000000000000000000000000000001"), + addr04, + addr01, amount, version, stateRoot, storageRoot, blockHash, )) @@ -203,28 +207,30 @@ func Test_UpdateProposal(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) config := types.BridgeConfig{ - Proposer: addrs[0].String(), - Challenger: addrs[1].String(), + Proposer: addrsStr[0], + Challenger: addrsStr[1], SubmissionInterval: time.Second * 10, FinalizationPeriod: time.Second * 60, SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) + _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrsStr[0], config)) require.NoError(t, err) // gov signer - msg := types.NewMsgUpdateProposer(authtypes.NewModuleAddress("gov"), 1, addrs[1]) + govAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov")) + require.NoError(t, err) + msg := types.NewMsgUpdateProposer(govAddr, 1, addrsStr[1]) _, err = ms.UpdateProposer(ctx, msg) require.NoError(t, err) _config, err := ms.GetBridgeConfig(ctx, 1) require.NoError(t, err) - require.Equal(t, addrs[1].String(), _config.Proposer) - require.Equal(t, addrs[1].String(), input.BridgeHook.proposer) + require.Equal(t, addrsStr[1], _config.Proposer) + require.Equal(t, addrsStr[1], input.BridgeHook.proposer) // current proposer signer - msg = types.NewMsgUpdateProposer(addrs[1], 1, addrs[2]) + msg = types.NewMsgUpdateProposer(addrsStr[1], 1, addrsStr[2]) _, err = ms.UpdateProposer(ctx, msg) require.NoError(t, err) _config, err = ms.GetBridgeConfig(ctx, 1) @@ -233,7 +239,9 @@ func Test_UpdateProposal(t *testing.T) { require.Equal(t, addrs[2].String(), input.BridgeHook.proposer) // invalid signer - msg = types.NewMsgUpdateProposer(authtypes.NewModuleAddress(types.ModuleName), 1, addrs[1]) + invalidAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) + require.NoError(t, err) + msg = types.NewMsgUpdateProposer(invalidAddr, 1, addrsStr[1]) require.NoError(t, err) _, err = ms.UpdateProposer( @@ -248,19 +256,21 @@ func Test_UpdateChallenger(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPHostKeeper) config := types.BridgeConfig{ - Proposer: addrs[0].String(), - Challenger: addrs[1].String(), + Proposer: addrsStr[0], + Challenger: addrsStr[1], SubmissionInterval: time.Second * 10, FinalizationPeriod: time.Second * 60, SubmissionStartTime: time.Now().UTC(), Metadata: []byte{1, 2, 3}, } - _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrs[0], config)) + _, err := ms.CreateBridge(ctx, types.NewMsgCreateBridge(addrsStr[0], config)) require.NoError(t, err) // gov signer - msg := types.NewMsgUpdateChallenger(authtypes.NewModuleAddress("gov"), 1, addrs[2]) + govAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov")) + require.NoError(t, err) + msg := types.NewMsgUpdateChallenger(govAddr, 1, addrsStr[2]) _, err = ms.UpdateChallenger(ctx, msg) require.NoError(t, err) _config, err := ms.GetBridgeConfig(ctx, 1) @@ -269,7 +279,7 @@ func Test_UpdateChallenger(t *testing.T) { require.Equal(t, addrs[2].String(), input.BridgeHook.challenger) // current challenger - msg = types.NewMsgUpdateChallenger(addrs[2], 1, addrs[3]) + msg = types.NewMsgUpdateChallenger(addrsStr[2], 1, addrsStr[3]) _, err = ms.UpdateChallenger(ctx, msg) require.NoError(t, err) _config, err = ms.GetBridgeConfig(ctx, 1) @@ -278,7 +288,9 @@ func Test_UpdateChallenger(t *testing.T) { require.Equal(t, addrs[3].String(), input.BridgeHook.challenger) // invalid signer - msg = types.NewMsgUpdateChallenger(authtypes.NewModuleAddress(types.ModuleName), 1, addrs[1]) + invalidAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) + require.NoError(t, err) + msg = types.NewMsgUpdateChallenger(invalidAddr, 1, addrsStr[1]) require.NoError(t, err) _, err = ms.UpdateChallenger( @@ -295,13 +307,17 @@ func Test_MsgServer_UpdateParams(t *testing.T) { params := ms.GetParams(ctx) params.RegistrationFee = sdk.NewCoins(sdk.NewCoin("foo", math.NewInt(100))) - msg := types.NewMsgUpdateParams(authtypes.NewModuleAddress("gov"), ¶ms) - _, err := ms.UpdateParams(ctx, msg) + govAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov")) + require.NoError(t, err) + msg := types.NewMsgUpdateParams(govAddr, ¶ms) + _, err = ms.UpdateParams(ctx, msg) require.NoError(t, err) require.Equal(t, params, ms.GetParams(ctx)) // invalid signer - msg = types.NewMsgUpdateParams(authtypes.NewModuleAddress(types.ModuleName), ¶ms) + invalidAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) + require.NoError(t, err) + msg = types.NewMsgUpdateParams(invalidAddr, ¶ms) require.NoError(t, err) _, err = ms.UpdateParams( diff --git a/x/ophost/types/tx.go b/x/ophost/types/tx.go index 2d369225..52d155fd 100644 --- a/x/ophost/types/tx.go +++ b/x/ophost/types/tx.go @@ -34,12 +34,12 @@ var ( // NewMsgRecordBatch creates a new MsgRecordBatch instance. func NewMsgRecordBatch( - submitter sdk.AccAddress, + submitter string, bridgeId uint64, batchBytes []byte, ) *MsgRecordBatch { return &MsgRecordBatch{ - Submitter: submitter.String(), + Submitter: submitter, BridgeId: bridgeId, BatchBytes: batchBytes, } @@ -62,11 +62,11 @@ func (msg MsgRecordBatch) Validate(accAddressCodec address.Codec) error { // NewMsgCreateBridge creates a new MsgCreateBridge instance. func NewMsgCreateBridge( - creator sdk.AccAddress, + creator string, config BridgeConfig, ) *MsgCreateBridge { return &MsgCreateBridge{ - Creator: creator.String(), + Creator: creator, Config: config, } } @@ -89,13 +89,13 @@ func (msg MsgCreateBridge) Validate(ac address.Codec) error { // NewMsgProposeOutput creates a new MsgProposeOutput instance. // Delegator address and validator address are the same. func NewMsgProposeOutput( - proposer sdk.AccAddress, + proposer string, bridgeId uint64, l2BlockNumber uint64, outputRoot []byte, ) *MsgProposeOutput { return &MsgProposeOutput{ - Proposer: proposer.String(), + Proposer: proposer, BridgeId: bridgeId, L2BlockNumber: l2BlockNumber, OutputRoot: outputRoot, @@ -124,12 +124,12 @@ func (msg MsgProposeOutput) Validate(accAddressCodec address.Codec) error { // NewMsgDeleteOutput creates a new MsgDeleteOutput instance. func NewMsgDeleteOutput( - challenger sdk.AccAddress, + challenger string, bridgeId uint64, outputIndex uint64, ) *MsgDeleteOutput { return &MsgDeleteOutput{ - Challenger: challenger.String(), + Challenger: challenger, BridgeId: bridgeId, OutputIndex: outputIndex, } @@ -156,15 +156,15 @@ func (msg MsgDeleteOutput) Validate(accAddressCodec address.Codec) error { // NewMsgInitiateTokenDeposit creates a new MsgInitiateTokenDeposit instance. func NewMsgInitiateTokenDeposit( - sender sdk.AccAddress, + sender string, bridgeId uint64, - to sdk.AccAddress, + to string, amount sdk.Coin, data []byte, ) *MsgInitiateTokenDeposit { return &MsgInitiateTokenDeposit{ - Sender: sender.String(), - To: to.String(), + Sender: sender, + To: to, Amount: amount, BridgeId: bridgeId, Data: data, @@ -200,8 +200,8 @@ func NewMsgFinalizeTokenWithdrawal( outputIndex uint64, sequence uint64, withdrawalProofs [][]byte, - sender sdk.AccAddress, - receiver sdk.AccAddress, + sender string, + receiver string, amount sdk.Coin, version []byte, stateRoot []byte, @@ -212,8 +212,8 @@ func NewMsgFinalizeTokenWithdrawal( BridgeId: bridgeId, OutputIndex: outputIndex, WithdrawalProofs: withdrawalProofs, - Sender: sender.String(), - Receiver: receiver.String(), + Sender: sender, + Receiver: receiver, Sequence: sequence, Amount: amount, Version: version, @@ -278,14 +278,14 @@ func (msg MsgFinalizeTokenWithdrawal) Validate(accAddressCodec address.Codec) er // NewMsgUpdateProposer creates a new MsgUpdateProposer instance. func NewMsgUpdateProposer( - authority sdk.AccAddress, + authority string, bridgeId uint64, - newProposer sdk.AccAddress, + newProposer string, ) *MsgUpdateProposer { return &MsgUpdateProposer{ - Authority: authority.String(), + Authority: authority, BridgeId: bridgeId, - NewProposer: newProposer.String(), + NewProposer: newProposer, } } @@ -310,14 +310,14 @@ func (msg MsgUpdateProposer) Validate(accAddressCodec address.Codec) error { // NewMsgUpdateChallenger creates a new MsgUpdateChallenger instance. func NewMsgUpdateChallenger( - authority sdk.AccAddress, + authority string, bridgeId uint64, - newChallenger sdk.AccAddress, + newChallenger string, ) *MsgUpdateChallenger { return &MsgUpdateChallenger{ - Authority: authority.String(), + Authority: authority, BridgeId: bridgeId, - NewChallenger: newChallenger.String(), + NewChallenger: newChallenger, } } @@ -341,9 +341,9 @@ func (msg MsgUpdateChallenger) Validate(accAddressCodec address.Codec) error { /* MsgUpdateParams */ // NewMsgUpdateParams returns a new MsgUpdateParams instance -func NewMsgUpdateParams(authority sdk.AccAddress, params *Params) *MsgUpdateParams { +func NewMsgUpdateParams(authority string, params *Params) *MsgUpdateParams { return &MsgUpdateParams{ - Authority: authority.String(), + Authority: authority, Params: params, } } From 633225c39604b9bc9074c700119baf6a6feef021 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:48:51 +0900 Subject: [PATCH 08/11] clear key naming --- x/opchild/keeper/keeper.go | 2 +- x/opchild/types/keys.go | 20 ++++++++------------ x/ophost/types/keys.go | 20 ++++++++------------ 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/x/opchild/keeper/keeper.go b/x/opchild/keeper/keeper.go index 7acc9832..15795e5d 100644 --- a/x/opchild/keeper/keeper.go +++ b/x/opchild/keeper/keeper.go @@ -80,7 +80,7 @@ func NewKeeper( consensusAddressCodec: consensusAddressCodec, NextL2Sequence: collections.NewItem(sb, types.NextL2SequenceKey, "next_l2_sequence", collections.Uint64Value), Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), - FinalizedL1Sequence: collections.NewMap(sb, types.FinalizedL1SequenceKey, "finalized_l1_sequence", collections.Uint64Key, collections.BoolValue), + FinalizedL1Sequence: collections.NewMap(sb, types.FinalizedL1SequencePrefix, "finalized_l1_sequence", collections.Uint64Key, collections.BoolValue), LastValidatorPowers: collections.NewMap(sb, types.LastValidatorPowerPrefix, "last_validator_powers", collections.BytesKey, collections.Int64Value), Validators: collections.NewMap(sb, types.ValidatorsPrefix, "validators", collections.BytesKey, codec.CollValue[types.Validator](cdc)), ValidatorsByConsAddr: collections.NewMap(sb, types.ValidatorsByConsAddrPrefix, "validators_by_cons_addr", collections.BytesKey, collections.BytesValue), diff --git a/x/opchild/types/keys.go b/x/opchild/types/keys.go index 3dfbe415..aedc5257 100644 --- a/x/opchild/types/keys.go +++ b/x/opchild/types/keys.go @@ -14,16 +14,12 @@ const ( var ( // Keys for store prefixes - // Last* values are constant during a block. - LastValidatorPowerPrefix = []byte{0x11} // prefix for each key to a validator index, for bonded validators - - ValidatorsPrefix = []byte{0x21} // prefix for each key to a validator - ValidatorsByConsAddrPrefix = []byte{0x22} // prefix for each key to a validator index, by pubkey - - HistoricalInfoPrefix = []byte{0x31} // prefix for the historical info - - ParamsKey = []byte{0x41} // prefix for parameters for module x/opchild - - NextL2SequenceKey = []byte{0x51} // key for the outbound sequence number - FinalizedL1SequenceKey = []byte{0x62} // prefix for finalized deposit sequences + ParamsKey = []byte{0x11} // prefix for parameters for module x/opchild + NextL2SequenceKey = []byte{0x12} // key for the outbound sequence number + + LastValidatorPowerPrefix = []byte{0x21} // prefix for each key to a validator index, for bonded validators + ValidatorsPrefix = []byte{0x31} // prefix for each key to a validator + ValidatorsByConsAddrPrefix = []byte{0x41} // prefix for each key to a validator index, by pubkey + FinalizedL1SequencePrefix = []byte{0x51} // prefix for finalized deposit sequences + HistoricalInfoPrefix = []byte{0x61} // prefix for the historical info ) diff --git a/x/ophost/types/keys.go b/x/ophost/types/keys.go index 9fc9a87c..ebd736ad 100644 --- a/x/ophost/types/keys.go +++ b/x/ophost/types/keys.go @@ -15,16 +15,12 @@ var ( // Keys for store prefixes NextBridgeIdKey = []byte{0x11} - - BridgeConfigPrefix = []byte{0x21} - NextL1SequencePrefix = []byte{0x22} - - TokenPairPrefix = []byte{0x31} - - OutputProposalPrefix = []byte{0x41} - NextOutputIndexPrefix = []byte{0x42} - - ProvenWithdrawalPrefix = []byte{0x51} - - ParamsKey = []byte{0x61} + ParamsKey = []byte{0x12} + + BridgeConfigPrefix = []byte{0x21} + NextL1SequencePrefix = []byte{0x31} + TokenPairPrefix = []byte{0x41} + OutputProposalPrefix = []byte{0x51} + NextOutputIndexPrefix = []byte{0x61} + ProvenWithdrawalPrefix = []byte{0x71} ) From 6740833f5354bcda5ed4b61541b624410bdcfe22 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Wed, 27 Dec 2023 12:38:48 +0900 Subject: [PATCH 09/11] use sequence --- x/opchild/keeper/keeper.go | 4 ++-- x/opchild/keeper/sequences.go | 23 +++++++++++++---------- x/opchild/types/genesis.go | 8 +++++++- x/ophost/keeper/bridge.go | 25 ++++++++++++++----------- x/ophost/keeper/keeper.go | 4 ++-- x/ophost/types/genesis.go | 11 ++++++++--- 6 files changed, 46 insertions(+), 29 deletions(-) diff --git a/x/opchild/keeper/keeper.go b/x/opchild/keeper/keeper.go index 15795e5d..0800d7d7 100644 --- a/x/opchild/keeper/keeper.go +++ b/x/opchild/keeper/keeper.go @@ -36,7 +36,7 @@ type Keeper struct { consensusAddressCodec address.Codec Schema collections.Schema - NextL2Sequence collections.Item[uint64] + NextL2Sequence collections.Sequence Params collections.Item[types.Params] FinalizedL1Sequence collections.Map[uint64, bool] LastValidatorPowers collections.Map[[]byte, int64] @@ -78,7 +78,7 @@ func NewKeeper( authority: authority, validatorAddressCodec: validatorAddressCodec, consensusAddressCodec: consensusAddressCodec, - NextL2Sequence: collections.NewItem(sb, types.NextL2SequenceKey, "next_l2_sequence", collections.Uint64Value), + NextL2Sequence: collections.NewSequence(sb, types.NextL2SequenceKey, "next_l2_sequence"), Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), FinalizedL1Sequence: collections.NewMap(sb, types.FinalizedL1SequencePrefix, "finalized_l1_sequence", collections.Uint64Key, collections.BoolValue), LastValidatorPowers: collections.NewMap(sb, types.LastValidatorPowerPrefix, "last_validator_powers", collections.BytesKey, collections.Int64Value), diff --git a/x/opchild/keeper/sequences.go b/x/opchild/keeper/sequences.go index 163abaef..91b11111 100644 --- a/x/opchild/keeper/sequences.go +++ b/x/opchild/keeper/sequences.go @@ -2,9 +2,9 @@ package keeper import ( "context" - "errors" "cosmossdk.io/collections" + "github.com/initia-labs/OPinit/x/opchild/types" ) func (k Keeper) RecordFinalizedL1Sequence(ctx context.Context, l1Sequence uint64) error { @@ -26,27 +26,30 @@ func (k Keeper) SetNextL2Sequence(ctx context.Context, l2Sequence uint64) error } func (k Keeper) GetNextL2Sequence(ctx context.Context) (uint64, error) { - nextL2Sequence, err := k.NextL2Sequence.Get(ctx) + nextL2Sequence, err := k.NextL2Sequence.Peek(ctx) if err != nil { - if errors.Is(err, collections.ErrNotFound) { - return 1, nil - } - return 0, err } + if nextL2Sequence == collections.DefaultSequenceStart { + return types.DefaultL2SequenceStart, nil + } + return nextL2Sequence, nil } func (k Keeper) IncreaseNextL2Sequence(ctx context.Context) (uint64, error) { - nextL2Sequence, err := k.GetNextL2Sequence(ctx) + nextL2Sequence, err := k.NextL2Sequence.Next(ctx) if err != nil { return 0, err } - // increase NextL2Sequence - if err = k.NextL2Sequence.Set(ctx, nextL2Sequence+1); err != nil { - return 0, err + if nextL2Sequence == collections.DefaultSequenceStart { + if err := k.NextL2Sequence.Set(ctx, types.DefaultL2SequenceStart+1); err != nil { + return 0, err + } + + return types.DefaultL2SequenceStart, nil } return nextL2Sequence, nil diff --git a/x/opchild/types/genesis.go b/x/opchild/types/genesis.go index 011efc41..e60192fa 100644 --- a/x/opchild/types/genesis.go +++ b/x/opchild/types/genesis.go @@ -9,6 +9,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) +const DefaultL2SequenceStart = 1 + // NewGenesisState creates a new GenesisState instance func NewGenesisState(params Params, validators []Validator) *GenesisState { return &GenesisState{ @@ -26,7 +28,7 @@ func DefaultGenesisState() *GenesisState { LastValidatorPowers: []LastValidatorPower{}, Validators: []Validator{}, Exported: false, - NextL2Sequence: 1, + NextL2Sequence: DefaultL2SequenceStart, FinalizedL1Sequences: []uint64{}, } } @@ -38,6 +40,10 @@ func ValidateGenesis(data *GenesisState, ac address.Codec) error { return err } + if data.NextL2Sequence < DefaultL2SequenceStart { + return ErrInvalidSequence + } + return data.Params.Validate(ac) } diff --git a/x/ophost/keeper/bridge.go b/x/ophost/keeper/bridge.go index 8498139f..3ac7061c 100644 --- a/x/ophost/keeper/bridge.go +++ b/x/ophost/keeper/bridge.go @@ -45,7 +45,7 @@ func (k Keeper) GetNextL1Sequence(ctx context.Context, bridgeId uint64) (uint64, nextSequence, err := k.NextL1Sequences.Get(ctx, bridgeId) if err != nil { if errors.Is(err, collections.ErrNotFound) { - nextSequence = 1 + nextSequence = types.DefaultL1SequenceStart } else { return 0, err } @@ -76,27 +76,30 @@ func (k Keeper) SetNextBridgeId(ctx context.Context, nextBridgeId uint64) error } func (k Keeper) GetNextBridgeId(ctx context.Context) (uint64, error) { - nextBridgeId, err := k.NextBridgeId.Get(ctx) + nextBridgeId, err := k.NextBridgeId.Peek(ctx) if err != nil { - if errors.Is(err, collections.ErrNotFound) { - nextBridgeId = 1 - } else { - return 0, err - } + return 0, err + } + + if nextBridgeId == collections.DefaultSequenceStart { + return types.DefaultBridgeIdStart, nil } return nextBridgeId, nil } func (k Keeper) IncreaseNextBridgeId(ctx context.Context) (uint64, error) { - nextBridgeId, err := k.GetNextBridgeId(ctx) + nextBridgeId, err := k.NextBridgeId.Next(ctx) if err != nil { return 0, err } - // increase NextBridgeId - if err := k.NextBridgeId.Set(ctx, nextBridgeId+1); err != nil { - return 0, err + if nextBridgeId == collections.DefaultSequenceStart { + if err := k.NextBridgeId.Set(ctx, types.DefaultBridgeIdStart+1); err != nil { + return 0, err + } + + return types.DefaultBridgeIdStart, nil } return nextBridgeId, nil diff --git a/x/ophost/keeper/keeper.go b/x/ophost/keeper/keeper.go index 67b14936..ad9dcc3b 100644 --- a/x/ophost/keeper/keeper.go +++ b/x/ophost/keeper/keeper.go @@ -26,7 +26,7 @@ type Keeper struct { authority string Schema collections.Schema - NextBridgeId collections.Item[uint64] + NextBridgeId collections.Sequence Params collections.Item[types.Params] BridgeConfigs collections.Map[uint64, types.BridgeConfig] NextL1Sequences collections.Map[uint64, uint64] @@ -58,7 +58,7 @@ func NewKeeper( bankKeeper: bk, bridgeHook: bridgeHook, authority: authority, - NextBridgeId: collections.NewItem(sb, types.NextBridgeIdKey, "next_bridge_id", collections.Uint64Value), + NextBridgeId: collections.NewSequence(sb, types.NextBridgeIdKey, "next_bridge_id"), Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), BridgeConfigs: collections.NewMap(sb, types.BridgeConfigPrefix, "bridge_configs", collections.Uint64Key, codec.CollValue[types.BridgeConfig](cdc)), NextL1Sequences: collections.NewMap(sb, types.NextL1SequencePrefix, "next_l1_sequences", collections.Uint64Key, collections.Uint64Value), diff --git a/x/ophost/types/genesis.go b/x/ophost/types/genesis.go index 1dad4228..8ff159e1 100644 --- a/x/ophost/types/genesis.go +++ b/x/ophost/types/genesis.go @@ -5,6 +5,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +const ( + DefaultBridgeIdStart = 1 + DefaultL1SequenceStart = 1 +) + // NewGenesisState creates a new GenesisState instance func NewGenesisState(params Params, bridges []Bridge, nextBridgeId uint64) *GenesisState { return &GenesisState{ @@ -19,7 +24,7 @@ func DefaultGenesisState() *GenesisState { return &GenesisState{ Params: DefaultParams(), Bridges: []Bridge{}, - NextBridgeId: 1, + NextBridgeId: DefaultBridgeIdStart, } } @@ -35,7 +40,7 @@ func ValidateGenesis(data *GenesisState, ac address.Codec) error { return ErrInvalidBridgeId } - if bridge.NextL1Sequence == 0 { + if bridge.NextL1Sequence < DefaultL1SequenceStart { return ErrInvalidSequence } @@ -65,7 +70,7 @@ func ValidateGenesis(data *GenesisState, ac address.Codec) error { } } - if data.NextBridgeId == 0 { + if data.NextBridgeId < DefaultBridgeIdStart { return ErrInvalidBridgeId } From f63e6d88dd7cbd65dc0002d05475ace3deca2c6c Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:38:19 +0900 Subject: [PATCH 10/11] use sdk.DefaultBondDenom for testing --- x/opchild/ante/fee_test.go | 34 ++++++++++++++--------------- x/opchild/keeper/common_test.go | 4 +--- x/opchild/keeper/msg_server_test.go | 6 ++--- x/ophost/keeper/common_test.go | 4 +--- x/ophost/keeper/msg_server_test.go | 6 ++--- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/x/opchild/ante/fee_test.go b/x/opchild/ante/fee_test.go index 74190ae9..e03a395b 100644 --- a/x/opchild/ante/fee_test.go +++ b/x/opchild/ante/fee_test.go @@ -11,8 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx/signing" ) -var baseDenom = sdk.DefaultBondDenom - type TestAnteKeeper struct { minGasPrices sdk.DecCoins } @@ -27,7 +25,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // set price 0.5 base == 1 quote fc := ante.NewMempoolFeeChecker(TestAnteKeeper{ - minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyZeroDec())), + minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyZeroDec())), }) // keys and addresses @@ -36,7 +34,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // msg and signatures // gas price 0.0005 msg := testdata.NewTestMsg(addr1) - feeAmount := sdk.NewCoins(sdk.NewCoin(baseDenom, math.NewInt(100))) + feeAmount := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) gasLimit := uint64(200_000) suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) @@ -48,7 +46,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { suite.Require().NoError(err) // Set high gas price so standard test fee fails - basePrice := sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000))) + basePrice := sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000))) highGasPrice := []sdk.DecCoin{basePrice} suite.ctx = suite.ctx.WithMinGasPrices(highGasPrice) @@ -70,7 +68,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { suite.ctx = suite.ctx.WithIsCheckTx(true) // gas price = 0.0005 - basePrice = sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDecWithPrec(5, 4)) + basePrice = sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecWithPrec(5, 4)) lowGasPrice := []sdk.DecCoin{basePrice} suite.ctx = suite.ctx.WithMinGasPrices(lowGasPrice) @@ -79,7 +77,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // set high base_min_gas_price to test should be failed fc = ante.NewMempoolFeeChecker(TestAnteKeeper{ - minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000)))), + minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000)))), }) suite.txBuilder.SetFeeAmount(feeAmount) @@ -88,33 +86,33 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { } func (suite *AnteTestSuite) TestCombinedMinGasPrices() { - minGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100))) - configMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100))) + minGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100))) + configMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100))) combined := ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(100))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(100))) - configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(150))) + configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(150))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(150))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(150))) - minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200))) + minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(200))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(200))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(200))) - configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test", math.LegacyNewDec(100))) + configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test", math.LegacyNewDec(100))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 2) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(200))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(200))) suite.Require().True(combined.AmountOf("test").Equal(math.LegacyNewDec(100))) - minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test2", math.LegacyNewDec(300))) + minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test2", math.LegacyNewDec(300))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 3) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(100))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(100))) suite.Require().True(combined.AmountOf("test").Equal(math.LegacyNewDec(100))) suite.Require().True(combined.AmountOf("test2").Equal(math.LegacyNewDec(300))) } diff --git a/x/opchild/keeper/common_test.go b/x/opchild/keeper/common_test.go index 83a69847..aedf2e50 100644 --- a/x/opchild/keeper/common_test.go +++ b/x/opchild/keeper/common_test.go @@ -47,8 +47,6 @@ import ( opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" ) -const baseDenom = "umin" - var ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, bank.AppModuleBasic{}, @@ -145,7 +143,7 @@ func MakeEncodingConfig(_ testing.TB) EncodingConfig { } func initialTotalSupply() sdk.Coins { - faucetBalance := sdk.NewCoins(sdk.NewCoin(baseDenom, initiaSupply)) + faucetBalance := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initiaSupply)) for _, testDenom := range testDenoms { faucetBalance = faucetBalance.Add(sdk.NewCoin(testDenom, initiaSupply)) } diff --git a/x/opchild/keeper/msg_server_test.go b/x/opchild/keeper/msg_server_test.go index 5d3b75cf..f597a8c0 100644 --- a/x/opchild/keeper/msg_server_test.go +++ b/x/opchild/keeper/msg_server_test.go @@ -185,10 +185,10 @@ func Test_MsgServer_SpendFeePool(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPChildKeeper) // fund fee pool - collectedFees := sdk.NewCoins(sdk.NewCoin(baseDenom, math.NewInt(100))) + collectedFees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) input.Faucet.Fund(ctx, authtypes.NewModuleAddress(authtypes.FeeCollectorName), collectedFees...) - beforeAmount := input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).Amount + beforeAmount := input.BankKeeper.GetBalance(ctx, addrs[1], sdk.DefaultBondDenom).Amount msg := types.NewMsgSpendFeePool( authtypes.NewModuleAddress(types.ModuleName), @@ -198,7 +198,7 @@ func Test_MsgServer_SpendFeePool(t *testing.T) { _, err := ms.SpendFeePool(ctx, msg) require.NoError(t, err) - afterAmount := input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).Amount + afterAmount := input.BankKeeper.GetBalance(ctx, addrs[1], sdk.DefaultBondDenom).Amount require.Equal(t, beforeAmount.Add(math.NewInt(100)), afterAmount) } diff --git a/x/ophost/keeper/common_test.go b/x/ophost/keeper/common_test.go index 8ec9143e..b011c6b6 100644 --- a/x/ophost/keeper/common_test.go +++ b/x/ophost/keeper/common_test.go @@ -48,8 +48,6 @@ import ( ophosttypes "github.com/initia-labs/OPinit/x/ophost/types" ) -const baseDenom = "umin" - var ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, bank.AppModuleBasic{}, @@ -130,7 +128,7 @@ func MakeEncodingConfig(_ testing.TB) EncodingConfig { } func initialTotalSupply() sdk.Coins { - faucetBalance := sdk.NewCoins(sdk.NewCoin(baseDenom, initiaSupply)) + faucetBalance := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initiaSupply)) for _, testDenom := range testDenoms { faucetBalance = faucetBalance.Add(sdk.NewCoin(testDenom, initiaSupply)) } diff --git a/x/ophost/keeper/msg_server_test.go b/x/ophost/keeper/msg_server_test.go index 7c0d6477..d2a1b85b 100644 --- a/x/ophost/keeper/msg_server_test.go +++ b/x/ophost/keeper/msg_server_test.go @@ -133,15 +133,15 @@ func Test_InitiateTokenDeposit(t *testing.T) { require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) - amount := sdk.NewCoin(baseDenom, math.NewInt(100)) + amount := sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100)) input.Faucet.Fund(ctx, addrs[1], amount) _, err = ms.InitiateTokenDeposit( ctx, types.NewMsgInitiateTokenDeposit(addrsStr[1], 1, addrsStr[2], amount, []byte("messages")), ) require.NoError(t, err) - require.True(t, input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).IsZero()) - require.Equal(t, amount, input.BankKeeper.GetBalance(ctx, types.BridgeAddress(1), baseDenom)) + require.True(t, input.BankKeeper.GetBalance(ctx, addrs[1], sdk.DefaultBondDenom).IsZero()) + require.Equal(t, amount, input.BankKeeper.GetBalance(ctx, types.BridgeAddress(1), sdk.DefaultBondDenom)) } func Test_FinalizeTokenWithdrawal(t *testing.T) { From 7154a69a110178900c3a5e559460c5e25c3f1d03 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:55:09 +0900 Subject: [PATCH 11/11] use accountKeeper.NewAccount --- x/opchild/types/expected_keepers.go | 1 + x/ophost/keeper/msg_server.go | 4 ++-- x/ophost/types/expected_keeper.go | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/x/opchild/types/expected_keepers.go b/x/opchild/types/expected_keepers.go index 2a5ef8ab..945850e1 100644 --- a/x/opchild/types/expected_keepers.go +++ b/x/opchild/types/expected_keepers.go @@ -13,6 +13,7 @@ type AccountKeeper interface { NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool)) + NewAccount(ctx context.Context, acc sdk.AccountI) sdk.AccountI GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation HasAccount(ctx context.Context, addr sdk.AccAddress) bool SetAccount(ctx context.Context, acc sdk.AccountI) diff --git a/x/ophost/keeper/msg_server.go b/x/ophost/keeper/msg_server.go index c3cee9a1..9c240a93 100644 --- a/x/ophost/keeper/msg_server.go +++ b/x/ophost/keeper/msg_server.go @@ -66,8 +66,8 @@ func (ms MsgServer) CreateBridge(ctx context.Context, req *types.MsgCreateBridge // create bridge account bridgeAcc := types.NewBridgeAccountWithAddress(types.BridgeAddress(bridgeId)) - bridgeAcc.AccountNumber = ms.authKeeper.NextAccountNumber(ctx) - ms.authKeeper.SetAccount(ctx, bridgeAcc) + bridgeAccI := (ms.authKeeper.NewAccount(ctx, bridgeAcc)) // set the account number + ms.authKeeper.SetAccount(ctx, bridgeAccI) sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypeCreateBridge, diff --git a/x/ophost/types/expected_keeper.go b/x/ophost/types/expected_keeper.go index b6886b05..afe344a5 100644 --- a/x/ophost/types/expected_keeper.go +++ b/x/ophost/types/expected_keeper.go @@ -14,6 +14,7 @@ type AccountKeeper interface { NextAccountNumber(ctx context.Context) uint64 IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool)) + NewAccount(ctx context.Context, acc sdk.AccountI) sdk.AccountI GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI HasAccount(ctx context.Context, addr sdk.AccAddress) bool SetAccount(ctx context.Context, acc sdk.AccountI)