From dde7485ee9ac5ae222f02c04cfb4c183a8c857fc Mon Sep 17 00:00:00 2001 From: Solovyov1796 Date: Wed, 24 Apr 2024 15:10:22 +0800 Subject: [PATCH] migrate code and fix go mod --- Makefile | 45 +- app/_sim_test.go | 18 +- app/_simulate_tx_test.go | 2 +- app/ante/ante_test.go | 6 +- app/ante/authorized_test.go | 4 +- app/ante/authz_test.go | 4 +- app/ante/eip712_test.go | 14 +- app/ante/min_gas_filter_test.go | 4 +- app/ante/vesting_test.go | 4 +- app/app.go | 40 +- app/encoding.go | 2 +- app/test_common.go | 2 +- chaincfg/coin.go | 22 + chaincfg/config.go | 15 + chaincfg/denoms.go | 28 + chaincfg/homedir.go | 25 + chaincfg/prefix.go | 44 + cli_test/test_helpers.go | 2 +- client/grpc/README.md | 4 +- client/grpc/client.go | 4 +- client/grpc/client_test.go | 2 +- client/grpc/query/query.go | 30 +- client/grpc/query/query_test.go | 2 +- client/grpc/util/util.go | 6 +- client/rest/rest_test.go | 2 +- cmd/{kava/cmd => 0gchaind}/app.go | 6 +- .../cmd => 0gchaind}/assert-invariants.go | 6 +- cmd/{kava/cmd => 0gchaind}/genaccounts.go | 2 +- cmd/{kava/cmd => 0gchaind}/keys.go | 2 +- cmd/{kava/cmd => 0gchaind}/query.go | 4 +- cmd/{kava/cmd => 0gchaind}/root.go | 38 +- cmd/{kava/cmd => 0gchaind}/shard.go | 4 +- cmd/{kava/cmd => 0gchaind}/status.go | 2 +- cmd/{kava/cmd => 0gchaind}/tx.go | 4 +- cmd/kava/main.go | 25 - cmd/main.go | 28 + cmd/{kava => }/opendb/metrics.go | 0 cmd/{kava => }/opendb/opendb.go | 0 cmd/{kava => }/opendb/opendb_rocksdb.go | 0 cmd/{kava => }/opendb/opendb_rocksdb_test.go | 0 cmd/{kava => }/opendb/props_loader.go | 0 cmd/{kava => }/opendb/props_loader_test.go | 0 cmd/{kava => }/opendb/stat_parser.go | 0 cmd/{kava => }/opendb/stat_parser_test.go | 0 cmd/{kava => }/opendb/stats_loader.go | 0 cmd/{kava => }/opendb/stats_loader_test.go | 0 cmd/{kava/cmd => }/rocksdb/compact.go | 2 +- cmd/{kava/cmd => }/rocksdb/rocksdb.go | 0 cmd/{kava/cmd => }/rocksdb/rocksdb_dummy.go | 0 crypto/vrf/algorithm.go | 58 + crypto/vrf/keys.pb.go | 496 ++++++ crypto/vrf/vrf.go | 194 +++ crypto/vrf/vrf_test.go | 96 ++ go.mod | 6 +- go.sum | 2 + helper/da/client/client.go | 61 + helper/da/client/pool.go | 101 ++ helper/da/go.mod | 26 + helper/da/go.sum | 60 + helper/da/light/light.pb.go | 397 +++++ helper/da/light/light_grpc.pb.go | 141 ++ helper/da/main.go | 89 + helper/da/proto/light.proto | 33 + helper/da/service/handler.go | 186 +++ helper/da/types/dasreq.go | 8 + helper/da/types/keys.go | 10 + helper/da/utils/sizedw8grp/sizedw8grp.go | 51 + tests/e2e/e2e_community_update_params_test.go | 2 +- tests/e2e/e2e_convert_cosmos_coins_test.go | 6 +- tests/e2e/e2e_evm_contracts_test.go | 10 +- tests/e2e/e2e_grpc_client_query_test.go | 2 +- tests/e2e/e2e_min_fees_test.go | 4 +- tests/e2e/e2e_test.go | 6 +- tests/e2e/runner/live.go | 2 +- tests/e2e/testutil/account.go | 4 +- tests/e2e/testutil/chain.go | 10 +- tests/e2e/testutil/config.go | 4 +- tests/e2e/testutil/init_evm.go | 8 +- tests/e2e/testutil/suite.go | 10 +- tests/util/addresses_test.go | 4 +- tests/util/sdksigner.go | 2 +- x/committee/v1/client/cli/query.go | 87 + x/committee/v1/client/cli/tx.go | 196 +++ x/committee/v1/genesis.go | 56 + x/committee/v1/keeper/abci.go | 72 + x/committee/v1/keeper/grpc_query.go | 35 + x/committee/v1/keeper/keeper.go | 323 ++++ x/committee/v1/keeper/msg_server.go | 51 + x/committee/v1/keeper/params.go | 29 + x/committee/v1/module.go | 171 ++ x/committee/v1/types/codec.go | 52 + x/committee/v1/types/council.go | 21 + x/committee/v1/types/epoch.go | 3 + x/committee/v1/types/errors.go | 19 + x/committee/v1/types/events.go | 19 + x/committee/v1/types/genesis.go | 42 + x/committee/v1/types/genesis.pb.go | 1467 +++++++++++++++++ x/committee/v1/types/interfaces.go | 23 + x/committee/v1/types/keys.go | 52 + x/committee/v1/types/msg.go | 65 + x/committee/v1/types/query.pb.go | 839 ++++++++++ x/committee/v1/types/query.pb.gw.go | 218 +++ x/committee/v1/types/tx.pb.go | 975 +++++++++++ x/das/v1/client/cli/query.go | 57 + x/das/v1/client/cli/tx.go | 103 ++ x/das/v1/genesis.go | 39 + x/das/v1/keeper/grpc_query.go | 22 + x/das/v1/keeper/keeper.go | 198 +++ x/das/v1/keeper/msg_server.go | 49 + x/das/v1/module.go | 169 ++ x/das/v1/types/codec.go | 47 + x/das/v1/types/errors.go | 8 + x/das/v1/types/events.go | 11 + x/das/v1/types/genesis.go | 28 + x/das/v1/types/genesis.pb.go | 1191 +++++++++++++ x/das/v1/types/interfaces.go | 10 + x/das/v1/types/keys.go | 44 + x/das/v1/types/msg.go | 57 + x/das/v1/types/query.pb.go | 511 ++++++ x/das/v1/types/query.pb.gw.go | 153 ++ x/das/v1/types/tx.pb.go | 1110 +++++++++++++ x/evmutil/client/cli/address.go | 2 +- x/evmutil/client/cli/query.go | 2 +- x/evmutil/client/cli/tx.go | 2 +- x/evmutil/genesis.go | 4 +- x/evmutil/genesis_test.go | 14 +- x/evmutil/keeper/bank_keeper.go | 2 +- x/evmutil/keeper/bank_keeper_test.go | 6 +- x/evmutil/keeper/conversion_cosmos_native.go | 2 +- .../keeper/conversion_cosmos_native_test.go | 6 +- x/evmutil/keeper/conversion_evm_native.go | 2 +- .../keeper/conversion_evm_native_bep3.go | 2 +- .../keeper/conversion_evm_native_bep3_test.go | 4 +- .../keeper/conversion_evm_native_test.go | 4 +- x/evmutil/keeper/erc20.go | 2 +- x/evmutil/keeper/erc20_test.go | 6 +- x/evmutil/keeper/evm.go | 2 +- x/evmutil/keeper/evm_test.go | 2 +- x/evmutil/keeper/grpc_query.go | 2 +- x/evmutil/keeper/grpc_query_test.go | 8 +- x/evmutil/keeper/invariants.go | 2 +- x/evmutil/keeper/invariants_test.go | 8 +- x/evmutil/keeper/keeper.go | 2 +- x/evmutil/keeper/keeper_test.go | 4 +- x/evmutil/keeper/migrations.go | 2 +- x/evmutil/keeper/msg_server.go | 4 +- x/evmutil/keeper/msg_server_bep3_test.go | 28 +- x/evmutil/keeper/msg_server_test.go | 16 +- x/evmutil/keeper/params.go | 4 +- x/evmutil/keeper/params_test.go | 10 +- x/evmutil/migrations/v2/store.go | 2 +- x/evmutil/migrations/v2/store_test.go | 4 +- x/evmutil/module.go | 6 +- x/evmutil/testutil/suite.go | 6 +- x/evmutil/types/address_test.go | 4 +- x/evmutil/types/bytes_test.go | 2 +- x/evmutil/types/conversion_pair.go | 20 +- x/evmutil/types/conversion_pair.pb.go | 92 +- x/evmutil/types/conversion_pairs_test.go | 14 +- x/evmutil/types/genesis.pb.go | 88 +- x/evmutil/types/genesis_test.go | 4 +- x/evmutil/types/keys_test.go | 2 +- x/evmutil/types/msg.go | 10 +- x/evmutil/types/msg_test.go | 14 +- x/evmutil/types/params_test.go | 6 +- x/evmutil/types/query.pb.go | 109 +- x/evmutil/types/query.pb.gw.go | 6 +- x/evmutil/types/tx.pb.go | 179 +- x/validator-vesting/client/cli/query.go | 2 +- x/validator-vesting/client/rest/query.go | 4 +- x/validator-vesting/keeper/grpc_query.go | 2 +- x/validator-vesting/keeper/grpc_query_test.go | 6 +- x/validator-vesting/module.go | 6 +- x/validator-vesting/types/query.pb.go | 182 +- x/validator-vesting/types/query.pb.gw.go | 16 +- 175 files changed, 11447 insertions(+), 658 deletions(-) create mode 100644 chaincfg/coin.go create mode 100644 chaincfg/config.go create mode 100644 chaincfg/denoms.go create mode 100644 chaincfg/homedir.go create mode 100644 chaincfg/prefix.go rename cmd/{kava/cmd => 0gchaind}/app.go (98%) rename cmd/{kava/cmd => 0gchaind}/assert-invariants.go (95%) rename cmd/{kava/cmd => 0gchaind}/genaccounts.go (99%) rename cmd/{kava/cmd => 0gchaind}/keys.go (99%) rename cmd/{kava/cmd => 0gchaind}/query.go (94%) rename cmd/{kava/cmd => 0gchaind}/root.go (81%) rename cmd/{kava/cmd => 0gchaind}/shard.go (99%) rename cmd/{kava/cmd => 0gchaind}/status.go (99%) rename cmd/{kava/cmd => 0gchaind}/tx.go (94%) delete mode 100644 cmd/kava/main.go create mode 100644 cmd/main.go rename cmd/{kava => }/opendb/metrics.go (100%) rename cmd/{kava => }/opendb/opendb.go (100%) rename cmd/{kava => }/opendb/opendb_rocksdb.go (100%) rename cmd/{kava => }/opendb/opendb_rocksdb_test.go (100%) rename cmd/{kava => }/opendb/props_loader.go (100%) rename cmd/{kava => }/opendb/props_loader_test.go (100%) rename cmd/{kava => }/opendb/stat_parser.go (100%) rename cmd/{kava => }/opendb/stat_parser_test.go (100%) rename cmd/{kava => }/opendb/stats_loader.go (100%) rename cmd/{kava => }/opendb/stats_loader_test.go (100%) rename cmd/{kava/cmd => }/rocksdb/compact.go (99%) rename cmd/{kava/cmd => }/rocksdb/rocksdb.go (100%) rename cmd/{kava/cmd => }/rocksdb/rocksdb_dummy.go (100%) create mode 100644 crypto/vrf/algorithm.go create mode 100644 crypto/vrf/keys.pb.go create mode 100644 crypto/vrf/vrf.go create mode 100644 crypto/vrf/vrf_test.go create mode 100644 helper/da/client/client.go create mode 100644 helper/da/client/pool.go create mode 100644 helper/da/go.mod create mode 100644 helper/da/go.sum create mode 100644 helper/da/light/light.pb.go create mode 100644 helper/da/light/light_grpc.pb.go create mode 100644 helper/da/main.go create mode 100644 helper/da/proto/light.proto create mode 100644 helper/da/service/handler.go create mode 100644 helper/da/types/dasreq.go create mode 100644 helper/da/types/keys.go create mode 100644 helper/da/utils/sizedw8grp/sizedw8grp.go create mode 100644 x/committee/v1/client/cli/query.go create mode 100644 x/committee/v1/client/cli/tx.go create mode 100644 x/committee/v1/genesis.go create mode 100644 x/committee/v1/keeper/abci.go create mode 100644 x/committee/v1/keeper/grpc_query.go create mode 100644 x/committee/v1/keeper/keeper.go create mode 100644 x/committee/v1/keeper/msg_server.go create mode 100644 x/committee/v1/keeper/params.go create mode 100644 x/committee/v1/module.go create mode 100644 x/committee/v1/types/codec.go create mode 100644 x/committee/v1/types/council.go create mode 100644 x/committee/v1/types/epoch.go create mode 100644 x/committee/v1/types/errors.go create mode 100644 x/committee/v1/types/events.go create mode 100644 x/committee/v1/types/genesis.go create mode 100644 x/committee/v1/types/genesis.pb.go create mode 100644 x/committee/v1/types/interfaces.go create mode 100644 x/committee/v1/types/keys.go create mode 100644 x/committee/v1/types/msg.go create mode 100644 x/committee/v1/types/query.pb.go create mode 100644 x/committee/v1/types/query.pb.gw.go create mode 100644 x/committee/v1/types/tx.pb.go create mode 100644 x/das/v1/client/cli/query.go create mode 100644 x/das/v1/client/cli/tx.go create mode 100644 x/das/v1/genesis.go create mode 100644 x/das/v1/keeper/grpc_query.go create mode 100644 x/das/v1/keeper/keeper.go create mode 100644 x/das/v1/keeper/msg_server.go create mode 100644 x/das/v1/module.go create mode 100644 x/das/v1/types/codec.go create mode 100644 x/das/v1/types/errors.go create mode 100644 x/das/v1/types/events.go create mode 100644 x/das/v1/types/genesis.go create mode 100644 x/das/v1/types/genesis.pb.go create mode 100644 x/das/v1/types/interfaces.go create mode 100644 x/das/v1/types/keys.go create mode 100644 x/das/v1/types/msg.go create mode 100644 x/das/v1/types/query.pb.go create mode 100644 x/das/v1/types/query.pb.gw.go create mode 100644 x/das/v1/types/tx.pb.go diff --git a/Makefile b/Makefile index d44d1ea9..64b6ad6f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ ################################################################################ ### Project Info ### ################################################################################ -PROJECT_NAME := kava# unique namespace for project - +PROJECT_NAME := 0g-chain# unique namespace for project +MAIN_ENTRY := ./cmd +BINARY_NAME := 0gchaind +DOCKER_IMAGE_NAME := 0glabs/0g-chain GO_BIN ?= go GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) @@ -37,7 +39,7 @@ print-git-info: .PHONY: print-version print-version: - @echo "kava $(VERSION)\ntendermint $(TENDERMINT_VERSION)\ncosmos $(COSMOS_SDK_VERSION)" + @echo "$(BINARY_NAME) $(VERSION)\ntendermint $(TENDERMINT_VERSION)\ncosmos $(COSMOS_SDK_VERSION)" ################################################################################ ### Project Settings ### @@ -45,7 +47,7 @@ print-version: LEDGER_ENABLED ?= true DOCKER:=docker DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf -HTTPS_GIT := https://github.com/Kava-Labs/kava.git +HTTPS_GIT := https://github.com/0glabs/0g-chain.git ################################################################################ ### Machine Info ### @@ -142,8 +144,8 @@ build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) # process linker flags -ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=kava \ - -X github.com/cosmos/cosmos-sdk/version.AppName=kava \ +ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(PROJECT_NAME) \ + -X github.com/cosmos/cosmos-sdk/version.AppName=$(PROJECT_NAME) \ -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION_NUMBER) \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_COMMIT) \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \ @@ -188,15 +190,15 @@ all: install build: go.sum ifeq ($(OS), Windows_NT) - $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava.exe ./cmd/kava + $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME).exe $(MAIN_ENTRY) else - $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava ./cmd/kava + $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME) $(MAIN_ENTRY) endif build-linux: go.sum LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build -# build on rocksdb-backed kava on macOS with shared libs from brew +# build on rocksdb-backed 0gchaind on macOS with shared libs from brew # this assumes you are on macOS & these deps have been installed with brew: # rocksdb, snappy, lz4, and zstd # use like `make build-rocksdb-brew COSMOS_BUILD_OPTIONS=rocksdb` @@ -205,7 +207,7 @@ build-rocksdb-brew: export CGO_LDFLAGS := -L$(shell brew --prefix rocksdb)/lib -lrocksdb -lstdc++ -lm -lz -L$(shell brew --prefix snappy)/lib -L$(shell brew --prefix lz4)/lib -L$(shell brew --prefix zstd)/lib install: go.sum - $(GO_BIN) install -mod=readonly $(BUILD_FLAGS) ./cmd/kava + $(GO_BIN) install -mod=readonly $(BUILD_FLAGS) $(MAIN_ENTRY) ######################################## ### Tools & dependencies @@ -227,6 +229,7 @@ go.sum: go.mod # Set to exclude riot links as they trigger false positives link-check: @$(GO_BIN) get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3 + # TODO: replace kava in following line with project name liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*" @@ -241,26 +244,26 @@ format: find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs misspell -w find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/tendermint find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/kava-labs/kava + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/0glabs/0g-chain .PHONY: format ############################################################################### ### Localnet ### ############################################################################### -# Build docker image and tag as kava/kava:local +# Build docker image and tag as 0glabs/0g-chain:local docker-build: - DOCKER_BUILDKIT=1 $(DOCKER) build -t kava/kava:local . + DOCKER_BUILDKIT=1 $(DOCKER) build -t $(DOCKER_IMAGE_NAME):local . docker-build-rocksdb: - DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile-rocksdb -t kava/kava:local . + DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile-rocksdb -t $(DOCKER_IMAGE_NAME):local . -build-docker-local-kava: +build-docker-local-0gchain: @$(MAKE) -C networks/local # Run a 4-node testnet locally localnet-start: build-linux localnet-stop - @if ! [ -f build/node0/kvd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/kvd:Z kava/kavanode testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi + @if ! [ -f build/node0/kvd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/kvd:Z $(DOCKER_IMAGE_NAME)-node testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi docker-compose up -d localnet-stop: @@ -269,7 +272,7 @@ localnet-stop: # Launch a new single validator chain start: ./contrib/devnet/init-new-chain.sh - kava start + $(BINARY_NAME) start #proto-format: #@echo "Formatting Protobuf files" @@ -310,7 +313,7 @@ test: @$(GO_BIN) test $$($(GO_BIN) list ./... | grep -v 'contrib' | grep -v 'tests/e2e') test-rocksdb: - @go test -tags=rocksdb ./cmd/kava/opendb + @go test -tags=rocksdb $(MAIN_ENTRY)/opendb # Run cli integration tests # `-p 4` to use 4 cores, `-tags cli_test` to tell $(GO_BIN) not to ignore the cli package @@ -326,15 +329,15 @@ test-migrate: # This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3 start-remote-sims: # build the image used for running sims in, and tag it - docker build -f simulations/Dockerfile -t kava/kava-sim:master . + docker build -f simulations/Dockerfile -t $(DOCKER_IMAGE_NAME)-sim:master . # push that image to the hub - docker push kava/kava-sim:master + docker push $(DOCKER_IMAGE_NAME)-sim:master # submit an array job on AWS Batch, using 1000 seeds, spot instances aws batch submit-job \ -—job-name "master-$(VERSION)" \ -—job-queue “simulation-1-queue-spot" \ -—array-properties size=1000 \ - -—job-definition kava-sim-master \ + -—job-definition $(BINARY_NAME)-sim-master \ -—container-override environment=[{SIM_NAME=master-$(VERSION)}] update-kvtool: diff --git a/app/_sim_test.go b/app/_sim_test.go index 0b75637f..d2b0a473 100644 --- a/app/_sim_test.go +++ b/app/_sim_test.go @@ -32,15 +32,15 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/supply" - "github.com/kava-labs/kava/x/auction" - "github.com/kava-labs/kava/x/bep3" - "github.com/kava-labs/kava/x/cdp" - "github.com/kava-labs/kava/x/committee" - "github.com/kava-labs/kava/x/incentive" - "github.com/kava-labs/kava/x/kavadist" - "github.com/kava-labs/kava/x/pricefeed" - "github.com/kava-labs/kava/x/swap" - validatorvesting "github.com/kava-labs/kava/x/validator-vesting" + "github.com/0glabs/0g-chain/x/auction" + "github.com/0glabs/0g-chain/x/bep3" + "github.com/0glabs/0g-chain/x/cdp" + "github.com/0glabs/0g-chain/x/committee" + "github.com/0glabs/0g-chain/x/incentive" + "github.com/0glabs/0g-chain/x/kavadist" + "github.com/0glabs/0g-chain/x/pricefeed" + "github.com/0glabs/0g-chain/x/swap" + validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting" ) type StoreKeysPrefixes struct { diff --git a/app/_simulate_tx_test.go b/app/_simulate_tx_test.go index a6136020..53bb31bf 100644 --- a/app/_simulate_tx_test.go +++ b/app/_simulate_tx_test.go @@ -9,7 +9,7 @@ import ( "testing" sdkmath "cosmossdk.io/math" - "github.com/kava-labs/kava/app" + "github.com/0glabs/0g-chain/app" abci "github.com/cometbft/cometbft/abci/types" tmbytes "github.com/cometbft/cometbft/libs/bytes" diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index ebe2c4c6..e5641da9 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -20,9 +20,9 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" - "github.com/kava-labs/kava/app" - // bep3types "github.com/kava-labs/kava/x/bep3/types" - // pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types" + "github.com/0glabs/0g-chain/app" + // bep3types "github.com/0glabs/0g-chain/x/bep3/types" + // pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types" ) func TestMain(m *testing.M) { diff --git a/app/ante/authorized_test.go b/app/ante/authorized_test.go index 2cca0a75..d6dcf220 100644 --- a/app/ante/authorized_test.go +++ b/app/ante/authorized_test.go @@ -10,8 +10,8 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/require" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/ante" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/ante" ) var _ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle diff --git a/app/ante/authz_test.go b/app/ante/authz_test.go index 452da4d2..ea98ecfb 100644 --- a/app/ante/authz_test.go +++ b/app/ante/authz_test.go @@ -14,8 +14,8 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/ante" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/ante" ) func newMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a authz.Authorization, expiration time.Time) *authz.MsgGrant { diff --git a/app/ante/eip712_test.go b/app/ante/eip712_test.go index 9b2df617..ec31a488 100644 --- a/app/ante/eip712_test.go +++ b/app/ante/eip712_test.go @@ -33,13 +33,13 @@ import ( feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/app" - // cdptypes "github.com/kava-labs/kava/x/cdp/types" - evmutilkeeper "github.com/kava-labs/kava/x/evmutil/keeper" - evmutiltestutil "github.com/kava-labs/kava/x/evmutil/testutil" - evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" - // hardtypes "github.com/kava-labs/kava/x/hard/types" - // pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types" + "github.com/0glabs/0g-chain/app" + // cdptypes "github.com/0glabs/0g-chain/x/cdp/types" + evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper" + evmutiltestutil "github.com/0glabs/0g-chain/x/evmutil/testutil" + evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" + // hardtypes "github.com/0glabs/0g-chain/x/hard/types" + // pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types" ) const ( diff --git a/app/ante/min_gas_filter_test.go b/app/ante/min_gas_filter_test.go index b8f00df3..037034af 100644 --- a/app/ante/min_gas_filter_test.go +++ b/app/ante/min_gas_filter_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/ante" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/ante" ) func mustParseDecCoins(value string) sdk.DecCoins { diff --git a/app/ante/vesting_test.go b/app/ante/vesting_test.go index f0216655..8dfdae08 100644 --- a/app/ante/vesting_test.go +++ b/app/ante/vesting_test.go @@ -12,8 +12,8 @@ import ( vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/ante" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/ante" ) func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing.T) { diff --git a/app/app.go b/app/app.go index fcfa8615..16b38d70 100644 --- a/app/app.go +++ b/app/app.go @@ -105,16 +105,22 @@ import ( feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" "github.com/gorilla/mux" - "github.com/kava-labs/kava/app/ante" - kavaparams "github.com/kava-labs/kava/app/params" + "github.com/0glabs/0g-chain/app/ante" + kavaparams "github.com/0glabs/0g-chain/app/params" - evmutil "github.com/kava-labs/kava/x/evmutil" - evmutilkeeper "github.com/kava-labs/kava/x/evmutil/keeper" - evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" + evmutil "github.com/0glabs/0g-chain/x/evmutil" + evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper" + evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" - validatorvesting "github.com/kava-labs/kava/x/validator-vesting" - validatorvestingrest "github.com/kava-labs/kava/x/validator-vesting/client/rest" - validatorvestingtypes "github.com/kava-labs/kava/x/validator-vesting/types" + committee "github.com/0glabs/0g-chain/x/committee/v1" + committeekeeper "github.com/0glabs/0g-chain/x/committee/v1/keeper" + committeetypes "github.com/0glabs/0g-chain/x/committee/v1/types" + das "github.com/0glabs/0g-chain/x/das/v1" + daskeeper "github.com/0glabs/0g-chain/x/das/v1/keeper" + dastypes "github.com/0glabs/0g-chain/x/das/v1/types" + validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting" + validatorvestingrest "github.com/0glabs/0g-chain/x/validator-vesting/client/rest" + validatorvestingtypes "github.com/0glabs/0g-chain/x/validator-vesting/types" ) const ( @@ -159,6 +165,8 @@ var ( evmutil.AppModuleBasic{}, mint.AppModuleBasic{}, consensus.AppModuleBasic{}, + committee.AppModuleBasic{}, + das.AppModuleBasic{}, ) // module account permissions @@ -235,6 +243,8 @@ type App struct { transferKeeper ibctransferkeeper.Keeper mintKeeper mintkeeper.Keeper consensusParamsKeeper consensusparamkeeper.Keeper + CommitteeKeeper committeekeeper.Keeper + DasKeeper daskeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -299,6 +309,8 @@ func NewApp( minttypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, + committeetypes.StoreKey, + dastypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -540,6 +552,11 @@ func NewApp( govKeeper.SetLegacyRouter(govRouter) app.govKeeper = *govKeeper + app.CommitteeKeeper = committeekeeper.NewKeeper( + keys[committeetypes.StoreKey], appCodec, app.stakingKeeper, + ) + app.DasKeeper = daskeeper.NewKeeper(keys[dastypes.StoreKey], appCodec, app.stakingKeeper) + // create the module manager (Note: Any module instantiated in the module manager that is later modified // must be passed by reference here.) app.mm = module.NewManager( @@ -599,6 +616,9 @@ func NewApp( evmutiltypes.ModuleName, consensusparamtypes.ModuleName, packetforwardtypes.ModuleName, + + committeetypes.ModuleName, + dastypes.ModuleName, ) // Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list. @@ -628,6 +648,8 @@ func NewApp( minttypes.ModuleName, consensusparamtypes.ModuleName, packetforwardtypes.ModuleName, + committeetypes.ModuleName, + dastypes.ModuleName, ) // Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list @@ -656,6 +678,8 @@ func NewApp( consensusparamtypes.ModuleName, packetforwardtypes.ModuleName, crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules + committeetypes.ModuleName, + dastypes.ModuleName, ) app.mm.RegisterInvariants(&app.crisisKeeper) diff --git a/app/encoding.go b/app/encoding.go index 17445f10..ac95666f 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -3,7 +3,7 @@ package app import ( enccodec "github.com/evmos/ethermint/encoding/codec" - "github.com/kava-labs/kava/app/params" + "github.com/0glabs/0g-chain/app/params" ) // MakeEncodingConfig creates an EncodingConfig and registers the app's types on it. diff --git a/app/test_common.go b/app/test_common.go index 0bc45cce..4853efa8 100644 --- a/app/test_common.go +++ b/app/test_common.go @@ -41,7 +41,7 @@ import ( feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper" "github.com/stretchr/testify/require" - evmutilkeeper "github.com/kava-labs/kava/x/evmutil/keeper" + evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper" ) var ( diff --git a/chaincfg/coin.go b/chaincfg/coin.go new file mode 100644 index 00000000..96a10d2e --- /dev/null +++ b/chaincfg/coin.go @@ -0,0 +1,22 @@ +package chaincfg + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + ethaccounts "github.com/ethereum/go-ethereum/accounts" +) + +var ( + // Bip44CoinType satisfies EIP84. See https://github.com/ethereum/EIPs/issues/84 for more info. + Bip44CoinType uint32 = 60 // TODO: need new coin type for 0g-chain (a0gi) + + // BIP44HDPath is the default BIP44 HD path used on Ethereum. + BIP44HDPath = ethaccounts.DefaultBaseDerivationPath.String() +) + +// TODO: Implement BIP44CoinType and BIP44HDPath +// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets. +func setBip44CoinType(config *sdk.Config) { + config.SetCoinType(Bip44CoinType) + config.SetPurpose(sdk.Purpose) // Shared + config.SetFullFundraiserPath(BIP44HDPath) //nolint: staticcheck +} diff --git a/chaincfg/config.go b/chaincfg/config.go new file mode 100644 index 00000000..305afafe --- /dev/null +++ b/chaincfg/config.go @@ -0,0 +1,15 @@ +package chaincfg + +import sdk "github.com/cosmos/cosmos-sdk/types" + +const ( + AppName = "0gchain" + EnvPrefix = "0GCHAIN" +) + +func SetSDKConfig() *sdk.Config { + config := sdk.GetConfig() + setBech32Prefixes(config) + // setBip44CoinType(config) + return config +} diff --git a/chaincfg/denoms.go b/chaincfg/denoms.go new file mode 100644 index 00000000..d119a2a9 --- /dev/null +++ b/chaincfg/denoms.go @@ -0,0 +1,28 @@ +package chaincfg + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // DisplayDenom defines the denomination displayed to users in client applications. + DisplayDenom = "a0gi" + // BaseDenom defines to the default denomination used in 0g-chain + BaseDenom = "neuron" + + BaseDenomUnit = 18 + + ConversionMultiplier = 1e18 +) + +// RegisterDenoms registers the base and display denominations to the SDK. +func RegisterDenoms() { + if err := sdk.RegisterDenom(DisplayDenom, math.LegacyOneDec()); err != nil { + panic(err) + } + + if err := sdk.RegisterDenom(BaseDenom, math.LegacyNewDecWithPrec(1, BaseDenomUnit)); err != nil { + panic(err) + } +} diff --git a/chaincfg/homedir.go b/chaincfg/homedir.go new file mode 100644 index 00000000..2a4cb933 --- /dev/null +++ b/chaincfg/homedir.go @@ -0,0 +1,25 @@ +package chaincfg + +import ( + stdlog "log" + "os" + "path/filepath" +) + +const ( + HomeDirName = ".0gchain" +) + +var ( + // DefaultNodeHome default home directories for the application daemon + DefaultNodeHome string +) + +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + stdlog.Printf("Failed to get home dir %v", err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, HomeDirName) +} diff --git a/chaincfg/prefix.go b/chaincfg/prefix.go new file mode 100644 index 00000000..b45c8f6c --- /dev/null +++ b/chaincfg/prefix.go @@ -0,0 +1,44 @@ +package chaincfg + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // Bech32Prefix defines the Bech32 prefix used for EthAccounts + Bech32Prefix = "0g" + + // PrefixAccount is the prefix for account keys + PrefixAccount = "acc" + // PrefixValidator is the prefix for validator keys + PrefixValidator = "val" + // PrefixConsensus is the prefix for consensus keys + PrefixConsensus = "cons" + // PrefixPublic is the prefix for public keys + PrefixPublic = "pub" + // PrefixOperator is the prefix for operator keys + PrefixOperator = "oper" + + // PrefixAddress is the prefix for addresses + PrefixAddress = "addr" + + // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address + Bech32PrefixAccAddr = Bech32Prefix + // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key + Bech32PrefixAccPub = Bech32Prefix + PrefixPublic + // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address + Bech32PrefixValAddr = Bech32Prefix + PrefixValidator + PrefixOperator + // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key + Bech32PrefixValPub = Bech32Prefix + PrefixValidator + PrefixOperator + PrefixPublic + // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address + Bech32PrefixConsAddr = Bech32Prefix + PrefixValidator + PrefixConsensus + // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key + Bech32PrefixConsPub = Bech32Prefix + PrefixValidator + PrefixConsensus + PrefixPublic +) + +// setBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. +func setBech32Prefixes(config *sdk.Config) { + config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) + config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) + config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) +} diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 161217f6..b1ae5a30 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -28,7 +28,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/kava-labs/kava/app" + "github.com/0glabs/0g-chain/app" ) const ( diff --git a/client/grpc/README.md b/client/grpc/README.md index e9c1bdd1..c571a7f2 100644 --- a/client/grpc/README.md +++ b/client/grpc/README.md @@ -16,7 +16,7 @@ The Kava gRPC client is a tool for making gRPC queries on a Kava chain. package main import ( - kavaGrpc "github.com/kava-labs/kava/client/grpc" + kavaGrpc "github.com/0glabs/0g-chain/client/grpc" ) grpcUrl := "https://grpc.kava.io:443" client, err := kavaGrpc.NewClient(grpcUrl) @@ -46,7 +46,7 @@ Example: Query Kava module `x/evmutil` for params ```go import ( - evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" + evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" ) rsp, err := client.Query.Evmutil.Params( diff --git a/client/grpc/client.go b/client/grpc/client.go index 5cb309f1..e0d0b7f0 100644 --- a/client/grpc/client.go +++ b/client/grpc/client.go @@ -3,8 +3,8 @@ package grpc import ( "errors" - "github.com/kava-labs/kava/client/grpc/query" - "github.com/kava-labs/kava/client/grpc/util" + "github.com/0glabs/0g-chain/client/grpc/query" + "github.com/0glabs/0g-chain/client/grpc/util" ) // KavaGrpcClient enables the usage of kava grpc query clients and query utils diff --git a/client/grpc/client_test.go b/client/grpc/client_test.go index 82b8ae5d..116558d2 100644 --- a/client/grpc/client_test.go +++ b/client/grpc/client_test.go @@ -3,7 +3,7 @@ package grpc_test import ( "testing" - "github.com/kava-labs/kava/client/grpc" + "github.com/0glabs/0g-chain/client/grpc" "github.com/stretchr/testify/require" ) diff --git a/client/grpc/query/query.go b/client/grpc/query/query.go index 174ff435..7418819e 100644 --- a/client/grpc/query/query.go +++ b/client/grpc/query/query.go @@ -24,21 +24,21 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" - // auctiontypes "github.com/kava-labs/kava/x/auction/types" - // bep3types "github.com/kava-labs/kava/x/bep3/types" - // cdptypes "github.com/kava-labs/kava/x/cdp/types" - // committeetypes "github.com/kava-labs/kava/x/committee/types" - // communitytypes "github.com/kava-labs/kava/x/community/types" - // earntypes "github.com/kava-labs/kava/x/earn/types" - evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" - // hardtypes "github.com/kava-labs/kava/x/hard/types" - // incentivetypes "github.com/kava-labs/kava/x/incentive/types" - // issuancetypes "github.com/kava-labs/kava/x/issuance/types" - // kavadisttypes "github.com/kava-labs/kava/x/kavadist/types" - // liquidtypes "github.com/kava-labs/kava/x/liquid/types" - // pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types" - // savingstypes "github.com/kava-labs/kava/x/savings/types" - // swaptypes "github.com/kava-labs/kava/x/swap/types" + // auctiontypes "github.com/0glabs/0g-chain/x/auction/types" + // bep3types "github.com/0glabs/0g-chain/x/bep3/types" + // cdptypes "github.com/0glabs/0g-chain/x/cdp/types" + // committeetypes "github.com/0glabs/0g-chain/x/committee/types" + // communitytypes "github.com/0glabs/0g-chain/x/community/types" + // earntypes "github.com/0glabs/0g-chain/x/earn/types" + evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" + // hardtypes "github.com/0glabs/0g-chain/x/hard/types" + // incentivetypes "github.com/0glabs/0g-chain/x/incentive/types" + // issuancetypes "github.com/0glabs/0g-chain/x/issuance/types" + // kavadisttypes "github.com/0glabs/0g-chain/x/kavadist/types" + // liquidtypes "github.com/0glabs/0g-chain/x/liquid/types" + // pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types" + // savingstypes "github.com/0glabs/0g-chain/x/savings/types" + // swaptypes "github.com/0glabs/0g-chain/x/swap/types" ) // QueryClient is a wrapper with all Cosmos and Kava grpc query clients diff --git a/client/grpc/query/query_test.go b/client/grpc/query/query_test.go index 08c71a30..1307ae59 100644 --- a/client/grpc/query/query_test.go +++ b/client/grpc/query/query_test.go @@ -3,7 +3,7 @@ package query_test import ( "testing" - "github.com/kava-labs/kava/client/grpc/query" + "github.com/0glabs/0g-chain/client/grpc/query" "github.com/stretchr/testify/require" ) diff --git a/client/grpc/util/util.go b/client/grpc/util/util.go index 0c9c5744..1fed3f75 100644 --- a/client/grpc/util/util.go +++ b/client/grpc/util/util.go @@ -7,9 +7,9 @@ import ( grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" "google.golang.org/grpc/metadata" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/params" - query "github.com/kava-labs/kava/client/grpc/query" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/params" + query "github.com/0glabs/0g-chain/client/grpc/query" ) // Util contains utility functions for the Kava gRPC client diff --git a/client/rest/rest_test.go b/client/rest/rest_test.go index 6de35a45..2e5efde2 100644 --- a/client/rest/rest_test.go +++ b/client/rest/rest_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" simappparams "cosmossdk.io/simapp/params" + "github.com/0glabs/0g-chain/client/rest" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" @@ -20,7 +21,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/client/rest" ) func TestBaseReq_Sanitize(t *testing.T) { diff --git a/cmd/kava/cmd/app.go b/cmd/0gchaind/app.go similarity index 98% rename from cmd/kava/cmd/app.go rename to cmd/0gchaind/app.go index f505ea66..e217582d 100644 --- a/cmd/kava/cmd/app.go +++ b/cmd/0gchaind/app.go @@ -1,4 +1,4 @@ -package cmd +package zgchaind import ( "errors" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cast" "github.com/spf13/cobra" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/params" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/params" ) const ( diff --git a/cmd/kava/cmd/assert-invariants.go b/cmd/0gchaind/assert-invariants.go similarity index 95% rename from cmd/kava/cmd/assert-invariants.go rename to cmd/0gchaind/assert-invariants.go index de4ef717..af13e2df 100644 --- a/cmd/kava/cmd/assert-invariants.go +++ b/cmd/0gchaind/assert-invariants.go @@ -1,4 +1,4 @@ -package cmd +package zgchaind import ( "encoding/json" @@ -9,8 +9,8 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/spf13/cobra" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/params" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/params" ) func AssertInvariantsCmd(config params.EncodingConfig) *cobra.Command { diff --git a/cmd/kava/cmd/genaccounts.go b/cmd/0gchaind/genaccounts.go similarity index 99% rename from cmd/kava/cmd/genaccounts.go rename to cmd/0gchaind/genaccounts.go index 5a5d157f..f708f11b 100644 --- a/cmd/kava/cmd/genaccounts.go +++ b/cmd/0gchaind/genaccounts.go @@ -1,5 +1,5 @@ // Sourced from https://github.com/evmos/ethermint/blob/main/cmd/ethermintd/genaccounts.go -package cmd +package zgchaind import ( "bufio" diff --git a/cmd/kava/cmd/keys.go b/cmd/0gchaind/keys.go similarity index 99% rename from cmd/kava/cmd/keys.go rename to cmd/0gchaind/keys.go index 9d8587c0..687a0b2d 100644 --- a/cmd/kava/cmd/keys.go +++ b/cmd/0gchaind/keys.go @@ -1,4 +1,4 @@ -package cmd +package zgchaind import ( "bufio" diff --git a/cmd/kava/cmd/query.go b/cmd/0gchaind/query.go similarity index 94% rename from cmd/kava/cmd/query.go rename to cmd/0gchaind/query.go index 8bf5cec9..c5c652e3 100644 --- a/cmd/kava/cmd/query.go +++ b/cmd/0gchaind/query.go @@ -1,4 +1,4 @@ -package cmd +package zgchaind import ( "github.com/cosmos/cosmos-sdk/client" @@ -7,7 +7,7 @@ import ( authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/spf13/cobra" - "github.com/kava-labs/kava/app" + "github.com/0glabs/0g-chain/app" ) // newQueryCmd creates all the commands for querying blockchain state. diff --git a/cmd/kava/cmd/root.go b/cmd/0gchaind/root.go similarity index 81% rename from cmd/kava/cmd/root.go rename to cmd/0gchaind/root.go index 6b9242e7..6a0e8077 100644 --- a/cmd/kava/cmd/root.go +++ b/cmd/0gchaind/root.go @@ -1,4 +1,4 @@ -package cmd +package zgchaind import ( "fmt" @@ -23,21 +23,16 @@ import ( servercfg "github.com/evmos/ethermint/server/config" "github.com/spf13/cobra" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/app/params" - "github.com/kava-labs/kava/cmd/kava/cmd/rocksdb" - "github.com/kava-labs/kava/cmd/kava/opendb" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/app/params" + "github.com/0glabs/0g-chain/chaincfg" + "github.com/0glabs/0g-chain/cmd/opendb" + "github.com/0glabs/0g-chain/cmd/rocksdb" ) -// EnvPrefix is the prefix environment variables must have to configure the app. -const EnvPrefix = "KAVA" - -// NewRootCmd creates a new root command for the kava blockchain. +// NewRootCmd creates a new root command for the 0g-chain blockchain. func NewRootCmd() *cobra.Command { - app.SetSDKConfig().Seal() - encodingConfig := app.MakeEncodingConfig() - initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). @@ -46,13 +41,12 @@ func NewRootCmd() *cobra.Command { WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). WithBroadcastMode(flags.FlagBroadcastMode). - WithHomeDir(app.DefaultNodeHome). + WithHomeDir(chaincfg.DefaultNodeHome). WithKeyringOptions(hd.EthSecp256k1Option()). - WithViper(EnvPrefix) - + WithViper(chaincfg.EnvPrefix) rootCmd := &cobra.Command{ - Use: "kava", - Short: "Daemon and CLI for the Kava blockchain.", + Use: chaincfg.AppName, + Short: "Daemon and CLI for the 0g-chain blockchain.", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { cmd.SetOut(cmd.OutOrStdout()) cmd.SetErr(cmd.ErrOrStderr()) @@ -71,7 +65,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := servercfg.AppConfig("ukava") + customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.BaseDenom) return server.InterceptConfigsPreRunHandler( cmd, @@ -82,12 +76,12 @@ func NewRootCmd() *cobra.Command { }, } - addSubCmds(rootCmd, encodingConfig, app.DefaultNodeHome) + addSubCmds(rootCmd, encodingConfig, chaincfg.DefaultNodeHome) return rootCmd } -// addSubCmds registers all the sub commands used by kava. +// addSubCmds registers all the sub commands used by 0g-chain. func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, defaultNodeHome string) { gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) if !ok { @@ -116,7 +110,7 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de opts := ethermintserver.StartOptions{ AppCreator: ac.newApp, - DefaultNodeHome: app.DefaultNodeHome, + DefaultNodeHome: chaincfg.DefaultNodeHome, DBOpener: opendb.OpenDB, } // ethermintserver adds additional flags to start the JSON-RPC server for evm support @@ -131,7 +125,7 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de rootCmd.AddCommand( newQueryCmd(), newTxCmd(), - keyCommands(app.DefaultNodeHome), + keyCommands(chaincfg.DefaultNodeHome), rocksdb.RocksDBCmd, newShardCmd(opts), ) diff --git a/cmd/kava/cmd/shard.go b/cmd/0gchaind/shard.go similarity index 99% rename from cmd/kava/cmd/shard.go rename to cmd/0gchaind/shard.go index 7a44589b..4b33acd2 100644 --- a/cmd/kava/cmd/shard.go +++ b/cmd/0gchaind/shard.go @@ -1,10 +1,10 @@ -package cmd +package zgchaind import ( "fmt" "strings" - "github.com/kava-labs/kava/app" + "github.com/0glabs/0g-chain/app" "github.com/spf13/cobra" dbm "github.com/cometbft/cometbft-db" diff --git a/cmd/kava/cmd/status.go b/cmd/0gchaind/status.go similarity index 99% rename from cmd/kava/cmd/status.go rename to cmd/0gchaind/status.go index bc5165a0..538bbb5a 100644 --- a/cmd/kava/cmd/status.go +++ b/cmd/0gchaind/status.go @@ -1,4 +1,4 @@ -package cmd +package zgchaind import ( "context" diff --git a/cmd/kava/cmd/tx.go b/cmd/0gchaind/tx.go similarity index 94% rename from cmd/kava/cmd/tx.go rename to cmd/0gchaind/tx.go index 25d1c5ac..4bd159d4 100644 --- a/cmd/kava/cmd/tx.go +++ b/cmd/0gchaind/tx.go @@ -1,4 +1,4 @@ -package cmd +package zgchaind import ( "github.com/cosmos/cosmos-sdk/client" @@ -6,7 +6,7 @@ import ( authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/spf13/cobra" - "github.com/kava-labs/kava/app" + "github.com/0glabs/0g-chain/app" ) // newTxCmd creates all commands for submitting blockchain transactions. diff --git a/cmd/kava/main.go b/cmd/kava/main.go deleted file mode 100644 index 155b5a42..00000000 --- a/cmd/kava/main.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "os" - - "github.com/cosmos/cosmos-sdk/server" - svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/cmd/kava/cmd" -) - -func main() { - rootCmd := cmd.NewRootCmd() - - if err := svrcmd.Execute(rootCmd, cmd.EnvPrefix, app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - - default: - os.Exit(1) - } - } -} diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 00000000..ecd66dd6 --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "os" + + "github.com/cosmos/cosmos-sdk/server" + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" + + "github.com/0glabs/0g-chain/chaincfg" + chain "github.com/0glabs/0g-chain/cmd/0gchaind" +) + +func main() { + chaincfg.SetSDKConfig().Seal() + chaincfg.RegisterDenoms() + + rootCmd := chain.NewRootCmd() + + if err := svrcmd.Execute(rootCmd, chaincfg.EnvPrefix, chaincfg.DefaultNodeHome); err != nil { + switch e := err.(type) { + case server.ErrorCode: + os.Exit(e.Code) + + default: + os.Exit(1) + } + } +} diff --git a/cmd/kava/opendb/metrics.go b/cmd/opendb/metrics.go similarity index 100% rename from cmd/kava/opendb/metrics.go rename to cmd/opendb/metrics.go diff --git a/cmd/kava/opendb/opendb.go b/cmd/opendb/opendb.go similarity index 100% rename from cmd/kava/opendb/opendb.go rename to cmd/opendb/opendb.go diff --git a/cmd/kava/opendb/opendb_rocksdb.go b/cmd/opendb/opendb_rocksdb.go similarity index 100% rename from cmd/kava/opendb/opendb_rocksdb.go rename to cmd/opendb/opendb_rocksdb.go diff --git a/cmd/kava/opendb/opendb_rocksdb_test.go b/cmd/opendb/opendb_rocksdb_test.go similarity index 100% rename from cmd/kava/opendb/opendb_rocksdb_test.go rename to cmd/opendb/opendb_rocksdb_test.go diff --git a/cmd/kava/opendb/props_loader.go b/cmd/opendb/props_loader.go similarity index 100% rename from cmd/kava/opendb/props_loader.go rename to cmd/opendb/props_loader.go diff --git a/cmd/kava/opendb/props_loader_test.go b/cmd/opendb/props_loader_test.go similarity index 100% rename from cmd/kava/opendb/props_loader_test.go rename to cmd/opendb/props_loader_test.go diff --git a/cmd/kava/opendb/stat_parser.go b/cmd/opendb/stat_parser.go similarity index 100% rename from cmd/kava/opendb/stat_parser.go rename to cmd/opendb/stat_parser.go diff --git a/cmd/kava/opendb/stat_parser_test.go b/cmd/opendb/stat_parser_test.go similarity index 100% rename from cmd/kava/opendb/stat_parser_test.go rename to cmd/opendb/stat_parser_test.go diff --git a/cmd/kava/opendb/stats_loader.go b/cmd/opendb/stats_loader.go similarity index 100% rename from cmd/kava/opendb/stats_loader.go rename to cmd/opendb/stats_loader.go diff --git a/cmd/kava/opendb/stats_loader_test.go b/cmd/opendb/stats_loader_test.go similarity index 100% rename from cmd/kava/opendb/stats_loader_test.go rename to cmd/opendb/stats_loader_test.go diff --git a/cmd/kava/cmd/rocksdb/compact.go b/cmd/rocksdb/compact.go similarity index 99% rename from cmd/kava/cmd/rocksdb/compact.go rename to cmd/rocksdb/compact.go index 4adcbfe8..dc3721e1 100644 --- a/cmd/kava/cmd/rocksdb/compact.go +++ b/cmd/rocksdb/compact.go @@ -14,9 +14,9 @@ import ( "syscall" "time" + "github.com/0glabs/0g-chain/cmd/opendb" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" - "github.com/kava-labs/kava/cmd/kava/opendb" "github.com/linxGnu/grocksdb" "github.com/spf13/cobra" "golang.org/x/exp/slices" diff --git a/cmd/kava/cmd/rocksdb/rocksdb.go b/cmd/rocksdb/rocksdb.go similarity index 100% rename from cmd/kava/cmd/rocksdb/rocksdb.go rename to cmd/rocksdb/rocksdb.go diff --git a/cmd/kava/cmd/rocksdb/rocksdb_dummy.go b/cmd/rocksdb/rocksdb_dummy.go similarity index 100% rename from cmd/kava/cmd/rocksdb/rocksdb_dummy.go rename to cmd/rocksdb/rocksdb_dummy.go diff --git a/crypto/vrf/algorithm.go b/crypto/vrf/algorithm.go new file mode 100644 index 00000000..bc344e44 --- /dev/null +++ b/crypto/vrf/algorithm.go @@ -0,0 +1,58 @@ +package vrf + +import ( + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +) + +var ( + // SupportedAlgorithms defines the list of signing algorithms used on Evmos: + // - eth_secp256k1 (Ethereum) + // - secp256k1 (Tendermint) + SupportedAlgorithms = keyring.SigningAlgoList{VrfAlgo} + // SupportedAlgorithmsLedger defines the list of signing algorithms used on Evmos for the Ledger device: + // - eth_secp256k1 (Ethereum) + // - secp256k1 (Tendermint) + SupportedAlgorithmsLedger = keyring.SigningAlgoList{VrfAlgo} +) + +func VrfOption() keyring.Option { + return func(options *keyring.Options) { + options.SupportedAlgos = SupportedAlgorithms + options.SupportedAlgosLedger = SupportedAlgorithmsLedger + } +} + +const ( + VrfType = hd.PubKeyType(KeyType) +) + +var ( + _ keyring.SignatureAlgo = VrfAlgo + VrfAlgo = vrfAlgo{} +) + +type vrfAlgo struct{} + +func (s vrfAlgo) Name() hd.PubKeyType { + return VrfType +} + +func (s vrfAlgo) Derive() hd.DeriveFn { + return func(mnemonic, bip39Passphrase, path string) ([]byte, error) { + key, err := GenerateKey() + if err != nil { + return nil, err + } + + return key.Bytes(), nil + } +} + +func (s vrfAlgo) Generate() hd.GenerateFn { + return func(bz []byte) cryptotypes.PrivKey { + key, _ := GenerateKey() + return key + } +} diff --git a/crypto/vrf/keys.pb.go b/crypto/vrf/keys.pb.go new file mode 100644 index 00000000..e67dc52b --- /dev/null +++ b/crypto/vrf/keys.pb.go @@ -0,0 +1,496 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: crypto/vrf/keys.proto + +package vrf + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PubKey defines a type alias for an vrf.PublicKey that implements +// Vrf's PubKey interface. It represents the 32-byte compressed public +// key format. +type PubKey struct { + // key is the public key in byte form + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PubKey) Reset() { *m = PubKey{} } +func (*PubKey) ProtoMessage() {} +func (*PubKey) Descriptor() ([]byte, []int) { + return fileDescriptor_eae59d1af27f5957, []int{0} +} +func (m *PubKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubKey.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 *PubKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKey.Merge(m, src) +} +func (m *PubKey) XXX_Size() int { + return m.Size() +} +func (m *PubKey) XXX_DiscardUnknown() { + xxx_messageInfo_PubKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PubKey proto.InternalMessageInfo + +func (m *PubKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +// PrivKey defines a type alias for an vrf.PrivateKey that implements +// Vrf's PrivateKey interface. +type PrivKey struct { + // key is the private key in byte form + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PrivKey) Reset() { *m = PrivKey{} } +func (m *PrivKey) String() string { return proto.CompactTextString(m) } +func (*PrivKey) ProtoMessage() {} +func (*PrivKey) Descriptor() ([]byte, []int) { + return fileDescriptor_eae59d1af27f5957, []int{1} +} +func (m *PrivKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PrivKey.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 *PrivKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrivKey.Merge(m, src) +} +func (m *PrivKey) XXX_Size() int { + return m.Size() +} +func (m *PrivKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrivKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PrivKey proto.InternalMessageInfo + +func (m *PrivKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*PubKey)(nil), "crypto.vrf.PubKey") + proto.RegisterType((*PrivKey)(nil), "crypto.vrf.PrivKey") +} + +func init() { proto.RegisterFile("crypto/vrf/keys.proto", fileDescriptor_eae59d1af27f5957) } + +var fileDescriptor_eae59d1af27f5957 = []byte{ + // 174 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x2e, 0xaa, 0x2c, + 0x28, 0xc9, 0xd7, 0x2f, 0x2b, 0x4a, 0xd3, 0xcf, 0x4e, 0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0xe2, 0x82, 0x08, 0xeb, 0x95, 0x15, 0xa5, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, + 0x85, 0xf5, 0x41, 0x2c, 0x88, 0x0a, 0x25, 0x05, 0x2e, 0xb6, 0x80, 0xd2, 0x24, 0xef, 0xd4, 0x4a, + 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x9e, 0x20, 0x10, 0xd3, + 0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x25, 0x69, 0x2e, 0xf6, 0x80, 0xa2, 0xcc, 0x32, 0xac, 0x4a, + 0x9c, 0xec, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, + 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x35, 0x3d, 0xb3, + 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x20, 0x3d, 0x27, 0x31, 0xa9, 0x58, 0xdf, + 0x20, 0x5d, 0x37, 0x39, 0x23, 0x31, 0x33, 0x4f, 0x1f, 0xe1, 0xd8, 0x24, 0x36, 0xb0, 0x33, 0x8c, + 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xb8, 0x32, 0x07, 0xc1, 0x00, 0x00, 0x00, +} + +func (m *PubKey) 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 *PubKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PrivKey) 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 *PrivKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { + offset -= sovKeys(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PubKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func (m *PrivKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func sovKeys(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozKeys(x uint64) (n int) { + return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PubKey) 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 ErrIntOverflowKeys + } + 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: PubKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrivKey) 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 ErrIntOverflowKeys + } + 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: PrivKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrivKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipKeys(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKeys + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKeys + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKeys + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthKeys + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupKeys + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthKeys + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group") +) diff --git a/crypto/vrf/vrf.go b/crypto/vrf/vrf.go new file mode 100644 index 00000000..a3586cb2 --- /dev/null +++ b/crypto/vrf/vrf.go @@ -0,0 +1,194 @@ +package vrf + +import ( + "bytes" + "crypto/subtle" + "fmt" + + errorsmod "cosmossdk.io/errors" + tmcrypto "github.com/cometbft/cometbft/crypto" + vrfalgo "github.com/coniks-sys/coniks-go/crypto/vrf" + "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" +) + +const ( + // PrivKeySize defines the size of the PrivKey bytes + PrivKeySize = 64 + // PubKeySize defines the size of the PubKey bytes + PubKeySize = 32 + // KeyType is the string constant for the vrf algorithm + KeyType = "vrf" +) + +// Amino encoding names +const ( + // PrivKeyName defines the amino encoding name for the vrf private key + PrivKeyName = "vrf/PrivKey" + // PubKeyName defines the amino encoding name for the vrf public key + PubKeyName = "vrf/PubKey" +) + +// ---------------------------------------------------------------------------- +// vrf Private Key + +var ( + _ cryptotypes.PrivKey = &PrivKey{} + _ codec.AminoMarshaler = &PrivKey{} +) + +// GenerateKey generates a new random private key. It returns an error upon +// failure. +func GenerateKey() (*PrivKey, error) { + priv, err := vrfalgo.GenerateKey(nil) + if err != nil { + return nil, err + } + + return &PrivKey{ + Key: priv, + }, nil +} + +func (privKey PrivKey) getVrfPrivateKey() vrfalgo.PrivateKey { + return vrfalgo.PrivateKey(privKey.Key) +} + +// Bytes returns the byte representation of the Private Key. +func (privKey PrivKey) Bytes() []byte { + bz := make([]byte, len(privKey.Key)) + copy(bz, privKey.Key) + + return bz +} + +// PubKey returns the private key's public key. If the privkey is not valid +// it returns a nil value. +func (privKey PrivKey) PubKey() cryptotypes.PubKey { + pk, _ := vrfalgo.PrivateKey(privKey.Key).Public() + + return &PubKey{ + Key: pk, + } +} + +// Equals returns true if two private keys are equal and false otherwise. +func (privKey PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { + return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1 +} + +// Type returns vrf +func (privKey PrivKey) Type() string { + return KeyType +} + +// Compute generates the vrf value for the byte slice m using the +// underlying private key sk. +func (privKey PrivKey) Sign(digestBz []byte) ([]byte, error) { + sk := privKey.getVrfPrivateKey() + + return sk.Compute(digestBz), nil +} + +// MarshalAmino overrides Amino binary marshaling. +func (privKey PrivKey) MarshalAmino() ([]byte, error) { + return privKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshaling. +func (privKey *PrivKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PrivKeySize { + return fmt.Errorf("invalid privkey size, expected %d got %d", PrivKeySize, len(bz)) + } + privKey.Key = bz + + return nil +} + +// MarshalAminoJSON overrides Amino JSON marshaling. +func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return privKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshaling. +func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error { + return privKey.UnmarshalAmino(bz) +} + +// ---------------------------------------------------------------------------- +// vrf Public Key + +var ( + _ cryptotypes.PubKey = &PubKey{} + _ codec.AminoMarshaler = &PubKey{} +) + +// func (pubKey PubKey) getVrfPublicKey() vrfalgo.PublicKey { +// return vrfalgo.PublicKey(pubKey.Key) +// } + +// Address returns the address of the ECDSA public key. +// The function will return an empty address if the public key is invalid. +func (pubKey PubKey) Address() tmcrypto.Address { + return tmcrypto.Address(common.BytesToAddress(pubKey.Key).Bytes()) +} + +// Bytes returns the raw bytes of the ECDSA public key. +func (pubKey PubKey) Bytes() []byte { + bz := make([]byte, len(pubKey.Key)) + copy(bz, pubKey.Key) + + return bz +} + +// String implements the fmt.Stringer interface. +func (pubKey PubKey) String() string { + return fmt.Sprintf("vrf{%X}", pubKey.Key) +} + +// Type returns vrf +func (pubKey PubKey) Type() string { + return KeyType +} + +// Equals returns true if the pubkey type is the same and their bytes are deeply equal. +func (pubKey PubKey) Equals(other cryptotypes.PubKey) bool { + return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes()) +} + +// Verify returns true iff vrf=Compute(m) for the sk that +// corresponds to pk. +func (pubKey PubKey) VerifySignature(msg, sig []byte) bool { + panic("not implement") +} + +// MarshalAmino overrides Amino binary marshaling. +func (pubKey PubKey) MarshalAmino() ([]byte, error) { + return pubKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshaling. +func (pubKey *PubKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PubKeySize { + return errorsmod.Wrapf(errortypes.ErrInvalidPubKey, "invalid pubkey size, expected %d, got %d", PubKeySize, len(bz)) + } + pubKey.Key = bz + + return nil +} + +// MarshalAminoJSON overrides Amino JSON marshaling. +func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return pubKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshaling. +func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error { + return pubKey.UnmarshalAmino(bz) +} diff --git a/crypto/vrf/vrf_test.go b/crypto/vrf/vrf_test.go new file mode 100644 index 00000000..f5696182 --- /dev/null +++ b/crypto/vrf/vrf_test.go @@ -0,0 +1,96 @@ +package vrf + +import ( + "testing" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + + "encoding/base64" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/codec" +) + +func TestPrivKey(t *testing.T) { + // validate type and equality + privKey, err := GenerateKey() + require.NoError(t, err) + require.Implements(t, (*cryptotypes.PrivKey)(nil), privKey) + + // validate inequality + privKey2, err := GenerateKey() + require.NoError(t, err) + require.False(t, privKey.Equals(privKey2)) +} + +func TestPrivKey_PubKey(t *testing.T) { + privKey, err := GenerateKey() + require.NoError(t, err) + + // validate type and equality + pubKey := &PubKey{ + Key: privKey.PubKey().Bytes(), + } + require.Implements(t, (*cryptotypes.PubKey)(nil), pubKey) + + // validate inequality + privKey2, err := GenerateKey() + require.NoError(t, err) + require.False(t, pubKey.Equals(privKey2.PubKey())) +} + +func TestMarshalAmino(t *testing.T) { + aminoCdc := codec.NewLegacyAmino() + privKey, err := GenerateKey() + require.NoError(t, err) + + pubKey := privKey.PubKey().(*PubKey) + + testCases := []struct { + desc string + msg codec.AminoMarshaler + typ interface{} + expBinary []byte + expJSON string + }{ + { + "vrf private key", + privKey, + &PrivKey{}, + append([]byte{64}, privKey.Bytes()...), // Length-prefixed. + "\"" + base64.StdEncoding.EncodeToString(privKey.Bytes()) + "\"", + }, + { + "vrf public key", + pubKey, + &PubKey{}, + append([]byte{32}, pubKey.Bytes()...), // Length-prefixed. + "\"" + base64.StdEncoding.EncodeToString(pubKey.Bytes()) + "\"", + }, + } + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + // Do a round trip of encoding/decoding binary. + bz, err := aminoCdc.Marshal(tc.msg) + require.NoError(t, err) + require.Equal(t, tc.expBinary, bz) + + err = aminoCdc.Unmarshal(bz, tc.typ) + require.NoError(t, err) + + require.Equal(t, tc.msg, tc.typ) + + // Do a round trip of encoding/decoding JSON. + bz, err = aminoCdc.MarshalJSON(tc.msg) + require.NoError(t, err) + require.Equal(t, tc.expJSON, string(bz)) + + err = aminoCdc.UnmarshalJSON(bz, tc.typ) + require.NoError(t, err) + + require.Equal(t, tc.msg, tc.typ) + }) + } +} diff --git a/go.mod b/go.mod index 4e300659..d315df3a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/kava-labs/kava +module github.com/0glabs/0g-chain go 1.21 @@ -9,6 +9,7 @@ require ( github.com/cenkalti/backoff/v4 v4.1.3 github.com/cometbft/cometbft v0.37.4 github.com/cometbft/cometbft-db v0.9.1 + github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 github.com/cosmos/cosmos-proto v1.0.0-beta.4 github.com/cosmos/cosmos-sdk v0.47.10 github.com/cosmos/go-bip39 v1.0.0 @@ -18,7 +19,6 @@ require ( github.com/ethereum/go-ethereum v1.10.26 github.com/evmos/ethermint v0.21.0 github.com/go-kit/kit v0.12.0 - github.com/gogo/protobuf v1.3.2 github.com/golang/protobuf v1.5.3 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -111,6 +111,7 @@ require ( github.com/go-stack/stack v1.8.1 // 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.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect @@ -183,7 +184,6 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/status-im/keycard-go v0.2.0 // indirect - github.com/stretchr/objx v0.5.0 // 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 diff --git a/go.sum b/go.sum index 33f558d2..05106bfb 100644 --- a/go.sum +++ b/go.sum @@ -396,6 +396,8 @@ github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZ github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= 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/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 h1:MFLTqgfJclmtaQ1SRUrWwmDX/1UBok3XWUethkJ2swQ= +github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71/go.mod h1:TrHYHH4Wze7v7Hkwu1MH1W+mCPQKM+gs+PicdEV14o8= github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= diff --git a/helper/da/client/client.go b/helper/da/client/client.go new file mode 100644 index 00000000..533c9e9c --- /dev/null +++ b/helper/da/client/client.go @@ -0,0 +1,61 @@ +package client + +import ( + "context" + "time" + + "github.com/0glabs/0g-evmos/helper/da/light" + + "github.com/pkg/errors" +) + +type DaLightRpcClient interface { + Sample(ctx context.Context, streamId, headerHash []byte, blobIdx, times uint32) (bool, error) + Destroy() + GetInstanceCount() int +} + +type daLightClient struct { + maxInstance int + pool ConnectionPool +} + +func NewDaLightClient(address string, instanceLimit int) DaLightRpcClient { + return &daLightClient{ + maxInstance: instanceLimit, + pool: NewConnectionPool(address, instanceLimit, 10*time.Minute), + } +} + +func (c *daLightClient) Sample(ctx context.Context, streamId, headerHash []byte, blobIdx, times uint32) (bool, error) { + connection, err := c.pool.GetConnection() + if err != nil { + return false, errors.Wrap(err, "failed to connect to da light server") + } + defer c.pool.ReleaseConnection(connection) + + req := &light.SampleRequest{ + StreamId: streamId, + BatchHeaderHash: headerHash, + BlobIndex: blobIdx, + Times: times, + } + client := light.NewLightClient(connection) + reply, err := client.Sample(ctx, req) + if err != nil { + return false, errors.Wrap(err, "failed to sample from da light server") + } + + return reply.Success, nil +} + +func (c *daLightClient) Destroy() { + if c.pool != nil { + c.pool.Close() + c.pool = nil + } +} + +func (c *daLightClient) GetInstanceCount() int { + return c.maxInstance +} diff --git a/helper/da/client/pool.go b/helper/da/client/pool.go new file mode 100644 index 00000000..887704a0 --- /dev/null +++ b/helper/da/client/pool.go @@ -0,0 +1,101 @@ +package client + +import ( + "errors" + "sync" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/backoff" + "google.golang.org/grpc/credentials/insecure" +) + +type ConnectionPool interface { + GetConnection() (*grpc.ClientConn, error) + ReleaseConnection(*grpc.ClientConn) + Close() +} + +type connectionPoolImpl struct { + address string + maxSize int + timeout time.Duration + param grpc.ConnectParams + + mu sync.Mutex + pool []*grpc.ClientConn +} + +func NewConnectionPool(address string, maxSize int, timeout time.Duration) ConnectionPool { + return &connectionPoolImpl{ + address: address, + maxSize: maxSize, + timeout: timeout, + param: grpc.ConnectParams{ + Backoff: backoff.Config{ + BaseDelay: 1.0 * time.Second, + Multiplier: 1.5, + Jitter: 0.2, + MaxDelay: 30 * time.Second, + }, + MinConnectTimeout: 30 * time.Second, + }, + pool: make([]*grpc.ClientConn, 0, maxSize), + } +} + +func (p *connectionPoolImpl) GetConnection() (*grpc.ClientConn, error) { + p.mu.Lock() + defer p.mu.Unlock() + + if p.pool == nil { + return nil, errors.New("connection pool is closed") + } + + // Check if there's any available connection in the pool + if len(p.pool) > 0 { + conn := p.pool[0] + p.pool = p.pool[1:] + return conn, nil + } + + // If the pool is empty, create a new connection + conn, err := grpc.Dial(p.address, grpc.WithBlock(), + grpc.WithConnectParams(p.param), + grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + return nil, err + } + return conn, nil +} + +func (p *connectionPoolImpl) ReleaseConnection(conn *grpc.ClientConn) { + p.mu.Lock() + defer p.mu.Unlock() + + if p.pool != nil { + // If the pool is full, close the connection + if len(p.pool) >= p.maxSize { + conn.Close() + return + } + + // Add the connection back to the pool + p.pool = append(p.pool, conn) + } else { + conn.Close() + } +} + +func (p *connectionPoolImpl) Close() { + p.mu.Lock() + defer p.mu.Unlock() + + if p.pool != nil { + for _, conn := range p.pool { + conn.Close() + } + + p.pool = nil + } +} diff --git a/helper/da/go.mod b/helper/da/go.mod new file mode 100644 index 00000000..b0e11e7e --- /dev/null +++ b/helper/da/go.mod @@ -0,0 +1,26 @@ +module github.com/0glabs/0g-evmos/helper/da + +go 1.20 + +require ( + github.com/json-iterator/go v1.1.12 + github.com/lesismal/nbio v1.5.4 + github.com/pkg/errors v0.9.1 + github.com/rs/zerolog v1.32.0 + google.golang.org/grpc v1.63.2 + google.golang.org/protobuf v1.33.0 +) + +require ( + github.com/lesismal/llib v1.1.13 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/stretchr/testify v1.8.4 // indirect + golang.org/x/crypto v0.19.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect +) diff --git a/helper/da/go.sum b/helper/da/go.sum new file mode 100644 index 00000000..cc3cf3ca --- /dev/null +++ b/helper/da/go.sum @@ -0,0 +1,60 @@ +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +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/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/lesismal/llib v1.1.13 h1:+w1+t0PykXpj2dXQck0+p6vdC9/mnbEXHgUy/HXDGfE= +github.com/lesismal/llib v1.1.13/go.mod h1:70tFXXe7P1FZ02AU9l8LgSOK7d7sRrpnkUr3rd3gKSg= +github.com/lesismal/nbio v1.5.4 h1:fZ6FOVZOBm7nFuudYsq+WyHJuM2UNuPdlvF/1LVa6lo= +github.com/lesismal/nbio v1.5.4/go.mod h1:mvfYBAA1jmrafXf2XvkM28jWkMTfA5jGks+HKDBMmOc= +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.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/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= +github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.0.0-20210513122933-cd7d49e622d5/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/helper/da/light/light.pb.go b/helper/da/light/light.pb.go new file mode 100644 index 00000000..60c987f2 --- /dev/null +++ b/helper/da/light/light.pb.go @@ -0,0 +1,397 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v4.25.3 +// source: light/light.proto + +package light + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// SampleRequest contains the blob to sample (by batch and blob index) and required sample times +type SampleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StreamId []byte `protobuf:"bytes,1,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"` + BatchHeaderHash []byte `protobuf:"bytes,2,opt,name=batch_header_hash,json=batchHeaderHash,proto3" json:"batch_header_hash,omitempty"` + BlobIndex uint32 `protobuf:"varint,3,opt,name=blob_index,json=blobIndex,proto3" json:"blob_index,omitempty"` + Times uint32 `protobuf:"varint,4,opt,name=times,proto3" json:"times,omitempty"` +} + +func (x *SampleRequest) Reset() { + *x = SampleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_light_light_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SampleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SampleRequest) ProtoMessage() {} + +func (x *SampleRequest) ProtoReflect() protoreflect.Message { + mi := &file_light_light_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SampleRequest.ProtoReflect.Descriptor instead. +func (*SampleRequest) Descriptor() ([]byte, []int) { + return file_light_light_proto_rawDescGZIP(), []int{0} +} + +func (x *SampleRequest) GetStreamId() []byte { + if x != nil { + return x.StreamId + } + return nil +} + +func (x *SampleRequest) GetBatchHeaderHash() []byte { + if x != nil { + return x.BatchHeaderHash + } + return nil +} + +func (x *SampleRequest) GetBlobIndex() uint32 { + if x != nil { + return x.BlobIndex + } + return 0 +} + +func (x *SampleRequest) GetTimes() uint32 { + if x != nil { + return x.Times + } + return 0 +} + +// SampleReply contains the sample result +type SampleReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` +} + +func (x *SampleReply) Reset() { + *x = SampleReply{} + if protoimpl.UnsafeEnabled { + mi := &file_light_light_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SampleReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SampleReply) ProtoMessage() {} + +func (x *SampleReply) ProtoReflect() protoreflect.Message { + mi := &file_light_light_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SampleReply.ProtoReflect.Descriptor instead. +func (*SampleReply) Descriptor() ([]byte, []int) { + return file_light_light_proto_rawDescGZIP(), []int{1} +} + +func (x *SampleReply) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +type RetrieveRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BatchHeaderHash []byte `protobuf:"bytes,1,opt,name=batch_header_hash,json=batchHeaderHash,proto3" json:"batch_header_hash,omitempty"` + BlobIndex uint32 `protobuf:"varint,2,opt,name=blob_index,json=blobIndex,proto3" json:"blob_index,omitempty"` +} + +func (x *RetrieveRequest) Reset() { + *x = RetrieveRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_light_light_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RetrieveRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RetrieveRequest) ProtoMessage() {} + +func (x *RetrieveRequest) ProtoReflect() protoreflect.Message { + mi := &file_light_light_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RetrieveRequest.ProtoReflect.Descriptor instead. +func (*RetrieveRequest) Descriptor() ([]byte, []int) { + return file_light_light_proto_rawDescGZIP(), []int{2} +} + +func (x *RetrieveRequest) GetBatchHeaderHash() []byte { + if x != nil { + return x.BatchHeaderHash + } + return nil +} + +func (x *RetrieveRequest) GetBlobIndex() uint32 { + if x != nil { + return x.BlobIndex + } + return 0 +} + +type RetrieveReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status bool `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *RetrieveReply) Reset() { + *x = RetrieveReply{} + if protoimpl.UnsafeEnabled { + mi := &file_light_light_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RetrieveReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RetrieveReply) ProtoMessage() {} + +func (x *RetrieveReply) ProtoReflect() protoreflect.Message { + mi := &file_light_light_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RetrieveReply.ProtoReflect.Descriptor instead. +func (*RetrieveReply) Descriptor() ([]byte, []int) { + return file_light_light_proto_rawDescGZIP(), []int{3} +} + +func (x *RetrieveReply) GetStatus() bool { + if x != nil { + return x.Status + } + return false +} + +func (x *RetrieveReply) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +var File_light_light_proto protoreflect.FileDescriptor + +var file_light_light_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x22, 0x8d, 0x01, 0x0a, 0x0d, 0x53, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x08, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x62, 0x61, 0x74, + 0x63, 0x68, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x48, 0x61, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x62, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x05, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x22, 0x27, 0x0a, 0x0b, 0x53, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x22, 0x5c, 0x0a, 0x0f, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x0f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x61, + 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x62, 0x49, 0x6e, 0x64, 0x65, + 0x78, 0x22, 0x3b, 0x0a, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x79, + 0x0a, 0x05, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x34, 0x0a, 0x06, 0x53, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x12, 0x14, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e, + 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3a, 0x0a, + 0x08, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x67, 0x68, + 0x74, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x14, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, + 0x76, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x30, + 0x67, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2d, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x2f, 0x72, 0x75, 0x6e, + 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_light_light_proto_rawDescOnce sync.Once + file_light_light_proto_rawDescData = file_light_light_proto_rawDesc +) + +func file_light_light_proto_rawDescGZIP() []byte { + file_light_light_proto_rawDescOnce.Do(func() { + file_light_light_proto_rawDescData = protoimpl.X.CompressGZIP(file_light_light_proto_rawDescData) + }) + return file_light_light_proto_rawDescData +} + +var file_light_light_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_light_light_proto_goTypes = []interface{}{ + (*SampleRequest)(nil), // 0: light.SampleRequest + (*SampleReply)(nil), // 1: light.SampleReply + (*RetrieveRequest)(nil), // 2: light.RetrieveRequest + (*RetrieveReply)(nil), // 3: light.RetrieveReply +} +var file_light_light_proto_depIdxs = []int32{ + 0, // 0: light.Light.Sample:input_type -> light.SampleRequest + 2, // 1: light.Light.Retrieve:input_type -> light.RetrieveRequest + 1, // 2: light.Light.Sample:output_type -> light.SampleReply + 3, // 3: light.Light.Retrieve:output_type -> light.RetrieveReply + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_light_light_proto_init() } +func file_light_light_proto_init() { + if File_light_light_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_light_light_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SampleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_light_light_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SampleReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_light_light_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RetrieveRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_light_light_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RetrieveReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_light_light_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_light_light_proto_goTypes, + DependencyIndexes: file_light_light_proto_depIdxs, + MessageInfos: file_light_light_proto_msgTypes, + }.Build() + File_light_light_proto = out.File + file_light_light_proto_rawDesc = nil + file_light_light_proto_goTypes = nil + file_light_light_proto_depIdxs = nil +} diff --git a/helper/da/light/light_grpc.pb.go b/helper/da/light/light_grpc.pb.go new file mode 100644 index 00000000..0586c987 --- /dev/null +++ b/helper/da/light/light_grpc.pb.go @@ -0,0 +1,141 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v4.25.3 +// source: light/light.proto + +package light + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// LightClient is the client API for Light service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type LightClient interface { + Sample(ctx context.Context, in *SampleRequest, opts ...grpc.CallOption) (*SampleReply, error) + Retrieve(ctx context.Context, in *RetrieveRequest, opts ...grpc.CallOption) (*RetrieveReply, error) +} + +type lightClient struct { + cc grpc.ClientConnInterface +} + +func NewLightClient(cc grpc.ClientConnInterface) LightClient { + return &lightClient{cc} +} + +func (c *lightClient) Sample(ctx context.Context, in *SampleRequest, opts ...grpc.CallOption) (*SampleReply, error) { + out := new(SampleReply) + err := c.cc.Invoke(ctx, "/light.Light/Sample", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *lightClient) Retrieve(ctx context.Context, in *RetrieveRequest, opts ...grpc.CallOption) (*RetrieveReply, error) { + out := new(RetrieveReply) + err := c.cc.Invoke(ctx, "/light.Light/Retrieve", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// LightServer is the server API for Light service. +// All implementations must embed UnimplementedLightServer +// for forward compatibility +type LightServer interface { + Sample(context.Context, *SampleRequest) (*SampleReply, error) + Retrieve(context.Context, *RetrieveRequest) (*RetrieveReply, error) + mustEmbedUnimplementedLightServer() +} + +// UnimplementedLightServer must be embedded to have forward compatible implementations. +type UnimplementedLightServer struct { +} + +func (UnimplementedLightServer) Sample(context.Context, *SampleRequest) (*SampleReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Sample not implemented") +} +func (UnimplementedLightServer) Retrieve(context.Context, *RetrieveRequest) (*RetrieveReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Retrieve not implemented") +} +func (UnimplementedLightServer) mustEmbedUnimplementedLightServer() {} + +// UnsafeLightServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to LightServer will +// result in compilation errors. +type UnsafeLightServer interface { + mustEmbedUnimplementedLightServer() +} + +func RegisterLightServer(s grpc.ServiceRegistrar, srv LightServer) { + s.RegisterService(&Light_ServiceDesc, srv) +} + +func _Light_Sample_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SampleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LightServer).Sample(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/light.Light/Sample", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LightServer).Sample(ctx, req.(*SampleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Light_Retrieve_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RetrieveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LightServer).Retrieve(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/light.Light/Retrieve", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LightServer).Retrieve(ctx, req.(*RetrieveRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Light_ServiceDesc is the grpc.ServiceDesc for Light service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Light_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "light.Light", + HandlerType: (*LightServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Sample", + Handler: _Light_Sample_Handler, + }, + { + MethodName: "Retrieve", + Handler: _Light_Retrieve_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "light/light.proto", +} diff --git a/helper/da/main.go b/helper/da/main.go new file mode 100644 index 00000000..001737a8 --- /dev/null +++ b/helper/da/main.go @@ -0,0 +1,89 @@ +package main + +import ( + "context" + "flag" + "fmt" + "io" + "log" + "net/url" + "os" + "os/signal" + "time" + + "github.com/0glabs/0g-evmos/helper/da/service" + "github.com/0glabs/0g-evmos/helper/da/types" + + "github.com/lesismal/nbio/nbhttp" + "github.com/lesismal/nbio/nbhttp/websocket" +) + +const ( + subscribeMsg = "{\"jsonrpc\":\"2.0\",\"method\":\"subscribe\",\"id\":1,\"params\":{\"query\":\"tm.event='Tx'\"}}" +) + +var ( + rpcAddress = flag.String("rpc-address", "34.214.2.28:32001", "address of da-light rpc server") + wsAddress = flag.String("ws-address", "127.0.0.1:26657", "address of emvos ws server") + relativePath = flag.String("relative-path", "", "relative path of evmosd") + account = flag.String("account", "", "account to run evmosd cli") + keyring = flag.String("keyring", "", "keyring to run evmosd cli") + homePath = flag.String("home", "", "home path of evmosd node") +) + +func newUpgrader() *websocket.Upgrader { + u := websocket.NewUpgrader() + u.OnMessage(func(c *websocket.Conn, messageType websocket.MessageType, data []byte) { + log.Println("onEcho:", string(data)) + ctx := context.WithValue(context.Background(), types.DA_RPC_ADDRESS, *rpcAddress) + ctx = context.WithValue(ctx, types.NODE_CLI_RELATIVE_PATH, *relativePath) + ctx = context.WithValue(ctx, types.NODE_CLI_EXEC_ACCOUNT, *account) + ctx = context.WithValue(ctx, types.NODE_CLI_EXEC_KEYRING, *keyring) + ctx = context.WithValue(ctx, types.NODE_HOME_PATH, *homePath) + go func() { service.OnMessage(ctx, c, messageType, data) }() + }) + + u.OnClose(func(c *websocket.Conn, err error) { + fmt.Println("OnClose:", c.RemoteAddr().String(), err) + service.OnClose() + }) + + return u +} + +func main() { + flag.Parse() + engine := nbhttp.NewEngine(nbhttp.Config{}) + err := engine.Start() + if err != nil { + fmt.Printf("nbio.Start failed: %v\n", err) + return + } + + go func() { + u := url.URL{Scheme: "ws", Host: *wsAddress, Path: "/websocket"} + dialer := &websocket.Dialer{ + Engine: engine, + Upgrader: newUpgrader(), + DialTimeout: time.Second * 3, + } + c, res, err := dialer.Dial(u.String(), nil) + if err != nil { + if res != nil && res.Body != nil { + bReason, _ := io.ReadAll(res.Body) + fmt.Printf("dial failed: %v, reason: %v\n", err, string(bReason)) + } else { + fmt.Printf("dial failed: %v\n", err) + } + return + } + c.WriteMessage(websocket.TextMessage, []byte(subscribeMsg)) + }() + + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt) + <-interrupt + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + engine.Shutdown(ctx) +} diff --git a/helper/da/proto/light.proto b/helper/da/proto/light.proto new file mode 100644 index 00000000..f816b54f --- /dev/null +++ b/helper/da/proto/light.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package light; + +option go_package = "proto/light"; + +service Light { + rpc Sample(SampleRequest) returns (SampleReply) {} + rpc Retrieve(RetrieveRequest) returns (RetrieveReply) {} +} + +// SampleRequest contains the blob to sample (by batch and blob index) and required sample times +message SampleRequest { + bytes stream_id = 1; + bytes batch_header_hash = 2; + uint32 blob_index = 3; + uint32 times = 4; +} + +// SampleReply contains the sample result +message SampleReply { + bool success = 1; +} + +message RetrieveRequest { + bytes batch_header_hash = 1; + uint32 blob_index = 2; +} + +message RetrieveReply { + bool status = 1; + bytes data = 2; +} \ No newline at end of file diff --git a/helper/da/service/handler.go b/helper/da/service/handler.go new file mode 100644 index 00000000..e7f5d19f --- /dev/null +++ b/helper/da/service/handler.go @@ -0,0 +1,186 @@ +package service + +import ( + "context" + "encoding/hex" + "os" + "os/exec" + "strconv" + "strings" + + "github.com/0glabs/0g-evmos/helper/da/client" + "github.com/0glabs/0g-evmos/helper/da/types" + "github.com/0glabs/0g-evmos/helper/da/utils/sizedw8grp" + + jsoniter "github.com/json-iterator/go" + "github.com/lesismal/nbio/nbhttp/websocket" + "github.com/pkg/errors" + "github.com/rs/zerolog/log" +) + +const ( + defaultClientInstance = 10 +) + +var rpcClient client.DaLightRpcClient + +func OnMessage(ctx context.Context, c *websocket.Conn, messageType websocket.MessageType, data []byte) { + if messageType == websocket.TextMessage { + rawMsg := unwrapJsonRpc(data) + if verifyQuery(rawMsg) { + eventStr := jsoniter.Get(rawMsg, "events").ToString() + events := map[string][]string{} + if err := jsoniter.UnmarshalFromString(eventStr, &events); err == nil { + dasRequestMap := make(map[string]string, 4) + for key, val := range events { + if strings.HasPrefix(key, "das_request.") { + dasRequestMap[strings.ReplaceAll(key, "das_request.", "")] = val[0] + } + } + if len(dasRequestMap) == 4 { + rid, _ := strconv.ParseUint(dasRequestMap["request_id"], 10, 64) + numBlobs, _ := strconv.ParseUint(dasRequestMap["num_blobs"], 10, 64) + req := types.DASRequest{ + RequestId: rid, + StreamId: dasRequestMap["stream_id"], + BatchHeaderHash: dasRequestMap["batch_header_hash"], + NumBlobs: numBlobs, + } + err := handleDasRequest(ctx, req) + + if err != nil { + log.Err(err).Msgf("failed to handle das request: %v, %v", req, err) + } else { + log.Info().Msgf("successfully handled das request: %v", req) + } + } + } + } + } else { + // TODO: handle other message + } +} + +func OnClose() { + if rpcClient != nil { + rpcClient.Destroy() + rpcClient = nil + } +} + +func unwrapJsonRpc(data []byte) []byte { + result := jsoniter.Get(data, "result") + if 0 < len(result.Keys()) { + return []byte(result.ToString()) + } + return []byte{} +} + +func verifyQuery(data []byte) bool { + if len(data) > 0 { + return jsoniter.Get(data, "query").ToString() == "tm.event='Tx'" + } + return false +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func handleDasRequest(ctx context.Context, request types.DASRequest) error { + if rpcClient == nil { + addrVal := ctx.Value(types.DA_RPC_ADDRESS) + if addrVal == nil { + return errors.New("da light service address not found in context") + } + + limit := ctx.Value(types.INSTANCE_LIMIT) + if limit == nil { + limit = defaultClientInstance + } + + rpcClient = client.NewDaLightClient(addrVal.(string), limit.(int)) + } + + streamID, err := hex.DecodeString(request.StreamId) + if err != nil { + return err + } + + batchHeaderHash, err := hex.DecodeString(request.BatchHeaderHash) + if err != nil { + return err + } + + result := make(chan bool, request.NumBlobs) + taskCnt := min(rpcClient.GetInstanceCount(), int(request.NumBlobs)) + wg := sizedw8grp.New(taskCnt) + + for i := uint64(0); i < request.NumBlobs; i++ { + wg.Add() + go func(idx uint64) { + defer wg.Done() + ret, err := rpcClient.Sample(ctx, streamID, batchHeaderHash, uint32(idx), 1) + if err != nil { + log.Err(err).Msgf("failed to sample data availability with blob index %d", idx) + result <- false + } else { + log.Info().Msgf("sample result for blob index %d: %v", idx, ret) + result <- ret + } + }(i) + } + wg.Wait() + close(result) + + finalResult := true + for val := range result { + if !val { + finalResult = false + break + } + } + + return runEvmosdCliReportDasResult(ctx, request.RequestId, finalResult) +} + +func runEvmosdCliReportDasResult(ctx context.Context, requestId uint64, result bool) error { + relativePath := ctx.Value(types.NODE_CLI_RELATIVE_PATH) + if relativePath == nil { + return errors.New("relativePath not found in context") + } + + account := ctx.Value(types.NODE_CLI_EXEC_ACCOUNT) + if account == nil { + return errors.New("account not found in context") + } + + args := []string{ + "tx", + "das", + "report-das-result", + strconv.FormatUint(requestId, 10), + strconv.FormatBool(result), + "--from", account.(string), + "--gas-prices", "767812500aevmos", // TODO: use args to set gas prices + } + + homePath := ctx.Value(types.NODE_HOME_PATH) + if homePath != nil { + args = append(args, "--home", homePath.(string)) + } + + keyring := ctx.Value(types.NODE_CLI_EXEC_KEYRING) + if keyring != nil { + args = append(args, "--keyring-backend", keyring.(string)) + } + + cmdStr := relativePath.(string) + "evmosd" + cmd := exec.Command(cmdStr, append(args, "-y")...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + return cmd.Run() +} diff --git a/helper/da/types/dasreq.go b/helper/da/types/dasreq.go new file mode 100644 index 00000000..1c3b92e3 --- /dev/null +++ b/helper/da/types/dasreq.go @@ -0,0 +1,8 @@ +package types + +type DASRequest struct { + RequestId uint64 `json:"request_id"` + StreamId string `json:"stream_id"` + BatchHeaderHash string `json:"batch_header_hash"` + NumBlobs uint64 `json:"num_blobs"` +} diff --git a/helper/da/types/keys.go b/helper/da/types/keys.go new file mode 100644 index 00000000..e824f793 --- /dev/null +++ b/helper/da/types/keys.go @@ -0,0 +1,10 @@ +package types + +const ( + DA_RPC_ADDRESS = "rpc_address" + INSTANCE_LIMIT = "instance_limit" + NODE_CLI_RELATIVE_PATH = "relative_path" + NODE_CLI_EXEC_ACCOUNT = "node_exec_account" + NODE_CLI_EXEC_KEYRING = "node_exec_keyring" + NODE_HOME_PATH = "home_path" +) diff --git a/helper/da/utils/sizedw8grp/sizedw8grp.go b/helper/da/utils/sizedw8grp/sizedw8grp.go new file mode 100644 index 00000000..ac7348e6 --- /dev/null +++ b/helper/da/utils/sizedw8grp/sizedw8grp.go @@ -0,0 +1,51 @@ +package sizedw8grp + +import ( + "context" + "math" + "sync" +) + +type SizedWaitGroup struct { + Size int + + current chan struct{} + wg sync.WaitGroup +} + +func New(limit int) SizedWaitGroup { + size := math.MaxInt32 + if limit > 0 { + size = limit + } + return SizedWaitGroup{ + Size: size, + + current: make(chan struct{}, size), + wg: sync.WaitGroup{}, + } +} + +func (s *SizedWaitGroup) Add() { + _ = s.AddWithContext(context.Background()) +} + +func (s *SizedWaitGroup) AddWithContext(ctx context.Context) error { + select { + case <-ctx.Done(): + return ctx.Err() + case s.current <- struct{}{}: + break + } + s.wg.Add(1) + return nil +} + +func (s *SizedWaitGroup) Done() { + <-s.current + s.wg.Done() +} + +func (s *SizedWaitGroup) Wait() { + s.wg.Wait() +} diff --git a/tests/e2e/e2e_community_update_params_test.go b/tests/e2e/e2e_community_update_params_test.go index e406dccf..5fc42e93 100644 --- a/tests/e2e/e2e_community_update_params_test.go +++ b/tests/e2e/e2e_community_update_params_test.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - // communitytypes "github.com/kava-labs/kava/x/community/types" + // communitytypes "github.com/0glabs/0g-chain/x/community/types" ) // func (suite *IntegrationTestSuite) TestCommunityUpdateParams_NonAuthority() { diff --git a/tests/e2e/e2e_convert_cosmos_coins_test.go b/tests/e2e/e2e_convert_cosmos_coins_test.go index aca92140..3f3aa7e5 100644 --- a/tests/e2e/e2e_convert_cosmos_coins_test.go +++ b/tests/e2e/e2e_convert_cosmos_coins_test.go @@ -12,9 +12,9 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/kava-labs/kava/tests/e2e/testutil" - "github.com/kava-labs/kava/tests/util" - evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/tests/e2e/testutil" + "github.com/0glabs/0g-chain/tests/util" + evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" ) const initialCosmosCoinConversionDenomFunds = int64(1e4) diff --git a/tests/e2e/e2e_evm_contracts_test.go b/tests/e2e/e2e_evm_contracts_test.go index 521448d2..b68a4f4a 100644 --- a/tests/e2e/e2e_evm_contracts_test.go +++ b/tests/e2e/e2e_evm_contracts_test.go @@ -10,12 +10,12 @@ import ( txtypes "github.com/cosmos/cosmos-sdk/types/tx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/kava-labs/kava/app" - // cdptypes "github.com/kava-labs/kava/x/cdp/types" - // evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + // cdptypes "github.com/0glabs/0g-chain/x/cdp/types" + // evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" - "github.com/kava-labs/kava/tests/e2e/contracts/greeter" - "github.com/kava-labs/kava/tests/util" + "github.com/0glabs/0g-chain/tests/e2e/contracts/greeter" + "github.com/0glabs/0g-chain/tests/util" ) func (suite *IntegrationTestSuite) TestEthCallToGreeterContract() { diff --git a/tests/e2e/e2e_grpc_client_query_test.go b/tests/e2e/e2e_grpc_client_query_test.go index b066c9fa..a565bc89 100644 --- a/tests/e2e/e2e_grpc_client_query_test.go +++ b/tests/e2e/e2e_grpc_client_query_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" + evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" ) func (suite *IntegrationTestSuite) TestGrpcClientQueryCosmosModule_Balance() { diff --git a/tests/e2e/e2e_min_fees_test.go b/tests/e2e/e2e_min_fees_test.go index bf908f53..21cf7d89 100644 --- a/tests/e2e/e2e_min_fees_test.go +++ b/tests/e2e/e2e_min_fees_test.go @@ -12,8 +12,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/tests/util" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/tests/util" ) func (suite *IntegrationTestSuite) TestEthGasPriceReturnsMinFee() { diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 63e63c46..f043335a 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -18,9 +18,9 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" emtypes "github.com/evmos/ethermint/types" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/tests/e2e/testutil" - "github.com/kava-labs/kava/tests/util" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/tests/e2e/testutil" + "github.com/0glabs/0g-chain/tests/util" ) var ( diff --git a/tests/e2e/runner/live.go b/tests/e2e/runner/live.go index ecefd731..e9a1da28 100644 --- a/tests/e2e/runner/live.go +++ b/tests/e2e/runner/live.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/kava-labs/kava/client/grpc" + "github.com/0glabs/0g-chain/client/grpc" ) // LiveNodeRunnerConfig implements NodeRunner. diff --git a/tests/e2e/testutil/account.go b/tests/e2e/testutil/account.go index 3db20ef5..ca67e2ad 100644 --- a/tests/e2e/testutil/account.go +++ b/tests/e2e/testutil/account.go @@ -28,8 +28,8 @@ import ( emtests "github.com/evmos/ethermint/tests" emtypes "github.com/evmos/ethermint/types" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/tests/util" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/tests/util" ) // SigningAccount wraps details about an account and its private keys. diff --git a/tests/e2e/testutil/chain.go b/tests/e2e/testutil/chain.go index c0586070..3e4a5153 100644 --- a/tests/e2e/testutil/chain.go +++ b/tests/e2e/testutil/chain.go @@ -21,11 +21,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" - "github.com/kava-labs/kava/app" - kavaparams "github.com/kava-labs/kava/app/params" - "github.com/kava-labs/kava/client/grpc" - "github.com/kava-labs/kava/tests/e2e/runner" - "github.com/kava-labs/kava/tests/util" + "github.com/0glabs/0g-chain/app" + kavaparams "github.com/0glabs/0g-chain/app/params" + "github.com/0glabs/0g-chain/client/grpc" + "github.com/0glabs/0g-chain/tests/e2e/runner" + "github.com/0glabs/0g-chain/tests/util" ) // Chain wraps query clients & accounts for a network diff --git a/tests/e2e/testutil/config.go b/tests/e2e/testutil/config.go index bf78e7ec..57a7d334 100644 --- a/tests/e2e/testutil/config.go +++ b/tests/e2e/testutil/config.go @@ -27,7 +27,7 @@ type SuiteConfig struct { IncludeIbcTests bool // The contract address of a deployed ERC-20 token - KavaErc20Address string + ZgchainERC20Address string // When true, the chains will remain running after tests complete (pass or fail) SkipShutdown bool @@ -66,7 +66,7 @@ func ParseSuiteConfig() SuiteConfig { // this mnemonic is expected to be a funded account that can seed the funds for all // new accounts created during tests. it will be available under Accounts["whale"] FundedAccountMnemonic: nonemptyStringEnv("E2E_KAVA_FUNDED_ACCOUNT_MNEMONIC"), - KavaErc20Address: nonemptyStringEnv("E2E_KAVA_ERC20_ADDRESS"), + ZgchainERC20Address: nonemptyStringEnv("E2E_KAVA_ERC20_ADDRESS"), IncludeIbcTests: mustParseBool("E2E_INCLUDE_IBC_TESTS"), } diff --git a/tests/e2e/testutil/init_evm.go b/tests/e2e/testutil/init_evm.go index 9c44f063..de920f12 100644 --- a/tests/e2e/testutil/init_evm.go +++ b/tests/e2e/testutil/init_evm.go @@ -7,9 +7,9 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/kava-labs/kava/tests/e2e/contracts/greeter" - // "github.com/kava-labs/kava/x/cdp/types" - evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/tests/e2e/contracts/greeter" + // "github.com/0glabs/0g-chain/x/cdp/types" + evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" ) // InitKavaEvmData is run after the chain is running, but before the tests are run. @@ -35,7 +35,7 @@ func (suite *E2eTestSuite) InitKavaEvmData() { found := false erc20Addr := suite.DeployedErc20.Address.Hex() for _, p := range params.Params.EnabledConversionPairs { - if common.BytesToAddress(p.KavaERC20Address).Hex() == erc20Addr { + if common.BytesToAddress(p.ZgchainERC20Address).Hex() == erc20Addr { found = true suite.DeployedErc20.CosmosDenom = p.Denom } diff --git a/tests/e2e/testutil/suite.go b/tests/e2e/testutil/suite.go index 5c0d93bb..55ba9352 100644 --- a/tests/e2e/testutil/suite.go +++ b/tests/e2e/testutil/suite.go @@ -10,9 +10,9 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/tests/e2e/runner" - "github.com/kava-labs/kava/tests/util" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/tests/e2e/runner" + "github.com/0glabs/0g-chain/tests/util" ) const ( @@ -27,7 +27,7 @@ const ( ) // DeployedErc20 is a type that wraps the details of the pre-deployed erc20 used by the e2e test suite. -// The Address comes from SuiteConfig.KavaErc20Address +// The Address comes from SuiteConfig.ZgchainERC20Address // The CosmosDenom is fetched from the EnabledConversionPairs param of x/evmutil. // The tests expect the following: // - the funded account has a nonzero balance of the erc20 @@ -90,7 +90,7 @@ func (suite *E2eTestSuite) SetupSuite() { suiteConfig := ParseSuiteConfig() suite.config = suiteConfig suite.DeployedErc20 = DeployedErc20{ - Address: common.HexToAddress(suiteConfig.KavaErc20Address), + Address: common.HexToAddress(suiteConfig.ZgchainERC20Address), // Denom & CdpCollateralType are fetched in InitKavaEvmData() } diff --git a/tests/util/addresses_test.go b/tests/util/addresses_test.go index 85574d7e..3a89c4a5 100644 --- a/tests/util/addresses_test.go +++ b/tests/util/addresses_test.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/tests/util" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/tests/util" ) func TestAddressConversion(t *testing.T) { diff --git a/tests/util/sdksigner.go b/tests/util/sdksigner.go index a37676ff..c5e97f36 100644 --- a/tests/util/sdksigner.go +++ b/tests/util/sdksigner.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "github.com/kava-labs/kava/app/params" + "github.com/0glabs/0g-chain/app/params" "google.golang.org/grpc/codes" grpcstatus "google.golang.org/grpc/status" diff --git a/x/committee/v1/client/cli/query.go b/x/committee/v1/client/cli/query.go new file mode 100644 index 00000000..cdb65c6d --- /dev/null +++ b/x/committee/v1/client/cli/query.go @@ -0,0 +1,87 @@ +package cli + +import ( + "context" + "fmt" + "strings" + + "github.com/spf13/cobra" + + "github.com/0glabs/0g-chain/x/committee/v1/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +// GetQueryCmd returns the cli query commands for the inflation module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the committee module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetCurrentCommitteeID(), + GetRegisteredVoters(), + ) + + return cmd +} + +func GetCurrentCommitteeID() *cobra.Command { + cmd := &cobra.Command{ + Use: "current-committee-id", + Short: "Query the current committee ID", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryCurrentCommitteeIDRequest{} + res, err := queryClient.CurrentCommitteeID(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%v\n", res.CurrentCommitteeID)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func GetRegisteredVoters() *cobra.Command { + cmd := &cobra.Command{ + Use: "registered-voters", + Short: "Query registered voters", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryRegisteredVotersRequest{} + res, err := queryClient.RegisteredVoters(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%v\n", strings.Join(res.Voters, ","))) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/committee/v1/client/cli/tx.go b/x/committee/v1/client/cli/tx.go new file mode 100644 index 00000000..cc648b78 --- /dev/null +++ b/x/committee/v1/client/cli/tx.go @@ -0,0 +1,196 @@ +package cli + +import ( + "bufio" + "bytes" + "encoding/hex" + "errors" + "fmt" + "strconv" + + sdkmath "cosmossdk.io/math" + "github.com/0glabs/0g-chain/crypto/vrf" + "github.com/0glabs/0g-chain/x/committee/v1/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdkkr "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + vrfalgo "github.com/coniks-sys/coniks-go/crypto/vrf" + "github.com/cosmos/cosmos-sdk/client/input" + "github.com/spf13/cobra" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand( + NewRegisterCmd(), + NewVoteCmd(), + ) + return cmd +} + +func NewRegisterCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "register", + Short: "Register a voter", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + // bypass the restriction of set keyring options + ctx := client.GetClientContextFromCmd(cmd).WithKeyringOptions(vrf.VrfOption()) + client.SetCmdClientContext(cmd, ctx) + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + kr := clientCtx.Keyring + // get account name by address + accAddr := clientCtx.GetFromAddress() + accRecord, err := kr.KeyByAddress(accAddr) + if err != nil { + // not found record by address in keyring + return nil + } + + // check voter account record exists + voterAccName := accRecord.Name + "-voter" + _, err = kr.Key(voterAccName) + if err == nil { + // account exists, ask for user confirmation + response, err2 := input.GetConfirmation(fmt.Sprintf("override the existing name %s", voterAccName), bufio.NewReader(clientCtx.Input), cmd.ErrOrStderr()) + if err2 != nil { + return err2 + } + + if !response { + return errors.New("aborted") + } + + err2 = kr.Delete(voterAccName) + if err2 != nil { + return err2 + } + } + + keyringAlgos, _ := kr.SupportedAlgorithms() + algo, err := sdkkr.NewSigningAlgoFromString("vrf", keyringAlgos) + if err != nil { + return err + } + + newRecord, err := kr.NewAccount(voterAccName, "", "", "", algo) + if err != nil { + return err + } + + pubKey, err := newRecord.GetPubKey() + if err != nil { + return err + } + + valAddr, err := sdk.ValAddressFromHex(hex.EncodeToString(clientCtx.GetFromAddress().Bytes())) + if err != nil { + return err + } + + msg := &types.MsgRegister{ + Voter: valAddr.String(), + Key: pubKey.Bytes(), + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +func NewVoteCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote committee-id", + Short: "Vote on a proposal", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + kr := clientCtx.Keyring + + // get account name by address + inAddr := clientCtx.GetFromAddress() + + valAddr, err := sdk.ValAddressFromHex(hex.EncodeToString(inAddr.Bytes())) + if err != nil { + return err + } + + inRecord, err := kr.KeyByAddress(inAddr) + if err != nil { + // not found record by address in keyring + return nil + } + + // check voter account record exists + voterAccName := inRecord.Name + "-voter" + voterRecord, err := kr.Key(voterAccName) + if err != nil { + // not found voter account + return err + } + sk := vrfalgo.PrivateKey(voterRecord.GetLocal().PrivKey.Value) + + committeeID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + votingStartHeight := types.DefaultVotingStartHeight + (committeeID-1)*types.DefaultVotingPeriod + + rsp, err := stakingtypes.NewQueryClient(clientCtx).HistoricalInfo(cmd.Context(), &stakingtypes.QueryHistoricalInfoRequest{Height: int64(votingStartHeight)}) + if err != nil { + return err + } + + var tokens sdkmath.Int + for _, val := range rsp.Hist.Valset { + thisValAddr := val.GetOperator() + if thisValAddr.Equals(valAddr) { + tokens = val.GetTokens() + } + } + + // 1_000 0AGI token / vote + numBallots := tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000)).Quo(sdk.NewInt(1_000)).Uint64() + ballots := make([]*types.Ballot, numBallots) + for i := range ballots { + ballotID := uint64(i) + ballots[i] = &types.Ballot{ + ID: ballotID, + Content: sk.Compute(bytes.Join([][]byte{rsp.Hist.Header.LastCommitHash, types.Uint64ToBytes(ballotID)}, nil)), + } + } + + msg := &types.MsgVote{ + CommitteeID: committeeID, + Voter: valAddr.String(), + Ballots: ballots, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/committee/v1/genesis.go b/x/committee/v1/genesis.go new file mode 100644 index 00000000..c369ff45 --- /dev/null +++ b/x/committee/v1/genesis.go @@ -0,0 +1,56 @@ +package committee + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/0glabs/0g-chain/x/committee/v1/keeper" + "github.com/0glabs/0g-chain/x/committee/v1/types" +) + +// InitGenesis initializes the store state from a genesis state. +func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { + panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) + } + + params := gs.Params + err := keeper.SetParams(ctx, params) + if err != nil { + panic(errorsmod.Wrapf(err, "error setting params")) + } + + keeper.SetCurrentCommitteeID(ctx, gs.CurrentCommitteeID) + + for _, p := range gs.Committees { + keeper.SetCommittee(ctx, p) + } +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { + startHeight, err := keeper.GetVotingStartHeight(ctx) + if err != nil { + panic(err) + } + + period, err := keeper.GetVotingPeriod(ctx) + if err != nil { + panic(err) + } + + currentID, err := keeper.GetCurrentCommitteeID(ctx) + if err != nil { + panic(err) + } + + return types.NewGenesisState( + keeper.GetParams(ctx), + startHeight, + period, + currentID, + keeper.GetCommittees(ctx), + ) +} diff --git a/x/committee/v1/keeper/abci.go b/x/committee/v1/keeper/abci.go new file mode 100644 index 00000000..5357c4e4 --- /dev/null +++ b/x/committee/v1/keeper/abci.go @@ -0,0 +1,72 @@ +package keeper + +import ( + "sort" + + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Ballot struct { + voter sdk.ValAddress + content string +} + +func (k *Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + committeeID, err := k.GetCurrentCommitteeID(ctx) + if err != nil { + // TODO: handle the case where committeeID is not available + return + } + committee, bz := k.GetCommittee(ctx, committeeID) + if !bz { + return + } + + if ctx.BlockHeight() >= int64(committee.StartHeight) { + // We are ready to accept votes for the next committee + if err := k.StoreNewCommittee(ctx, committee.StartHeight); err != nil { + return + } + } + + if ctx.BlockHeight() < int64(committee.EndHeight) { + return + } + + k.IncrementCurrentCommitteeID(ctx) + committee, bz = k.GetCommittee(ctx, committeeID+1) + if !bz { + return + } + + ballots := []Ballot{} + seen := make(map[string]struct{}) + for _, vote := range committee.Votes { + for _, ballot := range vote.Ballots { + ballot := Ballot{ + voter: vote.Voter, + content: string(ballot.Content), + } + if _, ok := seen[ballot.content]; ok { + continue + } + ballots = append(ballots, ballot) + seen[ballot.content] = struct{}{} + } + } + sort.Slice(ballots, func(i, j int) bool { + return ballots[i].content < ballots[j].content + }) + + committeeSize := k.GetParams(ctx).CommitteeSize + committee.Members = make([]sdk.ValAddress, committeeSize) + for i := 0; i < int(committeeSize); i = i + 1 { + committee.Members[i] = ballots[i].voter + } + + k.SetCommittee(ctx, committee) +} + +func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) { +} diff --git a/x/committee/v1/keeper/grpc_query.go b/x/committee/v1/keeper/grpc_query.go new file mode 100644 index 00000000..efb23909 --- /dev/null +++ b/x/committee/v1/keeper/grpc_query.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/x/committee/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) CurrentCommitteeID( + c context.Context, + _ *types.QueryCurrentCommitteeIDRequest, +) (*types.QueryCurrentCommitteeIDResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + currentCommitteeID, err := k.GetCurrentCommitteeID(ctx) + if err != nil { + return nil, err + } + return &types.QueryCurrentCommitteeIDResponse{CurrentCommitteeID: currentCommitteeID}, nil +} + +func (k Keeper) RegisteredVoters( + c context.Context, + _ *types.QueryRegisteredVotersRequest, +) (*types.QueryRegisteredVotersResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + voterAddrs := k.GetVoters(ctx) + voters := make([]string, len(voterAddrs)) + for i, voterAddr := range voterAddrs { + voters[i] = voterAddr.String() + } + return &types.QueryRegisteredVotersResponse{Voters: voters}, nil +} diff --git a/x/committee/v1/keeper/keeper.go b/x/committee/v1/keeper/keeper.go new file mode 100644 index 00000000..ab81d32a --- /dev/null +++ b/x/committee/v1/keeper/keeper.go @@ -0,0 +1,323 @@ +package keeper + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + "github.com/cometbft/cometbft/libs/log" + "github.com/coniks-sys/coniks-go/crypto/vrf" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/0glabs/0g-chain/x/committee/v1/types" +) + +// Keeper of the inflation store +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + stakingKeeper types.StakingKeeper +} + +// NewKeeper creates a new mint Keeper instance +func NewKeeper( + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, + stakingKeeper types.StakingKeeper, +) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + stakingKeeper: stakingKeeper, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +// ------------------------------------------ +// Committees +// ------------------------------------------ + +func (k Keeper) SetCurrentCommitteeID(ctx sdk.Context, id uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.CurrentCommitteeIDKey, types.GetKeyFromID(id)) +} + +func (k Keeper) GetCurrentCommitteeID(ctx sdk.Context) (uint64, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.CurrentCommitteeIDKey) + if bz == nil { + return 0, errorsmod.Wrap(types.ErrInvalidGenesis, "current committee ID not set at genesis") + } + return types.Uint64FromBytes(bz), nil +} + +func (k Keeper) IncrementCurrentCommitteeID(ctx sdk.Context) error { + id, err := k.GetCurrentCommitteeID(ctx) + if err != nil { + return err + } + k.SetCurrentCommitteeID(ctx, id+1) + return nil +} + +func (k Keeper) SetVotingStartHeight(ctx sdk.Context, votingStartHeight uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.VotingStartHeightKey, types.GetKeyFromID(votingStartHeight)) +} + +func (k Keeper) GetVotingStartHeight(ctx sdk.Context) (uint64, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.VotingStartHeightKey) + if bz == nil { + return 0, errorsmod.Wrap(types.ErrInvalidGenesis, "voting start height not set at genesis") + } + return types.Uint64FromBytes(bz), nil +} + +func (k Keeper) SetVotingPeriod(ctx sdk.Context, votingPeriod uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.VotingPeriodKey, types.GetKeyFromID(votingPeriod)) +} + +func (k Keeper) GetVotingPeriod(ctx sdk.Context) (uint64, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.VotingPeriodKey) + if bz == nil { + return 0, errorsmod.Wrap(types.ErrInvalidGenesis, "voting period not set at genesis") + } + return types.Uint64FromBytes(bz), nil +} + +// StoreNewCommittee stores a committee, adding a new ID +func (k Keeper) StoreNewCommittee(ctx sdk.Context, votingStartHeight uint64) error { + currentCommitteeID, err := k.GetCurrentCommitteeID(ctx) + if err != nil { + return err + } + + votingPeriod, err := k.GetVotingPeriod(ctx) + if err != nil { + return err + } + com := types.Committee{ + ID: currentCommitteeID + 1, + VotingStartHeight: votingStartHeight, + StartHeight: votingStartHeight + votingPeriod, + EndHeight: votingStartHeight + votingPeriod*2, + Votes: []types.Vote{}, + Members: []sdk.ValAddress{}, + } + k.SetCommittee(ctx, com) + + return nil +} + +func (k Keeper) GetCommittee(ctx sdk.Context, committeeID uint64) (types.Committee, bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.CommitteeKeyPrefix) + bz := store.Get(types.GetKeyFromID(committeeID)) + if bz == nil { + return types.Committee{}, false + } + var com types.Committee + k.cdc.MustUnmarshal(bz, &com) + return com, true +} + +// SetCommittee puts a committee into the store. +func (k Keeper) SetCommittee(ctx sdk.Context, committee types.Committee) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.CommitteeKeyPrefix) + bz := k.cdc.MustMarshal(&committee) + store.Set(types.GetKeyFromID(committee.ID), bz) +} + +// // DeleteProposal removes a proposal from the store. +// func (k Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64) { +// store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ProposalKeyPrefix) +// store.Delete(types.GetKeyFromID(proposalID)) +// } + +// IterateProposals provides an iterator over all stored proposals. +// For each proposal, cb will be called. If cb returns true, the iterator will close and stop. +func (k Keeper) IterateCommittee(ctx sdk.Context, cb func(proposal types.Committee) (stop bool)) { + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.CommitteeKeyPrefix) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var committee types.Committee + k.cdc.MustUnmarshal(iterator.Value(), &committee) + if cb(committee) { + break + } + } +} + +func (k Keeper) GetCommittees(ctx sdk.Context) types.Committees { + results := types.Committees{} + k.IterateCommittee(ctx, func(prop types.Committee) bool { + results = append(results, prop) + return false + }) + return results +} + +// // DeleteProposalAndVotes removes a proposal and its associated votes. +// func (k Keeper) DeleteProposalAndVotes(ctx sdk.Context, proposalID uint64) { +// votes := k.GetVotesByProposal(ctx, proposalID) +// k.DeleteProposal(ctx, proposalID) +// for _, v := range votes { +// k.DeleteVote(ctx, v.ProposalID, v.Voter) +// } +// } + +// ------------------------------------------ +// Votes +// ------------------------------------------ + +// GetVote gets a vote from the store. +func (k Keeper) GetVote(ctx sdk.Context, epochID uint64, voter sdk.ValAddress) (types.Vote, bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VoteKeyPrefix) + bz := store.Get(types.GetVoteKey(epochID, voter)) + if bz == nil { + return types.Vote{}, false + } + var vote types.Vote + k.cdc.MustUnmarshal(bz, &vote) + return vote, true +} + +// SetVote puts a vote into the store. +func (k Keeper) SetVote(ctx sdk.Context, vote types.Vote) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VoteKeyPrefix) + bz := k.cdc.MustMarshal(&vote) + store.Set(types.GetVoteKey(vote.CommitteeID, vote.Voter), bz) +} + +// DeleteVote removes a Vote from the store. +func (k Keeper) DeleteVote(ctx sdk.Context, committeeID uint64, voter sdk.ValAddress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VoteKeyPrefix) + store.Delete(types.GetVoteKey(committeeID, voter)) +} + +// IterateVotes provides an iterator over all stored votes. +// For each vote, cb will be called. If cb returns true, the iterator will close and stop. +func (k Keeper) IterateVotes(ctx sdk.Context, cb func(vote types.Vote) (stop bool)) { + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.VoteKeyPrefix) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var vote types.Vote + k.cdc.MustUnmarshal(iterator.Value(), &vote) + + if cb(vote) { + break + } + } +} + +// GetVotes returns all stored votes. +func (k Keeper) GetVotes(ctx sdk.Context) []types.Vote { + results := []types.Vote{} + k.IterateVotes(ctx, func(vote types.Vote) bool { + results = append(results, vote) + return false + }) + return results +} + +// GetVotesByProposal returns all votes for one proposal. +func (k Keeper) GetVotesByCommittee(ctx sdk.Context, committeeID uint64) []types.Vote { + results := []types.Vote{} + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), append(types.VoteKeyPrefix, types.GetKeyFromID(committeeID)...)) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var vote types.Vote + k.cdc.MustUnmarshal(iterator.Value(), &vote) + results = append(results, vote) + } + + return results +} + +// ------------------------------------------ +// Voters +// ------------------------------------------ + +func (k Keeper) SetVoter(ctx sdk.Context, voter sdk.ValAddress, pk vrf.PublicKey) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VoterKeyPrefix) + store.Set(types.GetVoterKey(voter), pk) + fmt.Printf("voterStoreKey: %v, publicKey: %v\n", types.GetVoterKey(voter), pk) +} + +func (k Keeper) IterateVoters(ctx sdk.Context, cb func(voter sdk.ValAddress, pk vrf.PublicKey) (stop bool)) { + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.VoterKeyPrefix) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + if cb(sdk.ValAddress(iterator.Key()[1:]), vrf.PublicKey(iterator.Value())) { + break + } + } +} + +// GetVotes returns all stored voters +func (k Keeper) GetVoters(ctx sdk.Context) []sdk.ValAddress { + results := []sdk.ValAddress{} + k.IterateVoters(ctx, func(voter sdk.ValAddress, _ vrf.PublicKey) bool { + results = append(results, voter) + return false + }) + return results +} + +func (k Keeper) AddVoter(ctx sdk.Context, voter sdk.ValAddress, key []byte) error { + if len(key) != vrf.PublicKeySize { + return types.ErrInvalidPublicKey + } + + k.SetVoter(ctx, voter, vrf.PublicKey(key)) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeRegister, + sdk.NewAttribute(types.AttributeKeyVoter, voter.String()), + // TODO: types.AttributeKeyPublicKey + ), + ) + + return nil +} + +func (k Keeper) AddVote(ctx sdk.Context, committeeID uint64, voter sdk.ValAddress, ballots []*types.Ballot) error { + // Validate + com, found := k.GetCommittee(ctx, committeeID) + if !found { + return errorsmod.Wrapf(types.ErrUnknownCommittee, "%d", committeeID) + } + if com.HasVotingEndedBy(ctx.BlockHeight()) { + return errorsmod.Wrapf(types.ErrProposalExpired, "%d ≥ %d", ctx.BlockHeight(), com.StartHeight) + } + + // TODO: verify if the voter is registered + // TODO: verify whether ballots are valid or not + + // Store vote, overwriting any prior vote + k.SetVote(ctx, types.NewVote(committeeID, voter, ballots)) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeVote, + sdk.NewAttribute(types.AttributeKeyCommitteeID, fmt.Sprintf("%d", com.ID)), + sdk.NewAttribute(types.AttributeKeyVoter, voter.String()), + // TODO: types.AttributeKeyBallots + ), + ) + + return nil +} diff --git a/x/committee/v1/keeper/msg_server.go b/x/committee/v1/keeper/msg_server.go new file mode 100644 index 00000000..668031d1 --- /dev/null +++ b/x/committee/v1/keeper/msg_server.go @@ -0,0 +1,51 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) + +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/x/committee/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +var _ types.MsgServer = &Keeper{} + +// Register handles MsgRegister messages +func (k Keeper) Register(goCtx context.Context, msg *types.MsgRegister) (*types.MsgRegisterResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + valAddr, err := sdk.ValAddressFromBech32(msg.Voter) + if err != nil { + return nil, err + } + + _, found := k.stakingKeeper.GetValidator(ctx, valAddr) + if !found { + return nil, stakingtypes.ErrNoValidatorFound + } + + if err := k.AddVoter(ctx, valAddr, msg.Key); err != nil { + return nil, err + } + + return &types.MsgRegisterResponse{}, nil +} + +// Vote handles MsgVote messages +func (k Keeper) Vote(goCtx context.Context, msg *types.MsgVote) (*types.MsgVoteResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + voter, err := sdk.ValAddressFromBech32(msg.Voter) + if err != nil { + return nil, err + } + + if err := k.AddVote(ctx, msg.CommitteeID, voter, msg.Ballots); err != nil { + return nil, err + } + + return &types.MsgVoteResponse{}, nil +} diff --git a/x/committee/v1/keeper/params.go b/x/committee/v1/keeper/params.go new file mode 100644 index 00000000..edbe3a20 --- /dev/null +++ b/x/committee/v1/keeper/params.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "github.com/0glabs/0g-chain/x/committee/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if len(bz) == 0 { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + store := ctx.KVStore(k.storeKey) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + + store.Set(types.ParamsKey, bz) + + return nil +} diff --git a/x/committee/v1/module.go b/x/committee/v1/module.go new file mode 100644 index 00000000..4b330ce0 --- /dev/null +++ b/x/committee/v1/module.go @@ -0,0 +1,171 @@ +package committee + +import ( + "context" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/0glabs/0g-chain/x/committee/v1/client/cli" + "github.com/0glabs/0g-chain/x/committee/v1/keeper" + "github.com/0glabs/0g-chain/x/committee/v1/types" +) + +// consensusVersion defines the current x/committee module consensus version. +const consensusVersion = 1 + +// type check to ensure the interface is properly implemented +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} + _ module.BeginBlockAppModule = AppModule{} + _ module.EndBlockAppModule = AppModule{} +) + +// app module Basics object +type AppModuleBasic struct{} + +// Name returns the inflation module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the inflation module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// ConsensusVersion returns the consensus state-breaking version for the module. +func (AppModuleBasic) ConsensusVersion() uint64 { + return consensusVersion +} + +// RegisterInterfaces registers interfaces and implementations of the incentives +// module. +func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(interfaceRegistry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the incentives +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the inflation module. +func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genesisState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genesisState.Validate() +} + +// RegisterRESTRoutes performs a no-op as the inflation module doesn't expose REST +// endpoints +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the inflation module. +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root tx command for the inflation module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() } + +// GetQueryCmd returns no root query command for the inflation module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ___________________________________________________________________________ + +// AppModule implements an application module for the inflation module. +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper + sk *stakingkeeper.Keeper +} + +// NewAppModule creates a new AppModule Object +func NewAppModule( + k keeper.Keeper, + sk *stakingkeeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: k, + sk: sk, + } +} + +// Name returns the inflation module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the inflation module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { + am.keeper.BeginBlock(ctx, req) +} + +func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { + am.keeper.EndBlock(ctx, req) + return []abci.ValidatorUpdate{} +} + +// InitGenesis performs genesis initialization for the inflation module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(data, &genesisState) + InitGenesis(ctx, am.keeper, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the inflation +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(gs) +} + +// ___________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the inflation module. +func (am AppModule) GenerateGenesisState(_ *module.SimulationState) { +} + +// RegisterStoreDecoder registers a decoder for inflation module's types. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +} + +// WeightedOperations doesn't return any inflation module operation. +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} diff --git a/x/committee/v1/types/codec.go b/x/committee/v1/types/codec.go new file mode 100644 index 00000000..288f2b89 --- /dev/null +++ b/x/committee/v1/types/codec.go @@ -0,0 +1,52 @@ +package types + +import ( + "github.com/0glabs/0g-chain/crypto/vrf" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + // ModuleCdc references the global evm module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino JSON compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +const ( + // Amino names + registerName = "evmos/committee/MsgRegister" + voteName = "evmos/committee/MsgVote" +) + +// NOTE: This is required for the GetSignBytes function +func init() { + RegisterLegacyAminoCodec(amino) + amino.Seal() +} + +// RegisterInterfaces register implementations +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgRegister{}, + &MsgVote{}, + ) + + registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &vrf.PubKey{}) + registry.RegisterImplementations((*cryptotypes.PrivKey)(nil), &vrf.PrivKey{}) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// RegisterLegacyAminoCodec required for EIP-712 +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRegister{}, registerName, nil) + cdc.RegisterConcrete(&MsgVote{}, voteName, nil) +} diff --git a/x/committee/v1/types/council.go b/x/committee/v1/types/council.go new file mode 100644 index 00000000..f879d6ed --- /dev/null +++ b/x/committee/v1/types/council.go @@ -0,0 +1,21 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Committees []Committee +type Votes []Vote + +func (c Committee) HasVotingEndedBy(height int64) bool { + return height >= int64(c.StartHeight) +} + +// NewVote instantiates a new instance of Vote +func NewVote(committeeID uint64, voter sdk.ValAddress, ballots []*Ballot) Vote { + return Vote{ + CommitteeID: committeeID, + Voter: voter, + Ballots: ballots, + } +} diff --git a/x/committee/v1/types/epoch.go b/x/committee/v1/types/epoch.go new file mode 100644 index 00000000..d44612a1 --- /dev/null +++ b/x/committee/v1/types/epoch.go @@ -0,0 +1,3 @@ +package types + +type Epoch struct{} diff --git a/x/committee/v1/types/errors.go b/x/committee/v1/types/errors.go new file mode 100644 index 00000000..9ee139fb --- /dev/null +++ b/x/committee/v1/types/errors.go @@ -0,0 +1,19 @@ +package types + +import errorsmod "cosmossdk.io/errors" + +var ( + ErrUnknownCommittee = errorsmod.Register(ModuleName, 2, "committee not found") + ErrInvalidCommittee = errorsmod.Register(ModuleName, 3, "invalid committee") + ErrUnknownProposal = errorsmod.Register(ModuleName, 4, "proposal not found") + ErrProposalExpired = errorsmod.Register(ModuleName, 5, "proposal expired") + ErrInvalidPubProposal = errorsmod.Register(ModuleName, 6, "invalid pubproposal") + ErrUnknownVote = errorsmod.Register(ModuleName, 7, "vote not found") + ErrInvalidGenesis = errorsmod.Register(ModuleName, 8, "invalid genesis") + ErrNoProposalHandlerExists = errorsmod.Register(ModuleName, 9, "pubproposal has no corresponding handler") + ErrUnknownSubspace = errorsmod.Register(ModuleName, 10, "subspace not found") + ErrInvalidVoteType = errorsmod.Register(ModuleName, 11, "invalid vote type") + ErrNotFoundProposalTally = errorsmod.Register(ModuleName, 12, "proposal tally not found") + ErrInvalidPublicKey = errorsmod.Register(ModuleName, 13, "invalid public key") + ErrInvalidValidatorAddress = errorsmod.Register(ModuleName, 14, "invalid validator address") +) diff --git a/x/committee/v1/types/events.go b/x/committee/v1/types/events.go new file mode 100644 index 00000000..a8807b44 --- /dev/null +++ b/x/committee/v1/types/events.go @@ -0,0 +1,19 @@ +package types + +// Module event types +const ( + EventTypeRegister = "register" + EventTypeVote = "vote" + + AttributeValueCategory = "committee" + AttributeKeyCommitteeID = "committee_id" + AttributeKeyProposalID = "proposal_id" + AttributeKeyVotingStartHeight = "voting_start_height" + AttributeKeyVotingEndHeight = "voting_end_height" + AttributeKeyProposalCloseStatus = "status" + AttributeKeyVoter = "voter" + AttributeKeyBallots = "ballots" + AttributeKeyPublicKey = "public_key" + AttributeKeyProposalOutcome = "proposal_outcome" + AttributeKeyProposalTally = "proposal_tally" +) diff --git a/x/committee/v1/types/genesis.go b/x/committee/v1/types/genesis.go new file mode 100644 index 00000000..66fea4f3 --- /dev/null +++ b/x/committee/v1/types/genesis.go @@ -0,0 +1,42 @@ +package types + +const ( + DefaultVotingStartHeight = 1 + DefaultVotingPeriod = 200 +) + +// NewGenesisState returns a new genesis state object for the module. +func NewGenesisState(params Params, votingStartHeight uint64, votingPeriod uint64, currentCommitteeID uint64, committees Committees) *GenesisState { + return &GenesisState{ + Params: params, + VotingStartHeight: votingStartHeight, + VotingPeriod: votingPeriod, + CurrentCommitteeID: currentCommitteeID, + Committees: committees, + } +} + +// DefaultGenesisState returns the default genesis state for the module. +func DefaultGenesisState() *GenesisState { + return NewGenesisState( + Params{ + CommitteeSize: 1, + }, + DefaultVotingStartHeight, + DefaultVotingPeriod, + 1, + []Committee{ + { + ID: 1, + VotingStartHeight: DefaultVotingStartHeight, + StartHeight: DefaultVotingStartHeight + DefaultVotingPeriod, + EndHeight: DefaultVotingStartHeight + DefaultVotingPeriod*2, + Votes: Votes{}, + }}, + ) +} + +// Validate performs basic validation of genesis data. +func (gs GenesisState) Validate() error { + return nil +} diff --git a/x/committee/v1/types/genesis.pb.go b/x/committee/v1/types/genesis.pb.go new file mode 100644 index 00000000..8ab49adf --- /dev/null +++ b/x/committee/v1/types/genesis.pb.go @@ -0,0 +1,1467 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/committee/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Params struct { + CommitteeSize uint64 `protobuf:"varint,1,opt,name=committee_size,json=committeeSize,proto3" json:"committee_size,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_8ed77f46b627050b, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetCommitteeSize() uint64 { + if m != nil { + return m.CommitteeSize + } + return 0 +} + +// GenesisState defines the committee module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + VotingStartHeight uint64 `protobuf:"varint,2,opt,name=voting_start_height,json=votingStartHeight,proto3" json:"voting_start_height,omitempty"` + VotingPeriod uint64 `protobuf:"varint,3,opt,name=voting_period,json=votingPeriod,proto3" json:"voting_period,omitempty"` + CurrentCommitteeID uint64 `protobuf:"varint,4,opt,name=current_committee_id,json=currentCommitteeId,proto3" json:"current_committee_id,omitempty"` + Committees []Committee `protobuf:"bytes,5,rep,name=committees,proto3" json:"committees"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_8ed77f46b627050b, []int{1} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +type Committee struct { + ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + VotingStartHeight uint64 `protobuf:"varint,2,opt,name=voting_start_height,json=votingStartHeight,proto3" json:"voting_start_height,omitempty"` + StartHeight uint64 `protobuf:"varint,3,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + EndHeight uint64 `protobuf:"varint,4,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + Votes []Vote `protobuf:"bytes,5,rep,name=votes,proto3" json:"votes"` + Members []github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,6,rep,name=members,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"members,omitempty"` +} + +func (m *Committee) Reset() { *m = Committee{} } +func (m *Committee) String() string { return proto.CompactTextString(m) } +func (*Committee) ProtoMessage() {} +func (*Committee) Descriptor() ([]byte, []int) { + return fileDescriptor_8ed77f46b627050b, []int{2} +} +func (m *Committee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Committee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Committee.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 *Committee) XXX_Merge(src proto.Message) { + xxx_messageInfo_Committee.Merge(m, src) +} +func (m *Committee) XXX_Size() int { + return m.Size() +} +func (m *Committee) XXX_DiscardUnknown() { + xxx_messageInfo_Committee.DiscardUnknown(m) +} + +var xxx_messageInfo_Committee proto.InternalMessageInfo + +func (m *Committee) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Committee) GetVotingStartHeight() uint64 { + if m != nil { + return m.VotingStartHeight + } + return 0 +} + +func (m *Committee) GetStartHeight() uint64 { + if m != nil { + return m.StartHeight + } + return 0 +} + +func (m *Committee) GetEndHeight() uint64 { + if m != nil { + return m.EndHeight + } + return 0 +} + +func (m *Committee) GetVotes() []Vote { + if m != nil { + return m.Votes + } + return nil +} + +func (m *Committee) GetMembers() []github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.Members + } + return nil +} + +type Vote struct { + CommitteeID uint64 `protobuf:"varint,1,opt,name=committee_id,json=committeeId,proto3" json:"committee_id,omitempty"` + Voter github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=voter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"voter,omitempty"` + Ballots []*Ballot `protobuf:"bytes,3,rep,name=ballots,proto3" json:"ballots,omitempty"` +} + +func (m *Vote) Reset() { *m = Vote{} } +func (m *Vote) String() string { return proto.CompactTextString(m) } +func (*Vote) ProtoMessage() {} +func (*Vote) Descriptor() ([]byte, []int) { + return fileDescriptor_8ed77f46b627050b, []int{3} +} +func (m *Vote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Vote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Vote.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 *Vote) XXX_Merge(src proto.Message) { + xxx_messageInfo_Vote.Merge(m, src) +} +func (m *Vote) XXX_Size() int { + return m.Size() +} +func (m *Vote) XXX_DiscardUnknown() { + xxx_messageInfo_Vote.DiscardUnknown(m) +} + +var xxx_messageInfo_Vote proto.InternalMessageInfo + +type Ballot struct { + ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Content []byte `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` +} + +func (m *Ballot) Reset() { *m = Ballot{} } +func (m *Ballot) String() string { return proto.CompactTextString(m) } +func (*Ballot) ProtoMessage() {} +func (*Ballot) Descriptor() ([]byte, []int) { + return fileDescriptor_8ed77f46b627050b, []int{4} +} +func (m *Ballot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Ballot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Ballot.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 *Ballot) XXX_Merge(src proto.Message) { + xxx_messageInfo_Ballot.Merge(m, src) +} +func (m *Ballot) XXX_Size() int { + return m.Size() +} +func (m *Ballot) XXX_DiscardUnknown() { + xxx_messageInfo_Ballot.DiscardUnknown(m) +} + +var xxx_messageInfo_Ballot proto.InternalMessageInfo + +func (m *Ballot) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Ballot) GetContent() []byte { + if m != nil { + return m.Content + } + return nil +} + +func init() { + proto.RegisterType((*Params)(nil), "zgc.committee.v1.Params") + proto.RegisterType((*GenesisState)(nil), "zgc.committee.v1.GenesisState") + proto.RegisterType((*Committee)(nil), "zgc.committee.v1.Committee") + proto.RegisterType((*Vote)(nil), "zgc.committee.v1.Vote") + proto.RegisterType((*Ballot)(nil), "zgc.committee.v1.Ballot") +} + +func init() { proto.RegisterFile("zgc/committee/v1/genesis.proto", fileDescriptor_8ed77f46b627050b) } + +var fileDescriptor_8ed77f46b627050b = []byte{ + // 596 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4d, 0x6e, 0xd3, 0x40, + 0x14, 0xc7, 0x63, 0x27, 0x75, 0xd5, 0x89, 0xcb, 0xc7, 0xb4, 0xaa, 0xdc, 0x22, 0xec, 0x12, 0x84, + 0x94, 0x4d, 0xec, 0x36, 0x48, 0x2c, 0xba, 0xab, 0x5b, 0x89, 0x64, 0x57, 0x39, 0x52, 0x17, 0x2c, + 0x88, 0xfc, 0x31, 0x4c, 0x46, 0xc4, 0x9e, 0xc8, 0x33, 0x89, 0x48, 0x4e, 0xc0, 0x92, 0x23, 0x70, + 0x01, 0x58, 0x71, 0x88, 0x2e, 0x2b, 0xc4, 0x82, 0x55, 0x84, 0x9c, 0x5b, 0xb0, 0x42, 0x99, 0xb1, + 0x4d, 0x92, 0xc2, 0x02, 0x89, 0x95, 0x3d, 0xef, 0xff, 0x9b, 0x37, 0xf3, 0x7f, 0xef, 0xd9, 0xc0, + 0x9c, 0xe1, 0xd0, 0x09, 0x69, 0x1c, 0x13, 0xce, 0x11, 0x72, 0x26, 0xa7, 0x0e, 0x46, 0x09, 0x62, + 0x84, 0xd9, 0xa3, 0x94, 0x72, 0x0a, 0x1f, 0xcc, 0x70, 0x68, 0x97, 0xba, 0x3d, 0x39, 0x3d, 0x3a, + 0x0c, 0x29, 0x8b, 0x29, 0xeb, 0x0b, 0xdd, 0x91, 0x0b, 0x09, 0x1f, 0xed, 0x63, 0x8a, 0xa9, 0x8c, + 0x2f, 0xdf, 0xf2, 0xe8, 0x21, 0xa6, 0x14, 0x0f, 0x91, 0x23, 0x56, 0xc1, 0xf8, 0x8d, 0xe3, 0x27, + 0xd3, 0x5c, 0xb2, 0x36, 0x25, 0x4e, 0x62, 0xc4, 0xb8, 0x1f, 0x8f, 0x24, 0xd0, 0x70, 0x80, 0x76, + 0xe5, 0xa7, 0x7e, 0xcc, 0xe0, 0x33, 0x70, 0xaf, 0xbc, 0x46, 0x9f, 0x91, 0x19, 0x32, 0x94, 0x63, + 0xa5, 0x59, 0xf3, 0x76, 0xcb, 0x68, 0x8f, 0xcc, 0x50, 0xe3, 0xb3, 0x0a, 0xf4, 0x97, 0xd2, 0x41, + 0x8f, 0xfb, 0x1c, 0xc1, 0x17, 0x40, 0x1b, 0x89, 0x0c, 0x82, 0xaf, 0xb7, 0x0d, 0x7b, 0xd3, 0x91, + 0x2d, 0x4f, 0x70, 0x6b, 0x37, 0x73, 0xab, 0xe2, 0xe5, 0x34, 0xb4, 0xc1, 0xde, 0x84, 0x72, 0x92, + 0xe0, 0x3e, 0xe3, 0x7e, 0xca, 0xfb, 0x03, 0x44, 0xf0, 0x80, 0x1b, 0xaa, 0x38, 0xf4, 0xa1, 0x94, + 0x7a, 0x4b, 0xa5, 0x23, 0x04, 0xf8, 0x14, 0xec, 0xe6, 0xfc, 0x08, 0xa5, 0x84, 0x46, 0x46, 0x55, + 0x90, 0xba, 0x0c, 0x5e, 0x89, 0x18, 0xec, 0x80, 0xfd, 0x70, 0x9c, 0xa6, 0x28, 0xe1, 0xfd, 0xdf, + 0x66, 0x48, 0x64, 0xd4, 0x96, 0xac, 0x7b, 0x90, 0xcd, 0x2d, 0x78, 0x21, 0xf5, 0x8b, 0x42, 0xee, + 0x5e, 0x7a, 0x30, 0xdc, 0x8c, 0x45, 0xf0, 0x1c, 0x80, 0x32, 0x03, 0x33, 0xb6, 0x8e, 0xab, 0xcd, + 0x7a, 0xfb, 0xd1, 0x5d, 0x6b, 0xe5, 0x96, 0xdc, 0xdd, 0xca, 0xa6, 0xb3, 0xda, 0xfb, 0x8f, 0x56, + 0xa5, 0xf1, 0x49, 0x05, 0x3b, 0x25, 0x05, 0x0f, 0x80, 0x4a, 0x22, 0x59, 0x59, 0x57, 0xcb, 0xe6, + 0x96, 0xda, 0xbd, 0xf4, 0x54, 0x12, 0xfd, 0x73, 0x35, 0x9e, 0x00, 0x7d, 0x0d, 0x94, 0xc5, 0xa8, + 0xb3, 0x15, 0xe4, 0x31, 0x00, 0x28, 0x89, 0x0a, 0x40, 0x54, 0xc0, 0xdb, 0x41, 0x49, 0x94, 0xcb, + 0x6d, 0xb0, 0x35, 0xa1, 0xbc, 0xf4, 0x76, 0x70, 0xd7, 0xdb, 0x35, 0xe5, 0x85, 0x2d, 0x89, 0xc2, + 0x00, 0x6c, 0xc7, 0x28, 0x0e, 0x50, 0xca, 0x0c, 0xed, 0xb8, 0xda, 0xd4, 0xdd, 0xce, 0xcf, 0xb9, + 0xd5, 0xc2, 0x84, 0x0f, 0xc6, 0xc1, 0x72, 0x6f, 0x3e, 0xad, 0xf9, 0xa3, 0xc5, 0xa2, 0xb7, 0x0e, + 0x9f, 0x8e, 0x10, 0xb3, 0xaf, 0xfd, 0xe1, 0x79, 0x14, 0xa5, 0x88, 0xb1, 0xaf, 0x5f, 0x5a, 0x7b, + 0xf9, 0x4c, 0xe7, 0x11, 0x77, 0xca, 0x11, 0xf3, 0x8a, 0xc4, 0x8d, 0x6f, 0x0a, 0xa8, 0x2d, 0x4f, + 0x86, 0x6d, 0xa0, 0xaf, 0xf5, 0x50, 0x16, 0xed, 0x7e, 0x36, 0xb7, 0xea, 0xab, 0xcd, 0xab, 0x87, + 0x2b, 0x5d, 0x7b, 0x2d, 0x4d, 0xa5, 0xa2, 0x70, 0xff, 0xf3, 0x7a, 0x32, 0x2d, 0x6c, 0x83, 0xed, + 0xc0, 0x1f, 0x0e, 0x29, 0x67, 0x46, 0x55, 0x94, 0xed, 0x0f, 0xd3, 0xee, 0x0a, 0xc0, 0x2b, 0xc0, + 0x7c, 0x0c, 0xce, 0x80, 0x26, 0x85, 0xbf, 0x8e, 0x80, 0x01, 0xb6, 0x43, 0x9a, 0x70, 0x94, 0xc8, + 0xb6, 0xeb, 0x5e, 0xb1, 0x74, 0xbb, 0x37, 0x99, 0xa9, 0xdc, 0x66, 0xa6, 0xf2, 0x23, 0x33, 0x95, + 0x0f, 0x0b, 0xb3, 0x72, 0xbb, 0x30, 0x2b, 0xdf, 0x17, 0x66, 0xe5, 0x95, 0xb3, 0x62, 0xee, 0x04, + 0x0f, 0xfd, 0x80, 0x39, 0x27, 0xb8, 0x15, 0x0e, 0x7c, 0x92, 0x38, 0xef, 0xd6, 0x7f, 0x3b, 0xc2, + 0x69, 0xa0, 0x89, 0xcf, 0xfe, 0xf9, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x35, 0x1d, 0xae, + 0x97, 0x04, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CommitteeSize != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.CommitteeSize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Committees) > 0 { + for iNdEx := len(m.Committees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Committees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.CurrentCommitteeID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentCommitteeID)) + i-- + dAtA[i] = 0x20 + } + if m.VotingPeriod != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.VotingPeriod)) + i-- + dAtA[i] = 0x18 + } + if m.VotingStartHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.VotingStartHeight)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Committee) 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 *Committee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Committee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Members[iNdEx]) + copy(dAtA[i:], m.Members[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Members[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.EndHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.EndHeight)) + i-- + dAtA[i] = 0x20 + } + if m.StartHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x18 + } + if m.VotingStartHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.VotingStartHeight)) + i-- + dAtA[i] = 0x10 + } + if m.ID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Vote) 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 *Vote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ballots) > 0 { + for iNdEx := len(m.Ballots) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Ballots[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.CommitteeID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.CommitteeID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Ballot) 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 *Ballot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Ballot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Content) > 0 { + i -= len(m.Content) + copy(dAtA[i:], m.Content) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Content))) + i-- + dAtA[i] = 0x12 + } + if m.ID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CommitteeSize != 0 { + n += 1 + sovGenesis(uint64(m.CommitteeSize)) + } + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.VotingStartHeight != 0 { + n += 1 + sovGenesis(uint64(m.VotingStartHeight)) + } + if m.VotingPeriod != 0 { + n += 1 + sovGenesis(uint64(m.VotingPeriod)) + } + if m.CurrentCommitteeID != 0 { + n += 1 + sovGenesis(uint64(m.CurrentCommitteeID)) + } + if len(m.Committees) > 0 { + for _, e := range m.Committees { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *Committee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovGenesis(uint64(m.ID)) + } + if m.VotingStartHeight != 0 { + n += 1 + sovGenesis(uint64(m.VotingStartHeight)) + } + if m.StartHeight != 0 { + n += 1 + sovGenesis(uint64(m.StartHeight)) + } + if m.EndHeight != 0 { + n += 1 + sovGenesis(uint64(m.EndHeight)) + } + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Members) > 0 { + for _, b := range m.Members { + l = len(b) + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *Vote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CommitteeID != 0 { + n += 1 + sovGenesis(uint64(m.CommitteeID)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Ballots) > 0 { + for _, e := range m.Ballots { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *Ballot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovGenesis(uint64(m.ID)) + } + l = len(m.Content) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CommitteeSize", wireType) + } + m.CommitteeSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CommitteeSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingStartHeight", wireType) + } + m.VotingStartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingStartHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPeriod", wireType) + } + m.VotingPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentCommitteeID", wireType) + } + m.CurrentCommitteeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentCommitteeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Committees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Committees = append(m.Committees, Committee{}) + if err := m.Committees[len(m.Committees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Committee) 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 ErrIntOverflowGenesis + } + 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: Committee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Committee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingStartHeight", wireType) + } + m.VotingStartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingStartHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) + } + m.StartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EndHeight", wireType) + } + m.EndHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EndHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Votes = append(m.Votes, Vote{}) + if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Members = append(m.Members, make([]byte, postIndex-iNdEx)) + copy(m.Members[len(m.Members)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Vote) 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 ErrIntOverflowGenesis + } + 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: Vote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Vote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CommitteeID", wireType) + } + m.CommitteeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CommitteeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = append(m.Voter[:0], dAtA[iNdEx:postIndex]...) + if m.Voter == nil { + m.Voter = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ballots", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ballots = append(m.Ballots, &Ballot{}) + if err := m.Ballots[len(m.Ballots)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Ballot) 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 ErrIntOverflowGenesis + } + 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: Ballot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Ballot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Content = append(m.Content[:0], dAtA[iNdEx:postIndex]...) + if m.Content == nil { + m.Content = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/committee/v1/types/interfaces.go b/x/committee/v1/types/interfaces.go new file mode 100644 index 00000000..c48ad7f0 --- /dev/null +++ b/x/committee/v1/types/interfaces.go @@ -0,0 +1,23 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// AccountKeeper defines the expected account keeper +type AccountKeeper interface { + GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI +} + +// BankKeeper defines the expected bank keeper interface +type BankKeeper interface { + GetSupply(ctx sdk.Context, denom string) sdk.Coin + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin +} + +type StakingKeeper interface { + BondDenom(ctx sdk.Context) (res string) + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) +} diff --git a/x/committee/v1/types/keys.go b/x/committee/v1/types/keys.go new file mode 100644 index 00000000..3a55aa92 --- /dev/null +++ b/x/committee/v1/types/keys.go @@ -0,0 +1,52 @@ +package types + +import ( + "encoding/binary" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName The name that will be used throughout the module + ModuleName = "committee" + + // StoreKey Top level store key where all module items will be stored + StoreKey = ModuleName +) + +// Key prefixes +var ( + CommitteeKeyPrefix = []byte{0x00} // prefix for keys that store committees + VoteKeyPrefix = []byte{0x01} // prefix for keys that store votes + VoterKeyPrefix = []byte{0x02} // prefix for keys that store voters + + ParamsKey = []byte{0x03} + VotingStartHeightKey = []byte{0x04} + VotingPeriodKey = []byte{0x05} + CurrentCommitteeIDKey = []byte{0x06} +) + +// GetKeyFromID returns the bytes to use as a key for a uint64 id +func GetKeyFromID(id uint64) []byte { + return Uint64ToBytes(id) +} + +func GetVoteKey(committeeID uint64, voter sdk.ValAddress) []byte { + return append(GetKeyFromID(committeeID), voter.Bytes()...) +} + +func GetVoterKey(voter sdk.ValAddress) []byte { + return voter.Bytes() +} + +// Uint64ToBytes converts a uint64 into fixed length bytes for use in store keys. +func Uint64ToBytes(id uint64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, uint64(id)) + return bz +} + +// Uint64FromBytes converts some fixed length bytes back into a uint64. +func Uint64FromBytes(bz []byte) uint64 { + return binary.BigEndian.Uint64(bz) +} diff --git a/x/committee/v1/types/msg.go b/x/committee/v1/types/msg.go new file mode 100644 index 00000000..640cdf6f --- /dev/null +++ b/x/committee/v1/types/msg.go @@ -0,0 +1,65 @@ +package types + +import ( + "encoding/hex" + + "github.com/coniks-sys/coniks-go/crypto/vrf" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _, _ sdk.Msg = &MsgRegister{}, &MsgVote{} + +// GetSigners returns the expected signers for a MsgRegister message. +func (msg *MsgRegister) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Voter) + if err != nil { + panic(err) + } + accAddr, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(valAddr.Bytes())) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +// ValidateBasic does a sanity check of the provided data +func (msg *MsgRegister) ValidateBasic() error { + if _, err := sdk.ValAddressFromBech32(msg.Voter); err != nil { + return ErrInvalidValidatorAddress + } + if len(msg.Key) != vrf.PublicKeySize { + return ErrInvalidPublicKey + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgRegister) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + +// GetSigners returns the expected signers for a MsgVote message. +func (msg *MsgVote) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Voter) + if err != nil { + panic(err) + } + accAddr, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(valAddr.Bytes())) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +// ValidateBasic does a sanity check of the provided data +func (msg *MsgVote) ValidateBasic() error { + if _, err := sdk.ValAddressFromBech32(msg.Voter); err != nil { + return ErrInvalidValidatorAddress + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgVote) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} diff --git a/x/committee/v1/types/query.pb.go b/x/committee/v1/types/query.pb.go new file mode 100644 index 00000000..9d78029f --- /dev/null +++ b/x/committee/v1/types/query.pb.go @@ -0,0 +1,839 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/committee/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + 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" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryCurrentCommitteeIDRequest struct { +} + +func (m *QueryCurrentCommitteeIDRequest) Reset() { *m = QueryCurrentCommitteeIDRequest{} } +func (m *QueryCurrentCommitteeIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentCommitteeIDRequest) ProtoMessage() {} +func (*QueryCurrentCommitteeIDRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e1eb280fe137a977, []int{0} +} +func (m *QueryCurrentCommitteeIDRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentCommitteeIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentCommitteeIDRequest.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 *QueryCurrentCommitteeIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentCommitteeIDRequest.Merge(m, src) +} +func (m *QueryCurrentCommitteeIDRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentCommitteeIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentCommitteeIDRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentCommitteeIDRequest proto.InternalMessageInfo + +type QueryCurrentCommitteeIDResponse struct { + CurrentCommitteeID uint64 `protobuf:"varint,1,opt,name=current_committee_id,json=currentCommitteeId,proto3" json:"current_committee_id,omitempty"` +} + +func (m *QueryCurrentCommitteeIDResponse) Reset() { *m = QueryCurrentCommitteeIDResponse{} } +func (m *QueryCurrentCommitteeIDResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentCommitteeIDResponse) ProtoMessage() {} +func (*QueryCurrentCommitteeIDResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e1eb280fe137a977, []int{1} +} +func (m *QueryCurrentCommitteeIDResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentCommitteeIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentCommitteeIDResponse.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 *QueryCurrentCommitteeIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentCommitteeIDResponse.Merge(m, src) +} +func (m *QueryCurrentCommitteeIDResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentCommitteeIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentCommitteeIDResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentCommitteeIDResponse proto.InternalMessageInfo + +type QueryRegisteredVotersRequest struct { +} + +func (m *QueryRegisteredVotersRequest) Reset() { *m = QueryRegisteredVotersRequest{} } +func (m *QueryRegisteredVotersRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRegisteredVotersRequest) ProtoMessage() {} +func (*QueryRegisteredVotersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e1eb280fe137a977, []int{2} +} +func (m *QueryRegisteredVotersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRegisteredVotersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRegisteredVotersRequest.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 *QueryRegisteredVotersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRegisteredVotersRequest.Merge(m, src) +} +func (m *QueryRegisteredVotersRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRegisteredVotersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRegisteredVotersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRegisteredVotersRequest proto.InternalMessageInfo + +type QueryRegisteredVotersResponse struct { + Voters []string `protobuf:"bytes,1,rep,name=voters,proto3" json:"voters,omitempty"` +} + +func (m *QueryRegisteredVotersResponse) Reset() { *m = QueryRegisteredVotersResponse{} } +func (m *QueryRegisteredVotersResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRegisteredVotersResponse) ProtoMessage() {} +func (*QueryRegisteredVotersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e1eb280fe137a977, []int{3} +} +func (m *QueryRegisteredVotersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRegisteredVotersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRegisteredVotersResponse.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 *QueryRegisteredVotersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRegisteredVotersResponse.Merge(m, src) +} +func (m *QueryRegisteredVotersResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRegisteredVotersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRegisteredVotersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRegisteredVotersResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryCurrentCommitteeIDRequest)(nil), "zgc.committee.v1.QueryCurrentCommitteeIDRequest") + proto.RegisterType((*QueryCurrentCommitteeIDResponse)(nil), "zgc.committee.v1.QueryCurrentCommitteeIDResponse") + proto.RegisterType((*QueryRegisteredVotersRequest)(nil), "zgc.committee.v1.QueryRegisteredVotersRequest") + proto.RegisterType((*QueryRegisteredVotersResponse)(nil), "zgc.committee.v1.QueryRegisteredVotersResponse") +} + +func init() { proto.RegisterFile("zgc/committee/v1/query.proto", fileDescriptor_e1eb280fe137a977) } + +var fileDescriptor_e1eb280fe137a977 = []byte{ + // 425 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xf7, 0x15, 0xa8, 0xc4, 0x4d, 0xd5, 0xa9, 0xaa, 0x5a, 0x2b, 0x5c, 0x22, 0x2f, 0x14, 0x84, + 0x7d, 0x4e, 0x19, 0xd8, 0x5b, 0x06, 0x18, 0x18, 0xc8, 0xc0, 0xc0, 0x12, 0xf9, 0xcf, 0xe3, 0x7a, + 0xa2, 0xbe, 0x73, 0x7d, 0xe7, 0x88, 0x76, 0xe4, 0x13, 0x20, 0xf1, 0x15, 0x58, 0xf9, 0x1e, 0x19, + 0x23, 0xb1, 0x30, 0x45, 0xe0, 0xf0, 0x41, 0x50, 0xec, 0x8b, 0xa5, 0x98, 0x18, 0xc1, 0xe6, 0xf7, + 0xfb, 0xf3, 0xde, 0xef, 0xde, 0x33, 0x1e, 0xdc, 0xf2, 0x84, 0x25, 0x2a, 0xcb, 0x84, 0x31, 0x00, + 0x6c, 0x36, 0x66, 0xd7, 0x25, 0x14, 0x37, 0x41, 0x5e, 0x28, 0xa3, 0xc8, 0xc1, 0x2d, 0x4f, 0x82, + 0x96, 0x0d, 0x66, 0x63, 0xf7, 0x24, 0x51, 0x3a, 0x53, 0x7a, 0x5a, 0xf3, 0xac, 0x29, 0x1a, 0xb1, + 0x7b, 0xc8, 0x15, 0x57, 0x0d, 0xbe, 0xfe, 0xb2, 0xe8, 0x80, 0x2b, 0xc5, 0xaf, 0x80, 0x45, 0xb9, + 0x60, 0x91, 0x94, 0xca, 0x44, 0x46, 0x28, 0xb9, 0xf1, 0x9c, 0x58, 0xb6, 0xae, 0xe2, 0xf2, 0x1d, + 0x8b, 0xa4, 0x9d, 0xed, 0x0e, 0xbb, 0x94, 0x11, 0x19, 0x68, 0x13, 0x65, 0xb9, 0x15, 0xd0, 0x3f, + 0xa2, 0x73, 0x90, 0xa0, 0x85, 0xed, 0xed, 0x8d, 0x30, 0x7d, 0xbd, 0x7e, 0xcb, 0x45, 0x59, 0x14, + 0x20, 0xcd, 0xc5, 0x46, 0xf9, 0xf2, 0xf9, 0x04, 0xae, 0x4b, 0xd0, 0xc6, 0x7b, 0x8f, 0x87, 0xbd, + 0x0a, 0x9d, 0x2b, 0xa9, 0x81, 0xbc, 0xc0, 0x87, 0x49, 0xc3, 0x4e, 0xdb, 0x51, 0x53, 0x91, 0x1e, + 0xa3, 0x11, 0x3a, 0xbd, 0x7b, 0x7e, 0x54, 0x2d, 0x87, 0x64, 0x87, 0x9b, 0x24, 0x5d, 0x2c, 0xf5, + 0x28, 0x1e, 0xd4, 0xc3, 0x26, 0xc0, 0x85, 0x36, 0x50, 0x40, 0xfa, 0x46, 0x19, 0x28, 0xf4, 0x26, + 0xcc, 0x33, 0xfc, 0xa0, 0x87, 0xb7, 0x51, 0x8e, 0xf0, 0xfe, 0xac, 0x46, 0x8e, 0xd1, 0xe8, 0xce, + 0xe9, 0xfd, 0x89, 0xad, 0xce, 0x96, 0x7b, 0xf8, 0x5e, 0xed, 0x24, 0x5f, 0x11, 0xde, 0x91, 0x86, + 0x84, 0x41, 0xf7, 0x8c, 0xc1, 0xdf, 0x17, 0xe3, 0x8e, 0xff, 0xc3, 0xd1, 0xa4, 0xf3, 0xce, 0x3e, + 0x7e, 0xfb, 0xf5, 0x79, 0xef, 0x09, 0x79, 0xcc, 0x42, 0x9e, 0x5c, 0x46, 0x42, 0x6e, 0x9f, 0xc6, + 0x2e, 0xc4, 0x6f, 0x41, 0x5f, 0xa4, 0xe4, 0x0b, 0xc2, 0x07, 0xdd, 0xe7, 0x92, 0xa0, 0x67, 0x76, + 0xcf, 0xde, 0x5c, 0xf6, 0xcf, 0x7a, 0x9b, 0x94, 0xd5, 0x49, 0x1f, 0x91, 0x87, 0xbb, 0x93, 0x16, + 0xad, 0xcf, 0x6f, 0x16, 0x7c, 0xfe, 0x6a, 0xfe, 0x93, 0x3a, 0xf3, 0x8a, 0xa2, 0x45, 0x45, 0xd1, + 0x8f, 0x8a, 0xa2, 0x4f, 0x2b, 0xea, 0x2c, 0x56, 0xd4, 0xf9, 0xbe, 0xa2, 0xce, 0x5b, 0xc6, 0x85, + 0xb9, 0x2c, 0xe3, 0x75, 0x02, 0x16, 0xf2, 0xab, 0x28, 0xd6, 0x2c, 0xe4, 0x7e, 0xd3, 0xf8, 0xc3, + 0x76, 0x6b, 0x73, 0x93, 0x83, 0x8e, 0xf7, 0xeb, 0xdf, 0xf3, 0xe9, 0xef, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xbc, 0x1f, 0xba, 0xac, 0x7b, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + CurrentCommitteeID(ctx context.Context, in *QueryCurrentCommitteeIDRequest, opts ...grpc.CallOption) (*QueryCurrentCommitteeIDResponse, error) + RegisteredVoters(ctx context.Context, in *QueryRegisteredVotersRequest, opts ...grpc.CallOption) (*QueryRegisteredVotersResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) CurrentCommitteeID(ctx context.Context, in *QueryCurrentCommitteeIDRequest, opts ...grpc.CallOption) (*QueryCurrentCommitteeIDResponse, error) { + out := new(QueryCurrentCommitteeIDResponse) + err := c.cc.Invoke(ctx, "/zgc.committee.v1.Query/CurrentCommitteeID", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RegisteredVoters(ctx context.Context, in *QueryRegisteredVotersRequest, opts ...grpc.CallOption) (*QueryRegisteredVotersResponse, error) { + out := new(QueryRegisteredVotersResponse) + err := c.cc.Invoke(ctx, "/zgc.committee.v1.Query/RegisteredVoters", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + CurrentCommitteeID(context.Context, *QueryCurrentCommitteeIDRequest) (*QueryCurrentCommitteeIDResponse, error) + RegisteredVoters(context.Context, *QueryRegisteredVotersRequest) (*QueryRegisteredVotersResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) CurrentCommitteeID(ctx context.Context, req *QueryCurrentCommitteeIDRequest) (*QueryCurrentCommitteeIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CurrentCommitteeID not implemented") +} +func (*UnimplementedQueryServer) RegisteredVoters(ctx context.Context, req *QueryRegisteredVotersRequest) (*QueryRegisteredVotersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisteredVoters not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_CurrentCommitteeID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCurrentCommitteeIDRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CurrentCommitteeID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.committee.v1.Query/CurrentCommitteeID", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CurrentCommitteeID(ctx, req.(*QueryCurrentCommitteeIDRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RegisteredVoters_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRegisteredVotersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RegisteredVoters(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.committee.v1.Query/RegisteredVoters", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RegisteredVoters(ctx, req.(*QueryRegisteredVotersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.committee.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CurrentCommitteeID", + Handler: _Query_CurrentCommitteeID_Handler, + }, + { + MethodName: "RegisteredVoters", + Handler: _Query_RegisteredVoters_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/committee/v1/query.proto", +} + +func (m *QueryCurrentCommitteeIDRequest) 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 *QueryCurrentCommitteeIDRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentCommitteeIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryCurrentCommitteeIDResponse) 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 *QueryCurrentCommitteeIDResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentCommitteeIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentCommitteeID != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CurrentCommitteeID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryRegisteredVotersRequest) 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 *QueryRegisteredVotersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRegisteredVotersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryRegisteredVotersResponse) 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 *QueryRegisteredVotersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRegisteredVotersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Voters) > 0 { + for iNdEx := len(m.Voters) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Voters[iNdEx]) + copy(dAtA[i:], m.Voters[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Voters[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryCurrentCommitteeIDRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryCurrentCommitteeIDResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CurrentCommitteeID != 0 { + n += 1 + sovQuery(uint64(m.CurrentCommitteeID)) + } + return n +} + +func (m *QueryRegisteredVotersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryRegisteredVotersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Voters) > 0 { + for _, s := range m.Voters { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryCurrentCommitteeIDRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCurrentCommitteeIDRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentCommitteeIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCurrentCommitteeIDResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCurrentCommitteeIDResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentCommitteeIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentCommitteeID", wireType) + } + m.CurrentCommitteeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentCommitteeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRegisteredVotersRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRegisteredVotersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRegisteredVotersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRegisteredVotersResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRegisteredVotersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRegisteredVotersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voters", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voters = append(m.Voters, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/committee/v1/types/query.pb.gw.go b/x/committee/v1/types/query.pb.gw.go new file mode 100644 index 00000000..acb545c0 --- /dev/null +++ b/x/committee/v1/types/query.pb.gw.go @@ -0,0 +1,218 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: zgc/committee/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_CurrentCommitteeID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentCommitteeIDRequest + var metadata runtime.ServerMetadata + + msg, err := client.CurrentCommitteeID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CurrentCommitteeID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentCommitteeIDRequest + var metadata runtime.ServerMetadata + + msg, err := server.CurrentCommitteeID(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RegisteredVoters_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRegisteredVotersRequest + var metadata runtime.ServerMetadata + + msg, err := client.RegisteredVoters(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RegisteredVoters_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRegisteredVotersRequest + var metadata runtime.ServerMetadata + + msg, err := server.RegisteredVoters(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_CurrentCommitteeID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CurrentCommitteeID_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CurrentCommitteeID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RegisteredVoters_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RegisteredVoters_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RegisteredVoters_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_CurrentCommitteeID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_CurrentCommitteeID_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CurrentCommitteeID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RegisteredVoters_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RegisteredVoters_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RegisteredVoters_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_CurrentCommitteeID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "committee", "v1", "current-committee-id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RegisteredVoters_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "committee", "v1", "registered-voters"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_CurrentCommitteeID_0 = runtime.ForwardResponseMessage + + forward_Query_RegisteredVoters_0 = runtime.ForwardResponseMessage +) diff --git a/x/committee/v1/types/tx.pb.go b/x/committee/v1/types/tx.pb.go new file mode 100644 index 00000000..5f9d335a --- /dev/null +++ b/x/committee/v1/types/tx.pb.go @@ -0,0 +1,975 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/committee/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgRegister struct { + Voter string `protobuf:"bytes,1,opt,name=voter,proto3" json:"voter,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *MsgRegister) Reset() { *m = MsgRegister{} } +func (m *MsgRegister) String() string { return proto.CompactTextString(m) } +func (*MsgRegister) ProtoMessage() {} +func (*MsgRegister) Descriptor() ([]byte, []int) { + return fileDescriptor_ea97a64f78abecc0, []int{0} +} +func (m *MsgRegister) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegister) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegister.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 *MsgRegister) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegister.Merge(m, src) +} +func (m *MsgRegister) XXX_Size() int { + return m.Size() +} +func (m *MsgRegister) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegister.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegister proto.InternalMessageInfo + +type MsgRegisterResponse struct { +} + +func (m *MsgRegisterResponse) Reset() { *m = MsgRegisterResponse{} } +func (m *MsgRegisterResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterResponse) ProtoMessage() {} +func (*MsgRegisterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ea97a64f78abecc0, []int{1} +} +func (m *MsgRegisterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterResponse.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 *MsgRegisterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterResponse.Merge(m, src) +} +func (m *MsgRegisterResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterResponse proto.InternalMessageInfo + +type MsgVote struct { + CommitteeID uint64 `protobuf:"varint,1,opt,name=committee_id,json=committeeId,proto3" json:"committee_id,omitempty"` + Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"` + Ballots []*Ballot `protobuf:"bytes,3,rep,name=ballots,proto3" json:"ballots,omitempty"` +} + +func (m *MsgVote) Reset() { *m = MsgVote{} } +func (m *MsgVote) String() string { return proto.CompactTextString(m) } +func (*MsgVote) ProtoMessage() {} +func (*MsgVote) Descriptor() ([]byte, []int) { + return fileDescriptor_ea97a64f78abecc0, []int{2} +} +func (m *MsgVote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVote.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 *MsgVote) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVote.Merge(m, src) +} +func (m *MsgVote) XXX_Size() int { + return m.Size() +} +func (m *MsgVote) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVote.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVote proto.InternalMessageInfo + +type MsgVoteResponse struct { +} + +func (m *MsgVoteResponse) Reset() { *m = MsgVoteResponse{} } +func (m *MsgVoteResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVoteResponse) ProtoMessage() {} +func (*MsgVoteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ea97a64f78abecc0, []int{3} +} +func (m *MsgVoteResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVoteResponse.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 *MsgVoteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteResponse.Merge(m, src) +} +func (m *MsgVoteResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgVoteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegister)(nil), "zgc.committee.v1.MsgRegister") + proto.RegisterType((*MsgRegisterResponse)(nil), "zgc.committee.v1.MsgRegisterResponse") + proto.RegisterType((*MsgVote)(nil), "zgc.committee.v1.MsgVote") + proto.RegisterType((*MsgVoteResponse)(nil), "zgc.committee.v1.MsgVoteResponse") +} + +func init() { proto.RegisterFile("zgc/committee/v1/tx.proto", fileDescriptor_ea97a64f78abecc0) } + +var fileDescriptor_ea97a64f78abecc0 = []byte{ + // 377 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0x4d, 0x8e, 0xda, 0x30, + 0x18, 0x8d, 0x09, 0x2d, 0xad, 0x83, 0x04, 0x4d, 0xa9, 0x94, 0x44, 0xaa, 0x4b, 0x23, 0x55, 0x62, + 0xd3, 0x18, 0x52, 0xf5, 0x02, 0x94, 0x0d, 0x8b, 0x48, 0x55, 0x16, 0x5d, 0x74, 0x83, 0x92, 0xe0, + 0x9a, 0xa8, 0x21, 0x46, 0xd8, 0x20, 0xe0, 0x02, 0xb3, 0x9d, 0x0b, 0xcc, 0x7d, 0x58, 0xb2, 0x9c, + 0xd5, 0x68, 0x26, 0x5c, 0x64, 0x94, 0xdf, 0x41, 0x30, 0x33, 0xbb, 0xef, 0xfb, 0xde, 0xf3, 0x7b, + 0xdf, 0xb3, 0x0d, 0xf5, 0x1d, 0x0d, 0x70, 0xc0, 0xe6, 0xf3, 0x50, 0x08, 0x42, 0xf0, 0x7a, 0x80, + 0xc5, 0xc6, 0x5a, 0x2c, 0x99, 0x60, 0x6a, 0x7b, 0x47, 0x03, 0xab, 0x82, 0xac, 0xf5, 0xc0, 0xd0, + 0x03, 0xc6, 0xe7, 0x8c, 0x4f, 0x32, 0x1c, 0xe7, 0x4d, 0x4e, 0x36, 0x3a, 0x94, 0x51, 0x96, 0xcf, + 0xd3, 0xaa, 0x98, 0xea, 0x94, 0x31, 0x1a, 0x11, 0x9c, 0x75, 0xfe, 0xea, 0x1f, 0xf6, 0xe2, 0x6d, + 0x01, 0xa1, 0x0b, 0x63, 0x4a, 0x62, 0xc2, 0xc3, 0x42, 0xd0, 0xfc, 0x09, 0x15, 0x87, 0x53, 0x97, + 0xd0, 0x90, 0x0b, 0xb2, 0x54, 0x3b, 0xf0, 0xcd, 0x9a, 0x09, 0xb2, 0xd4, 0x40, 0x17, 0xf4, 0xde, + 0xbb, 0x79, 0xa3, 0xb6, 0xa1, 0xfc, 0x9f, 0x6c, 0xb5, 0x5a, 0x17, 0xf4, 0x9a, 0x6e, 0x5a, 0x9a, + 0x9f, 0xe0, 0xc7, 0x93, 0x63, 0x2e, 0xe1, 0x0b, 0x16, 0x73, 0x62, 0x5e, 0x01, 0xd8, 0x70, 0x38, + 0xfd, 0xc3, 0x04, 0x51, 0x6d, 0xd8, 0xac, 0x7c, 0x27, 0xe1, 0x34, 0x53, 0xac, 0x0f, 0x5b, 0xc9, + 0xdd, 0x17, 0xe5, 0x57, 0x39, 0x1f, 0x8f, 0x5c, 0xa5, 0x22, 0x8d, 0xa7, 0x4f, 0xf6, 0xb5, 0x53, + 0x7b, 0x1b, 0x36, 0x7c, 0x2f, 0x8a, 0x98, 0xe0, 0x9a, 0xdc, 0x95, 0x7b, 0x8a, 0xad, 0x59, 0xe7, + 0x77, 0x66, 0x0d, 0x33, 0x82, 0x5b, 0x12, 0xcd, 0x0f, 0xb0, 0x55, 0x2c, 0x52, 0x2e, 0x67, 0xdf, + 0x00, 0x28, 0x3b, 0x9c, 0xaa, 0xbf, 0xe1, 0xbb, 0x2a, 0xef, 0xe7, 0x4b, 0xa5, 0x93, 0x5c, 0xc6, + 0xb7, 0x57, 0xe1, 0x52, 0x59, 0x1d, 0xc1, 0x7a, 0x16, 0x59, 0x7f, 0x96, 0x9e, 0x42, 0xc6, 0xd7, + 0x17, 0xa1, 0x52, 0x65, 0xe8, 0xec, 0x1f, 0x90, 0xb4, 0x4f, 0x10, 0x38, 0x24, 0x08, 0xdc, 0x27, + 0x08, 0x5c, 0x1f, 0x91, 0x74, 0x38, 0x22, 0xe9, 0xf6, 0x88, 0xa4, 0xbf, 0x98, 0x86, 0x62, 0xb6, + 0xf2, 0x53, 0x09, 0xdc, 0xa7, 0x91, 0xe7, 0x73, 0xdc, 0xa7, 0xdf, 0x83, 0x99, 0x17, 0xc6, 0x78, + 0x73, 0xf6, 0xb5, 0xb6, 0x0b, 0xc2, 0xfd, 0xb7, 0xd9, 0x03, 0xff, 0x78, 0x0c, 0x00, 0x00, 0xff, + 0xff, 0xec, 0xc0, 0x4c, 0xa8, 0x7b, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + Register(ctx context.Context, in *MsgRegister, opts ...grpc.CallOption) (*MsgRegisterResponse, error) + Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) Register(ctx context.Context, in *MsgRegister, opts ...grpc.CallOption) (*MsgRegisterResponse, error) { + out := new(MsgRegisterResponse) + err := c.cc.Invoke(ctx, "/zgc.committee.v1.Msg/Register", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) { + out := new(MsgVoteResponse) + err := c.cc.Invoke(ctx, "/zgc.committee.v1.Msg/Vote", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + Register(context.Context, *MsgRegister) (*MsgRegisterResponse, error) + Vote(context.Context, *MsgVote) (*MsgVoteResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) Register(ctx context.Context, req *MsgRegister) (*MsgRegisterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") +} +func (*UnimplementedMsgServer) Vote(ctx context.Context, req *MsgVote) (*MsgVoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Vote not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegister) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Register(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.committee.v1.Msg/Register", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Register(ctx, req.(*MsgRegister)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVote) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Vote(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.committee.v1.Msg/Vote", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Vote(ctx, req.(*MsgVote)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.committee.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Register", + Handler: _Msg_Register_Handler, + }, + { + MethodName: "Vote", + Handler: _Msg_Vote_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/committee/v1/tx.proto", +} + +func (m *MsgRegister) 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 *MsgRegister) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegister) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTx(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterResponse) 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 *MsgRegisterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgVote) 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 *MsgVote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ballots) > 0 { + for iNdEx := len(m.Ballots) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Ballots[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.CommitteeID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.CommitteeID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgVoteResponse) 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 *MsgVoteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegister) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgVote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CommitteeID != 0 { + n += 1 + sovTx(uint64(m.CommitteeID)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Ballots) > 0 { + for _, e := range m.Ballots { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgVoteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgRegister) 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: MsgRegister: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegister: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", 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.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + 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 *MsgRegisterResponse) 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: MsgRegisterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterResponse: 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 *MsgVote) 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: MsgVote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CommitteeID", wireType) + } + m.CommitteeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CommitteeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", 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.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ballots", 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.Ballots = append(m.Ballots, &Ballot{}) + if err := m.Ballots[len(m.Ballots)-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 *MsgVoteResponse) 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: MsgVoteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteResponse: 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 skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/das/v1/client/cli/query.go b/x/das/v1/client/cli/query.go new file mode 100644 index 00000000..b7a715e3 --- /dev/null +++ b/x/das/v1/client/cli/query.go @@ -0,0 +1,57 @@ +package cli + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + + "github.com/0glabs/0g-chain/x/das/v1/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +// GetQueryCmd returns the cli query commands for the inflation module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the das module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetNextRequestID(), + ) + + return cmd +} + +func GetNextRequestID() *cobra.Command { + cmd := &cobra.Command{ + Use: "next-request-id", + Short: "Query the next request ID", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryNextRequestIDRequest{} + res, err := queryClient.NextRequestID(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%v\n", res.NextRequestID)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/das/v1/client/cli/tx.go b/x/das/v1/client/cli/tx.go new file mode 100644 index 00000000..1a97c959 --- /dev/null +++ b/x/das/v1/client/cli/tx.go @@ -0,0 +1,103 @@ +package cli + +import ( + "encoding/hex" + "fmt" + "strconv" + + "github.com/0glabs/0g-chain/x/das/v1/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand( + NewRequestDASCmd(), + NewReportDASResultCmd(), + ) + return cmd +} + +func NewRequestDASCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "request-das steram-id batch-header-hash num-blobs", + Short: "Request data-availability-sampling", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + numBlobs, err := strconv.Atoi(args[2]) + if err != nil { + return err + } + + msg := types.NewMsgRequestDAS(clientCtx.GetFromAddress(), args[0], args[1], uint32(numBlobs)) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd + +} + +func NewReportDASResultCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "report-das-result request-id results", + Short: "Report data-availability-sampling result", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + requestID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + n := len(args) - 1 + results := make([]bool, n) + for i := 0; i < n; i++ { + var err error + results[i], err = strconv.ParseBool(args[i+1]) + if err != nil { + return err + } + } + + // get account name by address + accAddr := clientCtx.GetFromAddress() + + samplerAddr, err := sdk.ValAddressFromHex(hex.EncodeToString(accAddr.Bytes())) + if err != nil { + return err + } + + msg := &types.MsgReportDASResult{ + RequestID: requestID, + Sampler: samplerAddr.String(), + Results: results, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/das/v1/genesis.go b/x/das/v1/genesis.go new file mode 100644 index 00000000..4780b693 --- /dev/null +++ b/x/das/v1/genesis.go @@ -0,0 +1,39 @@ +package das + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/0glabs/0g-chain/x/das/v1/keeper" + "github.com/0glabs/0g-chain/x/das/v1/types" +) + +// InitGenesis initializes the store state from a genesis state. +func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { + panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) + } + + keeper.SetNextRequestID(ctx, gs.NextRequestID) + for _, req := range gs.Requests { + keeper.SetDASRequest(ctx, req) + } + for _, resp := range gs.Responses { + keeper.SetDASResponse(ctx, resp) + } +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { + nextRequestID, err := keeper.GetNextRequestID(ctx) + if err != nil { + panic(err) + } + + return types.NewGenesisState( + nextRequestID, + keeper.GetDASRequests(ctx), + keeper.GetDASResponses(ctx), + ) +} diff --git a/x/das/v1/keeper/grpc_query.go b/x/das/v1/keeper/grpc_query.go new file mode 100644 index 00000000..e4fddea2 --- /dev/null +++ b/x/das/v1/keeper/grpc_query.go @@ -0,0 +1,22 @@ +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/x/das/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) NextRequestID( + c context.Context, + _ *types.QueryNextRequestIDRequest, +) (*types.QueryNextRequestIDResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + nextRequestID, err := k.GetNextRequestID(ctx) + if err != nil { + return nil, err + } + return &types.QueryNextRequestIDResponse{NextRequestID: nextRequestID}, nil +} diff --git a/x/das/v1/keeper/keeper.go b/x/das/v1/keeper/keeper.go new file mode 100644 index 00000000..5dcedad5 --- /dev/null +++ b/x/das/v1/keeper/keeper.go @@ -0,0 +1,198 @@ +package keeper + +import ( + "encoding/hex" + "strconv" + + errorsmod "cosmossdk.io/errors" + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/0glabs/0g-chain/x/das/v1/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + stakingKeeperRef types.StakingKeeperRef +} + +// NewKeeper creates a new das Keeper instance +func NewKeeper( + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, + stakingKeeper types.StakingKeeperRef, +) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + stakingKeeperRef: stakingKeeper, + } +} + +// 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) SetNextRequestID(ctx sdk.Context, id uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.NextRequestIDKey, types.GetKeyFromID(id)) +} + +func (k Keeper) GetNextRequestID(ctx sdk.Context) (uint64, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.NextRequestIDKey) + if bz == nil { + return 0, errorsmod.Wrap(types.ErrInvalidGenesis, "next request ID not set at genesis") + } + return types.Uint64FromBytes(bz), nil +} + +func (k Keeper) IncrementNextRequestID(ctx sdk.Context) error { + id, err := k.GetNextRequestID(ctx) + if err != nil { + return err + } + k.SetNextRequestID(ctx, id+1) + return nil +} + +func (k Keeper) GetDASRequest(ctx sdk.Context, requestID uint64) (types.DASRequest, bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RequestKeyPrefix) + bz := store.Get(types.GetKeyFromID(requestID)) + if bz == nil { + return types.DASRequest{}, false + } + var req types.DASRequest + k.cdc.MustUnmarshal(bz, &req) + return req, true +} + +func (k Keeper) SetDASRequest(ctx sdk.Context, req types.DASRequest) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RequestKeyPrefix) + bz := k.cdc.MustMarshal(&req) + store.Set(types.GetKeyFromID(req.ID), bz) +} + +func (k Keeper) IterateDASRequest(ctx sdk.Context, cb func(req types.DASRequest) (stop bool)) { + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.RequestKeyPrefix) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var req types.DASRequest + k.cdc.MustUnmarshal(iterator.Value(), &req) + if cb(req) { + break + } + } +} + +func (k Keeper) GetDASRequests(ctx sdk.Context) []types.DASRequest { + results := []types.DASRequest{} + k.IterateDASRequest(ctx, func(req types.DASRequest) bool { + results = append(results, req) + return false + }) + return results +} + +func (k Keeper) StoreNewDASRequest( + ctx sdk.Context, + streamIDHexStr string, + batchHeaderHashHexStr string, + numBlobs uint32) (uint64, error) { + requestID, err := k.GetNextRequestID(ctx) + if err != nil { + return 0, err + } + + streamID, err := hex.DecodeString(streamIDHexStr) + if err != nil { + return 0, err + } + + batchHeaderHash, err := hex.DecodeString(batchHeaderHashHexStr) + if err != nil { + return 0, err + } + + req := types.DASRequest{ + ID: requestID, + StreamID: streamID, + BatchHeaderHash: batchHeaderHash, + NumBlobs: numBlobs, + } + k.SetDASRequest(ctx, req) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeDASRequest, + sdk.NewAttribute(types.AttributeKeyRequestID, strconv.FormatUint(requestID, 10)), + sdk.NewAttribute(types.AttributeKeyStreamID, streamIDHexStr), + sdk.NewAttribute(types.AttributeKeyBatchHeaderHash, batchHeaderHashHexStr), + sdk.NewAttribute(types.AttributeKeyNumBlobs, strconv.FormatUint(uint64(numBlobs), 10)), + ), + ) + + return requestID, nil +} + +func (k Keeper) GetDASResponse( + ctx sdk.Context, requestID uint64, sampler sdk.ValAddress, +) (types.DASResponse, bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ResponseKeyPrefix) + bz := store.Get(types.GetResponseKey(requestID, sampler)) + if bz == nil { + return types.DASResponse{}, false + } + var vote types.DASResponse + k.cdc.MustUnmarshal(bz, &vote) + return vote, true +} + +func (k Keeper) SetDASResponse(ctx sdk.Context, resp types.DASResponse) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ResponseKeyPrefix) + bz := k.cdc.MustMarshal(&resp) + store.Set(types.GetResponseKey(resp.ID, resp.Sampler), bz) +} + +func (k Keeper) IterateDASResponse(ctx sdk.Context, cb func(resp types.DASResponse) (stop bool)) { + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.ResponseKeyPrefix) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var resp types.DASResponse + k.cdc.MustUnmarshal(iterator.Value(), &resp) + if cb(resp) { + break + } + } +} + +func (k Keeper) GetDASResponses(ctx sdk.Context) []types.DASResponse { + results := []types.DASResponse{} + k.IterateDASResponse(ctx, func(resp types.DASResponse) bool { + results = append(results, resp) + return false + }) + return results +} + +func (k Keeper) StoreNewDASResponse( + ctx sdk.Context, requestID uint64, sampler sdk.ValAddress, results []bool) error { + if _, found := k.GetDASRequest(ctx, requestID); !found { + return errorsmod.Wrapf(types.ErrUnknownRequest, "%d", requestID) + } + + k.SetDASResponse(ctx, types.DASResponse{ + ID: requestID, + Sampler: sampler, + Results: results, + }) + + return nil +} diff --git a/x/das/v1/keeper/msg_server.go b/x/das/v1/keeper/msg_server.go new file mode 100644 index 00000000..4109f90a --- /dev/null +++ b/x/das/v1/keeper/msg_server.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/x/das/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +var _ types.MsgServer = &Keeper{} + +// RequestDAS handles MsgRequestDAS messages +func (k Keeper) RequestDAS( + goCtx context.Context, msg *types.MsgRequestDAS, +) (*types.MsgRequestDASResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + requestID, err := k.StoreNewDASRequest(ctx, msg.StreamID, msg.BatchHeaderHash, msg.NumBlobs) + if err != nil { + return nil, err + } + k.IncrementNextRequestID(ctx) + return &types.MsgRequestDASResponse{ + RequestID: requestID, + }, nil +} + +// ReportDASResult handles MsgReportDASResult messages +func (k Keeper) ReportDASResult( + goCtx context.Context, msg *types.MsgReportDASResult, +) (*types.MsgReportDASResultResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + sampler, err := sdk.ValAddressFromBech32(msg.Sampler) + if err != nil { + return nil, err + } + + if _, found := k.stakingKeeperRef.GetValidator(ctx, sampler); !found { + return nil, stakingtypes.ErrNoValidatorFound + } + + if err := k.StoreNewDASResponse(ctx, msg.RequestID, sampler, msg.Results); err != nil { + return nil, err + } + + return &types.MsgReportDASResultResponse{}, nil +} diff --git a/x/das/v1/module.go b/x/das/v1/module.go new file mode 100644 index 00000000..288c00bd --- /dev/null +++ b/x/das/v1/module.go @@ -0,0 +1,169 @@ +package das + +import ( + "context" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/0glabs/0g-chain/x/das/v1/client/cli" + "github.com/0glabs/0g-chain/x/das/v1/keeper" + "github.com/0glabs/0g-chain/x/das/v1/types" +) + +// consensusVersion defines the current x/committee module consensus version. +const consensusVersion = 1 + +// type check to ensure the interface is properly implemented +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} + _ module.BeginBlockAppModule = AppModule{} + _ module.EndBlockAppModule = AppModule{} +) + +// app module Basics object +type AppModuleBasic struct{} + +// Name returns the inflation module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the inflation module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// ConsensusVersion returns the consensus state-breaking version for the module. +func (AppModuleBasic) ConsensusVersion() uint64 { + return consensusVersion +} + +// RegisterInterfaces registers interfaces and implementations of the incentives +// module. +func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(interfaceRegistry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the incentives +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the inflation module. +func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genesisState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genesisState.Validate() +} + +// RegisterRESTRoutes performs a no-op as the inflation module doesn't expose REST +// endpoints +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the inflation module. +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root tx command for the inflation module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns no root query command for the inflation module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ___________________________________________________________________________ + +// AppModule implements an application module for the inflation module. +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule Object +func NewAppModule( + k keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: k, + } +} + +// Name returns the inflation module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the inflation module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { + // am.keeper.BeginBlock(ctx, req) +} + +func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { + // am.keeper.EndBlock(ctx, req) + return []abci.ValidatorUpdate{} +} + +// InitGenesis performs genesis initialization for the inflation module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(data, &genesisState) + InitGenesis(ctx, am.keeper, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the inflation +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(gs) +} + +// ___________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the inflation module. +func (am AppModule) GenerateGenesisState(_ *module.SimulationState) { +} + +// RegisterStoreDecoder registers a decoder for inflation module's types. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +} + +// WeightedOperations doesn't return any inflation module operation. +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} diff --git a/x/das/v1/types/codec.go b/x/das/v1/types/codec.go new file mode 100644 index 00000000..883a699e --- /dev/null +++ b/x/das/v1/types/codec.go @@ -0,0 +1,47 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + // ModuleCdc references the global evm module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino JSON compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +const ( + // Amino names + requestDASName = "evmos/das/MsgRequestDAS" + reportDASResultName = "evmos/das/MsgReportDASResult" +) + +// NOTE: This is required for the GetSignBytes function +func init() { + RegisterLegacyAminoCodec(amino) + amino.Seal() +} + +// RegisterInterfaces register implementations +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgRequestDAS{}, + &MsgReportDASResult{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// RegisterLegacyAminoCodec required for EIP-712 +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRequestDAS{}, requestDASName, nil) + cdc.RegisterConcrete(&MsgReportDASResult{}, reportDASResultName, nil) +} diff --git a/x/das/v1/types/errors.go b/x/das/v1/types/errors.go new file mode 100644 index 00000000..77469e4a --- /dev/null +++ b/x/das/v1/types/errors.go @@ -0,0 +1,8 @@ +package types + +import errorsmod "cosmossdk.io/errors" + +var ( + ErrUnknownRequest = errorsmod.Register(ModuleName, 0, "request not found") + ErrInvalidGenesis = errorsmod.Register(ModuleName, 1, "invalid genesis") +) diff --git a/x/das/v1/types/events.go b/x/das/v1/types/events.go new file mode 100644 index 00000000..3a7159a4 --- /dev/null +++ b/x/das/v1/types/events.go @@ -0,0 +1,11 @@ +package types + +// Module event types +const ( + EventTypeDASRequest = "das_request" + + AttributeKeyRequestID = "request_id" + AttributeKeyStreamID = "stream_id" + AttributeKeyBatchHeaderHash = "batch_header_hash" + AttributeKeyNumBlobs = "num_blobs" +) diff --git a/x/das/v1/types/genesis.go b/x/das/v1/types/genesis.go new file mode 100644 index 00000000..fd0c6fde --- /dev/null +++ b/x/das/v1/types/genesis.go @@ -0,0 +1,28 @@ +package types + +const ( + DefaultNextRequestID = 0 +) + +// NewGenesisState returns a new genesis state object for the module. +func NewGenesisState(nextRequestID uint64, requests []DASRequest, responses []DASResponse) *GenesisState { + return &GenesisState{ + NextRequestID: nextRequestID, + Requests: requests, + Responses: responses, + } +} + +// DefaultGenesisState returns the default genesis state for the module. +func DefaultGenesisState() *GenesisState { + return NewGenesisState( + DefaultNextRequestID, + []DASRequest{}, + []DASResponse{}, + ) +} + +// Validate performs basic validation of genesis data. +func (gs GenesisState) Validate() error { + return nil +} diff --git a/x/das/v1/types/genesis.pb.go b/x/das/v1/types/genesis.pb.go new file mode 100644 index 00000000..15cab4cf --- /dev/null +++ b/x/das/v1/types/genesis.pb.go @@ -0,0 +1,1191 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/das/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3f8b8b164973ed21, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +// GenesisState defines the das module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + NextRequestID uint64 `protobuf:"varint,2,opt,name=next_request_id,json=nextRequestId,proto3" json:"next_request_id,omitempty"` + Requests []DASRequest `protobuf:"bytes,3,rep,name=requests,proto3" json:"requests"` + Responses []DASResponse `protobuf:"bytes,4,rep,name=responses,proto3" json:"responses"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_3f8b8b164973ed21, []int{1} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +type DASRequest struct { + ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + StreamID []byte `protobuf:"bytes,2,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"` + BatchHeaderHash []byte `protobuf:"bytes,3,opt,name=batch_header_hash,json=batchHeaderHash,proto3" json:"batch_header_hash,omitempty"` + NumBlobs uint32 `protobuf:"varint,4,opt,name=num_blobs,json=numBlobs,proto3" json:"num_blobs,omitempty"` +} + +func (m *DASRequest) Reset() { *m = DASRequest{} } +func (m *DASRequest) String() string { return proto.CompactTextString(m) } +func (*DASRequest) ProtoMessage() {} +func (*DASRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3f8b8b164973ed21, []int{2} +} +func (m *DASRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DASRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DASRequest.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 *DASRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DASRequest.Merge(m, src) +} +func (m *DASRequest) XXX_Size() int { + return m.Size() +} +func (m *DASRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DASRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DASRequest proto.InternalMessageInfo + +func (m *DASRequest) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *DASRequest) GetStreamID() []byte { + if m != nil { + return m.StreamID + } + return nil +} + +func (m *DASRequest) GetBatchHeaderHash() []byte { + if m != nil { + return m.BatchHeaderHash + } + return nil +} + +func (m *DASRequest) GetNumBlobs() uint32 { + if m != nil { + return m.NumBlobs + } + return 0 +} + +type DASResponse struct { + ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Sampler github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=sampler,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"sampler,omitempty"` + Results []bool `protobuf:"varint,3,rep,packed,name=results,proto3" json:"results,omitempty"` +} + +func (m *DASResponse) Reset() { *m = DASResponse{} } +func (m *DASResponse) String() string { return proto.CompactTextString(m) } +func (*DASResponse) ProtoMessage() {} +func (*DASResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3f8b8b164973ed21, []int{3} +} +func (m *DASResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DASResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DASResponse.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 *DASResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DASResponse.Merge(m, src) +} +func (m *DASResponse) XXX_Size() int { + return m.Size() +} +func (m *DASResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DASResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DASResponse proto.InternalMessageInfo + +func (m *DASResponse) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *DASResponse) GetSampler() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.Sampler + } + return nil +} + +func (m *DASResponse) GetResults() []bool { + if m != nil { + return m.Results + } + return nil +} + +func init() { + proto.RegisterType((*Params)(nil), "zgc.das.v1.Params") + proto.RegisterType((*GenesisState)(nil), "zgc.das.v1.GenesisState") + proto.RegisterType((*DASRequest)(nil), "zgc.das.v1.DASRequest") + proto.RegisterType((*DASResponse)(nil), "zgc.das.v1.DASResponse") +} + +func init() { proto.RegisterFile("zgc/das/v1/genesis.proto", fileDescriptor_3f8b8b164973ed21) } + +var fileDescriptor_3f8b8b164973ed21 = []byte{ + // 521 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0xbd, 0x6e, 0xd3, 0x50, + 0x14, 0x8e, 0x93, 0x28, 0x75, 0x6e, 0x12, 0x55, 0x35, 0xa8, 0xb8, 0x45, 0xb2, 0xa3, 0x4c, 0x29, + 0x52, 0xec, 0xb4, 0x2c, 0xfc, 0x4c, 0x35, 0x91, 0x48, 0x16, 0x84, 0x1c, 0x89, 0x81, 0xc5, 0xba, + 0xf6, 0xbd, 0xd8, 0x16, 0xb6, 0xaf, 0xf1, 0xb9, 0xae, 0x92, 0x3e, 0x01, 0x23, 0x23, 0x23, 0x12, + 0xaf, 0xc0, 0x43, 0x74, 0xac, 0x98, 0x98, 0x22, 0xe4, 0xbc, 0x04, 0x62, 0x42, 0xb1, 0x6f, 0x48, + 0x04, 0xea, 0x94, 0x7c, 0x7f, 0x3e, 0xdf, 0x91, 0x8f, 0x91, 0x7a, 0xed, 0x7b, 0x26, 0xc1, 0x60, + 0x5e, 0x9d, 0x9b, 0x3e, 0x4d, 0x28, 0x84, 0x60, 0xa4, 0x19, 0xe3, 0x4c, 0x41, 0xd7, 0xbe, 0x67, + 0x10, 0x0c, 0xc6, 0xd5, 0xf9, 0xe9, 0x89, 0xc7, 0x20, 0x66, 0xe0, 0x94, 0x8a, 0x59, 0x81, 0xca, + 0x76, 0x7a, 0xdf, 0x67, 0x3e, 0xab, 0xf8, 0xcd, 0x3f, 0xc1, 0x9e, 0xf8, 0x8c, 0xf9, 0x11, 0x35, + 0x4b, 0xe4, 0xe6, 0xef, 0x4c, 0x9c, 0x2c, 0x85, 0xa4, 0xff, 0x2b, 0xf1, 0x30, 0xa6, 0xc0, 0x71, + 0x9c, 0x56, 0x86, 0x81, 0x8c, 0x5a, 0xaf, 0x71, 0x86, 0x63, 0x18, 0xfc, 0x92, 0x50, 0xf7, 0x65, + 0x55, 0x6a, 0xce, 0x31, 0xa7, 0xca, 0x18, 0xb5, 0xd2, 0x52, 0x52, 0xa5, 0xbe, 0x34, 0xec, 0x5c, + 0x28, 0xc6, 0xae, 0xa4, 0x51, 0x85, 0xac, 0xe6, 0xcd, 0x4a, 0xaf, 0xd9, 0xc2, 0xa7, 0x3c, 0x45, + 0x87, 0x09, 0x5d, 0x70, 0x27, 0xa3, 0x1f, 0x72, 0x0a, 0xdc, 0x09, 0x89, 0x5a, 0xef, 0x4b, 0xc3, + 0xa6, 0x75, 0x54, 0xac, 0xf4, 0xde, 0x2b, 0xba, 0xe0, 0x76, 0xa5, 0xcc, 0x26, 0x76, 0x2f, 0xd9, + 0x83, 0x44, 0x79, 0x82, 0x64, 0x91, 0x02, 0xb5, 0xd1, 0x6f, 0x0c, 0x3b, 0x17, 0xc7, 0xfb, 0xe3, + 0x26, 0x97, 0x73, 0xe1, 0x15, 0x23, 0xff, 0xba, 0x95, 0xe7, 0xa8, 0x9d, 0x51, 0x48, 0x59, 0x02, + 0x14, 0xd4, 0x66, 0x19, 0x7d, 0xf0, 0x5f, 0xb4, 0xd2, 0x45, 0x76, 0xe7, 0x7f, 0xd6, 0xfc, 0xf8, + 0x45, 0xaf, 0x0d, 0x3e, 0x4b, 0x08, 0xed, 0x26, 0x28, 0xc7, 0xa8, 0x1e, 0x92, 0x72, 0xe9, 0xa6, + 0xd5, 0x2a, 0x56, 0x7a, 0x7d, 0x36, 0xb1, 0xeb, 0x21, 0x51, 0xce, 0x50, 0x1b, 0x78, 0x46, 0x71, + 0xbc, 0x5d, 0xac, 0x6b, 0x75, 0x8b, 0x95, 0x2e, 0xcf, 0x4b, 0x72, 0x36, 0xb1, 0xe5, 0x4a, 0x9e, + 0x11, 0xe5, 0x11, 0x3a, 0x72, 0x31, 0xf7, 0x02, 0x27, 0xa0, 0x98, 0xd0, 0xcc, 0x09, 0x30, 0x04, + 0x6a, 0x63, 0x13, 0xb1, 0x0f, 0x4b, 0x61, 0x5a, 0xf2, 0x53, 0x0c, 0x81, 0xf2, 0x10, 0xb5, 0x93, + 0x3c, 0x76, 0xdc, 0x88, 0xb9, 0x9b, 0x05, 0xa4, 0x61, 0xcf, 0x96, 0x93, 0x3c, 0xb6, 0x36, 0x78, + 0xf0, 0x55, 0x42, 0x9d, 0xbd, 0x0d, 0xee, 0xec, 0xe6, 0xa2, 0x03, 0xc0, 0x71, 0x1a, 0xd1, 0x4c, + 0x34, 0x9b, 0xfe, 0x5e, 0xe9, 0x23, 0x3f, 0xe4, 0x41, 0xee, 0x1a, 0x1e, 0x8b, 0xc5, 0x1d, 0x89, + 0x9f, 0x11, 0x90, 0xf7, 0x26, 0x5f, 0xa6, 0x14, 0x8c, 0x37, 0x38, 0xba, 0x24, 0x24, 0xa3, 0x00, + 0xdf, 0xbf, 0x8d, 0xee, 0x89, 0x6b, 0x13, 0x8c, 0xb5, 0xe4, 0x14, 0xec, 0xed, 0x83, 0x15, 0x15, + 0x1d, 0x64, 0x14, 0xf2, 0x48, 0xbc, 0x22, 0xd9, 0xde, 0x42, 0xeb, 0xc5, 0x4d, 0xa1, 0x49, 0xb7, + 0x85, 0x26, 0xfd, 0x2c, 0x34, 0xe9, 0xd3, 0x5a, 0xab, 0xdd, 0xae, 0xb5, 0xda, 0x8f, 0xb5, 0x56, + 0x7b, 0x7b, 0xb6, 0x57, 0x61, 0xec, 0x47, 0xd8, 0x05, 0x73, 0xec, 0x8f, 0xbc, 0x00, 0x87, 0x89, + 0xb9, 0xd8, 0x7e, 0x0b, 0x65, 0x13, 0xb7, 0x55, 0x5e, 0xe4, 0xe3, 0x3f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x5b, 0x0e, 0xfc, 0x0d, 0x26, 0x03, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Responses) > 0 { + for iNdEx := len(m.Responses) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Responses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Requests) > 0 { + for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Requests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.NextRequestID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextRequestID)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *DASRequest) 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 *DASRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DASRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumBlobs != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NumBlobs)) + i-- + dAtA[i] = 0x20 + } + if len(m.BatchHeaderHash) > 0 { + i -= len(m.BatchHeaderHash) + copy(dAtA[i:], m.BatchHeaderHash) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.BatchHeaderHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.StreamID) > 0 { + i -= len(m.StreamID) + copy(dAtA[i:], m.StreamID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.StreamID))) + i-- + dAtA[i] = 0x12 + } + if m.ID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DASResponse) 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 *DASResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DASResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + i-- + if m.Results[iNdEx] { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + } + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Results))) + i-- + dAtA[i] = 0x1a + } + if len(m.Sampler) > 0 { + i -= len(m.Sampler) + copy(dAtA[i:], m.Sampler) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Sampler))) + i-- + dAtA[i] = 0x12 + } + if m.ID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.NextRequestID != 0 { + n += 1 + sovGenesis(uint64(m.NextRequestID)) + } + if len(m.Requests) > 0 { + for _, e := range m.Requests { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Responses) > 0 { + for _, e := range m.Responses { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *DASRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovGenesis(uint64(m.ID)) + } + l = len(m.StreamID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.BatchHeaderHash) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.NumBlobs != 0 { + n += 1 + sovGenesis(uint64(m.NumBlobs)) + } + return n +} + +func (m *DASResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovGenesis(uint64(m.ID)) + } + l = len(m.Sampler) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Results) > 0 { + n += 1 + sovGenesis(uint64(len(m.Results))) + len(m.Results)*1 + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextRequestID", wireType) + } + m.NextRequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextRequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Requests = append(m.Requests, DASRequest{}) + if err := m.Requests[len(m.Requests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Responses = append(m.Responses, DASResponse{}) + if err := m.Responses[len(m.Responses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DASRequest) 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 ErrIntOverflowGenesis + } + 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: DASRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DASRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StreamID", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StreamID = append(m.StreamID[:0], dAtA[iNdEx:postIndex]...) + if m.StreamID == nil { + m.StreamID = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BatchHeaderHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BatchHeaderHash = append(m.BatchHeaderHash[:0], dAtA[iNdEx:postIndex]...) + if m.BatchHeaderHash == nil { + m.BatchHeaderHash = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlobs", wireType) + } + m.NumBlobs = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumBlobs |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DASResponse) 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 ErrIntOverflowGenesis + } + 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: DASResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DASResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sampler", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sampler = append(m.Sampler[:0], dAtA[iNdEx:postIndex]...) + if m.Sampler == nil { + m.Sampler = []byte{} + } + iNdEx = postIndex + case 3: + if wireType == 0 { + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Results = append(m.Results, bool(v != 0)) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Results) == 0 { + m.Results = make([]bool, 0, elementCount) + } + for iNdEx < postIndex { + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Results = append(m.Results, bool(v != 0)) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/das/v1/types/interfaces.go b/x/das/v1/types/interfaces.go new file mode 100644 index 00000000..ff56b322 --- /dev/null +++ b/x/das/v1/types/interfaces.go @@ -0,0 +1,10 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +type StakingKeeperRef interface { + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) +} diff --git a/x/das/v1/types/keys.go b/x/das/v1/types/keys.go new file mode 100644 index 00000000..06846cb9 --- /dev/null +++ b/x/das/v1/types/keys.go @@ -0,0 +1,44 @@ +package types + +import ( + "encoding/binary" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName The name that will be used throughout the module + ModuleName = "das" + + // StoreKey Top level store key where all module items will be stored + StoreKey = ModuleName +) + +// Key prefixes +var ( + RequestKeyPrefix = []byte{0x00} // prefix for keys that store requests + ResponseKeyPrefix = []byte{0x01} // prefix for keys that store responses + + NextRequestIDKey = []byte{0x02} +) + +// GetKeyFromID returns the bytes to use as a key for a uint64 id +func GetKeyFromID(id uint64) []byte { + return Uint64ToBytes(id) +} + +func GetResponseKey(requestID uint64, sampler sdk.ValAddress) []byte { + return append(GetKeyFromID(requestID), sampler.Bytes()...) +} + +// Uint64ToBytes converts a uint64 into fixed length bytes for use in store keys. +func Uint64ToBytes(id uint64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, uint64(id)) + return bz +} + +// Uint64FromBytes converts some fixed length bytes back into a uint64. +func Uint64FromBytes(bz []byte) uint64 { + return binary.BigEndian.Uint64(bz) +} diff --git a/x/das/v1/types/msg.go b/x/das/v1/types/msg.go new file mode 100644 index 00000000..f1c07ce4 --- /dev/null +++ b/x/das/v1/types/msg.go @@ -0,0 +1,57 @@ +package types + +import ( + "encoding/hex" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _, _ sdk.Msg = &MsgRequestDAS{}, &MsgReportDASResult{} + +func NewMsgRequestDAS(fromAddr sdk.AccAddress, streamID, hash string, numBlobs uint32) *MsgRequestDAS { + return &MsgRequestDAS{ + Requester: fromAddr.String(), + StreamID: streamID, + BatchHeaderHash: hash, + NumBlobs: numBlobs, + } +} + +func (msg MsgRequestDAS) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Requester) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +func (msg MsgRequestDAS) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Requester) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid requester account address (%s)", err) + } + + return nil +} + +func (msg *MsgReportDASResult) GetSigners() []sdk.AccAddress { + samplerValAddr, err := sdk.ValAddressFromBech32(msg.Sampler) + if err != nil { + panic(err) + } + accAddr, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(samplerValAddr.Bytes())) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +func (msg *MsgReportDASResult) ValidateBasic() error { + _, err := sdk.ValAddressFromBech32(msg.Sampler) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sampler validator address (%s)", err) + } + return nil +} diff --git a/x/das/v1/types/query.pb.go b/x/das/v1/types/query.pb.go new file mode 100644 index 00000000..16015f83 --- /dev/null +++ b/x/das/v1/types/query.pb.go @@ -0,0 +1,511 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/das/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + 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" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryNextRequestIDRequest struct { +} + +func (m *QueryNextRequestIDRequest) Reset() { *m = QueryNextRequestIDRequest{} } +func (m *QueryNextRequestIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNextRequestIDRequest) ProtoMessage() {} +func (*QueryNextRequestIDRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d404c1962bca645f, []int{0} +} +func (m *QueryNextRequestIDRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNextRequestIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNextRequestIDRequest.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 *QueryNextRequestIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNextRequestIDRequest.Merge(m, src) +} +func (m *QueryNextRequestIDRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNextRequestIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNextRequestIDRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNextRequestIDRequest proto.InternalMessageInfo + +type QueryNextRequestIDResponse struct { + NextRequestID uint64 `protobuf:"varint,1,opt,name=next_request_id,json=nextRequestId,proto3" json:"next_request_id,omitempty"` +} + +func (m *QueryNextRequestIDResponse) Reset() { *m = QueryNextRequestIDResponse{} } +func (m *QueryNextRequestIDResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNextRequestIDResponse) ProtoMessage() {} +func (*QueryNextRequestIDResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d404c1962bca645f, []int{1} +} +func (m *QueryNextRequestIDResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNextRequestIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNextRequestIDResponse.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 *QueryNextRequestIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNextRequestIDResponse.Merge(m, src) +} +func (m *QueryNextRequestIDResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNextRequestIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNextRequestIDResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNextRequestIDResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryNextRequestIDRequest)(nil), "zgc.das.v1.QueryNextRequestIDRequest") + proto.RegisterType((*QueryNextRequestIDResponse)(nil), "zgc.das.v1.QueryNextRequestIDResponse") +} + +func init() { proto.RegisterFile("zgc/das/v1/query.proto", fileDescriptor_d404c1962bca645f) } + +var fileDescriptor_d404c1962bca645f = []byte{ + // 334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xbf, 0x4b, 0x03, 0x31, + 0x14, 0xc7, 0x2f, 0xa2, 0x0e, 0x81, 0x22, 0x1e, 0x22, 0xf6, 0x94, 0x54, 0x0b, 0xfe, 0x1a, 0x9a, + 0xb4, 0x3a, 0xb9, 0x16, 0x41, 0x5c, 0x04, 0x5d, 0x04, 0x97, 0x92, 0xbb, 0x8b, 0x69, 0xa0, 0x97, + 0x5c, 0x9b, 0x5c, 0x69, 0x3b, 0xba, 0xb8, 0x2a, 0xfe, 0x53, 0x1d, 0x0b, 0x2e, 0x4e, 0xa2, 0x57, + 0xff, 0x10, 0xe9, 0xe5, 0x0e, 0xad, 0x28, 0x6e, 0xef, 0xbd, 0xef, 0xf7, 0x7d, 0xf3, 0xe1, 0x05, + 0xae, 0x8f, 0x78, 0x40, 0x42, 0xaa, 0x49, 0xbf, 0x41, 0xba, 0x09, 0xeb, 0x0d, 0x71, 0xdc, 0x53, + 0x46, 0xb9, 0x70, 0xc4, 0x03, 0x1c, 0x52, 0x8d, 0xfb, 0x0d, 0xaf, 0x1c, 0x28, 0x1d, 0x29, 0xdd, + 0xca, 0x14, 0x62, 0x1b, 0x6b, 0xf3, 0xd6, 0xb8, 0xe2, 0xca, 0xce, 0x67, 0x55, 0x3e, 0xdd, 0xe2, + 0x4a, 0xf1, 0x0e, 0x23, 0x34, 0x16, 0x84, 0x4a, 0xa9, 0x0c, 0x35, 0x42, 0xc9, 0x62, 0xa7, 0x9c, + 0xab, 0x59, 0xe7, 0x27, 0xb7, 0x84, 0xca, 0xfc, 0x55, 0xaf, 0xf2, 0x53, 0x32, 0x22, 0x62, 0xda, + 0xd0, 0x28, 0xb6, 0x86, 0xea, 0x26, 0x2c, 0x5f, 0xce, 0x28, 0x2f, 0xd8, 0xc0, 0x5c, 0xb1, 0x6e, + 0xc2, 0xb4, 0x39, 0x3f, 0xcd, 0x8b, 0xea, 0x35, 0xf4, 0x7e, 0x13, 0x75, 0xac, 0xa4, 0x66, 0xee, + 0x09, 0x5c, 0x91, 0x6c, 0x60, 0x5a, 0x3d, 0xab, 0xb4, 0x44, 0xb8, 0x01, 0xb6, 0xc1, 0xc1, 0x62, + 0x73, 0x35, 0x7d, 0xad, 0x94, 0xe6, 0x77, 0x4a, 0xf2, 0x5b, 0x1b, 0x1e, 0x3d, 0x02, 0xb8, 0x94, + 0x25, 0xbb, 0xf7, 0x00, 0xce, 0x5b, 0xdd, 0x5d, 0xfc, 0x75, 0x29, 0xfc, 0x27, 0x9b, 0xb7, 0xf7, + 0x9f, 0xcd, 0x52, 0x56, 0xf7, 0xef, 0x9e, 0x3f, 0x9e, 0x16, 0x76, 0xdc, 0x0a, 0xa9, 0xf3, 0xa0, + 0x4d, 0x85, 0x2c, 0x3e, 0x67, 0x46, 0x54, 0xcb, 0xd9, 0x6b, 0x22, 0x6c, 0x9e, 0x8d, 0xdf, 0x91, + 0x33, 0x4e, 0x11, 0x98, 0xa4, 0x08, 0xbc, 0xa5, 0x08, 0x3c, 0x4c, 0x91, 0x33, 0x99, 0x22, 0xe7, + 0x65, 0x8a, 0x9c, 0x9b, 0x43, 0x2e, 0x4c, 0x3b, 0xf1, 0x71, 0xa0, 0x22, 0x52, 0xe7, 0x1d, 0xea, + 0x6b, 0x52, 0xe7, 0x35, 0x1b, 0x38, 0x28, 0x22, 0xcd, 0x30, 0x66, 0xda, 0x5f, 0xce, 0x2e, 0x7b, + 0xfc, 0x19, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x9e, 0xd6, 0x49, 0x0a, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + NextRequestID(ctx context.Context, in *QueryNextRequestIDRequest, opts ...grpc.CallOption) (*QueryNextRequestIDResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) NextRequestID(ctx context.Context, in *QueryNextRequestIDRequest, opts ...grpc.CallOption) (*QueryNextRequestIDResponse, error) { + out := new(QueryNextRequestIDResponse) + err := c.cc.Invoke(ctx, "/zgc.das.v1.Query/NextRequestID", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + NextRequestID(context.Context, *QueryNextRequestIDRequest) (*QueryNextRequestIDResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) NextRequestID(ctx context.Context, req *QueryNextRequestIDRequest) (*QueryNextRequestIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NextRequestID not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_NextRequestID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNextRequestIDRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NextRequestID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.das.v1.Query/NextRequestID", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NextRequestID(ctx, req.(*QueryNextRequestIDRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.das.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "NextRequestID", + Handler: _Query_NextRequestID_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/das/v1/query.proto", +} + +func (m *QueryNextRequestIDRequest) 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 *QueryNextRequestIDRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNextRequestIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryNextRequestIDResponse) 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 *QueryNextRequestIDResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNextRequestIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NextRequestID != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.NextRequestID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryNextRequestIDRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryNextRequestIDResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NextRequestID != 0 { + n += 1 + sovQuery(uint64(m.NextRequestID)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryNextRequestIDRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryNextRequestIDRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNextRequestIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNextRequestIDResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryNextRequestIDResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNextRequestIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextRequestID", wireType) + } + m.NextRequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextRequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/das/v1/types/query.pb.gw.go b/x/das/v1/types/query.pb.gw.go new file mode 100644 index 00000000..5567645e --- /dev/null +++ b/x/das/v1/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: zgc/das/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_NextRequestID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNextRequestIDRequest + var metadata runtime.ServerMetadata + + msg, err := client.NextRequestID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_NextRequestID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNextRequestIDRequest + var metadata runtime.ServerMetadata + + msg, err := server.NextRequestID(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_NextRequestID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_NextRequestID_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NextRequestID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_NextRequestID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_NextRequestID_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NextRequestID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_NextRequestID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "das", "v1", "next-request-id"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_NextRequestID_0 = runtime.ForwardResponseMessage +) diff --git a/x/das/v1/types/tx.pb.go b/x/das/v1/types/tx.pb.go new file mode 100644 index 00000000..f18f23f6 --- /dev/null +++ b/x/das/v1/types/tx.pb.go @@ -0,0 +1,1110 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/das/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgRequestDAS struct { + Requester string `protobuf:"bytes,1,opt,name=requester,proto3" json:"requester,omitempty" Requester` + StreamID string `protobuf:"bytes,2,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"` + BatchHeaderHash string `protobuf:"bytes,3,opt,name=batch_header_hash,json=batchHeaderHash,proto3" json:"batch_header_hash,omitempty"` + NumBlobs uint32 `protobuf:"varint,4,opt,name=num_blobs,json=numBlobs,proto3" json:"num_blobs,omitempty"` +} + +func (m *MsgRequestDAS) Reset() { *m = MsgRequestDAS{} } +func (m *MsgRequestDAS) String() string { return proto.CompactTextString(m) } +func (*MsgRequestDAS) ProtoMessage() {} +func (*MsgRequestDAS) Descriptor() ([]byte, []int) { + return fileDescriptor_030259cfeac21931, []int{0} +} +func (m *MsgRequestDAS) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestDAS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestDAS.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 *MsgRequestDAS) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestDAS.Merge(m, src) +} +func (m *MsgRequestDAS) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestDAS) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestDAS.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestDAS proto.InternalMessageInfo + +type MsgRequestDASResponse struct { + RequestID uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (m *MsgRequestDASResponse) Reset() { *m = MsgRequestDASResponse{} } +func (m *MsgRequestDASResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRequestDASResponse) ProtoMessage() {} +func (*MsgRequestDASResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_030259cfeac21931, []int{1} +} +func (m *MsgRequestDASResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestDASResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestDASResponse.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 *MsgRequestDASResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestDASResponse.Merge(m, src) +} +func (m *MsgRequestDASResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestDASResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestDASResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestDASResponse proto.InternalMessageInfo + +type MsgReportDASResult struct { + RequestID uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + Sampler string `protobuf:"bytes,2,opt,name=sampler,proto3" json:"sampler,omitempty"` + Results []bool `protobuf:"varint,3,rep,packed,name=results,proto3" json:"results,omitempty"` +} + +func (m *MsgReportDASResult) Reset() { *m = MsgReportDASResult{} } +func (m *MsgReportDASResult) String() string { return proto.CompactTextString(m) } +func (*MsgReportDASResult) ProtoMessage() {} +func (*MsgReportDASResult) Descriptor() ([]byte, []int) { + return fileDescriptor_030259cfeac21931, []int{2} +} +func (m *MsgReportDASResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgReportDASResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgReportDASResult.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 *MsgReportDASResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgReportDASResult.Merge(m, src) +} +func (m *MsgReportDASResult) XXX_Size() int { + return m.Size() +} +func (m *MsgReportDASResult) XXX_DiscardUnknown() { + xxx_messageInfo_MsgReportDASResult.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgReportDASResult proto.InternalMessageInfo + +type MsgReportDASResultResponse struct { +} + +func (m *MsgReportDASResultResponse) Reset() { *m = MsgReportDASResultResponse{} } +func (m *MsgReportDASResultResponse) String() string { return proto.CompactTextString(m) } +func (*MsgReportDASResultResponse) ProtoMessage() {} +func (*MsgReportDASResultResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_030259cfeac21931, []int{3} +} +func (m *MsgReportDASResultResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgReportDASResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgReportDASResultResponse.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 *MsgReportDASResultResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgReportDASResultResponse.Merge(m, src) +} +func (m *MsgReportDASResultResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgReportDASResultResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgReportDASResultResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgReportDASResultResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRequestDAS)(nil), "zgc.das.v1.MsgRequestDAS") + proto.RegisterType((*MsgRequestDASResponse)(nil), "zgc.das.v1.MsgRequestDASResponse") + proto.RegisterType((*MsgReportDASResult)(nil), "zgc.das.v1.MsgReportDASResult") + proto.RegisterType((*MsgReportDASResultResponse)(nil), "zgc.das.v1.MsgReportDASResultResponse") +} + +func init() { proto.RegisterFile("zgc/das/v1/tx.proto", fileDescriptor_030259cfeac21931) } + +var fileDescriptor_030259cfeac21931 = []byte{ + // 452 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x4f, 0x6e, 0xd3, 0x40, + 0x14, 0xc6, 0x63, 0x52, 0x41, 0xf2, 0x44, 0x54, 0x31, 0x80, 0xe4, 0x18, 0xe4, 0x86, 0x2c, 0x50, + 0xca, 0x1f, 0x4f, 0x0b, 0x27, 0x20, 0x0a, 0xa2, 0x41, 0xea, 0x66, 0xba, 0x82, 0x8d, 0x35, 0xb6, + 0x87, 0x71, 0x24, 0xdb, 0x63, 0xfc, 0xec, 0xa8, 0xed, 0x29, 0x38, 0x08, 0x0b, 0x8e, 0xd1, 0x65, + 0x97, 0xac, 0x2a, 0x70, 0x6e, 0xc0, 0x09, 0x90, 0xc7, 0x76, 0xd2, 0x50, 0x81, 0xc4, 0x2e, 0xdf, + 0xf7, 0x9b, 0xf9, 0xe6, 0x7b, 0xf1, 0x83, 0xfb, 0xe7, 0xd2, 0xa7, 0x01, 0x47, 0xba, 0x3c, 0xa4, + 0xf9, 0xa9, 0x93, 0x66, 0x2a, 0x57, 0x04, 0xce, 0xa5, 0xef, 0x04, 0x1c, 0x9d, 0xe5, 0xa1, 0x35, + 0xf4, 0x15, 0xc6, 0x0a, 0x5d, 0x4d, 0x68, 0x2d, 0xea, 0x63, 0xd6, 0x03, 0xa9, 0xa4, 0xaa, 0xfd, + 0xea, 0x57, 0xe3, 0x0e, 0xa5, 0x52, 0x32, 0x12, 0x54, 0x2b, 0xaf, 0xf8, 0x44, 0x79, 0x72, 0xd6, + 0x20, 0xf3, 0xda, 0x63, 0x52, 0x24, 0x02, 0x17, 0x4d, 0xd4, 0xf8, 0x9b, 0x01, 0x83, 0x63, 0x94, + 0x4c, 0x7c, 0x2e, 0x04, 0xe6, 0xb3, 0x37, 0x27, 0xe4, 0x39, 0xf4, 0xb3, 0x5a, 0x89, 0xcc, 0x34, + 0x46, 0xc6, 0xa4, 0x3f, 0x1d, 0xfc, 0xba, 0xda, 0xeb, 0xb3, 0xd6, 0x64, 0x1b, 0x4e, 0xf6, 0xa1, + 0x8f, 0x79, 0x26, 0x78, 0xec, 0x2e, 0x02, 0xf3, 0x96, 0x3e, 0x7c, 0xb7, 0xbc, 0xda, 0xeb, 0x9d, + 0x68, 0x73, 0x3e, 0x63, 0xbd, 0x1a, 0xcf, 0x03, 0xf2, 0x0c, 0xee, 0x79, 0x3c, 0xf7, 0x43, 0x37, + 0x14, 0x3c, 0x10, 0x99, 0x1b, 0x72, 0x0c, 0xcd, 0x6e, 0x75, 0x85, 0xed, 0x6a, 0x70, 0xa4, 0xfd, + 0x23, 0x8e, 0x21, 0x79, 0x04, 0xfd, 0xa4, 0x88, 0x5d, 0x2f, 0x52, 0x1e, 0x9a, 0x3b, 0x23, 0x63, + 0x32, 0x60, 0xbd, 0xa4, 0x88, 0xa7, 0x95, 0x1e, 0xbf, 0x85, 0x87, 0x5b, 0x8d, 0x99, 0xc0, 0x54, + 0x25, 0x28, 0xc8, 0x0b, 0x80, 0xa6, 0x59, 0xd5, 0xa6, 0xaa, 0xbe, 0x33, 0x1d, 0x94, 0x9b, 0xea, + 0xf3, 0xd9, 0xba, 0xfa, 0x3c, 0x18, 0x2f, 0x81, 0xe8, 0x98, 0x54, 0x65, 0x4d, 0x4a, 0x11, 0xe5, + 0xff, 0x97, 0x41, 0x4c, 0xb8, 0x83, 0x3c, 0x4e, 0x23, 0x91, 0xd5, 0xc3, 0xb3, 0x56, 0x56, 0x24, + 0xd3, 0x89, 0x68, 0x76, 0x47, 0xdd, 0x49, 0x8f, 0xb5, 0x72, 0xfc, 0x18, 0xac, 0x9b, 0xef, 0xb6, + 0x33, 0xbc, 0xfa, 0x6a, 0x40, 0xf7, 0x18, 0x25, 0x79, 0x0f, 0x70, 0xed, 0x9b, 0x0c, 0x9d, 0xcd, + 0x62, 0x38, 0x5b, 0xc3, 0x5b, 0x4f, 0xfe, 0x8a, 0xd6, 0xff, 0xcb, 0x07, 0xd8, 0xfd, 0x73, 0x4c, + 0xfb, 0xc6, 0xad, 0x2d, 0x6e, 0x3d, 0xfd, 0x37, 0x6f, 0xa3, 0xa7, 0xef, 0x2e, 0x7e, 0xda, 0x9d, + 0x8b, 0xd2, 0x36, 0x2e, 0x4b, 0xdb, 0xf8, 0x51, 0xda, 0xc6, 0x97, 0x95, 0xdd, 0xb9, 0x5c, 0xd9, + 0x9d, 0xef, 0x2b, 0xbb, 0xf3, 0x71, 0x5f, 0x2e, 0xf2, 0xb0, 0xf0, 0x1c, 0x5f, 0xc5, 0xf4, 0x40, + 0x46, 0xdc, 0x43, 0x7a, 0x20, 0x5f, 0xfa, 0x21, 0x5f, 0x24, 0xf4, 0x74, 0xbd, 0xfc, 0x67, 0xa9, + 0x40, 0xef, 0xb6, 0x5e, 0xc7, 0xd7, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xba, 0x08, 0x98, + 0x17, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + RequestDAS(ctx context.Context, in *MsgRequestDAS, opts ...grpc.CallOption) (*MsgRequestDASResponse, error) + ReportDASResult(ctx context.Context, in *MsgReportDASResult, opts ...grpc.CallOption) (*MsgReportDASResultResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RequestDAS(ctx context.Context, in *MsgRequestDAS, opts ...grpc.CallOption) (*MsgRequestDASResponse, error) { + out := new(MsgRequestDASResponse) + err := c.cc.Invoke(ctx, "/zgc.das.v1.Msg/RequestDAS", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ReportDASResult(ctx context.Context, in *MsgReportDASResult, opts ...grpc.CallOption) (*MsgReportDASResultResponse, error) { + out := new(MsgReportDASResultResponse) + err := c.cc.Invoke(ctx, "/zgc.das.v1.Msg/ReportDASResult", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + RequestDAS(context.Context, *MsgRequestDAS) (*MsgRequestDASResponse, error) + ReportDASResult(context.Context, *MsgReportDASResult) (*MsgReportDASResultResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RequestDAS(ctx context.Context, req *MsgRequestDAS) (*MsgRequestDASResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RequestDAS not implemented") +} +func (*UnimplementedMsgServer) ReportDASResult(ctx context.Context, req *MsgReportDASResult) (*MsgReportDASResultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReportDASResult not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RequestDAS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRequestDAS) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RequestDAS(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.das.v1.Msg/RequestDAS", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RequestDAS(ctx, req.(*MsgRequestDAS)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ReportDASResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgReportDASResult) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ReportDASResult(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.das.v1.Msg/ReportDASResult", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ReportDASResult(ctx, req.(*MsgReportDASResult)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.das.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RequestDAS", + Handler: _Msg_RequestDAS_Handler, + }, + { + MethodName: "ReportDASResult", + Handler: _Msg_ReportDASResult_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/das/v1/tx.proto", +} + +func (m *MsgRequestDAS) 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 *MsgRequestDAS) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestDAS) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumBlobs != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NumBlobs)) + i-- + dAtA[i] = 0x20 + } + if len(m.BatchHeaderHash) > 0 { + i -= len(m.BatchHeaderHash) + copy(dAtA[i:], m.BatchHeaderHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.BatchHeaderHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.StreamID) > 0 { + i -= len(m.StreamID) + copy(dAtA[i:], m.StreamID) + i = encodeVarintTx(dAtA, i, uint64(len(m.StreamID))) + i-- + dAtA[i] = 0x12 + } + if len(m.Requester) > 0 { + i -= len(m.Requester) + copy(dAtA[i:], m.Requester) + i = encodeVarintTx(dAtA, i, uint64(len(m.Requester))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRequestDASResponse) 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 *MsgRequestDASResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestDASResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RequestID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgReportDASResult) 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 *MsgReportDASResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgReportDASResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + i-- + if m.Results[iNdEx] { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + } + i = encodeVarintTx(dAtA, i, uint64(len(m.Results))) + i-- + dAtA[i] = 0x1a + } + if len(m.Sampler) > 0 { + i -= len(m.Sampler) + copy(dAtA[i:], m.Sampler) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sampler))) + i-- + dAtA[i] = 0x12 + } + if m.RequestID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgReportDASResultResponse) 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 *MsgReportDASResultResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgReportDASResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRequestDAS) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Requester) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.StreamID) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BatchHeaderHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.NumBlobs != 0 { + n += 1 + sovTx(uint64(m.NumBlobs)) + } + return n +} + +func (m *MsgRequestDASResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestID != 0 { + n += 1 + sovTx(uint64(m.RequestID)) + } + return n +} + +func (m *MsgReportDASResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestID != 0 { + n += 1 + sovTx(uint64(m.RequestID)) + } + l = len(m.Sampler) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Results) > 0 { + n += 1 + sovTx(uint64(len(m.Results))) + len(m.Results)*1 + } + return n +} + +func (m *MsgReportDASResultResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgRequestDAS) 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: MsgRequestDAS: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestDAS: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requester", 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.Requester = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StreamID", 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.StreamID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BatchHeaderHash", 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.BatchHeaderHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlobs", wireType) + } + m.NumBlobs = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumBlobs |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgRequestDASResponse) 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: MsgRequestDASResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestDASResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgReportDASResult) 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: MsgReportDASResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgReportDASResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sampler", 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.Sampler = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType == 0 { + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Results = append(m.Results, bool(v != 0)) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Results) == 0 { + m.Results = make([]bool, 0, elementCount) + } + for iNdEx < postIndex { + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Results = append(m.Results, bool(v != 0)) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + } + 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 *MsgReportDASResultResponse) 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: MsgReportDASResultResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgReportDASResultResponse: 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 skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/evmutil/client/cli/address.go b/x/evmutil/client/cli/address.go index f748c63f..31017c4b 100644 --- a/x/evmutil/client/cli/address.go +++ b/x/evmutil/client/cli/address.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" + "github.com/0glabs/0g-chain/x/evmutil/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - "github.com/kava-labs/kava/x/evmutil/types" ) // ParseAddrFromHexOrBech32 parses a string address that can be either a hex or diff --git a/x/evmutil/client/cli/query.go b/x/evmutil/client/cli/query.go index e0539800..0b693364 100644 --- a/x/evmutil/client/cli/query.go +++ b/x/evmutil/client/cli/query.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/spf13/cobra" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/evmutil/client/cli/tx.go b/x/evmutil/client/cli/tx.go index 22201af6..56238d3b 100644 --- a/x/evmutil/client/cli/tx.go +++ b/x/evmutil/client/cli/tx.go @@ -14,7 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/evmutil/genesis.go b/x/evmutil/genesis.go index 209dda25..8099da14 100644 --- a/x/evmutil/genesis.go +++ b/x/evmutil/genesis.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // InitGenesis initializes the store state from a genesis state. diff --git a/x/evmutil/genesis_test.go b/x/evmutil/genesis_test.go index 0c71f9ff..cd9b3c47 100644 --- a/x/evmutil/genesis_test.go +++ b/x/evmutil/genesis_test.go @@ -6,10 +6,10 @@ import ( "github.com/stretchr/testify/suite" sdkmath "cosmossdk.io/math" + "github.com/0glabs/0g-chain/x/evmutil" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/kava-labs/kava/x/evmutil" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" ) type genesisTestSuite struct { @@ -40,8 +40,8 @@ func (s *genesisTestSuite) TestInitGenesis_SetAccounts() { func (s *genesisTestSuite) TestInitGenesis_SetParams() { params := types.DefaultParams() conversionPair := types.ConversionPair{ - KavaERC20Address: testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2").Bytes(), - Denom: "weth", + ZgchainERC20Address: testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2").Bytes(), + Denom: "weth", } params.EnabledConversionPairs = []types.ConversionPair{conversionPair} gs := types.NewGenesisState( @@ -92,8 +92,8 @@ func (s *genesisTestSuite) TestExportGenesis() { params := types.DefaultParams() params.EnabledConversionPairs = []types.ConversionPair{ { - KavaERC20Address: testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2").Bytes(), - Denom: "weth"}, + ZgchainERC20Address: testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2").Bytes(), + Denom: "weth"}, } params.AllowedCosmosDenoms = []types.AllowedCosmosCoinERC20Token{ { diff --git a/x/evmutil/keeper/bank_keeper.go b/x/evmutil/keeper/bank_keeper.go index 8061561b..b25220ef 100644 --- a/x/evmutil/keeper/bank_keeper.go +++ b/x/evmutil/keeper/bank_keeper.go @@ -9,7 +9,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) const ( diff --git a/x/evmutil/keeper/bank_keeper_test.go b/x/evmutil/keeper/bank_keeper_test.go index 96b3b747..444cba3d 100644 --- a/x/evmutil/keeper/bank_keeper_test.go +++ b/x/evmutil/keeper/bank_keeper_test.go @@ -13,9 +13,9 @@ import ( vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type evmBankKeeperTestSuite struct { diff --git a/x/evmutil/keeper/conversion_cosmos_native.go b/x/evmutil/keeper/conversion_cosmos_native.go index 6c8c813a..5e1d7289 100644 --- a/x/evmutil/keeper/conversion_cosmos_native.go +++ b/x/evmutil/keeper/conversion_cosmos_native.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // ConvertCosmosCoinToERC20 locks the initiator's sdk.Coin in the module account diff --git a/x/evmutil/keeper/conversion_cosmos_native_test.go b/x/evmutil/keeper/conversion_cosmos_native_test.go index 15857957..cc025b29 100644 --- a/x/evmutil/keeper/conversion_cosmos_native_test.go +++ b/x/evmutil/keeper/conversion_cosmos_native_test.go @@ -10,9 +10,9 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type convertCosmosCoinToERC20Suite struct { diff --git a/x/evmutil/keeper/conversion_evm_native.go b/x/evmutil/keeper/conversion_evm_native.go index 69a97de2..edb0ff49 100644 --- a/x/evmutil/keeper/conversion_evm_native.go +++ b/x/evmutil/keeper/conversion_evm_native.go @@ -7,7 +7,7 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // MintConversionPairCoin mints the given amount of a ConversionPair denom and diff --git a/x/evmutil/keeper/conversion_evm_native_bep3.go b/x/evmutil/keeper/conversion_evm_native_bep3.go index b727996d..c63465ab 100644 --- a/x/evmutil/keeper/conversion_evm_native_bep3.go +++ b/x/evmutil/keeper/conversion_evm_native_bep3.go @@ -4,7 +4,7 @@ import ( "math/big" errorsmod "cosmossdk.io/errors" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) var ( diff --git a/x/evmutil/keeper/conversion_evm_native_bep3_test.go b/x/evmutil/keeper/conversion_evm_native_bep3_test.go index c2d06128..12d9f9b8 100644 --- a/x/evmutil/keeper/conversion_evm_native_bep3_test.go +++ b/x/evmutil/keeper/conversion_evm_native_bep3_test.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type Bep3ConversionTestSuite struct { diff --git a/x/evmutil/keeper/conversion_evm_native_test.go b/x/evmutil/keeper/conversion_evm_native_test.go index 3cd9d1c7..8e7555d9 100644 --- a/x/evmutil/keeper/conversion_evm_native_test.go +++ b/x/evmutil/keeper/conversion_evm_native_test.go @@ -9,8 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type ConversionTestSuite struct { diff --git a/x/evmutil/keeper/erc20.go b/x/evmutil/keeper/erc20.go index a4b7fe5d..6768aadc 100644 --- a/x/evmutil/keeper/erc20.go +++ b/x/evmutil/keeper/erc20.go @@ -13,7 +13,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) const ( diff --git a/x/evmutil/keeper/erc20_test.go b/x/evmutil/keeper/erc20_test.go index 5cfcd52a..2c9fb9cd 100644 --- a/x/evmutil/keeper/erc20_test.go +++ b/x/evmutil/keeper/erc20_test.go @@ -7,9 +7,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type ERC20TestSuite struct { diff --git a/x/evmutil/keeper/evm.go b/x/evmutil/keeper/evm.go index 43829dd4..32d948ff 100644 --- a/x/evmutil/keeper/evm.go +++ b/x/evmutil/keeper/evm.go @@ -28,7 +28,7 @@ import ( "github.com/evmos/ethermint/server/config" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // CallEVM performs a smart contract method call using given args diff --git a/x/evmutil/keeper/evm_test.go b/x/evmutil/keeper/evm_test.go index c4fba03d..343d8a6c 100644 --- a/x/evmutil/keeper/evm_test.go +++ b/x/evmutil/keeper/evm_test.go @@ -17,7 +17,7 @@ import ( "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" - "github.com/kava-labs/kava/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/testutil" ) type evmKeeperTestSuite struct { diff --git a/x/evmutil/keeper/grpc_query.go b/x/evmutil/keeper/grpc_query.go index 0ff2d0e9..8485ce1f 100644 --- a/x/evmutil/keeper/grpc_query.go +++ b/x/evmutil/keeper/grpc_query.go @@ -10,7 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type queryServer struct { diff --git a/x/evmutil/keeper/grpc_query_test.go b/x/evmutil/keeper/grpc_query_test.go index 4f6c6c05..95341089 100644 --- a/x/evmutil/keeper/grpc_query_test.go +++ b/x/evmutil/keeper/grpc_query_test.go @@ -11,10 +11,10 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type grpcQueryTestSuite struct { diff --git a/x/evmutil/keeper/invariants.go b/x/evmutil/keeper/invariants.go index b8c880b1..6b3a1db0 100644 --- a/x/evmutil/keeper/invariants.go +++ b/x/evmutil/keeper/invariants.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // RegisterInvariants registers the swap module invariants diff --git a/x/evmutil/keeper/invariants_test.go b/x/evmutil/keeper/invariants_test.go index 3b3867c0..55355b4b 100644 --- a/x/evmutil/keeper/invariants_test.go +++ b/x/evmutil/keeper/invariants_test.go @@ -11,10 +11,10 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type invariantTestSuite struct { diff --git a/x/evmutil/keeper/keeper.go b/x/evmutil/keeper/keeper.go index 02098c8d..78e84bad 100644 --- a/x/evmutil/keeper/keeper.go +++ b/x/evmutil/keeper/keeper.go @@ -11,7 +11,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // Keeper of the evmutil store. diff --git a/x/evmutil/keeper/keeper_test.go b/x/evmutil/keeper/keeper_test.go index a5ea5c6e..bdbd6ad5 100644 --- a/x/evmutil/keeper/keeper_test.go +++ b/x/evmutil/keeper/keeper_test.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type keeperTestSuite struct { diff --git a/x/evmutil/keeper/migrations.go b/x/evmutil/keeper/migrations.go index f74aa0ca..518b5f3e 100644 --- a/x/evmutil/keeper/migrations.go +++ b/x/evmutil/keeper/migrations.go @@ -1,8 +1,8 @@ package keeper import ( + v2 "github.com/0glabs/0g-chain/x/evmutil/migrations/v2" sdk "github.com/cosmos/cosmos-sdk/types" - v2 "github.com/kava-labs/kava/x/evmutil/migrations/v2" ) // Migrator is a struct for handling in-place store migrations. diff --git a/x/evmutil/keeper/msg_server.go b/x/evmutil/keeper/msg_server.go index 6d843500..319426d3 100644 --- a/x/evmutil/keeper/msg_server.go +++ b/x/evmutil/keeper/msg_server.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type msgServer struct { @@ -81,7 +81,7 @@ func (s msgServer) ConvertERC20ToCoin( return nil, fmt.Errorf("invalid receiver address: %w", err) } - contractAddr, err := types.NewInternalEVMAddressFromString(msg.KavaERC20Address) + contractAddr, err := types.NewInternalEVMAddressFromString(msg.ZgchainERC20Address) if err != nil { return nil, fmt.Errorf("invalid contract address: %w", err) } diff --git a/x/evmutil/keeper/msg_server_bep3_test.go b/x/evmutil/keeper/msg_server_bep3_test.go index d36c68fd..a9324812 100644 --- a/x/evmutil/keeper/msg_server_bep3_test.go +++ b/x/evmutil/keeper/msg_server_bep3_test.go @@ -4,8 +4,8 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) func (suite *MsgServerSuite) TestConvertCoinToERC20_Bep3() { @@ -198,10 +198,10 @@ func (suite *MsgServerSuite) TestConvertERC20ToCoin_Bep3() { { name: "invalid - invalid initiator address", msg: types.MsgConvertERC20ToCoin{ - Initiator: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc", - Receiver: invokerCosmosAddr.String(), - KavaERC20Address: contractAddr.String(), - Amount: sdkmath.NewInt(12e8), + Initiator: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc", + Receiver: invokerCosmosAddr.String(), + ZgchainERC20Address: contractAddr.String(), + Amount: sdkmath.NewInt(12e8), }, userErc20Balance: sdkmath.NewInt(2e18), errArgs: errArgs{ @@ -212,10 +212,10 @@ func (suite *MsgServerSuite) TestConvertERC20ToCoin_Bep3() { { name: "invalid - invalid receiver address", msg: types.MsgConvertERC20ToCoin{ - Initiator: invoker.String(), - Receiver: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc", - KavaERC20Address: contractAddr.String(), - Amount: sdkmath.NewInt(12e8), + Initiator: invoker.String(), + Receiver: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc", + ZgchainERC20Address: contractAddr.String(), + Amount: sdkmath.NewInt(12e8), }, userErc20Balance: sdkmath.NewInt(2e18), errArgs: errArgs{ @@ -226,10 +226,10 @@ func (suite *MsgServerSuite) TestConvertERC20ToCoin_Bep3() { { name: "invalid - invalid contract address", msg: types.MsgConvertERC20ToCoin{ - Initiator: invoker.String(), - Receiver: invokerCosmosAddr.String(), - KavaERC20Address: invokerCosmosAddr.String(), - Amount: sdkmath.NewInt(12e8), + Initiator: invoker.String(), + Receiver: invokerCosmosAddr.String(), + ZgchainERC20Address: invokerCosmosAddr.String(), + Amount: sdkmath.NewInt(12e8), }, userErc20Balance: sdkmath.NewInt(2e18), errArgs: errArgs{ diff --git a/x/evmutil/keeper/msg_server_test.go b/x/evmutil/keeper/msg_server_test.go index 89c7c04a..70890337 100644 --- a/x/evmutil/keeper/msg_server_test.go +++ b/x/evmutil/keeper/msg_server_test.go @@ -12,10 +12,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type MsgServerSuite struct { @@ -185,10 +185,10 @@ func (suite *MsgServerSuite) TestConvertERC20ToCoin() { { "invalid - invalid hex address", types.MsgConvertERC20ToCoin{ - Initiator: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc", - Receiver: invokerCosmosAddr.String(), - KavaERC20Address: contractAddr.String(), - Amount: sdkmath.NewInt(10_000), + Initiator: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc", + Receiver: invokerCosmosAddr.String(), + ZgchainERC20Address: contractAddr.String(), + Amount: sdkmath.NewInt(10_000), }, math.MaxBig256, errArgs{ diff --git a/x/evmutil/keeper/params.go b/x/evmutil/keeper/params.go index 2b13cb1a..76fabd21 100644 --- a/x/evmutil/keeper/params.go +++ b/x/evmutil/keeper/params.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // GetParams returns the total set of evm parameters. @@ -39,7 +39,7 @@ func (k Keeper) GetEnabledConversionPairFromERC20Address( ) (types.ConversionPair, error) { params := k.GetParams(ctx) for _, pair := range params.EnabledConversionPairs { - if bytes.Equal(pair.KavaERC20Address, address.Bytes()) { + if bytes.Equal(pair.ZgchainERC20Address, address.Bytes()) { return pair, nil } } diff --git a/x/evmutil/keeper/params_test.go b/x/evmutil/keeper/params_test.go index 4a1a016a..1085e7dc 100644 --- a/x/evmutil/keeper/params_test.go +++ b/x/evmutil/keeper/params_test.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type ParamsTestSuite struct { @@ -23,8 +23,8 @@ func TestParamsSuite(t *testing.T) { func (suite *ParamsTestSuite) TestEnabledConversionPair() { pairAddr := testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2") expPair := types.ConversionPair{ - KavaERC20Address: pairAddr.Bytes(), - Denom: "weth", + ZgchainERC20Address: pairAddr.Bytes(), + Denom: "weth", } params := types.DefaultParams() params.EnabledConversionPairs = []types.ConversionPair{expPair} diff --git a/x/evmutil/migrations/v2/store.go b/x/evmutil/migrations/v2/store.go index aa506e16..493e0ea2 100644 --- a/x/evmutil/migrations/v2/store.go +++ b/x/evmutil/migrations/v2/store.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // MigrateStore performs in-place store migrations for consensus version 2 diff --git a/x/evmutil/migrations/v2/store_test.go b/x/evmutil/migrations/v2/store_test.go index 69a6cd99..3d3160d7 100644 --- a/x/evmutil/migrations/v2/store_test.go +++ b/x/evmutil/migrations/v2/store_test.go @@ -10,8 +10,8 @@ import ( moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - v2evmutil "github.com/kava-labs/kava/x/evmutil/migrations/v2" - "github.com/kava-labs/kava/x/evmutil/types" + v2evmutil "github.com/0glabs/0g-chain/x/evmutil/migrations/v2" + "github.com/0glabs/0g-chain/x/evmutil/types" ) func TestStoreMigrationAddsKeyTableIncludingNewParam(t *testing.T) { diff --git a/x/evmutil/module.go b/x/evmutil/module.go index 09ed8b11..c7e0ce64 100644 --- a/x/evmutil/module.go +++ b/x/evmutil/module.go @@ -15,9 +15,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/kava-labs/kava/x/evmutil/client/cli" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/client/cli" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/types" ) // ConsensusVersion defines the current module consensus version. diff --git a/x/evmutil/testutil/suite.go b/x/evmutil/testutil/suite.go index c09ec153..601ec909 100644 --- a/x/evmutil/testutil/suite.go +++ b/x/evmutil/testutil/suite.go @@ -36,9 +36,9 @@ import ( feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/keeper" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/keeper" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type Suite struct { diff --git a/x/evmutil/types/address_test.go b/x/evmutil/types/address_test.go index bc8e80bb..aa4b842c 100644 --- a/x/evmutil/types/address_test.go +++ b/x/evmutil/types/address_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" "github.com/stretchr/testify/require" ) diff --git a/x/evmutil/types/bytes_test.go b/x/evmutil/types/bytes_test.go index 1109180c..317eb9f8 100644 --- a/x/evmutil/types/bytes_test.go +++ b/x/evmutil/types/bytes_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" "github.com/stretchr/testify/require" ) diff --git a/x/evmutil/types/conversion_pair.go b/x/evmutil/types/conversion_pair.go index eab8b318..550ab5b5 100644 --- a/x/evmutil/types/conversion_pair.go +++ b/x/evmutil/types/conversion_pair.go @@ -18,14 +18,14 @@ import ( // NewConversionPair returns a new ConversionPair. func NewConversionPair(address InternalEVMAddress, denom string) ConversionPair { return ConversionPair{ - KavaERC20Address: address.Address.Bytes(), - Denom: denom, + ZgchainERC20Address: address.Address.Bytes(), + Denom: denom, } } // GetAddress returns the InternalEVMAddress of the Kava ERC20 address. func (pair ConversionPair) GetAddress() InternalEVMAddress { - return NewInternalEVMAddress(common.BytesToAddress(pair.KavaERC20Address)) + return NewInternalEVMAddress(common.BytesToAddress(pair.ZgchainERC20Address)) } // Validate returns an error if the ConversionPair is invalid. @@ -34,12 +34,12 @@ func (pair ConversionPair) Validate() error { return fmt.Errorf("conversion pair denom invalid: %v", err) } - if len(pair.KavaERC20Address) != common.AddressLength { - return fmt.Errorf("address length is %v but expected %v", len(pair.KavaERC20Address), common.AddressLength) + if len(pair.ZgchainERC20Address) != common.AddressLength { + return fmt.Errorf("address length is %v but expected %v", len(pair.ZgchainERC20Address), common.AddressLength) } - if bytes.Equal(pair.KavaERC20Address, common.Address{}.Bytes()) { - return fmt.Errorf("address cannot be zero value %v", hex.EncodeToString(pair.KavaERC20Address)) + if bytes.Equal(pair.ZgchainERC20Address, common.Address{}.Bytes()) { + return fmt.Errorf("address cannot be zero value %v", hex.EncodeToString(pair.ZgchainERC20Address)) } return nil @@ -59,10 +59,10 @@ func (pairs ConversionPairs) Validate() error { denoms := map[string]bool{} for _, pair := range pairs { - if addrs[hex.EncodeToString(pair.KavaERC20Address)] { + if addrs[hex.EncodeToString(pair.ZgchainERC20Address)] { return fmt.Errorf( "found duplicate enabled conversion pair internal ERC20 address %s", - hex.EncodeToString(pair.KavaERC20Address), + hex.EncodeToString(pair.ZgchainERC20Address), ) } @@ -77,7 +77,7 @@ func (pairs ConversionPairs) Validate() error { return err } - addrs[hex.EncodeToString(pair.KavaERC20Address)] = true + addrs[hex.EncodeToString(pair.ZgchainERC20Address)] = true denoms[pair.Denom] = true } diff --git a/x/evmutil/types/conversion_pair.pb.go b/x/evmutil/types/conversion_pair.pb.go index 637dd783..1e62ae26 100644 --- a/x/evmutil/types/conversion_pair.pb.go +++ b/x/evmutil/types/conversion_pair.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kava/evmutil/v1beta1/conversion_pair.proto +// source: zgc/evmutil/v1beta1/conversion_pair.proto package types @@ -24,11 +24,11 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// ConversionPair defines a Kava ERC20 address and corresponding denom that is +// ConversionPair defines a 0g-chain ERC20 address and corresponding denom that is // allowed to be converted between ERC20 and sdk.Coin type ConversionPair struct { - // ERC20 address of the token on the Kava EVM - KavaERC20Address HexBytes `protobuf:"bytes,1,opt,name=kava_erc20_address,json=kavaErc20Address,proto3,casttype=HexBytes" json:"kava_erc20_address,omitempty"` + // ERC20 address of the token on the 0g-chain EVM + ZgchainERC20Address HexBytes `protobuf:"bytes,1,opt,name=zgchain_erc20_address,json=zgchainErc20Address,proto3,casttype=HexBytes" json:"zgchain_erc20_address,omitempty"` // Denom of the corresponding sdk.Coin Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` } @@ -37,7 +37,7 @@ func (m *ConversionPair) Reset() { *m = ConversionPair{} } func (m *ConversionPair) String() string { return proto.CompactTextString(m) } func (*ConversionPair) ProtoMessage() {} func (*ConversionPair) Descriptor() ([]byte, []int) { - return fileDescriptor_e1396d08199817d0, []int{0} + return fileDescriptor_6bad9d4ffa6874ec, []int{0} } func (m *ConversionPair) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -85,7 +85,7 @@ func (m *AllowedCosmosCoinERC20Token) Reset() { *m = AllowedCosmosCoinER func (m *AllowedCosmosCoinERC20Token) String() string { return proto.CompactTextString(m) } func (*AllowedCosmosCoinERC20Token) ProtoMessage() {} func (*AllowedCosmosCoinERC20Token) Descriptor() ([]byte, []int) { - return fileDescriptor_e1396d08199817d0, []int{1} + return fileDescriptor_6bad9d4ffa6874ec, []int{1} } func (m *AllowedCosmosCoinERC20Token) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -115,39 +115,39 @@ func (m *AllowedCosmosCoinERC20Token) XXX_DiscardUnknown() { var xxx_messageInfo_AllowedCosmosCoinERC20Token proto.InternalMessageInfo func init() { - proto.RegisterType((*ConversionPair)(nil), "kava.evmutil.v1beta1.ConversionPair") - proto.RegisterType((*AllowedCosmosCoinERC20Token)(nil), "kava.evmutil.v1beta1.AllowedCosmosCoinERC20Token") + proto.RegisterType((*ConversionPair)(nil), "zgc.evmutil.v1beta1.ConversionPair") + proto.RegisterType((*AllowedCosmosCoinERC20Token)(nil), "zgc.evmutil.v1beta1.AllowedCosmosCoinERC20Token") } func init() { - proto.RegisterFile("kava/evmutil/v1beta1/conversion_pair.proto", fileDescriptor_e1396d08199817d0) + proto.RegisterFile("zgc/evmutil/v1beta1/conversion_pair.proto", fileDescriptor_6bad9d4ffa6874ec) } -var fileDescriptor_e1396d08199817d0 = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x91, 0xcf, 0x4a, 0xeb, 0x40, - 0x18, 0xc5, 0x33, 0xf7, 0xf6, 0x96, 0xde, 0xb1, 0x4a, 0x19, 0x8a, 0x84, 0x0a, 0xd3, 0xd8, 0x55, - 0x15, 0x4c, 0xda, 0xba, 0x73, 0xd7, 0xc6, 0x82, 0x50, 0x10, 0x09, 0xae, 0xdc, 0x84, 0x49, 0x32, - 0xd4, 0xd0, 0x24, 0x5f, 0xc9, 0xa4, 0xb1, 0x05, 0x1f, 0xc0, 0x95, 0xf8, 0x08, 0x2e, 0x7d, 0x14, - 0x97, 0x5d, 0xba, 0x2a, 0x35, 0x7d, 0x0b, 0x57, 0x92, 0x49, 0xe8, 0xee, 0x3b, 0xe7, 0x3b, 0xe7, - 0xc7, 0xfc, 0xc1, 0xe7, 0x33, 0x96, 0x32, 0x83, 0xa7, 0xe1, 0x22, 0xf1, 0x03, 0x23, 0xed, 0x3b, - 0x3c, 0x61, 0x7d, 0xc3, 0x85, 0x28, 0xe5, 0xb1, 0xf0, 0x21, 0xb2, 0xe7, 0xcc, 0x8f, 0xf5, 0x79, - 0x0c, 0x09, 0x90, 0x66, 0x9e, 0xd5, 0xcb, 0xac, 0x5e, 0x66, 0x5b, 0xcd, 0x29, 0x4c, 0x41, 0x06, - 0x8c, 0x7c, 0x2a, 0xb2, 0x9d, 0x67, 0x7c, 0x64, 0xee, 0x21, 0x77, 0xcc, 0x8f, 0xc9, 0x2d, 0x26, - 0x79, 0xdf, 0xe6, 0xb1, 0x3b, 0xe8, 0xd9, 0xcc, 0xf3, 0x62, 0x2e, 0x84, 0x8a, 0x34, 0xd4, 0xad, - 0x8f, 0xb4, 0x6c, 0xd3, 0x6e, 0x4c, 0x58, 0xca, 0xc6, 0x96, 0x39, 0xe8, 0x0d, 0x8b, 0xdd, 0xcf, - 0xa6, 0x5d, 0xbb, 0xe1, 0xcb, 0xd1, 0x2a, 0xe1, 0xc2, 0x6a, 0xe4, 0xdd, 0x71, 0x5e, 0x2d, 0xb7, - 0xa4, 0x89, 0xff, 0x79, 0x3c, 0x82, 0x50, 0xfd, 0xa3, 0xa1, 0xee, 0x7f, 0xab, 0x10, 0x57, 0x95, - 0x97, 0xf7, 0xb6, 0xd2, 0x79, 0x45, 0xf8, 0x64, 0x18, 0x04, 0xf0, 0xc4, 0x3d, 0x13, 0x44, 0x08, - 0xc2, 0x04, 0x3f, 0x92, 0xec, 0x7b, 0x98, 0xf1, 0x88, 0x9c, 0xe2, 0xba, 0x2b, 0x7d, 0xbb, 0x40, - 0x20, 0x89, 0x38, 0x28, 0xbc, 0xeb, 0xdc, 0x22, 0x04, 0x57, 0x22, 0x16, 0xf2, 0x92, 0x2e, 0x67, - 0x72, 0x8c, 0xab, 0x62, 0x15, 0x3a, 0x10, 0xa8, 0x7f, 0xa5, 0x5b, 0x2a, 0xd2, 0xc2, 0x35, 0x8f, - 0xbb, 0x7e, 0xc8, 0x02, 0xa1, 0x56, 0x34, 0xd4, 0x3d, 0xb4, 0xf6, 0xba, 0x38, 0xd0, 0x68, 0xb2, - 0xfd, 0xa6, 0xe8, 0x23, 0xa3, 0xe8, 0x33, 0xa3, 0x68, 0x9d, 0x51, 0xb4, 0xcd, 0x28, 0x7a, 0xdb, - 0x51, 0x65, 0xbd, 0xa3, 0xca, 0xd7, 0x8e, 0x2a, 0x0f, 0x67, 0x53, 0x3f, 0x79, 0x5c, 0x38, 0xba, - 0x0b, 0xa1, 0x91, 0xdf, 0xf5, 0x22, 0x60, 0x8e, 0x90, 0x93, 0xb1, 0xdc, 0xff, 0x4f, 0xb2, 0x9a, - 0x73, 0xe1, 0x54, 0xe5, 0x13, 0x5f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x95, 0x40, 0xc5, 0x63, - 0xbc, 0x01, 0x00, 0x00, +var fileDescriptor_6bad9d4ffa6874ec = []byte{ + // 359 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x91, 0x3f, 0x4f, 0xc2, 0x40, + 0x18, 0xc6, 0x7b, 0x8a, 0x04, 0x4f, 0x74, 0x38, 0xd0, 0x34, 0x98, 0x1c, 0x88, 0x0b, 0x9a, 0xd8, + 0x16, 0xdc, 0xdc, 0xa0, 0x92, 0x38, 0x38, 0x98, 0xc6, 0xc4, 0x84, 0xa5, 0xb9, 0x5e, 0x2f, 0x47, + 0x63, 0xdb, 0x23, 0xbd, 0x82, 0xc0, 0x6e, 0xe2, 0x64, 0xfc, 0x08, 0x8e, 0x7e, 0x14, 0x47, 0x46, + 0x27, 0x82, 0xe5, 0x5b, 0x38, 0x19, 0xda, 0x86, 0xed, 0x7d, 0x9e, 0xf7, 0x97, 0x5f, 0xee, 0x0f, + 0xbc, 0x98, 0x73, 0xaa, 0xb3, 0x49, 0x30, 0x8e, 0x3d, 0x5f, 0x9f, 0xb4, 0x1d, 0x16, 0x93, 0xb6, + 0x4e, 0x45, 0x38, 0x61, 0x91, 0xf4, 0x44, 0x68, 0x8f, 0x88, 0x17, 0x69, 0xa3, 0x48, 0xc4, 0x02, + 0x55, 0xe6, 0x9c, 0x6a, 0x39, 0xaa, 0xe5, 0x68, 0xad, 0xca, 0x05, 0x17, 0xe9, 0x5e, 0xdf, 0x4c, + 0x19, 0xda, 0x7c, 0x05, 0xf0, 0xc8, 0xdc, 0x4a, 0x1e, 0x88, 0x17, 0xa1, 0x27, 0x78, 0x3c, 0xe7, + 0x74, 0x48, 0xbc, 0xd0, 0x66, 0x11, 0xed, 0x18, 0x36, 0x71, 0xdd, 0x88, 0x49, 0xa9, 0x82, 0x06, + 0x68, 0x95, 0x7b, 0xe7, 0xc9, 0xb2, 0x5e, 0x19, 0x64, 0x40, 0xdf, 0x32, 0x3b, 0x46, 0x37, 0x5b, + 0xff, 0x2d, 0xeb, 0xa5, 0x3b, 0x36, 0xed, 0xcd, 0x62, 0x26, 0xad, 0x4a, 0x6e, 0xe8, 0x6f, 0x04, + 0x39, 0x80, 0xaa, 0x70, 0xcf, 0x65, 0xa1, 0x08, 0xd4, 0x9d, 0x06, 0x68, 0xed, 0x5b, 0x59, 0xb8, + 0x29, 0xbc, 0x7d, 0xd6, 0x95, 0xe6, 0x3b, 0x80, 0xa7, 0x5d, 0xdf, 0x17, 0x2f, 0xcc, 0x35, 0x85, + 0x0c, 0x84, 0x34, 0x45, 0xae, 0x7f, 0x14, 0xcf, 0x2c, 0x44, 0x67, 0xb0, 0x4c, 0xd3, 0xde, 0xce, + 0x14, 0x20, 0x55, 0x1c, 0x64, 0xdd, 0xed, 0xa6, 0x42, 0x08, 0x16, 0x42, 0x12, 0xb0, 0xdc, 0x9e, + 0xce, 0xe8, 0x04, 0x16, 0xe5, 0x2c, 0x70, 0x84, 0xaf, 0xee, 0xa6, 0x6d, 0x9e, 0x50, 0x0d, 0x96, + 0x5c, 0x46, 0xbd, 0x80, 0xf8, 0x52, 0x2d, 0x34, 0x40, 0xeb, 0xd0, 0xda, 0xe6, 0xec, 0x40, 0xbd, + 0xfb, 0xd5, 0x2f, 0x06, 0x5f, 0x09, 0x06, 0xdf, 0x09, 0x06, 0x8b, 0x04, 0x83, 0x55, 0x82, 0xc1, + 0xc7, 0x1a, 0x2b, 0x8b, 0x35, 0x56, 0x7e, 0xd6, 0x58, 0x19, 0x5c, 0x72, 0x2f, 0x1e, 0x8e, 0x1d, + 0x8d, 0x8a, 0x40, 0x37, 0xb8, 0x4f, 0x1c, 0xa9, 0x1b, 0xfc, 0x2a, 0xbd, 0xb6, 0x3e, 0xdd, 0xfe, + 0x54, 0x3c, 0x1b, 0x31, 0xe9, 0x14, 0xd3, 0xd7, 0xbe, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x3f, + 0x0a, 0x22, 0xb3, 0xc5, 0x01, 0x00, 0x00, } func (this *ConversionPair) VerboseEqual(that interface{}) error { @@ -175,8 +175,8 @@ func (this *ConversionPair) VerboseEqual(that interface{}) error { } else if this == nil { return fmt.Errorf("that is type *ConversionPair but is not nil && this == nil") } - if !bytes.Equal(this.KavaERC20Address, that1.KavaERC20Address) { - return fmt.Errorf("KavaERC20Address this(%v) Not Equal that(%v)", this.KavaERC20Address, that1.KavaERC20Address) + if !bytes.Equal(this.ZgchainERC20Address, that1.ZgchainERC20Address) { + return fmt.Errorf("ZgchainERC20Address this(%v) Not Equal that(%v)", this.ZgchainERC20Address, that1.ZgchainERC20Address) } if this.Denom != that1.Denom { return fmt.Errorf("Denom this(%v) Not Equal that(%v)", this.Denom, that1.Denom) @@ -202,7 +202,7 @@ func (this *ConversionPair) Equal(that interface{}) bool { } else if this == nil { return false } - if !bytes.Equal(this.KavaERC20Address, that1.KavaERC20Address) { + if !bytes.Equal(this.ZgchainERC20Address, that1.ZgchainERC20Address) { return false } if this.Denom != that1.Denom { @@ -309,10 +309,10 @@ func (m *ConversionPair) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.KavaERC20Address) > 0 { - i -= len(m.KavaERC20Address) - copy(dAtA[i:], m.KavaERC20Address) - i = encodeVarintConversionPair(dAtA, i, uint64(len(m.KavaERC20Address))) + if len(m.ZgchainERC20Address) > 0 { + i -= len(m.ZgchainERC20Address) + copy(dAtA[i:], m.ZgchainERC20Address) + i = encodeVarintConversionPair(dAtA, i, uint64(len(m.ZgchainERC20Address))) i-- dAtA[i] = 0xa } @@ -385,7 +385,7 @@ func (m *ConversionPair) Size() (n int) { } var l int _ = l - l = len(m.KavaERC20Address) + l = len(m.ZgchainERC20Address) if l > 0 { n += 1 + l + sovConversionPair(uint64(l)) } @@ -457,7 +457,7 @@ func (m *ConversionPair) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KavaERC20Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ZgchainERC20Address", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -484,9 +484,9 @@ func (m *ConversionPair) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.KavaERC20Address = append(m.KavaERC20Address[:0], dAtA[iNdEx:postIndex]...) - if m.KavaERC20Address == nil { - m.KavaERC20Address = []byte{} + m.ZgchainERC20Address = append(m.ZgchainERC20Address[:0], dAtA[iNdEx:postIndex]...) + if m.ZgchainERC20Address == nil { + m.ZgchainERC20Address = []byte{} } iNdEx = postIndex case 2: diff --git a/x/evmutil/types/conversion_pairs_test.go b/x/evmutil/types/conversion_pairs_test.go index 70f0ba5c..6407dc4b 100644 --- a/x/evmutil/types/conversion_pairs_test.go +++ b/x/evmutil/types/conversion_pairs_test.go @@ -3,8 +3,8 @@ package types_test import ( "testing" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" "github.com/stretchr/testify/require" ) @@ -76,8 +76,8 @@ func TestConversionPairValidate_Direct(t *testing.T) { { "valid", types.ConversionPair{ - KavaERC20Address: testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2").Bytes(), - Denom: "weth", + ZgchainERC20Address: testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2").Bytes(), + Denom: "weth", }, errArgs{ expectPass: true, @@ -87,8 +87,8 @@ func TestConversionPairValidate_Direct(t *testing.T) { { "invalid - length", types.ConversionPair{ - KavaERC20Address: []byte{1}, - Denom: "weth", + ZgchainERC20Address: []byte{1}, + Denom: "weth", }, errArgs{ expectPass: false, @@ -119,7 +119,7 @@ func TestConversionPair_GetAddress(t *testing.T) { "weth", ) - require.Equal(t, types.HexBytes(addr.Bytes()), pair.KavaERC20Address, "struct address should match input bytes") + require.Equal(t, types.HexBytes(addr.Bytes()), pair.ZgchainERC20Address, "struct address should match input bytes") require.Equal(t, addr, pair.GetAddress(), "get internal address should match input bytes") } diff --git a/x/evmutil/types/genesis.pb.go b/x/evmutil/types/genesis.pb.go index 93aa0b97..3f3064f7 100644 --- a/x/evmutil/types/genesis.pb.go +++ b/x/evmutil/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kava/evmutil/v1beta1/genesis.proto +// source: zgc/evmutil/v1beta1/genesis.proto package types @@ -37,7 +37,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_d916ab97b8e628c2, []int{0} + return fileDescriptor_7bf39927f71414e6, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -69,7 +69,7 @@ var xxx_messageInfo_GenesisState proto.InternalMessageInfo // BalanceAccount defines an account in the evmutil module. type Account struct { Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty"` - // balance indicates the amount of akava owned by the address. + // balance indicates the amount of neuron owned by the address. Balance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=balance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"balance"` } @@ -77,7 +77,7 @@ func (m *Account) Reset() { *m = Account{} } func (m *Account) String() string { return proto.CompactTextString(m) } func (*Account) ProtoMessage() {} func (*Account) Descriptor() ([]byte, []int) { - return fileDescriptor_d916ab97b8e628c2, []int{1} + return fileDescriptor_7bf39927f71414e6, []int{1} } func (m *Account) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -109,7 +109,7 @@ var xxx_messageInfo_Account proto.InternalMessageInfo // Params defines the evmutil module params type Params struct { // enabled_conversion_pairs defines the list of conversion pairs allowed to be - // converted between Kava ERC20 and sdk.Coin + // converted between 0g-chain ERC20 and sdk.Coin EnabledConversionPairs ConversionPairs `protobuf:"bytes,4,rep,name=enabled_conversion_pairs,json=enabledConversionPairs,proto3,castrepeated=ConversionPairs" json:"enabled_conversion_pairs"` // allowed_cosmos_denoms is a list of denom & erc20 token metadata pairs. // if a denom is in the list, it is allowed to be converted to an erc20 in the evm. @@ -120,7 +120,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_d916ab97b8e628c2, []int{2} + return fileDescriptor_7bf39927f71414e6, []int{2} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -164,48 +164,46 @@ func (m *Params) GetAllowedCosmosDenoms() AllowedCosmosCoinERC20Tokens { } func init() { - proto.RegisterType((*GenesisState)(nil), "kava.evmutil.v1beta1.GenesisState") - proto.RegisterType((*Account)(nil), "kava.evmutil.v1beta1.Account") - proto.RegisterType((*Params)(nil), "kava.evmutil.v1beta1.Params") + proto.RegisterType((*GenesisState)(nil), "zgc.evmutil.v1beta1.GenesisState") + proto.RegisterType((*Account)(nil), "zgc.evmutil.v1beta1.Account") + proto.RegisterType((*Params)(nil), "zgc.evmutil.v1beta1.Params") } -func init() { - proto.RegisterFile("kava/evmutil/v1beta1/genesis.proto", fileDescriptor_d916ab97b8e628c2) -} +func init() { proto.RegisterFile("zgc/evmutil/v1beta1/genesis.proto", fileDescriptor_7bf39927f71414e6) } -var fileDescriptor_d916ab97b8e628c2 = []byte{ - // 489 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xde, 0xa9, 0x21, 0xd1, 0x69, 0x41, 0xd8, 0x56, 0x8d, 0xa5, 0xce, 0x96, 0x50, 0x24, 0x0a, - 0xbb, 0x6b, 0xe2, 0xad, 0x08, 0xd2, 0x8d, 0xa2, 0xc5, 0x4b, 0x59, 0xc5, 0x83, 0x97, 0xf0, 0x76, - 0x77, 0x88, 0x4b, 0x76, 0x67, 0xc2, 0xce, 0x24, 0xb5, 0xff, 0x40, 0xf0, 0xa0, 0xfe, 0x03, 0x8f, - 0xe2, 0xb9, 0x3f, 0xa2, 0xe0, 0xa5, 0xf4, 0x24, 0x1e, 0x62, 0x4d, 0xfe, 0x85, 0x27, 0xd9, 0x99, - 0x49, 0xa8, 0x21, 0x8a, 0xa7, 0x9d, 0x7d, 0xf3, 0x7d, 0xef, 0xfb, 0xe6, 0x7b, 0x0f, 0x37, 0xfa, - 0x30, 0x02, 0x9f, 0x8e, 0xf2, 0xa1, 0x4c, 0x33, 0x7f, 0xd4, 0x8a, 0xa8, 0x84, 0x96, 0xdf, 0xa3, - 0x8c, 0x8a, 0x54, 0x78, 0x83, 0x82, 0x4b, 0x6e, 0x6f, 0x94, 0x18, 0xcf, 0x60, 0x3c, 0x83, 0xd9, - 0xbc, 0x19, 0x73, 0x91, 0x73, 0xd1, 0x55, 0x18, 0x5f, 0xff, 0x68, 0xc2, 0xe6, 0x46, 0x8f, 0xf7, - 0xb8, 0xae, 0x97, 0x27, 0x53, 0xbd, 0xbb, 0x54, 0x2a, 0xe6, 0x6c, 0x44, 0x0b, 0x91, 0x72, 0xd6, - 0x1d, 0x40, 0x5a, 0x68, 0x6c, 0xe3, 0x23, 0xc2, 0x6b, 0x4f, 0xb4, 0x89, 0xe7, 0x12, 0x24, 0xb5, - 0x1f, 0xe2, 0xcb, 0x10, 0xc7, 0x7c, 0xc8, 0xa4, 0xa8, 0xa3, 0xed, 0x4b, 0xcd, 0xd5, 0xf6, 0x2d, - 0x6f, 0x99, 0x2d, 0x6f, 0x4f, 0xa3, 0x82, 0xca, 0xc9, 0xd8, 0xb1, 0xc2, 0x39, 0xc9, 0xde, 0xc5, - 0xd5, 0x01, 0x14, 0x90, 0x8b, 0xfa, 0xca, 0x36, 0x6a, 0xae, 0xb6, 0xb7, 0x96, 0xd3, 0x0f, 0x14, - 0xc6, 0xb0, 0x0d, 0x63, 0xb7, 0xf2, 0xf6, 0x93, 0x63, 0x35, 0xbe, 0x22, 0x5c, 0x33, 0xdd, 0xed, - 0x08, 0xd7, 0x20, 0x49, 0x0a, 0x2a, 0x4a, 0x37, 0xa8, 0xb9, 0x16, 0x3c, 0xfd, 0x35, 0x76, 0xdc, - 0x5e, 0x2a, 0x5f, 0x0f, 0x23, 0x2f, 0xe6, 0xb9, 0xc9, 0xc3, 0x7c, 0x5c, 0x91, 0xf4, 0x7d, 0x79, - 0x34, 0xa0, 0xa2, 0xb4, 0xb7, 0xa7, 0x89, 0x67, 0xc7, 0xee, 0xba, 0x49, 0xcd, 0x54, 0x82, 0x23, - 0x49, 0x45, 0x38, 0x6b, 0x6c, 0xbf, 0xc4, 0xb5, 0x08, 0x32, 0x60, 0x31, 0x55, 0x96, 0xaf, 0x04, - 0x0f, 0x4a, 0x53, 0xdf, 0xc7, 0xce, 0xed, 0xff, 0xd0, 0xd9, 0x67, 0xf2, 0xec, 0xd8, 0xc5, 0x46, - 0x60, 0x9f, 0xc9, 0x70, 0xd6, 0xcc, 0xbc, 0xe6, 0xfd, 0x0a, 0xae, 0xea, 0xc7, 0xda, 0x87, 0xb8, - 0x4e, 0x19, 0x44, 0x19, 0x4d, 0xba, 0x0b, 0xd3, 0x10, 0xf5, 0x8a, 0xca, 0x7a, 0x67, 0x79, 0x58, - 0x9d, 0x39, 0xfa, 0x00, 0xd2, 0x22, 0xb8, 0x51, 0xfa, 0xfb, 0xf2, 0xc3, 0xb9, 0xfa, 0x67, 0x5d, - 0x84, 0xd7, 0x4d, 0xfb, 0x85, 0xba, 0xfd, 0x0e, 0xe1, 0x6b, 0x90, 0x65, 0xfc, 0x50, 0x29, 0xab, - 0x6d, 0x4a, 0x28, 0xe3, 0xf9, 0x6c, 0xc4, 0xad, 0xbf, 0x8c, 0x58, 0x53, 0x3a, 0x8a, 0xd1, 0xe1, - 0x29, 0x7b, 0x1c, 0x76, 0xda, 0xf7, 0x5e, 0xf0, 0x3e, 0x65, 0xc1, 0x8e, 0xf1, 0xb0, 0xf5, 0x0f, - 0x90, 0x08, 0xd7, 0xe1, 0xe2, 0xed, 0x23, 0xa5, 0x19, 0x3c, 0x3b, 0xff, 0x49, 0xd0, 0xe7, 0x09, - 0x41, 0x27, 0x13, 0x82, 0x4e, 0x27, 0x04, 0x9d, 0x4f, 0x08, 0xfa, 0x30, 0x25, 0xd6, 0xe9, 0x94, - 0x58, 0xdf, 0xa6, 0xc4, 0x7a, 0x75, 0xe7, 0x42, 0xf0, 0xa5, 0x33, 0x37, 0x83, 0x48, 0xa8, 0x93, - 0xff, 0x66, 0xbe, 0xd8, 0x2a, 0xff, 0xa8, 0xaa, 0xf6, 0xf8, 0xfe, 0xef, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xa1, 0xec, 0x74, 0x78, 0x60, 0x03, 0x00, 0x00, +var fileDescriptor_7bf39927f71414e6 = []byte{ + // 494 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4f, 0x6b, 0xd4, 0x40, + 0x1c, 0xcd, 0xd4, 0x65, 0x57, 0xa7, 0x05, 0x21, 0xeb, 0x9f, 0xb5, 0x96, 0xa4, 0x56, 0x91, 0x55, + 0x48, 0xb2, 0x5d, 0x4f, 0x8a, 0x08, 0xcd, 0x2a, 0x5a, 0xf0, 0x50, 0xa2, 0x78, 0xf0, 0xb2, 0x4c, + 0x26, 0x43, 0x3a, 0x34, 0x99, 0x59, 0x32, 0xb3, 0xab, 0xed, 0x27, 0x10, 0x41, 0xf4, 0x23, 0x78, + 0x14, 0xcf, 0xfd, 0x10, 0x05, 0x2f, 0xa5, 0x27, 0xf1, 0xb0, 0xd6, 0xdd, 0x6f, 0xe1, 0x49, 0x32, + 0x33, 0xbb, 0xd4, 0x25, 0x88, 0xa7, 0x24, 0x2f, 0xef, 0xfd, 0xde, 0x9b, 0x37, 0x3f, 0x78, 0xe3, + 0x20, 0xc5, 0x01, 0x19, 0xe5, 0x43, 0x49, 0xb3, 0x60, 0xb4, 0x19, 0x13, 0x89, 0x36, 0x83, 0x94, + 0x30, 0x22, 0xa8, 0xf0, 0x07, 0x05, 0x97, 0xdc, 0x6e, 0x1e, 0xa4, 0xd8, 0x37, 0x14, 0xdf, 0x50, + 0x56, 0xaf, 0x61, 0x2e, 0x72, 0x2e, 0xfa, 0x8a, 0x12, 0xe8, 0x0f, 0xcd, 0x5f, 0xbd, 0x94, 0xf2, + 0x94, 0x6b, 0xbc, 0x7c, 0x33, 0xe8, 0x9d, 0x2a, 0x23, 0xcc, 0xd9, 0x88, 0x14, 0x82, 0x72, 0xd6, + 0x1f, 0x20, 0x5a, 0x68, 0xea, 0xc6, 0x47, 0x00, 0x57, 0x9e, 0xea, 0x08, 0x2f, 0x24, 0x92, 0xc4, + 0x7e, 0x04, 0xcf, 0x23, 0x8c, 0xf9, 0x90, 0x49, 0xd1, 0x02, 0xeb, 0xe7, 0xda, 0xcb, 0xdd, 0x35, + 0xbf, 0x22, 0x94, 0xbf, 0xa5, 0x49, 0x61, 0xed, 0x68, 0xec, 0x5a, 0xd1, 0x5c, 0x63, 0xdf, 0x87, + 0xf5, 0x01, 0x2a, 0x50, 0x2e, 0x5a, 0x4b, 0xeb, 0xa0, 0xbd, 0xdc, 0xbd, 0x5e, 0xa9, 0xde, 0x51, + 0x14, 0x23, 0x36, 0x82, 0x07, 0xb5, 0x77, 0x9f, 0x5d, 0x6b, 0xe3, 0x1b, 0x80, 0x0d, 0x33, 0xdc, + 0x8e, 0x61, 0x03, 0x25, 0x49, 0x41, 0x44, 0x99, 0x05, 0xb4, 0x57, 0xc2, 0x67, 0xbf, 0xc7, 0xae, + 0x97, 0x52, 0xb9, 0x3b, 0x8c, 0x7d, 0xcc, 0x73, 0x53, 0x86, 0x79, 0x78, 0x22, 0xd9, 0x0b, 0xe4, + 0xfe, 0x80, 0x88, 0x32, 0xdd, 0x96, 0x16, 0x9e, 0x1c, 0x7a, 0x4d, 0x53, 0x99, 0x41, 0xc2, 0x7d, + 0x49, 0x44, 0x34, 0x1b, 0x6c, 0xbf, 0x82, 0x8d, 0x18, 0x65, 0x88, 0x61, 0xa2, 0x12, 0x5f, 0x08, + 0x1f, 0x96, 0xa1, 0x7e, 0x8c, 0xdd, 0xdb, 0xff, 0xe1, 0xb3, 0xcd, 0xe4, 0xc9, 0xa1, 0x07, 0x8d, + 0xc1, 0x36, 0x93, 0xd1, 0x6c, 0x98, 0x39, 0xcd, 0x87, 0x25, 0x58, 0xd7, 0x87, 0xb5, 0x47, 0xb0, + 0x45, 0x18, 0x8a, 0x33, 0x92, 0xf4, 0x17, 0xee, 0x42, 0xb4, 0x6a, 0xaa, 0xe9, 0x9b, 0x95, 0x5d, + 0xf5, 0xe6, 0xe4, 0x1d, 0x44, 0x8b, 0xf0, 0x6a, 0x19, 0xef, 0xeb, 0x4f, 0xf7, 0xe2, 0xdf, 0xb8, + 0x88, 0xae, 0x98, 0xe9, 0x0b, 0xb8, 0xfd, 0x1e, 0xc0, 0xcb, 0x28, 0xcb, 0xf8, 0x1b, 0x65, 0xac, + 0x36, 0x29, 0x21, 0x8c, 0xe7, 0xb3, 0xfb, 0xed, 0x54, 0xdf, 0xaf, 0x56, 0xf4, 0x94, 0xa0, 0xc7, + 0x29, 0x7b, 0x12, 0xf5, 0xba, 0x9d, 0x97, 0x7c, 0x8f, 0xb0, 0xf0, 0x96, 0x89, 0xb0, 0xf6, 0x0f, + 0x92, 0x88, 0x9a, 0xe8, 0xec, 0xdf, 0xc7, 0xca, 0x32, 0x7c, 0x7e, 0xfa, 0xcb, 0x01, 0x5f, 0x26, + 0x0e, 0x38, 0x9a, 0x38, 0xe0, 0x78, 0xe2, 0x80, 0xd3, 0x89, 0x03, 0x3e, 0x4d, 0x1d, 0xeb, 0x78, + 0xea, 0x58, 0xdf, 0xa7, 0x8e, 0xf5, 0xfa, 0xee, 0x99, 0xda, 0x3b, 0x69, 0x86, 0x62, 0x11, 0x74, + 0x52, 0x0f, 0xef, 0x22, 0xca, 0x82, 0xb7, 0xf3, 0xad, 0x56, 0xf5, 0xc7, 0x75, 0xb5, 0xc4, 0xf7, + 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x55, 0x8b, 0x5d, 0xb5, 0x5a, 0x03, 0x00, 0x00, } func (this *GenesisState) VerboseEqual(that interface{}) error { diff --git a/x/evmutil/types/genesis_test.go b/x/evmutil/types/genesis_test.go index 5ec5cded..55037691 100644 --- a/x/evmutil/types/genesis_test.go +++ b/x/evmutil/types/genesis_test.go @@ -7,8 +7,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/types" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/evmutil/types/keys_test.go b/x/evmutil/types/keys_test.go index e102da19..9dcefbff 100644 --- a/x/evmutil/types/keys_test.go +++ b/x/evmutil/types/keys_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/x/evmutil/types" ) func TestDeployedCosmosCoinContractKey(t *testing.T) { diff --git a/x/evmutil/types/msg.go b/x/evmutil/types/msg.go index 8c9b5650..16b9ac70 100644 --- a/x/evmutil/types/msg.go +++ b/x/evmutil/types/msg.go @@ -102,10 +102,10 @@ func NewMsgConvertERC20ToCoin( amount sdkmath.Int, ) MsgConvertERC20ToCoin { return MsgConvertERC20ToCoin{ - Initiator: initiator.String(), - Receiver: receiver.String(), - KavaERC20Address: contractAddr.String(), - Amount: amount, + Initiator: initiator.String(), + Receiver: receiver.String(), + ZgchainERC20Address: contractAddr.String(), + Amount: amount, } } @@ -125,7 +125,7 @@ func (msg MsgConvertERC20ToCoin) ValidateBasic() error { ) } - if !common.IsHexAddress(msg.KavaERC20Address) { + if !common.IsHexAddress(msg.ZgchainERC20Address) { return errorsmod.Wrap( sdkerrors.ErrInvalidAddress, "erc20 contract address is not a valid hex address", diff --git a/x/evmutil/types/msg_test.go b/x/evmutil/types/msg_test.go index 1a73fdaa..2ac8376e 100644 --- a/x/evmutil/types/msg_test.go +++ b/x/evmutil/types/msg_test.go @@ -3,9 +3,9 @@ package types_test import ( "testing" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" "github.com/stretchr/testify/require" sdkmath "cosmossdk.io/math" @@ -192,10 +192,10 @@ func TestMsgConvertERC20ToCoin(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { msg := types.MsgConvertERC20ToCoin{ - Initiator: tc.initiator, - Receiver: tc.receiver, - KavaERC20Address: tc.contractAddr, - Amount: tc.amount, + Initiator: tc.initiator, + Receiver: tc.receiver, + ZgchainERC20Address: tc.contractAddr, + Amount: tc.amount, } err := msg.ValidateBasic() diff --git a/x/evmutil/types/params_test.go b/x/evmutil/types/params_test.go index 75850686..0295789d 100644 --- a/x/evmutil/types/params_test.go +++ b/x/evmutil/types/params_test.go @@ -9,9 +9,9 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/evmutil/testutil" - "github.com/kava-labs/kava/x/evmutil/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/evmutil/testutil" + "github.com/0glabs/0g-chain/x/evmutil/types" ) type ParamsTestSuite struct { diff --git a/x/evmutil/types/query.pb.go b/x/evmutil/types/query.pb.go index 9336d95d..8f743d1b 100644 --- a/x/evmutil/types/query.pb.go +++ b/x/evmutil/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kava/evmutil/v1beta1/query.proto +// source: zgc/evmutil/v1beta1/query.proto package types @@ -38,7 +38,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4a8d0512331709e7, []int{0} + return fileDescriptor_f7cba1d0f1a293ad, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -76,7 +76,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4a8d0512331709e7, []int{1} + return fileDescriptor_f7cba1d0f1a293ad, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -128,7 +128,7 @@ func (m *QueryDeployedCosmosCoinContractsRequest) Reset() { func (m *QueryDeployedCosmosCoinContractsRequest) String() string { return proto.CompactTextString(m) } func (*QueryDeployedCosmosCoinContractsRequest) ProtoMessage() {} func (*QueryDeployedCosmosCoinContractsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4a8d0512331709e7, []int{2} + return fileDescriptor_f7cba1d0f1a293ad, []int{2} } func (m *QueryDeployedCosmosCoinContractsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -171,7 +171,7 @@ func (m *QueryDeployedCosmosCoinContractsResponse) Reset() { func (m *QueryDeployedCosmosCoinContractsResponse) String() string { return proto.CompactTextString(m) } func (*QueryDeployedCosmosCoinContractsResponse) ProtoMessage() {} func (*QueryDeployedCosmosCoinContractsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4a8d0512331709e7, []int{3} + return fileDescriptor_f7cba1d0f1a293ad, []int{3} } func (m *QueryDeployedCosmosCoinContractsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -224,7 +224,7 @@ func (m *DeployedCosmosCoinContract) Reset() { *m = DeployedCosmosCoinCo func (m *DeployedCosmosCoinContract) String() string { return proto.CompactTextString(m) } func (*DeployedCosmosCoinContract) ProtoMessage() {} func (*DeployedCosmosCoinContract) Descriptor() ([]byte, []int) { - return fileDescriptor_4a8d0512331709e7, []int{4} + return fileDescriptor_f7cba1d0f1a293ad, []int{4} } func (m *DeployedCosmosCoinContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -261,51 +261,52 @@ func (m *DeployedCosmosCoinContract) GetCosmosDenom() string { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "kava.evmutil.v1beta1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "kava.evmutil.v1beta1.QueryParamsResponse") - proto.RegisterType((*QueryDeployedCosmosCoinContractsRequest)(nil), "kava.evmutil.v1beta1.QueryDeployedCosmosCoinContractsRequest") - proto.RegisterType((*QueryDeployedCosmosCoinContractsResponse)(nil), "kava.evmutil.v1beta1.QueryDeployedCosmosCoinContractsResponse") - proto.RegisterType((*DeployedCosmosCoinContract)(nil), "kava.evmutil.v1beta1.DeployedCosmosCoinContract") + proto.RegisterType((*QueryParamsRequest)(nil), "zgc.evmutil.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "zgc.evmutil.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryDeployedCosmosCoinContractsRequest)(nil), "zgc.evmutil.v1beta1.QueryDeployedCosmosCoinContractsRequest") + proto.RegisterType((*QueryDeployedCosmosCoinContractsResponse)(nil), "zgc.evmutil.v1beta1.QueryDeployedCosmosCoinContractsResponse") + proto.RegisterType((*DeployedCosmosCoinContract)(nil), "zgc.evmutil.v1beta1.DeployedCosmosCoinContract") } -func init() { proto.RegisterFile("kava/evmutil/v1beta1/query.proto", fileDescriptor_4a8d0512331709e7) } +func init() { proto.RegisterFile("zgc/evmutil/v1beta1/query.proto", fileDescriptor_f7cba1d0f1a293ad) } -var fileDescriptor_4a8d0512331709e7 = []byte{ - // 542 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0x8f, 0x0b, 0x14, 0xea, 0x8e, 0x8b, 0xa9, 0xd0, 0xd4, 0x55, 0xe9, 0x08, 0x88, 0x75, 0x48, - 0x38, 0x5b, 0x41, 0x1c, 0x26, 0x40, 0xa2, 0x1d, 0x20, 0x0e, 0x48, 0x2c, 0x07, 0x0e, 0x5c, 0x2a, - 0x27, 0xb1, 0x42, 0x44, 0x6a, 0xa7, 0xb1, 0x5b, 0x51, 0x71, 0x83, 0x0b, 0x47, 0x24, 0xbe, 0x40, - 0x3f, 0xce, 0x8e, 0x93, 0xb8, 0xa0, 0x1d, 0x26, 0xd4, 0x72, 0x40, 0x9c, 0xf8, 0x08, 0xa8, 0xb6, - 0xbb, 0x15, 0x91, 0xb6, 0x88, 0x9b, 0xf5, 0xfc, 0x7b, 0xfe, 0xfd, 0x79, 0x2f, 0x81, 0x9b, 0x6f, - 0xc8, 0x80, 0xb8, 0x74, 0xd0, 0xed, 0xcb, 0x38, 0x71, 0x07, 0xbb, 0x3e, 0x95, 0x64, 0xd7, 0xed, - 0xf5, 0x69, 0x36, 0xc4, 0x69, 0xc6, 0x25, 0x47, 0x95, 0x29, 0x02, 0x1b, 0x04, 0x36, 0x88, 0xea, - 0xad, 0x80, 0x8b, 0x2e, 0x17, 0xae, 0x4f, 0x04, 0xd5, 0xf0, 0xd3, 0xe6, 0x94, 0x44, 0x31, 0x23, - 0x32, 0xe6, 0x4c, 0xbf, 0x50, 0xad, 0x44, 0x3c, 0xe2, 0xea, 0xe8, 0x4e, 0x4f, 0xa6, 0x5a, 0x8b, - 0x38, 0x8f, 0x12, 0xea, 0x92, 0x34, 0x76, 0x09, 0x63, 0x5c, 0xaa, 0x16, 0x61, 0x6e, 0x9d, 0x5c, - 0x5d, 0x11, 0x65, 0x54, 0xc4, 0x06, 0xe3, 0x54, 0x20, 0x3a, 0x98, 0x32, 0xbf, 0x20, 0x19, 0xe9, - 0x0a, 0x8f, 0xf6, 0xfa, 0x54, 0x48, 0xe7, 0x00, 0x5e, 0xf9, 0xa3, 0x2a, 0x52, 0xce, 0x04, 0x45, - 0x7b, 0xb0, 0x98, 0xaa, 0xca, 0x3a, 0xd8, 0x04, 0x8d, 0x72, 0xb3, 0x86, 0xf3, 0x7c, 0x61, 0xdd, - 0xd5, 0x3a, 0x7f, 0x78, 0x52, 0xb7, 0x3c, 0xd3, 0xe1, 0x8c, 0x00, 0xdc, 0x52, 0x6f, 0xee, 0xd3, - 0x34, 0xe1, 0x43, 0x1a, 0xb6, 0x95, 0xf9, 0x36, 0x8f, 0x59, 0x9b, 0x33, 0x99, 0x91, 0x40, 0xce, - 0xe8, 0xd1, 0x75, 0x78, 0x59, 0x47, 0xd3, 0x09, 0x29, 0xe3, 0x8a, 0xee, 0x5c, 0xa3, 0xe4, 0xad, - 0xe9, 0xe2, 0xbe, 0xaa, 0xa1, 0x27, 0x10, 0x9e, 0xa5, 0xb4, 0x5e, 0x50, 0x82, 0x6e, 0x62, 0x0d, - 0xc1, 0xd3, 0x48, 0xb1, 0x9e, 0xc0, 0x99, 0xaa, 0x88, 0x1a, 0x02, 0x6f, 0xae, 0x73, 0xef, 0xd2, - 0xc7, 0x51, 0xdd, 0xfa, 0x31, 0xaa, 0x5b, 0xce, 0x2f, 0x00, 0x1b, 0xab, 0x25, 0x9a, 0x2c, 0xde, - 0x41, 0x3b, 0x34, 0xb0, 0x8e, 0x11, 0x1b, 0xf0, 0x98, 0x75, 0x82, 0x19, 0x52, 0x89, 0x2e, 0x37, - 0x77, 0xf2, 0x33, 0x5a, 0x4c, 0x61, 0x72, 0xdb, 0x08, 0x17, 0x8b, 0x40, 0x4f, 0x73, 0xbc, 0x6f, - 0xad, 0xf4, 0xae, 0x95, 0xcf, 0x9b, 0x77, 0x7a, 0xb0, 0xba, 0x58, 0x09, 0xba, 0x06, 0xd7, 0xe6, - 0xe7, 0xa0, 0xa6, 0x5e, 0xf2, 0xca, 0x73, 0x63, 0x40, 0x3b, 0xf0, 0x22, 0x09, 0xc3, 0x8c, 0x0a, - 0xa1, 0x64, 0x94, 0x5a, 0x57, 0x8f, 0x4f, 0xea, 0xe8, 0x19, 0x93, 0x34, 0x63, 0x24, 0x79, 0xfc, - 0xf2, 0xf9, 0x23, 0x7d, 0xeb, 0xcd, 0x60, 0xcd, 0x9f, 0x05, 0x78, 0x41, 0xa5, 0x8c, 0x3e, 0x00, - 0x58, 0xd4, 0xbb, 0x82, 0x1a, 0xf9, 0x29, 0xfd, 0xbd, 0x9a, 0xd5, 0xed, 0x7f, 0x40, 0x6a, 0xa3, - 0xce, 0x8d, 0xf7, 0x5f, 0xbe, 0x7f, 0x2e, 0xd8, 0xa8, 0xe6, 0xe6, 0x7e, 0x08, 0x7a, 0x31, 0xd1, - 0x31, 0x80, 0x1b, 0x4b, 0x06, 0x8e, 0x1e, 0x2c, 0x21, 0x5c, 0xbd, 0xcb, 0xd5, 0x87, 0xff, 0xdb, - 0x6e, 0x4c, 0xdc, 0x57, 0x26, 0xee, 0xa1, 0xbb, 0xf9, 0x26, 0x96, 0xef, 0x60, 0xab, 0x7d, 0x38, - 0xb6, 0xc1, 0xd1, 0xd8, 0x06, 0xdf, 0xc6, 0x36, 0xf8, 0x34, 0xb1, 0xad, 0xa3, 0x89, 0x6d, 0x7d, - 0x9d, 0xd8, 0xd6, 0xab, 0xed, 0x28, 0x96, 0xaf, 0xfb, 0x3e, 0x0e, 0x78, 0x57, 0xbd, 0x7c, 0x3b, - 0x21, 0xbe, 0xd0, 0x1c, 0x6f, 0x4f, 0x59, 0xe4, 0x30, 0xa5, 0xc2, 0x2f, 0xaa, 0x5f, 0xc5, 0x9d, - 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1f, 0xfa, 0x86, 0x41, 0xe8, 0x04, 0x00, 0x00, +var fileDescriptor_f7cba1d0f1a293ad = []byte{ + // 546 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4f, 0x6b, 0x13, 0x41, + 0x14, 0xdf, 0x8d, 0x1a, 0xcd, 0xa4, 0x5e, 0xa6, 0x45, 0x4a, 0x22, 0x9b, 0x76, 0x05, 0x13, 0x0a, + 0xee, 0xa4, 0xf1, 0xa2, 0x45, 0x41, 0x93, 0xa8, 0x78, 0x10, 0xea, 0x1e, 0x3c, 0x78, 0x09, 0x93, + 0xdd, 0x61, 0xba, 0x90, 0xcc, 0x6c, 0x76, 0x26, 0xc5, 0xe4, 0x28, 0x08, 0x1e, 0x05, 0xbf, 0x40, + 0x3e, 0x4e, 0x8f, 0x05, 0x2f, 0x22, 0x52, 0x24, 0xf1, 0xe0, 0x49, 0xbf, 0x82, 0x64, 0x66, 0xd2, + 0x44, 0xba, 0xdb, 0x80, 0xb7, 0xe1, 0xcd, 0xef, 0xcd, 0xef, 0xcf, 0x7b, 0xbb, 0xa0, 0x32, 0xa6, + 0x01, 0x22, 0xc7, 0xfd, 0xa1, 0x8c, 0x7a, 0xe8, 0x78, 0xbf, 0x4b, 0x24, 0xde, 0x47, 0x83, 0x21, + 0x49, 0x46, 0x5e, 0x9c, 0x70, 0xc9, 0xe1, 0xe6, 0x98, 0x06, 0x9e, 0x01, 0x78, 0x06, 0x50, 0xda, + 0x0b, 0xb8, 0xe8, 0x73, 0x81, 0xba, 0x58, 0x10, 0x8d, 0x3e, 0xef, 0x8d, 0x31, 0x8d, 0x18, 0x96, + 0x11, 0x67, 0xfa, 0x81, 0xd2, 0x16, 0xe5, 0x94, 0xab, 0x23, 0x9a, 0x9f, 0x4c, 0xf5, 0x36, 0xe5, + 0x9c, 0xf6, 0x08, 0xc2, 0x71, 0x84, 0x30, 0x63, 0x5c, 0xaa, 0x16, 0x61, 0x6e, 0x77, 0xd3, 0x54, + 0x51, 0xc2, 0x88, 0x88, 0x0c, 0xc4, 0xdd, 0x02, 0xf0, 0xf5, 0x9c, 0xf8, 0x10, 0x27, 0xb8, 0x2f, + 0x7c, 0x32, 0x18, 0x12, 0x21, 0xdd, 0x43, 0xb0, 0xf9, 0x4f, 0x55, 0xc4, 0x9c, 0x09, 0x02, 0x1f, + 0x82, 0x7c, 0xac, 0x2a, 0xdb, 0xf6, 0x8e, 0x5d, 0x2b, 0x36, 0xca, 0x5e, 0x8a, 0x2b, 0x4f, 0x37, + 0x35, 0xaf, 0x9e, 0x9c, 0x55, 0x2c, 0xdf, 0x34, 0xb8, 0x13, 0x1b, 0x54, 0xd5, 0x93, 0x6d, 0x12, + 0xf7, 0xf8, 0x88, 0x84, 0x2d, 0x65, 0xbd, 0xc5, 0x23, 0xd6, 0xe2, 0x4c, 0x26, 0x38, 0x90, 0x0b, + 0x76, 0x78, 0x07, 0xdc, 0xd4, 0xc1, 0x74, 0x42, 0xc2, 0xb8, 0x62, 0xbb, 0x52, 0x2b, 0xf8, 0x1b, + 0xba, 0xd8, 0x56, 0x35, 0xf8, 0x1c, 0x80, 0x65, 0x46, 0xdb, 0x39, 0xa5, 0xe7, 0xae, 0xa7, 0x21, + 0xde, 0x3c, 0x50, 0x4f, 0xc7, 0xbf, 0x54, 0x45, 0x89, 0x21, 0xf0, 0x57, 0x3a, 0x0f, 0x6e, 0x7c, + 0x9c, 0x54, 0xac, 0x5f, 0x93, 0x8a, 0xe5, 0xfe, 0xb1, 0x41, 0x6d, 0xbd, 0x44, 0x13, 0xc5, 0x18, + 0x38, 0xa1, 0x81, 0x75, 0x8c, 0xd8, 0x80, 0x47, 0xac, 0x13, 0x2c, 0x90, 0x4a, 0x74, 0xb1, 0x81, + 0x52, 0x23, 0xca, 0x66, 0x30, 0xb1, 0x95, 0xc3, 0x6c, 0x0d, 0xf0, 0x45, 0x8a, 0xf5, 0xea, 0x5a, + 0xeb, 0x5a, 0xf8, 0xaa, 0x77, 0x77, 0x00, 0x4a, 0xd9, 0x4a, 0xe0, 0x2e, 0xd8, 0x58, 0x1d, 0x83, + 0x9a, 0x79, 0xc1, 0x2f, 0xae, 0x4c, 0x01, 0xd6, 0xc1, 0x75, 0x1c, 0x86, 0x09, 0x11, 0x42, 0xc9, + 0x28, 0x34, 0x6f, 0x7d, 0x3b, 0xab, 0xc0, 0x97, 0x4c, 0x92, 0x84, 0xe1, 0xde, 0xb3, 0x37, 0xaf, + 0x9e, 0xea, 0x5b, 0x7f, 0x01, 0x6b, 0xfc, 0xce, 0x81, 0x6b, 0x2a, 0x64, 0xf8, 0xc1, 0x06, 0x79, + 0xbd, 0x2a, 0xb0, 0x9a, 0x1a, 0xd2, 0xc5, 0xbd, 0x2c, 0xd5, 0xd6, 0x03, 0xb5, 0x4d, 0xb7, 0xf6, + 0xfe, 0xcb, 0xcf, 0xcf, 0x39, 0x17, 0xee, 0xa0, 0x3a, 0xbd, 0x17, 0x1c, 0xe1, 0x88, 0x5d, 0xf8, + 0x10, 0xf4, 0x66, 0xc2, 0xef, 0x36, 0x28, 0x5f, 0x32, 0x71, 0xf8, 0x28, 0x9b, 0x73, 0xfd, 0x2e, + 0x97, 0x1e, 0xff, 0x67, 0xb7, 0xb1, 0xf1, 0x44, 0xd9, 0x38, 0x80, 0x0f, 0xb2, 0x6d, 0x5c, 0xbe, + 0x86, 0xcd, 0xf6, 0xc9, 0xd4, 0xb1, 0x4f, 0xa7, 0x8e, 0xfd, 0x63, 0xea, 0xd8, 0x9f, 0x66, 0x8e, + 0x75, 0x3a, 0x73, 0xac, 0xaf, 0x33, 0xc7, 0x7a, 0xbb, 0x47, 0x23, 0x79, 0x34, 0xec, 0x7a, 0x01, + 0xef, 0xa3, 0x3a, 0xed, 0xe1, 0xae, 0x58, 0x92, 0xbc, 0x3b, 0xa7, 0x91, 0xa3, 0x98, 0x88, 0x6e, + 0x5e, 0xfd, 0x2d, 0xee, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x70, 0xa1, 0x5b, 0xe8, 0x04, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -336,7 +337,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/kava.evmutil.v1beta1.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.evmutil.v1beta1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -345,7 +346,7 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . func (c *queryClient) DeployedCosmosCoinContracts(ctx context.Context, in *QueryDeployedCosmosCoinContractsRequest, opts ...grpc.CallOption) (*QueryDeployedCosmosCoinContractsResponse, error) { out := new(QueryDeployedCosmosCoinContractsResponse) - err := c.cc.Invoke(ctx, "/kava.evmutil.v1beta1.Query/DeployedCosmosCoinContracts", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.evmutil.v1beta1.Query/DeployedCosmosCoinContracts", in, out, opts...) if err != nil { return nil, err } @@ -385,7 +386,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.evmutil.v1beta1.Query/Params", + FullMethod: "/zgc.evmutil.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -403,7 +404,7 @@ func _Query_DeployedCosmosCoinContracts_Handler(srv interface{}, ctx context.Con } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.evmutil.v1beta1.Query/DeployedCosmosCoinContracts", + FullMethod: "/zgc.evmutil.v1beta1.Query/DeployedCosmosCoinContracts", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).DeployedCosmosCoinContracts(ctx, req.(*QueryDeployedCosmosCoinContractsRequest)) @@ -412,7 +413,7 @@ func _Query_DeployedCosmosCoinContracts_Handler(srv interface{}, ctx context.Con } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "kava.evmutil.v1beta1.Query", + ServiceName: "zgc.evmutil.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -425,7 +426,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "kava/evmutil/v1beta1/query.proto", + Metadata: "zgc/evmutil/v1beta1/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/evmutil/types/query.pb.gw.go b/x/evmutil/types/query.pb.gw.go index e9c9b1df..36fd0ec1 100644 --- a/x/evmutil/types/query.pb.gw.go +++ b/x/evmutil/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: kava/evmutil/v1beta1/query.proto +// source: zgc/evmutil/v1beta1/query.proto /* Package types is a reverse proxy. @@ -224,9 +224,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "evmutil", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "evmutil", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_DeployedCosmosCoinContracts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "evmutil", "v1beta1", "deployed_cosmos_coin_contracts"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_DeployedCosmosCoinContracts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "evmutil", "v1beta1", "deployed_cosmos_coin_contracts"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/evmutil/types/tx.pb.go b/x/evmutil/types/tx.pb.go index d4aa63b4..32bef31f 100644 --- a/x/evmutil/types/tx.pb.go +++ b/x/evmutil/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kava/evmutil/v1beta1/tx.proto +// source: zgc/evmutil/v1beta1/tx.proto package types @@ -31,11 +31,11 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgConvertCoinToERC20 defines a conversion from sdk.Coin to Kava ERC20 for EVM-native assets. +// MsgConvertCoinToERC20 defines a conversion from sdk.Coin to 0g-chain ERC20 for EVM-native assets. type MsgConvertCoinToERC20 struct { - // Kava bech32 address initiating the conversion. + // 0g-chain bech32 address initiating the conversion. Initiator string `protobuf:"bytes,1,opt,name=initiator,proto3" json:"initiator,omitempty"` - // EVM 0x hex address that will receive the converted Kava ERC20 tokens. + // EVM 0x hex address that will receive the converted 0g-chain ERC20 tokens. Receiver string `protobuf:"bytes,2,opt,name=receiver,proto3" json:"receiver,omitempty"` // Amount is the sdk.Coin amount to convert. Amount *types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` @@ -45,7 +45,7 @@ func (m *MsgConvertCoinToERC20) Reset() { *m = MsgConvertCoinToERC20{} } func (m *MsgConvertCoinToERC20) String() string { return proto.CompactTextString(m) } func (*MsgConvertCoinToERC20) ProtoMessage() {} func (*MsgConvertCoinToERC20) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{0} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{0} } func (m *MsgConvertCoinToERC20) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -103,7 +103,7 @@ func (m *MsgConvertCoinToERC20Response) Reset() { *m = MsgConvertCoinToE func (m *MsgConvertCoinToERC20Response) String() string { return proto.CompactTextString(m) } func (*MsgConvertCoinToERC20Response) ProtoMessage() {} func (*MsgConvertCoinToERC20Response) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{1} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{1} } func (m *MsgConvertCoinToERC20Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -132,14 +132,14 @@ func (m *MsgConvertCoinToERC20Response) XXX_DiscardUnknown() { var xxx_messageInfo_MsgConvertCoinToERC20Response proto.InternalMessageInfo -// MsgConvertERC20ToCoin defines a conversion from Kava ERC20 to sdk.Coin for EVM-native assets. +// MsgConvertERC20ToCoin defines a conversion from 0g-chain ERC20 to sdk.Coin for EVM-native assets. type MsgConvertERC20ToCoin struct { // EVM 0x hex address initiating the conversion. Initiator string `protobuf:"bytes,1,opt,name=initiator,proto3" json:"initiator,omitempty"` - // Kava bech32 address that will receive the converted sdk.Coin. + // 0g-chain bech32 address that will receive the converted sdk.Coin. Receiver string `protobuf:"bytes,2,opt,name=receiver,proto3" json:"receiver,omitempty"` // EVM 0x hex address of the ERC20 contract. - KavaERC20Address string `protobuf:"bytes,3,opt,name=kava_erc20_address,json=kavaErc20Address,proto3" json:"kava_erc20_address,omitempty"` + ZgchainERC20Address string `protobuf:"bytes,3,opt,name=zgchain_erc20_address,json=zgchainErc20Address,proto3" json:"zgchain_erc20_address,omitempty"` // ERC20 token amount to convert. Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` } @@ -148,7 +148,7 @@ func (m *MsgConvertERC20ToCoin) Reset() { *m = MsgConvertERC20ToCoin{} } func (m *MsgConvertERC20ToCoin) String() string { return proto.CompactTextString(m) } func (*MsgConvertERC20ToCoin) ProtoMessage() {} func (*MsgConvertERC20ToCoin) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{2} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{2} } func (m *MsgConvertERC20ToCoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -191,9 +191,9 @@ func (m *MsgConvertERC20ToCoin) GetReceiver() string { return "" } -func (m *MsgConvertERC20ToCoin) GetKavaERC20Address() string { +func (m *MsgConvertERC20ToCoin) GetZgchainERC20Address() string { if m != nil { - return m.KavaERC20Address + return m.ZgchainERC20Address } return "" } @@ -207,7 +207,7 @@ func (m *MsgConvertERC20ToCoinResponse) Reset() { *m = MsgConvertERC20To func (m *MsgConvertERC20ToCoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgConvertERC20ToCoinResponse) ProtoMessage() {} func (*MsgConvertERC20ToCoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{3} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{3} } func (m *MsgConvertERC20ToCoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -238,7 +238,7 @@ var xxx_messageInfo_MsgConvertERC20ToCoinResponse proto.InternalMessageInfo // MsgConvertCosmosCoinToERC20 defines a conversion from cosmos sdk.Coin to ERC20 for cosmos-native assets. type MsgConvertCosmosCoinToERC20 struct { - // Kava bech32 address initiating the conversion. + // 0g-chain bech32 address initiating the conversion. Initiator string `protobuf:"bytes,1,opt,name=initiator,proto3" json:"initiator,omitempty"` // EVM hex address that will receive the ERC20 tokens. Receiver string `protobuf:"bytes,2,opt,name=receiver,proto3" json:"receiver,omitempty"` @@ -250,7 +250,7 @@ func (m *MsgConvertCosmosCoinToERC20) Reset() { *m = MsgConvertCosmosCoi func (m *MsgConvertCosmosCoinToERC20) String() string { return proto.CompactTextString(m) } func (*MsgConvertCosmosCoinToERC20) ProtoMessage() {} func (*MsgConvertCosmosCoinToERC20) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{4} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{4} } func (m *MsgConvertCosmosCoinToERC20) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -308,7 +308,7 @@ func (m *MsgConvertCosmosCoinToERC20Response) Reset() { *m = MsgConvertC func (m *MsgConvertCosmosCoinToERC20Response) String() string { return proto.CompactTextString(m) } func (*MsgConvertCosmosCoinToERC20Response) ProtoMessage() {} func (*MsgConvertCosmosCoinToERC20Response) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{5} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{5} } func (m *MsgConvertCosmosCoinToERC20Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -341,7 +341,7 @@ var xxx_messageInfo_MsgConvertCosmosCoinToERC20Response proto.InternalMessageInf type MsgConvertCosmosCoinFromERC20 struct { // EVM hex address initiating the conversion. Initiator string `protobuf:"bytes,1,opt,name=initiator,proto3" json:"initiator,omitempty"` - // Kava bech32 address that will receive the cosmos coins. + // 0g-chain bech32 address that will receive the cosmos coins. Receiver string `protobuf:"bytes,2,opt,name=receiver,proto3" json:"receiver,omitempty"` // Amount is the amount to convert, expressed as a Cosmos coin. Amount *types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` @@ -351,7 +351,7 @@ func (m *MsgConvertCosmosCoinFromERC20) Reset() { *m = MsgConvertCosmosC func (m *MsgConvertCosmosCoinFromERC20) String() string { return proto.CompactTextString(m) } func (*MsgConvertCosmosCoinFromERC20) ProtoMessage() {} func (*MsgConvertCosmosCoinFromERC20) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{6} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{6} } func (m *MsgConvertCosmosCoinFromERC20) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -409,7 +409,7 @@ func (m *MsgConvertCosmosCoinFromERC20Response) Reset() { *m = MsgConver func (m *MsgConvertCosmosCoinFromERC20Response) String() string { return proto.CompactTextString(m) } func (*MsgConvertCosmosCoinFromERC20Response) ProtoMessage() {} func (*MsgConvertCosmosCoinFromERC20Response) Descriptor() ([]byte, []int) { - return fileDescriptor_6e82783c6c58f89c, []int{7} + return fileDescriptor_b60fa1a7a6ac0cc3, []int{7} } func (m *MsgConvertCosmosCoinFromERC20Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -439,55 +439,56 @@ func (m *MsgConvertCosmosCoinFromERC20Response) XXX_DiscardUnknown() { var xxx_messageInfo_MsgConvertCosmosCoinFromERC20Response proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgConvertCoinToERC20)(nil), "kava.evmutil.v1beta1.MsgConvertCoinToERC20") - proto.RegisterType((*MsgConvertCoinToERC20Response)(nil), "kava.evmutil.v1beta1.MsgConvertCoinToERC20Response") - proto.RegisterType((*MsgConvertERC20ToCoin)(nil), "kava.evmutil.v1beta1.MsgConvertERC20ToCoin") - proto.RegisterType((*MsgConvertERC20ToCoinResponse)(nil), "kava.evmutil.v1beta1.MsgConvertERC20ToCoinResponse") - proto.RegisterType((*MsgConvertCosmosCoinToERC20)(nil), "kava.evmutil.v1beta1.MsgConvertCosmosCoinToERC20") - proto.RegisterType((*MsgConvertCosmosCoinToERC20Response)(nil), "kava.evmutil.v1beta1.MsgConvertCosmosCoinToERC20Response") - proto.RegisterType((*MsgConvertCosmosCoinFromERC20)(nil), "kava.evmutil.v1beta1.MsgConvertCosmosCoinFromERC20") - proto.RegisterType((*MsgConvertCosmosCoinFromERC20Response)(nil), "kava.evmutil.v1beta1.MsgConvertCosmosCoinFromERC20Response") + proto.RegisterType((*MsgConvertCoinToERC20)(nil), "zgc.evmutil.v1beta1.MsgConvertCoinToERC20") + proto.RegisterType((*MsgConvertCoinToERC20Response)(nil), "zgc.evmutil.v1beta1.MsgConvertCoinToERC20Response") + proto.RegisterType((*MsgConvertERC20ToCoin)(nil), "zgc.evmutil.v1beta1.MsgConvertERC20ToCoin") + proto.RegisterType((*MsgConvertERC20ToCoinResponse)(nil), "zgc.evmutil.v1beta1.MsgConvertERC20ToCoinResponse") + proto.RegisterType((*MsgConvertCosmosCoinToERC20)(nil), "zgc.evmutil.v1beta1.MsgConvertCosmosCoinToERC20") + proto.RegisterType((*MsgConvertCosmosCoinToERC20Response)(nil), "zgc.evmutil.v1beta1.MsgConvertCosmosCoinToERC20Response") + proto.RegisterType((*MsgConvertCosmosCoinFromERC20)(nil), "zgc.evmutil.v1beta1.MsgConvertCosmosCoinFromERC20") + proto.RegisterType((*MsgConvertCosmosCoinFromERC20Response)(nil), "zgc.evmutil.v1beta1.MsgConvertCosmosCoinFromERC20Response") } -func init() { proto.RegisterFile("kava/evmutil/v1beta1/tx.proto", fileDescriptor_6e82783c6c58f89c) } +func init() { proto.RegisterFile("zgc/evmutil/v1beta1/tx.proto", fileDescriptor_b60fa1a7a6ac0cc3) } -var fileDescriptor_6e82783c6c58f89c = []byte{ - // 559 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x41, 0x6b, 0xd4, 0x4c, - 0x18, 0xde, 0x69, 0x4b, 0xf9, 0x76, 0xbe, 0x4b, 0x19, 0x56, 0x48, 0xa3, 0xcd, 0x96, 0x95, 0x6a, - 0x45, 0x36, 0xe9, 0xee, 0x8a, 0x20, 0x7a, 0x71, 0x97, 0x0a, 0xa5, 0xf4, 0x12, 0xf7, 0xe4, 0x65, - 0x99, 0x64, 0x87, 0x18, 0xda, 0x64, 0x96, 0xcc, 0x6c, 0xa8, 0x3f, 0x40, 0x10, 0x11, 0xd1, 0x3f, - 0xe0, 0xd9, 0x1f, 0xd0, 0x1f, 0xd1, 0x63, 0xe9, 0x49, 0x3c, 0x2c, 0x35, 0xfb, 0x47, 0x64, 0x92, - 0x49, 0x3a, 0xd6, 0x98, 0xb5, 0x22, 0x78, 0xda, 0xcc, 0xbc, 0xcf, 0xf3, 0xbe, 0xcf, 0xf3, 0xbe, - 0x33, 0xb3, 0x70, 0xe3, 0x10, 0xc7, 0xd8, 0x22, 0x71, 0x30, 0xe5, 0xfe, 0x91, 0x15, 0x77, 0x1c, - 0xc2, 0x71, 0xc7, 0xe2, 0xc7, 0xe6, 0x24, 0xa2, 0x9c, 0xa2, 0x86, 0x08, 0x9b, 0x32, 0x6c, 0xca, - 0xb0, 0x6e, 0xb8, 0x94, 0x05, 0x94, 0x59, 0x0e, 0x66, 0xa4, 0xe0, 0xb8, 0xd4, 0x0f, 0x33, 0x96, - 0xbe, 0x9e, 0xc5, 0x47, 0xe9, 0xca, 0xca, 0x16, 0x32, 0xd4, 0xf0, 0xa8, 0x47, 0xb3, 0x7d, 0xf1, - 0x95, 0xed, 0xb6, 0x3e, 0x01, 0x78, 0xe3, 0x80, 0x79, 0x03, 0x1a, 0xc6, 0x24, 0xe2, 0x03, 0xea, - 0x87, 0x43, 0xba, 0x6b, 0x0f, 0xba, 0x3b, 0xe8, 0x21, 0xac, 0xfb, 0xa1, 0xcf, 0x7d, 0xcc, 0x69, - 0xa4, 0x81, 0x4d, 0xb0, 0x5d, 0xef, 0x6b, 0xe7, 0x27, 0xed, 0x86, 0x4c, 0xfa, 0x74, 0x3c, 0x8e, - 0x08, 0x63, 0xcf, 0x79, 0xe4, 0x87, 0x9e, 0x7d, 0x09, 0x45, 0x3a, 0xfc, 0x2f, 0x22, 0x2e, 0xf1, - 0x63, 0x12, 0x69, 0x4b, 0x82, 0x66, 0x17, 0x6b, 0xd4, 0x81, 0xab, 0x38, 0xa0, 0xd3, 0x90, 0x6b, - 0xcb, 0x9b, 0x60, 0xfb, 0xff, 0xee, 0xba, 0x29, 0xb3, 0x09, 0x3f, 0xb9, 0x49, 0x53, 0xa8, 0xb0, - 0x25, 0xb0, 0xd5, 0x84, 0x1b, 0xa5, 0xfa, 0x6c, 0xc2, 0x26, 0x34, 0x64, 0xa4, 0xf5, 0x7a, 0x49, - 0x75, 0x90, 0xc6, 0x86, 0x54, 0x00, 0xd1, 0xad, 0x9f, 0x1c, 0xa8, 0x3a, 0x1f, 0x5c, 0xd5, 0x59, - 0x61, 0xef, 0xd2, 0x41, 0x1f, 0x22, 0x31, 0x98, 0x11, 0x89, 0xdc, 0xee, 0xce, 0x08, 0x67, 0xa8, - 0xd4, 0x4d, 0xbd, 0xdf, 0x48, 0x66, 0xcd, 0xb5, 0x7d, 0x1c, 0xe3, 0x54, 0x84, 0xcc, 0x60, 0xaf, - 0x09, 0xfc, 0xae, 0x80, 0xcb, 0x1d, 0x34, 0x2c, 0xba, 0xb0, 0x92, 0xf2, 0x9e, 0x9c, 0xce, 0x9a, - 0xb5, 0xaf, 0xb3, 0xe6, 0x1d, 0xcf, 0xe7, 0x2f, 0xa7, 0x8e, 0xe9, 0xd2, 0x40, 0x8e, 0x4e, 0xfe, - 0xb4, 0xd9, 0xf8, 0xd0, 0xe2, 0xaf, 0x26, 0x84, 0x99, 0x7b, 0x21, 0x3f, 0x3f, 0x69, 0x43, 0xa9, - 0x72, 0x2f, 0xe4, 0xe5, 0x8d, 0x52, 0xda, 0x50, 0x34, 0xea, 0x2d, 0x80, 0x37, 0xd5, 0x56, 0x8a, - 0x0c, 0xea, 0xc0, 0xab, 0xdb, 0xf5, 0x97, 0xc7, 0xba, 0x05, 0x6f, 0x57, 0x68, 0x29, 0x34, 0xbf, - 0x03, 0x3f, 0x8e, 0x3f, 0xc7, 0x3d, 0x8b, 0x68, 0xf0, 0x0f, 0x54, 0xdf, 0x85, 0x5b, 0x95, 0x6a, - 0x72, 0xdd, 0xdd, 0x8f, 0x2b, 0x70, 0xf9, 0x80, 0x79, 0x28, 0x86, 0xa8, 0xe4, 0x6a, 0xdd, 0x37, - 0xcb, 0x2e, 0xb7, 0x59, 0x7a, 0xce, 0xf5, 0xde, 0x35, 0xc0, 0x79, 0x7d, 0xa5, 0xae, 0x7a, 0x21, - 0x16, 0xd6, 0x55, 0xc0, 0x8b, 0xeb, 0x96, 0x9c, 0x31, 0xf4, 0x06, 0x40, 0xed, 0x97, 0x07, 0xac, - 0xb3, 0xd8, 0xc9, 0x15, 0x8a, 0xfe, 0xe8, 0xda, 0x94, 0x42, 0xca, 0x7b, 0x00, 0xf5, 0x8a, 0x73, - 0xd3, 0xfb, 0xfd, 0xcc, 0x05, 0x49, 0x7f, 0xfc, 0x07, 0xa4, 0x5c, 0x50, 0x7f, 0xff, 0xe2, 0x9b, - 0x01, 0x3e, 0x27, 0x06, 0x38, 0x4d, 0x0c, 0x70, 0x96, 0x18, 0xe0, 0x22, 0x31, 0xc0, 0x87, 0xb9, - 0x51, 0x3b, 0x9b, 0x1b, 0xb5, 0x2f, 0x73, 0xa3, 0xf6, 0xe2, 0x9e, 0xf2, 0x00, 0x88, 0x42, 0xed, - 0x23, 0xec, 0xb0, 0xf4, 0xcb, 0x3a, 0x2e, 0xfe, 0x29, 0xd2, 0x77, 0xc0, 0x59, 0x4d, 0x9f, 0xef, - 0xde, 0xf7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa2, 0x5a, 0x1f, 0x90, 0x46, 0x06, 0x00, 0x00, +var fileDescriptor_b60fa1a7a6ac0cc3 = []byte{ + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xae, 0xb7, 0x69, 0xa2, 0xe6, 0x96, 0x6e, 0xa2, 0x0b, 0x23, 0x9d, 0x8a, 0x06, 0xd3, 0xa4, + 0x26, 0x69, 0x40, 0x08, 0x21, 0x2e, 0xb4, 0x1a, 0xd2, 0x04, 0xbb, 0x84, 0x9e, 0x76, 0xa9, 0x92, + 0xd4, 0xf2, 0x2c, 0x16, 0xbb, 0x8a, 0xdd, 0x6a, 0xf4, 0x01, 0x90, 0x40, 0x13, 0xe2, 0x09, 0x38, + 0xf3, 0x00, 0x7b, 0x88, 0x1d, 0xa7, 0x9d, 0x10, 0x87, 0x6a, 0xa4, 0x2f, 0x82, 0x92, 0x38, 0x59, + 0x18, 0x21, 0xdd, 0x24, 0xa4, 0x9d, 0x5a, 0xfb, 0xff, 0xbe, 0xdf, 0xdf, 0xf7, 0xfb, 0xff, 0x1d, + 0xb8, 0x3e, 0xc1, 0x9e, 0x81, 0xc6, 0xfe, 0x48, 0x90, 0x43, 0x63, 0xdc, 0x76, 0x91, 0x70, 0xda, + 0x86, 0x38, 0xd2, 0x87, 0x01, 0x13, 0x4c, 0xa9, 0x4d, 0xb0, 0xa7, 0xcb, 0xa8, 0x2e, 0xa3, 0xaa, + 0xe6, 0x31, 0xee, 0x33, 0x6e, 0xb8, 0x0e, 0x47, 0x19, 0xc5, 0x63, 0x84, 0x26, 0x24, 0x75, 0x2d, + 0x89, 0xf7, 0xe3, 0x95, 0x91, 0x2c, 0x64, 0x68, 0x05, 0x33, 0xcc, 0x92, 0xfd, 0xe8, 0x5f, 0xb2, + 0xdb, 0xfc, 0x06, 0xe0, 0xea, 0x1e, 0xc7, 0x5d, 0x46, 0xc7, 0x28, 0x10, 0x5d, 0x46, 0x68, 0x8f, + 0xed, 0xd8, 0x5d, 0xcb, 0x54, 0x9e, 0xc1, 0x2a, 0xa1, 0x44, 0x10, 0x47, 0xb0, 0xa0, 0x0e, 0x36, + 0xc0, 0x56, 0xb5, 0x53, 0x3f, 0x3f, 0x69, 0xad, 0xc8, 0xa4, 0xaf, 0x06, 0x83, 0x00, 0x71, 0xfe, + 0x4e, 0x04, 0x84, 0x62, 0xfb, 0x12, 0xaa, 0xa8, 0xf0, 0x4e, 0x80, 0x3c, 0x44, 0xc6, 0x28, 0xa8, + 0x2f, 0x44, 0x34, 0x3b, 0x5b, 0x2b, 0x6d, 0xb8, 0xec, 0xf8, 0x6c, 0x44, 0x45, 0x7d, 0x71, 0x03, + 0x6c, 0xdd, 0xb5, 0xd6, 0x74, 0x99, 0x2d, 0xf2, 0x93, 0x9a, 0xd4, 0x23, 0x15, 0xb6, 0x04, 0x36, + 0x1b, 0xf0, 0x41, 0xa1, 0x3e, 0x1b, 0xf1, 0x21, 0xa3, 0x1c, 0x35, 0xbf, 0x2c, 0xe4, 0x1d, 0xc4, + 0xb1, 0x1e, 0x8b, 0x80, 0xca, 0xfa, 0x5f, 0x0e, 0xf2, 0x3a, 0x9f, 0x5e, 0xd5, 0x59, 0x62, 0xef, + 0xd2, 0xc1, 0x1b, 0xb8, 0x3a, 0xc1, 0xde, 0x81, 0x43, 0x68, 0x1f, 0x05, 0x9e, 0x65, 0xf6, 0x9d, + 0x04, 0x18, 0x1b, 0xaa, 0x76, 0xee, 0x85, 0xd3, 0x46, 0x6d, 0x3f, 0x01, 0xc4, 0x52, 0x64, 0x1e, + 0xbb, 0x26, 0x59, 0x3b, 0x11, 0x49, 0x6e, 0x2a, 0xbd, 0xac, 0x1c, 0x4b, 0x31, 0xfb, 0xe5, 0xe9, + 0xb4, 0x51, 0xf9, 0x39, 0x6d, 0x3c, 0xc2, 0x44, 0x1c, 0x8c, 0x5c, 0xdd, 0x63, 0xbe, 0xbc, 0x43, + 0xf9, 0xd3, 0xe2, 0x83, 0xf7, 0x86, 0xf8, 0x30, 0x44, 0x5c, 0xdf, 0xa5, 0xe2, 0xfc, 0xa4, 0x05, + 0xa5, 0xdc, 0x5d, 0x2a, 0x8a, 0x2b, 0x96, 0xab, 0x47, 0x56, 0xb1, 0xcf, 0x00, 0xde, 0xcf, 0xd7, + 0x34, 0xca, 0x90, 0xbf, 0xf9, 0xf2, 0xba, 0xfd, 0xe7, 0xfb, 0xdd, 0x84, 0x0f, 0x4b, 0xb4, 0x64, + 0x9a, 0x8f, 0xc1, 0x9f, 0x7d, 0x90, 0xe2, 0x5e, 0x07, 0xcc, 0xbf, 0x05, 0xd5, 0x8f, 0xe1, 0x66, + 0xa9, 0x9a, 0x54, 0xb7, 0xf5, 0x69, 0x09, 0x2e, 0xee, 0x71, 0xac, 0x08, 0xa8, 0x14, 0xcc, 0xd8, + 0xb6, 0x5e, 0x30, 0xe4, 0x7a, 0x61, 0xbf, 0xab, 0xd6, 0xf5, 0xb1, 0xe9, 0xe9, 0xb9, 0x53, 0xf3, + 0x73, 0x31, 0xef, 0xd4, 0x1c, 0x76, 0xee, 0xa9, 0x05, 0xfd, 0xa5, 0x7c, 0x04, 0xb0, 0xfe, 0xcf, + 0xe6, 0x32, 0xe7, 0xda, 0xb8, 0xc2, 0x50, 0x9f, 0xdf, 0x94, 0x91, 0x09, 0x39, 0x06, 0x50, 0x2d, + 0xe9, 0x18, 0xeb, 0xda, 0x89, 0x33, 0x8e, 0xfa, 0xe2, 0xe6, 0x9c, 0x54, 0x4e, 0xe7, 0xed, 0xc5, + 0x2f, 0x0d, 0x7c, 0x0f, 0x35, 0x70, 0x1a, 0x6a, 0xe0, 0x2c, 0xd4, 0xc0, 0x45, 0xa8, 0x81, 0xaf, + 0x33, 0xad, 0x72, 0x36, 0xd3, 0x2a, 0x3f, 0x66, 0x5a, 0x65, 0x7f, 0x3b, 0x37, 0xf8, 0x26, 0x3e, + 0x74, 0x5c, 0x6e, 0x98, 0xb8, 0x15, 0x3f, 0x1c, 0xc6, 0x51, 0xf6, 0xa9, 0x88, 0x1f, 0x00, 0x77, + 0x39, 0x7e, 0xc0, 0x9f, 0xfc, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x01, 0xd4, 0x2a, 0x46, 0x06, + 0x00, 0x00, } func (this *MsgConvertCoinToERC20) VerboseEqual(that interface{}) error { @@ -635,8 +636,8 @@ func (this *MsgConvertERC20ToCoin) VerboseEqual(that interface{}) error { if this.Receiver != that1.Receiver { return fmt.Errorf("Receiver this(%v) Not Equal that(%v)", this.Receiver, that1.Receiver) } - if this.KavaERC20Address != that1.KavaERC20Address { - return fmt.Errorf("KavaERC20Address this(%v) Not Equal that(%v)", this.KavaERC20Address, that1.KavaERC20Address) + if this.ZgchainERC20Address != that1.ZgchainERC20Address { + return fmt.Errorf("ZgchainERC20Address this(%v) Not Equal that(%v)", this.ZgchainERC20Address, that1.ZgchainERC20Address) } if !this.Amount.Equal(that1.Amount) { return fmt.Errorf("Amount this(%v) Not Equal that(%v)", this.Amount, that1.Amount) @@ -668,7 +669,7 @@ func (this *MsgConvertERC20ToCoin) Equal(that interface{}) bool { if this.Receiver != that1.Receiver { return false } - if this.KavaERC20Address != that1.KavaERC20Address { + if this.ZgchainERC20Address != that1.ZgchainERC20Address { return false } if !this.Amount.Equal(that1.Amount) { @@ -965,9 +966,9 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // ConvertCoinToERC20 defines a method for converting sdk.Coin to Kava ERC20. + // ConvertCoinToERC20 defines a method for converting sdk.Coin to 0g-chain ERC20. ConvertCoinToERC20(ctx context.Context, in *MsgConvertCoinToERC20, opts ...grpc.CallOption) (*MsgConvertCoinToERC20Response, error) - // ConvertERC20ToCoin defines a method for converting Kava ERC20 to sdk.Coin. + // ConvertERC20ToCoin defines a method for converting 0g-chain ERC20 to sdk.Coin. ConvertERC20ToCoin(ctx context.Context, in *MsgConvertERC20ToCoin, opts ...grpc.CallOption) (*MsgConvertERC20ToCoinResponse, error) // ConvertCosmosCoinToERC20 defines a method for converting a cosmos sdk.Coin to an ERC20. ConvertCosmosCoinToERC20(ctx context.Context, in *MsgConvertCosmosCoinToERC20, opts ...grpc.CallOption) (*MsgConvertCosmosCoinToERC20Response, error) @@ -985,7 +986,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) ConvertCoinToERC20(ctx context.Context, in *MsgConvertCoinToERC20, opts ...grpc.CallOption) (*MsgConvertCoinToERC20Response, error) { out := new(MsgConvertCoinToERC20Response) - err := c.cc.Invoke(ctx, "/kava.evmutil.v1beta1.Msg/ConvertCoinToERC20", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.evmutil.v1beta1.Msg/ConvertCoinToERC20", in, out, opts...) if err != nil { return nil, err } @@ -994,7 +995,7 @@ func (c *msgClient) ConvertCoinToERC20(ctx context.Context, in *MsgConvertCoinTo func (c *msgClient) ConvertERC20ToCoin(ctx context.Context, in *MsgConvertERC20ToCoin, opts ...grpc.CallOption) (*MsgConvertERC20ToCoinResponse, error) { out := new(MsgConvertERC20ToCoinResponse) - err := c.cc.Invoke(ctx, "/kava.evmutil.v1beta1.Msg/ConvertERC20ToCoin", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.evmutil.v1beta1.Msg/ConvertERC20ToCoin", in, out, opts...) if err != nil { return nil, err } @@ -1003,7 +1004,7 @@ func (c *msgClient) ConvertERC20ToCoin(ctx context.Context, in *MsgConvertERC20T func (c *msgClient) ConvertCosmosCoinToERC20(ctx context.Context, in *MsgConvertCosmosCoinToERC20, opts ...grpc.CallOption) (*MsgConvertCosmosCoinToERC20Response, error) { out := new(MsgConvertCosmosCoinToERC20Response) - err := c.cc.Invoke(ctx, "/kava.evmutil.v1beta1.Msg/ConvertCosmosCoinToERC20", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.evmutil.v1beta1.Msg/ConvertCosmosCoinToERC20", in, out, opts...) if err != nil { return nil, err } @@ -1012,7 +1013,7 @@ func (c *msgClient) ConvertCosmosCoinToERC20(ctx context.Context, in *MsgConvert func (c *msgClient) ConvertCosmosCoinFromERC20(ctx context.Context, in *MsgConvertCosmosCoinFromERC20, opts ...grpc.CallOption) (*MsgConvertCosmosCoinFromERC20Response, error) { out := new(MsgConvertCosmosCoinFromERC20Response) - err := c.cc.Invoke(ctx, "/kava.evmutil.v1beta1.Msg/ConvertCosmosCoinFromERC20", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.evmutil.v1beta1.Msg/ConvertCosmosCoinFromERC20", in, out, opts...) if err != nil { return nil, err } @@ -1021,9 +1022,9 @@ func (c *msgClient) ConvertCosmosCoinFromERC20(ctx context.Context, in *MsgConve // MsgServer is the server API for Msg service. type MsgServer interface { - // ConvertCoinToERC20 defines a method for converting sdk.Coin to Kava ERC20. + // ConvertCoinToERC20 defines a method for converting sdk.Coin to 0g-chain ERC20. ConvertCoinToERC20(context.Context, *MsgConvertCoinToERC20) (*MsgConvertCoinToERC20Response, error) - // ConvertERC20ToCoin defines a method for converting Kava ERC20 to sdk.Coin. + // ConvertERC20ToCoin defines a method for converting 0g-chain ERC20 to sdk.Coin. ConvertERC20ToCoin(context.Context, *MsgConvertERC20ToCoin) (*MsgConvertERC20ToCoinResponse, error) // ConvertCosmosCoinToERC20 defines a method for converting a cosmos sdk.Coin to an ERC20. ConvertCosmosCoinToERC20(context.Context, *MsgConvertCosmosCoinToERC20) (*MsgConvertCosmosCoinToERC20Response, error) @@ -1062,7 +1063,7 @@ func _Msg_ConvertCoinToERC20_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.evmutil.v1beta1.Msg/ConvertCoinToERC20", + FullMethod: "/zgc.evmutil.v1beta1.Msg/ConvertCoinToERC20", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).ConvertCoinToERC20(ctx, req.(*MsgConvertCoinToERC20)) @@ -1080,7 +1081,7 @@ func _Msg_ConvertERC20ToCoin_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.evmutil.v1beta1.Msg/ConvertERC20ToCoin", + FullMethod: "/zgc.evmutil.v1beta1.Msg/ConvertERC20ToCoin", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).ConvertERC20ToCoin(ctx, req.(*MsgConvertERC20ToCoin)) @@ -1098,7 +1099,7 @@ func _Msg_ConvertCosmosCoinToERC20_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.evmutil.v1beta1.Msg/ConvertCosmosCoinToERC20", + FullMethod: "/zgc.evmutil.v1beta1.Msg/ConvertCosmosCoinToERC20", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).ConvertCosmosCoinToERC20(ctx, req.(*MsgConvertCosmosCoinToERC20)) @@ -1116,7 +1117,7 @@ func _Msg_ConvertCosmosCoinFromERC20_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.evmutil.v1beta1.Msg/ConvertCosmosCoinFromERC20", + FullMethod: "/zgc.evmutil.v1beta1.Msg/ConvertCosmosCoinFromERC20", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).ConvertCosmosCoinFromERC20(ctx, req.(*MsgConvertCosmosCoinFromERC20)) @@ -1125,7 +1126,7 @@ func _Msg_ConvertCosmosCoinFromERC20_Handler(srv interface{}, ctx context.Contex } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "kava.evmutil.v1beta1.Msg", + ServiceName: "zgc.evmutil.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -1146,7 +1147,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "kava/evmutil/v1beta1/tx.proto", + Metadata: "zgc/evmutil/v1beta1/tx.proto", } func (m *MsgConvertCoinToERC20) Marshal() (dAtA []byte, err error) { @@ -1251,10 +1252,10 @@ func (m *MsgConvertERC20ToCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x22 - if len(m.KavaERC20Address) > 0 { - i -= len(m.KavaERC20Address) - copy(dAtA[i:], m.KavaERC20Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.KavaERC20Address))) + if len(m.ZgchainERC20Address) > 0 { + i -= len(m.ZgchainERC20Address) + copy(dAtA[i:], m.ZgchainERC20Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.ZgchainERC20Address))) i-- dAtA[i] = 0x1a } @@ -1497,7 +1498,7 @@ func (m *MsgConvertERC20ToCoin) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.KavaERC20Address) + l = len(m.ZgchainERC20Address) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1876,7 +1877,7 @@ func (m *MsgConvertERC20ToCoin) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KavaERC20Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ZgchainERC20Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1904,7 +1905,7 @@ func (m *MsgConvertERC20ToCoin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.KavaERC20Address = string(dAtA[iNdEx:postIndex]) + m.ZgchainERC20Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { diff --git a/x/validator-vesting/client/cli/query.go b/x/validator-vesting/client/cli/query.go index 748d21b2..f9fac926 100644 --- a/x/validator-vesting/client/cli/query.go +++ b/x/validator-vesting/client/cli/query.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/kava-labs/kava/x/validator-vesting/types" + "github.com/0glabs/0g-chain/x/validator-vesting/types" ) // GetQueryCmd returns the cli query commands for the kavadist module diff --git a/x/validator-vesting/client/rest/query.go b/x/validator-vesting/client/rest/query.go index 005546ec..af098eca 100644 --- a/x/validator-vesting/client/rest/query.go +++ b/x/validator-vesting/client/rest/query.go @@ -8,10 +8,10 @@ import ( "github.com/gorilla/mux" + "github.com/0glabs/0g-chain/client/rest" "github.com/cosmos/cosmos-sdk/client" - "github.com/kava-labs/kava/client/rest" - "github.com/kava-labs/kava/x/validator-vesting/types" + "github.com/0glabs/0g-chain/x/validator-vesting/types" ) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/validator-vesting/keeper/grpc_query.go b/x/validator-vesting/keeper/grpc_query.go index c633638f..1c887b40 100644 --- a/x/validator-vesting/keeper/grpc_query.go +++ b/x/validator-vesting/keeper/grpc_query.go @@ -5,8 +5,8 @@ import ( "time" sdkmath "cosmossdk.io/math" + "github.com/0glabs/0g-chain/x/validator-vesting/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/kava-labs/kava/x/validator-vesting/types" ) type queryServer struct { diff --git a/x/validator-vesting/keeper/grpc_query_test.go b/x/validator-vesting/keeper/grpc_query_test.go index b6c22c0e..16b28e15 100644 --- a/x/validator-vesting/keeper/grpc_query_test.go +++ b/x/validator-vesting/keeper/grpc_query_test.go @@ -11,9 +11,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/validator-vesting/keeper" - "github.com/kava-labs/kava/x/validator-vesting/types" + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/x/validator-vesting/keeper" + "github.com/0glabs/0g-chain/x/validator-vesting/types" ) type grpcQueryTestSuite struct { diff --git a/x/validator-vesting/module.go b/x/validator-vesting/module.go index 39fa0c61..2bf8f6b2 100644 --- a/x/validator-vesting/module.go +++ b/x/validator-vesting/module.go @@ -15,9 +15,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/kava-labs/kava/x/validator-vesting/client/cli" - "github.com/kava-labs/kava/x/validator-vesting/keeper" - "github.com/kava-labs/kava/x/validator-vesting/types" + "github.com/0glabs/0g-chain/x/validator-vesting/client/cli" + "github.com/0glabs/0g-chain/x/validator-vesting/keeper" + "github.com/0glabs/0g-chain/x/validator-vesting/types" ) var ( diff --git a/x/validator-vesting/types/query.pb.go b/x/validator-vesting/types/query.pb.go index b8a8442d..9bd4278c 100644 --- a/x/validator-vesting/types/query.pb.go +++ b/x/validator-vesting/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kava/validatorvesting/v1beta1/query.proto +// source: zgc/validatorvesting/v1beta1/query.proto package types @@ -39,7 +39,7 @@ func (m *QueryCirculatingSupplyRequest) Reset() { *m = QueryCirculatingS func (m *QueryCirculatingSupplyRequest) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplyRequest) ProtoMessage() {} func (*QueryCirculatingSupplyRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{0} + return fileDescriptor_4eb4aa17850547e7, []int{0} } func (m *QueryCirculatingSupplyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -77,7 +77,7 @@ func (m *QueryCirculatingSupplyResponse) Reset() { *m = QueryCirculating func (m *QueryCirculatingSupplyResponse) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplyResponse) ProtoMessage() {} func (*QueryCirculatingSupplyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{1} + return fileDescriptor_4eb4aa17850547e7, []int{1} } func (m *QueryCirculatingSupplyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -114,7 +114,7 @@ func (m *QueryTotalSupplyRequest) Reset() { *m = QueryTotalSupplyRequest func (m *QueryTotalSupplyRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyRequest) ProtoMessage() {} func (*QueryTotalSupplyRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{2} + return fileDescriptor_4eb4aa17850547e7, []int{2} } func (m *QueryTotalSupplyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -152,7 +152,7 @@ func (m *QueryTotalSupplyResponse) Reset() { *m = QueryTotalSupplyRespon func (m *QueryTotalSupplyResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyResponse) ProtoMessage() {} func (*QueryTotalSupplyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{3} + return fileDescriptor_4eb4aa17850547e7, []int{3} } func (m *QueryTotalSupplyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -189,7 +189,7 @@ func (m *QueryCirculatingSupplyHARDRequest) Reset() { *m = QueryCirculat func (m *QueryCirculatingSupplyHARDRequest) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplyHARDRequest) ProtoMessage() {} func (*QueryCirculatingSupplyHARDRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{4} + return fileDescriptor_4eb4aa17850547e7, []int{4} } func (m *QueryCirculatingSupplyHARDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -227,7 +227,7 @@ func (m *QueryCirculatingSupplyHARDResponse) Reset() { *m = QueryCircula func (m *QueryCirculatingSupplyHARDResponse) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplyHARDResponse) ProtoMessage() {} func (*QueryCirculatingSupplyHARDResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{5} + return fileDescriptor_4eb4aa17850547e7, []int{5} } func (m *QueryCirculatingSupplyHARDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -264,7 +264,7 @@ func (m *QueryCirculatingSupplyUSDXRequest) Reset() { *m = QueryCirculat func (m *QueryCirculatingSupplyUSDXRequest) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplyUSDXRequest) ProtoMessage() {} func (*QueryCirculatingSupplyUSDXRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{6} + return fileDescriptor_4eb4aa17850547e7, []int{6} } func (m *QueryCirculatingSupplyUSDXRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -302,7 +302,7 @@ func (m *QueryCirculatingSupplyUSDXResponse) Reset() { *m = QueryCircula func (m *QueryCirculatingSupplyUSDXResponse) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplyUSDXResponse) ProtoMessage() {} func (*QueryCirculatingSupplyUSDXResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{7} + return fileDescriptor_4eb4aa17850547e7, []int{7} } func (m *QueryCirculatingSupplyUSDXResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -339,7 +339,7 @@ func (m *QueryCirculatingSupplySWPRequest) Reset() { *m = QueryCirculati func (m *QueryCirculatingSupplySWPRequest) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplySWPRequest) ProtoMessage() {} func (*QueryCirculatingSupplySWPRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{8} + return fileDescriptor_4eb4aa17850547e7, []int{8} } func (m *QueryCirculatingSupplySWPRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -377,7 +377,7 @@ func (m *QueryCirculatingSupplySWPResponse) Reset() { *m = QueryCirculat func (m *QueryCirculatingSupplySWPResponse) String() string { return proto.CompactTextString(m) } func (*QueryCirculatingSupplySWPResponse) ProtoMessage() {} func (*QueryCirculatingSupplySWPResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{9} + return fileDescriptor_4eb4aa17850547e7, []int{9} } func (m *QueryCirculatingSupplySWPResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -414,7 +414,7 @@ func (m *QueryTotalSupplyHARDRequest) Reset() { *m = QueryTotalSupplyHAR func (m *QueryTotalSupplyHARDRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyHARDRequest) ProtoMessage() {} func (*QueryTotalSupplyHARDRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{10} + return fileDescriptor_4eb4aa17850547e7, []int{10} } func (m *QueryTotalSupplyHARDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -452,7 +452,7 @@ func (m *QueryTotalSupplyHARDResponse) Reset() { *m = QueryTotalSupplyHA func (m *QueryTotalSupplyHARDResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyHARDResponse) ProtoMessage() {} func (*QueryTotalSupplyHARDResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{11} + return fileDescriptor_4eb4aa17850547e7, []int{11} } func (m *QueryTotalSupplyHARDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -489,7 +489,7 @@ func (m *QueryTotalSupplyUSDXRequest) Reset() { *m = QueryTotalSupplyUSD func (m *QueryTotalSupplyUSDXRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyUSDXRequest) ProtoMessage() {} func (*QueryTotalSupplyUSDXRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{12} + return fileDescriptor_4eb4aa17850547e7, []int{12} } func (m *QueryTotalSupplyUSDXRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -527,7 +527,7 @@ func (m *QueryTotalSupplyUSDXResponse) Reset() { *m = QueryTotalSupplyUS func (m *QueryTotalSupplyUSDXResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyUSDXResponse) ProtoMessage() {} func (*QueryTotalSupplyUSDXResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2198ebff70588a65, []int{13} + return fileDescriptor_4eb4aa17850547e7, []int{13} } func (m *QueryTotalSupplyUSDXResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -557,67 +557,67 @@ func (m *QueryTotalSupplyUSDXResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTotalSupplyUSDXResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*QueryCirculatingSupplyRequest)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplyRequest") - proto.RegisterType((*QueryCirculatingSupplyResponse)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplyResponse") - proto.RegisterType((*QueryTotalSupplyRequest)(nil), "kava.validatorvesting.v1beta1.QueryTotalSupplyRequest") - proto.RegisterType((*QueryTotalSupplyResponse)(nil), "kava.validatorvesting.v1beta1.QueryTotalSupplyResponse") - proto.RegisterType((*QueryCirculatingSupplyHARDRequest)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDRequest") - proto.RegisterType((*QueryCirculatingSupplyHARDResponse)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDResponse") - proto.RegisterType((*QueryCirculatingSupplyUSDXRequest)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXRequest") - proto.RegisterType((*QueryCirculatingSupplyUSDXResponse)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXResponse") - proto.RegisterType((*QueryCirculatingSupplySWPRequest)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPRequest") - proto.RegisterType((*QueryCirculatingSupplySWPResponse)(nil), "kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPResponse") - proto.RegisterType((*QueryTotalSupplyHARDRequest)(nil), "kava.validatorvesting.v1beta1.QueryTotalSupplyHARDRequest") - proto.RegisterType((*QueryTotalSupplyHARDResponse)(nil), "kava.validatorvesting.v1beta1.QueryTotalSupplyHARDResponse") - proto.RegisterType((*QueryTotalSupplyUSDXRequest)(nil), "kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXRequest") - proto.RegisterType((*QueryTotalSupplyUSDXResponse)(nil), "kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXResponse") + proto.RegisterType((*QueryCirculatingSupplyRequest)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplyRequest") + proto.RegisterType((*QueryCirculatingSupplyResponse)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplyResponse") + proto.RegisterType((*QueryTotalSupplyRequest)(nil), "zgc.validatorvesting.v1beta1.QueryTotalSupplyRequest") + proto.RegisterType((*QueryTotalSupplyResponse)(nil), "zgc.validatorvesting.v1beta1.QueryTotalSupplyResponse") + proto.RegisterType((*QueryCirculatingSupplyHARDRequest)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplyHARDRequest") + proto.RegisterType((*QueryCirculatingSupplyHARDResponse)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplyHARDResponse") + proto.RegisterType((*QueryCirculatingSupplyUSDXRequest)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXRequest") + proto.RegisterType((*QueryCirculatingSupplyUSDXResponse)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXResponse") + proto.RegisterType((*QueryCirculatingSupplySWPRequest)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplySWPRequest") + proto.RegisterType((*QueryCirculatingSupplySWPResponse)(nil), "zgc.validatorvesting.v1beta1.QueryCirculatingSupplySWPResponse") + proto.RegisterType((*QueryTotalSupplyHARDRequest)(nil), "zgc.validatorvesting.v1beta1.QueryTotalSupplyHARDRequest") + proto.RegisterType((*QueryTotalSupplyHARDResponse)(nil), "zgc.validatorvesting.v1beta1.QueryTotalSupplyHARDResponse") + proto.RegisterType((*QueryTotalSupplyUSDXRequest)(nil), "zgc.validatorvesting.v1beta1.QueryTotalSupplyUSDXRequest") + proto.RegisterType((*QueryTotalSupplyUSDXResponse)(nil), "zgc.validatorvesting.v1beta1.QueryTotalSupplyUSDXResponse") } func init() { - proto.RegisterFile("kava/validatorvesting/v1beta1/query.proto", fileDescriptor_2198ebff70588a65) + proto.RegisterFile("zgc/validatorvesting/v1beta1/query.proto", fileDescriptor_4eb4aa17850547e7) } -var fileDescriptor_2198ebff70588a65 = []byte{ - // 619 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0xc7, 0x33, 0x9f, 0xf4, 0x55, 0x62, 0xba, 0x40, 0x8c, 0x8a, 0x68, 0x4d, 0xe3, 0x14, 0x23, - 0x21, 0x90, 0x88, 0xad, 0x34, 0x55, 0x4b, 0x2f, 0xd0, 0x0b, 0x5d, 0xd0, 0x1d, 0x4d, 0x8a, 0x40, - 0x6c, 0xa2, 0x49, 0x62, 0xb9, 0x56, 0x1d, 0x8f, 0xeb, 0x19, 0x9b, 0x86, 0x25, 0x4f, 0x80, 0xc4, - 0xab, 0x74, 0xc3, 0x03, 0x20, 0x65, 0xc1, 0xa2, 0x82, 0x0d, 0x20, 0x51, 0x41, 0xc2, 0x83, 0x20, - 0x8f, 0x27, 0xaa, 0xeb, 0xb8, 0x29, 0x76, 0x14, 0x58, 0x25, 0xb1, 0xcf, 0xe5, 0xf7, 0xf7, 0x39, - 0xf3, 0x77, 0xe0, 0xbd, 0x03, 0xec, 0x63, 0xcd, 0xc7, 0x96, 0xd9, 0xc4, 0x8c, 0xb8, 0xbe, 0x4e, - 0x99, 0x69, 0x1b, 0x9a, 0x5f, 0xaa, 0xeb, 0x0c, 0x97, 0xb4, 0x43, 0x4f, 0x77, 0xdb, 0xaa, 0xe3, - 0x12, 0x46, 0x50, 0x3e, 0x08, 0x55, 0xe3, 0xa1, 0xaa, 0x08, 0x95, 0x66, 0x1a, 0x84, 0xb6, 0x08, - 0xad, 0xf1, 0x60, 0x2d, 0xfc, 0x11, 0x66, 0x4a, 0x53, 0x06, 0x31, 0x48, 0x78, 0x3d, 0xf8, 0x26, - 0xae, 0xce, 0x1a, 0x84, 0x18, 0x96, 0xae, 0x61, 0xc7, 0xd4, 0xb0, 0x6d, 0x13, 0x86, 0x99, 0x49, - 0x6c, 0x91, 0xa3, 0x14, 0x60, 0x7e, 0x37, 0x68, 0xfe, 0xd8, 0x74, 0x1b, 0x9e, 0x85, 0x83, 0x56, - 0x55, 0xcf, 0x71, 0xac, 0x76, 0x45, 0x3f, 0xf4, 0x74, 0xca, 0x14, 0x1f, 0xca, 0x17, 0x05, 0x50, - 0x87, 0xd8, 0x54, 0x47, 0x7b, 0x70, 0x02, 0xb7, 0x88, 0x67, 0xb3, 0x69, 0x30, 0x07, 0xee, 0x5e, - 0xd9, 0x5a, 0xeb, 0x9c, 0x16, 0x72, 0xdf, 0x4e, 0x0b, 0x77, 0x0c, 0x93, 0xed, 0x7b, 0x75, 0xb5, - 0x41, 0x5a, 0x82, 0x53, 0x7c, 0x14, 0x69, 0xf3, 0x40, 0x63, 0x6d, 0x47, 0xa7, 0xea, 0x8e, 0xcd, - 0x3e, 0x1d, 0x17, 0xa1, 0x90, 0xb1, 0x63, 0xb3, 0x8a, 0xa8, 0xa5, 0xcc, 0xc0, 0x1b, 0xbc, 0xef, - 0x1e, 0x61, 0xd8, 0x3a, 0x8f, 0xe4, 0xc0, 0xe9, 0xc1, 0x5b, 0x63, 0x85, 0xb9, 0x0d, 0x6f, 0x25, - 0x3f, 0x84, 0x27, 0x9b, 0x95, 0xed, 0x3e, 0xd6, 0x6b, 0xa8, 0x0c, 0x0b, 0xfa, 0x37, 0x80, 0xcf, - 0xaa, 0xdb, 0x2f, 0x2e, 0x05, 0x0c, 0x83, 0xc6, 0x0a, 0xa8, 0xc0, 0xb9, 0xe4, 0xde, 0xd5, 0xe7, - 0x4f, 0xfb, 0x7c, 0xed, 0x8b, 0x44, 0xf0, 0x98, 0xb1, 0xe2, 0xe5, 0xe1, 0xcd, 0xf8, 0x4a, 0x45, - 0x47, 0xcb, 0xe0, 0x6c, 0xf2, 0xed, 0xbf, 0x0d, 0x15, 0x1d, 0x67, 0x02, 0xd4, 0xf8, 0x07, 0x39, - 0xff, 0x7e, 0x12, 0xfe, 0xcf, 0xdb, 0xa2, 0x8f, 0x00, 0x5e, 0x1b, 0x18, 0x15, 0x5a, 0x53, 0x87, - 0xfa, 0x97, 0x3a, 0xd4, 0x6d, 0xa4, 0x87, 0x19, 0xb3, 0x43, 0xc9, 0xca, 0xca, 0x9b, 0xcf, 0xbf, - 0xde, 0xfd, 0xb7, 0x80, 0xe6, 0xb5, 0xf3, 0x7e, 0x5b, 0x8c, 0x1b, 0x6e, 0xe3, 0xac, 0x44, 0x8d, - 0x86, 0xe0, 0xc7, 0x00, 0x4e, 0x46, 0x1e, 0x25, 0x5a, 0xfc, 0x13, 0x94, 0x41, 0x77, 0x92, 0x96, - 0x52, 0xe7, 0x09, 0xf8, 0x05, 0x0e, 0xaf, 0xa2, 0xfb, 0x97, 0xc1, 0xb3, 0x20, 0xb9, 0x8f, 0xfd, - 0x1d, 0xc0, 0xeb, 0x89, 0x8e, 0x83, 0x36, 0x32, 0x3d, 0xcb, 0xc8, 0xda, 0x4b, 0x9b, 0x23, 0x54, - 0x10, 0xa2, 0xd6, 0xb9, 0xa8, 0x65, 0xb4, 0x94, 0x7e, 0x22, 0xb5, 0x7d, 0xec, 0x36, 0x93, 0xf5, - 0x05, 0x7b, 0x9e, 0x51, 0x5f, 0xe4, 0x04, 0x65, 0xd4, 0x17, 0x3d, 0x64, 0x23, 0xe9, 0xf3, 0x68, - 0xf3, 0x08, 0x7d, 0x05, 0x70, 0x2a, 0xc9, 0xf0, 0xd0, 0x7a, 0x26, 0xb8, 0x33, 0x3b, 0x95, 0x36, - 0xb2, 0x17, 0x10, 0xe2, 0x1e, 0x71, 0x71, 0x0f, 0xd0, 0x62, 0x06, 0x71, 0xf4, 0x95, 0x83, 0x3e, - 0x00, 0x78, 0x35, 0x66, 0x99, 0x68, 0x25, 0xe5, 0xf1, 0x88, 0xee, 0xe3, 0x6a, 0xa6, 0x5c, 0x21, - 0x66, 0x99, 0x8b, 0x29, 0xa3, 0x52, 0x9a, 0xe3, 0x15, 0xee, 0x60, 0x4c, 0x07, 0xdf, 0xbe, 0xb4, - 0x3a, 0xa2, 0x7b, 0xb7, 0x9a, 0x29, 0x77, 0x24, 0x1d, 0xc1, 0xae, 0x6d, 0xed, 0x76, 0x7e, 0xca, - 0xb9, 0x4e, 0x57, 0x06, 0x27, 0x5d, 0x19, 0xfc, 0xe8, 0xca, 0xe0, 0x6d, 0x4f, 0xce, 0x9d, 0xf4, - 0xe4, 0xdc, 0x97, 0x9e, 0x9c, 0x7b, 0x59, 0x8e, 0xbc, 0x17, 0x82, 0xd2, 0x45, 0x0b, 0xd7, 0x69, - 0xd8, 0xe4, 0x28, 0xa1, 0x0d, 0x7f, 0x51, 0xd4, 0x27, 0xf8, 0xdf, 0xc8, 0xf2, 0xef, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xbd, 0x0f, 0x0a, 0x7d, 0xe1, 0x0a, 0x00, 0x00, +var fileDescriptor_4eb4aa17850547e7 = []byte{ + // 621 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x1b, 0x24, 0x26, 0xe1, 0x1d, 0x10, 0xd6, 0x10, 0x5b, 0xe8, 0xd2, 0x11, 0x24, 0xb4, + 0x4b, 0x93, 0x6e, 0xb0, 0x31, 0xba, 0x6e, 0x83, 0x6e, 0x07, 0x76, 0x83, 0x76, 0x08, 0xc4, 0xa5, + 0x72, 0xd3, 0x28, 0x8d, 0x48, 0xe3, 0xac, 0x76, 0xca, 0xda, 0x23, 0x9f, 0x00, 0x89, 0xaf, 0x82, + 0xf8, 0x0a, 0xeb, 0x09, 0x4d, 0x70, 0x41, 0x20, 0x0d, 0x68, 0xf9, 0x20, 0x28, 0x8e, 0xab, 0x86, + 0x34, 0x2b, 0xab, 0xa7, 0xc2, 0xa9, 0x6d, 0xf2, 0x9e, 0xdf, 0xef, 0xef, 0xf7, 0xfc, 0x77, 0xc1, + 0x72, 0xc7, 0x32, 0xf4, 0x16, 0x72, 0xec, 0x1a, 0xa2, 0xb8, 0xd9, 0x32, 0x09, 0xb5, 0x5d, 0x4b, + 0x6f, 0xad, 0x54, 0x4d, 0x8a, 0x56, 0xf4, 0x43, 0xdf, 0x6c, 0xb6, 0x35, 0xaf, 0x89, 0x29, 0x86, + 0xe9, 0x8e, 0x65, 0x68, 0xf1, 0x48, 0x8d, 0x47, 0xca, 0x0b, 0x06, 0x26, 0x0d, 0x4c, 0x2a, 0x2c, + 0x56, 0x0f, 0x7f, 0x84, 0x89, 0xf2, 0x9c, 0x85, 0x2d, 0x1c, 0x3e, 0x0f, 0xbe, 0xf1, 0xa7, 0x69, + 0x0b, 0x63, 0xcb, 0x31, 0x75, 0xe4, 0xd9, 0x3a, 0x72, 0x5d, 0x4c, 0x11, 0xb5, 0xb1, 0xcb, 0x73, + 0xd4, 0x0c, 0x58, 0x7c, 0x1a, 0xd4, 0xde, 0xb5, 0x9b, 0x86, 0xef, 0xa0, 0xa0, 0x54, 0xd9, 0xf7, + 0x3c, 0xa7, 0x5d, 0x32, 0x0f, 0x7d, 0x93, 0x50, 0xb5, 0x05, 0x94, 0xb3, 0x02, 0x88, 0x87, 0x5d, + 0x62, 0xc2, 0x03, 0x30, 0x83, 0x1a, 0xd8, 0x77, 0xe9, 0xbc, 0xb4, 0x24, 0x2d, 0x5f, 0x29, 0x16, + 0xba, 0xa7, 0x99, 0xd4, 0xd7, 0xd3, 0xcc, 0x1d, 0xcb, 0xa6, 0x75, 0xbf, 0xaa, 0x19, 0xb8, 0xc1, + 0x39, 0xf9, 0x47, 0x96, 0xd4, 0x5e, 0xe9, 0xb4, 0xed, 0x99, 0x44, 0xdb, 0x77, 0xe9, 0xa7, 0xf7, + 0x59, 0xc0, 0x65, 0xec, 0xbb, 0xb4, 0xc4, 0xd7, 0x52, 0x17, 0xc0, 0x0d, 0x56, 0xf7, 0x00, 0x53, + 0xe4, 0xfc, 0x89, 0xe4, 0x81, 0xf9, 0xd1, 0x57, 0x53, 0x85, 0xb9, 0x0d, 0x6e, 0x25, 0x6f, 0xc2, + 0xe3, 0x47, 0xa5, 0xbd, 0x01, 0x56, 0x07, 0xa8, 0xe3, 0x82, 0xfe, 0x0f, 0xe0, 0xb3, 0xf2, 0xde, + 0x8b, 0xbf, 0x02, 0x86, 0x41, 0x53, 0x05, 0x54, 0xc1, 0x52, 0x72, 0xed, 0xf2, 0xf3, 0x27, 0x03, + 0xbe, 0xf6, 0x59, 0x22, 0x58, 0xcc, 0x54, 0xf1, 0x16, 0xc1, 0xcd, 0xf8, 0x48, 0x45, 0x5b, 0x4b, + 0x41, 0x3a, 0xf9, 0xf5, 0xbf, 0x86, 0x8a, 0xb6, 0x33, 0x01, 0x6a, 0xfa, 0x8d, 0x5c, 0x3d, 0x9e, + 0x05, 0x97, 0x59, 0x59, 0xf8, 0x51, 0x02, 0xd7, 0x46, 0x5a, 0x05, 0x37, 0xb5, 0x71, 0xf6, 0xa5, + 0x8d, 0x35, 0x1b, 0xb9, 0x20, 0x96, 0x1c, 0x0a, 0x56, 0xb7, 0xdf, 0x7c, 0xfe, 0xf5, 0xee, 0xd2, + 0x06, 0x5c, 0xd7, 0x73, 0x56, 0xd6, 0xa8, 0x23, 0xdb, 0x1d, 0x1a, 0x6e, 0x36, 0xee, 0xb8, 0xc6, + 0x70, 0x99, 0x0a, 0x09, 0xd1, 0x3f, 0x48, 0x60, 0x36, 0xb2, 0x99, 0x70, 0xed, 0x1c, 0x34, 0xa3, + 0xf6, 0x24, 0xaf, 0x4f, 0x9a, 0xc6, 0xf1, 0x37, 0x18, 0xfe, 0x2a, 0xcc, 0x9d, 0x07, 0x9f, 0x06, + 0x0b, 0x0c, 0xc0, 0xbf, 0x4b, 0xe0, 0x7a, 0xa2, 0xeb, 0xc0, 0x1d, 0x91, 0x0d, 0x8d, 0x4c, 0xbe, + 0xfc, 0x50, 0x7c, 0x01, 0x2e, 0x6b, 0x97, 0xc9, 0xda, 0x82, 0x9b, 0x62, 0x5d, 0xa9, 0xd4, 0x51, + 0xb3, 0x96, 0xac, 0x30, 0x98, 0x76, 0x31, 0x85, 0x91, 0x63, 0x24, 0xa6, 0x30, 0x7a, 0xd0, 0x2e, + 0xac, 0xd0, 0x27, 0xb5, 0x23, 0xf8, 0x4d, 0x02, 0x73, 0x49, 0xc6, 0x07, 0xb7, 0x45, 0xf8, 0x86, + 0xae, 0x2a, 0xef, 0x08, 0xe7, 0x73, 0x79, 0x45, 0x26, 0xaf, 0x00, 0xf3, 0x82, 0xf2, 0xc8, 0x6b, + 0x0f, 0x1e, 0x4b, 0xe0, 0x6a, 0xcc, 0x3c, 0xe1, 0x83, 0xc9, 0xce, 0x49, 0x74, 0x2a, 0xf3, 0x22, + 0xa9, 0x5c, 0xce, 0x16, 0x93, 0x73, 0x1f, 0xae, 0x4d, 0x7a, 0xcc, 0xc2, 0x49, 0x8c, 0x29, 0x61, + 0x33, 0x38, 0xa1, 0x92, 0xe8, 0xf4, 0xe5, 0x45, 0x52, 0x2f, 0xac, 0x24, 0x98, 0xb8, 0x62, 0xa9, + 0xfb, 0x53, 0x49, 0x75, 0x7b, 0x8a, 0x74, 0xd2, 0x53, 0xa4, 0x1f, 0x3d, 0x45, 0x7a, 0xdb, 0x57, + 0x52, 0x27, 0x7d, 0x25, 0xf5, 0xa5, 0xaf, 0xa4, 0x5e, 0xde, 0x8b, 0xdc, 0x12, 0x39, 0xcb, 0x41, + 0x55, 0x32, 0xac, 0x72, 0x94, 0x50, 0x87, 0xdd, 0x1b, 0xd5, 0x19, 0xf6, 0xaf, 0xf2, 0xee, 0xef, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x5a, 0x7b, 0xbb, 0xee, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -632,9 +632,9 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // CirculatingSupply returns the total amount of kava tokens in circulation + // CirculatingSupply returns the total amount of 0g-chain tokens in circulation CirculatingSupply(ctx context.Context, in *QueryCirculatingSupplyRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplyResponse, error) - // TotalSupply returns the total amount of kava tokens + // TotalSupply returns the total amount of 0g-chain tokens TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) // CirculatingSupplyHARD returns the total amount of hard tokens in circulation CirculatingSupplyHARD(ctx context.Context, in *QueryCirculatingSupplyHARDRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplyHARDResponse, error) @@ -658,7 +658,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) CirculatingSupply(ctx context.Context, in *QueryCirculatingSupplyRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplyResponse, error) { out := new(QueryCirculatingSupplyResponse) - err := c.cc.Invoke(ctx, "/kava.validatorvesting.v1beta1.Query/CirculatingSupply", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.validatorvesting.v1beta1.Query/CirculatingSupply", in, out, opts...) if err != nil { return nil, err } @@ -667,7 +667,7 @@ func (c *queryClient) CirculatingSupply(ctx context.Context, in *QueryCirculatin func (c *queryClient) TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) { out := new(QueryTotalSupplyResponse) - err := c.cc.Invoke(ctx, "/kava.validatorvesting.v1beta1.Query/TotalSupply", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.validatorvesting.v1beta1.Query/TotalSupply", in, out, opts...) if err != nil { return nil, err } @@ -676,7 +676,7 @@ func (c *queryClient) TotalSupply(ctx context.Context, in *QueryTotalSupplyReque func (c *queryClient) CirculatingSupplyHARD(ctx context.Context, in *QueryCirculatingSupplyHARDRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplyHARDResponse, error) { out := new(QueryCirculatingSupplyHARDResponse) - err := c.cc.Invoke(ctx, "/kava.validatorvesting.v1beta1.Query/CirculatingSupplyHARD", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.validatorvesting.v1beta1.Query/CirculatingSupplyHARD", in, out, opts...) if err != nil { return nil, err } @@ -685,7 +685,7 @@ func (c *queryClient) CirculatingSupplyHARD(ctx context.Context, in *QueryCircul func (c *queryClient) CirculatingSupplyUSDX(ctx context.Context, in *QueryCirculatingSupplyUSDXRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplyUSDXResponse, error) { out := new(QueryCirculatingSupplyUSDXResponse) - err := c.cc.Invoke(ctx, "/kava.validatorvesting.v1beta1.Query/CirculatingSupplyUSDX", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.validatorvesting.v1beta1.Query/CirculatingSupplyUSDX", in, out, opts...) if err != nil { return nil, err } @@ -694,7 +694,7 @@ func (c *queryClient) CirculatingSupplyUSDX(ctx context.Context, in *QueryCircul func (c *queryClient) CirculatingSupplySWP(ctx context.Context, in *QueryCirculatingSupplySWPRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplySWPResponse, error) { out := new(QueryCirculatingSupplySWPResponse) - err := c.cc.Invoke(ctx, "/kava.validatorvesting.v1beta1.Query/CirculatingSupplySWP", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.validatorvesting.v1beta1.Query/CirculatingSupplySWP", in, out, opts...) if err != nil { return nil, err } @@ -703,7 +703,7 @@ func (c *queryClient) CirculatingSupplySWP(ctx context.Context, in *QueryCircula func (c *queryClient) TotalSupplyHARD(ctx context.Context, in *QueryTotalSupplyHARDRequest, opts ...grpc.CallOption) (*QueryTotalSupplyHARDResponse, error) { out := new(QueryTotalSupplyHARDResponse) - err := c.cc.Invoke(ctx, "/kava.validatorvesting.v1beta1.Query/TotalSupplyHARD", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.validatorvesting.v1beta1.Query/TotalSupplyHARD", in, out, opts...) if err != nil { return nil, err } @@ -712,7 +712,7 @@ func (c *queryClient) TotalSupplyHARD(ctx context.Context, in *QueryTotalSupplyH func (c *queryClient) TotalSupplyUSDX(ctx context.Context, in *QueryTotalSupplyUSDXRequest, opts ...grpc.CallOption) (*QueryTotalSupplyUSDXResponse, error) { out := new(QueryTotalSupplyUSDXResponse) - err := c.cc.Invoke(ctx, "/kava.validatorvesting.v1beta1.Query/TotalSupplyUSDX", in, out, opts...) + err := c.cc.Invoke(ctx, "/zgc.validatorvesting.v1beta1.Query/TotalSupplyUSDX", in, out, opts...) if err != nil { return nil, err } @@ -721,9 +721,9 @@ func (c *queryClient) TotalSupplyUSDX(ctx context.Context, in *QueryTotalSupplyU // QueryServer is the server API for Query service. type QueryServer interface { - // CirculatingSupply returns the total amount of kava tokens in circulation + // CirculatingSupply returns the total amount of 0g-chain tokens in circulation CirculatingSupply(context.Context, *QueryCirculatingSupplyRequest) (*QueryCirculatingSupplyResponse, error) - // TotalSupply returns the total amount of kava tokens + // TotalSupply returns the total amount of 0g-chain tokens TotalSupply(context.Context, *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) // CirculatingSupplyHARD returns the total amount of hard tokens in circulation CirculatingSupplyHARD(context.Context, *QueryCirculatingSupplyHARDRequest) (*QueryCirculatingSupplyHARDResponse, error) @@ -777,7 +777,7 @@ func _Query_CirculatingSupply_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.validatorvesting.v1beta1.Query/CirculatingSupply", + FullMethod: "/zgc.validatorvesting.v1beta1.Query/CirculatingSupply", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).CirculatingSupply(ctx, req.(*QueryCirculatingSupplyRequest)) @@ -795,7 +795,7 @@ func _Query_TotalSupply_Handler(srv interface{}, ctx context.Context, dec func(i } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.validatorvesting.v1beta1.Query/TotalSupply", + FullMethod: "/zgc.validatorvesting.v1beta1.Query/TotalSupply", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).TotalSupply(ctx, req.(*QueryTotalSupplyRequest)) @@ -813,7 +813,7 @@ func _Query_CirculatingSupplyHARD_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.validatorvesting.v1beta1.Query/CirculatingSupplyHARD", + FullMethod: "/zgc.validatorvesting.v1beta1.Query/CirculatingSupplyHARD", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).CirculatingSupplyHARD(ctx, req.(*QueryCirculatingSupplyHARDRequest)) @@ -831,7 +831,7 @@ func _Query_CirculatingSupplyUSDX_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.validatorvesting.v1beta1.Query/CirculatingSupplyUSDX", + FullMethod: "/zgc.validatorvesting.v1beta1.Query/CirculatingSupplyUSDX", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).CirculatingSupplyUSDX(ctx, req.(*QueryCirculatingSupplyUSDXRequest)) @@ -849,7 +849,7 @@ func _Query_CirculatingSupplySWP_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.validatorvesting.v1beta1.Query/CirculatingSupplySWP", + FullMethod: "/zgc.validatorvesting.v1beta1.Query/CirculatingSupplySWP", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).CirculatingSupplySWP(ctx, req.(*QueryCirculatingSupplySWPRequest)) @@ -867,7 +867,7 @@ func _Query_TotalSupplyHARD_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.validatorvesting.v1beta1.Query/TotalSupplyHARD", + FullMethod: "/zgc.validatorvesting.v1beta1.Query/TotalSupplyHARD", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).TotalSupplyHARD(ctx, req.(*QueryTotalSupplyHARDRequest)) @@ -885,7 +885,7 @@ func _Query_TotalSupplyUSDX_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kava.validatorvesting.v1beta1.Query/TotalSupplyUSDX", + FullMethod: "/zgc.validatorvesting.v1beta1.Query/TotalSupplyUSDX", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).TotalSupplyUSDX(ctx, req.(*QueryTotalSupplyUSDXRequest)) @@ -894,7 +894,7 @@ func _Query_TotalSupplyUSDX_Handler(srv interface{}, ctx context.Context, dec fu } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "kava.validatorvesting.v1beta1.Query", + ServiceName: "zgc.validatorvesting.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -927,7 +927,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "kava/validatorvesting/v1beta1/query.proto", + Metadata: "zgc/validatorvesting/v1beta1/query.proto", } func (m *QueryCirculatingSupplyRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/validator-vesting/types/query.pb.gw.go b/x/validator-vesting/types/query.pb.gw.go index 4b9c0d4f..c43a43c4 100644 --- a/x/validator-vesting/types/query.pb.gw.go +++ b/x/validator-vesting/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: kava/validatorvesting/v1beta1/query.proto +// source: zgc/validatorvesting/v1beta1/query.proto /* Package types is a reverse proxy. @@ -511,19 +511,19 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_CirculatingSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_CirculatingSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "validator-vesting", "v1beta1", "circulating_supply"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TotalSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "total_supply"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TotalSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "validator-vesting", "v1beta1", "total_supply"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_CirculatingSupplyHARD_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply_hard"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_CirculatingSupplyHARD_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "validator-vesting", "v1beta1", "circulating_supply_hard"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_CirculatingSupplyUSDX_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply_usdx"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_CirculatingSupplyUSDX_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "validator-vesting", "v1beta1", "circulating_supply_usdx"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_CirculatingSupplySWP_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply_swp"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_CirculatingSupplySWP_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "validator-vesting", "v1beta1", "circulating_supply_swp"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TotalSupplyHARD_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "total_supply_hard"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TotalSupplyHARD_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "validator-vesting", "v1beta1", "total_supply_hard"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TotalSupplyUSDX_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "total_supply_usdx"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TotalSupplyUSDX_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g-chain", "validator-vesting", "v1beta1", "total_supply_usdx"}, "", runtime.AssumeColonVerbOpt(false))) ) var (