From 1dcb836f773163e9b9eaa830edb8ae996090dc0b Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 15:31:20 +0200 Subject: [PATCH 001/112] test: test deploy to server --- settings-ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 settings-ci.yml diff --git a/settings-ci.yml b/settings-ci.yml new file mode 100644 index 0000000..48be011 --- /dev/null +++ b/settings-ci.yml @@ -0,0 +1,23 @@ +--- +trufflehog_ignore: true + +deploy: + environment: + tacchain: + branch: develop + docker_compose: true + docker_compose_file: ./networks/tacchain_2391-1/docker-compose-geth0.yml + runner_tags: + - taccnetwork-dev + +apps: + geth: + image: golang:1.23.8-alpine3.20 + runner_tags: + - docker + code_analysis: false + build: false + docker_build: + runner_tags: + - docker + test_docker: false \ No newline at end of file From affd81cf887ba18f162b59f6378d24bfc5512094 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 15:33:50 +0200 Subject: [PATCH 002/112] fix: fix docker-compose path --- settings-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings-ci.yml b/settings-ci.yml index 48be011..b39f686 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -6,12 +6,12 @@ deploy: tacchain: branch: develop docker_compose: true - docker_compose_file: ./networks/tacchain_2391-1/docker-compose-geth0.yml + docker_compose_file: ./networks/tacchain_2391-1/docker-compose.yml runner_tags: - taccnetwork-dev apps: - geth: + tac: image: golang:1.23.8-alpine3.20 runner_tags: - docker From 3634b2ba8618c9f0585da55d42513d72a1da6e44 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 17:46:38 +0200 Subject: [PATCH 003/112] fix: fix docker-compose path --- .../{docker-compose.yaml => docker-compose.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename networks/tacchain_2391-1/{docker-compose.yaml => docker-compose.yml} (95%) diff --git a/networks/tacchain_2391-1/docker-compose.yaml b/networks/tacchain_2391-1/docker-compose.yml similarity index 95% rename from networks/tacchain_2391-1/docker-compose.yaml rename to networks/tacchain_2391-1/docker-compose.yml index 2cb8500..3b640f8 100644 --- a/networks/tacchain_2391-1/docker-compose.yaml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -1,7 +1,7 @@ services: tac-spb-testnet-init: user: "${USER_ID}:${GROUP_ID}" - image: tacchain:v0.0.11 + image: ${IMAGE} env_file: - .env.spb volumes: @@ -12,7 +12,7 @@ services: tac-spb-testnet-validator-1: user: "${USER_ID}:${GROUP_ID}" - network_mode: host + network_mode: ${IMAGE} restart: unless-stopped image: tacchain:v0.0.11 env_file: From 6007a2d6ba1dd9a0168b59344b5571b067eaf4c7 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 17:47:06 +0200 Subject: [PATCH 004/112] fix: fix docker-compose path #1 --- .../{docker-compose.yml => docker-compose.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename networks/tacchain_2391-1/{docker-compose.yml => docker-compose.yaml} (95%) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yaml similarity index 95% rename from networks/tacchain_2391-1/docker-compose.yml rename to networks/tacchain_2391-1/docker-compose.yaml index 3b640f8..b8179e8 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yaml @@ -12,9 +12,9 @@ services: tac-spb-testnet-validator-1: user: "${USER_ID}:${GROUP_ID}" - network_mode: ${IMAGE} + network_mode: host restart: unless-stopped - image: tacchain:v0.0.11 + image: ${IMAGE} env_file: - .env.spb volumes: From 998586a59b3d8399439bed09a4f4279c1e9c74f4 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 17:56:18 +0200 Subject: [PATCH 005/112] fix: fix docker-compose path #2 --- .../tacchain_2391-1/{docker-compose.yaml => docker-compose.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename networks/tacchain_2391-1/{docker-compose.yaml => docker-compose.yml} (100%) diff --git a/networks/tacchain_2391-1/docker-compose.yaml b/networks/tacchain_2391-1/docker-compose.yml similarity index 100% rename from networks/tacchain_2391-1/docker-compose.yaml rename to networks/tacchain_2391-1/docker-compose.yml From 6b2146dfdb300e3b5fb03f3519585b0cbbbbf69d Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 18:23:43 +0200 Subject: [PATCH 006/112] fix(HOTFIX): add envs to compose --- networks/tacchain_2391-1/docker-compose.yml | 26 ++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index b8179e8..fa3fb51 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -1,24 +1,34 @@ services: tac-spb-testnet-init: - user: "${USER_ID}:${GROUP_ID}" image: ${IMAGE} - env_file: - - .env.spb + environment: + - MONIKER=tac-validator + - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 + - EXT_IP=0.0.0.0 + - P2P_PORT=45130 + - RPC_PORT=45131 + - RPC_PORT_EVM=45138 + - WS_PORT_EVM=45139 volumes: - - "./:/data" + - "/data/tac:/data" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" tac-spb-testnet-validator-1: - user: "${USER_ID}:${GROUP_ID}" network_mode: host restart: unless-stopped image: ${IMAGE} - env_file: - - .env.spb + environment: + - MONIKER=tac-validator + - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 + - EXT_IP=0.0.0.0 + - P2P_PORT=45130 + - RPC_PORT=45131 + - RPC_PORT_EVM=45138 + - WS_PORT_EVM=45139 volumes: - - "./:/data" + - "/data/tac:/data" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From 726b6d804aadf19587beba9489e7cb599fcacaa2 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 18:33:40 +0200 Subject: [PATCH 007/112] fix(HOTFIX): add envs to compose #1 --- networks/tacchain_2391-1/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index fa3fb51..cf5764e 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -10,7 +10,7 @@ services: - RPC_PORT_EVM=45138 - WS_PORT_EVM=45139 volumes: - - "/data/tac:/data" + - "/data/tac/:/data" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" @@ -28,7 +28,7 @@ services: - RPC_PORT_EVM=45138 - WS_PORT_EVM=45139 volumes: - - "/data/tac:/data" + - "/data/tac/:/data" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From 29cbd0f300c4e88e7da3e7592dd82a3f907cb520 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 18:50:10 +0200 Subject: [PATCH 008/112] fix(HOTFIX): add envs to compose #2 --- networks/tacchain_2391-1/docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index cf5764e..c3a219a 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -11,6 +11,7 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" + - "./genesis.json:/data/config/genesis.json" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" @@ -29,6 +30,7 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" + - "./genesis.json:/data/config/genesis.json" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From ec8844dc93025f6eb5142ab6891ef9f3bc137d28 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 19:16:37 +0200 Subject: [PATCH 009/112] fix(HOTFIX): add envs to compose #3 --- networks/tacchain_2391-1/docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index c3a219a..58a9b6d 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -1,6 +1,7 @@ services: tac-spb-testnet-init: image: ${IMAGE} + network_mode: host environment: - MONIKER=tac-validator - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 @@ -11,7 +12,6 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" - - "./genesis.json:/data/config/genesis.json" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" @@ -30,7 +30,6 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" - - "./genesis.json:/data/config/genesis.json" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From e57025a11c396d92d83d08e077079e148903f07b Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 21 Jun 2025 16:00:20 +0200 Subject: [PATCH 010/112] feat(TAC-21): update node to main finally --- docker-compose.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ settings-ci.yml | 22 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 docker-compose.yml create mode 100644 settings-ci.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..09c5b55 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,43 @@ +services: + tac-spb-testnet-init: + user: "${USER_ID}:${GROUP_ID}" + image: ${IMAGE} + volumes: + - "/mnt/data:/data" + entrypoint: /bin/sh + command: > + -c "[ ! -e /data/config/config.toml ] && tacchaind init testnode --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" + + tac-spb-testnet-validator-1: + user: "${USER_ID}:${GROUP_ID}" + network_mode: host + restart: unless-stopped + image: ${IMAGE} + ports: + - "26656:26656" # P2P + - "26657:26657" # RPC + - "1317:1317" # REST + - "8545:8545" # RPC_EVM + - "8546:8546" # WS_EVM + - "9090:9090" # GRPC + volumes: + - "/mnt/data:/data" + depends_on: + tac-spb-testnet-init: + condition: service_completed_successfully + entrypoint: tacchaind + command: > + start + --chain-id=tacchain_2391-1 + --home=/data + --db_dir=data + --log_level=info + --p2p.persistent_peers=${P2P_PERSISTENT_PEERS} + --p2p.laddr=tcp://0.0.0.0:${P2P_PORT} + --p2p.external-address=${EXT_IP}:${P2P_PORT} + --rpc.laddr=tcp://0.0.0.0:${RPC_PORT} + --json-rpc.address=0.0.0.0:${RPC_PORT_EVM} + --json-rpc.ws-address=0.0.0.0:${WS_PORT_EVM} + --grpc.enable + --grpc-web.enable + --rpc.grpc_laddr=tcp://0.0.0.0:${GRPC_PORT} \ No newline at end of file diff --git a/settings-ci.yml b/settings-ci.yml new file mode 100644 index 0000000..5a3a791 --- /dev/null +++ b/settings-ci.yml @@ -0,0 +1,22 @@ +--- +trufflehog_ignore: true + +deploy: + environment: + tacchain: + branch: main + docker_compose: true + runner_tags: + - taccnetwork-dev + +apps: + tac: + image: golang:1.23.8-alpine3.20 + runner_tags: + - docker + code_analysis: false + build: false + docker_build: + runner_tags: + - docker + test_docker: false From ee21872ed6d01035366365e265aee9e33b57b50f Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Mon, 23 Jun 2025 11:16:31 +0300 Subject: [PATCH 011/112] draft: Register gTAC with x/erc20 --- app/app.go | 17 +++++++++++++++++ app/token_pair.go | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 app/token_pair.go diff --git a/app/app.go b/app/app.go index 8ffd82d..7dda7b4 100644 --- a/app/app.go +++ b/app/app.go @@ -1,6 +1,7 @@ package app import ( + "context" "encoding/json" "fmt" "io" @@ -583,6 +584,11 @@ func NewTacChainApp( &app.TransferKeeper, ) + app.Erc20Keeper.RegisterERC20(context.Background(), &evmerc20types.MsgRegisterERC20{ + Authority: authAddr, + Erc20Addresses: []string{WTACContract}, + }) + // instantiate IBC transfer keeper AFTER the ERC-20 keeper to use it in the instantiation app.TransferKeeper = evmibctransferkeeper.NewKeeper( encodingConfig.Codec, @@ -1088,10 +1094,21 @@ func (app *TacChainApp) AutoCliOpts() autocli.AppOptions { func (app *TacChainApp) DefaultGenesis() map[string]json.RawMessage { genesis := app.BasicModuleManager.DefaultGenesis(app.appCodec) + // Mint denom configuration + mintGenState := minttypes.DefaultGenesisState() + mintGenState.Params.MintDenom = BaseDenom + genesis[minttypes.ModuleName] = app.appCodec.MustMarshalJSON(mintGenState) + + // EVM genesis configuration evmGenState := evmd.NewEVMGenesisState() + evmGenState.Params.ActiveStaticPrecompiles = evmvmtypes.AvailableStaticPrecompiles genesis[evmvmtypes.ModuleName] = app.appCodec.MustMarshalJSON(evmGenState) + // ERC20 genesis configuration erc20GenState := evmerc20types.DefaultGenesisState() + erc20GenState.TokenPairs = TacTokenPairs + erc20GenState.Params.NativePrecompiles = append(erc20GenState.Params.NativePrecompiles, WTACContract) + erc20GenState.Params.EnableErc20 = true genesis[evmerc20types.ModuleName] = app.appCodec.MustMarshalJSON(erc20GenState) return genesis diff --git a/app/token_pair.go b/app/token_pair.go new file mode 100644 index 0000000..526fb9a --- /dev/null +++ b/app/token_pair.go @@ -0,0 +1,19 @@ +package app + +import ( + erc20types "github.com/cosmos/evm/x/erc20/types" + "github.com/ethereum/go-ethereum/common" +) + +// NOTE: This is the WToken contract on EVM Testnet (Saint Peterburg) +const WTACContract = "0xCf61405b7525F09f4E7501fc831fE7cbCc823d4c" + +const gTACDenom = "ugtac" + +var GTACTokenPair = erc20types.NewTokenPair( + common.HexToAddress(WTACContract), + gTACDenom, + erc20types.OWNER_MODULE, +) + +var TacTokenPairs = []erc20types.TokenPair{GTACTokenPair} From 0e7e05b7b4dd01e2af7a5a14bc4acb9c79303de2 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Mon, 23 Jun 2025 11:29:48 +0300 Subject: [PATCH 012/112] draft(FIX): Removed gTAC registration in app constructor --- app/app.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/app.go b/app/app.go index 7dda7b4..2c60b21 100644 --- a/app/app.go +++ b/app/app.go @@ -1,7 +1,6 @@ package app import ( - "context" "encoding/json" "fmt" "io" @@ -584,11 +583,6 @@ func NewTacChainApp( &app.TransferKeeper, ) - app.Erc20Keeper.RegisterERC20(context.Background(), &evmerc20types.MsgRegisterERC20{ - Authority: authAddr, - Erc20Addresses: []string{WTACContract}, - }) - // instantiate IBC transfer keeper AFTER the ERC-20 keeper to use it in the instantiation app.TransferKeeper = evmibctransferkeeper.NewKeeper( encodingConfig.Codec, From cc06b2566e0bddf48fe2319e7ed615d0d18fd282 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Mon, 23 Jun 2025 14:29:52 +0300 Subject: [PATCH 013/112] draft(FEAT): Added set token pair function into InitChainer --- app/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.go b/app/app.go index 2c60b21..fdabdff 100644 --- a/app/app.go +++ b/app/app.go @@ -1020,6 +1020,7 @@ func (a *TacChainApp) Configurator() module.Configurator { // InitChainer application update at chain initialization func (app *TacChainApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { + app.Erc20Keeper.SetTokenPair(ctx, GTACTokenPair) var genesisState GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) From c95288c171dfa49478d04c5af0e3bc2f572cac80 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 17:46:38 +0200 Subject: [PATCH 014/112] fix: fix docker-compose path --- .../{docker-compose.yaml => docker-compose.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename networks/tacchain_2391-1/{docker-compose.yaml => docker-compose.yml} (95%) diff --git a/networks/tacchain_2391-1/docker-compose.yaml b/networks/tacchain_2391-1/docker-compose.yml similarity index 95% rename from networks/tacchain_2391-1/docker-compose.yaml rename to networks/tacchain_2391-1/docker-compose.yml index 2cb8500..3b640f8 100644 --- a/networks/tacchain_2391-1/docker-compose.yaml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -1,7 +1,7 @@ services: tac-spb-testnet-init: user: "${USER_ID}:${GROUP_ID}" - image: tacchain:v0.0.11 + image: ${IMAGE} env_file: - .env.spb volumes: @@ -12,7 +12,7 @@ services: tac-spb-testnet-validator-1: user: "${USER_ID}:${GROUP_ID}" - network_mode: host + network_mode: ${IMAGE} restart: unless-stopped image: tacchain:v0.0.11 env_file: From 54e49a020b80e696d2fd758f6c1f2d691eb6c28b Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 17:47:06 +0200 Subject: [PATCH 015/112] fix: fix docker-compose path #1 --- .../{docker-compose.yml => docker-compose.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename networks/tacchain_2391-1/{docker-compose.yml => docker-compose.yaml} (95%) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yaml similarity index 95% rename from networks/tacchain_2391-1/docker-compose.yml rename to networks/tacchain_2391-1/docker-compose.yaml index 3b640f8..b8179e8 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yaml @@ -12,9 +12,9 @@ services: tac-spb-testnet-validator-1: user: "${USER_ID}:${GROUP_ID}" - network_mode: ${IMAGE} + network_mode: host restart: unless-stopped - image: tacchain:v0.0.11 + image: ${IMAGE} env_file: - .env.spb volumes: From 362853e1f2d18c5145273b14b1d5d59d81a6b3b2 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 17:56:18 +0200 Subject: [PATCH 016/112] fix: fix docker-compose path #2 --- .../tacchain_2391-1/{docker-compose.yaml => docker-compose.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename networks/tacchain_2391-1/{docker-compose.yaml => docker-compose.yml} (100%) diff --git a/networks/tacchain_2391-1/docker-compose.yaml b/networks/tacchain_2391-1/docker-compose.yml similarity index 100% rename from networks/tacchain_2391-1/docker-compose.yaml rename to networks/tacchain_2391-1/docker-compose.yml From 8cc465024773d57a58c42d90298408c1172b9271 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 18:23:43 +0200 Subject: [PATCH 017/112] fix(HOTFIX): add envs to compose --- networks/tacchain_2391-1/docker-compose.yml | 26 ++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index b8179e8..fa3fb51 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -1,24 +1,34 @@ services: tac-spb-testnet-init: - user: "${USER_ID}:${GROUP_ID}" image: ${IMAGE} - env_file: - - .env.spb + environment: + - MONIKER=tac-validator + - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 + - EXT_IP=0.0.0.0 + - P2P_PORT=45130 + - RPC_PORT=45131 + - RPC_PORT_EVM=45138 + - WS_PORT_EVM=45139 volumes: - - "./:/data" + - "/data/tac:/data" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" tac-spb-testnet-validator-1: - user: "${USER_ID}:${GROUP_ID}" network_mode: host restart: unless-stopped image: ${IMAGE} - env_file: - - .env.spb + environment: + - MONIKER=tac-validator + - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 + - EXT_IP=0.0.0.0 + - P2P_PORT=45130 + - RPC_PORT=45131 + - RPC_PORT_EVM=45138 + - WS_PORT_EVM=45139 volumes: - - "./:/data" + - "/data/tac:/data" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From a2e369c5ee845f2c1b4e57d1138e94c84e7b7521 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 18:33:40 +0200 Subject: [PATCH 018/112] fix(HOTFIX): add envs to compose #1 --- networks/tacchain_2391-1/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index fa3fb51..cf5764e 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -10,7 +10,7 @@ services: - RPC_PORT_EVM=45138 - WS_PORT_EVM=45139 volumes: - - "/data/tac:/data" + - "/data/tac/:/data" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" @@ -28,7 +28,7 @@ services: - RPC_PORT_EVM=45138 - WS_PORT_EVM=45139 volumes: - - "/data/tac:/data" + - "/data/tac/:/data" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From ae45d072496f643db01939c34b51498d2f022980 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 18:50:10 +0200 Subject: [PATCH 019/112] fix(HOTFIX): add envs to compose #2 --- networks/tacchain_2391-1/docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index cf5764e..c3a219a 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -11,6 +11,7 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" + - "./genesis.json:/data/config/genesis.json" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" @@ -29,6 +30,7 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" + - "./genesis.json:/data/config/genesis.json" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From bf4ddccb30f550e58f046d0a87902df28db2f78a Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Sat, 14 Jun 2025 19:16:37 +0200 Subject: [PATCH 020/112] fix(HOTFIX): add envs to compose #3 --- networks/tacchain_2391-1/docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index c3a219a..58a9b6d 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -1,6 +1,7 @@ services: tac-spb-testnet-init: image: ${IMAGE} + network_mode: host environment: - MONIKER=tac-validator - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 @@ -11,7 +12,6 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" - - "./genesis.json:/data/config/genesis.json" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" @@ -30,7 +30,6 @@ services: - WS_PORT_EVM=45139 volumes: - "/data/tac/:/data" - - "./genesis.json:/data/config/genesis.json" depends_on: tac-spb-testnet-init: condition: service_completed_successfully From d19d79a9c0c66c36c383ffff864c4d59c5cf852c Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 17 Jun 2025 19:53:24 +0300 Subject: [PATCH 021/112] =?UTF-8?q?feat:=20Integrate=20=E2=80=9Cx/liquidst?= =?UTF-8?q?ake=E2=80=9D=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 11 + go.mod | 70 +- go.sum | 112 +- proto/buf.gen.gogo.yaml | 8 + proto/buf.lock | 23 + proto/buf.yaml | 7 + .../pstake/liquidstake/v1beta1/genesis.proto | 20 + .../liquidstake/v1beta1/liquidstake.proto | 214 ++ proto/pstake/liquidstake/v1beta1/query.proto | 55 + proto/pstake/liquidstake/v1beta1/tx.proto | 155 + scripts/protocgen.sh | 16 + x/liquidstake/abci.go | 20 + x/liquidstake/client/cli/query.go | 155 + x/liquidstake/client/cli/tx.go | 333 +++ x/liquidstake/keeper/genesis.go | 47 + x/liquidstake/keeper/grpc_query.go | 49 + x/liquidstake/keeper/hooks.go | 45 + x/liquidstake/keeper/keeper.go | 100 + x/liquidstake/keeper/liquidstake.go | 1147 ++++++++ x/liquidstake/keeper/msg_server.go | 299 ++ x/liquidstake/keeper/rebalancing.go | 278 ++ x/liquidstake/module.go | 152 + x/liquidstake/types/codec.go | 50 + x/liquidstake/types/errors.go | 32 + x/liquidstake/types/events.go | 38 + x/liquidstake/types/expected_keepers.go | 96 + x/liquidstake/types/genesis.go | 37 + x/liquidstake/types/genesis.pb.go | 377 +++ x/liquidstake/types/genesis_test.go | 64 + x/liquidstake/types/keys.go | 39 + x/liquidstake/types/liquidstake.go | 215 ++ x/liquidstake/types/liquidstake.pb.go | 2056 +++++++++++++ x/liquidstake/types/logging.go | 19 + x/liquidstake/types/msgs.go | 330 +++ x/liquidstake/types/msgs_test.go | 150 + x/liquidstake/types/params.go | 253 ++ x/liquidstake/types/query.pb.go | 1222 ++++++++ x/liquidstake/types/query.pb.gw.go | 283 ++ x/liquidstake/types/rebalancing.go | 52 + x/liquidstake/types/tx.pb.go | 2621 +++++++++++++++++ 40 files changed, 11158 insertions(+), 92 deletions(-) create mode 100644 proto/buf.gen.gogo.yaml create mode 100644 proto/buf.lock create mode 100644 proto/buf.yaml create mode 100644 proto/pstake/liquidstake/v1beta1/genesis.proto create mode 100644 proto/pstake/liquidstake/v1beta1/liquidstake.proto create mode 100644 proto/pstake/liquidstake/v1beta1/query.proto create mode 100644 proto/pstake/liquidstake/v1beta1/tx.proto create mode 100644 scripts/protocgen.sh create mode 100644 x/liquidstake/abci.go create mode 100644 x/liquidstake/client/cli/query.go create mode 100644 x/liquidstake/client/cli/tx.go create mode 100644 x/liquidstake/keeper/genesis.go create mode 100644 x/liquidstake/keeper/grpc_query.go create mode 100644 x/liquidstake/keeper/hooks.go create mode 100644 x/liquidstake/keeper/keeper.go create mode 100644 x/liquidstake/keeper/liquidstake.go create mode 100644 x/liquidstake/keeper/msg_server.go create mode 100644 x/liquidstake/keeper/rebalancing.go create mode 100644 x/liquidstake/module.go create mode 100644 x/liquidstake/types/codec.go create mode 100644 x/liquidstake/types/errors.go create mode 100644 x/liquidstake/types/events.go create mode 100644 x/liquidstake/types/expected_keepers.go create mode 100644 x/liquidstake/types/genesis.go create mode 100644 x/liquidstake/types/genesis.pb.go create mode 100644 x/liquidstake/types/genesis_test.go create mode 100644 x/liquidstake/types/keys.go create mode 100644 x/liquidstake/types/liquidstake.go create mode 100644 x/liquidstake/types/liquidstake.pb.go create mode 100644 x/liquidstake/types/logging.go create mode 100644 x/liquidstake/types/msgs.go create mode 100644 x/liquidstake/types/msgs_test.go create mode 100644 x/liquidstake/types/params.go create mode 100644 x/liquidstake/types/query.pb.go create mode 100644 x/liquidstake/types/query.pb.gw.go create mode 100644 x/liquidstake/types/rebalancing.go create mode 100644 x/liquidstake/types/tx.pb.go diff --git a/Makefile b/Makefile index e30a6d9..6b25757 100644 --- a/Makefile +++ b/Makefile @@ -139,3 +139,14 @@ localnet-init-multi-node: localnet-start: ./contrib/localnet/start.sh +DOCKER := $(shell which docker) +BUILDDIR ?= $(CURDIR)/build + +protoVer=0.14.0 +protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) +protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) + +proto-gen: + @echo "Generating Protobuf files" + @$(protoImage) sh ./scripts/protocgen.sh + diff --git a/go.mod b/go.mod index b3634c6..b0d17d6 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( cosmossdk.io/api v0.7.6 cosmossdk.io/client/v2 v2.0.0-beta.7 cosmossdk.io/core v0.11.1 + cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.5.0 cosmossdk.io/math v1.5.0 cosmossdk.io/simapp v0.0.0-20231103111158-e83a20081ced @@ -16,20 +17,28 @@ require ( cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/nft v0.1.1 cosmossdk.io/x/upgrade v0.1.4 + github.com/CosmWasm/wasmd v0.55.0 github.com/cometbft/cometbft v0.38.17 github.com/cosmos/cosmos-db v1.1.1 + github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.50.13 github.com/cosmos/evm v0.1.1-0.20250328143818-59c573a37f8b github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/cosmos/ibc-go/v8 v8.7.0 - github.com/ethereum/go-ethereum v1.13.15 + github.com/ethereum/go-ethereum v1.15.5 + github.com/golang/protobuf v1.5.4 + github.com/gorilla/mux v1.8.1 + github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/onsi/ginkgo/v2 v2.22.2 github.com/onsi/gomega v1.36.2 github.com/spf13/cast v1.7.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 + google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a + google.golang.org/grpc v1.70.0 + google.golang.org/protobuf v1.36.5 ) require ( @@ -41,28 +50,28 @@ require ( cloud.google.com/go/storage v1.41.0 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/depinject v1.1.0 // indirect - cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/x/tx v0.13.7 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect - github.com/99designs/keyring v1.2.1 // indirect - github.com/DataDog/datadog-go v3.2.0+incompatible // indirect + github.com/99designs/keyring v1.2.2 // indirect + github.com/CosmWasm/wasmvm/v2 v2.2.1 // indirect + github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.1 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect - github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect - github.com/bits-and-blooms/bitset v1.10.0 // indirect + github.com/bgentry/speakeasy v0.2.0 // indirect + github.com/bits-and-blooms/bitset v1.17.0 // indirect github.com/btcsuite/btcd v0.24.2 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/btcsuite/btcd/btcutil v1.1.6 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect github.com/bytedance/sonic v1.12.3 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect - github.com/cenkalti/backoff/v4 v4.1.3 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cloudwego/base64x v0.1.4 // indirect @@ -78,35 +87,36 @@ require ( github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.4 // indirect + github.com/cosmos/ibc-go/v10 v10.0.0 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect - github.com/danieljoos/wincred v1.1.2 // indirect + github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect - github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect + github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect + github.com/distribution/reference v0.5.0 // indirect github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/dvsekhvalnov/jose2go v1.6.0 // indirect + github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect github.com/ethereum/c-kzg-4844 v0.4.0 // indirect - github.com/fatih/color v1.15.0 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect - github.com/getsentry/sentry-go v0.27.0 // indirect + github.com/getsentry/sentry-go v0.28.1 // indirect github.com/go-kit/kit v0.13.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect @@ -122,10 +132,9 @@ require ( github.com/golang/glog v1.2.4 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.3 // indirect - github.com/google/flatbuffers v23.5.26+incompatible // indirect + github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect @@ -134,24 +143,22 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.5 // indirect github.com/gorilla/handlers v1.5.2 // indirect - github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.5 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-metrics v0.5.3 // indirect - github.com/hashicorp/go-plugin v1.5.2 // indirect + github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect - github.com/hdevalence/ed25519consensus v0.1.0 // indirect + github.com/hdevalence/ed25519consensus v0.2.0 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/holiman/uint256 v1.3.2 // indirect github.com/huandu/skiplist v1.2.0 // indirect @@ -172,7 +179,7 @@ require ( github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect github.com/minio/highwayhash v1.0.3 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect @@ -183,6 +190,7 @@ require ( github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -196,9 +204,10 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/cors v1.11.1 // indirect github.com/rs/zerolog v1.33.0 // indirect - github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect + github.com/shamaton/msgpack/v2 v2.2.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect @@ -221,7 +230,7 @@ require ( github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect - go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect + go.etcd.io/bbolt v1.4.0-alpha.1 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect @@ -232,26 +241,22 @@ require ( golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.32.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect - golang.org/x/mod v0.22.0 // indirect golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.29.0 // indirect golang.org/x/term v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect - golang.org/x/time v0.5.0 // indirect + golang.org/x/time v0.9.0 // indirect golang.org/x/tools v0.28.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect - google.golang.org/grpc v1.70.0 // indirect - google.golang.org/protobuf v1.36.4 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect - nhooyr.io/websocket v1.8.7 // indirect + nhooyr.io/websocket v1.8.17 // indirect pgregory.net/rapid v1.1.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect @@ -270,8 +275,9 @@ replace ( // Pin this pebble version to avoid breaking compilation of geth github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 - // use Cosmos-SDK fork to enable Ledger functionality - github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 + // // use Cosmos-SDK fork to enable Ledger functionality + // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 + github.com/cosmos/cosmos-sdk => ../cosmos-sdk/ // replace cosmos evm with our fork that uses geth v1.13.15 github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index 959fe5d..ace1ce3 100644 --- a/go.sum +++ b/go.sum @@ -227,13 +227,18 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= +github.com/CosmWasm/wasmd v0.55.0 h1:NJgTxvdqh4WunjQ/djL0hnnq3LUU58rW7CiUkeCBu/8= +github.com/CosmWasm/wasmd v0.55.0/go.mod h1:67K2PzoSF9+NjImaALEYMaAHd3zwaSuWLsQ7iSznUik= +github.com/CosmWasm/wasmvm/v2 v2.2.1 h1:cmOnM+TDfUl2VRugeo1eJBw4U/Lw0WLviuQHKSo9DVQ= +github.com/CosmWasm/wasmvm/v2 v2.2.1/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= +github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -281,10 +286,10 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= -github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= -github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= +github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.17.0 h1:1X2TS7aHz1ELcC0yU1y2stUs/0ig5oMU6STFZGrhvHI= +github.com/bits-and-blooms/bitset v1.17.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= @@ -325,8 +330,8 @@ github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= @@ -405,8 +410,6 @@ github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNC github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 h1:zoOAawQLQXLg+HuSOfmuwtTMC4Qovc23a60+xfoHKUw= -github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= github.com/cosmos/cosmos-sdk/store v1.1.2-0.20250319183239-53dea340efc7 h1:7EBHeRE/Kmba2A9JlJ9/sOlHhmEHggyyWRD/uGccnC8= github.com/cosmos/cosmos-sdk/store v1.1.2-0.20250319183239-53dea340efc7/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= @@ -420,6 +423,8 @@ github.com/cosmos/iavl v1.2.4 h1:IHUrG8dkyueKEY72y92jajrizbkZKPZbMmG14QzsEkw= github.com/cosmos/iavl v1.2.4/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= +github.com/cosmos/ibc-go/v10 v10.0.0 h1:38nkt3kSrBLnA7mm9Gg4S11X3wtWdbLv7laBZ8hzc5o= +github.com/cosmos/ibc-go/v10 v10.0.0/go.mod h1:82OVClziZQ+9EyDRrnlr2eewcewQ0cxLu7LAbF+q7mc= github.com/cosmos/ibc-go/v8 v8.7.0 h1:HqhVOkO8bDpClXE81DFQgFjroQcTvtpm0tCS7SQVKVY= github.com/cosmos/ibc-go/v8 v8.7.0/go.mod h1:G2z+Q6ZQSMcyHI2+BVcJdvfOupb09M2h/tgpXOEdY6k= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= @@ -441,8 +446,8 @@ github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6 github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= -github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= +github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= +github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -457,8 +462,9 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeC github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= +github.com/desertbit/timer v1.0.1 h1:yRpYNn5Vaaj6QXecdLMPMJsW81JLiI1eokUft5nBmeo= +github.com/desertbit/timer v1.0.1/go.mod h1:htRrYeY5V/t4iu1xCJ5XsQvp4xve8QulXXctAzxqcwE= github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= @@ -467,6 +473,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= +github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= @@ -483,8 +491,8 @@ github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:Htrtb github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY= -github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/dvsekhvalnov/jose2go v1.7.0 h1:bnQc8+GMnidJZA8zc6lLEAb4xNrIqHwO+9TzqvtQZPo= +github.com/dvsekhvalnov/jose2go v1.7.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= @@ -506,8 +514,8 @@ github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= @@ -522,18 +530,15 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= -github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= -github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/getsentry/sentry-go v0.28.1 h1:zzaSm/vHmGllRM6Tpx1492r0YDzauArdBfkJRtY6P5k= +github.com/getsentry/sentry-go v0.28.1/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= @@ -562,11 +567,8 @@ github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= @@ -574,13 +576,9 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= @@ -647,8 +645,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/flatbuffers v23.5.26+incompatible h1:M9dgRyhJemaM4Sw8+66GHBu8ioaQmyPLg1b8VwK5WJg= -github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v24.3.25+incompatible h1:CX395cjN9Kke9mmalRoL3d81AtFUxJM+yDthflgJGkI= +github.com/google/flatbuffers v24.3.25+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -756,8 +754,8 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4= github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -765,8 +763,8 @@ github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYS github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= -github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= +github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= +github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= @@ -796,8 +794,8 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU= -github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= +github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA= @@ -842,7 +840,6 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -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/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -880,7 +877,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -909,8 +905,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= @@ -934,11 +930,9 @@ github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iP github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -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/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= @@ -957,8 +951,8 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= +github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q= github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= @@ -1078,14 +1072,16 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= -github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= +github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shamaton/msgpack/v2 v2.2.0 h1:IP1m01pHwCrMa6ZccP9B3bqxEMKMSmMVAVKk54g3L/Y= +github.com/shamaton/msgpack/v2 v2.2.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -1170,7 +1166,6 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= @@ -1194,8 +1189,8 @@ github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo= -go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= +go.etcd.io/bbolt v1.4.0-alpha.1 h1:3yrqQzbRRPFPdOMWS/QQIVxVnzSkAZQYeWlZFv1kbj4= +go.etcd.io/bbolt v1.4.0-alpha.1/go.mod h1:S/Z/Nm3iuOnyO1W4XuFfPci51Gj6F1Hv0z8hisyYYOw= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1297,8 +1292,6 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= -golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1475,7 +1468,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1538,8 +1530,8 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= +golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1846,8 +1838,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= -google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1893,8 +1885,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= -nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= +nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml new file mode 100644 index 0000000..9c8ba0a --- /dev/null +++ b/proto/buf.gen.gogo.yaml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - name: gocosmos + out: .. + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types + - name: grpc-gateway + out: .. + opt: logtostderr=true,allow_colon_final_segments=true diff --git a/proto/buf.lock b/proto/buf.lock new file mode 100644 index 0000000..8b5ec2b --- /dev/null +++ b/proto/buf.lock @@ -0,0 +1,23 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: cosmos + repository: cosmos-proto + commit: 1935555c206d4afb9e94615dfd0fad31 + digest: shake256:c74d91a3ac7ae07d579e90eee33abf9b29664047ac8816500cf22c081fec0d72d62c89ce0bebafc1f6fec7aa5315be72606717740ca95007248425102c365377 + - remote: buf.build + owner: cosmos + repository: gogo-proto + commit: 5e5b9fdd01804356895f8f79a6f1ddc1 + digest: shake256:0b85da49e2e5f9ebc4806eae058e2f56096ff3b1c59d1fb7c190413dd15f45dd456f0b69ced9059341c80795d2b6c943de15b120a9e0308b499e43e4b5fc2952 + - remote: buf.build + owner: googleapis + repository: googleapis + commit: cc916c31859748a68fd229a3c8d7a2e8 + digest: shake256:469b049d0eb04203d5272062636c078decefc96fec69739159c25d85349c50c34c7706918a8b216c5c27f76939df48452148cff8c5c3ae77fa6ba5c25c1b8bf8 + - remote: buf.build + owner: persistence + repository: cosmos-sdk-lsm + commit: ac3de0dcbfbe4150b68e337f3063beed + digest: shake256:85111a50f8f3d210189e8b5c179c9883f2b94d99028814f9ebec0680b4f2bd365086c3fa1d8bb5990b35b316f1ac4854bfbcd3b954060f065025e94c21989ca5 diff --git a/proto/buf.yaml b/proto/buf.yaml new file mode 100644 index 0000000..30f7039 --- /dev/null +++ b/proto/buf.yaml @@ -0,0 +1,7 @@ +version: v1 +name: buf.build/persistence/pstake-native +deps: + - buf.build/cosmos/cosmos-proto + - buf.build/cosmos/gogo-proto + - buf.build/googleapis/googleapis + - buf.build/persistence/cosmos-sdk-lsm:v0.47.3-lsm diff --git a/proto/pstake/liquidstake/v1beta1/genesis.proto b/proto/pstake/liquidstake/v1beta1/genesis.proto new file mode 100644 index 0000000..e8222af --- /dev/null +++ b/proto/pstake/liquidstake/v1beta1/genesis.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package pstake.liquidstake.v1beta1; + +import "gogoproto/gogo.proto"; +import "pstake/liquidstake/v1beta1/liquidstake.proto"; + +option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; +option (gogoproto.equal_all) = true; + +// GenesisState defines the liquidstake module's genesis state. +message GenesisState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // params defines all the parameters for the liquidstake module + Params params = 1 [ (gogoproto.nullable) = false ]; + + repeated LiquidValidator liquid_validators = 2 + [ (gogoproto.nullable) = false ]; +} diff --git a/proto/pstake/liquidstake/v1beta1/liquidstake.proto b/proto/pstake/liquidstake/v1beta1/liquidstake.proto new file mode 100644 index 0000000..f81375e --- /dev/null +++ b/proto/pstake/liquidstake/v1beta1/liquidstake.proto @@ -0,0 +1,214 @@ +syntax = "proto3"; + +package pstake.liquidstake.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; + +// Params defines the set of params for the liquidstake module. +message Params { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // LiquidBondDenom specifies the denomination of the token receiving after + // liquid stake, The value is calculated through NetAmount. + string liquid_bond_denom = 1; + + // WhitelistedValidators specifies the validators elected to become Active + // Liquid Validators. + repeated WhitelistedValidator whitelisted_validators = 2 + [ (gogoproto.nullable) = false ]; + + // UnstakeFeeRate specifies the fee rate when liquid unstake is requested, + // unbonded by subtracting it from unbondingAmount + string unstake_fee_rate = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // LsmDisabled allows to block any msgs that convert staked tokens into + // stkXPRT through LSM. + bool lsm_disabled = 4; + + // MinLiquidStakingAmount specifies the minimum number of coins to be staked + // to the active liquid validators on liquid staking to minimize decimal loss + // and consider gas efficiency. + string min_liquid_stake_amount = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // CwLockedPoolAddress defines the bech32-encoded address of + // a CW smart-contract representing a time locked LP (e.g. Superfluid LP). + string cw_locked_pool_address = 6 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // FeeAccountAddress defines the bech32-encoded address of + // a an account responsible for accumulating protocol fees. + string fee_account_address = 7 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // AutocompoundFeeRate specifies the fee rate for auto redelegating the stake + // rewards. The fee is taken in favour of the fee account (see + // FeeAccountAddress). + string autocompound_fee_rate = 8 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // WhitelistAdminAddress the bech32-encoded address of an admin authority + // that is allowed to update whitelisted validators or pause liquidstaking + // module entirely. The key is controlled by an offchain process that is + // selecting validators based on a criteria. Pausing of the module can be + // required during important migrations or failures. + string whitelist_admin_address = 9 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // ModulePaused is a safety toggle that allows to stop main module functions + // such as stake/unstake/stake-to-lp and the BeginBlocker logic. + bool module_paused = 10; +} + +// ValidatorStatus enumerates the status of a liquid validator. +enum ValidatorStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // VALIDATOR_STATUS_UNSPECIFIED defines the unspecified invalid status. + VALIDATOR_STATUS_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = "ValidatorStatusUnspecified" ]; + // VALIDATOR_STATUS_ACTIVE defines the active, valid status + VALIDATOR_STATUS_ACTIVE = 1 + [ (gogoproto.enumvalue_customname) = "ValidatorStatusActive" ]; + // VALIDATOR_STATUS_INACTIVE defines the inactive, invalid status + VALIDATOR_STATUS_INACTIVE = 2 + [ (gogoproto.enumvalue_customname) = "ValidatorStatusInactive" ]; +} + +// WhitelistedValidator consists of the validator operator address and the +// target weight, which is a value for calculating the real weight to be derived +// according to the active status. +message WhitelistedValidator { + option (gogoproto.goproto_getters) = false; + + // validator_address defines the bech32-encoded address that whitelisted + // validator + string validator_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // target_weight specifies the target weight for liquid staking, unstaking + // amount, which is a value for calculating the real weight to be derived + // according to the active status + string target_weight = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +// LiquidValidator defines a Validator that can be the target of LiquidStaking +// and LiquidUnstaking, Active, Weight, etc. fields are derived as functions to +// deal with by maintaining consistency with the state of the staking module. +message LiquidValidator { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // operator_address defines the address of the validator's operator; bech + // encoded in JSON. + string operator_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} + +// LiquidValidatorState is type LiquidValidator with state added to return to +// query results. +message LiquidValidatorState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // operator_address defines the address of the validator's operator; bech + // encoded in JSON. + string operator_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // weight specifies the weight for liquid staking, unstaking amount + string weight = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // status is the liquid validator status + ValidatorStatus status = 3; + + // del_shares define the delegation shares of the validator + string del_shares = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // liquid_tokens define the token amount worth of delegation shares of the + // validator (slashing applied amount) + string liquid_tokens = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +// NetAmountState is type for net amount raw data and mint rate, This is a value +// that depends on the several module state every time, so it is used only for +// calculation and query and is not stored in kv. +message NetAmountState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = true; + + // mint_rate is stkXPRTTotalSupply / NetAmount + string mint_rate = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // btoken_total_supply returns the total supply of stk/uxprt (stkXPRT denom) + string stkxprt_total_supply = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // net_amount is proxy account's native token balance + total liquid tokens + + // total remaining rewards + total unbonding balance + string net_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // total_del_shares define the delegation shares of all liquid validators + string total_del_shares = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // total_liquid_tokens define the token amount worth of delegation shares of + // all liquid validator (slashing applied amount) + string total_liquid_tokens = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // total_remaining_rewards define the sum of remaining rewards of proxy + // account by all liquid validators + string total_remaining_rewards = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // total_unbonding_balance define the unbonding balance of proxy account by + // all liquid validator (slashing applied amount) + string total_unbonding_balance = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // proxy_acc_balance define the balance of proxy account for the native token + string proxy_acc_balance = 8 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/pstake/liquidstake/v1beta1/query.proto b/proto/pstake/liquidstake/v1beta1/query.proto new file mode 100644 index 0000000..9960909 --- /dev/null +++ b/proto/pstake/liquidstake/v1beta1/query.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; +package pstake.liquidstake.v1beta1; + +import "google/api/annotations.proto"; +import "pstake/liquidstake/v1beta1/liquidstake.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; + +// Query defines the gRPC query service for the liquidstake module. +service Query { + // Params returns parameters of the liquidstake module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/pstake/liquidstake/v1beta1/params"; + } + + // LiquidValidators returns liquid validators with states of the liquidstake + // module. + rpc LiquidValidators(QueryLiquidValidatorsRequest) + returns (QueryLiquidValidatorsResponse) { + option (google.api.http).get = "/pstake/liquidstake/v1beta1/validators"; + } + + // States returns states of the liquidstake module. + rpc States(QueryStatesRequest) returns (QueryStatesResponse) { + option (google.api.http).get = "/pstake/liquidstake/v1beta1/states"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryLiquidValidatorsRequest is the request type for the +// Query/LiquidValidators RPC method. +message QueryLiquidValidatorsRequest {} + +// QueryLiquidValidatorsResponse is the response type for the +// Query/LiquidValidators RPC method. +message QueryLiquidValidatorsResponse { + repeated LiquidValidatorState liquid_validators = 1 + [ (gogoproto.nullable) = false ]; +} + +// QueryStatesRequest is the request type for the Query/States RPC method. +message QueryStatesRequest {} + +// QueryStatesResponse is the response type for the Query/States RPC method. +message QueryStatesResponse { + NetAmountState net_amount_state = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/pstake/liquidstake/v1beta1/tx.proto b/proto/pstake/liquidstake/v1beta1/tx.proto new file mode 100644 index 0000000..d9215c1 --- /dev/null +++ b/proto/pstake/liquidstake/v1beta1/tx.proto @@ -0,0 +1,155 @@ +syntax = "proto3"; +package pstake.liquidstake.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/msg/v1/msg.proto"; +import "google/protobuf/timestamp.proto"; +import "pstake/liquidstake/v1beta1/liquidstake.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; + +// Msg defines the liquid staking Msg service. +service Msg { + // LiquidStake defines a method for performing a delegation of coins + // from a delegator to whitelisted validators. + rpc LiquidStake(MsgLiquidStake) returns (MsgLiquidStakeResponse); + + // LiquidUnstake defines a method for performing an undelegation of liquid + // staking from a delegate. + rpc LiquidUnstake(MsgLiquidUnstake) returns (MsgLiquidUnstakeResponse); + + // StakeToLP defines a method for LSM-transfer of staked XPRT + // into stkXPRT with locking into an LP. + rpc StakeToLP(MsgStakeToLP) returns (MsgStakeToLPResponse); + + // UpdateParams defines a method to update the module params. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // UpdateWhitelistedValidators defines a method to update the whitelisted + // validators list. + rpc UpdateWhitelistedValidators(MsgUpdateWhitelistedValidators) + returns (MsgUpdateWhitelistedValidatorsResponse); + + // SetModulePaused defines a method to update the module's pause status, + // setting value of the safety flag in params. + rpc SetModulePaused(MsgSetModulePaused) returns (MsgSetModulePausedResponse); +} + +// MsgLiquidStake defines a SDK message for performing a liquid stake of coins +// from a delegator to whitelisted validators. +message MsgLiquidStake { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "delegator_address"; + option (amino.name) = "liquidstake/MsgLiquidStake"; + + string delegator_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + cosmos.base.v1beta1.Coin amount = 2 [ (gogoproto.nullable) = false ]; +} + +// MsgLiquidStakeResponse defines the MsgLiquidStake response type. +message MsgLiquidStakeResponse {} + +// MsgStakeToLP defines a SDK message for performing an LSM-transfer of staked +// XPRT into stkXPRT with locking into an LP. +message MsgStakeToLP { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (amino.name) = "liquidstake/MsgStakeToLP"; + option (cosmos.msg.v1.signer) = "delegator_address"; + + string delegator_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + string validator_address = 2 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + cosmos.base.v1beta1.Coin staked_amount = 3 [ (gogoproto.nullable) = false ]; + cosmos.base.v1beta1.Coin liquid_amount = 4 [ (gogoproto.nullable) = false ]; +} + +// MsgStakeToLPResponse defines the MsgStakeToLP response type. +message MsgStakeToLPResponse {} + +// MsgLiquidUnstake defines a SDK message for performing an undelegation of +// liquid staking from a delegate. +message MsgLiquidUnstake { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (amino.name) = "liquidstake/MsgLiquidUnstake"; + option (cosmos.msg.v1.signer) = "delegator_address"; + + string delegator_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + cosmos.base.v1beta1.Coin amount = 2 [ (gogoproto.nullable) = false ]; +} + +// MsgLiquidUnstakeResponse defines the MsgLiquidUnstake response type. +message MsgLiquidUnstakeResponse { + google.protobuf.Timestamp completion_time = 1 + [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; +} + +message MsgUpdateParams { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (amino.name) = "liquidstake/MsgUpdateParams"; + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // params defines the parameters to update. + // + // NOTE: denom and whitelisted validators are not updated. + // + Params params = 2 [ (gogoproto.nullable) = false ]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +message MsgUpdateParamsResponse {} + +message MsgUpdateWhitelistedValidators { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (amino.name) = "liquidstake/MsgUpdateWhitelistedValidators"; + option (cosmos.msg.v1.signer) = "authority"; + + // Authority is the address that is allowed to update whitelisted validators, + // defined as admin address in params (WhitelistAdminAddress). + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // WhitelistedValidators specifies the validators elected to become Active + // Liquid Validators. + repeated WhitelistedValidator whitelisted_validators = 2 + [ (gogoproto.nullable) = false ]; +} + +// MsgUpdateWhitelistedValidatorsResponse defines the response structure for +// executing a +message MsgUpdateWhitelistedValidatorsResponse {} + +message MsgSetModulePaused { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (amino.name) = "liquidstake/MsgSetModulePaused"; + option (cosmos.msg.v1.signer) = "authority"; + + // Authority is the address that is allowed to update module's paused state, + // defined as admin address in params (WhitelistAdminAddress). + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // IsPaused represents the target state of the paused flag. + bool is_paused = 2; +} + +// MsgSetModulePausedResponse defines the response structure for +// executing a +message MsgSetModulePausedResponse {} diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh new file mode 100644 index 0000000..4ab35d8 --- /dev/null +++ b/scripts/protocgen.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -eo pipefail + +echo "Generating gogo proto code" +cd proto + +buf generate --template buf.gen.gogo.yaml $file + +cd .. + +# move proto files to the right places +cp -r github.com/persistenceOne/pstake-native/v*/* ./ +rm -rf github.com + +go mod tidy diff --git a/x/liquidstake/abci.go b/x/liquidstake/abci.go new file mode 100644 index 0000000..9ffc03d --- /dev/null +++ b/x/liquidstake/abci.go @@ -0,0 +1,20 @@ +package liquidstake + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +func BeginBlock(ctx sdk.Context, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + if !k.GetParams(ctx).ModulePaused { + // return value of UpdateLiquidValidatorSet is useful only in testing + _ = k.UpdateLiquidValidatorSet(ctx, false) + } +} diff --git a/x/liquidstake/client/cli/query.go b/x/liquidstake/client/cli/query.go new file mode 100644 index 0000000..015c436 --- /dev/null +++ b/x/liquidstake/client/cli/query.go @@ -0,0 +1,155 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +// GetQueryCmd returns a root CLI command handler for all x/liquidstake query commands. +func GetQueryCmd() *cobra.Command { + liquidValidatorQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Aliases: []string{"ls"}, + Short: "Querying commands for the liquidstake module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + liquidValidatorQueryCmd.AddCommand( + GetCmdQueryParams(), + GetCmdQueryLiquidValidators(), + GetCmdQueryStates(), + ) + + return liquidValidatorQueryCmd +} + +// GetCmdQueryParams implements the params query command. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Args: cobra.NoArgs, + Short: "Query the values set as liquidstake parameters", + Long: strings.TrimSpace( + fmt.Sprintf(`Query values set as liquidstake parameters. + +Example: +$ %s query %s params +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Params( + cmd.Context(), + &types.QueryParamsRequest{}, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryLiquidValidators implements the query liquidValidators command. +func GetCmdQueryLiquidValidators() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquid-validators", + Args: cobra.NoArgs, + Short: "Query all liquid validators", + Long: strings.TrimSpace( + fmt.Sprintf(`Queries all liquid validators. + +Example: +$ %s query %s liquid-validators +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + if err != nil { + return err + } + + res, err := queryClient.LiquidValidators( + cmd.Context(), + &types.QueryLiquidValidatorsRequest{}, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryStates implements the query states command. +func GetCmdQueryStates() *cobra.Command { + cmd := &cobra.Command{ + Use: "states", + Args: cobra.NoArgs, + Short: "Query states", + Long: strings.TrimSpace( + fmt.Sprintf(`Queries states about net amount, mint rate. + +Example: +$ %s query %s states +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.States( + cmd.Context(), + &types.QueryStatesRequest{}, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/liquidstake/client/cli/tx.go b/x/liquidstake/client/cli/tx.go new file mode 100644 index 0000000..c2cc026 --- /dev/null +++ b/x/liquidstake/client/cli/tx.go @@ -0,0 +1,333 @@ +package cli + +// DONTCOVER +// client is excluded from test coverage in MVP version + +import ( + "encoding/json" + "fmt" + "os" + "strings" + + "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/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +// GetTxCmd returns a root CLI command handler for all x/liquidstake transaction commands. +func GetTxCmd() *cobra.Command { + liquidstakeTxCmd := &cobra.Command{ + Use: types.ModuleName, + Aliases: []string{"ls"}, + Short: "XPRT liquid stake transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + liquidstakeTxCmd.AddCommand( + NewLiquidStakeCmd(), + NewStakeToLPCmd(), + NewLiquidUnstakeCmd(), + NewUpdateParamsCmd(), + NewUpdateWhitelistedValidatorsCmd(), + NewSetModulePausedCmd(), + ) + + return liquidstakeTxCmd +} + +// NewLiquidStakeCmd implements the liquid stake XPRT command handler. +func NewLiquidStakeCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquid-stake [amount]", + Args: cobra.ExactArgs(1), + Short: "Liquid-stake XPRT", + Long: strings.TrimSpace( + fmt.Sprintf(`Liquid-stake XPRT. + +Example: +$ %s tx %s liquid-stake 1000uxprt --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + liquidStaker := clientCtx.GetFromAddress() + + stakingCoin, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgLiquidStake(liquidStaker, stakingCoin) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewStakeToLPCmd implements the liquid stake XPRT command handler. +func NewStakeToLPCmd() *cobra.Command { + bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() + + cmd := &cobra.Command{ + Use: "stake-to-lp [validator-addr] [staked_amount] [liquid_amount]", + Args: cobra.RangeArgs(2, 3), + Short: "Convert delegation into stkXPRT and lock into LP.", + Long: strings.TrimSpace( + fmt.Sprintf(`Convert delegation into stkXPRT and lock into LP. +Allows to specify both staked and non-staked XPRT amounts to convert into stkXPRT and lock into LP. + +Examples: +$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000uxprt --from mykey +$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000uxprt 5000uxprt --from mykey +`, + version.AppName, types.ModuleName, bech32PrefixValAddr, + version.AppName, types.ModuleName, bech32PrefixValAddr, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + liquidStaker := clientCtx.GetFromAddress() + + valAddr, err := sdk.ValAddressFromBech32(args[0]) + if err != nil { + return err + } + + stakedCoin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + var liquidCoin sdk.Coin + if len(args) > 2 { + liquidCoin, err = sdk.ParseCoinNormalized(args[2]) + if err != nil { + return err + } + } + + msg := types.NewMsgStakeToLP(liquidStaker, valAddr, stakedCoin, liquidCoin) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewLiquidUnstakeCmd implements the liquid unstake XPRT command handler. +func NewLiquidUnstakeCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquid-unstake [amount]", + Args: cobra.ExactArgs(1), + Short: "Liquid-unstake stkXPRT", + Long: strings.TrimSpace( + fmt.Sprintf(`Liquid-unstake stkXPRT. + +Example: +$ %s tx %s liquid-unstake 500stk/uxprt --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + liquidStaker := clientCtx.GetFromAddress() + + unstakingCoin, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgLiquidUnstake(liquidStaker, unstakingCoin) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewUpdateParamsCmd implements the params update command handler. +func NewUpdateParamsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-params [params.json]", + Args: cobra.ExactArgs(1), + Short: "Update-params of liquidstake module.", + Long: strings.TrimSpace( + fmt.Sprintf(`update-params param-file. + +Example: +$ %s tx %s update-params ~/params.json --from mykey + +Example params.json +{ + "liquid_bond_denom": "stk/uxprt", + "whitelisted_validators": [ + { + "validator_address": "persistencevaloper1hcqg5wj9t42zawqkqucs7la85ffyv08lmnhye9", + "target_weight": "10" + } + ], + "lsm_disabled": false, + "unstake_fee_rate": "0.000000000000000000", + "min_liquid_staking_amount": "10000", + "min_liquid_staking_amount": "10000", + "cw_locked_pool_address": "persistence14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjvz4fk" +} +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + var params types.Params + + paramsInFile, err := os.ReadFile(args[0]) + if err != nil { + return err + } + + err = json.Unmarshal(paramsInFile, ¶ms) + if err != nil { + return err + } + authority := clientCtx.GetFromAddress() + + msg := types.NewMsgUpdateParams(authority, params) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewUpdateWhitelistedValidatorsCmd implements the update of whitelisted validators command handler. +func NewUpdateWhitelistedValidatorsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-whitelisted-validators [validators_list.json]", + Args: cobra.ExactArgs(1), + Short: "Update whitelisted validators in params of liquidstake module.", + Long: strings.TrimSpace( + fmt.Sprintf(`update-whitelisted-validators validators_list.json + +Example: +$ %s tx %s update-whitelisted-validators ~/validators_list.json --from mykey + +Example validators_list.json +[ + { + "validator_address": "persistencevaloper1hcqg5wj9t42zawqkqucs7la85ffyv08lmnhye9", + "target_weight": "10" + } +] +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + var validatorsList []types.WhitelistedValidator + + validatorsListFile, err := os.ReadFile(args[0]) + if err != nil { + return err + } + + err = json.Unmarshal(validatorsListFile, &validatorsList) + if err != nil { + return err + } + authority := clientCtx.GetFromAddress() + + msg := types.NewMsgUpdateWhitelistedValidators(authority, validatorsList) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewSetModulePausedCmd implements the command handler for updating of safety toggle that disables the module. +func NewSetModulePausedCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "pause-module [flag]", + Args: cobra.ExactArgs(1), + Short: "Pause or unpause the liquidstake module for an emergency updates.", + Long: strings.TrimSpace( + fmt.Sprintf(`pause-module [true/false] + +Example: +$ %s tx %s pause-module true --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + isPaused := false + if strings.ToLower(args[0]) == "true" { + isPaused = true + } else if strings.ToLower(args[0]) != "false" { + err := fmt.Errorf("expected flag to be true or false – where 'true' means the module is paused") + return err + } + + authority := clientCtx.GetFromAddress() + msg := types.NewMsgSetModulePaused(authority, isPaused) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/liquidstake/keeper/genesis.go b/x/liquidstake/keeper/genesis.go new file mode 100644 index 0000000..f03028b --- /dev/null +++ b/x/liquidstake/keeper/genesis.go @@ -0,0 +1,47 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +// InitGenesis initializes the liquidstake module's state from a given genesis state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + if err := types.ValidateGenesis(genState); err != nil { + panic(err) + } + + // init to prevent nil slice, []types.WhitelistedValidator(nil) + if genState.Params.WhitelistedValidators == nil || len(genState.Params.WhitelistedValidators) == 0 { + genState.Params.WhitelistedValidators = []types.WhitelistedValidator{} + } + + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } + + for _, lv := range genState.LiquidValidators { + k.SetLiquidValidator(ctx, lv) + } + + moduleAcc := k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) + if moduleAcc == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } +} + +// ExportGenesis returns the liquidstake module's genesis state. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + params := k.GetParams(ctx) + + // init to prevent nil slice, []types.WhitelistedValidator(nil) + if params.WhitelistedValidators == nil || len(params.WhitelistedValidators) == 0 { + params.WhitelistedValidators = []types.WhitelistedValidator{} + } + + liquidValidators := k.GetAllLiquidValidators(ctx) + return types.NewGenesisState(params, liquidValidators) +} diff --git a/x/liquidstake/keeper/grpc_query.go b/x/liquidstake/keeper/grpc_query.go new file mode 100644 index 0000000..fd92f2d --- /dev/null +++ b/x/liquidstake/keeper/grpc_query.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +// Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper. +type Querier struct { + Keeper +} + +var _ types.QueryServer = Querier{} + +// Params queries the parameters of the liquidstake module. +func (k Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + params := k.GetParams(ctx) + + return &types.QueryParamsResponse{Params: params}, nil +} + +// LiquidValidators queries all liquid validators. +func (k Querier) LiquidValidators(c context.Context, req *types.QueryLiquidValidatorsRequest) (*types.QueryLiquidValidatorsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryLiquidValidatorsResponse{LiquidValidators: k.GetAllLiquidValidatorStates(ctx)}, nil +} + +// States queries states of liquid stake module. +func (k Querier) States(c context.Context, req *types.QueryStatesRequest) (*types.QueryStatesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryStatesResponse{NetAmountState: k.GetNetAmountState(ctx)}, nil +} diff --git a/x/liquidstake/keeper/hooks.go b/x/liquidstake/keeper/hooks.go new file mode 100644 index 0000000..6d5ec22 --- /dev/null +++ b/x/liquidstake/keeper/hooks.go @@ -0,0 +1,45 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + // TODO: replace it with local cosmos sdk epoch hooks + // epochstypes "github.com/persistenceOne/persistence-sdk/v2/x/epochs/types" + + liquidstake "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +type EpochHooks struct { + k Keeper +} + +// TODO: replace it with local cosmos sdk epoch hooks +// var _ epochstypes.EpochHooks = EpochHooks{} + +func (k Keeper) EpochHooks() EpochHooks { + return EpochHooks{k} +} + +func (h EpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + return h.k.BeforeEpochStart(ctx, epochIdentifier, epochNumber) +} + +func (h EpochHooks) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error { + // Nothing to do + return nil +} + +func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, _ int64) error { + if !k.GetParams(ctx).ModulePaused { + // Update the liquid validator set at the start of each epoch + if epochIdentifier == liquidstake.AutocompoundEpoch { + k.AutocompoundStakingRewards(ctx, liquidstake.GetWhitelistedValsMap(k.GetParams(ctx).WhitelistedValidators)) + } + + if epochIdentifier == liquidstake.RebalanceEpoch { + // return value of UpdateLiquidValidatorSet is useful only in testing + _ = k.UpdateLiquidValidatorSet(ctx, true) + } + } + + return nil +} diff --git a/x/liquidstake/keeper/keeper.go b/x/liquidstake/keeper/keeper.go new file mode 100644 index 0000000..8d0815a --- /dev/null +++ b/x/liquidstake/keeper/keeper.go @@ -0,0 +1,100 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +// Keeper of the liquidstake store +type Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + stakingKeeper types.StakingKeeper + mintKeeper types.MintKeeper + distrKeeper types.DistrKeeper + slashingKeeper types.SlashingKeeper + + router *baseapp.MsgServiceRouter + authority string +} + +// NewKeeper returns a liquidstake keeper. +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + stakingKeeper types.StakingKeeper, + mintKeeper types.MintKeeper, + distrKeeper types.DistrKeeper, + slashingKeeper types.SlashingKeeper, + router *baseapp.MsgServiceRouter, + authority string, +) Keeper { + // ensure liquidstake module account is set + if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } + + return Keeper{ + cdc: cdc, + storeKey: storeKey, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + stakingKeeper: stakingKeeper, + mintKeeper: mintKeeper, + distrKeeper: distrKeeper, + slashingKeeper: slashingKeeper, + router: router, + authority: authority, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +// SetParams sets the auth module's parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + if err := params.Validate(); err != nil { + return err + } + + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) + + return nil +} + +// GetParams gets the auth module's parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +// GetCodec return codec.Codec object used by the keeper +func (k Keeper) GetCodec() codec.BinaryCodec { return k.cdc } + +// Router returns the keeper's msg router +func (k Keeper) Router() *baseapp.MsgServiceRouter { + return k.router +} diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go new file mode 100644 index 0000000..c1aa483 --- /dev/null +++ b/x/liquidstake/keeper/liquidstake.go @@ -0,0 +1,1147 @@ +package keeper + +import ( + "encoding/json" + "sort" + "time" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +func (k Keeper) LiquidBondDenom(ctx sdk.Context) string { + return k.GetParams(ctx).LiquidBondDenom +} + +// GetNetAmountState calculates the sum of bondedDenom balance, total delegation tokens(slash applied LiquidTokens), total remaining reward of types.LiquidStakeProxyAcc +// During liquid unstaking, stkxprt immediately burns and the unbonding queue belongs to the requester, so the liquid staker's unbonding values are excluded on netAmount +// It is used only for calculation and query and is not stored in kv. +func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas types.NetAmountState) { + totalRemainingRewards, totalDelShares, totalLiquidTokens := k.CheckDelegationStates(ctx, types.LiquidStakeProxyAcc) + + totalUnbondingBalance := math.ZeroInt() + ubds := k.stakingKeeper.GetAllUnbondingDelegations(ctx, types.LiquidStakeProxyAcc) + for _, ubd := range ubds { + for _, entry := range ubd.Entries { + // use Balance(slashing applied) not InitialBalance(without slashing) + totalUnbondingBalance = totalUnbondingBalance.Add(entry.Balance) + } + } + + nas = types.NetAmountState{ + StkxprtTotalSupply: k.bankKeeper.GetSupply(ctx, k.LiquidBondDenom(ctx)).Amount, + TotalDelShares: totalDelShares, + TotalLiquidTokens: totalLiquidTokens, + TotalRemainingRewards: totalRemainingRewards, + TotalUnbondingBalance: totalUnbondingBalance, + ProxyAccBalance: k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc).Amount, + } + + nas.NetAmount = nas.CalcNetAmount() + nas.MintRate = nas.CalcMintRate() + return +} + +// LiquidStake mints stkXPRT worth of staking coin value according to NetAmount and performs LiquidDelegate. +func (k Keeper) LiquidStake( + ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, stakingCoin sdk.Coin, +) (stkXPRTMintAmount math.Int, err error) { + params := k.GetParams(ctx) + + if params.ModulePaused { + return math.ZeroInt(), types.ErrModulePaused + } + + // check minimum liquid stake amount + if stakingCoin.Amount.LT(params.MinLiquidStakeAmount) { + return math.ZeroInt(), types.ErrLessThanMinLiquidStakeAmount + } + + // check bond denomination + bondDenom := k.stakingKeeper.BondDenom(ctx) + if stakingCoin.Denom != bondDenom { + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidBondDenom, "invalid coin denomination: got %s, expected %s", stakingCoin.Denom, bondDenom, + ) + } + + whitelistedValsMap := types.GetWhitelistedValsMap(params.WhitelistedValidators) + activeVals := k.GetActiveLiquidValidators(ctx, whitelistedValsMap) + + if activeVals.Len() == 0 { + return math.ZeroInt(), types.ErrActiveLiquidValidatorsNotExists + } + + totalActiveWeight := activeVals.TotalWeight(whitelistedValsMap) + activeWeightQuorum := math.LegacyNewDecFromInt(totalActiveWeight).Quo( + math.LegacyNewDecFromInt(types.TotalValidatorWeight), + ) + if activeWeightQuorum.LT(types.ActiveLiquidValidatorsWeightQuorum) { + k.Logger(ctx).Error( + "active liquid validators weight quorum not reached", + types.ActiveWeightQuorumKeyVal, + activeWeightQuorum.String(), + types.MinActiveWeightQuorumKeyVal, + types.ActiveLiquidValidatorsWeightQuorum.String(), + ) + + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrActiveLiquidValidatorsWeightQuorumNotReached, "%s < %s", + activeWeightQuorum.String(), types.ActiveLiquidValidatorsWeightQuorum.String(), + ) + } + + // NetAmount must be calculated before send + nas := k.GetNetAmountState(ctx) + + // send staking coin to liquid stake proxy account to proxy delegation, need sufficient spendable balances + err = k.bankKeeper.SendCoins(ctx, liquidStaker, proxyAcc, sdk.NewCoins(stakingCoin)) + if err != nil { + return math.ZeroInt(), err + } + + // mint stkxprt, MintAmount = TotalSupply * StakeAmount/NetAmount + liquidBondDenom := k.LiquidBondDenom(ctx) + stkXPRTMintAmount = stakingCoin.Amount + + if nas.StkxprtTotalSupply.IsPositive() { + if nas.NetAmount.IsZero() { + // this case must not be reachable, consider stopping module for investigation + // c_value -> inf + k.Logger(ctx).Error( + "infinite c value", + types.NetAmountStateKeyVal, + nas.String(), + ) + + return math.ZeroInt(), types.ErrInsufficientProxyAccBalance + } + + stkXPRTMintAmount = types.NativeTokenToStkXPRT(stakingCoin.Amount, nas.StkxprtTotalSupply, nas.NetAmount) + } + + if !stkXPRTMintAmount.IsPositive() { + return math.ZeroInt(), types.ErrTooSmallLiquidStakeAmount + } + + // mint on module acc and send + mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, stkXPRTMintAmount)) + err = k.bankKeeper.MintCoins(ctx, types.ModuleName, mintCoin) + if err != nil { + return stkXPRTMintAmount, err + } + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, liquidStaker, mintCoin) + if err != nil { + k.Logger(ctx).Error( + "failed to send minted coins to liquid staker", + types.ErrorKeyVal, + err, + ) + + return stkXPRTMintAmount, err + } + + err = k.LiquidDelegate(ctx, proxyAcc, activeVals, stakingCoin.Amount, whitelistedValsMap) + return stkXPRTMintAmount, err +} + +// LockOnLP sends tokens to a CW contract (Superfluid LP) with time locking. +// It performs a CosmWasm execution through global message handler and may fail. +// Emits events on a successful call. +func (k Keeper) LockOnLP(ctx sdk.Context, delegator sdk.AccAddress, amount sdk.Coin) ([]*codectypes.Any, error) { + params := k.GetParams(ctx) + + if len(params.CwLockedPoolAddress) == 0 { + return nil, types.ErrNoLPContractAddress + } else if amount.Denom != params.LiquidBondDenom { + return nil, types.ErrInvalidDenom.Wrapf("cannot lock any denom on LP except liquid bond denom: %s", params.LiquidBondDenom) + } + + msg := &LockLstAssetMsg{ + Asset: Asset{ + Amount: amount.Amount.String(), + Info: AssetInfo{ + NativeToken: NativeTokenInfo{ + Denom: amount.Denom, + }, + }, + }, + } + + callData, err := json.Marshal(&ExecMsg{ + LockLstAsset: msg, + }) + if err != nil { + panic("failed to marshal CW contract call LockLstAsset") + } + + cwMsg := &wasmtypes.MsgExecuteContract{ + Sender: delegator.String(), + Contract: k.GetParams(ctx).CwLockedPoolAddress, + Msg: wasmtypes.RawContractMessage(callData), + Funds: sdk.NewCoins(amount), + } + + handler := k.router.Handler(cwMsg) + if handler == nil { + k.Logger(ctx).Error("failed to find CW contract handler") + + return nil, sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(cwMsg)) + } + + msgResp, err := handler(ctx, cwMsg) + if err != nil { + k.Logger(ctx).Error( + "failed to execute CW contract message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + cwMsg.String(), + ) + + return nil, types.ErrLPContract.Wrapf("error: %s, message %v", err.Error(), cwMsg) + } + + // emit the events from the dispatched actions + ctx.EventManager().EmitEvents(msgResp.GetEvents()) + + return msgResp.MsgResponses, nil +} + +type ExecMsg struct { + LockLstAsset *LockLstAssetMsg `json:"lock_lst_asset,omitempty"` +} + +type LockLstAssetMsg struct { + Asset Asset `json:"asset"` +} + +type Asset struct { + Amount string `json:"amount"` + Info AssetInfo `json:"info"` +} + +type AssetInfo struct { + NativeToken NativeTokenInfo `json:"native_token"` +} + +type NativeTokenInfo struct { + Denom string `json:"denom"` +} + +// DelegateWithCap is a wrapper to invoke stakingKeeper.Delegate but account for +// the amount of liquid staked shares and check against liquid staking cap. +func (k Keeper) DelegateWithCap( + ctx sdk.Context, + delegatorAddress sdk.AccAddress, + validator stakingtypes.Validator, + bondAmt math.Int, +) error { + msgDelegate := &stakingtypes.MsgDelegate{ + DelegatorAddress: delegatorAddress.String(), + ValidatorAddress: validator.OperatorAddress, + Amount: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), bondAmt), + } + handler := k.router.Handler(msgDelegate) + if handler == nil { + k.Logger(ctx).Error("failed to find delegate handler") + + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s", sdk.MsgTypeURL(msgDelegate)) + } + res, err := handler(ctx, msgDelegate) + if err != nil { + k.Logger(ctx).Error( + "failed to execute delegate msg", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + msgDelegate.String(), + ) + + return errorsmod.Wrapf(types.ErrDelegationFailed, "failed to send delegate msg with err: %v", err) + } + ctx.EventManager().EmitEvents(res.GetEvents()) + + if len(res.MsgResponses) != 1 { + return errorsmod.Wrapf( + types.ErrInvalidResponse, + "expected msg response should be exactly 1, got: %v, responses: %v", + len(res.MsgResponses), res.MsgResponses, + ) + } + + var msgDelegateResponse stakingtypes.MsgDelegateResponse + if err = k.cdc.Unmarshal(res.MsgResponses[0].Value, &msgDelegateResponse); err != nil { + return errorsmod.Wrapf( + sdkerrors.ErrJSONUnmarshal, + "cannot unmarshal delegate tx response message: %v", + err, + ) + } + + return nil +} + +// UnbondWithCap is a wrapper to invoke stakingKeeper.Unbond but updates +// the total liquid staked tokens. +func (k Keeper) UnbondWithCap( + ctx sdk.Context, + delegatorAddress sdk.AccAddress, + validatorAddress sdk.ValAddress, + amount sdk.Coin, + userAddress sdk.AccAddress, +) (math.Int, error) { + // perform an LSM tokenize->bank send->redeem flow: moving delegation from proxyAcc onto user's account + lsmTokenizeMsg := &stakingtypes.MsgTokenizeShares{ + DelegatorAddress: delegatorAddress.String(), + ValidatorAddress: validatorAddress.String(), + Amount: amount, + TokenizedShareOwner: userAddress.String(), + } + + handler := k.router.Handler(lsmTokenizeMsg) + if handler == nil { + k.Logger(ctx).Error("failed to find tokenize handler") + + return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmTokenizeMsg)) + } + + // [1] tokenize delegation into LSM shares + msgResp, err := handler(ctx, lsmTokenizeMsg) + if err != nil { + k.Logger(ctx).Error( + "failed to execute tokenize shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmTokenizeMsg.String(), + ) + + return math.ZeroInt(), types.ErrLSMTokenizeFailed.Wrapf("error: %s; message: %v", err.Error(), lsmTokenizeMsg) + } + ctx.EventManager().EmitEvents(msgResp.GetEvents()) + + if len(msgResp.MsgResponses) != 1 { + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidResponse, + "expected msg response should be exactly 1, got: %v, responses: %v", + len(msgResp.MsgResponses), msgResp.MsgResponses, + ) + } + + var lsmTokenizeResp stakingtypes.MsgTokenizeSharesResponse + if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmTokenizeResp); err != nil { + return math.ZeroInt(), errorsmod.Wrapf( + sdkerrors.ErrJSONUnmarshal, + "cannot unmarshal tokenize share tx response message: %v", + err, + ) + } + + // [2] send LSM shares to proxyAcc + err = k.bankKeeper.SendCoins(ctx, delegatorAddress, userAddress, sdk.NewCoins(lsmTokenizeResp.Amount)) + if err != nil { + return math.ZeroInt(), err + } + + lsmRedeemMsg := &stakingtypes.MsgRedeemTokensForShares{ + DelegatorAddress: userAddress.String(), + Amount: lsmTokenizeResp.Amount, + } + + handler = k.router.Handler(lsmRedeemMsg) + if handler == nil { + k.Logger(ctx).Error("failed to find redeem handler") + return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmRedeemMsg)) + } + + // [3] redeem LSM shares from proxyAcc, to obtain a delegation + msgResp, err = handler(ctx, lsmRedeemMsg) + if err != nil { + k.Logger(ctx).Error( + "failed to execute redeem tokens for shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmRedeemMsg.String(), + ) + + return math.ZeroInt(), types.ErrLSMRedeemFailed.Wrapf("error: %s; message: %v", err.Error(), lsmRedeemMsg) + } + ctx.EventManager().EmitEvents(msgResp.GetEvents()) + + if len(msgResp.MsgResponses) != 1 { + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidResponse, + "expected msg response should be exactly 1, got: %v, responses: %v", + len(msgResp.MsgResponses), msgResp.MsgResponses, + ) + } + + var lsmRedeemResp stakingtypes.MsgRedeemTokensForSharesResponse + if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmRedeemResp); err != nil { + return math.ZeroInt(), errorsmod.Wrapf( + sdkerrors.ErrJSONUnmarshal, + "cannot unmarshal redeem tokens for shares tx response message: %v", + err, + ) + } + + // [4] unstake from user's account. + unstakeMsg := &stakingtypes.MsgUndelegate{ + DelegatorAddress: userAddress.String(), + ValidatorAddress: validatorAddress.String(), + Amount: lsmRedeemResp.Amount, + } + + handler = k.router.Handler(unstakeMsg) + if handler == nil { + k.Logger(ctx).Error("failed to find undelegate handler") + + return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(unstakeMsg)) + } + + msgResp, err = handler(ctx, unstakeMsg) + if err != nil { + k.Logger(ctx).Error( + "failed to execute undelegate message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + unstakeMsg.String(), + ) + + return math.ZeroInt(), types.ErrUnstakeFailed.Wrapf("error: %s; message: %v", err.Error(), unstakeMsg) + } + ctx.EventManager().EmitEvents(msgResp.GetEvents()) + + if len(msgResp.MsgResponses) != 1 { + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidResponse, + "expected msg response should be exactly 1, got: %v, responses: %v", + len(msgResp.MsgResponses), msgResp.MsgResponses, + ) + } + + var msgUndelegateResp stakingtypes.MsgUndelegateResponse + if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &msgUndelegateResp); err != nil { + return math.ZeroInt(), errorsmod.Wrapf( + sdkerrors.ErrJSONUnmarshal, + "cannot unmarshal msg undelegate tx response message: %v", + err, + ) + } + + return lsmRedeemResp.Amount.Amount, nil +} + +// RedelegateWithCap is a wrapper to invoke stakingKeeper.Redelegate but account for +// the amount of liquid staked shares and check against liquid staking cap. +func (k Keeper) RedelegateWithCap( + ctx sdk.Context, + delegatorAddress sdk.AccAddress, + validatorSrc sdk.ValAddress, + validatorDst sdk.ValAddress, + bondAmt math.Int, +) (time.Time, error) { + msgRedelegate := &stakingtypes.MsgBeginRedelegate{ + DelegatorAddress: delegatorAddress.String(), + ValidatorSrcAddress: validatorSrc.String(), + ValidatorDstAddress: validatorDst.String(), + Amount: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), bondAmt), + } + handler := k.router.Handler(msgRedelegate) + if handler == nil { + k.Logger(ctx).Error("failed to find redelegate handler") + + return time.Time{}, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s", sdk.MsgTypeURL(msgRedelegate)) + } + res, err := handler(ctx, msgRedelegate) + if err != nil { + k.Logger(ctx).Error( + "failed to execute redelegate msg", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + msgRedelegate.String(), + ) + + return time.Time{}, errorsmod.Wrapf(types.ErrRedelegateFailed, "failed to send redelegate msg with err: %v", err) + } + ctx.EventManager().EmitEvents(res.GetEvents()) + + if len(res.MsgResponses) != 1 { + return time.Time{}, errorsmod.Wrapf( + types.ErrInvalidResponse, + "expected msg response should be exactly 1, got: %v, responses: %v", + len(res.MsgResponses), res.MsgResponses, + ) + } + + var msgRedelegateResponse stakingtypes.MsgBeginRedelegateResponse + if err = k.cdc.Unmarshal(res.MsgResponses[0].Value, &msgRedelegateResponse); err != nil { + return time.Time{}, errorsmod.Wrapf( + sdkerrors.ErrJSONUnmarshal, + "cannot unmarshal redelegate tx response message: %v", + err, + ) + } + + return msgRedelegateResponse.CompletionTime, nil +} + +// LSMDelegate captures a staked amount from existing delegation using LSM, re-stakes from proxyAcc and +// mints stkXPRT worth of stk coin value according to NetAmount and performs LiquidDelegate. +func (k Keeper) LSMDelegate( + ctx sdk.Context, + delegator sdk.AccAddress, + validator sdk.ValAddress, + proxyAcc sdk.AccAddress, + preLsmStake sdk.Coin, +) (stkXPRTMintAmount math.Int, err error) { + params := k.GetParams(ctx) + + if params.ModulePaused { + return math.ZeroInt(), types.ErrModulePaused + } else if params.LsmDisabled { + return math.ZeroInt(), types.ErrDisabledLSM + } + + // check minimum liquid stake amount + if preLsmStake.Amount.LT(params.MinLiquidStakeAmount) { + return math.ZeroInt(), types.ErrLessThanMinLiquidStakeAmount + } + + // check bond denomination + bondDenom := k.stakingKeeper.BondDenom(ctx) + if preLsmStake.Denom != bondDenom { + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidBondDenom, "invalid coin denomination: got %s, expected %s", preLsmStake.Denom, bondDenom, + ) + } + + whitelistedValsMap := types.GetWhitelistedValsMap(params.WhitelistedValidators) + activeVals := k.GetActiveLiquidValidators(ctx, whitelistedValsMap) + + if activeVals.Len() == 0 { + return math.ZeroInt(), types.ErrActiveLiquidValidatorsNotExists + } + + totalActiveWeight := activeVals.TotalWeight(whitelistedValsMap) + activeWeightQuorum := math.LegacyNewDecFromInt(totalActiveWeight).Quo( + math.LegacyNewDecFromInt(types.TotalValidatorWeight), + ) + if activeWeightQuorum.LT(types.ActiveLiquidValidatorsWeightQuorum) { + k.Logger(ctx).Error( + "active liquid validators weight quorum not reached", + types.ActiveWeightQuorumKeyVal, + activeWeightQuorum.String(), + types.MinActiveWeightQuorumKeyVal, + types.ActiveLiquidValidatorsWeightQuorum.String(), + ) + + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrActiveLiquidValidatorsWeightQuorumNotReached, "%s < %s", + activeWeightQuorum.String(), types.ActiveLiquidValidatorsWeightQuorum.String(), + ) + } + + if !whitelistedValsMap.IsListed(validator.String()) { + return math.ZeroInt(), types.ErrLiquidValidatorsNotExists.Wrap("delegation from a non allowed validator") + } + + // NetAmount must be calculated before send + nas := k.GetNetAmountState(ctx) + + // perform an LSM tokenize->bank send->redeem flow: moving delegation from user's account onto proxyAcc + + lsmTokenizeMsg := &stakingtypes.MsgTokenizeShares{ + DelegatorAddress: delegator.String(), + ValidatorAddress: validator.String(), + Amount: preLsmStake, + TokenizedShareOwner: proxyAcc.String(), + } + + handler := k.router.Handler(lsmTokenizeMsg) + if handler == nil { + k.Logger(ctx).Error("failed to find tokenize handler") + + return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmTokenizeMsg)) + } + + // [1] tokenize delegation into LSM shares + msgResp, err := handler(ctx, lsmTokenizeMsg) + if err != nil { + k.Logger(ctx).Error( + "failed to execute tokenize shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmTokenizeMsg.String(), + ) + + return math.ZeroInt(), types.ErrLSMTokenizeFailed.Wrapf("error: %s; message: %v", err.Error(), lsmTokenizeMsg) + } + ctx.EventManager().EmitEvents(msgResp.GetEvents()) + + if len(msgResp.MsgResponses) != 1 { + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidResponse, + "expected msg response should be exactly 1, got: %v, responses: %v", + len(msgResp.MsgResponses), msgResp.MsgResponses, + ) + } + + var lsmTokenizeResp stakingtypes.MsgTokenizeSharesResponse + if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmTokenizeResp); err != nil { + return math.ZeroInt(), errorsmod.Wrapf( + sdkerrors.ErrJSONUnmarshal, + "cannot unmarshal tokenize share tx response message: %v", + err, + ) + } + + // [2] send LSM shares to proxyAcc + err = k.bankKeeper.SendCoins(ctx, delegator, proxyAcc, sdk.NewCoins(lsmTokenizeResp.Amount)) + if err != nil { + return stkXPRTMintAmount, err + } + + lsmRedeemMsg := &stakingtypes.MsgRedeemTokensForShares{ + DelegatorAddress: proxyAcc.String(), + Amount: lsmTokenizeResp.Amount, + } + + handler = k.router.Handler(lsmRedeemMsg) + if handler == nil { + k.Logger(ctx).Error("failed to find redeem handler") + + return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmRedeemMsg)) + } + + // [3] redeem LSM shares from proxyAcc, to obtain a delegation + msgResp, err = handler(ctx, lsmRedeemMsg) + if err != nil { + k.Logger(ctx).Error( + "failed to execute redeem tokens for shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmRedeemMsg.String(), + ) + + return math.ZeroInt(), types.ErrLSMRedeemFailed.Wrapf("error: %s; message: %v", err.Error(), lsmRedeemMsg) + } + ctx.EventManager().EmitEvents(msgResp.GetEvents()) + + if len(msgResp.MsgResponses) != 1 { + return math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidResponse, + "expected msg response should be exactly 1, got: %v, responses: %v", + len(msgResp.MsgResponses), msgResp.MsgResponses, + ) + } + + var lsmRedeemResp stakingtypes.MsgRedeemTokensForSharesResponse + if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmRedeemResp); err != nil { + return math.ZeroInt(), errorsmod.Wrapf( + sdkerrors.ErrJSONUnmarshal, + "cannot unmarshal redeem tokens for shares tx response message: %v", + err, + ) + } + + // mint stkxprt, MintAmount = TotalSupply * StakeAmount/NetAmount + liquidBondDenom := k.LiquidBondDenom(ctx) + stkXPRTMintAmount = lsmRedeemResp.Amount.Amount + + if nas.StkxprtTotalSupply.IsPositive() { + stkXPRTMintAmount = types.NativeTokenToStkXPRT( + stkXPRTMintAmount, + nas.StkxprtTotalSupply, + nas.NetAmount, + ) + } + + if !stkXPRTMintAmount.IsPositive() { + return math.ZeroInt(), types.ErrTooSmallLiquidStakeAmount + } + + // mint stkXPRT on module acc + mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, stkXPRTMintAmount)) + err = k.bankKeeper.MintCoins(ctx, types.ModuleName, mintCoin) + if err != nil { + return stkXPRTMintAmount, err + } + + // send stkXPRT to delegator acc + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, delegator, mintCoin) + if err != nil { + return stkXPRTMintAmount, err + } + + // but immediately lock new stkXPRT into LP on behalf of the delegator + _, err = k.LockOnLP(ctx, delegator, sdk.NewCoin(liquidBondDenom, stkXPRTMintAmount)) + if err != nil { + return stkXPRTMintAmount, err + } + + return stkXPRTMintAmount, err +} + +// LiquidDelegate delegates staking amount to active validators by proxy account. +func (k Keeper) LiquidDelegate(ctx sdk.Context, proxyAcc sdk.AccAddress, activeVals types.ActiveLiquidValidators, stakingAmt math.Int, whitelistedValsMap types.WhitelistedValsMap) (err error) { + // crumb may occur due to a decimal point error in dividing the staking amount into the weight of liquid validators, It added on first active liquid validator + weightedAmt, crumb := types.DivideByWeight(activeVals, stakingAmt, whitelistedValsMap) + if len(weightedAmt) == 0 { + k.Logger(ctx).Error( + "invalid active liquid validators", + types.ActiveValidatorsKeyVal, + activeVals, + types.AmountKeyVal, + stakingAmt.String(), + types.WhitelistedValidatorsMapKeyVal, + whitelistedValsMap, + ) + + return types.ErrInvalidActiveLiquidValidators + } + weightedAmt[0] = weightedAmt[0].Add(crumb) + for i, val := range activeVals { + if !weightedAmt[i].IsPositive() { + continue + } + validator, _ := k.stakingKeeper.GetValidator(ctx, val.GetOperator()) + err = k.DelegateWithCap(ctx, proxyAcc, validator, weightedAmt[i]) + if err != nil { + return errorsmod.Wrapf(err, "failed to delegate to validator %s", val.GetOperator()) + } + } + return nil +} + +// LiquidUnstake burns unstakingStkXPRT and performs LiquidUnbond to active liquid validators with del shares worth of shares according to NetAmount with each validators current weight. +func (k Keeper) LiquidUnstake( + ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, unstakingStkXPRT sdk.Coin, +) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) { + params := k.GetParams(ctx) + bondDenom := k.stakingKeeper.BondDenom(ctx) + + if params.ModulePaused { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrModulePaused + } + + // check bond denomination + liquidBondDenom := k.LiquidBondDenom(ctx) + if unstakingStkXPRT.Denom != liquidBondDenom { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), errorsmod.Wrapf( + types.ErrInvalidLiquidBondDenom, "invalid coin denomination: got %s, expected %s", unstakingStkXPRT.Denom, liquidBondDenom, + ) + } + + // Get NetAmount states + nas := k.GetNetAmountState(ctx) + + if unstakingStkXPRT.Amount.GT(nas.StkxprtTotalSupply) || nas.StkxprtTotalSupply.IsZero() { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrInvalidStkXPRTSupply + } + + // UnstakeAmount = NetAmount * StkXPRTAmount/TotalSupply * (1-UnstakeFeeRate) + unbondingAmount := types.StkXPRTToNativeToken(unstakingStkXPRT.Amount, nas.StkxprtTotalSupply, nas.NetAmount) + unbondingAmount = types.DeductFeeRate(unbondingAmount, params.UnstakeFeeRate) + unbondingAmountInt := unbondingAmount.TruncateInt() + + if !unbondingAmountInt.IsPositive() { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrTooSmallLiquidUnstakingAmount + } + + // burn stkxprt + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, liquidStaker, types.ModuleName, sdk.NewCoins(unstakingStkXPRT)) + if err != nil { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err + } + err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(liquidBondDenom, unstakingStkXPRT.Amount))) + if err != nil { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err + } + + liquidVals := k.GetAllLiquidValidators(ctx) + totalLiquidTokens, liquidTokenMap := liquidVals.TotalLiquidTokens(ctx, k.stakingKeeper, false) + + // if no totalLiquidTokens, withdraw directly from balance of proxy acc + if !totalLiquidTokens.IsPositive() { + if nas.ProxyAccBalance.GTE(unbondingAmountInt) { + err = k.bankKeeper.SendCoins( + ctx, + types.LiquidStakeProxyAcc, + liquidStaker, + sdk.NewCoins(sdk.NewCoin( + bondDenom, + unbondingAmountInt, + )), + ) + if err != nil { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err + } + + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, unbondingAmountInt, nil + } + + k.Logger(ctx).Error( + "non-positive total liquid tokens", + types.ValidatorsKeyVal, + liquidVals, + types.TotalLiquidTokensKeyVal, + totalLiquidTokens.String(), + ) + + // error case where there is a quantity that are unbonding balance or remaining rewards that is not re-stake or withdrawn in netAmount. + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrInsufficientProxyAccBalance + } + + // fail when no liquid validators to unbond + if liquidVals.Len() == 0 { + k.Logger(ctx).Error( + "no liquid validators to unbond", + types.ValidatorsKeyVal, + liquidVals, + ) + + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrLiquidValidatorsNotExists + } + + // prioritize inactive liquid validators in the list to be used in DivideByCurrentWeight + liquidVals = k.PrioritiseInactiveLiquidValidators(ctx, liquidVals) + + // crumb may occur due to a decimal error in dividing the unstaking stkXPRT into the weight of liquid validators, it will remain in the NetAmount + unbondingAmounts, crumb := types.DivideByCurrentWeight(liquidVals, unbondingAmount, totalLiquidTokens, liquidTokenMap) + if !unbondingAmount.Sub(crumb).IsPositive() { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrTooSmallLiquidUnstakingAmount + } + + totalReturnAmount := math.ZeroInt() + + var ubdTime time.Time + ubds := make([]stakingtypes.UnbondingDelegation, 0, len(liquidVals)) + for i, val := range liquidVals { + // skip zero weight liquid validator + if !unbondingAmounts[i].IsPositive() { + continue + } + + var ubd stakingtypes.UnbondingDelegation + var returnAmount math.Int + var weightedShare math.LegacyDec + + // calculate delShares from tokens with validation + weightedShare, err = k.stakingKeeper.ValidateUnbondAmount(ctx, proxyAcc, val.GetOperator(), unbondingAmounts[i].TruncateInt()) + if err != nil { + k.Logger(ctx).Error( + "failed to validate unbond amount", + types.ErrorKeyVal, + err, + types.ValidatorKeyVal, + val.GetOperator().String(), + types.AmountKeyVal, + unbondingAmounts[i].TruncateInt().String(), + ) + + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err + } + + if !weightedShare.IsPositive() { + continue + } + + // unbond with weightedShare + ubdTime, returnAmount, ubd, err = k.LiquidUnbond(ctx, proxyAcc, liquidStaker, val.GetOperator(), weightedShare, true, sdk.NewCoin(bondDenom, unbondingAmounts[i].TruncateInt())) + if err != nil { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err + } + + ubds = append(ubds, ubd) + totalReturnAmount = totalReturnAmount.Add(returnAmount) + } + + return ubdTime, totalReturnAmount, ubds, math.ZeroInt(), nil +} + +// LiquidUnbond unbond delegation shares to active validators by proxy account. +func (k Keeper) LiquidUnbond( + ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, valAddr sdk.ValAddress, shares math.LegacyDec, checkMaxEntries bool, unbondAmount sdk.Coin, +) (time.Time, math.Int, stakingtypes.UnbondingDelegation, error) { + _, found := k.stakingKeeper.GetValidator(ctx, valAddr) + if !found { + return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrNoDelegatorForAddress + } + + // If checkMaxEntries is true, perform a maximum limit unbonding entries check. + if checkMaxEntries && k.stakingKeeper.HasMaxUnbondingDelegationEntries(ctx, liquidStaker, valAddr) { + return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrMaxUnbondingDelegationEntries + } + + // unbond from proxy account + returnAmount, err := k.UnbondWithCap(ctx, proxyAcc, valAddr, unbondAmount, liquidStaker) + if err != nil { + return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, err + } + + //// Unbonding from proxy account, but queues to liquid staker. + completionTime := ctx.BlockHeader().Time.Add(k.stakingKeeper.UnbondingTime(ctx)) + ubd, found := k.stakingKeeper.GetUnbondingDelegation(ctx, liquidStaker, valAddr) + if !found { + k.Logger(ctx).Error( + "failed to find unbonding delegation", + types.DelegatorKeyVal, + liquidStaker.String(), + types.ValidatorKeyVal, + valAddr.String(), + ) + + return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, types.ErrInvalidResponse.Wrap("expected undelegation entry, found none") + } + + return completionTime, returnAmount, ubd, nil +} + +// PrioritiseInactiveLiquidValidators sorts LiquidValidators array to have inactive validators first. Used for the case when +// unbonding should begin from the inactive validators first. +func (k Keeper) PrioritiseInactiveLiquidValidators( + ctx sdk.Context, + vs types.LiquidValidators, +) types.LiquidValidators { + sort.SliceStable(vs, func(i, j int) bool { + vs1, vs1ok := k.stakingKeeper.GetValidator(ctx, vs[i].GetOperator()) + vs2, vs2ok := k.stakingKeeper.GetValidator(ctx, vs[j].GetOperator()) + + if !vs1ok && vs2ok { + // only one case when less + return true + } else if vs1ok && vs2ok { + // both exist, compare status + + vs1Active := vs[i].GetStatus(types.ActiveCondition( + vs1, + true, + k.IsTombstoned(ctx, vs1), + )) + vs2Active := vs[j].GetStatus(types.ActiveCondition( + vs2, + true, + k.IsTombstoned(ctx, vs2), + )) + + if vs1Active != types.ValidatorStatusActive && + vs2Active == types.ValidatorStatusActive { + // only one case when is less + return true + } + + // not less, or are equal + return false + } + + // not less, or are equal + return false + }) + + return vs +} + +// CheckDelegationStates returns total remaining rewards, delshares, liquid tokens of delegations by proxy account +func (k Keeper) CheckDelegationStates(ctx sdk.Context, proxyAcc sdk.AccAddress) (math.LegacyDec, math.LegacyDec, math.Int) { + bondDenom := k.stakingKeeper.BondDenom(ctx) + totalRewards := math.LegacyZeroDec() + totalDelShares := math.LegacyZeroDec() + totalLiquidTokens := math.ZeroInt() + + // Cache ctx for calculate rewards + cachedCtx, _ := ctx.CacheContext() + k.stakingKeeper.IterateDelegations( + cachedCtx, proxyAcc, + func(_ int64, del stakingtypes.DelegationI) (stop bool) { + valAddr := del.GetValidatorAddr() + val := k.stakingKeeper.Validator(cachedCtx, sdk.ValAddress(valAddr)) + endingPeriod := k.distrKeeper.IncrementValidatorPeriod(cachedCtx, val) + delReward := k.distrKeeper.CalculateDelegationRewards(cachedCtx, val, del, endingPeriod) + delShares := del.GetShares() + if delShares.IsPositive() { + totalDelShares = totalDelShares.Add(delShares) + liquidTokens := val.TokensFromSharesTruncated(delShares).TruncateInt() + totalLiquidTokens = totalLiquidTokens.Add(liquidTokens) + totalRewards = totalRewards.Add(delReward.AmountOf(bondDenom).TruncateDec()) + } + return false + }, + ) + + return totalRewards, totalDelShares, totalLiquidTokens +} + +func (k Keeper) WithdrawLiquidRewards(ctx sdk.Context, proxyAcc sdk.AccAddress) { + // iterate over all the delegations (even those out of the active set) and withdraw rewards + k.stakingKeeper.IterateDelegations( + ctx, proxyAcc, + func(_ int64, del stakingtypes.DelegationI) (stop bool) { + // construct the withdrawal rewards message + msgWithdraw := &distributiontypes.MsgWithdrawDelegatorReward{ + DelegatorAddress: proxyAcc.String(), + ValidatorAddress: del.GetValidatorAddr(), + } + + // run the message handler + handler := k.router.Handler(msgWithdraw) + if handler == nil { + k.Logger(ctx).Error("could not find distribution handler for withdraw rewards msg") + return true + } + res, err := handler(ctx, msgWithdraw) + if err != nil { + k.Logger(ctx).Error( + "failed to execute withdraw rewards msg", + types.MsgKeyVal, + msgWithdraw.String(), + types.ErrorKeyVal, + err, + ) + // no need to return here, will be picked up in the next epoch + } else { + // emit the events + ctx.EventManager().EmitEvents(res.GetEvents()) + } + + return false + }, + ) +} + +// GetLiquidValidator get a single liquid validator +func (k Keeper) GetLiquidValidator(ctx sdk.Context, addr sdk.ValAddress) (val types.LiquidValidator, found bool) { + store := ctx.KVStore(k.storeKey) + + value := store.Get(types.GetLiquidValidatorKey(addr)) + if value == nil { + return val, false + } + + val = types.MustUnmarshalLiquidValidator(k.cdc, value) + return val, true +} + +// SetLiquidValidator set the main record holding liquid validator details +func (k Keeper) SetLiquidValidator(ctx sdk.Context, val types.LiquidValidator) { + store := ctx.KVStore(k.storeKey) + bz := types.MustMarshalLiquidValidator(k.cdc, &val) + store.Set(types.GetLiquidValidatorKey(val.GetOperator()), bz) +} + +// RemoveLiquidValidator remove a liquid validator on kv store +func (k Keeper) RemoveLiquidValidator(ctx sdk.Context, val types.LiquidValidator) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetLiquidValidatorKey(val.GetOperator())) +} + +// GetAllLiquidValidators gets the set of all liquid validators, with no pagination limits. +func (k Keeper) GetAllLiquidValidators(ctx sdk.Context) (vals types.LiquidValidators) { + store := ctx.KVStore(k.storeKey) + vals = types.LiquidValidators{} + iterator := storetypes.KVStorePrefixIterator(store, types.LiquidValidatorsKey) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + val := types.MustUnmarshalLiquidValidator(k.cdc, iterator.Value()) + vals = append(vals, val) + } + + return vals +} + +// GetActiveLiquidValidators get the set of active liquid validators. +func (k Keeper) GetActiveLiquidValidators(ctx sdk.Context, whitelistedValsMap types.WhitelistedValsMap) (vals types.ActiveLiquidValidators) { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.LiquidValidatorsKey) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + val := types.MustUnmarshalLiquidValidator(k.cdc, iterator.Value()) + if k.IsActiveLiquidValidator(ctx, val, whitelistedValsMap) { + vals = append(vals, val) + } + } + return vals +} + +func (k Keeper) GetAllLiquidValidatorStates(ctx sdk.Context) (liquidValidatorStates []types.LiquidValidatorState) { + lvs := k.GetAllLiquidValidators(ctx) + whitelistedValsMap := k.GetParams(ctx).WhitelistedValsMap() + for _, lv := range lvs { + active := k.IsActiveLiquidValidator(ctx, lv, whitelistedValsMap) + lvState := types.LiquidValidatorState{ + OperatorAddress: lv.OperatorAddress, + Weight: lv.GetWeight(whitelistedValsMap, active), + Status: lv.GetStatus(active), + DelShares: lv.GetDelShares(ctx, k.stakingKeeper), + LiquidTokens: lv.GetLiquidTokens(ctx, k.stakingKeeper, false), + } + liquidValidatorStates = append(liquidValidatorStates, lvState) + } + return +} + +func (k Keeper) GetLiquidValidatorState(ctx sdk.Context, addr sdk.ValAddress) (liquidValidatorState types.LiquidValidatorState, found bool) { + lv, found := k.GetLiquidValidator(ctx, addr) + if !found { + return types.LiquidValidatorState{ + OperatorAddress: addr.String(), + Weight: math.ZeroInt(), + Status: types.ValidatorStatusUnspecified, + DelShares: math.LegacyZeroDec(), + LiquidTokens: math.ZeroInt(), + }, false + } + whitelistedValsMap := k.GetParams(ctx).WhitelistedValsMap() + active := k.IsActiveLiquidValidator(ctx, lv, whitelistedValsMap) + return types.LiquidValidatorState{ + OperatorAddress: lv.OperatorAddress, + Weight: lv.GetWeight(whitelistedValsMap, active), + Status: lv.GetStatus(active), + DelShares: lv.GetDelShares(ctx, k.stakingKeeper), + LiquidTokens: lv.GetLiquidTokens(ctx, k.stakingKeeper, false), + }, true +} + +func (k Keeper) IsActiveLiquidValidator(ctx sdk.Context, lv types.LiquidValidator, whitelistedValsMap types.WhitelistedValsMap) bool { + val, found := k.stakingKeeper.GetValidator(ctx, lv.GetOperator()) + if !found { + return false + } + return types.ActiveCondition(val, whitelistedValsMap.IsListed(lv.OperatorAddress), k.IsTombstoned(ctx, val)) +} + +func (k Keeper) IsTombstoned(ctx sdk.Context, val stakingtypes.Validator) bool { + consPk, err := val.ConsPubKey() + if err != nil { + return false + } + return k.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(consPk.Address())) +} + +func (k Keeper) GetWeightMap(ctx sdk.Context, liquidVals types.LiquidValidators, whitelistedValsMap types.WhitelistedValsMap) (map[string]math.Int, math.Int) { + weightMap := map[string]math.Int{} + totalWeight := math.ZeroInt() + for _, val := range liquidVals { + weight := val.GetWeight(whitelistedValsMap, k.IsActiveLiquidValidator(ctx, val, whitelistedValsMap)) + totalWeight = totalWeight.Add(weight) + weightMap[val.OperatorAddress] = weight + } + return weightMap, totalWeight +} diff --git a/x/liquidstake/keeper/msg_server.go b/x/liquidstake/keeper/msg_server.go new file mode 100644 index 0000000..473590b --- /dev/null +++ b/x/liquidstake/keeper/msg_server.go @@ -0,0 +1,299 @@ +package keeper + +// DONTCOVER + +// Although written in msg_server_test.go, it is approached at the keeper level rather than at the msgServer level +// so is not included in the coverage. + +import ( + "context" + "encoding/json" + "fmt" + "time" + + "cosmossdk.io/errors" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the liquidstake MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) (*types.MsgLiquidStakeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + stkXPRTMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.Amount) + if err != nil { + return nil, err + } + + var cValue math.LegacyDec + if stkXPRTMintAmount.IsPositive() { + cValue = stkXPRTMintAmount.ToLegacyDec().Quo(msg.Amount.Amount.ToLegacyDec()) + } + + liquidBondDenom := k.LiquidBondDenom(ctx) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + sdk.NewEvent( + types.EventTypeMsgLiquidStake, + sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), + sdk.NewAttribute(types.AttributeKeyLiquidAmount, msg.Amount.String()), + sdk.NewAttribute(types.AttributeKeyStkXPRTMintedAmount, sdk.Coin{Denom: liquidBondDenom, Amount: stkXPRTMintAmount}.String()), + sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), + ), + }) + return &types.MsgLiquidStakeResponse{}, nil +} + +func (k msgServer) StakeToLP(goCtx context.Context, msg *types.MsgStakeToLP) (*types.MsgStakeToLPResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + stkXPRTMintAmount, err := k.LSMDelegate( + ctx, + msg.GetDelegator(), + msg.GetValidator(), + types.LiquidStakeProxyAcc, + msg.StakedAmount, + ) + if err != nil { + return nil, err + } + + liquidBondDenom := k.LiquidBondDenom(ctx) + stkXPRTMinted := sdk.Coin{ + Denom: liquidBondDenom, + Amount: stkXPRTMintAmount, + } + + var cValue math.LegacyDec + if stkXPRTMintAmount.IsPositive() { + cValue = stkXPRTMintAmount.ToLegacyDec().Quo(msg.StakedAmount.Amount.ToLegacyDec()) + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + sdk.NewEvent( + types.EventTypeMsgStakeToLP, + sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), + sdk.NewAttribute(types.AttributeKeyStakedAmount, msg.StakedAmount.String()), + sdk.NewAttribute(types.AttributeKeyStkXPRTMintedAmount, stkXPRTMinted.String()), + sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), + ), + }) + + if (msg.LiquidAmount != sdk.Coin{}) && (msg.LiquidAmount.Amount != math.Int{}) && msg.LiquidAmount.Amount.IsPositive() { + stkXPRTMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.LiquidAmount) + if err != nil { + return nil, err + } + + stkXPRTMinted := sdk.Coin{ + Denom: liquidBondDenom, + Amount: stkXPRTMintAmount, + } + + var cValue math.LegacyDec + if stkXPRTMintAmount.IsPositive() { + cValue = stkXPRTMintAmount.ToLegacyDec().Quo(msg.LiquidAmount.Amount.ToLegacyDec()) + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + sdk.NewEvent( + types.EventTypeMsgStakeToLP, + sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), + sdk.NewAttribute(types.AttributeKeyLiquidAmount, msg.LiquidAmount.String()), + sdk.NewAttribute(types.AttributeKeyStkXPRTMintedAmount, stkXPRTMinted.String()), + sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), + ), + }) + + _, err = k.LockOnLP(ctx, msg.GetDelegator(), stkXPRTMinted) + if err != nil { + return nil, err + } + } + + return &types.MsgStakeToLPResponse{}, nil +} + +func (k msgServer) LiquidUnstake(goCtx context.Context, msg *types.MsgLiquidUnstake) (*types.MsgLiquidUnstakeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + completionTime, unbondingAmount, _, unbondedAmount, err := k.Keeper.LiquidUnstake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.Amount) + if err != nil { + return nil, err + } + + bondDenom := k.stakingKeeper.BondDenom(ctx) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + sdk.NewEvent( + types.EventTypeMsgLiquidUnstake, + sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), + sdk.NewAttribute(types.AttributeKeyUnstakeAmount, msg.Amount.String()), + sdk.NewAttribute(types.AttributeKeyUnbondingAmount, sdk.Coin{Denom: bondDenom, Amount: unbondingAmount}.String()), + sdk.NewAttribute(types.AttributeKeyUnbondedAmount, sdk.Coin{Denom: bondDenom, Amount: unbondedAmount}.String()), + sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), + ), + }) + return &types.MsgLiquidUnstakeResponse{ + CompletionTime: completionTime, + }, nil +} + +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if msg.Authority != k.authority && msg.Authority != k.GetParams(ctx).WhitelistAdminAddress { + return nil, errors.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + paramsToSet := k.GetParams(ctx) + + // List of all updateable param + paramsToSet.UnstakeFeeRate = msg.Params.UnstakeFeeRate + paramsToSet.LsmDisabled = msg.Params.LsmDisabled + paramsToSet.MinLiquidStakeAmount = msg.Params.MinLiquidStakeAmount + paramsToSet.CwLockedPoolAddress = msg.Params.CwLockedPoolAddress + paramsToSet.FeeAccountAddress = msg.Params.FeeAccountAddress + paramsToSet.AutocompoundFeeRate = msg.Params.AutocompoundFeeRate + paramsToSet.WhitelistAdminAddress = msg.Params.WhitelistAdminAddress + + err := k.SetParams(ctx, paramsToSet) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + sdk.NewEvent( + types.EventTypeMsgUpdateParams, + sdk.NewAttribute(types.AttributeKeyAuthority, msg.Authority), + sdk.NewAttribute(types.AttributeKeyUpdatedParams, msg.Params.String()), + ), + }) + + return &types.MsgUpdateParamsResponse{}, nil +} + +func (k msgServer) UpdateWhitelistedValidators(goCtx context.Context, msg *types.MsgUpdateWhitelistedValidators) (*types.MsgUpdateWhitelistedValidatorsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + params := k.GetParams(ctx) + + if msg.Authority != k.authority && msg.Authority != params.WhitelistAdminAddress { + return nil, errors.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s, got %s", params.WhitelistAdminAddress, msg.Authority) + } + + totalWeight := math.NewInt(0) + for _, val := range msg.WhitelistedValidators { + totalWeight = totalWeight.Add(val.TargetWeight) + + valAddr := val.GetValidatorAddress() + fullVal, ok := k.stakingKeeper.GetValidator(ctx, valAddr) + if !ok { + return nil, errors.Wrapf( + types.ErrWhitelistedValidatorsList, + "validator not found: %s", valAddr, + ) + } + + if fullVal.Status != stakingtypes.Bonded { + return nil, errors.Wrapf( + types.ErrWhitelistedValidatorsList, + "validator status %s: expected %s; got %s", valAddr, stakingtypes.Bonded.String(), fullVal.Status.String(), + ) + } + } + + if !totalWeight.Equal(types.TotalValidatorWeight) { + return nil, errors.Wrapf( + types.ErrWhitelistedValidatorsList, + "weights don't add up; expected %s, got %s", types.TotalValidatorWeight.String(), totalWeight.String(), + ) + } + + params.WhitelistedValidators = msg.WhitelistedValidators + + err := k.SetParams(ctx, params) + if err != nil { + return nil, err + } + + updatedValidatorsListJSON, _ := json.Marshal(msg.WhitelistedValidators) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + sdk.NewEvent( + types.EventTypeMsgUpdateWhitelistedValidators, + sdk.NewAttribute(types.AttributeKeyAuthority, msg.Authority), + sdk.NewAttribute(types.AttributeKeyUpdatedWhitelistedValidators, string(updatedValidatorsListJSON)), + ), + }) + + return &types.MsgUpdateWhitelistedValidatorsResponse{}, nil +} + +func (k msgServer) SetModulePaused(goCtx context.Context, msg *types.MsgSetModulePaused) (*types.MsgSetModulePausedResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + params := k.GetParams(ctx) + + if msg.Authority != k.authority && msg.Authority != params.WhitelistAdminAddress { + return nil, errors.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s, got %s", params.WhitelistAdminAddress, msg.Authority) + } + + params.ModulePaused = msg.IsPaused + + err := k.SetParams(ctx, params) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + sdk.NewEvent( + types.EventTypeMsgSetModulePaused, + sdk.NewAttribute(types.AttributeKeyAuthority, msg.Authority), + sdk.NewAttribute(types.AttributeKeyModulePaused, fmt.Sprintf("%t", msg.IsPaused)), + ), + }) + + return &types.MsgSetModulePausedResponse{}, nil +} diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go new file mode 100644 index 0000000..fbc49ab --- /dev/null +++ b/x/liquidstake/keeper/rebalancing.go @@ -0,0 +1,278 @@ +package keeper + +import ( + "fmt" + "strconv" + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +func (k Keeper) GetProxyAccBalance(ctx sdk.Context, proxyAcc sdk.AccAddress) (balance sdk.Coin) { + bondDenom := k.stakingKeeper.BondDenom(ctx) + return sdk.NewCoin(bondDenom, k.bankKeeper.SpendableCoins(ctx, proxyAcc).AmountOf(bondDenom)) +} + +// TryRedelegation attempts redelegation, which is applied only when successful through cached context because there is a constraint that fails if already receiving redelegation. +func (k Keeper) TryRedelegation(ctx sdk.Context, re types.Redelegation) (completionTime time.Time, err error) { + dstVal := re.DstValidator.GetOperator() + srcVal := re.SrcValidator.GetOperator() + + // check the source validator already has receiving transitive redelegation + hasReceiving := k.stakingKeeper.HasReceivingRedelegation(ctx, re.Delegator, srcVal) + if hasReceiving { + return time.Time{}, stakingtypes.ErrTransitiveRedelegation + } + + // calculate delShares from tokens with validation + _, err = k.stakingKeeper.ValidateUnbondAmount( + ctx, re.Delegator, srcVal, re.Amount, + ) + if err != nil { + return time.Time{}, fmt.Errorf("failed to validate unbond amount: %w", err) + } + + // when last, full redelegation of shares from delegation + amt := re.Amount + if re.Last { + amt = re.SrcValidator.GetLiquidTokens(ctx, k.stakingKeeper, false) + } + cachedCtx, writeCache := ctx.CacheContext() + completionTime, err = k.RedelegateWithCap(cachedCtx, re.Delegator, srcVal, dstVal, amt) + if err != nil { + return time.Time{}, fmt.Errorf("failed to begin redelegation: %w", err) + } + writeCache() + return completionTime, nil +} + +// Rebalance argument liquidVals containing ValidatorStatusActive which is containing just added on whitelist(liquidToken 0) and ValidatorStatusInactive to delist +func (k Keeper) Rebalance( + ctx sdk.Context, + proxyAcc sdk.AccAddress, + liquidVals types.LiquidValidators, + whitelistedValsMap types.WhitelistedValsMap, + rebalancingTrigger math.LegacyDec, +) (redelegations []types.Redelegation) { + totalLiquidTokens, liquidTokenMap := liquidVals.TotalLiquidTokens(ctx, k.stakingKeeper, false) + if !totalLiquidTokens.IsPositive() { + return redelegations + } + + weightMap, totalWeight := k.GetWeightMap(ctx, liquidVals, whitelistedValsMap) + + // no active liquid validators + if !totalWeight.IsPositive() { + return redelegations + } + + // calculate rebalancing target map + targetMap := map[string]math.Int{} + totalTargetMap := math.ZeroInt() + for _, val := range liquidVals { + targetMap[val.OperatorAddress] = totalLiquidTokens.Mul(weightMap[val.OperatorAddress]).Quo(totalWeight) + totalTargetMap = totalTargetMap.Add(targetMap[val.OperatorAddress]) + } + crumb := totalLiquidTokens.Sub(totalTargetMap) + if !totalTargetMap.IsPositive() { + return redelegations + } + // crumb to first non zero liquid validator + for _, val := range liquidVals { + if targetMap[val.OperatorAddress].IsPositive() { + targetMap[val.OperatorAddress] = targetMap[val.OperatorAddress].Add(crumb) + break + } + } + + failCount := 0 + rebalancingThresholdAmt := rebalancingTrigger.Mul(math.LegacyNewDecFromInt(totalLiquidTokens)).TruncateInt() + redelegations = make([]types.Redelegation, 0, liquidVals.Len()) + + for i := 0; i < liquidVals.Len(); i++ { + // get min, max of liquid token gap + minVal, maxVal, amountNeeded, last := liquidVals.MinMaxGap(targetMap, liquidTokenMap) + if amountNeeded.IsZero() || (i == 0 && !amountNeeded.GT(rebalancingThresholdAmt)) { + break + } + + // sync liquidTokenMap applied rebalancing + liquidTokenMap[maxVal.OperatorAddress] = liquidTokenMap[maxVal.OperatorAddress].Sub(amountNeeded) + liquidTokenMap[minVal.OperatorAddress] = liquidTokenMap[minVal.OperatorAddress].Add(amountNeeded) + + // try redelegation from max validator to min validator + redelegation := types.Redelegation{ + Delegator: proxyAcc, + SrcValidator: maxVal, + DstValidator: minVal, + Amount: amountNeeded, + Last: last, + } + + _, err := k.TryRedelegation(ctx, redelegation) + if err != nil { + redelegation.Error = err + failCount++ + + k.Logger(ctx).Info( + "redelegation failed", + types.DelegatorKeyVal, proxyAcc.String(), + types.SrcValidatorKeyVal, maxVal.OperatorAddress, + types.DstValidatorKeyVal, minVal.OperatorAddress, + types.AmountKeyVal, amountNeeded.String(), + types.ErrorKeyVal, err.Error(), + ) + } + + redelegations = append(redelegations, redelegation) + } + + if len(redelegations) != 0 { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeBeginRebalancing, + sdk.NewAttribute(types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String()), + sdk.NewAttribute(types.AttributeKeyRedelegationCount, strconv.Itoa(len(redelegations))), + sdk.NewAttribute(types.AttributeKeyRedelegationFailCount, strconv.Itoa(failCount)), + ), + }) + k.Logger(ctx).Info(types.EventTypeBeginRebalancing, + types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String(), + types.AttributeKeyRedelegationCount, strconv.Itoa(len(redelegations)), + types.AttributeKeyRedelegationFailCount, strconv.Itoa(failCount)) + } + + return redelegations +} + +func (k Keeper) UpdateLiquidValidatorSet(ctx sdk.Context, redelegate bool) (redelegations []types.Redelegation) { + params := k.GetParams(ctx) + liquidValidators := k.GetAllLiquidValidators(ctx) + liquidValsMap := liquidValidators.Map() + whitelistedValsMap := types.GetWhitelistedValsMap(params.WhitelistedValidators) + + // Set Liquid validators for added whitelist validators + for _, wv := range params.WhitelistedValidators { + if _, ok := liquidValsMap[wv.ValidatorAddress]; !ok { + lv := types.LiquidValidator{ + OperatorAddress: wv.ValidatorAddress, + } + if k.IsActiveLiquidValidator(ctx, lv, whitelistedValsMap) { + k.SetLiquidValidator(ctx, lv) + liquidValidators = append(liquidValidators, lv) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeAddLiquidValidator, + sdk.NewAttribute(types.AttributeKeyLiquidValidator, lv.OperatorAddress), + ), + }) + k.Logger(ctx).Info(types.EventTypeAddLiquidValidator, types.AttributeKeyLiquidValidator, lv.OperatorAddress) + } + } + } + + // rebalancing based updated liquid validators status with threshold, try by cachedCtx + // tombstone status also handled on Rebalance + if redelegate { + redelegations = k.Rebalance( + ctx, + types.LiquidStakeProxyAcc, + liquidValidators, + whitelistedValsMap, + types.RebalancingTrigger, + ) + + // if there are inactive liquid validators, do not unbond, + // instead let validator selection and rebalancing take care of it. + + return redelegations + } + return nil +} + +// AutocompoundStakingRewards withdraws staking rewards and re-stakes when over threshold. +func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap types.WhitelistedValsMap) { + // withdraw rewards of LiquidStakeProxyAcc + k.WithdrawLiquidRewards(ctx, types.LiquidStakeProxyAcc) + + // skip when no active liquid validator + activeVals := k.GetActiveLiquidValidators(ctx, whitelistedValsMap) + if len(activeVals) == 0 { + return + } + + // get all the APY components + bondDenom := k.stakingKeeper.BondDenom(ctx) + totalSupply := k.bankKeeper.GetSupply(ctx, bondDenom).Amount + bondedTokens := k.bankKeeper.GetBalance(ctx, k.stakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount + inflation := k.mintKeeper.GetMinter(ctx).Inflation + + // calculate the hourly APY + bondRatio := math.LegacyDec(bondedTokens).Quo(math.LegacyDec(totalSupply)) + hourlyApy := inflation.Quo(bondRatio). + Quo(types.DefaultLimitAutocompoundPeriodDays). + Quo(types.DefaultLimitAutocompoundPeriodHours) + + // calculate autocompoundable amount by limiting the current net amount with the calculated APY + autoCompoundableAmount := k.GetNetAmountState(ctx).NetAmount.Mul(hourlyApy).TruncateInt() + + // use the calculated autocompoundable amount as the limit for the transfer + proxyAccBalance := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) + if proxyAccBalance.Amount.LT(autoCompoundableAmount) { + autoCompoundableAmount = proxyAccBalance.Amount + } + + // calculate autocompounding fee + params := k.GetParams(ctx) + autocompoundFee := sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), math.ZeroInt()) + if !params.AutocompoundFeeRate.IsZero() && autoCompoundableAmount.IsPositive() { + autocompoundFee = sdk.NewCoin( + k.stakingKeeper.BondDenom(ctx), + params.AutocompoundFeeRate.MulInt(autoCompoundableAmount).TruncateInt(), + ) + } + + // re-staking of the accumulated rewards + cachedCtx, writeCache := ctx.CacheContext() + delegableAmount := autoCompoundableAmount.Sub(autocompoundFee.Amount) + err := k.LiquidDelegate(cachedCtx, types.LiquidStakeProxyAcc, activeVals, delegableAmount, whitelistedValsMap) + if err != nil { + k.Logger(ctx).Error( + "failed to re-stake the accumulated rewards", + types.ErrorKeyVal, + err, + ) + return + // skip errors as they might occur due to reaching global liquid cap + } + writeCache() + + // move autocompounding fee from the balance to fee account + feeAccountAddr := sdk.MustAccAddressFromBech32(params.FeeAccountAddress) + err = k.bankKeeper.SendCoins(ctx, types.LiquidStakeProxyAcc, feeAccountAddr, sdk.NewCoins(autocompoundFee)) + if err != nil { + k.Logger(ctx).Error( + "failed to send autocompound fee to fee account", + types.ErrorKeyVal, + err, + ) + return + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeAutocompound, + sdk.NewAttribute(types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, delegableAmount.String()), + sdk.NewAttribute(types.AttributeKeyAutocompoundFee, autocompoundFee.String()), + ), + }) + k.Logger(ctx).Info(types.EventTypeAutocompound, + types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String(), + sdk.AttributeKeyAmount, delegableAmount.String(), + types.AttributeKeyAutocompoundFee, autocompoundFee.String()) +} diff --git a/x/liquidstake/module.go b/x/liquidstake/module.go new file mode 100644 index 0000000..92bd6b1 --- /dev/null +++ b/x/liquidstake/module.go @@ -0,0 +1,152 @@ +package liquidstake + +import ( + "context" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + sdkclient "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/client/cli" + "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic defines the basic application module used by the liquidstake module. +type AppModuleBasic struct{} + +// Name returns the liquidstake module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the liquidstake module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// DefaultGenesis returns default genesis state as raw bytes for the liquidstake +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the liquidstake module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ sdkclient.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return types.ValidateGenesis(data) +} + +// RegisterRESTRoutes registers the REST routes for the liquidstake module. +func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the liquidstake module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root tx command for the liquidstake module. +// Modifying parameters of a liquidstake can be done through governance process, not through transaction level. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the liquidstake module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +func (b AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// AppModule implements an application module for the liquidstake module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule( + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: keeper, + } +} + +// Name returns the liquidstake module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the liquidstake module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// QuerierRoute returns the liquidstake module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.Querier{Keeper: am.keeper}) +} + +// InitGenesis performs genesis initialization for the liquidstake 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) + am.keeper.InitGenesis(ctx, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the liquidstake +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock returns the begin blocker for the liquidstake module. +func (am AppModule) BeginBlock(ctx sdk.Context) { + BeginBlock(ctx, am.keeper) +} + +// EndBlock returns the end blocker for the liquidstake module. It returns no validator +// updates. +func (am AppModule) EndBlock(_ sdk.Context) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/liquidstake/types/codec.go b/x/liquidstake/types/codec.go new file mode 100644 index 0000000..e50ad2f --- /dev/null +++ b/x/liquidstake/types/codec.go @@ -0,0 +1,50 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// RegisterLegacyAminoCodec registers the necessary x/liquidstake interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgLiquidStake{}, "liquidstake/MsgLiquidStake", nil) + cdc.RegisterConcrete(&MsgStakeToLP{}, "liquidstake/MsgStakeToLP", nil) + cdc.RegisterConcrete(&MsgLiquidUnstake{}, "liquidstake/MsgLiquidUnstake", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "liquidstake/MsgUpdateParams", nil) + cdc.RegisterConcrete(&MsgUpdateWhitelistedValidators{}, "liquidstake/MsgUpdateWhitelistedValidators", nil) + cdc.RegisterConcrete(&MsgSetModulePaused{}, "liquidstake/MsgSetModulePaused", nil) +} + +// RegisterInterfaces registers the x/liquidstake interfaces types with the interface registry. +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgLiquidStake{}, + &MsgStakeToLP{}, + &MsgLiquidUnstake{}, + &MsgUpdateParams{}, + &MsgUpdateWhitelistedValidators{}, + &MsgSetModulePaused{}, + ) +} + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/liquidstake module codec. Note, the codec + // should ONLY be used in certain instances of tests and for JSON encoding as Amino + // is still used for that purpose. + // + // The actual codec used for serialization should be provided to x/liquidstake and + // defined at the application level. + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/x/liquidstake/types/errors.go b/x/liquidstake/types/errors.go new file mode 100644 index 0000000..a3981ff --- /dev/null +++ b/x/liquidstake/types/errors.go @@ -0,0 +1,32 @@ +package types + +import "cosmossdk.io/errors" + +// Sentinel errors for the liquidstake module. +var ( + ErrActiveLiquidValidatorsNotExists = errors.Register(ModuleName, 2, "active liquid validators not exists") + ErrInvalidDenom = errors.Register(ModuleName, 3, "invalid denom") + ErrInvalidBondDenom = errors.Register(ModuleName, 4, "invalid bond denom") + ErrInvalidLiquidBondDenom = errors.Register(ModuleName, 5, "invalid liquid bond denom") + ErrNotImplementedYet = errors.Register(ModuleName, 6, "not implemented yet") + ErrLessThanMinLiquidStakeAmount = errors.Register(ModuleName, 7, "staking amount should be over params.min_liquid_stake_amount") + ErrInvalidStkXPRTSupply = errors.Register(ModuleName, 8, "invalid liquid bond denom supply") + ErrInvalidActiveLiquidValidators = errors.Register(ModuleName, 9, "invalid active liquid validators") + ErrLiquidValidatorsNotExists = errors.Register(ModuleName, 10, "liquid validators not exists") + ErrInsufficientProxyAccBalance = errors.Register(ModuleName, 11, "insufficient liquid tokens or balance of proxy account, need to wait for new liquid validator to be added or unbonding of proxy account to be completed") + ErrTooSmallLiquidStakeAmount = errors.Register(ModuleName, 12, "liquid stake amount is too small, the result becomes zero") + ErrTooSmallLiquidUnstakingAmount = errors.Register(ModuleName, 13, "liquid unstaking amount is too small, the result becomes zero") + ErrNoLPContractAddress = errors.Register(ModuleName, 14, "CW address of an LP contract is not set") + ErrDisabledLSM = errors.Register(ModuleName, 15, "LSM delegation is disabled") + ErrLSMTokenizeFailed = errors.Register(ModuleName, 16, "LSM tokenization failed") + ErrLSMRedeemFailed = errors.Register(ModuleName, 17, "LSM redemption failed") + ErrLPContract = errors.Register(ModuleName, 18, "CW contract execution failed") + ErrWhitelistedValidatorsList = errors.Register(ModuleName, 19, "whitelisted validators list incorrect") + ErrActiveLiquidValidatorsWeightQuorumNotReached = errors.Register(ModuleName, 20, "active liquid validators weight quorum not reached") + ErrModulePaused = errors.Register(ModuleName, 21, "module functions have been paused") + ErrDelegationFailed = errors.Register(ModuleName, 22, "delegation failed") + ErrUnbondFailed = errors.Register(ModuleName, 23, "unbond failed") + ErrInvalidResponse = errors.Register(ModuleName, 24, "invalid response") + ErrUnstakeFailed = errors.Register(ModuleName, 25, "Unstaking failed") + ErrRedelegateFailed = errors.Register(ModuleName, 26, "Redelegate failed") +) diff --git a/x/liquidstake/types/events.go b/x/liquidstake/types/events.go new file mode 100644 index 0000000..f29f414 --- /dev/null +++ b/x/liquidstake/types/events.go @@ -0,0 +1,38 @@ +package types + +// Event types for the liquidstake module. +const ( + EventTypeMsgLiquidStake = MsgTypeLiquidStake + EventTypeMsgLiquidUnstake = MsgTypeLiquidUnstake + EventTypeMsgStakeToLP = MsgTypeStakeToLP + EventTypeMsgUpdateParams = MsgTypeUpdateParams + EventTypeMsgUpdateWhitelistedValidators = MsgTypeUpdateWhitelistedValidators + EventTypeMsgSetModulePaused = MsgTypeSetModulePaused + EventTypeAddLiquidValidator = "add_liquid_validator" + EventTypeRemoveLiquidValidator = "remove_liquid_validator" + EventTypeBeginRebalancing = "begin_rebalancing" + EventTypeAutocompound = "autocompound" + EventTypeUnbondInactiveLiquidTokens = "unbond_inactive_liquid_tokens" + + AttributeKeyDelegator = "delegator" + AttributeKeyNewShares = "new_shares" + AttributeKeyCValue = "c_value" + AttributeKeyStkXPRTMintedAmount = "stkxprt_minted_amount" + AttributeKeyCompletionTime = "completion_time" + AttributeKeyUnbondingAmount = "unbonding_amount" + AttributeKeyUnbondedAmount = "unbonded_amount" + AttributeKeyLiquidValidator = "liquid_validator" + AttributeKeyRedelegationCount = "redelegation_count" + AttributeKeyRedelegationFailCount = "redelegation_fail_count" + AttributeKeyLiquidAmount = "liquid_amount" + AttributeKeyStakedAmount = "staked_amount" + AttributeKeyUnstakeAmount = "unstake_amount" + AttributeKeyAutocompoundFee = "autocompound_fee" + AttributeKeyModulePaused = "module_paused" + + AttributeKeyAuthority = "authority" + AttributeKeyUpdatedParams = "updated_params" + AttributeKeyUpdatedWhitelistedValidators = "updated_whitelisted_validators" + + AttributeValueCategory = ModuleName +) diff --git a/x/liquidstake/types/expected_keepers.go b/x/liquidstake/types/expected_keepers.go new file mode 100644 index 0000000..7f253e9 --- /dev/null +++ b/x/liquidstake/types/expected_keepers.go @@ -0,0 +1,96 @@ +package types + +import ( + "time" + + "cosmossdk.io/math" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/mint/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// BankKeeper defines the expected bank send keeper +type BankKeeper interface { + SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error + + GetSupply(ctx sdk.Context, denom string) sdk.Coin + SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error + MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin +} + +// AccountKeeper defines the expected account keeper +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI +} + +// StakingKeeper expected staking keeper (noalias) +type StakingKeeper interface { + Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI + ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) + + GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) + GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator + + GetLastTotalPower(ctx sdk.Context) math.Int + GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 + + Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI + GetDelegation(ctx sdk.Context, + delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) + IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, + fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) + + BondDenom(ctx sdk.Context) (res string) + UnbondingTime(ctx sdk.Context) (res time.Duration) + ValidateUnbondAmount( + ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt math.Int, + ) (shares math.LegacyDec, err error) + GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.UnbondingDelegation, bool) + GetAllUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.UnbondingDelegation + GetAllRedelegations( + ctx sdk.Context, delegator sdk.AccAddress, srcValAddress, dstValAddress sdk.ValAddress, + ) []stakingtypes.Redelegation + HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool + BlockValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate + HasMaxUnbondingDelegationEntries(ctx sdk.Context, + delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool + GetBondedPool(ctx sdk.Context) (bondedPool authtypes.ModuleAccountI) +} + +// MintKeeper expected minting keeper (noalias) +type MintKeeper interface { + GetMinter(ctx sdk.Context) (minter types.Minter) +} + +// DistrKeeper expected distribution keeper (noalias) +type DistrKeeper interface { + IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.ValidatorI) uint64 + CalculateDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) + WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) +} + +// SlashingKeeper expected slashing keeper (noalias) +type SlashingKeeper interface { + IsTombstoned(ctx sdk.Context, consAddr sdk.ConsAddress) bool +} + +// StakingHooks event hooks for staking validator object (noalias) +type StakingHooks interface { + AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created + AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted + + BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation is created + BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation's shares are modified + AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) + BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction math.LegacyDec) +} diff --git a/x/liquidstake/types/genesis.go b/x/liquidstake/types/genesis.go new file mode 100644 index 0000000..08ea0f3 --- /dev/null +++ b/x/liquidstake/types/genesis.go @@ -0,0 +1,37 @@ +package types + +import ( + "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewGenesisState returns new GenesisState instance. +func NewGenesisState(params Params, liquidValidators []LiquidValidator) *GenesisState { + return &GenesisState{ + Params: params, + LiquidValidators: liquidValidators, + } +} + +// DefaultGenesisState returns the default genesis state. +func DefaultGenesisState() *GenesisState { + return NewGenesisState( + DefaultParams(), + []LiquidValidator{}, + ) +} + +// ValidateGenesis validates GenesisState. +func ValidateGenesis(data GenesisState) error { + if err := data.Params.Validate(); err != nil { + return err + } + for _, lv := range data.LiquidValidators { + if err := lv.Validate(); err != nil { + return errors.Wrapf( + sdkerrors.ErrInvalidAddress, + "invalid liquid validator %s: %v", lv, err) + } + } + return nil +} diff --git a/x/liquidstake/types/genesis.pb.go b/x/liquidstake/types/genesis.pb.go new file mode 100644 index 0000000..b007358 --- /dev/null +++ b/x/liquidstake/types/genesis.pb.go @@ -0,0 +1,377 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pstake/liquidstake/v1beta1/genesis.proto + +package types + +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 + +// GenesisState defines the liquidstake module's genesis state. +type GenesisState struct { + // params defines all the parameters for the liquidstake module + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + LiquidValidators []LiquidValidator `protobuf:"bytes,2,rep,name=liquid_validators,json=liquidValidators,proto3" json:"liquid_validators"` +} + +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_bbc03e56b740bb6c, []int{0} +} +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 + +func init() { + proto.RegisterType((*GenesisState)(nil), "pstake.liquidstake.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("pstake/liquidstake/v1beta1/genesis.proto", fileDescriptor_bbc03e56b740bb6c) +} + +var fileDescriptor_bbc03e56b740bb6c = []byte{ + // 279 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x28, 0x2e, 0x49, + 0xcc, 0x4e, 0xd5, 0xcf, 0xc9, 0x2c, 0x2c, 0xcd, 0x4c, 0x81, 0xb0, 0xcb, 0x0c, 0x93, 0x52, 0x4b, + 0x12, 0x0d, 0xf5, 0xd3, 0x53, 0xf3, 0x52, 0x8b, 0x33, 0x8b, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, + 0x85, 0xa4, 0x20, 0x2a, 0xf5, 0x90, 0x54, 0xea, 0x41, 0x55, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, + 0x83, 0x95, 0xe9, 0x83, 0x58, 0x10, 0x1d, 0x52, 0x3a, 0x78, 0xcc, 0x46, 0x36, 0x05, 0xac, 0x5a, + 0x69, 0x17, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xc6, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x07, 0x2e, + 0xb6, 0x82, 0xc4, 0xa2, 0xc4, 0xdc, 0x62, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x25, 0x3d, + 0xdc, 0x2e, 0xd0, 0x0b, 0x00, 0xab, 0x74, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0x4f, + 0x28, 0x8e, 0x4b, 0x10, 0xa2, 0x36, 0xbe, 0x2c, 0x31, 0x27, 0x33, 0x25, 0xb1, 0x24, 0xbf, 0xa8, + 0x58, 0x82, 0x49, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x1b, 0x9f, 0x61, 0x3e, 0x60, 0xb1, 0x30, 0x98, + 0x1e, 0xa8, 0xa9, 0x02, 0x39, 0xa8, 0xc2, 0xc5, 0x56, 0x1c, 0x1d, 0x0b, 0xe4, 0x19, 0x5e, 0x2c, + 0x90, 0x67, 0x70, 0x8a, 0x59, 0xf1, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, + 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, + 0xe5, 0x18, 0xa2, 0xec, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, + 0x52, 0x8b, 0x8a, 0x33, 0x8b, 0x4b, 0x52, 0xf3, 0x92, 0x53, 0xfd, 0xf3, 0x52, 0xf5, 0x21, 0xae, + 0xd0, 0xcd, 0x4b, 0x2c, 0xc9, 0x2c, 0x4b, 0xd5, 0x2f, 0x33, 0xd2, 0xaf, 0x40, 0x09, 0xae, 0x92, + 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x08, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x54, + 0xe3, 0xaa, 0x70, 0xad, 0x01, 0x00, 0x00, +} + +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.LiquidValidators) > 0 { + for iNdEx := len(m.LiquidValidators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LiquidValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +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 *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.LiquidValidators) > 0 { + for _, e := range m.LiquidValidators { + l = e.Size() + 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 *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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidValidators", 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.LiquidValidators = append(m.LiquidValidators, LiquidValidator{}) + if err := m.LiquidValidators[len(m.LiquidValidators)-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 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/liquidstake/types/genesis_test.go b/x/liquidstake/types/genesis_test.go new file mode 100644 index 0000000..f13d548 --- /dev/null +++ b/x/liquidstake/types/genesis_test.go @@ -0,0 +1,64 @@ +package types_test + +import ( + "testing" + + "cosmossdk.io/math" + "github.com/stretchr/testify/require" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(genState *types.GenesisState) + expectedErr string + }{ + { + "default is valid", + func(genState *types.GenesisState) {}, + "", + }, + { + "invalid liquid validator address", + func(genState *types.GenesisState) { + genState.LiquidValidators = []types.LiquidValidator{ + { + OperatorAddress: "invalidAddr", + }, + } + }, + "invalid liquid validator {invalidAddr}: decoding bech32 failed: string not all lowercase or all uppercase: invalid address", + }, + { + "empty liquid validator address", + func(genState *types.GenesisState) { + genState.LiquidValidators = []types.LiquidValidator{ + { + OperatorAddress: "", + }, + } + }, + "invalid liquid validator {}: empty address string is not allowed: invalid address", + }, + { + "invalid params(UnstakeFeeRate)", + func(genState *types.GenesisState) { + genState.Params.UnstakeFeeRate = math.LegacyDec{} + }, + "unstake fee rate must not be nil", + }, + } { + t.Run(tc.name, func(t *testing.T) { + genState := types.DefaultGenesisState() + tc.malleate(genState) + err := types.ValidateGenesis(*genState) + if tc.expectedErr == "" { + require.NoError(t, err) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} diff --git a/x/liquidstake/types/keys.go b/x/liquidstake/types/keys.go new file mode 100644 index 0000000..9935daa --- /dev/null +++ b/x/liquidstake/types/keys.go @@ -0,0 +1,39 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" +) + +const ( + // ModuleName is the name of the liquidstake module + ModuleName = "liquidstake" + + // RouterKey is the message router key for the liquidstake module + RouterKey = ModuleName + + // StoreKey is the default store key for the liquidstake module + // To avoid collision with liquidstakeibc we make it xprtliquidstake + StoreKey = "xprt" + ModuleName + + // QuerierRoute is the querier route for the liquidstake module + QuerierRoute = ModuleName + + // Epoch identifiers + AutocompoundEpoch = "hour" + RebalanceEpoch = "day" +) + +var ( + ParamsKey = []byte{0x01} + + // LiquidValidatorsKey defines prefix for each key to a liquid validator + LiquidValidatorsKey = []byte{0x02} +) + +// GetLiquidValidatorKey creates the key for the liquid validator with address +// VALUE: liquidstake/LiquidValidator +func GetLiquidValidatorKey(operatorAddr sdk.ValAddress) []byte { + tmp := append([]byte{}, LiquidValidatorsKey...) + return append(tmp, address.MustLengthPrefix(operatorAddr)...) +} diff --git a/x/liquidstake/types/liquidstake.go b/x/liquidstake/types/liquidstake.go new file mode 100644 index 0000000..275ae38 --- /dev/null +++ b/x/liquidstake/types/liquidstake.go @@ -0,0 +1,215 @@ +package types + +import ( + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +type WhitelistedValsMap map[string]WhitelistedValidator + +func (whitelistedValsMap WhitelistedValsMap) IsListed(operatorAddr string) bool { + if _, ok := whitelistedValsMap[operatorAddr]; ok { + return true + } + + return false +} + +func GetWhitelistedValsMap(whitelistedValidators []WhitelistedValidator) WhitelistedValsMap { + whitelistedValsMap := make(WhitelistedValsMap) + for _, wv := range whitelistedValidators { + whitelistedValsMap[wv.ValidatorAddress] = wv + } + return whitelistedValsMap +} + +// Validate validates LiquidValidator. +func (v LiquidValidator) Validate() error { + _, valErr := sdk.ValAddressFromBech32(v.OperatorAddress) + if valErr != nil { + return valErr + } + return nil +} + +func (v LiquidValidator) GetOperator() sdk.ValAddress { + if v.OperatorAddress == "" { + return nil + } + addr, err := sdk.ValAddressFromBech32(v.OperatorAddress) + if err != nil { + panic(err) + } + return addr +} + +func (v LiquidValidator) GetDelShares(ctx sdk.Context, sk StakingKeeper) math.LegacyDec { + del, found := sk.GetDelegation(ctx, LiquidStakeProxyAcc, v.GetOperator()) + if !found { + return math.LegacyZeroDec() + } + return del.GetShares() +} + +func (v LiquidValidator) GetLiquidTokens(ctx sdk.Context, sk StakingKeeper, onlyBonded bool) math.Int { + delShares := v.GetDelShares(ctx, sk) + if !delShares.IsPositive() { + return math.ZeroInt() + } + val := sk.Validator(ctx, v.GetOperator()) + if onlyBonded && !val.IsBonded() { + return math.ZeroInt() + } + return val.TokensFromSharesTruncated(delShares).TruncateInt() +} + +func (v LiquidValidator) GetWeight(whitelistedValsMap WhitelistedValsMap, active bool) math.Int { + if wv, ok := whitelistedValsMap[v.OperatorAddress]; ok && active { + return wv.TargetWeight + } + + return math.ZeroInt() +} + +func (v LiquidValidator) GetStatus(activeCondition bool) ValidatorStatus { + if activeCondition { + return ValidatorStatusActive + } + + return ValidatorStatusInactive +} + +// ActiveCondition checks the liquid validator could be active by below cases +// - included on whitelist +// - existed valid validator on staking module ( existed, not nil del shares and tokens, valid exchange rate) +// - not tombstoned +func ActiveCondition(validator stakingtypes.Validator, whitelisted, tombstoned bool) bool { + return whitelisted && + !tombstoned && + // !Unspecified ==> Bonded, Unbonding, Unbonded + validator.GetStatus() != stakingtypes.Unspecified && + !validator.GetTokens().IsNil() && + !validator.GetDelegatorShares().IsNil() && + !validator.InvalidExRate() +} + +// LiquidValidators is a collection of LiquidValidator +type ( + LiquidValidators []LiquidValidator + ActiveLiquidValidators LiquidValidators +) + +// MinMaxGap Return the list of LiquidValidator with the maximum gap and minimum gap from the target weight of LiquidValidators, respectively. +func (vs LiquidValidators) MinMaxGap(targetMap, liquidTokenMap map[string]math.Int) (minGapVal, maxGapVal LiquidValidator, amountNeeded math.Int, lastRedelegation bool) { + maxGap := math.ZeroInt() + minGap := math.ZeroInt() + + for _, val := range vs { + gap := liquidTokenMap[val.OperatorAddress].Sub(targetMap[val.OperatorAddress]) + if gap.GT(maxGap) { + maxGap = gap + maxGapVal = val + } + if gap.LT(minGap) { + minGap = gap + minGapVal = val + } + } + amountNeeded = math.MinInt(maxGap, minGap.Abs()) + // lastRedelegation when maxGap validator's liquid token == amountNeeded for redelegation all delShares + lastRedelegation = amountNeeded.IsPositive() && + !targetMap[maxGapVal.OperatorAddress].IsPositive() && + liquidTokenMap[maxGapVal.OperatorAddress].Equal(amountNeeded) + + return minGapVal, maxGapVal, amountNeeded, lastRedelegation +} + +func (vs LiquidValidators) Len() int { + return len(vs) +} + +func (vs LiquidValidators) TotalLiquidTokens(ctx sdk.Context, sk StakingKeeper, onlyBonded bool) (math.Int, map[string]math.Int) { + totalLiquidTokens := math.ZeroInt() + liquidTokenMap := map[string]math.Int{} + for _, lv := range vs { + liquidTokens := lv.GetLiquidTokens(ctx, sk, onlyBonded) + liquidTokenMap[lv.OperatorAddress] = liquidTokens + totalLiquidTokens = totalLiquidTokens.Add(liquidTokens) + } + return totalLiquidTokens, liquidTokenMap +} + +func (vs LiquidValidators) Map() map[string]struct{} { + valsMap := map[string]struct{}{} + for _, val := range vs { + valsMap[val.OperatorAddress] = struct{}{} + } + return valsMap +} + +func (avs ActiveLiquidValidators) Len() int { + return LiquidValidators(avs).Len() +} + +func (avs ActiveLiquidValidators) TotalActiveLiquidTokens(ctx sdk.Context, sk StakingKeeper, onlyBonded bool) (math.Int, map[string]math.Int) { + return LiquidValidators(avs).TotalLiquidTokens(ctx, sk, onlyBonded) +} + +// TotalWeight for active liquid validator +func (avs ActiveLiquidValidators) TotalWeight(whitelistedValsMap WhitelistedValsMap) math.Int { + totalWeight := math.ZeroInt() + for _, val := range avs { + totalWeight = totalWeight.Add(val.GetWeight(whitelistedValsMap, true)) + } + return totalWeight +} + +// NativeTokenToStkXPRT returns StkxprtTotalSupply * nativeTokenAmount / netAmount +func NativeTokenToStkXPRT(nativeTokenAmount, stkXPRTTotalSupplyAmount math.Int, netAmount math.LegacyDec) (stkXPRTAmount math.Int) { + return math.LegacyNewDecFromInt(stkXPRTTotalSupplyAmount).MulTruncate(math.LegacyNewDecFromInt(nativeTokenAmount)).QuoTruncate(netAmount.TruncateDec()).TruncateInt() +} + +// StkXPRTToNativeToken returns stkXPRTAmount * netAmount / StkxprtTotalSupply with truncations +func StkXPRTToNativeToken(stkXPRTAmount, stkXPRTTotalSupplyAmount math.Int, netAmount math.LegacyDec) (nativeTokenAmount math.LegacyDec) { + return math.LegacyNewDecFromInt(stkXPRTAmount).MulTruncate(netAmount).Quo(math.LegacyNewDecFromInt(stkXPRTTotalSupplyAmount)).TruncateDec() +} + +// DeductFeeRate returns Input * (1-FeeRate) with truncations +func DeductFeeRate(input, feeRate math.LegacyDec) (feeDeductedOutput math.LegacyDec) { + return input.MulTruncate(math.LegacyOneDec().Sub(feeRate)).TruncateDec() +} + +func (nas NetAmountState) CalcNetAmount() math.LegacyDec { + return math.LegacyNewDecFromInt(nas.TotalLiquidTokens.Add(nas.TotalUnbondingBalance)) +} + +func (nas NetAmountState) CalcMintRate() math.LegacyDec { + if nas.NetAmount.IsNil() || !nas.NetAmount.IsPositive() { + return math.LegacyZeroDec() + } + return math.LegacyNewDecFromInt(nas.StkxprtTotalSupply).QuoTruncate(nas.NetAmount) +} + +type LiquidValidatorStates []LiquidValidatorState + +func MustMarshalLiquidValidator(cdc codec.BinaryCodec, val *LiquidValidator) []byte { + return cdc.MustMarshal(val) +} + +// must unmarshal a liquid validator from a store value +func MustUnmarshalLiquidValidator(cdc codec.BinaryCodec, value []byte) LiquidValidator { + validator, err := UnmarshalLiquidValidator(cdc, value) + if err != nil { + panic(err) + } + + return validator +} + +// unmarshal a liquid validator from a store value +func UnmarshalLiquidValidator(cdc codec.BinaryCodec, value []byte) (val LiquidValidator, err error) { + err = cdc.Unmarshal(value, &val) + return val, err +} diff --git a/x/liquidstake/types/liquidstake.pb.go b/x/liquidstake/types/liquidstake.pb.go new file mode 100644 index 0000000..fba8251 --- /dev/null +++ b/x/liquidstake/types/liquidstake.pb.go @@ -0,0 +1,2056 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pstake/liquidstake/v1beta1/liquidstake.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "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 + +// ValidatorStatus enumerates the status of a liquid validator. +type ValidatorStatus int32 + +const ( + // VALIDATOR_STATUS_UNSPECIFIED defines the unspecified invalid status. + ValidatorStatusUnspecified ValidatorStatus = 0 + // VALIDATOR_STATUS_ACTIVE defines the active, valid status + ValidatorStatusActive ValidatorStatus = 1 + // VALIDATOR_STATUS_INACTIVE defines the inactive, invalid status + ValidatorStatusInactive ValidatorStatus = 2 +) + +var ValidatorStatus_name = map[int32]string{ + 0: "VALIDATOR_STATUS_UNSPECIFIED", + 1: "VALIDATOR_STATUS_ACTIVE", + 2: "VALIDATOR_STATUS_INACTIVE", +} + +var ValidatorStatus_value = map[string]int32{ + "VALIDATOR_STATUS_UNSPECIFIED": 0, + "VALIDATOR_STATUS_ACTIVE": 1, + "VALIDATOR_STATUS_INACTIVE": 2, +} + +func (x ValidatorStatus) String() string { + return proto.EnumName(ValidatorStatus_name, int32(x)) +} + +func (ValidatorStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_8f87e6d47a5a3bba, []int{0} +} + +// Params defines the set of params for the liquidstake module. +type Params struct { + // LiquidBondDenom specifies the denomination of the token receiving after + // liquid stake, The value is calculated through NetAmount. + LiquidBondDenom string `protobuf:"bytes,1,opt,name=liquid_bond_denom,json=liquidBondDenom,proto3" json:"liquid_bond_denom,omitempty"` + // WhitelistedValidators specifies the validators elected to become Active + // Liquid Validators. + WhitelistedValidators []WhitelistedValidator `protobuf:"bytes,2,rep,name=whitelisted_validators,json=whitelistedValidators,proto3" json:"whitelisted_validators"` + // UnstakeFeeRate specifies the fee rate when liquid unstake is requested, + // unbonded by subtracting it from unbondingAmount + UnstakeFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=unstake_fee_rate,json=unstakeFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"unstake_fee_rate"` + // LsmDisabled allows to block any msgs that convert staked tokens into + // stkXPRT through LSM. + LsmDisabled bool `protobuf:"varint,4,opt,name=lsm_disabled,json=lsmDisabled,proto3" json:"lsm_disabled,omitempty"` + // MinLiquidStakingAmount specifies the minimum number of coins to be staked + // to the active liquid validators on liquid staking to minimize decimal loss + // and consider gas efficiency. + MinLiquidStakeAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=min_liquid_stake_amount,json=minLiquidStakeAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_liquid_stake_amount"` + // CwLockedPoolAddress defines the bech32-encoded address of + // a CW smart-contract representing a time locked LP (e.g. Superfluid LP). + CwLockedPoolAddress string `protobuf:"bytes,6,opt,name=cw_locked_pool_address,json=cwLockedPoolAddress,proto3" json:"cw_locked_pool_address,omitempty"` + // FeeAccountAddress defines the bech32-encoded address of + // a an account responsible for accumulating protocol fees. + FeeAccountAddress string `protobuf:"bytes,7,opt,name=fee_account_address,json=feeAccountAddress,proto3" json:"fee_account_address,omitempty"` + // AutocompoundFeeRate specifies the fee rate for auto redelegating the stake + // rewards. The fee is taken in favour of the fee account (see + // FeeAccountAddress). + AutocompoundFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=autocompound_fee_rate,json=autocompoundFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"autocompound_fee_rate"` + // WhitelistAdminAddress the bech32-encoded address of an admin authority + // that is allowed to update whitelisted validators or pause liquidstaking + // module entirely. The key is controlled by an offchain process that is + // selecting validators based on a criteria. Pausing of the module can be + // required during important migrations or failures. + WhitelistAdminAddress string `protobuf:"bytes,9,opt,name=whitelist_admin_address,json=whitelistAdminAddress,proto3" json:"whitelist_admin_address,omitempty"` + // ModulePaused is a safety toggle that allows to stop main module functions + // such as stake/unstake/stake-to-lp and the BeginBlocker logic. + ModulePaused bool `protobuf:"varint,10,opt,name=module_paused,json=modulePaused,proto3" json:"module_paused,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_8f87e6d47a5a3bba, []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 + +// WhitelistedValidator consists of the validator operator address and the +// target weight, which is a value for calculating the real weight to be derived +// according to the active status. +type WhitelistedValidator struct { + // validator_address defines the bech32-encoded address that whitelisted + // validator + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // target_weight specifies the target weight for liquid staking, unstaking + // amount, which is a value for calculating the real weight to be derived + // according to the active status + TargetWeight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=target_weight,json=targetWeight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"target_weight"` +} + +func (m *WhitelistedValidator) Reset() { *m = WhitelistedValidator{} } +func (m *WhitelistedValidator) String() string { return proto.CompactTextString(m) } +func (*WhitelistedValidator) ProtoMessage() {} +func (*WhitelistedValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_8f87e6d47a5a3bba, []int{1} +} +func (m *WhitelistedValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WhitelistedValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WhitelistedValidator.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 *WhitelistedValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_WhitelistedValidator.Merge(m, src) +} +func (m *WhitelistedValidator) XXX_Size() int { + return m.Size() +} +func (m *WhitelistedValidator) XXX_DiscardUnknown() { + xxx_messageInfo_WhitelistedValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_WhitelistedValidator proto.InternalMessageInfo + +// LiquidValidator defines a Validator that can be the target of LiquidStaking +// and LiquidUnstaking, Active, Weight, etc. fields are derived as functions to +// deal with by maintaining consistency with the state of the staking module. +type LiquidValidator struct { + // operator_address defines the address of the validator's operator; bech + // encoded in JSON. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` +} + +func (m *LiquidValidator) Reset() { *m = LiquidValidator{} } +func (m *LiquidValidator) String() string { return proto.CompactTextString(m) } +func (*LiquidValidator) ProtoMessage() {} +func (*LiquidValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_8f87e6d47a5a3bba, []int{2} +} +func (m *LiquidValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LiquidValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LiquidValidator.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 *LiquidValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiquidValidator.Merge(m, src) +} +func (m *LiquidValidator) XXX_Size() int { + return m.Size() +} +func (m *LiquidValidator) XXX_DiscardUnknown() { + xxx_messageInfo_LiquidValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_LiquidValidator proto.InternalMessageInfo + +// LiquidValidatorState is type LiquidValidator with state added to return to +// query results. +type LiquidValidatorState struct { + // operator_address defines the address of the validator's operator; bech + // encoded in JSON. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // weight specifies the weight for liquid staking, unstaking amount + Weight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"weight"` + // status is the liquid validator status + Status ValidatorStatus `protobuf:"varint,3,opt,name=status,proto3,enum=pstake.liquidstake.v1beta1.ValidatorStatus" json:"status,omitempty"` + // del_shares define the delegation shares of the validator + DelShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=del_shares,json=delShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"del_shares"` + // liquid_tokens define the token amount worth of delegation shares of the + // validator (slashing applied amount) + LiquidTokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=liquid_tokens,json=liquidTokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"liquid_tokens"` +} + +func (m *LiquidValidatorState) Reset() { *m = LiquidValidatorState{} } +func (m *LiquidValidatorState) String() string { return proto.CompactTextString(m) } +func (*LiquidValidatorState) ProtoMessage() {} +func (*LiquidValidatorState) Descriptor() ([]byte, []int) { + return fileDescriptor_8f87e6d47a5a3bba, []int{3} +} +func (m *LiquidValidatorState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LiquidValidatorState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LiquidValidatorState.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 *LiquidValidatorState) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiquidValidatorState.Merge(m, src) +} +func (m *LiquidValidatorState) XXX_Size() int { + return m.Size() +} +func (m *LiquidValidatorState) XXX_DiscardUnknown() { + xxx_messageInfo_LiquidValidatorState.DiscardUnknown(m) +} + +var xxx_messageInfo_LiquidValidatorState proto.InternalMessageInfo + +// NetAmountState is type for net amount raw data and mint rate, This is a value +// that depends on the several module state every time, so it is used only for +// calculation and query and is not stored in kv. +type NetAmountState struct { + // mint_rate is stkXPRTTotalSupply / NetAmount + MintRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=mint_rate,json=mintRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"mint_rate"` + // btoken_total_supply returns the total supply of stk/uxprt (stkXPRT denom) + StkxprtTotalSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=stkxprt_total_supply,json=stkxprtTotalSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"stkxprt_total_supply"` + // net_amount is proxy account's native token balance + total liquid tokens + + // total remaining rewards + total unbonding balance + NetAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=net_amount,json=netAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"net_amount"` + // total_del_shares define the delegation shares of all liquid validators + TotalDelShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=total_del_shares,json=totalDelShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"total_del_shares"` + // total_liquid_tokens define the token amount worth of delegation shares of + // all liquid validator (slashing applied amount) + TotalLiquidTokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=total_liquid_tokens,json=totalLiquidTokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_liquid_tokens"` + // total_remaining_rewards define the sum of remaining rewards of proxy + // account by all liquid validators + TotalRemainingRewards github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=total_remaining_rewards,json=totalRemainingRewards,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"total_remaining_rewards"` + // total_unbonding_balance define the unbonding balance of proxy account by + // all liquid validator (slashing applied amount) + TotalUnbondingBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=total_unbonding_balance,json=totalUnbondingBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_unbonding_balance"` + // proxy_acc_balance define the balance of proxy account for the native token + ProxyAccBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=proxy_acc_balance,json=proxyAccBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"proxy_acc_balance"` +} + +func (m *NetAmountState) Reset() { *m = NetAmountState{} } +func (m *NetAmountState) String() string { return proto.CompactTextString(m) } +func (*NetAmountState) ProtoMessage() {} +func (*NetAmountState) Descriptor() ([]byte, []int) { + return fileDescriptor_8f87e6d47a5a3bba, []int{4} +} +func (m *NetAmountState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NetAmountState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NetAmountState.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 *NetAmountState) XXX_Merge(src proto.Message) { + xxx_messageInfo_NetAmountState.Merge(m, src) +} +func (m *NetAmountState) XXX_Size() int { + return m.Size() +} +func (m *NetAmountState) XXX_DiscardUnknown() { + xxx_messageInfo_NetAmountState.DiscardUnknown(m) +} + +var xxx_messageInfo_NetAmountState proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("pstake.liquidstake.v1beta1.ValidatorStatus", ValidatorStatus_name, ValidatorStatus_value) + proto.RegisterType((*Params)(nil), "pstake.liquidstake.v1beta1.Params") + proto.RegisterType((*WhitelistedValidator)(nil), "pstake.liquidstake.v1beta1.WhitelistedValidator") + proto.RegisterType((*LiquidValidator)(nil), "pstake.liquidstake.v1beta1.LiquidValidator") + proto.RegisterType((*LiquidValidatorState)(nil), "pstake.liquidstake.v1beta1.LiquidValidatorState") + proto.RegisterType((*NetAmountState)(nil), "pstake.liquidstake.v1beta1.NetAmountState") +} + +func init() { + proto.RegisterFile("pstake/liquidstake/v1beta1/liquidstake.proto", fileDescriptor_8f87e6d47a5a3bba) +} + +var fileDescriptor_8f87e6d47a5a3bba = []byte{ + // 1007 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xc1, 0x6e, 0x1b, 0x45, + 0x18, 0xc7, 0xbd, 0x4d, 0x6a, 0x92, 0x69, 0x9a, 0xc4, 0x1b, 0xa7, 0x76, 0x0c, 0x72, 0x4c, 0x90, + 0x50, 0x54, 0x88, 0x4d, 0x83, 0xc4, 0x21, 0x07, 0xc4, 0x3a, 0x4e, 0x84, 0x45, 0x9a, 0x5a, 0x6b, + 0x27, 0xad, 0x7a, 0x60, 0x3a, 0xde, 0x99, 0x38, 0x2b, 0xef, 0xce, 0x2c, 0x3b, 0xb3, 0x71, 0xf2, + 0x00, 0x48, 0x55, 0x4e, 0x9c, 0x10, 0x97, 0x48, 0x95, 0x78, 0x05, 0x0e, 0x3c, 0x42, 0x2f, 0x48, + 0x15, 0x27, 0xc4, 0xa1, 0x42, 0xc9, 0x85, 0xa7, 0x40, 0x68, 0x66, 0x76, 0x6d, 0xd7, 0x2d, 0x44, + 0x76, 0x7b, 0xf2, 0x7a, 0x66, 0xff, 0xbf, 0xef, 0x9b, 0xef, 0x3f, 0xf3, 0xcd, 0x82, 0x4f, 0x03, + 0x2e, 0x50, 0x97, 0x54, 0x3c, 0xf7, 0xbb, 0xc8, 0xc5, 0xfa, 0xf9, 0xe4, 0x5e, 0x9b, 0x08, 0x74, + 0x6f, 0x78, 0xac, 0x1c, 0x84, 0x4c, 0x30, 0xb3, 0xa0, 0xdf, 0x2e, 0x0f, 0xcf, 0xc4, 0x6f, 0x17, + 0xb2, 0x1d, 0xd6, 0x61, 0xea, 0xb5, 0x8a, 0x7c, 0xd2, 0x8a, 0xc2, 0x8a, 0xc3, 0xb8, 0xcf, 0x38, + 0xd4, 0x13, 0xfa, 0x8f, 0x9e, 0x5a, 0xfb, 0x3e, 0x0d, 0xd2, 0x0d, 0x14, 0x22, 0x9f, 0x9b, 0x77, + 0x41, 0x46, 0x23, 0x61, 0x9b, 0x51, 0x0c, 0x31, 0xa1, 0xcc, 0xcf, 0x1b, 0x25, 0x63, 0x7d, 0xd6, + 0x5e, 0xd0, 0x13, 0x55, 0x46, 0x71, 0x4d, 0x0e, 0x9b, 0x3e, 0xb8, 0xd3, 0x3b, 0x76, 0x05, 0xf1, + 0x5c, 0x2e, 0x08, 0x86, 0x27, 0xc8, 0x73, 0x31, 0x12, 0x2c, 0xe4, 0xf9, 0x1b, 0xa5, 0xa9, 0xf5, + 0x5b, 0x9b, 0x9f, 0x95, 0xff, 0x3b, 0xc9, 0xf2, 0xc3, 0x81, 0xf2, 0x30, 0x11, 0x56, 0xa7, 0x9f, + 0xbf, 0x5c, 0x4d, 0xd9, 0xcb, 0xbd, 0x37, 0xcc, 0x71, 0xf3, 0x11, 0x58, 0x8c, 0xa8, 0x82, 0xc0, + 0x23, 0x42, 0x60, 0x88, 0x04, 0xc9, 0x4f, 0xc9, 0xcc, 0xaa, 0x65, 0x29, 0xfb, 0xf3, 0xe5, 0xea, + 0xc7, 0x1d, 0x57, 0x1c, 0x47, 0xed, 0xb2, 0xc3, 0xfc, 0x78, 0x81, 0xf1, 0xcf, 0x06, 0xc7, 0xdd, + 0x8a, 0x38, 0x0b, 0x08, 0x2f, 0xd7, 0x88, 0x63, 0xcf, 0xc7, 0x9c, 0x5d, 0x42, 0x6c, 0x24, 0x88, + 0xf9, 0x21, 0x98, 0xf3, 0xb8, 0x0f, 0xb1, 0xcb, 0x51, 0xdb, 0x23, 0x38, 0x3f, 0x5d, 0x32, 0xd6, + 0x67, 0xec, 0x5b, 0x1e, 0xf7, 0x6b, 0xf1, 0x90, 0x49, 0x40, 0xce, 0x77, 0x29, 0x8c, 0x6b, 0xa3, + 0xb3, 0x40, 0x3e, 0x8b, 0xa8, 0xc8, 0xdf, 0x1c, 0x3b, 0x87, 0x3a, 0x15, 0x76, 0xd6, 0x77, 0xe9, + 0x9e, 0xa2, 0x35, 0x25, 0xcc, 0x52, 0x2c, 0xf3, 0x3e, 0xb8, 0xe3, 0xf4, 0xa0, 0xc7, 0x9c, 0x2e, + 0xc1, 0x30, 0x60, 0xcc, 0x83, 0x08, 0xe3, 0x90, 0x70, 0x9e, 0x4f, 0xab, 0x28, 0xf9, 0xdf, 0x7f, + 0xd9, 0xc8, 0xc6, 0xde, 0x59, 0x7a, 0xa6, 0x29, 0x42, 0x97, 0x76, 0xec, 0x25, 0xa7, 0xb7, 0xa7, + 0x64, 0x0d, 0xc6, 0xbc, 0x78, 0xca, 0xfc, 0x1a, 0x2c, 0xc9, 0x52, 0x21, 0xc7, 0x91, 0xf4, 0x3e, + 0xeb, 0xbd, 0x6b, 0x58, 0x99, 0x23, 0x42, 0x2c, 0xad, 0x49, 0x48, 0x6d, 0xb0, 0x8c, 0x22, 0xc1, + 0x1c, 0xe6, 0x07, 0x2c, 0xa2, 0x78, 0xe0, 0xc0, 0xcc, 0x44, 0x0e, 0x2c, 0x0d, 0xc3, 0x12, 0x1b, + 0x1a, 0x20, 0xd7, 0x77, 0x1e, 0x22, 0x2c, 0xeb, 0x9d, 0x64, 0x3c, 0x7b, 0x4d, 0xc6, 0x83, 0x2d, + 0x63, 0x49, 0x5d, 0x92, 0xf5, 0x47, 0xe0, 0xb6, 0xcf, 0x70, 0xe4, 0x11, 0x18, 0xa0, 0x88, 0x13, + 0x9c, 0x07, 0xca, 0xd9, 0x39, 0x3d, 0xd8, 0x50, 0x63, 0x5b, 0x33, 0x4f, 0x9f, 0xad, 0xa6, 0x7e, + 0x7a, 0xb6, 0x9a, 0x5a, 0xfb, 0xd5, 0x00, 0xd9, 0x37, 0xed, 0x4b, 0x73, 0x07, 0x64, 0xfa, 0xbb, + 0xbb, 0x9f, 0x93, 0x71, 0x4d, 0x4e, 0x8b, 0x7d, 0x49, 0x92, 0x4e, 0x13, 0xdc, 0x16, 0x28, 0xec, + 0x10, 0x01, 0x7b, 0xc4, 0xed, 0x1c, 0x8b, 0xfc, 0x8d, 0x89, 0xb6, 0xce, 0x9c, 0x86, 0x3c, 0x54, + 0x8c, 0xad, 0x69, 0x99, 0xfe, 0xda, 0x13, 0xb0, 0xa0, 0x77, 0xd3, 0x20, 0xe9, 0x6d, 0xb0, 0xc8, + 0x02, 0x12, 0x8e, 0x95, 0xf3, 0x42, 0xa2, 0x88, 0x87, 0x75, 0x71, 0xfe, 0x96, 0x11, 0x7e, 0x9c, + 0x02, 0xd9, 0x91, 0x10, 0x4d, 0x21, 0x6d, 0x7b, 0x17, 0x71, 0xcc, 0x5d, 0x90, 0x7e, 0xab, 0x9a, + 0xc4, 0x6a, 0x73, 0x1b, 0xa4, 0xb9, 0x40, 0x22, 0xe2, 0xaa, 0x35, 0xcc, 0x6f, 0x7e, 0xf2, 0x7f, + 0x3d, 0xe8, 0x95, 0x85, 0x44, 0xdc, 0x8e, 0xa5, 0xe6, 0x7d, 0x00, 0x30, 0xf1, 0x20, 0x3f, 0x46, + 0x21, 0xe1, 0xaa, 0x1b, 0x8c, 0xbf, 0xc3, 0x67, 0x31, 0xf1, 0x9a, 0x0a, 0x20, 0x6d, 0x8f, 0xfb, + 0x86, 0x60, 0x5d, 0x42, 0xf9, 0x84, 0x1d, 0x63, 0x4e, 0x43, 0x5a, 0x8a, 0x31, 0x64, 0xcc, 0x3f, + 0x37, 0xc1, 0xfc, 0x3e, 0x11, 0xba, 0x83, 0x68, 0x4b, 0xbe, 0x01, 0xb3, 0xbe, 0x4b, 0x85, 0x3e, + 0xa1, 0xc6, 0x44, 0xf9, 0xcf, 0x48, 0x80, 0x3a, 0x96, 0x4f, 0x40, 0x96, 0x8b, 0xee, 0x69, 0x10, + 0x0a, 0x28, 0x98, 0x40, 0x1e, 0xe4, 0x51, 0x10, 0x78, 0x67, 0x13, 0x1a, 0x65, 0xc6, 0xac, 0x96, + 0x44, 0x35, 0x15, 0x49, 0xd6, 0x9b, 0x12, 0x91, 0xf4, 0xd3, 0xc9, 0x7a, 0xfa, 0x2c, 0x4d, 0x4a, + 0x20, 0x2f, 0x0a, 0x9d, 0xe8, 0x5b, 0x9b, 0x38, 0xaf, 0x38, 0xb5, 0xbe, 0x93, 0xdf, 0x82, 0x25, + 0x4d, 0x7e, 0x17, 0x7e, 0x66, 0x14, 0x6a, 0x6f, 0xc8, 0x54, 0xf3, 0x08, 0xe4, 0x34, 0x3f, 0x24, + 0x3e, 0x72, 0xa9, 0x4b, 0x3b, 0x30, 0x24, 0x3d, 0x14, 0xe2, 0xa4, 0xff, 0x8f, 0xbb, 0x80, 0x65, + 0x85, 0xb3, 0x13, 0x9a, 0xad, 0x61, 0x83, 0x38, 0x11, 0x95, 0xd7, 0xbc, 0x8c, 0xd3, 0x46, 0x1e, + 0xa2, 0x0e, 0x89, 0xef, 0x86, 0x71, 0xd7, 0xa2, 0xe3, 0x1c, 0x24, 0xb4, 0xaa, 0x86, 0x99, 0x8f, + 0x41, 0x26, 0x08, 0xd9, 0xe9, 0x99, 0xbc, 0x81, 0xfa, 0x11, 0x66, 0x26, 0x8a, 0xb0, 0xa0, 0x40, + 0x96, 0xe3, 0xc4, 0x6c, 0x75, 0x00, 0x0c, 0x79, 0x00, 0xee, 0xfe, 0x66, 0x80, 0x85, 0x91, 0xa3, + 0x6c, 0x7e, 0x05, 0x3e, 0x38, 0xb4, 0xf6, 0xea, 0x35, 0xab, 0xf5, 0xc0, 0x86, 0xcd, 0x96, 0xd5, + 0x3a, 0x68, 0xc2, 0x83, 0xfd, 0x66, 0x63, 0x67, 0xbb, 0xbe, 0x5b, 0xdf, 0xa9, 0x2d, 0xa6, 0x0a, + 0xc5, 0xf3, 0x8b, 0x52, 0x61, 0x44, 0x76, 0x40, 0x79, 0x40, 0x1c, 0xf7, 0xc8, 0x25, 0xd8, 0xfc, + 0x02, 0xe4, 0x5e, 0x23, 0x58, 0xdb, 0xad, 0xfa, 0xe1, 0xce, 0xa2, 0x51, 0x58, 0x39, 0xbf, 0x28, + 0x2d, 0x8f, 0x88, 0x2d, 0x47, 0xb8, 0x27, 0xc4, 0xdc, 0x02, 0x2b, 0xaf, 0xe9, 0xea, 0xfb, 0xb1, + 0xf2, 0x46, 0xe1, 0xfd, 0xf3, 0x8b, 0x52, 0x6e, 0x44, 0x59, 0xa7, 0x48, 0x69, 0x0b, 0xd3, 0x4f, + 0x7f, 0x2e, 0xa6, 0xaa, 0x8f, 0x9e, 0x5f, 0x16, 0x8d, 0x17, 0x97, 0x45, 0xe3, 0xaf, 0xcb, 0xa2, + 0xf1, 0xc3, 0x55, 0x31, 0xf5, 0xe2, 0xaa, 0x98, 0xfa, 0xe3, 0xaa, 0x98, 0x7a, 0xfc, 0xe5, 0x50, + 0xb1, 0x02, 0x12, 0x72, 0x79, 0x4d, 0x51, 0x87, 0x3c, 0xa0, 0xa4, 0xa2, 0xdb, 0xdc, 0x06, 0x45, + 0x12, 0x54, 0x39, 0xd9, 0xac, 0x9c, 0xbe, 0xf2, 0x25, 0xa9, 0x0a, 0xd9, 0x4e, 0xab, 0xef, 0xbd, + 0xcf, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x53, 0xe1, 0xf8, 0x6c, 0x0a, 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.ModulePaused { + i-- + if m.ModulePaused { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x50 + } + if len(m.WhitelistAdminAddress) > 0 { + i -= len(m.WhitelistAdminAddress) + copy(dAtA[i:], m.WhitelistAdminAddress) + i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.WhitelistAdminAddress))) + i-- + dAtA[i] = 0x4a + } + { + size := m.AutocompoundFeeRate.Size() + i -= size + if _, err := m.AutocompoundFeeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + if len(m.FeeAccountAddress) > 0 { + i -= len(m.FeeAccountAddress) + copy(dAtA[i:], m.FeeAccountAddress) + i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.FeeAccountAddress))) + i-- + dAtA[i] = 0x3a + } + if len(m.CwLockedPoolAddress) > 0 { + i -= len(m.CwLockedPoolAddress) + copy(dAtA[i:], m.CwLockedPoolAddress) + i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.CwLockedPoolAddress))) + i-- + dAtA[i] = 0x32 + } + { + size := m.MinLiquidStakeAmount.Size() + i -= size + if _, err := m.MinLiquidStakeAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if m.LsmDisabled { + i-- + if m.LsmDisabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + { + size := m.UnstakeFeeRate.Size() + i -= size + if _, err := m.UnstakeFeeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.WhitelistedValidators) > 0 { + for iNdEx := len(m.WhitelistedValidators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WhitelistedValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.LiquidBondDenom) > 0 { + i -= len(m.LiquidBondDenom) + copy(dAtA[i:], m.LiquidBondDenom) + i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.LiquidBondDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *WhitelistedValidator) 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 *WhitelistedValidator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WhitelistedValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TargetWeight.Size() + i -= size + if _, err := m.TargetWeight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LiquidValidator) 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 *LiquidValidator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LiquidValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LiquidValidatorState) 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 *LiquidValidatorState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LiquidValidatorState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.LiquidTokens.Size() + i -= size + if _, err := m.LiquidTokens.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.DelShares.Size() + i -= size + if _, err := m.DelShares.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Status != 0 { + i = encodeVarintLiquidstake(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Weight.Size() + i -= size + if _, err := m.Weight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *NetAmountState) 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 *NetAmountState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NetAmountState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.ProxyAccBalance.Size() + i -= size + if _, err := m.ProxyAccBalance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.TotalUnbondingBalance.Size() + i -= size + if _, err := m.TotalUnbondingBalance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.TotalRemainingRewards.Size() + i -= size + if _, err := m.TotalRemainingRewards.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.TotalLiquidTokens.Size() + i -= size + if _, err := m.TotalLiquidTokens.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.TotalDelShares.Size() + i -= size + if _, err := m.TotalDelShares.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.NetAmount.Size() + i -= size + if _, err := m.NetAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.StkxprtTotalSupply.Size() + i -= size + if _, err := m.StkxprtTotalSupply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.MintRate.Size() + i -= size + if _, err := m.MintRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidstake(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintLiquidstake(dAtA []byte, offset int, v uint64) int { + offset -= sovLiquidstake(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 + l = len(m.LiquidBondDenom) + if l > 0 { + n += 1 + l + sovLiquidstake(uint64(l)) + } + if len(m.WhitelistedValidators) > 0 { + for _, e := range m.WhitelistedValidators { + l = e.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + } + } + l = m.UnstakeFeeRate.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + if m.LsmDisabled { + n += 2 + } + l = m.MinLiquidStakeAmount.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = len(m.CwLockedPoolAddress) + if l > 0 { + n += 1 + l + sovLiquidstake(uint64(l)) + } + l = len(m.FeeAccountAddress) + if l > 0 { + n += 1 + l + sovLiquidstake(uint64(l)) + } + l = m.AutocompoundFeeRate.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = len(m.WhitelistAdminAddress) + if l > 0 { + n += 1 + l + sovLiquidstake(uint64(l)) + } + if m.ModulePaused { + n += 2 + } + return n +} + +func (m *WhitelistedValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovLiquidstake(uint64(l)) + } + l = m.TargetWeight.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + return n +} + +func (m *LiquidValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovLiquidstake(uint64(l)) + } + return n +} + +func (m *LiquidValidatorState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovLiquidstake(uint64(l)) + } + l = m.Weight.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + if m.Status != 0 { + n += 1 + sovLiquidstake(uint64(m.Status)) + } + l = m.DelShares.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.LiquidTokens.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + return n +} + +func (m *NetAmountState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.MintRate.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.StkxprtTotalSupply.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.NetAmount.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.TotalDelShares.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.TotalLiquidTokens.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.TotalRemainingRewards.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.TotalUnbondingBalance.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + l = m.ProxyAccBalance.Size() + n += 1 + l + sovLiquidstake(uint64(l)) + return n +} + +func sovLiquidstake(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLiquidstake(x uint64) (n int) { + return sovLiquidstake(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 ErrIntOverflowLiquidstake + } + 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidBondDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidBondDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedValidators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistedValidators = append(m.WhitelistedValidators, WhitelistedValidator{}) + if err := m.WhitelistedValidators[len(m.WhitelistedValidators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnstakeFeeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UnstakeFeeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LsmDisabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LsmDisabled = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinLiquidStakeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinLiquidStakeAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CwLockedPoolAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CwLockedPoolAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeAccountAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeAccountAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AutocompoundFeeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AutocompoundFeeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistAdminAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistAdminAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ModulePaused", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ModulePaused = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipLiquidstake(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidstake + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *WhitelistedValidator) 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 ErrIntOverflowLiquidstake + } + 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: WhitelistedValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WhitelistedValidator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TargetWeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidstake(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidstake + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LiquidValidator) 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 ErrIntOverflowLiquidstake + } + 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: LiquidValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LiquidValidator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidstake(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidstake + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LiquidValidatorState) 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 ErrIntOverflowLiquidstake + } + 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: LiquidValidatorState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LiquidValidatorState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Weight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= ValidatorStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelShares", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DelShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidTokens", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LiquidTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidstake(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidstake + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NetAmountState) 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 ErrIntOverflowLiquidstake + } + 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: NetAmountState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NetAmountState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MintRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StkxprtTotalSupply", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StkxprtTotalSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NetAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NetAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalDelShares", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalDelShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalLiquidTokens", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalLiquidTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalRemainingRewards", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalRemainingRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalUnbondingBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalUnbondingBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProxyAccBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidstake + } + 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 ErrInvalidLengthLiquidstake + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidstake + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProxyAccBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidstake(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidstake + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLiquidstake(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, ErrIntOverflowLiquidstake + } + 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, ErrIntOverflowLiquidstake + } + 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, ErrIntOverflowLiquidstake + } + 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, ErrInvalidLengthLiquidstake + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLiquidstake + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLiquidstake + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLiquidstake = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLiquidstake = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLiquidstake = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/liquidstake/types/logging.go b/x/liquidstake/types/logging.go new file mode 100644 index 0000000..15cfa46 --- /dev/null +++ b/x/liquidstake/types/logging.go @@ -0,0 +1,19 @@ +package types + +const ( + // keyvals + DelegatorKeyVal string = "delegator" + ValidatorKeyVal string = "validator" + SrcValidatorKeyVal string = "src_validator" + DstValidatorKeyVal string = "dst_validator" + AmountKeyVal string = "amount" + MsgKeyVal string = "msg" + ErrorKeyVal string = "error" + ActiveWeightQuorumKeyVal string = "active_weight_quorum" + MinActiveWeightQuorumKeyVal string = "min_active_weight_quorum" + ActiveValidatorsKeyVal string = "active_validators" + WhitelistedValidatorsMapKeyVal string = "whitelisted_validators_map" + ValidatorsKeyVal string = "validators" + NetAmountStateKeyVal string = "net_amount_state" + TotalLiquidTokensKeyVal string = "total_liquid_tokens" +) diff --git a/x/liquidstake/types/msgs.go b/x/liquidstake/types/msgs.go new file mode 100644 index 0000000..5376755 --- /dev/null +++ b/x/liquidstake/types/msgs.go @@ -0,0 +1,330 @@ +package types + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + _ sdk.Msg = (*MsgLiquidStake)(nil) + _ sdk.Msg = (*MsgLiquidUnstake)(nil) + _ sdk.Msg = (*MsgUpdateParams)(nil) + _ sdk.Msg = (*MsgStakeToLP)(nil) + _ sdk.Msg = (*MsgUpdateWhitelistedValidators)(nil) + _ sdk.Msg = (*MsgSetModulePaused)(nil) +) + +// Message types for the liquidstake module +const ( + MsgTypeLiquidStake = "liquid_stake" + MsgTypeLiquidUnstake = "liquid_unstake" + MsgTypeStakeToLP = "stake_to_lp" + MsgTypeUpdateParams = "update_params" + MsgTypeUpdateWhitelistedValidators = "update_whitelisted_validators" + MsgTypeSetModulePaused = "set_module_paused" +) + +// NewMsgLiquidStake creates a new MsgLiquidStake. +func NewMsgLiquidStake( + liquidStaker sdk.AccAddress, + amount sdk.Coin, +) *MsgLiquidStake { + return &MsgLiquidStake{ + DelegatorAddress: liquidStaker.String(), + Amount: amount, + } +} + +func (m *MsgLiquidStake) Route() string { return RouterKey } + +func (m *MsgLiquidStake) Type() string { return MsgTypeLiquidStake } + +func (m *MsgLiquidStake) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.DelegatorAddress); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid delegator address %q: %v", m.DelegatorAddress, err) + } + if ok := m.Amount.IsZero(); ok { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "staking amount must not be zero") + } + if err := m.Amount.Validate(); err != nil { + return err + } + return nil +} + +func (m *MsgLiquidStake) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +func (m *MsgLiquidStake) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (m *MsgLiquidStake) GetDelegator() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgStakeToLP creates a new MsgStakeToLP. +func NewMsgStakeToLP( + liquidStaker sdk.AccAddress, + validator sdk.ValAddress, + stakedAmount, + liquidAmount sdk.Coin, +) *MsgStakeToLP { + return &MsgStakeToLP{ + DelegatorAddress: liquidStaker.String(), + ValidatorAddress: validator.String(), + StakedAmount: stakedAmount, + LiquidAmount: liquidAmount, + } +} + +func (m *MsgStakeToLP) Route() string { return RouterKey } + +func (m *MsgStakeToLP) Type() string { return MsgTypeStakeToLP } + +func (m *MsgStakeToLP) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.DelegatorAddress); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid delegator address %q: %v", m.DelegatorAddress, err) + } + + if _, err := sdk.ValAddressFromBech32(m.ValidatorAddress); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid validator address %q: %v", m.ValidatorAddress, err) + } + + if (m.StakedAmount == sdk.Coin{}) || m.StakedAmount.IsZero() { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "staked amount must not be zero") + } else if err := m.StakedAmount.Validate(); err != nil { + return err + } + + if (m.LiquidAmount != sdk.Coin{}) && !m.LiquidAmount.IsZero() { + if err := m.LiquidAmount.Validate(); err != nil { + return err + } + } + + return nil +} + +func (m *MsgStakeToLP) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +func (m *MsgStakeToLP) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (m *MsgStakeToLP) GetValidator() sdk.ValAddress { + addr, err := sdk.ValAddressFromBech32(m.ValidatorAddress) + if err != nil { + panic(err) + } + return addr +} + +func (m *MsgStakeToLP) GetDelegator() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgLiquidUnstake creates a new MsgLiquidUnstake. +func NewMsgLiquidUnstake( + liquidStaker sdk.AccAddress, + amount sdk.Coin, +) *MsgLiquidUnstake { + return &MsgLiquidUnstake{ + DelegatorAddress: liquidStaker.String(), + Amount: amount, + } +} + +func (m *MsgLiquidUnstake) Route() string { return RouterKey } + +func (m *MsgLiquidUnstake) Type() string { return MsgTypeLiquidUnstake } + +func (m *MsgLiquidUnstake) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.DelegatorAddress); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid delegator address %q: %v", m.DelegatorAddress, err) + } + if ok := m.Amount.IsZero(); ok { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "unstaking amount must not be zero") + } + if err := m.Amount.Validate(); err != nil { + return err + } + return nil +} + +func (m *MsgLiquidUnstake) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +func (m *MsgLiquidUnstake) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (m *MsgLiquidUnstake) GetDelegator() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgUpdateParams creates a new MsgUpdateParams. +func NewMsgUpdateParams(authority sdk.AccAddress, amount Params) *MsgUpdateParams { + return &MsgUpdateParams{ + Authority: authority.String(), + Params: amount, + } +} + +func (m *MsgUpdateParams) Route() string { + return RouterKey +} + +// Type should return the action +func (m *MsgUpdateParams) Type() string { + return MsgTypeUpdateParams +} + +// GetSignBytes encodes the message for signing +func (m *MsgUpdateParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +// GetSigners defines whose signature is required +func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address %q: %v", m.Authority, err) + } + + err := m.Params.Validate() + if err != nil { + return err + } + return nil +} + +// NewMsgUpdateWhitelistedValidators creates a new MsgUpdateWhitelistedValidators. +func NewMsgUpdateWhitelistedValidators(authority sdk.AccAddress, list []WhitelistedValidator) *MsgUpdateWhitelistedValidators { + return &MsgUpdateWhitelistedValidators{ + Authority: authority.String(), + WhitelistedValidators: list, + } +} + +func (m *MsgUpdateWhitelistedValidators) Route() string { + return RouterKey +} + +// Type should return the action +func (m *MsgUpdateWhitelistedValidators) Type() string { + return MsgTypeUpdateWhitelistedValidators +} + +// GetSignBytes encodes the message for signing +func (m *MsgUpdateWhitelistedValidators) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +// GetSigners defines whose signature is required +func (m *MsgUpdateWhitelistedValidators) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Authority) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{addr} +} + +func (m *MsgUpdateWhitelistedValidators) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address %q: %v", m.Authority, err) + } + + err := validateWhitelistedValidators(m.WhitelistedValidators) + if err != nil { + return err + } + + return nil +} + +func (w *WhitelistedValidator) GetValidatorAddress() sdk.ValAddress { + valAddr, err := sdk.ValAddressFromBech32(w.ValidatorAddress) + if err != nil { + panic(err) + } + + return valAddr +} + +// NewMsgSetModulePaused creates a new MsgSetModulePaused. +func NewMsgSetModulePaused(authority sdk.AccAddress, isPaused bool) *MsgSetModulePaused { + return &MsgSetModulePaused{ + Authority: authority.String(), + IsPaused: isPaused, + } +} + +func (m *MsgSetModulePaused) Route() string { + return RouterKey +} + +// Type should return the action +func (m *MsgSetModulePaused) Type() string { + return MsgTypeSetModulePaused +} + +// GetSignBytes encodes the message for signing +func (m *MsgSetModulePaused) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +// GetSigners defines whose signature is required +func (m *MsgSetModulePaused) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Authority) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{addr} +} + +func (m *MsgSetModulePaused) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address %q: %v", m.Authority, err) + } + + return nil +} diff --git a/x/liquidstake/types/msgs_test.go b/x/liquidstake/types/msgs_test.go new file mode 100644 index 0000000..fb51e88 --- /dev/null +++ b/x/liquidstake/types/msgs_test.go @@ -0,0 +1,150 @@ +package types_test + +import ( + "testing" + + "cosmossdk.io/math" + "github.com/cometbft/cometbft/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +func TestMsgLiquidStake(t *testing.T) { + delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) + stakingCoin := sdk.NewCoin("uxprt", math.NewInt(1)) + + testCases := []struct { + expectedErr string + msg *types.MsgLiquidStake + }{ + { + "", // empty means no error expected + types.NewMsgLiquidStake(delegatorAddr, stakingCoin), + }, + { + "invalid delegator address \"\": empty address string is not allowed: invalid address", + types.NewMsgLiquidStake(sdk.AccAddress{}, stakingCoin), + }, + { + "staking amount must not be zero: invalid request", + types.NewMsgLiquidStake(delegatorAddr, sdk.NewCoin("token", math.NewInt(0))), + }, + } + + for _, tc := range testCases { + require.IsType(t, &types.MsgLiquidStake{}, tc.msg) + require.Equal(t, types.MsgTypeLiquidStake, tc.msg.Type()) + require.Equal(t, types.RouterKey, tc.msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(tc.msg)), tc.msg.GetSignBytes()) + + err := tc.msg.ValidateBasic() + if tc.expectedErr == "" { + require.Nil(t, err) + signers := tc.msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, tc.msg.GetDelegator(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + } +} + +func TestMsgLiquidUnstake(t *testing.T) { + delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) + stakingCoin := sdk.NewCoin("stk/uxprt", math.NewInt(1)) + + testCases := []struct { + expectedErr string + msg *types.MsgLiquidUnstake + }{ + { + "", // empty means no error expected + types.NewMsgLiquidUnstake(delegatorAddr, stakingCoin), + }, + { + "invalid delegator address \"\": empty address string is not allowed: invalid address", + types.NewMsgLiquidUnstake(sdk.AccAddress{}, stakingCoin), + }, + { + "unstaking amount must not be zero: invalid request", + types.NewMsgLiquidUnstake(delegatorAddr, sdk.NewCoin("btoken", math.NewInt(0))), + }, + } + + for _, tc := range testCases { + require.IsType(t, &types.MsgLiquidUnstake{}, tc.msg) + require.Equal(t, types.MsgTypeLiquidUnstake, tc.msg.Type()) + require.Equal(t, types.RouterKey, tc.msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(tc.msg)), tc.msg.GetSignBytes()) + + err := tc.msg.ValidateBasic() + if tc.expectedErr == "" { + require.Nil(t, err) + signers := tc.msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, tc.msg.GetDelegator(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + } +} + +func TestMsgStakeToLP(t *testing.T) { + delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) + validatorAddr := sdk.ValAddress(crypto.AddressHash([]byte("validatorAddr"))) + stakingCoin := sdk.NewCoin("uxprt", math.NewInt(1)) + zeroStakingCoin := sdk.NewCoin("uxprt", math.NewInt(0)) + + testCases := []struct { + expectedErr string + msg *types.MsgStakeToLP + }{ + { + "", // empty means no error expected + types.NewMsgStakeToLP(delegatorAddr, validatorAddr, stakingCoin, zeroStakingCoin), + }, + { + "", + types.NewMsgStakeToLP(delegatorAddr, validatorAddr, stakingCoin, sdk.Coin{}), + }, + { + "", + types.NewMsgStakeToLP(delegatorAddr, validatorAddr, stakingCoin, stakingCoin), + }, + { + "invalid delegator address \"\": empty address string is not allowed: invalid address", + types.NewMsgStakeToLP(sdk.AccAddress{}, validatorAddr, stakingCoin, zeroStakingCoin), + }, + { + "invalid validator address \"\": empty address string is not allowed: invalid address", + types.NewMsgStakeToLP(delegatorAddr, sdk.ValAddress{}, stakingCoin, zeroStakingCoin), + }, + { + "staked amount must not be zero: invalid request", + types.NewMsgStakeToLP(delegatorAddr, validatorAddr, zeroStakingCoin, zeroStakingCoin), + }, + { + "staked amount must not be zero: invalid request", + types.NewMsgStakeToLP(delegatorAddr, validatorAddr, zeroStakingCoin, stakingCoin), + }, + } + + for _, tc := range testCases { + require.IsType(t, &types.MsgStakeToLP{}, tc.msg) + require.Equal(t, types.MsgTypeStakeToLP, tc.msg.Type()) + require.Equal(t, types.RouterKey, tc.msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(tc.msg)), tc.msg.GetSignBytes()) + + err := tc.msg.ValidateBasic() + if tc.expectedErr == "" { + require.Nil(t, err) + signers := tc.msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, tc.msg.GetDelegator(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + } +} diff --git a/x/liquidstake/types/params.go b/x/liquidstake/types/params.go new file mode 100644 index 0000000..c061ab0 --- /dev/null +++ b/x/liquidstake/types/params.go @@ -0,0 +1,253 @@ +package types + +import ( + "encoding/json" + "fmt" + "strings" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" +) + +// Parameter store keys +var ( + DefaultLiquidBondDenom = "stk/uxprt" + + // DefaultUnstakeFeeRate is the default Unstake Fee Rate. + DefaultUnstakeFeeRate = math.LegacyZeroDec() + + // DefaultAutocompoundFeeRate is the default fee rate for auto redelegating the stake rewards. + DefaultAutocompoundFeeRate = math.LegacyMustNewDecFromStr("0.05") + + // DefaultMinLiquidStakeAmount is the default minimum liquid stake amount. + DefaultMinLiquidStakeAmount = math.NewInt(1000) + + // DefaultLimitAutocompoundPeriodDays is the number of days for which APY autocompound limit is calculated. + DefaultLimitAutocompoundPeriodDays = math.LegacyNewDec(365) + + // DefaultLimitAutocompoundPeriodHours is the number of hours for which APY autocompound limit is calculated. + DefaultLimitAutocompoundPeriodHours = math.LegacyNewDec(24) + + // Const variables + + // TotalValidatorWeight specifies the target sum of validator weights in the whitelist. + TotalValidatorWeight = math.NewInt(10000) + + // ActiveLiquidValidatorsWeightQuorum is the minium required weight quorum for liquid validators set + ActiveLiquidValidatorsWeightQuorum = math.LegacyNewDecWithPrec(3333, 4) // "0.333300000000000000" + + // RebalancingTrigger if the maximum difference and needed each redelegation amount exceeds it, asset rebalacing will be executed. + RebalancingTrigger = math.LegacyNewDecWithPrec(1, 3) // "0.001000000000000000" + + // LiquidStakeProxyAcc is a proxy reserve account for delegation and undelegation. + // + // Important: derive this address using module.Address to obtain a 32-byte version distinguishable for LSM + // authtypes.NewModuleAddress returns 20-byte addresses. + // persistence19zwggtdgaspa9tje6mxdap9xjpc4rayf3nd6dt5g3lwkx4y7z6dqmj3hnc + LiquidStakeProxyAcc = sdk.AccAddress(address.Module(ModuleName, []byte("-LiquidStakeProxyAcc"))) + + // DummyFeeAccountAcc is a dummy fee collection account that should be replaced via params. + // + // Note: it could be authtypes.NewModuleAddress, but made it derived as well, for consistency. + DummyFeeAccountAcc = sdk.AccAddress(address.Module(ModuleName, []byte("-FeeAcc"))) +) + +// DefaultParams returns the default liquidstake module parameters. +func DefaultParams() Params { + return Params{ + WhitelistedValidators: []WhitelistedValidator{}, + LiquidBondDenom: DefaultLiquidBondDenom, + UnstakeFeeRate: DefaultUnstakeFeeRate, + MinLiquidStakeAmount: DefaultMinLiquidStakeAmount, + FeeAccountAddress: DummyFeeAccountAcc.String(), + AutocompoundFeeRate: DefaultAutocompoundFeeRate, + CwLockedPoolAddress: "", + WhitelistAdminAddress: "", + ModulePaused: true, + } +} + +// String returns a human-readable string representation of the parameters. +func (p Params) String() string { + out, _ := json.MarshalIndent(p, "", "") + return string(out) +} + +func (p Params) WhitelistedValsMap() WhitelistedValsMap { + return GetWhitelistedValsMap(p.WhitelistedValidators) +} + +// Validate validates parameters. +func (p Params) Validate() error { + for _, v := range []struct { + value interface{} + validator func(interface{}) error + }{ + {p.LiquidBondDenom, validateLiquidBondDenom}, + {p.WhitelistedValidators, validateWhitelistedValidators}, + {p.UnstakeFeeRate, validateUnstakeFeeRate}, + {p.MinLiquidStakeAmount, validateMinLiquidStakeAmount}, + {p.AutocompoundFeeRate, validateAutocompoundFeeRate}, + {p.FeeAccountAddress, validateFeeAccountAddress}, + {p.CwLockedPoolAddress, validateCwLockedPoolAddress}, + {p.WhitelistAdminAddress, validateWhitelistAdminAddress}, + } { + if err := v.validator(v.value); err != nil { + return err + } + } + return nil +} + +func validateLiquidBondDenom(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if strings.TrimSpace(v) == "" { + return fmt.Errorf("liquid bond denom cannot be blank") + } + + if err := sdk.ValidateDenom(v); err != nil { + return err + } + return nil +} + +// validateWhitelistedValidators validates liquidstake validator and total weight. +func validateWhitelistedValidators(i interface{}) error { + wvs, ok := i.([]WhitelistedValidator) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + valsMap := map[string]struct{}{} + for _, wv := range wvs { + _, valErr := sdk.ValAddressFromBech32(wv.ValidatorAddress) + if valErr != nil { + return valErr + } + + if wv.TargetWeight.IsNil() { + return fmt.Errorf("liquidstake validator target weight must not be nil") + } + + if !wv.TargetWeight.IsPositive() { + return fmt.Errorf("liquidstake validator target weight must be positive: %s", wv.TargetWeight) + } + + if _, ok := valsMap[wv.ValidatorAddress]; ok { + return fmt.Errorf("liquidstake validator cannot be duplicated: %s", wv.ValidatorAddress) + } + valsMap[wv.ValidatorAddress] = struct{}{} + } + return nil +} + +func validateUnstakeFeeRate(i interface{}) error { + v, ok := i.(math.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("unstake fee rate must not be nil") + } + + if v.IsNegative() { + return fmt.Errorf("unstake fee rate must not be negative: %s", v) + } + + if v.GT(math.LegacyOneDec()) { + return fmt.Errorf("unstake fee rate too large: %s", v) + } + + return nil +} + +func validateMinLiquidStakeAmount(i interface{}) error { + v, ok := i.(math.Int) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("min liquid stake amount must not be nil") + } + + if v.IsNegative() { + return fmt.Errorf("min liquid stake amount must not be negative: %s", v) + } + + return nil +} + +func validateAutocompoundFeeRate(i interface{}) error { + v, ok := i.(math.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("autocompound fee rate must not be nil") + } + + if v.IsNegative() { + return fmt.Errorf("autocompound fee rate must not be negative: %s", v) + } + + if v.GT(math.LegacyOneDec()) { + return fmt.Errorf("autocompound fee rate too large: %s", v) + } + + return nil +} + +func validateFeeAccountAddress(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + _, err := sdk.AccAddressFromBech32(v) + if err != nil { + return fmt.Errorf("cannot convert fee account address to bech32, invalid address: %s, err: %v", v, err) + } + return nil +} + +func validateCwLockedPoolAddress(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + // allow empty address + if len(v) == 0 { + return nil + } + + _, err := sdk.AccAddressFromBech32(v) + if err != nil { + return fmt.Errorf("cannot convert cw contract address to bech32, invalid address: %s, err: %v", v, err) + } + return nil +} + +func validateWhitelistAdminAddress(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + // allow empty address + if len(v) == 0 { + return nil + } + + _, err := sdk.AccAddressFromBech32(v) + if err != nil { + return fmt.Errorf("cannot convert whitelist admin address to bech32, invalid address: %s, err: %v", v, err) + } + return nil +} diff --git a/x/liquidstake/types/query.pb.go b/x/liquidstake/types/query.pb.go new file mode 100644 index 0000000..55b324d --- /dev/null +++ b/x/liquidstake/types/query.pb.go @@ -0,0 +1,1222 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pstake/liquidstake/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "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" + 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 + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1badba19848dd753, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1badba19848dd753, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryLiquidValidatorsRequest is the request type for the +// Query/LiquidValidators RPC method. +type QueryLiquidValidatorsRequest struct { +} + +func (m *QueryLiquidValidatorsRequest) Reset() { *m = QueryLiquidValidatorsRequest{} } +func (m *QueryLiquidValidatorsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryLiquidValidatorsRequest) ProtoMessage() {} +func (*QueryLiquidValidatorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1badba19848dd753, []int{2} +} +func (m *QueryLiquidValidatorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLiquidValidatorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLiquidValidatorsRequest.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 *QueryLiquidValidatorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLiquidValidatorsRequest.Merge(m, src) +} +func (m *QueryLiquidValidatorsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryLiquidValidatorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLiquidValidatorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLiquidValidatorsRequest proto.InternalMessageInfo + +// QueryLiquidValidatorsResponse is the response type for the +// Query/LiquidValidators RPC method. +type QueryLiquidValidatorsResponse struct { + LiquidValidators []LiquidValidatorState `protobuf:"bytes,1,rep,name=liquid_validators,json=liquidValidators,proto3" json:"liquid_validators"` +} + +func (m *QueryLiquidValidatorsResponse) Reset() { *m = QueryLiquidValidatorsResponse{} } +func (m *QueryLiquidValidatorsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryLiquidValidatorsResponse) ProtoMessage() {} +func (*QueryLiquidValidatorsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1badba19848dd753, []int{3} +} +func (m *QueryLiquidValidatorsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLiquidValidatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLiquidValidatorsResponse.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 *QueryLiquidValidatorsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLiquidValidatorsResponse.Merge(m, src) +} +func (m *QueryLiquidValidatorsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryLiquidValidatorsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLiquidValidatorsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLiquidValidatorsResponse proto.InternalMessageInfo + +func (m *QueryLiquidValidatorsResponse) GetLiquidValidators() []LiquidValidatorState { + if m != nil { + return m.LiquidValidators + } + return nil +} + +// QueryStatesRequest is the request type for the Query/States RPC method. +type QueryStatesRequest struct { +} + +func (m *QueryStatesRequest) Reset() { *m = QueryStatesRequest{} } +func (m *QueryStatesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStatesRequest) ProtoMessage() {} +func (*QueryStatesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1badba19848dd753, []int{4} +} +func (m *QueryStatesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStatesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStatesRequest.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 *QueryStatesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStatesRequest.Merge(m, src) +} +func (m *QueryStatesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStatesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStatesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStatesRequest proto.InternalMessageInfo + +// QueryStatesResponse is the response type for the Query/States RPC method. +type QueryStatesResponse struct { + NetAmountState NetAmountState `protobuf:"bytes,1,opt,name=net_amount_state,json=netAmountState,proto3" json:"net_amount_state"` +} + +func (m *QueryStatesResponse) Reset() { *m = QueryStatesResponse{} } +func (m *QueryStatesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStatesResponse) ProtoMessage() {} +func (*QueryStatesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1badba19848dd753, []int{5} +} +func (m *QueryStatesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStatesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStatesResponse.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 *QueryStatesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStatesResponse.Merge(m, src) +} +func (m *QueryStatesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStatesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStatesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStatesResponse proto.InternalMessageInfo + +func (m *QueryStatesResponse) GetNetAmountState() NetAmountState { + if m != nil { + return m.NetAmountState + } + return NetAmountState{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "pstake.liquidstake.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "pstake.liquidstake.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryLiquidValidatorsRequest)(nil), "pstake.liquidstake.v1beta1.QueryLiquidValidatorsRequest") + proto.RegisterType((*QueryLiquidValidatorsResponse)(nil), "pstake.liquidstake.v1beta1.QueryLiquidValidatorsResponse") + proto.RegisterType((*QueryStatesRequest)(nil), "pstake.liquidstake.v1beta1.QueryStatesRequest") + proto.RegisterType((*QueryStatesResponse)(nil), "pstake.liquidstake.v1beta1.QueryStatesResponse") +} + +func init() { + proto.RegisterFile("pstake/liquidstake/v1beta1/query.proto", fileDescriptor_1badba19848dd753) +} + +var fileDescriptor_1badba19848dd753 = []byte{ + // 463 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcd, 0x8a, 0x13, 0x41, + 0x10, 0x4e, 0xbb, 0x9a, 0x43, 0x2f, 0x48, 0x6c, 0xf7, 0xb0, 0x0c, 0xeb, 0xb8, 0x0c, 0xb2, 0x84, + 0x45, 0xbb, 0xdd, 0x78, 0xd1, 0x8b, 0xe8, 0x9e, 0xc5, 0x9f, 0x15, 0x54, 0xf6, 0x12, 0x3a, 0xd9, + 0x62, 0x6c, 0x4c, 0xba, 0x27, 0xd3, 0x35, 0xc1, 0xbd, 0x8a, 0x0f, 0x20, 0x88, 0xcf, 0xe2, 0x2b, + 0xec, 0x71, 0xc1, 0x8b, 0x27, 0x91, 0xc4, 0x17, 0xf0, 0x0d, 0x24, 0xdd, 0xed, 0x98, 0x89, 0x64, + 0x1c, 0xbc, 0x15, 0xd5, 0x5f, 0xd5, 0xf7, 0xcd, 0x57, 0xdf, 0xd0, 0xbd, 0xcc, 0xa2, 0x7c, 0x03, + 0x62, 0xa4, 0x26, 0x85, 0x3a, 0xf1, 0xf5, 0xf4, 0x60, 0x00, 0x28, 0x0f, 0xc4, 0xa4, 0x80, 0xfc, + 0x94, 0x67, 0xb9, 0x41, 0xc3, 0x22, 0x8f, 0xe3, 0x4b, 0x38, 0x1e, 0x70, 0xd1, 0x4e, 0x6a, 0x4c, + 0x3a, 0x02, 0x21, 0x33, 0x25, 0xa4, 0xd6, 0x06, 0x25, 0x2a, 0xa3, 0xad, 0x9f, 0x8c, 0x6e, 0xd6, + 0x30, 0x2c, 0x6f, 0xf3, 0xe8, 0xad, 0xd4, 0xa4, 0xc6, 0x95, 0x62, 0x51, 0xf9, 0x6e, 0xb2, 0x45, + 0xd9, 0xb3, 0x85, 0x98, 0xa7, 0x32, 0x97, 0x63, 0x7b, 0x04, 0x93, 0x02, 0x2c, 0x26, 0x2f, 0xe9, + 0xd5, 0x4a, 0xd7, 0x66, 0x46, 0x5b, 0x60, 0x0f, 0x68, 0x3b, 0x73, 0x9d, 0x6d, 0xb2, 0x4b, 0xba, + 0x9b, 0xbd, 0x84, 0xaf, 0xd7, 0xce, 0xfd, 0xec, 0xe1, 0xc5, 0xb3, 0x6f, 0xd7, 0x5b, 0x47, 0x61, + 0x2e, 0x89, 0xe9, 0x8e, 0x5b, 0xfc, 0xc8, 0x0d, 0xbc, 0x90, 0x23, 0x75, 0x22, 0xd1, 0xe4, 0x25, + 0xf1, 0x7b, 0x42, 0xaf, 0xad, 0x01, 0x04, 0x0d, 0x43, 0x7a, 0xc5, 0xb3, 0xf5, 0xa7, 0xe5, 0xe3, + 0x36, 0xd9, 0xdd, 0xe8, 0x6e, 0xf6, 0x6e, 0xd7, 0xc9, 0x59, 0x59, 0xf8, 0x1c, 0x25, 0x42, 0x10, + 0xd7, 0x19, 0xad, 0x90, 0x95, 0xae, 0x38, 0x54, 0x29, 0x6e, 0x12, 0x5c, 0xf9, 0xdd, 0x0d, 0x8a, + 0x8e, 0x69, 0x47, 0x03, 0xf6, 0xe5, 0xd8, 0x14, 0x1a, 0xfb, 0x76, 0xf1, 0x18, 0xfc, 0xd9, 0xaf, + 0x13, 0xf4, 0x18, 0xf0, 0xa1, 0x1b, 0x59, 0x96, 0x72, 0x59, 0x57, 0xba, 0xbd, 0x9f, 0x1b, 0xf4, + 0x92, 0xe3, 0x64, 0x9f, 0x08, 0x6d, 0x7b, 0x4b, 0x19, 0xaf, 0x5b, 0xfb, 0xf7, 0x35, 0x23, 0xd1, + 0x18, 0xef, 0xbf, 0x28, 0xd9, 0x7f, 0xf7, 0xe5, 0xc7, 0xc7, 0x0b, 0x37, 0x58, 0x22, 0x6a, 0x12, + 0xe6, 0x2f, 0xca, 0x3e, 0x13, 0xda, 0x59, 0x3d, 0x16, 0xbb, 0xfb, 0x4f, 0xc6, 0x35, 0x01, 0x88, + 0xee, 0xfd, 0xc7, 0x64, 0x50, 0xcd, 0x9d, 0xea, 0x2e, 0xdb, 0xab, 0x53, 0xfd, 0x27, 0x34, 0xce, + 0x51, 0x7f, 0xca, 0x06, 0x8e, 0x56, 0x92, 0xd0, 0xc0, 0xd1, 0x6a, 0x46, 0x9a, 0x39, 0xea, 0xa2, + 0x63, 0x0f, 0x5f, 0x9d, 0xcd, 0x62, 0x72, 0x3e, 0x8b, 0xc9, 0xf7, 0x59, 0x4c, 0x3e, 0xcc, 0xe3, + 0xd6, 0xf9, 0x3c, 0x6e, 0x7d, 0x9d, 0xc7, 0xad, 0xe3, 0xfb, 0xa9, 0xc2, 0xd7, 0xc5, 0x80, 0x0f, + 0xcd, 0x58, 0x64, 0x90, 0x5b, 0x65, 0x11, 0xf4, 0x10, 0x9e, 0x68, 0x08, 0x6b, 0x6f, 0x69, 0x89, + 0x6a, 0x0a, 0x62, 0xda, 0x13, 0x6f, 0x2b, 0x14, 0x78, 0x9a, 0x81, 0x1d, 0xb4, 0xdd, 0x3f, 0x7f, + 0xe7, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x2b, 0x8a, 0x4b, 0x9b, 0x04, 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 { + // Params returns parameters of the liquidstake module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // LiquidValidators returns liquid validators with states of the liquidstake + // module. + LiquidValidators(ctx context.Context, in *QueryLiquidValidatorsRequest, opts ...grpc.CallOption) (*QueryLiquidValidatorsResponse, error) + // States returns states of the liquidstake module. + States(ctx context.Context, in *QueryStatesRequest, opts ...grpc.CallOption) (*QueryStatesResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) LiquidValidators(ctx context.Context, in *QueryLiquidValidatorsRequest, opts ...grpc.CallOption) (*QueryLiquidValidatorsResponse, error) { + out := new(QueryLiquidValidatorsResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Query/LiquidValidators", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) States(ctx context.Context, in *QueryStatesRequest, opts ...grpc.CallOption) (*QueryStatesResponse, error) { + out := new(QueryStatesResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Query/States", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params returns parameters of the liquidstake module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // LiquidValidators returns liquid validators with states of the liquidstake + // module. + LiquidValidators(context.Context, *QueryLiquidValidatorsRequest) (*QueryLiquidValidatorsResponse, error) + // States returns states of the liquidstake module. + States(context.Context, *QueryStatesRequest) (*QueryStatesResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) LiquidValidators(ctx context.Context, req *QueryLiquidValidatorsRequest) (*QueryLiquidValidatorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidValidators not implemented") +} +func (*UnimplementedQueryServer) States(ctx context.Context, req *QueryStatesRequest) (*QueryStatesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method States not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_LiquidValidators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryLiquidValidatorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).LiquidValidators(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Query/LiquidValidators", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).LiquidValidators(ctx, req.(*QueryLiquidValidatorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_States_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStatesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).States(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Query/States", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).States(ctx, req.(*QueryStatesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pstake.liquidstake.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "LiquidValidators", + Handler: _Query_LiquidValidators_Handler, + }, + { + MethodName: "States", + Handler: _Query_States_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "pstake/liquidstake/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryLiquidValidatorsRequest) 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 *QueryLiquidValidatorsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLiquidValidatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryLiquidValidatorsResponse) 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 *QueryLiquidValidatorsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLiquidValidatorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.LiquidValidators) > 0 { + for iNdEx := len(m.LiquidValidators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LiquidValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryStatesRequest) 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 *QueryStatesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStatesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryStatesResponse) 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 *QueryStatesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.NetAmountState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func 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 *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryLiquidValidatorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryLiquidValidatorsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.LiquidValidators) > 0 { + for _, e := range m.LiquidValidators { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryStatesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryStatesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.NetAmountState.Size() + 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 *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLiquidValidatorsRequest) 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: QueryLiquidValidatorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLiquidValidatorsRequest: 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 *QueryLiquidValidatorsResponse) 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: QueryLiquidValidatorsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLiquidValidatorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidValidators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidValidators = append(m.LiquidValidators, LiquidValidatorState{}) + if err := m.LiquidValidators[len(m.LiquidValidators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStatesRequest) 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: QueryStatesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStatesRequest: 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 *QueryStatesResponse) 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: QueryStatesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStatesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NetAmountState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NetAmountState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func 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/liquidstake/types/query.pb.gw.go b/x/liquidstake/types/query.pb.gw.go new file mode 100644 index 0000000..6592e01 --- /dev/null +++ b/x/liquidstake/types/query.pb.gw.go @@ -0,0 +1,283 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: pstake/liquidstake/v1beta1/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_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_LiquidValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLiquidValidatorsRequest + var metadata runtime.ServerMetadata + + msg, err := client.LiquidValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_LiquidValidators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLiquidValidatorsRequest + var metadata runtime.ServerMetadata + + msg, err := server.LiquidValidators(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_States_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStatesRequest + var metadata runtime.ServerMetadata + + msg, err := client.States(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_States_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStatesRequest + var metadata runtime.ServerMetadata + + msg, err := server.States(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_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LiquidValidators_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_LiquidValidators_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_LiquidValidators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_States_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_States_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_States_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_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LiquidValidators_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_LiquidValidators_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_LiquidValidators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_States_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_States_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_States_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"pstake", "liquidstake", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_LiquidValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"pstake", "liquidstake", "v1beta1", "validators"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_States_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"pstake", "liquidstake", "v1beta1", "states"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_LiquidValidators_0 = runtime.ForwardResponseMessage + + forward_Query_States_0 = runtime.ForwardResponseMessage +) diff --git a/x/liquidstake/types/rebalancing.go b/x/liquidstake/types/rebalancing.go new file mode 100644 index 0000000..0ff7e52 --- /dev/null +++ b/x/liquidstake/types/rebalancing.go @@ -0,0 +1,52 @@ +package types + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Redelegation struct { + Delegator sdk.AccAddress + SrcValidator LiquidValidator + DstValidator LiquidValidator + Amount math.Int + Last bool + Error error +} + +// DivideByWeight divide the input value by the ratio of the param weight of the liquid validator and return it with crumb +// which is may occur while dividing according to the weight of active liquid validators by decimal error. +func DivideByWeight(avs ActiveLiquidValidators, input math.Int, whitelistedValsMap WhitelistedValsMap) (outputs []math.Int, crumb math.Int) { + totalWeight := avs.TotalWeight(whitelistedValsMap) + if !totalWeight.IsPositive() { + return []math.Int{}, math.ZeroInt() + } + + totalOutput := math.ZeroInt() + unitInput := math.LegacyNewDecFromInt(input).QuoTruncate(math.LegacyNewDecFromInt(totalWeight)) + for _, val := range avs { + output := unitInput.MulInt(val.GetWeight(whitelistedValsMap, true)).TruncateInt() + totalOutput = totalOutput.Add(output) + outputs = append(outputs, output) + } + + return outputs, input.Sub(totalOutput) +} + +// DivideByCurrentWeight divide the input value by the ratio of the weight of the liquid validator's liquid token and return it with crumb +// which is may occur while dividing according to the weight of liquid validators by decimal error, outputs is truncated decimal. +func DivideByCurrentWeight(lvs LiquidValidators, input math.LegacyDec, totalLiquidTokens math.Int, liquidTokenMap map[string]math.Int) (outputs []math.LegacyDec, crumb math.LegacyDec) { + if !totalLiquidTokens.IsPositive() { + return []math.LegacyDec{}, math.LegacyZeroDec() + } + + totalOutput := math.LegacyZeroDec() + unitInput := input.QuoTruncate(math.LegacyNewDecFromInt(totalLiquidTokens)) + for _, val := range lvs { + output := unitInput.MulTruncate(math.LegacyNewDecFromInt(liquidTokenMap[val.OperatorAddress])).TruncateDec() + totalOutput = totalOutput.Add(output) + outputs = append(outputs, output) + } + + return outputs, input.Sub(totalOutput) +} diff --git a/x/liquidstake/types/tx.pb.go b/x/liquidstake/types/tx.pb.go new file mode 100644 index 0000000..a9b6c6d --- /dev/null +++ b/x/liquidstake/types/tx.pb.go @@ -0,0 +1,2621 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pstake/liquidstake/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + 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" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 + +// MsgLiquidStake defines a SDK message for performing a liquid stake of coins +// from a delegator to whitelisted validators. +type MsgLiquidStake struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgLiquidStake) Reset() { *m = MsgLiquidStake{} } +func (m *MsgLiquidStake) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidStake) ProtoMessage() {} +func (*MsgLiquidStake) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{0} +} +func (m *MsgLiquidStake) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidStake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidStake.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 *MsgLiquidStake) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidStake.Merge(m, src) +} +func (m *MsgLiquidStake) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidStake) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidStake.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidStake proto.InternalMessageInfo + +// MsgLiquidStakeResponse defines the MsgLiquidStake response type. +type MsgLiquidStakeResponse struct { +} + +func (m *MsgLiquidStakeResponse) Reset() { *m = MsgLiquidStakeResponse{} } +func (m *MsgLiquidStakeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidStakeResponse) ProtoMessage() {} +func (*MsgLiquidStakeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{1} +} +func (m *MsgLiquidStakeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidStakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidStakeResponse.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 *MsgLiquidStakeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidStakeResponse.Merge(m, src) +} +func (m *MsgLiquidStakeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidStakeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidStakeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidStakeResponse proto.InternalMessageInfo + +// MsgStakeToLP defines a SDK message for performing an LSM-transfer of staked +// XPRT into stkXPRT with locking into an LP. +type MsgStakeToLP struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + StakedAmount types.Coin `protobuf:"bytes,3,opt,name=staked_amount,json=stakedAmount,proto3" json:"staked_amount"` + LiquidAmount types.Coin `protobuf:"bytes,4,opt,name=liquid_amount,json=liquidAmount,proto3" json:"liquid_amount"` +} + +func (m *MsgStakeToLP) Reset() { *m = MsgStakeToLP{} } +func (m *MsgStakeToLP) String() string { return proto.CompactTextString(m) } +func (*MsgStakeToLP) ProtoMessage() {} +func (*MsgStakeToLP) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{2} +} +func (m *MsgStakeToLP) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgStakeToLP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStakeToLP.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 *MsgStakeToLP) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStakeToLP.Merge(m, src) +} +func (m *MsgStakeToLP) XXX_Size() int { + return m.Size() +} +func (m *MsgStakeToLP) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStakeToLP.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStakeToLP proto.InternalMessageInfo + +// MsgStakeToLPResponse defines the MsgStakeToLP response type. +type MsgStakeToLPResponse struct { +} + +func (m *MsgStakeToLPResponse) Reset() { *m = MsgStakeToLPResponse{} } +func (m *MsgStakeToLPResponse) String() string { return proto.CompactTextString(m) } +func (*MsgStakeToLPResponse) ProtoMessage() {} +func (*MsgStakeToLPResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{3} +} +func (m *MsgStakeToLPResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgStakeToLPResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStakeToLPResponse.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 *MsgStakeToLPResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStakeToLPResponse.Merge(m, src) +} +func (m *MsgStakeToLPResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgStakeToLPResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStakeToLPResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStakeToLPResponse proto.InternalMessageInfo + +// MsgLiquidUnstake defines a SDK message for performing an undelegation of +// liquid staking from a delegate. +type MsgLiquidUnstake struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgLiquidUnstake) Reset() { *m = MsgLiquidUnstake{} } +func (m *MsgLiquidUnstake) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidUnstake) ProtoMessage() {} +func (*MsgLiquidUnstake) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{4} +} +func (m *MsgLiquidUnstake) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidUnstake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidUnstake.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 *MsgLiquidUnstake) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidUnstake.Merge(m, src) +} +func (m *MsgLiquidUnstake) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidUnstake) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidUnstake.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidUnstake proto.InternalMessageInfo + +// MsgLiquidUnstakeResponse defines the MsgLiquidUnstake response type. +type MsgLiquidUnstakeResponse struct { + CompletionTime time.Time `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time"` +} + +func (m *MsgLiquidUnstakeResponse) Reset() { *m = MsgLiquidUnstakeResponse{} } +func (m *MsgLiquidUnstakeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidUnstakeResponse) ProtoMessage() {} +func (*MsgLiquidUnstakeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{5} +} +func (m *MsgLiquidUnstakeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidUnstakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidUnstakeResponse.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 *MsgLiquidUnstakeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidUnstakeResponse.Merge(m, src) +} +func (m *MsgLiquidUnstakeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidUnstakeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidUnstakeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidUnstakeResponse proto.InternalMessageInfo + +func (m *MsgLiquidUnstakeResponse) GetCompletionTime() time.Time { + if m != nil { + return m.CompletionTime + } + return time.Time{} +} + +type MsgUpdateParams struct { + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the parameters to update. + // + // NOTE: denom and whitelisted validators are not updated. + // + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{6} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +// MsgUpdateParamsResponse defines the response structure for executing a +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{7} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +type MsgUpdateWhitelistedValidators struct { + // Authority is the address that is allowed to update whitelisted validators, + // defined as admin address in params (WhitelistAdminAddress). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // WhitelistedValidators specifies the validators elected to become Active + // Liquid Validators. + WhitelistedValidators []WhitelistedValidator `protobuf:"bytes,2,rep,name=whitelisted_validators,json=whitelistedValidators,proto3" json:"whitelisted_validators"` +} + +func (m *MsgUpdateWhitelistedValidators) Reset() { *m = MsgUpdateWhitelistedValidators{} } +func (m *MsgUpdateWhitelistedValidators) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateWhitelistedValidators) ProtoMessage() {} +func (*MsgUpdateWhitelistedValidators) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{8} +} +func (m *MsgUpdateWhitelistedValidators) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateWhitelistedValidators) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateWhitelistedValidators.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 *MsgUpdateWhitelistedValidators) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateWhitelistedValidators.Merge(m, src) +} +func (m *MsgUpdateWhitelistedValidators) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateWhitelistedValidators) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateWhitelistedValidators.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateWhitelistedValidators proto.InternalMessageInfo + +// MsgUpdateWhitelistedValidatorsResponse defines the response structure for +// executing a +type MsgUpdateWhitelistedValidatorsResponse struct { +} + +func (m *MsgUpdateWhitelistedValidatorsResponse) Reset() { + *m = MsgUpdateWhitelistedValidatorsResponse{} +} +func (m *MsgUpdateWhitelistedValidatorsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateWhitelistedValidatorsResponse) ProtoMessage() {} +func (*MsgUpdateWhitelistedValidatorsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{9} +} +func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse.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 *MsgUpdateWhitelistedValidatorsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse.Merge(m, src) +} +func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse proto.InternalMessageInfo + +type MsgSetModulePaused struct { + // Authority is the address that is allowed to update module's paused state, + // defined as admin address in params (WhitelistAdminAddress). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // IsPaused represents the target state of the paused flag. + IsPaused bool `protobuf:"varint,2,opt,name=is_paused,json=isPaused,proto3" json:"is_paused,omitempty"` +} + +func (m *MsgSetModulePaused) Reset() { *m = MsgSetModulePaused{} } +func (m *MsgSetModulePaused) String() string { return proto.CompactTextString(m) } +func (*MsgSetModulePaused) ProtoMessage() {} +func (*MsgSetModulePaused) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{10} +} +func (m *MsgSetModulePaused) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetModulePaused) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetModulePaused.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 *MsgSetModulePaused) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetModulePaused.Merge(m, src) +} +func (m *MsgSetModulePaused) XXX_Size() int { + return m.Size() +} +func (m *MsgSetModulePaused) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetModulePaused.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetModulePaused proto.InternalMessageInfo + +// MsgSetModulePausedResponse defines the response structure for +// executing a +type MsgSetModulePausedResponse struct { +} + +func (m *MsgSetModulePausedResponse) Reset() { *m = MsgSetModulePausedResponse{} } +func (m *MsgSetModulePausedResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetModulePausedResponse) ProtoMessage() {} +func (*MsgSetModulePausedResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d90501ae6d9f0009, []int{11} +} +func (m *MsgSetModulePausedResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetModulePausedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetModulePausedResponse.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 *MsgSetModulePausedResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetModulePausedResponse.Merge(m, src) +} +func (m *MsgSetModulePausedResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetModulePausedResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetModulePausedResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetModulePausedResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgLiquidStake)(nil), "pstake.liquidstake.v1beta1.MsgLiquidStake") + proto.RegisterType((*MsgLiquidStakeResponse)(nil), "pstake.liquidstake.v1beta1.MsgLiquidStakeResponse") + proto.RegisterType((*MsgStakeToLP)(nil), "pstake.liquidstake.v1beta1.MsgStakeToLP") + proto.RegisterType((*MsgStakeToLPResponse)(nil), "pstake.liquidstake.v1beta1.MsgStakeToLPResponse") + proto.RegisterType((*MsgLiquidUnstake)(nil), "pstake.liquidstake.v1beta1.MsgLiquidUnstake") + proto.RegisterType((*MsgLiquidUnstakeResponse)(nil), "pstake.liquidstake.v1beta1.MsgLiquidUnstakeResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "pstake.liquidstake.v1beta1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "pstake.liquidstake.v1beta1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgUpdateWhitelistedValidators)(nil), "pstake.liquidstake.v1beta1.MsgUpdateWhitelistedValidators") + proto.RegisterType((*MsgUpdateWhitelistedValidatorsResponse)(nil), "pstake.liquidstake.v1beta1.MsgUpdateWhitelistedValidatorsResponse") + proto.RegisterType((*MsgSetModulePaused)(nil), "pstake.liquidstake.v1beta1.MsgSetModulePaused") + proto.RegisterType((*MsgSetModulePausedResponse)(nil), "pstake.liquidstake.v1beta1.MsgSetModulePausedResponse") +} + +func init() { + proto.RegisterFile("pstake/liquidstake/v1beta1/tx.proto", fileDescriptor_d90501ae6d9f0009) +} + +var fileDescriptor_d90501ae6d9f0009 = []byte{ + // 851 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4d, 0x4f, 0x13, 0x41, + 0x18, 0xee, 0x16, 0x24, 0x74, 0xca, 0xe7, 0x06, 0xa1, 0x2c, 0x64, 0x4b, 0xd6, 0xc4, 0x34, 0x15, + 0x76, 0xa1, 0x18, 0x8c, 0x35, 0x7e, 0x50, 0xe5, 0x46, 0x23, 0x29, 0xa0, 0xc6, 0x4b, 0xb3, 0xed, + 0x8e, 0xcb, 0xc4, 0xee, 0xce, 0xda, 0x99, 0x16, 0xb8, 0x7a, 0x32, 0x1e, 0x0c, 0x7f, 0xc0, 0x84, + 0x83, 0x3f, 0x80, 0x83, 0xff, 0xc0, 0x0b, 0x37, 0x89, 0x5e, 0x3c, 0x89, 0x81, 0x18, 0xfc, 0x19, + 0x66, 0x77, 0x76, 0xb7, 0xbb, 0xa5, 0xb4, 0x85, 0x78, 0xf0, 0x02, 0xbb, 0xf3, 0x3e, 0xef, 0xf3, + 0xbe, 0xcf, 0x33, 0xf3, 0xce, 0x16, 0xdc, 0xb0, 0x08, 0x55, 0x5f, 0x43, 0xa5, 0x82, 0xde, 0xd4, + 0x90, 0xc6, 0x9e, 0xeb, 0x0b, 0x25, 0x48, 0xd5, 0x05, 0x85, 0xee, 0xc8, 0x56, 0x15, 0x53, 0xcc, + 0x0b, 0x0c, 0x24, 0x07, 0x40, 0xb2, 0x0b, 0x12, 0xc6, 0x74, 0xac, 0x63, 0x07, 0xa6, 0xd8, 0x4f, + 0x2c, 0x43, 0x98, 0x2c, 0x63, 0x62, 0x60, 0x52, 0x64, 0x01, 0xf6, 0xe2, 0x86, 0x44, 0xf6, 0xa6, + 0x94, 0x54, 0xd2, 0x28, 0x55, 0xc6, 0xc8, 0x74, 0xe3, 0x13, 0x6e, 0xdc, 0x20, 0xba, 0x52, 0x5f, + 0xb0, 0xff, 0xb9, 0x81, 0xa4, 0x8e, 0xb1, 0x5e, 0x81, 0x8a, 0xf3, 0x56, 0xaa, 0xbd, 0x52, 0x28, + 0x32, 0x20, 0xa1, 0xaa, 0x61, 0xb9, 0x80, 0xd9, 0x36, 0x5a, 0x82, 0xad, 0x33, 0xf4, 0xa8, 0x6a, + 0x20, 0x13, 0x2b, 0xce, 0x5f, 0xb6, 0x24, 0x7d, 0xe5, 0xc0, 0x50, 0x9e, 0xe8, 0xab, 0x0e, 0x76, + 0xdd, 0xc6, 0xf2, 0x2b, 0x60, 0x54, 0x83, 0x15, 0xa8, 0xab, 0x14, 0x57, 0x8b, 0xaa, 0xa6, 0x55, + 0x21, 0x21, 0x09, 0x6e, 0x86, 0x4b, 0xc5, 0x72, 0x89, 0x6f, 0x9f, 0xe7, 0xc6, 0x5c, 0x69, 0xcb, + 0x2c, 0xb2, 0x4e, 0xab, 0xc8, 0xd4, 0x0b, 0x23, 0x7e, 0x8a, 0xbb, 0xce, 0xdf, 0x01, 0x7d, 0xaa, + 0x81, 0x6b, 0x26, 0x4d, 0x44, 0x67, 0xb8, 0x54, 0x3c, 0x33, 0x29, 0xbb, 0x89, 0xb6, 0x0b, 0x9e, + 0x97, 0xf2, 0x63, 0x8c, 0xcc, 0x5c, 0xef, 0xe1, 0xcf, 0x64, 0xa4, 0xe0, 0xc2, 0xb3, 0xf7, 0xdf, + 0xed, 0x27, 0x23, 0x7f, 0xf6, 0x93, 0x91, 0xb7, 0x67, 0x07, 0xe9, 0xf3, 0xad, 0xbc, 0x3f, 0x3b, + 0x48, 0x0b, 0x41, 0xbd, 0xe1, 0xf6, 0xa5, 0x04, 0x18, 0x0f, 0xaf, 0x14, 0x20, 0xb1, 0xb0, 0x49, + 0xa0, 0xf4, 0x3b, 0x0a, 0x06, 0xf2, 0x44, 0x77, 0x16, 0x37, 0xf0, 0xea, 0xda, 0xbf, 0x52, 0xba, + 0x02, 0x46, 0xeb, 0x6a, 0x05, 0x69, 0x21, 0x9a, 0x68, 0x27, 0x1a, 0x3f, 0xc5, 0xa3, 0x79, 0x02, + 0x06, 0x1d, 0x41, 0x5a, 0xd1, 0xf5, 0xad, 0xa7, 0x3b, 0xdf, 0x06, 0x58, 0xd6, 0xb2, 0x93, 0x64, + 0xb3, 0x30, 0x73, 0x3c, 0x96, 0xde, 0x2e, 0x59, 0x58, 0x16, 0x63, 0xc9, 0xde, 0xeb, 0xbc, 0x07, + 0x89, 0xa6, 0x3d, 0xf0, 0x6d, 0x95, 0xc6, 0xc1, 0x58, 0xf0, 0xdd, 0xf7, 0xff, 0x3b, 0x07, 0x46, + 0xfc, 0xad, 0xd9, 0x34, 0xc9, 0x7f, 0x71, 0xda, 0x1e, 0x76, 0x56, 0x3a, 0xdd, 0xf2, 0xb4, 0xb9, + 0x02, 0x24, 0x04, 0x12, 0xcd, 0x6b, 0x9e, 0x62, 0x3e, 0x0f, 0x86, 0xcb, 0xd8, 0xb0, 0x2a, 0x90, + 0x22, 0x6c, 0x16, 0xed, 0xe1, 0x75, 0xa4, 0xc5, 0x33, 0x82, 0xcc, 0x26, 0x5b, 0xf6, 0x26, 0x5b, + 0xde, 0xf0, 0x26, 0x3b, 0xd7, 0x6f, 0xf7, 0xb7, 0x77, 0x9c, 0xe4, 0x0a, 0x43, 0x8d, 0x64, 0x3b, + 0x2c, 0x7d, 0xe1, 0xc0, 0x70, 0x9e, 0xe8, 0x9b, 0x96, 0xa6, 0x52, 0xb8, 0xa6, 0x56, 0x55, 0x83, + 0xf0, 0x4b, 0x20, 0xa6, 0xd6, 0xe8, 0x16, 0xae, 0x22, 0xba, 0xdb, 0xd1, 0xb7, 0x06, 0x94, 0x7f, + 0x04, 0xfa, 0x2c, 0x87, 0xc1, 0x35, 0x4c, 0x92, 0x2f, 0xbe, 0xf1, 0x64, 0x56, 0xcb, 0x73, 0x8e, + 0xe5, 0x65, 0x97, 0x82, 0xce, 0x35, 0x98, 0x6d, 0xc7, 0xa6, 0x9a, 0x1c, 0x0b, 0x76, 0x2c, 0x4d, + 0x82, 0x89, 0xa6, 0x25, 0xff, 0x84, 0x7c, 0x88, 0x02, 0xd1, 0x8f, 0x3d, 0xdf, 0x42, 0x14, 0x56, + 0x10, 0xa1, 0x50, 0x7b, 0xe6, 0xcd, 0xca, 0xd5, 0xf5, 0x1a, 0x60, 0x7c, 0xbb, 0x41, 0x58, 0xf4, + 0xa7, 0xcf, 0xd6, 0xdf, 0x93, 0x8a, 0x67, 0xe6, 0xdb, 0xe9, 0x6f, 0xd5, 0x8a, 0xeb, 0xc6, 0xf5, + 0xed, 0x56, 0x6d, 0x66, 0x57, 0x2e, 0x36, 0x27, 0xdd, 0xd2, 0x9c, 0x96, 0x6a, 0xa5, 0x14, 0xb8, + 0xd9, 0x1e, 0xe1, 0x5b, 0xf7, 0x89, 0x03, 0xbc, 0x3d, 0x75, 0x90, 0xe6, 0xb1, 0x56, 0xab, 0xc0, + 0x35, 0xb5, 0x46, 0xa0, 0x76, 0x65, 0xbb, 0xa6, 0x40, 0x0c, 0x91, 0xa2, 0xe5, 0x90, 0x38, 0x27, + 0xa4, 0xbf, 0xd0, 0x8f, 0x08, 0x23, 0xcd, 0xde, 0xbd, 0x58, 0x9c, 0xd8, 0x7c, 0x2b, 0x84, 0xfb, + 0x91, 0xa6, 0x81, 0x70, 0x7e, 0xd5, 0x13, 0x91, 0x39, 0xbe, 0x06, 0x7a, 0xf2, 0x44, 0xe7, 0x0d, + 0x10, 0x0f, 0x7e, 0x91, 0xd2, 0xed, 0xf6, 0x26, 0x7c, 0xd9, 0x0b, 0x99, 0xee, 0xb1, 0xfe, 0x98, + 0x12, 0x30, 0x18, 0xbe, 0x94, 0x66, 0xbb, 0x22, 0x71, 0xd1, 0xc2, 0xed, 0xcb, 0xa0, 0xfd, 0xa2, + 0x3a, 0x88, 0x35, 0xbe, 0x44, 0xa9, 0x0e, 0x14, 0x3e, 0x52, 0x98, 0xef, 0x16, 0xe9, 0x17, 0xb2, + 0xc0, 0x40, 0xe8, 0xc6, 0xb8, 0xd5, 0x81, 0x21, 0x08, 0x16, 0x16, 0x2f, 0x01, 0xf6, 0x2b, 0x7e, + 0xe4, 0xc0, 0x54, 0xbb, 0x19, 0xce, 0x76, 0x45, 0xda, 0x32, 0x57, 0xc8, 0x5d, 0x3d, 0xd7, 0xef, + 0x6f, 0x17, 0x0c, 0x37, 0xcf, 0x89, 0xdc, 0xc9, 0xd6, 0x30, 0x5e, 0x58, 0xba, 0x1c, 0xde, 0x2b, + 0x9d, 0x7b, 0x71, 0x78, 0x22, 0x72, 0x47, 0x27, 0x22, 0xf7, 0xeb, 0x44, 0xe4, 0xf6, 0x4e, 0xc5, + 0xc8, 0xd1, 0xa9, 0x18, 0xf9, 0x71, 0x2a, 0x46, 0x5e, 0x3e, 0xd0, 0x11, 0xdd, 0xaa, 0x95, 0xe4, + 0x32, 0x36, 0x14, 0x0b, 0x56, 0x89, 0xdd, 0xbc, 0x59, 0x86, 0x4f, 0x4d, 0xa8, 0xb0, 0x52, 0x73, + 0xa6, 0x4a, 0x51, 0x1d, 0x2a, 0xf5, 0x8c, 0xb2, 0x13, 0xfa, 0xc1, 0x47, 0x77, 0x2d, 0x48, 0x4a, + 0x7d, 0xce, 0xa7, 0x64, 0xf1, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x63, 0x40, 0x59, 0x7c, 0xdf, + 0x0a, 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 { + // LiquidStake defines a method for performing a delegation of coins + // from a delegator to whitelisted validators. + LiquidStake(ctx context.Context, in *MsgLiquidStake, opts ...grpc.CallOption) (*MsgLiquidStakeResponse, error) + // LiquidUnstake defines a method for performing an undelegation of liquid + // staking from a delegate. + LiquidUnstake(ctx context.Context, in *MsgLiquidUnstake, opts ...grpc.CallOption) (*MsgLiquidUnstakeResponse, error) + // StakeToLP defines a method for LSM-transfer of staked XPRT + // into stkXPRT with locking into an LP. + StakeToLP(ctx context.Context, in *MsgStakeToLP, opts ...grpc.CallOption) (*MsgStakeToLPResponse, error) + // UpdateParams defines a method to update the module params. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // UpdateWhitelistedValidators defines a method to update the whitelisted + // validators list. + UpdateWhitelistedValidators(ctx context.Context, in *MsgUpdateWhitelistedValidators, opts ...grpc.CallOption) (*MsgUpdateWhitelistedValidatorsResponse, error) + // SetModulePaused defines a method to update the module's pause status, + // setting value of the safety flag in params. + SetModulePaused(ctx context.Context, in *MsgSetModulePaused, opts ...grpc.CallOption) (*MsgSetModulePausedResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) LiquidStake(ctx context.Context, in *MsgLiquidStake, opts ...grpc.CallOption) (*MsgLiquidStakeResponse, error) { + out := new(MsgLiquidStakeResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/LiquidStake", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) LiquidUnstake(ctx context.Context, in *MsgLiquidUnstake, opts ...grpc.CallOption) (*MsgLiquidUnstakeResponse, error) { + out := new(MsgLiquidUnstakeResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/LiquidUnstake", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) StakeToLP(ctx context.Context, in *MsgStakeToLP, opts ...grpc.CallOption) (*MsgStakeToLPResponse, error) { + out := new(MsgStakeToLPResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/StakeToLP", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateWhitelistedValidators(ctx context.Context, in *MsgUpdateWhitelistedValidators, opts ...grpc.CallOption) (*MsgUpdateWhitelistedValidatorsResponse, error) { + out := new(MsgUpdateWhitelistedValidatorsResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SetModulePaused(ctx context.Context, in *MsgSetModulePaused, opts ...grpc.CallOption) (*MsgSetModulePausedResponse, error) { + out := new(MsgSetModulePausedResponse) + err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/SetModulePaused", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // LiquidStake defines a method for performing a delegation of coins + // from a delegator to whitelisted validators. + LiquidStake(context.Context, *MsgLiquidStake) (*MsgLiquidStakeResponse, error) + // LiquidUnstake defines a method for performing an undelegation of liquid + // staking from a delegate. + LiquidUnstake(context.Context, *MsgLiquidUnstake) (*MsgLiquidUnstakeResponse, error) + // StakeToLP defines a method for LSM-transfer of staked XPRT + // into stkXPRT with locking into an LP. + StakeToLP(context.Context, *MsgStakeToLP) (*MsgStakeToLPResponse, error) + // UpdateParams defines a method to update the module params. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // UpdateWhitelistedValidators defines a method to update the whitelisted + // validators list. + UpdateWhitelistedValidators(context.Context, *MsgUpdateWhitelistedValidators) (*MsgUpdateWhitelistedValidatorsResponse, error) + // SetModulePaused defines a method to update the module's pause status, + // setting value of the safety flag in params. + SetModulePaused(context.Context, *MsgSetModulePaused) (*MsgSetModulePausedResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) LiquidStake(ctx context.Context, req *MsgLiquidStake) (*MsgLiquidStakeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidStake not implemented") +} +func (*UnimplementedMsgServer) LiquidUnstake(ctx context.Context, req *MsgLiquidUnstake) (*MsgLiquidUnstakeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidUnstake not implemented") +} +func (*UnimplementedMsgServer) StakeToLP(ctx context.Context, req *MsgStakeToLP) (*MsgStakeToLPResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StakeToLP not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (*UnimplementedMsgServer) UpdateWhitelistedValidators(ctx context.Context, req *MsgUpdateWhitelistedValidators) (*MsgUpdateWhitelistedValidatorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateWhitelistedValidators not implemented") +} +func (*UnimplementedMsgServer) SetModulePaused(ctx context.Context, req *MsgSetModulePaused) (*MsgSetModulePausedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetModulePaused not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_LiquidStake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgLiquidStake) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).LiquidStake(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Msg/LiquidStake", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).LiquidStake(ctx, req.(*MsgLiquidStake)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_LiquidUnstake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgLiquidUnstake) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).LiquidUnstake(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Msg/LiquidUnstake", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).LiquidUnstake(ctx, req.(*MsgLiquidUnstake)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_StakeToLP_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgStakeToLP) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).StakeToLP(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Msg/StakeToLP", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).StakeToLP(ctx, req.(*MsgStakeToLP)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateWhitelistedValidators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateWhitelistedValidators) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateWhitelistedValidators(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateWhitelistedValidators(ctx, req.(*MsgUpdateWhitelistedValidators)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SetModulePaused_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetModulePaused) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetModulePaused(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pstake.liquidstake.v1beta1.Msg/SetModulePaused", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetModulePaused(ctx, req.(*MsgSetModulePaused)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pstake.liquidstake.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "LiquidStake", + Handler: _Msg_LiquidStake_Handler, + }, + { + MethodName: "LiquidUnstake", + Handler: _Msg_LiquidUnstake_Handler, + }, + { + MethodName: "StakeToLP", + Handler: _Msg_StakeToLP_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + { + MethodName: "UpdateWhitelistedValidators", + Handler: _Msg_UpdateWhitelistedValidators_Handler, + }, + { + MethodName: "SetModulePaused", + Handler: _Msg_SetModulePaused_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "pstake/liquidstake/v1beta1/tx.proto", +} + +func (m *MsgLiquidStake) 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 *MsgLiquidStake) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidStake) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgLiquidStakeResponse) 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 *MsgLiquidStakeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidStakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgStakeToLP) 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 *MsgStakeToLP) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgStakeToLP) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.LiquidAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.StakedAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgStakeToLPResponse) 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 *MsgStakeToLPResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgStakeToLPResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgLiquidUnstake) 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 *MsgLiquidUnstake) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidUnstake) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgLiquidUnstakeResponse) 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 *MsgLiquidUnstakeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidUnstakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CompletionTime):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintTx(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateWhitelistedValidators) 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 *MsgUpdateWhitelistedValidators) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateWhitelistedValidators) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WhitelistedValidators) > 0 { + for iNdEx := len(m.WhitelistedValidators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WhitelistedValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateWhitelistedValidatorsResponse) 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 *MsgUpdateWhitelistedValidatorsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateWhitelistedValidatorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetModulePaused) 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 *MsgSetModulePaused) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetModulePaused) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsPaused { + i-- + if m.IsPaused { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetModulePausedResponse) 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 *MsgSetModulePausedResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetModulePausedResponse) 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 *MsgLiquidStake) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgLiquidStakeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgStakeToLP) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.StakedAmount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.LiquidAmount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgStakeToLPResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgLiquidUnstake) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgLiquidUnstakeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CompletionTime) + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateWhitelistedValidators) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.WhitelistedValidators) > 0 { + for _, e := range m.WhitelistedValidators { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgUpdateWhitelistedValidatorsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetModulePaused) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.IsPaused { + n += 2 + } + return n +} + +func (m *MsgSetModulePausedResponse) 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 *MsgLiquidStake) 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: MsgLiquidStake: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidStake: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 + } + if err := m.Amount.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 *MsgLiquidStakeResponse) 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: MsgLiquidStakeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidStakeResponse: 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 *MsgStakeToLP) 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: MsgStakeToLP: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgStakeToLP: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakedAmount", 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 + } + if err := m.StakedAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidAmount", 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 + } + if err := m.LiquidAmount.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 *MsgStakeToLPResponse) 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: MsgStakeToLPResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgStakeToLPResponse: 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 *MsgLiquidUnstake) 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: MsgLiquidUnstake: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidUnstake: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 + } + if err := m.Amount.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 *MsgLiquidUnstakeResponse) 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: MsgLiquidUnstakeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidUnstakeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", 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 + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CompletionTime, 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 *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 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 + } + if err := m.Params.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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: 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 *MsgUpdateWhitelistedValidators) 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: MsgUpdateWhitelistedValidators: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateWhitelistedValidators: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedValidators", 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.WhitelistedValidators = append(m.WhitelistedValidators, WhitelistedValidator{}) + if err := m.WhitelistedValidators[len(m.WhitelistedValidators)-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 *MsgUpdateWhitelistedValidatorsResponse) 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: MsgUpdateWhitelistedValidatorsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateWhitelistedValidatorsResponse: 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 *MsgSetModulePaused) 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: MsgSetModulePaused: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetModulePaused: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPaused", wireType) + } + 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.IsPaused = bool(v != 0) + 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 *MsgSetModulePausedResponse) 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: MsgSetModulePausedResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetModulePausedResponse: 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") +) From cb3a8d483097914a752616057855279152e4c997 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 17 Jun 2025 20:25:16 +0300 Subject: [PATCH 022/112] chore: Update Cosmos SDK --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b0d17d6..b28b55d 100644 --- a/go.mod +++ b/go.mod @@ -277,7 +277,7 @@ replace ( // // use Cosmos-SDK fork to enable Ledger functionality // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - github.com/cosmos/cosmos-sdk => ../cosmos-sdk/ + github.com/cosmos/cosmos-sdk => gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd // replace cosmos evm with our fork that uses geth v1.13.15 github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index ace1ce3..91cda01 100644 --- a/go.sum +++ b/go.sum @@ -1188,6 +1188,8 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= +gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:u2/mX9cm100Rffheni7PO4OCfjUKMr8imlrO/xPKzG0= +gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.4.0-alpha.1 h1:3yrqQzbRRPFPdOMWS/QQIVxVnzSkAZQYeWlZFv1kbj4= go.etcd.io/bbolt v1.4.0-alpha.1/go.mod h1:S/Z/Nm3iuOnyO1W4XuFfPci51Gj6F1Hv0z8hisyYYOw= From efb8cd758d2eb5a76868e8920325630242c124dd Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Wed, 18 Jun 2025 15:46:04 +0300 Subject: [PATCH 023/112] refactor: Refactor x/liquidstake module --- x/liquidstake/client/cli/query.go | 5 +---- x/liquidstake/client/cli/tx.go | 1 - x/liquidstake/keeper/hooks.go | 12 +++++++----- x/liquidstake/keeper/msg_server.go | 4 +++- x/liquidstake/keeper/rebalancing.go | 8 +++++--- x/liquidstake/types/expected_keepers.go | 7 +++---- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/x/liquidstake/client/cli/query.go b/x/liquidstake/client/cli/query.go index 015c436..8f5dd06 100644 --- a/x/liquidstake/client/cli/query.go +++ b/x/liquidstake/client/cli/query.go @@ -92,10 +92,7 @@ $ %s query %s liquid-validators return err } - queryClient := types.NewQueryClient(clientCtx) - if err != nil { - return err - } + queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.LiquidValidators( cmd.Context(), diff --git a/x/liquidstake/client/cli/tx.go b/x/liquidstake/client/cli/tx.go index c2cc026..8c2b240 100644 --- a/x/liquidstake/client/cli/tx.go +++ b/x/liquidstake/client/cli/tx.go @@ -201,7 +201,6 @@ Example params.json "lsm_disabled": false, "unstake_fee_rate": "0.000000000000000000", "min_liquid_staking_amount": "10000", - "min_liquid_staking_amount": "10000", "cw_locked_pool_address": "persistence14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjvz4fk" } `, diff --git a/x/liquidstake/keeper/hooks.go b/x/liquidstake/keeper/hooks.go index 6d5ec22..e5cfb5a 100644 --- a/x/liquidstake/keeper/hooks.go +++ b/x/liquidstake/keeper/hooks.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" // TODO: replace it with local cosmos sdk epoch hooks // epochstypes "github.com/persistenceOne/persistence-sdk/v2/x/epochs/types" @@ -31,13 +33,13 @@ func (h EpochHooks) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error { func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, _ int64) error { if !k.GetParams(ctx).ModulePaused { // Update the liquid validator set at the start of each epoch - if epochIdentifier == liquidstake.AutocompoundEpoch { + switch epochIdentifier { + case liquidstake.AutocompoundEpoch: k.AutocompoundStakingRewards(ctx, liquidstake.GetWhitelistedValsMap(k.GetParams(ctx).WhitelistedValidators)) - } - - if epochIdentifier == liquidstake.RebalanceEpoch { - // return value of UpdateLiquidValidatorSet is useful only in testing + case liquidstake.RebalanceEpoch: _ = k.UpdateLiquidValidatorSet(ctx, true) + default: + return fmt.Errorf("unknown epoch identifier: %s", epochIdentifier) } } diff --git a/x/liquidstake/keeper/msg_server.go b/x/liquidstake/keeper/msg_server.go index 473590b..8ed1939 100644 --- a/x/liquidstake/keeper/msg_server.go +++ b/x/liquidstake/keeper/msg_server.go @@ -236,13 +236,15 @@ func (k msgServer) UpdateWhitelistedValidators(goCtx context.Context, msg *types } } + if len(msg.WhitelistedValidators) == 0 { + return nil, errors.Wrap(types.ErrWhitelistedValidatorsList, "whitelisted validators list cannot be empty") + } if !totalWeight.Equal(types.TotalValidatorWeight) { return nil, errors.Wrapf( types.ErrWhitelistedValidatorsList, "weights don't add up; expected %s, got %s", types.TotalValidatorWeight.String(), totalWeight.String(), ) } - params.WhitelistedValidators = msg.WhitelistedValidators err := k.SetParams(ctx, params) diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go index fbc49ab..95252e2 100644 --- a/x/liquidstake/keeper/rebalancing.go +++ b/x/liquidstake/keeper/rebalancing.go @@ -93,10 +93,10 @@ func (k Keeper) Rebalance( rebalancingThresholdAmt := rebalancingTrigger.Mul(math.LegacyNewDecFromInt(totalLiquidTokens)).TruncateInt() redelegations = make([]types.Redelegation, 0, liquidVals.Len()) - for i := 0; i < liquidVals.Len(); i++ { + for i := range liquidVals.Len() { // get min, max of liquid token gap minVal, maxVal, amountNeeded, last := liquidVals.MinMaxGap(targetMap, liquidTokenMap) - if amountNeeded.IsZero() || (i == 0 && !amountNeeded.GT(rebalancingThresholdAmt)) { + if amountNeeded.IsNegative() || amountNeeded.IsZero() || (i == 0 && !amountNeeded.GT(rebalancingThresholdAmt)) { break } @@ -222,7 +222,9 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t // use the calculated autocompoundable amount as the limit for the transfer proxyAccBalance := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) - if proxyAccBalance.Amount.LT(autoCompoundableAmount) { + if proxyAccBalance.Amount.IsNegative() { + autoCompoundableAmount = math.ZeroInt() + } else if proxyAccBalance.Amount.LT(autoCompoundableAmount) { autoCompoundableAmount = proxyAccBalance.Amount } diff --git a/x/liquidstake/types/expected_keepers.go b/x/liquidstake/types/expected_keepers.go index 7f253e9..e4b6e50 100644 --- a/x/liquidstake/types/expected_keepers.go +++ b/x/liquidstake/types/expected_keepers.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -28,8 +27,8 @@ type BankKeeper interface { // AccountKeeper defines the expected account keeper type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI } // StakingKeeper expected staking keeper (noalias) @@ -64,7 +63,7 @@ type StakingKeeper interface { BlockValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate HasMaxUnbondingDelegationEntries(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool - GetBondedPool(ctx sdk.Context) (bondedPool authtypes.ModuleAccountI) + GetBondedPool(ctx sdk.Context) (bondedPool sdk.ModuleAccountI) } // MintKeeper expected minting keeper (noalias) From 9be14d300dcb7d8d39df8c63a1b6be49ca22f8f3 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 20 Jun 2025 15:14:10 +0300 Subject: [PATCH 024/112] try to emplement liquid staking --- app/app.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/app.go b/app/app.go index 8ffd82d..9973a77 100644 --- a/app/app.go +++ b/app/app.go @@ -152,6 +152,10 @@ import ( evmibctransferkeeper "github.com/cosmos/evm/x/ibc/transfer/keeper" evmvmkeeper "github.com/cosmos/evm/x/vm/keeper" evmvmtypes "github.com/cosmos/evm/x/vm/types" + + "github.com/Asphere-xyz/tacchain/x/liquidstake" + liquidstakekeeper "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" + liquidstaketypes "github.com/Asphere-xyz/tacchain/x/liquidstake/types" ) // module account permissions @@ -167,6 +171,8 @@ var maccPerms = map[string][]string{ ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibcfeetypes.ModuleName: nil, icatypes.ModuleName: nil, + // liquidstake module + liquidstaketypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // Cosmos EVM modules evmvmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, evmfeemarkettypes.ModuleName: nil, @@ -233,6 +239,9 @@ type TacChainApp struct { // module configurator configurator module.Configurator + // liquidstake keeper + LiquidstakeKeeper liquidstakekeeper.Keeper + // Cosmos EVM keepers FeeMarketKeeper evmfeemarketkeeper.Keeper EVMKeeper *evmvmkeeper.Keeper @@ -300,6 +309,8 @@ func NewTacChainApp( // non sdk store keys capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, + // liquidstake module + liquidstaketypes.StoreKey, // Cosmos EVM store keys evmvmtypes.StoreKey, evmfeemarkettypes.StoreKey, evmerc20types.StoreKey, ) @@ -545,6 +556,20 @@ func NewTacChainApp( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper + // liquidstake keeper + app.LiquidstakeKeeper = liquidstakekeeper.NewKeeper( + encodingConfig.Codec, + keys[liquidstaketypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + app.StakingKeeper, + app.MintKeeper, + app.DistrKeeper, + app.SlashingKeeper, + app.MsgServiceRouter(), + authAddr, + ) + // Cosmos EVM keepers app.FeeMarketKeeper = evmfeemarketkeeper.NewKeeper( encodingConfig.Codec, authtypes.NewModuleAddress(govtypes.ModuleName), @@ -719,6 +744,8 @@ func NewTacChainApp( ibcfee.NewAppModule(app.IBCFeeKeeper), ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), ibctm.AppModule{}, + // liquidstake module + liquidstake.NewAppModule(app.LiquidstakeKeeper), // sdk crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them // Cosmos EVM modules @@ -760,6 +787,8 @@ func NewTacChainApp( capabilitytypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, + // liquidstake module after staking + liquidstaketypes.ModuleName, slashingtypes.ModuleName, minttypes.ModuleName, ibcexported.ModuleName, @@ -840,6 +869,8 @@ func NewTacChainApp( ibcexported.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, + // liquidstake module + liquidstaketypes.ModuleName, // Cosmos EVM modules // From b4720844e0ea0838da89b8e53e8cc0ba4d3dce9a Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 20 Jun 2025 21:14:15 +0300 Subject: [PATCH 025/112] (draft) fixing compatibility issues --- app/app.go | 3 +- app/app_test.go | 2 + x/liquidstake/errors_conflict_test.go | 28 +++++ x/liquidstake/errors_minimal_test.go | 21 ++++ x/liquidstake/keeper/grpc_query.go | 7 +- x/liquidstake/keeper/keeper.go | 31 +++-- x/liquidstake/keeper/liquidstake.go | 118 ++++++++++++++----- x/liquidstake/keeper/msg_server.go | 20 +++- x/liquidstake/keeper/rebalancing.go | 50 ++++++-- x/liquidstake/types/errors.go | 50 ++++---- x/liquidstake/types/errors_test.go | 18 +++ x/liquidstake/types/expected_keepers.go | 150 ++++++++++++++---------- x/liquidstake/types/liquidstake.go | 10 +- 13 files changed, 354 insertions(+), 154 deletions(-) create mode 100644 x/liquidstake/errors_conflict_test.go create mode 100644 x/liquidstake/errors_minimal_test.go create mode 100644 x/liquidstake/types/errors_test.go diff --git a/app/app.go b/app/app.go index 9973a77..15667e8 100644 --- a/app/app.go +++ b/app/app.go @@ -97,6 +97,7 @@ import ( authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" @@ -562,7 +563,7 @@ func NewTacChainApp( keys[liquidstaketypes.StoreKey], app.AccountKeeper, app.BankKeeper, - app.StakingKeeper, + *app.StakingKeeper, app.MintKeeper, app.DistrKeeper, app.SlashingKeeper, diff --git a/app/app_test.go b/app/app_test.go index 81dec08..99be041 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -28,6 +28,8 @@ func TestExportAndBlockedAddrs(t *testing.T) { AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), }) + fmt.Print("AAAAAAAAAAAAAAa") + // BlockedAddresses returns a map of addresses in app v1 and a map of modules name in app v2. for acc := range BlockedAddresses() { var addr sdk.AccAddress diff --git a/x/liquidstake/errors_conflict_test.go b/x/liquidstake/errors_conflict_test.go new file mode 100644 index 0000000..920b659 --- /dev/null +++ b/x/liquidstake/errors_conflict_test.go @@ -0,0 +1,28 @@ +package liquidstake_test + +import ( + "testing" + + "cosmossdk.io/errors" +) + +func TestErrorCodeConflict(t *testing.T) { + // This test intentionally tries to register the same error code twice + // but with the same module name + + // Setup panic recovery + defer func() { + r := recover() + if r == nil { + t.Fatal("Expected panic when registering duplicate error code, but no panic occurred") + } + t.Logf("Got expected panic: %v", r) + }() + + // Register error code 2 with "invalid proof" message (similar to IBC) + _ = errors.RegisterWithGRPCCode("commitment", 2, 2, "invalid proof") + + // Try to register the same error code again with the same module name + // This should cause a panic + _ = errors.RegisterWithGRPCCode("commitment", 2, 2, "another message") +} diff --git a/x/liquidstake/errors_minimal_test.go b/x/liquidstake/errors_minimal_test.go new file mode 100644 index 0000000..e40d2a7 --- /dev/null +++ b/x/liquidstake/errors_minimal_test.go @@ -0,0 +1,21 @@ +package liquidstake_test + +import ( + "testing" + + "cosmossdk.io/errors" +) + +func TestErrorCodeRegistrationMinimal(t *testing.T) { + // This test directly registers error codes to check for conflicts + + // Register error code 2 with "invalid proof" message (similar to IBC) + _ = errors.Register("test-module", 2, "invalid proof") + + // Register error code 1000 (our new liquidstake error code) with any message + // This should not conflict with the previous registration + _ = errors.Register("test-module-2", 1000, "some error message") + + // If we reach this point without panicking, the test passes + // which means our fix of changing error codes to start from 1000 works +} diff --git a/x/liquidstake/keeper/grpc_query.go b/x/liquidstake/keeper/grpc_query.go index fd92f2d..62fdf05 100644 --- a/x/liquidstake/keeper/grpc_query.go +++ b/x/liquidstake/keeper/grpc_query.go @@ -45,5 +45,10 @@ func (k Querier) States(c context.Context, req *types.QueryStatesRequest) (*type ctx := sdk.UnwrapSDKContext(c) - return &types.QueryStatesResponse{NetAmountState: k.GetNetAmountState(ctx)}, nil + AmountState, err := k.GetNetAmountState(ctx) + if err != nil { + return nil, err + } + + return &types.QueryStatesResponse{NetAmountState: *AmountState}, nil } diff --git a/x/liquidstake/keeper/keeper.go b/x/liquidstake/keeper/keeper.go index 8d0815a..332be00 100644 --- a/x/liquidstake/keeper/keeper.go +++ b/x/liquidstake/keeper/keeper.go @@ -9,6 +9,13 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" ) @@ -17,12 +24,12 @@ type Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper - stakingKeeper types.StakingKeeper - mintKeeper types.MintKeeper - distrKeeper types.DistrKeeper - slashingKeeper types.SlashingKeeper + accountKeeper authkeeper.AccountKeeper + bankKeeper bankkeeper.BaseKeeper + stakingKeeper stakingkeeper.Keeper + mintKeeper mintkeeper.Keeper + distrKeeper distrkeeper.Keeper + slashingKeeper slashingkeeper.Keeper router *baseapp.MsgServiceRouter authority string @@ -32,12 +39,12 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, - accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, - stakingKeeper types.StakingKeeper, - mintKeeper types.MintKeeper, - distrKeeper types.DistrKeeper, - slashingKeeper types.SlashingKeeper, + accountKeeper authkeeper.AccountKeeper, + bankKeeper bankkeeper.BaseKeeper, + stakingKeeper stakingkeeper.Keeper, + mintKeeper mintkeeper.Keeper, + distrKeeper distrkeeper.Keeper, + slashingKeeper slashingkeeper.Keeper, router *baseapp.MsgServiceRouter, authority string, ) Keeper { diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index c1aa483..a957343 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -25,11 +25,17 @@ func (k Keeper) LiquidBondDenom(ctx sdk.Context) string { // GetNetAmountState calculates the sum of bondedDenom balance, total delegation tokens(slash applied LiquidTokens), total remaining reward of types.LiquidStakeProxyAcc // During liquid unstaking, stkxprt immediately burns and the unbonding queue belongs to the requester, so the liquid staker's unbonding values are excluded on netAmount // It is used only for calculation and query and is not stored in kv. -func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas types.NetAmountState) { - totalRemainingRewards, totalDelShares, totalLiquidTokens := k.CheckDelegationStates(ctx, types.LiquidStakeProxyAcc) +func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, err error) { + totalRemainingRewards, totalDelShares, totalLiquidTokens, err := k.CheckDelegationStates(ctx, types.LiquidStakeProxyAcc) + if err != nil { + return nil, err + } totalUnbondingBalance := math.ZeroInt() - ubds := k.stakingKeeper.GetAllUnbondingDelegations(ctx, types.LiquidStakeProxyAcc) + ubds, err := k.stakingKeeper.GetAllUnbondingDelegations(ctx, types.LiquidStakeProxyAcc) + if err != nil{ + return nil, err + } for _, ubd := range ubds { for _, entry := range ubd.Entries { // use Balance(slashing applied) not InitialBalance(without slashing) @@ -37,7 +43,7 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas types.NetAmountState) { } } - nas = types.NetAmountState{ + nas = &types.NetAmountState{ StkxprtTotalSupply: k.bankKeeper.GetSupply(ctx, k.LiquidBondDenom(ctx)).Amount, TotalDelShares: totalDelShares, TotalLiquidTokens: totalLiquidTokens, @@ -48,7 +54,7 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas types.NetAmountState) { nas.NetAmount = nas.CalcNetAmount() nas.MintRate = nas.CalcMintRate() - return + return nas, nil } // LiquidStake mints stkXPRT worth of staking coin value according to NetAmount and performs LiquidDelegate. @@ -67,7 +73,10 @@ func (k Keeper) LiquidStake( } // check bond denomination - bondDenom := k.stakingKeeper.BondDenom(ctx) + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + return math.ZeroInt(), err + } if stakingCoin.Denom != bondDenom { return math.ZeroInt(), errorsmod.Wrapf( types.ErrInvalidBondDenom, "invalid coin denomination: got %s, expected %s", stakingCoin.Denom, bondDenom, @@ -101,7 +110,10 @@ func (k Keeper) LiquidStake( } // NetAmount must be calculated before send - nas := k.GetNetAmountState(ctx) + nas, err := k.GetNetAmountState(ctx) + if err != nil { + return math.ZeroInt(), err + } // send staking coin to liquid stake proxy account to proxy delegation, need sufficient spendable balances err = k.bankKeeper.SendCoins(ctx, liquidStaker, proxyAcc, sdk.NewCoins(stakingCoin)) @@ -246,10 +258,14 @@ func (k Keeper) DelegateWithCap( validator stakingtypes.Validator, bondAmt math.Int, ) error { + denom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + return err + } msgDelegate := &stakingtypes.MsgDelegate{ DelegatorAddress: delegatorAddress.String(), ValidatorAddress: validator.OperatorAddress, - Amount: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), bondAmt), + Amount: sdk.NewCoin(denom, bondAmt), } handler := k.router.Handler(msgDelegate) if handler == nil { @@ -453,11 +469,15 @@ func (k Keeper) RedelegateWithCap( validatorDst sdk.ValAddress, bondAmt math.Int, ) (time.Time, error) { + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + return time.Time{}, err + } msgRedelegate := &stakingtypes.MsgBeginRedelegate{ DelegatorAddress: delegatorAddress.String(), ValidatorSrcAddress: validatorSrc.String(), ValidatorDstAddress: validatorDst.String(), - Amount: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), bondAmt), + Amount: sdk.NewCoin(bondDenom, bondAmt), } handler := k.router.Handler(msgRedelegate) if handler == nil { @@ -522,7 +542,10 @@ func (k Keeper) LSMDelegate( } // check bond denomination - bondDenom := k.stakingKeeper.BondDenom(ctx) + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + return math.ZeroInt(), err + } if preLsmStake.Denom != bondDenom { return math.ZeroInt(), errorsmod.Wrapf( types.ErrInvalidBondDenom, "invalid coin denomination: got %s, expected %s", preLsmStake.Denom, bondDenom, @@ -560,7 +583,10 @@ func (k Keeper) LSMDelegate( } // NetAmount must be calculated before send - nas := k.GetNetAmountState(ctx) + nas, err := k.GetNetAmountState(ctx) + if err != nil { + return math.ZeroInt(), err + } // perform an LSM tokenize->bank send->redeem flow: moving delegation from user's account onto proxyAcc @@ -734,8 +760,11 @@ func (k Keeper) LiquidUnstake( ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, unstakingStkXPRT sdk.Coin, ) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) { params := k.GetParams(ctx) - bondDenom := k.stakingKeeper.BondDenom(ctx) + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err + } if params.ModulePaused { return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrModulePaused } @@ -749,7 +778,10 @@ func (k Keeper) LiquidUnstake( } // Get NetAmount states - nas := k.GetNetAmountState(ctx) + nas, err := k.GetNetAmountState(ctx) + if err != nil { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err + } if unstakingStkXPRT.Amount.GT(nas.StkxprtTotalSupply) || nas.StkxprtTotalSupply.IsZero() { return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrInvalidStkXPRTSupply @@ -765,7 +797,7 @@ func (k Keeper) LiquidUnstake( } // burn stkxprt - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, liquidStaker, types.ModuleName, sdk.NewCoins(unstakingStkXPRT)) + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, liquidStaker, types.ModuleName, sdk.NewCoins(unstakingStkXPRT)) if err != nil { return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err } @@ -879,13 +911,16 @@ func (k Keeper) LiquidUnstake( func (k Keeper) LiquidUnbond( ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, valAddr sdk.ValAddress, shares math.LegacyDec, checkMaxEntries bool, unbondAmount sdk.Coin, ) (time.Time, math.Int, stakingtypes.UnbondingDelegation, error) { - _, found := k.stakingKeeper.GetValidator(ctx, valAddr) - if !found { + _, err := k.stakingKeeper.GetValidator(ctx, valAddr) + if err != nil { return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrNoDelegatorForAddress } // If checkMaxEntries is true, perform a maximum limit unbonding entries check. - if checkMaxEntries && k.stakingKeeper.HasMaxUnbondingDelegationEntries(ctx, liquidStaker, valAddr) { + //TODO: maybe? fix + hasMax, _ := k.stakingKeeper.HasMaxUnbondingDelegationEntries(ctx, liquidStaker, valAddr) + + if checkMaxEntries && hasMax { return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrMaxUnbondingDelegationEntries } @@ -895,10 +930,15 @@ func (k Keeper) LiquidUnbond( return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, err } + unbondTime, err := k.stakingKeeper.UnbondingTime(ctx) + if err != nil { + return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, err + } + //// Unbonding from proxy account, but queues to liquid staker. - completionTime := ctx.BlockHeader().Time.Add(k.stakingKeeper.UnbondingTime(ctx)) - ubd, found := k.stakingKeeper.GetUnbondingDelegation(ctx, liquidStaker, valAddr) - if !found { + completionTime := ctx.BlockHeader().Time.Add(unbondTime) + ubd, err := k.stakingKeeper.GetUnbondingDelegation(ctx, liquidStaker, valAddr) + if err != nil { k.Logger(ctx).Error( "failed to find unbonding delegation", types.DelegatorKeyVal, @@ -920,13 +960,13 @@ func (k Keeper) PrioritiseInactiveLiquidValidators( vs types.LiquidValidators, ) types.LiquidValidators { sort.SliceStable(vs, func(i, j int) bool { - vs1, vs1ok := k.stakingKeeper.GetValidator(ctx, vs[i].GetOperator()) - vs2, vs2ok := k.stakingKeeper.GetValidator(ctx, vs[j].GetOperator()) + vs1, err1 := k.stakingKeeper.GetValidator(ctx, vs[i].GetOperator()) + vs2, err2 := k.stakingKeeper.GetValidator(ctx, vs[j].GetOperator()) - if !vs1ok && vs2ok { + if err1 != nil && err2 == nil { // only one case when less return true - } else if vs1ok && vs2ok { + } else if err1 == nil && err2 == nil { // both exist, compare status vs1Active := vs[i].GetStatus(types.ActiveCondition( @@ -958,8 +998,12 @@ func (k Keeper) PrioritiseInactiveLiquidValidators( } // CheckDelegationStates returns total remaining rewards, delshares, liquid tokens of delegations by proxy account -func (k Keeper) CheckDelegationStates(ctx sdk.Context, proxyAcc sdk.AccAddress) (math.LegacyDec, math.LegacyDec, math.Int) { - bondDenom := k.stakingKeeper.BondDenom(ctx) +func (k Keeper) CheckDelegationStates(ctx sdk.Context, proxyAcc sdk.AccAddress) (math.LegacyDec, math.LegacyDec, math.Int, error) { + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + return math.LegacyZeroDec(), math.LegacyZeroDec(), math.ZeroInt(), err + } + totalRewards := math.LegacyZeroDec() totalDelShares := math.LegacyZeroDec() totalLiquidTokens := math.ZeroInt() @@ -970,9 +1014,18 @@ func (k Keeper) CheckDelegationStates(ctx sdk.Context, proxyAcc sdk.AccAddress) cachedCtx, proxyAcc, func(_ int64, del stakingtypes.DelegationI) (stop bool) { valAddr := del.GetValidatorAddr() - val := k.stakingKeeper.Validator(cachedCtx, sdk.ValAddress(valAddr)) - endingPeriod := k.distrKeeper.IncrementValidatorPeriod(cachedCtx, val) - delReward := k.distrKeeper.CalculateDelegationRewards(cachedCtx, val, del, endingPeriod) + val, err := k.stakingKeeper.Validator(cachedCtx, sdk.ValAddress(valAddr)) + if err != nil { + return false + } + endingPeriod, err := k.distrKeeper.IncrementValidatorPeriod(cachedCtx, val) + if err != nil { + return false + } + delReward, err := k.distrKeeper.CalculateDelegationRewards(cachedCtx, val, del, endingPeriod) + if err != nil { + return false + } delShares := del.GetShares() if delShares.IsPositive() { totalDelShares = totalDelShares.Add(delShares) @@ -984,7 +1037,7 @@ func (k Keeper) CheckDelegationStates(ctx sdk.Context, proxyAcc sdk.AccAddress) }, ) - return totalRewards, totalDelShares, totalLiquidTokens + return totalRewards, totalDelShares, totalLiquidTokens, nil } func (k Keeper) WithdrawLiquidRewards(ctx sdk.Context, proxyAcc sdk.AccAddress) { @@ -1120,8 +1173,9 @@ func (k Keeper) GetLiquidValidatorState(ctx sdk.Context, addr sdk.ValAddress) (l } func (k Keeper) IsActiveLiquidValidator(ctx sdk.Context, lv types.LiquidValidator, whitelistedValsMap types.WhitelistedValsMap) bool { - val, found := k.stakingKeeper.GetValidator(ctx, lv.GetOperator()) - if !found { + val, err := k.stakingKeeper.GetValidator(ctx, lv.GetOperator()) + if err != nil { + //TODO: maybe? fix return false } return types.ActiveCondition(val, whitelistedValsMap.IsListed(lv.OperatorAddress), k.IsTombstoned(ctx, val)) diff --git a/x/liquidstake/keeper/msg_server.go b/x/liquidstake/keeper/msg_server.go index 8ed1939..e929a41 100644 --- a/x/liquidstake/keeper/msg_server.go +++ b/x/liquidstake/keeper/msg_server.go @@ -11,6 +11,8 @@ import ( "fmt" "time" + normal_errors "errors" + "cosmossdk.io/errors" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -148,7 +150,10 @@ func (k msgServer) LiquidUnstake(goCtx context.Context, msg *types.MsgLiquidUnst return nil, err } - bondDenom := k.stakingKeeper.BondDenom(ctx) + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + return nil, err + } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( sdk.EventTypeMessage, @@ -220,11 +225,14 @@ func (k msgServer) UpdateWhitelistedValidators(goCtx context.Context, msg *types totalWeight = totalWeight.Add(val.TargetWeight) valAddr := val.GetValidatorAddress() - fullVal, ok := k.stakingKeeper.GetValidator(ctx, valAddr) - if !ok { - return nil, errors.Wrapf( - types.ErrWhitelistedValidatorsList, - "validator not found: %s", valAddr, + fullVal, err := k.stakingKeeper.GetValidator(ctx, valAddr) + if err != nil { + return nil, normal_errors.Join( + errors.Wrapf( + types.ErrWhitelistedValidatorsList, + "validator not found: %s", valAddr, + ), + err, ) } diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go index 95252e2..e01e1ce 100644 --- a/x/liquidstake/keeper/rebalancing.go +++ b/x/liquidstake/keeper/rebalancing.go @@ -8,12 +8,17 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" ) func (k Keeper) GetProxyAccBalance(ctx sdk.Context, proxyAcc sdk.AccAddress) (balance sdk.Coin) { - bondDenom := k.stakingKeeper.BondDenom(ctx) + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + //TODO: fix + panic(-1) + } + return sdk.NewCoin(bondDenom, k.bankKeeper.SpendableCoins(ctx, proxyAcc).AmountOf(bondDenom)) } @@ -23,7 +28,11 @@ func (k Keeper) TryRedelegation(ctx sdk.Context, re types.Redelegation) (complet srcVal := re.SrcValidator.GetOperator() // check the source validator already has receiving transitive redelegation - hasReceiving := k.stakingKeeper.HasReceivingRedelegation(ctx, re.Delegator, srcVal) + hasReceiving, err := k.stakingKeeper.HasReceivingRedelegation(ctx, re.Delegator, srcVal) + if err != nil { + return time.Time{}, err + } + if hasReceiving { return time.Time{}, stakingtypes.ErrTransitiveRedelegation } @@ -206,10 +215,22 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t } // get all the APY components - bondDenom := k.stakingKeeper.BondDenom(ctx) + bondDenom, err := k.stakingKeeper.BondDenom(ctx) + if err != nil { + //TODO: fix + panic(-1) + } + totalSupply := k.bankKeeper.GetSupply(ctx, bondDenom).Amount bondedTokens := k.bankKeeper.GetBalance(ctx, k.stakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount - inflation := k.mintKeeper.GetMinter(ctx).Inflation + //inflation := k.mintKeeper.GetMinter(ctx).Inflation + minter, err := k.mintKeeper.Minter.Get(ctx) + if err != nil { + //TODO: fix + panic(-1) + } + inflation := minter.Inflation + // calculate the hourly APY bondRatio := math.LegacyDec(bondedTokens).Quo(math.LegacyDec(totalSupply)) @@ -218,7 +239,12 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t Quo(types.DefaultLimitAutocompoundPeriodHours) // calculate autocompoundable amount by limiting the current net amount with the calculated APY - autoCompoundableAmount := k.GetNetAmountState(ctx).NetAmount.Mul(hourlyApy).TruncateInt() + NetAmountState, err := k.GetNetAmountState(ctx) + if err != nil { + //TODO: fix + panic(-1) + } + autoCompoundableAmount := NetAmountState.NetAmount.Mul(hourlyApy).TruncateInt() // use the calculated autocompoundable amount as the limit for the transfer proxyAccBalance := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) @@ -230,10 +256,16 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t // calculate autocompounding fee params := k.GetParams(ctx) - autocompoundFee := sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), math.ZeroInt()) + bondDenom, err = k.stakingKeeper.BondDenom(ctx) + if err != nil { + //TODO: fix + panic(-1) + } + + autocompoundFee := sdk.NewCoin(bondDenom, math.ZeroInt()) if !params.AutocompoundFeeRate.IsZero() && autoCompoundableAmount.IsPositive() { autocompoundFee = sdk.NewCoin( - k.stakingKeeper.BondDenom(ctx), + bondDenom, params.AutocompoundFeeRate.MulInt(autoCompoundableAmount).TruncateInt(), ) } @@ -241,7 +273,7 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t // re-staking of the accumulated rewards cachedCtx, writeCache := ctx.CacheContext() delegableAmount := autoCompoundableAmount.Sub(autocompoundFee.Amount) - err := k.LiquidDelegate(cachedCtx, types.LiquidStakeProxyAcc, activeVals, delegableAmount, whitelistedValsMap) + err = k.LiquidDelegate(cachedCtx, types.LiquidStakeProxyAcc, activeVals, delegableAmount, whitelistedValsMap) if err != nil { k.Logger(ctx).Error( "failed to re-stake the accumulated rewards", diff --git a/x/liquidstake/types/errors.go b/x/liquidstake/types/errors.go index a3981ff..8dda2df 100644 --- a/x/liquidstake/types/errors.go +++ b/x/liquidstake/types/errors.go @@ -4,29 +4,29 @@ import "cosmossdk.io/errors" // Sentinel errors for the liquidstake module. var ( - ErrActiveLiquidValidatorsNotExists = errors.Register(ModuleName, 2, "active liquid validators not exists") - ErrInvalidDenom = errors.Register(ModuleName, 3, "invalid denom") - ErrInvalidBondDenom = errors.Register(ModuleName, 4, "invalid bond denom") - ErrInvalidLiquidBondDenom = errors.Register(ModuleName, 5, "invalid liquid bond denom") - ErrNotImplementedYet = errors.Register(ModuleName, 6, "not implemented yet") - ErrLessThanMinLiquidStakeAmount = errors.Register(ModuleName, 7, "staking amount should be over params.min_liquid_stake_amount") - ErrInvalidStkXPRTSupply = errors.Register(ModuleName, 8, "invalid liquid bond denom supply") - ErrInvalidActiveLiquidValidators = errors.Register(ModuleName, 9, "invalid active liquid validators") - ErrLiquidValidatorsNotExists = errors.Register(ModuleName, 10, "liquid validators not exists") - ErrInsufficientProxyAccBalance = errors.Register(ModuleName, 11, "insufficient liquid tokens or balance of proxy account, need to wait for new liquid validator to be added or unbonding of proxy account to be completed") - ErrTooSmallLiquidStakeAmount = errors.Register(ModuleName, 12, "liquid stake amount is too small, the result becomes zero") - ErrTooSmallLiquidUnstakingAmount = errors.Register(ModuleName, 13, "liquid unstaking amount is too small, the result becomes zero") - ErrNoLPContractAddress = errors.Register(ModuleName, 14, "CW address of an LP contract is not set") - ErrDisabledLSM = errors.Register(ModuleName, 15, "LSM delegation is disabled") - ErrLSMTokenizeFailed = errors.Register(ModuleName, 16, "LSM tokenization failed") - ErrLSMRedeemFailed = errors.Register(ModuleName, 17, "LSM redemption failed") - ErrLPContract = errors.Register(ModuleName, 18, "CW contract execution failed") - ErrWhitelistedValidatorsList = errors.Register(ModuleName, 19, "whitelisted validators list incorrect") - ErrActiveLiquidValidatorsWeightQuorumNotReached = errors.Register(ModuleName, 20, "active liquid validators weight quorum not reached") - ErrModulePaused = errors.Register(ModuleName, 21, "module functions have been paused") - ErrDelegationFailed = errors.Register(ModuleName, 22, "delegation failed") - ErrUnbondFailed = errors.Register(ModuleName, 23, "unbond failed") - ErrInvalidResponse = errors.Register(ModuleName, 24, "invalid response") - ErrUnstakeFailed = errors.Register(ModuleName, 25, "Unstaking failed") - ErrRedelegateFailed = errors.Register(ModuleName, 26, "Redelegate failed") + ErrActiveLiquidValidatorsNotExists = errors.Register(ModuleName, 1000, "active liquid validators not exists") + ErrInvalidDenom = errors.Register(ModuleName, 1001, "invalid denom") + ErrInvalidBondDenom = errors.Register(ModuleName, 1002, "invalid bond denom") + ErrInvalidLiquidBondDenom = errors.Register(ModuleName, 1003, "invalid liquid bond denom") + ErrNotImplementedYet = errors.Register(ModuleName, 1004, "not implemented yet") + ErrLessThanMinLiquidStakeAmount = errors.Register(ModuleName, 1005, "staking amount should be over params.min_liquid_stake_amount") + ErrInvalidStkXPRTSupply = errors.Register(ModuleName, 1006, "invalid liquid bond denom supply") + ErrInvalidActiveLiquidValidators = errors.Register(ModuleName, 1007, "invalid active liquid validators") + ErrLiquidValidatorsNotExists = errors.Register(ModuleName, 1008, "liquid validators not exists") + ErrInsufficientProxyAccBalance = errors.Register(ModuleName, 1009, "insufficient liquid tokens or balance of proxy account, need to wait for new liquid validator to be added or unbonding of proxy account to be completed") + ErrTooSmallLiquidStakeAmount = errors.Register(ModuleName, 1010, "liquid stake amount is too small, the result becomes zero") + ErrTooSmallLiquidUnstakingAmount = errors.Register(ModuleName, 1011, "liquid unstaking amount is too small, the result becomes zero") + ErrNoLPContractAddress = errors.Register(ModuleName, 1012, "CW address of an LP contract is not set") + ErrDisabledLSM = errors.Register(ModuleName, 1013, "LSM delegation is disabled") + ErrLSMTokenizeFailed = errors.Register(ModuleName, 1014, "LSM tokenization failed") + ErrLSMRedeemFailed = errors.Register(ModuleName, 1015, "LSM redemption failed") + ErrLPContract = errors.Register(ModuleName, 1016, "CW contract execution failed") + ErrWhitelistedValidatorsList = errors.Register(ModuleName, 1017, "whitelisted validators list incorrect") + ErrActiveLiquidValidatorsWeightQuorumNotReached = errors.Register(ModuleName, 1018, "active liquid validators weight quorum not reached") + ErrModulePaused = errors.Register(ModuleName, 1019, "module functions have been paused") + ErrDelegationFailed = errors.Register(ModuleName, 1020, "delegation failed") + ErrUnbondFailed = errors.Register(ModuleName, 1021, "unbond failed") + ErrInvalidResponse = errors.Register(ModuleName, 1022, "invalid response") + ErrUnstakeFailed = errors.Register(ModuleName, 1023, "Unstaking failed") + ErrRedelegateFailed = errors.Register(ModuleName, 1024, "Redelegate failed") ) diff --git a/x/liquidstake/types/errors_test.go b/x/liquidstake/types/errors_test.go new file mode 100644 index 0000000..f958aef --- /dev/null +++ b/x/liquidstake/types/errors_test.go @@ -0,0 +1,18 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" + ibctypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" // Import the conflicting module +) + +func TestErrorCodeRegistration(t *testing.T) { + // This test simply imports both modules with error registrations + // If there's a conflict, it will panic during initialization + // The test passes if it doesn't panic + assert.NotNil(t, types.ErrActiveLiquidValidatorsNotExists, "liquidstake error should be registered") + assert.NotNil(t, ibctypes.ErrInvalidProof, "IBC error should be registered") +} diff --git a/x/liquidstake/types/expected_keepers.go b/x/liquidstake/types/expected_keepers.go index e4b6e50..2123811 100644 --- a/x/liquidstake/types/expected_keepers.go +++ b/x/liquidstake/types/expected_keepers.go @@ -1,87 +1,107 @@ package types import ( - "time" + //"time" + //"context" "cosmossdk.io/math" - abci "github.com/cometbft/cometbft/abci/types" + //abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + //"github.com/cosmos/cosmos-sdk/x/mint/types" + //stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" ) +type BankKeeper = bankkeeper.Keeper + // BankKeeper defines the expected bank send keeper -type BankKeeper interface { - SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error - - GetSupply(ctx sdk.Context, denom string) sdk.Coin - SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error - MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin -} +//type BankKeeper interface { +// SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error +// +// GetSupply(ctx sdk.Context, denom string) sdk.Coin +// SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error +// SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error +// SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +// BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error +// MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error +// SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins +// GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin +//} // AccountKeeper defines the expected account keeper -type AccountKeeper interface { - GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI -} +type AccountKeeper = authkeeper.AccountKeeper + +//type AccountKeeper interface { +// GetModuleAddress(name string) sdk.AccAddress +// GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI +// GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI +//} + +type StakingKeeper = stakingkeeper.Keeper // StakingKeeper expected staking keeper (noalias) -type StakingKeeper interface { - Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI - ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI - GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) - - GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) - GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator - - GetLastTotalPower(ctx sdk.Context) math.Int - GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 - - Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI - GetDelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) - IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, - fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) - - BondDenom(ctx sdk.Context) (res string) - UnbondingTime(ctx sdk.Context) (res time.Duration) - ValidateUnbondAmount( - ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt math.Int, - ) (shares math.LegacyDec, err error) - GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.UnbondingDelegation, bool) - GetAllUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.UnbondingDelegation - GetAllRedelegations( - ctx sdk.Context, delegator sdk.AccAddress, srcValAddress, dstValAddress sdk.ValAddress, - ) []stakingtypes.Redelegation - HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool - BlockValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate - HasMaxUnbondingDelegationEntries(ctx sdk.Context, - delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool - GetBondedPool(ctx sdk.Context) (bondedPool sdk.ModuleAccountI) -} +//type StakingKeeper interface { +// Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI +// ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI +// GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) +// +// GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) +// GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator +// +// GetLastTotalPower(ctx sdk.Context) math.Int +// GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 +// +// Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI +// GetDelegation(ctx sdk.Context, +// delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) +// IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, +// fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) +// +// BondDenom(ctx sdk.Context) (res string) +// UnbondingTime(ctx sdk.Context) (res time.Duration) +// ValidateUnbondAmount( +// ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt math.Int, +// ) (shares math.LegacyDec, err error) +// GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.UnbondingDelegation, bool) +// GetAllUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.UnbondingDelegation +// GetAllRedelegations( +// ctx sdk.Context, delegator sdk.AccAddress, srcValAddress, dstValAddress sdk.ValAddress, +// ) []stakingtypes.Redelegation +// HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool +// BlockValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate +// HasMaxUnbondingDelegationEntries(ctx sdk.Context, +// delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool +// GetBondedPool(ctx sdk.Context) (bondedPool sdk.ModuleAccountI) +//} // MintKeeper expected minting keeper (noalias) -type MintKeeper interface { - GetMinter(ctx sdk.Context) (minter types.Minter) -} +type MintKeeper = mintkeeper.Keeper; + +//type MintKeeper interface { +// GetMinter(ctx sdk.Context) (minter types.Minter) +//} // DistrKeeper expected distribution keeper (noalias) -type DistrKeeper interface { - IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.ValidatorI) uint64 - CalculateDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) - WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) -} +type DistrKeeper = distrkeeper.Keeper +//type DistrKeeper interface { +// IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.ValidatorI) uint64 +// CalculateDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) +// WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) +//} + + +type SlashingKeeper = slashingkeeper.Keeper // SlashingKeeper expected slashing keeper (noalias) -type SlashingKeeper interface { - IsTombstoned(ctx sdk.Context, consAddr sdk.ConsAddress) bool -} +//type SlashingKeeper interface { +// IsTombstoned(ctx sdk.Context, consAddr sdk.ConsAddress) bool +//} // StakingHooks event hooks for staking validator object (noalias) type StakingHooks interface { diff --git a/x/liquidstake/types/liquidstake.go b/x/liquidstake/types/liquidstake.go index 275ae38..d2da6ef 100644 --- a/x/liquidstake/types/liquidstake.go +++ b/x/liquidstake/types/liquidstake.go @@ -46,8 +46,8 @@ func (v LiquidValidator) GetOperator() sdk.ValAddress { } func (v LiquidValidator) GetDelShares(ctx sdk.Context, sk StakingKeeper) math.LegacyDec { - del, found := sk.GetDelegation(ctx, LiquidStakeProxyAcc, v.GetOperator()) - if !found { + del, err := sk.GetDelegation(ctx, LiquidStakeProxyAcc, v.GetOperator()) + if err != nil { return math.LegacyZeroDec() } return del.GetShares() @@ -58,7 +58,11 @@ func (v LiquidValidator) GetLiquidTokens(ctx sdk.Context, sk StakingKeeper, only if !delShares.IsPositive() { return math.ZeroInt() } - val := sk.Validator(ctx, v.GetOperator()) + val, err := sk.Validator(ctx, v.GetOperator()) + if err != nil { + //TODO: fix + panic(-1) + } if onlyBonded && !val.IsBonded() { return math.ZeroInt() } From ba99838aff10c700d9f69bd427a781d602f5dc46 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 20 Jun 2025 22:34:22 +0300 Subject: [PATCH 026/112] dependency cherry-picking --- go.mod | 8 ++++---- go.sum | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index b28b55d..a462621 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/nft v0.1.1 cosmossdk.io/x/upgrade v0.1.4 - github.com/CosmWasm/wasmd v0.55.0 + github.com/CosmWasm/wasmd v0.53.0 github.com/cometbft/cometbft v0.38.17 github.com/cosmos/cosmos-db v1.1.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 @@ -25,7 +25,6 @@ require ( github.com/cosmos/evm v0.1.1-0.20250328143818-59c573a37f8b github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 - github.com/cosmos/ibc-go/v8 v8.7.0 github.com/ethereum/go-ethereum v1.15.5 github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.1 @@ -41,6 +40,8 @@ require ( google.golang.org/protobuf v1.36.5 ) +require github.com/cosmos/ibc-go/v8 v8.7.0 + require ( cloud.google.com/go v0.115.0 // indirect cloud.google.com/go/auth v0.6.0 // indirect @@ -54,7 +55,7 @@ require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect - github.com/CosmWasm/wasmvm/v2 v2.2.1 // indirect + github.com/CosmWasm/wasmvm/v2 v2.1.2 // indirect github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect @@ -90,7 +91,6 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.4 // indirect - github.com/cosmos/ibc-go/v10 v10.0.0 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect diff --git a/go.sum b/go.sum index 91cda01..e551fff 100644 --- a/go.sum +++ b/go.sum @@ -227,10 +227,10 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CosmWasm/wasmd v0.55.0 h1:NJgTxvdqh4WunjQ/djL0hnnq3LUU58rW7CiUkeCBu/8= -github.com/CosmWasm/wasmd v0.55.0/go.mod h1:67K2PzoSF9+NjImaALEYMaAHd3zwaSuWLsQ7iSznUik= -github.com/CosmWasm/wasmvm/v2 v2.2.1 h1:cmOnM+TDfUl2VRugeo1eJBw4U/Lw0WLviuQHKSo9DVQ= -github.com/CosmWasm/wasmvm/v2 v2.2.1/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= +github.com/CosmWasm/wasmd v0.53.0 h1:kdaoAi20bIb4VCsxw9pRaT2g5PpIp82Wqrr9DRVN9ao= +github.com/CosmWasm/wasmd v0.53.0/go.mod h1:FJl/aWjdpGof3usAMFQpDe07Rkx77PUzp0cygFMOvtw= +github.com/CosmWasm/wasmvm/v2 v2.1.2 h1:GkJ5bAsRlLHfIQVg/FY1VHwLyBwlCjAhDea0B8L+e20= +github.com/CosmWasm/wasmvm/v2 v2.1.2/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -423,8 +423,6 @@ github.com/cosmos/iavl v1.2.4 h1:IHUrG8dkyueKEY72y92jajrizbkZKPZbMmG14QzsEkw= github.com/cosmos/iavl v1.2.4/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= -github.com/cosmos/ibc-go/v10 v10.0.0 h1:38nkt3kSrBLnA7mm9Gg4S11X3wtWdbLv7laBZ8hzc5o= -github.com/cosmos/ibc-go/v10 v10.0.0/go.mod h1:82OVClziZQ+9EyDRrnlr2eewcewQ0cxLu7LAbF+q7mc= github.com/cosmos/ibc-go/v8 v8.7.0 h1:HqhVOkO8bDpClXE81DFQgFjroQcTvtpm0tCS7SQVKVY= github.com/cosmos/ibc-go/v8 v8.7.0/go.mod h1:G2z+Q6ZQSMcyHI2+BVcJdvfOupb09M2h/tgpXOEdY6k= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= From d9949d9a283d422e13a3f87f6c64401bac687b0f Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Mon, 23 Jun 2025 15:17:14 +0300 Subject: [PATCH 027/112] remove redunant tests --- x/liquidstake/errors_conflict_test.go | 28 --------------------------- x/liquidstake/errors_minimal_test.go | 21 -------------------- 2 files changed, 49 deletions(-) delete mode 100644 x/liquidstake/errors_conflict_test.go delete mode 100644 x/liquidstake/errors_minimal_test.go diff --git a/x/liquidstake/errors_conflict_test.go b/x/liquidstake/errors_conflict_test.go deleted file mode 100644 index 920b659..0000000 --- a/x/liquidstake/errors_conflict_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package liquidstake_test - -import ( - "testing" - - "cosmossdk.io/errors" -) - -func TestErrorCodeConflict(t *testing.T) { - // This test intentionally tries to register the same error code twice - // but with the same module name - - // Setup panic recovery - defer func() { - r := recover() - if r == nil { - t.Fatal("Expected panic when registering duplicate error code, but no panic occurred") - } - t.Logf("Got expected panic: %v", r) - }() - - // Register error code 2 with "invalid proof" message (similar to IBC) - _ = errors.RegisterWithGRPCCode("commitment", 2, 2, "invalid proof") - - // Try to register the same error code again with the same module name - // This should cause a panic - _ = errors.RegisterWithGRPCCode("commitment", 2, 2, "another message") -} diff --git a/x/liquidstake/errors_minimal_test.go b/x/liquidstake/errors_minimal_test.go deleted file mode 100644 index e40d2a7..0000000 --- a/x/liquidstake/errors_minimal_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package liquidstake_test - -import ( - "testing" - - "cosmossdk.io/errors" -) - -func TestErrorCodeRegistrationMinimal(t *testing.T) { - // This test directly registers error codes to check for conflicts - - // Register error code 2 with "invalid proof" message (similar to IBC) - _ = errors.Register("test-module", 2, "invalid proof") - - // Register error code 1000 (our new liquidstake error code) with any message - // This should not conflict with the previous registration - _ = errors.Register("test-module-2", 1000, "some error message") - - // If we reach this point without panicking, the test passes - // which means our fix of changing error codes to start from 1000 works -} From 9dde47bb3240d0b67e5c771779c8cf79b201a782 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Mon, 23 Jun 2025 16:49:05 +0300 Subject: [PATCH 028/112] protogen fix --- Makefile | 1 + scripts/protocgen.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6b25757..a0ba65b 100644 --- a/Makefile +++ b/Makefile @@ -149,4 +149,5 @@ protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(pro proto-gen: @echo "Generating Protobuf files" @$(protoImage) sh ./scripts/protocgen.sh + @go mod tidy diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 4ab35d8..e2f8d7a 100644 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -13,4 +13,4 @@ cd .. cp -r github.com/persistenceOne/pstake-native/v*/* ./ rm -rf github.com -go mod tidy +#go mod tidy From dbd83dae6d694a6bbf2856249adbbeb39b2e7a18 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Mon, 23 Jun 2025 16:55:38 +0300 Subject: [PATCH 029/112] another fix on fix --- proto/pstake/liquidstake/v1beta1/query.proto | 3 + proto/pstake/liquidstake/v1beta1/tx.proto | 1 + x/liquidstake/types/query.pb.go | 63 ++++++----- x/liquidstake/types/tx.pb.go | 110 +++++++++---------- 4 files changed, 92 insertions(+), 85 deletions(-) diff --git a/proto/pstake/liquidstake/v1beta1/query.proto b/proto/pstake/liquidstake/v1beta1/query.proto index 9960909..176397b 100644 --- a/proto/pstake/liquidstake/v1beta1/query.proto +++ b/proto/pstake/liquidstake/v1beta1/query.proto @@ -4,11 +4,14 @@ package pstake.liquidstake.v1beta1; import "google/api/annotations.proto"; import "pstake/liquidstake/v1beta1/liquidstake.proto"; import "gogoproto/gogo.proto"; +import "cosmos/msg/v1/msg.proto"; + option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; // Query defines the gRPC query service for the liquidstake module. service Query { + option (cosmos.msg.v1.service) = true; // Params returns parameters of the liquidstake module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/pstake/liquidstake/v1beta1/params"; diff --git a/proto/pstake/liquidstake/v1beta1/tx.proto b/proto/pstake/liquidstake/v1beta1/tx.proto index d9215c1..28549f0 100644 --- a/proto/pstake/liquidstake/v1beta1/tx.proto +++ b/proto/pstake/liquidstake/v1beta1/tx.proto @@ -13,6 +13,7 @@ option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/ty // Msg defines the liquid staking Msg service. service Msg { + option (cosmos.msg.v1.service) = true; // LiquidStake defines a method for performing a delegation of coins // from a delegator to whitelisted validators. rpc LiquidStake(MsgLiquidStake) returns (MsgLiquidStakeResponse); diff --git a/x/liquidstake/types/query.pb.go b/x/liquidstake/types/query.pb.go index 55b324d..546f5ed 100644 --- a/x/liquidstake/types/query.pb.go +++ b/x/liquidstake/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -291,36 +292,38 @@ func init() { } var fileDescriptor_1badba19848dd753 = []byte{ - // 463 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcd, 0x8a, 0x13, 0x41, - 0x10, 0x4e, 0xbb, 0x9a, 0x43, 0x2f, 0x48, 0x6c, 0xf7, 0xb0, 0x0c, 0xeb, 0xb8, 0x0c, 0xb2, 0x84, - 0x45, 0xbb, 0xdd, 0x78, 0xd1, 0x8b, 0xe8, 0x9e, 0xc5, 0x9f, 0x15, 0x54, 0xf6, 0x12, 0x3a, 0xd9, - 0x62, 0x6c, 0x4c, 0xba, 0x27, 0xd3, 0x35, 0xc1, 0xbd, 0x8a, 0x0f, 0x20, 0x88, 0xcf, 0xe2, 0x2b, - 0xec, 0x71, 0xc1, 0x8b, 0x27, 0x91, 0xc4, 0x17, 0xf0, 0x0d, 0x24, 0xdd, 0xed, 0x98, 0x89, 0x64, - 0x1c, 0xbc, 0x15, 0xd5, 0x5f, 0xd5, 0xf7, 0xcd, 0x57, 0xdf, 0xd0, 0xbd, 0xcc, 0xa2, 0x7c, 0x03, - 0x62, 0xa4, 0x26, 0x85, 0x3a, 0xf1, 0xf5, 0xf4, 0x60, 0x00, 0x28, 0x0f, 0xc4, 0xa4, 0x80, 0xfc, - 0x94, 0x67, 0xb9, 0x41, 0xc3, 0x22, 0x8f, 0xe3, 0x4b, 0x38, 0x1e, 0x70, 0xd1, 0x4e, 0x6a, 0x4c, - 0x3a, 0x02, 0x21, 0x33, 0x25, 0xa4, 0xd6, 0x06, 0x25, 0x2a, 0xa3, 0xad, 0x9f, 0x8c, 0x6e, 0xd6, - 0x30, 0x2c, 0x6f, 0xf3, 0xe8, 0xad, 0xd4, 0xa4, 0xc6, 0x95, 0x62, 0x51, 0xf9, 0x6e, 0xb2, 0x45, - 0xd9, 0xb3, 0x85, 0x98, 0xa7, 0x32, 0x97, 0x63, 0x7b, 0x04, 0x93, 0x02, 0x2c, 0x26, 0x2f, 0xe9, - 0xd5, 0x4a, 0xd7, 0x66, 0x46, 0x5b, 0x60, 0x0f, 0x68, 0x3b, 0x73, 0x9d, 0x6d, 0xb2, 0x4b, 0xba, - 0x9b, 0xbd, 0x84, 0xaf, 0xd7, 0xce, 0xfd, 0xec, 0xe1, 0xc5, 0xb3, 0x6f, 0xd7, 0x5b, 0x47, 0x61, - 0x2e, 0x89, 0xe9, 0x8e, 0x5b, 0xfc, 0xc8, 0x0d, 0xbc, 0x90, 0x23, 0x75, 0x22, 0xd1, 0xe4, 0x25, - 0xf1, 0x7b, 0x42, 0xaf, 0xad, 0x01, 0x04, 0x0d, 0x43, 0x7a, 0xc5, 0xb3, 0xf5, 0xa7, 0xe5, 0xe3, - 0x36, 0xd9, 0xdd, 0xe8, 0x6e, 0xf6, 0x6e, 0xd7, 0xc9, 0x59, 0x59, 0xf8, 0x1c, 0x25, 0x42, 0x10, - 0xd7, 0x19, 0xad, 0x90, 0x95, 0xae, 0x38, 0x54, 0x29, 0x6e, 0x12, 0x5c, 0xf9, 0xdd, 0x0d, 0x8a, - 0x8e, 0x69, 0x47, 0x03, 0xf6, 0xe5, 0xd8, 0x14, 0x1a, 0xfb, 0x76, 0xf1, 0x18, 0xfc, 0xd9, 0xaf, - 0x13, 0xf4, 0x18, 0xf0, 0xa1, 0x1b, 0x59, 0x96, 0x72, 0x59, 0x57, 0xba, 0xbd, 0x9f, 0x1b, 0xf4, - 0x92, 0xe3, 0x64, 0x9f, 0x08, 0x6d, 0x7b, 0x4b, 0x19, 0xaf, 0x5b, 0xfb, 0xf7, 0x35, 0x23, 0xd1, - 0x18, 0xef, 0xbf, 0x28, 0xd9, 0x7f, 0xf7, 0xe5, 0xc7, 0xc7, 0x0b, 0x37, 0x58, 0x22, 0x6a, 0x12, - 0xe6, 0x2f, 0xca, 0x3e, 0x13, 0xda, 0x59, 0x3d, 0x16, 0xbb, 0xfb, 0x4f, 0xc6, 0x35, 0x01, 0x88, - 0xee, 0xfd, 0xc7, 0x64, 0x50, 0xcd, 0x9d, 0xea, 0x2e, 0xdb, 0xab, 0x53, 0xfd, 0x27, 0x34, 0xce, - 0x51, 0x7f, 0xca, 0x06, 0x8e, 0x56, 0x92, 0xd0, 0xc0, 0xd1, 0x6a, 0x46, 0x9a, 0x39, 0xea, 0xa2, - 0x63, 0x0f, 0x5f, 0x9d, 0xcd, 0x62, 0x72, 0x3e, 0x8b, 0xc9, 0xf7, 0x59, 0x4c, 0x3e, 0xcc, 0xe3, - 0xd6, 0xf9, 0x3c, 0x6e, 0x7d, 0x9d, 0xc7, 0xad, 0xe3, 0xfb, 0xa9, 0xc2, 0xd7, 0xc5, 0x80, 0x0f, - 0xcd, 0x58, 0x64, 0x90, 0x5b, 0x65, 0x11, 0xf4, 0x10, 0x9e, 0x68, 0x08, 0x6b, 0x6f, 0x69, 0x89, - 0x6a, 0x0a, 0x62, 0xda, 0x13, 0x6f, 0x2b, 0x14, 0x78, 0x9a, 0x81, 0x1d, 0xb4, 0xdd, 0x3f, 0x7f, - 0xe7, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x2b, 0x8a, 0x4b, 0x9b, 0x04, 0x00, 0x00, + // 486 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcf, 0x8b, 0xd3, 0x40, + 0x14, 0xee, 0xb8, 0x6e, 0x0f, 0xb3, 0x20, 0x75, 0x5c, 0x70, 0x09, 0x6b, 0x5c, 0x82, 0x2c, 0xa5, + 0x68, 0xc6, 0xd6, 0x8b, 0x5e, 0x44, 0xf7, 0x2c, 0xfe, 0x58, 0x41, 0x65, 0x2f, 0x65, 0xda, 0x7d, + 0xc4, 0x60, 0x33, 0x93, 0x66, 0x5e, 0x82, 0x7b, 0x13, 0xf1, 0x0f, 0x10, 0xc4, 0xff, 0xc3, 0x9b, + 0xff, 0xc2, 0x1e, 0x0b, 0x5e, 0x3c, 0x89, 0xb4, 0x82, 0xff, 0x82, 0x47, 0xe9, 0xcc, 0x58, 0x9b, + 0x4a, 0x63, 0xd8, 0x53, 0x86, 0x37, 0xdf, 0x7b, 0xdf, 0x37, 0xdf, 0xfb, 0x42, 0xf7, 0x53, 0x8d, + 0xe2, 0x15, 0xf0, 0x51, 0x3c, 0xce, 0xe3, 0x63, 0x7b, 0x2e, 0xba, 0x03, 0x40, 0xd1, 0xe5, 0xe3, + 0x1c, 0xb2, 0x93, 0x30, 0xcd, 0x14, 0x2a, 0xe6, 0x59, 0x5c, 0xb8, 0x84, 0x0b, 0x1d, 0xce, 0xdb, + 0x8d, 0x94, 0x8a, 0x46, 0xc0, 0x45, 0x1a, 0x73, 0x21, 0xa5, 0x42, 0x81, 0xb1, 0x92, 0xda, 0x76, + 0x7a, 0xd7, 0x2b, 0x18, 0x96, 0xa7, 0x59, 0xf4, 0x76, 0xa4, 0x22, 0x65, 0x8e, 0x7c, 0x7e, 0x72, + 0xd5, 0xcb, 0x43, 0xa5, 0x13, 0xa5, 0x79, 0xa2, 0x23, 0x5e, 0x74, 0xe7, 0x1f, 0x7b, 0x11, 0x6c, + 0x53, 0xf6, 0x64, 0xae, 0xf2, 0xb1, 0xc8, 0x44, 0xa2, 0x0f, 0x61, 0x9c, 0x83, 0xc6, 0xe0, 0x39, + 0xbd, 0x54, 0xaa, 0xea, 0x54, 0x49, 0x0d, 0xec, 0x1e, 0x6d, 0xa6, 0xa6, 0xb2, 0x43, 0xf6, 0x48, + 0x7b, 0xab, 0x17, 0x84, 0xeb, 0x1f, 0x15, 0xda, 0xde, 0x83, 0xf3, 0xa7, 0xdf, 0xae, 0x36, 0x0e, + 0x5d, 0x5f, 0xe0, 0xd3, 0x5d, 0x33, 0xf8, 0x81, 0x69, 0x78, 0x26, 0x46, 0xf1, 0xb1, 0x40, 0x95, + 0x2d, 0x88, 0xdf, 0x11, 0x7a, 0x65, 0x0d, 0xc0, 0x69, 0x18, 0xd2, 0x8b, 0x96, 0xad, 0x5f, 0x2c, + 0x2e, 0x77, 0xc8, 0xde, 0x46, 0x7b, 0xab, 0x77, 0xb3, 0x4a, 0xce, 0xca, 0xc0, 0xa7, 0x28, 0x10, + 0x9c, 0xb8, 0xd6, 0x68, 0x85, 0x6c, 0xe1, 0x8a, 0x41, 0x2d, 0xc4, 0x8d, 0x9d, 0x2b, 0x7f, 0xaa, + 0x4e, 0xd1, 0x11, 0x6d, 0x49, 0xc0, 0xbe, 0x48, 0x54, 0x2e, 0xb1, 0xaf, 0xe7, 0x97, 0xce, 0x9f, + 0x4e, 0x95, 0xa0, 0x87, 0x80, 0xf7, 0x4d, 0xcb, 0xb2, 0x94, 0x0b, 0xb2, 0x54, 0xed, 0xfd, 0xda, + 0xa0, 0x9b, 0x86, 0x93, 0x7d, 0x24, 0xb4, 0x69, 0x2d, 0x65, 0x61, 0xd5, 0xd8, 0x7f, 0xb7, 0xe9, + 0xf1, 0xda, 0x78, 0xfb, 0xa2, 0xa0, 0xf3, 0xf6, 0xcb, 0x8f, 0x0f, 0xe7, 0xae, 0xb1, 0x80, 0x57, + 0x44, 0xcf, 0x6e, 0x94, 0x7d, 0x26, 0xb4, 0xb5, 0xba, 0x2c, 0x76, 0xfb, 0xbf, 0x8c, 0x6b, 0x02, + 0xe0, 0xdd, 0x39, 0x43, 0xa7, 0x53, 0x1d, 0x1a, 0xd5, 0x6d, 0xb6, 0x5f, 0xa5, 0xfa, 0x6f, 0x68, + 0x8c, 0xa3, 0x76, 0x95, 0x35, 0x1c, 0x2d, 0x25, 0xa1, 0x86, 0xa3, 0xe5, 0x8c, 0xd4, 0x73, 0xd4, + 0x44, 0x47, 0x7b, 0x9b, 0x6f, 0x7e, 0x7e, 0xea, 0x90, 0x83, 0x17, 0xa7, 0x53, 0x9f, 0x4c, 0xa6, + 0x3e, 0xf9, 0x3e, 0xf5, 0xc9, 0xfb, 0x99, 0xdf, 0x98, 0xcc, 0xfc, 0xc6, 0xd7, 0x99, 0xdf, 0x38, + 0xba, 0x1b, 0xc5, 0xf8, 0x32, 0x1f, 0x84, 0x43, 0x95, 0xf0, 0x14, 0x32, 0x1d, 0x6b, 0x04, 0x39, + 0x84, 0x47, 0x12, 0xdc, 0xf4, 0x1b, 0x52, 0x60, 0x5c, 0x00, 0x2f, 0x7a, 0xfc, 0x75, 0x89, 0x09, + 0x4f, 0x52, 0xd0, 0x83, 0xa6, 0xf9, 0xf5, 0x6f, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xca, 0xbf, + 0xae, 0xde, 0xbb, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/liquidstake/types/tx.pb.go b/x/liquidstake/types/tx.pb.go index a9b6c6d..fb34000 100644 --- a/x/liquidstake/types/tx.pb.go +++ b/x/liquidstake/types/tx.pb.go @@ -539,61 +539,61 @@ func init() { } var fileDescriptor_d90501ae6d9f0009 = []byte{ - // 851 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4d, 0x4f, 0x13, 0x41, - 0x18, 0xee, 0x16, 0x24, 0x74, 0xca, 0xe7, 0x06, 0xa1, 0x2c, 0x64, 0x4b, 0xd6, 0xc4, 0x34, 0x15, - 0x76, 0xa1, 0x18, 0x8c, 0x35, 0x7e, 0x50, 0xe5, 0x46, 0x23, 0x29, 0xa0, 0xc6, 0x4b, 0xb3, 0xed, - 0x8e, 0xcb, 0xc4, 0xee, 0xce, 0xda, 0x99, 0x16, 0xb8, 0x7a, 0x32, 0x1e, 0x0c, 0x7f, 0xc0, 0x84, - 0x83, 0x3f, 0x80, 0x83, 0xff, 0xc0, 0x0b, 0x37, 0x89, 0x5e, 0x3c, 0x89, 0x81, 0x18, 0xfc, 0x19, - 0x66, 0x77, 0x76, 0xb7, 0xbb, 0xa5, 0xb4, 0x85, 0x78, 0xf0, 0x02, 0xbb, 0xf3, 0x3e, 0xef, 0xf3, - 0xbe, 0xcf, 0x33, 0xf3, 0xce, 0x16, 0xdc, 0xb0, 0x08, 0x55, 0x5f, 0x43, 0xa5, 0x82, 0xde, 0xd4, - 0x90, 0xc6, 0x9e, 0xeb, 0x0b, 0x25, 0x48, 0xd5, 0x05, 0x85, 0xee, 0xc8, 0x56, 0x15, 0x53, 0xcc, - 0x0b, 0x0c, 0x24, 0x07, 0x40, 0xb2, 0x0b, 0x12, 0xc6, 0x74, 0xac, 0x63, 0x07, 0xa6, 0xd8, 0x4f, - 0x2c, 0x43, 0x98, 0x2c, 0x63, 0x62, 0x60, 0x52, 0x64, 0x01, 0xf6, 0xe2, 0x86, 0x44, 0xf6, 0xa6, - 0x94, 0x54, 0xd2, 0x28, 0x55, 0xc6, 0xc8, 0x74, 0xe3, 0x13, 0x6e, 0xdc, 0x20, 0xba, 0x52, 0x5f, - 0xb0, 0xff, 0xb9, 0x81, 0xa4, 0x8e, 0xb1, 0x5e, 0x81, 0x8a, 0xf3, 0x56, 0xaa, 0xbd, 0x52, 0x28, - 0x32, 0x20, 0xa1, 0xaa, 0x61, 0xb9, 0x80, 0xd9, 0x36, 0x5a, 0x82, 0xad, 0x33, 0xf4, 0xa8, 0x6a, - 0x20, 0x13, 0x2b, 0xce, 0x5f, 0xb6, 0x24, 0x7d, 0xe5, 0xc0, 0x50, 0x9e, 0xe8, 0xab, 0x0e, 0x76, - 0xdd, 0xc6, 0xf2, 0x2b, 0x60, 0x54, 0x83, 0x15, 0xa8, 0xab, 0x14, 0x57, 0x8b, 0xaa, 0xa6, 0x55, - 0x21, 0x21, 0x09, 0x6e, 0x86, 0x4b, 0xc5, 0x72, 0x89, 0x6f, 0x9f, 0xe7, 0xc6, 0x5c, 0x69, 0xcb, - 0x2c, 0xb2, 0x4e, 0xab, 0xc8, 0xd4, 0x0b, 0x23, 0x7e, 0x8a, 0xbb, 0xce, 0xdf, 0x01, 0x7d, 0xaa, - 0x81, 0x6b, 0x26, 0x4d, 0x44, 0x67, 0xb8, 0x54, 0x3c, 0x33, 0x29, 0xbb, 0x89, 0xb6, 0x0b, 0x9e, - 0x97, 0xf2, 0x63, 0x8c, 0xcc, 0x5c, 0xef, 0xe1, 0xcf, 0x64, 0xa4, 0xe0, 0xc2, 0xb3, 0xf7, 0xdf, - 0xed, 0x27, 0x23, 0x7f, 0xf6, 0x93, 0x91, 0xb7, 0x67, 0x07, 0xe9, 0xf3, 0xad, 0xbc, 0x3f, 0x3b, - 0x48, 0x0b, 0x41, 0xbd, 0xe1, 0xf6, 0xa5, 0x04, 0x18, 0x0f, 0xaf, 0x14, 0x20, 0xb1, 0xb0, 0x49, - 0xa0, 0xf4, 0x3b, 0x0a, 0x06, 0xf2, 0x44, 0x77, 0x16, 0x37, 0xf0, 0xea, 0xda, 0xbf, 0x52, 0xba, - 0x02, 0x46, 0xeb, 0x6a, 0x05, 0x69, 0x21, 0x9a, 0x68, 0x27, 0x1a, 0x3f, 0xc5, 0xa3, 0x79, 0x02, - 0x06, 0x1d, 0x41, 0x5a, 0xd1, 0xf5, 0xad, 0xa7, 0x3b, 0xdf, 0x06, 0x58, 0xd6, 0xb2, 0x93, 0x64, - 0xb3, 0x30, 0x73, 0x3c, 0x96, 0xde, 0x2e, 0x59, 0x58, 0x16, 0x63, 0xc9, 0xde, 0xeb, 0xbc, 0x07, - 0x89, 0xa6, 0x3d, 0xf0, 0x6d, 0x95, 0xc6, 0xc1, 0x58, 0xf0, 0xdd, 0xf7, 0xff, 0x3b, 0x07, 0x46, - 0xfc, 0xad, 0xd9, 0x34, 0xc9, 0x7f, 0x71, 0xda, 0x1e, 0x76, 0x56, 0x3a, 0xdd, 0xf2, 0xb4, 0xb9, - 0x02, 0x24, 0x04, 0x12, 0xcd, 0x6b, 0x9e, 0x62, 0x3e, 0x0f, 0x86, 0xcb, 0xd8, 0xb0, 0x2a, 0x90, - 0x22, 0x6c, 0x16, 0xed, 0xe1, 0x75, 0xa4, 0xc5, 0x33, 0x82, 0xcc, 0x26, 0x5b, 0xf6, 0x26, 0x5b, - 0xde, 0xf0, 0x26, 0x3b, 0xd7, 0x6f, 0xf7, 0xb7, 0x77, 0x9c, 0xe4, 0x0a, 0x43, 0x8d, 0x64, 0x3b, - 0x2c, 0x7d, 0xe1, 0xc0, 0x70, 0x9e, 0xe8, 0x9b, 0x96, 0xa6, 0x52, 0xb8, 0xa6, 0x56, 0x55, 0x83, - 0xf0, 0x4b, 0x20, 0xa6, 0xd6, 0xe8, 0x16, 0xae, 0x22, 0xba, 0xdb, 0xd1, 0xb7, 0x06, 0x94, 0x7f, - 0x04, 0xfa, 0x2c, 0x87, 0xc1, 0x35, 0x4c, 0x92, 0x2f, 0xbe, 0xf1, 0x64, 0x56, 0xcb, 0x73, 0x8e, - 0xe5, 0x65, 0x97, 0x82, 0xce, 0x35, 0x98, 0x6d, 0xc7, 0xa6, 0x9a, 0x1c, 0x0b, 0x76, 0x2c, 0x4d, - 0x82, 0x89, 0xa6, 0x25, 0xff, 0x84, 0x7c, 0x88, 0x02, 0xd1, 0x8f, 0x3d, 0xdf, 0x42, 0x14, 0x56, - 0x10, 0xa1, 0x50, 0x7b, 0xe6, 0xcd, 0xca, 0xd5, 0xf5, 0x1a, 0x60, 0x7c, 0xbb, 0x41, 0x58, 0xf4, - 0xa7, 0xcf, 0xd6, 0xdf, 0x93, 0x8a, 0x67, 0xe6, 0xdb, 0xe9, 0x6f, 0xd5, 0x8a, 0xeb, 0xc6, 0xf5, - 0xed, 0x56, 0x6d, 0x66, 0x57, 0x2e, 0x36, 0x27, 0xdd, 0xd2, 0x9c, 0x96, 0x6a, 0xa5, 0x14, 0xb8, - 0xd9, 0x1e, 0xe1, 0x5b, 0xf7, 0x89, 0x03, 0xbc, 0x3d, 0x75, 0x90, 0xe6, 0xb1, 0x56, 0xab, 0xc0, - 0x35, 0xb5, 0x46, 0xa0, 0x76, 0x65, 0xbb, 0xa6, 0x40, 0x0c, 0x91, 0xa2, 0xe5, 0x90, 0x38, 0x27, - 0xa4, 0xbf, 0xd0, 0x8f, 0x08, 0x23, 0xcd, 0xde, 0xbd, 0x58, 0x9c, 0xd8, 0x7c, 0x2b, 0x84, 0xfb, - 0x91, 0xa6, 0x81, 0x70, 0x7e, 0xd5, 0x13, 0x91, 0x39, 0xbe, 0x06, 0x7a, 0xf2, 0x44, 0xe7, 0x0d, - 0x10, 0x0f, 0x7e, 0x91, 0xd2, 0xed, 0xf6, 0x26, 0x7c, 0xd9, 0x0b, 0x99, 0xee, 0xb1, 0xfe, 0x98, - 0x12, 0x30, 0x18, 0xbe, 0x94, 0x66, 0xbb, 0x22, 0x71, 0xd1, 0xc2, 0xed, 0xcb, 0xa0, 0xfd, 0xa2, - 0x3a, 0x88, 0x35, 0xbe, 0x44, 0xa9, 0x0e, 0x14, 0x3e, 0x52, 0x98, 0xef, 0x16, 0xe9, 0x17, 0xb2, - 0xc0, 0x40, 0xe8, 0xc6, 0xb8, 0xd5, 0x81, 0x21, 0x08, 0x16, 0x16, 0x2f, 0x01, 0xf6, 0x2b, 0x7e, - 0xe4, 0xc0, 0x54, 0xbb, 0x19, 0xce, 0x76, 0x45, 0xda, 0x32, 0x57, 0xc8, 0x5d, 0x3d, 0xd7, 0xef, - 0x6f, 0x17, 0x0c, 0x37, 0xcf, 0x89, 0xdc, 0xc9, 0xd6, 0x30, 0x5e, 0x58, 0xba, 0x1c, 0xde, 0x2b, - 0x9d, 0x7b, 0x71, 0x78, 0x22, 0x72, 0x47, 0x27, 0x22, 0xf7, 0xeb, 0x44, 0xe4, 0xf6, 0x4e, 0xc5, - 0xc8, 0xd1, 0xa9, 0x18, 0xf9, 0x71, 0x2a, 0x46, 0x5e, 0x3e, 0xd0, 0x11, 0xdd, 0xaa, 0x95, 0xe4, - 0x32, 0x36, 0x14, 0x0b, 0x56, 0x89, 0xdd, 0xbc, 0x59, 0x86, 0x4f, 0x4d, 0xa8, 0xb0, 0x52, 0x73, - 0xa6, 0x4a, 0x51, 0x1d, 0x2a, 0xf5, 0x8c, 0xb2, 0x13, 0xfa, 0xc1, 0x47, 0x77, 0x2d, 0x48, 0x4a, - 0x7d, 0xce, 0xa7, 0x64, 0xf1, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x63, 0x40, 0x59, 0x7c, 0xdf, - 0x0a, 0x00, 0x00, + // 860 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcd, 0x4e, 0xdb, 0x4a, + 0x14, 0x8e, 0xc3, 0x8f, 0xc8, 0x84, 0x5f, 0x8b, 0x0b, 0xc1, 0x20, 0x07, 0xf9, 0x4a, 0x57, 0x51, + 0x2e, 0xd8, 0x10, 0x2a, 0xaa, 0xa6, 0xea, 0x0f, 0x69, 0xd9, 0x11, 0x15, 0x05, 0x68, 0xab, 0x6e, + 0x22, 0x27, 0x9e, 0x9a, 0x51, 0x63, 0x8f, 0x9b, 0x99, 0x04, 0xd8, 0x55, 0x5d, 0x55, 0x5d, 0x54, + 0xbc, 0x40, 0x25, 0x16, 0x7d, 0x00, 0x16, 0x7d, 0x83, 0x6e, 0xd8, 0x15, 0xb5, 0x9b, 0xae, 0xda, + 0x0a, 0xd4, 0xd2, 0xc7, 0xa8, 0xec, 0xb1, 0x1d, 0x3b, 0x84, 0x24, 0xa0, 0x2e, 0xba, 0x01, 0x7b, + 0xce, 0x77, 0xbe, 0x73, 0xbe, 0x6f, 0xe6, 0x8c, 0x03, 0xfe, 0xb5, 0x08, 0x55, 0x9f, 0x41, 0xa5, + 0x82, 0x9e, 0xd7, 0x90, 0xc6, 0x9e, 0xeb, 0x8b, 0x25, 0x48, 0xd5, 0x45, 0x85, 0xee, 0xca, 0x56, + 0x15, 0x53, 0xcc, 0x0b, 0x0c, 0x24, 0x07, 0x40, 0xb2, 0x0b, 0x12, 0xc6, 0x75, 0xac, 0x63, 0x07, + 0xa6, 0xd8, 0x4f, 0x2c, 0x43, 0x98, 0x2a, 0x63, 0x62, 0x60, 0x52, 0x64, 0x01, 0xf6, 0xe2, 0x86, + 0x44, 0xf6, 0xa6, 0x94, 0x54, 0xd2, 0x28, 0x55, 0xc6, 0xc8, 0x74, 0xe3, 0x93, 0x6e, 0xdc, 0x20, + 0xba, 0x52, 0x5f, 0xb4, 0xff, 0xb9, 0x81, 0xa4, 0x8e, 0xb1, 0x5e, 0x81, 0x8a, 0xf3, 0x56, 0xaa, + 0x3d, 0x55, 0x28, 0x32, 0x20, 0xa1, 0xaa, 0x61, 0xb9, 0x80, 0xb9, 0x36, 0x5a, 0x82, 0xad, 0x33, + 0xf4, 0x98, 0x6a, 0x20, 0x13, 0x2b, 0xce, 0x5f, 0xb6, 0x24, 0x7d, 0xe4, 0xc0, 0x70, 0x9e, 0xe8, + 0x6b, 0x0e, 0x76, 0xc3, 0xc6, 0xf2, 0xab, 0x60, 0x4c, 0x83, 0x15, 0xa8, 0xab, 0x14, 0x57, 0x8b, + 0xaa, 0xa6, 0x55, 0x21, 0x21, 0x09, 0x6e, 0x96, 0x4b, 0xc5, 0x72, 0x89, 0x4f, 0xef, 0xe7, 0xc7, + 0x5d, 0x69, 0x2b, 0x2c, 0xb2, 0x41, 0xab, 0xc8, 0xd4, 0x0b, 0xa3, 0x7e, 0x8a, 0xbb, 0xce, 0x5f, + 0x07, 0xfd, 0xaa, 0x81, 0x6b, 0x26, 0x4d, 0x44, 0x67, 0xb9, 0x54, 0x3c, 0x33, 0x25, 0xbb, 0x89, + 0xb6, 0x0b, 0x9e, 0x97, 0xf2, 0x3d, 0x8c, 0xcc, 0x5c, 0xef, 0xd1, 0xd7, 0x64, 0xa4, 0xe0, 0xc2, + 0xb3, 0xb7, 0x5e, 0x1d, 0x24, 0x23, 0xbf, 0x0e, 0x92, 0x91, 0x97, 0x67, 0x87, 0xe9, 0xf3, 0xad, + 0xbc, 0x3e, 0x3b, 0x4c, 0x0b, 0x41, 0xbd, 0xe1, 0xf6, 0xa5, 0x04, 0x98, 0x08, 0xaf, 0x14, 0x20, + 0xb1, 0xb0, 0x49, 0xa0, 0xf4, 0x23, 0x0a, 0x06, 0xf3, 0x44, 0x77, 0x16, 0x37, 0xf1, 0xda, 0xfa, + 0x9f, 0x52, 0xba, 0x0a, 0xc6, 0xea, 0x6a, 0x05, 0x69, 0x21, 0x9a, 0x68, 0x27, 0x1a, 0x3f, 0xc5, + 0xa3, 0xb9, 0x0f, 0x86, 0x1c, 0x41, 0x5a, 0xd1, 0xf5, 0xad, 0xa7, 0x3b, 0xdf, 0x06, 0x59, 0xd6, + 0x8a, 0x93, 0x64, 0xb3, 0x30, 0x73, 0x3c, 0x96, 0xde, 0x2e, 0x59, 0x58, 0x16, 0x63, 0xc9, 0xde, + 0xec, 0xbc, 0x07, 0x89, 0xa6, 0x3d, 0xf0, 0x6d, 0x95, 0x26, 0xc0, 0x78, 0xf0, 0xdd, 0xf7, 0xff, + 0x33, 0x07, 0x46, 0xfd, 0xad, 0xd9, 0x32, 0xc9, 0x5f, 0x71, 0xda, 0xee, 0x74, 0x56, 0x3a, 0xd3, + 0xf2, 0xb4, 0xb9, 0x02, 0x24, 0x04, 0x12, 0xcd, 0x6b, 0x9e, 0x62, 0x3e, 0x0f, 0x46, 0xca, 0xd8, + 0xb0, 0x2a, 0x90, 0x22, 0x6c, 0x16, 0xed, 0xe1, 0x75, 0xa4, 0xc5, 0x33, 0x82, 0xcc, 0x26, 0x5b, + 0xf6, 0x26, 0x5b, 0xde, 0xf4, 0x26, 0x3b, 0x37, 0x60, 0xf7, 0xb7, 0xff, 0x2d, 0xc9, 0x15, 0x86, + 0x1b, 0xc9, 0x76, 0x58, 0xfa, 0xc0, 0x81, 0x91, 0x3c, 0xd1, 0xb7, 0x2c, 0x4d, 0xa5, 0x70, 0x5d, + 0xad, 0xaa, 0x06, 0xe1, 0x97, 0x41, 0x4c, 0xad, 0xd1, 0x6d, 0x5c, 0x45, 0x74, 0xaf, 0xa3, 0x6f, + 0x0d, 0x28, 0x7f, 0x17, 0xf4, 0x5b, 0x0e, 0x83, 0x6b, 0x98, 0x24, 0x5f, 0x7c, 0xe3, 0xc9, 0xac, + 0x96, 0xe7, 0x1c, 0xcb, 0xcb, 0x2e, 0x07, 0x9d, 0x6b, 0x30, 0xdb, 0x8e, 0x4d, 0x37, 0x39, 0x16, + 0xec, 0x58, 0x9a, 0x02, 0x93, 0x4d, 0x4b, 0xfe, 0x09, 0x79, 0x13, 0x05, 0xa2, 0x1f, 0x7b, 0xb4, + 0x8d, 0x28, 0xac, 0x20, 0x42, 0xa1, 0xf6, 0xd0, 0x9b, 0x95, 0xab, 0xeb, 0x35, 0xc0, 0xc4, 0x4e, + 0x83, 0xb0, 0xe8, 0x4f, 0x9f, 0xad, 0xbf, 0x27, 0x15, 0xcf, 0x2c, 0xb4, 0xd3, 0xdf, 0xaa, 0x15, + 0xd7, 0x8d, 0x7f, 0x76, 0x5a, 0xb5, 0x99, 0x5d, 0xbd, 0xd8, 0x9c, 0x74, 0x4b, 0x73, 0x5a, 0xaa, + 0x95, 0x52, 0xe0, 0xbf, 0xf6, 0x08, 0xdf, 0xba, 0x77, 0x1c, 0xe0, 0xed, 0xa9, 0x83, 0x34, 0x8f, + 0xb5, 0x5a, 0x05, 0xae, 0xab, 0x35, 0x02, 0xb5, 0x2b, 0xdb, 0x35, 0x0d, 0x62, 0x88, 0x14, 0x2d, + 0x87, 0xc4, 0x39, 0x21, 0x03, 0x85, 0x01, 0x44, 0x18, 0x69, 0xf6, 0xc6, 0xc5, 0xe2, 0xc4, 0xe6, + 0x5b, 0x21, 0xdc, 0x8f, 0x34, 0x03, 0x84, 0xf3, 0xab, 0x9e, 0x88, 0xcc, 0xcf, 0x3e, 0xd0, 0x93, + 0x27, 0x3a, 0x6f, 0x80, 0x78, 0xf0, 0x8b, 0x94, 0x6e, 0xb7, 0x37, 0xe1, 0xcb, 0x5e, 0xc8, 0x74, + 0x8f, 0xf5, 0xc7, 0x94, 0x80, 0xa1, 0xf0, 0xa5, 0x34, 0xd7, 0x15, 0x89, 0x8b, 0x16, 0xae, 0x5d, + 0x06, 0xed, 0x17, 0xd5, 0x41, 0xac, 0xf1, 0x25, 0x4a, 0x75, 0xa0, 0xf0, 0x91, 0xc2, 0x42, 0xb7, + 0x48, 0xbf, 0x90, 0x05, 0x06, 0x43, 0x37, 0xc6, 0xff, 0x1d, 0x18, 0x82, 0x60, 0x61, 0xe9, 0x12, + 0x60, 0xbf, 0xe2, 0x5b, 0x0e, 0x4c, 0xb7, 0x9b, 0xe1, 0x6c, 0x57, 0xa4, 0x2d, 0x73, 0x85, 0xdc, + 0xd5, 0x73, 0xfd, 0xfe, 0xf6, 0xc0, 0x48, 0xf3, 0x9c, 0xc8, 0x9d, 0x6c, 0x0d, 0xe3, 0x85, 0xe5, + 0xcb, 0xe1, 0xbd, 0xd2, 0x42, 0xdf, 0x8b, 0xb3, 0xc3, 0x34, 0x97, 0x7b, 0x7c, 0x74, 0x22, 0x72, + 0xc7, 0x27, 0x22, 0xf7, 0xfd, 0x44, 0xe4, 0xf6, 0x4f, 0xc5, 0xc8, 0xf1, 0xa9, 0x18, 0xf9, 0x72, + 0x2a, 0x46, 0x9e, 0xdc, 0xd6, 0x11, 0xdd, 0xae, 0x95, 0xe4, 0x32, 0x36, 0x14, 0x0b, 0x56, 0x89, + 0xad, 0xc1, 0x2c, 0xc3, 0x07, 0x26, 0x54, 0x58, 0xc5, 0x79, 0x53, 0xa5, 0xa8, 0x0e, 0x95, 0x7a, + 0x46, 0xd9, 0x0d, 0xfd, 0xee, 0xa3, 0x7b, 0x16, 0x24, 0xa5, 0x7e, 0xe7, 0x8b, 0xb2, 0xf4, 0x3b, + 0x00, 0x00, 0xff, 0xff, 0x90, 0x3b, 0x26, 0x67, 0xe6, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From c1ac0622bdcd87edd0e1ab28724790487202e994 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Mon, 23 Jun 2025 17:18:41 +0300 Subject: [PATCH 030/112] error handling --- x/liquidstake/keeper/liquidstake.go | 16 +++++++++----- x/liquidstake/keeper/rebalancing.go | 34 ++++++++++++++--------------- x/liquidstake/types/liquidstake.go | 3 +-- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index a957343..be0bdeb 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -43,13 +43,19 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, e } } + balance, err := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) + + if err != nil { + return nil, err + } + nas = &types.NetAmountState{ StkxprtTotalSupply: k.bankKeeper.GetSupply(ctx, k.LiquidBondDenom(ctx)).Amount, TotalDelShares: totalDelShares, TotalLiquidTokens: totalLiquidTokens, TotalRemainingRewards: totalRemainingRewards, TotalUnbondingBalance: totalUnbondingBalance, - ProxyAccBalance: k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc).Amount, + ProxyAccBalance: balance.Amount, } nas.NetAmount = nas.CalcNetAmount() @@ -916,9 +922,10 @@ func (k Keeper) LiquidUnbond( return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrNoDelegatorForAddress } - // If checkMaxEntries is true, perform a maximum limit unbonding entries check. - //TODO: maybe? fix - hasMax, _ := k.stakingKeeper.HasMaxUnbondingDelegationEntries(ctx, liquidStaker, valAddr) + hasMax, error := k.stakingKeeper.HasMaxUnbondingDelegationEntries(ctx, liquidStaker, valAddr) + if error != nil { + return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, error + } if checkMaxEntries && hasMax { return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrMaxUnbondingDelegationEntries @@ -1175,7 +1182,6 @@ func (k Keeper) GetLiquidValidatorState(ctx sdk.Context, addr sdk.ValAddress) (l func (k Keeper) IsActiveLiquidValidator(ctx sdk.Context, lv types.LiquidValidator, whitelistedValsMap types.WhitelistedValsMap) bool { val, err := k.stakingKeeper.GetValidator(ctx, lv.GetOperator()) if err != nil { - //TODO: maybe? fix return false } return types.ActiveCondition(val, whitelistedValsMap.IsListed(lv.OperatorAddress), k.IsTombstoned(ctx, val)) diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go index e01e1ce..b3fa6c2 100644 --- a/x/liquidstake/keeper/rebalancing.go +++ b/x/liquidstake/keeper/rebalancing.go @@ -12,14 +12,13 @@ import ( "github.com/Asphere-xyz/tacchain/x/liquidstake/types" ) -func (k Keeper) GetProxyAccBalance(ctx sdk.Context, proxyAcc sdk.AccAddress) (balance sdk.Coin) { +func (k Keeper) GetProxyAccBalance(ctx sdk.Context, proxyAcc sdk.AccAddress) (balance sdk.Coin, err error) { bondDenom, err := k.stakingKeeper.BondDenom(ctx) if err != nil { - //TODO: fix - panic(-1) + return sdk.Coin{}, err } - return sdk.NewCoin(bondDenom, k.bankKeeper.SpendableCoins(ctx, proxyAcc).AmountOf(bondDenom)) + return sdk.NewCoin(bondDenom, k.bankKeeper.SpendableCoins(ctx, proxyAcc).AmountOf(bondDenom)), nil } // TryRedelegation attempts redelegation, which is applied only when successful through cached context because there is a constraint that fails if already receiving redelegation. @@ -204,21 +203,20 @@ func (k Keeper) UpdateLiquidValidatorSet(ctx sdk.Context, redelegate bool) (rede } // AutocompoundStakingRewards withdraws staking rewards and re-stakes when over threshold. -func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap types.WhitelistedValsMap) { +func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap types.WhitelistedValsMap) error { // withdraw rewards of LiquidStakeProxyAcc k.WithdrawLiquidRewards(ctx, types.LiquidStakeProxyAcc) // skip when no active liquid validator activeVals := k.GetActiveLiquidValidators(ctx, whitelistedValsMap) if len(activeVals) == 0 { - return + return nil } // get all the APY components bondDenom, err := k.stakingKeeper.BondDenom(ctx) if err != nil { - //TODO: fix - panic(-1) + return err } totalSupply := k.bankKeeper.GetSupply(ctx, bondDenom).Amount @@ -226,8 +224,7 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t //inflation := k.mintKeeper.GetMinter(ctx).Inflation minter, err := k.mintKeeper.Minter.Get(ctx) if err != nil { - //TODO: fix - panic(-1) + return err } inflation := minter.Inflation @@ -241,13 +238,15 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t // calculate autocompoundable amount by limiting the current net amount with the calculated APY NetAmountState, err := k.GetNetAmountState(ctx) if err != nil { - //TODO: fix - panic(-1) + return err } autoCompoundableAmount := NetAmountState.NetAmount.Mul(hourlyApy).TruncateInt() // use the calculated autocompoundable amount as the limit for the transfer - proxyAccBalance := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) + proxyAccBalance, err := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) + if err != nil { + return err + } if proxyAccBalance.Amount.IsNegative() { autoCompoundableAmount = math.ZeroInt() } else if proxyAccBalance.Amount.LT(autoCompoundableAmount) { @@ -258,8 +257,7 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t params := k.GetParams(ctx) bondDenom, err = k.stakingKeeper.BondDenom(ctx) if err != nil { - //TODO: fix - panic(-1) + return err } autocompoundFee := sdk.NewCoin(bondDenom, math.ZeroInt()) @@ -280,7 +278,7 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t types.ErrorKeyVal, err, ) - return + return nil // skip errors as they might occur due to reaching global liquid cap } writeCache() @@ -294,7 +292,7 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t types.ErrorKeyVal, err, ) - return + return nil } ctx.EventManager().EmitEvents(sdk.Events{ @@ -309,4 +307,6 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String(), sdk.AttributeKeyAmount, delegableAmount.String(), types.AttributeKeyAutocompoundFee, autocompoundFee.String()) + + return nil } diff --git a/x/liquidstake/types/liquidstake.go b/x/liquidstake/types/liquidstake.go index d2da6ef..1110580 100644 --- a/x/liquidstake/types/liquidstake.go +++ b/x/liquidstake/types/liquidstake.go @@ -60,8 +60,7 @@ func (v LiquidValidator) GetLiquidTokens(ctx sdk.Context, sk StakingKeeper, only } val, err := sk.Validator(ctx, v.GetOperator()) if err != nil { - //TODO: fix - panic(-1) + return math.ZeroInt() } if onlyBonded && !val.IsBonded() { return math.ZeroInt() From 9849dde023d6fda3bd0e8dad07dc2d075e1d58bb Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 24 Jun 2025 18:14:30 +0300 Subject: [PATCH 031/112] draft: added init function for erc20, x/liauidstake modules and change base denom in x/liquidstake --- app/app.go | 24 +++++++++++++++++++++++- x/liquidstake/types/params.go | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 65a7d61..7b3d892 100644 --- a/app/app.go +++ b/app/app.go @@ -13,6 +13,7 @@ import ( _ "github.com/ethereum/go-ethereum/eth/tracers/native" abci "github.com/cometbft/cometbft/abci/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" "github.com/cosmos/ibc-go/modules/capability" @@ -984,6 +985,10 @@ func NewTacChainApp( } } + app.initErc20TokenPair(app.NewUncachedContext(false, cmtproto.Header{})) + + app.initLiquidStakeModule(app.NewUncachedContext(false, cmtproto.Header{})) + return app } @@ -1052,7 +1057,6 @@ func (a *TacChainApp) Configurator() module.Configurator { // InitChainer application update at chain initialization func (app *TacChainApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - app.Erc20Keeper.SetTokenPair(ctx, GTACTokenPair) var genesisState GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -1061,6 +1065,7 @@ func (app *TacChainApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) if err != nil { panic(err) } + response, err := app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) return response, err } @@ -1138,6 +1143,11 @@ func (app *TacChainApp) DefaultGenesis() map[string]json.RawMessage { erc20GenState.Params.EnableErc20 = true genesis[evmerc20types.ModuleName] = app.appCodec.MustMarshalJSON(erc20GenState) + // Liquidstake + lsGenState := liquidstaketypes.DefaultGenesisState() + lsGenState.Params.ModulePaused = false + genesis[liquidstaketypes.ModuleName] = app.appCodec.MustMarshalJSON(lsGenState) + return genesis } @@ -1229,6 +1239,18 @@ func (app *TacChainApp) RegisterNodeService(clientCtx client.Context, cfg config nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } +func (app *TacChainApp) initErc20TokenPair(ctx sdk.Context) { + for _, pair := range TacTokenPairs { + app.Erc20Keeper.SetToken(ctx, pair) + } +} + +func (app *TacChainApp) initLiquidStakeModule(ctx sdk.Context) { + params := app.LiquidstakeKeeper.GetParams(ctx) + params.ModulePaused = false + app.LiquidstakeKeeper.SetParams(ctx, params) +} + // GetMaccPerms returns a copy of the module account permissions // // NOTE: This is solely to be used for testing purposes. diff --git a/x/liquidstake/types/params.go b/x/liquidstake/types/params.go index c061ab0..5f98003 100644 --- a/x/liquidstake/types/params.go +++ b/x/liquidstake/types/params.go @@ -12,7 +12,7 @@ import ( // Parameter store keys var ( - DefaultLiquidBondDenom = "stk/uxprt" + DefaultLiquidBondDenom = "ugtac" // DefaultUnstakeFeeRate is the default Unstake Fee Rate. DefaultUnstakeFeeRate = math.LegacyZeroDec() From 529f9493e962a423485d29e7a5515f56bd1de287 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Wed, 25 Jun 2025 19:00:44 +0300 Subject: [PATCH 032/112] fix docker build --- Dockerfile | 26 ++++++++++++++++---------- docker-compose.yml | 45 +++++++++++++++++++-------------------------- go.mod | 4 ++-- go.sum | 4 ++-- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Dockerfile b/Dockerfile index fac020d..fe1f221 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,27 @@ # docker build . -t tacchaind:latest # docker run --rm -it tacchaind:latest tacchaind --help -FROM golang:1.23.8-alpine3.20 AS go-builder - -# this comes from standard alpine nightly file -# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile -# with some changes to support our toolchain, etc -RUN set -eux; apk add --no-cache ca-certificates build-base libusb-dev linux-headers; +FROM golang:1.23.8-bullseye AS go-builder + +# Install build dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates \ + build-essential \ + git \ + curl \ + wget \ + libusb-1.0-0-dev \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* WORKDIR /code COPY . /code/ -RUN LEDGER_ENABLED=true make build - +# force it to use static lib (from above) not standard libgo_cosmwasm.so file +RUN make build +RUN LEDGER_ENABLED=false make build -# -------------------------------------------------------- -FROM alpine:3.18 +FROM ubuntu:22.04 COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind diff --git a/docker-compose.yml b/docker-compose.yml index 09c5b55..60dafe1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,43 +1,36 @@ services: tac-spb-testnet-init: - user: "${USER_ID}:${GROUP_ID}" - image: ${IMAGE} + user: "1000:1000" + build: + dockerfile: Dockerfile volumes: - - "/mnt/data:/data" - entrypoint: /bin/sh - command: > - -c "[ ! -e /data/config/config.toml ] && tacchaind init testnode --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" + - "./tacchain:/data" + entrypoint: sh + command: /scripts/init.sh + environment: + - MONIKER=tac-validator + - HOMEDIR=/data/ tac-spb-testnet-validator-1: - user: "${USER_ID}:${GROUP_ID}" + user: "1000:1000" network_mode: host restart: unless-stopped - image: ${IMAGE} + build: + dockerfile: Dockerfile ports: - "26656:26656" # P2P - "26657:26657" # RPC - "1317:1317" # REST - "8545:8545" # RPC_EVM - "8546:8546" # WS_EVM - - "9090:9090" # GRPC + - "9090:9090" # gRPC volumes: - - "/mnt/data:/data" + - "./tacchain:/data" depends_on: tac-spb-testnet-init: condition: service_completed_successfully - entrypoint: tacchaind - command: > - start - --chain-id=tacchain_2391-1 - --home=/data - --db_dir=data - --log_level=info - --p2p.persistent_peers=${P2P_PERSISTENT_PEERS} - --p2p.laddr=tcp://0.0.0.0:${P2P_PORT} - --p2p.external-address=${EXT_IP}:${P2P_PORT} - --rpc.laddr=tcp://0.0.0.0:${RPC_PORT} - --json-rpc.address=0.0.0.0:${RPC_PORT_EVM} - --json-rpc.ws-address=0.0.0.0:${WS_PORT_EVM} - --grpc.enable - --grpc-web.enable - --rpc.grpc_laddr=tcp://0.0.0.0:${GRPC_PORT} \ No newline at end of file + entrypoint: sh + command: /scripts/start.sh + environment: + - MONIKER=tac-validator + - HOMEDIR=/data/ diff --git a/go.mod b/go.mod index a462621..d2fbd98 100644 --- a/go.mod +++ b/go.mod @@ -184,7 +184,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect; indirect; github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect @@ -277,7 +277,7 @@ replace ( // // use Cosmos-SDK fork to enable Ledger functionality // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - github.com/cosmos/cosmos-sdk => gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd + github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd // replace cosmos evm with our fork that uses geth v1.13.15 github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index e551fff..55beb64 100644 --- a/go.sum +++ b/go.sum @@ -1006,6 +1006,8 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:wdNwCUHsrId91KHpGSJT4MPxPLYv014IuJimc2BlvQo= +github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1186,8 +1188,6 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= -gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:u2/mX9cm100Rffheni7PO4OCfjUKMr8imlrO/xPKzG0= -gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.4.0-alpha.1 h1:3yrqQzbRRPFPdOMWS/QQIVxVnzSkAZQYeWlZFv1kbj4= go.etcd.io/bbolt v1.4.0-alpha.1/go.mod h1:S/Z/Nm3iuOnyO1W4XuFfPci51Gj6F1Hv0z8hisyYYOw= From 42d5b8f6cf93d1772faa7f4b09bc26855443d788 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 26 Jun 2025 12:54:39 +0300 Subject: [PATCH 033/112] chore: remove needless log and updated Cosmos SDK module location in go.mod --- app/app_test.go | 2 -- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/app_test.go b/app/app_test.go index 99be041..81dec08 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -28,8 +28,6 @@ func TestExportAndBlockedAddrs(t *testing.T) { AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), }) - fmt.Print("AAAAAAAAAAAAAAa") - // BlockedAddresses returns a map of addresses in app v1 and a map of modules name in app v2. for acc := range BlockedAddresses() { var addr sdk.AccAddress diff --git a/go.mod b/go.mod index a462621..08dac5f 100644 --- a/go.mod +++ b/go.mod @@ -277,7 +277,7 @@ replace ( // // use Cosmos-SDK fork to enable Ledger functionality // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - github.com/cosmos/cosmos-sdk => gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd + github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd // replace cosmos evm with our fork that uses geth v1.13.15 github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index e551fff..55beb64 100644 --- a/go.sum +++ b/go.sum @@ -1006,6 +1006,8 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:wdNwCUHsrId91KHpGSJT4MPxPLYv014IuJimc2BlvQo= +github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1186,8 +1188,6 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= -gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:u2/mX9cm100Rffheni7PO4OCfjUKMr8imlrO/xPKzG0= -gitlab.pixelplexlabs.com/862-tac/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.4.0-alpha.1 h1:3yrqQzbRRPFPdOMWS/QQIVxVnzSkAZQYeWlZFv1kbj4= go.etcd.io/bbolt v1.4.0-alpha.1/go.mod h1:S/Z/Nm3iuOnyO1W4XuFfPci51Gj6F1Hv0z8hisyYYOw= From e1e375e01236b901f3f1e67f8e971085707817f1 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 12:06:34 +0200 Subject: [PATCH 034/112] [TAC-46]: deploy localnode --- Dockerfile | 14 +++++++++++++- docker-compose.yml | 16 +++++++--------- settings-ci.yml | 4 ++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index fe1f221..1eead6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,20 @@ RUN LEDGER_ENABLED=false make build FROM ubuntu:22.04 COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind +# To run a localnet -------------------------------------- +COPY --from=go-builder /code/contrib/localnet/init.sh /scripts/init.sh +COPY --from=go-builder /code/contrib/localnet/start.sh /scripts/start.sh +RUN chmod +x /scripts/*.sh -WORKDIR /opt +RUN apt-get update && apt-get install -y \ + wget \ + jq \ + bc \ + && rm -rf /var/lib/apt/lists/* + +RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.1.0/libwasmvm.x86_64.so + +WORKDIR /scripts # rest server EXPOSE 1317 diff --git a/docker-compose.yml b/docker-compose.yml index 60dafe1..81d38d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,16 @@ services: - tac-spb-testnet-init: - user: "1000:1000" + tac-localnet-init: build: dockerfile: Dockerfile volumes: - - "./tacchain:/data" + - "/mnt/data:/tacchain_data" entrypoint: sh command: /scripts/init.sh environment: - MONIKER=tac-validator - - HOMEDIR=/data/ + - HOMEDIR=/tacchain_data - tac-spb-testnet-validator-1: - user: "1000:1000" + tac-localnet-validator: network_mode: host restart: unless-stopped build: @@ -25,12 +23,12 @@ services: - "8546:8546" # WS_EVM - "9090:9090" # gRPC volumes: - - "./tacchain:/data" + - "/mnt/data:/tacchain_data" depends_on: - tac-spb-testnet-init: + tac-localnet-init: condition: service_completed_successfully entrypoint: sh command: /scripts/start.sh environment: - MONIKER=tac-validator - - HOMEDIR=/data/ + - HOMEDIR=/tacchain_data \ No newline at end of file diff --git a/settings-ci.yml b/settings-ci.yml index 5a3a791..d7bb6e9 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -4,10 +4,10 @@ trufflehog_ignore: true deploy: environment: tacchain: - branch: main + branch: localchain docker_compose: true runner_tags: - - taccnetwork-dev + - tac-localchain-1 apps: tac: From 6a97f07de9b5cdcf0e27de0743773f8261d00621 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 10:08:09 +0000 Subject: [PATCH 035/112] fix(HOTFIX): change deployed branch --- settings-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-ci.yml b/settings-ci.yml index d7bb6e9..fe42358 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -4,7 +4,7 @@ trufflehog_ignore: true deploy: environment: tacchain: - branch: localchain + branch: localnet docker_compose: true runner_tags: - tac-localchain-1 From 05d805f386e1743f7fb70ec0b9c553c7dbf484b8 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 10:14:11 +0000 Subject: [PATCH 036/112] feat(UPDATE): change built image --- settings-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-ci.yml b/settings-ci.yml index fe42358..5aaf903 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -11,7 +11,7 @@ deploy: apps: tac: - image: golang:1.23.8-alpine3.20 + image: golang:1.23.8-bullseye runner_tags: - docker code_analysis: false From a42cc841853c32c845267cbf89d0ca948905d5cb Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 12:53:38 +0200 Subject: [PATCH 037/112] feat(UPDATE): add libc6 --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 1eead6f..e4248ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \ curl \ wget \ libusb-1.0-0-dev \ + libc6 \ pkg-config \ && rm -rf /var/lib/apt/lists/* From af81de9e7603ff922b2a47ce9846f346352b4991 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 13:18:22 +0200 Subject: [PATCH 038/112] feat(UPDATE): change runner tag --- Dockerfile | 2 +- settings-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4248ff..d37e76d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # docker build . -t tacchaind:latest # docker run --rm -it tacchaind:latest tacchaind --help -FROM golang:1.23.8-bullseye AS go-builder +FROM golang:1.23.8-bookworm AS go-builder # Install build dependencies RUN apt-get update && apt-get install -y \ diff --git a/settings-ci.yml b/settings-ci.yml index 5aaf903..136ff68 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -18,5 +18,5 @@ apps: build: false docker_build: runner_tags: - - docker + - tac-localchain-1 test_docker: false From 70daa6e9a92d3a31853c2aa936009b5e722c410c Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 13:19:44 +0200 Subject: [PATCH 039/112] feat(UPDATE): unchange runner tag --- settings-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-ci.yml b/settings-ci.yml index 136ff68..5aaf903 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -18,5 +18,5 @@ apps: build: false docker_build: runner_tags: - - tac-localchain-1 + - docker test_docker: false From 4b27ec5adce5db8506922c17e5b7be1e5081ed93 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 13:28:27 +0200 Subject: [PATCH 040/112] feat(UPDATE): add image --- docker-compose.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 81d38d2..cbe051a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ services: tac-localnet-init: - build: - dockerfile: Dockerfile + image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" entrypoint: sh @@ -13,8 +12,7 @@ services: tac-localnet-validator: network_mode: host restart: unless-stopped - build: - dockerfile: Dockerfile + image: ${IMAGE} ports: - "26656:26656" # P2P - "26657:26657" # RPC From f40dc0d9157cd35c93c67bd5c7aacfea56abaed7 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 14:18:24 +0200 Subject: [PATCH 041/112] feat(UPDATE): expose necessary ports --- contrib/localnet/start.sh | 2 +- docker-compose.yml | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index 342a593..b94f9a3 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -4,4 +4,4 @@ CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} TACCHAIND=${TACCHAIND:-$(which tacchaind)} HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} -$TACCHAIND start --chain-id $CHAIN_ID --home $HOMEDIR +$TACCHAIND start --chain-id $CHAIN_ID --home $HOMEDIR --p2p.laddr $P2P_LADDR --p2p.external-address $P2P_EXTERNAL_ADDRESS --rpc.laddr $RPC_LADDR --json-rpc.address $JSON_RPC_ADDR --json-rpc.ws-address $JSON_RPC_WS_ADDR --json-rpc.enable diff --git a/docker-compose.yml b/docker-compose.yml index cbe051a..5cc325e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ services: tac-localnet-init: - image: ${IMAGE} + build: + dockerfile: Dockerfile volumes: - "/mnt/data:/tacchain_data" entrypoint: sh @@ -12,7 +13,8 @@ services: tac-localnet-validator: network_mode: host restart: unless-stopped - image: ${IMAGE} + build: + dockerfile: Dockerfile ports: - "26656:26656" # P2P - "26657:26657" # RPC @@ -29,4 +31,9 @@ services: command: /scripts/start.sh environment: - MONIKER=tac-validator - - HOMEDIR=/tacchain_data \ No newline at end of file + - HOMEDIR=/tacchain_data + - P2P_LADDR=tcp://0.0.0.0:26656 + - P2P_EXTERNAL_ADDRESS=0.0.0.0:26656 + - RPC_LADDR=tcp://0.0.0.0:26657 + - JSON_RPC_ADDR=0.0.0.0:8545 + - JSON_RPC_WS_ADDR=0.0.0.0:8546 \ No newline at end of file From 5ee09711d84578e083328e3e1819eed856bf74c2 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Thu, 26 Jun 2025 14:36:21 +0200 Subject: [PATCH 042/112] feat(UPDATE): expose necessary ports#! --- docker-compose.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5cc325e..c1013f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ services: tac-localnet-init: - build: - dockerfile: Dockerfile + image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" entrypoint: sh @@ -13,8 +12,7 @@ services: tac-localnet-validator: network_mode: host restart: unless-stopped - build: - dockerfile: Dockerfile + image: ${IMAGE} ports: - "26656:26656" # P2P - "26657:26657" # RPC From 0af94b5dcb85df57efa283f6ab3a305607f07acc Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 26 Jun 2025 17:07:52 +0300 Subject: [PATCH 043/112] draft: added tests --- app/app.go | 10 +- app/test_helpers.go | 153 ++++++++ x/liquidstake/keeper/genesis_test.go | 68 ++++ x/liquidstake/keeper/keeper_test.go | 477 ++++++++++++++++++++++++ x/liquidstake/types/expected_keepers.go | 99 +---- 5 files changed, 714 insertions(+), 93 deletions(-) create mode 100644 x/liquidstake/keeper/genesis_test.go create mode 100644 x/liquidstake/keeper/keeper_test.go diff --git a/app/app.go b/app/app.go index 7b3d892..b44fe19 100644 --- a/app/app.go +++ b/app/app.go @@ -242,7 +242,7 @@ type TacChainApp struct { configurator module.Configurator // liquidstake keeper - LiquidstakeKeeper liquidstakekeeper.Keeper + LiquidStakeKeeper liquidstakekeeper.Keeper // Cosmos EVM keepers FeeMarketKeeper evmfeemarketkeeper.Keeper @@ -559,7 +559,7 @@ func NewTacChainApp( app.EvidenceKeeper = *evidenceKeeper // liquidstake keeper - app.LiquidstakeKeeper = liquidstakekeeper.NewKeeper( + app.LiquidStakeKeeper = liquidstakekeeper.NewKeeper( encodingConfig.Codec, keys[liquidstaketypes.StoreKey], app.AccountKeeper, @@ -747,7 +747,7 @@ func NewTacChainApp( ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), ibctm.AppModule{}, // liquidstake module - liquidstake.NewAppModule(app.LiquidstakeKeeper), + liquidstake.NewAppModule(app.LiquidStakeKeeper), // sdk crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them // Cosmos EVM modules @@ -1246,9 +1246,9 @@ func (app *TacChainApp) initErc20TokenPair(ctx sdk.Context) { } func (app *TacChainApp) initLiquidStakeModule(ctx sdk.Context) { - params := app.LiquidstakeKeeper.GetParams(ctx) + params := app.LiquidStakeKeeper.GetParams(ctx) params.ModulePaused = false - app.LiquidstakeKeeper.SetParams(ctx, params) + app.LiquidStakeKeeper.SetParams(ctx, params) } // GetMaccPerms returns a copy of the module account permissions diff --git a/app/test_helpers.go b/app/test_helpers.go index 0818994..1f9262c 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -1,18 +1,30 @@ package app import ( + "bytes" + "fmt" + "strconv" "testing" + "time" + "encoding/hex" + + errorsmod "cosmossdk.io/errors" abci "github.com/cometbft/cometbft/abci/types" cmtjson "github.com/cometbft/cometbft/libs/json" cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" "cosmossdk.io/log" + "cosmossdk.io/math" sdkmath "cosmossdk.io/math" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" bam "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/testutil/mock" @@ -79,3 +91,144 @@ func NewTacChainAppWithCustomOptions(t *testing.T, isCheckTx bool, invCheckPerio return app } + +// AddTestAddrs constructs and returns accNum amount of accounts with an +// initial balance of accAmt in random order +func AddTestAddrs(app *TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { + return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts) +} + +func addTestAddrs(app *TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { + testAddrs := strategy(accNum) + + initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, accAmt)) + + for _, addr := range testAddrs { + InitAccountWithCoins(app, ctx, addr, initCoins) + } + + return testAddrs +} + +// createRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order. +func createRandomAccounts(accNum int) []sdk.AccAddress { + testAddrs := make([]sdk.AccAddress, accNum) + for i := 0; i < accNum; i++ { + pk := ed25519.GenPrivKey().PubKey() + testAddrs[i] = sdk.AccAddress(pk.Address()) + } + + return testAddrs +} + +func InitAccountWithCoins(app *TacChainApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { + err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) + if err != nil { + panic(err) + } + + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) + if err != nil { + panic(err) + } +} + +type GenerateAccountStrategy func(int) []sdk.AccAddress + +// ConvertAddrsToValAddrs converts the provided addresses to ValAddress. +func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { + valAddrs := make([]sdk.ValAddress, len(addrs)) + + for i, addr := range addrs { + valAddrs[i] = sdk.ValAddress(addr) + } + + return valAddrs +} + +// ParseTime parses and returns time.Time in time.RFC3339 format. +func ParseTime(s string) time.Time { + t, err := time.Parse(time.RFC3339, s) + if err != nil { + panic(err) + } + return t +} + +// AddTestAddrs constructs and returns accNum amount of accounts with an +// initial balance of accAmt in random order +func AddTestAddrsIncremental(app *TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { + return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) +} + +// createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order. +func createIncrementalAccounts(accNum int) []sdk.AccAddress { + var addresses []sdk.AccAddress + var buffer bytes.Buffer + + // start at 100 so we can make up to 999 test addresses with valid test addresses + for i := 100; i < (accNum + 100); i++ { + numString := strconv.Itoa(i) + buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string + + buffer.WriteString(numString) // adding on final two digits to make addresses unique + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) + bech := res.String() + addr, _ := TestAddr(buffer.String(), bech) + + addresses = append(addresses, addr) + buffer.Reset() + } + + return addresses +} + +func TestAddr(addr, bech string) (sdk.AccAddress, error) { + res, err := sdk.AccAddressFromHexUnsafe(addr) + if err != nil { + return nil, err + } + bechexpected := res.String() + if bech != bechexpected { + return nil, fmt.Errorf("bech encoding doesn't match reference") + } + + bechres, err := sdk.AccAddressFromBech32(bech) + if err != nil { + return nil, err + } + if !bytes.Equal(bechres, res) { + return nil, err + } + + return res, nil +} + +// CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. +func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { + var publicKeys []cryptotypes.PubKey + var buffer bytes.Buffer + + // start at 10 to avoid changing 1 to 01, 2 to 02, etc + for i := 100; i < (numPubKeys + 100); i++ { + numString := strconv.Itoa(i) + buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string + buffer.WriteString(numString) // adding on final two digits to make pubkeys unique + publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String())) + buffer.Reset() + } + + return publicKeys +} + +// NewPubKeyFromHex returns a PubKey from a hex string. +func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { + pkBytes, err := hex.DecodeString(pk) + if err != nil { + panic(err) + } + if len(pkBytes) != ed25519.PubKeySize { + panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) + } + return &ed25519.PubKey{Key: pkBytes} +} diff --git a/x/liquidstake/keeper/genesis_test.go b/x/liquidstake/keeper/genesis_test.go new file mode 100644 index 0000000..54ea26e --- /dev/null +++ b/x/liquidstake/keeper/genesis_test.go @@ -0,0 +1,68 @@ +package keeper_test + +import ( + _ "github.com/stretchr/testify/suite" + + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +func (s *KeeperTestSuite) TestInitGenesis() { + genState := *types.DefaultGenesisState() + s.keeper.InitGenesis(s.ctx, genState) + got := s.keeper.ExportGenesis(s.ctx) + s.Require().Equal(genState, *got) +} + +// func (s *KeeperTestSuite) TestImportExportGenesis() { +// k, ctx := s.keeper, s.ctx +// _, valOpers, _ := s.CreateValidators([]int64{1000000, 1000000, 1000000}) +// params := k.GetParams(ctx) +// +// params.WhitelistedValidators = []types.WhitelistedValidator{ +// {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(5000)}, +// {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(5000)}, +// } +// params.ModulePaused = false +// k.SetParams(ctx, params) +// k.UpdateLiquidValidatorSet(ctx, true) +// +// stakingAmt := math.NewInt(100000000) +// s.Require().NoError(s.liquidStaking(s.delAddrs[0], stakingAmt)) +// lvs := k.GetAllLiquidValidators(ctx) +// s.Require().Len(lvs, 2) +// +// lvStates := k.GetAllLiquidValidatorStates(ctx) +// genState := k.ExportGenesis(ctx) +// +// bz := s.app.AppCodec().MustMarshalJSON(genState) +// +// var genState2 types.GenesisState +// s.app.AppCodec().MustUnmarshalJSON(bz, &genState2) +// k.InitGenesis(ctx, genState2) +// genState3 := k.ExportGenesis(ctx) +// +// s.Require().Equal(*genState, genState2) +// s.Require().Equal(genState2, *genState3) +// +// lvs = k.GetAllLiquidValidators(ctx) +// s.Require().Len(lvs, 2) +// +// lvStates3 := k.GetAllLiquidValidatorStates(ctx) +// s.Require().EqualValues(lvStates, lvStates3) +// } + +func (s *KeeperTestSuite) TestImportExportGenesisEmpty() { + k, ctx := s.keeper, s.ctx + k.SetParams(ctx, types.DefaultParams()) + k.UpdateLiquidValidatorSet(ctx, true) + genState := k.ExportGenesis(ctx) + + var genState2 types.GenesisState + bz := s.app.AppCodec().MustMarshalJSON(genState) + s.app.AppCodec().MustUnmarshalJSON(bz, &genState2) + k.InitGenesis(ctx, genState2) + + genState3 := k.ExportGenesis(ctx) + s.Require().Equal(*genState, genState2) + s.Require().Equal(genState2, *genState3) +} diff --git a/x/liquidstake/keeper/keeper_test.go b/x/liquidstake/keeper/keeper_test.go new file mode 100644 index 0000000..f2e35a0 --- /dev/null +++ b/x/liquidstake/keeper/keeper_test.go @@ -0,0 +1,477 @@ +package keeper_test + +import ( + "fmt" + "testing" + "time" + + "cosmossdk.io/log" + "cosmossdk.io/math" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/crisis" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/mint" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/suite" + + chain "github.com/Asphere-xyz/tacchain/app" + "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" + dbm "github.com/cosmos/cosmos-db" +) + +var BlockTime = 6 * time.Second + +type KeeperTestSuite struct { + suite.Suite + + app *chain.TacChainApp + ctx sdk.Context + keeper keeper.Keeper + querier keeper.Querier + addrs []sdk.AccAddress + delAddrs []sdk.AccAddress + valAddrs []sdk.ValAddress +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (s *KeeperTestSuite) SetupTest() { + db := dbm.NewMemDB() + logger := log.NewTestLogger(s.T()) + app := chain.NewTacChainAppWithCustomOptions(s.T(), false, 0, chain.SetupOptions{ + Logger: logger.With("instance", "first"), + DB: db, + AppOpts: simtestutil.NewAppOptionsWithFlagHome(s.T().TempDir()), + }) + s.app = app + s.ctx = s.app.BaseApp.NewContext(false) + stakingParams := stakingtypes.DefaultParams() + stakingParams.MaxEntries = 7 + stakingParams.MaxValidators = 30 + s.Require().NoError(s.app.StakingKeeper.SetParams(s.ctx, stakingParams)) + + s.keeper = s.app.LiquidStakeKeeper + s.querier = keeper.Querier{Keeper: s.keeper} + s.addrs = chain.AddTestAddrs(s.app, s.ctx, 10, math.NewInt(1_000_000_000)) + s.delAddrs = chain.AddTestAddrs(s.app, s.ctx, 10, math.NewInt(1_000_000_000)) + s.valAddrs = chain.ConvertAddrsToValAddrs(s.delAddrs) + + s.ctx = s.ctx.WithBlockHeight(100).WithBlockTime(chain.ParseTime("2022-03-01T00:00:00Z")) + params := s.keeper.GetParams(s.ctx) + params.UnstakeFeeRate = sdk.ZeroDec() + params.AutocompoundFeeRate = types.DefaultAutocompoundFeeRate + s.Require().NoError(s.keeper.SetParams(s.ctx, params)) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + // call mint.BeginBlocker for init k.SetLastBlockTime(ctx, ctx.BlockTime()) + mint.BeginBlocker(s.ctx, s.app.MintKeeper, minttypes.DefaultInflationCalculationFn) +} + +func (s *KeeperTestSuite) TearDownTest() { + // invariant check + crisis.EndBlocker(s.ctx, *s.app.CrisisKeeper) +} + +// TODO: Upgrade Cosmos SDK +// func (s *KeeperTestSuite) CreateValidators(powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []cryptotypes.PubKey) { +// s.app.BeginBlocker(s.ctx) +// num := len(powers) +// addrs := chain.AddTestAddrsIncremental(s.app, s.ctx, num, math.NewInt(10000000000000)) +// valAddrs := chain.ConvertAddrsToValAddrs(addrs) +// pks := chain.CreateTestPubKeys(num) +// skParams, _ := s.app.StakingKeeper.GetParams(s.ctx) +// skParams.ValidatorLiquidStakingCap = sdk.OneDec() +// _ = s.app.StakingKeeper.SetParams(s.ctx, skParams) +// for i, power := range powers { +// val, err := stakingtypes.NewValidator(valAddrs[i].String(), pks[i], stakingtypes.Description{}) +// s.Require().NoError(err) +// s.app.StakingKeeper.SetValidator(s.ctx, val) +// err = s.app.StakingKeeper.SetValidatorByConsAddr(s.ctx, val) +// s.Require().NoError(err) +// s.app.StakingKeeper.SetNewValidatorByPowerIndex(s.ctx, val) +// _ = s.app.StakingKeeper.Hooks().AfterValidatorCreated(s.ctx, sdk.ValAddress(val.GetOperator())) +// newShares, err := s.app.StakingKeeper.Delegate(s.ctx, addrs[i], math.NewInt(power), stakingtypes.Unbonded, val, true) +// s.Require().NoError(err) +// s.Require().Equal(newShares.TruncateInt(), math.NewInt(power)) +// msgValidatorBond := &stakingtypes.MsgValidatorBond{ +// DelegatorAddress: addrs[i].String(), +// ValidatorAddress: val.OperatorAddress, +// } +// handler := s.app.MsgServiceRouter().Handler(msgValidatorBond) +// _, err = handler(s.ctx, msgValidatorBond) +// s.Require().NoError(err) +// } +// +// s.app.EndBlocker(s.ctx) +// return addrs, valAddrs, pks +// } + +func (s *KeeperTestSuite) liquidStaking(liquidStaker sdk.AccAddress, stakingAmt math.Int) error { + ctx, writeCache := s.ctx.CacheContext() + params := s.keeper.GetParams(ctx) + + stkxprtBalanceBefore := s.app.BankKeeper.GetBalance( + ctx, liquidStaker, params.LiquidBondDenom, + ).Amount + + stkXPRTMintAmt, err := s.keeper.LiquidStake( + ctx, + types.LiquidStakeProxyAcc, + liquidStaker, + sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), + ) + if err != nil { + return err + } + + stkxprtBalanceAfter := s.app.BankKeeper.GetBalance( + ctx, liquidStaker, params.LiquidBondDenom, + ).Amount + + s.Require().NoError(err) + s.Require().EqualValues( + stkXPRTMintAmt, stkxprtBalanceAfter.Sub(stkxprtBalanceBefore), + ) + writeCache() + + return nil +} + +func (s *KeeperTestSuite) liquidUnstaking( + liquidStaker sdk.AccAddress, + ubdStkXPRTAmt math.Int, + ubdComplete bool, +) error { + ctx := s.ctx + params := s.keeper.GetParams(ctx) + + balanceBefore := s.app.BankKeeper.GetBalance( + ctx, + liquidStaker, + sdk.DefaultBondDenom, + ).Amount + + ubdTime, unbondingAmt, _, unbondedAmt, err := s.liquidUnstakingWithResult( + liquidStaker, + sdk.NewCoin(params.LiquidBondDenom, ubdStkXPRTAmt), + ) + if err != nil { + return err + } + + if ubdComplete { + alv := s.keeper.GetActiveLiquidValidators(ctx, params.WhitelistedValsMap()) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 200). + WithBlockTime(ubdTime.Add(1)) + + // EndBlock of staking keeper, mature UBD + s.app.StakingKeeper.BlockValidatorUpdates(ctx) + + balanceCompleteUBD := s.app.BankKeeper.GetBalance( + ctx, + liquidStaker, + sdk.DefaultBondDenom, + ) + for _, v := range alv { + _, err := s.app.StakingKeeper.GetUnbondingDelegation( + ctx, + liquidStaker, + v.GetOperator(), + ) + s.Require().Error(err) + } + + s.Require().EqualValues( + balanceCompleteUBD.Amount, + balanceBefore.Add(unbondingAmt).Add(unbondedAmt), + ) + } + + return nil +} + +func (s *KeeperTestSuite) liquidUnstakingWithResult( + liquidStaker sdk.AccAddress, unstakingStkXPRT sdk.Coin, +) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) { + ctx, writeCache := s.ctx.CacheContext() + params := s.keeper.GetParams(ctx) + alv := s.keeper.GetActiveLiquidValidators(ctx, params.WhitelistedValsMap()) + + balanceBefore := s.app.BankKeeper.GetBalance( + ctx, liquidStaker, sdk.DefaultBondDenom, + ).Amount + stkxprtBalanceBefore := s.app.BankKeeper.GetBalance( + ctx, liquidStaker, params.LiquidBondDenom, + ).Amount + + ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.keeper.LiquidUnstake( + ctx, types.LiquidStakeProxyAcc, liquidStaker, unstakingStkXPRT, + ) + if err != nil { + return ubdTime, unbondingAmt, ubds, unbondedAmt, err + } + + balanceAfter := s.app.BankKeeper.GetBalance( + ctx, liquidStaker, sdk.DefaultBondDenom, + ).Amount + stkxprtBalanceAfter := s.app.BankKeeper.GetBalance( + ctx, liquidStaker, params.LiquidBondDenom, + ).Amount + s.Require().EqualValues( + unstakingStkXPRT.Amount, stkxprtBalanceBefore.Sub(stkxprtBalanceAfter), + ) + + if unbondedAmt.IsPositive() { + s.Require().EqualValues( + unbondedAmt, balanceAfter.Sub(balanceBefore), + ) + } + + for _, v := range alv { + _, err := s.app.StakingKeeper.GetUnbondingDelegation( + ctx, liquidStaker, v.GetOperator(), + ) + s.Require().NoError(err) + } + + writeCache() + return ubdTime, unbondingAmt, ubds, unbondedAmt, err +} + +func (s *KeeperTestSuite) RequireNetAmountStateZero() { + nas, err := s.keeper.GetNetAmountState(s.ctx) + s.Require().NoError(err) + s.Require().EqualValues(nas.MintRate, sdk.ZeroDec()) + s.Require().EqualValues(nas.StkxprtTotalSupply, sdk.ZeroInt()) + s.Require().EqualValues(nas.NetAmount, sdk.ZeroDec()) + s.Require().EqualValues(nas.TotalDelShares, sdk.ZeroDec()) + s.Require().EqualValues(nas.TotalLiquidTokens, sdk.ZeroInt()) + s.Require().EqualValues(nas.TotalRemainingRewards, sdk.ZeroDec()) + s.Require().EqualValues(nas.TotalUnbondingBalance, sdk.ZeroDec()) + s.Require().EqualValues(nas.ProxyAccBalance, sdk.ZeroInt()) +} + +// advance block time and height for complete redelegations and unbondings +func (s *KeeperTestSuite) completeRedelegationUnbonding() { + s.ctx = s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 100). + WithBlockTime(s.ctx.BlockTime().Add(stakingtypes.DefaultUnbondingTime)) + s.app.EndBlocker(s.ctx) + reds, err := s.app.StakingKeeper.GetRedelegations(s.ctx, types.LiquidStakeProxyAcc, 100) + s.Require().NoError(err) + s.Require().Len(reds, 0) + ubds, err := s.app.StakingKeeper.GetUnbondingDelegations(s.ctx, types.LiquidStakeProxyAcc, 100) + s.Require().NoError(err) + s.Require().Len(ubds, 0) +} + +func (s *KeeperTestSuite) redelegationsErrorCount(redelegations []types.Redelegation) int { + errCnt := 0 + for _, red := range redelegations { + if red.Error != nil { + errCnt++ + } + } + return errCnt +} + +func (s *KeeperTestSuite) printRedelegationsLiquidTokens() { + redsIng, err := s.app.StakingKeeper.GetRedelegations(s.ctx, types.LiquidStakeProxyAcc, 50) + s.Require().NoError(err) + if len(redsIng) != 0 { + fmt.Println("[Redelegations]") + for i, red := range redsIng { + fmt.Println("\tRedelegation #", i+1) + fmt.Println("\t\tDelegatorAddress: ", red.DelegatorAddress) + fmt.Println("\t\tValidatorSrcAddress : ", red.ValidatorSrcAddress) + fmt.Println("\t\tValidatorDstAddress: ", red.ValidatorDstAddress) + fmt.Println("\t\tEntries: ") + for _, e := range red.Entries { + fmt.Println("\t\t\tCreationHeight: ", e.CreationHeight) + fmt.Println("\t\t\tCompletionTime: ", e.CompletionTime) + fmt.Println("\t\t\tInitialBalance: ", e.InitialBalance) + fmt.Println("\t\t\tSharesDst: ", e.SharesDst) + } + } + fmt.Println("") + } + liquidVals := s.keeper.GetAllLiquidValidators(s.ctx) + if len(liquidVals) != 0 { + fmt.Println("[LiquidValidators]") + for _, v := range s.keeper.GetAllLiquidValidators(s.ctx) { + fmt.Printf(" OperatorAddress %s; LiquidTokens: %s\n", + v.OperatorAddress, v.GetLiquidTokens(s.ctx, *s.app.StakingKeeper, false)) + } + } +} + +func (s *KeeperTestSuite) advanceHeight(height int, _ bool) { + feeCollector := s.app.AccountKeeper.GetModuleAddress( + authtypes.FeeCollectorName, + ) + + for i := 0; i < height; i++ { + s.ctx = s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1). + WithBlockTime(s.ctx.BlockTime().Add(BlockTime)) + + mint.BeginBlocker(s.ctx, s.app.MintKeeper, minttypes.DefaultInflationCalculationFn) + feeCollectorBalance := s.app.BankKeeper.GetAllBalances( + s.ctx, feeCollector, + ) + rewardsToBeDistributed := feeCollectorBalance.AmountOf( + sdk.DefaultBondDenom, + ) + + // mimic distribution.BeginBlock (AllocateTokens, get rewards from + // feeCollector, AllocateTokensToValidator, add remaining to feePool) + err := s.app.BankKeeper.SendCoinsFromModuleToModule( + s.ctx, authtypes.FeeCollectorName, distrtypes.ModuleName, + feeCollectorBalance, + ) + + s.Require().NoError(err) + totalRewards := sdk.ZeroDec() + totalPower := int64(0) + s.app.StakingKeeper.IterateBondedValidatorsByPower( + s.ctx, + func(index int64, validator stakingtypes.ValidatorI) (stop bool) { + consPower := validator.GetConsensusPower( + s.app.StakingKeeper.PowerReduction(s.ctx), + ) + totalPower = totalPower + consPower + return false + }, + ) + + if totalPower != 0 { + s.app.StakingKeeper.IterateBondedValidatorsByPower( + s.ctx, + func(index int64, validator stakingtypes.ValidatorI) (stop bool) { + consPower := validator.GetConsensusPower( + s.app.StakingKeeper.PowerReduction(s.ctx), + ) + powerFraction := math.LegacyNewDec(consPower).QuoTruncate( + math.LegacyNewDec(totalPower), + ) + reward := rewardsToBeDistributed.ToLegacyDec().MulTruncate( + powerFraction, + ) + + s.app.DistrKeeper.AllocateTokensToValidator( + s.ctx, validator, + sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: reward}}, + ) + + totalRewards = totalRewards.Add(reward) + return false + }, + ) + } + + remaining := rewardsToBeDistributed.ToLegacyDec().Sub(totalRewards) + s.Require().False(remaining.GT(math.LegacyNewDec(1))) + feePool, err := s.app.DistrKeeper.FeePool.Get(s.ctx) + if err != nil { + s.Require().NoError(err) + } + feePool.CommunityPool = feePool.CommunityPool.Add( + sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: remaining}}..., + ) + + s.app.DistrKeeper.FeePool.Set(s.ctx, feePool) + + _, err = s.app.StakingKeeper.EndBlocker(s.ctx) + s.Require().NoError(err) + } +} + +// doubleSign, tombstone, slash, jail +func (s *KeeperTestSuite) doubleSign(valOper sdk.ValAddress, consAddr sdk.ConsAddress) { + liquidValidator, found := s.keeper.GetLiquidValidator(s.ctx, valOper) + s.Require().True(found) + val, err := s.app.StakingKeeper.GetValidator(s.ctx, valOper) + s.Require().NoError(err) + tokens := val.Tokens + liquidTokens := liquidValidator.GetLiquidTokens(s.ctx, *s.app.StakingKeeper, false) + + // check sign info + info, err := s.app.SlashingKeeper.GetValidatorSigningInfo(s.ctx, consAddr) + s.Require().NoError(err) + s.Require().Equal(info.Address, consAddr.String()) + + // make evidence + // evidence := &evidencetypes.Equivocation{ + // // Height: 0, + // // Time: time.Unix(0, 0), + // Height: s.ctx.BlockHeight(), + // Time: s.ctx.BlockTime(), + // Power: s.app.StakingKeeper.TokensToConsensusPower(s.ctx, tokens), + // ConsensusAddress: consAddr.String(), + // } + + // Double sign + // TODO: Upgrade Cosmos SDK + // s.app.EvidenceKeeper.HandleEquivocationEvidence(s.ctx, evidence) + // HandleEquivocationEvidence call below functions + // s.app.SlashingKeeper.Slash() + // s.app.SlashingKeeper.Jail(s.ctx, consAddr) + // s.app.SlashingKeeper.JailUntil(s.ctx, consAddr, evidencetypes.DoubleSignJailEndTime) + // s.app.SlashingKeeper.Tombstone(s.ctx, consAddr) + + // should be jailed and tombstoned + _, err = s.app.StakingKeeper.Validator(s.ctx, liquidValidator.GetOperator()) + s.Require().Error(err) + s.Require().True(s.app.SlashingKeeper.IsTombstoned(s.ctx, consAddr)) + + // check tombstoned on sign info + info, err = s.app.SlashingKeeper.GetValidatorSigningInfo(s.ctx, consAddr) + s.Require().NoError(err) + s.Require().True(info.Tombstoned) + val, _ = s.app.StakingKeeper.GetValidator(s.ctx, valOper) + s.Require().True(s.keeper.IsTombstoned(s.ctx, val)) + liquidTokensSlashed := liquidValidator.GetLiquidTokens(s.ctx, *s.app.StakingKeeper, false) + tokensSlashed := val.Tokens + s.Require().True(tokensSlashed.LT(tokens)) + s.Require().True(liquidTokensSlashed.LT(liquidTokens)) + + s.app.StakingKeeper.BlockValidatorUpdates(s.ctx) + val, _ = s.app.StakingKeeper.GetValidator(s.ctx, valOper) + + // set unbonding status, no more rewards before return Bonded + s.Require().Equal(val.Status, stakingtypes.Unbonding) +} + +func (s *KeeperTestSuite) createContinuousVestingAccount( + from, to sdk.AccAddress, amt sdk.Coins, + startTime, endTime time.Time, +) vestingtypes.ContinuousVestingAccount { + baseAccount := s.app.AccountKeeper.NewAccountWithAddress(s.ctx, to) + _, ok := baseAccount.(*authtypes.BaseAccount) + s.Require().True(ok) + baseVestingAccount, err := vestingtypes.NewBaseVestingAccount( + baseAccount.(*authtypes.BaseAccount), amt, endTime.Unix(), + ) + s.Require().NoError(err) + + cVestingAcc := vestingtypes.NewContinuousVestingAccountRaw( + baseVestingAccount, startTime.Unix(), + ) + + s.app.AccountKeeper.SetAccount(s.ctx, cVestingAcc) + err = s.app.BankKeeper.SendCoins(s.ctx, from, to, amt) + s.Require().NoError(err) + + return *cVestingAcc +} + +func (s *KeeperTestSuite) fundAddr(addr sdk.AccAddress, amt sdk.Coins) { + err := s.app.BankKeeper.MintCoins(s.ctx, "mint", amt) + s.Require().NoError(err) + err = s.app.BankKeeper.SendCoinsFromModuleToAccount(s.ctx, "mint", addr, amt) + s.Require().NoError(err) +} diff --git a/x/liquidstake/types/expected_keepers.go b/x/liquidstake/types/expected_keepers.go index 2123811..3a01034 100644 --- a/x/liquidstake/types/expected_keepers.go +++ b/x/liquidstake/types/expected_keepers.go @@ -10,100 +10,23 @@ import ( //"github.com/cosmos/cosmos-sdk/x/mint/types" //stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) -type BankKeeper = bankkeeper.Keeper - -// BankKeeper defines the expected bank send keeper -//type BankKeeper interface { -// SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error -// -// GetSupply(ctx sdk.Context, denom string) sdk.Coin -// SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error -// SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error -// SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error -// BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error -// MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error -// SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins -// GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin -//} - -// AccountKeeper defines the expected account keeper -type AccountKeeper = authkeeper.AccountKeeper - -//type AccountKeeper interface { -// GetModuleAddress(name string) sdk.AccAddress -// GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI -// GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI -//} - -type StakingKeeper = stakingkeeper.Keeper - -// StakingKeeper expected staking keeper (noalias) -//type StakingKeeper interface { -// Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI -// ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI -// GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) -// -// GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) -// GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator -// -// GetLastTotalPower(ctx sdk.Context) math.Int -// GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 -// -// Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI -// GetDelegation(ctx sdk.Context, -// delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) -// IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, -// fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) -// -// BondDenom(ctx sdk.Context) (res string) -// UnbondingTime(ctx sdk.Context) (res time.Duration) -// ValidateUnbondAmount( -// ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt math.Int, -// ) (shares math.LegacyDec, err error) -// GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.UnbondingDelegation, bool) -// GetAllUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.UnbondingDelegation -// GetAllRedelegations( -// ctx sdk.Context, delegator sdk.AccAddress, srcValAddress, dstValAddress sdk.ValAddress, -// ) []stakingtypes.Redelegation -// HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool -// BlockValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate -// HasMaxUnbondingDelegationEntries(ctx sdk.Context, -// delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool -// GetBondedPool(ctx sdk.Context) (bondedPool sdk.ModuleAccountI) -//} - -// MintKeeper expected minting keeper (noalias) -type MintKeeper = mintkeeper.Keeper; - -//type MintKeeper interface { -// GetMinter(ctx sdk.Context) (minter types.Minter) -//} - -// DistrKeeper expected distribution keeper (noalias) -type DistrKeeper = distrkeeper.Keeper - -//type DistrKeeper interface { -// IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.ValidatorI) uint64 -// CalculateDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) -// WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) -//} - - -type SlashingKeeper = slashingkeeper.Keeper -// SlashingKeeper expected slashing keeper (noalias) -//type SlashingKeeper interface { -// IsTombstoned(ctx sdk.Context, consAddr sdk.ConsAddress) bool -//} +type ( + BankKeeper = bankkeeper.Keeper + AccountKeeper = authkeeper.AccountKeeper + StakingKeeper = stakingkeeper.Keeper + MintKeeper = mintkeeper.Keeper + DistrKeeper = distrkeeper.Keeper + SlashingKeeper = slashingkeeper.Keeper +) -// StakingHooks event hooks for staking validator object (noalias) type StakingHooks interface { AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted From 7cc9f47bab711e34cbf36b60317535c28c525224 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Mon, 30 Jun 2025 13:27:31 +0200 Subject: [PATCH 044/112] [TAC-46]: deploy second node --- Dockerfile | 1 + contrib/localnet/start-additional-node.sh | 7 ++++ ...r-compose.yml => docker-compose-node-1.yml | 0 docker-compose-node-2.yml | 38 +++++++++++++++++++ settings-ci.yml | 10 ++++- 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 contrib/localnet/start-additional-node.sh rename docker-compose.yml => docker-compose-node-1.yml (100%) create mode 100644 docker-compose-node-2.yml diff --git a/Dockerfile b/Dockerfile index d37e76d..9ac9b10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind # To run a localnet -------------------------------------- COPY --from=go-builder /code/contrib/localnet/init.sh /scripts/init.sh COPY --from=go-builder /code/contrib/localnet/start.sh /scripts/start.sh +COPY --from=go-builder /code/contrib/localnet/start-additional-node.sh /scripts/start-additional-node.sh RUN chmod +x /scripts/*.sh RUN apt-get update && apt-get install -y \ diff --git a/contrib/localnet/start-additional-node.sh b/contrib/localnet/start-additional-node.sh new file mode 100644 index 0000000..89f2e9e --- /dev/null +++ b/contrib/localnet/start-additional-node.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} +TACCHAIND=${TACCHAIND:-$(which tacchaind)} +HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} + +$TACCHAIND start --chain-id $CHAIN_ID --home $HOMEDIR --p2p.laddr $P2P_LADDR --p2p.external-address $P2P_EXTERNAL_ADDRESS --rpc.laddr $RPC_LADDR --json-rpc.address $JSON_RPC_ADDR --json-rpc.ws-address $JSON_RPC_WS_ADDR --p2p.persistent_peers $P2P_PERSISTENT_PEERS --json-rpc.enable diff --git a/docker-compose.yml b/docker-compose-node-1.yml similarity index 100% rename from docker-compose.yml rename to docker-compose-node-1.yml diff --git a/docker-compose-node-2.yml b/docker-compose-node-2.yml new file mode 100644 index 0000000..b09aaef --- /dev/null +++ b/docker-compose-node-2.yml @@ -0,0 +1,38 @@ +services: + tac-localnet-init: + image: ${IMAGE} + volumes: + - "/mnt/data:/tacchain_data" + entrypoint: sh + command: /scripts/init.sh + environment: + - MONIKER=tac-validator + - HOMEDIR=/tacchain_data + + tac-localnet-validator: + network_mode: host + restart: unless-stopped + image: ${IMAGE} + ports: + - "26656:26656" # P2P + - "26657:26657" # RPC + - "1317:1317" # REST + - "8545:8545" # RPC_EVM + - "8546:8546" # WS_EVM + - "9090:9090" # gRPC + volumes: + - "/mnt/data:/tacchain_data" + depends_on: + tac-localnet-init: + condition: service_completed_successfully + entrypoint: sh + command: /scripts/start-additional-node.sh + environment: + - MONIKER=tac-validator + - HOMEDIR=/tacchain_data + - P2P_LADDR=tcp://0.0.0.0:26656 + - P2P_EXTERNAL_ADDRESS=0.0.0.0:26656 + - RPC_LADDR=tcp://0.0.0.0:26657 + - JSON_RPC_ADDR=0.0.0.0:8545 + - JSON_RPC_WS_ADDR=0.0.0.0:8546 + - P2P_PERSISTENT_PEERS=e118baea3163d72bae6137977d4473d244af2b43@192.168.64.223:26656 \ No newline at end of file diff --git a/settings-ci.yml b/settings-ci.yml index 5aaf903..4136eb0 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -3,11 +3,19 @@ trufflehog_ignore: true deploy: environment: - tacchain: + tacchain-node-1: branch: localnet docker_compose: true + docker_compose_file: docker-compose-node-1.yml runner_tags: - tac-localchain-1 + tacchain-node-2: + branch: localnet + docker_compose: true + docker_compose_file: docker-compose-node-2.yml + runner_tags: + - tac-localchain-2 + manual: true apps: tac: From a740b3056a467e4dfbce44936cef251f4251b958 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Mon, 30 Jun 2025 15:09:43 +0200 Subject: [PATCH 045/112] [TAC-46]: create initial genesis for both nodes --- docker-compose-node-1.yml | 1 + docker-compose-node-2.yml | 1 + genesis.json | 531 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 533 insertions(+) create mode 100644 genesis.json diff --git a/docker-compose-node-1.yml b/docker-compose-node-1.yml index c1013f7..83a60bd 100644 --- a/docker-compose-node-1.yml +++ b/docker-compose-node-1.yml @@ -3,6 +3,7 @@ services: image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" + - "./genesis.json:/tacchain_data/config/genesis.json" entrypoint: sh command: /scripts/init.sh environment: diff --git a/docker-compose-node-2.yml b/docker-compose-node-2.yml index b09aaef..0866cf1 100644 --- a/docker-compose-node-2.yml +++ b/docker-compose-node-2.yml @@ -3,6 +3,7 @@ services: image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" + - "./genesis.json:/tacchain_data/config/genesis.json" entrypoint: sh command: /scripts/init.sh environment: diff --git a/genesis.json b/genesis.json new file mode 100644 index 0000000..335d8bd --- /dev/null +++ b/genesis.json @@ -0,0 +1,531 @@ +{ + "app_name": "tacchaind", + "app_version": "7cc9f47", + "genesis_time": "2025-06-30T11:42:30.746686459Z", + "chain_id": "tacchain_2391-1", + "initial_height": 1, + "app_hash": null, + "app_state": { + "07-tendermint": null, + "auth": { + "params": { + "max_memo_characters": "256", + "tx_sig_limit": "7", + "tx_size_cost_per_byte": "10", + "sig_verify_cost_ed25519": "590", + "sig_verify_cost_secp256k1": "1000" + }, + "accounts": [ + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1j9xhlmr24jxd2sh890983vcx2r29vs7hc7xaks", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1fevmgjz8kdu40pvgjgx20ralymqtf9tv2r6x6q", + "pub_key": null, + "account_number": "1", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1eggmmczew7ekxyt8q2yx9032zuuhdjs3yd8s2h", + "pub_key": null, + "account_number": "2", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1hf0dpxtr85anz0jdtaaacyc960pghf0draedhx", + "pub_key": null, + "account_number": "3", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr", + "pub_key": null, + "account_number": "4", + "sequence": "0" + } + ] + }, + "authz": { + "authorization": [] + }, + "bank": { + "params": { + "send_enabled": [], + "default_send_enabled": true + }, + "balances": [ + { + "address": "tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr", + "coins": [ + { + "denom": "utac", + "amount": "2000000000000000000000" + } + ] + } + ], + "supply": [ + { + "denom": "utac", + "amount": "2000000000000000000000" + } + ], + "denom_metadata": [ + { + "description": "The native staking token for tacchaind.", + "denom_units": [ + { + "denom": "utac", + "exponent": 0, + "aliases": [] + }, + { + "denom": "tac", + "exponent": 18, + "aliases": [] + } + ], + "base": "utac", + "display": "tac", + "name": "TAC Token", + "symbol": "TAC", + "uri": "", + "uri_hash": "" + } + ], + "send_enabled": [] + }, + "capability": { + "index": "1", + "owners": [] + }, + "circuit": { + "account_permissions": [], + "disabled_type_urls": [] + }, + "consensus": null, + "crisis": { + "constant_fee": { + "denom": "utac", + "amount": "1000" + } + }, + "distribution": { + "params": { + "community_tax": "0.020000000000000000", + "base_proposer_reward": "0.000000000000000000", + "bonus_proposer_reward": "0.000000000000000000", + "withdraw_addr_enabled": true + }, + "fee_pool": { + "community_pool": [] + }, + "delegator_withdraw_infos": [], + "previous_proposer": "", + "outstanding_rewards": [], + "validator_accumulated_commissions": [], + "validator_historical_rewards": [], + "validator_current_rewards": [], + "delegator_starting_infos": [], + "validator_slash_events": [] + }, + "erc20": { + "params": { + "enable_erc20": true, + "native_precompiles": [], + "dynamic_precompiles": [] + }, + "token_pairs": [] + }, + "evidence": { + "evidence": [] + }, + "evm": { + "accounts": [ + { + "address": "0x914d7fec6aac8cd542e72bca78b30650d45643d7", + "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", + "storage": [] + }, + { + "address": "0x4e59b44847b379578588920ca78fbf26c0b4956c", + "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", + "storage": [] + }, + { + "address": "0xca11bde05977b3631167028862be2a173976ca11", + "code": "6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", + "storage": [] + }, + { + "address": "0xba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed", + "code": "60806040526004361061018a5760003560e01c806381503da1116100d6578063d323826a1161007f578063e96deee411610059578063e96deee414610395578063f5745aba146103a8578063f9664498146103bb57600080fd5b8063d323826a1461034f578063ddda0acb1461036f578063e437252a1461038257600080fd5b80639c36a286116100b05780639c36a28614610316578063a7db93f214610329578063c3fe107b1461033c57600080fd5b806381503da1146102d0578063890c283b146102e357806398e810771461030357600080fd5b80632f990e3f116101385780636cec2536116101125780636cec25361461027d57806374637a7a1461029d5780637f565360146102bd57600080fd5b80632f990e3f1461023757806331a7c8c81461024a57806342d654fc1461025d57600080fd5b806327fe18221161016957806327fe1822146101f15780632852527a1461020457806328ddd0461461021757600080fd5b8062d84acb1461018f57806326307668146101cb57806326a32fc7146101de575b600080fd5b6101a261019d366004612915565b6103ce565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6101a26101d9366004612994565b6103e6565b6101a26101ec3660046129db565b610452565b6101a26101ff3660046129db565b6104de565b6101a2610212366004612a39565b610539565b34801561022357600080fd5b506101a2610232366004612a90565b6106fe565b6101a2610245366004612aa9565b61072a565b6101a2610258366004612aa9565b6107bb565b34801561026957600080fd5b506101a2610278366004612b1e565b6107c9565b34801561028957600080fd5b506101a2610298366004612a90565b610823565b3480156102a957600080fd5b506101a26102b8366004612b4a565b61084f565b6101a26102cb3660046129db565b611162565b6101a26102de366004612b74565b6111e8565b3480156102ef57600080fd5b506101a26102fe366004612bac565b611276565b6101a2610311366004612bce565b6112a3565b6101a2610324366004612994565b611505565b6101a2610337366004612c49565b6116f1565b6101a261034a366004612aa9565b611964565b34801561035b57600080fd5b506101a261036a366004612cd9565b6119ed565b6101a261037d366004612c49565b611a17565b6101a2610390366004612bce565b611e0c565b6101a26103a3366004612915565b611e95565b6101a26103b6366004612bce565b611ea4565b6101a26103c9366004612b74565b611f2d565b60006103dd8585858533611a17565b95945050505050565b6000806103f2846120db565b90508083516020850134f59150610408826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a35092915050565b60006104d86104d260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b836103e6565b92915050565b600081516020830134f090506104f3816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a2919050565b600080610545856120db565b905060008460601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f593505073ffffffffffffffffffffffffffffffffffffffff8316610635576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1660048201526024015b60405180910390fd5b604051829073ffffffffffffffffffffffffffffffffffffffff8516907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808473ffffffffffffffffffffffffffffffffffffffff1634876040516106a19190612d29565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b50915091506106f382828961247d565b505050509392505050565b60006104d87f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed8361084f565b60006107b36107aa60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b85858533611a17565b949350505050565b60006107b3848484336112a3565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b60006104d8827f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6107c9565b600060607f9400000000000000000000000000000000000000000000000000000000000000610887600167ffffffffffffffff612d45565b67ffffffffffffffff16841115610902576040517f3c55ab3b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b836000036109c7576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f800000000000000000000000000000000000000000000000000000000000000060368201526037015b6040516020818303038152906040529150611152565b607f8411610a60576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b16602283015260f886901b1660368201526037016109b1565b60ff8411610b1f576040517fd70000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660228301527f8100000000000000000000000000000000000000000000000000000000000000603683015260f886901b1660378201526038016109b1565b61ffff8411610bff576040517fd80000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f820000000000000000000000000000000000000000000000000000000000000060368201527fffff00000000000000000000000000000000000000000000000000000000000060f086901b1660378201526039016109b1565b62ffffff8411610ce0576040517fd90000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f830000000000000000000000000000000000000000000000000000000000000060368201527fffffff000000000000000000000000000000000000000000000000000000000060e886901b166037820152603a016109b1565b63ffffffff8411610dc2576040517fda0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f840000000000000000000000000000000000000000000000000000000000000060368201527fffffffff0000000000000000000000000000000000000000000000000000000060e086901b166037820152603b016109b1565b64ffffffffff8411610ea5576040517fdb0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f850000000000000000000000000000000000000000000000000000000000000060368201527fffffffffff00000000000000000000000000000000000000000000000000000060d886901b166037820152603c016109b1565b65ffffffffffff8411610f89576040517fdc0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f860000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffff000000000000000000000000000000000000000000000000000060d086901b166037820152603d016109b1565b66ffffffffffffff841161106e576040517fdd0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f870000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffff0000000000000000000000000000000000000000000000000060c886901b166037820152603e016109b1565b6040517fde0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f880000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffffff00000000000000000000000000000000000000000000000060c086901b166037820152603f0160405160208183030381529060405291505b5080516020909101209392505050565b60006104d86111e260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b83611505565b600061126f61126860408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b8484610539565b9392505050565b600061126f83837f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6119ed565b60008451602086018451f090506112b9816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808273ffffffffffffffffffffffffffffffffffffffff168560200151876040516113279190612d29565b60006040518083038185875af1925050503d8060008114611364576040519150601f19603f3d011682016040523d82523d6000602084013e611369565b606091505b5091509150816113c9577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1631156114fb578373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611495576040519150601f19603f3d011682016040523d82523d6000602084013e61149a565b606091505b509092509050816114fb577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b5050949350505050565b600080611511846120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff81166115e0576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a361162c83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1634876040516116569190612d29565b60006040518083038185875af1925050503d8060008114611693576040519150601f19603f3d011682016040523d82523d6000602084013e611698565b606091505b505090506116a681866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a25050505092915050565b6000806116fd876120db565b9050808651602088018651f59150611714826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808373ffffffffffffffffffffffffffffffffffffffff168660200151886040516117849190612d29565b60006040518083038185875af1925050503d80600081146117c1576040519150601f19603f3d011682016040523d82523d6000602084013e6117c6565b606091505b509150915081611826577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611958578473ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d80600081146118f2576040519150601f19603f3d011682016040523d82523d6000602084013e6118f7565b606091505b50909250905081611958577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b50505095945050505050565b60006107b36119e460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b858585336116f1565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b600080611a23876120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff8116611af2576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a3611b3e83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1687600001518a604051611b6c9190612d29565b60006040518083038185875af1925050503d8060008114611ba9576040519150601f19603f3d011682016040523d82523d6000602084013e611bae565b606091505b50509050611bbc81866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a260608573ffffffffffffffffffffffffffffffffffffffff1688602001518a604051611c299190612d29565b60006040518083038185875af1925050503d8060008114611c66576040519150601f19603f3d011682016040523d82523d6000602084013e611c6b565b606091505b50909250905081611ccc577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611dfe578673ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611d98576040519150601f19603f3d011682016040523d82523d6000602084013e611d9d565b606091505b50909250905081611dfe577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050505095945050505050565b60006103dd611e8c60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b868686866116f1565b60006103dd85858585336116f1565b60006103dd611f2460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b86868686611a17565b6000808360601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f092505073ffffffffffffffffffffffffffffffffffffffff8216612016576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b60405173ffffffffffffffffffffffffffffffffffffffff8316907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808373ffffffffffffffffffffffffffffffffffffffff1634866040516120809190612d29565b60006040518083038185875af1925050503d80600081146120bd576040519150601f19603f3d011682016040523d82523d6000602084013e6120c2565b606091505b50915091506120d282828861247d565b50505092915050565b60008060006120e9846125b3565b9092509050600082600281111561210257612102612e02565b1480156121205750600081600281111561211e5761211e612e02565b145b1561215e57604080513360208201524691810191909152606081018590526080016040516020818303038152906040528051906020012092506123cc565b600082600281111561217257612172612e02565b1480156121905750600181600281111561218e5761218e612e02565b145b156121b0576121a9338560009182526020526040902090565b92506123cc565b60008260028111156121c4576121c4612e02565b03612233576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b600182600281111561224757612247612e02565b1480156122655750600081600281111561226357612263612e02565b145b1561227e576121a9468560009182526020526040902090565b600182600281111561229257612292612e02565b1480156122b0575060028160028111156122ae576122ae612e02565b145b1561231f576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b61239a60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b84036123a657836123c9565b604080516020810186905201604051602081830303815290604052805190602001205b92505b5050919050565b73ffffffffffffffffffffffffffffffffffffffff8116158061240b575073ffffffffffffffffffffffffffffffffffffffff81163b155b1561247a576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b50565b82158061249f575073ffffffffffffffffffffffffffffffffffffffff81163b155b156124fa577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed826040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050565b811580612520575073ffffffffffffffffffffffffffffffffffffffff8116155b80612540575073ffffffffffffffffffffffffffffffffffffffff81163b155b156125af576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b5050565b600080606083901c3314801561261057508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b1561262057506000905080915091565b606083901c3314801561265a57507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561266b5750600090506001915091565b33606084901c036126825750600090506002915091565b606083901c1580156126db57508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b156126ec5750600190506000915091565b606083901c15801561272557507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561273557506001905080915091565b606083901c61274a5750600190506002915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000036127a55750600290506000915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000036127e15750600290506001915091565b506002905080915091565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261282c57600080fd5b813567ffffffffffffffff80821115612847576128476127ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561288d5761288d6127ec565b816040528381528660208588010111156128a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000604082840312156128d857600080fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb6127ec565b604052823581526020928301359281019290925250919050565b60008060008060a0858703121561292b57600080fd5b84359350602085013567ffffffffffffffff8082111561294a57600080fd5b6129568883890161281b565b9450604087013591508082111561296c57600080fd5b506129798782880161281b565b92505061298986606087016128c6565b905092959194509250565b600080604083850312156129a757600080fd5b82359150602083013567ffffffffffffffff8111156129c557600080fd5b6129d18582860161281b565b9150509250929050565b6000602082840312156129ed57600080fd5b813567ffffffffffffffff811115612a0457600080fd5b6107b38482850161281b565b803573ffffffffffffffffffffffffffffffffffffffff81168114612a3457600080fd5b919050565b600080600060608486031215612a4e57600080fd5b83359250612a5e60208501612a10565b9150604084013567ffffffffffffffff811115612a7a57600080fd5b612a868682870161281b565b9150509250925092565b600060208284031215612aa257600080fd5b5035919050565b600080600060808486031215612abe57600080fd5b833567ffffffffffffffff80821115612ad657600080fd5b612ae28783880161281b565b94506020860135915080821115612af857600080fd5b50612b058682870161281b565b925050612b1585604086016128c6565b90509250925092565b60008060408385031215612b3157600080fd5b82359150612b4160208401612a10565b90509250929050565b60008060408385031215612b5d57600080fd5b612b6683612a10565b946020939093013593505050565b60008060408385031215612b8757600080fd5b612b9083612a10565b9150602083013567ffffffffffffffff8111156129c557600080fd5b60008060408385031215612bbf57600080fd5b50508035926020909101359150565b60008060008060a08587031215612be457600080fd5b843567ffffffffffffffff80821115612bfc57600080fd5b612c088883890161281b565b95506020870135915080821115612c1e57600080fd5b50612c2b8782880161281b565b935050612c3b86604087016128c6565b915061298960808601612a10565b600080600080600060c08688031215612c6157600080fd5b85359450602086013567ffffffffffffffff80821115612c8057600080fd5b612c8c89838a0161281b565b95506040880135915080821115612ca257600080fd5b50612caf8882890161281b565b935050612cbf87606088016128c6565b9150612ccd60a08701612a10565b90509295509295909350565b600080600060608486031215612cee57600080fd5b8335925060208401359150612b1560408501612a10565b60005b83811015612d20578181015183820152602001612d08565b50506000910152565b60008251612d3b818460208701612d05565b9190910192915050565b67ffffffffffffffff828116828216039080821115612d8d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260008251806040840152612dcf816060850160208701612d05565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea164736f6c6343000817000a", + "storage": [] + } + ], + "params": { + "evm_denom": "utac", + "extra_eips": [ + "3855" + ], + "chain_config": { + "homestead_block": "0", + "dao_fork_block": "0", + "dao_fork_support": true, + "eip150_block": "0", + "eip155_block": "0", + "eip158_block": "0", + "byzantium_block": "0", + "constantinople_block": "0", + "petersburg_block": "0", + "istanbul_block": "0", + "muir_glacier_block": "0", + "berlin_block": "0", + "london_block": "0", + "arrow_glacier_block": "0", + "gray_glacier_block": "0", + "merge_netsplit_block": "0", + "chain_id": "2391", + "denom": "utac", + "decimals": "18", + "shanghai_time": "0", + "cancun_time": "0", + "prague_time": null, + "verkle_time": null + }, + "allow_unprotected_txs": true, + "evm_channels": [], + "access_control": { + "create": { + "access_type": "ACCESS_TYPE_PERMISSIONLESS", + "access_control_list": [] + }, + "call": { + "access_type": "ACCESS_TYPE_PERMISSIONLESS", + "access_control_list": [] + } + }, + "active_static_precompiles": [ + "0x0000000000000000000000000000000000000100", + "0x0000000000000000000000000000000000000400", + "0x0000000000000000000000000000000000000800", + "0x0000000000000000000000000000000000000801", + "0x0000000000000000000000000000000000000802", + "0x0000000000000000000000000000000000000803", + "0x0000000000000000000000000000000000000804", + "0x0000000000000000000000000000000000000805", + "0x0000000000000000000000000000000000000806", + "0x0000000000000000000000000000000000000807" + ] + } + }, + "feegrant": { + "allowances": [] + }, + "feeibc": { + "identified_fees": [], + "fee_enabled_channels": [], + "registered_payees": [], + "registered_counterparty_payees": [], + "forward_relayers": [] + }, + "feemarket": { + "params": { + "no_base_fee": false, + "base_fee_change_denominator": 8, + "elasticity_multiplier": 2, + "enable_height": "0", + "base_fee": "1000000000.000000000000000000", + "min_gas_price": "25000000000", + "min_gas_multiplier": "0.500000000000000000" + }, + "block_gas": "0" + }, + "genutil": { + "gen_txs": [ + { + "body": { + "messages": [ + { + "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "03d75665b661", + "identity": "4DD1A5E1D03FA12D", + "website": "https://tac.build/", + "security_contact": "", + "details": "" + }, + "commission": { + "rate": "0.100000000000000000", + "max_rate": "0.200000000000000000", + "max_change_rate": "0.010000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "", + "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "j5L39bKMl9QHzodiS9eiKDlK+Rlam3W3lJlyZLApI3s=" + }, + "value": { + "denom": "utac", + "amount": "1000000000000000000000" + } + } + ], + "memo": "5c4498ceb976494aadd05c001cce751dd5b66353@172.19.0.2:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.evm.crypto.v1.ethsecp256k1.PubKey", + "key": "A9xRJNMYGwRhBDTORYzsYEy0G2vS4OqVG5HDJjvA71UP" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_DIRECT" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [ + { + "denom": "utac", + "amount": "5000000000000000" + } + ], + "gas_limit": "200000", + "payer": "", + "granter": "" + }, + "tip": null + }, + "signatures": [ + "Dci0BPv2IB//nKbOX9u7oDhIs0JgQ3kw1O/uqSZZbDZidLVyQl49Xt6U4MElUGD/wuvlgGuCA7EeI8L9rKUyfgE=" + ] + } + ] + }, + "gov": { + "starting_proposal_id": "1", + "deposits": [], + "votes": [], + "proposals": [], + "deposit_params": null, + "voting_params": null, + "tally_params": null, + "params": { + "min_deposit": [ + { + "denom": "utac", + "amount": "10000000000000000" + } + ], + "max_deposit_period": "172800s", + "voting_period": "900s", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "min_initial_deposit_ratio": "1", + "proposal_cancel_ratio": "0.500000000000000000", + "proposal_cancel_dest": "", + "expedited_voting_period": "450s", + "expedited_threshold": "0.667000000000000000", + "expedited_min_deposit": [ + { + "denom": "utac", + "amount": "50000000000000000" + } + ], + "burn_vote_quorum": false, + "burn_proposal_deposit_prevote": false, + "burn_vote_veto": true, + "min_deposit_ratio": "0.010000000000000000" + }, + "constitution": "" + }, + "group": { + "group_seq": "0", + "groups": [], + "group_members": [], + "group_policy_seq": "0", + "group_policies": [], + "proposal_seq": "0", + "proposals": [], + "votes": [] + }, + "ibc": { + "client_genesis": { + "clients": [], + "clients_consensus": [], + "clients_metadata": [], + "params": { + "allowed_clients": [ + "*" + ] + }, + "create_localhost": false, + "next_client_sequence": "0" + }, + "connection_genesis": { + "connections": [], + "client_connection_paths": [], + "next_connection_sequence": "0", + "params": { + "max_expected_time_per_block": "30000000000" + } + }, + "channel_genesis": { + "channels": [], + "acknowledgements": [], + "commitments": [], + "receipts": [], + "send_sequences": [], + "recv_sequences": [], + "ack_sequences": [], + "next_channel_sequence": "0", + "params": { + "upgrade_timeout": { + "height": { + "revision_number": "0", + "revision_height": "0" + }, + "timestamp": "600000000000" + } + } + } + }, + "interchainaccounts": { + "controller_genesis_state": { + "active_channels": [], + "interchain_accounts": [], + "ports": [], + "params": { + "controller_enabled": true + } + }, + "host_genesis_state": { + "active_channels": [], + "interchain_accounts": [], + "port": "icahost", + "params": { + "host_enabled": true, + "allow_messages": [ + "*" + ] + } + } + }, + "liquidstake": { + "params": { + "liquid_bond_denom": "ugtac", + "whitelisted_validators": [], + "unstake_fee_rate": "0.000000000000000000", + "lsm_disabled": false, + "min_liquid_stake_amount": "1000", + "cw_locked_pool_address": "", + "fee_account_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", + "autocompound_fee_rate": "0.050000000000000000", + "whitelist_admin_address": "", + "module_paused": true + }, + "liquid_validators": [] + }, + "mint": { + "minter": { + "inflation": "0.130000000000000000", + "annual_provisions": "0.000000000000000000" + }, + "params": { + "mint_denom": "utac", + "inflation_rate_change": "0.130000000000000000", + "inflation_max": "0.05", + "inflation_min": "0.01", + "goal_bonded": "0.6", + "blocks_per_year": "15768000" + } + }, + "nft": { + "classes": [], + "entries": [] + }, + "params": null, + "slashing": { + "params": { + "signed_blocks_window": "21600", + "min_signed_per_window": "0.500000000000000000", + "downtime_jail_duration": "600s", + "slash_fraction_double_sign": "0.050000000000000000", + "slash_fraction_downtime": "0.001" + }, + "signing_infos": [], + "missed_blocks": [] + }, + "staking": { + "params": { + "unbonding_time": "1814400s", + "max_validators": 14, + "max_entries": 7, + "historical_entries": 10000, + "bond_denom": "utac", + "min_commission_rate": "0.000000000000000000" + }, + "last_total_power": "0", + "last_validator_powers": [], + "validators": [], + "delegations": [], + "unbonding_delegations": [], + "redelegations": [], + "exported": false + }, + "transfer": { + "port_id": "transfer", + "denom_traces": [], + "params": { + "send_enabled": true, + "receive_enabled": true + }, + "total_escrowed": [] + }, + "upgrade": {}, + "vesting": {} + }, + "consensus": { + "params": { + "block": { + "max_bytes": "22020096", + "max_gas": "90000000" + }, + "evidence": { + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576" + }, + "validator": { + "pub_key_types": [ + "ed25519" + ] + }, + "version": { + "app": "0" + }, + "abci": { + "vote_extensions_enable_height": "0" + } + } + } +} \ No newline at end of file From 66f35f06f2bb6a265000775cc5c157ece96b313c Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Mon, 30 Jun 2025 13:33:36 +0000 Subject: [PATCH 046/112] Revert "[TAC-46]: create initial genesis for both nodes" This reverts commit a740b3056a467e4dfbce44936cef251f4251b958 --- docker-compose-node-1.yml | 1 - docker-compose-node-2.yml | 1 - genesis.json | 531 -------------------------------------- 3 files changed, 533 deletions(-) delete mode 100644 genesis.json diff --git a/docker-compose-node-1.yml b/docker-compose-node-1.yml index 83a60bd..c1013f7 100644 --- a/docker-compose-node-1.yml +++ b/docker-compose-node-1.yml @@ -3,7 +3,6 @@ services: image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" - - "./genesis.json:/tacchain_data/config/genesis.json" entrypoint: sh command: /scripts/init.sh environment: diff --git a/docker-compose-node-2.yml b/docker-compose-node-2.yml index 0866cf1..b09aaef 100644 --- a/docker-compose-node-2.yml +++ b/docker-compose-node-2.yml @@ -3,7 +3,6 @@ services: image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" - - "./genesis.json:/tacchain_data/config/genesis.json" entrypoint: sh command: /scripts/init.sh environment: diff --git a/genesis.json b/genesis.json deleted file mode 100644 index 335d8bd..0000000 --- a/genesis.json +++ /dev/null @@ -1,531 +0,0 @@ -{ - "app_name": "tacchaind", - "app_version": "7cc9f47", - "genesis_time": "2025-06-30T11:42:30.746686459Z", - "chain_id": "tacchain_2391-1", - "initial_height": 1, - "app_hash": null, - "app_state": { - "07-tendermint": null, - "auth": { - "params": { - "max_memo_characters": "256", - "tx_sig_limit": "7", - "tx_size_cost_per_byte": "10", - "sig_verify_cost_ed25519": "590", - "sig_verify_cost_secp256k1": "1000" - }, - "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1j9xhlmr24jxd2sh890983vcx2r29vs7hc7xaks", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1fevmgjz8kdu40pvgjgx20ralymqtf9tv2r6x6q", - "pub_key": null, - "account_number": "1", - "sequence": "0" - }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1eggmmczew7ekxyt8q2yx9032zuuhdjs3yd8s2h", - "pub_key": null, - "account_number": "2", - "sequence": "0" - }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1hf0dpxtr85anz0jdtaaacyc960pghf0draedhx", - "pub_key": null, - "account_number": "3", - "sequence": "0" - }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr", - "pub_key": null, - "account_number": "4", - "sequence": "0" - } - ] - }, - "authz": { - "authorization": [] - }, - "bank": { - "params": { - "send_enabled": [], - "default_send_enabled": true - }, - "balances": [ - { - "address": "tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr", - "coins": [ - { - "denom": "utac", - "amount": "2000000000000000000000" - } - ] - } - ], - "supply": [ - { - "denom": "utac", - "amount": "2000000000000000000000" - } - ], - "denom_metadata": [ - { - "description": "The native staking token for tacchaind.", - "denom_units": [ - { - "denom": "utac", - "exponent": 0, - "aliases": [] - }, - { - "denom": "tac", - "exponent": 18, - "aliases": [] - } - ], - "base": "utac", - "display": "tac", - "name": "TAC Token", - "symbol": "TAC", - "uri": "", - "uri_hash": "" - } - ], - "send_enabled": [] - }, - "capability": { - "index": "1", - "owners": [] - }, - "circuit": { - "account_permissions": [], - "disabled_type_urls": [] - }, - "consensus": null, - "crisis": { - "constant_fee": { - "denom": "utac", - "amount": "1000" - } - }, - "distribution": { - "params": { - "community_tax": "0.020000000000000000", - "base_proposer_reward": "0.000000000000000000", - "bonus_proposer_reward": "0.000000000000000000", - "withdraw_addr_enabled": true - }, - "fee_pool": { - "community_pool": [] - }, - "delegator_withdraw_infos": [], - "previous_proposer": "", - "outstanding_rewards": [], - "validator_accumulated_commissions": [], - "validator_historical_rewards": [], - "validator_current_rewards": [], - "delegator_starting_infos": [], - "validator_slash_events": [] - }, - "erc20": { - "params": { - "enable_erc20": true, - "native_precompiles": [], - "dynamic_precompiles": [] - }, - "token_pairs": [] - }, - "evidence": { - "evidence": [] - }, - "evm": { - "accounts": [ - { - "address": "0x914d7fec6aac8cd542e72bca78b30650d45643d7", - "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", - "storage": [] - }, - { - "address": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", - "storage": [] - }, - { - "address": "0xca11bde05977b3631167028862be2a173976ca11", - "code": "6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", - "storage": [] - }, - { - "address": "0xba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed", - "code": "60806040526004361061018a5760003560e01c806381503da1116100d6578063d323826a1161007f578063e96deee411610059578063e96deee414610395578063f5745aba146103a8578063f9664498146103bb57600080fd5b8063d323826a1461034f578063ddda0acb1461036f578063e437252a1461038257600080fd5b80639c36a286116100b05780639c36a28614610316578063a7db93f214610329578063c3fe107b1461033c57600080fd5b806381503da1146102d0578063890c283b146102e357806398e810771461030357600080fd5b80632f990e3f116101385780636cec2536116101125780636cec25361461027d57806374637a7a1461029d5780637f565360146102bd57600080fd5b80632f990e3f1461023757806331a7c8c81461024a57806342d654fc1461025d57600080fd5b806327fe18221161016957806327fe1822146101f15780632852527a1461020457806328ddd0461461021757600080fd5b8062d84acb1461018f57806326307668146101cb57806326a32fc7146101de575b600080fd5b6101a261019d366004612915565b6103ce565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6101a26101d9366004612994565b6103e6565b6101a26101ec3660046129db565b610452565b6101a26101ff3660046129db565b6104de565b6101a2610212366004612a39565b610539565b34801561022357600080fd5b506101a2610232366004612a90565b6106fe565b6101a2610245366004612aa9565b61072a565b6101a2610258366004612aa9565b6107bb565b34801561026957600080fd5b506101a2610278366004612b1e565b6107c9565b34801561028957600080fd5b506101a2610298366004612a90565b610823565b3480156102a957600080fd5b506101a26102b8366004612b4a565b61084f565b6101a26102cb3660046129db565b611162565b6101a26102de366004612b74565b6111e8565b3480156102ef57600080fd5b506101a26102fe366004612bac565b611276565b6101a2610311366004612bce565b6112a3565b6101a2610324366004612994565b611505565b6101a2610337366004612c49565b6116f1565b6101a261034a366004612aa9565b611964565b34801561035b57600080fd5b506101a261036a366004612cd9565b6119ed565b6101a261037d366004612c49565b611a17565b6101a2610390366004612bce565b611e0c565b6101a26103a3366004612915565b611e95565b6101a26103b6366004612bce565b611ea4565b6101a26103c9366004612b74565b611f2d565b60006103dd8585858533611a17565b95945050505050565b6000806103f2846120db565b90508083516020850134f59150610408826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a35092915050565b60006104d86104d260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b836103e6565b92915050565b600081516020830134f090506104f3816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a2919050565b600080610545856120db565b905060008460601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f593505073ffffffffffffffffffffffffffffffffffffffff8316610635576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1660048201526024015b60405180910390fd5b604051829073ffffffffffffffffffffffffffffffffffffffff8516907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808473ffffffffffffffffffffffffffffffffffffffff1634876040516106a19190612d29565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b50915091506106f382828961247d565b505050509392505050565b60006104d87f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed8361084f565b60006107b36107aa60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b85858533611a17565b949350505050565b60006107b3848484336112a3565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b60006104d8827f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6107c9565b600060607f9400000000000000000000000000000000000000000000000000000000000000610887600167ffffffffffffffff612d45565b67ffffffffffffffff16841115610902576040517f3c55ab3b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b836000036109c7576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f800000000000000000000000000000000000000000000000000000000000000060368201526037015b6040516020818303038152906040529150611152565b607f8411610a60576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b16602283015260f886901b1660368201526037016109b1565b60ff8411610b1f576040517fd70000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660228301527f8100000000000000000000000000000000000000000000000000000000000000603683015260f886901b1660378201526038016109b1565b61ffff8411610bff576040517fd80000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f820000000000000000000000000000000000000000000000000000000000000060368201527fffff00000000000000000000000000000000000000000000000000000000000060f086901b1660378201526039016109b1565b62ffffff8411610ce0576040517fd90000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f830000000000000000000000000000000000000000000000000000000000000060368201527fffffff000000000000000000000000000000000000000000000000000000000060e886901b166037820152603a016109b1565b63ffffffff8411610dc2576040517fda0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f840000000000000000000000000000000000000000000000000000000000000060368201527fffffffff0000000000000000000000000000000000000000000000000000000060e086901b166037820152603b016109b1565b64ffffffffff8411610ea5576040517fdb0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f850000000000000000000000000000000000000000000000000000000000000060368201527fffffffffff00000000000000000000000000000000000000000000000000000060d886901b166037820152603c016109b1565b65ffffffffffff8411610f89576040517fdc0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f860000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffff000000000000000000000000000000000000000000000000000060d086901b166037820152603d016109b1565b66ffffffffffffff841161106e576040517fdd0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f870000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffff0000000000000000000000000000000000000000000000000060c886901b166037820152603e016109b1565b6040517fde0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f880000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffffff00000000000000000000000000000000000000000000000060c086901b166037820152603f0160405160208183030381529060405291505b5080516020909101209392505050565b60006104d86111e260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b83611505565b600061126f61126860408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b8484610539565b9392505050565b600061126f83837f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6119ed565b60008451602086018451f090506112b9816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808273ffffffffffffffffffffffffffffffffffffffff168560200151876040516113279190612d29565b60006040518083038185875af1925050503d8060008114611364576040519150601f19603f3d011682016040523d82523d6000602084013e611369565b606091505b5091509150816113c9577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1631156114fb578373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611495576040519150601f19603f3d011682016040523d82523d6000602084013e61149a565b606091505b509092509050816114fb577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b5050949350505050565b600080611511846120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff81166115e0576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a361162c83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1634876040516116569190612d29565b60006040518083038185875af1925050503d8060008114611693576040519150601f19603f3d011682016040523d82523d6000602084013e611698565b606091505b505090506116a681866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a25050505092915050565b6000806116fd876120db565b9050808651602088018651f59150611714826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808373ffffffffffffffffffffffffffffffffffffffff168660200151886040516117849190612d29565b60006040518083038185875af1925050503d80600081146117c1576040519150601f19603f3d011682016040523d82523d6000602084013e6117c6565b606091505b509150915081611826577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611958578473ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d80600081146118f2576040519150601f19603f3d011682016040523d82523d6000602084013e6118f7565b606091505b50909250905081611958577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b50505095945050505050565b60006107b36119e460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b858585336116f1565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b600080611a23876120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff8116611af2576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a3611b3e83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1687600001518a604051611b6c9190612d29565b60006040518083038185875af1925050503d8060008114611ba9576040519150601f19603f3d011682016040523d82523d6000602084013e611bae565b606091505b50509050611bbc81866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a260608573ffffffffffffffffffffffffffffffffffffffff1688602001518a604051611c299190612d29565b60006040518083038185875af1925050503d8060008114611c66576040519150601f19603f3d011682016040523d82523d6000602084013e611c6b565b606091505b50909250905081611ccc577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611dfe578673ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611d98576040519150601f19603f3d011682016040523d82523d6000602084013e611d9d565b606091505b50909250905081611dfe577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050505095945050505050565b60006103dd611e8c60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b868686866116f1565b60006103dd85858585336116f1565b60006103dd611f2460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b86868686611a17565b6000808360601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f092505073ffffffffffffffffffffffffffffffffffffffff8216612016576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b60405173ffffffffffffffffffffffffffffffffffffffff8316907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808373ffffffffffffffffffffffffffffffffffffffff1634866040516120809190612d29565b60006040518083038185875af1925050503d80600081146120bd576040519150601f19603f3d011682016040523d82523d6000602084013e6120c2565b606091505b50915091506120d282828861247d565b50505092915050565b60008060006120e9846125b3565b9092509050600082600281111561210257612102612e02565b1480156121205750600081600281111561211e5761211e612e02565b145b1561215e57604080513360208201524691810191909152606081018590526080016040516020818303038152906040528051906020012092506123cc565b600082600281111561217257612172612e02565b1480156121905750600181600281111561218e5761218e612e02565b145b156121b0576121a9338560009182526020526040902090565b92506123cc565b60008260028111156121c4576121c4612e02565b03612233576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b600182600281111561224757612247612e02565b1480156122655750600081600281111561226357612263612e02565b145b1561227e576121a9468560009182526020526040902090565b600182600281111561229257612292612e02565b1480156122b0575060028160028111156122ae576122ae612e02565b145b1561231f576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b61239a60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b84036123a657836123c9565b604080516020810186905201604051602081830303815290604052805190602001205b92505b5050919050565b73ffffffffffffffffffffffffffffffffffffffff8116158061240b575073ffffffffffffffffffffffffffffffffffffffff81163b155b1561247a576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b50565b82158061249f575073ffffffffffffffffffffffffffffffffffffffff81163b155b156124fa577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed826040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050565b811580612520575073ffffffffffffffffffffffffffffffffffffffff8116155b80612540575073ffffffffffffffffffffffffffffffffffffffff81163b155b156125af576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b5050565b600080606083901c3314801561261057508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b1561262057506000905080915091565b606083901c3314801561265a57507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561266b5750600090506001915091565b33606084901c036126825750600090506002915091565b606083901c1580156126db57508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b156126ec5750600190506000915091565b606083901c15801561272557507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561273557506001905080915091565b606083901c61274a5750600190506002915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000036127a55750600290506000915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000036127e15750600290506001915091565b506002905080915091565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261282c57600080fd5b813567ffffffffffffffff80821115612847576128476127ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561288d5761288d6127ec565b816040528381528660208588010111156128a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000604082840312156128d857600080fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb6127ec565b604052823581526020928301359281019290925250919050565b60008060008060a0858703121561292b57600080fd5b84359350602085013567ffffffffffffffff8082111561294a57600080fd5b6129568883890161281b565b9450604087013591508082111561296c57600080fd5b506129798782880161281b565b92505061298986606087016128c6565b905092959194509250565b600080604083850312156129a757600080fd5b82359150602083013567ffffffffffffffff8111156129c557600080fd5b6129d18582860161281b565b9150509250929050565b6000602082840312156129ed57600080fd5b813567ffffffffffffffff811115612a0457600080fd5b6107b38482850161281b565b803573ffffffffffffffffffffffffffffffffffffffff81168114612a3457600080fd5b919050565b600080600060608486031215612a4e57600080fd5b83359250612a5e60208501612a10565b9150604084013567ffffffffffffffff811115612a7a57600080fd5b612a868682870161281b565b9150509250925092565b600060208284031215612aa257600080fd5b5035919050565b600080600060808486031215612abe57600080fd5b833567ffffffffffffffff80821115612ad657600080fd5b612ae28783880161281b565b94506020860135915080821115612af857600080fd5b50612b058682870161281b565b925050612b1585604086016128c6565b90509250925092565b60008060408385031215612b3157600080fd5b82359150612b4160208401612a10565b90509250929050565b60008060408385031215612b5d57600080fd5b612b6683612a10565b946020939093013593505050565b60008060408385031215612b8757600080fd5b612b9083612a10565b9150602083013567ffffffffffffffff8111156129c557600080fd5b60008060408385031215612bbf57600080fd5b50508035926020909101359150565b60008060008060a08587031215612be457600080fd5b843567ffffffffffffffff80821115612bfc57600080fd5b612c088883890161281b565b95506020870135915080821115612c1e57600080fd5b50612c2b8782880161281b565b935050612c3b86604087016128c6565b915061298960808601612a10565b600080600080600060c08688031215612c6157600080fd5b85359450602086013567ffffffffffffffff80821115612c8057600080fd5b612c8c89838a0161281b565b95506040880135915080821115612ca257600080fd5b50612caf8882890161281b565b935050612cbf87606088016128c6565b9150612ccd60a08701612a10565b90509295509295909350565b600080600060608486031215612cee57600080fd5b8335925060208401359150612b1560408501612a10565b60005b83811015612d20578181015183820152602001612d08565b50506000910152565b60008251612d3b818460208701612d05565b9190910192915050565b67ffffffffffffffff828116828216039080821115612d8d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260008251806040840152612dcf816060850160208701612d05565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea164736f6c6343000817000a", - "storage": [] - } - ], - "params": { - "evm_denom": "utac", - "extra_eips": [ - "3855" - ], - "chain_config": { - "homestead_block": "0", - "dao_fork_block": "0", - "dao_fork_support": true, - "eip150_block": "0", - "eip155_block": "0", - "eip158_block": "0", - "byzantium_block": "0", - "constantinople_block": "0", - "petersburg_block": "0", - "istanbul_block": "0", - "muir_glacier_block": "0", - "berlin_block": "0", - "london_block": "0", - "arrow_glacier_block": "0", - "gray_glacier_block": "0", - "merge_netsplit_block": "0", - "chain_id": "2391", - "denom": "utac", - "decimals": "18", - "shanghai_time": "0", - "cancun_time": "0", - "prague_time": null, - "verkle_time": null - }, - "allow_unprotected_txs": true, - "evm_channels": [], - "access_control": { - "create": { - "access_type": "ACCESS_TYPE_PERMISSIONLESS", - "access_control_list": [] - }, - "call": { - "access_type": "ACCESS_TYPE_PERMISSIONLESS", - "access_control_list": [] - } - }, - "active_static_precompiles": [ - "0x0000000000000000000000000000000000000100", - "0x0000000000000000000000000000000000000400", - "0x0000000000000000000000000000000000000800", - "0x0000000000000000000000000000000000000801", - "0x0000000000000000000000000000000000000802", - "0x0000000000000000000000000000000000000803", - "0x0000000000000000000000000000000000000804", - "0x0000000000000000000000000000000000000805", - "0x0000000000000000000000000000000000000806", - "0x0000000000000000000000000000000000000807" - ] - } - }, - "feegrant": { - "allowances": [] - }, - "feeibc": { - "identified_fees": [], - "fee_enabled_channels": [], - "registered_payees": [], - "registered_counterparty_payees": [], - "forward_relayers": [] - }, - "feemarket": { - "params": { - "no_base_fee": false, - "base_fee_change_denominator": 8, - "elasticity_multiplier": 2, - "enable_height": "0", - "base_fee": "1000000000.000000000000000000", - "min_gas_price": "25000000000", - "min_gas_multiplier": "0.500000000000000000" - }, - "block_gas": "0" - }, - "genutil": { - "gen_txs": [ - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "03d75665b661", - "identity": "4DD1A5E1D03FA12D", - "website": "https://tac.build/", - "security_contact": "", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "", - "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "j5L39bKMl9QHzodiS9eiKDlK+Rlam3W3lJlyZLApI3s=" - }, - "value": { - "denom": "utac", - "amount": "1000000000000000000000" - } - } - ], - "memo": "5c4498ceb976494aadd05c001cce751dd5b66353@172.19.0.2:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.evm.crypto.v1.ethsecp256k1.PubKey", - "key": "A9xRJNMYGwRhBDTORYzsYEy0G2vS4OqVG5HDJjvA71UP" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_DIRECT" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [ - { - "denom": "utac", - "amount": "5000000000000000" - } - ], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "Dci0BPv2IB//nKbOX9u7oDhIs0JgQ3kw1O/uqSZZbDZidLVyQl49Xt6U4MElUGD/wuvlgGuCA7EeI8L9rKUyfgE=" - ] - } - ] - }, - "gov": { - "starting_proposal_id": "1", - "deposits": [], - "votes": [], - "proposals": [], - "deposit_params": null, - "voting_params": null, - "tally_params": null, - "params": { - "min_deposit": [ - { - "denom": "utac", - "amount": "10000000000000000" - } - ], - "max_deposit_period": "172800s", - "voting_period": "900s", - "quorum": "0.334000000000000000", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000", - "min_initial_deposit_ratio": "1", - "proposal_cancel_ratio": "0.500000000000000000", - "proposal_cancel_dest": "", - "expedited_voting_period": "450s", - "expedited_threshold": "0.667000000000000000", - "expedited_min_deposit": [ - { - "denom": "utac", - "amount": "50000000000000000" - } - ], - "burn_vote_quorum": false, - "burn_proposal_deposit_prevote": false, - "burn_vote_veto": true, - "min_deposit_ratio": "0.010000000000000000" - }, - "constitution": "" - }, - "group": { - "group_seq": "0", - "groups": [], - "group_members": [], - "group_policy_seq": "0", - "group_policies": [], - "proposal_seq": "0", - "proposals": [], - "votes": [] - }, - "ibc": { - "client_genesis": { - "clients": [], - "clients_consensus": [], - "clients_metadata": [], - "params": { - "allowed_clients": [ - "*" - ] - }, - "create_localhost": false, - "next_client_sequence": "0" - }, - "connection_genesis": { - "connections": [], - "client_connection_paths": [], - "next_connection_sequence": "0", - "params": { - "max_expected_time_per_block": "30000000000" - } - }, - "channel_genesis": { - "channels": [], - "acknowledgements": [], - "commitments": [], - "receipts": [], - "send_sequences": [], - "recv_sequences": [], - "ack_sequences": [], - "next_channel_sequence": "0", - "params": { - "upgrade_timeout": { - "height": { - "revision_number": "0", - "revision_height": "0" - }, - "timestamp": "600000000000" - } - } - } - }, - "interchainaccounts": { - "controller_genesis_state": { - "active_channels": [], - "interchain_accounts": [], - "ports": [], - "params": { - "controller_enabled": true - } - }, - "host_genesis_state": { - "active_channels": [], - "interchain_accounts": [], - "port": "icahost", - "params": { - "host_enabled": true, - "allow_messages": [ - "*" - ] - } - } - }, - "liquidstake": { - "params": { - "liquid_bond_denom": "ugtac", - "whitelisted_validators": [], - "unstake_fee_rate": "0.000000000000000000", - "lsm_disabled": false, - "min_liquid_stake_amount": "1000", - "cw_locked_pool_address": "", - "fee_account_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", - "autocompound_fee_rate": "0.050000000000000000", - "whitelist_admin_address": "", - "module_paused": true - }, - "liquid_validators": [] - }, - "mint": { - "minter": { - "inflation": "0.130000000000000000", - "annual_provisions": "0.000000000000000000" - }, - "params": { - "mint_denom": "utac", - "inflation_rate_change": "0.130000000000000000", - "inflation_max": "0.05", - "inflation_min": "0.01", - "goal_bonded": "0.6", - "blocks_per_year": "15768000" - } - }, - "nft": { - "classes": [], - "entries": [] - }, - "params": null, - "slashing": { - "params": { - "signed_blocks_window": "21600", - "min_signed_per_window": "0.500000000000000000", - "downtime_jail_duration": "600s", - "slash_fraction_double_sign": "0.050000000000000000", - "slash_fraction_downtime": "0.001" - }, - "signing_infos": [], - "missed_blocks": [] - }, - "staking": { - "params": { - "unbonding_time": "1814400s", - "max_validators": 14, - "max_entries": 7, - "historical_entries": 10000, - "bond_denom": "utac", - "min_commission_rate": "0.000000000000000000" - }, - "last_total_power": "0", - "last_validator_powers": [], - "validators": [], - "delegations": [], - "unbonding_delegations": [], - "redelegations": [], - "exported": false - }, - "transfer": { - "port_id": "transfer", - "denom_traces": [], - "params": { - "send_enabled": true, - "receive_enabled": true - }, - "total_escrowed": [] - }, - "upgrade": {}, - "vesting": {} - }, - "consensus": { - "params": { - "block": { - "max_bytes": "22020096", - "max_gas": "90000000" - }, - "evidence": { - "max_age_num_blocks": "100000", - "max_age_duration": "172800000000000", - "max_bytes": "1048576" - }, - "validator": { - "pub_key_types": [ - "ed25519" - ] - }, - "version": { - "app": "0" - }, - "abci": { - "vote_extensions_enable_height": "0" - } - } - } -} \ No newline at end of file From f84b816b91f161ddcc4fe8b3e23587f54e7d71dc Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Mon, 30 Jun 2025 15:47:42 +0200 Subject: [PATCH 047/112] [TAC-46]: change node_id --- docker-compose-node-2.yml | 2 +- settings-ci.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose-node-2.yml b/docker-compose-node-2.yml index b09aaef..5330150 100644 --- a/docker-compose-node-2.yml +++ b/docker-compose-node-2.yml @@ -35,4 +35,4 @@ services: - RPC_LADDR=tcp://0.0.0.0:26657 - JSON_RPC_ADDR=0.0.0.0:8545 - JSON_RPC_WS_ADDR=0.0.0.0:8546 - - P2P_PERSISTENT_PEERS=e118baea3163d72bae6137977d4473d244af2b43@192.168.64.223:26656 \ No newline at end of file + - P2P_PERSISTENT_PEERS=be386c9b65213011522782ddccd5147f7a8093e8@192.168.64.223:26656 \ No newline at end of file diff --git a/settings-ci.yml b/settings-ci.yml index 4136eb0..16942f0 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -9,6 +9,7 @@ deploy: docker_compose_file: docker-compose-node-1.yml runner_tags: - tac-localchain-1 + manual: true tacchain-node-2: branch: localnet docker_compose: true From 7f54ba847e04af375c11fdb5b8559cae06280069 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Mon, 30 Jun 2025 19:10:48 +0200 Subject: [PATCH 048/112] [TAC-46]: deploy multi-node chain --- Dockerfile | 1 + contrib/localnet/init-multi-node.sh | 12 +-- docker-compose-node-2.yml | 123 +++++++++++++++++++++++----- 3 files changed, 110 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9ac9b10..0363b83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ FROM ubuntu:22.04 COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind # To run a localnet -------------------------------------- COPY --from=go-builder /code/contrib/localnet/init.sh /scripts/init.sh +COPY --from=go-builder /code/contrib/localnet/init-multi-node.sh /scripts/init-multi-node.sh COPY --from=go-builder /code/contrib/localnet/start.sh /scripts/start.sh COPY --from=go-builder /code/contrib/localnet/start-additional-node.sh /scripts/start-additional-node.sh RUN chmod +x /scripts/*.sh diff --git a/contrib/localnet/init-multi-node.sh b/contrib/localnet/init-multi-node.sh index 12fce53..b9763fa 100755 --- a/contrib/localnet/init-multi-node.sh +++ b/contrib/localnet/init-multi-node.sh @@ -30,12 +30,12 @@ export SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} export SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} export MAX_VALIDATORS=${MAX_VALIDATORS:-14} -# prompt user for confirmation before cleanup -read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm -if [[ $confirm != "y" && $confirm != "Y" ]]; then - echo "Cleanup aborted." - exit 1 -fi +# # prompt user for confirmation before cleanup +# read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm +# if [[ $confirm != "y" && $confirm != "Y" ]]; then +# echo "Cleanup aborted." +# exit 1 +# fi # cleanup old data rm -rf $HOMEDIR diff --git a/docker-compose-node-2.yml b/docker-compose-node-2.yml index 5330150..5271355 100644 --- a/docker-compose-node-2.yml +++ b/docker-compose-node-2.yml @@ -1,38 +1,121 @@ services: - tac-localnet-init: + init: image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" - entrypoint: sh - command: /scripts/init.sh + entrypoint: bash + command: /scripts/init-multi-node.sh environment: + - CHAIN_ID=tacchain_2391-1 - MONIKER=tac-validator - HOMEDIR=/tacchain_data - tac-localnet-validator: + node1: network_mode: host restart: unless-stopped image: ${IMAGE} ports: - - "26656:26656" # P2P - - "26657:26657" # RPC - - "1317:1317" # REST - - "8545:8545" # RPC_EVM - - "8546:8546" # WS_EVM - - "9090:9090" # gRPC + - "45110:45110" # P2P + - "45111:45111" # RPC + - "45112:45112" # REST + - "45118:45118" # RPC_EVM + - "45119:45119" # WS_EVM volumes: - - "/mnt/data:/tacchain_data" + - "/mnt/data/node0:/tacchain_data/node0" depends_on: - tac-localnet-init: + init: condition: service_completed_successfully entrypoint: sh - command: /scripts/start-additional-node.sh + command: /scripts/start.sh environment: + - CHAIN_ID=tacchain_2391-1 - MONIKER=tac-validator - - HOMEDIR=/tacchain_data - - P2P_LADDR=tcp://0.0.0.0:26656 - - P2P_EXTERNAL_ADDRESS=0.0.0.0:26656 - - RPC_LADDR=tcp://0.0.0.0:26657 - - JSON_RPC_ADDR=0.0.0.0:8545 - - JSON_RPC_WS_ADDR=0.0.0.0:8546 - - P2P_PERSISTENT_PEERS=be386c9b65213011522782ddccd5147f7a8093e8@192.168.64.223:26656 \ No newline at end of file + - HOMEDIR=/tacchain_data/node0 + - P2P_LADDR=tcp://0.0.0.0:45110 + - P2P_EXTERNAL_ADDRESS=0.0.0.0:45110 + - RPC_LADDR=tcp://0.0.0.0:45111 + - JSON_RPC_ADDR=0.0.0.0:45118 + - JSON_RPC_WS_ADDR=0.0.0.0:45119 + + node2: + network_mode: host + restart: unless-stopped + image: ${IMAGE} + ports: + - "45120:45120" # P2P + - "45121:45121" # RPC + - "45122:45122" # REST + - "45128:45128" # RPC_EVM + - "45129:45129" # WS_EVM + volumes: + - "/mnt/data/node1:/tacchain_data/node1" + depends_on: + init: + condition: service_completed_successfully + entrypoint: sh + command: /scripts/start.sh + environment: + - CHAIN_ID=tacchain_2391-1 + - MONIKER=tac-validator + - HOMEDIR=/tacchain_data/node1 + - P2P_LADDR=tcp://0.0.0.0:45120 + - P2P_EXTERNAL_ADDRESS=0.0.0.0:45120 + - RPC_LADDR=tcp://0.0.0.0:45121 + - JSON_RPC_ADDR=0.0.0.0:45128 + - JSON_RPC_WS_ADDR=0.0.0.0:45129 + + node3: + network_mode: host + restart: unless-stopped + image: ${IMAGE} + ports: + - "45130:45130" # P2P + - "45131:45131" # RPC + - "45132:45132" # REST + - "45138:45138" # RPC_EVM + - "45139:45139" # WS_EVM + volumes: + - "/mnt/data/node2:/tacchain_data/node2" + depends_on: + init: + condition: service_completed_successfully + entrypoint: sh + command: /scripts/start.sh + environment: + - CHAIN_ID=tacchain_2391-1 + - MONIKER=tac-validator + - HOMEDIR=/tacchain_data/node2 + - P2P_LADDR=tcp://0.0.0.0:45130 + - P2P_EXTERNAL_ADDRESS=0.0.0.0:45130 + - RPC_LADDR=tcp://0.0.0.0:45131 + - JSON_RPC_ADDR=0.0.0.0:45138 + - JSON_RPC_WS_ADDR=0.0.0.0:45139 + + node4: + network_mode: host + restart: unless-stopped + build: + dockerfile: Dockerfile + context: . + ports: + - "45140:45140" # P2P + - "45141:45141" # RPC + - "45142:45142" # REST + - "45148:45148" # RPC_EVM + - "45149:45149" # WS_EVM + volumes: + - "/mnt/data/node3:/tacchain_data/node3" + depends_on: + init: + condition: service_completed_successfully + entrypoint: sh + command: /scripts/start.sh + environment: + - CHAIN_ID=tacchain_2391-1 + - MONIKER=tac-validator + - HOMEDIR=/tacchain_data/node3 + - P2P_LADDR=tcp://0.0.0.0:45140 + - P2P_EXTERNAL_ADDRESS=0.0.0.0:45140 + - RPC_LADDR=tcp://0.0.0.0:45141 + - JSON_RPC_ADDR=0.0.0.0:45148 + - JSON_RPC_WS_ADDR=0.0.0.0:45149 \ No newline at end of file From e5f912f36b3c60429d7381b07b8ba6125f0a0114 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Mon, 30 Jun 2025 19:19:50 +0200 Subject: [PATCH 049/112] [TAC-46]: deploy multi-node chain #1 --- docker-compose-node-2.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose-node-2.yml b/docker-compose-node-2.yml index 5271355..4b4710b 100644 --- a/docker-compose-node-2.yml +++ b/docker-compose-node-2.yml @@ -94,9 +94,7 @@ services: node4: network_mode: host restart: unless-stopped - build: - dockerfile: Dockerfile - context: . + image: ${IMAGE} ports: - "45140:45140" # P2P - "45141:45141" # RPC From f0d63626bd0860392d2f66f9ff35e257e619354b Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Mon, 30 Jun 2025 20:45:28 +0200 Subject: [PATCH 050/112] [TAC-46]: deploy localchain with 4 node-validators --- docker-compose-node-1.yml | 37 ------------------- ...r-compose-node-2.yml => docker-compose.yml | 8 ++-- settings-ci.yml | 10 +---- 3 files changed, 5 insertions(+), 50 deletions(-) delete mode 100644 docker-compose-node-1.yml rename docker-compose-node-2.yml => docker-compose.yml (98%) diff --git a/docker-compose-node-1.yml b/docker-compose-node-1.yml deleted file mode 100644 index c1013f7..0000000 --- a/docker-compose-node-1.yml +++ /dev/null @@ -1,37 +0,0 @@ -services: - tac-localnet-init: - image: ${IMAGE} - volumes: - - "/mnt/data:/tacchain_data" - entrypoint: sh - command: /scripts/init.sh - environment: - - MONIKER=tac-validator - - HOMEDIR=/tacchain_data - - tac-localnet-validator: - network_mode: host - restart: unless-stopped - image: ${IMAGE} - ports: - - "26656:26656" # P2P - - "26657:26657" # RPC - - "1317:1317" # REST - - "8545:8545" # RPC_EVM - - "8546:8546" # WS_EVM - - "9090:9090" # gRPC - volumes: - - "/mnt/data:/tacchain_data" - depends_on: - tac-localnet-init: - condition: service_completed_successfully - entrypoint: sh - command: /scripts/start.sh - environment: - - MONIKER=tac-validator - - HOMEDIR=/tacchain_data - - P2P_LADDR=tcp://0.0.0.0:26656 - - P2P_EXTERNAL_ADDRESS=0.0.0.0:26656 - - RPC_LADDR=tcp://0.0.0.0:26657 - - JSON_RPC_ADDR=0.0.0.0:8545 - - JSON_RPC_WS_ADDR=0.0.0.0:8546 \ No newline at end of file diff --git a/docker-compose-node-2.yml b/docker-compose.yml similarity index 98% rename from docker-compose-node-2.yml rename to docker-compose.yml index 4b4710b..22f5b12 100644 --- a/docker-compose-node-2.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - MONIKER=tac-validator - HOMEDIR=/tacchain_data - node1: + validator-1: network_mode: host restart: unless-stopped image: ${IMAGE} @@ -37,7 +37,7 @@ services: - JSON_RPC_ADDR=0.0.0.0:45118 - JSON_RPC_WS_ADDR=0.0.0.0:45119 - node2: + validator-2: network_mode: host restart: unless-stopped image: ${IMAGE} @@ -64,7 +64,7 @@ services: - JSON_RPC_ADDR=0.0.0.0:45128 - JSON_RPC_WS_ADDR=0.0.0.0:45129 - node3: + validator-3: network_mode: host restart: unless-stopped image: ${IMAGE} @@ -91,7 +91,7 @@ services: - JSON_RPC_ADDR=0.0.0.0:45138 - JSON_RPC_WS_ADDR=0.0.0.0:45139 - node4: + validator-4: network_mode: host restart: unless-stopped image: ${IMAGE} diff --git a/settings-ci.yml b/settings-ci.yml index 16942f0..a407c0c 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -3,17 +3,9 @@ trufflehog_ignore: true deploy: environment: - tacchain-node-1: + tacchain: branch: localnet docker_compose: true - docker_compose_file: docker-compose-node-1.yml - runner_tags: - - tac-localchain-1 - manual: true - tacchain-node-2: - branch: localnet - docker_compose: true - docker_compose_file: docker-compose-node-2.yml runner_tags: - tac-localchain-2 manual: true From e17bf3972185a6e777661cea787534304b2d09b4 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 8 Jul 2025 19:47:41 +0300 Subject: [PATCH 051/112] feat: added web3Tx extension to implement eip-712 tx --- app/ante.go | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/app/ante.go b/app/ante.go index 19494c3..efb1e8c 100644 --- a/app/ante.go +++ b/app/ante.go @@ -83,9 +83,18 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { options.MaxTxGasWanted, ), ) + case "/cosmos.evm.types.v1.ExtensionOptionsWeb3Tx": + // handle as normal Cosmos SDK tx, except signature is checked for EIP712 representation + anteHandler, err = newCosmosAnteHandler(cosmosHandlerOptions{ + HandlerOptions: options, + isEIP712: true, + }) case "/cosmos.evm.types.v1.ExtensionOptionDynamicFeeTx": // cosmos-sdk tx with dynamic fee extension - anteHandler, err = newCosmosAnteHandler(options) + anteHandler, err = newCosmosAnteHandler(cosmosHandlerOptions{ + HandlerOptions: options, + isEIP712: false, + }) default: return ctx, errors.New(fmt.Sprintf("rejecting tx with unsupported extension option: %s", typeURL)) } @@ -101,7 +110,10 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { // handle as totally normal Cosmos SDK tx switch tx.(type) { case sdk.Tx: - anteHandler, err = newCosmosAnteHandler(options) + anteHandler, err = newCosmosAnteHandler(cosmosHandlerOptions{ + HandlerOptions: options, + isEIP712: false, + }) default: return ctx, errors.New("invalid transaction type") } @@ -114,8 +126,14 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { }, nil } -func newCosmosAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { - return sdk.ChainAnteDecorators( +// cosmosHandlerOptions extends HandlerOptions to provide some Cosmos specific configurations +type cosmosHandlerOptions struct { + HandlerOptions + isEIP712 bool +} + +func newCosmosAnteHandler(options cosmosHandlerOptions) (sdk.AnteHandler, error) { + decorators := []sdk.AnteDecorator{ evmcosmosante.NewRejectMessagesDecorator(), // reject MsgEthereumTxs evmcosmosante.NewAuthzLimiterDecorator( // disable the Msg types that cannot be included on an authz.MsgExec msgs field sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}), @@ -123,7 +141,7 @@ func newCosmosAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ), authante.NewSetUpContextDecorator(), circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), - authante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), + // authante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), authante.NewValidateBasicDecorator(), authante.NewTxTimeoutHeightDecorator(), authante.NewValidateMemoDecorator(options.AccountKeeper), @@ -134,9 +152,21 @@ func newCosmosAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { authante.NewSetPubKeyDecorator(options.AccountKeeper), authante.NewValidateSigCountDecorator(options.AccountKeeper), authante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), - authante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), + } + if !options.isEIP712 { + decorators = append(decorators, authante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker)) + } + var sigVerification sdk.AnteDecorator = authante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler) + if options.isEIP712 { + sigVerification = evmcosmosante.NewLegacyEip712SigVerificationDecorator(options.AccountKeeper) + } + decorators = append(decorators, sigVerification) + + decorators = append(decorators, authante.NewIncrementSequenceDecorator(options.AccountKeeper), ibcante.NewRedundantRelayDecorator(options.IBCKeeper), evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper), - ), nil + ) + + return sdk.ChainAnteDecorators(decorators...), nil } From cd91ec434d85eb3259c4f0ec64036960410d5faa Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Mon, 30 Jun 2025 19:20:42 +0300 Subject: [PATCH 052/112] testing migration --- app/upgrades.go | 3 +++ app/upgrades/liquidstake/upgrades.go | 33 ++++++++++++++++++++++++++++ app/upgrades/types.go | 3 +++ app/upgrades/v0.0.11/upgrades.go | 2 +- contrib/localnet/init.sh | 4 ++-- contrib/localnet/vote.sh | 19 ++++++++++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 app/upgrades/liquidstake/upgrades.go create mode 100755 contrib/localnet/vote.sh diff --git a/app/upgrades.go b/app/upgrades.go index 8be4129..f3f2701 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -9,6 +9,7 @@ import ( v0010 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.10" v0011 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.11" v009 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.9" + liquidstake_upgrade "github.com/Asphere-xyz/tacchain/app/upgrades/liquidstake" ) // Upgrades list of chain upgrades @@ -16,6 +17,7 @@ var Upgrades = []upgrades.Upgrade{ v009.Upgrade, v0010.Upgrade, v0011.Upgrade, + liquidstake_upgrade.Upgrade, } // RegisterUpgradeHandlers registers the chain upgrade handlers @@ -28,6 +30,7 @@ func (app *TacChainApp) RegisterUpgradeHandlers() { IBCKeeper: app.IBCKeeper, Codec: app.appCodec, GetStoreKey: app.GetKey, + LiquidsStakeKeeper: &app.LiquidStakeKeeper, } app.GetStoreKeys() // register all upgrade handlers diff --git a/app/upgrades/liquidstake/upgrades.go b/app/upgrades/liquidstake/upgrades.go new file mode 100644 index 0000000..8a666b2 --- /dev/null +++ b/app/upgrades/liquidstake/upgrades.go @@ -0,0 +1,33 @@ +package liquidstake_upgrade + +import ( + "context" + + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + + "github.com/Asphere-xyz/tacchain/app/upgrades" + "github.com/cosmos/cosmos-sdk/types/module" +) + +// UpgradeName defines the on-chain upgrade name +const UpgradeName = "liquidstake" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{ + Added: []string{"liquidstake"}, + Deleted: []string{}, + }, +} + +func CreateUpgradeHandler( + mm upgrades.ModuleManager, + configurator module.Configurator, + ak *upgrades.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, fromVM) + } +} diff --git a/app/upgrades/types.go b/app/upgrades/types.go index fb365af..8decc4b 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -14,6 +14,8 @@ import ( authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + + liquidstakekeeper "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" ) type AppKeepers struct { @@ -24,6 +26,7 @@ type AppKeepers struct { GetStoreKey func(storeKey string) *storetypes.KVStoreKey CapabilityKeeper *capabilitykeeper.Keeper IBCKeeper *ibckeeper.Keeper + LiquidsStakeKeeper *liquidstakekeeper.Keeper } type ModuleManager interface { diff --git a/app/upgrades/v0.0.11/upgrades.go b/app/upgrades/v0.0.11/upgrades.go index c4655ee..860b82d 100644 --- a/app/upgrades/v0.0.11/upgrades.go +++ b/app/upgrades/v0.0.11/upgrades.go @@ -1,4 +1,4 @@ -package v010 +package v011 import ( "context" diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index 554371c..91e0668 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -14,7 +14,7 @@ INITIAL_STAKE=${INITIAL_STAKE:-1000000000000000000000} BLOCK_TIME_SECONDS=${BLOCK_TIME_SECONDS:-2} MAX_GAS=${MAX_GAS:-90000000} MIN_GAS_PRICE=${MIN_GAS_PRICE:-25000000000} -GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-900} +GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-15} GOV_MIN_DEPOSIT=${GOV_MIN_DEPOSIT:-10000000000000000} GOV_MIN_EXPEDITED_DEPOSIT=${GOV_MIN_EXPEDITED_DEPOSIT:-50000000000000000} GOV_MIN_INITIAL_DEPOSIT_RATIO=${GOV_MIN_INITIAL_DEPOSIT_RATIO:-1} @@ -246,4 +246,4 @@ sed -i.bak "s/26658/$PROXY_PORT/g" $HOMEDIR/config/config.toml echo $VALIDATOR_MNEMONIC | $TACCHAIND keys add validator --recover --keyring-backend $KEYRING_BACKEND --home $HOMEDIR $TACCHAIND genesis add-genesis-account validator ${INITIAL_BALANCE}utac --keyring-backend $KEYRING_BACKEND --home $HOMEDIR $TACCHAIND genesis gentx validator ${INITIAL_STAKE}utac --identity $VALIDATOR_IDENTITY --website $VALIDATOR_WEBSITE --chain-id $CHAIN_ID --keyring-backend $KEYRING_BACKEND --gas-prices ${MIN_GAS_PRICE}utac --gas 200000 --home $HOMEDIR -$TACCHAIND genesis collect-gentxs --keyring-backend $KEYRING_BACKEND --home $HOMEDIR \ No newline at end of file +$TACCHAIND genesis collect-gentxs --keyring-backend $KEYRING_BACKEND --home $HOMEDIR diff --git a/contrib/localnet/vote.sh b/contrib/localnet/vote.sh new file mode 100755 index 0000000..555efd5 --- /dev/null +++ b/contrib/localnet/vote.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +hash = tacchaind tx upgrade software-upgrade liquidstake \ + --upgrade-height ${1} \ + --title "Liquidstake Module Upgrade" \ + --summary "Upgrade to add liquidstake functionality" \ + --upgrade-info '{}' \ + --no-validate \ + --deposit "10000000000000000utac" \ + --from validator \ + --gas-prices "25000000000utac" \ + --yes | jq -r ".hash" + +tacchain query tx BD49A41AF9568C12E90B67F5DB50D973FF2BB88784BFFED0C71C2F4967F9C4CA | jq -r ".raw_log" + +sleep .5 + +tacchaind tx gov vote ${2} yes --from validator --gas-prices "25000000000utac" --yes + From e2c2e1a4b25a9d9fc3beaf2e53fff90ccdc9a024 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Tue, 1 Jul 2025 12:58:18 +0300 Subject: [PATCH 053/112] rstore vote --- contrib/localnet/vote.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/localnet/vote.sh b/contrib/localnet/vote.sh index 555efd5..1a3c9e2 100755 --- a/contrib/localnet/vote.sh +++ b/contrib/localnet/vote.sh @@ -1,6 +1,6 @@ #!/bin/bash -hash = tacchaind tx upgrade software-upgrade liquidstake \ +tacchaind tx upgrade software-upgrade liquidstake \ --upgrade-height ${1} \ --title "Liquidstake Module Upgrade" \ --summary "Upgrade to add liquidstake functionality" \ @@ -11,8 +11,6 @@ hash = tacchaind tx upgrade software-upgrade liquidstake \ --gas-prices "25000000000utac" \ --yes | jq -r ".hash" -tacchain query tx BD49A41AF9568C12E90B67F5DB50D973FF2BB88784BFFED0C71C2F4967F9C4CA | jq -r ".raw_log" - sleep .5 tacchaind tx gov vote ${2} yes --from validator --gas-prices "25000000000utac" --yes From 4b395c5aebc0cf0808bd497f7a8698ccd64122f8 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Tue, 1 Jul 2025 13:16:45 +0300 Subject: [PATCH 054/112] few fixes --- app/upgrades/liquidstake/upgrades.go | 2 +- x/liquidstake/types/keys.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/upgrades/liquidstake/upgrades.go b/app/upgrades/liquidstake/upgrades.go index 8a666b2..c3a59b8 100644 --- a/app/upgrades/liquidstake/upgrades.go +++ b/app/upgrades/liquidstake/upgrades.go @@ -17,7 +17,7 @@ var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, StoreUpgrades: storetypes.StoreUpgrades{ - Added: []string{"liquidstake"}, + Added: []string{"utacliquidstake"}, Deleted: []string{}, }, } diff --git a/x/liquidstake/types/keys.go b/x/liquidstake/types/keys.go index 9935daa..ac6abf1 100644 --- a/x/liquidstake/types/keys.go +++ b/x/liquidstake/types/keys.go @@ -14,7 +14,7 @@ const ( // StoreKey is the default store key for the liquidstake module // To avoid collision with liquidstakeibc we make it xprtliquidstake - StoreKey = "xprt" + ModuleName + StoreKey = "utac" + ModuleName // QuerierRoute is the querier route for the liquidstake module QuerierRoute = ModuleName From 23f2de9f5c5def2b593d63012bb413d78c8f0d60 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Wed, 9 Jul 2025 14:08:17 +0300 Subject: [PATCH 055/112] draft: updated script for init multinode --- .../init-liquidstake-for-multinode.sh | 316 ++++++++++++++++++ contrib/localnet/init-multi-node.sh | 58 ++-- 2 files changed, 345 insertions(+), 29 deletions(-) create mode 100644 contrib/localnet/init-liquidstake-for-multinode.sh diff --git a/contrib/localnet/init-liquidstake-for-multinode.sh b/contrib/localnet/init-liquidstake-for-multinode.sh new file mode 100644 index 0000000..9e9069a --- /dev/null +++ b/contrib/localnet/init-liquidstake-for-multinode.sh @@ -0,0 +1,316 @@ +#!/bin/bash -e + +# environment variables +TACCHAIND=${TACCHAIND:-$(which tacchaind)} +HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} +NODE_MONIKER=${NODE_MONIKER:-$(hostname)} +CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} +KEYRING_BACKEND=${KEYRING_BACKEND:-test} +VALIDATOR_IDENTITY=${VALIDATOR_IDENTITY:-4DD1A5E1D03FA12D} +VALIDATOR_WEBSITE=${VALIDATOR_WEBSITE:-https://tac.build/} +VALIDATOR_MNEMONIC=${VALIDATOR_MNEMONIC:-"island mail dice alien project surround orchard ball twist worth innocent arrange assume dragon rotate enough flee rapid rookie swim addict ice destroy run"} # tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr +INITIAL_BALANCE=${INITIAL_BALANCE:-2000000000000000000000} +INITIAL_STAKE=${INITIAL_STAKE:-1000000000000000000000} +BLOCK_TIME_SECONDS=${BLOCK_TIME_SECONDS:-2} +MAX_GAS=${MAX_GAS:-90000000} +MIN_GAS_PRICE=${MIN_GAS_PRICE:-25000000000} +GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-900} +GOV_MIN_DEPOSIT=${GOV_MIN_DEPOSIT:-10000000000000000} +GOV_MIN_EXPEDITED_DEPOSIT=${GOV_MIN_EXPEDITED_DEPOSIT:-50000000000000000} +GOV_MIN_INITIAL_DEPOSIT_RATIO=${GOV_MIN_INITIAL_DEPOSIT_RATIO:-1} +INFLATION_MAX=${INFLATION_MAX:-0.05} +INFLATION_MIN=${INFLATION_MIN:-0.01} +GOAL_BONDED=${GOAL_BONDED:-0.6} +SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} +SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} +MAX_VALIDATORS=${MAX_VALIDATORS:-14} + +# ports +RPC_PORT=${RPC_PORT:-26657} +P2P_PORT=${P2P_PORT:-26656} +GRPC_PORT=${GRPC_PORT:-9090} +GRPC_WEB_PORT=${GRPC_WEB_PORT:-9091} +API_PORT=${API_PORT:-1317} +JSON_RPC_PORT=${JSON_RPC_PORT:-8545} +JSON_WS_PORT=${JSON_WS_PORT:-8546} +METRICS_PORT=${METRICS_PORT:-6065} +PROMETHEUS_PORT=${PROMETHEUS_PORT:-26660} +PPROF_PORT=${PPROF_PORT:-6060} +PROXY_PORT=${PROXY_PORT:-26658} + +# prompt user for confirmation before cleanup +read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm +if [[ $confirm != "y" && $confirm != "Y" ]]; then + echo "Cleanup aborted." + exit 1 +fi + +# cleanup old data +rm -rf $HOMEDIR + +# set cli options default values +$TACCHAIND config set client chain-id $CHAIN_ID +$TACCHAIND config set client keyring-backend $KEYRING_BACKEND +$TACCHAIND config set client output json + +# init genesis file +$TACCHAIND init "$NODE_MONIKER" --chain-id $CHAIN_ID --default-denom utac --home $HOMEDIR + +# predeployed contracts (all precompiled contracts need to be defined before genesis accounts to avoid issues with auth account_numbers) +# safe singleton factory (https://github.com/safe-global/safe-singleton-factory) +jq ' + .app_state.auth.accounts += [{ + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1j9xhlmr24jxd2sh890983vcx2r29vs7hc7xaks", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }] + | .app_state.evm.accounts += [{ + "address": "0x914d7fec6aac8cd542e72bca78b30650d45643d7", + "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", + "storage": [] + }] +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +# arachnid (https://github.com/Arachnid/deterministic-deployment-proxy) +jq ' + .app_state.auth.accounts += [{ + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1fevmgjz8kdu40pvgjgx20ralymqtf9tv2r6x6q", + "pub_key": null, + "account_number": "1", + "sequence": "0" + }] + | .app_state.evm.accounts += [{ + "address": "0x4e59b44847b379578588920ca78fbf26c0b4956c", + "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", + "storage": [] + }] +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +# multicall (https://github.com/mds1/multicall3) +jq ' + .app_state.auth.accounts += [{ + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1eggmmczew7ekxyt8q2yx9032zuuhdjs3yd8s2h", + "pub_key": null, + "account_number": "2", + "sequence": "0" + }] + | .app_state.evm.accounts += [{ + "address": "0xca11bde05977b3631167028862be2a173976ca11", + "code": "6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", + "storage": [] + }] +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +# createx (https://github.com/pcaversaccio/createx) +jq ' + .app_state.auth.accounts += [{ + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "tac1hf0dpxtr85anz0jdtaaacyc960pghf0draedhx", + "pub_key": null, + "account_number": "3", + "sequence": "0" + }] + | .app_state.evm.accounts += [{ + "address": "0xba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed", + "code": "60806040526004361061018a5760003560e01c806381503da1116100d6578063d323826a1161007f578063e96deee411610059578063e96deee414610395578063f5745aba146103a8578063f9664498146103bb57600080fd5b8063d323826a1461034f578063ddda0acb1461036f578063e437252a1461038257600080fd5b80639c36a286116100b05780639c36a28614610316578063a7db93f214610329578063c3fe107b1461033c57600080fd5b806381503da1146102d0578063890c283b146102e357806398e810771461030357600080fd5b80632f990e3f116101385780636cec2536116101125780636cec25361461027d57806374637a7a1461029d5780637f565360146102bd57600080fd5b80632f990e3f1461023757806331a7c8c81461024a57806342d654fc1461025d57600080fd5b806327fe18221161016957806327fe1822146101f15780632852527a1461020457806328ddd0461461021757600080fd5b8062d84acb1461018f57806326307668146101cb57806326a32fc7146101de575b600080fd5b6101a261019d366004612915565b6103ce565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6101a26101d9366004612994565b6103e6565b6101a26101ec3660046129db565b610452565b6101a26101ff3660046129db565b6104de565b6101a2610212366004612a39565b610539565b34801561022357600080fd5b506101a2610232366004612a90565b6106fe565b6101a2610245366004612aa9565b61072a565b6101a2610258366004612aa9565b6107bb565b34801561026957600080fd5b506101a2610278366004612b1e565b6107c9565b34801561028957600080fd5b506101a2610298366004612a90565b610823565b3480156102a957600080fd5b506101a26102b8366004612b4a565b61084f565b6101a26102cb3660046129db565b611162565b6101a26102de366004612b74565b6111e8565b3480156102ef57600080fd5b506101a26102fe366004612bac565b611276565b6101a2610311366004612bce565b6112a3565b6101a2610324366004612994565b611505565b6101a2610337366004612c49565b6116f1565b6101a261034a366004612aa9565b611964565b34801561035b57600080fd5b506101a261036a366004612cd9565b6119ed565b6101a261037d366004612c49565b611a17565b6101a2610390366004612bce565b611e0c565b6101a26103a3366004612915565b611e95565b6101a26103b6366004612bce565b611ea4565b6101a26103c9366004612b74565b611f2d565b60006103dd8585858533611a17565b95945050505050565b6000806103f2846120db565b90508083516020850134f59150610408826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a35092915050565b60006104d86104d260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b836103e6565b92915050565b600081516020830134f090506104f3816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a2919050565b600080610545856120db565b905060008460601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f593505073ffffffffffffffffffffffffffffffffffffffff8316610635576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1660048201526024015b60405180910390fd5b604051829073ffffffffffffffffffffffffffffffffffffffff8516907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808473ffffffffffffffffffffffffffffffffffffffff1634876040516106a19190612d29565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b50915091506106f382828961247d565b505050509392505050565b60006104d87f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed8361084f565b60006107b36107aa60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b85858533611a17565b949350505050565b60006107b3848484336112a3565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b60006104d8827f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6107c9565b600060607f9400000000000000000000000000000000000000000000000000000000000000610887600167ffffffffffffffff612d45565b67ffffffffffffffff16841115610902576040517f3c55ab3b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b836000036109c7576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f800000000000000000000000000000000000000000000000000000000000000060368201526037015b6040516020818303038152906040529150611152565b607f8411610a60576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b16602283015260f886901b1660368201526037016109b1565b60ff8411610b1f576040517fd70000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660228301527f8100000000000000000000000000000000000000000000000000000000000000603683015260f886901b1660378201526038016109b1565b61ffff8411610bff576040517fd80000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f820000000000000000000000000000000000000000000000000000000000000060368201527fffff00000000000000000000000000000000000000000000000000000000000060f086901b1660378201526039016109b1565b62ffffff8411610ce0576040517fd90000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f830000000000000000000000000000000000000000000000000000000000000060368201527fffffff000000000000000000000000000000000000000000000000000000000060e886901b166037820152603a016109b1565b63ffffffff8411610dc2576040517fda0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f840000000000000000000000000000000000000000000000000000000000000060368201527fffffffff0000000000000000000000000000000000000000000000000000000060e086901b166037820152603b016109b1565b64ffffffffff8411610ea5576040517fdb0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f850000000000000000000000000000000000000000000000000000000000000060368201527fffffffffff00000000000000000000000000000000000000000000000000000060d886901b166037820152603c016109b1565b65ffffffffffff8411610f89576040517fdc0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f860000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffff000000000000000000000000000000000000000000000000000060d086901b166037820152603d016109b1565b66ffffffffffffff841161106e576040517fdd0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f870000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffff0000000000000000000000000000000000000000000000000060c886901b166037820152603e016109b1565b6040517fde0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f880000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffffff00000000000000000000000000000000000000000000000060c086901b166037820152603f0160405160208183030381529060405291505b5080516020909101209392505050565b60006104d86111e260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b83611505565b600061126f61126860408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b8484610539565b9392505050565b600061126f83837f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6119ed565b60008451602086018451f090506112b9816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808273ffffffffffffffffffffffffffffffffffffffff168560200151876040516113279190612d29565b60006040518083038185875af1925050503d8060008114611364576040519150601f19603f3d011682016040523d82523d6000602084013e611369565b606091505b5091509150816113c9577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1631156114fb578373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611495576040519150601f19603f3d011682016040523d82523d6000602084013e61149a565b606091505b509092509050816114fb577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b5050949350505050565b600080611511846120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff81166115e0576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a361162c83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1634876040516116569190612d29565b60006040518083038185875af1925050503d8060008114611693576040519150601f19603f3d011682016040523d82523d6000602084013e611698565b606091505b505090506116a681866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a25050505092915050565b6000806116fd876120db565b9050808651602088018651f59150611714826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808373ffffffffffffffffffffffffffffffffffffffff168660200151886040516117849190612d29565b60006040518083038185875af1925050503d80600081146117c1576040519150601f19603f3d011682016040523d82523d6000602084013e6117c6565b606091505b509150915081611826577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611958578473ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d80600081146118f2576040519150601f19603f3d011682016040523d82523d6000602084013e6118f7565b606091505b50909250905081611958577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b50505095945050505050565b60006107b36119e460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b858585336116f1565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b600080611a23876120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff8116611af2576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a3611b3e83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1687600001518a604051611b6c9190612d29565b60006040518083038185875af1925050503d8060008114611ba9576040519150601f19603f3d011682016040523d82523d6000602084013e611bae565b606091505b50509050611bbc81866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a260608573ffffffffffffffffffffffffffffffffffffffff1688602001518a604051611c299190612d29565b60006040518083038185875af1925050503d8060008114611c66576040519150601f19603f3d011682016040523d82523d6000602084013e611c6b565b606091505b50909250905081611ccc577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611dfe578673ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611d98576040519150601f19603f3d011682016040523d82523d6000602084013e611d9d565b606091505b50909250905081611dfe577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050505095945050505050565b60006103dd611e8c60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b868686866116f1565b60006103dd85858585336116f1565b60006103dd611f2460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b86868686611a17565b6000808360601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f092505073ffffffffffffffffffffffffffffffffffffffff8216612016576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b60405173ffffffffffffffffffffffffffffffffffffffff8316907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808373ffffffffffffffffffffffffffffffffffffffff1634866040516120809190612d29565b60006040518083038185875af1925050503d80600081146120bd576040519150601f19603f3d011682016040523d82523d6000602084013e6120c2565b606091505b50915091506120d282828861247d565b50505092915050565b60008060006120e9846125b3565b9092509050600082600281111561210257612102612e02565b1480156121205750600081600281111561211e5761211e612e02565b145b1561215e57604080513360208201524691810191909152606081018590526080016040516020818303038152906040528051906020012092506123cc565b600082600281111561217257612172612e02565b1480156121905750600181600281111561218e5761218e612e02565b145b156121b0576121a9338560009182526020526040902090565b92506123cc565b60008260028111156121c4576121c4612e02565b03612233576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b600182600281111561224757612247612e02565b1480156122655750600081600281111561226357612263612e02565b145b1561227e576121a9468560009182526020526040902090565b600182600281111561229257612292612e02565b1480156122b0575060028160028111156122ae576122ae612e02565b145b1561231f576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b61239a60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b84036123a657836123c9565b604080516020810186905201604051602081830303815290604052805190602001205b92505b5050919050565b73ffffffffffffffffffffffffffffffffffffffff8116158061240b575073ffffffffffffffffffffffffffffffffffffffff81163b155b1561247a576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b50565b82158061249f575073ffffffffffffffffffffffffffffffffffffffff81163b155b156124fa577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed826040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050565b811580612520575073ffffffffffffffffffffffffffffffffffffffff8116155b80612540575073ffffffffffffffffffffffffffffffffffffffff81163b155b156125af576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b5050565b600080606083901c3314801561261057508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b1561262057506000905080915091565b606083901c3314801561265a57507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561266b5750600090506001915091565b33606084901c036126825750600090506002915091565b606083901c1580156126db57508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b156126ec5750600190506000915091565b606083901c15801561272557507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561273557506001905080915091565b606083901c61274a5750600190506002915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000036127a55750600290506000915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000036127e15750600290506001915091565b506002905080915091565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261282c57600080fd5b813567ffffffffffffffff80821115612847576128476127ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561288d5761288d6127ec565b816040528381528660208588010111156128a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000604082840312156128d857600080fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb6127ec565b604052823581526020928301359281019290925250919050565b60008060008060a0858703121561292b57600080fd5b84359350602085013567ffffffffffffffff8082111561294a57600080fd5b6129568883890161281b565b9450604087013591508082111561296c57600080fd5b506129798782880161281b565b92505061298986606087016128c6565b905092959194509250565b600080604083850312156129a757600080fd5b82359150602083013567ffffffffffffffff8111156129c557600080fd5b6129d18582860161281b565b9150509250929050565b6000602082840312156129ed57600080fd5b813567ffffffffffffffff811115612a0457600080fd5b6107b38482850161281b565b803573ffffffffffffffffffffffffffffffffffffffff81168114612a3457600080fd5b919050565b600080600060608486031215612a4e57600080fd5b83359250612a5e60208501612a10565b9150604084013567ffffffffffffffff811115612a7a57600080fd5b612a868682870161281b565b9150509250925092565b600060208284031215612aa257600080fd5b5035919050565b600080600060808486031215612abe57600080fd5b833567ffffffffffffffff80821115612ad657600080fd5b612ae28783880161281b565b94506020860135915080821115612af857600080fd5b50612b058682870161281b565b925050612b1585604086016128c6565b90509250925092565b60008060408385031215612b3157600080fd5b82359150612b4160208401612a10565b90509250929050565b60008060408385031215612b5d57600080fd5b612b6683612a10565b946020939093013593505050565b60008060408385031215612b8757600080fd5b612b9083612a10565b9150602083013567ffffffffffffffff8111156129c557600080fd5b60008060408385031215612bbf57600080fd5b50508035926020909101359150565b60008060008060a08587031215612be457600080fd5b843567ffffffffffffffff80821115612bfc57600080fd5b612c088883890161281b565b95506020870135915080821115612c1e57600080fd5b50612c2b8782880161281b565b935050612c3b86604087016128c6565b915061298960808601612a10565b600080600080600060c08688031215612c6157600080fd5b85359450602086013567ffffffffffffffff80821115612c8057600080fd5b612c8c89838a0161281b565b95506040880135915080821115612ca257600080fd5b50612caf8882890161281b565b935050612cbf87606088016128c6565b9150612ccd60a08701612a10565b90509295509295909350565b600080600060608486031215612cee57600080fd5b8335925060208401359150612b1560408501612a10565b60005b83811015612d20578181015183820152602001612d08565b50506000910152565b60008251612d3b818460208701612d05565b9190910192915050565b67ffffffffffffffff828116828216039080821115612d8d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260008251806040840152612dcf816060850160208701612d05565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea164736f6c6343000817000a", + "storage": [] + }] +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +# edit configs + +# set EVM config +# get ethereum chain id from CHAIN_ID +EVM_CHAIN_ID=$(echo $CHAIN_ID | sed -E 's/.*_([0-9]+)-.*/\1/') +if [[ -z $EVM_CHAIN_ID ]]; then + echo "Invalid CHAIN_ID format. Expected format: _-" + exit 1 +fi + +sed -i.bak "s/\"chain_id\": \"262144\"/\"chain_id\": \"$EVM_CHAIN_ID\"/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"denom\": \"atest\"/\"denom\": \"utac\"/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"evm_denom\": \"atest\"/\"evm_denom\": \"utac\"/g" $HOMEDIR/config/genesis.json + +# enable evm eip-3855 +sed -i.bak "s/\"extra_eips\": \[\]/\"extra_eips\": \[\"3855\"\]/g" $HOMEDIR/config/genesis.json + +# disable EIP-155 +sed -i.bak "s/\"allow_unprotected_txs\": false/\"allow_unprotected_txs\": true/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/allow-unprotected-txs = false/allow-unprotected-txs = true/g" $HOMEDIR/config/app.toml + +# set evm precompiles +sed -i.bak "s/\"active_static_precompiles\": \[\]/\"active_static_precompiles\": \[\"0x0000000000000000000000000000000000000100\",\"0x0000000000000000000000000000000000000400\",\"0x0000000000000000000000000000000000000800\",\"0x0000000000000000000000000000000000000801\",\"0x0000000000000000000000000000000000000802\",\"0x0000000000000000000000000000000000000803\",\"0x0000000000000000000000000000000000000804\",\"0x0000000000000000000000000000000000000805\",\"0x0000000000000000000000000000000000000806\",\"0x0000000000000000000000000000000000000807\"\]/g" $HOMEDIR/config/genesis.json + +# set x/feemarket min gas price +sed -i.bak "s/\"min_gas_price\": \"0.000000000000000000\"/\"min_gas_price\": \"$MIN_GAS_PRICE\"/g" $HOMEDIR/config/genesis.json + +# set max gas +sed -i.bak "s/\"max_gas\": \"-1\"/\"max_gas\": \"$MAX_GAS\"/g" $HOMEDIR/config/genesis.json + +# update blocks per year to match our block time +BLOCKS_PER_YEAR=$(echo "(365 * 24 * 60 * 60) / $BLOCK_TIME_SECONDS" | bc) +sed -i.bak "s/\"blocks_per_year\": \"6311520\"/\"blocks_per_year\": \"$BLOCKS_PER_YEAR\"/g" $HOMEDIR/config/genesis.json + +# set inflation +sed -i.bak "s/\"inflation_max\": \"0.200000000000000000\"/\"inflation_max\": \"$INFLATION_MAX\"/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"inflation_min\": \"0.070000000000000000\"/\"inflation_min\": \"$INFLATION_MIN\"/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"goal_bonded\": \"0.670000000000000000\"/\"goal_bonded\": \"$GOAL_BONDED\"/g" $HOMEDIR/config/genesis.json + +# set gov vote time +sed -i.bak "s/\"voting_period\": \"172800s\"/\"voting_period\": \"${GOV_TIME_SECONDS}s\"/g" $HOMEDIR/config/genesis.json +EXPEDITED_TIME_SECONDS=$((GOV_TIME_SECONDS / 2)) +sed -i.bak "s/\"expedited_voting_period\": \"86400s\"/\"expedited_voting_period\": \"${EXPEDITED_TIME_SECONDS}s\"/g" $HOMEDIR/config/genesis.json + +# set gov min initial deposit ratio +sed -i.bak "s/\"min_initial_deposit_ratio\": \"0.000000000000000000\"/\"min_initial_deposit_ratio\": \"$GOV_MIN_INITIAL_DEPOSIT_RATIO\"/g" $HOMEDIR/config/genesis.json + +# set min gov deposit +jq --arg GOV_MIN_DEPOSIT "$GOV_MIN_DEPOSIT" ' + .app_state.gov.params.min_deposit = [ + { + "denom": "utac", + "amount": $GOV_MIN_DEPOSIT + } + ] +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +# set min expedited gov deposit +jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' + .app_state.gov.params.expedited_min_deposit = [ + { + "denom": "utac", + "amount": $GOV_MIN_EXPEDITED_DEPOSIT + } + ] +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +# enable apis +sed -i.bak "s/enable = false/enable = true/g" $HOMEDIR/config/app.toml + +# enable rpc cors +sed -i.bak "s/cors_allowed_origins = \[\]/cors_allowed_origins = \[\"*\"\]/g" $HOMEDIR/config/config.toml + +# set slashing +sed -i.bak "s/\"slash_fraction_downtime\": \"0.010000000000000000\"/\"slash_fraction_downtime\": \"$SLASH_DOWNTIME_PENALTY\"/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"signed_blocks_window\": \"100\"/\"signed_blocks_window\": \"$SLASH_SIGNED_BLOCKS_WINDOW\"/g" $HOMEDIR/config/genesis.json + +# add token metadata +jq ' + .app_state.bank.denom_metadata = [ + { + "description": "The native staking token for tacchaind.", + "denom_units": [ + { + "denom": "utac", + "exponent": 0, + "aliases": [] + }, + { + "denom": "tac", + "exponent": 18, + "aliases": [] + } + ], + "base": "utac", + "display": "tac", + "name": "TAC Token", + "symbol": "TAC", + "uri": "", + "uri_hash": "" + } + ] +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +jq ' +.app_state.erc20 = { + "params": { + "enable_erc20": true, + "native_precompiles": [ + "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" + ], + "dynamic_precompiles": [] + }, + "token_pairs": [ + { + "erc20_address": "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517", + "denom": "ugtac", + "enabled": true, + "contract_owner": "OWNER_MODULE" + } + ] +} +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +jq ' +.app_state.liquidstake = { + "params": { + "liquid_bond_denom": "ugtac", + "whitelisted_validators": [ + { + "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", + "target_weight": "10000" + }, + { + "validator_address": "tacvaloper1qp4h82jgqqa5ezgzck8z75dn8q0t0nv4fneehy", + "target_weight": "10000" + }, + { + "validator_address": "tacvaloper1d30q62hl0wn6n5m39sd0yqswq6jr3hntkcr4cm", + "target_weight": "10000" + }, + { + "validator_address": "tacvaloper16p9nqhd348aaungp5p5vjuwedaw03pvynleqq7", + "target_weight": "10000" + } + ], + "unstake_fee_rate": "0.000000000000000000", + "lsm_disabled": false, + "min_liquid_stake_amount": "1000", + "cw_locked_pool_address": "", + "fee_account_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", + "autocompound_fee_rate": "0.050000000000000000", + "whitelist_admin_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", + "module_paused": false + }, + "liquid_validators": [ + { + "operator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt" + }, + { + "operator_address": "tacvaloper1qp4h82jgqqa5ezgzck8z75dn8q0t0nv4fneehy" + }, + { + "operator_address": "tacvaloper1d30q62hl0wn6n5m39sd0yqswq6jr3hntkcr4cm" + }, + { + "operator_address": "tacvaloper16p9nqhd348aaungp5p5vjuwedaw03pvynleqq7" + } + ] +} +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +# set max validators +sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json + +# set ports +sed -i.bak "s/26657/$RPC_PORT/g" $HOMEDIR/config/config.toml +sed -i.bak "s/26656/$P2P_PORT/g" $HOMEDIR/config/config.toml +sed -i.bak "s/9090/$GRPC_PORT/g" $HOMEDIR/config/app.toml +sed -i.bak "s/9091/$GRPC_WEB_PORT/g" $HOMEDIR/config/app.toml +sed -i.bak "s/1317/$API_PORT/g" $HOMEDIR/config/app.toml +sed -i.bak "s/8545/$JSON_RPC_PORT/g" $HOMEDIR/config/app.toml +sed -i.bak "s/8546/$JSON_WS_PORT/g" $HOMEDIR/config/app.toml +sed -i.bak "s/6065/$METRICS_PORT/g" $HOMEDIR/config/app.toml +sed -i.bak "s/26660/$PROMETHEUS_PORT/g" $HOMEDIR/config/config.toml +sed -i.bak "s/6060/$PPROF_PORT/g" $HOMEDIR/config/config.toml +sed -i.bak "s/26658/$PROXY_PORT/g" $HOMEDIR/config/config.toml + +# setup and add validator to genesis +echo $VALIDATOR_MNEMONIC | $TACCHAIND keys add validator --recover --keyring-backend $KEYRING_BACKEND --home $HOMEDIR +$TACCHAIND genesis add-genesis-account validator ${INITIAL_BALANCE}utac --keyring-backend $KEYRING_BACKEND --home $HOMEDIR +$TACCHAIND genesis gentx validator ${INITIAL_STAKE}utac --identity $VALIDATOR_IDENTITY --website $VALIDATOR_WEBSITE --chain-id $CHAIN_ID --keyring-backend $KEYRING_BACKEND --gas-prices ${MIN_GAS_PRICE}utac --gas 200000 --home $HOMEDIR --sequence 1 +$TACCHAIND genesis collect-gentxs --keyring-backend $KEYRING_BACKEND --home $HOMEDIR diff --git a/contrib/localnet/init-multi-node.sh b/contrib/localnet/init-multi-node.sh index 12fce53..f6da08a 100755 --- a/contrib/localnet/init-multi-node.sh +++ b/contrib/localnet/init-multi-node.sh @@ -10,9 +10,9 @@ export VALIDATOR_NAME=${VALIDATOR_NAME:-TAC Validator} export VALIDATOR_IDENTITY=${VALIDATOR_IDENTITY:-4DD1A5E1D03FA12D} export VALIDATOR_WEBSITE=${VALIDATOR_WEBSITE:-https://tac.build/} export VALIDATOR_1_MNEMONIC=${VALIDATOR_1_MNEMONIC:-"island mail dice alien project surround orchard ball twist worth innocent arrange assume dragon rotate enough flee rapid rookie swim addict ice destroy run"} # tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr -export VALIDATOR_2_MNEMONIC=${VALIDATOR_2_MNEMONIC:-"margin funny awkward answer squirrel inner venue spell expose close tank salute series neck oval real bunker can text chronic capital teach arena extend"} # tac16p9nqhd348aaungp5p5vjuwedaw03pvywdzwdk -export VALIDATOR_3_MNEMONIC=${VALIDATOR_3_MNEMONIC:-"that away spike absorb aspect loan shuffle purchase number knock cover night library shock mask cheese upset float churn wall fox veteran actress motor"} # tac1qp4h82jgqqa5ezgzck8z75dn8q0t0nv45pzh6v -export VALIDATOR_4_MNEMONIC=${VALIDATOR_4_MNEMONIC:-"floor wrong idle cloth nose material forward urge grape always into buyer atom excuse odor decade crouch purchase shadow energy voyage pact skate pigeon"} # tac1d30q62hl0wn6n5m39sd0yqswq6jr3hntt2cm4n +export VALIDATOR_2_MNEMONIC=${VALIDATOR_2_MNEMONIC:-"margin funny awkward answer squirrel inner venue spell expose close tank salute series neck oval real bunker can text chronic capital teach arena extend"} # tac16p9nqhd348aaungp5p5vjuwedaw03pvywdzwdk +export VALIDATOR_3_MNEMONIC=${VALIDATOR_3_MNEMONIC:-"that away spike absorb aspect loan shuffle purchase number knock cover night library shock mask cheese upset float churn wall fox veteran actress motor"} # tac1qp4h82jgqqa5ezgzck8z75dn8q0t0nv45pzh6v +export VALIDATOR_4_MNEMONIC=${VALIDATOR_4_MNEMONIC:-"floor wrong idle cloth nose material forward urge grape always into buyer atom excuse odor decade crouch purchase shadow energy voyage pact skate pigeon"} # tac1d30q62hl0wn6n5m39sd0yqswq6jr3hntt2cm4n export GENESIS_ACC_1_ADDRESS=${GENESIS_ACC_1_ADDRESS:-} export GENESIS_ACC_2_ADDRESS=${GENESIS_ACC_2_ADDRESS:-} export INITIAL_SUPPLY=${INITIAL_SUPPLY:-10000000000000000000000000000} @@ -33,8 +33,8 @@ export MAX_VALIDATORS=${MAX_VALIDATORS:-14} # prompt user for confirmation before cleanup read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm if [[ $confirm != "y" && $confirm != "Y" ]]; then - echo "Cleanup aborted." - exit 1 + echo "Cleanup aborted." + exit 1 fi # cleanup old data @@ -62,38 +62,38 @@ GENESIS_ACC_2_BALANCE=10000000000000000000000 GENESIS_ACC_1_BALANCE=$(echo "$INITIAL_SUPPLY - ($VALIDATOR_BALANCE * $VALIDATORS_COUNT) - $GENESIS_ACC_2_BALANCE" | bc) # initialize config folder for each validator -for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do +for ((i = 0; i < VALIDATORS_COUNT; i++)); do NODE_KEY="node$i" NODEDIR="$HOMEDIR/$NODE_KEY" # set ports - export P2P_PORT=451$((i+1))0 # 45110 - export RPC_PORT=451$((i+1))1 # 45111 - export API_PORT=451$((i+1))2 # 45112 - export METRICS_PORT=451$((i+1))3 # 45113 - export PPROF_PORT=451$((i+1))4 # 45114 - export PROMETHEUS_PORT=451$((i+1))5 # 45115 - export GRPC_WEB_PORT=451$((i+1))6 # 45116 - export GRPC_PORT=451$((i+1))7 # 45117 - export JSON_RPC_PORT=451$((i+1))8 # 45118 - export JSON_WS_PORT=451$((i+1))9 # 45119 - export PROXY_PORT=451$((i+1))10 # 451110 + export P2P_PORT=451$((i + 1))0 # 45110 + export RPC_PORT=451$((i + 1))1 # 45111 + export API_PORT=451$((i + 1))2 # 45112 + export METRICS_PORT=451$((i + 1))3 # 45113 + export PPROF_PORT=451$((i + 1))4 # 45114 + export PROMETHEUS_PORT=451$((i + 1))5 # 45115 + export GRPC_WEB_PORT=451$((i + 1))6 # 45116 + export GRPC_PORT=451$((i + 1))7 # 45117 + export JSON_RPC_PORT=451$((i + 1))8 # 45118 + export JSON_WS_PORT=451$((i + 1))9 # 45119 + export PROXY_PORT=451$((i + 1))10 # 451110 export NODE_MONIKER="$VALIDATOR_NAME $((i + 1))" - + export INITIAL_BALANCE=$VALIDATOR_BALANCE export INITIAL_STAKE=$VALIDATOR_SELF_DELEGATION # dynamically get mnemonic env var for each validator - mnemonic_var="VALIDATOR_$((i+1))_MNEMONIC" + mnemonic_var="VALIDATOR_$((i + 1))_MNEMONIC" export VALIDATOR_MNEMONIC="${!mnemonic_var}" # call init.sh script to initialize the node - echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init.sh + echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init-liquidstake-for-multinode.sh # explicitly add balances to first node(node0) which will be used to collect gentxs later ADDRESS=$($TACCHAIND keys show validator --keyring-backend $KEYRING_BACKEND --home $NODEDIR -a) - $TACCHAIND genesis add-genesis-account $ADDRESS ${VALIDATOR_BALANCE}utac --keyring-backend $KEYRING_BACKEND --home $HOMEDIR/node0 &> /dev/null || true + $TACCHAIND genesis add-genesis-account $ADDRESS ${VALIDATOR_BALANCE}utac --keyring-backend $KEYRING_BACKEND --home $HOMEDIR/node0 &>/dev/null || true # copy gentx into main gentxs cp $NODEDIR/config/gentx/* "$HOMEDIR/gentxs/" @@ -117,29 +117,29 @@ $TACCHAIND genesis add-genesis-account $GENESIS_ACC_2_ADDRESS ${GENESIS_ACC_2_BA cp $HOMEDIR/gentxs/* "$HOMEDIR/node0/config/gentx/" # clear gentx in genesis because we already collect in init.sh, so recollect here instead changing the original script -jq '.app_state.genutil.gen_txs = []' "$HOMEDIR/node0/config/genesis.json" > "$HOMEDIR/node0/config/genesis_tmp.json" && mv "$HOMEDIR/node0/config/genesis_tmp.json" "$HOMEDIR/node0/config/genesis.json" +jq '.app_state.genutil.gen_txs = []' "$HOMEDIR/node0/config/genesis.json" >"$HOMEDIR/node0/config/genesis_tmp.json" && mv "$HOMEDIR/node0/config/genesis_tmp.json" "$HOMEDIR/node0/config/genesis.json" $TACCHAIND genesis collect-gentxs --home $HOMEDIR/node0 # copy genesis to main directory for reference cp $HOMEDIR/node0/config/genesis.json $HOMEDIR/genesis.json -for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do +for ((i = 0; i < VALIDATORS_COUNT; i++)); do # copy final genesis to all validators - cp $HOMEDIR/node0/config/genesis.json $HOMEDIR/node$i/config/genesis.json &> /dev/null || true - + cp $HOMEDIR/node0/config/genesis.json $HOMEDIR/node$i/config/genesis.json &>/dev/null || true + # update persistent peers PERSISTENT_PEERS="" CURRENT_PEER=0 - for ((j = 0 ; j < VALIDATORS_COUNT ; j++)); do + for ((j = 0; j < VALIDATORS_COUNT; j++)); do # add all nodes except the current one if [ "$i" != "$j" ]; then CURRENT_PEER=$((CURRENT_PEER + 1)) NODE_ID=$($TACCHAIND tendermint show-node-id --home $HOMEDIR/node$j) - P2P_PORT=451$((j+1))0 + P2P_PORT=451$((j + 1))0 PERSISTENT_PEERS+=$NODE_ID@127.0.0.1:$P2P_PORT # add comma if not last node - if [ "$CURRENT_PEER" != "$((VALIDATORS_COUNT-1))" ]; then + if [ "$CURRENT_PEER" != "$((VALIDATORS_COUNT - 1))" ]; then PERSISTENT_PEERS+="," fi fi @@ -150,4 +150,4 @@ for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do # set multi node configs sed -i.bak "s/addr_book_strict = true/addr_book_strict = false/g" $HOMEDIR/node$i/config/config.toml sed -i.bak "s/allow_duplicate_ip = false/allow_duplicate_ip = true/g" $HOMEDIR/node$i/config/config.toml -done \ No newline at end of file +done From 8ebbe07e0378f466387ed1e6822bbb412a74ce95 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Wed, 9 Jul 2025 14:06:56 +0200 Subject: [PATCH 056/112] fix(HOTFIX): add liquiedstake script do docker --- Dockerfile | 2 +- docker-compose.yml | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0363b83..8c304e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind COPY --from=go-builder /code/contrib/localnet/init.sh /scripts/init.sh COPY --from=go-builder /code/contrib/localnet/init-multi-node.sh /scripts/init-multi-node.sh COPY --from=go-builder /code/contrib/localnet/start.sh /scripts/start.sh -COPY --from=go-builder /code/contrib/localnet/start-additional-node.sh /scripts/start-additional-node.sh +COPY --from=go-builder /code/contrib/localnet/init-liquidstake-for-multinode.sh /scripts/init-liquidstake-for-multinode.sh RUN chmod +x /scripts/*.sh RUN apt-get update && apt-get install -y \ diff --git a/docker-compose.yml b/docker-compose.yml index 22f5b12..d332bdb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,8 @@ services: init: - image: ${IMAGE} + build: + dockerfile: Dockerfile + context: . volumes: - "/mnt/data:/tacchain_data" entrypoint: bash @@ -13,7 +15,9 @@ services: validator-1: network_mode: host restart: unless-stopped - image: ${IMAGE} + build: + dockerfile: Dockerfile + context: . ports: - "45110:45110" # P2P - "45111:45111" # RPC @@ -40,7 +44,9 @@ services: validator-2: network_mode: host restart: unless-stopped - image: ${IMAGE} + build: + dockerfile: Dockerfile + context: . ports: - "45120:45120" # P2P - "45121:45121" # RPC @@ -67,7 +73,9 @@ services: validator-3: network_mode: host restart: unless-stopped - image: ${IMAGE} + build: + dockerfile: Dockerfile + context: . ports: - "45130:45130" # P2P - "45131:45131" # RPC @@ -94,7 +102,9 @@ services: validator-4: network_mode: host restart: unless-stopped - image: ${IMAGE} + build: + dockerfile: Dockerfile + context: . ports: - "45140:45140" # P2P - "45141:45141" # RPC From 9681118781b5d00cc54ed145a87647a9dfb784d4 Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Wed, 9 Jul 2025 14:14:17 +0200 Subject: [PATCH 057/112] fix(HOTFIX): add liquiedstake script do docker #1 --- docker-compose.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d332bdb..22f5b12 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ services: init: - build: - dockerfile: Dockerfile - context: . + image: ${IMAGE} volumes: - "/mnt/data:/tacchain_data" entrypoint: bash @@ -15,9 +13,7 @@ services: validator-1: network_mode: host restart: unless-stopped - build: - dockerfile: Dockerfile - context: . + image: ${IMAGE} ports: - "45110:45110" # P2P - "45111:45111" # RPC @@ -44,9 +40,7 @@ services: validator-2: network_mode: host restart: unless-stopped - build: - dockerfile: Dockerfile - context: . + image: ${IMAGE} ports: - "45120:45120" # P2P - "45121:45121" # RPC @@ -73,9 +67,7 @@ services: validator-3: network_mode: host restart: unless-stopped - build: - dockerfile: Dockerfile - context: . + image: ${IMAGE} ports: - "45130:45130" # P2P - "45131:45131" # RPC @@ -102,9 +94,7 @@ services: validator-4: network_mode: host restart: unless-stopped - build: - dockerfile: Dockerfile - context: . + image: ${IMAGE} ports: - "45140:45140" # P2P - "45141:45141" # RPC From 4df4a484eb413571f7ac3853f3c8031d2d8895dc Mon Sep 17 00:00:00 2001 From: Nikita Misiura Date: Wed, 9 Jul 2025 15:13:39 +0200 Subject: [PATCH 058/112] fix(HOTFIX): change init-multi-node.sh script --- contrib/localnet/init-multi-node.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/contrib/localnet/init-multi-node.sh b/contrib/localnet/init-multi-node.sh index f6da08a..670c2d5 100755 --- a/contrib/localnet/init-multi-node.sh +++ b/contrib/localnet/init-multi-node.sh @@ -30,13 +30,6 @@ export SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} export SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} export MAX_VALIDATORS=${MAX_VALIDATORS:-14} -# prompt user for confirmation before cleanup -read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm -if [[ $confirm != "y" && $confirm != "Y" ]]; then - echo "Cleanup aborted." - exit 1 -fi - # cleanup old data rm -rf $HOMEDIR From a7bc306acf10a55b2fc76a78bc8cbcd1a929937b Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 17 Jul 2025 16:40:57 +0300 Subject: [PATCH 059/112] feat: upgraded cosmos evm for eip712 --- go.mod | 3 ++- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d2fbd98..b118272 100644 --- a/go.mod +++ b/go.mod @@ -280,7 +280,8 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd // replace cosmos evm with our fork that uses geth v1.13.15 - github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c + // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250717120932-81edb6f1dac1 // use Cosmos geth fork // replace with our fork using geth v1.13.15 diff --git a/go.sum b/go.sum index 55beb64..e20b684 100644 --- a/go.sum +++ b/go.sum @@ -246,8 +246,6 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c h1:sby6GxoiQbUelMYP2PIcD5v1wbJ0Mgm4WnmyIFGqEDE= -github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a h1:d5s3in80qbAEpMLo2gVHKPrR6qn60nyxV+rK17tqZ1Q= github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= @@ -1008,6 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:wdNwCUHsrId91KHpGSJT4MPxPLYv014IuJimc2BlvQo= github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= +github.com/pixelplex/tac-evm v0.0.0-20250717120932-81edb6f1dac1 h1:HfYWUEJ6SjV4BOvisCFn2AMJoI1+BISrR837QbkUQtY= +github.com/pixelplex/tac-evm v0.0.0-20250717120932-81edb6f1dac1/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 93b778d73b6eaca87fea79c4d9691f425bc42e37 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 17 Jul 2025 17:10:30 +0300 Subject: [PATCH 060/112] chore: open grpc and rest ports --- Dockerfile | 2 ++ docker-compose.yml | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8c304e5..66e8c99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,5 +48,7 @@ EXPOSE 1317 EXPOSE 26656 # tendermint rpc EXPOSE 26657 +# grpc +EXPOSE 9090 CMD ["/usr/bin/tacchaind", "version"] diff --git a/docker-compose.yml b/docker-compose.yml index 22f5b12..c01955d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,7 @@ services: - "45110:45110" # P2P - "45111:45111" # RPC - "45112:45112" # REST + - "45113:45113" # GRPC - "45118:45118" # RPC_EVM - "45119:45119" # WS_EVM volumes: @@ -36,6 +37,8 @@ services: - RPC_LADDR=tcp://0.0.0.0:45111 - JSON_RPC_ADDR=0.0.0.0:45118 - JSON_RPC_WS_ADDR=0.0.0.0:45119 + - REST_LADDR=tcp://0.0.0.0:45112 + - GRPC_LADDR=tcp://0.0.0.0:45113 validator-2: network_mode: host @@ -45,6 +48,7 @@ services: - "45120:45120" # P2P - "45121:45121" # RPC - "45122:45122" # REST + - "45123:45123" # GRPC - "45128:45128" # RPC_EVM - "45129:45129" # WS_EVM volumes: @@ -63,6 +67,8 @@ services: - RPC_LADDR=tcp://0.0.0.0:45121 - JSON_RPC_ADDR=0.0.0.0:45128 - JSON_RPC_WS_ADDR=0.0.0.0:45129 + - REST_LADDR=tcp://0.0.0.0:45122 + - GRPC_LADDR=tcp://0.0.0.0:45123 validator-3: network_mode: host @@ -72,6 +78,7 @@ services: - "45130:45130" # P2P - "45131:45131" # RPC - "45132:45132" # REST + - "45133:45133" # GRPC - "45138:45138" # RPC_EVM - "45139:45139" # WS_EVM volumes: @@ -90,6 +97,8 @@ services: - RPC_LADDR=tcp://0.0.0.0:45131 - JSON_RPC_ADDR=0.0.0.0:45138 - JSON_RPC_WS_ADDR=0.0.0.0:45139 + - REST_LADDR=tcp://0.0.0.0:45132 + - GRPC_LADDR=tcp://0.0.0.0:45133 validator-4: network_mode: host @@ -99,6 +108,7 @@ services: - "45140:45140" # P2P - "45141:45141" # RPC - "45142:45142" # REST + - "45143:45143" # GRPC - "45148:45148" # RPC_EVM - "45149:45149" # WS_EVM volumes: @@ -116,4 +126,6 @@ services: - P2P_EXTERNAL_ADDRESS=0.0.0.0:45140 - RPC_LADDR=tcp://0.0.0.0:45141 - JSON_RPC_ADDR=0.0.0.0:45148 - - JSON_RPC_WS_ADDR=0.0.0.0:45149 \ No newline at end of file + - JSON_RPC_WS_ADDR=0.0.0.0:45149 + - REST_LADDR=tcp://0.0.0.0:45142 + - GRPC_LADDR=tcp://0.0.0.0:45143 From b84492a0b270fceacbc5b786e8d0d7eeb26793a1 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 17 Jul 2025 18:11:16 +0300 Subject: [PATCH 061/112] chore: add ports to start script --- contrib/localnet/start.sh | 12 +++++++++++- docker-compose.yml | 12 ++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index b94f9a3..0baa39f 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -4,4 +4,14 @@ CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} TACCHAIND=${TACCHAIND:-$(which tacchaind)} HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} -$TACCHAIND start --chain-id $CHAIN_ID --home $HOMEDIR --p2p.laddr $P2P_LADDR --p2p.external-address $P2P_EXTERNAL_ADDRESS --rpc.laddr $RPC_LADDR --json-rpc.address $JSON_RPC_ADDR --json-rpc.ws-address $JSON_RPC_WS_ADDR --json-rpc.enable +$TACCHAIND start --chain-id $CHAIN_ID \ + --home $HOMEDIR \ + --p2p.laddr $P2P_LADDR \ + --p2p.external-address $P2P_EXTERNAL_ADDRESS \ + --rpc.laddr $RPC_LADDR \ + --json-rpc.address $JSON_RPC_ADDR \ + --json-rpc.ws-address $JSON_RPC_WS_ADDR \ + --json-rpc.enable \ + --grpc.address $GRPC_LADDR \ + --grpc.enable=true \ + --api.enable=true diff --git a/docker-compose.yml b/docker-compose.yml index c01955d..727358d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: ports: - "45110:45110" # P2P - "45111:45111" # RPC - - "45112:45112" # REST + - "45112:1317" # REST - "45113:45113" # GRPC - "45118:45118" # RPC_EVM - "45119:45119" # WS_EVM @@ -37,7 +37,6 @@ services: - RPC_LADDR=tcp://0.0.0.0:45111 - JSON_RPC_ADDR=0.0.0.0:45118 - JSON_RPC_WS_ADDR=0.0.0.0:45119 - - REST_LADDR=tcp://0.0.0.0:45112 - GRPC_LADDR=tcp://0.0.0.0:45113 validator-2: @@ -47,7 +46,7 @@ services: ports: - "45120:45120" # P2P - "45121:45121" # RPC - - "45122:45122" # REST + - "45122:1317" # REST - "45123:45123" # GRPC - "45128:45128" # RPC_EVM - "45129:45129" # WS_EVM @@ -67,7 +66,6 @@ services: - RPC_LADDR=tcp://0.0.0.0:45121 - JSON_RPC_ADDR=0.0.0.0:45128 - JSON_RPC_WS_ADDR=0.0.0.0:45129 - - REST_LADDR=tcp://0.0.0.0:45122 - GRPC_LADDR=tcp://0.0.0.0:45123 validator-3: @@ -77,7 +75,7 @@ services: ports: - "45130:45130" # P2P - "45131:45131" # RPC - - "45132:45132" # REST + - "45132:1317" # REST - "45133:45133" # GRPC - "45138:45138" # RPC_EVM - "45139:45139" # WS_EVM @@ -97,7 +95,6 @@ services: - RPC_LADDR=tcp://0.0.0.0:45131 - JSON_RPC_ADDR=0.0.0.0:45138 - JSON_RPC_WS_ADDR=0.0.0.0:45139 - - REST_LADDR=tcp://0.0.0.0:45132 - GRPC_LADDR=tcp://0.0.0.0:45133 validator-4: @@ -107,7 +104,7 @@ services: ports: - "45140:45140" # P2P - "45141:45141" # RPC - - "45142:45142" # REST + - "45142:1317" # REST - "45143:45143" # GRPC - "45148:45148" # RPC_EVM - "45149:45149" # WS_EVM @@ -127,5 +124,4 @@ services: - RPC_LADDR=tcp://0.0.0.0:45141 - JSON_RPC_ADDR=0.0.0.0:45148 - JSON_RPC_WS_ADDR=0.0.0.0:45149 - - REST_LADDR=tcp://0.0.0.0:45142 - GRPC_LADDR=tcp://0.0.0.0:45143 From 09b665d69960a14afd801d8724e765e061fc7ccd Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 17 Jul 2025 18:38:01 +0300 Subject: [PATCH 062/112] fix: grpc address --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 727358d..d505bc7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,7 @@ services: - RPC_LADDR=tcp://0.0.0.0:45111 - JSON_RPC_ADDR=0.0.0.0:45118 - JSON_RPC_WS_ADDR=0.0.0.0:45119 - - GRPC_LADDR=tcp://0.0.0.0:45113 + - GRPC_LADDR=0.0.0.0:45113 validator-2: network_mode: host @@ -66,7 +66,7 @@ services: - RPC_LADDR=tcp://0.0.0.0:45121 - JSON_RPC_ADDR=0.0.0.0:45128 - JSON_RPC_WS_ADDR=0.0.0.0:45129 - - GRPC_LADDR=tcp://0.0.0.0:45123 + - GRPC_LADDR=0.0.0.0:45123 validator-3: network_mode: host @@ -95,7 +95,7 @@ services: - RPC_LADDR=tcp://0.0.0.0:45131 - JSON_RPC_ADDR=0.0.0.0:45138 - JSON_RPC_WS_ADDR=0.0.0.0:45139 - - GRPC_LADDR=tcp://0.0.0.0:45133 + - GRPC_LADDR=0.0.0.0:45133 validator-4: network_mode: host @@ -124,4 +124,4 @@ services: - RPC_LADDR=tcp://0.0.0.0:45141 - JSON_RPC_ADDR=0.0.0.0:45148 - JSON_RPC_WS_ADDR=0.0.0.0:45149 - - GRPC_LADDR=tcp://0.0.0.0:45143 + - GRPC_LADDR=0.0.0.0:45143 From a5b52fe569f8e9a2b9069a49c49c0eee9e34f255 Mon Sep 17 00:00:00 2001 From: Sergey Andreev Date: Fri, 18 Jul 2025 14:44:55 +0300 Subject: [PATCH 063/112] fix(TAC-70): fix REST API port --- contrib/localnet/start.sh | 2 ++ docker-compose.yml | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index 0baa39f..90b87a2 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -4,6 +4,8 @@ CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} TACCHAIND=${TACCHAIND:-$(which tacchaind)} HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} +sed -i.bak -E 's@(address = "tcp://)[^:/]+(:[0-9]+")@\10.0.0.0\2@g' "$HOMEDIR/config/app.toml" + $TACCHAIND start --chain-id $CHAIN_ID \ --home $HOMEDIR \ --p2p.laddr $P2P_LADDR \ diff --git a/docker-compose.yml b/docker-compose.yml index d505bc7..e2e85dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: ports: - "45110:45110" # P2P - "45111:45111" # RPC - - "45112:1317" # REST + - "45112:45112" # REST - "45113:45113" # GRPC - "45118:45118" # RPC_EVM - "45119:45119" # WS_EVM @@ -46,7 +46,7 @@ services: ports: - "45120:45120" # P2P - "45121:45121" # RPC - - "45122:1317" # REST + - "45122:45122" # REST - "45123:45123" # GRPC - "45128:45128" # RPC_EVM - "45129:45129" # WS_EVM @@ -67,7 +67,7 @@ services: - JSON_RPC_ADDR=0.0.0.0:45128 - JSON_RPC_WS_ADDR=0.0.0.0:45129 - GRPC_LADDR=0.0.0.0:45123 - + validator-3: network_mode: host restart: unless-stopped @@ -75,7 +75,7 @@ services: ports: - "45130:45130" # P2P - "45131:45131" # RPC - - "45132:1317" # REST + - "45132:45132" # REST - "45133:45133" # GRPC - "45138:45138" # RPC_EVM - "45139:45139" # WS_EVM @@ -104,7 +104,7 @@ services: ports: - "45140:45140" # P2P - "45141:45141" # RPC - - "45142:1317" # REST + - "45142:45142" # REST - "45143:45143" # GRPC - "45148:45148" # RPC_EVM - "45149:45149" # WS_EVM From dd39b3cf1bebffecfb84eb49f8c713c7951bf4c9 Mon Sep 17 00:00:00 2001 From: Sergey Andreev Date: Fri, 18 Jul 2025 15:42:51 +0300 Subject: [PATCH 064/112] fix(TAC-70): allow cors --- contrib/localnet/start.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index 90b87a2..e9d1897 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -16,4 +16,5 @@ $TACCHAIND start --chain-id $CHAIN_ID \ --json-rpc.enable \ --grpc.address $GRPC_LADDR \ --grpc.enable=true \ - --api.enable=true + --api.enable=true \ + --api.enabled-unsafe-cors From 68af7d04dbda238ed7ae00962c6f567678c955a0 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Fri, 18 Jul 2025 16:58:57 +0300 Subject: [PATCH 065/112] fix: update cosmos evm --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b118272..f19c92c 100644 --- a/go.mod +++ b/go.mod @@ -281,7 +281,7 @@ replace ( // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250717120932-81edb6f1dac1 + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 // use Cosmos geth fork // replace with our fork using geth v1.13.15 diff --git a/go.sum b/go.sum index e20b684..4e97c2c 100644 --- a/go.sum +++ b/go.sum @@ -1006,8 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:wdNwCUHsrId91KHpGSJT4MPxPLYv014IuJimc2BlvQo= github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= -github.com/pixelplex/tac-evm v0.0.0-20250717120932-81edb6f1dac1 h1:HfYWUEJ6SjV4BOvisCFn2AMJoI1+BISrR837QbkUQtY= -github.com/pixelplex/tac-evm v0.0.0-20250717120932-81edb6f1dac1/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= +github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 h1:ddqzU2x2ZpPPvQKhBqPj9TZNtSyp0UsA5Ip2+elxlRM= +github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 79dfd14956c10684b4f0105decd9b53edce538f9 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Fri, 18 Jul 2025 17:11:12 +0300 Subject: [PATCH 066/112] chore: updated Dockerfile to download go modules before app building --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 66e8c99..72c25fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,11 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* WORKDIR /code + +# Download go modules +COPY go.mod go.sum /code/ +RUN go mod download + COPY . /code/ # force it to use static lib (from above) not standard libgo_cosmwasm.so file From 9a40cdeb26ec8f818596941ca135c7cdfeec92f5 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Mon, 21 Jul 2025 21:24:19 +0300 Subject: [PATCH 067/112] Correct Net amount calculation logick --- app/app.go | 1 + contrib/localnet/init.sh | 47 +++++++++++++++++++++++++++++ contrib/localnet/start.sh | 12 +------- x/liquidstake/keeper/liquidstake.go | 7 ++++- 4 files changed, 55 insertions(+), 12 deletions(-) diff --git a/app/app.go b/app/app.go index b44fe19..0f74bdc 100644 --- a/app/app.go +++ b/app/app.go @@ -831,6 +831,7 @@ func NewTacChainApp( group.ModuleName, // no-op modules stakingtypes.ModuleName, + liquidstaketypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, icatypes.ModuleName, diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index 91e0668..f3f4671 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -226,6 +226,53 @@ jq ' ] ' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +jq ' +.app_state.erc20 = { + "params": { + "enable_erc20": true, + "native_precompiles": [ + "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" + ], + "dynamic_precompiles": [] + }, + "token_pairs": [ + { + "erc20_address": "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517", + "denom": "ugtac", + "enabled": true, + "contract_owner": "OWNER_MODULE" + } + ] +} +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + +jq ' +.app_state.liquidstake = { + "params": { + "liquid_bond_denom": "ugtac", + "whitelisted_validators": [ + { + "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", + "target_weight": "10000" + } + ], + "unstake_fee_rate": "0.000000000000000000", + "lsm_disabled": false, + "min_liquid_stake_amount": "1000", + "cw_locked_pool_address": "", + "fee_account_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", + "autocompound_fee_rate": "0.050000000000000000", + "whitelist_admin_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", + "module_paused": false + }, + "liquid_validators": [ + { + "operator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt" + } + ] +} +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + # set max validators sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index e9d1897..b767058 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -7,14 +7,4 @@ HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} sed -i.bak -E 's@(address = "tcp://)[^:/]+(:[0-9]+")@\10.0.0.0\2@g' "$HOMEDIR/config/app.toml" $TACCHAIND start --chain-id $CHAIN_ID \ - --home $HOMEDIR \ - --p2p.laddr $P2P_LADDR \ - --p2p.external-address $P2P_EXTERNAL_ADDRESS \ - --rpc.laddr $RPC_LADDR \ - --json-rpc.address $JSON_RPC_ADDR \ - --json-rpc.ws-address $JSON_RPC_WS_ADDR \ - --json-rpc.enable \ - --grpc.address $GRPC_LADDR \ - --grpc.enable=true \ - --api.enable=true \ - --api.enabled-unsafe-cors + --home $HOMEDIR diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index be0bdeb..897f1fe 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -1021,7 +1021,12 @@ func (k Keeper) CheckDelegationStates(ctx sdk.Context, proxyAcc sdk.AccAddress) cachedCtx, proxyAcc, func(_ int64, del stakingtypes.DelegationI) (stop bool) { valAddr := del.GetValidatorAddr() - val, err := k.stakingKeeper.Validator(cachedCtx, sdk.ValAddress(valAddr)) + valAddrObj, parseErr := sdk.ValAddressFromBech32(valAddr) + if parseErr != nil { + return false + } + + val, err := k.stakingKeeper.Validator(cachedCtx, valAddrObj) if err != nil { return false } From 812b238be50282f4cfe0256af14d535c2ffef399 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 22 Jul 2025 11:06:33 +0300 Subject: [PATCH 068/112] chore: reverted flags --- contrib/localnet/start.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index b767058..f4b17cb 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -7,4 +7,15 @@ HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} sed -i.bak -E 's@(address = "tcp://)[^:/]+(:[0-9]+")@\10.0.0.0\2@g' "$HOMEDIR/config/app.toml" $TACCHAIND start --chain-id $CHAIN_ID \ - --home $HOMEDIR + --home $HOMEDIR \ + --p2p.laddr $P2P_LADDR \ + --p2p.external-address $P2P_EXTERNAL_ADDRESS \ + --rpc.laddr $RPC_LADDR \ + --json-rpc.address $JSON_RPC_ADDR \ + --json-rpc.ws-address $JSON_RPC_WS_ADDR \ + --json-rpc.enable \ + --grpc.address $GRPC_LADDR \ + --grpc.enable=true \ + --api.enable=true \ + --api.enabled-unsafe-cors +--home $HOMEDIR From 7e092edfb69e96859c78285fee3e25acf0a4d4e4 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 22 Jul 2025 13:08:30 +0300 Subject: [PATCH 069/112] draft: added tests --- go.mod | 3 +- go.sum | 2 - x/liquidstake/keeper/keeper_test.go | 68 ++-- x/liquidstake/keeper/liquidstake.go | 2 +- x/liquidstake/keeper/liquidstake_test.go | 494 +++++++++++++++++++++++ 5 files changed, 532 insertions(+), 37 deletions(-) create mode 100644 x/liquidstake/keeper/liquidstake_test.go diff --git a/go.mod b/go.mod index f19c92c..5369d3d 100644 --- a/go.mod +++ b/go.mod @@ -277,7 +277,8 @@ replace ( // // use Cosmos-SDK fork to enable Ledger functionality // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd + // github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd + github.com/cosmos/cosmos-sdk => ../../cosmos-sdk/ // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index 4e97c2c..4064183 100644 --- a/go.sum +++ b/go.sum @@ -1004,8 +1004,6 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:wdNwCUHsrId91KHpGSJT4MPxPLYv014IuJimc2BlvQo= -github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 h1:ddqzU2x2ZpPPvQKhBqPj9TZNtSyp0UsA5Ip2+elxlRM= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= diff --git a/x/liquidstake/keeper/keeper_test.go b/x/liquidstake/keeper/keeper_test.go index f2e35a0..68ad942 100644 --- a/x/liquidstake/keeper/keeper_test.go +++ b/x/liquidstake/keeper/keeper_test.go @@ -7,6 +7,8 @@ import ( "cosmossdk.io/log" "cosmossdk.io/math" + testhelpers "github.com/Asphere-xyz/tacchain/app/helpers" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -78,39 +80,39 @@ func (s *KeeperTestSuite) TearDownTest() { crisis.EndBlocker(s.ctx, *s.app.CrisisKeeper) } -// TODO: Upgrade Cosmos SDK -// func (s *KeeperTestSuite) CreateValidators(powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []cryptotypes.PubKey) { -// s.app.BeginBlocker(s.ctx) -// num := len(powers) -// addrs := chain.AddTestAddrsIncremental(s.app, s.ctx, num, math.NewInt(10000000000000)) -// valAddrs := chain.ConvertAddrsToValAddrs(addrs) -// pks := chain.CreateTestPubKeys(num) -// skParams, _ := s.app.StakingKeeper.GetParams(s.ctx) -// skParams.ValidatorLiquidStakingCap = sdk.OneDec() -// _ = s.app.StakingKeeper.SetParams(s.ctx, skParams) -// for i, power := range powers { -// val, err := stakingtypes.NewValidator(valAddrs[i].String(), pks[i], stakingtypes.Description{}) -// s.Require().NoError(err) -// s.app.StakingKeeper.SetValidator(s.ctx, val) -// err = s.app.StakingKeeper.SetValidatorByConsAddr(s.ctx, val) -// s.Require().NoError(err) -// s.app.StakingKeeper.SetNewValidatorByPowerIndex(s.ctx, val) -// _ = s.app.StakingKeeper.Hooks().AfterValidatorCreated(s.ctx, sdk.ValAddress(val.GetOperator())) -// newShares, err := s.app.StakingKeeper.Delegate(s.ctx, addrs[i], math.NewInt(power), stakingtypes.Unbonded, val, true) -// s.Require().NoError(err) -// s.Require().Equal(newShares.TruncateInt(), math.NewInt(power)) -// msgValidatorBond := &stakingtypes.MsgValidatorBond{ -// DelegatorAddress: addrs[i].String(), -// ValidatorAddress: val.OperatorAddress, -// } -// handler := s.app.MsgServiceRouter().Handler(msgValidatorBond) -// _, err = handler(s.ctx, msgValidatorBond) -// s.Require().NoError(err) -// } -// -// s.app.EndBlocker(s.ctx) -// return addrs, valAddrs, pks -// } +func (s *KeeperTestSuite) CreateValidators(powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []cryptotypes.PubKey) { + s.app.BeginBlocker(s.ctx) + num := len(powers) + addrs := testhelpers.AddTestAddrsIncremental(s.app, s.ctx, num, math.NewInt(10000000000000)) + valAddrs := testhelpers.ConvertAddrsToValAddrs(addrs) + pks := testhelpers.CreateTestPubKeys(num) + skParams, err := s.app.StakingKeeper.GetParams(s.ctx) + s.Require().NoError(err) + skParams.ValidatorLiquidStakingCap = sdk.OneDec() + _ = s.app.StakingKeeper.SetParams(s.ctx, skParams) + for i, power := range powers { + val, err := stakingtypes.NewValidator(valAddrs[i].String(), pks[i], stakingtypes.Description{}) + s.Require().NoError(err) + s.app.StakingKeeper.SetValidator(s.ctx, val) + err = s.app.StakingKeeper.SetValidatorByConsAddr(s.ctx, val) + s.Require().NoError(err) + s.app.StakingKeeper.SetNewValidatorByPowerIndex(s.ctx, val) + _ = s.app.StakingKeeper.Hooks().AfterValidatorCreated(s.ctx, valAddrs[i]) + newShares, err := s.app.StakingKeeper.Delegate(s.ctx, addrs[i], math.NewInt(power), stakingtypes.Unbonded, val, true) + s.Require().NoError(err) + s.Require().Equal(newShares.TruncateInt(), math.NewInt(power)) + msgValidatorBond := &stakingtypes.MsgValidatorBond{ + DelegatorAddress: addrs[i].String(), + ValidatorAddress: val.OperatorAddress, + } + handler := s.app.MsgServiceRouter().Handler(msgValidatorBond) + _, err = handler(s.ctx, msgValidatorBond) + s.Require().NoError(err) + } + + s.app.EndBlocker(s.ctx) + return addrs, valAddrs, pks +} func (s *KeeperTestSuite) liquidStaking(liquidStaker sdk.AccAddress, stakingAmt math.Int) error { ctx, writeCache := s.ctx.CacheContext() diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index 897f1fe..67bd8dc 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -33,7 +33,7 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, e totalUnbondingBalance := math.ZeroInt() ubds, err := k.stakingKeeper.GetAllUnbondingDelegations(ctx, types.LiquidStakeProxyAcc) - if err != nil{ + if err != nil { return nil, err } for _, ubd := range ubds { diff --git a/x/liquidstake/keeper/liquidstake_test.go b/x/liquidstake/keeper/liquidstake_test.go new file mode 100644 index 0000000..87f5b68 --- /dev/null +++ b/x/liquidstake/keeper/liquidstake_test.go @@ -0,0 +1,494 @@ +package keeper_test + +import ( + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + testhelpers "github.com/Asphere-xyz/tacchain/app/helpers" + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +// tests LiquidStake, LiquidUnstake +func (s *KeeperTestSuite) TestLiquidStake() { + sdk.SetBaseDenom("utac") + sdk.GetConfig().SetBech32PrefixForAccount("tac", "tacpub") + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + params.MinLiquidStakeAmount = math.NewInt(50000) + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + stakingAmt := params.MinLiquidStakeAmount + + // fail, no active validator + cachedCtx, _ := s.ctx.CacheContext() + gTACMintAmt, err := s.keeper.LiquidStake( + cachedCtx, types.LiquidStakeProxyAcc, s.delAddrs[0], + sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), + ) + s.Require().ErrorIs(err, types.ErrActiveLiquidValidatorsNotExists) + s.Require().Equal(gTACMintAmt, sdk.ZeroInt()) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(2000)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(2000)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(2000)}, + } + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + res := s.keeper.GetAllLiquidValidatorStates(s.ctx) + s.Require().Equal(params.WhitelistedValidators[0].ValidatorAddress, + res[0].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[0].TargetWeight, + res[0].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[0].Status) + s.Require().Equal(sdk.ZeroDec(), res[0].DelShares) + s.Require().Equal(sdk.ZeroInt(), res[0].LiquidTokens) + + s.Require().Equal(params.WhitelistedValidators[1].ValidatorAddress, + res[1].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[1].TargetWeight, + res[1].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[1].Status) + s.Require().Equal(sdk.ZeroDec(), res[1].DelShares) + s.Require().Equal(sdk.ZeroInt(), res[1].LiquidTokens) + + s.Require().Equal(params.WhitelistedValidators[2].ValidatorAddress, + res[2].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[2].TargetWeight, + res[2].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[2].Status) + s.Require().Equal(sdk.ZeroDec(), res[2].DelShares) + s.Require().Equal(sdk.ZeroInt(), res[2].LiquidTokens) + + ///////////////////////////////////////// + nasTest, err := s.app.LiquidStakeKeeper.GetNetAmountState(s.ctx) + s.T().Logf( + "nasTest.NetAmount: %s", + nasTest.NetAmount, + ) + ///////////////////////////////////////// + + // liquid stake + gTACMintAmt, err = s.keeper.LiquidStake( + s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], + sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), + ) + s.Require().NoError(err) + s.Require().Equal(gTACMintAmt, stakingAmt) + + ///////////////////////////////////////// + nasTest, err = s.app.LiquidStakeKeeper.GetNetAmountState(s.ctx) + s.T().Logf( + "nasTest.NetAmount after liquid stake: %s", + nasTest.NetAmount, + ) + + s.T().Logf( + "nasTest.MintRate after liquid stake: %s", + nasTest.MintRate, + ) + ///////////////////////////////////////// + + _, err = s.app.StakingKeeper.GetDelegation( + s.ctx, s.delAddrs[0], valOpers[0], + ) + s.Require().Error(err) + _, err = s.app.StakingKeeper.GetDelegation( + s.ctx, s.delAddrs[0], valOpers[1], + ) + s.Require().Error(err) + _, err = s.app.StakingKeeper.GetDelegation( + s.ctx, s.delAddrs[0], valOpers[2], + ) + s.Require().Error(err) + + proxyAccDel1, err := s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[0], + ) + s.Require().NoError(err) + proxyAccDel2, err := s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[1], + ) + s.Require().NoError(err) + proxyAccDel3, err := s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[2], + ) + s.Require().NoError(err) + s.Require().Equal(proxyAccDel1.Shares, math.LegacyNewDec(16668)) + s.Require().Equal(proxyAccDel2.Shares, math.LegacyNewDec(16666)) + s.Require().Equal(proxyAccDel2.Shares, math.LegacyNewDec(16666)) + s.Require().Equal(stakingAmt.ToLegacyDec(), + proxyAccDel1.Shares.Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) + + liquidBondDenom := s.keeper.LiquidBondDenom(s.ctx) + balanceBeforeUBD := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, + ) + s.Require().Equal(balanceBeforeUBD.Amount, math.NewInt(999950000)) + ubdGTAC := sdk.NewCoin(liquidBondDenom, math.NewInt(10000)) + gTACBalance := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], liquidBondDenom, + ) + gTACTotalSupply := s.app.BankKeeper.GetSupply( + s.ctx, liquidBondDenom, + ) + s.Require().Equal(gTACBalance, + sdk.NewCoin(liquidBondDenom, math.NewInt(50000))) + s.Require().Equal(gTACBalance, gTACTotalSupply) + + // liquid unstaking + + ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.keeper.LiquidUnstake( + s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], ubdGTAC, + ) + s.Require().NoError(err) + s.Require().EqualValues(unbondedAmt, sdk.ZeroInt()) + s.Require().Len(ubds, 3) + + // crumb excepted on unbonding + crumb := ubdGTAC.Amount.Sub(ubdGTAC.Amount.QuoRaw(3).MulRaw(3)) + s.Require().EqualValues(unbondingAmt, ubdGTAC.Amount.Sub(crumb)) + s.Require().Equal(ubds[0].DelegatorAddress, s.delAddrs[0].String()) + s.Require().Equal(ubdTime, testhelpers.ParseTime("2022-03-22T00:00:00Z")) + gTACBalanceAfter := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], liquidBondDenom, + ) + s.Require().Equal(gTACBalanceAfter, + sdk.NewCoin(liquidBondDenom, math.NewInt(40000))) + + balanceBeginUBD := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, + ) + s.Require().Equal(balanceBeginUBD.Amount, balanceBeforeUBD.Amount) + + proxyAccDel1, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[0], + ) + s.Require().NoError(err) + proxyAccDel2, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[1], + ) + s.Require().NoError(err) + proxyAccDel3, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[2], + ) + s.Require().NoError(err) + s.Require().Equal(stakingAmt.Sub(unbondingAmt).ToLegacyDec(), + proxyAccDel1.GetShares().Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) + + // complete unbonding + s.ctx = s.ctx.WithBlockHeight(200).WithBlockTime(ubdTime.Add(1)) + updates, err := s.app.StakingKeeper.BlockValidatorUpdates(s.ctx) + s.Require().NoError(err) + s.Require().Empty(updates) + balanceCompleteUBD := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, + ) + s.Require().Equal(balanceCompleteUBD.Amount, + balanceBeforeUBD.Amount.Add(unbondingAmt)) + + proxyAccDel1, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[0], + ) + s.Require().NoError(err) + proxyAccDel2, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[1], + ) + s.Require().NoError(err) + proxyAccDel3, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[2], + ) + s.Require().NoError(err) + s.Require().Equal(math.LegacyNewDec(13335), proxyAccDel1.Shares) + s.Require().Equal(math.LegacyNewDec(13333), proxyAccDel2.Shares) + s.Require().Equal(math.LegacyNewDec(13333), proxyAccDel3.Shares) + + res = s.keeper.GetAllLiquidValidatorStates(s.ctx) + s.Require().Equal(params.WhitelistedValidators[0].ValidatorAddress, + res[0].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[0].TargetWeight, + res[0].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[0].Status) + s.Require().Equal(math.LegacyNewDec(13335), res[0].DelShares) + + s.Require().Equal(params.WhitelistedValidators[1].ValidatorAddress, + res[1].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[1].TargetWeight, + res[1].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[1].Status) + s.Require().Equal(math.LegacyNewDec(13333), res[1].DelShares) + + s.Require().Equal(params.WhitelistedValidators[2].ValidatorAddress, + res[2].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[2].TargetWeight, + res[2].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[2].Status) + s.Require().Equal(math.LegacyNewDec(13333), res[2].DelShares) + + // rewards are not autocompounded after validator set update and rebalancing + s.advanceHeight(10, true) + rewards, totalLiquidShares, _, err := s.keeper.CheckDelegationStates( + s.ctx, types.LiquidStakeProxyAcc, + ) + s.Require().NoError(err) + s.Require().NotEqualValues(rewards, sdk.ZeroDec()) + s.Require().EqualValues(totalLiquidShares, proxyAccDel1.Shares.Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) + + // all remaining rewards re-staked, request last unstaking, unbond all + s.keeper.AutocompoundStakingRewards(s.ctx, types.GetWhitelistedValsMap(s.keeper.GetParams(s.ctx).WhitelistedValidators)) + gtacBalanceBefore := s.app.BankKeeper.GetBalance(s.ctx, s.delAddrs[0], params.LiquidBondDenom).Amount + rewards, _, _, err = s.keeper.CheckDelegationStates( + s.ctx, types.LiquidStakeProxyAcc, + ) + s.Require().NoError(err) + s.Require().EqualValues(rewards, sdk.ZeroDec()) + s.Require().NoError( + s.liquidUnstaking(s.delAddrs[0], gtacBalanceBefore, true), + ) + + // still active liquid validator after unbond all + alv := s.keeper.GetActiveLiquidValidators( + s.ctx, params.WhitelistedValsMap(), + ) + s.Require().True(len(alv) != 0) + + // no btoken supply and netAmount after unbond all + nas, err := s.keeper.GetNetAmountState(s.ctx) + s.Require().NoError(err) + s.Require().EqualValues(nas.StkxprtTotalSupply, sdk.ZeroInt()) + s.Require().Equal(nas.TotalRemainingRewards, sdk.ZeroDec()) + s.Require().Equal(nas.TotalDelShares, sdk.ZeroDec()) + s.Require().Equal(nas.TotalLiquidTokens, sdk.ZeroInt()) + s.Require().Equal(nas.ProxyAccBalance, sdk.ZeroInt()) + s.Require().Equal(nas.NetAmount, sdk.ZeroDec()) +} + +func (s *KeeperTestSuite) TestLiquidStakeFromVestingAccount() { + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, + } + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + from := s.delAddrs[0] + vestingAmt := s.app.BankKeeper.GetAllBalances(s.ctx, from) + vestingStartTime := s.ctx.BlockTime().Add(1 * time.Hour) + vestingEndTime := s.ctx.BlockTime().Add(2 * time.Hour) + vestingMidTime := s.ctx.BlockTime().Add(90 * time.Minute) + + vestingAccAddr := "tac10n3ncmlsaqfuwsmfll8kq6hvt4x7c8czk3d7g6" + vestingAcc, err := sdk.AccAddressFromBech32(vestingAccAddr) + s.Require().NoError(err) + + // createContinuousVestingAccount + cVestingAcc := s.createContinuousVestingAccount(from, vestingAcc, vestingAmt, vestingStartTime, vestingEndTime) + spendableCoins := s.app.BankKeeper.SpendableCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().True(spendableCoins.IsZero()) + lockedCoins := s.app.BankKeeper.LockedCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().EqualValues(lockedCoins, vestingAmt) + + // failed liquid stake, no spendable coins on the vesting account ( not allowed locked coins ) + err = s.liquidStaking(vestingAcc, vestingAmt.AmountOf(sdk.DefaultBondDenom)) + s.Require().ErrorIs(err, sdkerrors.ErrInsufficientFunds) + + // release some vesting coins + s.ctx = s.ctx.WithBlockTime(vestingMidTime) + spendableCoins = s.app.BankKeeper.SpendableCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().True(spendableCoins.IsAllPositive()) + lockedCoins = s.app.BankKeeper.LockedCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().True(lockedCoins.IsAllPositive()) + + // success with released spendable coins + err = s.liquidStaking(vestingAcc, spendableCoins.AmountOf(sdk.DefaultBondDenom)) + s.Require().NoError(err) + nas, err := s.keeper.GetNetAmountState(s.ctx) + s.Require().NoError(err) + s.Require().EqualValues(nas.TotalLiquidTokens, spendableCoins.AmountOf(sdk.DefaultBondDenom)) +} + +func (s *KeeperTestSuite) TestLiquidStakeEdgeCases() { + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + stakingAmt := math.NewInt(5000000) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, + } + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + // fail Invalid BondDenom case + _, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], sdk.NewCoin("bad", stakingAmt)) + s.Require().ErrorIs(err, types.ErrInvalidBondDenom) + + // liquid stake, unstaking with huge amount + hugeAmt := math.NewInt(1_000_000_000_000_000_000) + s.fundAddr(s.delAddrs[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, hugeAmt.MulRaw(2)))) + s.Require().NoError(s.liquidStaking(s.delAddrs[0], hugeAmt)) + s.Require().NoError(s.liquidStaking(s.delAddrs[0], hugeAmt)) + s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], math.NewInt(10), true)) + s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], hugeAmt, true)) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + s.completeRedelegationUnbonding() + states, err := s.keeper.GetNetAmountState(s.ctx) + s.Require().NoError(err) + states.TotalLiquidTokens.Equal(hugeAmt) +} + +func (s *KeeperTestSuite) TestLiquidUnstakeEdgeCases() { + mintParams, err := s.app.MintKeeper.Params.Get(s.ctx) + s.Require().NoError(err) + mintParams.InflationMax = math.LegacyNewDec(0) + mintParams.InflationMin = math.LegacyNewDec(0) + mintParams.InflationRateChange = math.LegacyNewDec(0) + err = s.app.MintKeeper.Params.Set(s.ctx, mintParams) + s.Require().NoError(err) + + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + stakingAmt := math.NewInt(5000000) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, + } + params.ModulePaused = false + s.Require().NoError(s.keeper.SetParams(s.ctx, params)) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + // success liquid stake + s.Require().NoError(s.liquidStaking(s.delAddrs[0], stakingAmt)) + + // fail when liquid unstaking with too small amount + _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(2))) + s.Require().ErrorIs(err, types.ErrTooSmallLiquidUnstakingAmount) + + // fail when liquid unstaking with zero amount + _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(0))) + s.Require().ErrorIs(err, types.ErrTooSmallLiquidUnstakingAmount) + + // fail when invalid liquid bond denom + _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin("stake", math.NewInt(10000))) + s.Require().ErrorIs(err, types.ErrInvalidLiquidBondDenom) + + // verify that there is no problem performing liquid unstaking as much as the MaxEntries + stakingParams, err := s.app.StakingKeeper.GetParams(s.ctx) + s.Require().NoError(err) + for i := uint32(0); i < stakingParams.MaxEntries; i++ { + s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], math.NewInt(1000), false)) + } + + // on sdk 0.47+ shouldn't fail in an attempt to go beyond MaxEntries + err = s.liquidUnstaking(s.delAddrs[0], math.NewInt(1000), false) + s.Require().NoError(err) + + dels, err := s.app.StakingKeeper.GetUnbondingDelegations(s.ctx, s.delAddrs[0], 100) + s.Require().NoError(err) + for _, ubd := range dels { + s.Require().EqualValues(1, len(ubd.Entries)) + } + + // set empty whitelisted, active liquid validator + params.WhitelistedValidators = []types.WhitelistedValidator{} + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + // error case where there is a quantity that are unbonding balance or remaining rewards that is not re-stake or withdrawn in netAmount. + // NOT APPLICABLE since we do not validator unbond if validator goes inactive. + //_, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(1000))) + //s.Require().ErrorIs(err, types.ErrInsufficientProxyAccBalance) + + // success after complete unbonding, Not applicable + s.completeRedelegationUnbonding() + // ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(1000))) + // s.Require().NoError(err) + // s.Require().EqualValues(unbondedAmt, math.NewInt(1000)) + // s.Require().EqualValues(unbondingAmt, sdk.ZeroInt()) + // s.Require().EqualValues(ubdTime, time.Time{}) + // s.Require().Len(ubds, 0) +} + +func (s *KeeperTestSuite) TestShareInflation() { + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000, 4000000}) + params := s.keeper.GetParams(s.ctx) + + // set minimum amount and unstake fee to 0 for testing + params.MinLiquidStakeAmount = math.NewInt(0) + params.UnstakeFeeRate = sdk.NewDec(0) + s.keeper.SetParams(s.ctx, params) + + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(2500)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(2500)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(2500)}, + {ValidatorAddress: valOpers[3].String(), TargetWeight: math.NewInt(2500)}, + } + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + initialStakingAmt := math.NewInt(1) // little amount + initializingStakingAmt := math.NewInt(10000) // normal amount + attacker := s.delAddrs[0] + user := s.delAddrs[1] + protocol := s.delAddrs[3] + + // 0. [a solution?] be first depositor + mintAmount0, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, + protocol, sdk.NewCoin(sdk.DefaultBondDenom, initializingStakingAmt)) + s.Require().NoError(err) + s.Require().Equal(mintAmount0, initializingStakingAmt) + + // 1. attacker becomes first depositor and liquid stake + mintAmount, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, + attacker, sdk.NewCoin(sdk.DefaultBondDenom, initialStakingAmt)) + s.Require().NoError(err) + s.Require().Equal(mintAmount, initialStakingAmt) + + // 2. The user sends a liquid stake message, but their tx got front-run by the attacker + // ideally, the user should get 1000 gTAC (1 * 1000 / 1) + // gTAC to mint = gTAC supply * sent TAC / total TAC + userStakeAmount := math.NewInt(1_000) + + // 3. attacker's tx got accepted first which sends funds directly to proxy account + attackerTransferAmount := userStakeAmount.Quo(sdk.NewInt(2)) + s.app.BankKeeper.SendCoins(s.ctx, attacker, types.LiquidStakeProxyAcc, + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, attackerTransferAmount))) + + // 4. user tx went through and the mint rate is not affected by the TAC sent by the attacker + // gTAC to mint = 1 * 1000 / 1 = 1 + mintAmount, err = s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, user, sdk.NewCoin(sdk.DefaultBondDenom, userStakeAmount)) + s.Require().NoError(err) + s.Require().Equal(mintAmount, math.NewInt(1_000)) + + // 5. attacker unstakes the shares immediately + liquidBondDenom := s.keeper.LiquidBondDenom(s.ctx) + _, unbondingAmt, _, _, err := s.keeper.LiquidUnstake(s.ctx, types.LiquidStakeProxyAcc, attacker, sdk.NewCoin(liquidBondDenom, sdk.NewInt(1))) + // s.Require().NoError(err) + s.Require().ErrorContains(err, "liquid unstaking amount is too small") + + attackerProfit := unbondingAmt.Sub(initialStakingAmt).Sub(attackerTransferAmount) + s.Require().LessOrEqual(attackerProfit.Int64(), math.ZeroInt().Int64()) +} From 9bf0dd717e63ef0c8bca514cd63800a98edef8ef Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 22 Jul 2025 13:17:51 +0300 Subject: [PATCH 070/112] fix: added app helpers --- app/helpers/test_helpers.go | 174 ++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 app/helpers/test_helpers.go diff --git a/app/helpers/test_helpers.go b/app/helpers/test_helpers.go new file mode 100644 index 0000000..2df6b7c --- /dev/null +++ b/app/helpers/test_helpers.go @@ -0,0 +1,174 @@ +package helpers + +import ( + "bytes" + "fmt" + "strconv" + "testing" + "time" + + "encoding/hex" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + "cosmossdk.io/math" + chain "github.com/Asphere-xyz/tacchain/app" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *chain.TacChainApp { + db := dbm.NewMemDB() + logger := log.NewTestLogger(t) + return chain.NewTacChainAppWithCustomOptions(t, isCheckTx, invCheckPeriod, chain.SetupOptions{ + Logger: logger, + DB: db, + AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), + }) +} + +// AddTestAddrs constructs and returns accNum amount of accounts with an +// initial balance of accAmt in random order +func AddTestAddrs(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { + return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts) +} + +type GenerateAccountStrategy func(int) []sdk.AccAddress + +func addTestAddrs(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { + testAddrs := strategy(accNum) + + initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, accAmt)) + + for _, addr := range testAddrs { + InitAccountWithCoins(app, ctx, addr, initCoins) + } + + return testAddrs +} + +// createRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order. +func createRandomAccounts(accNum int) []sdk.AccAddress { + testAddrs := make([]sdk.AccAddress, accNum) + for i := 0; i < accNum; i++ { + pk := ed25519.GenPrivKey().PubKey() + testAddrs[i] = sdk.AccAddress(pk.Address()) + } + + return testAddrs +} + +func InitAccountWithCoins(app *chain.TacChainApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { + err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) + if err != nil { + panic(err) + } + + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) + if err != nil { + panic(err) + } +} + +// ConvertAddrsToValAddrs converts the provided addresses to ValAddress. +func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { + valAddrs := make([]sdk.ValAddress, len(addrs)) + + for i, addr := range addrs { + valAddrs[i] = sdk.ValAddress(addr) + } + + return valAddrs +} + +// ParseTime parses and returns time.Time in time.RFC3339 format. +func ParseTime(s string) time.Time { + t, err := time.Parse(time.RFC3339, s) + if err != nil { + panic(err) + } + return t +} + +// AddTestAddrs constructs and returns accNum amount of accounts with an +// initial balance of accAmt in random order +func AddTestAddrsIncremental(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { + return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) +} + +// createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order. +func createIncrementalAccounts(accNum int) []sdk.AccAddress { + var addresses []sdk.AccAddress + var buffer bytes.Buffer + + // start at 100 so we can make up to 999 test addresses with valid test addresses + for i := 100; i < (accNum + 100); i++ { + numString := strconv.Itoa(i) + buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string + + buffer.WriteString(numString) // adding on final two digits to make addresses unique + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) + bech := res.String() + addr, _ := TestAddr(buffer.String(), bech) + + addresses = append(addresses, addr) + buffer.Reset() + } + + return addresses +} + +func TestAddr(addr, bech string) (sdk.AccAddress, error) { + res, err := sdk.AccAddressFromHexUnsafe(addr) + if err != nil { + return nil, err + } + bechexpected := res.String() + if bech != bechexpected { + return nil, fmt.Errorf("bech encoding doesn't match reference") + } + + bechres, err := sdk.AccAddressFromBech32(bech) + if err != nil { + return nil, err + } + if !bytes.Equal(bechres, res) { + return nil, err + } + + return res, nil +} + +// CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. +func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { + var publicKeys []cryptotypes.PubKey + var buffer bytes.Buffer + + // start at 10 to avoid changing 1 to 01, 2 to 02, etc + for i := 100; i < (numPubKeys + 100); i++ { + numString := strconv.Itoa(i) + buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string + buffer.WriteString(numString) // adding on final two digits to make pubkeys unique + publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String())) + buffer.Reset() + } + + return publicKeys +} + +// NewPubKeyFromHex returns a PubKey from a hex string. +func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { + pkBytes, err := hex.DecodeString(pk) + if err != nil { + panic(err) + } + if len(pkBytes) != ed25519.PubKeySize { + panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) + } + return &ed25519.PubKey{Key: pkBytes} +} From 7a17e67b2f71cc4bf46ae5103677d4bcfa905a1f Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Wed, 23 Jul 2025 11:22:09 +0300 Subject: [PATCH 071/112] feat: added epochs module and upgraded cosmos sdk --- app/app.go | 18 +- go.mod | 5 +- go.sum | 2 + utils/cache_ctx.go | 60 +++ utils/epoch.go | 13 + utils/proofs.go | 64 +++ x/epochs/client/cli/query.go | 107 ++++ x/epochs/keeper/abci.go | 65 +++ x/epochs/keeper/epoch.go | 122 +++++ x/epochs/keeper/genesis.go | 25 + x/epochs/keeper/grpc_query.go | 56 +++ x/epochs/keeper/hooks.go | 17 + x/epochs/keeper/keeper.go | 44 ++ x/epochs/module.go | 158 ++++++ x/epochs/types/doc.go | 4 + x/epochs/types/errors.go | 12 + x/epochs/types/events.go | 9 + x/epochs/types/genesis.go | 77 +++ x/epochs/types/genesis.pb.go | 789 +++++++++++++++++++++++++++++ x/epochs/types/hooks.go | 59 +++ x/epochs/types/keys.go | 12 + x/epochs/types/query.pb.go | 912 ++++++++++++++++++++++++++++++++++ x/epochs/types/query.pb.gw.go | 236 +++++++++ x/liquidstake/keeper/hooks.go | 18 +- 24 files changed, 2869 insertions(+), 15 deletions(-) create mode 100644 utils/cache_ctx.go create mode 100644 utils/epoch.go create mode 100644 utils/proofs.go create mode 100644 x/epochs/client/cli/query.go create mode 100644 x/epochs/keeper/abci.go create mode 100644 x/epochs/keeper/epoch.go create mode 100644 x/epochs/keeper/genesis.go create mode 100644 x/epochs/keeper/grpc_query.go create mode 100644 x/epochs/keeper/hooks.go create mode 100644 x/epochs/keeper/keeper.go create mode 100644 x/epochs/module.go create mode 100644 x/epochs/types/doc.go create mode 100644 x/epochs/types/errors.go create mode 100644 x/epochs/types/events.go create mode 100644 x/epochs/types/genesis.go create mode 100644 x/epochs/types/genesis.pb.go create mode 100644 x/epochs/types/hooks.go create mode 100644 x/epochs/types/keys.go create mode 100644 x/epochs/types/query.pb.go create mode 100644 x/epochs/types/query.pb.gw.go diff --git a/app/app.go b/app/app.go index 0f74bdc..5175497 100644 --- a/app/app.go +++ b/app/app.go @@ -12,6 +12,9 @@ import ( _ "github.com/ethereum/go-ethereum/eth/tracers/js" _ "github.com/ethereum/go-ethereum/eth/tracers/native" + "github.com/Asphere-xyz/tacchain/x/epochs" + epochskeeper "github.com/Asphere-xyz/tacchain/x/epochs/keeper" + epochstypes "github.com/Asphere-xyz/tacchain/x/epochs/types" abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" @@ -241,6 +244,7 @@ type TacChainApp struct { // module configurator configurator module.Configurator + EpochsKeeper *epochskeeper.Keeper // liquidstake keeper LiquidStakeKeeper liquidstakekeeper.Keeper @@ -310,7 +314,7 @@ func NewTacChainApp( authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, // non sdk store keys capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, - icahosttypes.StoreKey, icacontrollertypes.StoreKey, + icahosttypes.StoreKey, epochstypes.StoreKey, icacontrollertypes.StoreKey, // liquidstake module liquidstaketypes.StoreKey, // Cosmos EVM store keys @@ -558,6 +562,8 @@ func NewTacChainApp( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper + app.EpochsKeeper = epochskeeper.NewKeeper(keys[epochstypes.StoreKey]) + // liquidstake keeper app.LiquidStakeKeeper = liquidstakekeeper.NewKeeper( encodingConfig.Codec, @@ -572,6 +578,12 @@ func NewTacChainApp( authAddr, ) + app.EpochsKeeper.SetHooks( + epochstypes.NewMultiEpochHooks( + app.LiquidStakeKeeper.EpochHooks(), + ), + ) + // Cosmos EVM keepers app.FeeMarketKeeper = evmfeemarketkeeper.NewKeeper( encodingConfig.Codec, authtypes.NewModuleAddress(govtypes.ModuleName), @@ -734,6 +746,7 @@ func NewTacChainApp( upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), + epochs.NewAppModule(*app.EpochsKeeper), authzmodule.NewAppModule(encodingConfig.Codec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), groupmodule.NewAppModule(encodingConfig.Codec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), nftmodule.NewAppModule(encodingConfig.Codec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), @@ -789,6 +802,7 @@ func NewTacChainApp( capabilitytypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, + epochstypes.ModuleName, // liquidstake module after staking liquidstaketypes.ModuleName, slashingtypes.ModuleName, @@ -830,6 +844,7 @@ func NewTacChainApp( feegrant.ModuleName, group.ModuleName, // no-op modules + epochstypes.ModuleName, stakingtypes.ModuleName, liquidstaketypes.ModuleName, ibctransfertypes.ModuleName, @@ -872,6 +887,7 @@ func NewTacChainApp( ibcexported.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, + epochstypes.ModuleName, // liquidstake module liquidstaketypes.ModuleName, diff --git a/go.mod b/go.mod index 5369d3d..3e1faea 100644 --- a/go.mod +++ b/go.mod @@ -240,7 +240,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.32.0 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.10.0 // indirect @@ -277,8 +277,7 @@ replace ( // // use Cosmos-SDK fork to enable Ledger functionality // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - // github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd - github.com/cosmos/cosmos-sdk => ../../cosmos-sdk/ + github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index 4064183..1c4fb1d 100644 --- a/go.sum +++ b/go.sum @@ -1004,6 +1004,8 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= +github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 h1:ddqzU2x2ZpPPvQKhBqPj9TZNtSyp0UsA5Ip2+elxlRM= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= diff --git a/utils/cache_ctx.go b/utils/cache_ctx.go new file mode 100644 index 0000000..6546d8f --- /dev/null +++ b/utils/cache_ctx.go @@ -0,0 +1,60 @@ +package utils + +import ( + "errors" + "fmt" + "runtime" + "runtime/debug" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ApplyFuncIfNoError This function lets you run the function f, but if theres an error or panic +// drop the state machine change and log the error. +// If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness) +// Try to avoid usage of iterators in f. +func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error) { + // Add a panic safeguard + defer func() { + if recoveryError := recover(); recoveryError != nil { + PrintPanicRecoveryError(ctx, recoveryError) + + err = errors.New("panic occurred during execution") + } + }() + // makes a new cache context, which all state changes get wrapped inside of. + cacheCtx, write := ctx.CacheContext() + + err = f(cacheCtx) + if err != nil { + ctx.Logger().Error(err.Error()) + } else { + // no error, write the output of f + write() + } + + return err +} + +// PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. +// If not emits them to stdout. +func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{}) { + errStackTrace := string(debug.Stack()) + + switch e := recoveryError.(type) { + case string: + ctx.Logger().Error("Recovering from (string) panic: " + e) + case runtime.Error: + ctx.Logger().Error("recovered (runtime.Error) panic: " + e.Error()) + case error: + ctx.Logger().Error("recovered (error) panic: " + e.Error()) + default: + ctx.Logger().Error("recovered (default) panic. Could not capture logs in ctx, see stdout") + fmt.Println("Recovering from panic ", recoveryError) + + debug.PrintStack() + + return + } + ctx.Logger().Error("stack trace: " + errStackTrace) +} diff --git a/utils/epoch.go b/utils/epoch.go new file mode 100644 index 0000000..726c3ef --- /dev/null +++ b/utils/epoch.go @@ -0,0 +1,13 @@ +package utils + +import ( + "sort" + + "golang.org/x/exp/constraints" +) + +func SortSlice[T constraints.Ordered](s []T) { + sort.Slice(s, func(i, j int) bool { + return s[i] < s[j] + }) +} diff --git a/utils/proofs.go b/utils/proofs.go new file mode 100644 index 0000000..35009d1 --- /dev/null +++ b/utils/proofs.go @@ -0,0 +1,64 @@ +package utils + +import ( + "fmt" + + "cosmossdk.io/errors" + "github.com/cometbft/cometbft/proto/tendermint/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibcKeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" +) + +func ValidateProofOps(ctx sdk.Context, ibcKeeper *ibcKeeper.Keeper, connectionID string, chainID string, height int64, module string, key []byte, data []byte, proofOps *crypto.ProofOps) error { + if proofOps == nil { + return fmt.Errorf("unable to validate proof. No proof submitted") + } + + connection, found := ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) + if !found { + return fmt.Errorf("connection %s not found", connectionID) + } + + csHeight := clienttypes.NewHeight(clienttypes.ParseChainID(chainID), uint64(height)+1) + consensusState, found := ibcKeeper.ClientKeeper.GetClientConsensusState(ctx, connection.ClientId, csHeight) + + if !found { + return fmt.Errorf("unable to fetch consensus state") + } + + tmConsState, ok := consensusState.(*ibctm.ConsensusState) + if !ok { + return fmt.Errorf("error unmarshaling consensus state") + } + + clientState, found := ibcKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId) + if !found { + return fmt.Errorf("unable to fetch client state") + } + + path := commitmenttypes.NewMerklePath([]string{module, string(key)}...) + + merkleProof, err := commitmenttypes.ConvertProofs(proofOps) + if err != nil { + return fmt.Errorf("error converting proofs") + } + + tmClientState, ok := clientState.(*ibctm.ClientState) + if !ok { + return fmt.Errorf("error unmarshaling client state") + } + + if len(data) != 0 { + err = merkleProof.VerifyMembership(tmClientState.ProofSpecs, tmConsState.GetRoot(), path, data) + err = errors.Wrap(err, "unable to verify inclusion proof") + } else { + // if we got a nil response, verify non inclusion proof. + err = merkleProof.VerifyNonMembership(tmClientState.ProofSpecs, tmConsState.GetRoot(), path) + err = errors.Wrap(err, "unable to verify non-inclusion proof") + } + + return err +} diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go new file mode 100644 index 0000000..0da8789 --- /dev/null +++ b/x/epochs/client/cli/query.go @@ -0,0 +1,107 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + // Group epochs queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetCmdEpochsInfos(), + GetCmdCurrentEpoch(), + ) + + return cmd +} + +// GetCmdEpochsInfos provide running epochInfos. +func GetCmdEpochsInfos() *cobra.Command { + cmd := &cobra.Command{ + Use: "epoch-infos", + Short: "Query running epochInfos", + Long: strings.TrimSpace( + fmt.Sprintf(`Query running epoch infos. + +Example: +$ %s query epochs epoch-infos +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.EpochInfos(cmd.Context(), &types.QueryEpochsInfoRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdCurrentEpoch provides current epoch by specified identifier. +func GetCmdCurrentEpoch() *cobra.Command { + cmd := &cobra.Command{ + Use: "current-epoch", + Short: "Query current epoch by specified identifier", + Long: strings.TrimSpace( + fmt.Sprintf(`Query current epoch by specified identifier. + +Example: +$ %s query epochs current-epoch day +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.CurrentEpoch(cmd.Context(), &types.QueryCurrentEpochRequest{ + Identifier: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/epochs/keeper/abci.go b/x/epochs/keeper/abci.go new file mode 100644 index 0000000..37a4534 --- /dev/null +++ b/x/epochs/keeper/abci.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "fmt" + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// BeginBlocker of epochs module. +func (k Keeper) BeginBlocker(ctx sdk.Context) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { + logger := k.Logger(ctx) + + // If blocktime < initial epoch start time, return + if ctx.BlockTime().Before(epochInfo.StartTime) { + return + } + // if epoch counting hasn't started, signal we need to start. + shouldInitialEpochStart := !epochInfo.EpochCountingStarted + + epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) + shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart + + if !shouldEpochStart { + return false + } + epochInfo.CurrentEpochStartHeight = ctx.BlockHeight() + + if shouldInitialEpochStart { + epochInfo.EpochCountingStarted = true + epochInfo.CurrentEpoch = 1 + epochInfo.CurrentEpochStartTime = epochInfo.StartTime + logger.Info(fmt.Sprintf("Starting new epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) + } else { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeEpochEnd, + sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)), + ), + ) + k.AfterEpochEnd(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch) + epochInfo.CurrentEpoch++ + epochInfo.CurrentEpochStartTime = epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) + logger.Info(fmt.Sprintf("Starting epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) + } + + // emit new epoch start event, set epoch info, and run BeforeEpochStart hook + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeEpochStart, + sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)), + sdk.NewAttribute(types.AttributeEpochStartTime, fmt.Sprintf("%d", epochInfo.CurrentEpochStartTime.Unix())), + ), + ) + k.setEpochInfo(ctx, epochInfo) + k.BeforeEpochStart(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch) + + return false + }) +} diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go new file mode 100644 index 0000000..6255f33 --- /dev/null +++ b/x/epochs/keeper/epoch.go @@ -0,0 +1,122 @@ +package keeper + +import ( + "fmt" + "time" + + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/gogoproto/proto" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// GetEpochInfo returns epoch info by identifier. +func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo { + epoch := types.EpochInfo{} + store := ctx.KVStore(k.storeKey) + + b := store.Get(append(types.KeyPrefixEpoch, []byte(identifier)...)) + if b == nil { + return epoch + } + + err := proto.Unmarshal(b, &epoch) + if err != nil { + panic(err) + } + + return epoch +} + +// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation, +// or re-uses an existing identifier. +// This method also sets the start time if left unset, and sets the epoch start height. +func (k Keeper) AddEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error { + err := epoch.Validate() + if err != nil { + return err + } + // Check if identifier already exists + if (k.GetEpochInfo(ctx, epoch.Identifier) != types.EpochInfo{}) { + return fmt.Errorf("epoch with identifier %s already exists", epoch.Identifier) + } + + // Initialize empty and default epoch values + if epoch.StartTime.Equal(time.Time{}) { + epoch.StartTime = ctx.BlockTime() + } + + epoch.CurrentEpochStartHeight = ctx.BlockHeight() + k.setEpochInfo(ctx, epoch) + + return nil +} + +// setEpochInfo set epoch info. +func (k Keeper) setEpochInfo(ctx sdk.Context, epoch types.EpochInfo) { + store := ctx.KVStore(k.storeKey) + + value, err := proto.Marshal(&epoch) + if err != nil { + panic(err) + } + + store.Set(append(types.KeyPrefixEpoch, []byte(epoch.Identifier)...), value) +} + +// DeleteEpochInfo delete epoch info. +func (k Keeper) DeleteEpochInfo(ctx sdk.Context, identifier string) { + store := ctx.KVStore(k.storeKey) + store.Delete(append(types.KeyPrefixEpoch, []byte(identifier)...)) +} + +// IterateEpochInfo iterate through epochs. +func (k Keeper) IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + iterator := storetypes.KVStorePrefixIterator(store, types.KeyPrefixEpoch) + defer iterator.Close() + + i := int64(0) + + for ; iterator.Valid(); iterator.Next() { + epoch := types.EpochInfo{} + + err := proto.Unmarshal(iterator.Value(), &epoch) + if err != nil { + panic(err) + } + + stop := fn(i, epoch) + if stop { + break + } + i++ + } +} + +// AllEpochInfos iterate through epochs to return all epochs info. +func (k Keeper) AllEpochInfos(ctx sdk.Context) []types.EpochInfo { + epochs := []types.EpochInfo{} + + k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { + epochs = append(epochs, epochInfo) + return false + }) + + return epochs +} + +// NumBlocksSinceEpochStart returns the number of blocks since the epoch started. +// if the epoch started on block N, then calling this during block N (after BeforeEpochStart) +// would return 0. +// Calling it any point in block N+1 (assuming the epoch doesn't increment) would return 1. +func (k Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (int64, error) { + epoch := k.GetEpochInfo(ctx, identifier) + if (epoch == types.EpochInfo{}) { + return 0, fmt.Errorf("epoch with identifier %s not found", identifier) + } + + return ctx.BlockHeight() - epoch.CurrentEpochStartHeight, nil +} diff --git a/x/epochs/keeper/genesis.go b/x/epochs/keeper/genesis.go new file mode 100644 index 0000000..f957b98 --- /dev/null +++ b/x/epochs/keeper/genesis.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// InitGenesis sets epoch info from genesis +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + for _, epoch := range genState.Epochs { + err := k.AddEpochInfo(ctx, epoch) + if err != nil { + panic(err) + } + } +} + +// ExportGenesis returns the capability module's exported genesis. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Epochs = k.AllEpochInfos(ctx) + + return genesis +} diff --git a/x/epochs/keeper/grpc_query.go b/x/epochs/keeper/grpc_query.go new file mode 100644 index 0000000..c7fa2e0 --- /dev/null +++ b/x/epochs/keeper/grpc_query.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "context" + "errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +var _ types.QueryServer = Querier{} + +// Querier defines a wrapper around the x/epochs keeper providing gRPC method +// handlers. +type Querier struct { + Keeper +} + +// NewQuerier initializes new querier. +func NewQuerier(k Keeper) Querier { + return Querier{Keeper: k} +} + +// EpochInfos provide running epochInfos. +func (q Querier) EpochInfos(c context.Context, _ *types.QueryEpochsInfoRequest) (*types.QueryEpochsInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryEpochsInfoResponse{ + Epochs: q.Keeper.AllEpochInfos(ctx), + }, nil +} + +// CurrentEpoch provides current epoch of specified identifier. +func (q Querier) CurrentEpoch(c context.Context, req *types.QueryCurrentEpochRequest) (*types.QueryCurrentEpochResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.Identifier == "" { + return nil, status.Error(codes.InvalidArgument, "identifier is empty") + } + + ctx := sdk.UnwrapSDKContext(c) + + info := q.Keeper.GetEpochInfo(ctx, req.Identifier) + if info.Identifier != req.Identifier { + return nil, errors.New("not available identifier") + } + + return &types.QueryCurrentEpochResponse{ + CurrentEpoch: info.CurrentEpoch, + }, nil +} diff --git a/x/epochs/keeper/hooks.go b/x/epochs/keeper/hooks.go new file mode 100644 index 0000000..77cc630 --- /dev/null +++ b/x/epochs/keeper/hooks.go @@ -0,0 +1,17 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// AfterEpochEnd gets called at the end of the epoch, end of epoch is the timestamp of first block produced after epoch duration. +func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber int64) { + // Error is not handled as AfterEpochEnd Hooks use osmoutils.ApplyFuncIfNoError() + _ = k.hooks.AfterEpochEnd(ctx, identifier, epochNumber) +} + +// BeforeEpochStart new epoch is next block of epoch end block +func (k Keeper) BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber int64) { + // Error is not handled as BeforeEpochStart Hooks use osmoutils.ApplyFuncIfNoError() + _ = k.hooks.BeforeEpochStart(ctx, identifier, epochNumber) +} diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go new file mode 100644 index 0000000..21daadf --- /dev/null +++ b/x/epochs/keeper/keeper.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +type ( + Keeper struct { + storeKey storetypes.StoreKey + hooks types.EpochHooks + } +) + +// NewKeeper returns a new keeper by codec and storeKey inputs. +func NewKeeper(storeKey storetypes.StoreKey) *Keeper { + return &Keeper{ + storeKey: storeKey, + } +} + +// Set the gamm hooks. +func (k *Keeper) SetHooks(eh types.EpochHooks) *Keeper { + if k.hooks != nil { + panic("cannot set epochs hooks twice") + } + + k.hooks = eh + + return k +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) HooksIsNil() bool { + return k.hooks == nil +} diff --git a/x/epochs/module.go b/x/epochs/module.go new file mode 100644 index 0000000..26f99f2 --- /dev/null +++ b/x/epochs/module.go @@ -0,0 +1,158 @@ +/* +Often in the SDK, we would like to run certain code every-so often. The +purpose of `epochs` module is to allow other modules to set that they +would like to be signaled once every period. So another module can +specify it wants to execute code once a week, starting at UTC-time = x. +`epochs` creates a generalized epoch interface to other modules so that +they can easily be signalled upon such events. + - Contains functionality for querying epoch. + - Events for BeginBlock and EndBlock. + - Initialization for epoch-related infos. +*/ + +package epochs + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/Asphere-xyz/tacchain/x/epochs/client/cli" + "github.com/Asphere-xyz/tacchain/x/epochs/keeper" + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ appmodule.HasBeginBlocker = AppModule{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct{} + +func NewAppModuleBasic() AppModuleBasic { + return AppModuleBasic{} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the module's Amino codec that properly handles protobuf types with Any's. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types. +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns no root tx command for the halving module. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { return nil } + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule(keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + am.keeper.InitGenesis(ctx, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx context.Context) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + am.keeper.BeginBlocker(sdkCtx) + return nil +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/epochs/types/doc.go b/x/epochs/types/doc.go new file mode 100644 index 0000000..c1b138d --- /dev/null +++ b/x/epochs/types/doc.go @@ -0,0 +1,4 @@ +/* +Package types translates gRPC into RESTful JSON APIs. +*/ +package types diff --git a/x/epochs/types/errors.go b/x/epochs/types/errors.go new file mode 100644 index 0000000..862294b --- /dev/null +++ b/x/epochs/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + "cosmossdk.io/errors" +) + +// x/epochs module sentinel errors. +var ( + ErrSample = errors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/epochs/types/events.go b/x/epochs/types/events.go new file mode 100644 index 0000000..da0ac83 --- /dev/null +++ b/x/epochs/types/events.go @@ -0,0 +1,9 @@ +package types + +const ( + EventTypeEpochEnd = "epoch_end" + EventTypeEpochStart = "epoch_start" + + AttributeEpochNumber = "epoch_number" + AttributeEpochStartTime = "start_time" +) diff --git a/x/epochs/types/genesis.go b/x/epochs/types/genesis.go new file mode 100644 index 0000000..613c111 --- /dev/null +++ b/x/epochs/types/genesis.go @@ -0,0 +1,77 @@ +package types + +import ( + "errors" + "time" +) + +// DefaultIndex is the default capability global index. +const DefaultIndex uint64 = 1 + +func NewGenesisState(epochs []EpochInfo) *GenesisState { + return &GenesisState{Epochs: epochs} +} + +// DefaultGenesis returns the default Capability genesis state. +func DefaultGenesis() *GenesisState { + epochs := []EpochInfo{ + NewGenesisEpochInfo("day", time.Hour*24), // alphabetical order + NewGenesisEpochInfo("hour", time.Hour), + NewGenesisEpochInfo("week", time.Hour*24*7), + } + + return NewGenesisState(epochs) +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + epochIdentifiers := map[string]bool{} + + for _, epoch := range gs.Epochs { + if err := epoch.Validate(); err != nil { + return err + } + + if epochIdentifiers[epoch.Identifier] { + return errors.New("epoch identifier should be unique") + } + + epochIdentifiers[epoch.Identifier] = true + } + + return nil +} + +// Validate also validates epoch info. +func (epoch EpochInfo) Validate() error { + if epoch.Identifier == "" { + return errors.New("epoch identifier should NOT be empty") + } + + if epoch.Duration == 0 { + return errors.New("epoch duration should NOT be 0") + } + + if epoch.CurrentEpoch < 0 { + return errors.New("epoch CurrentEpoch must be non-negative") + } + + if epoch.CurrentEpochStartHeight < 0 { + return errors.New("epoch CurrentEpoch must be non-negative") + } + + return nil +} + +func NewGenesisEpochInfo(identifier string, duration time.Duration) EpochInfo { + return EpochInfo{ + Identifier: identifier, + StartTime: time.Time{}, + Duration: duration, + CurrentEpoch: 0, + CurrentEpochStartHeight: 0, + CurrentEpochStartTime: time.Time{}, + EpochCountingStarted: false, + } +} diff --git a/x/epochs/types/genesis.pb.go b/x/epochs/types/genesis.pb.go new file mode 100644 index 0000000..9617a03 --- /dev/null +++ b/x/epochs/types/genesis.pb.go @@ -0,0 +1,789 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: tacchain/epochs/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 EpochInfo struct { + Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` + StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + Duration time.Duration `protobuf:"bytes,3,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"` + CurrentEpoch int64 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` + CurrentEpochStartTime time.Time `protobuf:"bytes,5,opt,name=current_epoch_start_time,json=currentEpochStartTime,proto3,stdtime" json:"current_epoch_start_time" yaml:"current_epoch_start_time"` + EpochCountingStarted bool `protobuf:"varint,6,opt,name=epoch_counting_started,json=epochCountingStarted,proto3" json:"epoch_counting_started,omitempty"` + CurrentEpochStartHeight int64 `protobuf:"varint,8,opt,name=current_epoch_start_height,json=currentEpochStartHeight,proto3" json:"current_epoch_start_height,omitempty"` +} + +func (m *EpochInfo) Reset() { *m = EpochInfo{} } +func (m *EpochInfo) String() string { return proto.CompactTextString(m) } +func (*EpochInfo) ProtoMessage() {} +func (*EpochInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_1d2331ae1f5f4a03, []int{0} +} +func (m *EpochInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EpochInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EpochInfo.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 *EpochInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_EpochInfo.Merge(m, src) +} +func (m *EpochInfo) XXX_Size() int { + return m.Size() +} +func (m *EpochInfo) XXX_DiscardUnknown() { + xxx_messageInfo_EpochInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_EpochInfo proto.InternalMessageInfo + +func (m *EpochInfo) GetIdentifier() string { + if m != nil { + return m.Identifier + } + return "" +} + +func (m *EpochInfo) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +func (m *EpochInfo) GetDuration() time.Duration { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *EpochInfo) GetCurrentEpoch() int64 { + if m != nil { + return m.CurrentEpoch + } + return 0 +} + +func (m *EpochInfo) GetCurrentEpochStartTime() time.Time { + if m != nil { + return m.CurrentEpochStartTime + } + return time.Time{} +} + +func (m *EpochInfo) GetEpochCountingStarted() bool { + if m != nil { + return m.EpochCountingStarted + } + return false +} + +func (m *EpochInfo) GetCurrentEpochStartHeight() int64 { + if m != nil { + return m.CurrentEpochStartHeight + } + return 0 +} + +// GenesisState defines the epochs module's genesis state. +type GenesisState struct { + Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"` +} + +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_1d2331ae1f5f4a03, []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 + +func (m *GenesisState) GetEpochs() []EpochInfo { + if m != nil { + return m.Epochs + } + return nil +} + +func init() { + proto.RegisterType((*EpochInfo)(nil), "tacchain.epochs.v1beta1.EpochInfo") + proto.RegisterType((*GenesisState)(nil), "tacchain.epochs.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("tacchain/epochs/v1beta1/genesis.proto", fileDescriptor_1d2331ae1f5f4a03) +} + +var fileDescriptor_1d2331ae1f5f4a03 = []byte{ + // 482 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xb1, 0x8e, 0xd3, 0x40, + 0x10, 0xcd, 0x92, 0x10, 0x9c, 0xbd, 0x43, 0xc0, 0xea, 0xe0, 0x4c, 0x24, 0x6c, 0xcb, 0x08, 0xc9, + 0x12, 0xb0, 0x56, 0x0e, 0x2a, 0x68, 0x20, 0x80, 0x38, 0xa8, 0x90, 0x43, 0x81, 0x68, 0x22, 0xc7, + 0xd9, 0xd8, 0x2b, 0x9d, 0x77, 0x2d, 0x7b, 0x8c, 0x2e, 0x54, 0x7c, 0x42, 0x4a, 0x3e, 0xe9, 0xca, + 0x2b, 0xa9, 0x02, 0x4a, 0x3a, 0xca, 0xfb, 0x02, 0xe4, 0x5d, 0x3b, 0x04, 0x8e, 0x13, 0x9d, 0x3d, + 0xef, 0xcd, 0x7b, 0x3b, 0x4f, 0x33, 0xf8, 0x1e, 0x84, 0x51, 0x94, 0x84, 0x5c, 0xf8, 0x2c, 0x93, + 0x51, 0x52, 0xf8, 0x9f, 0x06, 0x13, 0x06, 0xe1, 0xc0, 0x8f, 0x99, 0x60, 0x05, 0x2f, 0x68, 0x96, + 0x4b, 0x90, 0x64, 0xbf, 0xa1, 0x51, 0x4d, 0xa3, 0x35, 0xad, 0xbf, 0x17, 0xcb, 0x58, 0x2a, 0x8e, + 0x5f, 0x7d, 0x69, 0x7a, 0xdf, 0x8a, 0xa5, 0x8c, 0x8f, 0x98, 0xaf, 0xfe, 0x26, 0xe5, 0xcc, 0x9f, + 0x96, 0x79, 0x08, 0x5c, 0x8a, 0x1a, 0xb7, 0xff, 0xc6, 0x81, 0xa7, 0xac, 0x80, 0x30, 0xcd, 0x34, + 0xc1, 0x5d, 0x74, 0x70, 0xef, 0x55, 0xe5, 0xf4, 0x46, 0xcc, 0x24, 0xb1, 0x30, 0xe6, 0x53, 0x26, + 0x80, 0xcf, 0x38, 0xcb, 0x4d, 0xe4, 0x20, 0xaf, 0x17, 0x6c, 0x55, 0xc8, 0x07, 0x8c, 0x0b, 0x08, + 0x73, 0x18, 0x57, 0x32, 0xe6, 0x25, 0x07, 0x79, 0x3b, 0x07, 0x7d, 0xaa, 0x3d, 0x68, 0xe3, 0x41, + 0xdf, 0x37, 0x1e, 0xc3, 0x3b, 0x27, 0x4b, 0xbb, 0x75, 0xb6, 0xb4, 0x6f, 0xcc, 0xc3, 0xf4, 0xe8, + 0x89, 0xfb, 0xbb, 0xd7, 0x5d, 0x7c, 0xb7, 0x51, 0xd0, 0x53, 0x85, 0x8a, 0x4e, 0x12, 0x6c, 0x34, + 0x4f, 0x37, 0xdb, 0x4a, 0xf7, 0xf6, 0x39, 0xdd, 0x97, 0x35, 0x61, 0x38, 0xa8, 0x64, 0x7f, 0x2e, + 0x6d, 0xd2, 0xb4, 0x3c, 0x90, 0x29, 0x07, 0x96, 0x66, 0x30, 0x3f, 0x5b, 0xda, 0xd7, 0xb4, 0x59, + 0x83, 0xb9, 0x5f, 0x2b, 0xab, 0x8d, 0x3a, 0xb9, 0x8b, 0xaf, 0x46, 0x65, 0x9e, 0x33, 0x01, 0x63, + 0x15, 0xb1, 0xd9, 0x71, 0x90, 0xd7, 0x0e, 0x76, 0xeb, 0xa2, 0x0a, 0x83, 0x7c, 0x41, 0xd8, 0xfc, + 0x83, 0x35, 0xde, 0x9a, 0xfb, 0xf2, 0x7f, 0xe7, 0xbe, 0x5f, 0xcf, 0x6d, 0xeb, 0xa7, 0x5c, 0xa4, + 0xa4, 0x53, 0xb8, 0xb9, 0xed, 0x3c, 0xda, 0x24, 0xf2, 0x18, 0xdf, 0xd2, 0xfc, 0x48, 0x96, 0x02, + 0xb8, 0x88, 0x75, 0x23, 0x9b, 0x9a, 0x5d, 0x07, 0x79, 0x46, 0xb0, 0xa7, 0xd0, 0x17, 0x35, 0x38, + 0xd2, 0x18, 0x79, 0x8a, 0xfb, 0xff, 0x72, 0x4b, 0x18, 0x8f, 0x13, 0x30, 0x0d, 0x35, 0xea, 0xfe, + 0x39, 0xc3, 0x43, 0x05, 0xbf, 0xed, 0x18, 0x57, 0xae, 0x1b, 0xee, 0x3b, 0xbc, 0xfb, 0x5a, 0xef, + 0xe4, 0x08, 0x42, 0x60, 0xe4, 0x19, 0xee, 0xea, 0x5d, 0x34, 0x91, 0xd3, 0xf6, 0x76, 0x0e, 0x5c, + 0x7a, 0xc1, 0x8e, 0xd2, 0xcd, 0x22, 0x0d, 0x3b, 0x55, 0x00, 0x41, 0xdd, 0x37, 0x3c, 0x3c, 0x59, + 0x59, 0xe8, 0x74, 0x65, 0xa1, 0x1f, 0x2b, 0x0b, 0x2d, 0xd6, 0x56, 0xeb, 0x74, 0x6d, 0xb5, 0xbe, + 0xad, 0xad, 0xd6, 0x47, 0x1a, 0x73, 0x48, 0xca, 0x09, 0x8d, 0x64, 0xea, 0x3f, 0x2f, 0xb2, 0x84, + 0xe5, 0xec, 0xe1, 0xf1, 0xfc, 0xb3, 0xbf, 0x39, 0x96, 0xe3, 0xe6, 0x5c, 0x60, 0x9e, 0xb1, 0x62, + 0xd2, 0x55, 0x61, 0x3f, 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x91, 0xba, 0x89, 0x4e, 0x03, + 0x00, 0x00, +} + +func (m *EpochInfo) 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 *EpochInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EpochInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentEpochStartHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpochStartHeight)) + i-- + dAtA[i] = 0x40 + } + if m.EpochCountingStarted { + i-- + if m.EpochCountingStarted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CurrentEpochStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintGenesis(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x2a + if m.CurrentEpoch != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpoch)) + i-- + dAtA[i] = 0x20 + } + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.Duration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintGenesis(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x1a + n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintGenesis(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x12 + if len(m.Identifier) > 0 { + i -= len(m.Identifier) + copy(dAtA[i:], m.Identifier) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Identifier))) + i-- + dAtA[i] = 0xa + } + 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.Epochs) > 0 { + for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Epochs[iNdEx].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 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 *EpochInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identifier) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovGenesis(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration) + n += 1 + l + sovGenesis(uint64(l)) + if m.CurrentEpoch != 0 { + n += 1 + sovGenesis(uint64(m.CurrentEpoch)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime) + n += 1 + l + sovGenesis(uint64(l)) + if m.EpochCountingStarted { + n += 2 + } + if m.CurrentEpochStartHeight != 0 { + n += 1 + sovGenesis(uint64(m.CurrentEpochStartHeight)) + } + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Epochs) > 0 { + for _, e := range m.Epochs { + l = e.Size() + 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 *EpochInfo) 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: EpochInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EpochInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identifier = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", 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 := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) + } + m.CurrentEpoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpoch |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CurrentEpochStartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochCountingStarted", wireType) + } + 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.EpochCountingStarted = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartHeight", wireType) + } + m.CurrentEpochStartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpochStartHeight |= int64(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 Epochs", 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.Epochs = append(m.Epochs, EpochInfo{}) + if err := m.Epochs[len(m.Epochs)-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 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/epochs/types/hooks.go b/x/epochs/types/hooks.go new file mode 100644 index 0000000..780ad13 --- /dev/null +++ b/x/epochs/types/hooks.go @@ -0,0 +1,59 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/utils" +) + +type EpochHooks interface { + // the first block whose timestamp is after the duration is counted as the end of the epoch + AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error + // new epoch is next block of epoch end block + BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error +} + +var _ EpochHooks = MultiEpochHooks{} + +// combine multiple gamm hooks, all hook functions are run in array sequence. +type MultiEpochHooks []EpochHooks + +func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks { + return hooks +} + +// AfterEpochEnd is called when epoch is going to be ended, epochNumber is the number of epoch that is ending. +func (h MultiEpochHooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + for i := range h { + panicCatchingEpochHook(ctx, h[i].AfterEpochEnd, epochIdentifier, epochNumber) + } + + return nil +} + +// BeforeEpochStart is called when epoch is going to be started, epochNumber is the number of epoch that is starting. +func (h MultiEpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + for i := range h { + panicCatchingEpochHook(ctx, h[i].BeforeEpochStart, epochIdentifier, epochNumber) + } + + return nil +} + +func panicCatchingEpochHook( + ctx sdk.Context, + hookFn func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error, + epochIdentifier string, + epochNumber int64, +) { + wrappedHookFn := func(ctx sdk.Context) error { + return hookFn(ctx, epochIdentifier, epochNumber) + } + // TODO: Thread info for which hook this is, may be dependent on larger hook system refactoring + err := utils.ApplyFuncIfNoError(ctx, wrappedHookFn) + if err != nil { + ctx.Logger().Error(fmt.Sprintf("error in epoch hook %v", err)) + } +} diff --git a/x/epochs/types/keys.go b/x/epochs/types/keys.go new file mode 100644 index 0000000..4f3a602 --- /dev/null +++ b/x/epochs/types/keys.go @@ -0,0 +1,12 @@ +package types + +const ( + // ModuleName defines the module name. + ModuleName = "epochs" + + // StoreKey defines the primary module store key. + StoreKey = ModuleName +) + +// KeyPrefixEpoch defines prefix key for storing epochs. +var KeyPrefixEpoch = []byte{0x01} diff --git a/x/epochs/types/query.pb.go b/x/epochs/types/query.pb.go new file mode 100644 index 0000000..6187f94 --- /dev/null +++ b/x/epochs/types/query.pb.go @@ -0,0 +1,912 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: tacchain/epochs/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "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" + 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 QueryEpochsInfoRequest struct { +} + +func (m *QueryEpochsInfoRequest) Reset() { *m = QueryEpochsInfoRequest{} } +func (m *QueryEpochsInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEpochsInfoRequest) ProtoMessage() {} +func (*QueryEpochsInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{0} +} +func (m *QueryEpochsInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochsInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochsInfoRequest.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 *QueryEpochsInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochsInfoRequest.Merge(m, src) +} +func (m *QueryEpochsInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochsInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochsInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochsInfoRequest proto.InternalMessageInfo + +type QueryEpochsInfoResponse struct { + Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"` +} + +func (m *QueryEpochsInfoResponse) Reset() { *m = QueryEpochsInfoResponse{} } +func (m *QueryEpochsInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEpochsInfoResponse) ProtoMessage() {} +func (*QueryEpochsInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{1} +} +func (m *QueryEpochsInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochsInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochsInfoResponse.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 *QueryEpochsInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochsInfoResponse.Merge(m, src) +} +func (m *QueryEpochsInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochsInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochsInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochsInfoResponse proto.InternalMessageInfo + +func (m *QueryEpochsInfoResponse) GetEpochs() []EpochInfo { + if m != nil { + return m.Epochs + } + return nil +} + +type QueryCurrentEpochRequest struct { + Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` +} + +func (m *QueryCurrentEpochRequest) Reset() { *m = QueryCurrentEpochRequest{} } +func (m *QueryCurrentEpochRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentEpochRequest) ProtoMessage() {} +func (*QueryCurrentEpochRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{2} +} +func (m *QueryCurrentEpochRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentEpochRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentEpochRequest.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 *QueryCurrentEpochRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentEpochRequest.Merge(m, src) +} +func (m *QueryCurrentEpochRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentEpochRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentEpochRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentEpochRequest proto.InternalMessageInfo + +func (m *QueryCurrentEpochRequest) GetIdentifier() string { + if m != nil { + return m.Identifier + } + return "" +} + +type QueryCurrentEpochResponse struct { + CurrentEpoch int64 `protobuf:"varint,1,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` +} + +func (m *QueryCurrentEpochResponse) Reset() { *m = QueryCurrentEpochResponse{} } +func (m *QueryCurrentEpochResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentEpochResponse) ProtoMessage() {} +func (*QueryCurrentEpochResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{3} +} +func (m *QueryCurrentEpochResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentEpochResponse.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 *QueryCurrentEpochResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentEpochResponse.Merge(m, src) +} +func (m *QueryCurrentEpochResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentEpochResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentEpochResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentEpochResponse proto.InternalMessageInfo + +func (m *QueryCurrentEpochResponse) GetCurrentEpoch() int64 { + if m != nil { + return m.CurrentEpoch + } + return 0 +} + +func init() { + proto.RegisterType((*QueryEpochsInfoRequest)(nil), "tacchain.epochs.v1beta1.QueryEpochsInfoRequest") + proto.RegisterType((*QueryEpochsInfoResponse)(nil), "tacchain.epochs.v1beta1.QueryEpochsInfoResponse") + proto.RegisterType((*QueryCurrentEpochRequest)(nil), "tacchain.epochs.v1beta1.QueryCurrentEpochRequest") + proto.RegisterType((*QueryCurrentEpochResponse)(nil), "tacchain.epochs.v1beta1.QueryCurrentEpochResponse") +} + +func init() { + proto.RegisterFile("tacchain/epochs/v1beta1/query.proto", fileDescriptor_9f8cfb8c21c0a618) +} + +var fileDescriptor_9f8cfb8c21c0a618 = []byte{ + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbf, 0x4e, 0xe3, 0x30, + 0x1c, 0xc7, 0xe3, 0xf6, 0xae, 0xd2, 0xf9, 0x7a, 0x8b, 0x75, 0xba, 0xe6, 0xa2, 0x53, 0xda, 0x4b, + 0x75, 0x47, 0x17, 0x6c, 0x5a, 0x36, 0xa6, 0x52, 0x84, 0x04, 0x23, 0x19, 0x61, 0x40, 0x69, 0x70, + 0x13, 0x4b, 0x60, 0xa7, 0xb1, 0x83, 0x5a, 0x46, 0x9e, 0x00, 0x89, 0x85, 0x17, 0xe0, 0x5d, 0x2a, + 0xa6, 0x4a, 0x2c, 0x4c, 0x08, 0xb5, 0x3c, 0x08, 0xaa, 0x93, 0x42, 0x11, 0x0d, 0x82, 0x2d, 0xb1, + 0x3f, 0xdf, 0x3f, 0xbf, 0x5f, 0x02, 0xeb, 0xca, 0xf3, 0xfd, 0xd0, 0x63, 0x9c, 0xd0, 0x48, 0xf8, + 0xa1, 0x24, 0xa7, 0xcd, 0x2e, 0x55, 0x5e, 0x93, 0xf4, 0x13, 0x1a, 0x0f, 0x71, 0x14, 0x0b, 0x25, + 0x50, 0x65, 0x0e, 0xe1, 0x14, 0xc2, 0x19, 0x64, 0xfd, 0x0c, 0x44, 0x20, 0x34, 0x43, 0x66, 0x4f, + 0x29, 0x6e, 0xfd, 0x09, 0x84, 0x08, 0x8e, 0x29, 0xf1, 0x22, 0x46, 0x3c, 0xce, 0x85, 0xf2, 0x14, + 0x13, 0x5c, 0x66, 0xb7, 0xff, 0xf2, 0x12, 0x03, 0xca, 0xa9, 0x64, 0x19, 0xe6, 0x98, 0xf0, 0xd7, + 0xde, 0xac, 0xc2, 0xb6, 0x86, 0x76, 0x79, 0x4f, 0xb8, 0xb4, 0x9f, 0x50, 0xa9, 0x9c, 0x03, 0x58, + 0x79, 0x73, 0x23, 0x23, 0xc1, 0x25, 0x45, 0x6d, 0x58, 0x4a, 0x4d, 0x4d, 0x50, 0x2b, 0x36, 0xbe, + 0xb7, 0x1c, 0x9c, 0xd3, 0x1c, 0x6b, 0xf1, 0x4c, 0xdb, 0xf9, 0x32, 0xba, 0xaf, 0x1a, 0x6e, 0xa6, + 0x73, 0x36, 0xa0, 0xa9, 0xcd, 0xb7, 0x92, 0x38, 0xa6, 0x5c, 0x69, 0x2c, 0x0b, 0x46, 0x36, 0x84, + 0xec, 0x88, 0x72, 0xc5, 0x7a, 0x8c, 0xc6, 0x26, 0xa8, 0x81, 0xc6, 0x37, 0x77, 0xe1, 0xc4, 0x69, + 0xc3, 0xdf, 0x4b, 0xb4, 0x59, 0xb5, 0x3a, 0xfc, 0xe1, 0xa7, 0xe7, 0x87, 0x3a, 0x4a, 0xeb, 0x8b, + 0x6e, 0xd9, 0x5f, 0x80, 0x5b, 0x37, 0x05, 0xf8, 0x55, 0x5b, 0xa0, 0x2b, 0x00, 0xe1, 0x73, 0x47, + 0x89, 0x48, 0xee, 0x20, 0xcb, 0x97, 0x64, 0xad, 0x7d, 0x5c, 0x90, 0x16, 0x74, 0x56, 0xce, 0x6f, + 0x1f, 0x2f, 0x0b, 0x7f, 0x51, 0x95, 0xe4, 0x7d, 0xa0, 0xf4, 0x15, 0x5d, 0x03, 0x58, 0x5e, 0x1c, + 0x11, 0x35, 0xdf, 0xcf, 0x5a, 0xb2, 0x4a, 0xab, 0xf5, 0x19, 0x49, 0x56, 0x10, 0xeb, 0x82, 0x0d, + 0xf4, 0x3f, 0xb7, 0xe0, 0xab, 0x05, 0x77, 0x76, 0x46, 0x13, 0x1b, 0x8c, 0x27, 0x36, 0x78, 0x98, + 0xd8, 0xe0, 0x62, 0x6a, 0x1b, 0xe3, 0xa9, 0x6d, 0xdc, 0x4d, 0x6d, 0x63, 0x1f, 0x07, 0x4c, 0x85, + 0x49, 0x17, 0xfb, 0xe2, 0x84, 0x6c, 0xca, 0x28, 0xa4, 0x31, 0x5d, 0x1d, 0x0c, 0xcf, 0x5e, 0x7c, + 0x07, 0x73, 0x67, 0x35, 0x8c, 0xa8, 0xec, 0x96, 0xf4, 0x2f, 0xb9, 0xfe, 0x14, 0x00, 0x00, 0xff, + 0xff, 0xfa, 0xf5, 0xae, 0xf3, 0x2d, 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 { + // EpochInfos provide running epochInfos + EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) + // CurrentEpoch provide current epoch of specified identifier + CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) { + out := new(QueryEpochsInfoResponse) + err := c.cc.Invoke(ctx, "/tacchain.epochs.v1beta1.Query/EpochInfos", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) { + out := new(QueryCurrentEpochResponse) + err := c.cc.Invoke(ctx, "/tacchain.epochs.v1beta1.Query/CurrentEpoch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // EpochInfos provide running epochInfos + EpochInfos(context.Context, *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) + // CurrentEpoch provide current epoch of specified identifier + CurrentEpoch(context.Context, *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) EpochInfos(ctx context.Context, req *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EpochInfos not implemented") +} +func (*UnimplementedQueryServer) CurrentEpoch(ctx context.Context, req *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CurrentEpoch not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_EpochInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEpochsInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EpochInfos(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tacchain.epochs.v1beta1.Query/EpochInfos", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EpochInfos(ctx, req.(*QueryEpochsInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CurrentEpoch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCurrentEpochRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CurrentEpoch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tacchain.epochs.v1beta1.Query/CurrentEpoch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CurrentEpoch(ctx, req.(*QueryCurrentEpochRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "tacchain.epochs.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "EpochInfos", + Handler: _Query_EpochInfos_Handler, + }, + { + MethodName: "CurrentEpoch", + Handler: _Query_CurrentEpoch_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "tacchain/epochs/v1beta1/query.proto", +} + +func (m *QueryEpochsInfoRequest) 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 *QueryEpochsInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochsInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryEpochsInfoResponse) 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 *QueryEpochsInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochsInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Epochs) > 0 { + for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Epochs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryCurrentEpochRequest) 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 *QueryCurrentEpochRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentEpochRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Identifier) > 0 { + i -= len(m.Identifier) + copy(dAtA[i:], m.Identifier) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Identifier))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCurrentEpochResponse) 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 *QueryCurrentEpochResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentEpoch != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpoch)) + 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 *QueryEpochsInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryEpochsInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Epochs) > 0 { + for _, e := range m.Epochs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryCurrentEpochRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identifier) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCurrentEpochResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CurrentEpoch != 0 { + n += 1 + sovQuery(uint64(m.CurrentEpoch)) + } + 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 *QueryEpochsInfoRequest) 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: QueryEpochsInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochsInfoRequest: 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 *QueryEpochsInfoResponse) 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: QueryEpochsInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochsInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Epochs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Epochs = append(m.Epochs, EpochInfo{}) + if err := m.Epochs[len(m.Epochs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCurrentEpochRequest) 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: QueryCurrentEpochRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentEpochRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", 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.Identifier = 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 (m *QueryCurrentEpochResponse) 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: QueryCurrentEpochResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) + } + m.CurrentEpoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpoch |= int64(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/epochs/types/query.pb.gw.go b/x/epochs/types/query.pb.gw.go new file mode 100644 index 0000000..4051633 --- /dev/null +++ b/x/epochs/types/query.pb.gw.go @@ -0,0 +1,236 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: tacchain/epochs/v1beta1/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_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEpochsInfoRequest + var metadata runtime.ServerMetadata + + msg, err := client.EpochInfos(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEpochsInfoRequest + var metadata runtime.ServerMetadata + + msg, err := server.EpochInfos(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_CurrentEpoch_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentEpochRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CurrentEpoch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentEpochRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CurrentEpoch(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_EpochInfos_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_EpochInfos_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_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CurrentEpoch_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_CurrentEpoch_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_CurrentEpoch_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_EpochInfos_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_EpochInfos_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_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CurrentEpoch_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_CurrentEpoch_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_CurrentEpoch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_EpochInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"tacchain", "epochs", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_CurrentEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tacchain", "epochs", "v1beta1", "current_epoch"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_EpochInfos_0 = runtime.ForwardResponseMessage + + forward_Query_CurrentEpoch_0 = runtime.ForwardResponseMessage +) diff --git a/x/liquidstake/keeper/hooks.go b/x/liquidstake/keeper/hooks.go index e5cfb5a..82d624e 100644 --- a/x/liquidstake/keeper/hooks.go +++ b/x/liquidstake/keeper/hooks.go @@ -1,11 +1,8 @@ package keeper import ( - "fmt" - + epochstypes "github.com/Asphere-xyz/tacchain/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" - // TODO: replace it with local cosmos sdk epoch hooks - // epochstypes "github.com/persistenceOne/persistence-sdk/v2/x/epochs/types" liquidstake "github.com/Asphere-xyz/tacchain/x/liquidstake/types" ) @@ -14,8 +11,7 @@ type EpochHooks struct { k Keeper } -// TODO: replace it with local cosmos sdk epoch hooks -// var _ epochstypes.EpochHooks = EpochHooks{} +var _ epochstypes.EpochHooks = EpochHooks{} func (k Keeper) EpochHooks() EpochHooks { return EpochHooks{k} @@ -33,13 +29,13 @@ func (h EpochHooks) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error { func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, _ int64) error { if !k.GetParams(ctx).ModulePaused { // Update the liquid validator set at the start of each epoch - switch epochIdentifier { - case liquidstake.AutocompoundEpoch: + if epochIdentifier == liquidstake.AutocompoundEpoch { k.AutocompoundStakingRewards(ctx, liquidstake.GetWhitelistedValsMap(k.GetParams(ctx).WhitelistedValidators)) - case liquidstake.RebalanceEpoch: + } + + if epochIdentifier == liquidstake.RebalanceEpoch { + // return value of UpdateLiquidValidatorSet is useful only in testing _ = k.UpdateLiquidValidatorSet(ctx, true) - default: - return fmt.Errorf("unknown epoch identifier: %s", epochIdentifier) } } From 8ecad0fb31ac6eb6b3183a9f9dd59aa5346f6181 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 22 Jul 2025 13:08:30 +0300 Subject: [PATCH 072/112] draft: added tests --- go.mod | 3 +- go.sum | 2 - x/liquidstake/keeper/keeper_test.go | 68 ++-- x/liquidstake/keeper/liquidstake.go | 2 +- x/liquidstake/keeper/liquidstake_test.go | 494 +++++++++++++++++++++++ 5 files changed, 532 insertions(+), 37 deletions(-) create mode 100644 x/liquidstake/keeper/liquidstake_test.go diff --git a/go.mod b/go.mod index f19c92c..5369d3d 100644 --- a/go.mod +++ b/go.mod @@ -277,7 +277,8 @@ replace ( // // use Cosmos-SDK fork to enable Ledger functionality // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd + // github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd + github.com/cosmos/cosmos-sdk => ../../cosmos-sdk/ // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index 4e97c2c..4064183 100644 --- a/go.sum +++ b/go.sum @@ -1004,8 +1004,6 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd h1:wdNwCUHsrId91KHpGSJT4MPxPLYv014IuJimc2BlvQo= -github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd/go.mod h1:hrWEFMU1eoXqLJeE6VVESpJDQH67FS1nnMrQIjO2daw= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 h1:ddqzU2x2ZpPPvQKhBqPj9TZNtSyp0UsA5Ip2+elxlRM= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= diff --git a/x/liquidstake/keeper/keeper_test.go b/x/liquidstake/keeper/keeper_test.go index f2e35a0..68ad942 100644 --- a/x/liquidstake/keeper/keeper_test.go +++ b/x/liquidstake/keeper/keeper_test.go @@ -7,6 +7,8 @@ import ( "cosmossdk.io/log" "cosmossdk.io/math" + testhelpers "github.com/Asphere-xyz/tacchain/app/helpers" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -78,39 +80,39 @@ func (s *KeeperTestSuite) TearDownTest() { crisis.EndBlocker(s.ctx, *s.app.CrisisKeeper) } -// TODO: Upgrade Cosmos SDK -// func (s *KeeperTestSuite) CreateValidators(powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []cryptotypes.PubKey) { -// s.app.BeginBlocker(s.ctx) -// num := len(powers) -// addrs := chain.AddTestAddrsIncremental(s.app, s.ctx, num, math.NewInt(10000000000000)) -// valAddrs := chain.ConvertAddrsToValAddrs(addrs) -// pks := chain.CreateTestPubKeys(num) -// skParams, _ := s.app.StakingKeeper.GetParams(s.ctx) -// skParams.ValidatorLiquidStakingCap = sdk.OneDec() -// _ = s.app.StakingKeeper.SetParams(s.ctx, skParams) -// for i, power := range powers { -// val, err := stakingtypes.NewValidator(valAddrs[i].String(), pks[i], stakingtypes.Description{}) -// s.Require().NoError(err) -// s.app.StakingKeeper.SetValidator(s.ctx, val) -// err = s.app.StakingKeeper.SetValidatorByConsAddr(s.ctx, val) -// s.Require().NoError(err) -// s.app.StakingKeeper.SetNewValidatorByPowerIndex(s.ctx, val) -// _ = s.app.StakingKeeper.Hooks().AfterValidatorCreated(s.ctx, sdk.ValAddress(val.GetOperator())) -// newShares, err := s.app.StakingKeeper.Delegate(s.ctx, addrs[i], math.NewInt(power), stakingtypes.Unbonded, val, true) -// s.Require().NoError(err) -// s.Require().Equal(newShares.TruncateInt(), math.NewInt(power)) -// msgValidatorBond := &stakingtypes.MsgValidatorBond{ -// DelegatorAddress: addrs[i].String(), -// ValidatorAddress: val.OperatorAddress, -// } -// handler := s.app.MsgServiceRouter().Handler(msgValidatorBond) -// _, err = handler(s.ctx, msgValidatorBond) -// s.Require().NoError(err) -// } -// -// s.app.EndBlocker(s.ctx) -// return addrs, valAddrs, pks -// } +func (s *KeeperTestSuite) CreateValidators(powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []cryptotypes.PubKey) { + s.app.BeginBlocker(s.ctx) + num := len(powers) + addrs := testhelpers.AddTestAddrsIncremental(s.app, s.ctx, num, math.NewInt(10000000000000)) + valAddrs := testhelpers.ConvertAddrsToValAddrs(addrs) + pks := testhelpers.CreateTestPubKeys(num) + skParams, err := s.app.StakingKeeper.GetParams(s.ctx) + s.Require().NoError(err) + skParams.ValidatorLiquidStakingCap = sdk.OneDec() + _ = s.app.StakingKeeper.SetParams(s.ctx, skParams) + for i, power := range powers { + val, err := stakingtypes.NewValidator(valAddrs[i].String(), pks[i], stakingtypes.Description{}) + s.Require().NoError(err) + s.app.StakingKeeper.SetValidator(s.ctx, val) + err = s.app.StakingKeeper.SetValidatorByConsAddr(s.ctx, val) + s.Require().NoError(err) + s.app.StakingKeeper.SetNewValidatorByPowerIndex(s.ctx, val) + _ = s.app.StakingKeeper.Hooks().AfterValidatorCreated(s.ctx, valAddrs[i]) + newShares, err := s.app.StakingKeeper.Delegate(s.ctx, addrs[i], math.NewInt(power), stakingtypes.Unbonded, val, true) + s.Require().NoError(err) + s.Require().Equal(newShares.TruncateInt(), math.NewInt(power)) + msgValidatorBond := &stakingtypes.MsgValidatorBond{ + DelegatorAddress: addrs[i].String(), + ValidatorAddress: val.OperatorAddress, + } + handler := s.app.MsgServiceRouter().Handler(msgValidatorBond) + _, err = handler(s.ctx, msgValidatorBond) + s.Require().NoError(err) + } + + s.app.EndBlocker(s.ctx) + return addrs, valAddrs, pks +} func (s *KeeperTestSuite) liquidStaking(liquidStaker sdk.AccAddress, stakingAmt math.Int) error { ctx, writeCache := s.ctx.CacheContext() diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index 897f1fe..67bd8dc 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -33,7 +33,7 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, e totalUnbondingBalance := math.ZeroInt() ubds, err := k.stakingKeeper.GetAllUnbondingDelegations(ctx, types.LiquidStakeProxyAcc) - if err != nil{ + if err != nil { return nil, err } for _, ubd := range ubds { diff --git a/x/liquidstake/keeper/liquidstake_test.go b/x/liquidstake/keeper/liquidstake_test.go new file mode 100644 index 0000000..87f5b68 --- /dev/null +++ b/x/liquidstake/keeper/liquidstake_test.go @@ -0,0 +1,494 @@ +package keeper_test + +import ( + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + testhelpers "github.com/Asphere-xyz/tacchain/app/helpers" + "github.com/Asphere-xyz/tacchain/x/liquidstake/types" +) + +// tests LiquidStake, LiquidUnstake +func (s *KeeperTestSuite) TestLiquidStake() { + sdk.SetBaseDenom("utac") + sdk.GetConfig().SetBech32PrefixForAccount("tac", "tacpub") + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + params.MinLiquidStakeAmount = math.NewInt(50000) + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + stakingAmt := params.MinLiquidStakeAmount + + // fail, no active validator + cachedCtx, _ := s.ctx.CacheContext() + gTACMintAmt, err := s.keeper.LiquidStake( + cachedCtx, types.LiquidStakeProxyAcc, s.delAddrs[0], + sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), + ) + s.Require().ErrorIs(err, types.ErrActiveLiquidValidatorsNotExists) + s.Require().Equal(gTACMintAmt, sdk.ZeroInt()) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(2000)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(2000)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(2000)}, + } + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + res := s.keeper.GetAllLiquidValidatorStates(s.ctx) + s.Require().Equal(params.WhitelistedValidators[0].ValidatorAddress, + res[0].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[0].TargetWeight, + res[0].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[0].Status) + s.Require().Equal(sdk.ZeroDec(), res[0].DelShares) + s.Require().Equal(sdk.ZeroInt(), res[0].LiquidTokens) + + s.Require().Equal(params.WhitelistedValidators[1].ValidatorAddress, + res[1].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[1].TargetWeight, + res[1].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[1].Status) + s.Require().Equal(sdk.ZeroDec(), res[1].DelShares) + s.Require().Equal(sdk.ZeroInt(), res[1].LiquidTokens) + + s.Require().Equal(params.WhitelistedValidators[2].ValidatorAddress, + res[2].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[2].TargetWeight, + res[2].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[2].Status) + s.Require().Equal(sdk.ZeroDec(), res[2].DelShares) + s.Require().Equal(sdk.ZeroInt(), res[2].LiquidTokens) + + ///////////////////////////////////////// + nasTest, err := s.app.LiquidStakeKeeper.GetNetAmountState(s.ctx) + s.T().Logf( + "nasTest.NetAmount: %s", + nasTest.NetAmount, + ) + ///////////////////////////////////////// + + // liquid stake + gTACMintAmt, err = s.keeper.LiquidStake( + s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], + sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), + ) + s.Require().NoError(err) + s.Require().Equal(gTACMintAmt, stakingAmt) + + ///////////////////////////////////////// + nasTest, err = s.app.LiquidStakeKeeper.GetNetAmountState(s.ctx) + s.T().Logf( + "nasTest.NetAmount after liquid stake: %s", + nasTest.NetAmount, + ) + + s.T().Logf( + "nasTest.MintRate after liquid stake: %s", + nasTest.MintRate, + ) + ///////////////////////////////////////// + + _, err = s.app.StakingKeeper.GetDelegation( + s.ctx, s.delAddrs[0], valOpers[0], + ) + s.Require().Error(err) + _, err = s.app.StakingKeeper.GetDelegation( + s.ctx, s.delAddrs[0], valOpers[1], + ) + s.Require().Error(err) + _, err = s.app.StakingKeeper.GetDelegation( + s.ctx, s.delAddrs[0], valOpers[2], + ) + s.Require().Error(err) + + proxyAccDel1, err := s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[0], + ) + s.Require().NoError(err) + proxyAccDel2, err := s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[1], + ) + s.Require().NoError(err) + proxyAccDel3, err := s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[2], + ) + s.Require().NoError(err) + s.Require().Equal(proxyAccDel1.Shares, math.LegacyNewDec(16668)) + s.Require().Equal(proxyAccDel2.Shares, math.LegacyNewDec(16666)) + s.Require().Equal(proxyAccDel2.Shares, math.LegacyNewDec(16666)) + s.Require().Equal(stakingAmt.ToLegacyDec(), + proxyAccDel1.Shares.Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) + + liquidBondDenom := s.keeper.LiquidBondDenom(s.ctx) + balanceBeforeUBD := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, + ) + s.Require().Equal(balanceBeforeUBD.Amount, math.NewInt(999950000)) + ubdGTAC := sdk.NewCoin(liquidBondDenom, math.NewInt(10000)) + gTACBalance := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], liquidBondDenom, + ) + gTACTotalSupply := s.app.BankKeeper.GetSupply( + s.ctx, liquidBondDenom, + ) + s.Require().Equal(gTACBalance, + sdk.NewCoin(liquidBondDenom, math.NewInt(50000))) + s.Require().Equal(gTACBalance, gTACTotalSupply) + + // liquid unstaking + + ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.keeper.LiquidUnstake( + s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], ubdGTAC, + ) + s.Require().NoError(err) + s.Require().EqualValues(unbondedAmt, sdk.ZeroInt()) + s.Require().Len(ubds, 3) + + // crumb excepted on unbonding + crumb := ubdGTAC.Amount.Sub(ubdGTAC.Amount.QuoRaw(3).MulRaw(3)) + s.Require().EqualValues(unbondingAmt, ubdGTAC.Amount.Sub(crumb)) + s.Require().Equal(ubds[0].DelegatorAddress, s.delAddrs[0].String()) + s.Require().Equal(ubdTime, testhelpers.ParseTime("2022-03-22T00:00:00Z")) + gTACBalanceAfter := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], liquidBondDenom, + ) + s.Require().Equal(gTACBalanceAfter, + sdk.NewCoin(liquidBondDenom, math.NewInt(40000))) + + balanceBeginUBD := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, + ) + s.Require().Equal(balanceBeginUBD.Amount, balanceBeforeUBD.Amount) + + proxyAccDel1, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[0], + ) + s.Require().NoError(err) + proxyAccDel2, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[1], + ) + s.Require().NoError(err) + proxyAccDel3, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[2], + ) + s.Require().NoError(err) + s.Require().Equal(stakingAmt.Sub(unbondingAmt).ToLegacyDec(), + proxyAccDel1.GetShares().Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) + + // complete unbonding + s.ctx = s.ctx.WithBlockHeight(200).WithBlockTime(ubdTime.Add(1)) + updates, err := s.app.StakingKeeper.BlockValidatorUpdates(s.ctx) + s.Require().NoError(err) + s.Require().Empty(updates) + balanceCompleteUBD := s.app.BankKeeper.GetBalance( + s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, + ) + s.Require().Equal(balanceCompleteUBD.Amount, + balanceBeforeUBD.Amount.Add(unbondingAmt)) + + proxyAccDel1, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[0], + ) + s.Require().NoError(err) + proxyAccDel2, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[1], + ) + s.Require().NoError(err) + proxyAccDel3, err = s.app.StakingKeeper.GetDelegation( + s.ctx, types.LiquidStakeProxyAcc, valOpers[2], + ) + s.Require().NoError(err) + s.Require().Equal(math.LegacyNewDec(13335), proxyAccDel1.Shares) + s.Require().Equal(math.LegacyNewDec(13333), proxyAccDel2.Shares) + s.Require().Equal(math.LegacyNewDec(13333), proxyAccDel3.Shares) + + res = s.keeper.GetAllLiquidValidatorStates(s.ctx) + s.Require().Equal(params.WhitelistedValidators[0].ValidatorAddress, + res[0].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[0].TargetWeight, + res[0].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[0].Status) + s.Require().Equal(math.LegacyNewDec(13335), res[0].DelShares) + + s.Require().Equal(params.WhitelistedValidators[1].ValidatorAddress, + res[1].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[1].TargetWeight, + res[1].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[1].Status) + s.Require().Equal(math.LegacyNewDec(13333), res[1].DelShares) + + s.Require().Equal(params.WhitelistedValidators[2].ValidatorAddress, + res[2].OperatorAddress) + s.Require().Equal(params.WhitelistedValidators[2].TargetWeight, + res[2].Weight) + s.Require().Equal(types.ValidatorStatusActive, res[2].Status) + s.Require().Equal(math.LegacyNewDec(13333), res[2].DelShares) + + // rewards are not autocompounded after validator set update and rebalancing + s.advanceHeight(10, true) + rewards, totalLiquidShares, _, err := s.keeper.CheckDelegationStates( + s.ctx, types.LiquidStakeProxyAcc, + ) + s.Require().NoError(err) + s.Require().NotEqualValues(rewards, sdk.ZeroDec()) + s.Require().EqualValues(totalLiquidShares, proxyAccDel1.Shares.Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) + + // all remaining rewards re-staked, request last unstaking, unbond all + s.keeper.AutocompoundStakingRewards(s.ctx, types.GetWhitelistedValsMap(s.keeper.GetParams(s.ctx).WhitelistedValidators)) + gtacBalanceBefore := s.app.BankKeeper.GetBalance(s.ctx, s.delAddrs[0], params.LiquidBondDenom).Amount + rewards, _, _, err = s.keeper.CheckDelegationStates( + s.ctx, types.LiquidStakeProxyAcc, + ) + s.Require().NoError(err) + s.Require().EqualValues(rewards, sdk.ZeroDec()) + s.Require().NoError( + s.liquidUnstaking(s.delAddrs[0], gtacBalanceBefore, true), + ) + + // still active liquid validator after unbond all + alv := s.keeper.GetActiveLiquidValidators( + s.ctx, params.WhitelistedValsMap(), + ) + s.Require().True(len(alv) != 0) + + // no btoken supply and netAmount after unbond all + nas, err := s.keeper.GetNetAmountState(s.ctx) + s.Require().NoError(err) + s.Require().EqualValues(nas.StkxprtTotalSupply, sdk.ZeroInt()) + s.Require().Equal(nas.TotalRemainingRewards, sdk.ZeroDec()) + s.Require().Equal(nas.TotalDelShares, sdk.ZeroDec()) + s.Require().Equal(nas.TotalLiquidTokens, sdk.ZeroInt()) + s.Require().Equal(nas.ProxyAccBalance, sdk.ZeroInt()) + s.Require().Equal(nas.NetAmount, sdk.ZeroDec()) +} + +func (s *KeeperTestSuite) TestLiquidStakeFromVestingAccount() { + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, + } + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + from := s.delAddrs[0] + vestingAmt := s.app.BankKeeper.GetAllBalances(s.ctx, from) + vestingStartTime := s.ctx.BlockTime().Add(1 * time.Hour) + vestingEndTime := s.ctx.BlockTime().Add(2 * time.Hour) + vestingMidTime := s.ctx.BlockTime().Add(90 * time.Minute) + + vestingAccAddr := "tac10n3ncmlsaqfuwsmfll8kq6hvt4x7c8czk3d7g6" + vestingAcc, err := sdk.AccAddressFromBech32(vestingAccAddr) + s.Require().NoError(err) + + // createContinuousVestingAccount + cVestingAcc := s.createContinuousVestingAccount(from, vestingAcc, vestingAmt, vestingStartTime, vestingEndTime) + spendableCoins := s.app.BankKeeper.SpendableCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().True(spendableCoins.IsZero()) + lockedCoins := s.app.BankKeeper.LockedCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().EqualValues(lockedCoins, vestingAmt) + + // failed liquid stake, no spendable coins on the vesting account ( not allowed locked coins ) + err = s.liquidStaking(vestingAcc, vestingAmt.AmountOf(sdk.DefaultBondDenom)) + s.Require().ErrorIs(err, sdkerrors.ErrInsufficientFunds) + + // release some vesting coins + s.ctx = s.ctx.WithBlockTime(vestingMidTime) + spendableCoins = s.app.BankKeeper.SpendableCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().True(spendableCoins.IsAllPositive()) + lockedCoins = s.app.BankKeeper.LockedCoins(s.ctx, cVestingAcc.GetAddress()) + s.Require().True(lockedCoins.IsAllPositive()) + + // success with released spendable coins + err = s.liquidStaking(vestingAcc, spendableCoins.AmountOf(sdk.DefaultBondDenom)) + s.Require().NoError(err) + nas, err := s.keeper.GetNetAmountState(s.ctx) + s.Require().NoError(err) + s.Require().EqualValues(nas.TotalLiquidTokens, spendableCoins.AmountOf(sdk.DefaultBondDenom)) +} + +func (s *KeeperTestSuite) TestLiquidStakeEdgeCases() { + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + stakingAmt := math.NewInt(5000000) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, + } + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + // fail Invalid BondDenom case + _, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], sdk.NewCoin("bad", stakingAmt)) + s.Require().ErrorIs(err, types.ErrInvalidBondDenom) + + // liquid stake, unstaking with huge amount + hugeAmt := math.NewInt(1_000_000_000_000_000_000) + s.fundAddr(s.delAddrs[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, hugeAmt.MulRaw(2)))) + s.Require().NoError(s.liquidStaking(s.delAddrs[0], hugeAmt)) + s.Require().NoError(s.liquidStaking(s.delAddrs[0], hugeAmt)) + s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], math.NewInt(10), true)) + s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], hugeAmt, true)) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + s.completeRedelegationUnbonding() + states, err := s.keeper.GetNetAmountState(s.ctx) + s.Require().NoError(err) + states.TotalLiquidTokens.Equal(hugeAmt) +} + +func (s *KeeperTestSuite) TestLiquidUnstakeEdgeCases() { + mintParams, err := s.app.MintKeeper.Params.Get(s.ctx) + s.Require().NoError(err) + mintParams.InflationMax = math.LegacyNewDec(0) + mintParams.InflationMin = math.LegacyNewDec(0) + mintParams.InflationRateChange = math.LegacyNewDec(0) + err = s.app.MintKeeper.Params.Set(s.ctx, mintParams) + s.Require().NoError(err) + + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) + params := s.keeper.GetParams(s.ctx) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + stakingAmt := math.NewInt(5000000) + + // add active validator + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, + } + params.ModulePaused = false + s.Require().NoError(s.keeper.SetParams(s.ctx, params)) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + // success liquid stake + s.Require().NoError(s.liquidStaking(s.delAddrs[0], stakingAmt)) + + // fail when liquid unstaking with too small amount + _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(2))) + s.Require().ErrorIs(err, types.ErrTooSmallLiquidUnstakingAmount) + + // fail when liquid unstaking with zero amount + _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(0))) + s.Require().ErrorIs(err, types.ErrTooSmallLiquidUnstakingAmount) + + // fail when invalid liquid bond denom + _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin("stake", math.NewInt(10000))) + s.Require().ErrorIs(err, types.ErrInvalidLiquidBondDenom) + + // verify that there is no problem performing liquid unstaking as much as the MaxEntries + stakingParams, err := s.app.StakingKeeper.GetParams(s.ctx) + s.Require().NoError(err) + for i := uint32(0); i < stakingParams.MaxEntries; i++ { + s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], math.NewInt(1000), false)) + } + + // on sdk 0.47+ shouldn't fail in an attempt to go beyond MaxEntries + err = s.liquidUnstaking(s.delAddrs[0], math.NewInt(1000), false) + s.Require().NoError(err) + + dels, err := s.app.StakingKeeper.GetUnbondingDelegations(s.ctx, s.delAddrs[0], 100) + s.Require().NoError(err) + for _, ubd := range dels { + s.Require().EqualValues(1, len(ubd.Entries)) + } + + // set empty whitelisted, active liquid validator + params.WhitelistedValidators = []types.WhitelistedValidator{} + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + // error case where there is a quantity that are unbonding balance or remaining rewards that is not re-stake or withdrawn in netAmount. + // NOT APPLICABLE since we do not validator unbond if validator goes inactive. + //_, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(1000))) + //s.Require().ErrorIs(err, types.ErrInsufficientProxyAccBalance) + + // success after complete unbonding, Not applicable + s.completeRedelegationUnbonding() + // ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(1000))) + // s.Require().NoError(err) + // s.Require().EqualValues(unbondedAmt, math.NewInt(1000)) + // s.Require().EqualValues(unbondingAmt, sdk.ZeroInt()) + // s.Require().EqualValues(ubdTime, time.Time{}) + // s.Require().Len(ubds, 0) +} + +func (s *KeeperTestSuite) TestShareInflation() { + _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000, 4000000}) + params := s.keeper.GetParams(s.ctx) + + // set minimum amount and unstake fee to 0 for testing + params.MinLiquidStakeAmount = math.NewInt(0) + params.UnstakeFeeRate = sdk.NewDec(0) + s.keeper.SetParams(s.ctx, params) + + params.WhitelistedValidators = []types.WhitelistedValidator{ + {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(2500)}, + {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(2500)}, + {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(2500)}, + {ValidatorAddress: valOpers[3].String(), TargetWeight: math.NewInt(2500)}, + } + params.ModulePaused = false + s.keeper.SetParams(s.ctx, params) + s.keeper.UpdateLiquidValidatorSet(s.ctx, true) + + initialStakingAmt := math.NewInt(1) // little amount + initializingStakingAmt := math.NewInt(10000) // normal amount + attacker := s.delAddrs[0] + user := s.delAddrs[1] + protocol := s.delAddrs[3] + + // 0. [a solution?] be first depositor + mintAmount0, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, + protocol, sdk.NewCoin(sdk.DefaultBondDenom, initializingStakingAmt)) + s.Require().NoError(err) + s.Require().Equal(mintAmount0, initializingStakingAmt) + + // 1. attacker becomes first depositor and liquid stake + mintAmount, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, + attacker, sdk.NewCoin(sdk.DefaultBondDenom, initialStakingAmt)) + s.Require().NoError(err) + s.Require().Equal(mintAmount, initialStakingAmt) + + // 2. The user sends a liquid stake message, but their tx got front-run by the attacker + // ideally, the user should get 1000 gTAC (1 * 1000 / 1) + // gTAC to mint = gTAC supply * sent TAC / total TAC + userStakeAmount := math.NewInt(1_000) + + // 3. attacker's tx got accepted first which sends funds directly to proxy account + attackerTransferAmount := userStakeAmount.Quo(sdk.NewInt(2)) + s.app.BankKeeper.SendCoins(s.ctx, attacker, types.LiquidStakeProxyAcc, + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, attackerTransferAmount))) + + // 4. user tx went through and the mint rate is not affected by the TAC sent by the attacker + // gTAC to mint = 1 * 1000 / 1 = 1 + mintAmount, err = s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, user, sdk.NewCoin(sdk.DefaultBondDenom, userStakeAmount)) + s.Require().NoError(err) + s.Require().Equal(mintAmount, math.NewInt(1_000)) + + // 5. attacker unstakes the shares immediately + liquidBondDenom := s.keeper.LiquidBondDenom(s.ctx) + _, unbondingAmt, _, _, err := s.keeper.LiquidUnstake(s.ctx, types.LiquidStakeProxyAcc, attacker, sdk.NewCoin(liquidBondDenom, sdk.NewInt(1))) + // s.Require().NoError(err) + s.Require().ErrorContains(err, "liquid unstaking amount is too small") + + attackerProfit := unbondingAmt.Sub(initialStakingAmt).Sub(attackerTransferAmount) + s.Require().LessOrEqual(attackerProfit.Int64(), math.ZeroInt().Int64()) +} From bfad41205d6ac7d6dc531f81a50db6b08a1417c4 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Tue, 22 Jul 2025 13:17:51 +0300 Subject: [PATCH 073/112] fix: added app helpers --- app/helpers/test_helpers.go | 174 ++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 app/helpers/test_helpers.go diff --git a/app/helpers/test_helpers.go b/app/helpers/test_helpers.go new file mode 100644 index 0000000..2df6b7c --- /dev/null +++ b/app/helpers/test_helpers.go @@ -0,0 +1,174 @@ +package helpers + +import ( + "bytes" + "fmt" + "strconv" + "testing" + "time" + + "encoding/hex" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + "cosmossdk.io/math" + chain "github.com/Asphere-xyz/tacchain/app" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *chain.TacChainApp { + db := dbm.NewMemDB() + logger := log.NewTestLogger(t) + return chain.NewTacChainAppWithCustomOptions(t, isCheckTx, invCheckPeriod, chain.SetupOptions{ + Logger: logger, + DB: db, + AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), + }) +} + +// AddTestAddrs constructs and returns accNum amount of accounts with an +// initial balance of accAmt in random order +func AddTestAddrs(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { + return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts) +} + +type GenerateAccountStrategy func(int) []sdk.AccAddress + +func addTestAddrs(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { + testAddrs := strategy(accNum) + + initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, accAmt)) + + for _, addr := range testAddrs { + InitAccountWithCoins(app, ctx, addr, initCoins) + } + + return testAddrs +} + +// createRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order. +func createRandomAccounts(accNum int) []sdk.AccAddress { + testAddrs := make([]sdk.AccAddress, accNum) + for i := 0; i < accNum; i++ { + pk := ed25519.GenPrivKey().PubKey() + testAddrs[i] = sdk.AccAddress(pk.Address()) + } + + return testAddrs +} + +func InitAccountWithCoins(app *chain.TacChainApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { + err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) + if err != nil { + panic(err) + } + + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) + if err != nil { + panic(err) + } +} + +// ConvertAddrsToValAddrs converts the provided addresses to ValAddress. +func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { + valAddrs := make([]sdk.ValAddress, len(addrs)) + + for i, addr := range addrs { + valAddrs[i] = sdk.ValAddress(addr) + } + + return valAddrs +} + +// ParseTime parses and returns time.Time in time.RFC3339 format. +func ParseTime(s string) time.Time { + t, err := time.Parse(time.RFC3339, s) + if err != nil { + panic(err) + } + return t +} + +// AddTestAddrs constructs and returns accNum amount of accounts with an +// initial balance of accAmt in random order +func AddTestAddrsIncremental(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { + return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) +} + +// createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order. +func createIncrementalAccounts(accNum int) []sdk.AccAddress { + var addresses []sdk.AccAddress + var buffer bytes.Buffer + + // start at 100 so we can make up to 999 test addresses with valid test addresses + for i := 100; i < (accNum + 100); i++ { + numString := strconv.Itoa(i) + buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string + + buffer.WriteString(numString) // adding on final two digits to make addresses unique + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) + bech := res.String() + addr, _ := TestAddr(buffer.String(), bech) + + addresses = append(addresses, addr) + buffer.Reset() + } + + return addresses +} + +func TestAddr(addr, bech string) (sdk.AccAddress, error) { + res, err := sdk.AccAddressFromHexUnsafe(addr) + if err != nil { + return nil, err + } + bechexpected := res.String() + if bech != bechexpected { + return nil, fmt.Errorf("bech encoding doesn't match reference") + } + + bechres, err := sdk.AccAddressFromBech32(bech) + if err != nil { + return nil, err + } + if !bytes.Equal(bechres, res) { + return nil, err + } + + return res, nil +} + +// CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. +func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { + var publicKeys []cryptotypes.PubKey + var buffer bytes.Buffer + + // start at 10 to avoid changing 1 to 01, 2 to 02, etc + for i := 100; i < (numPubKeys + 100); i++ { + numString := strconv.Itoa(i) + buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string + buffer.WriteString(numString) // adding on final two digits to make pubkeys unique + publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String())) + buffer.Reset() + } + + return publicKeys +} + +// NewPubKeyFromHex returns a PubKey from a hex string. +func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { + pkBytes, err := hex.DecodeString(pk) + if err != nil { + panic(err) + } + if len(pkBytes) != ed25519.PubKeySize { + panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) + } + return &ed25519.PubKey{Key: pkBytes} +} From 5db043104619f4a8ebd154b5c606c10d4746ec30 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Wed, 23 Jul 2025 11:22:09 +0300 Subject: [PATCH 074/112] feat: added epochs module and upgraded cosmos sdk --- app/app.go | 18 +- go.mod | 5 +- go.sum | 2 + utils/cache_ctx.go | 60 +++ utils/epoch.go | 13 + utils/proofs.go | 64 +++ x/epochs/client/cli/query.go | 107 ++++ x/epochs/keeper/abci.go | 65 +++ x/epochs/keeper/epoch.go | 122 +++++ x/epochs/keeper/genesis.go | 25 + x/epochs/keeper/grpc_query.go | 56 +++ x/epochs/keeper/hooks.go | 17 + x/epochs/keeper/keeper.go | 44 ++ x/epochs/module.go | 158 ++++++ x/epochs/types/doc.go | 4 + x/epochs/types/errors.go | 12 + x/epochs/types/events.go | 9 + x/epochs/types/genesis.go | 77 +++ x/epochs/types/genesis.pb.go | 789 +++++++++++++++++++++++++++++ x/epochs/types/hooks.go | 59 +++ x/epochs/types/keys.go | 12 + x/epochs/types/query.pb.go | 912 ++++++++++++++++++++++++++++++++++ x/epochs/types/query.pb.gw.go | 236 +++++++++ x/liquidstake/keeper/hooks.go | 18 +- 24 files changed, 2869 insertions(+), 15 deletions(-) create mode 100644 utils/cache_ctx.go create mode 100644 utils/epoch.go create mode 100644 utils/proofs.go create mode 100644 x/epochs/client/cli/query.go create mode 100644 x/epochs/keeper/abci.go create mode 100644 x/epochs/keeper/epoch.go create mode 100644 x/epochs/keeper/genesis.go create mode 100644 x/epochs/keeper/grpc_query.go create mode 100644 x/epochs/keeper/hooks.go create mode 100644 x/epochs/keeper/keeper.go create mode 100644 x/epochs/module.go create mode 100644 x/epochs/types/doc.go create mode 100644 x/epochs/types/errors.go create mode 100644 x/epochs/types/events.go create mode 100644 x/epochs/types/genesis.go create mode 100644 x/epochs/types/genesis.pb.go create mode 100644 x/epochs/types/hooks.go create mode 100644 x/epochs/types/keys.go create mode 100644 x/epochs/types/query.pb.go create mode 100644 x/epochs/types/query.pb.gw.go diff --git a/app/app.go b/app/app.go index 0f74bdc..5175497 100644 --- a/app/app.go +++ b/app/app.go @@ -12,6 +12,9 @@ import ( _ "github.com/ethereum/go-ethereum/eth/tracers/js" _ "github.com/ethereum/go-ethereum/eth/tracers/native" + "github.com/Asphere-xyz/tacchain/x/epochs" + epochskeeper "github.com/Asphere-xyz/tacchain/x/epochs/keeper" + epochstypes "github.com/Asphere-xyz/tacchain/x/epochs/types" abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" @@ -241,6 +244,7 @@ type TacChainApp struct { // module configurator configurator module.Configurator + EpochsKeeper *epochskeeper.Keeper // liquidstake keeper LiquidStakeKeeper liquidstakekeeper.Keeper @@ -310,7 +314,7 @@ func NewTacChainApp( authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, // non sdk store keys capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, - icahosttypes.StoreKey, icacontrollertypes.StoreKey, + icahosttypes.StoreKey, epochstypes.StoreKey, icacontrollertypes.StoreKey, // liquidstake module liquidstaketypes.StoreKey, // Cosmos EVM store keys @@ -558,6 +562,8 @@ func NewTacChainApp( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper + app.EpochsKeeper = epochskeeper.NewKeeper(keys[epochstypes.StoreKey]) + // liquidstake keeper app.LiquidStakeKeeper = liquidstakekeeper.NewKeeper( encodingConfig.Codec, @@ -572,6 +578,12 @@ func NewTacChainApp( authAddr, ) + app.EpochsKeeper.SetHooks( + epochstypes.NewMultiEpochHooks( + app.LiquidStakeKeeper.EpochHooks(), + ), + ) + // Cosmos EVM keepers app.FeeMarketKeeper = evmfeemarketkeeper.NewKeeper( encodingConfig.Codec, authtypes.NewModuleAddress(govtypes.ModuleName), @@ -734,6 +746,7 @@ func NewTacChainApp( upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), + epochs.NewAppModule(*app.EpochsKeeper), authzmodule.NewAppModule(encodingConfig.Codec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), groupmodule.NewAppModule(encodingConfig.Codec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), nftmodule.NewAppModule(encodingConfig.Codec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), @@ -789,6 +802,7 @@ func NewTacChainApp( capabilitytypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, + epochstypes.ModuleName, // liquidstake module after staking liquidstaketypes.ModuleName, slashingtypes.ModuleName, @@ -830,6 +844,7 @@ func NewTacChainApp( feegrant.ModuleName, group.ModuleName, // no-op modules + epochstypes.ModuleName, stakingtypes.ModuleName, liquidstaketypes.ModuleName, ibctransfertypes.ModuleName, @@ -872,6 +887,7 @@ func NewTacChainApp( ibcexported.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, + epochstypes.ModuleName, // liquidstake module liquidstaketypes.ModuleName, diff --git a/go.mod b/go.mod index 5369d3d..3e1faea 100644 --- a/go.mod +++ b/go.mod @@ -240,7 +240,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.32.0 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.10.0 // indirect @@ -277,8 +277,7 @@ replace ( // // use Cosmos-SDK fork to enable Ledger functionality // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - // github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250617165712-c53a1019ecfd - github.com/cosmos/cosmos-sdk => ../../cosmos-sdk/ + github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c diff --git a/go.sum b/go.sum index 4064183..1c4fb1d 100644 --- a/go.sum +++ b/go.sum @@ -1004,6 +1004,8 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= +github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 h1:ddqzU2x2ZpPPvQKhBqPj9TZNtSyp0UsA5Ip2+elxlRM= github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= diff --git a/utils/cache_ctx.go b/utils/cache_ctx.go new file mode 100644 index 0000000..6546d8f --- /dev/null +++ b/utils/cache_ctx.go @@ -0,0 +1,60 @@ +package utils + +import ( + "errors" + "fmt" + "runtime" + "runtime/debug" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ApplyFuncIfNoError This function lets you run the function f, but if theres an error or panic +// drop the state machine change and log the error. +// If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness) +// Try to avoid usage of iterators in f. +func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error) { + // Add a panic safeguard + defer func() { + if recoveryError := recover(); recoveryError != nil { + PrintPanicRecoveryError(ctx, recoveryError) + + err = errors.New("panic occurred during execution") + } + }() + // makes a new cache context, which all state changes get wrapped inside of. + cacheCtx, write := ctx.CacheContext() + + err = f(cacheCtx) + if err != nil { + ctx.Logger().Error(err.Error()) + } else { + // no error, write the output of f + write() + } + + return err +} + +// PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. +// If not emits them to stdout. +func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{}) { + errStackTrace := string(debug.Stack()) + + switch e := recoveryError.(type) { + case string: + ctx.Logger().Error("Recovering from (string) panic: " + e) + case runtime.Error: + ctx.Logger().Error("recovered (runtime.Error) panic: " + e.Error()) + case error: + ctx.Logger().Error("recovered (error) panic: " + e.Error()) + default: + ctx.Logger().Error("recovered (default) panic. Could not capture logs in ctx, see stdout") + fmt.Println("Recovering from panic ", recoveryError) + + debug.PrintStack() + + return + } + ctx.Logger().Error("stack trace: " + errStackTrace) +} diff --git a/utils/epoch.go b/utils/epoch.go new file mode 100644 index 0000000..726c3ef --- /dev/null +++ b/utils/epoch.go @@ -0,0 +1,13 @@ +package utils + +import ( + "sort" + + "golang.org/x/exp/constraints" +) + +func SortSlice[T constraints.Ordered](s []T) { + sort.Slice(s, func(i, j int) bool { + return s[i] < s[j] + }) +} diff --git a/utils/proofs.go b/utils/proofs.go new file mode 100644 index 0000000..35009d1 --- /dev/null +++ b/utils/proofs.go @@ -0,0 +1,64 @@ +package utils + +import ( + "fmt" + + "cosmossdk.io/errors" + "github.com/cometbft/cometbft/proto/tendermint/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibcKeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" +) + +func ValidateProofOps(ctx sdk.Context, ibcKeeper *ibcKeeper.Keeper, connectionID string, chainID string, height int64, module string, key []byte, data []byte, proofOps *crypto.ProofOps) error { + if proofOps == nil { + return fmt.Errorf("unable to validate proof. No proof submitted") + } + + connection, found := ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) + if !found { + return fmt.Errorf("connection %s not found", connectionID) + } + + csHeight := clienttypes.NewHeight(clienttypes.ParseChainID(chainID), uint64(height)+1) + consensusState, found := ibcKeeper.ClientKeeper.GetClientConsensusState(ctx, connection.ClientId, csHeight) + + if !found { + return fmt.Errorf("unable to fetch consensus state") + } + + tmConsState, ok := consensusState.(*ibctm.ConsensusState) + if !ok { + return fmt.Errorf("error unmarshaling consensus state") + } + + clientState, found := ibcKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId) + if !found { + return fmt.Errorf("unable to fetch client state") + } + + path := commitmenttypes.NewMerklePath([]string{module, string(key)}...) + + merkleProof, err := commitmenttypes.ConvertProofs(proofOps) + if err != nil { + return fmt.Errorf("error converting proofs") + } + + tmClientState, ok := clientState.(*ibctm.ClientState) + if !ok { + return fmt.Errorf("error unmarshaling client state") + } + + if len(data) != 0 { + err = merkleProof.VerifyMembership(tmClientState.ProofSpecs, tmConsState.GetRoot(), path, data) + err = errors.Wrap(err, "unable to verify inclusion proof") + } else { + // if we got a nil response, verify non inclusion proof. + err = merkleProof.VerifyNonMembership(tmClientState.ProofSpecs, tmConsState.GetRoot(), path) + err = errors.Wrap(err, "unable to verify non-inclusion proof") + } + + return err +} diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go new file mode 100644 index 0000000..0da8789 --- /dev/null +++ b/x/epochs/client/cli/query.go @@ -0,0 +1,107 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + // Group epochs queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetCmdEpochsInfos(), + GetCmdCurrentEpoch(), + ) + + return cmd +} + +// GetCmdEpochsInfos provide running epochInfos. +func GetCmdEpochsInfos() *cobra.Command { + cmd := &cobra.Command{ + Use: "epoch-infos", + Short: "Query running epochInfos", + Long: strings.TrimSpace( + fmt.Sprintf(`Query running epoch infos. + +Example: +$ %s query epochs epoch-infos +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.EpochInfos(cmd.Context(), &types.QueryEpochsInfoRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdCurrentEpoch provides current epoch by specified identifier. +func GetCmdCurrentEpoch() *cobra.Command { + cmd := &cobra.Command{ + Use: "current-epoch", + Short: "Query current epoch by specified identifier", + Long: strings.TrimSpace( + fmt.Sprintf(`Query current epoch by specified identifier. + +Example: +$ %s query epochs current-epoch day +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.CurrentEpoch(cmd.Context(), &types.QueryCurrentEpochRequest{ + Identifier: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/epochs/keeper/abci.go b/x/epochs/keeper/abci.go new file mode 100644 index 0000000..37a4534 --- /dev/null +++ b/x/epochs/keeper/abci.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "fmt" + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// BeginBlocker of epochs module. +func (k Keeper) BeginBlocker(ctx sdk.Context) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { + logger := k.Logger(ctx) + + // If blocktime < initial epoch start time, return + if ctx.BlockTime().Before(epochInfo.StartTime) { + return + } + // if epoch counting hasn't started, signal we need to start. + shouldInitialEpochStart := !epochInfo.EpochCountingStarted + + epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) + shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart + + if !shouldEpochStart { + return false + } + epochInfo.CurrentEpochStartHeight = ctx.BlockHeight() + + if shouldInitialEpochStart { + epochInfo.EpochCountingStarted = true + epochInfo.CurrentEpoch = 1 + epochInfo.CurrentEpochStartTime = epochInfo.StartTime + logger.Info(fmt.Sprintf("Starting new epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) + } else { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeEpochEnd, + sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)), + ), + ) + k.AfterEpochEnd(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch) + epochInfo.CurrentEpoch++ + epochInfo.CurrentEpochStartTime = epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) + logger.Info(fmt.Sprintf("Starting epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) + } + + // emit new epoch start event, set epoch info, and run BeforeEpochStart hook + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeEpochStart, + sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)), + sdk.NewAttribute(types.AttributeEpochStartTime, fmt.Sprintf("%d", epochInfo.CurrentEpochStartTime.Unix())), + ), + ) + k.setEpochInfo(ctx, epochInfo) + k.BeforeEpochStart(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch) + + return false + }) +} diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go new file mode 100644 index 0000000..6255f33 --- /dev/null +++ b/x/epochs/keeper/epoch.go @@ -0,0 +1,122 @@ +package keeper + +import ( + "fmt" + "time" + + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/gogoproto/proto" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// GetEpochInfo returns epoch info by identifier. +func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo { + epoch := types.EpochInfo{} + store := ctx.KVStore(k.storeKey) + + b := store.Get(append(types.KeyPrefixEpoch, []byte(identifier)...)) + if b == nil { + return epoch + } + + err := proto.Unmarshal(b, &epoch) + if err != nil { + panic(err) + } + + return epoch +} + +// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation, +// or re-uses an existing identifier. +// This method also sets the start time if left unset, and sets the epoch start height. +func (k Keeper) AddEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error { + err := epoch.Validate() + if err != nil { + return err + } + // Check if identifier already exists + if (k.GetEpochInfo(ctx, epoch.Identifier) != types.EpochInfo{}) { + return fmt.Errorf("epoch with identifier %s already exists", epoch.Identifier) + } + + // Initialize empty and default epoch values + if epoch.StartTime.Equal(time.Time{}) { + epoch.StartTime = ctx.BlockTime() + } + + epoch.CurrentEpochStartHeight = ctx.BlockHeight() + k.setEpochInfo(ctx, epoch) + + return nil +} + +// setEpochInfo set epoch info. +func (k Keeper) setEpochInfo(ctx sdk.Context, epoch types.EpochInfo) { + store := ctx.KVStore(k.storeKey) + + value, err := proto.Marshal(&epoch) + if err != nil { + panic(err) + } + + store.Set(append(types.KeyPrefixEpoch, []byte(epoch.Identifier)...), value) +} + +// DeleteEpochInfo delete epoch info. +func (k Keeper) DeleteEpochInfo(ctx sdk.Context, identifier string) { + store := ctx.KVStore(k.storeKey) + store.Delete(append(types.KeyPrefixEpoch, []byte(identifier)...)) +} + +// IterateEpochInfo iterate through epochs. +func (k Keeper) IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + iterator := storetypes.KVStorePrefixIterator(store, types.KeyPrefixEpoch) + defer iterator.Close() + + i := int64(0) + + for ; iterator.Valid(); iterator.Next() { + epoch := types.EpochInfo{} + + err := proto.Unmarshal(iterator.Value(), &epoch) + if err != nil { + panic(err) + } + + stop := fn(i, epoch) + if stop { + break + } + i++ + } +} + +// AllEpochInfos iterate through epochs to return all epochs info. +func (k Keeper) AllEpochInfos(ctx sdk.Context) []types.EpochInfo { + epochs := []types.EpochInfo{} + + k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { + epochs = append(epochs, epochInfo) + return false + }) + + return epochs +} + +// NumBlocksSinceEpochStart returns the number of blocks since the epoch started. +// if the epoch started on block N, then calling this during block N (after BeforeEpochStart) +// would return 0. +// Calling it any point in block N+1 (assuming the epoch doesn't increment) would return 1. +func (k Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (int64, error) { + epoch := k.GetEpochInfo(ctx, identifier) + if (epoch == types.EpochInfo{}) { + return 0, fmt.Errorf("epoch with identifier %s not found", identifier) + } + + return ctx.BlockHeight() - epoch.CurrentEpochStartHeight, nil +} diff --git a/x/epochs/keeper/genesis.go b/x/epochs/keeper/genesis.go new file mode 100644 index 0000000..f957b98 --- /dev/null +++ b/x/epochs/keeper/genesis.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +// InitGenesis sets epoch info from genesis +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + for _, epoch := range genState.Epochs { + err := k.AddEpochInfo(ctx, epoch) + if err != nil { + panic(err) + } + } +} + +// ExportGenesis returns the capability module's exported genesis. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Epochs = k.AllEpochInfos(ctx) + + return genesis +} diff --git a/x/epochs/keeper/grpc_query.go b/x/epochs/keeper/grpc_query.go new file mode 100644 index 0000000..c7fa2e0 --- /dev/null +++ b/x/epochs/keeper/grpc_query.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "context" + "errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +var _ types.QueryServer = Querier{} + +// Querier defines a wrapper around the x/epochs keeper providing gRPC method +// handlers. +type Querier struct { + Keeper +} + +// NewQuerier initializes new querier. +func NewQuerier(k Keeper) Querier { + return Querier{Keeper: k} +} + +// EpochInfos provide running epochInfos. +func (q Querier) EpochInfos(c context.Context, _ *types.QueryEpochsInfoRequest) (*types.QueryEpochsInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryEpochsInfoResponse{ + Epochs: q.Keeper.AllEpochInfos(ctx), + }, nil +} + +// CurrentEpoch provides current epoch of specified identifier. +func (q Querier) CurrentEpoch(c context.Context, req *types.QueryCurrentEpochRequest) (*types.QueryCurrentEpochResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.Identifier == "" { + return nil, status.Error(codes.InvalidArgument, "identifier is empty") + } + + ctx := sdk.UnwrapSDKContext(c) + + info := q.Keeper.GetEpochInfo(ctx, req.Identifier) + if info.Identifier != req.Identifier { + return nil, errors.New("not available identifier") + } + + return &types.QueryCurrentEpochResponse{ + CurrentEpoch: info.CurrentEpoch, + }, nil +} diff --git a/x/epochs/keeper/hooks.go b/x/epochs/keeper/hooks.go new file mode 100644 index 0000000..77cc630 --- /dev/null +++ b/x/epochs/keeper/hooks.go @@ -0,0 +1,17 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// AfterEpochEnd gets called at the end of the epoch, end of epoch is the timestamp of first block produced after epoch duration. +func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber int64) { + // Error is not handled as AfterEpochEnd Hooks use osmoutils.ApplyFuncIfNoError() + _ = k.hooks.AfterEpochEnd(ctx, identifier, epochNumber) +} + +// BeforeEpochStart new epoch is next block of epoch end block +func (k Keeper) BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber int64) { + // Error is not handled as BeforeEpochStart Hooks use osmoutils.ApplyFuncIfNoError() + _ = k.hooks.BeforeEpochStart(ctx, identifier, epochNumber) +} diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go new file mode 100644 index 0000000..21daadf --- /dev/null +++ b/x/epochs/keeper/keeper.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +type ( + Keeper struct { + storeKey storetypes.StoreKey + hooks types.EpochHooks + } +) + +// NewKeeper returns a new keeper by codec and storeKey inputs. +func NewKeeper(storeKey storetypes.StoreKey) *Keeper { + return &Keeper{ + storeKey: storeKey, + } +} + +// Set the gamm hooks. +func (k *Keeper) SetHooks(eh types.EpochHooks) *Keeper { + if k.hooks != nil { + panic("cannot set epochs hooks twice") + } + + k.hooks = eh + + return k +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) HooksIsNil() bool { + return k.hooks == nil +} diff --git a/x/epochs/module.go b/x/epochs/module.go new file mode 100644 index 0000000..26f99f2 --- /dev/null +++ b/x/epochs/module.go @@ -0,0 +1,158 @@ +/* +Often in the SDK, we would like to run certain code every-so often. The +purpose of `epochs` module is to allow other modules to set that they +would like to be signaled once every period. So another module can +specify it wants to execute code once a week, starting at UTC-time = x. +`epochs` creates a generalized epoch interface to other modules so that +they can easily be signalled upon such events. + - Contains functionality for querying epoch. + - Events for BeginBlock and EndBlock. + - Initialization for epoch-related infos. +*/ + +package epochs + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/Asphere-xyz/tacchain/x/epochs/client/cli" + "github.com/Asphere-xyz/tacchain/x/epochs/keeper" + "github.com/Asphere-xyz/tacchain/x/epochs/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ appmodule.HasBeginBlocker = AppModule{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct{} + +func NewAppModuleBasic() AppModuleBasic { + return AppModuleBasic{} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the module's Amino codec that properly handles protobuf types with Any's. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types. +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns no root tx command for the halving module. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { return nil } + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule(keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + am.keeper.InitGenesis(ctx, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx context.Context) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + am.keeper.BeginBlocker(sdkCtx) + return nil +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/epochs/types/doc.go b/x/epochs/types/doc.go new file mode 100644 index 0000000..c1b138d --- /dev/null +++ b/x/epochs/types/doc.go @@ -0,0 +1,4 @@ +/* +Package types translates gRPC into RESTful JSON APIs. +*/ +package types diff --git a/x/epochs/types/errors.go b/x/epochs/types/errors.go new file mode 100644 index 0000000..862294b --- /dev/null +++ b/x/epochs/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + "cosmossdk.io/errors" +) + +// x/epochs module sentinel errors. +var ( + ErrSample = errors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/epochs/types/events.go b/x/epochs/types/events.go new file mode 100644 index 0000000..da0ac83 --- /dev/null +++ b/x/epochs/types/events.go @@ -0,0 +1,9 @@ +package types + +const ( + EventTypeEpochEnd = "epoch_end" + EventTypeEpochStart = "epoch_start" + + AttributeEpochNumber = "epoch_number" + AttributeEpochStartTime = "start_time" +) diff --git a/x/epochs/types/genesis.go b/x/epochs/types/genesis.go new file mode 100644 index 0000000..613c111 --- /dev/null +++ b/x/epochs/types/genesis.go @@ -0,0 +1,77 @@ +package types + +import ( + "errors" + "time" +) + +// DefaultIndex is the default capability global index. +const DefaultIndex uint64 = 1 + +func NewGenesisState(epochs []EpochInfo) *GenesisState { + return &GenesisState{Epochs: epochs} +} + +// DefaultGenesis returns the default Capability genesis state. +func DefaultGenesis() *GenesisState { + epochs := []EpochInfo{ + NewGenesisEpochInfo("day", time.Hour*24), // alphabetical order + NewGenesisEpochInfo("hour", time.Hour), + NewGenesisEpochInfo("week", time.Hour*24*7), + } + + return NewGenesisState(epochs) +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + epochIdentifiers := map[string]bool{} + + for _, epoch := range gs.Epochs { + if err := epoch.Validate(); err != nil { + return err + } + + if epochIdentifiers[epoch.Identifier] { + return errors.New("epoch identifier should be unique") + } + + epochIdentifiers[epoch.Identifier] = true + } + + return nil +} + +// Validate also validates epoch info. +func (epoch EpochInfo) Validate() error { + if epoch.Identifier == "" { + return errors.New("epoch identifier should NOT be empty") + } + + if epoch.Duration == 0 { + return errors.New("epoch duration should NOT be 0") + } + + if epoch.CurrentEpoch < 0 { + return errors.New("epoch CurrentEpoch must be non-negative") + } + + if epoch.CurrentEpochStartHeight < 0 { + return errors.New("epoch CurrentEpoch must be non-negative") + } + + return nil +} + +func NewGenesisEpochInfo(identifier string, duration time.Duration) EpochInfo { + return EpochInfo{ + Identifier: identifier, + StartTime: time.Time{}, + Duration: duration, + CurrentEpoch: 0, + CurrentEpochStartHeight: 0, + CurrentEpochStartTime: time.Time{}, + EpochCountingStarted: false, + } +} diff --git a/x/epochs/types/genesis.pb.go b/x/epochs/types/genesis.pb.go new file mode 100644 index 0000000..9617a03 --- /dev/null +++ b/x/epochs/types/genesis.pb.go @@ -0,0 +1,789 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: tacchain/epochs/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 EpochInfo struct { + Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` + StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + Duration time.Duration `protobuf:"bytes,3,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"` + CurrentEpoch int64 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` + CurrentEpochStartTime time.Time `protobuf:"bytes,5,opt,name=current_epoch_start_time,json=currentEpochStartTime,proto3,stdtime" json:"current_epoch_start_time" yaml:"current_epoch_start_time"` + EpochCountingStarted bool `protobuf:"varint,6,opt,name=epoch_counting_started,json=epochCountingStarted,proto3" json:"epoch_counting_started,omitempty"` + CurrentEpochStartHeight int64 `protobuf:"varint,8,opt,name=current_epoch_start_height,json=currentEpochStartHeight,proto3" json:"current_epoch_start_height,omitempty"` +} + +func (m *EpochInfo) Reset() { *m = EpochInfo{} } +func (m *EpochInfo) String() string { return proto.CompactTextString(m) } +func (*EpochInfo) ProtoMessage() {} +func (*EpochInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_1d2331ae1f5f4a03, []int{0} +} +func (m *EpochInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EpochInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EpochInfo.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 *EpochInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_EpochInfo.Merge(m, src) +} +func (m *EpochInfo) XXX_Size() int { + return m.Size() +} +func (m *EpochInfo) XXX_DiscardUnknown() { + xxx_messageInfo_EpochInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_EpochInfo proto.InternalMessageInfo + +func (m *EpochInfo) GetIdentifier() string { + if m != nil { + return m.Identifier + } + return "" +} + +func (m *EpochInfo) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +func (m *EpochInfo) GetDuration() time.Duration { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *EpochInfo) GetCurrentEpoch() int64 { + if m != nil { + return m.CurrentEpoch + } + return 0 +} + +func (m *EpochInfo) GetCurrentEpochStartTime() time.Time { + if m != nil { + return m.CurrentEpochStartTime + } + return time.Time{} +} + +func (m *EpochInfo) GetEpochCountingStarted() bool { + if m != nil { + return m.EpochCountingStarted + } + return false +} + +func (m *EpochInfo) GetCurrentEpochStartHeight() int64 { + if m != nil { + return m.CurrentEpochStartHeight + } + return 0 +} + +// GenesisState defines the epochs module's genesis state. +type GenesisState struct { + Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"` +} + +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_1d2331ae1f5f4a03, []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 + +func (m *GenesisState) GetEpochs() []EpochInfo { + if m != nil { + return m.Epochs + } + return nil +} + +func init() { + proto.RegisterType((*EpochInfo)(nil), "tacchain.epochs.v1beta1.EpochInfo") + proto.RegisterType((*GenesisState)(nil), "tacchain.epochs.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("tacchain/epochs/v1beta1/genesis.proto", fileDescriptor_1d2331ae1f5f4a03) +} + +var fileDescriptor_1d2331ae1f5f4a03 = []byte{ + // 482 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xb1, 0x8e, 0xd3, 0x40, + 0x10, 0xcd, 0x92, 0x10, 0x9c, 0xbd, 0x43, 0xc0, 0xea, 0xe0, 0x4c, 0x24, 0x6c, 0xcb, 0x08, 0xc9, + 0x12, 0xb0, 0x56, 0x0e, 0x2a, 0x68, 0x20, 0x80, 0x38, 0xa8, 0x90, 0x43, 0x81, 0x68, 0x22, 0xc7, + 0xd9, 0xd8, 0x2b, 0x9d, 0x77, 0x2d, 0x7b, 0x8c, 0x2e, 0x54, 0x7c, 0x42, 0x4a, 0x3e, 0xe9, 0xca, + 0x2b, 0xa9, 0x02, 0x4a, 0x3a, 0xca, 0xfb, 0x02, 0xe4, 0x5d, 0x3b, 0x04, 0x8e, 0x13, 0x9d, 0x3d, + 0xef, 0xcd, 0x7b, 0x3b, 0x4f, 0x33, 0xf8, 0x1e, 0x84, 0x51, 0x94, 0x84, 0x5c, 0xf8, 0x2c, 0x93, + 0x51, 0x52, 0xf8, 0x9f, 0x06, 0x13, 0x06, 0xe1, 0xc0, 0x8f, 0x99, 0x60, 0x05, 0x2f, 0x68, 0x96, + 0x4b, 0x90, 0x64, 0xbf, 0xa1, 0x51, 0x4d, 0xa3, 0x35, 0xad, 0xbf, 0x17, 0xcb, 0x58, 0x2a, 0x8e, + 0x5f, 0x7d, 0x69, 0x7a, 0xdf, 0x8a, 0xa5, 0x8c, 0x8f, 0x98, 0xaf, 0xfe, 0x26, 0xe5, 0xcc, 0x9f, + 0x96, 0x79, 0x08, 0x5c, 0x8a, 0x1a, 0xb7, 0xff, 0xc6, 0x81, 0xa7, 0xac, 0x80, 0x30, 0xcd, 0x34, + 0xc1, 0x5d, 0x74, 0x70, 0xef, 0x55, 0xe5, 0xf4, 0x46, 0xcc, 0x24, 0xb1, 0x30, 0xe6, 0x53, 0x26, + 0x80, 0xcf, 0x38, 0xcb, 0x4d, 0xe4, 0x20, 0xaf, 0x17, 0x6c, 0x55, 0xc8, 0x07, 0x8c, 0x0b, 0x08, + 0x73, 0x18, 0x57, 0x32, 0xe6, 0x25, 0x07, 0x79, 0x3b, 0x07, 0x7d, 0xaa, 0x3d, 0x68, 0xe3, 0x41, + 0xdf, 0x37, 0x1e, 0xc3, 0x3b, 0x27, 0x4b, 0xbb, 0x75, 0xb6, 0xb4, 0x6f, 0xcc, 0xc3, 0xf4, 0xe8, + 0x89, 0xfb, 0xbb, 0xd7, 0x5d, 0x7c, 0xb7, 0x51, 0xd0, 0x53, 0x85, 0x8a, 0x4e, 0x12, 0x6c, 0x34, + 0x4f, 0x37, 0xdb, 0x4a, 0xf7, 0xf6, 0x39, 0xdd, 0x97, 0x35, 0x61, 0x38, 0xa8, 0x64, 0x7f, 0x2e, + 0x6d, 0xd2, 0xb4, 0x3c, 0x90, 0x29, 0x07, 0x96, 0x66, 0x30, 0x3f, 0x5b, 0xda, 0xd7, 0xb4, 0x59, + 0x83, 0xb9, 0x5f, 0x2b, 0xab, 0x8d, 0x3a, 0xb9, 0x8b, 0xaf, 0x46, 0x65, 0x9e, 0x33, 0x01, 0x63, + 0x15, 0xb1, 0xd9, 0x71, 0x90, 0xd7, 0x0e, 0x76, 0xeb, 0xa2, 0x0a, 0x83, 0x7c, 0x41, 0xd8, 0xfc, + 0x83, 0x35, 0xde, 0x9a, 0xfb, 0xf2, 0x7f, 0xe7, 0xbe, 0x5f, 0xcf, 0x6d, 0xeb, 0xa7, 0x5c, 0xa4, + 0xa4, 0x53, 0xb8, 0xb9, 0xed, 0x3c, 0xda, 0x24, 0xf2, 0x18, 0xdf, 0xd2, 0xfc, 0x48, 0x96, 0x02, + 0xb8, 0x88, 0x75, 0x23, 0x9b, 0x9a, 0x5d, 0x07, 0x79, 0x46, 0xb0, 0xa7, 0xd0, 0x17, 0x35, 0x38, + 0xd2, 0x18, 0x79, 0x8a, 0xfb, 0xff, 0x72, 0x4b, 0x18, 0x8f, 0x13, 0x30, 0x0d, 0x35, 0xea, 0xfe, + 0x39, 0xc3, 0x43, 0x05, 0xbf, 0xed, 0x18, 0x57, 0xae, 0x1b, 0xee, 0x3b, 0xbc, 0xfb, 0x5a, 0xef, + 0xe4, 0x08, 0x42, 0x60, 0xe4, 0x19, 0xee, 0xea, 0x5d, 0x34, 0x91, 0xd3, 0xf6, 0x76, 0x0e, 0x5c, + 0x7a, 0xc1, 0x8e, 0xd2, 0xcd, 0x22, 0x0d, 0x3b, 0x55, 0x00, 0x41, 0xdd, 0x37, 0x3c, 0x3c, 0x59, + 0x59, 0xe8, 0x74, 0x65, 0xa1, 0x1f, 0x2b, 0x0b, 0x2d, 0xd6, 0x56, 0xeb, 0x74, 0x6d, 0xb5, 0xbe, + 0xad, 0xad, 0xd6, 0x47, 0x1a, 0x73, 0x48, 0xca, 0x09, 0x8d, 0x64, 0xea, 0x3f, 0x2f, 0xb2, 0x84, + 0xe5, 0xec, 0xe1, 0xf1, 0xfc, 0xb3, 0xbf, 0x39, 0x96, 0xe3, 0xe6, 0x5c, 0x60, 0x9e, 0xb1, 0x62, + 0xd2, 0x55, 0x61, 0x3f, 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x91, 0xba, 0x89, 0x4e, 0x03, + 0x00, 0x00, +} + +func (m *EpochInfo) 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 *EpochInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EpochInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentEpochStartHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpochStartHeight)) + i-- + dAtA[i] = 0x40 + } + if m.EpochCountingStarted { + i-- + if m.EpochCountingStarted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CurrentEpochStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintGenesis(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x2a + if m.CurrentEpoch != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpoch)) + i-- + dAtA[i] = 0x20 + } + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.Duration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintGenesis(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x1a + n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintGenesis(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x12 + if len(m.Identifier) > 0 { + i -= len(m.Identifier) + copy(dAtA[i:], m.Identifier) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Identifier))) + i-- + dAtA[i] = 0xa + } + 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.Epochs) > 0 { + for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Epochs[iNdEx].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 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 *EpochInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identifier) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovGenesis(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration) + n += 1 + l + sovGenesis(uint64(l)) + if m.CurrentEpoch != 0 { + n += 1 + sovGenesis(uint64(m.CurrentEpoch)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime) + n += 1 + l + sovGenesis(uint64(l)) + if m.EpochCountingStarted { + n += 2 + } + if m.CurrentEpochStartHeight != 0 { + n += 1 + sovGenesis(uint64(m.CurrentEpochStartHeight)) + } + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Epochs) > 0 { + for _, e := range m.Epochs { + l = e.Size() + 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 *EpochInfo) 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: EpochInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EpochInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identifier = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", 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 := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) + } + m.CurrentEpoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpoch |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CurrentEpochStartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochCountingStarted", wireType) + } + 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.EpochCountingStarted = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartHeight", wireType) + } + m.CurrentEpochStartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpochStartHeight |= int64(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 Epochs", 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.Epochs = append(m.Epochs, EpochInfo{}) + if err := m.Epochs[len(m.Epochs)-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 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/epochs/types/hooks.go b/x/epochs/types/hooks.go new file mode 100644 index 0000000..780ad13 --- /dev/null +++ b/x/epochs/types/hooks.go @@ -0,0 +1,59 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Asphere-xyz/tacchain/utils" +) + +type EpochHooks interface { + // the first block whose timestamp is after the duration is counted as the end of the epoch + AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error + // new epoch is next block of epoch end block + BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error +} + +var _ EpochHooks = MultiEpochHooks{} + +// combine multiple gamm hooks, all hook functions are run in array sequence. +type MultiEpochHooks []EpochHooks + +func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks { + return hooks +} + +// AfterEpochEnd is called when epoch is going to be ended, epochNumber is the number of epoch that is ending. +func (h MultiEpochHooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + for i := range h { + panicCatchingEpochHook(ctx, h[i].AfterEpochEnd, epochIdentifier, epochNumber) + } + + return nil +} + +// BeforeEpochStart is called when epoch is going to be started, epochNumber is the number of epoch that is starting. +func (h MultiEpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + for i := range h { + panicCatchingEpochHook(ctx, h[i].BeforeEpochStart, epochIdentifier, epochNumber) + } + + return nil +} + +func panicCatchingEpochHook( + ctx sdk.Context, + hookFn func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error, + epochIdentifier string, + epochNumber int64, +) { + wrappedHookFn := func(ctx sdk.Context) error { + return hookFn(ctx, epochIdentifier, epochNumber) + } + // TODO: Thread info for which hook this is, may be dependent on larger hook system refactoring + err := utils.ApplyFuncIfNoError(ctx, wrappedHookFn) + if err != nil { + ctx.Logger().Error(fmt.Sprintf("error in epoch hook %v", err)) + } +} diff --git a/x/epochs/types/keys.go b/x/epochs/types/keys.go new file mode 100644 index 0000000..4f3a602 --- /dev/null +++ b/x/epochs/types/keys.go @@ -0,0 +1,12 @@ +package types + +const ( + // ModuleName defines the module name. + ModuleName = "epochs" + + // StoreKey defines the primary module store key. + StoreKey = ModuleName +) + +// KeyPrefixEpoch defines prefix key for storing epochs. +var KeyPrefixEpoch = []byte{0x01} diff --git a/x/epochs/types/query.pb.go b/x/epochs/types/query.pb.go new file mode 100644 index 0000000..6187f94 --- /dev/null +++ b/x/epochs/types/query.pb.go @@ -0,0 +1,912 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: tacchain/epochs/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "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" + 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 QueryEpochsInfoRequest struct { +} + +func (m *QueryEpochsInfoRequest) Reset() { *m = QueryEpochsInfoRequest{} } +func (m *QueryEpochsInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEpochsInfoRequest) ProtoMessage() {} +func (*QueryEpochsInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{0} +} +func (m *QueryEpochsInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochsInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochsInfoRequest.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 *QueryEpochsInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochsInfoRequest.Merge(m, src) +} +func (m *QueryEpochsInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochsInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochsInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochsInfoRequest proto.InternalMessageInfo + +type QueryEpochsInfoResponse struct { + Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"` +} + +func (m *QueryEpochsInfoResponse) Reset() { *m = QueryEpochsInfoResponse{} } +func (m *QueryEpochsInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEpochsInfoResponse) ProtoMessage() {} +func (*QueryEpochsInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{1} +} +func (m *QueryEpochsInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochsInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochsInfoResponse.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 *QueryEpochsInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochsInfoResponse.Merge(m, src) +} +func (m *QueryEpochsInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochsInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochsInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochsInfoResponse proto.InternalMessageInfo + +func (m *QueryEpochsInfoResponse) GetEpochs() []EpochInfo { + if m != nil { + return m.Epochs + } + return nil +} + +type QueryCurrentEpochRequest struct { + Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` +} + +func (m *QueryCurrentEpochRequest) Reset() { *m = QueryCurrentEpochRequest{} } +func (m *QueryCurrentEpochRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentEpochRequest) ProtoMessage() {} +func (*QueryCurrentEpochRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{2} +} +func (m *QueryCurrentEpochRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentEpochRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentEpochRequest.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 *QueryCurrentEpochRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentEpochRequest.Merge(m, src) +} +func (m *QueryCurrentEpochRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentEpochRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentEpochRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentEpochRequest proto.InternalMessageInfo + +func (m *QueryCurrentEpochRequest) GetIdentifier() string { + if m != nil { + return m.Identifier + } + return "" +} + +type QueryCurrentEpochResponse struct { + CurrentEpoch int64 `protobuf:"varint,1,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` +} + +func (m *QueryCurrentEpochResponse) Reset() { *m = QueryCurrentEpochResponse{} } +func (m *QueryCurrentEpochResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentEpochResponse) ProtoMessage() {} +func (*QueryCurrentEpochResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9f8cfb8c21c0a618, []int{3} +} +func (m *QueryCurrentEpochResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentEpochResponse.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 *QueryCurrentEpochResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentEpochResponse.Merge(m, src) +} +func (m *QueryCurrentEpochResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentEpochResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentEpochResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentEpochResponse proto.InternalMessageInfo + +func (m *QueryCurrentEpochResponse) GetCurrentEpoch() int64 { + if m != nil { + return m.CurrentEpoch + } + return 0 +} + +func init() { + proto.RegisterType((*QueryEpochsInfoRequest)(nil), "tacchain.epochs.v1beta1.QueryEpochsInfoRequest") + proto.RegisterType((*QueryEpochsInfoResponse)(nil), "tacchain.epochs.v1beta1.QueryEpochsInfoResponse") + proto.RegisterType((*QueryCurrentEpochRequest)(nil), "tacchain.epochs.v1beta1.QueryCurrentEpochRequest") + proto.RegisterType((*QueryCurrentEpochResponse)(nil), "tacchain.epochs.v1beta1.QueryCurrentEpochResponse") +} + +func init() { + proto.RegisterFile("tacchain/epochs/v1beta1/query.proto", fileDescriptor_9f8cfb8c21c0a618) +} + +var fileDescriptor_9f8cfb8c21c0a618 = []byte{ + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbf, 0x4e, 0xe3, 0x30, + 0x1c, 0xc7, 0xe3, 0xf6, 0xae, 0xd2, 0xf9, 0x7a, 0x8b, 0x75, 0xba, 0xe6, 0xa2, 0x53, 0xda, 0x4b, + 0x75, 0x47, 0x17, 0x6c, 0x5a, 0x36, 0xa6, 0x52, 0x84, 0x04, 0x23, 0x19, 0x61, 0x40, 0x69, 0x70, + 0x13, 0x4b, 0x60, 0xa7, 0xb1, 0x83, 0x5a, 0x46, 0x9e, 0x00, 0x89, 0x85, 0x17, 0xe0, 0x5d, 0x2a, + 0xa6, 0x4a, 0x2c, 0x4c, 0x08, 0xb5, 0x3c, 0x08, 0xaa, 0x93, 0x42, 0x11, 0x0d, 0x82, 0x2d, 0xb1, + 0x3f, 0xdf, 0x3f, 0xbf, 0x5f, 0x02, 0xeb, 0xca, 0xf3, 0xfd, 0xd0, 0x63, 0x9c, 0xd0, 0x48, 0xf8, + 0xa1, 0x24, 0xa7, 0xcd, 0x2e, 0x55, 0x5e, 0x93, 0xf4, 0x13, 0x1a, 0x0f, 0x71, 0x14, 0x0b, 0x25, + 0x50, 0x65, 0x0e, 0xe1, 0x14, 0xc2, 0x19, 0x64, 0xfd, 0x0c, 0x44, 0x20, 0x34, 0x43, 0x66, 0x4f, + 0x29, 0x6e, 0xfd, 0x09, 0x84, 0x08, 0x8e, 0x29, 0xf1, 0x22, 0x46, 0x3c, 0xce, 0x85, 0xf2, 0x14, + 0x13, 0x5c, 0x66, 0xb7, 0xff, 0xf2, 0x12, 0x03, 0xca, 0xa9, 0x64, 0x19, 0xe6, 0x98, 0xf0, 0xd7, + 0xde, 0xac, 0xc2, 0xb6, 0x86, 0x76, 0x79, 0x4f, 0xb8, 0xb4, 0x9f, 0x50, 0xa9, 0x9c, 0x03, 0x58, + 0x79, 0x73, 0x23, 0x23, 0xc1, 0x25, 0x45, 0x6d, 0x58, 0x4a, 0x4d, 0x4d, 0x50, 0x2b, 0x36, 0xbe, + 0xb7, 0x1c, 0x9c, 0xd3, 0x1c, 0x6b, 0xf1, 0x4c, 0xdb, 0xf9, 0x32, 0xba, 0xaf, 0x1a, 0x6e, 0xa6, + 0x73, 0x36, 0xa0, 0xa9, 0xcd, 0xb7, 0x92, 0x38, 0xa6, 0x5c, 0x69, 0x2c, 0x0b, 0x46, 0x36, 0x84, + 0xec, 0x88, 0x72, 0xc5, 0x7a, 0x8c, 0xc6, 0x26, 0xa8, 0x81, 0xc6, 0x37, 0x77, 0xe1, 0xc4, 0x69, + 0xc3, 0xdf, 0x4b, 0xb4, 0x59, 0xb5, 0x3a, 0xfc, 0xe1, 0xa7, 0xe7, 0x87, 0x3a, 0x4a, 0xeb, 0x8b, + 0x6e, 0xd9, 0x5f, 0x80, 0x5b, 0x37, 0x05, 0xf8, 0x55, 0x5b, 0xa0, 0x2b, 0x00, 0xe1, 0x73, 0x47, + 0x89, 0x48, 0xee, 0x20, 0xcb, 0x97, 0x64, 0xad, 0x7d, 0x5c, 0x90, 0x16, 0x74, 0x56, 0xce, 0x6f, + 0x1f, 0x2f, 0x0b, 0x7f, 0x51, 0x95, 0xe4, 0x7d, 0xa0, 0xf4, 0x15, 0x5d, 0x03, 0x58, 0x5e, 0x1c, + 0x11, 0x35, 0xdf, 0xcf, 0x5a, 0xb2, 0x4a, 0xab, 0xf5, 0x19, 0x49, 0x56, 0x10, 0xeb, 0x82, 0x0d, + 0xf4, 0x3f, 0xb7, 0xe0, 0xab, 0x05, 0x77, 0x76, 0x46, 0x13, 0x1b, 0x8c, 0x27, 0x36, 0x78, 0x98, + 0xd8, 0xe0, 0x62, 0x6a, 0x1b, 0xe3, 0xa9, 0x6d, 0xdc, 0x4d, 0x6d, 0x63, 0x1f, 0x07, 0x4c, 0x85, + 0x49, 0x17, 0xfb, 0xe2, 0x84, 0x6c, 0xca, 0x28, 0xa4, 0x31, 0x5d, 0x1d, 0x0c, 0xcf, 0x5e, 0x7c, + 0x07, 0x73, 0x67, 0x35, 0x8c, 0xa8, 0xec, 0x96, 0xf4, 0x2f, 0xb9, 0xfe, 0x14, 0x00, 0x00, 0xff, + 0xff, 0xfa, 0xf5, 0xae, 0xf3, 0x2d, 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 { + // EpochInfos provide running epochInfos + EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) + // CurrentEpoch provide current epoch of specified identifier + CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) { + out := new(QueryEpochsInfoResponse) + err := c.cc.Invoke(ctx, "/tacchain.epochs.v1beta1.Query/EpochInfos", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) { + out := new(QueryCurrentEpochResponse) + err := c.cc.Invoke(ctx, "/tacchain.epochs.v1beta1.Query/CurrentEpoch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // EpochInfos provide running epochInfos + EpochInfos(context.Context, *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) + // CurrentEpoch provide current epoch of specified identifier + CurrentEpoch(context.Context, *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) EpochInfos(ctx context.Context, req *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EpochInfos not implemented") +} +func (*UnimplementedQueryServer) CurrentEpoch(ctx context.Context, req *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CurrentEpoch not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_EpochInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEpochsInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EpochInfos(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tacchain.epochs.v1beta1.Query/EpochInfos", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EpochInfos(ctx, req.(*QueryEpochsInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CurrentEpoch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCurrentEpochRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CurrentEpoch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tacchain.epochs.v1beta1.Query/CurrentEpoch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CurrentEpoch(ctx, req.(*QueryCurrentEpochRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "tacchain.epochs.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "EpochInfos", + Handler: _Query_EpochInfos_Handler, + }, + { + MethodName: "CurrentEpoch", + Handler: _Query_CurrentEpoch_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "tacchain/epochs/v1beta1/query.proto", +} + +func (m *QueryEpochsInfoRequest) 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 *QueryEpochsInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochsInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryEpochsInfoResponse) 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 *QueryEpochsInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochsInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Epochs) > 0 { + for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Epochs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryCurrentEpochRequest) 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 *QueryCurrentEpochRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentEpochRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Identifier) > 0 { + i -= len(m.Identifier) + copy(dAtA[i:], m.Identifier) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Identifier))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCurrentEpochResponse) 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 *QueryCurrentEpochResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentEpoch != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpoch)) + 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 *QueryEpochsInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryEpochsInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Epochs) > 0 { + for _, e := range m.Epochs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryCurrentEpochRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identifier) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCurrentEpochResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CurrentEpoch != 0 { + n += 1 + sovQuery(uint64(m.CurrentEpoch)) + } + 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 *QueryEpochsInfoRequest) 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: QueryEpochsInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochsInfoRequest: 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 *QueryEpochsInfoResponse) 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: QueryEpochsInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochsInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Epochs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Epochs = append(m.Epochs, EpochInfo{}) + if err := m.Epochs[len(m.Epochs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCurrentEpochRequest) 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: QueryCurrentEpochRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentEpochRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", 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.Identifier = 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 (m *QueryCurrentEpochResponse) 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: QueryCurrentEpochResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) + } + m.CurrentEpoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpoch |= int64(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/epochs/types/query.pb.gw.go b/x/epochs/types/query.pb.gw.go new file mode 100644 index 0000000..4051633 --- /dev/null +++ b/x/epochs/types/query.pb.gw.go @@ -0,0 +1,236 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: tacchain/epochs/v1beta1/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_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEpochsInfoRequest + var metadata runtime.ServerMetadata + + msg, err := client.EpochInfos(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEpochsInfoRequest + var metadata runtime.ServerMetadata + + msg, err := server.EpochInfos(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_CurrentEpoch_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentEpochRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CurrentEpoch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentEpochRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CurrentEpoch(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_EpochInfos_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_EpochInfos_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_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CurrentEpoch_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_CurrentEpoch_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_CurrentEpoch_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_EpochInfos_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_EpochInfos_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_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CurrentEpoch_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_CurrentEpoch_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_CurrentEpoch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_EpochInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"tacchain", "epochs", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_CurrentEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tacchain", "epochs", "v1beta1", "current_epoch"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_EpochInfos_0 = runtime.ForwardResponseMessage + + forward_Query_CurrentEpoch_0 = runtime.ForwardResponseMessage +) diff --git a/x/liquidstake/keeper/hooks.go b/x/liquidstake/keeper/hooks.go index e5cfb5a..82d624e 100644 --- a/x/liquidstake/keeper/hooks.go +++ b/x/liquidstake/keeper/hooks.go @@ -1,11 +1,8 @@ package keeper import ( - "fmt" - + epochstypes "github.com/Asphere-xyz/tacchain/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" - // TODO: replace it with local cosmos sdk epoch hooks - // epochstypes "github.com/persistenceOne/persistence-sdk/v2/x/epochs/types" liquidstake "github.com/Asphere-xyz/tacchain/x/liquidstake/types" ) @@ -14,8 +11,7 @@ type EpochHooks struct { k Keeper } -// TODO: replace it with local cosmos sdk epoch hooks -// var _ epochstypes.EpochHooks = EpochHooks{} +var _ epochstypes.EpochHooks = EpochHooks{} func (k Keeper) EpochHooks() EpochHooks { return EpochHooks{k} @@ -33,13 +29,13 @@ func (h EpochHooks) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error { func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, _ int64) error { if !k.GetParams(ctx).ModulePaused { // Update the liquid validator set at the start of each epoch - switch epochIdentifier { - case liquidstake.AutocompoundEpoch: + if epochIdentifier == liquidstake.AutocompoundEpoch { k.AutocompoundStakingRewards(ctx, liquidstake.GetWhitelistedValsMap(k.GetParams(ctx).WhitelistedValidators)) - case liquidstake.RebalanceEpoch: + } + + if epochIdentifier == liquidstake.RebalanceEpoch { + // return value of UpdateLiquidValidatorSet is useful only in testing _ = k.UpdateLiquidValidatorSet(ctx, true) - default: - return fmt.Errorf("unknown epoch identifier: %s", epochIdentifier) } } From 81fba245109081ede67494c98fb4602519488b7a Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Wed, 23 Jul 2025 15:28:56 +0300 Subject: [PATCH 075/112] fix: localnet-start script --- contrib/localnet/start.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index f4b17cb..acd3d4f 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -4,6 +4,13 @@ CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} TACCHAIND=${TACCHAIND:-$(which tacchaind)} HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} +P2P_LADDR=${P2P_LADDR:-tcp://0.0.0.0:26656} +P2P_EXTERNAL_ADDRESS=${P2P_EXTERNAL_ADDRESS:-${P2P_LADDR}} +RPC_LADDR=${RPC_LADDR:-tcp://127.0.0.1:26657} +JSON_RPC_ADDR=${JSON_RPC_ADDR:-127.0.0.1:8545} +JSON_RPC_WS_ADDR=${JSON_RPC_WS_ADDR:-127.0.0.1:8546} +GRPC_LADDR=${GRPC_LADDR:-0.0.0.0:9090} + sed -i.bak -E 's@(address = "tcp://)[^:/]+(:[0-9]+")@\10.0.0.0\2@g' "$HOMEDIR/config/app.toml" $TACCHAIND start --chain-id $CHAIN_ID \ @@ -17,5 +24,5 @@ $TACCHAIND start --chain-id $CHAIN_ID \ --grpc.address $GRPC_LADDR \ --grpc.enable=true \ --api.enable=true \ - --api.enabled-unsafe-cors ---home $HOMEDIR + --api.enabled-unsafe-cors \ + --home $HOMEDIR From 92658f20a213497363e839897a5e1d983cf09322 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 24 Jul 2025 12:05:25 +0300 Subject: [PATCH 076/112] refactor: module variables renamed to TAC format --- Makefile | 23 ++ app/app.go | 19 -- app/token_pair.go | 19 -- .../init-liquidstake-for-multinode.sh | 4 +- contrib/localnet/init.sh | 27 ++- proto/buf.lock | 25 ++- proto/buf.yaml | 4 +- proto/tac/epochs/v1beta1/genesis.proto | 37 +++ proto/tac/epochs/v1beta1/query.proto | 29 +++ .../liquidstake/v1beta1/genesis.proto | 6 +- .../liquidstake/v1beta1/liquidstake.proto | 12 +- .../liquidstake/v1beta1/query.proto | 13 +- .../liquidstake/v1beta1/tx.proto | 14 +- scripts/protocgen.sh | 2 +- x/epochs/types/genesis.pb.go | 77 +++---- x/epochs/types/query.pb.go | 94 ++++---- x/epochs/types/query.pb.gw.go | 2 +- x/liquidstake/client/cli/query.go | 2 +- x/liquidstake/client/cli/tx.go | 38 ++-- x/liquidstake/keeper/keeper_test.go | 24 +- x/liquidstake/keeper/liquidstake.go | 88 ++++---- x/liquidstake/keeper/liquidstake_test.go | 2 +- x/liquidstake/keeper/msg_server.go | 36 +-- x/liquidstake/types/errors.go | 2 +- x/liquidstake/types/events.go | 2 +- x/liquidstake/types/genesis.pb.go | 48 ++-- x/liquidstake/types/keys.go | 2 +- x/liquidstake/types/liquidstake.go | 14 +- x/liquidstake/types/liquidstake.pb.go | 178 +++++++-------- x/liquidstake/types/msgs_test.go | 8 +- x/liquidstake/types/params.go | 4 +- x/liquidstake/types/query.pb.go | 114 +++++----- x/liquidstake/types/query.pb.gw.go | 8 +- x/liquidstake/types/tx.pb.go | 210 +++++++++--------- 34 files changed, 617 insertions(+), 570 deletions(-) delete mode 100644 app/token_pair.go create mode 100644 proto/tac/epochs/v1beta1/genesis.proto create mode 100644 proto/tac/epochs/v1beta1/query.proto rename proto/{pstake => tac}/liquidstake/v1beta1/genesis.proto (72%) rename proto/{pstake => tac}/liquidstake/v1beta1/liquidstake.proto (96%) rename proto/{pstake => tac}/liquidstake/v1beta1/query.proto (80%) rename proto/{pstake => tac}/liquidstake/v1beta1/tx.proto (93%) diff --git a/Makefile b/Makefile index a0ba65b..cca235d 100644 --- a/Makefile +++ b/Makefile @@ -88,6 +88,8 @@ go.sum: go.mod clean: rm -rf build/ +.PHONY: all install build build-windows-client go.sum clean + ############################################################################### ### Tests ### ############################################################################### @@ -121,6 +123,8 @@ test-ledger: test-solidity: ./tests/solidity/run-solidity-tests.sh +.PHONY: test test-unit test-race test-e2e test-cover test-benchmark test-localnet-params test-localnet-evm test-ledger test-solidity + ############################################################################### ### Networks ### ############################################################################### @@ -139,6 +143,12 @@ localnet-init-multi-node: localnet-start: ./contrib/localnet/start.sh +.PHONY: localnet-start localnet-init localnet-init-multi-node + +############################################################################### +### Protobuf ### +############################################################################### + DOCKER := $(shell which docker) BUILDDIR ?= $(CURDIR)/build @@ -146,8 +156,21 @@ protoVer=0.14.0 protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) +proto-all: proto-format proto-gen + proto-gen: @echo "Generating Protobuf files" @$(protoImage) sh ./scripts/protocgen.sh @go mod tidy +proto-format: + @$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \; + +proto-check-breaking: + @$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main + +proto-update-deps: + @echo "Updating Protobuf dependencies" + $(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(protoImageName) buf mod update + +.PHONY: proto-all proto-gen proto-format proto-check-breaking proto-update-deps diff --git a/app/app.go b/app/app.go index 5175497..f3e6b19 100644 --- a/app/app.go +++ b/app/app.go @@ -16,7 +16,6 @@ import ( epochskeeper "github.com/Asphere-xyz/tacchain/x/epochs/keeper" epochstypes "github.com/Asphere-xyz/tacchain/x/epochs/types" abci "github.com/cometbft/cometbft/abci/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" "github.com/cosmos/ibc-go/modules/capability" @@ -1002,10 +1001,6 @@ func NewTacChainApp( } } - app.initErc20TokenPair(app.NewUncachedContext(false, cmtproto.Header{})) - - app.initLiquidStakeModule(app.NewUncachedContext(false, cmtproto.Header{})) - return app } @@ -1155,8 +1150,6 @@ func (app *TacChainApp) DefaultGenesis() map[string]json.RawMessage { // ERC20 genesis configuration erc20GenState := evmerc20types.DefaultGenesisState() - erc20GenState.TokenPairs = TacTokenPairs - erc20GenState.Params.NativePrecompiles = append(erc20GenState.Params.NativePrecompiles, WTACContract) erc20GenState.Params.EnableErc20 = true genesis[evmerc20types.ModuleName] = app.appCodec.MustMarshalJSON(erc20GenState) @@ -1256,18 +1249,6 @@ func (app *TacChainApp) RegisterNodeService(clientCtx client.Context, cfg config nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } -func (app *TacChainApp) initErc20TokenPair(ctx sdk.Context) { - for _, pair := range TacTokenPairs { - app.Erc20Keeper.SetToken(ctx, pair) - } -} - -func (app *TacChainApp) initLiquidStakeModule(ctx sdk.Context) { - params := app.LiquidStakeKeeper.GetParams(ctx) - params.ModulePaused = false - app.LiquidStakeKeeper.SetParams(ctx, params) -} - // GetMaccPerms returns a copy of the module account permissions // // NOTE: This is solely to be used for testing purposes. diff --git a/app/token_pair.go b/app/token_pair.go deleted file mode 100644 index 526fb9a..0000000 --- a/app/token_pair.go +++ /dev/null @@ -1,19 +0,0 @@ -package app - -import ( - erc20types "github.com/cosmos/evm/x/erc20/types" - "github.com/ethereum/go-ethereum/common" -) - -// NOTE: This is the WToken contract on EVM Testnet (Saint Peterburg) -const WTACContract = "0xCf61405b7525F09f4E7501fc831fE7cbCc823d4c" - -const gTACDenom = "ugtac" - -var GTACTokenPair = erc20types.NewTokenPair( - common.HexToAddress(WTACContract), - gTACDenom, - erc20types.OWNER_MODULE, -) - -var TacTokenPairs = []erc20types.TokenPair{GTACTokenPair} diff --git a/contrib/localnet/init-liquidstake-for-multinode.sh b/contrib/localnet/init-liquidstake-for-multinode.sh index 9e9069a..d1eb602 100644 --- a/contrib/localnet/init-liquidstake-for-multinode.sh +++ b/contrib/localnet/init-liquidstake-for-multinode.sh @@ -237,7 +237,7 @@ jq ' "token_pairs": [ { "erc20_address": "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517", - "denom": "ugtac", + "denom": "stk/utac", "enabled": true, "contract_owner": "OWNER_MODULE" } @@ -248,7 +248,7 @@ jq ' jq ' .app_state.liquidstake = { "params": { - "liquid_bond_denom": "ugtac", + "liquid_bond_denom": "stk/utac", "whitelisted_validators": [ { "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index f3f4671..152d2b4 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -41,8 +41,8 @@ PROXY_PORT=${PROXY_PORT:-26658} # prompt user for confirmation before cleanup read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm if [[ $confirm != "y" && $confirm != "Y" ]]; then - echo "Cleanup aborted." - exit 1 + echo "Cleanup aborted." + exit 1 fi # cleanup old data @@ -71,7 +71,7 @@ jq ' "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # arachnid (https://github.com/Arachnid/deterministic-deployment-proxy) jq ' @@ -87,8 +87,7 @@ jq ' "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # multicall (https://github.com/mds1/multicall3) jq ' @@ -104,7 +103,7 @@ jq ' "code": "6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # createx (https://github.com/pcaversaccio/createx) jq ' @@ -120,7 +119,7 @@ jq ' "code": "60806040526004361061018a5760003560e01c806381503da1116100d6578063d323826a1161007f578063e96deee411610059578063e96deee414610395578063f5745aba146103a8578063f9664498146103bb57600080fd5b8063d323826a1461034f578063ddda0acb1461036f578063e437252a1461038257600080fd5b80639c36a286116100b05780639c36a28614610316578063a7db93f214610329578063c3fe107b1461033c57600080fd5b806381503da1146102d0578063890c283b146102e357806398e810771461030357600080fd5b80632f990e3f116101385780636cec2536116101125780636cec25361461027d57806374637a7a1461029d5780637f565360146102bd57600080fd5b80632f990e3f1461023757806331a7c8c81461024a57806342d654fc1461025d57600080fd5b806327fe18221161016957806327fe1822146101f15780632852527a1461020457806328ddd0461461021757600080fd5b8062d84acb1461018f57806326307668146101cb57806326a32fc7146101de575b600080fd5b6101a261019d366004612915565b6103ce565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6101a26101d9366004612994565b6103e6565b6101a26101ec3660046129db565b610452565b6101a26101ff3660046129db565b6104de565b6101a2610212366004612a39565b610539565b34801561022357600080fd5b506101a2610232366004612a90565b6106fe565b6101a2610245366004612aa9565b61072a565b6101a2610258366004612aa9565b6107bb565b34801561026957600080fd5b506101a2610278366004612b1e565b6107c9565b34801561028957600080fd5b506101a2610298366004612a90565b610823565b3480156102a957600080fd5b506101a26102b8366004612b4a565b61084f565b6101a26102cb3660046129db565b611162565b6101a26102de366004612b74565b6111e8565b3480156102ef57600080fd5b506101a26102fe366004612bac565b611276565b6101a2610311366004612bce565b6112a3565b6101a2610324366004612994565b611505565b6101a2610337366004612c49565b6116f1565b6101a261034a366004612aa9565b611964565b34801561035b57600080fd5b506101a261036a366004612cd9565b6119ed565b6101a261037d366004612c49565b611a17565b6101a2610390366004612bce565b611e0c565b6101a26103a3366004612915565b611e95565b6101a26103b6366004612bce565b611ea4565b6101a26103c9366004612b74565b611f2d565b60006103dd8585858533611a17565b95945050505050565b6000806103f2846120db565b90508083516020850134f59150610408826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a35092915050565b60006104d86104d260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b836103e6565b92915050565b600081516020830134f090506104f3816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a2919050565b600080610545856120db565b905060008460601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f593505073ffffffffffffffffffffffffffffffffffffffff8316610635576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1660048201526024015b60405180910390fd5b604051829073ffffffffffffffffffffffffffffffffffffffff8516907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808473ffffffffffffffffffffffffffffffffffffffff1634876040516106a19190612d29565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b50915091506106f382828961247d565b505050509392505050565b60006104d87f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed8361084f565b60006107b36107aa60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b85858533611a17565b949350505050565b60006107b3848484336112a3565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b60006104d8827f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6107c9565b600060607f9400000000000000000000000000000000000000000000000000000000000000610887600167ffffffffffffffff612d45565b67ffffffffffffffff16841115610902576040517f3c55ab3b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b836000036109c7576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f800000000000000000000000000000000000000000000000000000000000000060368201526037015b6040516020818303038152906040529150611152565b607f8411610a60576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b16602283015260f886901b1660368201526037016109b1565b60ff8411610b1f576040517fd70000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660228301527f8100000000000000000000000000000000000000000000000000000000000000603683015260f886901b1660378201526038016109b1565b61ffff8411610bff576040517fd80000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f820000000000000000000000000000000000000000000000000000000000000060368201527fffff00000000000000000000000000000000000000000000000000000000000060f086901b1660378201526039016109b1565b62ffffff8411610ce0576040517fd90000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f830000000000000000000000000000000000000000000000000000000000000060368201527fffffff000000000000000000000000000000000000000000000000000000000060e886901b166037820152603a016109b1565b63ffffffff8411610dc2576040517fda0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f840000000000000000000000000000000000000000000000000000000000000060368201527fffffffff0000000000000000000000000000000000000000000000000000000060e086901b166037820152603b016109b1565b64ffffffffff8411610ea5576040517fdb0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f850000000000000000000000000000000000000000000000000000000000000060368201527fffffffffff00000000000000000000000000000000000000000000000000000060d886901b166037820152603c016109b1565b65ffffffffffff8411610f89576040517fdc0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f860000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffff000000000000000000000000000000000000000000000000000060d086901b166037820152603d016109b1565b66ffffffffffffff841161106e576040517fdd0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f870000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffff0000000000000000000000000000000000000000000000000060c886901b166037820152603e016109b1565b6040517fde0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f880000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffffff00000000000000000000000000000000000000000000000060c086901b166037820152603f0160405160208183030381529060405291505b5080516020909101209392505050565b60006104d86111e260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b83611505565b600061126f61126860408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b8484610539565b9392505050565b600061126f83837f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6119ed565b60008451602086018451f090506112b9816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808273ffffffffffffffffffffffffffffffffffffffff168560200151876040516113279190612d29565b60006040518083038185875af1925050503d8060008114611364576040519150601f19603f3d011682016040523d82523d6000602084013e611369565b606091505b5091509150816113c9577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1631156114fb578373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611495576040519150601f19603f3d011682016040523d82523d6000602084013e61149a565b606091505b509092509050816114fb577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b5050949350505050565b600080611511846120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff81166115e0576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a361162c83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1634876040516116569190612d29565b60006040518083038185875af1925050503d8060008114611693576040519150601f19603f3d011682016040523d82523d6000602084013e611698565b606091505b505090506116a681866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a25050505092915050565b6000806116fd876120db565b9050808651602088018651f59150611714826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808373ffffffffffffffffffffffffffffffffffffffff168660200151886040516117849190612d29565b60006040518083038185875af1925050503d80600081146117c1576040519150601f19603f3d011682016040523d82523d6000602084013e6117c6565b606091505b509150915081611826577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611958578473ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d80600081146118f2576040519150601f19603f3d011682016040523d82523d6000602084013e6118f7565b606091505b50909250905081611958577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b50505095945050505050565b60006107b36119e460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b858585336116f1565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b600080611a23876120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff8116611af2576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a3611b3e83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1687600001518a604051611b6c9190612d29565b60006040518083038185875af1925050503d8060008114611ba9576040519150601f19603f3d011682016040523d82523d6000602084013e611bae565b606091505b50509050611bbc81866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a260608573ffffffffffffffffffffffffffffffffffffffff1688602001518a604051611c299190612d29565b60006040518083038185875af1925050503d8060008114611c66576040519150601f19603f3d011682016040523d82523d6000602084013e611c6b565b606091505b50909250905081611ccc577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611dfe578673ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611d98576040519150601f19603f3d011682016040523d82523d6000602084013e611d9d565b606091505b50909250905081611dfe577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050505095945050505050565b60006103dd611e8c60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b868686866116f1565b60006103dd85858585336116f1565b60006103dd611f2460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b86868686611a17565b6000808360601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f092505073ffffffffffffffffffffffffffffffffffffffff8216612016576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b60405173ffffffffffffffffffffffffffffffffffffffff8316907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808373ffffffffffffffffffffffffffffffffffffffff1634866040516120809190612d29565b60006040518083038185875af1925050503d80600081146120bd576040519150601f19603f3d011682016040523d82523d6000602084013e6120c2565b606091505b50915091506120d282828861247d565b50505092915050565b60008060006120e9846125b3565b9092509050600082600281111561210257612102612e02565b1480156121205750600081600281111561211e5761211e612e02565b145b1561215e57604080513360208201524691810191909152606081018590526080016040516020818303038152906040528051906020012092506123cc565b600082600281111561217257612172612e02565b1480156121905750600181600281111561218e5761218e612e02565b145b156121b0576121a9338560009182526020526040902090565b92506123cc565b60008260028111156121c4576121c4612e02565b03612233576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b600182600281111561224757612247612e02565b1480156122655750600081600281111561226357612263612e02565b145b1561227e576121a9468560009182526020526040902090565b600182600281111561229257612292612e02565b1480156122b0575060028160028111156122ae576122ae612e02565b145b1561231f576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b61239a60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b84036123a657836123c9565b604080516020810186905201604051602081830303815290604052805190602001205b92505b5050919050565b73ffffffffffffffffffffffffffffffffffffffff8116158061240b575073ffffffffffffffffffffffffffffffffffffffff81163b155b1561247a576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b50565b82158061249f575073ffffffffffffffffffffffffffffffffffffffff81163b155b156124fa577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed826040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050565b811580612520575073ffffffffffffffffffffffffffffffffffffffff8116155b80612540575073ffffffffffffffffffffffffffffffffffffffff81163b155b156125af576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b5050565b600080606083901c3314801561261057508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b1561262057506000905080915091565b606083901c3314801561265a57507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561266b5750600090506001915091565b33606084901c036126825750600090506002915091565b606083901c1580156126db57508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b156126ec5750600190506000915091565b606083901c15801561272557507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561273557506001905080915091565b606083901c61274a5750600190506002915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000036127a55750600290506000915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000036127e15750600290506001915091565b506002905080915091565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261282c57600080fd5b813567ffffffffffffffff80821115612847576128476127ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561288d5761288d6127ec565b816040528381528660208588010111156128a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000604082840312156128d857600080fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb6127ec565b604052823581526020928301359281019290925250919050565b60008060008060a0858703121561292b57600080fd5b84359350602085013567ffffffffffffffff8082111561294a57600080fd5b6129568883890161281b565b9450604087013591508082111561296c57600080fd5b506129798782880161281b565b92505061298986606087016128c6565b905092959194509250565b600080604083850312156129a757600080fd5b82359150602083013567ffffffffffffffff8111156129c557600080fd5b6129d18582860161281b565b9150509250929050565b6000602082840312156129ed57600080fd5b813567ffffffffffffffff811115612a0457600080fd5b6107b38482850161281b565b803573ffffffffffffffffffffffffffffffffffffffff81168114612a3457600080fd5b919050565b600080600060608486031215612a4e57600080fd5b83359250612a5e60208501612a10565b9150604084013567ffffffffffffffff811115612a7a57600080fd5b612a868682870161281b565b9150509250925092565b600060208284031215612aa257600080fd5b5035919050565b600080600060808486031215612abe57600080fd5b833567ffffffffffffffff80821115612ad657600080fd5b612ae28783880161281b565b94506020860135915080821115612af857600080fd5b50612b058682870161281b565b925050612b1585604086016128c6565b90509250925092565b60008060408385031215612b3157600080fd5b82359150612b4160208401612a10565b90509250929050565b60008060408385031215612b5d57600080fd5b612b6683612a10565b946020939093013593505050565b60008060408385031215612b8757600080fd5b612b9083612a10565b9150602083013567ffffffffffffffff8111156129c557600080fd5b60008060408385031215612bbf57600080fd5b50508035926020909101359150565b60008060008060a08587031215612be457600080fd5b843567ffffffffffffffff80821115612bfc57600080fd5b612c088883890161281b565b95506020870135915080821115612c1e57600080fd5b50612c2b8782880161281b565b935050612c3b86604087016128c6565b915061298960808601612a10565b600080600080600060c08688031215612c6157600080fd5b85359450602086013567ffffffffffffffff80821115612c8057600080fd5b612c8c89838a0161281b565b95506040880135915080821115612ca257600080fd5b50612caf8882890161281b565b935050612cbf87606088016128c6565b9150612ccd60a08701612a10565b90509295509295909350565b600080600060608486031215612cee57600080fd5b8335925060208401359150612b1560408501612a10565b60005b83811015612d20578181015183820152602001612d08565b50506000910152565b60008251612d3b818460208701612d05565b9190910192915050565b67ffffffffffffffff828116828216039080821115612d8d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260008251806040840152612dcf816060850160208701612d05565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea164736f6c6343000817000a", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # edit configs @@ -128,8 +127,8 @@ jq ' # get ethereum chain id from CHAIN_ID EVM_CHAIN_ID=$(echo $CHAIN_ID | sed -E 's/.*_([0-9]+)-.*/\1/') if [[ -z $EVM_CHAIN_ID ]]; then - echo "Invalid CHAIN_ID format. Expected format: _-" - exit 1 + echo "Invalid CHAIN_ID format. Expected format: _-" + exit 1 fi sed -i.bak "s/\"chain_id\": \"262144\"/\"chain_id\": \"$EVM_CHAIN_ID\"/g" $HOMEDIR/config/genesis.json @@ -177,7 +176,7 @@ jq --arg GOV_MIN_DEPOSIT "$GOV_MIN_DEPOSIT" ' "amount": $GOV_MIN_DEPOSIT } ] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # set min expedited gov deposit jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' @@ -187,7 +186,7 @@ jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' "amount": $GOV_MIN_EXPEDITED_DEPOSIT } ] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # enable apis sed -i.bak "s/enable = false/enable = true/g" $HOMEDIR/config/app.toml @@ -224,7 +223,7 @@ jq ' "uri_hash": "" } ] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json jq ' .app_state.erc20 = { @@ -238,7 +237,7 @@ jq ' "token_pairs": [ { "erc20_address": "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517", - "denom": "ugtac", + "denom": "stk/utac", "enabled": true, "contract_owner": "OWNER_MODULE" } @@ -249,7 +248,7 @@ jq ' jq ' .app_state.liquidstake = { "params": { - "liquid_bond_denom": "ugtac", + "liquid_bond_denom": "stk/utac", "whitelisted_validators": [ { "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", diff --git a/proto/buf.lock b/proto/buf.lock index 8b5ec2b..207c8a8 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -4,20 +4,25 @@ deps: - remote: buf.build owner: cosmos repository: cosmos-proto - commit: 1935555c206d4afb9e94615dfd0fad31 - digest: shake256:c74d91a3ac7ae07d579e90eee33abf9b29664047ac8816500cf22c081fec0d72d62c89ce0bebafc1f6fec7aa5315be72606717740ca95007248425102c365377 + commit: 04467658e59e44bbb22fe568206e1f70 + digest: shake256:73a640bd60e0c523b0f8237ff34eab67c45a38b64bbbde1d80224819d272dbf316ac183526bd245f994af6608b025f5130483d0133c5edd385531326b5990466 + - remote: buf.build + owner: cosmos + repository: cosmos-sdk + commit: 650cd9ad7f7a468e8e19975269958658 + digest: shake256:c2c1e67ed8efa7f5c6af7a2fc02a6c257dc78fe86911cbf4d3dd379710bf475565ffe2ae4f65221888373d515caa31be68b720897cccec6e0c6a1a91ff0b5227 - remote: buf.build owner: cosmos repository: gogo-proto - commit: 5e5b9fdd01804356895f8f79a6f1ddc1 - digest: shake256:0b85da49e2e5f9ebc4806eae058e2f56096ff3b1c59d1fb7c190413dd15f45dd456f0b69ced9059341c80795d2b6c943de15b120a9e0308b499e43e4b5fc2952 + commit: 88ef6483f90f478fb938c37dde52ece3 + digest: shake256:89c45df2aa11e0cff97b0d695436713db3d993d76792e9f8dc1ae90e6ab9a9bec55503d48ceedd6b86069ab07d3041b32001b2bfe0227fa725dd515ff381e5ba - remote: buf.build owner: googleapis repository: googleapis - commit: cc916c31859748a68fd229a3c8d7a2e8 - digest: shake256:469b049d0eb04203d5272062636c078decefc96fec69739159c25d85349c50c34c7706918a8b216c5c27f76939df48452148cff8c5c3ae77fa6ba5c25c1b8bf8 + commit: 61b203b9a9164be9a834f58c37be6f62 + digest: shake256:e619113001d6e284ee8a92b1561e5d4ea89a47b28bf0410815cb2fa23914df8be9f1a6a98dcf069f5bc2d829a2cfb1ac614863be45cd4f8a5ad8606c5f200224 - remote: buf.build - owner: persistence - repository: cosmos-sdk-lsm - commit: ac3de0dcbfbe4150b68e337f3063beed - digest: shake256:85111a50f8f3d210189e8b5c179c9883f2b94d99028814f9ebec0680b4f2bd365086c3fa1d8bb5990b35b316f1ac4854bfbcd3b954060f065025e94c21989ca5 + owner: protocolbuffers + repository: wellknowntypes + commit: 3ddd61d1f53d485abd3d3a2b47a62b8e + digest: shake256:9e6799d56700d0470c3723a2fd027e8b4a41a07085a0c90c58e05f6c0038fac9b7a0170acd7692707a849983b1b8189aa33e7b73f91d68157f7136823115546b diff --git a/proto/buf.yaml b/proto/buf.yaml index 30f7039..db919cf 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -1,7 +1,7 @@ version: v1 -name: buf.build/persistence/pstake-native +name: buf.build/Asphere-xyz/tacchain deps: - buf.build/cosmos/cosmos-proto - buf.build/cosmos/gogo-proto - buf.build/googleapis/googleapis - - buf.build/persistence/cosmos-sdk-lsm:v0.47.3-lsm + - buf.build/cosmos/cosmos-sdk diff --git a/proto/tac/epochs/v1beta1/genesis.proto b/proto/tac/epochs/v1beta1/genesis.proto new file mode 100644 index 0000000..8422025 --- /dev/null +++ b/proto/tac/epochs/v1beta1/genesis.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; +package tac.epochs.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/Asphere-xyz/tacchain/x/epochs/types"; + +message EpochInfo { + string identifier = 1; + google.protobuf.Timestamp start_time = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"start_time\"" + ]; + google.protobuf.Duration duration = 3 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.jsontag) = "duration,omitempty", + (gogoproto.moretags) = "yaml:\"duration\"" + ]; + int64 current_epoch = 4; + google.protobuf.Timestamp current_epoch_start_time = 5 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"current_epoch_start_time\"" + ]; + bool epoch_counting_started = 6; + reserved 7; + int64 current_epoch_start_height = 8; +} + +// GenesisState defines the epochs module's genesis state. +message GenesisState { + repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/tac/epochs/v1beta1/query.proto b/proto/tac/epochs/v1beta1/query.proto new file mode 100644 index 0000000..6913fbb --- /dev/null +++ b/proto/tac/epochs/v1beta1/query.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package tac.epochs.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "tac/epochs/v1beta1/genesis.proto"; + +option go_package = "github.com/Asphere-xyz/tacchain/x/epochs/types"; + +// Query defines the gRPC querier service. +service Query { + // EpochInfos provide running epochInfos + rpc EpochInfos(QueryEpochsInfoRequest) returns (QueryEpochsInfoResponse) { + option (google.api.http).get = "/tacchain/epochs/v1beta1/epochs"; + } + // CurrentEpoch provide current epoch of specified identifier + rpc CurrentEpoch(QueryCurrentEpochRequest) + returns (QueryCurrentEpochResponse) { + option (google.api.http).get = "/tacchain/epochs/v1beta1/current_epoch"; + } +} + +message QueryEpochsInfoRequest {} +message QueryEpochsInfoResponse { + repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ]; +} + +message QueryCurrentEpochRequest { string identifier = 1; } +message QueryCurrentEpochResponse { int64 current_epoch = 1; } diff --git a/proto/pstake/liquidstake/v1beta1/genesis.proto b/proto/tac/liquidstake/v1beta1/genesis.proto similarity index 72% rename from proto/pstake/liquidstake/v1beta1/genesis.proto rename to proto/tac/liquidstake/v1beta1/genesis.proto index e8222af..77d31cf 100644 --- a/proto/pstake/liquidstake/v1beta1/genesis.proto +++ b/proto/tac/liquidstake/v1beta1/genesis.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package pstake.liquidstake.v1beta1; +package tac.liquidstake.v1beta1; import "gogoproto/gogo.proto"; -import "pstake/liquidstake/v1beta1/liquidstake.proto"; +import "tac/liquidstake/v1beta1/liquidstake.proto"; -option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; +option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; option (gogoproto.equal_all) = true; // GenesisState defines the liquidstake module's genesis state. diff --git a/proto/pstake/liquidstake/v1beta1/liquidstake.proto b/proto/tac/liquidstake/v1beta1/liquidstake.proto similarity index 96% rename from proto/pstake/liquidstake/v1beta1/liquidstake.proto rename to proto/tac/liquidstake/v1beta1/liquidstake.proto index f81375e..c5a36b1 100644 --- a/proto/pstake/liquidstake/v1beta1/liquidstake.proto +++ b/proto/tac/liquidstake/v1beta1/liquidstake.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package pstake.liquidstake.v1beta1; +package tac.liquidstake.v1beta1; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; +option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; // Params defines the set of params for the liquidstake module. message Params { @@ -29,7 +29,7 @@ message Params { ]; // LsmDisabled allows to block any msgs that convert staked tokens into - // stkXPRT through LSM. + // gTAC through LSM. bool lsm_disabled = 4; // MinLiquidStakingAmount specifies the minimum number of coins to be staked @@ -160,14 +160,14 @@ message NetAmountState { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = true; - // mint_rate is stkXPRTTotalSupply / NetAmount + // mint_rate is gTACTotalSupply / NetAmount string mint_rate = 1 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - // btoken_total_supply returns the total supply of stk/uxprt (stkXPRT denom) - string stkxprt_total_supply = 2 [ + // btoken_total_supply returns the total supply of stk/utac (gTAC denom) + string gtac_total_supply = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; diff --git a/proto/pstake/liquidstake/v1beta1/query.proto b/proto/tac/liquidstake/v1beta1/query.proto similarity index 80% rename from proto/pstake/liquidstake/v1beta1/query.proto rename to proto/tac/liquidstake/v1beta1/query.proto index 176397b..d1121f6 100644 --- a/proto/pstake/liquidstake/v1beta1/query.proto +++ b/proto/tac/liquidstake/v1beta1/query.proto @@ -1,32 +1,31 @@ syntax = "proto3"; -package pstake.liquidstake.v1beta1; +package tac.liquidstake.v1beta1; import "google/api/annotations.proto"; -import "pstake/liquidstake/v1beta1/liquidstake.proto"; +import "tac/liquidstake/v1beta1/liquidstake.proto"; import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; - -option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; +option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; // Query defines the gRPC query service for the liquidstake module. service Query { option (cosmos.msg.v1.service) = true; // Params returns parameters of the liquidstake module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/pstake/liquidstake/v1beta1/params"; + option (google.api.http).get = "/tac/liquidstake/v1beta1/params"; } // LiquidValidators returns liquid validators with states of the liquidstake // module. rpc LiquidValidators(QueryLiquidValidatorsRequest) returns (QueryLiquidValidatorsResponse) { - option (google.api.http).get = "/pstake/liquidstake/v1beta1/validators"; + option (google.api.http).get = "/tac/liquidstake/v1beta1/validators"; } // States returns states of the liquidstake module. rpc States(QueryStatesRequest) returns (QueryStatesResponse) { - option (google.api.http).get = "/pstake/liquidstake/v1beta1/states"; + option (google.api.http).get = "/tac/liquidstake/v1beta1/states"; } } diff --git a/proto/pstake/liquidstake/v1beta1/tx.proto b/proto/tac/liquidstake/v1beta1/tx.proto similarity index 93% rename from proto/pstake/liquidstake/v1beta1/tx.proto rename to proto/tac/liquidstake/v1beta1/tx.proto index 28549f0..af854d1 100644 --- a/proto/pstake/liquidstake/v1beta1/tx.proto +++ b/proto/tac/liquidstake/v1beta1/tx.proto @@ -1,19 +1,19 @@ syntax = "proto3"; -package pstake.liquidstake.v1beta1; +package tac.liquidstake.v1beta1; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; import "cosmos/msg/v1/msg.proto"; import "google/protobuf/timestamp.proto"; -import "pstake/liquidstake/v1beta1/liquidstake.proto"; +import "tac/liquidstake/v1beta1/liquidstake.proto"; import "amino/amino.proto"; -option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"; +option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; // Msg defines the liquid staking Msg service. service Msg { - option (cosmos.msg.v1.service) = true; + option (cosmos.msg.v1.service) = true; // LiquidStake defines a method for performing a delegation of coins // from a delegator to whitelisted validators. rpc LiquidStake(MsgLiquidStake) returns (MsgLiquidStakeResponse); @@ -22,8 +22,8 @@ service Msg { // staking from a delegate. rpc LiquidUnstake(MsgLiquidUnstake) returns (MsgLiquidUnstakeResponse); - // StakeToLP defines a method for LSM-transfer of staked XPRT - // into stkXPRT with locking into an LP. + // StakeToLP defines a method for LSM-transfer of staked TAC + // into gTAC with locking into an LP. rpc StakeToLP(MsgStakeToLP) returns (MsgStakeToLPResponse); // UpdateParams defines a method to update the module params. @@ -57,7 +57,7 @@ message MsgLiquidStake { message MsgLiquidStakeResponse {} // MsgStakeToLP defines a SDK message for performing an LSM-transfer of staked -// XPRT into stkXPRT with locking into an LP. +// TAC into gTAC with locking into an LP. message MsgStakeToLP { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index e2f8d7a..1ca34d8 100644 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -10,7 +10,7 @@ buf generate --template buf.gen.gogo.yaml $file cd .. # move proto files to the right places -cp -r github.com/persistenceOne/pstake-native/v*/* ./ +cp -r github.com/Asphere-xyz/tacchain/* ./ rm -rf github.com #go mod tidy diff --git a/x/epochs/types/genesis.pb.go b/x/epochs/types/genesis.pb.go index 9617a03..2f50a26 100644 --- a/x/epochs/types/genesis.pb.go +++ b/x/epochs/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tacchain/epochs/v1beta1/genesis.proto +// source: tac/epochs/v1beta1/genesis.proto package types @@ -42,7 +42,7 @@ func (m *EpochInfo) Reset() { *m = EpochInfo{} } func (m *EpochInfo) String() string { return proto.CompactTextString(m) } func (*EpochInfo) ProtoMessage() {} func (*EpochInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_1d2331ae1f5f4a03, []int{0} + return fileDescriptor_e08a20027305544d, []int{0} } func (m *EpochInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -129,7 +129,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_1d2331ae1f5f4a03, []int{1} + return fileDescriptor_e08a20027305544d, []int{1} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -166,47 +166,44 @@ func (m *GenesisState) GetEpochs() []EpochInfo { } func init() { - proto.RegisterType((*EpochInfo)(nil), "tacchain.epochs.v1beta1.EpochInfo") - proto.RegisterType((*GenesisState)(nil), "tacchain.epochs.v1beta1.GenesisState") + proto.RegisterType((*EpochInfo)(nil), "tac.epochs.v1beta1.EpochInfo") + proto.RegisterType((*GenesisState)(nil), "tac.epochs.v1beta1.GenesisState") } -func init() { - proto.RegisterFile("tacchain/epochs/v1beta1/genesis.proto", fileDescriptor_1d2331ae1f5f4a03) -} +func init() { proto.RegisterFile("tac/epochs/v1beta1/genesis.proto", fileDescriptor_e08a20027305544d) } -var fileDescriptor_1d2331ae1f5f4a03 = []byte{ - // 482 bytes of a gzipped FileDescriptorProto +var fileDescriptor_e08a20027305544d = []byte{ + // 480 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xb1, 0x8e, 0xd3, 0x40, - 0x10, 0xcd, 0x92, 0x10, 0x9c, 0xbd, 0x43, 0xc0, 0xea, 0xe0, 0x4c, 0x24, 0x6c, 0xcb, 0x08, 0xc9, - 0x12, 0xb0, 0x56, 0x0e, 0x2a, 0x68, 0x20, 0x80, 0x38, 0xa8, 0x90, 0x43, 0x81, 0x68, 0x22, 0xc7, - 0xd9, 0xd8, 0x2b, 0x9d, 0x77, 0x2d, 0x7b, 0x8c, 0x2e, 0x54, 0x7c, 0x42, 0x4a, 0x3e, 0xe9, 0xca, - 0x2b, 0xa9, 0x02, 0x4a, 0x3a, 0xca, 0xfb, 0x02, 0xe4, 0x5d, 0x3b, 0x04, 0x8e, 0x13, 0x9d, 0x3d, - 0xef, 0xcd, 0x7b, 0x3b, 0x4f, 0x33, 0xf8, 0x1e, 0x84, 0x51, 0x94, 0x84, 0x5c, 0xf8, 0x2c, 0x93, - 0x51, 0x52, 0xf8, 0x9f, 0x06, 0x13, 0x06, 0xe1, 0xc0, 0x8f, 0x99, 0x60, 0x05, 0x2f, 0x68, 0x96, - 0x4b, 0x90, 0x64, 0xbf, 0xa1, 0x51, 0x4d, 0xa3, 0x35, 0xad, 0xbf, 0x17, 0xcb, 0x58, 0x2a, 0x8e, - 0x5f, 0x7d, 0x69, 0x7a, 0xdf, 0x8a, 0xa5, 0x8c, 0x8f, 0x98, 0xaf, 0xfe, 0x26, 0xe5, 0xcc, 0x9f, - 0x96, 0x79, 0x08, 0x5c, 0x8a, 0x1a, 0xb7, 0xff, 0xc6, 0x81, 0xa7, 0xac, 0x80, 0x30, 0xcd, 0x34, - 0xc1, 0x5d, 0x74, 0x70, 0xef, 0x55, 0xe5, 0xf4, 0x46, 0xcc, 0x24, 0xb1, 0x30, 0xe6, 0x53, 0x26, - 0x80, 0xcf, 0x38, 0xcb, 0x4d, 0xe4, 0x20, 0xaf, 0x17, 0x6c, 0x55, 0xc8, 0x07, 0x8c, 0x0b, 0x08, - 0x73, 0x18, 0x57, 0x32, 0xe6, 0x25, 0x07, 0x79, 0x3b, 0x07, 0x7d, 0xaa, 0x3d, 0x68, 0xe3, 0x41, - 0xdf, 0x37, 0x1e, 0xc3, 0x3b, 0x27, 0x4b, 0xbb, 0x75, 0xb6, 0xb4, 0x6f, 0xcc, 0xc3, 0xf4, 0xe8, - 0x89, 0xfb, 0xbb, 0xd7, 0x5d, 0x7c, 0xb7, 0x51, 0xd0, 0x53, 0x85, 0x8a, 0x4e, 0x12, 0x6c, 0x34, - 0x4f, 0x37, 0xdb, 0x4a, 0xf7, 0xf6, 0x39, 0xdd, 0x97, 0x35, 0x61, 0x38, 0xa8, 0x64, 0x7f, 0x2e, - 0x6d, 0xd2, 0xb4, 0x3c, 0x90, 0x29, 0x07, 0x96, 0x66, 0x30, 0x3f, 0x5b, 0xda, 0xd7, 0xb4, 0x59, - 0x83, 0xb9, 0x5f, 0x2b, 0xab, 0x8d, 0x3a, 0xb9, 0x8b, 0xaf, 0x46, 0x65, 0x9e, 0x33, 0x01, 0x63, - 0x15, 0xb1, 0xd9, 0x71, 0x90, 0xd7, 0x0e, 0x76, 0xeb, 0xa2, 0x0a, 0x83, 0x7c, 0x41, 0xd8, 0xfc, - 0x83, 0x35, 0xde, 0x9a, 0xfb, 0xf2, 0x7f, 0xe7, 0xbe, 0x5f, 0xcf, 0x6d, 0xeb, 0xa7, 0x5c, 0xa4, - 0xa4, 0x53, 0xb8, 0xb9, 0xed, 0x3c, 0xda, 0x24, 0xf2, 0x18, 0xdf, 0xd2, 0xfc, 0x48, 0x96, 0x02, - 0xb8, 0x88, 0x75, 0x23, 0x9b, 0x9a, 0x5d, 0x07, 0x79, 0x46, 0xb0, 0xa7, 0xd0, 0x17, 0x35, 0x38, - 0xd2, 0x18, 0x79, 0x8a, 0xfb, 0xff, 0x72, 0x4b, 0x18, 0x8f, 0x13, 0x30, 0x0d, 0x35, 0xea, 0xfe, - 0x39, 0xc3, 0x43, 0x05, 0xbf, 0xed, 0x18, 0x57, 0xae, 0x1b, 0xee, 0x3b, 0xbc, 0xfb, 0x5a, 0xef, - 0xe4, 0x08, 0x42, 0x60, 0xe4, 0x19, 0xee, 0xea, 0x5d, 0x34, 0x91, 0xd3, 0xf6, 0x76, 0x0e, 0x5c, - 0x7a, 0xc1, 0x8e, 0xd2, 0xcd, 0x22, 0x0d, 0x3b, 0x55, 0x00, 0x41, 0xdd, 0x37, 0x3c, 0x3c, 0x59, - 0x59, 0xe8, 0x74, 0x65, 0xa1, 0x1f, 0x2b, 0x0b, 0x2d, 0xd6, 0x56, 0xeb, 0x74, 0x6d, 0xb5, 0xbe, - 0xad, 0xad, 0xd6, 0x47, 0x1a, 0x73, 0x48, 0xca, 0x09, 0x8d, 0x64, 0xea, 0x3f, 0x2f, 0xb2, 0x84, - 0xe5, 0xec, 0xe1, 0xf1, 0xfc, 0xb3, 0xbf, 0x39, 0x96, 0xe3, 0xe6, 0x5c, 0x60, 0x9e, 0xb1, 0x62, - 0xd2, 0x55, 0x61, 0x3f, 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x91, 0xba, 0x89, 0x4e, 0x03, - 0x00, 0x00, + 0x14, 0xcc, 0x92, 0x10, 0x9c, 0xbd, 0x43, 0xc0, 0xea, 0x00, 0x13, 0xe9, 0x6c, 0xcb, 0x34, 0x96, + 0x80, 0xb5, 0x72, 0x50, 0x71, 0x15, 0x01, 0xc4, 0x01, 0x9d, 0x43, 0x81, 0x68, 0xa2, 0x8d, 0xb3, + 0xb1, 0x57, 0x3a, 0x7b, 0x2d, 0xfb, 0x19, 0x5d, 0xa8, 0xf8, 0x84, 0x94, 0x7c, 0xd2, 0x95, 0x57, + 0x52, 0x05, 0x94, 0x74, 0x94, 0xf7, 0x05, 0xc8, 0xbb, 0x76, 0x08, 0x04, 0x44, 0x97, 0xbc, 0x99, + 0x37, 0xb3, 0x33, 0x7a, 0xc6, 0x0e, 0xb0, 0xd0, 0xe7, 0x99, 0x0c, 0xe3, 0xc2, 0xff, 0x38, 0x98, + 0x70, 0x60, 0x03, 0x3f, 0xe2, 0x29, 0x2f, 0x44, 0x41, 0xb3, 0x5c, 0x82, 0x24, 0x04, 0x58, 0x48, + 0x35, 0x83, 0xd6, 0x8c, 0xfe, 0x41, 0x24, 0x23, 0xa9, 0x60, 0xbf, 0xfa, 0xa5, 0x99, 0x7d, 0x2b, + 0x92, 0x32, 0x3a, 0xe5, 0xbe, 0xfa, 0x37, 0x29, 0x67, 0xfe, 0xb4, 0xcc, 0x19, 0x08, 0x99, 0xd6, + 0xb8, 0xfd, 0x27, 0x0e, 0x22, 0xe1, 0x05, 0xb0, 0x24, 0xd3, 0x04, 0x77, 0xd1, 0xc1, 0xbd, 0x97, + 0x95, 0xd3, 0xeb, 0x74, 0x26, 0x89, 0x85, 0xb1, 0x98, 0xf2, 0x14, 0xc4, 0x4c, 0xf0, 0xdc, 0x44, + 0x0e, 0xf2, 0x7a, 0xc1, 0xd6, 0x84, 0xbc, 0xc7, 0xb8, 0x00, 0x96, 0xc3, 0xb8, 0x92, 0x31, 0xaf, + 0x38, 0xc8, 0xdb, 0x3b, 0xea, 0x53, 0xed, 0x41, 0x1b, 0x0f, 0xfa, 0xae, 0xf1, 0x18, 0x1e, 0x9e, + 0x2f, 0xed, 0xd6, 0xe5, 0xd2, 0xbe, 0x35, 0x67, 0xc9, 0xe9, 0x53, 0xf7, 0xd7, 0xae, 0xbb, 0xf8, + 0x66, 0xa3, 0xa0, 0xa7, 0x06, 0x15, 0x9d, 0xc4, 0xd8, 0x68, 0x9e, 0x6e, 0xb6, 0x95, 0xee, 0xbd, + 0x1d, 0xdd, 0x17, 0x35, 0x61, 0x38, 0xa8, 0x64, 0x7f, 0x2c, 0x6d, 0xd2, 0xac, 0x3c, 0x94, 0x89, + 0x00, 0x9e, 0x64, 0x30, 0xbf, 0x5c, 0xda, 0x37, 0xb4, 0x59, 0x83, 0xb9, 0x5f, 0x2a, 0xab, 0x8d, + 0x3a, 0xb9, 0x8f, 0xaf, 0x87, 0x65, 0x9e, 0xf3, 0x14, 0xc6, 0xaa, 0x62, 0xb3, 0xe3, 0x20, 0xaf, + 0x1d, 0xec, 0xd7, 0x43, 0x55, 0x06, 0xf9, 0x8c, 0xb0, 0xf9, 0x1b, 0x6b, 0xbc, 0x95, 0xfb, 0xea, + 0x7f, 0x73, 0x3f, 0xa8, 0x73, 0xdb, 0xfa, 0x29, 0xff, 0x52, 0xd2, 0x2d, 0xdc, 0xde, 0x76, 0x1e, + 0x6d, 0x1a, 0x79, 0x82, 0xef, 0x68, 0x7e, 0x28, 0xcb, 0x14, 0x44, 0x1a, 0xe9, 0x45, 0x3e, 0x35, + 0xbb, 0x0e, 0xf2, 0x8c, 0xe0, 0x40, 0xa1, 0xcf, 0x6b, 0x70, 0xa4, 0x31, 0x72, 0x8c, 0xfb, 0x7f, + 0x73, 0x8b, 0xb9, 0x88, 0x62, 0x30, 0x0d, 0x15, 0xf5, 0xee, 0x8e, 0xe1, 0x89, 0x82, 0xdf, 0x74, + 0x8c, 0x6b, 0x37, 0x0d, 0xf7, 0x2d, 0xde, 0x7f, 0xa5, 0xcf, 0x71, 0x04, 0x0c, 0x38, 0x39, 0xc6, + 0x5d, 0x7d, 0x8b, 0x26, 0x72, 0xda, 0xde, 0xde, 0xd1, 0x21, 0xdd, 0x3d, 0x4f, 0xba, 0xb9, 0xa1, + 0x61, 0xa7, 0xca, 0x1e, 0xd4, 0x2b, 0xc3, 0x93, 0xf3, 0x95, 0x85, 0x2e, 0x56, 0x16, 0xfa, 0xbe, + 0xb2, 0xd0, 0x62, 0x6d, 0xb5, 0x2e, 0xd6, 0x56, 0xeb, 0xeb, 0xda, 0x6a, 0x7d, 0xa0, 0x91, 0x80, + 0xb8, 0x9c, 0xd0, 0x50, 0x26, 0xfe, 0xb3, 0x22, 0x8b, 0x79, 0xce, 0x1f, 0x9d, 0xcd, 0x3f, 0xf9, + 0xc0, 0xc2, 0x30, 0x66, 0x22, 0xf5, 0xcf, 0x9a, 0x8f, 0x04, 0xe6, 0x19, 0x2f, 0x26, 0x5d, 0xd5, + 0xf3, 0xe3, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x33, 0x44, 0x86, 0xcf, 0x3f, 0x03, 0x00, 0x00, } func (m *EpochInfo) Marshal() (dAtA []byte, err error) { diff --git a/x/epochs/types/query.pb.go b/x/epochs/types/query.pb.go index 6187f94..2034ed1 100644 --- a/x/epochs/types/query.pb.go +++ b/x/epochs/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tacchain/epochs/v1beta1/query.proto +// source: tac/epochs/v1beta1/query.proto package types @@ -36,7 +36,7 @@ func (m *QueryEpochsInfoRequest) Reset() { *m = QueryEpochsInfoRequest{} func (m *QueryEpochsInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryEpochsInfoRequest) ProtoMessage() {} func (*QueryEpochsInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9f8cfb8c21c0a618, []int{0} + return fileDescriptor_9757813b51bf78cb, []int{0} } func (m *QueryEpochsInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -73,7 +73,7 @@ func (m *QueryEpochsInfoResponse) Reset() { *m = QueryEpochsInfoResponse func (m *QueryEpochsInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryEpochsInfoResponse) ProtoMessage() {} func (*QueryEpochsInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9f8cfb8c21c0a618, []int{1} + return fileDescriptor_9757813b51bf78cb, []int{1} } func (m *QueryEpochsInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -117,7 +117,7 @@ func (m *QueryCurrentEpochRequest) Reset() { *m = QueryCurrentEpochReque func (m *QueryCurrentEpochRequest) String() string { return proto.CompactTextString(m) } func (*QueryCurrentEpochRequest) ProtoMessage() {} func (*QueryCurrentEpochRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9f8cfb8c21c0a618, []int{2} + return fileDescriptor_9757813b51bf78cb, []int{2} } func (m *QueryCurrentEpochRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -161,7 +161,7 @@ func (m *QueryCurrentEpochResponse) Reset() { *m = QueryCurrentEpochResp func (m *QueryCurrentEpochResponse) String() string { return proto.CompactTextString(m) } func (*QueryCurrentEpochResponse) ProtoMessage() {} func (*QueryCurrentEpochResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9f8cfb8c21c0a618, []int{3} + return fileDescriptor_9757813b51bf78cb, []int{3} } func (m *QueryCurrentEpochResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,43 +198,41 @@ func (m *QueryCurrentEpochResponse) GetCurrentEpoch() int64 { } func init() { - proto.RegisterType((*QueryEpochsInfoRequest)(nil), "tacchain.epochs.v1beta1.QueryEpochsInfoRequest") - proto.RegisterType((*QueryEpochsInfoResponse)(nil), "tacchain.epochs.v1beta1.QueryEpochsInfoResponse") - proto.RegisterType((*QueryCurrentEpochRequest)(nil), "tacchain.epochs.v1beta1.QueryCurrentEpochRequest") - proto.RegisterType((*QueryCurrentEpochResponse)(nil), "tacchain.epochs.v1beta1.QueryCurrentEpochResponse") -} - -func init() { - proto.RegisterFile("tacchain/epochs/v1beta1/query.proto", fileDescriptor_9f8cfb8c21c0a618) -} - -var fileDescriptor_9f8cfb8c21c0a618 = []byte{ - // 393 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbf, 0x4e, 0xe3, 0x30, - 0x1c, 0xc7, 0xe3, 0xf6, 0xae, 0xd2, 0xf9, 0x7a, 0x8b, 0x75, 0xba, 0xe6, 0xa2, 0x53, 0xda, 0x4b, - 0x75, 0x47, 0x17, 0x6c, 0x5a, 0x36, 0xa6, 0x52, 0x84, 0x04, 0x23, 0x19, 0x61, 0x40, 0x69, 0x70, - 0x13, 0x4b, 0x60, 0xa7, 0xb1, 0x83, 0x5a, 0x46, 0x9e, 0x00, 0x89, 0x85, 0x17, 0xe0, 0x5d, 0x2a, - 0xa6, 0x4a, 0x2c, 0x4c, 0x08, 0xb5, 0x3c, 0x08, 0xaa, 0x93, 0x42, 0x11, 0x0d, 0x82, 0x2d, 0xb1, - 0x3f, 0xdf, 0x3f, 0xbf, 0x5f, 0x02, 0xeb, 0xca, 0xf3, 0xfd, 0xd0, 0x63, 0x9c, 0xd0, 0x48, 0xf8, - 0xa1, 0x24, 0xa7, 0xcd, 0x2e, 0x55, 0x5e, 0x93, 0xf4, 0x13, 0x1a, 0x0f, 0x71, 0x14, 0x0b, 0x25, - 0x50, 0x65, 0x0e, 0xe1, 0x14, 0xc2, 0x19, 0x64, 0xfd, 0x0c, 0x44, 0x20, 0x34, 0x43, 0x66, 0x4f, - 0x29, 0x6e, 0xfd, 0x09, 0x84, 0x08, 0x8e, 0x29, 0xf1, 0x22, 0x46, 0x3c, 0xce, 0x85, 0xf2, 0x14, - 0x13, 0x5c, 0x66, 0xb7, 0xff, 0xf2, 0x12, 0x03, 0xca, 0xa9, 0x64, 0x19, 0xe6, 0x98, 0xf0, 0xd7, - 0xde, 0xac, 0xc2, 0xb6, 0x86, 0x76, 0x79, 0x4f, 0xb8, 0xb4, 0x9f, 0x50, 0xa9, 0x9c, 0x03, 0x58, - 0x79, 0x73, 0x23, 0x23, 0xc1, 0x25, 0x45, 0x6d, 0x58, 0x4a, 0x4d, 0x4d, 0x50, 0x2b, 0x36, 0xbe, - 0xb7, 0x1c, 0x9c, 0xd3, 0x1c, 0x6b, 0xf1, 0x4c, 0xdb, 0xf9, 0x32, 0xba, 0xaf, 0x1a, 0x6e, 0xa6, - 0x73, 0x36, 0xa0, 0xa9, 0xcd, 0xb7, 0x92, 0x38, 0xa6, 0x5c, 0x69, 0x2c, 0x0b, 0x46, 0x36, 0x84, - 0xec, 0x88, 0x72, 0xc5, 0x7a, 0x8c, 0xc6, 0x26, 0xa8, 0x81, 0xc6, 0x37, 0x77, 0xe1, 0xc4, 0x69, - 0xc3, 0xdf, 0x4b, 0xb4, 0x59, 0xb5, 0x3a, 0xfc, 0xe1, 0xa7, 0xe7, 0x87, 0x3a, 0x4a, 0xeb, 0x8b, - 0x6e, 0xd9, 0x5f, 0x80, 0x5b, 0x37, 0x05, 0xf8, 0x55, 0x5b, 0xa0, 0x2b, 0x00, 0xe1, 0x73, 0x47, - 0x89, 0x48, 0xee, 0x20, 0xcb, 0x97, 0x64, 0xad, 0x7d, 0x5c, 0x90, 0x16, 0x74, 0x56, 0xce, 0x6f, - 0x1f, 0x2f, 0x0b, 0x7f, 0x51, 0x95, 0xe4, 0x7d, 0xa0, 0xf4, 0x15, 0x5d, 0x03, 0x58, 0x5e, 0x1c, - 0x11, 0x35, 0xdf, 0xcf, 0x5a, 0xb2, 0x4a, 0xab, 0xf5, 0x19, 0x49, 0x56, 0x10, 0xeb, 0x82, 0x0d, - 0xf4, 0x3f, 0xb7, 0xe0, 0xab, 0x05, 0x77, 0x76, 0x46, 0x13, 0x1b, 0x8c, 0x27, 0x36, 0x78, 0x98, - 0xd8, 0xe0, 0x62, 0x6a, 0x1b, 0xe3, 0xa9, 0x6d, 0xdc, 0x4d, 0x6d, 0x63, 0x1f, 0x07, 0x4c, 0x85, - 0x49, 0x17, 0xfb, 0xe2, 0x84, 0x6c, 0xca, 0x28, 0xa4, 0x31, 0x5d, 0x1d, 0x0c, 0xcf, 0x5e, 0x7c, - 0x07, 0x73, 0x67, 0x35, 0x8c, 0xa8, 0xec, 0x96, 0xf4, 0x2f, 0xb9, 0xfe, 0x14, 0x00, 0x00, 0xff, - 0xff, 0xfa, 0xf5, 0xae, 0xf3, 0x2d, 0x03, 0x00, 0x00, + proto.RegisterType((*QueryEpochsInfoRequest)(nil), "tac.epochs.v1beta1.QueryEpochsInfoRequest") + proto.RegisterType((*QueryEpochsInfoResponse)(nil), "tac.epochs.v1beta1.QueryEpochsInfoResponse") + proto.RegisterType((*QueryCurrentEpochRequest)(nil), "tac.epochs.v1beta1.QueryCurrentEpochRequest") + proto.RegisterType((*QueryCurrentEpochResponse)(nil), "tac.epochs.v1beta1.QueryCurrentEpochResponse") +} + +func init() { proto.RegisterFile("tac/epochs/v1beta1/query.proto", fileDescriptor_9757813b51bf78cb) } + +var fileDescriptor_9757813b51bf78cb = []byte{ + // 396 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x6e, 0xd3, 0x30, + 0x18, 0x8f, 0x5b, 0xa8, 0x84, 0x29, 0x17, 0x0b, 0x41, 0x88, 0xc0, 0x2d, 0x41, 0x82, 0x0a, 0xa8, + 0xad, 0x96, 0x1b, 0x5c, 0xa0, 0x08, 0x09, 0x8e, 0xe4, 0xc0, 0x81, 0x0b, 0x72, 0x8d, 0x9b, 0x58, + 0x02, 0x3b, 0x8d, 0x1d, 0xd4, 0x72, 0xe4, 0x01, 0xd0, 0xa4, 0x1d, 0xf7, 0x1e, 0x7b, 0x86, 0x1e, + 0x2b, 0xed, 0xb2, 0xd3, 0x34, 0xb5, 0x7b, 0x90, 0xa9, 0x4e, 0xb6, 0x75, 0x6b, 0x2a, 0xf5, 0x96, + 0x7c, 0xbf, 0xbf, 0xdf, 0x97, 0x40, 0x6c, 0x19, 0xa7, 0x22, 0xd5, 0x3c, 0x31, 0xf4, 0x4f, 0x6f, + 0x28, 0x2c, 0xeb, 0xd1, 0x71, 0x2e, 0xb2, 0x29, 0x49, 0x33, 0x6d, 0x35, 0x42, 0x96, 0x71, 0x52, + 0xe0, 0xa4, 0xc4, 0x83, 0xfb, 0xb1, 0x8e, 0xb5, 0x83, 0xe9, 0xea, 0xa9, 0x60, 0x06, 0x8f, 0x63, + 0xad, 0xe3, 0x5f, 0x82, 0xb2, 0x54, 0x52, 0xa6, 0x94, 0xb6, 0xcc, 0x4a, 0xad, 0x4c, 0x89, 0xb6, + 0x2b, 0x72, 0x62, 0xa1, 0x84, 0x91, 0x25, 0x23, 0xf4, 0xe1, 0x83, 0xaf, 0xab, 0xe0, 0x4f, 0x8e, + 0xf4, 0x45, 0x8d, 0x74, 0x24, 0xc6, 0xb9, 0x30, 0x36, 0xfc, 0x06, 0x1f, 0x6e, 0x20, 0x26, 0xd5, + 0xca, 0x08, 0xf4, 0x0e, 0x36, 0x0a, 0x53, 0x1f, 0xb4, 0xeb, 0x9d, 0xbb, 0xfd, 0x27, 0x64, 0xb3, + 0x2f, 0x71, 0xba, 0x95, 0x6c, 0x70, 0x6b, 0x76, 0xd2, 0xf2, 0xa2, 0x52, 0x12, 0xbe, 0x85, 0xbe, + 0xf3, 0xfd, 0x98, 0x67, 0x99, 0x50, 0xd6, 0xd1, 0xca, 0x4c, 0x84, 0x21, 0x94, 0x3f, 0x85, 0xb2, + 0x72, 0x24, 0x45, 0xe6, 0x83, 0x36, 0xe8, 0xdc, 0x89, 0xd6, 0x26, 0xe1, 0x7b, 0xf8, 0xa8, 0x42, + 0x5b, 0xb6, 0x7a, 0x06, 0xef, 0xf1, 0x62, 0xfe, 0xc3, 0x45, 0x39, 0x7d, 0x3d, 0x6a, 0xf2, 0x35, + 0x72, 0xff, 0xb0, 0x06, 0x6f, 0x3b, 0x0b, 0xf4, 0x1f, 0x40, 0x78, 0xd9, 0xd1, 0xa0, 0x97, 0x55, + 0x3b, 0x54, 0x9f, 0x26, 0x78, 0xb5, 0x13, 0xb7, 0xa8, 0x15, 0xbe, 0xf8, 0x77, 0x74, 0xb6, 0x5f, + 0x7b, 0x8a, 0x5a, 0xd4, 0x32, 0xce, 0x13, 0x26, 0xd5, 0xcd, 0x2f, 0x52, 0xbc, 0xa2, 0x03, 0x00, + 0x9b, 0xeb, 0x8b, 0xa1, 0xd7, 0x5b, 0x63, 0x2a, 0x6e, 0x17, 0x74, 0x77, 0x64, 0x97, 0xb5, 0x88, + 0xab, 0xd5, 0x41, 0xcf, 0xb7, 0xd6, 0xba, 0x76, 0xcc, 0xc1, 0xe7, 0xd9, 0x02, 0x83, 0xf9, 0x02, + 0x83, 0xd3, 0x05, 0x06, 0x7b, 0x4b, 0xec, 0xcd, 0x97, 0xd8, 0x3b, 0x5e, 0x62, 0xef, 0x3b, 0x89, + 0xa5, 0x4d, 0xf2, 0x21, 0xe1, 0xfa, 0x37, 0xfd, 0x60, 0xd2, 0x44, 0x64, 0xa2, 0x3b, 0x99, 0xfe, + 0xbd, 0xf2, 0x9d, 0x5c, 0x38, 0xdb, 0x69, 0x2a, 0xcc, 0xb0, 0xe1, 0xfe, 0xbc, 0x37, 0xe7, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x2a, 0xba, 0x43, 0x72, 0x05, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -265,7 +263,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) { out := new(QueryEpochsInfoResponse) - err := c.cc.Invoke(ctx, "/tacchain.epochs.v1beta1.Query/EpochInfos", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.epochs.v1beta1.Query/EpochInfos", in, out, opts...) if err != nil { return nil, err } @@ -274,7 +272,7 @@ func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest func (c *queryClient) CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) { out := new(QueryCurrentEpochResponse) - err := c.cc.Invoke(ctx, "/tacchain.epochs.v1beta1.Query/CurrentEpoch", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.epochs.v1beta1.Query/CurrentEpoch", in, out, opts...) if err != nil { return nil, err } @@ -314,7 +312,7 @@ func _Query_EpochInfos_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/tacchain.epochs.v1beta1.Query/EpochInfos", + FullMethod: "/tac.epochs.v1beta1.Query/EpochInfos", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).EpochInfos(ctx, req.(*QueryEpochsInfoRequest)) @@ -332,7 +330,7 @@ func _Query_CurrentEpoch_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/tacchain.epochs.v1beta1.Query/CurrentEpoch", + FullMethod: "/tac.epochs.v1beta1.Query/CurrentEpoch", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).CurrentEpoch(ctx, req.(*QueryCurrentEpochRequest)) @@ -341,7 +339,7 @@ func _Query_CurrentEpoch_Handler(srv interface{}, ctx context.Context, dec func( } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "tacchain.epochs.v1beta1.Query", + ServiceName: "tac.epochs.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -354,7 +352,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "tacchain/epochs/v1beta1/query.proto", + Metadata: "tac/epochs/v1beta1/query.proto", } func (m *QueryEpochsInfoRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/epochs/types/query.pb.gw.go b/x/epochs/types/query.pb.gw.go index 4051633..6a1dc0a 100644 --- a/x/epochs/types/query.pb.gw.go +++ b/x/epochs/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: tacchain/epochs/v1beta1/query.proto +// source: tac/epochs/v1beta1/query.proto /* Package types is a reverse proxy. diff --git a/x/liquidstake/client/cli/query.go b/x/liquidstake/client/cli/query.go index 8f5dd06..d919a51 100644 --- a/x/liquidstake/client/cli/query.go +++ b/x/liquidstake/client/cli/query.go @@ -92,7 +92,7 @@ $ %s query %s liquid-validators return err } - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.LiquidValidators( cmd.Context(), diff --git a/x/liquidstake/client/cli/tx.go b/x/liquidstake/client/cli/tx.go index 8c2b240..79d8d7e 100644 --- a/x/liquidstake/client/cli/tx.go +++ b/x/liquidstake/client/cli/tx.go @@ -24,7 +24,7 @@ func GetTxCmd() *cobra.Command { liquidstakeTxCmd := &cobra.Command{ Use: types.ModuleName, Aliases: []string{"ls"}, - Short: "XPRT liquid stake transaction subcommands", + Short: "TAC liquid stake transaction subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, @@ -42,17 +42,17 @@ func GetTxCmd() *cobra.Command { return liquidstakeTxCmd } -// NewLiquidStakeCmd implements the liquid stake XPRT command handler. +// NewLiquidStakeCmd implements the liquid stake TAC command handler. func NewLiquidStakeCmd() *cobra.Command { cmd := &cobra.Command{ Use: "liquid-stake [amount]", Args: cobra.ExactArgs(1), - Short: "Liquid-stake XPRT", + Short: "Liquid-stake TAC", Long: strings.TrimSpace( - fmt.Sprintf(`Liquid-stake XPRT. + fmt.Sprintf(`Liquid-stake TAC. Example: -$ %s tx %s liquid-stake 1000uxprt --from mykey +$ %s tx %s liquid-stake 1000utac --from mykey `, version.AppName, types.ModuleName, ), @@ -81,21 +81,21 @@ $ %s tx %s liquid-stake 1000uxprt --from mykey return cmd } -// NewStakeToLPCmd implements the liquid stake XPRT command handler. +// NewStakeToLPCmd implements the liquid stake TAC command handler. func NewStakeToLPCmd() *cobra.Command { bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() cmd := &cobra.Command{ Use: "stake-to-lp [validator-addr] [staked_amount] [liquid_amount]", Args: cobra.RangeArgs(2, 3), - Short: "Convert delegation into stkXPRT and lock into LP.", + Short: "Convert delegation into gTAC and lock into LP.", Long: strings.TrimSpace( - fmt.Sprintf(`Convert delegation into stkXPRT and lock into LP. -Allows to specify both staked and non-staked XPRT amounts to convert into stkXPRT and lock into LP. + fmt.Sprintf(`Convert delegation into gTAC and lock into LP. +Allows to specify both staked and non-staked TAC amounts to convert into gTAC and lock into LP. Examples: -$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000uxprt --from mykey -$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000uxprt 5000uxprt --from mykey +$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000utac --from mykey +$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000utac 5000utac --from mykey `, version.AppName, types.ModuleName, bech32PrefixValAddr, version.AppName, types.ModuleName, bech32PrefixValAddr, @@ -138,17 +138,17 @@ $ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000uxprt 5000u return cmd } -// NewLiquidUnstakeCmd implements the liquid unstake XPRT command handler. +// NewLiquidUnstakeCmd implements the liquid unstake TAC command handler. func NewLiquidUnstakeCmd() *cobra.Command { cmd := &cobra.Command{ Use: "liquid-unstake [amount]", Args: cobra.ExactArgs(1), - Short: "Liquid-unstake stkXPRT", + Short: "Liquid-unstake gTAC", Long: strings.TrimSpace( - fmt.Sprintf(`Liquid-unstake stkXPRT. + fmt.Sprintf(`Liquid-unstake gTAC. Example: -$ %s tx %s liquid-unstake 500stk/uxprt --from mykey +$ %s tx %s liquid-unstake 500stk/utac --from mykey `, version.AppName, types.ModuleName, ), @@ -191,17 +191,17 @@ $ %s tx %s update-params ~/params.json --from mykey Example params.json { - "liquid_bond_denom": "stk/uxprt", + "liquid_bond_denom": "stk/utac", "whitelisted_validators": [ { - "validator_address": "persistencevaloper1hcqg5wj9t42zawqkqucs7la85ffyv08lmnhye9", + "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", "target_weight": "10" } ], "lsm_disabled": false, "unstake_fee_rate": "0.000000000000000000", "min_liquid_staking_amount": "10000", - "cw_locked_pool_address": "persistence14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjvz4fk" + "cw_locked_pool_address": "tac14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjvz4fk" } `, version.AppName, types.ModuleName, @@ -252,7 +252,7 @@ $ %s tx %s update-whitelisted-validators ~/validators_list.json --from mykey Example validators_list.json [ { - "validator_address": "persistencevaloper1hcqg5wj9t42zawqkqucs7la85ffyv08lmnhye9", + "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", "target_weight": "10" } ] diff --git a/x/liquidstake/keeper/keeper_test.go b/x/liquidstake/keeper/keeper_test.go index 68ad942..02dd42f 100644 --- a/x/liquidstake/keeper/keeper_test.go +++ b/x/liquidstake/keeper/keeper_test.go @@ -118,11 +118,11 @@ func (s *KeeperTestSuite) liquidStaking(liquidStaker sdk.AccAddress, stakingAmt ctx, writeCache := s.ctx.CacheContext() params := s.keeper.GetParams(ctx) - stkxprtBalanceBefore := s.app.BankKeeper.GetBalance( + gtacBalanceBefore := s.app.BankKeeper.GetBalance( ctx, liquidStaker, params.LiquidBondDenom, ).Amount - stkXPRTMintAmt, err := s.keeper.LiquidStake( + gTACMintAmt, err := s.keeper.LiquidStake( ctx, types.LiquidStakeProxyAcc, liquidStaker, @@ -132,13 +132,13 @@ func (s *KeeperTestSuite) liquidStaking(liquidStaker sdk.AccAddress, stakingAmt return err } - stkxprtBalanceAfter := s.app.BankKeeper.GetBalance( + gtacBalanceAfter := s.app.BankKeeper.GetBalance( ctx, liquidStaker, params.LiquidBondDenom, ).Amount s.Require().NoError(err) s.Require().EqualValues( - stkXPRTMintAmt, stkxprtBalanceAfter.Sub(stkxprtBalanceBefore), + gTACMintAmt, gtacBalanceAfter.Sub(gtacBalanceBefore), ) writeCache() @@ -147,7 +147,7 @@ func (s *KeeperTestSuite) liquidStaking(liquidStaker sdk.AccAddress, stakingAmt func (s *KeeperTestSuite) liquidUnstaking( liquidStaker sdk.AccAddress, - ubdStkXPRTAmt math.Int, + ubdGTACAmt math.Int, ubdComplete bool, ) error { ctx := s.ctx @@ -161,7 +161,7 @@ func (s *KeeperTestSuite) liquidUnstaking( ubdTime, unbondingAmt, _, unbondedAmt, err := s.liquidUnstakingWithResult( liquidStaker, - sdk.NewCoin(params.LiquidBondDenom, ubdStkXPRTAmt), + sdk.NewCoin(params.LiquidBondDenom, ubdGTACAmt), ) if err != nil { return err @@ -199,7 +199,7 @@ func (s *KeeperTestSuite) liquidUnstaking( } func (s *KeeperTestSuite) liquidUnstakingWithResult( - liquidStaker sdk.AccAddress, unstakingStkXPRT sdk.Coin, + liquidStaker sdk.AccAddress, unstakingGTAC sdk.Coin, ) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) { ctx, writeCache := s.ctx.CacheContext() params := s.keeper.GetParams(ctx) @@ -208,12 +208,12 @@ func (s *KeeperTestSuite) liquidUnstakingWithResult( balanceBefore := s.app.BankKeeper.GetBalance( ctx, liquidStaker, sdk.DefaultBondDenom, ).Amount - stkxprtBalanceBefore := s.app.BankKeeper.GetBalance( + gtacBalanceBefore := s.app.BankKeeper.GetBalance( ctx, liquidStaker, params.LiquidBondDenom, ).Amount ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.keeper.LiquidUnstake( - ctx, types.LiquidStakeProxyAcc, liquidStaker, unstakingStkXPRT, + ctx, types.LiquidStakeProxyAcc, liquidStaker, unstakingGTAC, ) if err != nil { return ubdTime, unbondingAmt, ubds, unbondedAmt, err @@ -222,11 +222,11 @@ func (s *KeeperTestSuite) liquidUnstakingWithResult( balanceAfter := s.app.BankKeeper.GetBalance( ctx, liquidStaker, sdk.DefaultBondDenom, ).Amount - stkxprtBalanceAfter := s.app.BankKeeper.GetBalance( + gtacBalanceAfter := s.app.BankKeeper.GetBalance( ctx, liquidStaker, params.LiquidBondDenom, ).Amount s.Require().EqualValues( - unstakingStkXPRT.Amount, stkxprtBalanceBefore.Sub(stkxprtBalanceAfter), + unstakingGTAC.Amount, gtacBalanceBefore.Sub(gtacBalanceAfter), ) if unbondedAmt.IsPositive() { @@ -250,7 +250,7 @@ func (s *KeeperTestSuite) RequireNetAmountStateZero() { nas, err := s.keeper.GetNetAmountState(s.ctx) s.Require().NoError(err) s.Require().EqualValues(nas.MintRate, sdk.ZeroDec()) - s.Require().EqualValues(nas.StkxprtTotalSupply, sdk.ZeroInt()) + s.Require().EqualValues(nas.GtacTotalSupply, sdk.ZeroInt()) s.Require().EqualValues(nas.NetAmount, sdk.ZeroDec()) s.Require().EqualValues(nas.TotalDelShares, sdk.ZeroDec()) s.Require().EqualValues(nas.TotalLiquidTokens, sdk.ZeroInt()) diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index 67bd8dc..95ccefb 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -23,7 +23,7 @@ func (k Keeper) LiquidBondDenom(ctx sdk.Context) string { } // GetNetAmountState calculates the sum of bondedDenom balance, total delegation tokens(slash applied LiquidTokens), total remaining reward of types.LiquidStakeProxyAcc -// During liquid unstaking, stkxprt immediately burns and the unbonding queue belongs to the requester, so the liquid staker's unbonding values are excluded on netAmount +// During liquid unstaking, gtac immediately burns and the unbonding queue belongs to the requester, so the liquid staker's unbonding values are excluded on netAmount // It is used only for calculation and query and is not stored in kv. func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, err error) { totalRemainingRewards, totalDelShares, totalLiquidTokens, err := k.CheckDelegationStates(ctx, types.LiquidStakeProxyAcc) @@ -50,7 +50,7 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, e } nas = &types.NetAmountState{ - StkxprtTotalSupply: k.bankKeeper.GetSupply(ctx, k.LiquidBondDenom(ctx)).Amount, + GtacTotalSupply: k.bankKeeper.GetSupply(ctx, k.LiquidBondDenom(ctx)).Amount, TotalDelShares: totalDelShares, TotalLiquidTokens: totalLiquidTokens, TotalRemainingRewards: totalRemainingRewards, @@ -63,10 +63,10 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, e return nas, nil } -// LiquidStake mints stkXPRT worth of staking coin value according to NetAmount and performs LiquidDelegate. +// LiquidStake mints gTAC worth of staking coin value according to NetAmount and performs LiquidDelegate. func (k Keeper) LiquidStake( ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, stakingCoin sdk.Coin, -) (stkXPRTMintAmount math.Int, err error) { +) (gTACMintAmount math.Int, err error) { params := k.GetParams(ctx) if params.ModulePaused { @@ -127,11 +127,11 @@ func (k Keeper) LiquidStake( return math.ZeroInt(), err } - // mint stkxprt, MintAmount = TotalSupply * StakeAmount/NetAmount + // mint gtac, MintAmount = TotalSupply * StakeAmount/NetAmount liquidBondDenom := k.LiquidBondDenom(ctx) - stkXPRTMintAmount = stakingCoin.Amount + gTACMintAmount = stakingCoin.Amount - if nas.StkxprtTotalSupply.IsPositive() { + if nas.GtacTotalSupply.IsPositive() { if nas.NetAmount.IsZero() { // this case must not be reachable, consider stopping module for investigation // c_value -> inf @@ -144,18 +144,18 @@ func (k Keeper) LiquidStake( return math.ZeroInt(), types.ErrInsufficientProxyAccBalance } - stkXPRTMintAmount = types.NativeTokenToStkXPRT(stakingCoin.Amount, nas.StkxprtTotalSupply, nas.NetAmount) + gTACMintAmount = types.NativeTokenToGTAC(stakingCoin.Amount, nas.GtacTotalSupply, nas.NetAmount) } - if !stkXPRTMintAmount.IsPositive() { + if !gTACMintAmount.IsPositive() { return math.ZeroInt(), types.ErrTooSmallLiquidStakeAmount } // mint on module acc and send - mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, stkXPRTMintAmount)) + mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, gTACMintAmount)) err = k.bankKeeper.MintCoins(ctx, types.ModuleName, mintCoin) if err != nil { - return stkXPRTMintAmount, err + return gTACMintAmount, err } err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, liquidStaker, mintCoin) if err != nil { @@ -165,11 +165,11 @@ func (k Keeper) LiquidStake( err, ) - return stkXPRTMintAmount, err + return gTACMintAmount, err } err = k.LiquidDelegate(ctx, proxyAcc, activeVals, stakingCoin.Amount, whitelistedValsMap) - return stkXPRTMintAmount, err + return gTACMintAmount, err } // LockOnLP sends tokens to a CW contract (Superfluid LP) with time locking. @@ -526,14 +526,14 @@ func (k Keeper) RedelegateWithCap( } // LSMDelegate captures a staked amount from existing delegation using LSM, re-stakes from proxyAcc and -// mints stkXPRT worth of stk coin value according to NetAmount and performs LiquidDelegate. +// mints gTAC worth of stk coin value according to NetAmount and performs LiquidDelegate. func (k Keeper) LSMDelegate( ctx sdk.Context, delegator sdk.AccAddress, validator sdk.ValAddress, proxyAcc sdk.AccAddress, preLsmStake sdk.Coin, -) (stkXPRTMintAmount math.Int, err error) { +) (gTACMintAmount math.Int, err error) { params := k.GetParams(ctx) if params.ModulePaused { @@ -645,7 +645,7 @@ func (k Keeper) LSMDelegate( // [2] send LSM shares to proxyAcc err = k.bankKeeper.SendCoins(ctx, delegator, proxyAcc, sdk.NewCoins(lsmTokenizeResp.Amount)) if err != nil { - return stkXPRTMintAmount, err + return gTACMintAmount, err } lsmRedeemMsg := &stakingtypes.MsgRedeemTokensForShares{ @@ -692,42 +692,42 @@ func (k Keeper) LSMDelegate( ) } - // mint stkxprt, MintAmount = TotalSupply * StakeAmount/NetAmount + // mint gtac, MintAmount = TotalSupply * StakeAmount/NetAmount liquidBondDenom := k.LiquidBondDenom(ctx) - stkXPRTMintAmount = lsmRedeemResp.Amount.Amount + gTACMintAmount = lsmRedeemResp.Amount.Amount - if nas.StkxprtTotalSupply.IsPositive() { - stkXPRTMintAmount = types.NativeTokenToStkXPRT( - stkXPRTMintAmount, - nas.StkxprtTotalSupply, + if nas.GtacTotalSupply.IsPositive() { + gTACMintAmount = types.NativeTokenToGTAC( + gTACMintAmount, + nas.GtacTotalSupply, nas.NetAmount, ) } - if !stkXPRTMintAmount.IsPositive() { + if !gTACMintAmount.IsPositive() { return math.ZeroInt(), types.ErrTooSmallLiquidStakeAmount } - // mint stkXPRT on module acc - mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, stkXPRTMintAmount)) + // mint gTAC on module acc + mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, gTACMintAmount)) err = k.bankKeeper.MintCoins(ctx, types.ModuleName, mintCoin) if err != nil { - return stkXPRTMintAmount, err + return gTACMintAmount, err } - // send stkXPRT to delegator acc + // send gTAC to delegator acc err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, delegator, mintCoin) if err != nil { - return stkXPRTMintAmount, err + return gTACMintAmount, err } - // but immediately lock new stkXPRT into LP on behalf of the delegator - _, err = k.LockOnLP(ctx, delegator, sdk.NewCoin(liquidBondDenom, stkXPRTMintAmount)) + // but immediately lock new gTAC into LP on behalf of the delegator + _, err = k.LockOnLP(ctx, delegator, sdk.NewCoin(liquidBondDenom, gTACMintAmount)) if err != nil { - return stkXPRTMintAmount, err + return gTACMintAmount, err } - return stkXPRTMintAmount, err + return gTACMintAmount, err } // LiquidDelegate delegates staking amount to active validators by proxy account. @@ -761,9 +761,9 @@ func (k Keeper) LiquidDelegate(ctx sdk.Context, proxyAcc sdk.AccAddress, activeV return nil } -// LiquidUnstake burns unstakingStkXPRT and performs LiquidUnbond to active liquid validators with del shares worth of shares according to NetAmount with each validators current weight. +// LiquidUnstake burns unstakingGTAC and performs LiquidUnbond to active liquid validators with del shares worth of shares according to NetAmount with each validators current weight. func (k Keeper) LiquidUnstake( - ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, unstakingStkXPRT sdk.Coin, + ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, unstakingGTAC sdk.Coin, ) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) { params := k.GetParams(ctx) bondDenom, err := k.stakingKeeper.BondDenom(ctx) @@ -777,9 +777,9 @@ func (k Keeper) LiquidUnstake( // check bond denomination liquidBondDenom := k.LiquidBondDenom(ctx) - if unstakingStkXPRT.Denom != liquidBondDenom { + if unstakingGTAC.Denom != liquidBondDenom { return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidLiquidBondDenom, "invalid coin denomination: got %s, expected %s", unstakingStkXPRT.Denom, liquidBondDenom, + types.ErrInvalidLiquidBondDenom, "invalid coin denomination: got %s, expected %s", unstakingGTAC.Denom, liquidBondDenom, ) } @@ -789,12 +789,12 @@ func (k Keeper) LiquidUnstake( return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err } - if unstakingStkXPRT.Amount.GT(nas.StkxprtTotalSupply) || nas.StkxprtTotalSupply.IsZero() { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrInvalidStkXPRTSupply + if unstakingGTAC.Amount.GT(nas.GtacTotalSupply) || nas.GtacTotalSupply.IsZero() { + return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrInvalidGTACSupply } - // UnstakeAmount = NetAmount * StkXPRTAmount/TotalSupply * (1-UnstakeFeeRate) - unbondingAmount := types.StkXPRTToNativeToken(unstakingStkXPRT.Amount, nas.StkxprtTotalSupply, nas.NetAmount) + // UnstakeAmount = NetAmount * GTACAmount/TotalSupply * (1-UnstakeFeeRate) + unbondingAmount := types.GTACToNativeToken(unstakingGTAC.Amount, nas.GtacTotalSupply, nas.NetAmount) unbondingAmount = types.DeductFeeRate(unbondingAmount, params.UnstakeFeeRate) unbondingAmountInt := unbondingAmount.TruncateInt() @@ -802,12 +802,12 @@ func (k Keeper) LiquidUnstake( return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrTooSmallLiquidUnstakingAmount } - // burn stkxprt - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, liquidStaker, types.ModuleName, sdk.NewCoins(unstakingStkXPRT)) + // burn gtac + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, liquidStaker, types.ModuleName, sdk.NewCoins(unstakingGTAC)) if err != nil { return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err } - err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(liquidBondDenom, unstakingStkXPRT.Amount))) + err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(liquidBondDenom, unstakingGTAC.Amount))) if err != nil { return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err } @@ -860,7 +860,7 @@ func (k Keeper) LiquidUnstake( // prioritize inactive liquid validators in the list to be used in DivideByCurrentWeight liquidVals = k.PrioritiseInactiveLiquidValidators(ctx, liquidVals) - // crumb may occur due to a decimal error in dividing the unstaking stkXPRT into the weight of liquid validators, it will remain in the NetAmount + // crumb may occur due to a decimal error in dividing the unstaking gTAC into the weight of liquid validators, it will remain in the NetAmount unbondingAmounts, crumb := types.DivideByCurrentWeight(liquidVals, unbondingAmount, totalLiquidTokens, liquidTokenMap) if !unbondingAmount.Sub(crumb).IsPositive() { return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrTooSmallLiquidUnstakingAmount diff --git a/x/liquidstake/keeper/liquidstake_test.go b/x/liquidstake/keeper/liquidstake_test.go index 87f5b68..f4e510f 100644 --- a/x/liquidstake/keeper/liquidstake_test.go +++ b/x/liquidstake/keeper/liquidstake_test.go @@ -262,7 +262,7 @@ func (s *KeeperTestSuite) TestLiquidStake() { // no btoken supply and netAmount after unbond all nas, err := s.keeper.GetNetAmountState(s.ctx) s.Require().NoError(err) - s.Require().EqualValues(nas.StkxprtTotalSupply, sdk.ZeroInt()) + s.Require().EqualValues(nas.GtacTotalSupply, sdk.ZeroInt()) s.Require().Equal(nas.TotalRemainingRewards, sdk.ZeroDec()) s.Require().Equal(nas.TotalDelShares, sdk.ZeroDec()) s.Require().Equal(nas.TotalLiquidTokens, sdk.ZeroInt()) diff --git a/x/liquidstake/keeper/msg_server.go b/x/liquidstake/keeper/msg_server.go index e929a41..dc8418a 100644 --- a/x/liquidstake/keeper/msg_server.go +++ b/x/liquidstake/keeper/msg_server.go @@ -37,14 +37,14 @@ var _ types.MsgServer = msgServer{} func (k msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) (*types.MsgLiquidStakeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - stkXPRTMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.Amount) + gTACMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.Amount) if err != nil { return nil, err } var cValue math.LegacyDec - if stkXPRTMintAmount.IsPositive() { - cValue = stkXPRTMintAmount.ToLegacyDec().Quo(msg.Amount.Amount.ToLegacyDec()) + if gTACMintAmount.IsPositive() { + cValue = gTACMintAmount.ToLegacyDec().Quo(msg.Amount.Amount.ToLegacyDec()) } liquidBondDenom := k.LiquidBondDenom(ctx) @@ -57,7 +57,7 @@ func (k msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) types.EventTypeMsgLiquidStake, sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), sdk.NewAttribute(types.AttributeKeyLiquidAmount, msg.Amount.String()), - sdk.NewAttribute(types.AttributeKeyStkXPRTMintedAmount, sdk.Coin{Denom: liquidBondDenom, Amount: stkXPRTMintAmount}.String()), + sdk.NewAttribute(types.AttributeKeyGTACMintedAmount, sdk.Coin{Denom: liquidBondDenom, Amount: gTACMintAmount}.String()), sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), ), }) @@ -67,7 +67,7 @@ func (k msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) func (k msgServer) StakeToLP(goCtx context.Context, msg *types.MsgStakeToLP) (*types.MsgStakeToLPResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - stkXPRTMintAmount, err := k.LSMDelegate( + gTACMintAmount, err := k.LSMDelegate( ctx, msg.GetDelegator(), msg.GetValidator(), @@ -79,14 +79,14 @@ func (k msgServer) StakeToLP(goCtx context.Context, msg *types.MsgStakeToLP) (*t } liquidBondDenom := k.LiquidBondDenom(ctx) - stkXPRTMinted := sdk.Coin{ + gTACMinted := sdk.Coin{ Denom: liquidBondDenom, - Amount: stkXPRTMintAmount, + Amount: gTACMintAmount, } var cValue math.LegacyDec - if stkXPRTMintAmount.IsPositive() { - cValue = stkXPRTMintAmount.ToLegacyDec().Quo(msg.StakedAmount.Amount.ToLegacyDec()) + if gTACMintAmount.IsPositive() { + cValue = gTACMintAmount.ToLegacyDec().Quo(msg.StakedAmount.Amount.ToLegacyDec()) } ctx.EventManager().EmitEvents(sdk.Events{ @@ -98,25 +98,25 @@ func (k msgServer) StakeToLP(goCtx context.Context, msg *types.MsgStakeToLP) (*t types.EventTypeMsgStakeToLP, sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), sdk.NewAttribute(types.AttributeKeyStakedAmount, msg.StakedAmount.String()), - sdk.NewAttribute(types.AttributeKeyStkXPRTMintedAmount, stkXPRTMinted.String()), + sdk.NewAttribute(types.AttributeKeyGTACMintedAmount, gTACMinted.String()), sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), ), }) if (msg.LiquidAmount != sdk.Coin{}) && (msg.LiquidAmount.Amount != math.Int{}) && msg.LiquidAmount.Amount.IsPositive() { - stkXPRTMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.LiquidAmount) + gTACMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.LiquidAmount) if err != nil { return nil, err } - stkXPRTMinted := sdk.Coin{ + gTACMinted := sdk.Coin{ Denom: liquidBondDenom, - Amount: stkXPRTMintAmount, + Amount: gTACMintAmount, } var cValue math.LegacyDec - if stkXPRTMintAmount.IsPositive() { - cValue = stkXPRTMintAmount.ToLegacyDec().Quo(msg.LiquidAmount.Amount.ToLegacyDec()) + if gTACMintAmount.IsPositive() { + cValue = gTACMintAmount.ToLegacyDec().Quo(msg.LiquidAmount.Amount.ToLegacyDec()) } ctx.EventManager().EmitEvents(sdk.Events{ @@ -128,12 +128,12 @@ func (k msgServer) StakeToLP(goCtx context.Context, msg *types.MsgStakeToLP) (*t types.EventTypeMsgStakeToLP, sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), sdk.NewAttribute(types.AttributeKeyLiquidAmount, msg.LiquidAmount.String()), - sdk.NewAttribute(types.AttributeKeyStkXPRTMintedAmount, stkXPRTMinted.String()), + sdk.NewAttribute(types.AttributeKeyGTACMintedAmount, gTACMinted.String()), sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), ), }) - _, err = k.LockOnLP(ctx, msg.GetDelegator(), stkXPRTMinted) + _, err = k.LockOnLP(ctx, msg.GetDelegator(), gTACMinted) if err != nil { return nil, err } @@ -228,7 +228,7 @@ func (k msgServer) UpdateWhitelistedValidators(goCtx context.Context, msg *types fullVal, err := k.stakingKeeper.GetValidator(ctx, valAddr) if err != nil { return nil, normal_errors.Join( - errors.Wrapf( + errors.Wrapf( types.ErrWhitelistedValidatorsList, "validator not found: %s", valAddr, ), diff --git a/x/liquidstake/types/errors.go b/x/liquidstake/types/errors.go index 8dda2df..c274eec 100644 --- a/x/liquidstake/types/errors.go +++ b/x/liquidstake/types/errors.go @@ -10,7 +10,7 @@ var ( ErrInvalidLiquidBondDenom = errors.Register(ModuleName, 1003, "invalid liquid bond denom") ErrNotImplementedYet = errors.Register(ModuleName, 1004, "not implemented yet") ErrLessThanMinLiquidStakeAmount = errors.Register(ModuleName, 1005, "staking amount should be over params.min_liquid_stake_amount") - ErrInvalidStkXPRTSupply = errors.Register(ModuleName, 1006, "invalid liquid bond denom supply") + ErrInvalidGTACSupply = errors.Register(ModuleName, 1006, "invalid liquid bond denom supply") ErrInvalidActiveLiquidValidators = errors.Register(ModuleName, 1007, "invalid active liquid validators") ErrLiquidValidatorsNotExists = errors.Register(ModuleName, 1008, "liquid validators not exists") ErrInsufficientProxyAccBalance = errors.Register(ModuleName, 1009, "insufficient liquid tokens or balance of proxy account, need to wait for new liquid validator to be added or unbonding of proxy account to be completed") diff --git a/x/liquidstake/types/events.go b/x/liquidstake/types/events.go index f29f414..c889fed 100644 --- a/x/liquidstake/types/events.go +++ b/x/liquidstake/types/events.go @@ -17,7 +17,7 @@ const ( AttributeKeyDelegator = "delegator" AttributeKeyNewShares = "new_shares" AttributeKeyCValue = "c_value" - AttributeKeyStkXPRTMintedAmount = "stkxprt_minted_amount" + AttributeKeyGTACMintedAmount = "gtac_minted_amount" AttributeKeyCompletionTime = "completion_time" AttributeKeyUnbondingAmount = "unbonding_amount" AttributeKeyUnbondedAmount = "unbonded_amount" diff --git a/x/liquidstake/types/genesis.pb.go b/x/liquidstake/types/genesis.pb.go index b007358..11bb118 100644 --- a/x/liquidstake/types/genesis.pb.go +++ b/x/liquidstake/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pstake/liquidstake/v1beta1/genesis.proto +// source: tac/liquidstake/v1beta1/genesis.proto package types @@ -34,7 +34,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_bbc03e56b740bb6c, []int{0} + return fileDescriptor_6924241cc1e1a1cb, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -64,33 +64,33 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo func init() { - proto.RegisterType((*GenesisState)(nil), "pstake.liquidstake.v1beta1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "tac.liquidstake.v1beta1.GenesisState") } func init() { - proto.RegisterFile("pstake/liquidstake/v1beta1/genesis.proto", fileDescriptor_bbc03e56b740bb6c) + proto.RegisterFile("tac/liquidstake/v1beta1/genesis.proto", fileDescriptor_6924241cc1e1a1cb) } -var fileDescriptor_bbc03e56b740bb6c = []byte{ - // 279 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x28, 0x2e, 0x49, - 0xcc, 0x4e, 0xd5, 0xcf, 0xc9, 0x2c, 0x2c, 0xcd, 0x4c, 0x81, 0xb0, 0xcb, 0x0c, 0x93, 0x52, 0x4b, - 0x12, 0x0d, 0xf5, 0xd3, 0x53, 0xf3, 0x52, 0x8b, 0x33, 0x8b, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, - 0x85, 0xa4, 0x20, 0x2a, 0xf5, 0x90, 0x54, 0xea, 0x41, 0x55, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, - 0x83, 0x95, 0xe9, 0x83, 0x58, 0x10, 0x1d, 0x52, 0x3a, 0x78, 0xcc, 0x46, 0x36, 0x05, 0xac, 0x5a, - 0x69, 0x17, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xc6, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x07, 0x2e, - 0xb6, 0x82, 0xc4, 0xa2, 0xc4, 0xdc, 0x62, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x25, 0x3d, - 0xdc, 0x2e, 0xd0, 0x0b, 0x00, 0xab, 0x74, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0x4f, - 0x28, 0x8e, 0x4b, 0x10, 0xa2, 0x36, 0xbe, 0x2c, 0x31, 0x27, 0x33, 0x25, 0xb1, 0x24, 0xbf, 0xa8, - 0x58, 0x82, 0x49, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x1b, 0x9f, 0x61, 0x3e, 0x60, 0xb1, 0x30, 0x98, - 0x1e, 0xa8, 0xa9, 0x02, 0x39, 0xa8, 0xc2, 0xc5, 0x56, 0x1c, 0x1d, 0x0b, 0xe4, 0x19, 0x5e, 0x2c, - 0x90, 0x67, 0x70, 0x8a, 0x59, 0xf1, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, - 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, - 0xe5, 0x18, 0xa2, 0xec, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, - 0x52, 0x8b, 0x8a, 0x33, 0x8b, 0x4b, 0x52, 0xf3, 0x92, 0x53, 0xfd, 0xf3, 0x52, 0xf5, 0x21, 0xae, - 0xd0, 0xcd, 0x4b, 0x2c, 0xc9, 0x2c, 0x4b, 0xd5, 0x2f, 0x33, 0xd2, 0xaf, 0x40, 0x09, 0xae, 0x92, - 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x08, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x54, - 0xe3, 0xaa, 0x70, 0xad, 0x01, 0x00, 0x00, +var fileDescriptor_6924241cc1e1a1cb = []byte{ + // 274 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2d, 0x49, 0x4c, 0xd6, + 0xcf, 0xc9, 0x2c, 0x2c, 0xcd, 0x4c, 0x29, 0x2e, 0x49, 0xcc, 0x4e, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, + 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x12, 0x2f, 0x49, 0x4c, 0xd6, 0x43, 0x52, 0xa6, 0x07, 0x55, 0x26, 0x25, 0x92, 0x9e, + 0x9f, 0x9e, 0x0f, 0x56, 0xa3, 0x0f, 0x62, 0x41, 0x94, 0x4b, 0x69, 0xe2, 0x32, 0x15, 0xd9, 0x08, + 0xb0, 0x52, 0xa5, 0x2d, 0x8c, 0x5c, 0x3c, 0xee, 0x10, 0xbb, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, + 0x6c, 0xb9, 0xd8, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, + 0xe4, 0xf5, 0x70, 0xd8, 0xad, 0x17, 0x00, 0x56, 0xe6, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, + 0x54, 0x93, 0x50, 0x34, 0x97, 0x20, 0x44, 0x6d, 0x7c, 0x59, 0x62, 0x4e, 0x66, 0x4a, 0x62, 0x49, + 0x7e, 0x51, 0xb1, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x06, 0x4e, 0x93, 0x7c, 0xc0, 0x62, + 0x61, 0x30, 0x0d, 0x50, 0x23, 0x05, 0x72, 0x50, 0x85, 0x8b, 0xad, 0x38, 0x3a, 0x16, 0xc8, 0x33, + 0xbc, 0x58, 0x20, 0xcf, 0xe0, 0x14, 0xb8, 0xe2, 0x91, 0x1c, 0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17, + 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, + 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, + 0xea, 0x3b, 0x16, 0x17, 0x64, 0xa4, 0x16, 0xa5, 0xea, 0x56, 0x54, 0x56, 0xe9, 0x97, 0x24, 0x26, + 0x27, 0x67, 0x24, 0x66, 0xe6, 0xe9, 0x57, 0xa0, 0x84, 0x4e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0x38, 0x40, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x7a, 0x9e, 0x44, 0x93, 0x01, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/liquidstake/types/keys.go b/x/liquidstake/types/keys.go index ac6abf1..ac06b49 100644 --- a/x/liquidstake/types/keys.go +++ b/x/liquidstake/types/keys.go @@ -13,7 +13,7 @@ const ( RouterKey = ModuleName // StoreKey is the default store key for the liquidstake module - // To avoid collision with liquidstakeibc we make it xprtliquidstake + // To avoid collision with liquidstakeibc we make it tacliquidstake StoreKey = "utac" + ModuleName // QuerierRoute is the querier route for the liquidstake module diff --git a/x/liquidstake/types/liquidstake.go b/x/liquidstake/types/liquidstake.go index 1110580..265cd77 100644 --- a/x/liquidstake/types/liquidstake.go +++ b/x/liquidstake/types/liquidstake.go @@ -169,14 +169,14 @@ func (avs ActiveLiquidValidators) TotalWeight(whitelistedValsMap WhitelistedVals return totalWeight } -// NativeTokenToStkXPRT returns StkxprtTotalSupply * nativeTokenAmount / netAmount -func NativeTokenToStkXPRT(nativeTokenAmount, stkXPRTTotalSupplyAmount math.Int, netAmount math.LegacyDec) (stkXPRTAmount math.Int) { - return math.LegacyNewDecFromInt(stkXPRTTotalSupplyAmount).MulTruncate(math.LegacyNewDecFromInt(nativeTokenAmount)).QuoTruncate(netAmount.TruncateDec()).TruncateInt() +// NativeTokenToGTAC returns GtacTotalSupply * nativeTokenAmount / netAmount +func NativeTokenToGTAC(nativeTokenAmount, gTACTotalSupplyAmount math.Int, netAmount math.LegacyDec) (gTACAmount math.Int) { + return math.LegacyNewDecFromInt(gTACTotalSupplyAmount).MulTruncate(math.LegacyNewDecFromInt(nativeTokenAmount)).QuoTruncate(netAmount.TruncateDec()).TruncateInt() } -// StkXPRTToNativeToken returns stkXPRTAmount * netAmount / StkxprtTotalSupply with truncations -func StkXPRTToNativeToken(stkXPRTAmount, stkXPRTTotalSupplyAmount math.Int, netAmount math.LegacyDec) (nativeTokenAmount math.LegacyDec) { - return math.LegacyNewDecFromInt(stkXPRTAmount).MulTruncate(netAmount).Quo(math.LegacyNewDecFromInt(stkXPRTTotalSupplyAmount)).TruncateDec() +// GTACToNativeToken returns gTACAmount * netAmount / GtacTotalSupply with truncations +func GTACToNativeToken(gTACAmount, gTACTotalSupplyAmount math.Int, netAmount math.LegacyDec) (nativeTokenAmount math.LegacyDec) { + return math.LegacyNewDecFromInt(gTACAmount).MulTruncate(netAmount).Quo(math.LegacyNewDecFromInt(gTACTotalSupplyAmount)).TruncateDec() } // DeductFeeRate returns Input * (1-FeeRate) with truncations @@ -192,7 +192,7 @@ func (nas NetAmountState) CalcMintRate() math.LegacyDec { if nas.NetAmount.IsNil() || !nas.NetAmount.IsPositive() { return math.LegacyZeroDec() } - return math.LegacyNewDecFromInt(nas.StkxprtTotalSupply).QuoTruncate(nas.NetAmount) + return math.LegacyNewDecFromInt(nas.GtacTotalSupply).QuoTruncate(nas.NetAmount) } type LiquidValidatorStates []LiquidValidatorState diff --git a/x/liquidstake/types/liquidstake.pb.go b/x/liquidstake/types/liquidstake.pb.go index fba8251..fc8ace9 100644 --- a/x/liquidstake/types/liquidstake.pb.go +++ b/x/liquidstake/types/liquidstake.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pstake/liquidstake/v1beta1/liquidstake.proto +// source: tac/liquidstake/v1beta1/liquidstake.proto package types @@ -54,7 +54,7 @@ func (x ValidatorStatus) String() string { } func (ValidatorStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_8f87e6d47a5a3bba, []int{0} + return fileDescriptor_8986499a0b409e33, []int{0} } // Params defines the set of params for the liquidstake module. @@ -69,7 +69,7 @@ type Params struct { // unbonded by subtracting it from unbondingAmount UnstakeFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=unstake_fee_rate,json=unstakeFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"unstake_fee_rate"` // LsmDisabled allows to block any msgs that convert staked tokens into - // stkXPRT through LSM. + // gTAC through LSM. LsmDisabled bool `protobuf:"varint,4,opt,name=lsm_disabled,json=lsmDisabled,proto3" json:"lsm_disabled,omitempty"` // MinLiquidStakingAmount specifies the minimum number of coins to be staked // to the active liquid validators on liquid staking to minimize decimal loss @@ -99,7 +99,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_8f87e6d47a5a3bba, []int{0} + return fileDescriptor_8986499a0b409e33, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -145,7 +145,7 @@ func (m *WhitelistedValidator) Reset() { *m = WhitelistedValidator{} } func (m *WhitelistedValidator) String() string { return proto.CompactTextString(m) } func (*WhitelistedValidator) ProtoMessage() {} func (*WhitelistedValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_8f87e6d47a5a3bba, []int{1} + return fileDescriptor_8986499a0b409e33, []int{1} } func (m *WhitelistedValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -187,7 +187,7 @@ func (m *LiquidValidator) Reset() { *m = LiquidValidator{} } func (m *LiquidValidator) String() string { return proto.CompactTextString(m) } func (*LiquidValidator) ProtoMessage() {} func (*LiquidValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_8f87e6d47a5a3bba, []int{2} + return fileDescriptor_8986499a0b409e33, []int{2} } func (m *LiquidValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -225,7 +225,7 @@ type LiquidValidatorState struct { // weight specifies the weight for liquid staking, unstaking amount Weight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"weight"` // status is the liquid validator status - Status ValidatorStatus `protobuf:"varint,3,opt,name=status,proto3,enum=pstake.liquidstake.v1beta1.ValidatorStatus" json:"status,omitempty"` + Status ValidatorStatus `protobuf:"varint,3,opt,name=status,proto3,enum=tac.liquidstake.v1beta1.ValidatorStatus" json:"status,omitempty"` // del_shares define the delegation shares of the validator DelShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=del_shares,json=delShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"del_shares"` // liquid_tokens define the token amount worth of delegation shares of the @@ -237,7 +237,7 @@ func (m *LiquidValidatorState) Reset() { *m = LiquidValidatorState{} } func (m *LiquidValidatorState) String() string { return proto.CompactTextString(m) } func (*LiquidValidatorState) ProtoMessage() {} func (*LiquidValidatorState) Descriptor() ([]byte, []int) { - return fileDescriptor_8f87e6d47a5a3bba, []int{3} + return fileDescriptor_8986499a0b409e33, []int{3} } func (m *LiquidValidatorState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -270,10 +270,10 @@ var xxx_messageInfo_LiquidValidatorState proto.InternalMessageInfo // that depends on the several module state every time, so it is used only for // calculation and query and is not stored in kv. type NetAmountState struct { - // mint_rate is stkXPRTTotalSupply / NetAmount + // mint_rate is gTACTotalSupply / NetAmount MintRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=mint_rate,json=mintRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"mint_rate"` - // btoken_total_supply returns the total supply of stk/uxprt (stkXPRT denom) - StkxprtTotalSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=stkxprt_total_supply,json=stkxprtTotalSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"stkxprt_total_supply"` + // btoken_total_supply returns the total supply of stk/utac (gTAC denom) + GtacTotalSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=gtac_total_supply,json=gtacTotalSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gtac_total_supply"` // net_amount is proxy account's native token balance + total liquid tokens + // total remaining rewards + total unbonding balance NetAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=net_amount,json=netAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"net_amount"` @@ -296,7 +296,7 @@ func (m *NetAmountState) Reset() { *m = NetAmountState{} } func (m *NetAmountState) String() string { return proto.CompactTextString(m) } func (*NetAmountState) ProtoMessage() {} func (*NetAmountState) Descriptor() ([]byte, []int) { - return fileDescriptor_8f87e6d47a5a3bba, []int{4} + return fileDescriptor_8986499a0b409e33, []int{4} } func (m *NetAmountState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,83 +326,83 @@ func (m *NetAmountState) XXX_DiscardUnknown() { var xxx_messageInfo_NetAmountState proto.InternalMessageInfo func init() { - proto.RegisterEnum("pstake.liquidstake.v1beta1.ValidatorStatus", ValidatorStatus_name, ValidatorStatus_value) - proto.RegisterType((*Params)(nil), "pstake.liquidstake.v1beta1.Params") - proto.RegisterType((*WhitelistedValidator)(nil), "pstake.liquidstake.v1beta1.WhitelistedValidator") - proto.RegisterType((*LiquidValidator)(nil), "pstake.liquidstake.v1beta1.LiquidValidator") - proto.RegisterType((*LiquidValidatorState)(nil), "pstake.liquidstake.v1beta1.LiquidValidatorState") - proto.RegisterType((*NetAmountState)(nil), "pstake.liquidstake.v1beta1.NetAmountState") + proto.RegisterEnum("tac.liquidstake.v1beta1.ValidatorStatus", ValidatorStatus_name, ValidatorStatus_value) + proto.RegisterType((*Params)(nil), "tac.liquidstake.v1beta1.Params") + proto.RegisterType((*WhitelistedValidator)(nil), "tac.liquidstake.v1beta1.WhitelistedValidator") + proto.RegisterType((*LiquidValidator)(nil), "tac.liquidstake.v1beta1.LiquidValidator") + proto.RegisterType((*LiquidValidatorState)(nil), "tac.liquidstake.v1beta1.LiquidValidatorState") + proto.RegisterType((*NetAmountState)(nil), "tac.liquidstake.v1beta1.NetAmountState") } func init() { - proto.RegisterFile("pstake/liquidstake/v1beta1/liquidstake.proto", fileDescriptor_8f87e6d47a5a3bba) + proto.RegisterFile("tac/liquidstake/v1beta1/liquidstake.proto", fileDescriptor_8986499a0b409e33) } -var fileDescriptor_8f87e6d47a5a3bba = []byte{ - // 1007 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xc1, 0x6e, 0x1b, 0x45, - 0x18, 0xc7, 0xbd, 0x4d, 0x6a, 0x92, 0x69, 0x9a, 0xc4, 0x1b, 0xa7, 0x76, 0x0c, 0x72, 0x4c, 0x90, - 0x50, 0x54, 0x88, 0x4d, 0x83, 0xc4, 0x21, 0x07, 0xc4, 0x3a, 0x4e, 0x84, 0x45, 0x9a, 0x5a, 0x6b, - 0x27, 0xad, 0x7a, 0x60, 0x3a, 0xde, 0x99, 0x38, 0x2b, 0xef, 0xce, 0x2c, 0x3b, 0xb3, 0x71, 0xf2, - 0x00, 0x48, 0x55, 0x4e, 0x9c, 0x10, 0x97, 0x48, 0x95, 0x78, 0x05, 0x0e, 0x3c, 0x42, 0x2f, 0x48, - 0x15, 0x27, 0xc4, 0xa1, 0x42, 0xc9, 0x85, 0xa7, 0x40, 0x68, 0x66, 0x76, 0x6d, 0xd7, 0x2d, 0x44, - 0x76, 0x7b, 0xf2, 0x7a, 0x66, 0xff, 0xbf, 0xef, 0x9b, 0xef, 0x3f, 0xf3, 0xcd, 0x82, 0x4f, 0x03, - 0x2e, 0x50, 0x97, 0x54, 0x3c, 0xf7, 0xbb, 0xc8, 0xc5, 0xfa, 0xf9, 0xe4, 0x5e, 0x9b, 0x08, 0x74, - 0x6f, 0x78, 0xac, 0x1c, 0x84, 0x4c, 0x30, 0xb3, 0xa0, 0xdf, 0x2e, 0x0f, 0xcf, 0xc4, 0x6f, 0x17, - 0xb2, 0x1d, 0xd6, 0x61, 0xea, 0xb5, 0x8a, 0x7c, 0xd2, 0x8a, 0xc2, 0x8a, 0xc3, 0xb8, 0xcf, 0x38, - 0xd4, 0x13, 0xfa, 0x8f, 0x9e, 0x5a, 0xfb, 0x3e, 0x0d, 0xd2, 0x0d, 0x14, 0x22, 0x9f, 0x9b, 0x77, - 0x41, 0x46, 0x23, 0x61, 0x9b, 0x51, 0x0c, 0x31, 0xa1, 0xcc, 0xcf, 0x1b, 0x25, 0x63, 0x7d, 0xd6, - 0x5e, 0xd0, 0x13, 0x55, 0x46, 0x71, 0x4d, 0x0e, 0x9b, 0x3e, 0xb8, 0xd3, 0x3b, 0x76, 0x05, 0xf1, - 0x5c, 0x2e, 0x08, 0x86, 0x27, 0xc8, 0x73, 0x31, 0x12, 0x2c, 0xe4, 0xf9, 0x1b, 0xa5, 0xa9, 0xf5, - 0x5b, 0x9b, 0x9f, 0x95, 0xff, 0x3b, 0xc9, 0xf2, 0xc3, 0x81, 0xf2, 0x30, 0x11, 0x56, 0xa7, 0x9f, - 0xbf, 0x5c, 0x4d, 0xd9, 0xcb, 0xbd, 0x37, 0xcc, 0x71, 0xf3, 0x11, 0x58, 0x8c, 0xa8, 0x82, 0xc0, - 0x23, 0x42, 0x60, 0x88, 0x04, 0xc9, 0x4f, 0xc9, 0xcc, 0xaa, 0x65, 0x29, 0xfb, 0xf3, 0xe5, 0xea, - 0xc7, 0x1d, 0x57, 0x1c, 0x47, 0xed, 0xb2, 0xc3, 0xfc, 0x78, 0x81, 0xf1, 0xcf, 0x06, 0xc7, 0xdd, - 0x8a, 0x38, 0x0b, 0x08, 0x2f, 0xd7, 0x88, 0x63, 0xcf, 0xc7, 0x9c, 0x5d, 0x42, 0x6c, 0x24, 0x88, - 0xf9, 0x21, 0x98, 0xf3, 0xb8, 0x0f, 0xb1, 0xcb, 0x51, 0xdb, 0x23, 0x38, 0x3f, 0x5d, 0x32, 0xd6, - 0x67, 0xec, 0x5b, 0x1e, 0xf7, 0x6b, 0xf1, 0x90, 0x49, 0x40, 0xce, 0x77, 0x29, 0x8c, 0x6b, 0xa3, - 0xb3, 0x40, 0x3e, 0x8b, 0xa8, 0xc8, 0xdf, 0x1c, 0x3b, 0x87, 0x3a, 0x15, 0x76, 0xd6, 0x77, 0xe9, - 0x9e, 0xa2, 0x35, 0x25, 0xcc, 0x52, 0x2c, 0xf3, 0x3e, 0xb8, 0xe3, 0xf4, 0xa0, 0xc7, 0x9c, 0x2e, - 0xc1, 0x30, 0x60, 0xcc, 0x83, 0x08, 0xe3, 0x90, 0x70, 0x9e, 0x4f, 0xab, 0x28, 0xf9, 0xdf, 0x7f, - 0xd9, 0xc8, 0xc6, 0xde, 0x59, 0x7a, 0xa6, 0x29, 0x42, 0x97, 0x76, 0xec, 0x25, 0xa7, 0xb7, 0xa7, - 0x64, 0x0d, 0xc6, 0xbc, 0x78, 0xca, 0xfc, 0x1a, 0x2c, 0xc9, 0x52, 0x21, 0xc7, 0x91, 0xf4, 0x3e, - 0xeb, 0xbd, 0x6b, 0x58, 0x99, 0x23, 0x42, 0x2c, 0xad, 0x49, 0x48, 0x6d, 0xb0, 0x8c, 0x22, 0xc1, - 0x1c, 0xe6, 0x07, 0x2c, 0xa2, 0x78, 0xe0, 0xc0, 0xcc, 0x44, 0x0e, 0x2c, 0x0d, 0xc3, 0x12, 0x1b, - 0x1a, 0x20, 0xd7, 0x77, 0x1e, 0x22, 0x2c, 0xeb, 0x9d, 0x64, 0x3c, 0x7b, 0x4d, 0xc6, 0x83, 0x2d, - 0x63, 0x49, 0x5d, 0x92, 0xf5, 0x47, 0xe0, 0xb6, 0xcf, 0x70, 0xe4, 0x11, 0x18, 0xa0, 0x88, 0x13, - 0x9c, 0x07, 0xca, 0xd9, 0x39, 0x3d, 0xd8, 0x50, 0x63, 0x5b, 0x33, 0x4f, 0x9f, 0xad, 0xa6, 0x7e, - 0x7a, 0xb6, 0x9a, 0x5a, 0xfb, 0xd5, 0x00, 0xd9, 0x37, 0xed, 0x4b, 0x73, 0x07, 0x64, 0xfa, 0xbb, - 0xbb, 0x9f, 0x93, 0x71, 0x4d, 0x4e, 0x8b, 0x7d, 0x49, 0x92, 0x4e, 0x13, 0xdc, 0x16, 0x28, 0xec, - 0x10, 0x01, 0x7b, 0xc4, 0xed, 0x1c, 0x8b, 0xfc, 0x8d, 0x89, 0xb6, 0xce, 0x9c, 0x86, 0x3c, 0x54, - 0x8c, 0xad, 0x69, 0x99, 0xfe, 0xda, 0x13, 0xb0, 0xa0, 0x77, 0xd3, 0x20, 0xe9, 0x6d, 0xb0, 0xc8, - 0x02, 0x12, 0x8e, 0x95, 0xf3, 0x42, 0xa2, 0x88, 0x87, 0x75, 0x71, 0xfe, 0x96, 0x11, 0x7e, 0x9c, - 0x02, 0xd9, 0x91, 0x10, 0x4d, 0x21, 0x6d, 0x7b, 0x17, 0x71, 0xcc, 0x5d, 0x90, 0x7e, 0xab, 0x9a, - 0xc4, 0x6a, 0x73, 0x1b, 0xa4, 0xb9, 0x40, 0x22, 0xe2, 0xaa, 0x35, 0xcc, 0x6f, 0x7e, 0xf2, 0x7f, - 0x3d, 0xe8, 0x95, 0x85, 0x44, 0xdc, 0x8e, 0xa5, 0xe6, 0x7d, 0x00, 0x30, 0xf1, 0x20, 0x3f, 0x46, - 0x21, 0xe1, 0xaa, 0x1b, 0x8c, 0xbf, 0xc3, 0x67, 0x31, 0xf1, 0x9a, 0x0a, 0x20, 0x6d, 0x8f, 0xfb, - 0x86, 0x60, 0x5d, 0x42, 0xf9, 0x84, 0x1d, 0x63, 0x4e, 0x43, 0x5a, 0x8a, 0x31, 0x64, 0xcc, 0x3f, - 0x37, 0xc1, 0xfc, 0x3e, 0x11, 0xba, 0x83, 0x68, 0x4b, 0xbe, 0x01, 0xb3, 0xbe, 0x4b, 0x85, 0x3e, - 0xa1, 0xc6, 0x44, 0xf9, 0xcf, 0x48, 0x80, 0x3a, 0x96, 0x4f, 0x40, 0x96, 0x8b, 0xee, 0x69, 0x10, - 0x0a, 0x28, 0x98, 0x40, 0x1e, 0xe4, 0x51, 0x10, 0x78, 0x67, 0x13, 0x1a, 0x65, 0xc6, 0xac, 0x96, - 0x44, 0x35, 0x15, 0x49, 0xd6, 0x9b, 0x12, 0x91, 0xf4, 0xd3, 0xc9, 0x7a, 0xfa, 0x2c, 0x4d, 0x4a, - 0x20, 0x2f, 0x0a, 0x9d, 0xe8, 0x5b, 0x9b, 0x38, 0xaf, 0x38, 0xb5, 0xbe, 0x93, 0xdf, 0x82, 0x25, - 0x4d, 0x7e, 0x17, 0x7e, 0x66, 0x14, 0x6a, 0x6f, 0xc8, 0x54, 0xf3, 0x08, 0xe4, 0x34, 0x3f, 0x24, - 0x3e, 0x72, 0xa9, 0x4b, 0x3b, 0x30, 0x24, 0x3d, 0x14, 0xe2, 0xa4, 0xff, 0x8f, 0xbb, 0x80, 0x65, - 0x85, 0xb3, 0x13, 0x9a, 0xad, 0x61, 0x83, 0x38, 0x11, 0x95, 0xd7, 0xbc, 0x8c, 0xd3, 0x46, 0x1e, - 0xa2, 0x0e, 0x89, 0xef, 0x86, 0x71, 0xd7, 0xa2, 0xe3, 0x1c, 0x24, 0xb4, 0xaa, 0x86, 0x99, 0x8f, - 0x41, 0x26, 0x08, 0xd9, 0xe9, 0x99, 0xbc, 0x81, 0xfa, 0x11, 0x66, 0x26, 0x8a, 0xb0, 0xa0, 0x40, - 0x96, 0xe3, 0xc4, 0x6c, 0x75, 0x00, 0x0c, 0x79, 0x00, 0xee, 0xfe, 0x66, 0x80, 0x85, 0x91, 0xa3, - 0x6c, 0x7e, 0x05, 0x3e, 0x38, 0xb4, 0xf6, 0xea, 0x35, 0xab, 0xf5, 0xc0, 0x86, 0xcd, 0x96, 0xd5, - 0x3a, 0x68, 0xc2, 0x83, 0xfd, 0x66, 0x63, 0x67, 0xbb, 0xbe, 0x5b, 0xdf, 0xa9, 0x2d, 0xa6, 0x0a, - 0xc5, 0xf3, 0x8b, 0x52, 0x61, 0x44, 0x76, 0x40, 0x79, 0x40, 0x1c, 0xf7, 0xc8, 0x25, 0xd8, 0xfc, - 0x02, 0xe4, 0x5e, 0x23, 0x58, 0xdb, 0xad, 0xfa, 0xe1, 0xce, 0xa2, 0x51, 0x58, 0x39, 0xbf, 0x28, - 0x2d, 0x8f, 0x88, 0x2d, 0x47, 0xb8, 0x27, 0xc4, 0xdc, 0x02, 0x2b, 0xaf, 0xe9, 0xea, 0xfb, 0xb1, - 0xf2, 0x46, 0xe1, 0xfd, 0xf3, 0x8b, 0x52, 0x6e, 0x44, 0x59, 0xa7, 0x48, 0x69, 0x0b, 0xd3, 0x4f, - 0x7f, 0x2e, 0xa6, 0xaa, 0x8f, 0x9e, 0x5f, 0x16, 0x8d, 0x17, 0x97, 0x45, 0xe3, 0xaf, 0xcb, 0xa2, - 0xf1, 0xc3, 0x55, 0x31, 0xf5, 0xe2, 0xaa, 0x98, 0xfa, 0xe3, 0xaa, 0x98, 0x7a, 0xfc, 0xe5, 0x50, - 0xb1, 0x02, 0x12, 0x72, 0x79, 0x4d, 0x51, 0x87, 0x3c, 0xa0, 0xa4, 0xa2, 0xdb, 0xdc, 0x06, 0x45, - 0x12, 0x54, 0x39, 0xd9, 0xac, 0x9c, 0xbe, 0xf2, 0x25, 0xa9, 0x0a, 0xd9, 0x4e, 0xab, 0xef, 0xbd, - 0xcf, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x53, 0xe1, 0xf8, 0x6c, 0x0a, 0x00, 0x00, +var fileDescriptor_8986499a0b409e33 = []byte{ + // 999 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x41, 0x4f, 0x1b, 0x47, + 0x14, 0xc7, 0xbd, 0x40, 0x5c, 0x98, 0x10, 0xc0, 0x8b, 0x89, 0x8d, 0x5b, 0x19, 0x97, 0x4a, 0x15, + 0x8d, 0x84, 0xad, 0x24, 0x52, 0x0f, 0x9c, 0xb2, 0xc6, 0xa0, 0x5a, 0x05, 0x6a, 0xad, 0x0d, 0xa9, + 0x72, 0xe8, 0x74, 0xbc, 0x33, 0xd8, 0x5b, 0x76, 0x67, 0xb6, 0x3b, 0xb3, 0x18, 0x7a, 0xec, 0x29, + 0xe2, 0x54, 0xa9, 0x97, 0x5e, 0x90, 0x22, 0xf5, 0x2b, 0xf4, 0xd0, 0x8f, 0x90, 0x4b, 0xa5, 0xa8, + 0xa7, 0xaa, 0x87, 0xa8, 0x82, 0x4b, 0x3f, 0x42, 0x8f, 0xd5, 0xcc, 0xec, 0xda, 0x8e, 0x93, 0x08, + 0xd9, 0xc9, 0x09, 0x3c, 0xb3, 0xff, 0xdf, 0x7b, 0xf3, 0xfe, 0x6f, 0xdf, 0x2c, 0xf8, 0x4c, 0x20, + 0xa7, 0xe2, 0xb9, 0xdf, 0x47, 0x2e, 0xe6, 0x02, 0x9d, 0x90, 0xca, 0xe9, 0xfd, 0x36, 0x11, 0xe8, + 0xfe, 0xf0, 0x5a, 0x39, 0x08, 0x99, 0x60, 0x66, 0x4e, 0x20, 0xa7, 0x3c, 0xbc, 0x1c, 0x3f, 0x5a, + 0xc8, 0x76, 0x58, 0x87, 0xa9, 0x67, 0x2a, 0xf2, 0x3f, 0xfd, 0x78, 0x61, 0xd5, 0x61, 0xdc, 0x67, + 0x1c, 0xea, 0x0d, 0xfd, 0x43, 0x6f, 0xad, 0xff, 0x98, 0x06, 0xe9, 0x06, 0x0a, 0x91, 0xcf, 0xcd, + 0x7b, 0x20, 0xa3, 0x91, 0xb0, 0xcd, 0x28, 0x86, 0x98, 0x50, 0xe6, 0xe7, 0x8d, 0x92, 0xb1, 0x31, + 0x67, 0x2f, 0xea, 0x8d, 0x2a, 0xa3, 0xb8, 0x26, 0x97, 0xcd, 0xef, 0xc0, 0xdd, 0x5e, 0xd7, 0x15, + 0xc4, 0x73, 0xb9, 0x20, 0x18, 0x9e, 0x22, 0xcf, 0xc5, 0x48, 0xb0, 0x90, 0xe7, 0xa7, 0x4a, 0xd3, + 0x1b, 0xb7, 0x1f, 0x6c, 0x96, 0xdf, 0x92, 0x61, 0xf9, 0xf1, 0x40, 0x76, 0x94, 0xa8, 0xaa, 0x33, + 0xcf, 0x5f, 0xae, 0xa5, 0xec, 0x95, 0xde, 0x1b, 0xf6, 0xb8, 0xf9, 0x35, 0x58, 0x8a, 0xa8, 0x82, + 0xc0, 0x63, 0x42, 0x60, 0x88, 0x04, 0xc9, 0x4f, 0xcb, 0xb4, 0xaa, 0x65, 0x29, 0xfb, 0xfb, 0xe5, + 0xda, 0xa7, 0x1d, 0x57, 0x74, 0xa3, 0x76, 0xd9, 0x61, 0x7e, 0x7c, 0xba, 0xf8, 0xcf, 0x26, 0xc7, + 0x27, 0x15, 0x71, 0x1e, 0x10, 0x5e, 0xae, 0x11, 0xc7, 0x5e, 0x88, 0x39, 0xbb, 0x84, 0xd8, 0x48, + 0x10, 0xf3, 0x63, 0x30, 0xef, 0x71, 0x1f, 0x62, 0x97, 0xa3, 0xb6, 0x47, 0x70, 0x7e, 0xa6, 0x64, + 0x6c, 0xcc, 0xda, 0xb7, 0x3d, 0xee, 0xd7, 0xe2, 0x25, 0x93, 0x80, 0x9c, 0xef, 0x52, 0x18, 0x17, + 0x46, 0x67, 0x81, 0x7c, 0x16, 0x51, 0x91, 0xbf, 0x35, 0x76, 0x0e, 0x75, 0x2a, 0xec, 0xac, 0xef, + 0xd2, 0x3d, 0x45, 0x6b, 0x4a, 0x98, 0xa5, 0x58, 0xe6, 0x3e, 0xb8, 0xeb, 0xf4, 0xa0, 0xc7, 0x9c, + 0x13, 0x82, 0x61, 0xc0, 0x98, 0x07, 0x11, 0xc6, 0x21, 0xe1, 0x3c, 0x9f, 0x56, 0x51, 0xf2, 0x7f, + 0xfe, 0xb6, 0x99, 0x8d, 0x8d, 0xb3, 0xf4, 0x4e, 0x53, 0x84, 0x2e, 0xed, 0xd8, 0xcb, 0x4e, 0x6f, + 0x4f, 0xc9, 0x1a, 0x8c, 0x79, 0xf1, 0x96, 0xf9, 0x05, 0x58, 0x96, 0xa5, 0x42, 0x8e, 0x23, 0xe9, + 0x7d, 0xd6, 0x07, 0x37, 0xb0, 0x32, 0xc7, 0x84, 0x58, 0x5a, 0x93, 0x90, 0xda, 0x60, 0x05, 0x45, + 0x82, 0x39, 0xcc, 0x0f, 0x58, 0x44, 0xf1, 0xc0, 0x81, 0xd9, 0x89, 0x1c, 0x58, 0x1e, 0x86, 0x25, + 0x36, 0x34, 0x40, 0xae, 0xef, 0x3c, 0x44, 0x58, 0xd6, 0x3b, 0xc9, 0x78, 0xee, 0x86, 0x8c, 0x07, + 0x2d, 0x63, 0x49, 0x5d, 0x92, 0xf5, 0x27, 0xe0, 0x8e, 0xcf, 0x70, 0xe4, 0x11, 0x18, 0xa0, 0x88, + 0x13, 0x9c, 0x07, 0xca, 0xd9, 0x79, 0xbd, 0xd8, 0x50, 0x6b, 0x5b, 0xb3, 0x4f, 0x9f, 0xad, 0xa5, + 0x7e, 0x79, 0xb6, 0x96, 0x5a, 0xff, 0xdd, 0x00, 0xd9, 0x37, 0xf5, 0xa5, 0xb9, 0x03, 0x32, 0xfd, + 0xd6, 0xee, 0xe7, 0x64, 0xdc, 0x90, 0xd3, 0x52, 0x5f, 0x92, 0xa4, 0xd3, 0x04, 0x77, 0x04, 0x0a, + 0x3b, 0x44, 0xc0, 0x1e, 0x71, 0x3b, 0x5d, 0x91, 0x9f, 0x9a, 0xa8, 0x75, 0xe6, 0x35, 0xe4, 0xb1, + 0x62, 0x6c, 0xcd, 0xc8, 0xf4, 0xd7, 0xbf, 0x05, 0x8b, 0xba, 0x9b, 0x06, 0x49, 0x6f, 0x83, 0x25, + 0x16, 0x90, 0x70, 0xac, 0x9c, 0x17, 0x13, 0x45, 0xbc, 0xac, 0x8b, 0xf3, 0xaf, 0x8c, 0xf0, 0xf3, + 0x34, 0xc8, 0x8e, 0x84, 0x68, 0x0a, 0x69, 0xdb, 0xfb, 0x88, 0x63, 0xee, 0x82, 0xf4, 0x3b, 0xd5, + 0x24, 0x56, 0x9b, 0x8f, 0x40, 0x9a, 0x0b, 0x24, 0x22, 0xae, 0x46, 0xc3, 0xc2, 0x83, 0x8d, 0xb7, + 0x0e, 0xa0, 0x57, 0x4e, 0x11, 0x71, 0x3b, 0xd6, 0x99, 0xfb, 0x00, 0x60, 0xe2, 0x41, 0xde, 0x45, + 0x21, 0xe1, 0x6a, 0x14, 0x8c, 0xdf, 0xde, 0x73, 0x98, 0x78, 0x4d, 0x05, 0x90, 0x9e, 0xc7, 0x43, + 0x43, 0xb0, 0x13, 0x42, 0xf9, 0x84, 0xe3, 0x62, 0x5e, 0x43, 0x5a, 0x8a, 0x31, 0xe4, 0xca, 0x7f, + 0xb7, 0xc0, 0xc2, 0x01, 0x11, 0x7a, 0x7c, 0x68, 0x3f, 0xbe, 0x04, 0x73, 0xbe, 0x4b, 0x85, 0x7e, + 0x3d, 0x8d, 0x89, 0xf2, 0x9f, 0x95, 0x00, 0xf5, 0x4e, 0x3e, 0x01, 0x99, 0x8e, 0x40, 0x0e, 0x14, + 0x4c, 0x20, 0x0f, 0xf2, 0x28, 0x08, 0xbc, 0xf3, 0x09, 0x2d, 0x5a, 0x94, 0xa0, 0x96, 0xe4, 0x34, + 0x15, 0x46, 0x56, 0x9a, 0x12, 0x91, 0x8c, 0xd1, 0xc9, 0x46, 0xf9, 0x1c, 0x4d, 0x0e, 0x2f, 0xef, + 0x07, 0x9d, 0xe5, 0x3b, 0xdb, 0xb7, 0xa0, 0x38, 0xb5, 0xbe, 0x87, 0xdf, 0x80, 0x65, 0x4d, 0x7e, + 0x1f, 0x4e, 0x66, 0x14, 0x6a, 0x6f, 0xc8, 0x4e, 0xf3, 0x18, 0xe4, 0x34, 0x3f, 0x24, 0x3e, 0x72, + 0xa9, 0x4b, 0x3b, 0x30, 0x24, 0x3d, 0x14, 0xe2, 0x64, 0xec, 0x8f, 0x7b, 0x80, 0x15, 0x85, 0xb3, + 0x13, 0x9a, 0xad, 0x61, 0x83, 0x38, 0x11, 0x95, 0x57, 0xbb, 0x8c, 0xd3, 0x46, 0x1e, 0xa2, 0x0e, + 0x89, 0xaf, 0x84, 0x71, 0xcf, 0xa2, 0xe3, 0x1c, 0x26, 0xb4, 0xaa, 0x86, 0xc9, 0xa6, 0x09, 0x42, + 0x76, 0x76, 0x2e, 0x2f, 0x9e, 0x7e, 0x84, 0xd9, 0xc9, 0x9a, 0x46, 0x81, 0x2c, 0xc7, 0x89, 0xd9, + 0xaa, 0xf5, 0x0d, 0xd9, 0xfa, 0xf7, 0xfe, 0x30, 0xc0, 0xe2, 0xc8, 0x4b, 0x6c, 0x3e, 0x02, 0x1f, + 0x1d, 0x59, 0x7b, 0xf5, 0x9a, 0xd5, 0xfa, 0xca, 0x86, 0xcd, 0x96, 0xd5, 0x3a, 0x6c, 0xc2, 0xc3, + 0x83, 0x66, 0x63, 0x67, 0xbb, 0xbe, 0x5b, 0xdf, 0xa9, 0x2d, 0xa5, 0x0a, 0xc5, 0x8b, 0xcb, 0x52, + 0x61, 0x44, 0x76, 0x48, 0x79, 0x40, 0x1c, 0xf7, 0xd8, 0x25, 0xd8, 0xfc, 0x1c, 0xe4, 0x5e, 0x23, + 0x58, 0xdb, 0xad, 0xfa, 0xd1, 0xce, 0x92, 0x51, 0x58, 0xbd, 0xb8, 0x2c, 0xad, 0x8c, 0x88, 0x2d, + 0x47, 0xb8, 0xa7, 0xc4, 0xdc, 0x02, 0xab, 0xaf, 0xe9, 0xea, 0x07, 0xb1, 0x72, 0xaa, 0xf0, 0xe1, + 0xc5, 0x65, 0x29, 0x37, 0xa2, 0xac, 0x53, 0xa4, 0xb4, 0x85, 0x99, 0xa7, 0xbf, 0x16, 0x53, 0xd5, + 0xfd, 0xe7, 0x57, 0x45, 0xe3, 0xc5, 0x55, 0xd1, 0xf8, 0xe7, 0xaa, 0x68, 0xfc, 0x74, 0x5d, 0x4c, + 0xbd, 0xb8, 0x2e, 0xa6, 0xfe, 0xba, 0x2e, 0xa6, 0x9e, 0x3c, 0x1c, 0x2a, 0x96, 0xc5, 0x83, 0x2e, + 0x09, 0xc9, 0xe6, 0xd9, 0xf9, 0x0f, 0x15, 0x81, 0x1c, 0xa7, 0x8b, 0x5c, 0x5a, 0x39, 0x7b, 0xe5, + 0x7b, 0x51, 0x55, 0xaf, 0x9d, 0x56, 0x1f, 0x76, 0x0f, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x34, + 0xa7, 0xf5, 0x26, 0x4f, 0x0a, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -736,9 +736,9 @@ func (m *NetAmountState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a { - size := m.StkxprtTotalSupply.Size() + size := m.GtacTotalSupply.Size() i -= size - if _, err := m.StkxprtTotalSupply.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.GtacTotalSupply.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintLiquidstake(dAtA, i, uint64(size)) @@ -870,7 +870,7 @@ func (m *NetAmountState) Size() (n int) { _ = l l = m.MintRate.Size() n += 1 + l + sovLiquidstake(uint64(l)) - l = m.StkxprtTotalSupply.Size() + l = m.GtacTotalSupply.Size() n += 1 + l + sovLiquidstake(uint64(l)) l = m.NetAmount.Size() n += 1 + l + sovLiquidstake(uint64(l)) @@ -1713,7 +1713,7 @@ func (m *NetAmountState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StkxprtTotalSupply", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GtacTotalSupply", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1741,7 +1741,7 @@ func (m *NetAmountState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.StkxprtTotalSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.GtacTotalSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/liquidstake/types/msgs_test.go b/x/liquidstake/types/msgs_test.go index fb51e88..526dfe2 100644 --- a/x/liquidstake/types/msgs_test.go +++ b/x/liquidstake/types/msgs_test.go @@ -13,7 +13,7 @@ import ( func TestMsgLiquidStake(t *testing.T) { delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) - stakingCoin := sdk.NewCoin("uxprt", math.NewInt(1)) + stakingCoin := sdk.NewCoin("utac", math.NewInt(1)) testCases := []struct { expectedErr string @@ -53,7 +53,7 @@ func TestMsgLiquidStake(t *testing.T) { func TestMsgLiquidUnstake(t *testing.T) { delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) - stakingCoin := sdk.NewCoin("stk/uxprt", math.NewInt(1)) + stakingCoin := sdk.NewCoin("stk/utac", math.NewInt(1)) testCases := []struct { expectedErr string @@ -94,8 +94,8 @@ func TestMsgLiquidUnstake(t *testing.T) { func TestMsgStakeToLP(t *testing.T) { delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) validatorAddr := sdk.ValAddress(crypto.AddressHash([]byte("validatorAddr"))) - stakingCoin := sdk.NewCoin("uxprt", math.NewInt(1)) - zeroStakingCoin := sdk.NewCoin("uxprt", math.NewInt(0)) + stakingCoin := sdk.NewCoin("utac", math.NewInt(1)) + zeroStakingCoin := sdk.NewCoin("utac", math.NewInt(0)) testCases := []struct { expectedErr string diff --git a/x/liquidstake/types/params.go b/x/liquidstake/types/params.go index 5f98003..4f2bfd7 100644 --- a/x/liquidstake/types/params.go +++ b/x/liquidstake/types/params.go @@ -12,7 +12,7 @@ import ( // Parameter store keys var ( - DefaultLiquidBondDenom = "ugtac" + DefaultLiquidBondDenom = "stk/utac" // DefaultUnstakeFeeRate is the default Unstake Fee Rate. DefaultUnstakeFeeRate = math.LegacyZeroDec() @@ -44,7 +44,7 @@ var ( // // Important: derive this address using module.Address to obtain a 32-byte version distinguishable for LSM // authtypes.NewModuleAddress returns 20-byte addresses. - // persistence19zwggtdgaspa9tje6mxdap9xjpc4rayf3nd6dt5g3lwkx4y7z6dqmj3hnc + // tac19zwggtdgaspa9tje6mxdap9xjpc4rayf3nd6dt5g3lwkx4y7z6dqmj3hnc LiquidStakeProxyAcc = sdk.AccAddress(address.Module(ModuleName, []byte("-LiquidStakeProxyAcc"))) // DummyFeeAccountAcc is a dummy fee collection account that should be replaced via params. diff --git a/x/liquidstake/types/query.pb.go b/x/liquidstake/types/query.pb.go index 546f5ed..2fa8faa 100644 --- a/x/liquidstake/types/query.pb.go +++ b/x/liquidstake/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pstake/liquidstake/v1beta1/query.proto +// source: tac/liquidstake/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_1badba19848dd753, []int{0} + return fileDescriptor_55af05d4e7012c73, []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_1badba19848dd753, []int{1} + return fileDescriptor_55af05d4e7012c73, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -121,7 +121,7 @@ func (m *QueryLiquidValidatorsRequest) Reset() { *m = QueryLiquidValidat func (m *QueryLiquidValidatorsRequest) String() string { return proto.CompactTextString(m) } func (*QueryLiquidValidatorsRequest) ProtoMessage() {} func (*QueryLiquidValidatorsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1badba19848dd753, []int{2} + return fileDescriptor_55af05d4e7012c73, []int{2} } func (m *QueryLiquidValidatorsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -160,7 +160,7 @@ func (m *QueryLiquidValidatorsResponse) Reset() { *m = QueryLiquidValida func (m *QueryLiquidValidatorsResponse) String() string { return proto.CompactTextString(m) } func (*QueryLiquidValidatorsResponse) ProtoMessage() {} func (*QueryLiquidValidatorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1badba19848dd753, []int{3} + return fileDescriptor_55af05d4e7012c73, []int{3} } func (m *QueryLiquidValidatorsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -204,7 +204,7 @@ func (m *QueryStatesRequest) Reset() { *m = QueryStatesRequest{} } func (m *QueryStatesRequest) String() string { return proto.CompactTextString(m) } func (*QueryStatesRequest) ProtoMessage() {} func (*QueryStatesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1badba19848dd753, []int{4} + return fileDescriptor_55af05d4e7012c73, []int{4} } func (m *QueryStatesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -242,7 +242,7 @@ func (m *QueryStatesResponse) Reset() { *m = QueryStatesResponse{} } func (m *QueryStatesResponse) String() string { return proto.CompactTextString(m) } func (*QueryStatesResponse) ProtoMessage() {} func (*QueryStatesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1badba19848dd753, []int{5} + return fileDescriptor_55af05d4e7012c73, []int{5} } func (m *QueryStatesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -279,51 +279,51 @@ func (m *QueryStatesResponse) GetNetAmountState() NetAmountState { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "pstake.liquidstake.v1beta1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "pstake.liquidstake.v1beta1.QueryParamsResponse") - proto.RegisterType((*QueryLiquidValidatorsRequest)(nil), "pstake.liquidstake.v1beta1.QueryLiquidValidatorsRequest") - proto.RegisterType((*QueryLiquidValidatorsResponse)(nil), "pstake.liquidstake.v1beta1.QueryLiquidValidatorsResponse") - proto.RegisterType((*QueryStatesRequest)(nil), "pstake.liquidstake.v1beta1.QueryStatesRequest") - proto.RegisterType((*QueryStatesResponse)(nil), "pstake.liquidstake.v1beta1.QueryStatesResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "tac.liquidstake.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "tac.liquidstake.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryLiquidValidatorsRequest)(nil), "tac.liquidstake.v1beta1.QueryLiquidValidatorsRequest") + proto.RegisterType((*QueryLiquidValidatorsResponse)(nil), "tac.liquidstake.v1beta1.QueryLiquidValidatorsResponse") + proto.RegisterType((*QueryStatesRequest)(nil), "tac.liquidstake.v1beta1.QueryStatesRequest") + proto.RegisterType((*QueryStatesResponse)(nil), "tac.liquidstake.v1beta1.QueryStatesResponse") } func init() { - proto.RegisterFile("pstake/liquidstake/v1beta1/query.proto", fileDescriptor_1badba19848dd753) -} - -var fileDescriptor_1badba19848dd753 = []byte{ - // 486 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcf, 0x8b, 0xd3, 0x40, - 0x14, 0xee, 0xb8, 0x6e, 0x0f, 0xb3, 0x20, 0x75, 0x5c, 0x70, 0x09, 0x6b, 0x5c, 0x82, 0x2c, 0xa5, - 0x68, 0xc6, 0xd6, 0x8b, 0x5e, 0x44, 0xf7, 0x2c, 0xfe, 0x58, 0x41, 0x65, 0x2f, 0x65, 0xda, 0x7d, - 0xc4, 0x60, 0x33, 0x93, 0x66, 0x5e, 0x82, 0x7b, 0x13, 0xf1, 0x0f, 0x10, 0xc4, 0xff, 0xc3, 0x9b, - 0xff, 0xc2, 0x1e, 0x0b, 0x5e, 0x3c, 0x89, 0xb4, 0x82, 0xff, 0x82, 0x47, 0xe9, 0xcc, 0x58, 0x9b, - 0x4a, 0x63, 0xd8, 0x53, 0x86, 0x37, 0xdf, 0x7b, 0xdf, 0x37, 0xdf, 0xfb, 0x42, 0xf7, 0x53, 0x8d, - 0xe2, 0x15, 0xf0, 0x51, 0x3c, 0xce, 0xe3, 0x63, 0x7b, 0x2e, 0xba, 0x03, 0x40, 0xd1, 0xe5, 0xe3, - 0x1c, 0xb2, 0x93, 0x30, 0xcd, 0x14, 0x2a, 0xe6, 0x59, 0x5c, 0xb8, 0x84, 0x0b, 0x1d, 0xce, 0xdb, - 0x8d, 0x94, 0x8a, 0x46, 0xc0, 0x45, 0x1a, 0x73, 0x21, 0xa5, 0x42, 0x81, 0xb1, 0x92, 0xda, 0x76, - 0x7a, 0xd7, 0x2b, 0x18, 0x96, 0xa7, 0x59, 0xf4, 0x76, 0xa4, 0x22, 0x65, 0x8e, 0x7c, 0x7e, 0x72, - 0xd5, 0xcb, 0x43, 0xa5, 0x13, 0xa5, 0x79, 0xa2, 0x23, 0x5e, 0x74, 0xe7, 0x1f, 0x7b, 0x11, 0x6c, - 0x53, 0xf6, 0x64, 0xae, 0xf2, 0xb1, 0xc8, 0x44, 0xa2, 0x0f, 0x61, 0x9c, 0x83, 0xc6, 0xe0, 0x39, - 0xbd, 0x54, 0xaa, 0xea, 0x54, 0x49, 0x0d, 0xec, 0x1e, 0x6d, 0xa6, 0xa6, 0xb2, 0x43, 0xf6, 0x48, - 0x7b, 0xab, 0x17, 0x84, 0xeb, 0x1f, 0x15, 0xda, 0xde, 0x83, 0xf3, 0xa7, 0xdf, 0xae, 0x36, 0x0e, - 0x5d, 0x5f, 0xe0, 0xd3, 0x5d, 0x33, 0xf8, 0x81, 0x69, 0x78, 0x26, 0x46, 0xf1, 0xb1, 0x40, 0x95, - 0x2d, 0x88, 0xdf, 0x11, 0x7a, 0x65, 0x0d, 0xc0, 0x69, 0x18, 0xd2, 0x8b, 0x96, 0xad, 0x5f, 0x2c, - 0x2e, 0x77, 0xc8, 0xde, 0x46, 0x7b, 0xab, 0x77, 0xb3, 0x4a, 0xce, 0xca, 0xc0, 0xa7, 0x28, 0x10, - 0x9c, 0xb8, 0xd6, 0x68, 0x85, 0x6c, 0xe1, 0x8a, 0x41, 0x2d, 0xc4, 0x8d, 0x9d, 0x2b, 0x7f, 0xaa, - 0x4e, 0xd1, 0x11, 0x6d, 0x49, 0xc0, 0xbe, 0x48, 0x54, 0x2e, 0xb1, 0xaf, 0xe7, 0x97, 0xce, 0x9f, - 0x4e, 0x95, 0xa0, 0x87, 0x80, 0xf7, 0x4d, 0xcb, 0xb2, 0x94, 0x0b, 0xb2, 0x54, 0xed, 0xfd, 0xda, - 0xa0, 0x9b, 0x86, 0x93, 0x7d, 0x24, 0xb4, 0x69, 0x2d, 0x65, 0x61, 0xd5, 0xd8, 0x7f, 0xb7, 0xe9, - 0xf1, 0xda, 0x78, 0xfb, 0xa2, 0xa0, 0xf3, 0xf6, 0xcb, 0x8f, 0x0f, 0xe7, 0xae, 0xb1, 0x80, 0x57, - 0x44, 0xcf, 0x6e, 0x94, 0x7d, 0x26, 0xb4, 0xb5, 0xba, 0x2c, 0x76, 0xfb, 0xbf, 0x8c, 0x6b, 0x02, - 0xe0, 0xdd, 0x39, 0x43, 0xa7, 0x53, 0x1d, 0x1a, 0xd5, 0x6d, 0xb6, 0x5f, 0xa5, 0xfa, 0x6f, 0x68, - 0x8c, 0xa3, 0x76, 0x95, 0x35, 0x1c, 0x2d, 0x25, 0xa1, 0x86, 0xa3, 0xe5, 0x8c, 0xd4, 0x73, 0xd4, - 0x44, 0x47, 0x7b, 0x9b, 0x6f, 0x7e, 0x7e, 0xea, 0x90, 0x83, 0x17, 0xa7, 0x53, 0x9f, 0x4c, 0xa6, - 0x3e, 0xf9, 0x3e, 0xf5, 0xc9, 0xfb, 0x99, 0xdf, 0x98, 0xcc, 0xfc, 0xc6, 0xd7, 0x99, 0xdf, 0x38, - 0xba, 0x1b, 0xc5, 0xf8, 0x32, 0x1f, 0x84, 0x43, 0x95, 0xf0, 0x14, 0x32, 0x1d, 0x6b, 0x04, 0x39, - 0x84, 0x47, 0x12, 0xdc, 0xf4, 0x1b, 0x52, 0x60, 0x5c, 0x00, 0x2f, 0x7a, 0xfc, 0x75, 0x89, 0x09, - 0x4f, 0x52, 0xd0, 0x83, 0xa6, 0xf9, 0xf5, 0x6f, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xca, 0xbf, - 0xae, 0xde, 0xbb, 0x04, 0x00, 0x00, + proto.RegisterFile("tac/liquidstake/v1beta1/query.proto", fileDescriptor_55af05d4e7012c73) +} + +var fileDescriptor_55af05d4e7012c73 = []byte{ + // 482 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xae, 0x19, 0xeb, 0xc1, 0x93, 0x50, 0x31, 0x93, 0x36, 0x45, 0x23, 0x1d, 0x9d, 0xd0, 0x06, + 0x63, 0xb1, 0xda, 0x09, 0x6e, 0x1c, 0xb6, 0x33, 0x20, 0x18, 0x08, 0x24, 0x2e, 0xc5, 0xcd, 0xac, + 0x34, 0xa2, 0xb1, 0xd3, 0xf8, 0xa5, 0x5a, 0x39, 0x01, 0x67, 0x0e, 0x48, 0xfc, 0x0f, 0xc4, 0xcf, + 0xd8, 0x71, 0x12, 0x17, 0x2e, 0x20, 0xd4, 0x22, 0xf1, 0x37, 0x50, 0x6c, 0x13, 0x9a, 0x22, 0xb3, + 0x72, 0x8a, 0xf5, 0xfc, 0xbd, 0xef, 0x7d, 0xfe, 0xbe, 0x17, 0xbc, 0x05, 0x2c, 0xa4, 0x83, 0x78, + 0x98, 0xc7, 0xc7, 0x0a, 0xd8, 0x4b, 0x4e, 0x47, 0xed, 0x1e, 0x07, 0xd6, 0xa6, 0xc3, 0x9c, 0x67, + 0xe3, 0x20, 0xcd, 0x24, 0x48, 0xb2, 0x06, 0x2c, 0x0c, 0x66, 0x40, 0x81, 0x05, 0x79, 0x1b, 0x91, + 0x94, 0xd1, 0x80, 0x53, 0x96, 0xc6, 0x94, 0x09, 0x21, 0x81, 0x41, 0x2c, 0x85, 0x32, 0x6d, 0xde, + 0x0d, 0x17, 0xf7, 0x2c, 0x95, 0x81, 0xae, 0x46, 0x32, 0x92, 0xfa, 0x48, 0x8b, 0x93, 0xad, 0xae, + 0x85, 0x52, 0x25, 0x52, 0xd1, 0x44, 0x45, 0x74, 0xd4, 0x2e, 0x3e, 0xe6, 0xa2, 0xb5, 0x8a, 0xc9, + 0xa3, 0x42, 0xdf, 0x43, 0x96, 0xb1, 0x44, 0x1d, 0xf1, 0x61, 0xce, 0x15, 0xb4, 0x9e, 0xe0, 0x2b, + 0x95, 0xaa, 0x4a, 0xa5, 0x50, 0x9c, 0xdc, 0xc5, 0xf5, 0x54, 0x57, 0xd6, 0xd1, 0x26, 0xda, 0x59, + 0xe9, 0x34, 0x03, 0xc7, 0x73, 0x02, 0xd3, 0x78, 0x78, 0xf1, 0xf4, 0x5b, 0xb3, 0x76, 0x64, 0x9b, + 0x5a, 0x3e, 0xde, 0xd0, 0xac, 0xf7, 0x74, 0xc3, 0x53, 0x36, 0x88, 0x8f, 0x19, 0xc8, 0xac, 0x9c, + 0xfa, 0x06, 0xe1, 0xab, 0x0e, 0x80, 0x15, 0xf0, 0x02, 0x5f, 0x36, 0xd3, 0xba, 0xa3, 0xf2, 0x72, + 0x1d, 0x6d, 0x2e, 0xed, 0xac, 0x74, 0xf6, 0x9c, 0x5a, 0xe6, 0xd8, 0x1e, 0x03, 0x03, 0x6e, 0x95, + 0x35, 0x06, 0x73, 0x93, 0x4a, 0x3f, 0x34, 0xaa, 0x54, 0x26, 0xac, 0x1f, 0xbf, 0xab, 0x56, 0xce, + 0x33, 0xdc, 0x10, 0x1c, 0xba, 0x2c, 0x91, 0xb9, 0x80, 0xae, 0x2a, 0x2e, 0xad, 0x33, 0xdb, 0x4e, + 0x35, 0x0f, 0x38, 0x1c, 0x68, 0xfc, 0xac, 0x8e, 0x4b, 0xa2, 0x52, 0xed, 0x7c, 0x5d, 0xc2, 0xcb, + 0x7a, 0x20, 0x79, 0x87, 0x70, 0xdd, 0x98, 0x49, 0x76, 0x9d, 0x9c, 0x7f, 0x27, 0xe8, 0xdd, 0x5a, + 0x0c, 0x6c, 0x1e, 0xd2, 0xda, 0x7e, 0xfb, 0xf9, 0xc7, 0x87, 0x0b, 0xd7, 0x48, 0x93, 0xba, 0x16, + 0xcd, 0x44, 0x48, 0x3e, 0x22, 0xdc, 0x98, 0x4f, 0x87, 0xdc, 0xfe, 0xf7, 0x2c, 0x47, 0xdc, 0xde, + 0x9d, 0xff, 0x6d, 0xb3, 0x62, 0x77, 0xb5, 0xd8, 0xeb, 0x64, 0xcb, 0x29, 0xf6, 0xcf, 0x72, 0x68, + 0xff, 0x4c, 0x6a, 0xe7, 0xf9, 0x57, 0x49, 0xfc, 0x3c, 0xff, 0xaa, 0x8b, 0xb0, 0x80, 0x7f, 0x7a, + 0x39, 0x94, 0xb7, 0xfc, 0xfa, 0xe7, 0xa7, 0x9b, 0xe8, 0xf0, 0xfe, 0xe9, 0xc4, 0x47, 0x67, 0x13, + 0x1f, 0x7d, 0x9f, 0xf8, 0xe8, 0xfd, 0xd4, 0xaf, 0x9d, 0x4d, 0xfd, 0xda, 0x97, 0xa9, 0x5f, 0x7b, + 0xbe, 0x1f, 0xc5, 0xd0, 0xcf, 0x7b, 0x41, 0x28, 0x13, 0x7a, 0xa0, 0xd2, 0x3e, 0xcf, 0xf8, 0xde, + 0xc9, 0xf8, 0x55, 0xc1, 0x1b, 0xf6, 0x59, 0x2c, 0xe8, 0x49, 0x85, 0x1e, 0xc6, 0x29, 0x57, 0xbd, + 0xba, 0xfe, 0x97, 0xf7, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x37, 0x99, 0x1c, 0x85, 0x83, 0x04, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -357,7 +357,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, "/pstake.liquidstake.v1beta1.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -366,7 +366,7 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . func (c *queryClient) LiquidValidators(ctx context.Context, in *QueryLiquidValidatorsRequest, opts ...grpc.CallOption) (*QueryLiquidValidatorsResponse, error) { out := new(QueryLiquidValidatorsResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Query/LiquidValidators", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Query/LiquidValidators", in, out, opts...) if err != nil { return nil, err } @@ -375,7 +375,7 @@ func (c *queryClient) LiquidValidators(ctx context.Context, in *QueryLiquidValid func (c *queryClient) States(ctx context.Context, in *QueryStatesRequest, opts ...grpc.CallOption) (*QueryStatesResponse, error) { out := new(QueryStatesResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Query/States", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Query/States", in, out, opts...) if err != nil { return nil, err } @@ -421,7 +421,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Query/Params", + FullMethod: "/tac.liquidstake.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -439,7 +439,7 @@ func _Query_LiquidValidators_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Query/LiquidValidators", + FullMethod: "/tac.liquidstake.v1beta1.Query/LiquidValidators", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).LiquidValidators(ctx, req.(*QueryLiquidValidatorsRequest)) @@ -457,7 +457,7 @@ func _Query_States_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Query/States", + FullMethod: "/tac.liquidstake.v1beta1.Query/States", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).States(ctx, req.(*QueryStatesRequest)) @@ -466,7 +466,7 @@ func _Query_States_Handler(srv interface{}, ctx context.Context, dec func(interf } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "pstake.liquidstake.v1beta1.Query", + ServiceName: "tac.liquidstake.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -483,7 +483,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "pstake/liquidstake/v1beta1/query.proto", + Metadata: "tac/liquidstake/v1beta1/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/liquidstake/types/query.pb.gw.go b/x/liquidstake/types/query.pb.gw.go index 6592e01..d261869 100644 --- a/x/liquidstake/types/query.pb.gw.go +++ b/x/liquidstake/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: pstake/liquidstake/v1beta1/query.proto +// source: tac/liquidstake/v1beta1/query.proto /* Package types is a reverse proxy. @@ -267,11 +267,11 @@ 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{"pstake", "liquidstake", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tac", "liquidstake", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_LiquidValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"pstake", "liquidstake", "v1beta1", "validators"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_LiquidValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tac", "liquidstake", "v1beta1", "validators"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_States_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"pstake", "liquidstake", "v1beta1", "states"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_States_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tac", "liquidstake", "v1beta1", "states"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/liquidstake/types/tx.pb.go b/x/liquidstake/types/tx.pb.go index fb34000..6015871 100644 --- a/x/liquidstake/types/tx.pb.go +++ b/x/liquidstake/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pstake/liquidstake/v1beta1/tx.proto +// source: tac/liquidstake/v1beta1/tx.proto package types @@ -47,7 +47,7 @@ func (m *MsgLiquidStake) Reset() { *m = MsgLiquidStake{} } func (m *MsgLiquidStake) String() string { return proto.CompactTextString(m) } func (*MsgLiquidStake) ProtoMessage() {} func (*MsgLiquidStake) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{0} + return fileDescriptor_a8b8c4e8f1546252, []int{0} } func (m *MsgLiquidStake) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -84,7 +84,7 @@ func (m *MsgLiquidStakeResponse) Reset() { *m = MsgLiquidStakeResponse{} func (m *MsgLiquidStakeResponse) String() string { return proto.CompactTextString(m) } func (*MsgLiquidStakeResponse) ProtoMessage() {} func (*MsgLiquidStakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{1} + return fileDescriptor_a8b8c4e8f1546252, []int{1} } func (m *MsgLiquidStakeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -114,7 +114,7 @@ func (m *MsgLiquidStakeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgLiquidStakeResponse proto.InternalMessageInfo // MsgStakeToLP defines a SDK message for performing an LSM-transfer of staked -// XPRT into stkXPRT with locking into an LP. +// TAC into gTAC with locking into an LP. type MsgStakeToLP struct { DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` @@ -126,7 +126,7 @@ func (m *MsgStakeToLP) Reset() { *m = MsgStakeToLP{} } func (m *MsgStakeToLP) String() string { return proto.CompactTextString(m) } func (*MsgStakeToLP) ProtoMessage() {} func (*MsgStakeToLP) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{2} + return fileDescriptor_a8b8c4e8f1546252, []int{2} } func (m *MsgStakeToLP) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -163,7 +163,7 @@ func (m *MsgStakeToLPResponse) Reset() { *m = MsgStakeToLPResponse{} } func (m *MsgStakeToLPResponse) String() string { return proto.CompactTextString(m) } func (*MsgStakeToLPResponse) ProtoMessage() {} func (*MsgStakeToLPResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{3} + return fileDescriptor_a8b8c4e8f1546252, []int{3} } func (m *MsgStakeToLPResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,7 +203,7 @@ func (m *MsgLiquidUnstake) Reset() { *m = MsgLiquidUnstake{} } func (m *MsgLiquidUnstake) String() string { return proto.CompactTextString(m) } func (*MsgLiquidUnstake) ProtoMessage() {} func (*MsgLiquidUnstake) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{4} + return fileDescriptor_a8b8c4e8f1546252, []int{4} } func (m *MsgLiquidUnstake) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -241,7 +241,7 @@ func (m *MsgLiquidUnstakeResponse) Reset() { *m = MsgLiquidUnstakeRespon func (m *MsgLiquidUnstakeResponse) String() string { return proto.CompactTextString(m) } func (*MsgLiquidUnstakeResponse) ProtoMessage() {} func (*MsgLiquidUnstakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{5} + return fileDescriptor_a8b8c4e8f1546252, []int{5} } func (m *MsgLiquidUnstakeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -292,7 +292,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{6} + return fileDescriptor_a8b8c4e8f1546252, []int{6} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -329,7 +329,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{7} + return fileDescriptor_a8b8c4e8f1546252, []int{7} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -371,7 +371,7 @@ func (m *MsgUpdateWhitelistedValidators) Reset() { *m = MsgUpdateWhiteli func (m *MsgUpdateWhitelistedValidators) String() string { return proto.CompactTextString(m) } func (*MsgUpdateWhitelistedValidators) ProtoMessage() {} func (*MsgUpdateWhitelistedValidators) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{8} + return fileDescriptor_a8b8c4e8f1546252, []int{8} } func (m *MsgUpdateWhitelistedValidators) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -411,7 +411,7 @@ func (m *MsgUpdateWhitelistedValidatorsResponse) Reset() { func (m *MsgUpdateWhitelistedValidatorsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateWhitelistedValidatorsResponse) ProtoMessage() {} func (*MsgUpdateWhitelistedValidatorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{9} + return fileDescriptor_a8b8c4e8f1546252, []int{9} } func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -452,7 +452,7 @@ func (m *MsgSetModulePaused) Reset() { *m = MsgSetModulePaused{} } func (m *MsgSetModulePaused) String() string { return proto.CompactTextString(m) } func (*MsgSetModulePaused) ProtoMessage() {} func (*MsgSetModulePaused) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{10} + return fileDescriptor_a8b8c4e8f1546252, []int{10} } func (m *MsgSetModulePaused) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -490,7 +490,7 @@ func (m *MsgSetModulePausedResponse) Reset() { *m = MsgSetModulePausedRe func (m *MsgSetModulePausedResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetModulePausedResponse) ProtoMessage() {} func (*MsgSetModulePausedResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d90501ae6d9f0009, []int{11} + return fileDescriptor_a8b8c4e8f1546252, []int{11} } func (m *MsgSetModulePausedResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -520,80 +520,78 @@ func (m *MsgSetModulePausedResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetModulePausedResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgLiquidStake)(nil), "pstake.liquidstake.v1beta1.MsgLiquidStake") - proto.RegisterType((*MsgLiquidStakeResponse)(nil), "pstake.liquidstake.v1beta1.MsgLiquidStakeResponse") - proto.RegisterType((*MsgStakeToLP)(nil), "pstake.liquidstake.v1beta1.MsgStakeToLP") - proto.RegisterType((*MsgStakeToLPResponse)(nil), "pstake.liquidstake.v1beta1.MsgStakeToLPResponse") - proto.RegisterType((*MsgLiquidUnstake)(nil), "pstake.liquidstake.v1beta1.MsgLiquidUnstake") - proto.RegisterType((*MsgLiquidUnstakeResponse)(nil), "pstake.liquidstake.v1beta1.MsgLiquidUnstakeResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "pstake.liquidstake.v1beta1.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "pstake.liquidstake.v1beta1.MsgUpdateParamsResponse") - proto.RegisterType((*MsgUpdateWhitelistedValidators)(nil), "pstake.liquidstake.v1beta1.MsgUpdateWhitelistedValidators") - proto.RegisterType((*MsgUpdateWhitelistedValidatorsResponse)(nil), "pstake.liquidstake.v1beta1.MsgUpdateWhitelistedValidatorsResponse") - proto.RegisterType((*MsgSetModulePaused)(nil), "pstake.liquidstake.v1beta1.MsgSetModulePaused") - proto.RegisterType((*MsgSetModulePausedResponse)(nil), "pstake.liquidstake.v1beta1.MsgSetModulePausedResponse") -} - -func init() { - proto.RegisterFile("pstake/liquidstake/v1beta1/tx.proto", fileDescriptor_d90501ae6d9f0009) -} - -var fileDescriptor_d90501ae6d9f0009 = []byte{ - // 860 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcd, 0x4e, 0xdb, 0x4a, - 0x14, 0x8e, 0xc3, 0x8f, 0xc8, 0x84, 0x5f, 0x8b, 0x0b, 0xc1, 0x20, 0x07, 0xf9, 0x4a, 0x57, 0x51, - 0x2e, 0xd8, 0x10, 0x2a, 0xaa, 0xa6, 0xea, 0x0f, 0x69, 0xd9, 0x11, 0x15, 0x05, 0x68, 0xab, 0x6e, - 0x22, 0x27, 0x9e, 0x9a, 0x51, 0x63, 0x8f, 0x9b, 0x99, 0x04, 0xd8, 0x55, 0x5d, 0x55, 0x5d, 0x54, - 0xbc, 0x40, 0x25, 0x16, 0x7d, 0x00, 0x16, 0x7d, 0x83, 0x6e, 0xd8, 0x15, 0xb5, 0x9b, 0xae, 0xda, - 0x0a, 0xd4, 0xd2, 0xc7, 0xa8, 0xec, 0xb1, 0x1d, 0x3b, 0x84, 0x24, 0xa0, 0x2e, 0xba, 0x01, 0x7b, - 0xce, 0x77, 0xbe, 0x73, 0xbe, 0x6f, 0xe6, 0x8c, 0x03, 0xfe, 0xb5, 0x08, 0x55, 0x9f, 0x41, 0xa5, - 0x82, 0x9e, 0xd7, 0x90, 0xc6, 0x9e, 0xeb, 0x8b, 0x25, 0x48, 0xd5, 0x45, 0x85, 0xee, 0xca, 0x56, - 0x15, 0x53, 0xcc, 0x0b, 0x0c, 0x24, 0x07, 0x40, 0xb2, 0x0b, 0x12, 0xc6, 0x75, 0xac, 0x63, 0x07, - 0xa6, 0xd8, 0x4f, 0x2c, 0x43, 0x98, 0x2a, 0x63, 0x62, 0x60, 0x52, 0x64, 0x01, 0xf6, 0xe2, 0x86, - 0x44, 0xf6, 0xa6, 0x94, 0x54, 0xd2, 0x28, 0x55, 0xc6, 0xc8, 0x74, 0xe3, 0x93, 0x6e, 0xdc, 0x20, - 0xba, 0x52, 0x5f, 0xb4, 0xff, 0xb9, 0x81, 0xa4, 0x8e, 0xb1, 0x5e, 0x81, 0x8a, 0xf3, 0x56, 0xaa, - 0x3d, 0x55, 0x28, 0x32, 0x20, 0xa1, 0xaa, 0x61, 0xb9, 0x80, 0xb9, 0x36, 0x5a, 0x82, 0xad, 0x33, - 0xf4, 0x98, 0x6a, 0x20, 0x13, 0x2b, 0xce, 0x5f, 0xb6, 0x24, 0x7d, 0xe4, 0xc0, 0x70, 0x9e, 0xe8, - 0x6b, 0x0e, 0x76, 0xc3, 0xc6, 0xf2, 0xab, 0x60, 0x4c, 0x83, 0x15, 0xa8, 0xab, 0x14, 0x57, 0x8b, - 0xaa, 0xa6, 0x55, 0x21, 0x21, 0x09, 0x6e, 0x96, 0x4b, 0xc5, 0x72, 0x89, 0x4f, 0xef, 0xe7, 0xc7, - 0x5d, 0x69, 0x2b, 0x2c, 0xb2, 0x41, 0xab, 0xc8, 0xd4, 0x0b, 0xa3, 0x7e, 0x8a, 0xbb, 0xce, 0x5f, - 0x07, 0xfd, 0xaa, 0x81, 0x6b, 0x26, 0x4d, 0x44, 0x67, 0xb9, 0x54, 0x3c, 0x33, 0x25, 0xbb, 0x89, - 0xb6, 0x0b, 0x9e, 0x97, 0xf2, 0x3d, 0x8c, 0xcc, 0x5c, 0xef, 0xd1, 0xd7, 0x64, 0xa4, 0xe0, 0xc2, - 0xb3, 0xb7, 0x5e, 0x1d, 0x24, 0x23, 0xbf, 0x0e, 0x92, 0x91, 0x97, 0x67, 0x87, 0xe9, 0xf3, 0xad, - 0xbc, 0x3e, 0x3b, 0x4c, 0x0b, 0x41, 0xbd, 0xe1, 0xf6, 0xa5, 0x04, 0x98, 0x08, 0xaf, 0x14, 0x20, - 0xb1, 0xb0, 0x49, 0xa0, 0xf4, 0x23, 0x0a, 0x06, 0xf3, 0x44, 0x77, 0x16, 0x37, 0xf1, 0xda, 0xfa, - 0x9f, 0x52, 0xba, 0x0a, 0xc6, 0xea, 0x6a, 0x05, 0x69, 0x21, 0x9a, 0x68, 0x27, 0x1a, 0x3f, 0xc5, - 0xa3, 0xb9, 0x0f, 0x86, 0x1c, 0x41, 0x5a, 0xd1, 0xf5, 0xad, 0xa7, 0x3b, 0xdf, 0x06, 0x59, 0xd6, - 0x8a, 0x93, 0x64, 0xb3, 0x30, 0x73, 0x3c, 0x96, 0xde, 0x2e, 0x59, 0x58, 0x16, 0x63, 0xc9, 0xde, - 0xec, 0xbc, 0x07, 0x89, 0xa6, 0x3d, 0xf0, 0x6d, 0x95, 0x26, 0xc0, 0x78, 0xf0, 0xdd, 0xf7, 0xff, - 0x33, 0x07, 0x46, 0xfd, 0xad, 0xd9, 0x32, 0xc9, 0x5f, 0x71, 0xda, 0xee, 0x74, 0x56, 0x3a, 0xd3, - 0xf2, 0xb4, 0xb9, 0x02, 0x24, 0x04, 0x12, 0xcd, 0x6b, 0x9e, 0x62, 0x3e, 0x0f, 0x46, 0xca, 0xd8, - 0xb0, 0x2a, 0x90, 0x22, 0x6c, 0x16, 0xed, 0xe1, 0x75, 0xa4, 0xc5, 0x33, 0x82, 0xcc, 0x26, 0x5b, - 0xf6, 0x26, 0x5b, 0xde, 0xf4, 0x26, 0x3b, 0x37, 0x60, 0xf7, 0xb7, 0xff, 0x2d, 0xc9, 0x15, 0x86, - 0x1b, 0xc9, 0x76, 0x58, 0xfa, 0xc0, 0x81, 0x91, 0x3c, 0xd1, 0xb7, 0x2c, 0x4d, 0xa5, 0x70, 0x5d, - 0xad, 0xaa, 0x06, 0xe1, 0x97, 0x41, 0x4c, 0xad, 0xd1, 0x6d, 0x5c, 0x45, 0x74, 0xaf, 0xa3, 0x6f, - 0x0d, 0x28, 0x7f, 0x17, 0xf4, 0x5b, 0x0e, 0x83, 0x6b, 0x98, 0x24, 0x5f, 0x7c, 0xe3, 0xc9, 0xac, - 0x96, 0xe7, 0x1c, 0xcb, 0xcb, 0x2e, 0x07, 0x9d, 0x6b, 0x30, 0xdb, 0x8e, 0x4d, 0x37, 0x39, 0x16, - 0xec, 0x58, 0x9a, 0x02, 0x93, 0x4d, 0x4b, 0xfe, 0x09, 0x79, 0x13, 0x05, 0xa2, 0x1f, 0x7b, 0xb4, - 0x8d, 0x28, 0xac, 0x20, 0x42, 0xa1, 0xf6, 0xd0, 0x9b, 0x95, 0xab, 0xeb, 0x35, 0xc0, 0xc4, 0x4e, - 0x83, 0xb0, 0xe8, 0x4f, 0x9f, 0xad, 0xbf, 0x27, 0x15, 0xcf, 0x2c, 0xb4, 0xd3, 0xdf, 0xaa, 0x15, - 0xd7, 0x8d, 0x7f, 0x76, 0x5a, 0xb5, 0x99, 0x5d, 0xbd, 0xd8, 0x9c, 0x74, 0x4b, 0x73, 0x5a, 0xaa, - 0x95, 0x52, 0xe0, 0xbf, 0xf6, 0x08, 0xdf, 0xba, 0x77, 0x1c, 0xe0, 0xed, 0xa9, 0x83, 0x34, 0x8f, - 0xb5, 0x5a, 0x05, 0xae, 0xab, 0x35, 0x02, 0xb5, 0x2b, 0xdb, 0x35, 0x0d, 0x62, 0x88, 0x14, 0x2d, - 0x87, 0xc4, 0x39, 0x21, 0x03, 0x85, 0x01, 0x44, 0x18, 0x69, 0xf6, 0xc6, 0xc5, 0xe2, 0xc4, 0xe6, - 0x5b, 0x21, 0xdc, 0x8f, 0x34, 0x03, 0x84, 0xf3, 0xab, 0x9e, 0x88, 0xcc, 0xcf, 0x3e, 0xd0, 0x93, - 0x27, 0x3a, 0x6f, 0x80, 0x78, 0xf0, 0x8b, 0x94, 0x6e, 0xb7, 0x37, 0xe1, 0xcb, 0x5e, 0xc8, 0x74, - 0x8f, 0xf5, 0xc7, 0x94, 0x80, 0xa1, 0xf0, 0xa5, 0x34, 0xd7, 0x15, 0x89, 0x8b, 0x16, 0xae, 0x5d, - 0x06, 0xed, 0x17, 0xd5, 0x41, 0xac, 0xf1, 0x25, 0x4a, 0x75, 0xa0, 0xf0, 0x91, 0xc2, 0x42, 0xb7, - 0x48, 0xbf, 0x90, 0x05, 0x06, 0x43, 0x37, 0xc6, 0xff, 0x1d, 0x18, 0x82, 0x60, 0x61, 0xe9, 0x12, - 0x60, 0xbf, 0xe2, 0x5b, 0x0e, 0x4c, 0xb7, 0x9b, 0xe1, 0x6c, 0x57, 0xa4, 0x2d, 0x73, 0x85, 0xdc, - 0xd5, 0x73, 0xfd, 0xfe, 0xf6, 0xc0, 0x48, 0xf3, 0x9c, 0xc8, 0x9d, 0x6c, 0x0d, 0xe3, 0x85, 0xe5, - 0xcb, 0xe1, 0xbd, 0xd2, 0x42, 0xdf, 0x8b, 0xb3, 0xc3, 0x34, 0x97, 0x7b, 0x7c, 0x74, 0x22, 0x72, - 0xc7, 0x27, 0x22, 0xf7, 0xfd, 0x44, 0xe4, 0xf6, 0x4f, 0xc5, 0xc8, 0xf1, 0xa9, 0x18, 0xf9, 0x72, - 0x2a, 0x46, 0x9e, 0xdc, 0xd6, 0x11, 0xdd, 0xae, 0x95, 0xe4, 0x32, 0x36, 0x14, 0x0b, 0x56, 0x89, - 0xad, 0xc1, 0x2c, 0xc3, 0x07, 0x26, 0x54, 0x58, 0xc5, 0x79, 0x53, 0xa5, 0xa8, 0x0e, 0x95, 0x7a, - 0x46, 0xd9, 0x0d, 0xfd, 0xee, 0xa3, 0x7b, 0x16, 0x24, 0xa5, 0x7e, 0xe7, 0x8b, 0xb2, 0xf4, 0x3b, - 0x00, 0x00, 0xff, 0xff, 0x90, 0x3b, 0x26, 0x67, 0xe6, 0x0a, 0x00, 0x00, + proto.RegisterType((*MsgLiquidStake)(nil), "tac.liquidstake.v1beta1.MsgLiquidStake") + proto.RegisterType((*MsgLiquidStakeResponse)(nil), "tac.liquidstake.v1beta1.MsgLiquidStakeResponse") + proto.RegisterType((*MsgStakeToLP)(nil), "tac.liquidstake.v1beta1.MsgStakeToLP") + proto.RegisterType((*MsgStakeToLPResponse)(nil), "tac.liquidstake.v1beta1.MsgStakeToLPResponse") + proto.RegisterType((*MsgLiquidUnstake)(nil), "tac.liquidstake.v1beta1.MsgLiquidUnstake") + proto.RegisterType((*MsgLiquidUnstakeResponse)(nil), "tac.liquidstake.v1beta1.MsgLiquidUnstakeResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "tac.liquidstake.v1beta1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "tac.liquidstake.v1beta1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgUpdateWhitelistedValidators)(nil), "tac.liquidstake.v1beta1.MsgUpdateWhitelistedValidators") + proto.RegisterType((*MsgUpdateWhitelistedValidatorsResponse)(nil), "tac.liquidstake.v1beta1.MsgUpdateWhitelistedValidatorsResponse") + proto.RegisterType((*MsgSetModulePaused)(nil), "tac.liquidstake.v1beta1.MsgSetModulePaused") + proto.RegisterType((*MsgSetModulePausedResponse)(nil), "tac.liquidstake.v1beta1.MsgSetModulePausedResponse") +} + +func init() { proto.RegisterFile("tac/liquidstake/v1beta1/tx.proto", fileDescriptor_a8b8c4e8f1546252) } + +var fileDescriptor_a8b8c4e8f1546252 = []byte{ + // 859 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4d, 0x4f, 0xe3, 0x46, + 0x18, 0x8e, 0xc3, 0x87, 0xc8, 0x84, 0x4f, 0x8b, 0x42, 0x30, 0xc8, 0x41, 0x96, 0xda, 0x86, 0x54, + 0xb1, 0x9b, 0x20, 0x81, 0x9a, 0x0a, 0x21, 0xd2, 0x72, 0x23, 0x12, 0x0a, 0xd0, 0x4a, 0xbd, 0x44, + 0x13, 0x7b, 0xea, 0x0c, 0x8d, 0x3d, 0x6e, 0x66, 0xc2, 0x47, 0x4f, 0x55, 0x4f, 0x55, 0x7b, 0xe1, + 0xd6, 0x2b, 0x87, 0xfe, 0x00, 0x0e, 0xfb, 0x03, 0x56, 0x7b, 0xe2, 0xb6, 0x68, 0xf7, 0xb2, 0xa7, + 0xdd, 0x15, 0x68, 0xc5, 0xfe, 0x8c, 0x95, 0x3f, 0x63, 0x87, 0x7c, 0x2d, 0xda, 0xc3, 0x5e, 0x80, + 0x79, 0xdf, 0xe7, 0x7d, 0xe6, 0x7d, 0x9e, 0x99, 0x77, 0x0c, 0x58, 0x65, 0x50, 0x55, 0x1a, 0xf8, + 0xf7, 0x16, 0xd6, 0x28, 0x83, 0xbf, 0x21, 0xe5, 0x24, 0x5f, 0x43, 0x0c, 0xe6, 0x15, 0x76, 0x26, + 0x5b, 0x4d, 0xc2, 0x08, 0xbf, 0xc8, 0xa0, 0x2a, 0x87, 0x10, 0xb2, 0x87, 0x10, 0xe6, 0x75, 0xa2, + 0x13, 0x07, 0xa3, 0xd8, 0x7f, 0xb9, 0x70, 0x61, 0x49, 0x25, 0xd4, 0x20, 0xb4, 0xea, 0x26, 0xdc, + 0x85, 0x97, 0x12, 0xdd, 0x95, 0x52, 0x83, 0xb4, 0xbd, 0x8f, 0x4a, 0xb0, 0xe9, 0xe5, 0x17, 0xbd, + 0xbc, 0x41, 0x75, 0xe5, 0x24, 0x6f, 0xff, 0xf2, 0x12, 0x69, 0x9d, 0x10, 0xbd, 0x81, 0x14, 0x67, + 0x55, 0x6b, 0xfd, 0xaa, 0x30, 0x6c, 0x20, 0xca, 0xa0, 0x61, 0x79, 0x80, 0xb5, 0x5e, 0x2a, 0xc2, + 0x7d, 0xbb, 0xd0, 0x39, 0x68, 0x60, 0x93, 0x28, 0xce, 0x4f, 0x37, 0x24, 0x3d, 0xe7, 0xc0, 0x74, + 0x99, 0xea, 0x7b, 0x0e, 0xf6, 0xc0, 0xc6, 0xf2, 0xbb, 0x60, 0x4e, 0x43, 0x0d, 0xa4, 0x43, 0x46, + 0x9a, 0x55, 0xa8, 0x69, 0x4d, 0x44, 0x69, 0x8a, 0x5b, 0xe5, 0x32, 0x89, 0x52, 0xea, 0xc5, 0x93, + 0xdc, 0xbc, 0xa7, 0x6b, 0xc7, 0xcd, 0x1c, 0xb0, 0x26, 0x36, 0xf5, 0xca, 0x6c, 0x50, 0xe2, 0xc5, + 0xf9, 0x4d, 0x30, 0x0e, 0x0d, 0xd2, 0x32, 0x59, 0x2a, 0xbe, 0xca, 0x65, 0x92, 0x85, 0x25, 0xd9, + 0x2b, 0xb4, 0x2d, 0xf0, 0x8d, 0x94, 0x7f, 0x20, 0xd8, 0x2c, 0x8d, 0x5e, 0xbf, 0x4e, 0xc7, 0x2a, + 0x1e, 0xbc, 0xb8, 0xf5, 0xf7, 0x65, 0x3a, 0xf6, 0xfe, 0x32, 0x1d, 0xfb, 0xeb, 0xfe, 0x2a, 0xfb, + 0xb0, 0x95, 0x7f, 0xee, 0xaf, 0xb2, 0x42, 0x58, 0x6f, 0xb4, 0x7d, 0x29, 0x05, 0x16, 0xa2, 0x91, + 0x0a, 0xa2, 0x16, 0x31, 0x29, 0x92, 0xde, 0xc5, 0xc1, 0x64, 0x99, 0xea, 0x4e, 0xf0, 0x90, 0xec, + 0xed, 0x7f, 0x2a, 0xa5, 0xbb, 0x60, 0xee, 0x04, 0x36, 0xb0, 0x16, 0xa1, 0x89, 0x0f, 0xa2, 0x09, + 0x4a, 0x7c, 0x9a, 0x1f, 0xc1, 0x94, 0x23, 0x48, 0xab, 0x7a, 0xbe, 0x8d, 0x0c, 0xe7, 0xdb, 0xa4, + 0x5b, 0xb5, 0xe3, 0x14, 0xd9, 0x2c, 0xae, 0x39, 0x3e, 0xcb, 0xe8, 0x90, 0x2c, 0x6e, 0x95, 0xcb, + 0x52, 0xfc, 0x7e, 0xf0, 0x19, 0xa4, 0x3a, 0xce, 0x20, 0xb0, 0x55, 0x5a, 0x00, 0xf3, 0xe1, 0x75, + 0xe0, 0xff, 0x4b, 0x0e, 0xcc, 0x06, 0x47, 0x73, 0x64, 0xd2, 0xcf, 0xe2, 0xb6, 0x6d, 0x0f, 0x56, + 0xba, 0xd2, 0xf5, 0xb6, 0x79, 0x02, 0x24, 0x0c, 0x52, 0x9d, 0x31, 0x5f, 0x31, 0x5f, 0x06, 0x33, + 0x2a, 0x31, 0xac, 0x06, 0x62, 0x98, 0x98, 0x55, 0x7b, 0x72, 0x1d, 0x69, 0xc9, 0x82, 0x20, 0xbb, + 0x63, 0x2d, 0xfb, 0x63, 0x2d, 0x1f, 0xfa, 0x63, 0x5d, 0x9a, 0xb0, 0xfb, 0xbb, 0x78, 0x93, 0xe6, + 0x2a, 0xd3, 0xed, 0x62, 0x3b, 0x2d, 0x3d, 0xe5, 0xc0, 0x4c, 0x99, 0xea, 0x47, 0x96, 0x06, 0x19, + 0xda, 0x87, 0x4d, 0x68, 0x50, 0x7e, 0x03, 0x24, 0x60, 0x8b, 0xd5, 0x49, 0x13, 0xb3, 0xf3, 0x81, + 0xbe, 0xb5, 0xa1, 0xfc, 0x16, 0x18, 0xb7, 0x1c, 0x06, 0xcf, 0xb0, 0xb4, 0xdc, 0xe3, 0xad, 0x93, + 0xdd, 0x8d, 0x7c, 0xdb, 0xdc, 0xa2, 0xe2, 0x46, 0xd8, 0xb6, 0x36, 0xad, 0x6d, 0xd7, 0x72, 0x87, + 0x5d, 0xe1, 0x76, 0xa5, 0x25, 0xb0, 0xd8, 0x11, 0x0a, 0xae, 0xc7, 0xbf, 0x71, 0x20, 0x06, 0xb9, + 0x9f, 0xeb, 0x98, 0xa1, 0x06, 0xa6, 0x0c, 0x69, 0x3f, 0xf9, 0x83, 0xf2, 0x78, 0xb1, 0xc7, 0x60, + 0xe1, 0xb4, 0x4d, 0x58, 0x0d, 0x46, 0xcf, 0x16, 0x3f, 0x92, 0x49, 0x16, 0x72, 0x3d, 0xc5, 0x77, + 0xeb, 0xc3, 0xb3, 0xe2, 0x8b, 0xd3, 0x6e, 0x3d, 0x16, 0x77, 0x7b, 0x3b, 0x93, 0xed, 0xea, 0x4c, + 0x57, 0xa9, 0x52, 0x06, 0x7c, 0xd5, 0x1f, 0x11, 0xf8, 0xf6, 0x3f, 0x07, 0x78, 0x7b, 0xde, 0x10, + 0x2b, 0x13, 0xad, 0xd5, 0x40, 0xfb, 0xb0, 0x45, 0x91, 0xf6, 0x68, 0xaf, 0x96, 0x41, 0x02, 0xd3, + 0xaa, 0xe5, 0x90, 0x38, 0x77, 0x63, 0xa2, 0x32, 0x81, 0xa9, 0x4b, 0x5a, 0xfc, 0xae, 0xb7, 0x38, + 0xb1, 0xf3, 0x3d, 0x88, 0xf6, 0x23, 0xad, 0x00, 0xe1, 0x61, 0xd4, 0x17, 0x51, 0x78, 0x36, 0x06, + 0x46, 0xca, 0x54, 0xe7, 0x75, 0x90, 0x0c, 0x7f, 0x8b, 0xbe, 0xee, 0x79, 0x30, 0xd1, 0x37, 0x5e, + 0x50, 0x86, 0x04, 0x06, 0xa3, 0x69, 0x80, 0xa9, 0xe8, 0x43, 0xb4, 0x36, 0x98, 0xc1, 0x83, 0x0a, + 0xf9, 0xa1, 0xa1, 0xc1, 0x76, 0x10, 0x24, 0xda, 0xdf, 0x9d, 0x2f, 0xfb, 0xd5, 0x07, 0x30, 0x21, + 0x37, 0x14, 0x2c, 0xd8, 0xe2, 0x18, 0x4c, 0x46, 0x5e, 0x86, 0x4c, 0xbf, 0xf2, 0x30, 0x52, 0xf8, + 0x76, 0x58, 0x64, 0xb0, 0xd7, 0x7f, 0x1c, 0x58, 0xee, 0x37, 0xa8, 0x9b, 0x83, 0x19, 0xbb, 0x16, + 0x0a, 0xdb, 0x8f, 0x2c, 0x0c, 0x3a, 0xa3, 0x60, 0xa6, 0x73, 0x12, 0xbe, 0xe9, 0xeb, 0x63, 0x14, + 0x2c, 0xac, 0x7f, 0x04, 0xd8, 0xdf, 0x54, 0x18, 0xfb, 0xf3, 0xfe, 0x2a, 0xcb, 0x95, 0xca, 0xd7, + 0xb7, 0x22, 0x77, 0x73, 0x2b, 0x72, 0x6f, 0x6f, 0x45, 0xee, 0xe2, 0x4e, 0x8c, 0xdd, 0xdc, 0x89, + 0xb1, 0x57, 0x77, 0x62, 0xec, 0x97, 0x75, 0x1d, 0xb3, 0x7a, 0xab, 0x26, 0xab, 0xc4, 0x50, 0x76, + 0xa8, 0x55, 0x47, 0x4d, 0x94, 0x3b, 0x3b, 0xff, 0x43, 0x61, 0x50, 0x55, 0xeb, 0x10, 0x9b, 0xca, + 0x59, 0xe4, 0x5f, 0x38, 0x76, 0x6e, 0x21, 0x5a, 0x1b, 0x77, 0x3e, 0x0e, 0xeb, 0x1f, 0x02, 0x00, + 0x00, 0xff, 0xff, 0xca, 0x32, 0x13, 0x7c, 0xa8, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -614,8 +612,8 @@ type MsgClient interface { // LiquidUnstake defines a method for performing an undelegation of liquid // staking from a delegate. LiquidUnstake(ctx context.Context, in *MsgLiquidUnstake, opts ...grpc.CallOption) (*MsgLiquidUnstakeResponse, error) - // StakeToLP defines a method for LSM-transfer of staked XPRT - // into stkXPRT with locking into an LP. + // StakeToLP defines a method for LSM-transfer of staked TAC + // into gTAC with locking into an LP. StakeToLP(ctx context.Context, in *MsgStakeToLP, opts ...grpc.CallOption) (*MsgStakeToLPResponse, error) // UpdateParams defines a method to update the module params. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) @@ -637,7 +635,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) LiquidStake(ctx context.Context, in *MsgLiquidStake, opts ...grpc.CallOption) (*MsgLiquidStakeResponse, error) { out := new(MsgLiquidStakeResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/LiquidStake", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/LiquidStake", in, out, opts...) if err != nil { return nil, err } @@ -646,7 +644,7 @@ func (c *msgClient) LiquidStake(ctx context.Context, in *MsgLiquidStake, opts .. func (c *msgClient) LiquidUnstake(ctx context.Context, in *MsgLiquidUnstake, opts ...grpc.CallOption) (*MsgLiquidUnstakeResponse, error) { out := new(MsgLiquidUnstakeResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/LiquidUnstake", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/LiquidUnstake", in, out, opts...) if err != nil { return nil, err } @@ -655,7 +653,7 @@ func (c *msgClient) LiquidUnstake(ctx context.Context, in *MsgLiquidUnstake, opt func (c *msgClient) StakeToLP(ctx context.Context, in *MsgStakeToLP, opts ...grpc.CallOption) (*MsgStakeToLPResponse, error) { out := new(MsgStakeToLPResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/StakeToLP", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/StakeToLP", in, out, opts...) if err != nil { return nil, err } @@ -664,7 +662,7 @@ func (c *msgClient) StakeToLP(ctx context.Context, in *MsgStakeToLP, opts ...grp func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/UpdateParams", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/UpdateParams", in, out, opts...) if err != nil { return nil, err } @@ -673,7 +671,7 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts func (c *msgClient) UpdateWhitelistedValidators(ctx context.Context, in *MsgUpdateWhitelistedValidators, opts ...grpc.CallOption) (*MsgUpdateWhitelistedValidatorsResponse, error) { out := new(MsgUpdateWhitelistedValidatorsResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", in, out, opts...) if err != nil { return nil, err } @@ -682,7 +680,7 @@ func (c *msgClient) UpdateWhitelistedValidators(ctx context.Context, in *MsgUpda func (c *msgClient) SetModulePaused(ctx context.Context, in *MsgSetModulePaused, opts ...grpc.CallOption) (*MsgSetModulePausedResponse, error) { out := new(MsgSetModulePausedResponse) - err := c.cc.Invoke(ctx, "/pstake.liquidstake.v1beta1.Msg/SetModulePaused", in, out, opts...) + err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/SetModulePaused", in, out, opts...) if err != nil { return nil, err } @@ -697,8 +695,8 @@ type MsgServer interface { // LiquidUnstake defines a method for performing an undelegation of liquid // staking from a delegate. LiquidUnstake(context.Context, *MsgLiquidUnstake) (*MsgLiquidUnstakeResponse, error) - // StakeToLP defines a method for LSM-transfer of staked XPRT - // into stkXPRT with locking into an LP. + // StakeToLP defines a method for LSM-transfer of staked TAC + // into gTAC with locking into an LP. StakeToLP(context.Context, *MsgStakeToLP) (*MsgStakeToLPResponse, error) // UpdateParams defines a method to update the module params. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) @@ -747,7 +745,7 @@ func _Msg_LiquidStake_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Msg/LiquidStake", + FullMethod: "/tac.liquidstake.v1beta1.Msg/LiquidStake", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).LiquidStake(ctx, req.(*MsgLiquidStake)) @@ -765,7 +763,7 @@ func _Msg_LiquidUnstake_Handler(srv interface{}, ctx context.Context, dec func(i } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Msg/LiquidUnstake", + FullMethod: "/tac.liquidstake.v1beta1.Msg/LiquidUnstake", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).LiquidUnstake(ctx, req.(*MsgLiquidUnstake)) @@ -783,7 +781,7 @@ func _Msg_StakeToLP_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Msg/StakeToLP", + FullMethod: "/tac.liquidstake.v1beta1.Msg/StakeToLP", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).StakeToLP(ctx, req.(*MsgStakeToLP)) @@ -801,7 +799,7 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Msg/UpdateParams", + FullMethod: "/tac.liquidstake.v1beta1.Msg/UpdateParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) @@ -819,7 +817,7 @@ func _Msg_UpdateWhitelistedValidators_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", + FullMethod: "/tac.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).UpdateWhitelistedValidators(ctx, req.(*MsgUpdateWhitelistedValidators)) @@ -837,7 +835,7 @@ func _Msg_SetModulePaused_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pstake.liquidstake.v1beta1.Msg/SetModulePaused", + FullMethod: "/tac.liquidstake.v1beta1.Msg/SetModulePaused", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).SetModulePaused(ctx, req.(*MsgSetModulePaused)) @@ -846,7 +844,7 @@ func _Msg_SetModulePaused_Handler(srv interface{}, ctx context.Context, dec func } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "pstake.liquidstake.v1beta1.Msg", + ServiceName: "tac.liquidstake.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -875,7 +873,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "pstake/liquidstake/v1beta1/tx.proto", + Metadata: "tac/liquidstake/v1beta1/tx.proto", } func (m *MsgLiquidStake) Marshal() (dAtA []byte, err error) { From 42b610bf9576ed4aa45c9b08db9617abfd9b0523 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 24 Jul 2025 13:23:10 +0300 Subject: [PATCH 077/112] draft: changed unbonding time --- contrib/localnet/init.sh | 27 +++++++++++++++------------ docker-compose.yml | 4 ++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index f3f4671..2d4b44d 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -24,6 +24,7 @@ GOAL_BONDED=${GOAL_BONDED:-0.6} SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} MAX_VALIDATORS=${MAX_VALIDATORS:-14} +UNBONDING_TIME=${UNBONDING_TIME:-1814400s} # ports RPC_PORT=${RPC_PORT:-26657} @@ -41,8 +42,8 @@ PROXY_PORT=${PROXY_PORT:-26658} # prompt user for confirmation before cleanup read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm if [[ $confirm != "y" && $confirm != "Y" ]]; then - echo "Cleanup aborted." - exit 1 + echo "Cleanup aborted." + exit 1 fi # cleanup old data @@ -71,7 +72,7 @@ jq ' "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # arachnid (https://github.com/Arachnid/deterministic-deployment-proxy) jq ' @@ -87,8 +88,7 @@ jq ' "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # multicall (https://github.com/mds1/multicall3) jq ' @@ -104,7 +104,7 @@ jq ' "code": "6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # createx (https://github.com/pcaversaccio/createx) jq ' @@ -120,7 +120,7 @@ jq ' "code": "60806040526004361061018a5760003560e01c806381503da1116100d6578063d323826a1161007f578063e96deee411610059578063e96deee414610395578063f5745aba146103a8578063f9664498146103bb57600080fd5b8063d323826a1461034f578063ddda0acb1461036f578063e437252a1461038257600080fd5b80639c36a286116100b05780639c36a28614610316578063a7db93f214610329578063c3fe107b1461033c57600080fd5b806381503da1146102d0578063890c283b146102e357806398e810771461030357600080fd5b80632f990e3f116101385780636cec2536116101125780636cec25361461027d57806374637a7a1461029d5780637f565360146102bd57600080fd5b80632f990e3f1461023757806331a7c8c81461024a57806342d654fc1461025d57600080fd5b806327fe18221161016957806327fe1822146101f15780632852527a1461020457806328ddd0461461021757600080fd5b8062d84acb1461018f57806326307668146101cb57806326a32fc7146101de575b600080fd5b6101a261019d366004612915565b6103ce565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6101a26101d9366004612994565b6103e6565b6101a26101ec3660046129db565b610452565b6101a26101ff3660046129db565b6104de565b6101a2610212366004612a39565b610539565b34801561022357600080fd5b506101a2610232366004612a90565b6106fe565b6101a2610245366004612aa9565b61072a565b6101a2610258366004612aa9565b6107bb565b34801561026957600080fd5b506101a2610278366004612b1e565b6107c9565b34801561028957600080fd5b506101a2610298366004612a90565b610823565b3480156102a957600080fd5b506101a26102b8366004612b4a565b61084f565b6101a26102cb3660046129db565b611162565b6101a26102de366004612b74565b6111e8565b3480156102ef57600080fd5b506101a26102fe366004612bac565b611276565b6101a2610311366004612bce565b6112a3565b6101a2610324366004612994565b611505565b6101a2610337366004612c49565b6116f1565b6101a261034a366004612aa9565b611964565b34801561035b57600080fd5b506101a261036a366004612cd9565b6119ed565b6101a261037d366004612c49565b611a17565b6101a2610390366004612bce565b611e0c565b6101a26103a3366004612915565b611e95565b6101a26103b6366004612bce565b611ea4565b6101a26103c9366004612b74565b611f2d565b60006103dd8585858533611a17565b95945050505050565b6000806103f2846120db565b90508083516020850134f59150610408826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a35092915050565b60006104d86104d260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b836103e6565b92915050565b600081516020830134f090506104f3816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a2919050565b600080610545856120db565b905060008460601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f593505073ffffffffffffffffffffffffffffffffffffffff8316610635576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1660048201526024015b60405180910390fd5b604051829073ffffffffffffffffffffffffffffffffffffffff8516907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808473ffffffffffffffffffffffffffffffffffffffff1634876040516106a19190612d29565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b50915091506106f382828961247d565b505050509392505050565b60006104d87f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed8361084f565b60006107b36107aa60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b85858533611a17565b949350505050565b60006107b3848484336112a3565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b60006104d8827f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6107c9565b600060607f9400000000000000000000000000000000000000000000000000000000000000610887600167ffffffffffffffff612d45565b67ffffffffffffffff16841115610902576040517f3c55ab3b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b836000036109c7576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f800000000000000000000000000000000000000000000000000000000000000060368201526037015b6040516020818303038152906040529150611152565b607f8411610a60576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b16602283015260f886901b1660368201526037016109b1565b60ff8411610b1f576040517fd70000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660228301527f8100000000000000000000000000000000000000000000000000000000000000603683015260f886901b1660378201526038016109b1565b61ffff8411610bff576040517fd80000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f820000000000000000000000000000000000000000000000000000000000000060368201527fffff00000000000000000000000000000000000000000000000000000000000060f086901b1660378201526039016109b1565b62ffffff8411610ce0576040517fd90000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f830000000000000000000000000000000000000000000000000000000000000060368201527fffffff000000000000000000000000000000000000000000000000000000000060e886901b166037820152603a016109b1565b63ffffffff8411610dc2576040517fda0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f840000000000000000000000000000000000000000000000000000000000000060368201527fffffffff0000000000000000000000000000000000000000000000000000000060e086901b166037820152603b016109b1565b64ffffffffff8411610ea5576040517fdb0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f850000000000000000000000000000000000000000000000000000000000000060368201527fffffffffff00000000000000000000000000000000000000000000000000000060d886901b166037820152603c016109b1565b65ffffffffffff8411610f89576040517fdc0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f860000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffff000000000000000000000000000000000000000000000000000060d086901b166037820152603d016109b1565b66ffffffffffffff841161106e576040517fdd0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f870000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffff0000000000000000000000000000000000000000000000000060c886901b166037820152603e016109b1565b6040517fde0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f880000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffffff00000000000000000000000000000000000000000000000060c086901b166037820152603f0160405160208183030381529060405291505b5080516020909101209392505050565b60006104d86111e260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b83611505565b600061126f61126860408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b8484610539565b9392505050565b600061126f83837f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6119ed565b60008451602086018451f090506112b9816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808273ffffffffffffffffffffffffffffffffffffffff168560200151876040516113279190612d29565b60006040518083038185875af1925050503d8060008114611364576040519150601f19603f3d011682016040523d82523d6000602084013e611369565b606091505b5091509150816113c9577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1631156114fb578373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611495576040519150601f19603f3d011682016040523d82523d6000602084013e61149a565b606091505b509092509050816114fb577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b5050949350505050565b600080611511846120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff81166115e0576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a361162c83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1634876040516116569190612d29565b60006040518083038185875af1925050503d8060008114611693576040519150601f19603f3d011682016040523d82523d6000602084013e611698565b606091505b505090506116a681866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a25050505092915050565b6000806116fd876120db565b9050808651602088018651f59150611714826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808373ffffffffffffffffffffffffffffffffffffffff168660200151886040516117849190612d29565b60006040518083038185875af1925050503d80600081146117c1576040519150601f19603f3d011682016040523d82523d6000602084013e6117c6565b606091505b509150915081611826577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611958578473ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d80600081146118f2576040519150601f19603f3d011682016040523d82523d6000602084013e6118f7565b606091505b50909250905081611958577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b50505095945050505050565b60006107b36119e460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b858585336116f1565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b600080611a23876120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff8116611af2576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a3611b3e83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1687600001518a604051611b6c9190612d29565b60006040518083038185875af1925050503d8060008114611ba9576040519150601f19603f3d011682016040523d82523d6000602084013e611bae565b606091505b50509050611bbc81866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a260608573ffffffffffffffffffffffffffffffffffffffff1688602001518a604051611c299190612d29565b60006040518083038185875af1925050503d8060008114611c66576040519150601f19603f3d011682016040523d82523d6000602084013e611c6b565b606091505b50909250905081611ccc577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611dfe578673ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611d98576040519150601f19603f3d011682016040523d82523d6000602084013e611d9d565b606091505b50909250905081611dfe577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050505095945050505050565b60006103dd611e8c60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b868686866116f1565b60006103dd85858585336116f1565b60006103dd611f2460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b86868686611a17565b6000808360601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f092505073ffffffffffffffffffffffffffffffffffffffff8216612016576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b60405173ffffffffffffffffffffffffffffffffffffffff8316907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808373ffffffffffffffffffffffffffffffffffffffff1634866040516120809190612d29565b60006040518083038185875af1925050503d80600081146120bd576040519150601f19603f3d011682016040523d82523d6000602084013e6120c2565b606091505b50915091506120d282828861247d565b50505092915050565b60008060006120e9846125b3565b9092509050600082600281111561210257612102612e02565b1480156121205750600081600281111561211e5761211e612e02565b145b1561215e57604080513360208201524691810191909152606081018590526080016040516020818303038152906040528051906020012092506123cc565b600082600281111561217257612172612e02565b1480156121905750600181600281111561218e5761218e612e02565b145b156121b0576121a9338560009182526020526040902090565b92506123cc565b60008260028111156121c4576121c4612e02565b03612233576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b600182600281111561224757612247612e02565b1480156122655750600081600281111561226357612263612e02565b145b1561227e576121a9468560009182526020526040902090565b600182600281111561229257612292612e02565b1480156122b0575060028160028111156122ae576122ae612e02565b145b1561231f576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b61239a60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b84036123a657836123c9565b604080516020810186905201604051602081830303815290604052805190602001205b92505b5050919050565b73ffffffffffffffffffffffffffffffffffffffff8116158061240b575073ffffffffffffffffffffffffffffffffffffffff81163b155b1561247a576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b50565b82158061249f575073ffffffffffffffffffffffffffffffffffffffff81163b155b156124fa577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed826040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050565b811580612520575073ffffffffffffffffffffffffffffffffffffffff8116155b80612540575073ffffffffffffffffffffffffffffffffffffffff81163b155b156125af576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b5050565b600080606083901c3314801561261057508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b1561262057506000905080915091565b606083901c3314801561265a57507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561266b5750600090506001915091565b33606084901c036126825750600090506002915091565b606083901c1580156126db57508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b156126ec5750600190506000915091565b606083901c15801561272557507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561273557506001905080915091565b606083901c61274a5750600190506002915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000036127a55750600290506000915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000036127e15750600290506001915091565b506002905080915091565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261282c57600080fd5b813567ffffffffffffffff80821115612847576128476127ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561288d5761288d6127ec565b816040528381528660208588010111156128a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000604082840312156128d857600080fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb6127ec565b604052823581526020928301359281019290925250919050565b60008060008060a0858703121561292b57600080fd5b84359350602085013567ffffffffffffffff8082111561294a57600080fd5b6129568883890161281b565b9450604087013591508082111561296c57600080fd5b506129798782880161281b565b92505061298986606087016128c6565b905092959194509250565b600080604083850312156129a757600080fd5b82359150602083013567ffffffffffffffff8111156129c557600080fd5b6129d18582860161281b565b9150509250929050565b6000602082840312156129ed57600080fd5b813567ffffffffffffffff811115612a0457600080fd5b6107b38482850161281b565b803573ffffffffffffffffffffffffffffffffffffffff81168114612a3457600080fd5b919050565b600080600060608486031215612a4e57600080fd5b83359250612a5e60208501612a10565b9150604084013567ffffffffffffffff811115612a7a57600080fd5b612a868682870161281b565b9150509250925092565b600060208284031215612aa257600080fd5b5035919050565b600080600060808486031215612abe57600080fd5b833567ffffffffffffffff80821115612ad657600080fd5b612ae28783880161281b565b94506020860135915080821115612af857600080fd5b50612b058682870161281b565b925050612b1585604086016128c6565b90509250925092565b60008060408385031215612b3157600080fd5b82359150612b4160208401612a10565b90509250929050565b60008060408385031215612b5d57600080fd5b612b6683612a10565b946020939093013593505050565b60008060408385031215612b8757600080fd5b612b9083612a10565b9150602083013567ffffffffffffffff8111156129c557600080fd5b60008060408385031215612bbf57600080fd5b50508035926020909101359150565b60008060008060a08587031215612be457600080fd5b843567ffffffffffffffff80821115612bfc57600080fd5b612c088883890161281b565b95506020870135915080821115612c1e57600080fd5b50612c2b8782880161281b565b935050612c3b86604087016128c6565b915061298960808601612a10565b600080600080600060c08688031215612c6157600080fd5b85359450602086013567ffffffffffffffff80821115612c8057600080fd5b612c8c89838a0161281b565b95506040880135915080821115612ca257600080fd5b50612caf8882890161281b565b935050612cbf87606088016128c6565b9150612ccd60a08701612a10565b90509295509295909350565b600080600060608486031215612cee57600080fd5b8335925060208401359150612b1560408501612a10565b60005b83811015612d20578181015183820152602001612d08565b50506000910152565b60008251612d3b818460208701612d05565b9190910192915050565b67ffffffffffffffff828116828216039080821115612d8d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260008251806040840152612dcf816060850160208701612d05565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea164736f6c6343000817000a", "storage": [] }] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # edit configs @@ -128,8 +128,8 @@ jq ' # get ethereum chain id from CHAIN_ID EVM_CHAIN_ID=$(echo $CHAIN_ID | sed -E 's/.*_([0-9]+)-.*/\1/') if [[ -z $EVM_CHAIN_ID ]]; then - echo "Invalid CHAIN_ID format. Expected format: _-" - exit 1 + echo "Invalid CHAIN_ID format. Expected format: _-" + exit 1 fi sed -i.bak "s/\"chain_id\": \"262144\"/\"chain_id\": \"$EVM_CHAIN_ID\"/g" $HOMEDIR/config/genesis.json @@ -177,7 +177,7 @@ jq --arg GOV_MIN_DEPOSIT "$GOV_MIN_DEPOSIT" ' "amount": $GOV_MIN_DEPOSIT } ] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # set min expedited gov deposit jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' @@ -187,7 +187,7 @@ jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' "amount": $GOV_MIN_EXPEDITED_DEPOSIT } ] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # enable apis sed -i.bak "s/enable = false/enable = true/g" $HOMEDIR/config/app.toml @@ -224,7 +224,7 @@ jq ' "uri_hash": "" } ] -' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json jq ' .app_state.erc20 = { @@ -273,6 +273,9 @@ jq ' } ' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +# jq '.app_state.staking.params.unbonding_time = $$UNBONDING_TIME' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_TIME\"/g" $HOMEDIR/config/genesis.json + # set max validators sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json diff --git a/docker-compose.yml b/docker-compose.yml index e2e85dd..692bb47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,6 +38,7 @@ services: - JSON_RPC_ADDR=0.0.0.0:45118 - JSON_RPC_WS_ADDR=0.0.0.0:45119 - GRPC_LADDR=0.0.0.0:45113 + - UNBONDING_TIME=300s validator-2: network_mode: host @@ -67,6 +68,7 @@ services: - JSON_RPC_ADDR=0.0.0.0:45128 - JSON_RPC_WS_ADDR=0.0.0.0:45129 - GRPC_LADDR=0.0.0.0:45123 + - UNBONDING_TIME=300s validator-3: network_mode: host @@ -96,6 +98,7 @@ services: - JSON_RPC_ADDR=0.0.0.0:45138 - JSON_RPC_WS_ADDR=0.0.0.0:45139 - GRPC_LADDR=0.0.0.0:45133 + - UNBONDING_TIME=300s validator-4: network_mode: host @@ -125,3 +128,4 @@ services: - JSON_RPC_ADDR=0.0.0.0:45148 - JSON_RPC_WS_ADDR=0.0.0.0:45149 - GRPC_LADDR=0.0.0.0:45143 + - UNBONDING_TIME=300s From 00fb48c9e93e3ae43b32bb0c65b38cb94bfe66d6 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 24 Jul 2025 13:45:17 +0300 Subject: [PATCH 078/112] fix: changed unbonding time --- docker-compose.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 692bb47..20354a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: - CHAIN_ID=tacchain_2391-1 - MONIKER=tac-validator - HOMEDIR=/tacchain_data + - UNBONDING_TIME=300s validator-1: network_mode: host @@ -38,7 +39,6 @@ services: - JSON_RPC_ADDR=0.0.0.0:45118 - JSON_RPC_WS_ADDR=0.0.0.0:45119 - GRPC_LADDR=0.0.0.0:45113 - - UNBONDING_TIME=300s validator-2: network_mode: host @@ -68,7 +68,6 @@ services: - JSON_RPC_ADDR=0.0.0.0:45128 - JSON_RPC_WS_ADDR=0.0.0.0:45129 - GRPC_LADDR=0.0.0.0:45123 - - UNBONDING_TIME=300s validator-3: network_mode: host @@ -98,7 +97,6 @@ services: - JSON_RPC_ADDR=0.0.0.0:45138 - JSON_RPC_WS_ADDR=0.0.0.0:45139 - GRPC_LADDR=0.0.0.0:45133 - - UNBONDING_TIME=300s validator-4: network_mode: host @@ -128,4 +126,3 @@ services: - JSON_RPC_ADDR=0.0.0.0:45148 - JSON_RPC_WS_ADDR=0.0.0.0:45149 - GRPC_LADDR=0.0.0.0:45143 - - UNBONDING_TIME=300s From 599efd44a50e20c400701080012d88f5d9effc58 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 24 Jul 2025 14:49:33 +0300 Subject: [PATCH 079/112] fix: changed unbonding time 2 --- contrib/localnet/init-liquidstake-for-multinode.sh | 3 +++ contrib/localnet/init.sh | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/localnet/init-liquidstake-for-multinode.sh b/contrib/localnet/init-liquidstake-for-multinode.sh index 9e9069a..c5700f2 100644 --- a/contrib/localnet/init-liquidstake-for-multinode.sh +++ b/contrib/localnet/init-liquidstake-for-multinode.sh @@ -24,6 +24,7 @@ GOAL_BONDED=${GOAL_BONDED:-0.6} SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} MAX_VALIDATORS=${MAX_VALIDATORS:-14} +UNBONDING_TIME=${UNBONDING_TIME:-1814400s} # ports RPC_PORT=${RPC_PORT:-26657} @@ -296,6 +297,8 @@ jq ' # set max validators sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_TIME\"/g" $HOMEDIR/config/genesis.json + # set ports sed -i.bak "s/26657/$RPC_PORT/g" $HOMEDIR/config/config.toml sed -i.bak "s/26656/$P2P_PORT/g" $HOMEDIR/config/config.toml diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index 2d4b44d..f29bab9 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -273,7 +273,6 @@ jq ' } ' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json -# jq '.app_state.staking.params.unbonding_time = $$UNBONDING_TIME' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_TIME\"/g" $HOMEDIR/config/genesis.json # set max validators From 15779f54b3e907ae8c54bfc257e8d382207196bf Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 31 Jul 2025 13:40:58 +0300 Subject: [PATCH 080/112] moving module to evm --- app/app.go | 13 +- app/upgrades/types.go | 2 +- go.mod | 6 +- go.sum | 2 - proto/buf.gen.gogo.yaml | 8 - proto/buf.lock | 28 - proto/buf.yaml | 7 - proto/tac/epochs/v1beta1/genesis.proto | 37 - proto/tac/epochs/v1beta1/query.proto | 29 - proto/tac/liquidstake/v1beta1/genesis.proto | 20 - .../tac/liquidstake/v1beta1/liquidstake.proto | 214 -- proto/tac/liquidstake/v1beta1/query.proto | 57 - proto/tac/liquidstake/v1beta1/tx.proto | 156 - x/epochs/client/cli/query.go | 107 - x/epochs/keeper/abci.go | 65 - x/epochs/keeper/epoch.go | 122 - x/epochs/keeper/genesis.go | 25 - x/epochs/keeper/grpc_query.go | 56 - x/epochs/keeper/hooks.go | 17 - x/epochs/keeper/keeper.go | 44 - x/epochs/module.go | 158 - x/epochs/types/doc.go | 4 - x/epochs/types/errors.go | 12 - x/epochs/types/events.go | 9 - x/epochs/types/genesis.go | 77 - x/epochs/types/genesis.pb.go | 786 ----- x/epochs/types/hooks.go | 59 - x/epochs/types/keys.go | 12 - x/epochs/types/query.pb.go | 910 ------ x/epochs/types/query.pb.gw.go | 236 -- x/liquidstake/abci.go | 20 - x/liquidstake/client/cli/query.go | 152 - x/liquidstake/client/cli/tx.go | 332 --- x/liquidstake/keeper/genesis.go | 47 - x/liquidstake/keeper/genesis_test.go | 68 - x/liquidstake/keeper/grpc_query.go | 54 - x/liquidstake/keeper/hooks.go | 43 - x/liquidstake/keeper/keeper.go | 107 - x/liquidstake/keeper/keeper_test.go | 479 --- x/liquidstake/keeper/liquidstake.go | 1212 -------- x/liquidstake/keeper/liquidstake_test.go | 494 ---- x/liquidstake/keeper/msg_server.go | 309 -- x/liquidstake/keeper/rebalancing.go | 312 -- x/liquidstake/module.go | 152 - x/liquidstake/types/codec.go | 50 - x/liquidstake/types/errors.go | 32 - x/liquidstake/types/errors_test.go | 18 - x/liquidstake/types/events.go | 38 - x/liquidstake/types/expected_keepers.go | 38 - x/liquidstake/types/genesis.go | 37 - x/liquidstake/types/genesis.pb.go | 377 --- x/liquidstake/types/genesis_test.go | 64 - x/liquidstake/types/keys.go | 39 - x/liquidstake/types/liquidstake.go | 218 -- x/liquidstake/types/liquidstake.pb.go | 2056 ------------- x/liquidstake/types/logging.go | 19 - x/liquidstake/types/msgs.go | 330 --- x/liquidstake/types/msgs_test.go | 150 - x/liquidstake/types/params.go | 253 -- x/liquidstake/types/query.pb.go | 1225 -------- x/liquidstake/types/query.pb.gw.go | 283 -- x/liquidstake/types/rebalancing.go | 52 - x/liquidstake/types/tx.pb.go | 2619 ----------------- 63 files changed, 11 insertions(+), 14946 deletions(-) delete mode 100644 proto/buf.gen.gogo.yaml delete mode 100644 proto/buf.lock delete mode 100644 proto/buf.yaml delete mode 100644 proto/tac/epochs/v1beta1/genesis.proto delete mode 100644 proto/tac/epochs/v1beta1/query.proto delete mode 100644 proto/tac/liquidstake/v1beta1/genesis.proto delete mode 100644 proto/tac/liquidstake/v1beta1/liquidstake.proto delete mode 100644 proto/tac/liquidstake/v1beta1/query.proto delete mode 100644 proto/tac/liquidstake/v1beta1/tx.proto delete mode 100644 x/epochs/client/cli/query.go delete mode 100644 x/epochs/keeper/abci.go delete mode 100644 x/epochs/keeper/epoch.go delete mode 100644 x/epochs/keeper/genesis.go delete mode 100644 x/epochs/keeper/grpc_query.go delete mode 100644 x/epochs/keeper/hooks.go delete mode 100644 x/epochs/keeper/keeper.go delete mode 100644 x/epochs/module.go delete mode 100644 x/epochs/types/doc.go delete mode 100644 x/epochs/types/errors.go delete mode 100644 x/epochs/types/events.go delete mode 100644 x/epochs/types/genesis.go delete mode 100644 x/epochs/types/genesis.pb.go delete mode 100644 x/epochs/types/hooks.go delete mode 100644 x/epochs/types/keys.go delete mode 100644 x/epochs/types/query.pb.go delete mode 100644 x/epochs/types/query.pb.gw.go delete mode 100644 x/liquidstake/abci.go delete mode 100644 x/liquidstake/client/cli/query.go delete mode 100644 x/liquidstake/client/cli/tx.go delete mode 100644 x/liquidstake/keeper/genesis.go delete mode 100644 x/liquidstake/keeper/genesis_test.go delete mode 100644 x/liquidstake/keeper/grpc_query.go delete mode 100644 x/liquidstake/keeper/hooks.go delete mode 100644 x/liquidstake/keeper/keeper.go delete mode 100644 x/liquidstake/keeper/keeper_test.go delete mode 100644 x/liquidstake/keeper/liquidstake.go delete mode 100644 x/liquidstake/keeper/liquidstake_test.go delete mode 100644 x/liquidstake/keeper/msg_server.go delete mode 100644 x/liquidstake/keeper/rebalancing.go delete mode 100644 x/liquidstake/module.go delete mode 100644 x/liquidstake/types/codec.go delete mode 100644 x/liquidstake/types/errors.go delete mode 100644 x/liquidstake/types/errors_test.go delete mode 100644 x/liquidstake/types/events.go delete mode 100644 x/liquidstake/types/expected_keepers.go delete mode 100644 x/liquidstake/types/genesis.go delete mode 100644 x/liquidstake/types/genesis.pb.go delete mode 100644 x/liquidstake/types/genesis_test.go delete mode 100644 x/liquidstake/types/keys.go delete mode 100644 x/liquidstake/types/liquidstake.go delete mode 100644 x/liquidstake/types/liquidstake.pb.go delete mode 100644 x/liquidstake/types/logging.go delete mode 100644 x/liquidstake/types/msgs.go delete mode 100644 x/liquidstake/types/msgs_test.go delete mode 100644 x/liquidstake/types/params.go delete mode 100644 x/liquidstake/types/query.pb.go delete mode 100644 x/liquidstake/types/query.pb.gw.go delete mode 100644 x/liquidstake/types/rebalancing.go delete mode 100644 x/liquidstake/types/tx.pb.go diff --git a/app/app.go b/app/app.go index f3e6b19..75f80b3 100644 --- a/app/app.go +++ b/app/app.go @@ -12,9 +12,9 @@ import ( _ "github.com/ethereum/go-ethereum/eth/tracers/js" _ "github.com/ethereum/go-ethereum/eth/tracers/native" - "github.com/Asphere-xyz/tacchain/x/epochs" - epochskeeper "github.com/Asphere-xyz/tacchain/x/epochs/keeper" - epochstypes "github.com/Asphere-xyz/tacchain/x/epochs/types" + "github.com/cosmos/evm/x/epochs" + epochskeeper "github.com/cosmos/evm/x/epochs/keeper" + epochstypes "github.com/cosmos/evm/x/epochs/types" abci "github.com/cometbft/cometbft/abci/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" @@ -157,9 +157,9 @@ import ( evmvmkeeper "github.com/cosmos/evm/x/vm/keeper" evmvmtypes "github.com/cosmos/evm/x/vm/types" - "github.com/Asphere-xyz/tacchain/x/liquidstake" - liquidstakekeeper "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" - liquidstaketypes "github.com/Asphere-xyz/tacchain/x/liquidstake/types" + "github.com/cosmos/evm/x/liquidstake" + liquidstakekeeper "github.com/cosmos/evm/x/liquidstake/keeper" + liquidstaketypes "github.com/cosmos/evm/x/liquidstake/types" ) // module account permissions @@ -715,6 +715,7 @@ func NewTacChainApp( app.GovKeeper, app.SlashingKeeper, app.EvidenceKeeper, + app.LiquidStakeKeeper, ), ) diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 8decc4b..8b498f7 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -15,7 +15,7 @@ import ( consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - liquidstakekeeper "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" + liquidstakekeeper "github.com/cosmos/evm/x/liquidstake/keeper" ) type AppKeepers struct { diff --git a/go.mod b/go.mod index 3e1faea..4346cfa 100644 --- a/go.mod +++ b/go.mod @@ -281,9 +281,9 @@ replace ( // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 - - // use Cosmos geth fork + // github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 + github.com/cosmos/evm => ../evm + // Cosmos geth fork // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index 1c4fb1d..c3ac3ca 100644 --- a/go.sum +++ b/go.sum @@ -1006,8 +1006,6 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 h1:ddqzU2x2ZpPPvQKhBqPj9TZNtSyp0UsA5Ip2+elxlRM= -github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7/go.mod h1:kthk/QmpstaPB5USt4OIIoxqRBDcSqTv37fKWGFNUPM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml deleted file mode 100644 index 9c8ba0a..0000000 --- a/proto/buf.gen.gogo.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: v1 -plugins: - - name: gocosmos - out: .. - opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types - - name: grpc-gateway - out: .. - opt: logtostderr=true,allow_colon_final_segments=true diff --git a/proto/buf.lock b/proto/buf.lock deleted file mode 100644 index 207c8a8..0000000 --- a/proto/buf.lock +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by buf. DO NOT EDIT. -version: v1 -deps: - - remote: buf.build - owner: cosmos - repository: cosmos-proto - commit: 04467658e59e44bbb22fe568206e1f70 - digest: shake256:73a640bd60e0c523b0f8237ff34eab67c45a38b64bbbde1d80224819d272dbf316ac183526bd245f994af6608b025f5130483d0133c5edd385531326b5990466 - - remote: buf.build - owner: cosmos - repository: cosmos-sdk - commit: 650cd9ad7f7a468e8e19975269958658 - digest: shake256:c2c1e67ed8efa7f5c6af7a2fc02a6c257dc78fe86911cbf4d3dd379710bf475565ffe2ae4f65221888373d515caa31be68b720897cccec6e0c6a1a91ff0b5227 - - remote: buf.build - owner: cosmos - repository: gogo-proto - commit: 88ef6483f90f478fb938c37dde52ece3 - digest: shake256:89c45df2aa11e0cff97b0d695436713db3d993d76792e9f8dc1ae90e6ab9a9bec55503d48ceedd6b86069ab07d3041b32001b2bfe0227fa725dd515ff381e5ba - - remote: buf.build - owner: googleapis - repository: googleapis - commit: 61b203b9a9164be9a834f58c37be6f62 - digest: shake256:e619113001d6e284ee8a92b1561e5d4ea89a47b28bf0410815cb2fa23914df8be9f1a6a98dcf069f5bc2d829a2cfb1ac614863be45cd4f8a5ad8606c5f200224 - - remote: buf.build - owner: protocolbuffers - repository: wellknowntypes - commit: 3ddd61d1f53d485abd3d3a2b47a62b8e - digest: shake256:9e6799d56700d0470c3723a2fd027e8b4a41a07085a0c90c58e05f6c0038fac9b7a0170acd7692707a849983b1b8189aa33e7b73f91d68157f7136823115546b diff --git a/proto/buf.yaml b/proto/buf.yaml deleted file mode 100644 index db919cf..0000000 --- a/proto/buf.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: v1 -name: buf.build/Asphere-xyz/tacchain -deps: - - buf.build/cosmos/cosmos-proto - - buf.build/cosmos/gogo-proto - - buf.build/googleapis/googleapis - - buf.build/cosmos/cosmos-sdk diff --git a/proto/tac/epochs/v1beta1/genesis.proto b/proto/tac/epochs/v1beta1/genesis.proto deleted file mode 100644 index 8422025..0000000 --- a/proto/tac/epochs/v1beta1/genesis.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; -package tac.epochs.v1beta1; - -import "gogoproto/gogo.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "github.com/Asphere-xyz/tacchain/x/epochs/types"; - -message EpochInfo { - string identifier = 1; - google.protobuf.Timestamp start_time = 2 [ - (gogoproto.stdtime) = true, - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"start_time\"" - ]; - google.protobuf.Duration duration = 3 [ - (gogoproto.nullable) = false, - (gogoproto.stdduration) = true, - (gogoproto.jsontag) = "duration,omitempty", - (gogoproto.moretags) = "yaml:\"duration\"" - ]; - int64 current_epoch = 4; - google.protobuf.Timestamp current_epoch_start_time = 5 [ - (gogoproto.stdtime) = true, - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"current_epoch_start_time\"" - ]; - bool epoch_counting_started = 6; - reserved 7; - int64 current_epoch_start_height = 8; -} - -// GenesisState defines the epochs module's genesis state. -message GenesisState { - repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ]; -} diff --git a/proto/tac/epochs/v1beta1/query.proto b/proto/tac/epochs/v1beta1/query.proto deleted file mode 100644 index 6913fbb..0000000 --- a/proto/tac/epochs/v1beta1/query.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; -package tac.epochs.v1beta1; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "tac/epochs/v1beta1/genesis.proto"; - -option go_package = "github.com/Asphere-xyz/tacchain/x/epochs/types"; - -// Query defines the gRPC querier service. -service Query { - // EpochInfos provide running epochInfos - rpc EpochInfos(QueryEpochsInfoRequest) returns (QueryEpochsInfoResponse) { - option (google.api.http).get = "/tacchain/epochs/v1beta1/epochs"; - } - // CurrentEpoch provide current epoch of specified identifier - rpc CurrentEpoch(QueryCurrentEpochRequest) - returns (QueryCurrentEpochResponse) { - option (google.api.http).get = "/tacchain/epochs/v1beta1/current_epoch"; - } -} - -message QueryEpochsInfoRequest {} -message QueryEpochsInfoResponse { - repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ]; -} - -message QueryCurrentEpochRequest { string identifier = 1; } -message QueryCurrentEpochResponse { int64 current_epoch = 1; } diff --git a/proto/tac/liquidstake/v1beta1/genesis.proto b/proto/tac/liquidstake/v1beta1/genesis.proto deleted file mode 100644 index 77d31cf..0000000 --- a/proto/tac/liquidstake/v1beta1/genesis.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; -package tac.liquidstake.v1beta1; - -import "gogoproto/gogo.proto"; -import "tac/liquidstake/v1beta1/liquidstake.proto"; - -option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; -option (gogoproto.equal_all) = true; - -// GenesisState defines the liquidstake module's genesis state. -message GenesisState { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // params defines all the parameters for the liquidstake module - Params params = 1 [ (gogoproto.nullable) = false ]; - - repeated LiquidValidator liquid_validators = 2 - [ (gogoproto.nullable) = false ]; -} diff --git a/proto/tac/liquidstake/v1beta1/liquidstake.proto b/proto/tac/liquidstake/v1beta1/liquidstake.proto deleted file mode 100644 index c5a36b1..0000000 --- a/proto/tac/liquidstake/v1beta1/liquidstake.proto +++ /dev/null @@ -1,214 +0,0 @@ -syntax = "proto3"; - -package tac.liquidstake.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; - -option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; - -// Params defines the set of params for the liquidstake module. -message Params { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - // LiquidBondDenom specifies the denomination of the token receiving after - // liquid stake, The value is calculated through NetAmount. - string liquid_bond_denom = 1; - - // WhitelistedValidators specifies the validators elected to become Active - // Liquid Validators. - repeated WhitelistedValidator whitelisted_validators = 2 - [ (gogoproto.nullable) = false ]; - - // UnstakeFeeRate specifies the fee rate when liquid unstake is requested, - // unbonded by subtracting it from unbondingAmount - string unstake_fee_rate = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // LsmDisabled allows to block any msgs that convert staked tokens into - // gTAC through LSM. - bool lsm_disabled = 4; - - // MinLiquidStakingAmount specifies the minimum number of coins to be staked - // to the active liquid validators on liquid staking to minimize decimal loss - // and consider gas efficiency. - string min_liquid_stake_amount = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // CwLockedPoolAddress defines the bech32-encoded address of - // a CW smart-contract representing a time locked LP (e.g. Superfluid LP). - string cw_locked_pool_address = 6 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // FeeAccountAddress defines the bech32-encoded address of - // a an account responsible for accumulating protocol fees. - string fee_account_address = 7 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // AutocompoundFeeRate specifies the fee rate for auto redelegating the stake - // rewards. The fee is taken in favour of the fee account (see - // FeeAccountAddress). - string autocompound_fee_rate = 8 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // WhitelistAdminAddress the bech32-encoded address of an admin authority - // that is allowed to update whitelisted validators or pause liquidstaking - // module entirely. The key is controlled by an offchain process that is - // selecting validators based on a criteria. Pausing of the module can be - // required during important migrations or failures. - string whitelist_admin_address = 9 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // ModulePaused is a safety toggle that allows to stop main module functions - // such as stake/unstake/stake-to-lp and the BeginBlocker logic. - bool module_paused = 10; -} - -// ValidatorStatus enumerates the status of a liquid validator. -enum ValidatorStatus { - option (gogoproto.goproto_enum_prefix) = false; - - // VALIDATOR_STATUS_UNSPECIFIED defines the unspecified invalid status. - VALIDATOR_STATUS_UNSPECIFIED = 0 - [ (gogoproto.enumvalue_customname) = "ValidatorStatusUnspecified" ]; - // VALIDATOR_STATUS_ACTIVE defines the active, valid status - VALIDATOR_STATUS_ACTIVE = 1 - [ (gogoproto.enumvalue_customname) = "ValidatorStatusActive" ]; - // VALIDATOR_STATUS_INACTIVE defines the inactive, invalid status - VALIDATOR_STATUS_INACTIVE = 2 - [ (gogoproto.enumvalue_customname) = "ValidatorStatusInactive" ]; -} - -// WhitelistedValidator consists of the validator operator address and the -// target weight, which is a value for calculating the real weight to be derived -// according to the active status. -message WhitelistedValidator { - option (gogoproto.goproto_getters) = false; - - // validator_address defines the bech32-encoded address that whitelisted - // validator - string validator_address = 1 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // target_weight specifies the target weight for liquid staking, unstaking - // amount, which is a value for calculating the real weight to be derived - // according to the active status - string target_weight = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -// LiquidValidator defines a Validator that can be the target of LiquidStaking -// and LiquidUnstaking, Active, Weight, etc. fields are derived as functions to -// deal with by maintaining consistency with the state of the staking module. -message LiquidValidator { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // operator_address defines the address of the validator's operator; bech - // encoded in JSON. - string operator_address = 1 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; -} - -// LiquidValidatorState is type LiquidValidator with state added to return to -// query results. -message LiquidValidatorState { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // operator_address defines the address of the validator's operator; bech - // encoded in JSON. - string operator_address = 1 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // weight specifies the weight for liquid staking, unstaking amount - string weight = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // status is the liquid validator status - ValidatorStatus status = 3; - - // del_shares define the delegation shares of the validator - string del_shares = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // liquid_tokens define the token amount worth of delegation shares of the - // validator (slashing applied amount) - string liquid_tokens = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -// NetAmountState is type for net amount raw data and mint rate, This is a value -// that depends on the several module state every time, so it is used only for -// calculation and query and is not stored in kv. -message NetAmountState { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = true; - - // mint_rate is gTACTotalSupply / NetAmount - string mint_rate = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // btoken_total_supply returns the total supply of stk/utac (gTAC denom) - string gtac_total_supply = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // net_amount is proxy account's native token balance + total liquid tokens + - // total remaining rewards + total unbonding balance - string net_amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // total_del_shares define the delegation shares of all liquid validators - string total_del_shares = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // total_liquid_tokens define the token amount worth of delegation shares of - // all liquid validator (slashing applied amount) - string total_liquid_tokens = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // total_remaining_rewards define the sum of remaining rewards of proxy - // account by all liquid validators - string total_remaining_rewards = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // total_unbonding_balance define the unbonding balance of proxy account by - // all liquid validator (slashing applied amount) - string total_unbonding_balance = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // proxy_acc_balance define the balance of proxy account for the native token - string proxy_acc_balance = 8 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} diff --git a/proto/tac/liquidstake/v1beta1/query.proto b/proto/tac/liquidstake/v1beta1/query.proto deleted file mode 100644 index d1121f6..0000000 --- a/proto/tac/liquidstake/v1beta1/query.proto +++ /dev/null @@ -1,57 +0,0 @@ -syntax = "proto3"; -package tac.liquidstake.v1beta1; - -import "google/api/annotations.proto"; -import "tac/liquidstake/v1beta1/liquidstake.proto"; -import "gogoproto/gogo.proto"; -import "cosmos/msg/v1/msg.proto"; - -option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; - -// Query defines the gRPC query service for the liquidstake module. -service Query { - option (cosmos.msg.v1.service) = true; - // Params returns parameters of the liquidstake module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/tac/liquidstake/v1beta1/params"; - } - - // LiquidValidators returns liquid validators with states of the liquidstake - // module. - rpc LiquidValidators(QueryLiquidValidatorsRequest) - returns (QueryLiquidValidatorsResponse) { - option (google.api.http).get = "/tac/liquidstake/v1beta1/validators"; - } - - // States returns states of the liquidstake module. - rpc States(QueryStatesRequest) returns (QueryStatesResponse) { - option (google.api.http).get = "/tac/liquidstake/v1beta1/states"; - } -} - -// QueryParamsRequest is the request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryParamsResponse { - Params params = 1 [ (gogoproto.nullable) = false ]; -} - -// QueryLiquidValidatorsRequest is the request type for the -// Query/LiquidValidators RPC method. -message QueryLiquidValidatorsRequest {} - -// QueryLiquidValidatorsResponse is the response type for the -// Query/LiquidValidators RPC method. -message QueryLiquidValidatorsResponse { - repeated LiquidValidatorState liquid_validators = 1 - [ (gogoproto.nullable) = false ]; -} - -// QueryStatesRequest is the request type for the Query/States RPC method. -message QueryStatesRequest {} - -// QueryStatesResponse is the response type for the Query/States RPC method. -message QueryStatesResponse { - NetAmountState net_amount_state = 1 [ (gogoproto.nullable) = false ]; -} diff --git a/proto/tac/liquidstake/v1beta1/tx.proto b/proto/tac/liquidstake/v1beta1/tx.proto deleted file mode 100644 index af854d1..0000000 --- a/proto/tac/liquidstake/v1beta1/tx.proto +++ /dev/null @@ -1,156 +0,0 @@ -syntax = "proto3"; -package tac.liquidstake.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/msg/v1/msg.proto"; -import "google/protobuf/timestamp.proto"; -import "tac/liquidstake/v1beta1/liquidstake.proto"; -import "amino/amino.proto"; - -option go_package = "github.com/Asphere-xyz/tacchain/x/liquidstake/types"; - -// Msg defines the liquid staking Msg service. -service Msg { - option (cosmos.msg.v1.service) = true; - // LiquidStake defines a method for performing a delegation of coins - // from a delegator to whitelisted validators. - rpc LiquidStake(MsgLiquidStake) returns (MsgLiquidStakeResponse); - - // LiquidUnstake defines a method for performing an undelegation of liquid - // staking from a delegate. - rpc LiquidUnstake(MsgLiquidUnstake) returns (MsgLiquidUnstakeResponse); - - // StakeToLP defines a method for LSM-transfer of staked TAC - // into gTAC with locking into an LP. - rpc StakeToLP(MsgStakeToLP) returns (MsgStakeToLPResponse); - - // UpdateParams defines a method to update the module params. - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); - - // UpdateWhitelistedValidators defines a method to update the whitelisted - // validators list. - rpc UpdateWhitelistedValidators(MsgUpdateWhitelistedValidators) - returns (MsgUpdateWhitelistedValidatorsResponse); - - // SetModulePaused defines a method to update the module's pause status, - // setting value of the safety flag in params. - rpc SetModulePaused(MsgSetModulePaused) returns (MsgSetModulePausedResponse); -} - -// MsgLiquidStake defines a SDK message for performing a liquid stake of coins -// from a delegator to whitelisted validators. -message MsgLiquidStake { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "delegator_address"; - option (amino.name) = "liquidstake/MsgLiquidStake"; - - string delegator_address = 1 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - cosmos.base.v1beta1.Coin amount = 2 [ (gogoproto.nullable) = false ]; -} - -// MsgLiquidStakeResponse defines the MsgLiquidStake response type. -message MsgLiquidStakeResponse {} - -// MsgStakeToLP defines a SDK message for performing an LSM-transfer of staked -// TAC into gTAC with locking into an LP. -message MsgStakeToLP { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (amino.name) = "liquidstake/MsgStakeToLP"; - option (cosmos.msg.v1.signer) = "delegator_address"; - - string delegator_address = 1 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - string validator_address = 2 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - cosmos.base.v1beta1.Coin staked_amount = 3 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin liquid_amount = 4 [ (gogoproto.nullable) = false ]; -} - -// MsgStakeToLPResponse defines the MsgStakeToLP response type. -message MsgStakeToLPResponse {} - -// MsgLiquidUnstake defines a SDK message for performing an undelegation of -// liquid staking from a delegate. -message MsgLiquidUnstake { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (amino.name) = "liquidstake/MsgLiquidUnstake"; - option (cosmos.msg.v1.signer) = "delegator_address"; - - string delegator_address = 1 - [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - cosmos.base.v1beta1.Coin amount = 2 [ (gogoproto.nullable) = false ]; -} - -// MsgLiquidUnstakeResponse defines the MsgLiquidUnstake response type. -message MsgLiquidUnstakeResponse { - google.protobuf.Timestamp completion_time = 1 - [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; -} - -message MsgUpdateParams { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (amino.name) = "liquidstake/MsgUpdateParams"; - option (cosmos.msg.v1.signer) = "authority"; - - // authority is the address that controls the module (defaults to x/gov unless - // overwritten). - string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // params defines the parameters to update. - // - // NOTE: denom and whitelisted validators are not updated. - // - Params params = 2 [ (gogoproto.nullable) = false ]; -} - -// MsgUpdateParamsResponse defines the response structure for executing a -message MsgUpdateParamsResponse {} - -message MsgUpdateWhitelistedValidators { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (amino.name) = "liquidstake/MsgUpdateWhitelistedValidators"; - option (cosmos.msg.v1.signer) = "authority"; - - // Authority is the address that is allowed to update whitelisted validators, - // defined as admin address in params (WhitelistAdminAddress). - string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // WhitelistedValidators specifies the validators elected to become Active - // Liquid Validators. - repeated WhitelistedValidator whitelisted_validators = 2 - [ (gogoproto.nullable) = false ]; -} - -// MsgUpdateWhitelistedValidatorsResponse defines the response structure for -// executing a -message MsgUpdateWhitelistedValidatorsResponse {} - -message MsgSetModulePaused { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (amino.name) = "liquidstake/MsgSetModulePaused"; - option (cosmos.msg.v1.signer) = "authority"; - - // Authority is the address that is allowed to update module's paused state, - // defined as admin address in params (WhitelistAdminAddress). - string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // IsPaused represents the target state of the paused flag. - bool is_paused = 2; -} - -// MsgSetModulePausedResponse defines the response structure for -// executing a -message MsgSetModulePausedResponse {} diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go deleted file mode 100644 index 0da8789..0000000 --- a/x/epochs/client/cli/query.go +++ /dev/null @@ -1,107 +0,0 @@ -package cli - -import ( - "fmt" - "strings" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/version" - - "github.com/Asphere-xyz/tacchain/x/epochs/types" -) - -// GetQueryCmd returns the cli query commands for this module. -func GetQueryCmd() *cobra.Command { - // Group epochs queries under a subcommand - cmd := &cobra.Command{ - Use: types.ModuleName, - Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand( - GetCmdEpochsInfos(), - GetCmdCurrentEpoch(), - ) - - return cmd -} - -// GetCmdEpochsInfos provide running epochInfos. -func GetCmdEpochsInfos() *cobra.Command { - cmd := &cobra.Command{ - Use: "epoch-infos", - Short: "Query running epochInfos", - Long: strings.TrimSpace( - fmt.Sprintf(`Query running epoch infos. - -Example: -$ %s query epochs epoch-infos -`, - version.AppName, - ), - ), - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.EpochInfos(cmd.Context(), &types.QueryEpochsInfoRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// GetCmdCurrentEpoch provides current epoch by specified identifier. -func GetCmdCurrentEpoch() *cobra.Command { - cmd := &cobra.Command{ - Use: "current-epoch", - Short: "Query current epoch by specified identifier", - Long: strings.TrimSpace( - fmt.Sprintf(`Query current epoch by specified identifier. - -Example: -$ %s query epochs current-epoch day -`, - version.AppName, - ), - ), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.CurrentEpoch(cmd.Context(), &types.QueryCurrentEpochRequest{ - Identifier: args[0], - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/epochs/keeper/abci.go b/x/epochs/keeper/abci.go deleted file mode 100644 index 37a4534..0000000 --- a/x/epochs/keeper/abci.go +++ /dev/null @@ -1,65 +0,0 @@ -package keeper - -import ( - "fmt" - "time" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Asphere-xyz/tacchain/x/epochs/types" -) - -// BeginBlocker of epochs module. -func (k Keeper) BeginBlocker(ctx sdk.Context) { - defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) - k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { - logger := k.Logger(ctx) - - // If blocktime < initial epoch start time, return - if ctx.BlockTime().Before(epochInfo.StartTime) { - return - } - // if epoch counting hasn't started, signal we need to start. - shouldInitialEpochStart := !epochInfo.EpochCountingStarted - - epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) - shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart - - if !shouldEpochStart { - return false - } - epochInfo.CurrentEpochStartHeight = ctx.BlockHeight() - - if shouldInitialEpochStart { - epochInfo.EpochCountingStarted = true - epochInfo.CurrentEpoch = 1 - epochInfo.CurrentEpochStartTime = epochInfo.StartTime - logger.Info(fmt.Sprintf("Starting new epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) - } else { - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeEpochEnd, - sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)), - ), - ) - k.AfterEpochEnd(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch) - epochInfo.CurrentEpoch++ - epochInfo.CurrentEpochStartTime = epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) - logger.Info(fmt.Sprintf("Starting epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) - } - - // emit new epoch start event, set epoch info, and run BeforeEpochStart hook - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeEpochStart, - sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)), - sdk.NewAttribute(types.AttributeEpochStartTime, fmt.Sprintf("%d", epochInfo.CurrentEpochStartTime.Unix())), - ), - ) - k.setEpochInfo(ctx, epochInfo) - k.BeforeEpochStart(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch) - - return false - }) -} diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go deleted file mode 100644 index 6255f33..0000000 --- a/x/epochs/keeper/epoch.go +++ /dev/null @@ -1,122 +0,0 @@ -package keeper - -import ( - "fmt" - "time" - - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/gogoproto/proto" - - "github.com/Asphere-xyz/tacchain/x/epochs/types" -) - -// GetEpochInfo returns epoch info by identifier. -func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo { - epoch := types.EpochInfo{} - store := ctx.KVStore(k.storeKey) - - b := store.Get(append(types.KeyPrefixEpoch, []byte(identifier)...)) - if b == nil { - return epoch - } - - err := proto.Unmarshal(b, &epoch) - if err != nil { - panic(err) - } - - return epoch -} - -// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation, -// or re-uses an existing identifier. -// This method also sets the start time if left unset, and sets the epoch start height. -func (k Keeper) AddEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error { - err := epoch.Validate() - if err != nil { - return err - } - // Check if identifier already exists - if (k.GetEpochInfo(ctx, epoch.Identifier) != types.EpochInfo{}) { - return fmt.Errorf("epoch with identifier %s already exists", epoch.Identifier) - } - - // Initialize empty and default epoch values - if epoch.StartTime.Equal(time.Time{}) { - epoch.StartTime = ctx.BlockTime() - } - - epoch.CurrentEpochStartHeight = ctx.BlockHeight() - k.setEpochInfo(ctx, epoch) - - return nil -} - -// setEpochInfo set epoch info. -func (k Keeper) setEpochInfo(ctx sdk.Context, epoch types.EpochInfo) { - store := ctx.KVStore(k.storeKey) - - value, err := proto.Marshal(&epoch) - if err != nil { - panic(err) - } - - store.Set(append(types.KeyPrefixEpoch, []byte(epoch.Identifier)...), value) -} - -// DeleteEpochInfo delete epoch info. -func (k Keeper) DeleteEpochInfo(ctx sdk.Context, identifier string) { - store := ctx.KVStore(k.storeKey) - store.Delete(append(types.KeyPrefixEpoch, []byte(identifier)...)) -} - -// IterateEpochInfo iterate through epochs. -func (k Keeper) IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool)) { - store := ctx.KVStore(k.storeKey) - - iterator := storetypes.KVStorePrefixIterator(store, types.KeyPrefixEpoch) - defer iterator.Close() - - i := int64(0) - - for ; iterator.Valid(); iterator.Next() { - epoch := types.EpochInfo{} - - err := proto.Unmarshal(iterator.Value(), &epoch) - if err != nil { - panic(err) - } - - stop := fn(i, epoch) - if stop { - break - } - i++ - } -} - -// AllEpochInfos iterate through epochs to return all epochs info. -func (k Keeper) AllEpochInfos(ctx sdk.Context) []types.EpochInfo { - epochs := []types.EpochInfo{} - - k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { - epochs = append(epochs, epochInfo) - return false - }) - - return epochs -} - -// NumBlocksSinceEpochStart returns the number of blocks since the epoch started. -// if the epoch started on block N, then calling this during block N (after BeforeEpochStart) -// would return 0. -// Calling it any point in block N+1 (assuming the epoch doesn't increment) would return 1. -func (k Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (int64, error) { - epoch := k.GetEpochInfo(ctx, identifier) - if (epoch == types.EpochInfo{}) { - return 0, fmt.Errorf("epoch with identifier %s not found", identifier) - } - - return ctx.BlockHeight() - epoch.CurrentEpochStartHeight, nil -} diff --git a/x/epochs/keeper/genesis.go b/x/epochs/keeper/genesis.go deleted file mode 100644 index f957b98..0000000 --- a/x/epochs/keeper/genesis.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Asphere-xyz/tacchain/x/epochs/types" -) - -// InitGenesis sets epoch info from genesis -func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - for _, epoch := range genState.Epochs { - err := k.AddEpochInfo(ctx, epoch) - if err != nil { - panic(err) - } - } -} - -// ExportGenesis returns the capability module's exported genesis. -func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - genesis := types.DefaultGenesis() - genesis.Epochs = k.AllEpochInfos(ctx) - - return genesis -} diff --git a/x/epochs/keeper/grpc_query.go b/x/epochs/keeper/grpc_query.go deleted file mode 100644 index c7fa2e0..0000000 --- a/x/epochs/keeper/grpc_query.go +++ /dev/null @@ -1,56 +0,0 @@ -package keeper - -import ( - "context" - "errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/Asphere-xyz/tacchain/x/epochs/types" -) - -var _ types.QueryServer = Querier{} - -// Querier defines a wrapper around the x/epochs keeper providing gRPC method -// handlers. -type Querier struct { - Keeper -} - -// NewQuerier initializes new querier. -func NewQuerier(k Keeper) Querier { - return Querier{Keeper: k} -} - -// EpochInfos provide running epochInfos. -func (q Querier) EpochInfos(c context.Context, _ *types.QueryEpochsInfoRequest) (*types.QueryEpochsInfoResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - return &types.QueryEpochsInfoResponse{ - Epochs: q.Keeper.AllEpochInfos(ctx), - }, nil -} - -// CurrentEpoch provides current epoch of specified identifier. -func (q Querier) CurrentEpoch(c context.Context, req *types.QueryCurrentEpochRequest) (*types.QueryCurrentEpochResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if req.Identifier == "" { - return nil, status.Error(codes.InvalidArgument, "identifier is empty") - } - - ctx := sdk.UnwrapSDKContext(c) - - info := q.Keeper.GetEpochInfo(ctx, req.Identifier) - if info.Identifier != req.Identifier { - return nil, errors.New("not available identifier") - } - - return &types.QueryCurrentEpochResponse{ - CurrentEpoch: info.CurrentEpoch, - }, nil -} diff --git a/x/epochs/keeper/hooks.go b/x/epochs/keeper/hooks.go deleted file mode 100644 index 77cc630..0000000 --- a/x/epochs/keeper/hooks.go +++ /dev/null @@ -1,17 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// AfterEpochEnd gets called at the end of the epoch, end of epoch is the timestamp of first block produced after epoch duration. -func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber int64) { - // Error is not handled as AfterEpochEnd Hooks use osmoutils.ApplyFuncIfNoError() - _ = k.hooks.AfterEpochEnd(ctx, identifier, epochNumber) -} - -// BeforeEpochStart new epoch is next block of epoch end block -func (k Keeper) BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber int64) { - // Error is not handled as BeforeEpochStart Hooks use osmoutils.ApplyFuncIfNoError() - _ = k.hooks.BeforeEpochStart(ctx, identifier, epochNumber) -} diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go deleted file mode 100644 index 21daadf..0000000 --- a/x/epochs/keeper/keeper.go +++ /dev/null @@ -1,44 +0,0 @@ -package keeper - -import ( - "fmt" - - "cosmossdk.io/log" - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Asphere-xyz/tacchain/x/epochs/types" -) - -type ( - Keeper struct { - storeKey storetypes.StoreKey - hooks types.EpochHooks - } -) - -// NewKeeper returns a new keeper by codec and storeKey inputs. -func NewKeeper(storeKey storetypes.StoreKey) *Keeper { - return &Keeper{ - storeKey: storeKey, - } -} - -// Set the gamm hooks. -func (k *Keeper) SetHooks(eh types.EpochHooks) *Keeper { - if k.hooks != nil { - panic("cannot set epochs hooks twice") - } - - k.hooks = eh - - return k -} - -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} - -func (k Keeper) HooksIsNil() bool { - return k.hooks == nil -} diff --git a/x/epochs/module.go b/x/epochs/module.go deleted file mode 100644 index 26f99f2..0000000 --- a/x/epochs/module.go +++ /dev/null @@ -1,158 +0,0 @@ -/* -Often in the SDK, we would like to run certain code every-so often. The -purpose of `epochs` module is to allow other modules to set that they -would like to be signaled once every period. So another module can -specify it wants to execute code once a week, starting at UTC-time = x. -`epochs` creates a generalized epoch interface to other modules so that -they can easily be signalled upon such events. - - Contains functionality for querying epoch. - - Events for BeginBlock and EndBlock. - - Initialization for epoch-related infos. -*/ - -package epochs - -import ( - "context" - "encoding/json" - "fmt" - - "cosmossdk.io/core/appmodule" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/Asphere-xyz/tacchain/x/epochs/client/cli" - "github.com/Asphere-xyz/tacchain/x/epochs/keeper" - "github.com/Asphere-xyz/tacchain/x/epochs/types" -) - -var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ appmodule.HasBeginBlocker = AppModule{} -) - -// ---------------------------------------------------------------------------- -// AppModuleBasic -// ---------------------------------------------------------------------------- - -// AppModuleBasic implements the AppModuleBasic interface for the capability module. -type AppModuleBasic struct{} - -func NewAppModuleBasic() AppModuleBasic { - return AppModuleBasic{} -} - -// Name returns the capability module's name. -func (AppModuleBasic) Name() string { - return types.ModuleName -} - -// RegisterLegacyAminoCodec registers the module's Amino codec that properly handles protobuf types with Any's. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} - -// RegisterInterfaces registers the module's interface types. -func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {} - -// DefaultGenesis returns the capability module's default genesis state. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) -} - -// ValidateGenesis performs genesis state validation for the capability module. -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var genState types.GenesisState - if err := cdc.UnmarshalJSON(bz, &genState); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } - - return genState.Validate() -} - -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - panic(err) - } -} - -// GetTxCmd returns no root tx command for the halving module. -func (a AppModuleBasic) GetTxCmd() *cobra.Command { return nil } - -// GetQueryCmd returns the capability module's root query command. -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() -} - -// ---------------------------------------------------------------------------- -// AppModule -// ---------------------------------------------------------------------------- - -// AppModule implements the AppModule interface for the capability module. -type AppModule struct { - AppModuleBasic - - keeper keeper.Keeper -} - -func NewAppModule(keeper keeper.Keeper) AppModule { - return AppModule{ - AppModuleBasic: NewAppModuleBasic(), - keeper: keeper, - } -} - -// Name returns the capability module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - -// RegisterServices registers a GRPC query service to respond to the -// module-specific GRPC queries. -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) -} - -// RegisterInvariants registers the capability module's invariants. -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} - -// InitGenesis performs the capability module's genesis initialization It returns -// no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { - var genState types.GenesisState - // Initialize global index to index in genesis state - cdc.MustUnmarshalJSON(gs, &genState) - - am.keeper.InitGenesis(ctx, genState) - - return []abci.ValidatorUpdate{} -} - -// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := am.keeper.ExportGenesis(ctx) - return cdc.MustMarshalJSON(genState) -} - -// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(ctx context.Context) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - am.keeper.BeginBlocker(sdkCtx) - return nil -} - -// ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } - -// IsAppModule implements the appmodule.AppModule interface. -func (am AppModule) IsAppModule() {} - -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} diff --git a/x/epochs/types/doc.go b/x/epochs/types/doc.go deleted file mode 100644 index c1b138d..0000000 --- a/x/epochs/types/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -/* -Package types translates gRPC into RESTful JSON APIs. -*/ -package types diff --git a/x/epochs/types/errors.go b/x/epochs/types/errors.go deleted file mode 100644 index 862294b..0000000 --- a/x/epochs/types/errors.go +++ /dev/null @@ -1,12 +0,0 @@ -package types - -// DONTCOVER - -import ( - "cosmossdk.io/errors" -) - -// x/epochs module sentinel errors. -var ( - ErrSample = errors.Register(ModuleName, 1100, "sample error") -) diff --git a/x/epochs/types/events.go b/x/epochs/types/events.go deleted file mode 100644 index da0ac83..0000000 --- a/x/epochs/types/events.go +++ /dev/null @@ -1,9 +0,0 @@ -package types - -const ( - EventTypeEpochEnd = "epoch_end" - EventTypeEpochStart = "epoch_start" - - AttributeEpochNumber = "epoch_number" - AttributeEpochStartTime = "start_time" -) diff --git a/x/epochs/types/genesis.go b/x/epochs/types/genesis.go deleted file mode 100644 index 613c111..0000000 --- a/x/epochs/types/genesis.go +++ /dev/null @@ -1,77 +0,0 @@ -package types - -import ( - "errors" - "time" -) - -// DefaultIndex is the default capability global index. -const DefaultIndex uint64 = 1 - -func NewGenesisState(epochs []EpochInfo) *GenesisState { - return &GenesisState{Epochs: epochs} -} - -// DefaultGenesis returns the default Capability genesis state. -func DefaultGenesis() *GenesisState { - epochs := []EpochInfo{ - NewGenesisEpochInfo("day", time.Hour*24), // alphabetical order - NewGenesisEpochInfo("hour", time.Hour), - NewGenesisEpochInfo("week", time.Hour*24*7), - } - - return NewGenesisState(epochs) -} - -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { - epochIdentifiers := map[string]bool{} - - for _, epoch := range gs.Epochs { - if err := epoch.Validate(); err != nil { - return err - } - - if epochIdentifiers[epoch.Identifier] { - return errors.New("epoch identifier should be unique") - } - - epochIdentifiers[epoch.Identifier] = true - } - - return nil -} - -// Validate also validates epoch info. -func (epoch EpochInfo) Validate() error { - if epoch.Identifier == "" { - return errors.New("epoch identifier should NOT be empty") - } - - if epoch.Duration == 0 { - return errors.New("epoch duration should NOT be 0") - } - - if epoch.CurrentEpoch < 0 { - return errors.New("epoch CurrentEpoch must be non-negative") - } - - if epoch.CurrentEpochStartHeight < 0 { - return errors.New("epoch CurrentEpoch must be non-negative") - } - - return nil -} - -func NewGenesisEpochInfo(identifier string, duration time.Duration) EpochInfo { - return EpochInfo{ - Identifier: identifier, - StartTime: time.Time{}, - Duration: duration, - CurrentEpoch: 0, - CurrentEpochStartHeight: 0, - CurrentEpochStartTime: time.Time{}, - EpochCountingStarted: false, - } -} diff --git a/x/epochs/types/genesis.pb.go b/x/epochs/types/genesis.pb.go deleted file mode 100644 index 2f50a26..0000000 --- a/x/epochs/types/genesis.pb.go +++ /dev/null @@ -1,786 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tac/epochs/v1beta1/genesis.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - _ "google.golang.org/protobuf/types/known/durationpb" - _ "google.golang.org/protobuf/types/known/timestamppb" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// 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 EpochInfo struct { - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` - Duration time.Duration `protobuf:"bytes,3,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"` - CurrentEpoch int64 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` - CurrentEpochStartTime time.Time `protobuf:"bytes,5,opt,name=current_epoch_start_time,json=currentEpochStartTime,proto3,stdtime" json:"current_epoch_start_time" yaml:"current_epoch_start_time"` - EpochCountingStarted bool `protobuf:"varint,6,opt,name=epoch_counting_started,json=epochCountingStarted,proto3" json:"epoch_counting_started,omitempty"` - CurrentEpochStartHeight int64 `protobuf:"varint,8,opt,name=current_epoch_start_height,json=currentEpochStartHeight,proto3" json:"current_epoch_start_height,omitempty"` -} - -func (m *EpochInfo) Reset() { *m = EpochInfo{} } -func (m *EpochInfo) String() string { return proto.CompactTextString(m) } -func (*EpochInfo) ProtoMessage() {} -func (*EpochInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_e08a20027305544d, []int{0} -} -func (m *EpochInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EpochInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EpochInfo.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 *EpochInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_EpochInfo.Merge(m, src) -} -func (m *EpochInfo) XXX_Size() int { - return m.Size() -} -func (m *EpochInfo) XXX_DiscardUnknown() { - xxx_messageInfo_EpochInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_EpochInfo proto.InternalMessageInfo - -func (m *EpochInfo) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -func (m *EpochInfo) GetStartTime() time.Time { - if m != nil { - return m.StartTime - } - return time.Time{} -} - -func (m *EpochInfo) GetDuration() time.Duration { - if m != nil { - return m.Duration - } - return 0 -} - -func (m *EpochInfo) GetCurrentEpoch() int64 { - if m != nil { - return m.CurrentEpoch - } - return 0 -} - -func (m *EpochInfo) GetCurrentEpochStartTime() time.Time { - if m != nil { - return m.CurrentEpochStartTime - } - return time.Time{} -} - -func (m *EpochInfo) GetEpochCountingStarted() bool { - if m != nil { - return m.EpochCountingStarted - } - return false -} - -func (m *EpochInfo) GetCurrentEpochStartHeight() int64 { - if m != nil { - return m.CurrentEpochStartHeight - } - return 0 -} - -// GenesisState defines the epochs module's genesis state. -type GenesisState struct { - Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"` -} - -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_e08a20027305544d, []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 - -func (m *GenesisState) GetEpochs() []EpochInfo { - if m != nil { - return m.Epochs - } - return nil -} - -func init() { - proto.RegisterType((*EpochInfo)(nil), "tac.epochs.v1beta1.EpochInfo") - proto.RegisterType((*GenesisState)(nil), "tac.epochs.v1beta1.GenesisState") -} - -func init() { proto.RegisterFile("tac/epochs/v1beta1/genesis.proto", fileDescriptor_e08a20027305544d) } - -var fileDescriptor_e08a20027305544d = []byte{ - // 480 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xb1, 0x8e, 0xd3, 0x40, - 0x14, 0xcc, 0x92, 0x10, 0x9c, 0xbd, 0x43, 0xc0, 0xea, 0x00, 0x13, 0xe9, 0x6c, 0xcb, 0x34, 0x96, - 0x80, 0xb5, 0x72, 0x50, 0x71, 0x15, 0x01, 0xc4, 0x01, 0x9d, 0x43, 0x81, 0x68, 0xa2, 0x8d, 0xb3, - 0xb1, 0x57, 0x3a, 0x7b, 0x2d, 0xfb, 0x19, 0x5d, 0xa8, 0xf8, 0x84, 0x94, 0x7c, 0xd2, 0x95, 0x57, - 0x52, 0x05, 0x94, 0x74, 0x94, 0xf7, 0x05, 0xc8, 0xbb, 0x76, 0x08, 0x04, 0x44, 0x97, 0xbc, 0x99, - 0x37, 0xb3, 0x33, 0x7a, 0xc6, 0x0e, 0xb0, 0xd0, 0xe7, 0x99, 0x0c, 0xe3, 0xc2, 0xff, 0x38, 0x98, - 0x70, 0x60, 0x03, 0x3f, 0xe2, 0x29, 0x2f, 0x44, 0x41, 0xb3, 0x5c, 0x82, 0x24, 0x04, 0x58, 0x48, - 0x35, 0x83, 0xd6, 0x8c, 0xfe, 0x41, 0x24, 0x23, 0xa9, 0x60, 0xbf, 0xfa, 0xa5, 0x99, 0x7d, 0x2b, - 0x92, 0x32, 0x3a, 0xe5, 0xbe, 0xfa, 0x37, 0x29, 0x67, 0xfe, 0xb4, 0xcc, 0x19, 0x08, 0x99, 0xd6, - 0xb8, 0xfd, 0x27, 0x0e, 0x22, 0xe1, 0x05, 0xb0, 0x24, 0xd3, 0x04, 0x77, 0xd1, 0xc1, 0xbd, 0x97, - 0x95, 0xd3, 0xeb, 0x74, 0x26, 0x89, 0x85, 0xb1, 0x98, 0xf2, 0x14, 0xc4, 0x4c, 0xf0, 0xdc, 0x44, - 0x0e, 0xf2, 0x7a, 0xc1, 0xd6, 0x84, 0xbc, 0xc7, 0xb8, 0x00, 0x96, 0xc3, 0xb8, 0x92, 0x31, 0xaf, - 0x38, 0xc8, 0xdb, 0x3b, 0xea, 0x53, 0xed, 0x41, 0x1b, 0x0f, 0xfa, 0xae, 0xf1, 0x18, 0x1e, 0x9e, - 0x2f, 0xed, 0xd6, 0xe5, 0xd2, 0xbe, 0x35, 0x67, 0xc9, 0xe9, 0x53, 0xf7, 0xd7, 0xae, 0xbb, 0xf8, - 0x66, 0xa3, 0xa0, 0xa7, 0x06, 0x15, 0x9d, 0xc4, 0xd8, 0x68, 0x9e, 0x6e, 0xb6, 0x95, 0xee, 0xbd, - 0x1d, 0xdd, 0x17, 0x35, 0x61, 0x38, 0xa8, 0x64, 0x7f, 0x2c, 0x6d, 0xd2, 0xac, 0x3c, 0x94, 0x89, - 0x00, 0x9e, 0x64, 0x30, 0xbf, 0x5c, 0xda, 0x37, 0xb4, 0x59, 0x83, 0xb9, 0x5f, 0x2a, 0xab, 0x8d, - 0x3a, 0xb9, 0x8f, 0xaf, 0x87, 0x65, 0x9e, 0xf3, 0x14, 0xc6, 0xaa, 0x62, 0xb3, 0xe3, 0x20, 0xaf, - 0x1d, 0xec, 0xd7, 0x43, 0x55, 0x06, 0xf9, 0x8c, 0xb0, 0xf9, 0x1b, 0x6b, 0xbc, 0x95, 0xfb, 0xea, - 0x7f, 0x73, 0x3f, 0xa8, 0x73, 0xdb, 0xfa, 0x29, 0xff, 0x52, 0xd2, 0x2d, 0xdc, 0xde, 0x76, 0x1e, - 0x6d, 0x1a, 0x79, 0x82, 0xef, 0x68, 0x7e, 0x28, 0xcb, 0x14, 0x44, 0x1a, 0xe9, 0x45, 0x3e, 0x35, - 0xbb, 0x0e, 0xf2, 0x8c, 0xe0, 0x40, 0xa1, 0xcf, 0x6b, 0x70, 0xa4, 0x31, 0x72, 0x8c, 0xfb, 0x7f, - 0x73, 0x8b, 0xb9, 0x88, 0x62, 0x30, 0x0d, 0x15, 0xf5, 0xee, 0x8e, 0xe1, 0x89, 0x82, 0xdf, 0x74, - 0x8c, 0x6b, 0x37, 0x0d, 0xf7, 0x2d, 0xde, 0x7f, 0xa5, 0xcf, 0x71, 0x04, 0x0c, 0x38, 0x39, 0xc6, - 0x5d, 0x7d, 0x8b, 0x26, 0x72, 0xda, 0xde, 0xde, 0xd1, 0x21, 0xdd, 0x3d, 0x4f, 0xba, 0xb9, 0xa1, - 0x61, 0xa7, 0xca, 0x1e, 0xd4, 0x2b, 0xc3, 0x93, 0xf3, 0x95, 0x85, 0x2e, 0x56, 0x16, 0xfa, 0xbe, - 0xb2, 0xd0, 0x62, 0x6d, 0xb5, 0x2e, 0xd6, 0x56, 0xeb, 0xeb, 0xda, 0x6a, 0x7d, 0xa0, 0x91, 0x80, - 0xb8, 0x9c, 0xd0, 0x50, 0x26, 0xfe, 0xb3, 0x22, 0x8b, 0x79, 0xce, 0x1f, 0x9d, 0xcd, 0x3f, 0xf9, - 0xc0, 0xc2, 0x30, 0x66, 0x22, 0xf5, 0xcf, 0x9a, 0x8f, 0x04, 0xe6, 0x19, 0x2f, 0x26, 0x5d, 0xd5, - 0xf3, 0xe3, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x33, 0x44, 0x86, 0xcf, 0x3f, 0x03, 0x00, 0x00, -} - -func (m *EpochInfo) 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 *EpochInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EpochInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.CurrentEpochStartHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpochStartHeight)) - i-- - dAtA[i] = 0x40 - } - if m.EpochCountingStarted { - i-- - if m.EpochCountingStarted { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } - n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CurrentEpochStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintGenesis(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x2a - if m.CurrentEpoch != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpoch)) - i-- - dAtA[i] = 0x20 - } - n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.Duration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintGenesis(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x1a - n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) - if err3 != nil { - return 0, err3 - } - i -= n3 - i = encodeVarintGenesis(dAtA, i, uint64(n3)) - i-- - dAtA[i] = 0x12 - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0xa - } - 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.Epochs) > 0 { - for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Epochs[iNdEx].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 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 *EpochInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) - n += 1 + l + sovGenesis(uint64(l)) - l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration) - n += 1 + l + sovGenesis(uint64(l)) - if m.CurrentEpoch != 0 { - n += 1 + sovGenesis(uint64(m.CurrentEpoch)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime) - n += 1 + l + sovGenesis(uint64(l)) - if m.EpochCountingStarted { - n += 2 - } - if m.CurrentEpochStartHeight != 0 { - n += 1 + sovGenesis(uint64(m.CurrentEpochStartHeight)) - } - return n -} - -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Epochs) > 0 { - for _, e := range m.Epochs { - l = e.Size() - 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 *EpochInfo) 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: EpochInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EpochInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Duration", 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 := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) - } - m.CurrentEpoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CurrentEpoch |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CurrentEpochStartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochCountingStarted", wireType) - } - 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.EpochCountingStarted = bool(v != 0) - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartHeight", wireType) - } - m.CurrentEpochStartHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CurrentEpochStartHeight |= int64(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 Epochs", 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.Epochs = append(m.Epochs, EpochInfo{}) - if err := m.Epochs[len(m.Epochs)-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 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/epochs/types/hooks.go b/x/epochs/types/hooks.go deleted file mode 100644 index 780ad13..0000000 --- a/x/epochs/types/hooks.go +++ /dev/null @@ -1,59 +0,0 @@ -package types - -import ( - fmt "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Asphere-xyz/tacchain/utils" -) - -type EpochHooks interface { - // the first block whose timestamp is after the duration is counted as the end of the epoch - AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error - // new epoch is next block of epoch end block - BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error -} - -var _ EpochHooks = MultiEpochHooks{} - -// combine multiple gamm hooks, all hook functions are run in array sequence. -type MultiEpochHooks []EpochHooks - -func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks { - return hooks -} - -// AfterEpochEnd is called when epoch is going to be ended, epochNumber is the number of epoch that is ending. -func (h MultiEpochHooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - for i := range h { - panicCatchingEpochHook(ctx, h[i].AfterEpochEnd, epochIdentifier, epochNumber) - } - - return nil -} - -// BeforeEpochStart is called when epoch is going to be started, epochNumber is the number of epoch that is starting. -func (h MultiEpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - for i := range h { - panicCatchingEpochHook(ctx, h[i].BeforeEpochStart, epochIdentifier, epochNumber) - } - - return nil -} - -func panicCatchingEpochHook( - ctx sdk.Context, - hookFn func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error, - epochIdentifier string, - epochNumber int64, -) { - wrappedHookFn := func(ctx sdk.Context) error { - return hookFn(ctx, epochIdentifier, epochNumber) - } - // TODO: Thread info for which hook this is, may be dependent on larger hook system refactoring - err := utils.ApplyFuncIfNoError(ctx, wrappedHookFn) - if err != nil { - ctx.Logger().Error(fmt.Sprintf("error in epoch hook %v", err)) - } -} diff --git a/x/epochs/types/keys.go b/x/epochs/types/keys.go deleted file mode 100644 index 4f3a602..0000000 --- a/x/epochs/types/keys.go +++ /dev/null @@ -1,12 +0,0 @@ -package types - -const ( - // ModuleName defines the module name. - ModuleName = "epochs" - - // StoreKey defines the primary module store key. - StoreKey = ModuleName -) - -// KeyPrefixEpoch defines prefix key for storing epochs. -var KeyPrefixEpoch = []byte{0x01} diff --git a/x/epochs/types/query.pb.go b/x/epochs/types/query.pb.go deleted file mode 100644 index 2034ed1..0000000 --- a/x/epochs/types/query.pb.go +++ /dev/null @@ -1,910 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tac/epochs/v1beta1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "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" - 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 QueryEpochsInfoRequest struct { -} - -func (m *QueryEpochsInfoRequest) Reset() { *m = QueryEpochsInfoRequest{} } -func (m *QueryEpochsInfoRequest) String() string { return proto.CompactTextString(m) } -func (*QueryEpochsInfoRequest) ProtoMessage() {} -func (*QueryEpochsInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9757813b51bf78cb, []int{0} -} -func (m *QueryEpochsInfoRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryEpochsInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryEpochsInfoRequest.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 *QueryEpochsInfoRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEpochsInfoRequest.Merge(m, src) -} -func (m *QueryEpochsInfoRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryEpochsInfoRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEpochsInfoRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryEpochsInfoRequest proto.InternalMessageInfo - -type QueryEpochsInfoResponse struct { - Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"` -} - -func (m *QueryEpochsInfoResponse) Reset() { *m = QueryEpochsInfoResponse{} } -func (m *QueryEpochsInfoResponse) String() string { return proto.CompactTextString(m) } -func (*QueryEpochsInfoResponse) ProtoMessage() {} -func (*QueryEpochsInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9757813b51bf78cb, []int{1} -} -func (m *QueryEpochsInfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryEpochsInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryEpochsInfoResponse.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 *QueryEpochsInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEpochsInfoResponse.Merge(m, src) -} -func (m *QueryEpochsInfoResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryEpochsInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEpochsInfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryEpochsInfoResponse proto.InternalMessageInfo - -func (m *QueryEpochsInfoResponse) GetEpochs() []EpochInfo { - if m != nil { - return m.Epochs - } - return nil -} - -type QueryCurrentEpochRequest struct { - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` -} - -func (m *QueryCurrentEpochRequest) Reset() { *m = QueryCurrentEpochRequest{} } -func (m *QueryCurrentEpochRequest) String() string { return proto.CompactTextString(m) } -func (*QueryCurrentEpochRequest) ProtoMessage() {} -func (*QueryCurrentEpochRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9757813b51bf78cb, []int{2} -} -func (m *QueryCurrentEpochRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCurrentEpochRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCurrentEpochRequest.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 *QueryCurrentEpochRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCurrentEpochRequest.Merge(m, src) -} -func (m *QueryCurrentEpochRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryCurrentEpochRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCurrentEpochRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCurrentEpochRequest proto.InternalMessageInfo - -func (m *QueryCurrentEpochRequest) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -type QueryCurrentEpochResponse struct { - CurrentEpoch int64 `protobuf:"varint,1,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` -} - -func (m *QueryCurrentEpochResponse) Reset() { *m = QueryCurrentEpochResponse{} } -func (m *QueryCurrentEpochResponse) String() string { return proto.CompactTextString(m) } -func (*QueryCurrentEpochResponse) ProtoMessage() {} -func (*QueryCurrentEpochResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9757813b51bf78cb, []int{3} -} -func (m *QueryCurrentEpochResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCurrentEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCurrentEpochResponse.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 *QueryCurrentEpochResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCurrentEpochResponse.Merge(m, src) -} -func (m *QueryCurrentEpochResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryCurrentEpochResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCurrentEpochResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCurrentEpochResponse proto.InternalMessageInfo - -func (m *QueryCurrentEpochResponse) GetCurrentEpoch() int64 { - if m != nil { - return m.CurrentEpoch - } - return 0 -} - -func init() { - proto.RegisterType((*QueryEpochsInfoRequest)(nil), "tac.epochs.v1beta1.QueryEpochsInfoRequest") - proto.RegisterType((*QueryEpochsInfoResponse)(nil), "tac.epochs.v1beta1.QueryEpochsInfoResponse") - proto.RegisterType((*QueryCurrentEpochRequest)(nil), "tac.epochs.v1beta1.QueryCurrentEpochRequest") - proto.RegisterType((*QueryCurrentEpochResponse)(nil), "tac.epochs.v1beta1.QueryCurrentEpochResponse") -} - -func init() { proto.RegisterFile("tac/epochs/v1beta1/query.proto", fileDescriptor_9757813b51bf78cb) } - -var fileDescriptor_9757813b51bf78cb = []byte{ - // 396 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x6e, 0xd3, 0x30, - 0x18, 0x8f, 0x5b, 0xa8, 0x84, 0x29, 0x17, 0x0b, 0x41, 0x88, 0xc0, 0x2d, 0x41, 0x82, 0x0a, 0xa8, - 0xad, 0x96, 0x1b, 0x5c, 0xa0, 0x08, 0x09, 0x8e, 0xe4, 0xc0, 0x81, 0x0b, 0x72, 0x8d, 0x9b, 0x58, - 0x02, 0x3b, 0x8d, 0x1d, 0xd4, 0x72, 0xe4, 0x01, 0xd0, 0xa4, 0x1d, 0xf7, 0x1e, 0x7b, 0x86, 0x1e, - 0x2b, 0xed, 0xb2, 0xd3, 0x34, 0xb5, 0x7b, 0x90, 0xa9, 0x4e, 0xb6, 0x75, 0x6b, 0x2a, 0xf5, 0x96, - 0x7c, 0xbf, 0xbf, 0xdf, 0x97, 0x40, 0x6c, 0x19, 0xa7, 0x22, 0xd5, 0x3c, 0x31, 0xf4, 0x4f, 0x6f, - 0x28, 0x2c, 0xeb, 0xd1, 0x71, 0x2e, 0xb2, 0x29, 0x49, 0x33, 0x6d, 0x35, 0x42, 0x96, 0x71, 0x52, - 0xe0, 0xa4, 0xc4, 0x83, 0xfb, 0xb1, 0x8e, 0xb5, 0x83, 0xe9, 0xea, 0xa9, 0x60, 0x06, 0x8f, 0x63, - 0xad, 0xe3, 0x5f, 0x82, 0xb2, 0x54, 0x52, 0xa6, 0x94, 0xb6, 0xcc, 0x4a, 0xad, 0x4c, 0x89, 0xb6, - 0x2b, 0x72, 0x62, 0xa1, 0x84, 0x91, 0x25, 0x23, 0xf4, 0xe1, 0x83, 0xaf, 0xab, 0xe0, 0x4f, 0x8e, - 0xf4, 0x45, 0x8d, 0x74, 0x24, 0xc6, 0xb9, 0x30, 0x36, 0xfc, 0x06, 0x1f, 0x6e, 0x20, 0x26, 0xd5, - 0xca, 0x08, 0xf4, 0x0e, 0x36, 0x0a, 0x53, 0x1f, 0xb4, 0xeb, 0x9d, 0xbb, 0xfd, 0x27, 0x64, 0xb3, - 0x2f, 0x71, 0xba, 0x95, 0x6c, 0x70, 0x6b, 0x76, 0xd2, 0xf2, 0xa2, 0x52, 0x12, 0xbe, 0x85, 0xbe, - 0xf3, 0xfd, 0x98, 0x67, 0x99, 0x50, 0xd6, 0xd1, 0xca, 0x4c, 0x84, 0x21, 0x94, 0x3f, 0x85, 0xb2, - 0x72, 0x24, 0x45, 0xe6, 0x83, 0x36, 0xe8, 0xdc, 0x89, 0xd6, 0x26, 0xe1, 0x7b, 0xf8, 0xa8, 0x42, - 0x5b, 0xb6, 0x7a, 0x06, 0xef, 0xf1, 0x62, 0xfe, 0xc3, 0x45, 0x39, 0x7d, 0x3d, 0x6a, 0xf2, 0x35, - 0x72, 0xff, 0xb0, 0x06, 0x6f, 0x3b, 0x0b, 0xf4, 0x1f, 0x40, 0x78, 0xd9, 0xd1, 0xa0, 0x97, 0x55, - 0x3b, 0x54, 0x9f, 0x26, 0x78, 0xb5, 0x13, 0xb7, 0xa8, 0x15, 0xbe, 0xf8, 0x77, 0x74, 0xb6, 0x5f, - 0x7b, 0x8a, 0x5a, 0xd4, 0x32, 0xce, 0x13, 0x26, 0xd5, 0xcd, 0x2f, 0x52, 0xbc, 0xa2, 0x03, 0x00, - 0x9b, 0xeb, 0x8b, 0xa1, 0xd7, 0x5b, 0x63, 0x2a, 0x6e, 0x17, 0x74, 0x77, 0x64, 0x97, 0xb5, 0x88, - 0xab, 0xd5, 0x41, 0xcf, 0xb7, 0xd6, 0xba, 0x76, 0xcc, 0xc1, 0xe7, 0xd9, 0x02, 0x83, 0xf9, 0x02, - 0x83, 0xd3, 0x05, 0x06, 0x7b, 0x4b, 0xec, 0xcd, 0x97, 0xd8, 0x3b, 0x5e, 0x62, 0xef, 0x3b, 0x89, - 0xa5, 0x4d, 0xf2, 0x21, 0xe1, 0xfa, 0x37, 0xfd, 0x60, 0xd2, 0x44, 0x64, 0xa2, 0x3b, 0x99, 0xfe, - 0xbd, 0xf2, 0x9d, 0x5c, 0x38, 0xdb, 0x69, 0x2a, 0xcc, 0xb0, 0xe1, 0xfe, 0xbc, 0x37, 0xe7, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x2a, 0xba, 0x43, 0x72, 0x05, 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 { - // EpochInfos provide running epochInfos - EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) - // CurrentEpoch provide current epoch of specified identifier - CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) { - out := new(QueryEpochsInfoResponse) - err := c.cc.Invoke(ctx, "/tac.epochs.v1beta1.Query/EpochInfos", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) { - out := new(QueryCurrentEpochResponse) - err := c.cc.Invoke(ctx, "/tac.epochs.v1beta1.Query/CurrentEpoch", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // EpochInfos provide running epochInfos - EpochInfos(context.Context, *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) - // CurrentEpoch provide current epoch of specified identifier - CurrentEpoch(context.Context, *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) EpochInfos(ctx context.Context, req *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method EpochInfos not implemented") -} -func (*UnimplementedQueryServer) CurrentEpoch(ctx context.Context, req *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CurrentEpoch not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_EpochInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryEpochsInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).EpochInfos(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.epochs.v1beta1.Query/EpochInfos", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).EpochInfos(ctx, req.(*QueryEpochsInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_CurrentEpoch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCurrentEpochRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).CurrentEpoch(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.epochs.v1beta1.Query/CurrentEpoch", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).CurrentEpoch(ctx, req.(*QueryCurrentEpochRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "tac.epochs.v1beta1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "EpochInfos", - Handler: _Query_EpochInfos_Handler, - }, - { - MethodName: "CurrentEpoch", - Handler: _Query_CurrentEpoch_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "tac/epochs/v1beta1/query.proto", -} - -func (m *QueryEpochsInfoRequest) 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 *QueryEpochsInfoRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryEpochsInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryEpochsInfoResponse) 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 *QueryEpochsInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryEpochsInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Epochs) > 0 { - for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Epochs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryCurrentEpochRequest) 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 *QueryCurrentEpochRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCurrentEpochRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryCurrentEpochResponse) 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 *QueryCurrentEpochResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCurrentEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.CurrentEpoch != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpoch)) - 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 *QueryEpochsInfoRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryEpochsInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Epochs) > 0 { - for _, e := range m.Epochs { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryCurrentEpochRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryCurrentEpochResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CurrentEpoch != 0 { - n += 1 + sovQuery(uint64(m.CurrentEpoch)) - } - 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 *QueryEpochsInfoRequest) 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: QueryEpochsInfoRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryEpochsInfoRequest: 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 *QueryEpochsInfoResponse) 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: QueryEpochsInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryEpochsInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Epochs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Epochs = append(m.Epochs, EpochInfo{}) - if err := m.Epochs[len(m.Epochs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryCurrentEpochRequest) 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: QueryCurrentEpochRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCurrentEpochRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", 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.Identifier = 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 (m *QueryCurrentEpochResponse) 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: QueryCurrentEpochResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCurrentEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) - } - m.CurrentEpoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CurrentEpoch |= int64(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/epochs/types/query.pb.gw.go b/x/epochs/types/query.pb.gw.go deleted file mode 100644 index 6a1dc0a..0000000 --- a/x/epochs/types/query.pb.gw.go +++ /dev/null @@ -1,236 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: tac/epochs/v1beta1/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_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryEpochsInfoRequest - var metadata runtime.ServerMetadata - - msg, err := client.EpochInfos(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryEpochsInfoRequest - var metadata runtime.ServerMetadata - - msg, err := server.EpochInfos(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_CurrentEpoch_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCurrentEpochRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.CurrentEpoch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCurrentEpochRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.CurrentEpoch(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_EpochInfos_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_EpochInfos_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_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_CurrentEpoch_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_CurrentEpoch_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_CurrentEpoch_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_EpochInfos_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_EpochInfos_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_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_CurrentEpoch_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_CurrentEpoch_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_CurrentEpoch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_EpochInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"tacchain", "epochs", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_CurrentEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tacchain", "epochs", "v1beta1", "current_epoch"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_EpochInfos_0 = runtime.ForwardResponseMessage - - forward_Query_CurrentEpoch_0 = runtime.ForwardResponseMessage -) diff --git a/x/liquidstake/abci.go b/x/liquidstake/abci.go deleted file mode 100644 index 9ffc03d..0000000 --- a/x/liquidstake/abci.go +++ /dev/null @@ -1,20 +0,0 @@ -package liquidstake - -import ( - "time" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -func BeginBlock(ctx sdk.Context, k keeper.Keeper) { - defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) - - if !k.GetParams(ctx).ModulePaused { - // return value of UpdateLiquidValidatorSet is useful only in testing - _ = k.UpdateLiquidValidatorSet(ctx, false) - } -} diff --git a/x/liquidstake/client/cli/query.go b/x/liquidstake/client/cli/query.go deleted file mode 100644 index d919a51..0000000 --- a/x/liquidstake/client/cli/query.go +++ /dev/null @@ -1,152 +0,0 @@ -package cli - -import ( - "fmt" - "strings" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/version" - "github.com/spf13/cobra" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -// GetQueryCmd returns a root CLI command handler for all x/liquidstake query commands. -func GetQueryCmd() *cobra.Command { - liquidValidatorQueryCmd := &cobra.Command{ - Use: types.ModuleName, - Aliases: []string{"ls"}, - Short: "Querying commands for the liquidstake module", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - liquidValidatorQueryCmd.AddCommand( - GetCmdQueryParams(), - GetCmdQueryLiquidValidators(), - GetCmdQueryStates(), - ) - - return liquidValidatorQueryCmd -} - -// GetCmdQueryParams implements the params query command. -func GetCmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Args: cobra.NoArgs, - Short: "Query the values set as liquidstake parameters", - Long: strings.TrimSpace( - fmt.Sprintf(`Query values set as liquidstake parameters. - -Example: -$ %s query %s params -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.Params( - cmd.Context(), - &types.QueryParamsRequest{}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(&res.Params) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// GetCmdQueryLiquidValidators implements the query liquidValidators command. -func GetCmdQueryLiquidValidators() *cobra.Command { - cmd := &cobra.Command{ - Use: "liquid-validators", - Args: cobra.NoArgs, - Short: "Query all liquid validators", - Long: strings.TrimSpace( - fmt.Sprintf(`Queries all liquid validators. - -Example: -$ %s query %s liquid-validators -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.LiquidValidators( - cmd.Context(), - &types.QueryLiquidValidatorsRequest{}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// GetCmdQueryStates implements the query states command. -func GetCmdQueryStates() *cobra.Command { - cmd := &cobra.Command{ - Use: "states", - Args: cobra.NoArgs, - Short: "Query states", - Long: strings.TrimSpace( - fmt.Sprintf(`Queries states about net amount, mint rate. - -Example: -$ %s query %s states -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.States( - cmd.Context(), - &types.QueryStatesRequest{}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/liquidstake/client/cli/tx.go b/x/liquidstake/client/cli/tx.go deleted file mode 100644 index 79d8d7e..0000000 --- a/x/liquidstake/client/cli/tx.go +++ /dev/null @@ -1,332 +0,0 @@ -package cli - -// DONTCOVER -// client is excluded from test coverage in MVP version - -import ( - "encoding/json" - "fmt" - "os" - "strings" - - "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/cosmos/cosmos-sdk/version" - "github.com/spf13/cobra" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -// GetTxCmd returns a root CLI command handler for all x/liquidstake transaction commands. -func GetTxCmd() *cobra.Command { - liquidstakeTxCmd := &cobra.Command{ - Use: types.ModuleName, - Aliases: []string{"ls"}, - Short: "TAC liquid stake transaction subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - liquidstakeTxCmd.AddCommand( - NewLiquidStakeCmd(), - NewStakeToLPCmd(), - NewLiquidUnstakeCmd(), - NewUpdateParamsCmd(), - NewUpdateWhitelistedValidatorsCmd(), - NewSetModulePausedCmd(), - ) - - return liquidstakeTxCmd -} - -// NewLiquidStakeCmd implements the liquid stake TAC command handler. -func NewLiquidStakeCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "liquid-stake [amount]", - Args: cobra.ExactArgs(1), - Short: "Liquid-stake TAC", - Long: strings.TrimSpace( - fmt.Sprintf(`Liquid-stake TAC. - -Example: -$ %s tx %s liquid-stake 1000utac --from mykey -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - liquidStaker := clientCtx.GetFromAddress() - - stakingCoin, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - - msg := types.NewMsgLiquidStake(liquidStaker, stakingCoin) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewStakeToLPCmd implements the liquid stake TAC command handler. -func NewStakeToLPCmd() *cobra.Command { - bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() - - cmd := &cobra.Command{ - Use: "stake-to-lp [validator-addr] [staked_amount] [liquid_amount]", - Args: cobra.RangeArgs(2, 3), - Short: "Convert delegation into gTAC and lock into LP.", - Long: strings.TrimSpace( - fmt.Sprintf(`Convert delegation into gTAC and lock into LP. -Allows to specify both staked and non-staked TAC amounts to convert into gTAC and lock into LP. - -Examples: -$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000utac --from mykey -$ %s tx %s stake-to-lp %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 1000utac 5000utac --from mykey -`, - version.AppName, types.ModuleName, bech32PrefixValAddr, - version.AppName, types.ModuleName, bech32PrefixValAddr, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - liquidStaker := clientCtx.GetFromAddress() - - valAddr, err := sdk.ValAddressFromBech32(args[0]) - if err != nil { - return err - } - - stakedCoin, err := sdk.ParseCoinNormalized(args[1]) - if err != nil { - return err - } - - var liquidCoin sdk.Coin - if len(args) > 2 { - liquidCoin, err = sdk.ParseCoinNormalized(args[2]) - if err != nil { - return err - } - } - - msg := types.NewMsgStakeToLP(liquidStaker, valAddr, stakedCoin, liquidCoin) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewLiquidUnstakeCmd implements the liquid unstake TAC command handler. -func NewLiquidUnstakeCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "liquid-unstake [amount]", - Args: cobra.ExactArgs(1), - Short: "Liquid-unstake gTAC", - Long: strings.TrimSpace( - fmt.Sprintf(`Liquid-unstake gTAC. - -Example: -$ %s tx %s liquid-unstake 500stk/utac --from mykey -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - liquidStaker := clientCtx.GetFromAddress() - - unstakingCoin, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - - msg := types.NewMsgLiquidUnstake(liquidStaker, unstakingCoin) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewUpdateParamsCmd implements the params update command handler. -func NewUpdateParamsCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-params [params.json]", - Args: cobra.ExactArgs(1), - Short: "Update-params of liquidstake module.", - Long: strings.TrimSpace( - fmt.Sprintf(`update-params param-file. - -Example: -$ %s tx %s update-params ~/params.json --from mykey - -Example params.json -{ - "liquid_bond_denom": "stk/utac", - "whitelisted_validators": [ - { - "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", - "target_weight": "10" - } - ], - "lsm_disabled": false, - "unstake_fee_rate": "0.000000000000000000", - "min_liquid_staking_amount": "10000", - "cw_locked_pool_address": "tac14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjvz4fk" -} -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - var params types.Params - - paramsInFile, err := os.ReadFile(args[0]) - if err != nil { - return err - } - - err = json.Unmarshal(paramsInFile, ¶ms) - if err != nil { - return err - } - authority := clientCtx.GetFromAddress() - - msg := types.NewMsgUpdateParams(authority, params) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewUpdateWhitelistedValidatorsCmd implements the update of whitelisted validators command handler. -func NewUpdateWhitelistedValidatorsCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-whitelisted-validators [validators_list.json]", - Args: cobra.ExactArgs(1), - Short: "Update whitelisted validators in params of liquidstake module.", - Long: strings.TrimSpace( - fmt.Sprintf(`update-whitelisted-validators validators_list.json - -Example: -$ %s tx %s update-whitelisted-validators ~/validators_list.json --from mykey - -Example validators_list.json -[ - { - "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", - "target_weight": "10" - } -] -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - var validatorsList []types.WhitelistedValidator - - validatorsListFile, err := os.ReadFile(args[0]) - if err != nil { - return err - } - - err = json.Unmarshal(validatorsListFile, &validatorsList) - if err != nil { - return err - } - authority := clientCtx.GetFromAddress() - - msg := types.NewMsgUpdateWhitelistedValidators(authority, validatorsList) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewSetModulePausedCmd implements the command handler for updating of safety toggle that disables the module. -func NewSetModulePausedCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "pause-module [flag]", - Args: cobra.ExactArgs(1), - Short: "Pause or unpause the liquidstake module for an emergency updates.", - Long: strings.TrimSpace( - fmt.Sprintf(`pause-module [true/false] - -Example: -$ %s tx %s pause-module true --from mykey -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - isPaused := false - if strings.ToLower(args[0]) == "true" { - isPaused = true - } else if strings.ToLower(args[0]) != "false" { - err := fmt.Errorf("expected flag to be true or false – where 'true' means the module is paused") - return err - } - - authority := clientCtx.GetFromAddress() - msg := types.NewMsgSetModulePaused(authority, isPaused) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/liquidstake/keeper/genesis.go b/x/liquidstake/keeper/genesis.go deleted file mode 100644 index f03028b..0000000 --- a/x/liquidstake/keeper/genesis.go +++ /dev/null @@ -1,47 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -// InitGenesis initializes the liquidstake module's state from a given genesis state. -func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - if err := types.ValidateGenesis(genState); err != nil { - panic(err) - } - - // init to prevent nil slice, []types.WhitelistedValidator(nil) - if genState.Params.WhitelistedValidators == nil || len(genState.Params.WhitelistedValidators) == 0 { - genState.Params.WhitelistedValidators = []types.WhitelistedValidator{} - } - - if err := k.SetParams(ctx, genState.Params); err != nil { - panic(err) - } - - for _, lv := range genState.LiquidValidators { - k.SetLiquidValidator(ctx, lv) - } - - moduleAcc := k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) - if moduleAcc == nil { - panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) - } -} - -// ExportGenesis returns the liquidstake module's genesis state. -func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - params := k.GetParams(ctx) - - // init to prevent nil slice, []types.WhitelistedValidator(nil) - if params.WhitelistedValidators == nil || len(params.WhitelistedValidators) == 0 { - params.WhitelistedValidators = []types.WhitelistedValidator{} - } - - liquidValidators := k.GetAllLiquidValidators(ctx) - return types.NewGenesisState(params, liquidValidators) -} diff --git a/x/liquidstake/keeper/genesis_test.go b/x/liquidstake/keeper/genesis_test.go deleted file mode 100644 index 54ea26e..0000000 --- a/x/liquidstake/keeper/genesis_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package keeper_test - -import ( - _ "github.com/stretchr/testify/suite" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -func (s *KeeperTestSuite) TestInitGenesis() { - genState := *types.DefaultGenesisState() - s.keeper.InitGenesis(s.ctx, genState) - got := s.keeper.ExportGenesis(s.ctx) - s.Require().Equal(genState, *got) -} - -// func (s *KeeperTestSuite) TestImportExportGenesis() { -// k, ctx := s.keeper, s.ctx -// _, valOpers, _ := s.CreateValidators([]int64{1000000, 1000000, 1000000}) -// params := k.GetParams(ctx) -// -// params.WhitelistedValidators = []types.WhitelistedValidator{ -// {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(5000)}, -// {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(5000)}, -// } -// params.ModulePaused = false -// k.SetParams(ctx, params) -// k.UpdateLiquidValidatorSet(ctx, true) -// -// stakingAmt := math.NewInt(100000000) -// s.Require().NoError(s.liquidStaking(s.delAddrs[0], stakingAmt)) -// lvs := k.GetAllLiquidValidators(ctx) -// s.Require().Len(lvs, 2) -// -// lvStates := k.GetAllLiquidValidatorStates(ctx) -// genState := k.ExportGenesis(ctx) -// -// bz := s.app.AppCodec().MustMarshalJSON(genState) -// -// var genState2 types.GenesisState -// s.app.AppCodec().MustUnmarshalJSON(bz, &genState2) -// k.InitGenesis(ctx, genState2) -// genState3 := k.ExportGenesis(ctx) -// -// s.Require().Equal(*genState, genState2) -// s.Require().Equal(genState2, *genState3) -// -// lvs = k.GetAllLiquidValidators(ctx) -// s.Require().Len(lvs, 2) -// -// lvStates3 := k.GetAllLiquidValidatorStates(ctx) -// s.Require().EqualValues(lvStates, lvStates3) -// } - -func (s *KeeperTestSuite) TestImportExportGenesisEmpty() { - k, ctx := s.keeper, s.ctx - k.SetParams(ctx, types.DefaultParams()) - k.UpdateLiquidValidatorSet(ctx, true) - genState := k.ExportGenesis(ctx) - - var genState2 types.GenesisState - bz := s.app.AppCodec().MustMarshalJSON(genState) - s.app.AppCodec().MustUnmarshalJSON(bz, &genState2) - k.InitGenesis(ctx, genState2) - - genState3 := k.ExportGenesis(ctx) - s.Require().Equal(*genState, genState2) - s.Require().Equal(genState2, *genState3) -} diff --git a/x/liquidstake/keeper/grpc_query.go b/x/liquidstake/keeper/grpc_query.go deleted file mode 100644 index 62fdf05..0000000 --- a/x/liquidstake/keeper/grpc_query.go +++ /dev/null @@ -1,54 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -// Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper. -type Querier struct { - Keeper -} - -var _ types.QueryServer = Querier{} - -// Params queries the parameters of the liquidstake module. -func (k Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - params := k.GetParams(ctx) - - return &types.QueryParamsResponse{Params: params}, nil -} - -// LiquidValidators queries all liquid validators. -func (k Querier) LiquidValidators(c context.Context, req *types.QueryLiquidValidatorsRequest) (*types.QueryLiquidValidatorsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(c) - - return &types.QueryLiquidValidatorsResponse{LiquidValidators: k.GetAllLiquidValidatorStates(ctx)}, nil -} - -// States queries states of liquid stake module. -func (k Querier) States(c context.Context, req *types.QueryStatesRequest) (*types.QueryStatesResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(c) - - AmountState, err := k.GetNetAmountState(ctx) - if err != nil { - return nil, err - } - - return &types.QueryStatesResponse{NetAmountState: *AmountState}, nil -} diff --git a/x/liquidstake/keeper/hooks.go b/x/liquidstake/keeper/hooks.go deleted file mode 100644 index 82d624e..0000000 --- a/x/liquidstake/keeper/hooks.go +++ /dev/null @@ -1,43 +0,0 @@ -package keeper - -import ( - epochstypes "github.com/Asphere-xyz/tacchain/x/epochs/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - liquidstake "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -type EpochHooks struct { - k Keeper -} - -var _ epochstypes.EpochHooks = EpochHooks{} - -func (k Keeper) EpochHooks() EpochHooks { - return EpochHooks{k} -} - -func (h EpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - return h.k.BeforeEpochStart(ctx, epochIdentifier, epochNumber) -} - -func (h EpochHooks) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error { - // Nothing to do - return nil -} - -func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, _ int64) error { - if !k.GetParams(ctx).ModulePaused { - // Update the liquid validator set at the start of each epoch - if epochIdentifier == liquidstake.AutocompoundEpoch { - k.AutocompoundStakingRewards(ctx, liquidstake.GetWhitelistedValsMap(k.GetParams(ctx).WhitelistedValidators)) - } - - if epochIdentifier == liquidstake.RebalanceEpoch { - // return value of UpdateLiquidValidatorSet is useful only in testing - _ = k.UpdateLiquidValidatorSet(ctx, true) - } - } - - return nil -} diff --git a/x/liquidstake/keeper/keeper.go b/x/liquidstake/keeper/keeper.go deleted file mode 100644 index 332be00..0000000 --- a/x/liquidstake/keeper/keeper.go +++ /dev/null @@ -1,107 +0,0 @@ -package keeper - -import ( - "fmt" - - "cosmossdk.io/log" - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -// Keeper of the liquidstake store -type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - - accountKeeper authkeeper.AccountKeeper - bankKeeper bankkeeper.BaseKeeper - stakingKeeper stakingkeeper.Keeper - mintKeeper mintkeeper.Keeper - distrKeeper distrkeeper.Keeper - slashingKeeper slashingkeeper.Keeper - - router *baseapp.MsgServiceRouter - authority string -} - -// NewKeeper returns a liquidstake keeper. -func NewKeeper( - cdc codec.BinaryCodec, - storeKey storetypes.StoreKey, - accountKeeper authkeeper.AccountKeeper, - bankKeeper bankkeeper.BaseKeeper, - stakingKeeper stakingkeeper.Keeper, - mintKeeper mintkeeper.Keeper, - distrKeeper distrkeeper.Keeper, - slashingKeeper slashingkeeper.Keeper, - router *baseapp.MsgServiceRouter, - authority string, -) Keeper { - // ensure liquidstake module account is set - if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { - panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) - } - - return Keeper{ - cdc: cdc, - storeKey: storeKey, - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, - stakingKeeper: stakingKeeper, - mintKeeper: mintKeeper, - distrKeeper: distrKeeper, - slashingKeeper: slashingKeeper, - router: router, - authority: authority, - } -} - -// Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) -} - -// SetParams sets the auth module's parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - if err := params.Validate(); err != nil { - return err - } - - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(¶ms) - store.Set(types.ParamsKey, bz) - - return nil -} - -// GetParams gets the auth module's parameters. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(types.ParamsKey) - if bz == nil { - return params - } - - k.cdc.MustUnmarshal(bz, ¶ms) - return params -} - -// GetCodec return codec.Codec object used by the keeper -func (k Keeper) GetCodec() codec.BinaryCodec { return k.cdc } - -// Router returns the keeper's msg router -func (k Keeper) Router() *baseapp.MsgServiceRouter { - return k.router -} diff --git a/x/liquidstake/keeper/keeper_test.go b/x/liquidstake/keeper/keeper_test.go deleted file mode 100644 index 02dd42f..0000000 --- a/x/liquidstake/keeper/keeper_test.go +++ /dev/null @@ -1,479 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - "time" - - "cosmossdk.io/log" - "cosmossdk.io/math" - testhelpers "github.com/Asphere-xyz/tacchain/app/helpers" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - "github.com/cosmos/cosmos-sdk/x/crisis" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/mint" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/suite" - - chain "github.com/Asphere-xyz/tacchain/app" - "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" - dbm "github.com/cosmos/cosmos-db" -) - -var BlockTime = 6 * time.Second - -type KeeperTestSuite struct { - suite.Suite - - app *chain.TacChainApp - ctx sdk.Context - keeper keeper.Keeper - querier keeper.Querier - addrs []sdk.AccAddress - delAddrs []sdk.AccAddress - valAddrs []sdk.ValAddress -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) -} - -func (s *KeeperTestSuite) SetupTest() { - db := dbm.NewMemDB() - logger := log.NewTestLogger(s.T()) - app := chain.NewTacChainAppWithCustomOptions(s.T(), false, 0, chain.SetupOptions{ - Logger: logger.With("instance", "first"), - DB: db, - AppOpts: simtestutil.NewAppOptionsWithFlagHome(s.T().TempDir()), - }) - s.app = app - s.ctx = s.app.BaseApp.NewContext(false) - stakingParams := stakingtypes.DefaultParams() - stakingParams.MaxEntries = 7 - stakingParams.MaxValidators = 30 - s.Require().NoError(s.app.StakingKeeper.SetParams(s.ctx, stakingParams)) - - s.keeper = s.app.LiquidStakeKeeper - s.querier = keeper.Querier{Keeper: s.keeper} - s.addrs = chain.AddTestAddrs(s.app, s.ctx, 10, math.NewInt(1_000_000_000)) - s.delAddrs = chain.AddTestAddrs(s.app, s.ctx, 10, math.NewInt(1_000_000_000)) - s.valAddrs = chain.ConvertAddrsToValAddrs(s.delAddrs) - - s.ctx = s.ctx.WithBlockHeight(100).WithBlockTime(chain.ParseTime("2022-03-01T00:00:00Z")) - params := s.keeper.GetParams(s.ctx) - params.UnstakeFeeRate = sdk.ZeroDec() - params.AutocompoundFeeRate = types.DefaultAutocompoundFeeRate - s.Require().NoError(s.keeper.SetParams(s.ctx, params)) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - // call mint.BeginBlocker for init k.SetLastBlockTime(ctx, ctx.BlockTime()) - mint.BeginBlocker(s.ctx, s.app.MintKeeper, minttypes.DefaultInflationCalculationFn) -} - -func (s *KeeperTestSuite) TearDownTest() { - // invariant check - crisis.EndBlocker(s.ctx, *s.app.CrisisKeeper) -} - -func (s *KeeperTestSuite) CreateValidators(powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []cryptotypes.PubKey) { - s.app.BeginBlocker(s.ctx) - num := len(powers) - addrs := testhelpers.AddTestAddrsIncremental(s.app, s.ctx, num, math.NewInt(10000000000000)) - valAddrs := testhelpers.ConvertAddrsToValAddrs(addrs) - pks := testhelpers.CreateTestPubKeys(num) - skParams, err := s.app.StakingKeeper.GetParams(s.ctx) - s.Require().NoError(err) - skParams.ValidatorLiquidStakingCap = sdk.OneDec() - _ = s.app.StakingKeeper.SetParams(s.ctx, skParams) - for i, power := range powers { - val, err := stakingtypes.NewValidator(valAddrs[i].String(), pks[i], stakingtypes.Description{}) - s.Require().NoError(err) - s.app.StakingKeeper.SetValidator(s.ctx, val) - err = s.app.StakingKeeper.SetValidatorByConsAddr(s.ctx, val) - s.Require().NoError(err) - s.app.StakingKeeper.SetNewValidatorByPowerIndex(s.ctx, val) - _ = s.app.StakingKeeper.Hooks().AfterValidatorCreated(s.ctx, valAddrs[i]) - newShares, err := s.app.StakingKeeper.Delegate(s.ctx, addrs[i], math.NewInt(power), stakingtypes.Unbonded, val, true) - s.Require().NoError(err) - s.Require().Equal(newShares.TruncateInt(), math.NewInt(power)) - msgValidatorBond := &stakingtypes.MsgValidatorBond{ - DelegatorAddress: addrs[i].String(), - ValidatorAddress: val.OperatorAddress, - } - handler := s.app.MsgServiceRouter().Handler(msgValidatorBond) - _, err = handler(s.ctx, msgValidatorBond) - s.Require().NoError(err) - } - - s.app.EndBlocker(s.ctx) - return addrs, valAddrs, pks -} - -func (s *KeeperTestSuite) liquidStaking(liquidStaker sdk.AccAddress, stakingAmt math.Int) error { - ctx, writeCache := s.ctx.CacheContext() - params := s.keeper.GetParams(ctx) - - gtacBalanceBefore := s.app.BankKeeper.GetBalance( - ctx, liquidStaker, params.LiquidBondDenom, - ).Amount - - gTACMintAmt, err := s.keeper.LiquidStake( - ctx, - types.LiquidStakeProxyAcc, - liquidStaker, - sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), - ) - if err != nil { - return err - } - - gtacBalanceAfter := s.app.BankKeeper.GetBalance( - ctx, liquidStaker, params.LiquidBondDenom, - ).Amount - - s.Require().NoError(err) - s.Require().EqualValues( - gTACMintAmt, gtacBalanceAfter.Sub(gtacBalanceBefore), - ) - writeCache() - - return nil -} - -func (s *KeeperTestSuite) liquidUnstaking( - liquidStaker sdk.AccAddress, - ubdGTACAmt math.Int, - ubdComplete bool, -) error { - ctx := s.ctx - params := s.keeper.GetParams(ctx) - - balanceBefore := s.app.BankKeeper.GetBalance( - ctx, - liquidStaker, - sdk.DefaultBondDenom, - ).Amount - - ubdTime, unbondingAmt, _, unbondedAmt, err := s.liquidUnstakingWithResult( - liquidStaker, - sdk.NewCoin(params.LiquidBondDenom, ubdGTACAmt), - ) - if err != nil { - return err - } - - if ubdComplete { - alv := s.keeper.GetActiveLiquidValidators(ctx, params.WhitelistedValsMap()) - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 200). - WithBlockTime(ubdTime.Add(1)) - - // EndBlock of staking keeper, mature UBD - s.app.StakingKeeper.BlockValidatorUpdates(ctx) - - balanceCompleteUBD := s.app.BankKeeper.GetBalance( - ctx, - liquidStaker, - sdk.DefaultBondDenom, - ) - for _, v := range alv { - _, err := s.app.StakingKeeper.GetUnbondingDelegation( - ctx, - liquidStaker, - v.GetOperator(), - ) - s.Require().Error(err) - } - - s.Require().EqualValues( - balanceCompleteUBD.Amount, - balanceBefore.Add(unbondingAmt).Add(unbondedAmt), - ) - } - - return nil -} - -func (s *KeeperTestSuite) liquidUnstakingWithResult( - liquidStaker sdk.AccAddress, unstakingGTAC sdk.Coin, -) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) { - ctx, writeCache := s.ctx.CacheContext() - params := s.keeper.GetParams(ctx) - alv := s.keeper.GetActiveLiquidValidators(ctx, params.WhitelistedValsMap()) - - balanceBefore := s.app.BankKeeper.GetBalance( - ctx, liquidStaker, sdk.DefaultBondDenom, - ).Amount - gtacBalanceBefore := s.app.BankKeeper.GetBalance( - ctx, liquidStaker, params.LiquidBondDenom, - ).Amount - - ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.keeper.LiquidUnstake( - ctx, types.LiquidStakeProxyAcc, liquidStaker, unstakingGTAC, - ) - if err != nil { - return ubdTime, unbondingAmt, ubds, unbondedAmt, err - } - - balanceAfter := s.app.BankKeeper.GetBalance( - ctx, liquidStaker, sdk.DefaultBondDenom, - ).Amount - gtacBalanceAfter := s.app.BankKeeper.GetBalance( - ctx, liquidStaker, params.LiquidBondDenom, - ).Amount - s.Require().EqualValues( - unstakingGTAC.Amount, gtacBalanceBefore.Sub(gtacBalanceAfter), - ) - - if unbondedAmt.IsPositive() { - s.Require().EqualValues( - unbondedAmt, balanceAfter.Sub(balanceBefore), - ) - } - - for _, v := range alv { - _, err := s.app.StakingKeeper.GetUnbondingDelegation( - ctx, liquidStaker, v.GetOperator(), - ) - s.Require().NoError(err) - } - - writeCache() - return ubdTime, unbondingAmt, ubds, unbondedAmt, err -} - -func (s *KeeperTestSuite) RequireNetAmountStateZero() { - nas, err := s.keeper.GetNetAmountState(s.ctx) - s.Require().NoError(err) - s.Require().EqualValues(nas.MintRate, sdk.ZeroDec()) - s.Require().EqualValues(nas.GtacTotalSupply, sdk.ZeroInt()) - s.Require().EqualValues(nas.NetAmount, sdk.ZeroDec()) - s.Require().EqualValues(nas.TotalDelShares, sdk.ZeroDec()) - s.Require().EqualValues(nas.TotalLiquidTokens, sdk.ZeroInt()) - s.Require().EqualValues(nas.TotalRemainingRewards, sdk.ZeroDec()) - s.Require().EqualValues(nas.TotalUnbondingBalance, sdk.ZeroDec()) - s.Require().EqualValues(nas.ProxyAccBalance, sdk.ZeroInt()) -} - -// advance block time and height for complete redelegations and unbondings -func (s *KeeperTestSuite) completeRedelegationUnbonding() { - s.ctx = s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 100). - WithBlockTime(s.ctx.BlockTime().Add(stakingtypes.DefaultUnbondingTime)) - s.app.EndBlocker(s.ctx) - reds, err := s.app.StakingKeeper.GetRedelegations(s.ctx, types.LiquidStakeProxyAcc, 100) - s.Require().NoError(err) - s.Require().Len(reds, 0) - ubds, err := s.app.StakingKeeper.GetUnbondingDelegations(s.ctx, types.LiquidStakeProxyAcc, 100) - s.Require().NoError(err) - s.Require().Len(ubds, 0) -} - -func (s *KeeperTestSuite) redelegationsErrorCount(redelegations []types.Redelegation) int { - errCnt := 0 - for _, red := range redelegations { - if red.Error != nil { - errCnt++ - } - } - return errCnt -} - -func (s *KeeperTestSuite) printRedelegationsLiquidTokens() { - redsIng, err := s.app.StakingKeeper.GetRedelegations(s.ctx, types.LiquidStakeProxyAcc, 50) - s.Require().NoError(err) - if len(redsIng) != 0 { - fmt.Println("[Redelegations]") - for i, red := range redsIng { - fmt.Println("\tRedelegation #", i+1) - fmt.Println("\t\tDelegatorAddress: ", red.DelegatorAddress) - fmt.Println("\t\tValidatorSrcAddress : ", red.ValidatorSrcAddress) - fmt.Println("\t\tValidatorDstAddress: ", red.ValidatorDstAddress) - fmt.Println("\t\tEntries: ") - for _, e := range red.Entries { - fmt.Println("\t\t\tCreationHeight: ", e.CreationHeight) - fmt.Println("\t\t\tCompletionTime: ", e.CompletionTime) - fmt.Println("\t\t\tInitialBalance: ", e.InitialBalance) - fmt.Println("\t\t\tSharesDst: ", e.SharesDst) - } - } - fmt.Println("") - } - liquidVals := s.keeper.GetAllLiquidValidators(s.ctx) - if len(liquidVals) != 0 { - fmt.Println("[LiquidValidators]") - for _, v := range s.keeper.GetAllLiquidValidators(s.ctx) { - fmt.Printf(" OperatorAddress %s; LiquidTokens: %s\n", - v.OperatorAddress, v.GetLiquidTokens(s.ctx, *s.app.StakingKeeper, false)) - } - } -} - -func (s *KeeperTestSuite) advanceHeight(height int, _ bool) { - feeCollector := s.app.AccountKeeper.GetModuleAddress( - authtypes.FeeCollectorName, - ) - - for i := 0; i < height; i++ { - s.ctx = s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1). - WithBlockTime(s.ctx.BlockTime().Add(BlockTime)) - - mint.BeginBlocker(s.ctx, s.app.MintKeeper, minttypes.DefaultInflationCalculationFn) - feeCollectorBalance := s.app.BankKeeper.GetAllBalances( - s.ctx, feeCollector, - ) - rewardsToBeDistributed := feeCollectorBalance.AmountOf( - sdk.DefaultBondDenom, - ) - - // mimic distribution.BeginBlock (AllocateTokens, get rewards from - // feeCollector, AllocateTokensToValidator, add remaining to feePool) - err := s.app.BankKeeper.SendCoinsFromModuleToModule( - s.ctx, authtypes.FeeCollectorName, distrtypes.ModuleName, - feeCollectorBalance, - ) - - s.Require().NoError(err) - totalRewards := sdk.ZeroDec() - totalPower := int64(0) - s.app.StakingKeeper.IterateBondedValidatorsByPower( - s.ctx, - func(index int64, validator stakingtypes.ValidatorI) (stop bool) { - consPower := validator.GetConsensusPower( - s.app.StakingKeeper.PowerReduction(s.ctx), - ) - totalPower = totalPower + consPower - return false - }, - ) - - if totalPower != 0 { - s.app.StakingKeeper.IterateBondedValidatorsByPower( - s.ctx, - func(index int64, validator stakingtypes.ValidatorI) (stop bool) { - consPower := validator.GetConsensusPower( - s.app.StakingKeeper.PowerReduction(s.ctx), - ) - powerFraction := math.LegacyNewDec(consPower).QuoTruncate( - math.LegacyNewDec(totalPower), - ) - reward := rewardsToBeDistributed.ToLegacyDec().MulTruncate( - powerFraction, - ) - - s.app.DistrKeeper.AllocateTokensToValidator( - s.ctx, validator, - sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: reward}}, - ) - - totalRewards = totalRewards.Add(reward) - return false - }, - ) - } - - remaining := rewardsToBeDistributed.ToLegacyDec().Sub(totalRewards) - s.Require().False(remaining.GT(math.LegacyNewDec(1))) - feePool, err := s.app.DistrKeeper.FeePool.Get(s.ctx) - if err != nil { - s.Require().NoError(err) - } - feePool.CommunityPool = feePool.CommunityPool.Add( - sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: remaining}}..., - ) - - s.app.DistrKeeper.FeePool.Set(s.ctx, feePool) - - _, err = s.app.StakingKeeper.EndBlocker(s.ctx) - s.Require().NoError(err) - } -} - -// doubleSign, tombstone, slash, jail -func (s *KeeperTestSuite) doubleSign(valOper sdk.ValAddress, consAddr sdk.ConsAddress) { - liquidValidator, found := s.keeper.GetLiquidValidator(s.ctx, valOper) - s.Require().True(found) - val, err := s.app.StakingKeeper.GetValidator(s.ctx, valOper) - s.Require().NoError(err) - tokens := val.Tokens - liquidTokens := liquidValidator.GetLiquidTokens(s.ctx, *s.app.StakingKeeper, false) - - // check sign info - info, err := s.app.SlashingKeeper.GetValidatorSigningInfo(s.ctx, consAddr) - s.Require().NoError(err) - s.Require().Equal(info.Address, consAddr.String()) - - // make evidence - // evidence := &evidencetypes.Equivocation{ - // // Height: 0, - // // Time: time.Unix(0, 0), - // Height: s.ctx.BlockHeight(), - // Time: s.ctx.BlockTime(), - // Power: s.app.StakingKeeper.TokensToConsensusPower(s.ctx, tokens), - // ConsensusAddress: consAddr.String(), - // } - - // Double sign - // TODO: Upgrade Cosmos SDK - // s.app.EvidenceKeeper.HandleEquivocationEvidence(s.ctx, evidence) - // HandleEquivocationEvidence call below functions - // s.app.SlashingKeeper.Slash() - // s.app.SlashingKeeper.Jail(s.ctx, consAddr) - // s.app.SlashingKeeper.JailUntil(s.ctx, consAddr, evidencetypes.DoubleSignJailEndTime) - // s.app.SlashingKeeper.Tombstone(s.ctx, consAddr) - - // should be jailed and tombstoned - _, err = s.app.StakingKeeper.Validator(s.ctx, liquidValidator.GetOperator()) - s.Require().Error(err) - s.Require().True(s.app.SlashingKeeper.IsTombstoned(s.ctx, consAddr)) - - // check tombstoned on sign info - info, err = s.app.SlashingKeeper.GetValidatorSigningInfo(s.ctx, consAddr) - s.Require().NoError(err) - s.Require().True(info.Tombstoned) - val, _ = s.app.StakingKeeper.GetValidator(s.ctx, valOper) - s.Require().True(s.keeper.IsTombstoned(s.ctx, val)) - liquidTokensSlashed := liquidValidator.GetLiquidTokens(s.ctx, *s.app.StakingKeeper, false) - tokensSlashed := val.Tokens - s.Require().True(tokensSlashed.LT(tokens)) - s.Require().True(liquidTokensSlashed.LT(liquidTokens)) - - s.app.StakingKeeper.BlockValidatorUpdates(s.ctx) - val, _ = s.app.StakingKeeper.GetValidator(s.ctx, valOper) - - // set unbonding status, no more rewards before return Bonded - s.Require().Equal(val.Status, stakingtypes.Unbonding) -} - -func (s *KeeperTestSuite) createContinuousVestingAccount( - from, to sdk.AccAddress, amt sdk.Coins, - startTime, endTime time.Time, -) vestingtypes.ContinuousVestingAccount { - baseAccount := s.app.AccountKeeper.NewAccountWithAddress(s.ctx, to) - _, ok := baseAccount.(*authtypes.BaseAccount) - s.Require().True(ok) - baseVestingAccount, err := vestingtypes.NewBaseVestingAccount( - baseAccount.(*authtypes.BaseAccount), amt, endTime.Unix(), - ) - s.Require().NoError(err) - - cVestingAcc := vestingtypes.NewContinuousVestingAccountRaw( - baseVestingAccount, startTime.Unix(), - ) - - s.app.AccountKeeper.SetAccount(s.ctx, cVestingAcc) - err = s.app.BankKeeper.SendCoins(s.ctx, from, to, amt) - s.Require().NoError(err) - - return *cVestingAcc -} - -func (s *KeeperTestSuite) fundAddr(addr sdk.AccAddress, amt sdk.Coins) { - err := s.app.BankKeeper.MintCoins(s.ctx, "mint", amt) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToAccount(s.ctx, "mint", addr, amt) - s.Require().NoError(err) -} diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go deleted file mode 100644 index 95ccefb..0000000 --- a/x/liquidstake/keeper/liquidstake.go +++ /dev/null @@ -1,1212 +0,0 @@ -package keeper - -import ( - "encoding/json" - "sort" - "time" - - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" - storetypes "cosmossdk.io/store/types" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -func (k Keeper) LiquidBondDenom(ctx sdk.Context) string { - return k.GetParams(ctx).LiquidBondDenom -} - -// GetNetAmountState calculates the sum of bondedDenom balance, total delegation tokens(slash applied LiquidTokens), total remaining reward of types.LiquidStakeProxyAcc -// During liquid unstaking, gtac immediately burns and the unbonding queue belongs to the requester, so the liquid staker's unbonding values are excluded on netAmount -// It is used only for calculation and query and is not stored in kv. -func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas *types.NetAmountState, err error) { - totalRemainingRewards, totalDelShares, totalLiquidTokens, err := k.CheckDelegationStates(ctx, types.LiquidStakeProxyAcc) - if err != nil { - return nil, err - } - - totalUnbondingBalance := math.ZeroInt() - ubds, err := k.stakingKeeper.GetAllUnbondingDelegations(ctx, types.LiquidStakeProxyAcc) - if err != nil { - return nil, err - } - for _, ubd := range ubds { - for _, entry := range ubd.Entries { - // use Balance(slashing applied) not InitialBalance(without slashing) - totalUnbondingBalance = totalUnbondingBalance.Add(entry.Balance) - } - } - - balance, err := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) - - if err != nil { - return nil, err - } - - nas = &types.NetAmountState{ - GtacTotalSupply: k.bankKeeper.GetSupply(ctx, k.LiquidBondDenom(ctx)).Amount, - TotalDelShares: totalDelShares, - TotalLiquidTokens: totalLiquidTokens, - TotalRemainingRewards: totalRemainingRewards, - TotalUnbondingBalance: totalUnbondingBalance, - ProxyAccBalance: balance.Amount, - } - - nas.NetAmount = nas.CalcNetAmount() - nas.MintRate = nas.CalcMintRate() - return nas, nil -} - -// LiquidStake mints gTAC worth of staking coin value according to NetAmount and performs LiquidDelegate. -func (k Keeper) LiquidStake( - ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, stakingCoin sdk.Coin, -) (gTACMintAmount math.Int, err error) { - params := k.GetParams(ctx) - - if params.ModulePaused { - return math.ZeroInt(), types.ErrModulePaused - } - - // check minimum liquid stake amount - if stakingCoin.Amount.LT(params.MinLiquidStakeAmount) { - return math.ZeroInt(), types.ErrLessThanMinLiquidStakeAmount - } - - // check bond denomination - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return math.ZeroInt(), err - } - if stakingCoin.Denom != bondDenom { - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidBondDenom, "invalid coin denomination: got %s, expected %s", stakingCoin.Denom, bondDenom, - ) - } - - whitelistedValsMap := types.GetWhitelistedValsMap(params.WhitelistedValidators) - activeVals := k.GetActiveLiquidValidators(ctx, whitelistedValsMap) - - if activeVals.Len() == 0 { - return math.ZeroInt(), types.ErrActiveLiquidValidatorsNotExists - } - - totalActiveWeight := activeVals.TotalWeight(whitelistedValsMap) - activeWeightQuorum := math.LegacyNewDecFromInt(totalActiveWeight).Quo( - math.LegacyNewDecFromInt(types.TotalValidatorWeight), - ) - if activeWeightQuorum.LT(types.ActiveLiquidValidatorsWeightQuorum) { - k.Logger(ctx).Error( - "active liquid validators weight quorum not reached", - types.ActiveWeightQuorumKeyVal, - activeWeightQuorum.String(), - types.MinActiveWeightQuorumKeyVal, - types.ActiveLiquidValidatorsWeightQuorum.String(), - ) - - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrActiveLiquidValidatorsWeightQuorumNotReached, "%s < %s", - activeWeightQuorum.String(), types.ActiveLiquidValidatorsWeightQuorum.String(), - ) - } - - // NetAmount must be calculated before send - nas, err := k.GetNetAmountState(ctx) - if err != nil { - return math.ZeroInt(), err - } - - // send staking coin to liquid stake proxy account to proxy delegation, need sufficient spendable balances - err = k.bankKeeper.SendCoins(ctx, liquidStaker, proxyAcc, sdk.NewCoins(stakingCoin)) - if err != nil { - return math.ZeroInt(), err - } - - // mint gtac, MintAmount = TotalSupply * StakeAmount/NetAmount - liquidBondDenom := k.LiquidBondDenom(ctx) - gTACMintAmount = stakingCoin.Amount - - if nas.GtacTotalSupply.IsPositive() { - if nas.NetAmount.IsZero() { - // this case must not be reachable, consider stopping module for investigation - // c_value -> inf - k.Logger(ctx).Error( - "infinite c value", - types.NetAmountStateKeyVal, - nas.String(), - ) - - return math.ZeroInt(), types.ErrInsufficientProxyAccBalance - } - - gTACMintAmount = types.NativeTokenToGTAC(stakingCoin.Amount, nas.GtacTotalSupply, nas.NetAmount) - } - - if !gTACMintAmount.IsPositive() { - return math.ZeroInt(), types.ErrTooSmallLiquidStakeAmount - } - - // mint on module acc and send - mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, gTACMintAmount)) - err = k.bankKeeper.MintCoins(ctx, types.ModuleName, mintCoin) - if err != nil { - return gTACMintAmount, err - } - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, liquidStaker, mintCoin) - if err != nil { - k.Logger(ctx).Error( - "failed to send minted coins to liquid staker", - types.ErrorKeyVal, - err, - ) - - return gTACMintAmount, err - } - - err = k.LiquidDelegate(ctx, proxyAcc, activeVals, stakingCoin.Amount, whitelistedValsMap) - return gTACMintAmount, err -} - -// LockOnLP sends tokens to a CW contract (Superfluid LP) with time locking. -// It performs a CosmWasm execution through global message handler and may fail. -// Emits events on a successful call. -func (k Keeper) LockOnLP(ctx sdk.Context, delegator sdk.AccAddress, amount sdk.Coin) ([]*codectypes.Any, error) { - params := k.GetParams(ctx) - - if len(params.CwLockedPoolAddress) == 0 { - return nil, types.ErrNoLPContractAddress - } else if amount.Denom != params.LiquidBondDenom { - return nil, types.ErrInvalidDenom.Wrapf("cannot lock any denom on LP except liquid bond denom: %s", params.LiquidBondDenom) - } - - msg := &LockLstAssetMsg{ - Asset: Asset{ - Amount: amount.Amount.String(), - Info: AssetInfo{ - NativeToken: NativeTokenInfo{ - Denom: amount.Denom, - }, - }, - }, - } - - callData, err := json.Marshal(&ExecMsg{ - LockLstAsset: msg, - }) - if err != nil { - panic("failed to marshal CW contract call LockLstAsset") - } - - cwMsg := &wasmtypes.MsgExecuteContract{ - Sender: delegator.String(), - Contract: k.GetParams(ctx).CwLockedPoolAddress, - Msg: wasmtypes.RawContractMessage(callData), - Funds: sdk.NewCoins(amount), - } - - handler := k.router.Handler(cwMsg) - if handler == nil { - k.Logger(ctx).Error("failed to find CW contract handler") - - return nil, sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(cwMsg)) - } - - msgResp, err := handler(ctx, cwMsg) - if err != nil { - k.Logger(ctx).Error( - "failed to execute CW contract message", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - cwMsg.String(), - ) - - return nil, types.ErrLPContract.Wrapf("error: %s, message %v", err.Error(), cwMsg) - } - - // emit the events from the dispatched actions - ctx.EventManager().EmitEvents(msgResp.GetEvents()) - - return msgResp.MsgResponses, nil -} - -type ExecMsg struct { - LockLstAsset *LockLstAssetMsg `json:"lock_lst_asset,omitempty"` -} - -type LockLstAssetMsg struct { - Asset Asset `json:"asset"` -} - -type Asset struct { - Amount string `json:"amount"` - Info AssetInfo `json:"info"` -} - -type AssetInfo struct { - NativeToken NativeTokenInfo `json:"native_token"` -} - -type NativeTokenInfo struct { - Denom string `json:"denom"` -} - -// DelegateWithCap is a wrapper to invoke stakingKeeper.Delegate but account for -// the amount of liquid staked shares and check against liquid staking cap. -func (k Keeper) DelegateWithCap( - ctx sdk.Context, - delegatorAddress sdk.AccAddress, - validator stakingtypes.Validator, - bondAmt math.Int, -) error { - denom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return err - } - msgDelegate := &stakingtypes.MsgDelegate{ - DelegatorAddress: delegatorAddress.String(), - ValidatorAddress: validator.OperatorAddress, - Amount: sdk.NewCoin(denom, bondAmt), - } - handler := k.router.Handler(msgDelegate) - if handler == nil { - k.Logger(ctx).Error("failed to find delegate handler") - - return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s", sdk.MsgTypeURL(msgDelegate)) - } - res, err := handler(ctx, msgDelegate) - if err != nil { - k.Logger(ctx).Error( - "failed to execute delegate msg", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - msgDelegate.String(), - ) - - return errorsmod.Wrapf(types.ErrDelegationFailed, "failed to send delegate msg with err: %v", err) - } - ctx.EventManager().EmitEvents(res.GetEvents()) - - if len(res.MsgResponses) != 1 { - return errorsmod.Wrapf( - types.ErrInvalidResponse, - "expected msg response should be exactly 1, got: %v, responses: %v", - len(res.MsgResponses), res.MsgResponses, - ) - } - - var msgDelegateResponse stakingtypes.MsgDelegateResponse - if err = k.cdc.Unmarshal(res.MsgResponses[0].Value, &msgDelegateResponse); err != nil { - return errorsmod.Wrapf( - sdkerrors.ErrJSONUnmarshal, - "cannot unmarshal delegate tx response message: %v", - err, - ) - } - - return nil -} - -// UnbondWithCap is a wrapper to invoke stakingKeeper.Unbond but updates -// the total liquid staked tokens. -func (k Keeper) UnbondWithCap( - ctx sdk.Context, - delegatorAddress sdk.AccAddress, - validatorAddress sdk.ValAddress, - amount sdk.Coin, - userAddress sdk.AccAddress, -) (math.Int, error) { - // perform an LSM tokenize->bank send->redeem flow: moving delegation from proxyAcc onto user's account - lsmTokenizeMsg := &stakingtypes.MsgTokenizeShares{ - DelegatorAddress: delegatorAddress.String(), - ValidatorAddress: validatorAddress.String(), - Amount: amount, - TokenizedShareOwner: userAddress.String(), - } - - handler := k.router.Handler(lsmTokenizeMsg) - if handler == nil { - k.Logger(ctx).Error("failed to find tokenize handler") - - return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmTokenizeMsg)) - } - - // [1] tokenize delegation into LSM shares - msgResp, err := handler(ctx, lsmTokenizeMsg) - if err != nil { - k.Logger(ctx).Error( - "failed to execute tokenize shares message", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - lsmTokenizeMsg.String(), - ) - - return math.ZeroInt(), types.ErrLSMTokenizeFailed.Wrapf("error: %s; message: %v", err.Error(), lsmTokenizeMsg) - } - ctx.EventManager().EmitEvents(msgResp.GetEvents()) - - if len(msgResp.MsgResponses) != 1 { - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidResponse, - "expected msg response should be exactly 1, got: %v, responses: %v", - len(msgResp.MsgResponses), msgResp.MsgResponses, - ) - } - - var lsmTokenizeResp stakingtypes.MsgTokenizeSharesResponse - if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmTokenizeResp); err != nil { - return math.ZeroInt(), errorsmod.Wrapf( - sdkerrors.ErrJSONUnmarshal, - "cannot unmarshal tokenize share tx response message: %v", - err, - ) - } - - // [2] send LSM shares to proxyAcc - err = k.bankKeeper.SendCoins(ctx, delegatorAddress, userAddress, sdk.NewCoins(lsmTokenizeResp.Amount)) - if err != nil { - return math.ZeroInt(), err - } - - lsmRedeemMsg := &stakingtypes.MsgRedeemTokensForShares{ - DelegatorAddress: userAddress.String(), - Amount: lsmTokenizeResp.Amount, - } - - handler = k.router.Handler(lsmRedeemMsg) - if handler == nil { - k.Logger(ctx).Error("failed to find redeem handler") - return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmRedeemMsg)) - } - - // [3] redeem LSM shares from proxyAcc, to obtain a delegation - msgResp, err = handler(ctx, lsmRedeemMsg) - if err != nil { - k.Logger(ctx).Error( - "failed to execute redeem tokens for shares message", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - lsmRedeemMsg.String(), - ) - - return math.ZeroInt(), types.ErrLSMRedeemFailed.Wrapf("error: %s; message: %v", err.Error(), lsmRedeemMsg) - } - ctx.EventManager().EmitEvents(msgResp.GetEvents()) - - if len(msgResp.MsgResponses) != 1 { - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidResponse, - "expected msg response should be exactly 1, got: %v, responses: %v", - len(msgResp.MsgResponses), msgResp.MsgResponses, - ) - } - - var lsmRedeemResp stakingtypes.MsgRedeemTokensForSharesResponse - if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmRedeemResp); err != nil { - return math.ZeroInt(), errorsmod.Wrapf( - sdkerrors.ErrJSONUnmarshal, - "cannot unmarshal redeem tokens for shares tx response message: %v", - err, - ) - } - - // [4] unstake from user's account. - unstakeMsg := &stakingtypes.MsgUndelegate{ - DelegatorAddress: userAddress.String(), - ValidatorAddress: validatorAddress.String(), - Amount: lsmRedeemResp.Amount, - } - - handler = k.router.Handler(unstakeMsg) - if handler == nil { - k.Logger(ctx).Error("failed to find undelegate handler") - - return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(unstakeMsg)) - } - - msgResp, err = handler(ctx, unstakeMsg) - if err != nil { - k.Logger(ctx).Error( - "failed to execute undelegate message", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - unstakeMsg.String(), - ) - - return math.ZeroInt(), types.ErrUnstakeFailed.Wrapf("error: %s; message: %v", err.Error(), unstakeMsg) - } - ctx.EventManager().EmitEvents(msgResp.GetEvents()) - - if len(msgResp.MsgResponses) != 1 { - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidResponse, - "expected msg response should be exactly 1, got: %v, responses: %v", - len(msgResp.MsgResponses), msgResp.MsgResponses, - ) - } - - var msgUndelegateResp stakingtypes.MsgUndelegateResponse - if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &msgUndelegateResp); err != nil { - return math.ZeroInt(), errorsmod.Wrapf( - sdkerrors.ErrJSONUnmarshal, - "cannot unmarshal msg undelegate tx response message: %v", - err, - ) - } - - return lsmRedeemResp.Amount.Amount, nil -} - -// RedelegateWithCap is a wrapper to invoke stakingKeeper.Redelegate but account for -// the amount of liquid staked shares and check against liquid staking cap. -func (k Keeper) RedelegateWithCap( - ctx sdk.Context, - delegatorAddress sdk.AccAddress, - validatorSrc sdk.ValAddress, - validatorDst sdk.ValAddress, - bondAmt math.Int, -) (time.Time, error) { - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return time.Time{}, err - } - msgRedelegate := &stakingtypes.MsgBeginRedelegate{ - DelegatorAddress: delegatorAddress.String(), - ValidatorSrcAddress: validatorSrc.String(), - ValidatorDstAddress: validatorDst.String(), - Amount: sdk.NewCoin(bondDenom, bondAmt), - } - handler := k.router.Handler(msgRedelegate) - if handler == nil { - k.Logger(ctx).Error("failed to find redelegate handler") - - return time.Time{}, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s", sdk.MsgTypeURL(msgRedelegate)) - } - res, err := handler(ctx, msgRedelegate) - if err != nil { - k.Logger(ctx).Error( - "failed to execute redelegate msg", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - msgRedelegate.String(), - ) - - return time.Time{}, errorsmod.Wrapf(types.ErrRedelegateFailed, "failed to send redelegate msg with err: %v", err) - } - ctx.EventManager().EmitEvents(res.GetEvents()) - - if len(res.MsgResponses) != 1 { - return time.Time{}, errorsmod.Wrapf( - types.ErrInvalidResponse, - "expected msg response should be exactly 1, got: %v, responses: %v", - len(res.MsgResponses), res.MsgResponses, - ) - } - - var msgRedelegateResponse stakingtypes.MsgBeginRedelegateResponse - if err = k.cdc.Unmarshal(res.MsgResponses[0].Value, &msgRedelegateResponse); err != nil { - return time.Time{}, errorsmod.Wrapf( - sdkerrors.ErrJSONUnmarshal, - "cannot unmarshal redelegate tx response message: %v", - err, - ) - } - - return msgRedelegateResponse.CompletionTime, nil -} - -// LSMDelegate captures a staked amount from existing delegation using LSM, re-stakes from proxyAcc and -// mints gTAC worth of stk coin value according to NetAmount and performs LiquidDelegate. -func (k Keeper) LSMDelegate( - ctx sdk.Context, - delegator sdk.AccAddress, - validator sdk.ValAddress, - proxyAcc sdk.AccAddress, - preLsmStake sdk.Coin, -) (gTACMintAmount math.Int, err error) { - params := k.GetParams(ctx) - - if params.ModulePaused { - return math.ZeroInt(), types.ErrModulePaused - } else if params.LsmDisabled { - return math.ZeroInt(), types.ErrDisabledLSM - } - - // check minimum liquid stake amount - if preLsmStake.Amount.LT(params.MinLiquidStakeAmount) { - return math.ZeroInt(), types.ErrLessThanMinLiquidStakeAmount - } - - // check bond denomination - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return math.ZeroInt(), err - } - if preLsmStake.Denom != bondDenom { - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidBondDenom, "invalid coin denomination: got %s, expected %s", preLsmStake.Denom, bondDenom, - ) - } - - whitelistedValsMap := types.GetWhitelistedValsMap(params.WhitelistedValidators) - activeVals := k.GetActiveLiquidValidators(ctx, whitelistedValsMap) - - if activeVals.Len() == 0 { - return math.ZeroInt(), types.ErrActiveLiquidValidatorsNotExists - } - - totalActiveWeight := activeVals.TotalWeight(whitelistedValsMap) - activeWeightQuorum := math.LegacyNewDecFromInt(totalActiveWeight).Quo( - math.LegacyNewDecFromInt(types.TotalValidatorWeight), - ) - if activeWeightQuorum.LT(types.ActiveLiquidValidatorsWeightQuorum) { - k.Logger(ctx).Error( - "active liquid validators weight quorum not reached", - types.ActiveWeightQuorumKeyVal, - activeWeightQuorum.String(), - types.MinActiveWeightQuorumKeyVal, - types.ActiveLiquidValidatorsWeightQuorum.String(), - ) - - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrActiveLiquidValidatorsWeightQuorumNotReached, "%s < %s", - activeWeightQuorum.String(), types.ActiveLiquidValidatorsWeightQuorum.String(), - ) - } - - if !whitelistedValsMap.IsListed(validator.String()) { - return math.ZeroInt(), types.ErrLiquidValidatorsNotExists.Wrap("delegation from a non allowed validator") - } - - // NetAmount must be calculated before send - nas, err := k.GetNetAmountState(ctx) - if err != nil { - return math.ZeroInt(), err - } - - // perform an LSM tokenize->bank send->redeem flow: moving delegation from user's account onto proxyAcc - - lsmTokenizeMsg := &stakingtypes.MsgTokenizeShares{ - DelegatorAddress: delegator.String(), - ValidatorAddress: validator.String(), - Amount: preLsmStake, - TokenizedShareOwner: proxyAcc.String(), - } - - handler := k.router.Handler(lsmTokenizeMsg) - if handler == nil { - k.Logger(ctx).Error("failed to find tokenize handler") - - return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmTokenizeMsg)) - } - - // [1] tokenize delegation into LSM shares - msgResp, err := handler(ctx, lsmTokenizeMsg) - if err != nil { - k.Logger(ctx).Error( - "failed to execute tokenize shares message", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - lsmTokenizeMsg.String(), - ) - - return math.ZeroInt(), types.ErrLSMTokenizeFailed.Wrapf("error: %s; message: %v", err.Error(), lsmTokenizeMsg) - } - ctx.EventManager().EmitEvents(msgResp.GetEvents()) - - if len(msgResp.MsgResponses) != 1 { - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidResponse, - "expected msg response should be exactly 1, got: %v, responses: %v", - len(msgResp.MsgResponses), msgResp.MsgResponses, - ) - } - - var lsmTokenizeResp stakingtypes.MsgTokenizeSharesResponse - if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmTokenizeResp); err != nil { - return math.ZeroInt(), errorsmod.Wrapf( - sdkerrors.ErrJSONUnmarshal, - "cannot unmarshal tokenize share tx response message: %v", - err, - ) - } - - // [2] send LSM shares to proxyAcc - err = k.bankKeeper.SendCoins(ctx, delegator, proxyAcc, sdk.NewCoins(lsmTokenizeResp.Amount)) - if err != nil { - return gTACMintAmount, err - } - - lsmRedeemMsg := &stakingtypes.MsgRedeemTokensForShares{ - DelegatorAddress: proxyAcc.String(), - Amount: lsmTokenizeResp.Amount, - } - - handler = k.router.Handler(lsmRedeemMsg) - if handler == nil { - k.Logger(ctx).Error("failed to find redeem handler") - - return math.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmRedeemMsg)) - } - - // [3] redeem LSM shares from proxyAcc, to obtain a delegation - msgResp, err = handler(ctx, lsmRedeemMsg) - if err != nil { - k.Logger(ctx).Error( - "failed to execute redeem tokens for shares message", - types.ErrorKeyVal, - err, - types.MsgKeyVal, - lsmRedeemMsg.String(), - ) - - return math.ZeroInt(), types.ErrLSMRedeemFailed.Wrapf("error: %s; message: %v", err.Error(), lsmRedeemMsg) - } - ctx.EventManager().EmitEvents(msgResp.GetEvents()) - - if len(msgResp.MsgResponses) != 1 { - return math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidResponse, - "expected msg response should be exactly 1, got: %v, responses: %v", - len(msgResp.MsgResponses), msgResp.MsgResponses, - ) - } - - var lsmRedeemResp stakingtypes.MsgRedeemTokensForSharesResponse - if err = k.cdc.Unmarshal(msgResp.MsgResponses[0].Value, &lsmRedeemResp); err != nil { - return math.ZeroInt(), errorsmod.Wrapf( - sdkerrors.ErrJSONUnmarshal, - "cannot unmarshal redeem tokens for shares tx response message: %v", - err, - ) - } - - // mint gtac, MintAmount = TotalSupply * StakeAmount/NetAmount - liquidBondDenom := k.LiquidBondDenom(ctx) - gTACMintAmount = lsmRedeemResp.Amount.Amount - - if nas.GtacTotalSupply.IsPositive() { - gTACMintAmount = types.NativeTokenToGTAC( - gTACMintAmount, - nas.GtacTotalSupply, - nas.NetAmount, - ) - } - - if !gTACMintAmount.IsPositive() { - return math.ZeroInt(), types.ErrTooSmallLiquidStakeAmount - } - - // mint gTAC on module acc - mintCoin := sdk.NewCoins(sdk.NewCoin(liquidBondDenom, gTACMintAmount)) - err = k.bankKeeper.MintCoins(ctx, types.ModuleName, mintCoin) - if err != nil { - return gTACMintAmount, err - } - - // send gTAC to delegator acc - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, delegator, mintCoin) - if err != nil { - return gTACMintAmount, err - } - - // but immediately lock new gTAC into LP on behalf of the delegator - _, err = k.LockOnLP(ctx, delegator, sdk.NewCoin(liquidBondDenom, gTACMintAmount)) - if err != nil { - return gTACMintAmount, err - } - - return gTACMintAmount, err -} - -// LiquidDelegate delegates staking amount to active validators by proxy account. -func (k Keeper) LiquidDelegate(ctx sdk.Context, proxyAcc sdk.AccAddress, activeVals types.ActiveLiquidValidators, stakingAmt math.Int, whitelistedValsMap types.WhitelistedValsMap) (err error) { - // crumb may occur due to a decimal point error in dividing the staking amount into the weight of liquid validators, It added on first active liquid validator - weightedAmt, crumb := types.DivideByWeight(activeVals, stakingAmt, whitelistedValsMap) - if len(weightedAmt) == 0 { - k.Logger(ctx).Error( - "invalid active liquid validators", - types.ActiveValidatorsKeyVal, - activeVals, - types.AmountKeyVal, - stakingAmt.String(), - types.WhitelistedValidatorsMapKeyVal, - whitelistedValsMap, - ) - - return types.ErrInvalidActiveLiquidValidators - } - weightedAmt[0] = weightedAmt[0].Add(crumb) - for i, val := range activeVals { - if !weightedAmt[i].IsPositive() { - continue - } - validator, _ := k.stakingKeeper.GetValidator(ctx, val.GetOperator()) - err = k.DelegateWithCap(ctx, proxyAcc, validator, weightedAmt[i]) - if err != nil { - return errorsmod.Wrapf(err, "failed to delegate to validator %s", val.GetOperator()) - } - } - return nil -} - -// LiquidUnstake burns unstakingGTAC and performs LiquidUnbond to active liquid validators with del shares worth of shares according to NetAmount with each validators current weight. -func (k Keeper) LiquidUnstake( - ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, unstakingGTAC sdk.Coin, -) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) { - params := k.GetParams(ctx) - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err - - } - if params.ModulePaused { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrModulePaused - } - - // check bond denomination - liquidBondDenom := k.LiquidBondDenom(ctx) - if unstakingGTAC.Denom != liquidBondDenom { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), errorsmod.Wrapf( - types.ErrInvalidLiquidBondDenom, "invalid coin denomination: got %s, expected %s", unstakingGTAC.Denom, liquidBondDenom, - ) - } - - // Get NetAmount states - nas, err := k.GetNetAmountState(ctx) - if err != nil { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err - } - - if unstakingGTAC.Amount.GT(nas.GtacTotalSupply) || nas.GtacTotalSupply.IsZero() { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrInvalidGTACSupply - } - - // UnstakeAmount = NetAmount * GTACAmount/TotalSupply * (1-UnstakeFeeRate) - unbondingAmount := types.GTACToNativeToken(unstakingGTAC.Amount, nas.GtacTotalSupply, nas.NetAmount) - unbondingAmount = types.DeductFeeRate(unbondingAmount, params.UnstakeFeeRate) - unbondingAmountInt := unbondingAmount.TruncateInt() - - if !unbondingAmountInt.IsPositive() { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrTooSmallLiquidUnstakingAmount - } - - // burn gtac - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, liquidStaker, types.ModuleName, sdk.NewCoins(unstakingGTAC)) - if err != nil { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err - } - err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(liquidBondDenom, unstakingGTAC.Amount))) - if err != nil { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err - } - - liquidVals := k.GetAllLiquidValidators(ctx) - totalLiquidTokens, liquidTokenMap := liquidVals.TotalLiquidTokens(ctx, k.stakingKeeper, false) - - // if no totalLiquidTokens, withdraw directly from balance of proxy acc - if !totalLiquidTokens.IsPositive() { - if nas.ProxyAccBalance.GTE(unbondingAmountInt) { - err = k.bankKeeper.SendCoins( - ctx, - types.LiquidStakeProxyAcc, - liquidStaker, - sdk.NewCoins(sdk.NewCoin( - bondDenom, - unbondingAmountInt, - )), - ) - if err != nil { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err - } - - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, unbondingAmountInt, nil - } - - k.Logger(ctx).Error( - "non-positive total liquid tokens", - types.ValidatorsKeyVal, - liquidVals, - types.TotalLiquidTokensKeyVal, - totalLiquidTokens.String(), - ) - - // error case where there is a quantity that are unbonding balance or remaining rewards that is not re-stake or withdrawn in netAmount. - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrInsufficientProxyAccBalance - } - - // fail when no liquid validators to unbond - if liquidVals.Len() == 0 { - k.Logger(ctx).Error( - "no liquid validators to unbond", - types.ValidatorsKeyVal, - liquidVals, - ) - - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrLiquidValidatorsNotExists - } - - // prioritize inactive liquid validators in the list to be used in DivideByCurrentWeight - liquidVals = k.PrioritiseInactiveLiquidValidators(ctx, liquidVals) - - // crumb may occur due to a decimal error in dividing the unstaking gTAC into the weight of liquid validators, it will remain in the NetAmount - unbondingAmounts, crumb := types.DivideByCurrentWeight(liquidVals, unbondingAmount, totalLiquidTokens, liquidTokenMap) - if !unbondingAmount.Sub(crumb).IsPositive() { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), types.ErrTooSmallLiquidUnstakingAmount - } - - totalReturnAmount := math.ZeroInt() - - var ubdTime time.Time - ubds := make([]stakingtypes.UnbondingDelegation, 0, len(liquidVals)) - for i, val := range liquidVals { - // skip zero weight liquid validator - if !unbondingAmounts[i].IsPositive() { - continue - } - - var ubd stakingtypes.UnbondingDelegation - var returnAmount math.Int - var weightedShare math.LegacyDec - - // calculate delShares from tokens with validation - weightedShare, err = k.stakingKeeper.ValidateUnbondAmount(ctx, proxyAcc, val.GetOperator(), unbondingAmounts[i].TruncateInt()) - if err != nil { - k.Logger(ctx).Error( - "failed to validate unbond amount", - types.ErrorKeyVal, - err, - types.ValidatorKeyVal, - val.GetOperator().String(), - types.AmountKeyVal, - unbondingAmounts[i].TruncateInt().String(), - ) - - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err - } - - if !weightedShare.IsPositive() { - continue - } - - // unbond with weightedShare - ubdTime, returnAmount, ubd, err = k.LiquidUnbond(ctx, proxyAcc, liquidStaker, val.GetOperator(), weightedShare, true, sdk.NewCoin(bondDenom, unbondingAmounts[i].TruncateInt())) - if err != nil { - return time.Time{}, math.ZeroInt(), []stakingtypes.UnbondingDelegation{}, math.ZeroInt(), err - } - - ubds = append(ubds, ubd) - totalReturnAmount = totalReturnAmount.Add(returnAmount) - } - - return ubdTime, totalReturnAmount, ubds, math.ZeroInt(), nil -} - -// LiquidUnbond unbond delegation shares to active validators by proxy account. -func (k Keeper) LiquidUnbond( - ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, valAddr sdk.ValAddress, shares math.LegacyDec, checkMaxEntries bool, unbondAmount sdk.Coin, -) (time.Time, math.Int, stakingtypes.UnbondingDelegation, error) { - _, err := k.stakingKeeper.GetValidator(ctx, valAddr) - if err != nil { - return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrNoDelegatorForAddress - } - - hasMax, error := k.stakingKeeper.HasMaxUnbondingDelegationEntries(ctx, liquidStaker, valAddr) - if error != nil { - return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, error - } - - if checkMaxEntries && hasMax { - return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, stakingtypes.ErrMaxUnbondingDelegationEntries - } - - // unbond from proxy account - returnAmount, err := k.UnbondWithCap(ctx, proxyAcc, valAddr, unbondAmount, liquidStaker) - if err != nil { - return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, err - } - - unbondTime, err := k.stakingKeeper.UnbondingTime(ctx) - if err != nil { - return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, err - } - - //// Unbonding from proxy account, but queues to liquid staker. - completionTime := ctx.BlockHeader().Time.Add(unbondTime) - ubd, err := k.stakingKeeper.GetUnbondingDelegation(ctx, liquidStaker, valAddr) - if err != nil { - k.Logger(ctx).Error( - "failed to find unbonding delegation", - types.DelegatorKeyVal, - liquidStaker.String(), - types.ValidatorKeyVal, - valAddr.String(), - ) - - return time.Time{}, math.ZeroInt(), stakingtypes.UnbondingDelegation{}, types.ErrInvalidResponse.Wrap("expected undelegation entry, found none") - } - - return completionTime, returnAmount, ubd, nil -} - -// PrioritiseInactiveLiquidValidators sorts LiquidValidators array to have inactive validators first. Used for the case when -// unbonding should begin from the inactive validators first. -func (k Keeper) PrioritiseInactiveLiquidValidators( - ctx sdk.Context, - vs types.LiquidValidators, -) types.LiquidValidators { - sort.SliceStable(vs, func(i, j int) bool { - vs1, err1 := k.stakingKeeper.GetValidator(ctx, vs[i].GetOperator()) - vs2, err2 := k.stakingKeeper.GetValidator(ctx, vs[j].GetOperator()) - - if err1 != nil && err2 == nil { - // only one case when less - return true - } else if err1 == nil && err2 == nil { - // both exist, compare status - - vs1Active := vs[i].GetStatus(types.ActiveCondition( - vs1, - true, - k.IsTombstoned(ctx, vs1), - )) - vs2Active := vs[j].GetStatus(types.ActiveCondition( - vs2, - true, - k.IsTombstoned(ctx, vs2), - )) - - if vs1Active != types.ValidatorStatusActive && - vs2Active == types.ValidatorStatusActive { - // only one case when is less - return true - } - - // not less, or are equal - return false - } - - // not less, or are equal - return false - }) - - return vs -} - -// CheckDelegationStates returns total remaining rewards, delshares, liquid tokens of delegations by proxy account -func (k Keeper) CheckDelegationStates(ctx sdk.Context, proxyAcc sdk.AccAddress) (math.LegacyDec, math.LegacyDec, math.Int, error) { - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return math.LegacyZeroDec(), math.LegacyZeroDec(), math.ZeroInt(), err - } - - totalRewards := math.LegacyZeroDec() - totalDelShares := math.LegacyZeroDec() - totalLiquidTokens := math.ZeroInt() - - // Cache ctx for calculate rewards - cachedCtx, _ := ctx.CacheContext() - k.stakingKeeper.IterateDelegations( - cachedCtx, proxyAcc, - func(_ int64, del stakingtypes.DelegationI) (stop bool) { - valAddr := del.GetValidatorAddr() - valAddrObj, parseErr := sdk.ValAddressFromBech32(valAddr) - if parseErr != nil { - return false - } - - val, err := k.stakingKeeper.Validator(cachedCtx, valAddrObj) - if err != nil { - return false - } - endingPeriod, err := k.distrKeeper.IncrementValidatorPeriod(cachedCtx, val) - if err != nil { - return false - } - delReward, err := k.distrKeeper.CalculateDelegationRewards(cachedCtx, val, del, endingPeriod) - if err != nil { - return false - } - delShares := del.GetShares() - if delShares.IsPositive() { - totalDelShares = totalDelShares.Add(delShares) - liquidTokens := val.TokensFromSharesTruncated(delShares).TruncateInt() - totalLiquidTokens = totalLiquidTokens.Add(liquidTokens) - totalRewards = totalRewards.Add(delReward.AmountOf(bondDenom).TruncateDec()) - } - return false - }, - ) - - return totalRewards, totalDelShares, totalLiquidTokens, nil -} - -func (k Keeper) WithdrawLiquidRewards(ctx sdk.Context, proxyAcc sdk.AccAddress) { - // iterate over all the delegations (even those out of the active set) and withdraw rewards - k.stakingKeeper.IterateDelegations( - ctx, proxyAcc, - func(_ int64, del stakingtypes.DelegationI) (stop bool) { - // construct the withdrawal rewards message - msgWithdraw := &distributiontypes.MsgWithdrawDelegatorReward{ - DelegatorAddress: proxyAcc.String(), - ValidatorAddress: del.GetValidatorAddr(), - } - - // run the message handler - handler := k.router.Handler(msgWithdraw) - if handler == nil { - k.Logger(ctx).Error("could not find distribution handler for withdraw rewards msg") - return true - } - res, err := handler(ctx, msgWithdraw) - if err != nil { - k.Logger(ctx).Error( - "failed to execute withdraw rewards msg", - types.MsgKeyVal, - msgWithdraw.String(), - types.ErrorKeyVal, - err, - ) - // no need to return here, will be picked up in the next epoch - } else { - // emit the events - ctx.EventManager().EmitEvents(res.GetEvents()) - } - - return false - }, - ) -} - -// GetLiquidValidator get a single liquid validator -func (k Keeper) GetLiquidValidator(ctx sdk.Context, addr sdk.ValAddress) (val types.LiquidValidator, found bool) { - store := ctx.KVStore(k.storeKey) - - value := store.Get(types.GetLiquidValidatorKey(addr)) - if value == nil { - return val, false - } - - val = types.MustUnmarshalLiquidValidator(k.cdc, value) - return val, true -} - -// SetLiquidValidator set the main record holding liquid validator details -func (k Keeper) SetLiquidValidator(ctx sdk.Context, val types.LiquidValidator) { - store := ctx.KVStore(k.storeKey) - bz := types.MustMarshalLiquidValidator(k.cdc, &val) - store.Set(types.GetLiquidValidatorKey(val.GetOperator()), bz) -} - -// RemoveLiquidValidator remove a liquid validator on kv store -func (k Keeper) RemoveLiquidValidator(ctx sdk.Context, val types.LiquidValidator) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetLiquidValidatorKey(val.GetOperator())) -} - -// GetAllLiquidValidators gets the set of all liquid validators, with no pagination limits. -func (k Keeper) GetAllLiquidValidators(ctx sdk.Context) (vals types.LiquidValidators) { - store := ctx.KVStore(k.storeKey) - vals = types.LiquidValidators{} - iterator := storetypes.KVStorePrefixIterator(store, types.LiquidValidatorsKey) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - val := types.MustUnmarshalLiquidValidator(k.cdc, iterator.Value()) - vals = append(vals, val) - } - - return vals -} - -// GetActiveLiquidValidators get the set of active liquid validators. -func (k Keeper) GetActiveLiquidValidators(ctx sdk.Context, whitelistedValsMap types.WhitelistedValsMap) (vals types.ActiveLiquidValidators) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.LiquidValidatorsKey) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - val := types.MustUnmarshalLiquidValidator(k.cdc, iterator.Value()) - if k.IsActiveLiquidValidator(ctx, val, whitelistedValsMap) { - vals = append(vals, val) - } - } - return vals -} - -func (k Keeper) GetAllLiquidValidatorStates(ctx sdk.Context) (liquidValidatorStates []types.LiquidValidatorState) { - lvs := k.GetAllLiquidValidators(ctx) - whitelistedValsMap := k.GetParams(ctx).WhitelistedValsMap() - for _, lv := range lvs { - active := k.IsActiveLiquidValidator(ctx, lv, whitelistedValsMap) - lvState := types.LiquidValidatorState{ - OperatorAddress: lv.OperatorAddress, - Weight: lv.GetWeight(whitelistedValsMap, active), - Status: lv.GetStatus(active), - DelShares: lv.GetDelShares(ctx, k.stakingKeeper), - LiquidTokens: lv.GetLiquidTokens(ctx, k.stakingKeeper, false), - } - liquidValidatorStates = append(liquidValidatorStates, lvState) - } - return -} - -func (k Keeper) GetLiquidValidatorState(ctx sdk.Context, addr sdk.ValAddress) (liquidValidatorState types.LiquidValidatorState, found bool) { - lv, found := k.GetLiquidValidator(ctx, addr) - if !found { - return types.LiquidValidatorState{ - OperatorAddress: addr.String(), - Weight: math.ZeroInt(), - Status: types.ValidatorStatusUnspecified, - DelShares: math.LegacyZeroDec(), - LiquidTokens: math.ZeroInt(), - }, false - } - whitelistedValsMap := k.GetParams(ctx).WhitelistedValsMap() - active := k.IsActiveLiquidValidator(ctx, lv, whitelistedValsMap) - return types.LiquidValidatorState{ - OperatorAddress: lv.OperatorAddress, - Weight: lv.GetWeight(whitelistedValsMap, active), - Status: lv.GetStatus(active), - DelShares: lv.GetDelShares(ctx, k.stakingKeeper), - LiquidTokens: lv.GetLiquidTokens(ctx, k.stakingKeeper, false), - }, true -} - -func (k Keeper) IsActiveLiquidValidator(ctx sdk.Context, lv types.LiquidValidator, whitelistedValsMap types.WhitelistedValsMap) bool { - val, err := k.stakingKeeper.GetValidator(ctx, lv.GetOperator()) - if err != nil { - return false - } - return types.ActiveCondition(val, whitelistedValsMap.IsListed(lv.OperatorAddress), k.IsTombstoned(ctx, val)) -} - -func (k Keeper) IsTombstoned(ctx sdk.Context, val stakingtypes.Validator) bool { - consPk, err := val.ConsPubKey() - if err != nil { - return false - } - return k.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(consPk.Address())) -} - -func (k Keeper) GetWeightMap(ctx sdk.Context, liquidVals types.LiquidValidators, whitelistedValsMap types.WhitelistedValsMap) (map[string]math.Int, math.Int) { - weightMap := map[string]math.Int{} - totalWeight := math.ZeroInt() - for _, val := range liquidVals { - weight := val.GetWeight(whitelistedValsMap, k.IsActiveLiquidValidator(ctx, val, whitelistedValsMap)) - totalWeight = totalWeight.Add(weight) - weightMap[val.OperatorAddress] = weight - } - return weightMap, totalWeight -} diff --git a/x/liquidstake/keeper/liquidstake_test.go b/x/liquidstake/keeper/liquidstake_test.go deleted file mode 100644 index f4e510f..0000000 --- a/x/liquidstake/keeper/liquidstake_test.go +++ /dev/null @@ -1,494 +0,0 @@ -package keeper_test - -import ( - "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - testhelpers "github.com/Asphere-xyz/tacchain/app/helpers" - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -// tests LiquidStake, LiquidUnstake -func (s *KeeperTestSuite) TestLiquidStake() { - sdk.SetBaseDenom("utac") - sdk.GetConfig().SetBech32PrefixForAccount("tac", "tacpub") - _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) - params := s.keeper.GetParams(s.ctx) - params.MinLiquidStakeAmount = math.NewInt(50000) - params.ModulePaused = false - s.keeper.SetParams(s.ctx, params) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - - stakingAmt := params.MinLiquidStakeAmount - - // fail, no active validator - cachedCtx, _ := s.ctx.CacheContext() - gTACMintAmt, err := s.keeper.LiquidStake( - cachedCtx, types.LiquidStakeProxyAcc, s.delAddrs[0], - sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), - ) - s.Require().ErrorIs(err, types.ErrActiveLiquidValidatorsNotExists) - s.Require().Equal(gTACMintAmt, sdk.ZeroInt()) - - // add active validator - params.WhitelistedValidators = []types.WhitelistedValidator{ - {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(2000)}, - {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(2000)}, - {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(2000)}, - } - s.keeper.SetParams(s.ctx, params) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - - res := s.keeper.GetAllLiquidValidatorStates(s.ctx) - s.Require().Equal(params.WhitelistedValidators[0].ValidatorAddress, - res[0].OperatorAddress) - s.Require().Equal(params.WhitelistedValidators[0].TargetWeight, - res[0].Weight) - s.Require().Equal(types.ValidatorStatusActive, res[0].Status) - s.Require().Equal(sdk.ZeroDec(), res[0].DelShares) - s.Require().Equal(sdk.ZeroInt(), res[0].LiquidTokens) - - s.Require().Equal(params.WhitelistedValidators[1].ValidatorAddress, - res[1].OperatorAddress) - s.Require().Equal(params.WhitelistedValidators[1].TargetWeight, - res[1].Weight) - s.Require().Equal(types.ValidatorStatusActive, res[1].Status) - s.Require().Equal(sdk.ZeroDec(), res[1].DelShares) - s.Require().Equal(sdk.ZeroInt(), res[1].LiquidTokens) - - s.Require().Equal(params.WhitelistedValidators[2].ValidatorAddress, - res[2].OperatorAddress) - s.Require().Equal(params.WhitelistedValidators[2].TargetWeight, - res[2].Weight) - s.Require().Equal(types.ValidatorStatusActive, res[2].Status) - s.Require().Equal(sdk.ZeroDec(), res[2].DelShares) - s.Require().Equal(sdk.ZeroInt(), res[2].LiquidTokens) - - ///////////////////////////////////////// - nasTest, err := s.app.LiquidStakeKeeper.GetNetAmountState(s.ctx) - s.T().Logf( - "nasTest.NetAmount: %s", - nasTest.NetAmount, - ) - ///////////////////////////////////////// - - // liquid stake - gTACMintAmt, err = s.keeper.LiquidStake( - s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], - sdk.NewCoin(sdk.DefaultBondDenom, stakingAmt), - ) - s.Require().NoError(err) - s.Require().Equal(gTACMintAmt, stakingAmt) - - ///////////////////////////////////////// - nasTest, err = s.app.LiquidStakeKeeper.GetNetAmountState(s.ctx) - s.T().Logf( - "nasTest.NetAmount after liquid stake: %s", - nasTest.NetAmount, - ) - - s.T().Logf( - "nasTest.MintRate after liquid stake: %s", - nasTest.MintRate, - ) - ///////////////////////////////////////// - - _, err = s.app.StakingKeeper.GetDelegation( - s.ctx, s.delAddrs[0], valOpers[0], - ) - s.Require().Error(err) - _, err = s.app.StakingKeeper.GetDelegation( - s.ctx, s.delAddrs[0], valOpers[1], - ) - s.Require().Error(err) - _, err = s.app.StakingKeeper.GetDelegation( - s.ctx, s.delAddrs[0], valOpers[2], - ) - s.Require().Error(err) - - proxyAccDel1, err := s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[0], - ) - s.Require().NoError(err) - proxyAccDel2, err := s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[1], - ) - s.Require().NoError(err) - proxyAccDel3, err := s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[2], - ) - s.Require().NoError(err) - s.Require().Equal(proxyAccDel1.Shares, math.LegacyNewDec(16668)) - s.Require().Equal(proxyAccDel2.Shares, math.LegacyNewDec(16666)) - s.Require().Equal(proxyAccDel2.Shares, math.LegacyNewDec(16666)) - s.Require().Equal(stakingAmt.ToLegacyDec(), - proxyAccDel1.Shares.Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) - - liquidBondDenom := s.keeper.LiquidBondDenom(s.ctx) - balanceBeforeUBD := s.app.BankKeeper.GetBalance( - s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, - ) - s.Require().Equal(balanceBeforeUBD.Amount, math.NewInt(999950000)) - ubdGTAC := sdk.NewCoin(liquidBondDenom, math.NewInt(10000)) - gTACBalance := s.app.BankKeeper.GetBalance( - s.ctx, s.delAddrs[0], liquidBondDenom, - ) - gTACTotalSupply := s.app.BankKeeper.GetSupply( - s.ctx, liquidBondDenom, - ) - s.Require().Equal(gTACBalance, - sdk.NewCoin(liquidBondDenom, math.NewInt(50000))) - s.Require().Equal(gTACBalance, gTACTotalSupply) - - // liquid unstaking - - ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.keeper.LiquidUnstake( - s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], ubdGTAC, - ) - s.Require().NoError(err) - s.Require().EqualValues(unbondedAmt, sdk.ZeroInt()) - s.Require().Len(ubds, 3) - - // crumb excepted on unbonding - crumb := ubdGTAC.Amount.Sub(ubdGTAC.Amount.QuoRaw(3).MulRaw(3)) - s.Require().EqualValues(unbondingAmt, ubdGTAC.Amount.Sub(crumb)) - s.Require().Equal(ubds[0].DelegatorAddress, s.delAddrs[0].String()) - s.Require().Equal(ubdTime, testhelpers.ParseTime("2022-03-22T00:00:00Z")) - gTACBalanceAfter := s.app.BankKeeper.GetBalance( - s.ctx, s.delAddrs[0], liquidBondDenom, - ) - s.Require().Equal(gTACBalanceAfter, - sdk.NewCoin(liquidBondDenom, math.NewInt(40000))) - - balanceBeginUBD := s.app.BankKeeper.GetBalance( - s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, - ) - s.Require().Equal(balanceBeginUBD.Amount, balanceBeforeUBD.Amount) - - proxyAccDel1, err = s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[0], - ) - s.Require().NoError(err) - proxyAccDel2, err = s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[1], - ) - s.Require().NoError(err) - proxyAccDel3, err = s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[2], - ) - s.Require().NoError(err) - s.Require().Equal(stakingAmt.Sub(unbondingAmt).ToLegacyDec(), - proxyAccDel1.GetShares().Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) - - // complete unbonding - s.ctx = s.ctx.WithBlockHeight(200).WithBlockTime(ubdTime.Add(1)) - updates, err := s.app.StakingKeeper.BlockValidatorUpdates(s.ctx) - s.Require().NoError(err) - s.Require().Empty(updates) - balanceCompleteUBD := s.app.BankKeeper.GetBalance( - s.ctx, s.delAddrs[0], sdk.DefaultBondDenom, - ) - s.Require().Equal(balanceCompleteUBD.Amount, - balanceBeforeUBD.Amount.Add(unbondingAmt)) - - proxyAccDel1, err = s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[0], - ) - s.Require().NoError(err) - proxyAccDel2, err = s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[1], - ) - s.Require().NoError(err) - proxyAccDel3, err = s.app.StakingKeeper.GetDelegation( - s.ctx, types.LiquidStakeProxyAcc, valOpers[2], - ) - s.Require().NoError(err) - s.Require().Equal(math.LegacyNewDec(13335), proxyAccDel1.Shares) - s.Require().Equal(math.LegacyNewDec(13333), proxyAccDel2.Shares) - s.Require().Equal(math.LegacyNewDec(13333), proxyAccDel3.Shares) - - res = s.keeper.GetAllLiquidValidatorStates(s.ctx) - s.Require().Equal(params.WhitelistedValidators[0].ValidatorAddress, - res[0].OperatorAddress) - s.Require().Equal(params.WhitelistedValidators[0].TargetWeight, - res[0].Weight) - s.Require().Equal(types.ValidatorStatusActive, res[0].Status) - s.Require().Equal(math.LegacyNewDec(13335), res[0].DelShares) - - s.Require().Equal(params.WhitelistedValidators[1].ValidatorAddress, - res[1].OperatorAddress) - s.Require().Equal(params.WhitelistedValidators[1].TargetWeight, - res[1].Weight) - s.Require().Equal(types.ValidatorStatusActive, res[1].Status) - s.Require().Equal(math.LegacyNewDec(13333), res[1].DelShares) - - s.Require().Equal(params.WhitelistedValidators[2].ValidatorAddress, - res[2].OperatorAddress) - s.Require().Equal(params.WhitelistedValidators[2].TargetWeight, - res[2].Weight) - s.Require().Equal(types.ValidatorStatusActive, res[2].Status) - s.Require().Equal(math.LegacyNewDec(13333), res[2].DelShares) - - // rewards are not autocompounded after validator set update and rebalancing - s.advanceHeight(10, true) - rewards, totalLiquidShares, _, err := s.keeper.CheckDelegationStates( - s.ctx, types.LiquidStakeProxyAcc, - ) - s.Require().NoError(err) - s.Require().NotEqualValues(rewards, sdk.ZeroDec()) - s.Require().EqualValues(totalLiquidShares, proxyAccDel1.Shares.Add(proxyAccDel2.Shares).Add(proxyAccDel3.Shares)) - - // all remaining rewards re-staked, request last unstaking, unbond all - s.keeper.AutocompoundStakingRewards(s.ctx, types.GetWhitelistedValsMap(s.keeper.GetParams(s.ctx).WhitelistedValidators)) - gtacBalanceBefore := s.app.BankKeeper.GetBalance(s.ctx, s.delAddrs[0], params.LiquidBondDenom).Amount - rewards, _, _, err = s.keeper.CheckDelegationStates( - s.ctx, types.LiquidStakeProxyAcc, - ) - s.Require().NoError(err) - s.Require().EqualValues(rewards, sdk.ZeroDec()) - s.Require().NoError( - s.liquidUnstaking(s.delAddrs[0], gtacBalanceBefore, true), - ) - - // still active liquid validator after unbond all - alv := s.keeper.GetActiveLiquidValidators( - s.ctx, params.WhitelistedValsMap(), - ) - s.Require().True(len(alv) != 0) - - // no btoken supply and netAmount after unbond all - nas, err := s.keeper.GetNetAmountState(s.ctx) - s.Require().NoError(err) - s.Require().EqualValues(nas.GtacTotalSupply, sdk.ZeroInt()) - s.Require().Equal(nas.TotalRemainingRewards, sdk.ZeroDec()) - s.Require().Equal(nas.TotalDelShares, sdk.ZeroDec()) - s.Require().Equal(nas.TotalLiquidTokens, sdk.ZeroInt()) - s.Require().Equal(nas.ProxyAccBalance, sdk.ZeroInt()) - s.Require().Equal(nas.NetAmount, sdk.ZeroDec()) -} - -func (s *KeeperTestSuite) TestLiquidStakeFromVestingAccount() { - _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) - params := s.keeper.GetParams(s.ctx) - - // add active validator - params.WhitelistedValidators = []types.WhitelistedValidator{ - {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, - {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, - {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, - } - params.ModulePaused = false - s.keeper.SetParams(s.ctx, params) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - - from := s.delAddrs[0] - vestingAmt := s.app.BankKeeper.GetAllBalances(s.ctx, from) - vestingStartTime := s.ctx.BlockTime().Add(1 * time.Hour) - vestingEndTime := s.ctx.BlockTime().Add(2 * time.Hour) - vestingMidTime := s.ctx.BlockTime().Add(90 * time.Minute) - - vestingAccAddr := "tac10n3ncmlsaqfuwsmfll8kq6hvt4x7c8czk3d7g6" - vestingAcc, err := sdk.AccAddressFromBech32(vestingAccAddr) - s.Require().NoError(err) - - // createContinuousVestingAccount - cVestingAcc := s.createContinuousVestingAccount(from, vestingAcc, vestingAmt, vestingStartTime, vestingEndTime) - spendableCoins := s.app.BankKeeper.SpendableCoins(s.ctx, cVestingAcc.GetAddress()) - s.Require().True(spendableCoins.IsZero()) - lockedCoins := s.app.BankKeeper.LockedCoins(s.ctx, cVestingAcc.GetAddress()) - s.Require().EqualValues(lockedCoins, vestingAmt) - - // failed liquid stake, no spendable coins on the vesting account ( not allowed locked coins ) - err = s.liquidStaking(vestingAcc, vestingAmt.AmountOf(sdk.DefaultBondDenom)) - s.Require().ErrorIs(err, sdkerrors.ErrInsufficientFunds) - - // release some vesting coins - s.ctx = s.ctx.WithBlockTime(vestingMidTime) - spendableCoins = s.app.BankKeeper.SpendableCoins(s.ctx, cVestingAcc.GetAddress()) - s.Require().True(spendableCoins.IsAllPositive()) - lockedCoins = s.app.BankKeeper.LockedCoins(s.ctx, cVestingAcc.GetAddress()) - s.Require().True(lockedCoins.IsAllPositive()) - - // success with released spendable coins - err = s.liquidStaking(vestingAcc, spendableCoins.AmountOf(sdk.DefaultBondDenom)) - s.Require().NoError(err) - nas, err := s.keeper.GetNetAmountState(s.ctx) - s.Require().NoError(err) - s.Require().EqualValues(nas.TotalLiquidTokens, spendableCoins.AmountOf(sdk.DefaultBondDenom)) -} - -func (s *KeeperTestSuite) TestLiquidStakeEdgeCases() { - _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) - params := s.keeper.GetParams(s.ctx) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - stakingAmt := math.NewInt(5000000) - - // add active validator - params.WhitelistedValidators = []types.WhitelistedValidator{ - {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, - {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, - {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, - } - params.ModulePaused = false - s.keeper.SetParams(s.ctx, params) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - - // fail Invalid BondDenom case - _, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, s.delAddrs[0], sdk.NewCoin("bad", stakingAmt)) - s.Require().ErrorIs(err, types.ErrInvalidBondDenom) - - // liquid stake, unstaking with huge amount - hugeAmt := math.NewInt(1_000_000_000_000_000_000) - s.fundAddr(s.delAddrs[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, hugeAmt.MulRaw(2)))) - s.Require().NoError(s.liquidStaking(s.delAddrs[0], hugeAmt)) - s.Require().NoError(s.liquidStaking(s.delAddrs[0], hugeAmt)) - s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], math.NewInt(10), true)) - s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], hugeAmt, true)) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - s.completeRedelegationUnbonding() - states, err := s.keeper.GetNetAmountState(s.ctx) - s.Require().NoError(err) - states.TotalLiquidTokens.Equal(hugeAmt) -} - -func (s *KeeperTestSuite) TestLiquidUnstakeEdgeCases() { - mintParams, err := s.app.MintKeeper.Params.Get(s.ctx) - s.Require().NoError(err) - mintParams.InflationMax = math.LegacyNewDec(0) - mintParams.InflationMin = math.LegacyNewDec(0) - mintParams.InflationRateChange = math.LegacyNewDec(0) - err = s.app.MintKeeper.Params.Set(s.ctx, mintParams) - s.Require().NoError(err) - - _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000}) - params := s.keeper.GetParams(s.ctx) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - stakingAmt := math.NewInt(5000000) - - // add active validator - params.WhitelistedValidators = []types.WhitelistedValidator{ - {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(3334)}, - {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(3333)}, - {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(3333)}, - } - params.ModulePaused = false - s.Require().NoError(s.keeper.SetParams(s.ctx, params)) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - - // success liquid stake - s.Require().NoError(s.liquidStaking(s.delAddrs[0], stakingAmt)) - - // fail when liquid unstaking with too small amount - _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(2))) - s.Require().ErrorIs(err, types.ErrTooSmallLiquidUnstakingAmount) - - // fail when liquid unstaking with zero amount - _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(0))) - s.Require().ErrorIs(err, types.ErrTooSmallLiquidUnstakingAmount) - - // fail when invalid liquid bond denom - _, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin("stake", math.NewInt(10000))) - s.Require().ErrorIs(err, types.ErrInvalidLiquidBondDenom) - - // verify that there is no problem performing liquid unstaking as much as the MaxEntries - stakingParams, err := s.app.StakingKeeper.GetParams(s.ctx) - s.Require().NoError(err) - for i := uint32(0); i < stakingParams.MaxEntries; i++ { - s.Require().NoError(s.liquidUnstaking(s.delAddrs[0], math.NewInt(1000), false)) - } - - // on sdk 0.47+ shouldn't fail in an attempt to go beyond MaxEntries - err = s.liquidUnstaking(s.delAddrs[0], math.NewInt(1000), false) - s.Require().NoError(err) - - dels, err := s.app.StakingKeeper.GetUnbondingDelegations(s.ctx, s.delAddrs[0], 100) - s.Require().NoError(err) - for _, ubd := range dels { - s.Require().EqualValues(1, len(ubd.Entries)) - } - - // set empty whitelisted, active liquid validator - params.WhitelistedValidators = []types.WhitelistedValidator{} - s.keeper.SetParams(s.ctx, params) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - - // error case where there is a quantity that are unbonding balance or remaining rewards that is not re-stake or withdrawn in netAmount. - // NOT APPLICABLE since we do not validator unbond if validator goes inactive. - //_, _, _, _, err = s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(1000))) - //s.Require().ErrorIs(err, types.ErrInsufficientProxyAccBalance) - - // success after complete unbonding, Not applicable - s.completeRedelegationUnbonding() - // ubdTime, unbondingAmt, ubds, unbondedAmt, err := s.liquidUnstakingWithResult(s.delAddrs[0], sdk.NewCoin(params.LiquidBondDenom, math.NewInt(1000))) - // s.Require().NoError(err) - // s.Require().EqualValues(unbondedAmt, math.NewInt(1000)) - // s.Require().EqualValues(unbondingAmt, sdk.ZeroInt()) - // s.Require().EqualValues(ubdTime, time.Time{}) - // s.Require().Len(ubds, 0) -} - -func (s *KeeperTestSuite) TestShareInflation() { - _, valOpers, _ := s.CreateValidators([]int64{1000000, 2000000, 3000000, 4000000}) - params := s.keeper.GetParams(s.ctx) - - // set minimum amount and unstake fee to 0 for testing - params.MinLiquidStakeAmount = math.NewInt(0) - params.UnstakeFeeRate = sdk.NewDec(0) - s.keeper.SetParams(s.ctx, params) - - params.WhitelistedValidators = []types.WhitelistedValidator{ - {ValidatorAddress: valOpers[0].String(), TargetWeight: math.NewInt(2500)}, - {ValidatorAddress: valOpers[1].String(), TargetWeight: math.NewInt(2500)}, - {ValidatorAddress: valOpers[2].String(), TargetWeight: math.NewInt(2500)}, - {ValidatorAddress: valOpers[3].String(), TargetWeight: math.NewInt(2500)}, - } - params.ModulePaused = false - s.keeper.SetParams(s.ctx, params) - s.keeper.UpdateLiquidValidatorSet(s.ctx, true) - - initialStakingAmt := math.NewInt(1) // little amount - initializingStakingAmt := math.NewInt(10000) // normal amount - attacker := s.delAddrs[0] - user := s.delAddrs[1] - protocol := s.delAddrs[3] - - // 0. [a solution?] be first depositor - mintAmount0, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, - protocol, sdk.NewCoin(sdk.DefaultBondDenom, initializingStakingAmt)) - s.Require().NoError(err) - s.Require().Equal(mintAmount0, initializingStakingAmt) - - // 1. attacker becomes first depositor and liquid stake - mintAmount, err := s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, - attacker, sdk.NewCoin(sdk.DefaultBondDenom, initialStakingAmt)) - s.Require().NoError(err) - s.Require().Equal(mintAmount, initialStakingAmt) - - // 2. The user sends a liquid stake message, but their tx got front-run by the attacker - // ideally, the user should get 1000 gTAC (1 * 1000 / 1) - // gTAC to mint = gTAC supply * sent TAC / total TAC - userStakeAmount := math.NewInt(1_000) - - // 3. attacker's tx got accepted first which sends funds directly to proxy account - attackerTransferAmount := userStakeAmount.Quo(sdk.NewInt(2)) - s.app.BankKeeper.SendCoins(s.ctx, attacker, types.LiquidStakeProxyAcc, - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, attackerTransferAmount))) - - // 4. user tx went through and the mint rate is not affected by the TAC sent by the attacker - // gTAC to mint = 1 * 1000 / 1 = 1 - mintAmount, err = s.keeper.LiquidStake(s.ctx, types.LiquidStakeProxyAcc, user, sdk.NewCoin(sdk.DefaultBondDenom, userStakeAmount)) - s.Require().NoError(err) - s.Require().Equal(mintAmount, math.NewInt(1_000)) - - // 5. attacker unstakes the shares immediately - liquidBondDenom := s.keeper.LiquidBondDenom(s.ctx) - _, unbondingAmt, _, _, err := s.keeper.LiquidUnstake(s.ctx, types.LiquidStakeProxyAcc, attacker, sdk.NewCoin(liquidBondDenom, sdk.NewInt(1))) - // s.Require().NoError(err) - s.Require().ErrorContains(err, "liquid unstaking amount is too small") - - attackerProfit := unbondingAmt.Sub(initialStakingAmt).Sub(attackerTransferAmount) - s.Require().LessOrEqual(attackerProfit.Int64(), math.ZeroInt().Int64()) -} diff --git a/x/liquidstake/keeper/msg_server.go b/x/liquidstake/keeper/msg_server.go deleted file mode 100644 index dc8418a..0000000 --- a/x/liquidstake/keeper/msg_server.go +++ /dev/null @@ -1,309 +0,0 @@ -package keeper - -// DONTCOVER - -// Although written in msg_server_test.go, it is approached at the keeper level rather than at the msgServer level -// so is not included in the coverage. - -import ( - "context" - "encoding/json" - "fmt" - "time" - - normal_errors "errors" - - "cosmossdk.io/errors" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -type msgServer struct { - Keeper -} - -// NewMsgServerImpl returns an implementation of the liquidstake MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} -} - -var _ types.MsgServer = msgServer{} - -func (k msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) (*types.MsgLiquidStakeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - gTACMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.Amount) - if err != nil { - return nil, err - } - - var cValue math.LegacyDec - if gTACMintAmount.IsPositive() { - cValue = gTACMintAmount.ToLegacyDec().Quo(msg.Amount.Amount.ToLegacyDec()) - } - - liquidBondDenom := k.LiquidBondDenom(ctx) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - sdk.NewEvent( - types.EventTypeMsgLiquidStake, - sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), - sdk.NewAttribute(types.AttributeKeyLiquidAmount, msg.Amount.String()), - sdk.NewAttribute(types.AttributeKeyGTACMintedAmount, sdk.Coin{Denom: liquidBondDenom, Amount: gTACMintAmount}.String()), - sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), - ), - }) - return &types.MsgLiquidStakeResponse{}, nil -} - -func (k msgServer) StakeToLP(goCtx context.Context, msg *types.MsgStakeToLP) (*types.MsgStakeToLPResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - gTACMintAmount, err := k.LSMDelegate( - ctx, - msg.GetDelegator(), - msg.GetValidator(), - types.LiquidStakeProxyAcc, - msg.StakedAmount, - ) - if err != nil { - return nil, err - } - - liquidBondDenom := k.LiquidBondDenom(ctx) - gTACMinted := sdk.Coin{ - Denom: liquidBondDenom, - Amount: gTACMintAmount, - } - - var cValue math.LegacyDec - if gTACMintAmount.IsPositive() { - cValue = gTACMintAmount.ToLegacyDec().Quo(msg.StakedAmount.Amount.ToLegacyDec()) - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - sdk.NewEvent( - types.EventTypeMsgStakeToLP, - sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), - sdk.NewAttribute(types.AttributeKeyStakedAmount, msg.StakedAmount.String()), - sdk.NewAttribute(types.AttributeKeyGTACMintedAmount, gTACMinted.String()), - sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), - ), - }) - - if (msg.LiquidAmount != sdk.Coin{}) && (msg.LiquidAmount.Amount != math.Int{}) && msg.LiquidAmount.Amount.IsPositive() { - gTACMintAmount, err := k.Keeper.LiquidStake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.LiquidAmount) - if err != nil { - return nil, err - } - - gTACMinted := sdk.Coin{ - Denom: liquidBondDenom, - Amount: gTACMintAmount, - } - - var cValue math.LegacyDec - if gTACMintAmount.IsPositive() { - cValue = gTACMintAmount.ToLegacyDec().Quo(msg.LiquidAmount.Amount.ToLegacyDec()) - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - sdk.NewEvent( - types.EventTypeMsgStakeToLP, - sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), - sdk.NewAttribute(types.AttributeKeyLiquidAmount, msg.LiquidAmount.String()), - sdk.NewAttribute(types.AttributeKeyGTACMintedAmount, gTACMinted.String()), - sdk.NewAttribute(types.AttributeKeyCValue, cValue.String()), - ), - }) - - _, err = k.LockOnLP(ctx, msg.GetDelegator(), gTACMinted) - if err != nil { - return nil, err - } - } - - return &types.MsgStakeToLPResponse{}, nil -} - -func (k msgServer) LiquidUnstake(goCtx context.Context, msg *types.MsgLiquidUnstake) (*types.MsgLiquidUnstakeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - completionTime, unbondingAmount, _, unbondedAmount, err := k.Keeper.LiquidUnstake(ctx, types.LiquidStakeProxyAcc, msg.GetDelegator(), msg.Amount) - if err != nil { - return nil, err - } - - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return nil, err - } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - sdk.NewEvent( - types.EventTypeMsgLiquidUnstake, - sdk.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress), - sdk.NewAttribute(types.AttributeKeyUnstakeAmount, msg.Amount.String()), - sdk.NewAttribute(types.AttributeKeyUnbondingAmount, sdk.Coin{Denom: bondDenom, Amount: unbondingAmount}.String()), - sdk.NewAttribute(types.AttributeKeyUnbondedAmount, sdk.Coin{Denom: bondDenom, Amount: unbondedAmount}.String()), - sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), - ), - }) - return &types.MsgLiquidUnstakeResponse{ - CompletionTime: completionTime, - }, nil -} - -func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - if msg.Authority != k.authority && msg.Authority != k.GetParams(ctx).WhitelistAdminAddress { - return nil, errors.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) - } - - paramsToSet := k.GetParams(ctx) - - // List of all updateable param - paramsToSet.UnstakeFeeRate = msg.Params.UnstakeFeeRate - paramsToSet.LsmDisabled = msg.Params.LsmDisabled - paramsToSet.MinLiquidStakeAmount = msg.Params.MinLiquidStakeAmount - paramsToSet.CwLockedPoolAddress = msg.Params.CwLockedPoolAddress - paramsToSet.FeeAccountAddress = msg.Params.FeeAccountAddress - paramsToSet.AutocompoundFeeRate = msg.Params.AutocompoundFeeRate - paramsToSet.WhitelistAdminAddress = msg.Params.WhitelistAdminAddress - - err := k.SetParams(ctx, paramsToSet) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - sdk.NewEvent( - types.EventTypeMsgUpdateParams, - sdk.NewAttribute(types.AttributeKeyAuthority, msg.Authority), - sdk.NewAttribute(types.AttributeKeyUpdatedParams, msg.Params.String()), - ), - }) - - return &types.MsgUpdateParamsResponse{}, nil -} - -func (k msgServer) UpdateWhitelistedValidators(goCtx context.Context, msg *types.MsgUpdateWhitelistedValidators) (*types.MsgUpdateWhitelistedValidatorsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - params := k.GetParams(ctx) - - if msg.Authority != k.authority && msg.Authority != params.WhitelistAdminAddress { - return nil, errors.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s, got %s", params.WhitelistAdminAddress, msg.Authority) - } - - totalWeight := math.NewInt(0) - for _, val := range msg.WhitelistedValidators { - totalWeight = totalWeight.Add(val.TargetWeight) - - valAddr := val.GetValidatorAddress() - fullVal, err := k.stakingKeeper.GetValidator(ctx, valAddr) - if err != nil { - return nil, normal_errors.Join( - errors.Wrapf( - types.ErrWhitelistedValidatorsList, - "validator not found: %s", valAddr, - ), - err, - ) - } - - if fullVal.Status != stakingtypes.Bonded { - return nil, errors.Wrapf( - types.ErrWhitelistedValidatorsList, - "validator status %s: expected %s; got %s", valAddr, stakingtypes.Bonded.String(), fullVal.Status.String(), - ) - } - } - - if len(msg.WhitelistedValidators) == 0 { - return nil, errors.Wrap(types.ErrWhitelistedValidatorsList, "whitelisted validators list cannot be empty") - } - if !totalWeight.Equal(types.TotalValidatorWeight) { - return nil, errors.Wrapf( - types.ErrWhitelistedValidatorsList, - "weights don't add up; expected %s, got %s", types.TotalValidatorWeight.String(), totalWeight.String(), - ) - } - params.WhitelistedValidators = msg.WhitelistedValidators - - err := k.SetParams(ctx, params) - if err != nil { - return nil, err - } - - updatedValidatorsListJSON, _ := json.Marshal(msg.WhitelistedValidators) - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - sdk.NewEvent( - types.EventTypeMsgUpdateWhitelistedValidators, - sdk.NewAttribute(types.AttributeKeyAuthority, msg.Authority), - sdk.NewAttribute(types.AttributeKeyUpdatedWhitelistedValidators, string(updatedValidatorsListJSON)), - ), - }) - - return &types.MsgUpdateWhitelistedValidatorsResponse{}, nil -} - -func (k msgServer) SetModulePaused(goCtx context.Context, msg *types.MsgSetModulePaused) (*types.MsgSetModulePausedResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - params := k.GetParams(ctx) - - if msg.Authority != k.authority && msg.Authority != params.WhitelistAdminAddress { - return nil, errors.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s, got %s", params.WhitelistAdminAddress, msg.Authority) - } - - params.ModulePaused = msg.IsPaused - - err := k.SetParams(ctx, params) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - sdk.NewEvent( - types.EventTypeMsgSetModulePaused, - sdk.NewAttribute(types.AttributeKeyAuthority, msg.Authority), - sdk.NewAttribute(types.AttributeKeyModulePaused, fmt.Sprintf("%t", msg.IsPaused)), - ), - }) - - return &types.MsgSetModulePausedResponse{}, nil -} diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go deleted file mode 100644 index b3fa6c2..0000000 --- a/x/liquidstake/keeper/rebalancing.go +++ /dev/null @@ -1,312 +0,0 @@ -package keeper - -import ( - "fmt" - "strconv" - "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -func (k Keeper) GetProxyAccBalance(ctx sdk.Context, proxyAcc sdk.AccAddress) (balance sdk.Coin, err error) { - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return sdk.Coin{}, err - } - - return sdk.NewCoin(bondDenom, k.bankKeeper.SpendableCoins(ctx, proxyAcc).AmountOf(bondDenom)), nil -} - -// TryRedelegation attempts redelegation, which is applied only when successful through cached context because there is a constraint that fails if already receiving redelegation. -func (k Keeper) TryRedelegation(ctx sdk.Context, re types.Redelegation) (completionTime time.Time, err error) { - dstVal := re.DstValidator.GetOperator() - srcVal := re.SrcValidator.GetOperator() - - // check the source validator already has receiving transitive redelegation - hasReceiving, err := k.stakingKeeper.HasReceivingRedelegation(ctx, re.Delegator, srcVal) - if err != nil { - return time.Time{}, err - } - - if hasReceiving { - return time.Time{}, stakingtypes.ErrTransitiveRedelegation - } - - // calculate delShares from tokens with validation - _, err = k.stakingKeeper.ValidateUnbondAmount( - ctx, re.Delegator, srcVal, re.Amount, - ) - if err != nil { - return time.Time{}, fmt.Errorf("failed to validate unbond amount: %w", err) - } - - // when last, full redelegation of shares from delegation - amt := re.Amount - if re.Last { - amt = re.SrcValidator.GetLiquidTokens(ctx, k.stakingKeeper, false) - } - cachedCtx, writeCache := ctx.CacheContext() - completionTime, err = k.RedelegateWithCap(cachedCtx, re.Delegator, srcVal, dstVal, amt) - if err != nil { - return time.Time{}, fmt.Errorf("failed to begin redelegation: %w", err) - } - writeCache() - return completionTime, nil -} - -// Rebalance argument liquidVals containing ValidatorStatusActive which is containing just added on whitelist(liquidToken 0) and ValidatorStatusInactive to delist -func (k Keeper) Rebalance( - ctx sdk.Context, - proxyAcc sdk.AccAddress, - liquidVals types.LiquidValidators, - whitelistedValsMap types.WhitelistedValsMap, - rebalancingTrigger math.LegacyDec, -) (redelegations []types.Redelegation) { - totalLiquidTokens, liquidTokenMap := liquidVals.TotalLiquidTokens(ctx, k.stakingKeeper, false) - if !totalLiquidTokens.IsPositive() { - return redelegations - } - - weightMap, totalWeight := k.GetWeightMap(ctx, liquidVals, whitelistedValsMap) - - // no active liquid validators - if !totalWeight.IsPositive() { - return redelegations - } - - // calculate rebalancing target map - targetMap := map[string]math.Int{} - totalTargetMap := math.ZeroInt() - for _, val := range liquidVals { - targetMap[val.OperatorAddress] = totalLiquidTokens.Mul(weightMap[val.OperatorAddress]).Quo(totalWeight) - totalTargetMap = totalTargetMap.Add(targetMap[val.OperatorAddress]) - } - crumb := totalLiquidTokens.Sub(totalTargetMap) - if !totalTargetMap.IsPositive() { - return redelegations - } - // crumb to first non zero liquid validator - for _, val := range liquidVals { - if targetMap[val.OperatorAddress].IsPositive() { - targetMap[val.OperatorAddress] = targetMap[val.OperatorAddress].Add(crumb) - break - } - } - - failCount := 0 - rebalancingThresholdAmt := rebalancingTrigger.Mul(math.LegacyNewDecFromInt(totalLiquidTokens)).TruncateInt() - redelegations = make([]types.Redelegation, 0, liquidVals.Len()) - - for i := range liquidVals.Len() { - // get min, max of liquid token gap - minVal, maxVal, amountNeeded, last := liquidVals.MinMaxGap(targetMap, liquidTokenMap) - if amountNeeded.IsNegative() || amountNeeded.IsZero() || (i == 0 && !amountNeeded.GT(rebalancingThresholdAmt)) { - break - } - - // sync liquidTokenMap applied rebalancing - liquidTokenMap[maxVal.OperatorAddress] = liquidTokenMap[maxVal.OperatorAddress].Sub(amountNeeded) - liquidTokenMap[minVal.OperatorAddress] = liquidTokenMap[minVal.OperatorAddress].Add(amountNeeded) - - // try redelegation from max validator to min validator - redelegation := types.Redelegation{ - Delegator: proxyAcc, - SrcValidator: maxVal, - DstValidator: minVal, - Amount: amountNeeded, - Last: last, - } - - _, err := k.TryRedelegation(ctx, redelegation) - if err != nil { - redelegation.Error = err - failCount++ - - k.Logger(ctx).Info( - "redelegation failed", - types.DelegatorKeyVal, proxyAcc.String(), - types.SrcValidatorKeyVal, maxVal.OperatorAddress, - types.DstValidatorKeyVal, minVal.OperatorAddress, - types.AmountKeyVal, amountNeeded.String(), - types.ErrorKeyVal, err.Error(), - ) - } - - redelegations = append(redelegations, redelegation) - } - - if len(redelegations) != 0 { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeBeginRebalancing, - sdk.NewAttribute(types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String()), - sdk.NewAttribute(types.AttributeKeyRedelegationCount, strconv.Itoa(len(redelegations))), - sdk.NewAttribute(types.AttributeKeyRedelegationFailCount, strconv.Itoa(failCount)), - ), - }) - k.Logger(ctx).Info(types.EventTypeBeginRebalancing, - types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String(), - types.AttributeKeyRedelegationCount, strconv.Itoa(len(redelegations)), - types.AttributeKeyRedelegationFailCount, strconv.Itoa(failCount)) - } - - return redelegations -} - -func (k Keeper) UpdateLiquidValidatorSet(ctx sdk.Context, redelegate bool) (redelegations []types.Redelegation) { - params := k.GetParams(ctx) - liquidValidators := k.GetAllLiquidValidators(ctx) - liquidValsMap := liquidValidators.Map() - whitelistedValsMap := types.GetWhitelistedValsMap(params.WhitelistedValidators) - - // Set Liquid validators for added whitelist validators - for _, wv := range params.WhitelistedValidators { - if _, ok := liquidValsMap[wv.ValidatorAddress]; !ok { - lv := types.LiquidValidator{ - OperatorAddress: wv.ValidatorAddress, - } - if k.IsActiveLiquidValidator(ctx, lv, whitelistedValsMap) { - k.SetLiquidValidator(ctx, lv) - liquidValidators = append(liquidValidators, lv) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAddLiquidValidator, - sdk.NewAttribute(types.AttributeKeyLiquidValidator, lv.OperatorAddress), - ), - }) - k.Logger(ctx).Info(types.EventTypeAddLiquidValidator, types.AttributeKeyLiquidValidator, lv.OperatorAddress) - } - } - } - - // rebalancing based updated liquid validators status with threshold, try by cachedCtx - // tombstone status also handled on Rebalance - if redelegate { - redelegations = k.Rebalance( - ctx, - types.LiquidStakeProxyAcc, - liquidValidators, - whitelistedValsMap, - types.RebalancingTrigger, - ) - - // if there are inactive liquid validators, do not unbond, - // instead let validator selection and rebalancing take care of it. - - return redelegations - } - return nil -} - -// AutocompoundStakingRewards withdraws staking rewards and re-stakes when over threshold. -func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap types.WhitelistedValsMap) error { - // withdraw rewards of LiquidStakeProxyAcc - k.WithdrawLiquidRewards(ctx, types.LiquidStakeProxyAcc) - - // skip when no active liquid validator - activeVals := k.GetActiveLiquidValidators(ctx, whitelistedValsMap) - if len(activeVals) == 0 { - return nil - } - - // get all the APY components - bondDenom, err := k.stakingKeeper.BondDenom(ctx) - if err != nil { - return err - } - - totalSupply := k.bankKeeper.GetSupply(ctx, bondDenom).Amount - bondedTokens := k.bankKeeper.GetBalance(ctx, k.stakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount - //inflation := k.mintKeeper.GetMinter(ctx).Inflation - minter, err := k.mintKeeper.Minter.Get(ctx) - if err != nil { - return err - } - inflation := minter.Inflation - - - // calculate the hourly APY - bondRatio := math.LegacyDec(bondedTokens).Quo(math.LegacyDec(totalSupply)) - hourlyApy := inflation.Quo(bondRatio). - Quo(types.DefaultLimitAutocompoundPeriodDays). - Quo(types.DefaultLimitAutocompoundPeriodHours) - - // calculate autocompoundable amount by limiting the current net amount with the calculated APY - NetAmountState, err := k.GetNetAmountState(ctx) - if err != nil { - return err - } - autoCompoundableAmount := NetAmountState.NetAmount.Mul(hourlyApy).TruncateInt() - - // use the calculated autocompoundable amount as the limit for the transfer - proxyAccBalance, err := k.GetProxyAccBalance(ctx, types.LiquidStakeProxyAcc) - if err != nil { - return err - } - if proxyAccBalance.Amount.IsNegative() { - autoCompoundableAmount = math.ZeroInt() - } else if proxyAccBalance.Amount.LT(autoCompoundableAmount) { - autoCompoundableAmount = proxyAccBalance.Amount - } - - // calculate autocompounding fee - params := k.GetParams(ctx) - bondDenom, err = k.stakingKeeper.BondDenom(ctx) - if err != nil { - return err - } - - autocompoundFee := sdk.NewCoin(bondDenom, math.ZeroInt()) - if !params.AutocompoundFeeRate.IsZero() && autoCompoundableAmount.IsPositive() { - autocompoundFee = sdk.NewCoin( - bondDenom, - params.AutocompoundFeeRate.MulInt(autoCompoundableAmount).TruncateInt(), - ) - } - - // re-staking of the accumulated rewards - cachedCtx, writeCache := ctx.CacheContext() - delegableAmount := autoCompoundableAmount.Sub(autocompoundFee.Amount) - err = k.LiquidDelegate(cachedCtx, types.LiquidStakeProxyAcc, activeVals, delegableAmount, whitelistedValsMap) - if err != nil { - k.Logger(ctx).Error( - "failed to re-stake the accumulated rewards", - types.ErrorKeyVal, - err, - ) - return nil - // skip errors as they might occur due to reaching global liquid cap - } - writeCache() - - // move autocompounding fee from the balance to fee account - feeAccountAddr := sdk.MustAccAddressFromBech32(params.FeeAccountAddress) - err = k.bankKeeper.SendCoins(ctx, types.LiquidStakeProxyAcc, feeAccountAddr, sdk.NewCoins(autocompoundFee)) - if err != nil { - k.Logger(ctx).Error( - "failed to send autocompound fee to fee account", - types.ErrorKeyVal, - err, - ) - return nil - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAutocompound, - sdk.NewAttribute(types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String()), - sdk.NewAttribute(sdk.AttributeKeyAmount, delegableAmount.String()), - sdk.NewAttribute(types.AttributeKeyAutocompoundFee, autocompoundFee.String()), - ), - }) - k.Logger(ctx).Info(types.EventTypeAutocompound, - types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String(), - sdk.AttributeKeyAmount, delegableAmount.String(), - types.AttributeKeyAutocompoundFee, autocompoundFee.String()) - - return nil -} diff --git a/x/liquidstake/module.go b/x/liquidstake/module.go deleted file mode 100644 index 92bd6b1..0000000 --- a/x/liquidstake/module.go +++ /dev/null @@ -1,152 +0,0 @@ -package liquidstake - -import ( - "context" - "encoding/json" - "fmt" - - abci "github.com/cometbft/cometbft/abci/types" - sdkclient "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/client/cli" - "github.com/Asphere-xyz/tacchain/x/liquidstake/keeper" - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} -) - -// AppModuleBasic defines the basic application module used by the liquidstake module. -type AppModuleBasic struct{} - -// Name returns the liquidstake module's name. -func (AppModuleBasic) Name() string { - return types.ModuleName -} - -// RegisterLegacyAminoCodec registers the liquidstake module's types for the given codec. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(cdc) -} - -// DefaultGenesis returns default genesis state as raw bytes for the liquidstake -// module. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesisState()) -} - -// ValidateGenesis performs genesis state validation for the liquidstake module. -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ sdkclient.TxEncodingConfig, bz json.RawMessage) error { - var data types.GenesisState - if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } - - return types.ValidateGenesis(data) -} - -// RegisterRESTRoutes registers the REST routes for the liquidstake module. -func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} - -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the liquidstake module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - panic(err) - } -} - -// GetTxCmd returns the root tx command for the liquidstake module. -// Modifying parameters of a liquidstake can be done through governance process, not through transaction level. -func (AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd() -} - -// GetQueryCmd returns the root query command for the liquidstake module. -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() -} - -func (b AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { - types.RegisterInterfaces(reg) -} - -// AppModule implements an application module for the liquidstake module. -type AppModule struct { - AppModuleBasic - - keeper keeper.Keeper -} - -// NewAppModule creates a new AppModule object -func NewAppModule( - keeper keeper.Keeper, -) AppModule { - return AppModule{ - AppModuleBasic: AppModuleBasic{}, - keeper: keeper, - } -} - -// Name returns the liquidstake module's name. -func (AppModule) Name() string { - return types.ModuleName -} - -// RegisterInvariants registers the liquidstake module invariants. -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} - -// QuerierRoute returns the liquidstake module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - -// IsAppModule implements the appmodule.AppModule interface. -func (am AppModule) IsAppModule() {} - -// RegisterServices registers module services. -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), keeper.Querier{Keeper: am.keeper}) -} - -// InitGenesis performs genesis initialization for the liquidstake 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) - am.keeper.InitGenesis(ctx, genesisState) - return []abci.ValidatorUpdate{} -} - -// ExportGenesis returns the exported genesis state as raw bytes for the liquidstake -// module. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := am.keeper.ExportGenesis(ctx) - return cdc.MustMarshalJSON(gs) -} - -// ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } - -// BeginBlock returns the begin blocker for the liquidstake module. -func (am AppModule) BeginBlock(ctx sdk.Context) { - BeginBlock(ctx, am.keeper) -} - -// EndBlock returns the end blocker for the liquidstake module. It returns no validator -// updates. -func (am AppModule) EndBlock(_ sdk.Context) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} diff --git a/x/liquidstake/types/codec.go b/x/liquidstake/types/codec.go deleted file mode 100644 index e50ad2f..0000000 --- a/x/liquidstake/types/codec.go +++ /dev/null @@ -1,50 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// RegisterLegacyAminoCodec registers the necessary x/liquidstake interfaces and concrete types -// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgLiquidStake{}, "liquidstake/MsgLiquidStake", nil) - cdc.RegisterConcrete(&MsgStakeToLP{}, "liquidstake/MsgStakeToLP", nil) - cdc.RegisterConcrete(&MsgLiquidUnstake{}, "liquidstake/MsgLiquidUnstake", nil) - cdc.RegisterConcrete(&MsgUpdateParams{}, "liquidstake/MsgUpdateParams", nil) - cdc.RegisterConcrete(&MsgUpdateWhitelistedValidators{}, "liquidstake/MsgUpdateWhitelistedValidators", nil) - cdc.RegisterConcrete(&MsgSetModulePaused{}, "liquidstake/MsgSetModulePaused", nil) -} - -// RegisterInterfaces registers the x/liquidstake interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgLiquidStake{}, - &MsgStakeToLP{}, - &MsgLiquidUnstake{}, - &MsgUpdateParams{}, - &MsgUpdateWhitelistedValidators{}, - &MsgSetModulePaused{}, - ) -} - -var ( - amino = codec.NewLegacyAmino() - - // ModuleCdc references the global x/liquidstake module codec. Note, the codec - // should ONLY be used in certain instances of tests and for JSON encoding as Amino - // is still used for that purpose. - // - // The actual codec used for serialization should be provided to x/liquidstake and - // defined at the application level. - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - amino.Seal() -} diff --git a/x/liquidstake/types/errors.go b/x/liquidstake/types/errors.go deleted file mode 100644 index c274eec..0000000 --- a/x/liquidstake/types/errors.go +++ /dev/null @@ -1,32 +0,0 @@ -package types - -import "cosmossdk.io/errors" - -// Sentinel errors for the liquidstake module. -var ( - ErrActiveLiquidValidatorsNotExists = errors.Register(ModuleName, 1000, "active liquid validators not exists") - ErrInvalidDenom = errors.Register(ModuleName, 1001, "invalid denom") - ErrInvalidBondDenom = errors.Register(ModuleName, 1002, "invalid bond denom") - ErrInvalidLiquidBondDenom = errors.Register(ModuleName, 1003, "invalid liquid bond denom") - ErrNotImplementedYet = errors.Register(ModuleName, 1004, "not implemented yet") - ErrLessThanMinLiquidStakeAmount = errors.Register(ModuleName, 1005, "staking amount should be over params.min_liquid_stake_amount") - ErrInvalidGTACSupply = errors.Register(ModuleName, 1006, "invalid liquid bond denom supply") - ErrInvalidActiveLiquidValidators = errors.Register(ModuleName, 1007, "invalid active liquid validators") - ErrLiquidValidatorsNotExists = errors.Register(ModuleName, 1008, "liquid validators not exists") - ErrInsufficientProxyAccBalance = errors.Register(ModuleName, 1009, "insufficient liquid tokens or balance of proxy account, need to wait for new liquid validator to be added or unbonding of proxy account to be completed") - ErrTooSmallLiquidStakeAmount = errors.Register(ModuleName, 1010, "liquid stake amount is too small, the result becomes zero") - ErrTooSmallLiquidUnstakingAmount = errors.Register(ModuleName, 1011, "liquid unstaking amount is too small, the result becomes zero") - ErrNoLPContractAddress = errors.Register(ModuleName, 1012, "CW address of an LP contract is not set") - ErrDisabledLSM = errors.Register(ModuleName, 1013, "LSM delegation is disabled") - ErrLSMTokenizeFailed = errors.Register(ModuleName, 1014, "LSM tokenization failed") - ErrLSMRedeemFailed = errors.Register(ModuleName, 1015, "LSM redemption failed") - ErrLPContract = errors.Register(ModuleName, 1016, "CW contract execution failed") - ErrWhitelistedValidatorsList = errors.Register(ModuleName, 1017, "whitelisted validators list incorrect") - ErrActiveLiquidValidatorsWeightQuorumNotReached = errors.Register(ModuleName, 1018, "active liquid validators weight quorum not reached") - ErrModulePaused = errors.Register(ModuleName, 1019, "module functions have been paused") - ErrDelegationFailed = errors.Register(ModuleName, 1020, "delegation failed") - ErrUnbondFailed = errors.Register(ModuleName, 1021, "unbond failed") - ErrInvalidResponse = errors.Register(ModuleName, 1022, "invalid response") - ErrUnstakeFailed = errors.Register(ModuleName, 1023, "Unstaking failed") - ErrRedelegateFailed = errors.Register(ModuleName, 1024, "Redelegate failed") -) diff --git a/x/liquidstake/types/errors_test.go b/x/liquidstake/types/errors_test.go deleted file mode 100644 index f958aef..0000000 --- a/x/liquidstake/types/errors_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" - ibctypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" // Import the conflicting module -) - -func TestErrorCodeRegistration(t *testing.T) { - // This test simply imports both modules with error registrations - // If there's a conflict, it will panic during initialization - // The test passes if it doesn't panic - assert.NotNil(t, types.ErrActiveLiquidValidatorsNotExists, "liquidstake error should be registered") - assert.NotNil(t, ibctypes.ErrInvalidProof, "IBC error should be registered") -} diff --git a/x/liquidstake/types/events.go b/x/liquidstake/types/events.go deleted file mode 100644 index c889fed..0000000 --- a/x/liquidstake/types/events.go +++ /dev/null @@ -1,38 +0,0 @@ -package types - -// Event types for the liquidstake module. -const ( - EventTypeMsgLiquidStake = MsgTypeLiquidStake - EventTypeMsgLiquidUnstake = MsgTypeLiquidUnstake - EventTypeMsgStakeToLP = MsgTypeStakeToLP - EventTypeMsgUpdateParams = MsgTypeUpdateParams - EventTypeMsgUpdateWhitelistedValidators = MsgTypeUpdateWhitelistedValidators - EventTypeMsgSetModulePaused = MsgTypeSetModulePaused - EventTypeAddLiquidValidator = "add_liquid_validator" - EventTypeRemoveLiquidValidator = "remove_liquid_validator" - EventTypeBeginRebalancing = "begin_rebalancing" - EventTypeAutocompound = "autocompound" - EventTypeUnbondInactiveLiquidTokens = "unbond_inactive_liquid_tokens" - - AttributeKeyDelegator = "delegator" - AttributeKeyNewShares = "new_shares" - AttributeKeyCValue = "c_value" - AttributeKeyGTACMintedAmount = "gtac_minted_amount" - AttributeKeyCompletionTime = "completion_time" - AttributeKeyUnbondingAmount = "unbonding_amount" - AttributeKeyUnbondedAmount = "unbonded_amount" - AttributeKeyLiquidValidator = "liquid_validator" - AttributeKeyRedelegationCount = "redelegation_count" - AttributeKeyRedelegationFailCount = "redelegation_fail_count" - AttributeKeyLiquidAmount = "liquid_amount" - AttributeKeyStakedAmount = "staked_amount" - AttributeKeyUnstakeAmount = "unstake_amount" - AttributeKeyAutocompoundFee = "autocompound_fee" - AttributeKeyModulePaused = "module_paused" - - AttributeKeyAuthority = "authority" - AttributeKeyUpdatedParams = "updated_params" - AttributeKeyUpdatedWhitelistedValidators = "updated_whitelisted_validators" - - AttributeValueCategory = ModuleName -) diff --git a/x/liquidstake/types/expected_keepers.go b/x/liquidstake/types/expected_keepers.go deleted file mode 100644 index 3a01034..0000000 --- a/x/liquidstake/types/expected_keepers.go +++ /dev/null @@ -1,38 +0,0 @@ -package types - -import ( - //"time" - //"context" - - "cosmossdk.io/math" - //abci "github.com/cometbft/cometbft/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" - //"github.com/cosmos/cosmos-sdk/x/mint/types" - //stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" -) - -type ( - BankKeeper = bankkeeper.Keeper - AccountKeeper = authkeeper.AccountKeeper - StakingKeeper = stakingkeeper.Keeper - MintKeeper = mintkeeper.Keeper - DistrKeeper = distrkeeper.Keeper - SlashingKeeper = slashingkeeper.Keeper -) - -type StakingHooks interface { - AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created - AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted - - BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation is created - BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation's shares are modified - AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) - BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction math.LegacyDec) -} diff --git a/x/liquidstake/types/genesis.go b/x/liquidstake/types/genesis.go deleted file mode 100644 index 08ea0f3..0000000 --- a/x/liquidstake/types/genesis.go +++ /dev/null @@ -1,37 +0,0 @@ -package types - -import ( - "cosmossdk.io/errors" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewGenesisState returns new GenesisState instance. -func NewGenesisState(params Params, liquidValidators []LiquidValidator) *GenesisState { - return &GenesisState{ - Params: params, - LiquidValidators: liquidValidators, - } -} - -// DefaultGenesisState returns the default genesis state. -func DefaultGenesisState() *GenesisState { - return NewGenesisState( - DefaultParams(), - []LiquidValidator{}, - ) -} - -// ValidateGenesis validates GenesisState. -func ValidateGenesis(data GenesisState) error { - if err := data.Params.Validate(); err != nil { - return err - } - for _, lv := range data.LiquidValidators { - if err := lv.Validate(); err != nil { - return errors.Wrapf( - sdkerrors.ErrInvalidAddress, - "invalid liquid validator %s: %v", lv, err) - } - } - return nil -} diff --git a/x/liquidstake/types/genesis.pb.go b/x/liquidstake/types/genesis.pb.go deleted file mode 100644 index 11bb118..0000000 --- a/x/liquidstake/types/genesis.pb.go +++ /dev/null @@ -1,377 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tac/liquidstake/v1beta1/genesis.proto - -package types - -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 - -// GenesisState defines the liquidstake module's genesis state. -type GenesisState struct { - // params defines all the parameters for the liquidstake module - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - LiquidValidators []LiquidValidator `protobuf:"bytes,2,rep,name=liquid_validators,json=liquidValidators,proto3" json:"liquid_validators"` -} - -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_6924241cc1e1a1cb, []int{0} -} -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 - -func init() { - proto.RegisterType((*GenesisState)(nil), "tac.liquidstake.v1beta1.GenesisState") -} - -func init() { - proto.RegisterFile("tac/liquidstake/v1beta1/genesis.proto", fileDescriptor_6924241cc1e1a1cb) -} - -var fileDescriptor_6924241cc1e1a1cb = []byte{ - // 274 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2d, 0x49, 0x4c, 0xd6, - 0xcf, 0xc9, 0x2c, 0x2c, 0xcd, 0x4c, 0x29, 0x2e, 0x49, 0xcc, 0x4e, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, - 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x12, 0x2f, 0x49, 0x4c, 0xd6, 0x43, 0x52, 0xa6, 0x07, 0x55, 0x26, 0x25, 0x92, 0x9e, - 0x9f, 0x9e, 0x0f, 0x56, 0xa3, 0x0f, 0x62, 0x41, 0x94, 0x4b, 0x69, 0xe2, 0x32, 0x15, 0xd9, 0x08, - 0xb0, 0x52, 0xa5, 0x2d, 0x8c, 0x5c, 0x3c, 0xee, 0x10, 0xbb, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, - 0x6c, 0xb9, 0xd8, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, - 0xe4, 0xf5, 0x70, 0xd8, 0xad, 0x17, 0x00, 0x56, 0xe6, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, - 0x54, 0x93, 0x50, 0x34, 0x97, 0x20, 0x44, 0x6d, 0x7c, 0x59, 0x62, 0x4e, 0x66, 0x4a, 0x62, 0x49, - 0x7e, 0x51, 0xb1, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x06, 0x4e, 0x93, 0x7c, 0xc0, 0x62, - 0x61, 0x30, 0x0d, 0x50, 0x23, 0x05, 0x72, 0x50, 0x85, 0x8b, 0xad, 0x38, 0x3a, 0x16, 0xc8, 0x33, - 0xbc, 0x58, 0x20, 0xcf, 0xe0, 0x14, 0xb8, 0xe2, 0x91, 0x1c, 0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, - 0xea, 0x3b, 0x16, 0x17, 0x64, 0xa4, 0x16, 0xa5, 0xea, 0x56, 0x54, 0x56, 0xe9, 0x97, 0x24, 0x26, - 0x27, 0x67, 0x24, 0x66, 0xe6, 0xe9, 0x57, 0xa0, 0x84, 0x4e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, - 0x1b, 0x38, 0x40, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x7a, 0x9e, 0x44, 0x93, 0x01, - 0x00, 0x00, -} - -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.LiquidValidators) > 0 { - for iNdEx := len(m.LiquidValidators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LiquidValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -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 *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - if len(m.LiquidValidators) > 0 { - for _, e := range m.LiquidValidators { - l = e.Size() - 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 *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 != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidValidators", 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.LiquidValidators = append(m.LiquidValidators, LiquidValidator{}) - if err := m.LiquidValidators[len(m.LiquidValidators)-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 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/liquidstake/types/genesis_test.go b/x/liquidstake/types/genesis_test.go deleted file mode 100644 index f13d548..0000000 --- a/x/liquidstake/types/genesis_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package types_test - -import ( - "testing" - - "cosmossdk.io/math" - "github.com/stretchr/testify/require" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -func TestGenesisState_Validate(t *testing.T) { - for _, tc := range []struct { - name string - malleate func(genState *types.GenesisState) - expectedErr string - }{ - { - "default is valid", - func(genState *types.GenesisState) {}, - "", - }, - { - "invalid liquid validator address", - func(genState *types.GenesisState) { - genState.LiquidValidators = []types.LiquidValidator{ - { - OperatorAddress: "invalidAddr", - }, - } - }, - "invalid liquid validator {invalidAddr}: decoding bech32 failed: string not all lowercase or all uppercase: invalid address", - }, - { - "empty liquid validator address", - func(genState *types.GenesisState) { - genState.LiquidValidators = []types.LiquidValidator{ - { - OperatorAddress: "", - }, - } - }, - "invalid liquid validator {}: empty address string is not allowed: invalid address", - }, - { - "invalid params(UnstakeFeeRate)", - func(genState *types.GenesisState) { - genState.Params.UnstakeFeeRate = math.LegacyDec{} - }, - "unstake fee rate must not be nil", - }, - } { - t.Run(tc.name, func(t *testing.T) { - genState := types.DefaultGenesisState() - tc.malleate(genState) - err := types.ValidateGenesis(*genState) - if tc.expectedErr == "" { - require.NoError(t, err) - } else { - require.EqualError(t, err, tc.expectedErr) - } - }) - } -} diff --git a/x/liquidstake/types/keys.go b/x/liquidstake/types/keys.go deleted file mode 100644 index ac06b49..0000000 --- a/x/liquidstake/types/keys.go +++ /dev/null @@ -1,39 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" -) - -const ( - // ModuleName is the name of the liquidstake module - ModuleName = "liquidstake" - - // RouterKey is the message router key for the liquidstake module - RouterKey = ModuleName - - // StoreKey is the default store key for the liquidstake module - // To avoid collision with liquidstakeibc we make it tacliquidstake - StoreKey = "utac" + ModuleName - - // QuerierRoute is the querier route for the liquidstake module - QuerierRoute = ModuleName - - // Epoch identifiers - AutocompoundEpoch = "hour" - RebalanceEpoch = "day" -) - -var ( - ParamsKey = []byte{0x01} - - // LiquidValidatorsKey defines prefix for each key to a liquid validator - LiquidValidatorsKey = []byte{0x02} -) - -// GetLiquidValidatorKey creates the key for the liquid validator with address -// VALUE: liquidstake/LiquidValidator -func GetLiquidValidatorKey(operatorAddr sdk.ValAddress) []byte { - tmp := append([]byte{}, LiquidValidatorsKey...) - return append(tmp, address.MustLengthPrefix(operatorAddr)...) -} diff --git a/x/liquidstake/types/liquidstake.go b/x/liquidstake/types/liquidstake.go deleted file mode 100644 index 265cd77..0000000 --- a/x/liquidstake/types/liquidstake.go +++ /dev/null @@ -1,218 +0,0 @@ -package types - -import ( - "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -type WhitelistedValsMap map[string]WhitelistedValidator - -func (whitelistedValsMap WhitelistedValsMap) IsListed(operatorAddr string) bool { - if _, ok := whitelistedValsMap[operatorAddr]; ok { - return true - } - - return false -} - -func GetWhitelistedValsMap(whitelistedValidators []WhitelistedValidator) WhitelistedValsMap { - whitelistedValsMap := make(WhitelistedValsMap) - for _, wv := range whitelistedValidators { - whitelistedValsMap[wv.ValidatorAddress] = wv - } - return whitelistedValsMap -} - -// Validate validates LiquidValidator. -func (v LiquidValidator) Validate() error { - _, valErr := sdk.ValAddressFromBech32(v.OperatorAddress) - if valErr != nil { - return valErr - } - return nil -} - -func (v LiquidValidator) GetOperator() sdk.ValAddress { - if v.OperatorAddress == "" { - return nil - } - addr, err := sdk.ValAddressFromBech32(v.OperatorAddress) - if err != nil { - panic(err) - } - return addr -} - -func (v LiquidValidator) GetDelShares(ctx sdk.Context, sk StakingKeeper) math.LegacyDec { - del, err := sk.GetDelegation(ctx, LiquidStakeProxyAcc, v.GetOperator()) - if err != nil { - return math.LegacyZeroDec() - } - return del.GetShares() -} - -func (v LiquidValidator) GetLiquidTokens(ctx sdk.Context, sk StakingKeeper, onlyBonded bool) math.Int { - delShares := v.GetDelShares(ctx, sk) - if !delShares.IsPositive() { - return math.ZeroInt() - } - val, err := sk.Validator(ctx, v.GetOperator()) - if err != nil { - return math.ZeroInt() - } - if onlyBonded && !val.IsBonded() { - return math.ZeroInt() - } - return val.TokensFromSharesTruncated(delShares).TruncateInt() -} - -func (v LiquidValidator) GetWeight(whitelistedValsMap WhitelistedValsMap, active bool) math.Int { - if wv, ok := whitelistedValsMap[v.OperatorAddress]; ok && active { - return wv.TargetWeight - } - - return math.ZeroInt() -} - -func (v LiquidValidator) GetStatus(activeCondition bool) ValidatorStatus { - if activeCondition { - return ValidatorStatusActive - } - - return ValidatorStatusInactive -} - -// ActiveCondition checks the liquid validator could be active by below cases -// - included on whitelist -// - existed valid validator on staking module ( existed, not nil del shares and tokens, valid exchange rate) -// - not tombstoned -func ActiveCondition(validator stakingtypes.Validator, whitelisted, tombstoned bool) bool { - return whitelisted && - !tombstoned && - // !Unspecified ==> Bonded, Unbonding, Unbonded - validator.GetStatus() != stakingtypes.Unspecified && - !validator.GetTokens().IsNil() && - !validator.GetDelegatorShares().IsNil() && - !validator.InvalidExRate() -} - -// LiquidValidators is a collection of LiquidValidator -type ( - LiquidValidators []LiquidValidator - ActiveLiquidValidators LiquidValidators -) - -// MinMaxGap Return the list of LiquidValidator with the maximum gap and minimum gap from the target weight of LiquidValidators, respectively. -func (vs LiquidValidators) MinMaxGap(targetMap, liquidTokenMap map[string]math.Int) (minGapVal, maxGapVal LiquidValidator, amountNeeded math.Int, lastRedelegation bool) { - maxGap := math.ZeroInt() - minGap := math.ZeroInt() - - for _, val := range vs { - gap := liquidTokenMap[val.OperatorAddress].Sub(targetMap[val.OperatorAddress]) - if gap.GT(maxGap) { - maxGap = gap - maxGapVal = val - } - if gap.LT(minGap) { - minGap = gap - minGapVal = val - } - } - amountNeeded = math.MinInt(maxGap, minGap.Abs()) - // lastRedelegation when maxGap validator's liquid token == amountNeeded for redelegation all delShares - lastRedelegation = amountNeeded.IsPositive() && - !targetMap[maxGapVal.OperatorAddress].IsPositive() && - liquidTokenMap[maxGapVal.OperatorAddress].Equal(amountNeeded) - - return minGapVal, maxGapVal, amountNeeded, lastRedelegation -} - -func (vs LiquidValidators) Len() int { - return len(vs) -} - -func (vs LiquidValidators) TotalLiquidTokens(ctx sdk.Context, sk StakingKeeper, onlyBonded bool) (math.Int, map[string]math.Int) { - totalLiquidTokens := math.ZeroInt() - liquidTokenMap := map[string]math.Int{} - for _, lv := range vs { - liquidTokens := lv.GetLiquidTokens(ctx, sk, onlyBonded) - liquidTokenMap[lv.OperatorAddress] = liquidTokens - totalLiquidTokens = totalLiquidTokens.Add(liquidTokens) - } - return totalLiquidTokens, liquidTokenMap -} - -func (vs LiquidValidators) Map() map[string]struct{} { - valsMap := map[string]struct{}{} - for _, val := range vs { - valsMap[val.OperatorAddress] = struct{}{} - } - return valsMap -} - -func (avs ActiveLiquidValidators) Len() int { - return LiquidValidators(avs).Len() -} - -func (avs ActiveLiquidValidators) TotalActiveLiquidTokens(ctx sdk.Context, sk StakingKeeper, onlyBonded bool) (math.Int, map[string]math.Int) { - return LiquidValidators(avs).TotalLiquidTokens(ctx, sk, onlyBonded) -} - -// TotalWeight for active liquid validator -func (avs ActiveLiquidValidators) TotalWeight(whitelistedValsMap WhitelistedValsMap) math.Int { - totalWeight := math.ZeroInt() - for _, val := range avs { - totalWeight = totalWeight.Add(val.GetWeight(whitelistedValsMap, true)) - } - return totalWeight -} - -// NativeTokenToGTAC returns GtacTotalSupply * nativeTokenAmount / netAmount -func NativeTokenToGTAC(nativeTokenAmount, gTACTotalSupplyAmount math.Int, netAmount math.LegacyDec) (gTACAmount math.Int) { - return math.LegacyNewDecFromInt(gTACTotalSupplyAmount).MulTruncate(math.LegacyNewDecFromInt(nativeTokenAmount)).QuoTruncate(netAmount.TruncateDec()).TruncateInt() -} - -// GTACToNativeToken returns gTACAmount * netAmount / GtacTotalSupply with truncations -func GTACToNativeToken(gTACAmount, gTACTotalSupplyAmount math.Int, netAmount math.LegacyDec) (nativeTokenAmount math.LegacyDec) { - return math.LegacyNewDecFromInt(gTACAmount).MulTruncate(netAmount).Quo(math.LegacyNewDecFromInt(gTACTotalSupplyAmount)).TruncateDec() -} - -// DeductFeeRate returns Input * (1-FeeRate) with truncations -func DeductFeeRate(input, feeRate math.LegacyDec) (feeDeductedOutput math.LegacyDec) { - return input.MulTruncate(math.LegacyOneDec().Sub(feeRate)).TruncateDec() -} - -func (nas NetAmountState) CalcNetAmount() math.LegacyDec { - return math.LegacyNewDecFromInt(nas.TotalLiquidTokens.Add(nas.TotalUnbondingBalance)) -} - -func (nas NetAmountState) CalcMintRate() math.LegacyDec { - if nas.NetAmount.IsNil() || !nas.NetAmount.IsPositive() { - return math.LegacyZeroDec() - } - return math.LegacyNewDecFromInt(nas.GtacTotalSupply).QuoTruncate(nas.NetAmount) -} - -type LiquidValidatorStates []LiquidValidatorState - -func MustMarshalLiquidValidator(cdc codec.BinaryCodec, val *LiquidValidator) []byte { - return cdc.MustMarshal(val) -} - -// must unmarshal a liquid validator from a store value -func MustUnmarshalLiquidValidator(cdc codec.BinaryCodec, value []byte) LiquidValidator { - validator, err := UnmarshalLiquidValidator(cdc, value) - if err != nil { - panic(err) - } - - return validator -} - -// unmarshal a liquid validator from a store value -func UnmarshalLiquidValidator(cdc codec.BinaryCodec, value []byte) (val LiquidValidator, err error) { - err = cdc.Unmarshal(value, &val) - return val, err -} diff --git a/x/liquidstake/types/liquidstake.pb.go b/x/liquidstake/types/liquidstake.pb.go deleted file mode 100644 index fc8ace9..0000000 --- a/x/liquidstake/types/liquidstake.pb.go +++ /dev/null @@ -1,2056 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tac/liquidstake/v1beta1/liquidstake.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "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 - -// ValidatorStatus enumerates the status of a liquid validator. -type ValidatorStatus int32 - -const ( - // VALIDATOR_STATUS_UNSPECIFIED defines the unspecified invalid status. - ValidatorStatusUnspecified ValidatorStatus = 0 - // VALIDATOR_STATUS_ACTIVE defines the active, valid status - ValidatorStatusActive ValidatorStatus = 1 - // VALIDATOR_STATUS_INACTIVE defines the inactive, invalid status - ValidatorStatusInactive ValidatorStatus = 2 -) - -var ValidatorStatus_name = map[int32]string{ - 0: "VALIDATOR_STATUS_UNSPECIFIED", - 1: "VALIDATOR_STATUS_ACTIVE", - 2: "VALIDATOR_STATUS_INACTIVE", -} - -var ValidatorStatus_value = map[string]int32{ - "VALIDATOR_STATUS_UNSPECIFIED": 0, - "VALIDATOR_STATUS_ACTIVE": 1, - "VALIDATOR_STATUS_INACTIVE": 2, -} - -func (x ValidatorStatus) String() string { - return proto.EnumName(ValidatorStatus_name, int32(x)) -} - -func (ValidatorStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_8986499a0b409e33, []int{0} -} - -// Params defines the set of params for the liquidstake module. -type Params struct { - // LiquidBondDenom specifies the denomination of the token receiving after - // liquid stake, The value is calculated through NetAmount. - LiquidBondDenom string `protobuf:"bytes,1,opt,name=liquid_bond_denom,json=liquidBondDenom,proto3" json:"liquid_bond_denom,omitempty"` - // WhitelistedValidators specifies the validators elected to become Active - // Liquid Validators. - WhitelistedValidators []WhitelistedValidator `protobuf:"bytes,2,rep,name=whitelisted_validators,json=whitelistedValidators,proto3" json:"whitelisted_validators"` - // UnstakeFeeRate specifies the fee rate when liquid unstake is requested, - // unbonded by subtracting it from unbondingAmount - UnstakeFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=unstake_fee_rate,json=unstakeFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"unstake_fee_rate"` - // LsmDisabled allows to block any msgs that convert staked tokens into - // gTAC through LSM. - LsmDisabled bool `protobuf:"varint,4,opt,name=lsm_disabled,json=lsmDisabled,proto3" json:"lsm_disabled,omitempty"` - // MinLiquidStakingAmount specifies the minimum number of coins to be staked - // to the active liquid validators on liquid staking to minimize decimal loss - // and consider gas efficiency. - MinLiquidStakeAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=min_liquid_stake_amount,json=minLiquidStakeAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_liquid_stake_amount"` - // CwLockedPoolAddress defines the bech32-encoded address of - // a CW smart-contract representing a time locked LP (e.g. Superfluid LP). - CwLockedPoolAddress string `protobuf:"bytes,6,opt,name=cw_locked_pool_address,json=cwLockedPoolAddress,proto3" json:"cw_locked_pool_address,omitempty"` - // FeeAccountAddress defines the bech32-encoded address of - // a an account responsible for accumulating protocol fees. - FeeAccountAddress string `protobuf:"bytes,7,opt,name=fee_account_address,json=feeAccountAddress,proto3" json:"fee_account_address,omitempty"` - // AutocompoundFeeRate specifies the fee rate for auto redelegating the stake - // rewards. The fee is taken in favour of the fee account (see - // FeeAccountAddress). - AutocompoundFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=autocompound_fee_rate,json=autocompoundFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"autocompound_fee_rate"` - // WhitelistAdminAddress the bech32-encoded address of an admin authority - // that is allowed to update whitelisted validators or pause liquidstaking - // module entirely. The key is controlled by an offchain process that is - // selecting validators based on a criteria. Pausing of the module can be - // required during important migrations or failures. - WhitelistAdminAddress string `protobuf:"bytes,9,opt,name=whitelist_admin_address,json=whitelistAdminAddress,proto3" json:"whitelist_admin_address,omitempty"` - // ModulePaused is a safety toggle that allows to stop main module functions - // such as stake/unstake/stake-to-lp and the BeginBlocker logic. - ModulePaused bool `protobuf:"varint,10,opt,name=module_paused,json=modulePaused,proto3" json:"module_paused,omitempty"` -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_8986499a0b409e33, []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 - -// WhitelistedValidator consists of the validator operator address and the -// target weight, which is a value for calculating the real weight to be derived -// according to the active status. -type WhitelistedValidator struct { - // validator_address defines the bech32-encoded address that whitelisted - // validator - ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` - // target_weight specifies the target weight for liquid staking, unstaking - // amount, which is a value for calculating the real weight to be derived - // according to the active status - TargetWeight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=target_weight,json=targetWeight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"target_weight"` -} - -func (m *WhitelistedValidator) Reset() { *m = WhitelistedValidator{} } -func (m *WhitelistedValidator) String() string { return proto.CompactTextString(m) } -func (*WhitelistedValidator) ProtoMessage() {} -func (*WhitelistedValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_8986499a0b409e33, []int{1} -} -func (m *WhitelistedValidator) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *WhitelistedValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_WhitelistedValidator.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 *WhitelistedValidator) XXX_Merge(src proto.Message) { - xxx_messageInfo_WhitelistedValidator.Merge(m, src) -} -func (m *WhitelistedValidator) XXX_Size() int { - return m.Size() -} -func (m *WhitelistedValidator) XXX_DiscardUnknown() { - xxx_messageInfo_WhitelistedValidator.DiscardUnknown(m) -} - -var xxx_messageInfo_WhitelistedValidator proto.InternalMessageInfo - -// LiquidValidator defines a Validator that can be the target of LiquidStaking -// and LiquidUnstaking, Active, Weight, etc. fields are derived as functions to -// deal with by maintaining consistency with the state of the staking module. -type LiquidValidator struct { - // operator_address defines the address of the validator's operator; bech - // encoded in JSON. - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` -} - -func (m *LiquidValidator) Reset() { *m = LiquidValidator{} } -func (m *LiquidValidator) String() string { return proto.CompactTextString(m) } -func (*LiquidValidator) ProtoMessage() {} -func (*LiquidValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_8986499a0b409e33, []int{2} -} -func (m *LiquidValidator) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LiquidValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LiquidValidator.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 *LiquidValidator) XXX_Merge(src proto.Message) { - xxx_messageInfo_LiquidValidator.Merge(m, src) -} -func (m *LiquidValidator) XXX_Size() int { - return m.Size() -} -func (m *LiquidValidator) XXX_DiscardUnknown() { - xxx_messageInfo_LiquidValidator.DiscardUnknown(m) -} - -var xxx_messageInfo_LiquidValidator proto.InternalMessageInfo - -// LiquidValidatorState is type LiquidValidator with state added to return to -// query results. -type LiquidValidatorState struct { - // operator_address defines the address of the validator's operator; bech - // encoded in JSON. - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` - // weight specifies the weight for liquid staking, unstaking amount - Weight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"weight"` - // status is the liquid validator status - Status ValidatorStatus `protobuf:"varint,3,opt,name=status,proto3,enum=tac.liquidstake.v1beta1.ValidatorStatus" json:"status,omitempty"` - // del_shares define the delegation shares of the validator - DelShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=del_shares,json=delShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"del_shares"` - // liquid_tokens define the token amount worth of delegation shares of the - // validator (slashing applied amount) - LiquidTokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=liquid_tokens,json=liquidTokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"liquid_tokens"` -} - -func (m *LiquidValidatorState) Reset() { *m = LiquidValidatorState{} } -func (m *LiquidValidatorState) String() string { return proto.CompactTextString(m) } -func (*LiquidValidatorState) ProtoMessage() {} -func (*LiquidValidatorState) Descriptor() ([]byte, []int) { - return fileDescriptor_8986499a0b409e33, []int{3} -} -func (m *LiquidValidatorState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LiquidValidatorState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LiquidValidatorState.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 *LiquidValidatorState) XXX_Merge(src proto.Message) { - xxx_messageInfo_LiquidValidatorState.Merge(m, src) -} -func (m *LiquidValidatorState) XXX_Size() int { - return m.Size() -} -func (m *LiquidValidatorState) XXX_DiscardUnknown() { - xxx_messageInfo_LiquidValidatorState.DiscardUnknown(m) -} - -var xxx_messageInfo_LiquidValidatorState proto.InternalMessageInfo - -// NetAmountState is type for net amount raw data and mint rate, This is a value -// that depends on the several module state every time, so it is used only for -// calculation and query and is not stored in kv. -type NetAmountState struct { - // mint_rate is gTACTotalSupply / NetAmount - MintRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=mint_rate,json=mintRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"mint_rate"` - // btoken_total_supply returns the total supply of stk/utac (gTAC denom) - GtacTotalSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=gtac_total_supply,json=gtacTotalSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gtac_total_supply"` - // net_amount is proxy account's native token balance + total liquid tokens + - // total remaining rewards + total unbonding balance - NetAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=net_amount,json=netAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"net_amount"` - // total_del_shares define the delegation shares of all liquid validators - TotalDelShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=total_del_shares,json=totalDelShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"total_del_shares"` - // total_liquid_tokens define the token amount worth of delegation shares of - // all liquid validator (slashing applied amount) - TotalLiquidTokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=total_liquid_tokens,json=totalLiquidTokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_liquid_tokens"` - // total_remaining_rewards define the sum of remaining rewards of proxy - // account by all liquid validators - TotalRemainingRewards github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=total_remaining_rewards,json=totalRemainingRewards,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"total_remaining_rewards"` - // total_unbonding_balance define the unbonding balance of proxy account by - // all liquid validator (slashing applied amount) - TotalUnbondingBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=total_unbonding_balance,json=totalUnbondingBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_unbonding_balance"` - // proxy_acc_balance define the balance of proxy account for the native token - ProxyAccBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=proxy_acc_balance,json=proxyAccBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"proxy_acc_balance"` -} - -func (m *NetAmountState) Reset() { *m = NetAmountState{} } -func (m *NetAmountState) String() string { return proto.CompactTextString(m) } -func (*NetAmountState) ProtoMessage() {} -func (*NetAmountState) Descriptor() ([]byte, []int) { - return fileDescriptor_8986499a0b409e33, []int{4} -} -func (m *NetAmountState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NetAmountState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NetAmountState.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 *NetAmountState) XXX_Merge(src proto.Message) { - xxx_messageInfo_NetAmountState.Merge(m, src) -} -func (m *NetAmountState) XXX_Size() int { - return m.Size() -} -func (m *NetAmountState) XXX_DiscardUnknown() { - xxx_messageInfo_NetAmountState.DiscardUnknown(m) -} - -var xxx_messageInfo_NetAmountState proto.InternalMessageInfo - -func init() { - proto.RegisterEnum("tac.liquidstake.v1beta1.ValidatorStatus", ValidatorStatus_name, ValidatorStatus_value) - proto.RegisterType((*Params)(nil), "tac.liquidstake.v1beta1.Params") - proto.RegisterType((*WhitelistedValidator)(nil), "tac.liquidstake.v1beta1.WhitelistedValidator") - proto.RegisterType((*LiquidValidator)(nil), "tac.liquidstake.v1beta1.LiquidValidator") - proto.RegisterType((*LiquidValidatorState)(nil), "tac.liquidstake.v1beta1.LiquidValidatorState") - proto.RegisterType((*NetAmountState)(nil), "tac.liquidstake.v1beta1.NetAmountState") -} - -func init() { - proto.RegisterFile("tac/liquidstake/v1beta1/liquidstake.proto", fileDescriptor_8986499a0b409e33) -} - -var fileDescriptor_8986499a0b409e33 = []byte{ - // 999 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x41, 0x4f, 0x1b, 0x47, - 0x14, 0xc7, 0xbd, 0x40, 0x5c, 0x98, 0x10, 0xc0, 0x8b, 0x89, 0x8d, 0x5b, 0x19, 0x97, 0x4a, 0x15, - 0x8d, 0x84, 0xad, 0x24, 0x52, 0x0f, 0x9c, 0xb2, 0xc6, 0xa0, 0x5a, 0x05, 0x6a, 0xad, 0x0d, 0xa9, - 0x72, 0xe8, 0x74, 0xbc, 0x33, 0xd8, 0x5b, 0x76, 0x67, 0xb6, 0x3b, 0xb3, 0x18, 0x7a, 0xec, 0x29, - 0xe2, 0x54, 0xa9, 0x97, 0x5e, 0x90, 0x22, 0xf5, 0x2b, 0xf4, 0xd0, 0x8f, 0x90, 0x4b, 0xa5, 0xa8, - 0xa7, 0xaa, 0x87, 0xa8, 0x82, 0x4b, 0x3f, 0x42, 0x8f, 0xd5, 0xcc, 0xec, 0xda, 0x8e, 0x93, 0x08, - 0xd9, 0xc9, 0x09, 0x3c, 0xb3, 0xff, 0xdf, 0x7b, 0xf3, 0xfe, 0x6f, 0xdf, 0x2c, 0xf8, 0x4c, 0x20, - 0xa7, 0xe2, 0xb9, 0xdf, 0x47, 0x2e, 0xe6, 0x02, 0x9d, 0x90, 0xca, 0xe9, 0xfd, 0x36, 0x11, 0xe8, - 0xfe, 0xf0, 0x5a, 0x39, 0x08, 0x99, 0x60, 0x66, 0x4e, 0x20, 0xa7, 0x3c, 0xbc, 0x1c, 0x3f, 0x5a, - 0xc8, 0x76, 0x58, 0x87, 0xa9, 0x67, 0x2a, 0xf2, 0x3f, 0xfd, 0x78, 0x61, 0xd5, 0x61, 0xdc, 0x67, - 0x1c, 0xea, 0x0d, 0xfd, 0x43, 0x6f, 0xad, 0xff, 0x98, 0x06, 0xe9, 0x06, 0x0a, 0x91, 0xcf, 0xcd, - 0x7b, 0x20, 0xa3, 0x91, 0xb0, 0xcd, 0x28, 0x86, 0x98, 0x50, 0xe6, 0xe7, 0x8d, 0x92, 0xb1, 0x31, - 0x67, 0x2f, 0xea, 0x8d, 0x2a, 0xa3, 0xb8, 0x26, 0x97, 0xcd, 0xef, 0xc0, 0xdd, 0x5e, 0xd7, 0x15, - 0xc4, 0x73, 0xb9, 0x20, 0x18, 0x9e, 0x22, 0xcf, 0xc5, 0x48, 0xb0, 0x90, 0xe7, 0xa7, 0x4a, 0xd3, - 0x1b, 0xb7, 0x1f, 0x6c, 0x96, 0xdf, 0x92, 0x61, 0xf9, 0xf1, 0x40, 0x76, 0x94, 0xa8, 0xaa, 0x33, - 0xcf, 0x5f, 0xae, 0xa5, 0xec, 0x95, 0xde, 0x1b, 0xf6, 0xb8, 0xf9, 0x35, 0x58, 0x8a, 0xa8, 0x82, - 0xc0, 0x63, 0x42, 0x60, 0x88, 0x04, 0xc9, 0x4f, 0xcb, 0xb4, 0xaa, 0x65, 0x29, 0xfb, 0xfb, 0xe5, - 0xda, 0xa7, 0x1d, 0x57, 0x74, 0xa3, 0x76, 0xd9, 0x61, 0x7e, 0x7c, 0xba, 0xf8, 0xcf, 0x26, 0xc7, - 0x27, 0x15, 0x71, 0x1e, 0x10, 0x5e, 0xae, 0x11, 0xc7, 0x5e, 0x88, 0x39, 0xbb, 0x84, 0xd8, 0x48, - 0x10, 0xf3, 0x63, 0x30, 0xef, 0x71, 0x1f, 0x62, 0x97, 0xa3, 0xb6, 0x47, 0x70, 0x7e, 0xa6, 0x64, - 0x6c, 0xcc, 0xda, 0xb7, 0x3d, 0xee, 0xd7, 0xe2, 0x25, 0x93, 0x80, 0x9c, 0xef, 0x52, 0x18, 0x17, - 0x46, 0x67, 0x81, 0x7c, 0x16, 0x51, 0x91, 0xbf, 0x35, 0x76, 0x0e, 0x75, 0x2a, 0xec, 0xac, 0xef, - 0xd2, 0x3d, 0x45, 0x6b, 0x4a, 0x98, 0xa5, 0x58, 0xe6, 0x3e, 0xb8, 0xeb, 0xf4, 0xa0, 0xc7, 0x9c, - 0x13, 0x82, 0x61, 0xc0, 0x98, 0x07, 0x11, 0xc6, 0x21, 0xe1, 0x3c, 0x9f, 0x56, 0x51, 0xf2, 0x7f, - 0xfe, 0xb6, 0x99, 0x8d, 0x8d, 0xb3, 0xf4, 0x4e, 0x53, 0x84, 0x2e, 0xed, 0xd8, 0xcb, 0x4e, 0x6f, - 0x4f, 0xc9, 0x1a, 0x8c, 0x79, 0xf1, 0x96, 0xf9, 0x05, 0x58, 0x96, 0xa5, 0x42, 0x8e, 0x23, 0xe9, - 0x7d, 0xd6, 0x07, 0x37, 0xb0, 0x32, 0xc7, 0x84, 0x58, 0x5a, 0x93, 0x90, 0xda, 0x60, 0x05, 0x45, - 0x82, 0x39, 0xcc, 0x0f, 0x58, 0x44, 0xf1, 0xc0, 0x81, 0xd9, 0x89, 0x1c, 0x58, 0x1e, 0x86, 0x25, - 0x36, 0x34, 0x40, 0xae, 0xef, 0x3c, 0x44, 0x58, 0xd6, 0x3b, 0xc9, 0x78, 0xee, 0x86, 0x8c, 0x07, - 0x2d, 0x63, 0x49, 0x5d, 0x92, 0xf5, 0x27, 0xe0, 0x8e, 0xcf, 0x70, 0xe4, 0x11, 0x18, 0xa0, 0x88, - 0x13, 0x9c, 0x07, 0xca, 0xd9, 0x79, 0xbd, 0xd8, 0x50, 0x6b, 0x5b, 0xb3, 0x4f, 0x9f, 0xad, 0xa5, - 0x7e, 0x79, 0xb6, 0x96, 0x5a, 0xff, 0xdd, 0x00, 0xd9, 0x37, 0xf5, 0xa5, 0xb9, 0x03, 0x32, 0xfd, - 0xd6, 0xee, 0xe7, 0x64, 0xdc, 0x90, 0xd3, 0x52, 0x5f, 0x92, 0xa4, 0xd3, 0x04, 0x77, 0x04, 0x0a, - 0x3b, 0x44, 0xc0, 0x1e, 0x71, 0x3b, 0x5d, 0x91, 0x9f, 0x9a, 0xa8, 0x75, 0xe6, 0x35, 0xe4, 0xb1, - 0x62, 0x6c, 0xcd, 0xc8, 0xf4, 0xd7, 0xbf, 0x05, 0x8b, 0xba, 0x9b, 0x06, 0x49, 0x6f, 0x83, 0x25, - 0x16, 0x90, 0x70, 0xac, 0x9c, 0x17, 0x13, 0x45, 0xbc, 0xac, 0x8b, 0xf3, 0xaf, 0x8c, 0xf0, 0xf3, - 0x34, 0xc8, 0x8e, 0x84, 0x68, 0x0a, 0x69, 0xdb, 0xfb, 0x88, 0x63, 0xee, 0x82, 0xf4, 0x3b, 0xd5, - 0x24, 0x56, 0x9b, 0x8f, 0x40, 0x9a, 0x0b, 0x24, 0x22, 0xae, 0x46, 0xc3, 0xc2, 0x83, 0x8d, 0xb7, - 0x0e, 0xa0, 0x57, 0x4e, 0x11, 0x71, 0x3b, 0xd6, 0x99, 0xfb, 0x00, 0x60, 0xe2, 0x41, 0xde, 0x45, - 0x21, 0xe1, 0x6a, 0x14, 0x8c, 0xdf, 0xde, 0x73, 0x98, 0x78, 0x4d, 0x05, 0x90, 0x9e, 0xc7, 0x43, - 0x43, 0xb0, 0x13, 0x42, 0xf9, 0x84, 0xe3, 0x62, 0x5e, 0x43, 0x5a, 0x8a, 0x31, 0xe4, 0xca, 0x7f, - 0xb7, 0xc0, 0xc2, 0x01, 0x11, 0x7a, 0x7c, 0x68, 0x3f, 0xbe, 0x04, 0x73, 0xbe, 0x4b, 0x85, 0x7e, - 0x3d, 0x8d, 0x89, 0xf2, 0x9f, 0x95, 0x00, 0xf5, 0x4e, 0x3e, 0x01, 0x99, 0x8e, 0x40, 0x0e, 0x14, - 0x4c, 0x20, 0x0f, 0xf2, 0x28, 0x08, 0xbc, 0xf3, 0x09, 0x2d, 0x5a, 0x94, 0xa0, 0x96, 0xe4, 0x34, - 0x15, 0x46, 0x56, 0x9a, 0x12, 0x91, 0x8c, 0xd1, 0xc9, 0x46, 0xf9, 0x1c, 0x4d, 0x0e, 0x2f, 0xef, - 0x07, 0x9d, 0xe5, 0x3b, 0xdb, 0xb7, 0xa0, 0x38, 0xb5, 0xbe, 0x87, 0xdf, 0x80, 0x65, 0x4d, 0x7e, - 0x1f, 0x4e, 0x66, 0x14, 0x6a, 0x6f, 0xc8, 0x4e, 0xf3, 0x18, 0xe4, 0x34, 0x3f, 0x24, 0x3e, 0x72, - 0xa9, 0x4b, 0x3b, 0x30, 0x24, 0x3d, 0x14, 0xe2, 0x64, 0xec, 0x8f, 0x7b, 0x80, 0x15, 0x85, 0xb3, - 0x13, 0x9a, 0xad, 0x61, 0x83, 0x38, 0x11, 0x95, 0x57, 0xbb, 0x8c, 0xd3, 0x46, 0x1e, 0xa2, 0x0e, - 0x89, 0xaf, 0x84, 0x71, 0xcf, 0xa2, 0xe3, 0x1c, 0x26, 0xb4, 0xaa, 0x86, 0xc9, 0xa6, 0x09, 0x42, - 0x76, 0x76, 0x2e, 0x2f, 0x9e, 0x7e, 0x84, 0xd9, 0xc9, 0x9a, 0x46, 0x81, 0x2c, 0xc7, 0x89, 0xd9, - 0xaa, 0xf5, 0x0d, 0xd9, 0xfa, 0xf7, 0xfe, 0x30, 0xc0, 0xe2, 0xc8, 0x4b, 0x6c, 0x3e, 0x02, 0x1f, - 0x1d, 0x59, 0x7b, 0xf5, 0x9a, 0xd5, 0xfa, 0xca, 0x86, 0xcd, 0x96, 0xd5, 0x3a, 0x6c, 0xc2, 0xc3, - 0x83, 0x66, 0x63, 0x67, 0xbb, 0xbe, 0x5b, 0xdf, 0xa9, 0x2d, 0xa5, 0x0a, 0xc5, 0x8b, 0xcb, 0x52, - 0x61, 0x44, 0x76, 0x48, 0x79, 0x40, 0x1c, 0xf7, 0xd8, 0x25, 0xd8, 0xfc, 0x1c, 0xe4, 0x5e, 0x23, - 0x58, 0xdb, 0xad, 0xfa, 0xd1, 0xce, 0x92, 0x51, 0x58, 0xbd, 0xb8, 0x2c, 0xad, 0x8c, 0x88, 0x2d, - 0x47, 0xb8, 0xa7, 0xc4, 0xdc, 0x02, 0xab, 0xaf, 0xe9, 0xea, 0x07, 0xb1, 0x72, 0xaa, 0xf0, 0xe1, - 0xc5, 0x65, 0x29, 0x37, 0xa2, 0xac, 0x53, 0xa4, 0xb4, 0x85, 0x99, 0xa7, 0xbf, 0x16, 0x53, 0xd5, - 0xfd, 0xe7, 0x57, 0x45, 0xe3, 0xc5, 0x55, 0xd1, 0xf8, 0xe7, 0xaa, 0x68, 0xfc, 0x74, 0x5d, 0x4c, - 0xbd, 0xb8, 0x2e, 0xa6, 0xfe, 0xba, 0x2e, 0xa6, 0x9e, 0x3c, 0x1c, 0x2a, 0x96, 0xc5, 0x83, 0x2e, - 0x09, 0xc9, 0xe6, 0xd9, 0xf9, 0x0f, 0x15, 0x81, 0x1c, 0xa7, 0x8b, 0x5c, 0x5a, 0x39, 0x7b, 0xe5, - 0x7b, 0x51, 0x55, 0xaf, 0x9d, 0x56, 0x1f, 0x76, 0x0f, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x34, - 0xa7, 0xf5, 0x26, 0x4f, 0x0a, 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.ModulePaused { - i-- - if m.ModulePaused { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x50 - } - if len(m.WhitelistAdminAddress) > 0 { - i -= len(m.WhitelistAdminAddress) - copy(dAtA[i:], m.WhitelistAdminAddress) - i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.WhitelistAdminAddress))) - i-- - dAtA[i] = 0x4a - } - { - size := m.AutocompoundFeeRate.Size() - i -= size - if _, err := m.AutocompoundFeeRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - if len(m.FeeAccountAddress) > 0 { - i -= len(m.FeeAccountAddress) - copy(dAtA[i:], m.FeeAccountAddress) - i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.FeeAccountAddress))) - i-- - dAtA[i] = 0x3a - } - if len(m.CwLockedPoolAddress) > 0 { - i -= len(m.CwLockedPoolAddress) - copy(dAtA[i:], m.CwLockedPoolAddress) - i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.CwLockedPoolAddress))) - i-- - dAtA[i] = 0x32 - } - { - size := m.MinLiquidStakeAmount.Size() - i -= size - if _, err := m.MinLiquidStakeAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.LsmDisabled { - i-- - if m.LsmDisabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - { - size := m.UnstakeFeeRate.Size() - i -= size - if _, err := m.UnstakeFeeRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.WhitelistedValidators) > 0 { - for iNdEx := len(m.WhitelistedValidators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.WhitelistedValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.LiquidBondDenom) > 0 { - i -= len(m.LiquidBondDenom) - copy(dAtA[i:], m.LiquidBondDenom) - i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.LiquidBondDenom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *WhitelistedValidator) 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 *WhitelistedValidator) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *WhitelistedValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.TargetWeight.Size() - i -= size - if _, err := m.TargetWeight.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *LiquidValidator) 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 *LiquidValidator) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LiquidValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.OperatorAddress) > 0 { - i -= len(m.OperatorAddress) - copy(dAtA[i:], m.OperatorAddress) - i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.OperatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *LiquidValidatorState) 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 *LiquidValidatorState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LiquidValidatorState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.LiquidTokens.Size() - i -= size - if _, err := m.LiquidTokens.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.DelShares.Size() - i -= size - if _, err := m.DelShares.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if m.Status != 0 { - i = encodeVarintLiquidstake(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x18 - } - { - size := m.Weight.Size() - i -= size - if _, err := m.Weight.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.OperatorAddress) > 0 { - i -= len(m.OperatorAddress) - copy(dAtA[i:], m.OperatorAddress) - i = encodeVarintLiquidstake(dAtA, i, uint64(len(m.OperatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *NetAmountState) 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 *NetAmountState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NetAmountState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.ProxyAccBalance.Size() - i -= size - if _, err := m.ProxyAccBalance.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - { - size := m.TotalUnbondingBalance.Size() - i -= size - if _, err := m.TotalUnbondingBalance.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - { - size := m.TotalRemainingRewards.Size() - i -= size - if _, err := m.TotalRemainingRewards.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.TotalLiquidTokens.Size() - i -= size - if _, err := m.TotalLiquidTokens.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.TotalDelShares.Size() - i -= size - if _, err := m.TotalDelShares.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.NetAmount.Size() - i -= size - if _, err := m.NetAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.GtacTotalSupply.Size() - i -= size - if _, err := m.GtacTotalSupply.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.MintRate.Size() - i -= size - if _, err := m.MintRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLiquidstake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintLiquidstake(dAtA []byte, offset int, v uint64) int { - offset -= sovLiquidstake(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 - l = len(m.LiquidBondDenom) - if l > 0 { - n += 1 + l + sovLiquidstake(uint64(l)) - } - if len(m.WhitelistedValidators) > 0 { - for _, e := range m.WhitelistedValidators { - l = e.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - } - } - l = m.UnstakeFeeRate.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - if m.LsmDisabled { - n += 2 - } - l = m.MinLiquidStakeAmount.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = len(m.CwLockedPoolAddress) - if l > 0 { - n += 1 + l + sovLiquidstake(uint64(l)) - } - l = len(m.FeeAccountAddress) - if l > 0 { - n += 1 + l + sovLiquidstake(uint64(l)) - } - l = m.AutocompoundFeeRate.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = len(m.WhitelistAdminAddress) - if l > 0 { - n += 1 + l + sovLiquidstake(uint64(l)) - } - if m.ModulePaused { - n += 2 - } - return n -} - -func (m *WhitelistedValidator) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovLiquidstake(uint64(l)) - } - l = m.TargetWeight.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - return n -} - -func (m *LiquidValidator) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.OperatorAddress) - if l > 0 { - n += 1 + l + sovLiquidstake(uint64(l)) - } - return n -} - -func (m *LiquidValidatorState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.OperatorAddress) - if l > 0 { - n += 1 + l + sovLiquidstake(uint64(l)) - } - l = m.Weight.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - if m.Status != 0 { - n += 1 + sovLiquidstake(uint64(m.Status)) - } - l = m.DelShares.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.LiquidTokens.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - return n -} - -func (m *NetAmountState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.MintRate.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.GtacTotalSupply.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.NetAmount.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.TotalDelShares.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.TotalLiquidTokens.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.TotalRemainingRewards.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.TotalUnbondingBalance.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - l = m.ProxyAccBalance.Size() - n += 1 + l + sovLiquidstake(uint64(l)) - return n -} - -func sovLiquidstake(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozLiquidstake(x uint64) (n int) { - return sovLiquidstake(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 ErrIntOverflowLiquidstake - } - 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 != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidBondDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LiquidBondDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedValidators", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.WhitelistedValidators = append(m.WhitelistedValidators, WhitelistedValidator{}) - if err := m.WhitelistedValidators[len(m.WhitelistedValidators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnstakeFeeRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UnstakeFeeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LsmDisabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.LsmDisabled = bool(v != 0) - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinLiquidStakeAmount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinLiquidStakeAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CwLockedPoolAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CwLockedPoolAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeeAccountAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FeeAccountAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AutocompoundFeeRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.AutocompoundFeeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WhitelistAdminAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.WhitelistAdminAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ModulePaused", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ModulePaused = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipLiquidstake(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLiquidstake - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *WhitelistedValidator) 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 ErrIntOverflowLiquidstake - } - 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: WhitelistedValidator: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: WhitelistedValidator: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TargetWeight", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TargetWeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLiquidstake(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLiquidstake - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LiquidValidator) 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 ErrIntOverflowLiquidstake - } - 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: LiquidValidator: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LiquidValidator: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OperatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLiquidstake(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLiquidstake - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LiquidValidatorState) 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 ErrIntOverflowLiquidstake - } - 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: LiquidValidatorState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LiquidValidatorState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OperatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Weight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= ValidatorStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelShares", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidTokens", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LiquidTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLiquidstake(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLiquidstake - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *NetAmountState) 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 ErrIntOverflowLiquidstake - } - 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: NetAmountState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NetAmountState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MintRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MintRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GtacTotalSupply", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.GtacTotalSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NetAmount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.NetAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalDelShares", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TotalDelShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalLiquidTokens", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TotalLiquidTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalRemainingRewards", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TotalRemainingRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalUnbondingBalance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TotalUnbondingBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProxyAccBalance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLiquidstake - } - 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 ErrInvalidLengthLiquidstake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLiquidstake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProxyAccBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLiquidstake(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLiquidstake - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipLiquidstake(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, ErrIntOverflowLiquidstake - } - 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, ErrIntOverflowLiquidstake - } - 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, ErrIntOverflowLiquidstake - } - 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, ErrInvalidLengthLiquidstake - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupLiquidstake - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthLiquidstake - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthLiquidstake = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowLiquidstake = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupLiquidstake = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/liquidstake/types/logging.go b/x/liquidstake/types/logging.go deleted file mode 100644 index 15cfa46..0000000 --- a/x/liquidstake/types/logging.go +++ /dev/null @@ -1,19 +0,0 @@ -package types - -const ( - // keyvals - DelegatorKeyVal string = "delegator" - ValidatorKeyVal string = "validator" - SrcValidatorKeyVal string = "src_validator" - DstValidatorKeyVal string = "dst_validator" - AmountKeyVal string = "amount" - MsgKeyVal string = "msg" - ErrorKeyVal string = "error" - ActiveWeightQuorumKeyVal string = "active_weight_quorum" - MinActiveWeightQuorumKeyVal string = "min_active_weight_quorum" - ActiveValidatorsKeyVal string = "active_validators" - WhitelistedValidatorsMapKeyVal string = "whitelisted_validators_map" - ValidatorsKeyVal string = "validators" - NetAmountStateKeyVal string = "net_amount_state" - TotalLiquidTokensKeyVal string = "total_liquid_tokens" -) diff --git a/x/liquidstake/types/msgs.go b/x/liquidstake/types/msgs.go deleted file mode 100644 index 5376755..0000000 --- a/x/liquidstake/types/msgs.go +++ /dev/null @@ -1,330 +0,0 @@ -package types - -import ( - "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -var ( - _ sdk.Msg = (*MsgLiquidStake)(nil) - _ sdk.Msg = (*MsgLiquidUnstake)(nil) - _ sdk.Msg = (*MsgUpdateParams)(nil) - _ sdk.Msg = (*MsgStakeToLP)(nil) - _ sdk.Msg = (*MsgUpdateWhitelistedValidators)(nil) - _ sdk.Msg = (*MsgSetModulePaused)(nil) -) - -// Message types for the liquidstake module -const ( - MsgTypeLiquidStake = "liquid_stake" - MsgTypeLiquidUnstake = "liquid_unstake" - MsgTypeStakeToLP = "stake_to_lp" - MsgTypeUpdateParams = "update_params" - MsgTypeUpdateWhitelistedValidators = "update_whitelisted_validators" - MsgTypeSetModulePaused = "set_module_paused" -) - -// NewMsgLiquidStake creates a new MsgLiquidStake. -func NewMsgLiquidStake( - liquidStaker sdk.AccAddress, - amount sdk.Coin, -) *MsgLiquidStake { - return &MsgLiquidStake{ - DelegatorAddress: liquidStaker.String(), - Amount: amount, - } -} - -func (m *MsgLiquidStake) Route() string { return RouterKey } - -func (m *MsgLiquidStake) Type() string { return MsgTypeLiquidStake } - -func (m *MsgLiquidStake) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.DelegatorAddress); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid delegator address %q: %v", m.DelegatorAddress, err) - } - if ok := m.Amount.IsZero(); ok { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "staking amount must not be zero") - } - if err := m.Amount.Validate(); err != nil { - return err - } - return nil -} - -func (m *MsgLiquidStake) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) -} - -func (m *MsgLiquidStake) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{addr} -} - -func (m *MsgLiquidStake) GetDelegator() sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) - if err != nil { - panic(err) - } - return addr -} - -// NewMsgStakeToLP creates a new MsgStakeToLP. -func NewMsgStakeToLP( - liquidStaker sdk.AccAddress, - validator sdk.ValAddress, - stakedAmount, - liquidAmount sdk.Coin, -) *MsgStakeToLP { - return &MsgStakeToLP{ - DelegatorAddress: liquidStaker.String(), - ValidatorAddress: validator.String(), - StakedAmount: stakedAmount, - LiquidAmount: liquidAmount, - } -} - -func (m *MsgStakeToLP) Route() string { return RouterKey } - -func (m *MsgStakeToLP) Type() string { return MsgTypeStakeToLP } - -func (m *MsgStakeToLP) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.DelegatorAddress); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid delegator address %q: %v", m.DelegatorAddress, err) - } - - if _, err := sdk.ValAddressFromBech32(m.ValidatorAddress); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid validator address %q: %v", m.ValidatorAddress, err) - } - - if (m.StakedAmount == sdk.Coin{}) || m.StakedAmount.IsZero() { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "staked amount must not be zero") - } else if err := m.StakedAmount.Validate(); err != nil { - return err - } - - if (m.LiquidAmount != sdk.Coin{}) && !m.LiquidAmount.IsZero() { - if err := m.LiquidAmount.Validate(); err != nil { - return err - } - } - - return nil -} - -func (m *MsgStakeToLP) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) -} - -func (m *MsgStakeToLP) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{addr} -} - -func (m *MsgStakeToLP) GetValidator() sdk.ValAddress { - addr, err := sdk.ValAddressFromBech32(m.ValidatorAddress) - if err != nil { - panic(err) - } - return addr -} - -func (m *MsgStakeToLP) GetDelegator() sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) - if err != nil { - panic(err) - } - return addr -} - -// NewMsgLiquidUnstake creates a new MsgLiquidUnstake. -func NewMsgLiquidUnstake( - liquidStaker sdk.AccAddress, - amount sdk.Coin, -) *MsgLiquidUnstake { - return &MsgLiquidUnstake{ - DelegatorAddress: liquidStaker.String(), - Amount: amount, - } -} - -func (m *MsgLiquidUnstake) Route() string { return RouterKey } - -func (m *MsgLiquidUnstake) Type() string { return MsgTypeLiquidUnstake } - -func (m *MsgLiquidUnstake) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.DelegatorAddress); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid delegator address %q: %v", m.DelegatorAddress, err) - } - if ok := m.Amount.IsZero(); ok { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "unstaking amount must not be zero") - } - if err := m.Amount.Validate(); err != nil { - return err - } - return nil -} - -func (m *MsgLiquidUnstake) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) -} - -func (m *MsgLiquidUnstake) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{addr} -} - -func (m *MsgLiquidUnstake) GetDelegator() sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.DelegatorAddress) - if err != nil { - panic(err) - } - return addr -} - -// NewMsgUpdateParams creates a new MsgUpdateParams. -func NewMsgUpdateParams(authority sdk.AccAddress, amount Params) *MsgUpdateParams { - return &MsgUpdateParams{ - Authority: authority.String(), - Params: amount, - } -} - -func (m *MsgUpdateParams) Route() string { - return RouterKey -} - -// Type should return the action -func (m *MsgUpdateParams) Type() string { - return MsgTypeUpdateParams -} - -// GetSignBytes encodes the message for signing -func (m *MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) -} - -// GetSigners defines whose signature is required -func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.Authority) - if err != nil { - panic(err) - } - return []sdk.AccAddress{addr} -} - -func (m *MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address %q: %v", m.Authority, err) - } - - err := m.Params.Validate() - if err != nil { - return err - } - return nil -} - -// NewMsgUpdateWhitelistedValidators creates a new MsgUpdateWhitelistedValidators. -func NewMsgUpdateWhitelistedValidators(authority sdk.AccAddress, list []WhitelistedValidator) *MsgUpdateWhitelistedValidators { - return &MsgUpdateWhitelistedValidators{ - Authority: authority.String(), - WhitelistedValidators: list, - } -} - -func (m *MsgUpdateWhitelistedValidators) Route() string { - return RouterKey -} - -// Type should return the action -func (m *MsgUpdateWhitelistedValidators) Type() string { - return MsgTypeUpdateWhitelistedValidators -} - -// GetSignBytes encodes the message for signing -func (m *MsgUpdateWhitelistedValidators) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) -} - -// GetSigners defines whose signature is required -func (m *MsgUpdateWhitelistedValidators) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.Authority) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{addr} -} - -func (m *MsgUpdateWhitelistedValidators) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address %q: %v", m.Authority, err) - } - - err := validateWhitelistedValidators(m.WhitelistedValidators) - if err != nil { - return err - } - - return nil -} - -func (w *WhitelistedValidator) GetValidatorAddress() sdk.ValAddress { - valAddr, err := sdk.ValAddressFromBech32(w.ValidatorAddress) - if err != nil { - panic(err) - } - - return valAddr -} - -// NewMsgSetModulePaused creates a new MsgSetModulePaused. -func NewMsgSetModulePaused(authority sdk.AccAddress, isPaused bool) *MsgSetModulePaused { - return &MsgSetModulePaused{ - Authority: authority.String(), - IsPaused: isPaused, - } -} - -func (m *MsgSetModulePaused) Route() string { - return RouterKey -} - -// Type should return the action -func (m *MsgSetModulePaused) Type() string { - return MsgTypeSetModulePaused -} - -// GetSignBytes encodes the message for signing -func (m *MsgSetModulePaused) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) -} - -// GetSigners defines whose signature is required -func (m *MsgSetModulePaused) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.Authority) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{addr} -} - -func (m *MsgSetModulePaused) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address %q: %v", m.Authority, err) - } - - return nil -} diff --git a/x/liquidstake/types/msgs_test.go b/x/liquidstake/types/msgs_test.go deleted file mode 100644 index 526dfe2..0000000 --- a/x/liquidstake/types/msgs_test.go +++ /dev/null @@ -1,150 +0,0 @@ -package types_test - -import ( - "testing" - - "cosmossdk.io/math" - "github.com/cometbft/cometbft/crypto" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/Asphere-xyz/tacchain/x/liquidstake/types" -) - -func TestMsgLiquidStake(t *testing.T) { - delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) - stakingCoin := sdk.NewCoin("utac", math.NewInt(1)) - - testCases := []struct { - expectedErr string - msg *types.MsgLiquidStake - }{ - { - "", // empty means no error expected - types.NewMsgLiquidStake(delegatorAddr, stakingCoin), - }, - { - "invalid delegator address \"\": empty address string is not allowed: invalid address", - types.NewMsgLiquidStake(sdk.AccAddress{}, stakingCoin), - }, - { - "staking amount must not be zero: invalid request", - types.NewMsgLiquidStake(delegatorAddr, sdk.NewCoin("token", math.NewInt(0))), - }, - } - - for _, tc := range testCases { - require.IsType(t, &types.MsgLiquidStake{}, tc.msg) - require.Equal(t, types.MsgTypeLiquidStake, tc.msg.Type()) - require.Equal(t, types.RouterKey, tc.msg.Route()) - require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(tc.msg)), tc.msg.GetSignBytes()) - - err := tc.msg.ValidateBasic() - if tc.expectedErr == "" { - require.Nil(t, err) - signers := tc.msg.GetSigners() - require.Len(t, signers, 1) - require.Equal(t, tc.msg.GetDelegator(), signers[0]) - } else { - require.EqualError(t, err, tc.expectedErr) - } - } -} - -func TestMsgLiquidUnstake(t *testing.T) { - delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) - stakingCoin := sdk.NewCoin("stk/utac", math.NewInt(1)) - - testCases := []struct { - expectedErr string - msg *types.MsgLiquidUnstake - }{ - { - "", // empty means no error expected - types.NewMsgLiquidUnstake(delegatorAddr, stakingCoin), - }, - { - "invalid delegator address \"\": empty address string is not allowed: invalid address", - types.NewMsgLiquidUnstake(sdk.AccAddress{}, stakingCoin), - }, - { - "unstaking amount must not be zero: invalid request", - types.NewMsgLiquidUnstake(delegatorAddr, sdk.NewCoin("btoken", math.NewInt(0))), - }, - } - - for _, tc := range testCases { - require.IsType(t, &types.MsgLiquidUnstake{}, tc.msg) - require.Equal(t, types.MsgTypeLiquidUnstake, tc.msg.Type()) - require.Equal(t, types.RouterKey, tc.msg.Route()) - require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(tc.msg)), tc.msg.GetSignBytes()) - - err := tc.msg.ValidateBasic() - if tc.expectedErr == "" { - require.Nil(t, err) - signers := tc.msg.GetSigners() - require.Len(t, signers, 1) - require.Equal(t, tc.msg.GetDelegator(), signers[0]) - } else { - require.EqualError(t, err, tc.expectedErr) - } - } -} - -func TestMsgStakeToLP(t *testing.T) { - delegatorAddr := sdk.AccAddress(crypto.AddressHash([]byte("delegatorAddr"))) - validatorAddr := sdk.ValAddress(crypto.AddressHash([]byte("validatorAddr"))) - stakingCoin := sdk.NewCoin("utac", math.NewInt(1)) - zeroStakingCoin := sdk.NewCoin("utac", math.NewInt(0)) - - testCases := []struct { - expectedErr string - msg *types.MsgStakeToLP - }{ - { - "", // empty means no error expected - types.NewMsgStakeToLP(delegatorAddr, validatorAddr, stakingCoin, zeroStakingCoin), - }, - { - "", - types.NewMsgStakeToLP(delegatorAddr, validatorAddr, stakingCoin, sdk.Coin{}), - }, - { - "", - types.NewMsgStakeToLP(delegatorAddr, validatorAddr, stakingCoin, stakingCoin), - }, - { - "invalid delegator address \"\": empty address string is not allowed: invalid address", - types.NewMsgStakeToLP(sdk.AccAddress{}, validatorAddr, stakingCoin, zeroStakingCoin), - }, - { - "invalid validator address \"\": empty address string is not allowed: invalid address", - types.NewMsgStakeToLP(delegatorAddr, sdk.ValAddress{}, stakingCoin, zeroStakingCoin), - }, - { - "staked amount must not be zero: invalid request", - types.NewMsgStakeToLP(delegatorAddr, validatorAddr, zeroStakingCoin, zeroStakingCoin), - }, - { - "staked amount must not be zero: invalid request", - types.NewMsgStakeToLP(delegatorAddr, validatorAddr, zeroStakingCoin, stakingCoin), - }, - } - - for _, tc := range testCases { - require.IsType(t, &types.MsgStakeToLP{}, tc.msg) - require.Equal(t, types.MsgTypeStakeToLP, tc.msg.Type()) - require.Equal(t, types.RouterKey, tc.msg.Route()) - require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(tc.msg)), tc.msg.GetSignBytes()) - - err := tc.msg.ValidateBasic() - if tc.expectedErr == "" { - require.Nil(t, err) - signers := tc.msg.GetSigners() - require.Len(t, signers, 1) - require.Equal(t, tc.msg.GetDelegator(), signers[0]) - } else { - require.EqualError(t, err, tc.expectedErr) - } - } -} diff --git a/x/liquidstake/types/params.go b/x/liquidstake/types/params.go deleted file mode 100644 index 4f2bfd7..0000000 --- a/x/liquidstake/types/params.go +++ /dev/null @@ -1,253 +0,0 @@ -package types - -import ( - "encoding/json" - "fmt" - "strings" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" -) - -// Parameter store keys -var ( - DefaultLiquidBondDenom = "stk/utac" - - // DefaultUnstakeFeeRate is the default Unstake Fee Rate. - DefaultUnstakeFeeRate = math.LegacyZeroDec() - - // DefaultAutocompoundFeeRate is the default fee rate for auto redelegating the stake rewards. - DefaultAutocompoundFeeRate = math.LegacyMustNewDecFromStr("0.05") - - // DefaultMinLiquidStakeAmount is the default minimum liquid stake amount. - DefaultMinLiquidStakeAmount = math.NewInt(1000) - - // DefaultLimitAutocompoundPeriodDays is the number of days for which APY autocompound limit is calculated. - DefaultLimitAutocompoundPeriodDays = math.LegacyNewDec(365) - - // DefaultLimitAutocompoundPeriodHours is the number of hours for which APY autocompound limit is calculated. - DefaultLimitAutocompoundPeriodHours = math.LegacyNewDec(24) - - // Const variables - - // TotalValidatorWeight specifies the target sum of validator weights in the whitelist. - TotalValidatorWeight = math.NewInt(10000) - - // ActiveLiquidValidatorsWeightQuorum is the minium required weight quorum for liquid validators set - ActiveLiquidValidatorsWeightQuorum = math.LegacyNewDecWithPrec(3333, 4) // "0.333300000000000000" - - // RebalancingTrigger if the maximum difference and needed each redelegation amount exceeds it, asset rebalacing will be executed. - RebalancingTrigger = math.LegacyNewDecWithPrec(1, 3) // "0.001000000000000000" - - // LiquidStakeProxyAcc is a proxy reserve account for delegation and undelegation. - // - // Important: derive this address using module.Address to obtain a 32-byte version distinguishable for LSM - // authtypes.NewModuleAddress returns 20-byte addresses. - // tac19zwggtdgaspa9tje6mxdap9xjpc4rayf3nd6dt5g3lwkx4y7z6dqmj3hnc - LiquidStakeProxyAcc = sdk.AccAddress(address.Module(ModuleName, []byte("-LiquidStakeProxyAcc"))) - - // DummyFeeAccountAcc is a dummy fee collection account that should be replaced via params. - // - // Note: it could be authtypes.NewModuleAddress, but made it derived as well, for consistency. - DummyFeeAccountAcc = sdk.AccAddress(address.Module(ModuleName, []byte("-FeeAcc"))) -) - -// DefaultParams returns the default liquidstake module parameters. -func DefaultParams() Params { - return Params{ - WhitelistedValidators: []WhitelistedValidator{}, - LiquidBondDenom: DefaultLiquidBondDenom, - UnstakeFeeRate: DefaultUnstakeFeeRate, - MinLiquidStakeAmount: DefaultMinLiquidStakeAmount, - FeeAccountAddress: DummyFeeAccountAcc.String(), - AutocompoundFeeRate: DefaultAutocompoundFeeRate, - CwLockedPoolAddress: "", - WhitelistAdminAddress: "", - ModulePaused: true, - } -} - -// String returns a human-readable string representation of the parameters. -func (p Params) String() string { - out, _ := json.MarshalIndent(p, "", "") - return string(out) -} - -func (p Params) WhitelistedValsMap() WhitelistedValsMap { - return GetWhitelistedValsMap(p.WhitelistedValidators) -} - -// Validate validates parameters. -func (p Params) Validate() error { - for _, v := range []struct { - value interface{} - validator func(interface{}) error - }{ - {p.LiquidBondDenom, validateLiquidBondDenom}, - {p.WhitelistedValidators, validateWhitelistedValidators}, - {p.UnstakeFeeRate, validateUnstakeFeeRate}, - {p.MinLiquidStakeAmount, validateMinLiquidStakeAmount}, - {p.AutocompoundFeeRate, validateAutocompoundFeeRate}, - {p.FeeAccountAddress, validateFeeAccountAddress}, - {p.CwLockedPoolAddress, validateCwLockedPoolAddress}, - {p.WhitelistAdminAddress, validateWhitelistAdminAddress}, - } { - if err := v.validator(v.value); err != nil { - return err - } - } - return nil -} - -func validateLiquidBondDenom(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if strings.TrimSpace(v) == "" { - return fmt.Errorf("liquid bond denom cannot be blank") - } - - if err := sdk.ValidateDenom(v); err != nil { - return err - } - return nil -} - -// validateWhitelistedValidators validates liquidstake validator and total weight. -func validateWhitelistedValidators(i interface{}) error { - wvs, ok := i.([]WhitelistedValidator) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - valsMap := map[string]struct{}{} - for _, wv := range wvs { - _, valErr := sdk.ValAddressFromBech32(wv.ValidatorAddress) - if valErr != nil { - return valErr - } - - if wv.TargetWeight.IsNil() { - return fmt.Errorf("liquidstake validator target weight must not be nil") - } - - if !wv.TargetWeight.IsPositive() { - return fmt.Errorf("liquidstake validator target weight must be positive: %s", wv.TargetWeight) - } - - if _, ok := valsMap[wv.ValidatorAddress]; ok { - return fmt.Errorf("liquidstake validator cannot be duplicated: %s", wv.ValidatorAddress) - } - valsMap[wv.ValidatorAddress] = struct{}{} - } - return nil -} - -func validateUnstakeFeeRate(i interface{}) error { - v, ok := i.(math.LegacyDec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("unstake fee rate must not be nil") - } - - if v.IsNegative() { - return fmt.Errorf("unstake fee rate must not be negative: %s", v) - } - - if v.GT(math.LegacyOneDec()) { - return fmt.Errorf("unstake fee rate too large: %s", v) - } - - return nil -} - -func validateMinLiquidStakeAmount(i interface{}) error { - v, ok := i.(math.Int) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("min liquid stake amount must not be nil") - } - - if v.IsNegative() { - return fmt.Errorf("min liquid stake amount must not be negative: %s", v) - } - - return nil -} - -func validateAutocompoundFeeRate(i interface{}) error { - v, ok := i.(math.LegacyDec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("autocompound fee rate must not be nil") - } - - if v.IsNegative() { - return fmt.Errorf("autocompound fee rate must not be negative: %s", v) - } - - if v.GT(math.LegacyOneDec()) { - return fmt.Errorf("autocompound fee rate too large: %s", v) - } - - return nil -} - -func validateFeeAccountAddress(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - _, err := sdk.AccAddressFromBech32(v) - if err != nil { - return fmt.Errorf("cannot convert fee account address to bech32, invalid address: %s, err: %v", v, err) - } - return nil -} - -func validateCwLockedPoolAddress(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - // allow empty address - if len(v) == 0 { - return nil - } - - _, err := sdk.AccAddressFromBech32(v) - if err != nil { - return fmt.Errorf("cannot convert cw contract address to bech32, invalid address: %s, err: %v", v, err) - } - return nil -} - -func validateWhitelistAdminAddress(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - // allow empty address - if len(v) == 0 { - return nil - } - - _, err := sdk.AccAddressFromBech32(v) - if err != nil { - return fmt.Errorf("cannot convert whitelist admin address to bech32, invalid address: %s, err: %v", v, err) - } - return nil -} diff --git a/x/liquidstake/types/query.pb.go b/x/liquidstake/types/query.pb.go deleted file mode 100644 index 2fa8faa..0000000 --- a/x/liquidstake/types/query.pb.go +++ /dev/null @@ -1,1225 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tac/liquidstake/v1beta1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "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" - 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 - -// QueryParamsRequest is the request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_55af05d4e7012c73, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is the response type for the Query/Params RPC method. -type QueryParamsResponse struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_55af05d4e7012c73, []int{1} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// QueryLiquidValidatorsRequest is the request type for the -// Query/LiquidValidators RPC method. -type QueryLiquidValidatorsRequest struct { -} - -func (m *QueryLiquidValidatorsRequest) Reset() { *m = QueryLiquidValidatorsRequest{} } -func (m *QueryLiquidValidatorsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryLiquidValidatorsRequest) ProtoMessage() {} -func (*QueryLiquidValidatorsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_55af05d4e7012c73, []int{2} -} -func (m *QueryLiquidValidatorsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryLiquidValidatorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryLiquidValidatorsRequest.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 *QueryLiquidValidatorsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLiquidValidatorsRequest.Merge(m, src) -} -func (m *QueryLiquidValidatorsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryLiquidValidatorsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLiquidValidatorsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryLiquidValidatorsRequest proto.InternalMessageInfo - -// QueryLiquidValidatorsResponse is the response type for the -// Query/LiquidValidators RPC method. -type QueryLiquidValidatorsResponse struct { - LiquidValidators []LiquidValidatorState `protobuf:"bytes,1,rep,name=liquid_validators,json=liquidValidators,proto3" json:"liquid_validators"` -} - -func (m *QueryLiquidValidatorsResponse) Reset() { *m = QueryLiquidValidatorsResponse{} } -func (m *QueryLiquidValidatorsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryLiquidValidatorsResponse) ProtoMessage() {} -func (*QueryLiquidValidatorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_55af05d4e7012c73, []int{3} -} -func (m *QueryLiquidValidatorsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryLiquidValidatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryLiquidValidatorsResponse.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 *QueryLiquidValidatorsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLiquidValidatorsResponse.Merge(m, src) -} -func (m *QueryLiquidValidatorsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryLiquidValidatorsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLiquidValidatorsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryLiquidValidatorsResponse proto.InternalMessageInfo - -func (m *QueryLiquidValidatorsResponse) GetLiquidValidators() []LiquidValidatorState { - if m != nil { - return m.LiquidValidators - } - return nil -} - -// QueryStatesRequest is the request type for the Query/States RPC method. -type QueryStatesRequest struct { -} - -func (m *QueryStatesRequest) Reset() { *m = QueryStatesRequest{} } -func (m *QueryStatesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryStatesRequest) ProtoMessage() {} -func (*QueryStatesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_55af05d4e7012c73, []int{4} -} -func (m *QueryStatesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryStatesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryStatesRequest.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 *QueryStatesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryStatesRequest.Merge(m, src) -} -func (m *QueryStatesRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryStatesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryStatesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryStatesRequest proto.InternalMessageInfo - -// QueryStatesResponse is the response type for the Query/States RPC method. -type QueryStatesResponse struct { - NetAmountState NetAmountState `protobuf:"bytes,1,opt,name=net_amount_state,json=netAmountState,proto3" json:"net_amount_state"` -} - -func (m *QueryStatesResponse) Reset() { *m = QueryStatesResponse{} } -func (m *QueryStatesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryStatesResponse) ProtoMessage() {} -func (*QueryStatesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_55af05d4e7012c73, []int{5} -} -func (m *QueryStatesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryStatesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryStatesResponse.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 *QueryStatesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryStatesResponse.Merge(m, src) -} -func (m *QueryStatesResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryStatesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryStatesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryStatesResponse proto.InternalMessageInfo - -func (m *QueryStatesResponse) GetNetAmountState() NetAmountState { - if m != nil { - return m.NetAmountState - } - return NetAmountState{} -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "tac.liquidstake.v1beta1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "tac.liquidstake.v1beta1.QueryParamsResponse") - proto.RegisterType((*QueryLiquidValidatorsRequest)(nil), "tac.liquidstake.v1beta1.QueryLiquidValidatorsRequest") - proto.RegisterType((*QueryLiquidValidatorsResponse)(nil), "tac.liquidstake.v1beta1.QueryLiquidValidatorsResponse") - proto.RegisterType((*QueryStatesRequest)(nil), "tac.liquidstake.v1beta1.QueryStatesRequest") - proto.RegisterType((*QueryStatesResponse)(nil), "tac.liquidstake.v1beta1.QueryStatesResponse") -} - -func init() { - proto.RegisterFile("tac/liquidstake/v1beta1/query.proto", fileDescriptor_55af05d4e7012c73) -} - -var fileDescriptor_55af05d4e7012c73 = []byte{ - // 482 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xae, 0x19, 0xeb, 0xc1, 0x93, 0x50, 0x31, 0x93, 0x36, 0x45, 0x23, 0x1d, 0x9d, 0xd0, 0x06, - 0x63, 0xb1, 0xda, 0x09, 0x6e, 0x1c, 0xb6, 0x33, 0x20, 0x18, 0x08, 0x24, 0x2e, 0xc5, 0xcd, 0xac, - 0x34, 0xa2, 0xb1, 0xd3, 0xf8, 0xa5, 0x5a, 0x39, 0x01, 0x67, 0x0e, 0x48, 0xfc, 0x0f, 0xc4, 0xcf, - 0xd8, 0x71, 0x12, 0x17, 0x2e, 0x20, 0xd4, 0x22, 0xf1, 0x37, 0x50, 0x6c, 0x13, 0x9a, 0x22, 0xb3, - 0x72, 0x8a, 0xf5, 0xfc, 0xbd, 0xef, 0x7d, 0xfe, 0xbe, 0x17, 0xbc, 0x05, 0x2c, 0xa4, 0x83, 0x78, - 0x98, 0xc7, 0xc7, 0x0a, 0xd8, 0x4b, 0x4e, 0x47, 0xed, 0x1e, 0x07, 0xd6, 0xa6, 0xc3, 0x9c, 0x67, - 0xe3, 0x20, 0xcd, 0x24, 0x48, 0xb2, 0x06, 0x2c, 0x0c, 0x66, 0x40, 0x81, 0x05, 0x79, 0x1b, 0x91, - 0x94, 0xd1, 0x80, 0x53, 0x96, 0xc6, 0x94, 0x09, 0x21, 0x81, 0x41, 0x2c, 0x85, 0x32, 0x6d, 0xde, - 0x0d, 0x17, 0xf7, 0x2c, 0x95, 0x81, 0xae, 0x46, 0x32, 0x92, 0xfa, 0x48, 0x8b, 0x93, 0xad, 0xae, - 0x85, 0x52, 0x25, 0x52, 0xd1, 0x44, 0x45, 0x74, 0xd4, 0x2e, 0x3e, 0xe6, 0xa2, 0xb5, 0x8a, 0xc9, - 0xa3, 0x42, 0xdf, 0x43, 0x96, 0xb1, 0x44, 0x1d, 0xf1, 0x61, 0xce, 0x15, 0xb4, 0x9e, 0xe0, 0x2b, - 0x95, 0xaa, 0x4a, 0xa5, 0x50, 0x9c, 0xdc, 0xc5, 0xf5, 0x54, 0x57, 0xd6, 0xd1, 0x26, 0xda, 0x59, - 0xe9, 0x34, 0x03, 0xc7, 0x73, 0x02, 0xd3, 0x78, 0x78, 0xf1, 0xf4, 0x5b, 0xb3, 0x76, 0x64, 0x9b, - 0x5a, 0x3e, 0xde, 0xd0, 0xac, 0xf7, 0x74, 0xc3, 0x53, 0x36, 0x88, 0x8f, 0x19, 0xc8, 0xac, 0x9c, - 0xfa, 0x06, 0xe1, 0xab, 0x0e, 0x80, 0x15, 0xf0, 0x02, 0x5f, 0x36, 0xd3, 0xba, 0xa3, 0xf2, 0x72, - 0x1d, 0x6d, 0x2e, 0xed, 0xac, 0x74, 0xf6, 0x9c, 0x5a, 0xe6, 0xd8, 0x1e, 0x03, 0x03, 0x6e, 0x95, - 0x35, 0x06, 0x73, 0x93, 0x4a, 0x3f, 0x34, 0xaa, 0x54, 0x26, 0xac, 0x1f, 0xbf, 0xab, 0x56, 0xce, - 0x33, 0xdc, 0x10, 0x1c, 0xba, 0x2c, 0x91, 0xb9, 0x80, 0xae, 0x2a, 0x2e, 0xad, 0x33, 0xdb, 0x4e, - 0x35, 0x0f, 0x38, 0x1c, 0x68, 0xfc, 0xac, 0x8e, 0x4b, 0xa2, 0x52, 0xed, 0x7c, 0x5d, 0xc2, 0xcb, - 0x7a, 0x20, 0x79, 0x87, 0x70, 0xdd, 0x98, 0x49, 0x76, 0x9d, 0x9c, 0x7f, 0x27, 0xe8, 0xdd, 0x5a, - 0x0c, 0x6c, 0x1e, 0xd2, 0xda, 0x7e, 0xfb, 0xf9, 0xc7, 0x87, 0x0b, 0xd7, 0x48, 0x93, 0xba, 0x16, - 0xcd, 0x44, 0x48, 0x3e, 0x22, 0xdc, 0x98, 0x4f, 0x87, 0xdc, 0xfe, 0xf7, 0x2c, 0x47, 0xdc, 0xde, - 0x9d, 0xff, 0x6d, 0xb3, 0x62, 0x77, 0xb5, 0xd8, 0xeb, 0x64, 0xcb, 0x29, 0xf6, 0xcf, 0x72, 0x68, - 0xff, 0x4c, 0x6a, 0xe7, 0xf9, 0x57, 0x49, 0xfc, 0x3c, 0xff, 0xaa, 0x8b, 0xb0, 0x80, 0x7f, 0x7a, - 0x39, 0x94, 0xb7, 0xfc, 0xfa, 0xe7, 0xa7, 0x9b, 0xe8, 0xf0, 0xfe, 0xe9, 0xc4, 0x47, 0x67, 0x13, - 0x1f, 0x7d, 0x9f, 0xf8, 0xe8, 0xfd, 0xd4, 0xaf, 0x9d, 0x4d, 0xfd, 0xda, 0x97, 0xa9, 0x5f, 0x7b, - 0xbe, 0x1f, 0xc5, 0xd0, 0xcf, 0x7b, 0x41, 0x28, 0x13, 0x7a, 0xa0, 0xd2, 0x3e, 0xcf, 0xf8, 0xde, - 0xc9, 0xf8, 0x55, 0xc1, 0x1b, 0xf6, 0x59, 0x2c, 0xe8, 0x49, 0x85, 0x1e, 0xc6, 0x29, 0x57, 0xbd, - 0xba, 0xfe, 0x97, 0xf7, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x37, 0x99, 0x1c, 0x85, 0x83, 0x04, - 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 { - // Params returns parameters of the liquidstake module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // LiquidValidators returns liquid validators with states of the liquidstake - // module. - LiquidValidators(ctx context.Context, in *QueryLiquidValidatorsRequest, opts ...grpc.CallOption) (*QueryLiquidValidatorsResponse, error) - // States returns states of the liquidstake module. - States(ctx context.Context, in *QueryStatesRequest, opts ...grpc.CallOption) (*QueryStatesResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) LiquidValidators(ctx context.Context, in *QueryLiquidValidatorsRequest, opts ...grpc.CallOption) (*QueryLiquidValidatorsResponse, error) { - out := new(QueryLiquidValidatorsResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Query/LiquidValidators", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) States(ctx context.Context, in *QueryStatesRequest, opts ...grpc.CallOption) (*QueryStatesResponse, error) { - out := new(QueryStatesResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Query/States", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Params returns parameters of the liquidstake module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // LiquidValidators returns liquid validators with states of the liquidstake - // module. - LiquidValidators(context.Context, *QueryLiquidValidatorsRequest) (*QueryLiquidValidatorsResponse, error) - // States returns states of the liquidstake module. - States(context.Context, *QueryStatesRequest) (*QueryStatesResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} -func (*UnimplementedQueryServer) LiquidValidators(ctx context.Context, req *QueryLiquidValidatorsRequest) (*QueryLiquidValidatorsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LiquidValidators not implemented") -} -func (*UnimplementedQueryServer) States(ctx context.Context, req *QueryStatesRequest) (*QueryStatesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method States not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_LiquidValidators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryLiquidValidatorsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).LiquidValidators(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Query/LiquidValidators", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).LiquidValidators(ctx, req.(*QueryLiquidValidatorsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_States_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryStatesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).States(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Query/States", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).States(ctx, req.(*QueryStatesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "tac.liquidstake.v1beta1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "LiquidValidators", - Handler: _Query_LiquidValidators_Handler, - }, - { - MethodName: "States", - Handler: _Query_States_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "tac/liquidstake/v1beta1/query.proto", -} - -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryLiquidValidatorsRequest) 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 *QueryLiquidValidatorsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryLiquidValidatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryLiquidValidatorsResponse) 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 *QueryLiquidValidatorsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryLiquidValidatorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.LiquidValidators) > 0 { - for iNdEx := len(m.LiquidValidators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LiquidValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryStatesRequest) 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 *QueryStatesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryStatesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryStatesResponse) 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 *QueryStatesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryStatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.NetAmountState.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func 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 *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryLiquidValidatorsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryLiquidValidatorsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.LiquidValidators) > 0 { - for _, e := range m.LiquidValidators { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryStatesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryStatesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.NetAmountState.Size() - 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 *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryLiquidValidatorsRequest) 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: QueryLiquidValidatorsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLiquidValidatorsRequest: 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 *QueryLiquidValidatorsResponse) 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: QueryLiquidValidatorsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLiquidValidatorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidValidators", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LiquidValidators = append(m.LiquidValidators, LiquidValidatorState{}) - if err := m.LiquidValidators[len(m.LiquidValidators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryStatesRequest) 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: QueryStatesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryStatesRequest: 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 *QueryStatesResponse) 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: QueryStatesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryStatesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NetAmountState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.NetAmountState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func 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/liquidstake/types/query.pb.gw.go b/x/liquidstake/types/query.pb.gw.go deleted file mode 100644 index d261869..0000000 --- a/x/liquidstake/types/query.pb.gw.go +++ /dev/null @@ -1,283 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: tac/liquidstake/v1beta1/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_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_LiquidValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLiquidValidatorsRequest - var metadata runtime.ServerMetadata - - msg, err := client.LiquidValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_LiquidValidators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLiquidValidatorsRequest - var metadata runtime.ServerMetadata - - msg, err := server.LiquidValidators(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_States_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryStatesRequest - var metadata runtime.ServerMetadata - - msg, err := client.States(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_States_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryStatesRequest - var metadata runtime.ServerMetadata - - msg, err := server.States(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_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LiquidValidators_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_LiquidValidators_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_LiquidValidators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_States_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_States_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_States_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_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LiquidValidators_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_LiquidValidators_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_LiquidValidators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_States_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_States_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_States_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tac", "liquidstake", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_LiquidValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tac", "liquidstake", "v1beta1", "validators"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_States_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tac", "liquidstake", "v1beta1", "states"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_LiquidValidators_0 = runtime.ForwardResponseMessage - - forward_Query_States_0 = runtime.ForwardResponseMessage -) diff --git a/x/liquidstake/types/rebalancing.go b/x/liquidstake/types/rebalancing.go deleted file mode 100644 index 0ff7e52..0000000 --- a/x/liquidstake/types/rebalancing.go +++ /dev/null @@ -1,52 +0,0 @@ -package types - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type Redelegation struct { - Delegator sdk.AccAddress - SrcValidator LiquidValidator - DstValidator LiquidValidator - Amount math.Int - Last bool - Error error -} - -// DivideByWeight divide the input value by the ratio of the param weight of the liquid validator and return it with crumb -// which is may occur while dividing according to the weight of active liquid validators by decimal error. -func DivideByWeight(avs ActiveLiquidValidators, input math.Int, whitelistedValsMap WhitelistedValsMap) (outputs []math.Int, crumb math.Int) { - totalWeight := avs.TotalWeight(whitelistedValsMap) - if !totalWeight.IsPositive() { - return []math.Int{}, math.ZeroInt() - } - - totalOutput := math.ZeroInt() - unitInput := math.LegacyNewDecFromInt(input).QuoTruncate(math.LegacyNewDecFromInt(totalWeight)) - for _, val := range avs { - output := unitInput.MulInt(val.GetWeight(whitelistedValsMap, true)).TruncateInt() - totalOutput = totalOutput.Add(output) - outputs = append(outputs, output) - } - - return outputs, input.Sub(totalOutput) -} - -// DivideByCurrentWeight divide the input value by the ratio of the weight of the liquid validator's liquid token and return it with crumb -// which is may occur while dividing according to the weight of liquid validators by decimal error, outputs is truncated decimal. -func DivideByCurrentWeight(lvs LiquidValidators, input math.LegacyDec, totalLiquidTokens math.Int, liquidTokenMap map[string]math.Int) (outputs []math.LegacyDec, crumb math.LegacyDec) { - if !totalLiquidTokens.IsPositive() { - return []math.LegacyDec{}, math.LegacyZeroDec() - } - - totalOutput := math.LegacyZeroDec() - unitInput := input.QuoTruncate(math.LegacyNewDecFromInt(totalLiquidTokens)) - for _, val := range lvs { - output := unitInput.MulTruncate(math.LegacyNewDecFromInt(liquidTokenMap[val.OperatorAddress])).TruncateDec() - totalOutput = totalOutput.Add(output) - outputs = append(outputs, output) - } - - return outputs, input.Sub(totalOutput) -} diff --git a/x/liquidstake/types/tx.pb.go b/x/liquidstake/types/tx.pb.go deleted file mode 100644 index 6015871..0000000 --- a/x/liquidstake/types/tx.pb.go +++ /dev/null @@ -1,2619 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tac/liquidstake/v1beta1/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - 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" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// 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 - -// MsgLiquidStake defines a SDK message for performing a liquid stake of coins -// from a delegator to whitelisted validators. -type MsgLiquidStake struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` - Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount"` -} - -func (m *MsgLiquidStake) Reset() { *m = MsgLiquidStake{} } -func (m *MsgLiquidStake) String() string { return proto.CompactTextString(m) } -func (*MsgLiquidStake) ProtoMessage() {} -func (*MsgLiquidStake) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{0} -} -func (m *MsgLiquidStake) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgLiquidStake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgLiquidStake.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 *MsgLiquidStake) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgLiquidStake.Merge(m, src) -} -func (m *MsgLiquidStake) XXX_Size() int { - return m.Size() -} -func (m *MsgLiquidStake) XXX_DiscardUnknown() { - xxx_messageInfo_MsgLiquidStake.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgLiquidStake proto.InternalMessageInfo - -// MsgLiquidStakeResponse defines the MsgLiquidStake response type. -type MsgLiquidStakeResponse struct { -} - -func (m *MsgLiquidStakeResponse) Reset() { *m = MsgLiquidStakeResponse{} } -func (m *MsgLiquidStakeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgLiquidStakeResponse) ProtoMessage() {} -func (*MsgLiquidStakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{1} -} -func (m *MsgLiquidStakeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgLiquidStakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgLiquidStakeResponse.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 *MsgLiquidStakeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgLiquidStakeResponse.Merge(m, src) -} -func (m *MsgLiquidStakeResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgLiquidStakeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgLiquidStakeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgLiquidStakeResponse proto.InternalMessageInfo - -// MsgStakeToLP defines a SDK message for performing an LSM-transfer of staked -// TAC into gTAC with locking into an LP. -type MsgStakeToLP struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` - ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` - StakedAmount types.Coin `protobuf:"bytes,3,opt,name=staked_amount,json=stakedAmount,proto3" json:"staked_amount"` - LiquidAmount types.Coin `protobuf:"bytes,4,opt,name=liquid_amount,json=liquidAmount,proto3" json:"liquid_amount"` -} - -func (m *MsgStakeToLP) Reset() { *m = MsgStakeToLP{} } -func (m *MsgStakeToLP) String() string { return proto.CompactTextString(m) } -func (*MsgStakeToLP) ProtoMessage() {} -func (*MsgStakeToLP) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{2} -} -func (m *MsgStakeToLP) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgStakeToLP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgStakeToLP.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 *MsgStakeToLP) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgStakeToLP.Merge(m, src) -} -func (m *MsgStakeToLP) XXX_Size() int { - return m.Size() -} -func (m *MsgStakeToLP) XXX_DiscardUnknown() { - xxx_messageInfo_MsgStakeToLP.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgStakeToLP proto.InternalMessageInfo - -// MsgStakeToLPResponse defines the MsgStakeToLP response type. -type MsgStakeToLPResponse struct { -} - -func (m *MsgStakeToLPResponse) Reset() { *m = MsgStakeToLPResponse{} } -func (m *MsgStakeToLPResponse) String() string { return proto.CompactTextString(m) } -func (*MsgStakeToLPResponse) ProtoMessage() {} -func (*MsgStakeToLPResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{3} -} -func (m *MsgStakeToLPResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgStakeToLPResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgStakeToLPResponse.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 *MsgStakeToLPResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgStakeToLPResponse.Merge(m, src) -} -func (m *MsgStakeToLPResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgStakeToLPResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgStakeToLPResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgStakeToLPResponse proto.InternalMessageInfo - -// MsgLiquidUnstake defines a SDK message for performing an undelegation of -// liquid staking from a delegate. -type MsgLiquidUnstake struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` - Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount"` -} - -func (m *MsgLiquidUnstake) Reset() { *m = MsgLiquidUnstake{} } -func (m *MsgLiquidUnstake) String() string { return proto.CompactTextString(m) } -func (*MsgLiquidUnstake) ProtoMessage() {} -func (*MsgLiquidUnstake) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{4} -} -func (m *MsgLiquidUnstake) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgLiquidUnstake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgLiquidUnstake.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 *MsgLiquidUnstake) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgLiquidUnstake.Merge(m, src) -} -func (m *MsgLiquidUnstake) XXX_Size() int { - return m.Size() -} -func (m *MsgLiquidUnstake) XXX_DiscardUnknown() { - xxx_messageInfo_MsgLiquidUnstake.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgLiquidUnstake proto.InternalMessageInfo - -// MsgLiquidUnstakeResponse defines the MsgLiquidUnstake response type. -type MsgLiquidUnstakeResponse struct { - CompletionTime time.Time `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time"` -} - -func (m *MsgLiquidUnstakeResponse) Reset() { *m = MsgLiquidUnstakeResponse{} } -func (m *MsgLiquidUnstakeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgLiquidUnstakeResponse) ProtoMessage() {} -func (*MsgLiquidUnstakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{5} -} -func (m *MsgLiquidUnstakeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgLiquidUnstakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgLiquidUnstakeResponse.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 *MsgLiquidUnstakeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgLiquidUnstakeResponse.Merge(m, src) -} -func (m *MsgLiquidUnstakeResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgLiquidUnstakeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgLiquidUnstakeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgLiquidUnstakeResponse proto.InternalMessageInfo - -func (m *MsgLiquidUnstakeResponse) GetCompletionTime() time.Time { - if m != nil { - return m.CompletionTime - } - return time.Time{} -} - -type MsgUpdateParams struct { - // authority is the address that controls the module (defaults to x/gov unless - // overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the parameters to update. - // - // NOTE: denom and whitelisted validators are not updated. - // - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{6} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -// MsgUpdateParamsResponse defines the response structure for executing a -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{7} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -type MsgUpdateWhitelistedValidators struct { - // Authority is the address that is allowed to update whitelisted validators, - // defined as admin address in params (WhitelistAdminAddress). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // WhitelistedValidators specifies the validators elected to become Active - // Liquid Validators. - WhitelistedValidators []WhitelistedValidator `protobuf:"bytes,2,rep,name=whitelisted_validators,json=whitelistedValidators,proto3" json:"whitelisted_validators"` -} - -func (m *MsgUpdateWhitelistedValidators) Reset() { *m = MsgUpdateWhitelistedValidators{} } -func (m *MsgUpdateWhitelistedValidators) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateWhitelistedValidators) ProtoMessage() {} -func (*MsgUpdateWhitelistedValidators) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{8} -} -func (m *MsgUpdateWhitelistedValidators) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateWhitelistedValidators) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateWhitelistedValidators.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 *MsgUpdateWhitelistedValidators) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateWhitelistedValidators.Merge(m, src) -} -func (m *MsgUpdateWhitelistedValidators) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateWhitelistedValidators) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateWhitelistedValidators.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateWhitelistedValidators proto.InternalMessageInfo - -// MsgUpdateWhitelistedValidatorsResponse defines the response structure for -// executing a -type MsgUpdateWhitelistedValidatorsResponse struct { -} - -func (m *MsgUpdateWhitelistedValidatorsResponse) Reset() { - *m = MsgUpdateWhitelistedValidatorsResponse{} -} -func (m *MsgUpdateWhitelistedValidatorsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateWhitelistedValidatorsResponse) ProtoMessage() {} -func (*MsgUpdateWhitelistedValidatorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{9} -} -func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse.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 *MsgUpdateWhitelistedValidatorsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse.Merge(m, src) -} -func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateWhitelistedValidatorsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateWhitelistedValidatorsResponse proto.InternalMessageInfo - -type MsgSetModulePaused struct { - // Authority is the address that is allowed to update module's paused state, - // defined as admin address in params (WhitelistAdminAddress). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // IsPaused represents the target state of the paused flag. - IsPaused bool `protobuf:"varint,2,opt,name=is_paused,json=isPaused,proto3" json:"is_paused,omitempty"` -} - -func (m *MsgSetModulePaused) Reset() { *m = MsgSetModulePaused{} } -func (m *MsgSetModulePaused) String() string { return proto.CompactTextString(m) } -func (*MsgSetModulePaused) ProtoMessage() {} -func (*MsgSetModulePaused) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{10} -} -func (m *MsgSetModulePaused) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSetModulePaused) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSetModulePaused.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 *MsgSetModulePaused) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetModulePaused.Merge(m, src) -} -func (m *MsgSetModulePaused) XXX_Size() int { - return m.Size() -} -func (m *MsgSetModulePaused) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetModulePaused.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSetModulePaused proto.InternalMessageInfo - -// MsgSetModulePausedResponse defines the response structure for -// executing a -type MsgSetModulePausedResponse struct { -} - -func (m *MsgSetModulePausedResponse) Reset() { *m = MsgSetModulePausedResponse{} } -func (m *MsgSetModulePausedResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetModulePausedResponse) ProtoMessage() {} -func (*MsgSetModulePausedResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a8b8c4e8f1546252, []int{11} -} -func (m *MsgSetModulePausedResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSetModulePausedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSetModulePausedResponse.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 *MsgSetModulePausedResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetModulePausedResponse.Merge(m, src) -} -func (m *MsgSetModulePausedResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgSetModulePausedResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetModulePausedResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSetModulePausedResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgLiquidStake)(nil), "tac.liquidstake.v1beta1.MsgLiquidStake") - proto.RegisterType((*MsgLiquidStakeResponse)(nil), "tac.liquidstake.v1beta1.MsgLiquidStakeResponse") - proto.RegisterType((*MsgStakeToLP)(nil), "tac.liquidstake.v1beta1.MsgStakeToLP") - proto.RegisterType((*MsgStakeToLPResponse)(nil), "tac.liquidstake.v1beta1.MsgStakeToLPResponse") - proto.RegisterType((*MsgLiquidUnstake)(nil), "tac.liquidstake.v1beta1.MsgLiquidUnstake") - proto.RegisterType((*MsgLiquidUnstakeResponse)(nil), "tac.liquidstake.v1beta1.MsgLiquidUnstakeResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "tac.liquidstake.v1beta1.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "tac.liquidstake.v1beta1.MsgUpdateParamsResponse") - proto.RegisterType((*MsgUpdateWhitelistedValidators)(nil), "tac.liquidstake.v1beta1.MsgUpdateWhitelistedValidators") - proto.RegisterType((*MsgUpdateWhitelistedValidatorsResponse)(nil), "tac.liquidstake.v1beta1.MsgUpdateWhitelistedValidatorsResponse") - proto.RegisterType((*MsgSetModulePaused)(nil), "tac.liquidstake.v1beta1.MsgSetModulePaused") - proto.RegisterType((*MsgSetModulePausedResponse)(nil), "tac.liquidstake.v1beta1.MsgSetModulePausedResponse") -} - -func init() { proto.RegisterFile("tac/liquidstake/v1beta1/tx.proto", fileDescriptor_a8b8c4e8f1546252) } - -var fileDescriptor_a8b8c4e8f1546252 = []byte{ - // 859 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4d, 0x4f, 0xe3, 0x46, - 0x18, 0x8e, 0xc3, 0x87, 0xc8, 0x84, 0x4f, 0x8b, 0x42, 0x30, 0xc8, 0x41, 0x96, 0xda, 0x86, 0x54, - 0xb1, 0x9b, 0x20, 0x81, 0x9a, 0x0a, 0x21, 0xd2, 0x72, 0x23, 0x12, 0x0a, 0xd0, 0x4a, 0xbd, 0x44, - 0x13, 0x7b, 0xea, 0x0c, 0x8d, 0x3d, 0x6e, 0x66, 0xc2, 0x47, 0x4f, 0x55, 0x4f, 0x55, 0x7b, 0xe1, - 0xd6, 0x2b, 0x87, 0xfe, 0x00, 0x0e, 0xfb, 0x03, 0x56, 0x7b, 0xe2, 0xb6, 0x68, 0xf7, 0xb2, 0xa7, - 0xdd, 0x15, 0x68, 0xc5, 0xfe, 0x8c, 0x95, 0x3f, 0x63, 0x87, 0x7c, 0x2d, 0xda, 0xc3, 0x5e, 0x80, - 0x79, 0xdf, 0xe7, 0x7d, 0xe6, 0x7d, 0x9e, 0x99, 0x77, 0x0c, 0x58, 0x65, 0x50, 0x55, 0x1a, 0xf8, - 0xf7, 0x16, 0xd6, 0x28, 0x83, 0xbf, 0x21, 0xe5, 0x24, 0x5f, 0x43, 0x0c, 0xe6, 0x15, 0x76, 0x26, - 0x5b, 0x4d, 0xc2, 0x08, 0xbf, 0xc8, 0xa0, 0x2a, 0x87, 0x10, 0xb2, 0x87, 0x10, 0xe6, 0x75, 0xa2, - 0x13, 0x07, 0xa3, 0xd8, 0x7f, 0xb9, 0x70, 0x61, 0x49, 0x25, 0xd4, 0x20, 0xb4, 0xea, 0x26, 0xdc, - 0x85, 0x97, 0x12, 0xdd, 0x95, 0x52, 0x83, 0xb4, 0xbd, 0x8f, 0x4a, 0xb0, 0xe9, 0xe5, 0x17, 0xbd, - 0xbc, 0x41, 0x75, 0xe5, 0x24, 0x6f, 0xff, 0xf2, 0x12, 0x69, 0x9d, 0x10, 0xbd, 0x81, 0x14, 0x67, - 0x55, 0x6b, 0xfd, 0xaa, 0x30, 0x6c, 0x20, 0xca, 0xa0, 0x61, 0x79, 0x80, 0xb5, 0x5e, 0x2a, 0xc2, - 0x7d, 0xbb, 0xd0, 0x39, 0x68, 0x60, 0x93, 0x28, 0xce, 0x4f, 0x37, 0x24, 0x3d, 0xe7, 0xc0, 0x74, - 0x99, 0xea, 0x7b, 0x0e, 0xf6, 0xc0, 0xc6, 0xf2, 0xbb, 0x60, 0x4e, 0x43, 0x0d, 0xa4, 0x43, 0x46, - 0x9a, 0x55, 0xa8, 0x69, 0x4d, 0x44, 0x69, 0x8a, 0x5b, 0xe5, 0x32, 0x89, 0x52, 0xea, 0xc5, 0x93, - 0xdc, 0xbc, 0xa7, 0x6b, 0xc7, 0xcd, 0x1c, 0xb0, 0x26, 0x36, 0xf5, 0xca, 0x6c, 0x50, 0xe2, 0xc5, - 0xf9, 0x4d, 0x30, 0x0e, 0x0d, 0xd2, 0x32, 0x59, 0x2a, 0xbe, 0xca, 0x65, 0x92, 0x85, 0x25, 0xd9, - 0x2b, 0xb4, 0x2d, 0xf0, 0x8d, 0x94, 0x7f, 0x20, 0xd8, 0x2c, 0x8d, 0x5e, 0xbf, 0x4e, 0xc7, 0x2a, - 0x1e, 0xbc, 0xb8, 0xf5, 0xf7, 0x65, 0x3a, 0xf6, 0xfe, 0x32, 0x1d, 0xfb, 0xeb, 0xfe, 0x2a, 0xfb, - 0xb0, 0x95, 0x7f, 0xee, 0xaf, 0xb2, 0x42, 0x58, 0x6f, 0xb4, 0x7d, 0x29, 0x05, 0x16, 0xa2, 0x91, - 0x0a, 0xa2, 0x16, 0x31, 0x29, 0x92, 0xde, 0xc5, 0xc1, 0x64, 0x99, 0xea, 0x4e, 0xf0, 0x90, 0xec, - 0xed, 0x7f, 0x2a, 0xa5, 0xbb, 0x60, 0xee, 0x04, 0x36, 0xb0, 0x16, 0xa1, 0x89, 0x0f, 0xa2, 0x09, - 0x4a, 0x7c, 0x9a, 0x1f, 0xc1, 0x94, 0x23, 0x48, 0xab, 0x7a, 0xbe, 0x8d, 0x0c, 0xe7, 0xdb, 0xa4, - 0x5b, 0xb5, 0xe3, 0x14, 0xd9, 0x2c, 0xae, 0x39, 0x3e, 0xcb, 0xe8, 0x90, 0x2c, 0x6e, 0x95, 0xcb, - 0x52, 0xfc, 0x7e, 0xf0, 0x19, 0xa4, 0x3a, 0xce, 0x20, 0xb0, 0x55, 0x5a, 0x00, 0xf3, 0xe1, 0x75, - 0xe0, 0xff, 0x4b, 0x0e, 0xcc, 0x06, 0x47, 0x73, 0x64, 0xd2, 0xcf, 0xe2, 0xb6, 0x6d, 0x0f, 0x56, - 0xba, 0xd2, 0xf5, 0xb6, 0x79, 0x02, 0x24, 0x0c, 0x52, 0x9d, 0x31, 0x5f, 0x31, 0x5f, 0x06, 0x33, - 0x2a, 0x31, 0xac, 0x06, 0x62, 0x98, 0x98, 0x55, 0x7b, 0x72, 0x1d, 0x69, 0xc9, 0x82, 0x20, 0xbb, - 0x63, 0x2d, 0xfb, 0x63, 0x2d, 0x1f, 0xfa, 0x63, 0x5d, 0x9a, 0xb0, 0xfb, 0xbb, 0x78, 0x93, 0xe6, - 0x2a, 0xd3, 0xed, 0x62, 0x3b, 0x2d, 0x3d, 0xe5, 0xc0, 0x4c, 0x99, 0xea, 0x47, 0x96, 0x06, 0x19, - 0xda, 0x87, 0x4d, 0x68, 0x50, 0x7e, 0x03, 0x24, 0x60, 0x8b, 0xd5, 0x49, 0x13, 0xb3, 0xf3, 0x81, - 0xbe, 0xb5, 0xa1, 0xfc, 0x16, 0x18, 0xb7, 0x1c, 0x06, 0xcf, 0xb0, 0xb4, 0xdc, 0xe3, 0xad, 0x93, - 0xdd, 0x8d, 0x7c, 0xdb, 0xdc, 0xa2, 0xe2, 0x46, 0xd8, 0xb6, 0x36, 0xad, 0x6d, 0xd7, 0x72, 0x87, - 0x5d, 0xe1, 0x76, 0xa5, 0x25, 0xb0, 0xd8, 0x11, 0x0a, 0xae, 0xc7, 0xbf, 0x71, 0x20, 0x06, 0xb9, - 0x9f, 0xeb, 0x98, 0xa1, 0x06, 0xa6, 0x0c, 0x69, 0x3f, 0xf9, 0x83, 0xf2, 0x78, 0xb1, 0xc7, 0x60, - 0xe1, 0xb4, 0x4d, 0x58, 0x0d, 0x46, 0xcf, 0x16, 0x3f, 0x92, 0x49, 0x16, 0x72, 0x3d, 0xc5, 0x77, - 0xeb, 0xc3, 0xb3, 0xe2, 0x8b, 0xd3, 0x6e, 0x3d, 0x16, 0x77, 0x7b, 0x3b, 0x93, 0xed, 0xea, 0x4c, - 0x57, 0xa9, 0x52, 0x06, 0x7c, 0xd5, 0x1f, 0x11, 0xf8, 0xf6, 0x3f, 0x07, 0x78, 0x7b, 0xde, 0x10, - 0x2b, 0x13, 0xad, 0xd5, 0x40, 0xfb, 0xb0, 0x45, 0x91, 0xf6, 0x68, 0xaf, 0x96, 0x41, 0x02, 0xd3, - 0xaa, 0xe5, 0x90, 0x38, 0x77, 0x63, 0xa2, 0x32, 0x81, 0xa9, 0x4b, 0x5a, 0xfc, 0xae, 0xb7, 0x38, - 0xb1, 0xf3, 0x3d, 0x88, 0xf6, 0x23, 0xad, 0x00, 0xe1, 0x61, 0xd4, 0x17, 0x51, 0x78, 0x36, 0x06, - 0x46, 0xca, 0x54, 0xe7, 0x75, 0x90, 0x0c, 0x7f, 0x8b, 0xbe, 0xee, 0x79, 0x30, 0xd1, 0x37, 0x5e, - 0x50, 0x86, 0x04, 0x06, 0xa3, 0x69, 0x80, 0xa9, 0xe8, 0x43, 0xb4, 0x36, 0x98, 0xc1, 0x83, 0x0a, - 0xf9, 0xa1, 0xa1, 0xc1, 0x76, 0x10, 0x24, 0xda, 0xdf, 0x9d, 0x2f, 0xfb, 0xd5, 0x07, 0x30, 0x21, - 0x37, 0x14, 0x2c, 0xd8, 0xe2, 0x18, 0x4c, 0x46, 0x5e, 0x86, 0x4c, 0xbf, 0xf2, 0x30, 0x52, 0xf8, - 0x76, 0x58, 0x64, 0xb0, 0xd7, 0x7f, 0x1c, 0x58, 0xee, 0x37, 0xa8, 0x9b, 0x83, 0x19, 0xbb, 0x16, - 0x0a, 0xdb, 0x8f, 0x2c, 0x0c, 0x3a, 0xa3, 0x60, 0xa6, 0x73, 0x12, 0xbe, 0xe9, 0xeb, 0x63, 0x14, - 0x2c, 0xac, 0x7f, 0x04, 0xd8, 0xdf, 0x54, 0x18, 0xfb, 0xf3, 0xfe, 0x2a, 0xcb, 0x95, 0xca, 0xd7, - 0xb7, 0x22, 0x77, 0x73, 0x2b, 0x72, 0x6f, 0x6f, 0x45, 0xee, 0xe2, 0x4e, 0x8c, 0xdd, 0xdc, 0x89, - 0xb1, 0x57, 0x77, 0x62, 0xec, 0x97, 0x75, 0x1d, 0xb3, 0x7a, 0xab, 0x26, 0xab, 0xc4, 0x50, 0x76, - 0xa8, 0x55, 0x47, 0x4d, 0x94, 0x3b, 0x3b, 0xff, 0x43, 0x61, 0x50, 0x55, 0xeb, 0x10, 0x9b, 0xca, - 0x59, 0xe4, 0x5f, 0x38, 0x76, 0x6e, 0x21, 0x5a, 0x1b, 0x77, 0x3e, 0x0e, 0xeb, 0x1f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0xca, 0x32, 0x13, 0x7c, 0xa8, 0x0a, 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 { - // LiquidStake defines a method for performing a delegation of coins - // from a delegator to whitelisted validators. - LiquidStake(ctx context.Context, in *MsgLiquidStake, opts ...grpc.CallOption) (*MsgLiquidStakeResponse, error) - // LiquidUnstake defines a method for performing an undelegation of liquid - // staking from a delegate. - LiquidUnstake(ctx context.Context, in *MsgLiquidUnstake, opts ...grpc.CallOption) (*MsgLiquidUnstakeResponse, error) - // StakeToLP defines a method for LSM-transfer of staked TAC - // into gTAC with locking into an LP. - StakeToLP(ctx context.Context, in *MsgStakeToLP, opts ...grpc.CallOption) (*MsgStakeToLPResponse, error) - // UpdateParams defines a method to update the module params. - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) - // UpdateWhitelistedValidators defines a method to update the whitelisted - // validators list. - UpdateWhitelistedValidators(ctx context.Context, in *MsgUpdateWhitelistedValidators, opts ...grpc.CallOption) (*MsgUpdateWhitelistedValidatorsResponse, error) - // SetModulePaused defines a method to update the module's pause status, - // setting value of the safety flag in params. - SetModulePaused(ctx context.Context, in *MsgSetModulePaused, opts ...grpc.CallOption) (*MsgSetModulePausedResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) LiquidStake(ctx context.Context, in *MsgLiquidStake, opts ...grpc.CallOption) (*MsgLiquidStakeResponse, error) { - out := new(MsgLiquidStakeResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/LiquidStake", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) LiquidUnstake(ctx context.Context, in *MsgLiquidUnstake, opts ...grpc.CallOption) (*MsgLiquidUnstakeResponse, error) { - out := new(MsgLiquidUnstakeResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/LiquidUnstake", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) StakeToLP(ctx context.Context, in *MsgStakeToLP, opts ...grpc.CallOption) (*MsgStakeToLPResponse, error) { - out := new(MsgStakeToLPResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/StakeToLP", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateWhitelistedValidators(ctx context.Context, in *MsgUpdateWhitelistedValidators, opts ...grpc.CallOption) (*MsgUpdateWhitelistedValidatorsResponse, error) { - out := new(MsgUpdateWhitelistedValidatorsResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) SetModulePaused(ctx context.Context, in *MsgSetModulePaused, opts ...grpc.CallOption) (*MsgSetModulePausedResponse, error) { - out := new(MsgSetModulePausedResponse) - err := c.cc.Invoke(ctx, "/tac.liquidstake.v1beta1.Msg/SetModulePaused", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // LiquidStake defines a method for performing a delegation of coins - // from a delegator to whitelisted validators. - LiquidStake(context.Context, *MsgLiquidStake) (*MsgLiquidStakeResponse, error) - // LiquidUnstake defines a method for performing an undelegation of liquid - // staking from a delegate. - LiquidUnstake(context.Context, *MsgLiquidUnstake) (*MsgLiquidUnstakeResponse, error) - // StakeToLP defines a method for LSM-transfer of staked TAC - // into gTAC with locking into an LP. - StakeToLP(context.Context, *MsgStakeToLP) (*MsgStakeToLPResponse, error) - // UpdateParams defines a method to update the module params. - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) - // UpdateWhitelistedValidators defines a method to update the whitelisted - // validators list. - UpdateWhitelistedValidators(context.Context, *MsgUpdateWhitelistedValidators) (*MsgUpdateWhitelistedValidatorsResponse, error) - // SetModulePaused defines a method to update the module's pause status, - // setting value of the safety flag in params. - SetModulePaused(context.Context, *MsgSetModulePaused) (*MsgSetModulePausedResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) LiquidStake(ctx context.Context, req *MsgLiquidStake) (*MsgLiquidStakeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LiquidStake not implemented") -} -func (*UnimplementedMsgServer) LiquidUnstake(ctx context.Context, req *MsgLiquidUnstake) (*MsgLiquidUnstakeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LiquidUnstake not implemented") -} -func (*UnimplementedMsgServer) StakeToLP(ctx context.Context, req *MsgStakeToLP) (*MsgStakeToLPResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method StakeToLP not implemented") -} -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} -func (*UnimplementedMsgServer) UpdateWhitelistedValidators(ctx context.Context, req *MsgUpdateWhitelistedValidators) (*MsgUpdateWhitelistedValidatorsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateWhitelistedValidators not implemented") -} -func (*UnimplementedMsgServer) SetModulePaused(ctx context.Context, req *MsgSetModulePaused) (*MsgSetModulePausedResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetModulePaused not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_LiquidStake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgLiquidStake) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).LiquidStake(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Msg/LiquidStake", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).LiquidStake(ctx, req.(*MsgLiquidStake)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_LiquidUnstake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgLiquidUnstake) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).LiquidUnstake(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Msg/LiquidUnstake", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).LiquidUnstake(ctx, req.(*MsgLiquidUnstake)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_StakeToLP_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgStakeToLP) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).StakeToLP(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Msg/StakeToLP", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).StakeToLP(ctx, req.(*MsgStakeToLP)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateWhitelistedValidators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateWhitelistedValidators) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateWhitelistedValidators(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Msg/UpdateWhitelistedValidators", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateWhitelistedValidators(ctx, req.(*MsgUpdateWhitelistedValidators)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_SetModulePaused_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetModulePaused) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SetModulePaused(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/tac.liquidstake.v1beta1.Msg/SetModulePaused", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetModulePaused(ctx, req.(*MsgSetModulePaused)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "tac.liquidstake.v1beta1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "LiquidStake", - Handler: _Msg_LiquidStake_Handler, - }, - { - MethodName: "LiquidUnstake", - Handler: _Msg_LiquidUnstake_Handler, - }, - { - MethodName: "StakeToLP", - Handler: _Msg_StakeToLP_Handler, - }, - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, - { - MethodName: "UpdateWhitelistedValidators", - Handler: _Msg_UpdateWhitelistedValidators_Handler, - }, - { - MethodName: "SetModulePaused", - Handler: _Msg_SetModulePaused_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "tac/liquidstake/v1beta1/tx.proto", -} - -func (m *MsgLiquidStake) 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 *MsgLiquidStake) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgLiquidStake) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgLiquidStakeResponse) 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 *MsgLiquidStakeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgLiquidStakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgStakeToLP) 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 *MsgStakeToLP) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgStakeToLP) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.LiquidAmount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size, err := m.StakedAmount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgStakeToLPResponse) 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 *MsgStakeToLPResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgStakeToLPResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgLiquidUnstake) 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 *MsgLiquidUnstake) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgLiquidUnstake) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgLiquidUnstakeResponse) 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 *MsgLiquidUnstakeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgLiquidUnstakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CompletionTime):]) - if err5 != nil { - return 0, err5 - } - i -= n5 - i = encodeVarintTx(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateWhitelistedValidators) 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 *MsgUpdateWhitelistedValidators) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateWhitelistedValidators) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.WhitelistedValidators) > 0 { - for iNdEx := len(m.WhitelistedValidators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.WhitelistedValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateWhitelistedValidatorsResponse) 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 *MsgUpdateWhitelistedValidatorsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateWhitelistedValidatorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgSetModulePaused) 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 *MsgSetModulePaused) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSetModulePaused) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.IsPaused { - i-- - if m.IsPaused { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgSetModulePausedResponse) 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 *MsgSetModulePausedResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSetModulePausedResponse) 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 *MsgLiquidStake) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgLiquidStakeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgStakeToLP) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.StakedAmount.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.LiquidAmount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgStakeToLPResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgLiquidUnstake) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgLiquidUnstakeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CompletionTime) - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateWhitelistedValidators) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.WhitelistedValidators) > 0 { - for _, e := range m.WhitelistedValidators { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgUpdateWhitelistedValidatorsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgSetModulePaused) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.IsPaused { - n += 2 - } - return n -} - -func (m *MsgSetModulePausedResponse) 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 *MsgLiquidStake) 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: MsgLiquidStake: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgLiquidStake: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 - } - if err := m.Amount.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 *MsgLiquidStakeResponse) 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: MsgLiquidStakeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgLiquidStakeResponse: 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 *MsgStakeToLP) 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: MsgStakeToLP: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgStakeToLP: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakedAmount", 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 - } - if err := m.StakedAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidAmount", 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 - } - if err := m.LiquidAmount.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 *MsgStakeToLPResponse) 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: MsgStakeToLPResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgStakeToLPResponse: 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 *MsgLiquidUnstake) 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: MsgLiquidUnstake: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgLiquidUnstake: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 - } - if err := m.Amount.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 *MsgLiquidUnstakeResponse) 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: MsgLiquidUnstakeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgLiquidUnstakeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", 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 - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CompletionTime, 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 *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - 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 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 - } - if err := m.Params.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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: 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 *MsgUpdateWhitelistedValidators) 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: MsgUpdateWhitelistedValidators: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateWhitelistedValidators: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedValidators", 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.WhitelistedValidators = append(m.WhitelistedValidators, WhitelistedValidator{}) - if err := m.WhitelistedValidators[len(m.WhitelistedValidators)-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 *MsgUpdateWhitelistedValidatorsResponse) 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: MsgUpdateWhitelistedValidatorsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateWhitelistedValidatorsResponse: 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 *MsgSetModulePaused) 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: MsgSetModulePaused: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetModulePaused: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsPaused", wireType) - } - 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.IsPaused = bool(v != 0) - 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 *MsgSetModulePausedResponse) 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: MsgSetModulePausedResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetModulePausedResponse: 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") -) From 449b1be75ef44320994fded60ba824a7638f3cb1 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 31 Jul 2025 14:28:53 +0300 Subject: [PATCH 081/112] fix_dependency --- go.mod | 18 +++++++++--------- go.sum | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 4346cfa..911b680 100644 --- a/go.mod +++ b/go.mod @@ -17,27 +17,27 @@ require ( cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/nft v0.1.1 cosmossdk.io/x/upgrade v0.1.4 - github.com/CosmWasm/wasmd v0.53.0 + github.com/CosmWasm/wasmd v0.53.0 // indirect github.com/cometbft/cometbft v0.38.17 github.com/cosmos/cosmos-db v1.1.1 - github.com/cosmos/cosmos-proto v1.0.0-beta.5 + github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/cosmos-sdk v0.50.13 github.com/cosmos/evm v0.1.1-0.20250328143818-59c573a37f8b github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/ethereum/go-ethereum v1.15.5 - github.com/golang/protobuf v1.5.4 - github.com/gorilla/mux v1.8.1 - github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/golang/protobuf v1.5.4 // indirect + github.com/gorilla/mux v1.8.1 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/onsi/ginkgo/v2 v2.22.2 github.com/onsi/gomega v1.36.2 github.com/spf13/cast v1.7.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 - google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a - google.golang.org/grpc v1.70.0 - google.golang.org/protobuf v1.36.5 + google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a // indirect + google.golang.org/grpc v1.70.0 // indirect + google.golang.org/protobuf v1.36.5 // indirect ) require github.com/cosmos/ibc-go/v8 v8.7.0 @@ -282,7 +282,7 @@ replace ( // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c // github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 - github.com/cosmos/evm => ../evm + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250731111351-ffc1f0ce1828 // Cosmos geth fork // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index c3ac3ca..ba4d880 100644 --- a/go.sum +++ b/go.sum @@ -1006,6 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= +github.com/pixelplex/tac-evm v0.0.0-20250731111351-ffc1f0ce1828 h1:z7YmFLqWbTcVF/oKsdwIFvcksWGAJFn9to8op4h4efU= +github.com/pixelplex/tac-evm v0.0.0-20250731111351-ffc1f0ce1828/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 9a8e6b9d68532050303dca0de67562f5e6ae785b Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 31 Jul 2025 14:36:00 +0300 Subject: [PATCH 082/112] change ci/cd --- settings-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-ci.yml b/settings-ci.yml index a407c0c..8adca15 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -4,7 +4,7 @@ trufflehog_ignore: true deploy: environment: tacchain: - branch: localnet + branch: integrate_evm_liquidstake docker_compose: true runner_tags: - tac-localchain-2 From 1dcbf296209ccfadab787c0ff98a1f0386d22bb1 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 1 Aug 2025 15:20:58 +0300 Subject: [PATCH 083/112] fix generate genesis scripts --- contrib/localnet/init-liquidstake-for-multinode.sh | 2 +- contrib/localnet/init.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/localnet/init-liquidstake-for-multinode.sh b/contrib/localnet/init-liquidstake-for-multinode.sh index 150e91c..0a090b0 100644 --- a/contrib/localnet/init-liquidstake-for-multinode.sh +++ b/contrib/localnet/init-liquidstake-for-multinode.sh @@ -144,7 +144,7 @@ sed -i.bak "s/\"allow_unprotected_txs\": false/\"allow_unprotected_txs\": true/g sed -i.bak "s/allow-unprotected-txs = false/allow-unprotected-txs = true/g" $HOMEDIR/config/app.toml # set evm precompiles -sed -i.bak "s/\"active_static_precompiles\": \[\]/\"active_static_precompiles\": \[\"0x0000000000000000000000000000000000000100\",\"0x0000000000000000000000000000000000000400\",\"0x0000000000000000000000000000000000000800\",\"0x0000000000000000000000000000000000000801\",\"0x0000000000000000000000000000000000000802\",\"0x0000000000000000000000000000000000000803\",\"0x0000000000000000000000000000000000000804\",\"0x0000000000000000000000000000000000000805\",\"0x0000000000000000000000000000000000000806\",\"0x0000000000000000000000000000000000000807\"\]/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"active_static_precompiles\": \[\]/\"active_static_precompiles\": \[\"0x0000000000000000000000000000000000000100\",\"0x0000000000000000000000000000000000000400\",\"0x0000000000000000000000000000000000000800\",\"0x0000000000000000000000000000000000000801\",\"0x0000000000000000000000000000000000000802\",\"0x0000000000000000000000000000000000000803\",\"0x0000000000000000000000000000000000000804\",\"0x0000000000000000000000000000000000000805\",\"0x0000000000000000000000000000000000000806\",\"0x0000000000000000000000000000000000000807\", \"0x0000000000000000000000000000000000001600\"\]/g" $HOMEDIR/config/genesis.json # set x/feemarket min gas price sed -i.bak "s/\"min_gas_price\": \"0.000000000000000000\"/\"min_gas_price\": \"$MIN_GAS_PRICE\"/g" $HOMEDIR/config/genesis.json diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index e7974b4..9fe5fe3 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -144,7 +144,7 @@ sed -i.bak "s/\"allow_unprotected_txs\": false/\"allow_unprotected_txs\": true/g sed -i.bak "s/allow-unprotected-txs = false/allow-unprotected-txs = true/g" $HOMEDIR/config/app.toml # set evm precompiles -sed -i.bak "s/\"active_static_precompiles\": \[\]/\"active_static_precompiles\": \[\"0x0000000000000000000000000000000000000100\",\"0x0000000000000000000000000000000000000400\",\"0x0000000000000000000000000000000000000800\",\"0x0000000000000000000000000000000000000801\",\"0x0000000000000000000000000000000000000802\",\"0x0000000000000000000000000000000000000803\",\"0x0000000000000000000000000000000000000804\",\"0x0000000000000000000000000000000000000805\",\"0x0000000000000000000000000000000000000806\",\"0x0000000000000000000000000000000000000807\"\]/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"active_static_precompiles\": \[\]/\"active_static_precompiles\": \[\"0x0000000000000000000000000000000000000100\",\"0x0000000000000000000000000000000000000400\",\"0x0000000000000000000000000000000000000800\",\"0x0000000000000000000000000000000000000801\",\"0x0000000000000000000000000000000000000802\",\"0x0000000000000000000000000000000000000803\",\"0x0000000000000000000000000000000000000804\",\"0x0000000000000000000000000000000000000805\",\"0x0000000000000000000000000000000000000806\",\"0x0000000000000000000000000000000000000807\", \"0x0000000000000000000000000000000000001600\"\]/g" $HOMEDIR/config/genesis.json # set x/feemarket min gas price sed -i.bak "s/\"min_gas_price\": \"0.000000000000000000\"/\"min_gas_price\": \"$MIN_GAS_PRICE\"/g" $HOMEDIR/config/genesis.json From d9cabaa5c36459c7ab2210a0c6b9a0f34a7fb4b6 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 1 Aug 2025 18:27:22 +0300 Subject: [PATCH 084/112] return EIP typed data changes --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 911b680..bf43493 100644 --- a/go.mod +++ b/go.mod @@ -282,7 +282,7 @@ replace ( // replace cosmos evm with our fork that uses geth v1.13.15 // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c // github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250731111351-ffc1f0ce1828 + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250801152412-aeced0a4e7aa // Cosmos geth fork // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index ba4d880..6dd7eac 100644 --- a/go.sum +++ b/go.sum @@ -1006,8 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250731111351-ffc1f0ce1828 h1:z7YmFLqWbTcVF/oKsdwIFvcksWGAJFn9to8op4h4efU= -github.com/pixelplex/tac-evm v0.0.0-20250731111351-ffc1f0ce1828/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= +github.com/pixelplex/tac-evm v0.0.0-20250801152412-aeced0a4e7aa h1:e2EBAtlUjVYwaS/oNiP/38Gd1uVVPebHVRD1JqILVo4= +github.com/pixelplex/tac-evm v0.0.0-20250801152412-aeced0a4e7aa/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 11aee2d09a296f8a9d0363f3ddc0e14944d974af Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Mon, 4 Aug 2025 17:12:31 +0300 Subject: [PATCH 085/112] Update Evm version to precompiles with events --- go.mod | 5 ++--- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index bf43493..87b879c 100644 --- a/go.mod +++ b/go.mod @@ -280,9 +280,8 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 // replace cosmos evm with our fork that uses geth v1.13.15 - // github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20250604085412-f683909f629c - // github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250718135525-a52a06f062f7 - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250801152412-aeced0a4e7aa + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250731103130-04ede95cc662 + // Cosmos geth fork // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index 6dd7eac..e5ca355 100644 --- a/go.sum +++ b/go.sum @@ -1006,8 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250801152412-aeced0a4e7aa h1:e2EBAtlUjVYwaS/oNiP/38Gd1uVVPebHVRD1JqILVo4= -github.com/pixelplex/tac-evm v0.0.0-20250801152412-aeced0a4e7aa/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= +github.com/pixelplex/tac-evm v0.0.0-20250731103130-04ede95cc662 h1:l5PjcQV8L02H6dPeRaKxRi5Ag4XxqJtfzDwdpAAXvEY= +github.com/pixelplex/tac-evm v0.0.0-20250731103130-04ede95cc662/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 6c3921547ca885ea00a973e6c5cc37afbe548f64 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 7 Aug 2025 13:30:50 +0300 Subject: [PATCH 086/112] chore: set non-zero inflation --- app/app.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 75f80b3..43e4f0f 100644 --- a/app/app.go +++ b/app/app.go @@ -12,11 +12,11 @@ import ( _ "github.com/ethereum/go-ethereum/eth/tracers/js" _ "github.com/ethereum/go-ethereum/eth/tracers/native" + abci "github.com/cometbft/cometbft/abci/types" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm/x/epochs" epochskeeper "github.com/cosmos/evm/x/epochs/keeper" epochstypes "github.com/cosmos/evm/x/epochs/types" - abci "github.com/cometbft/cometbft/abci/types" - dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" "github.com/cosmos/ibc-go/modules/capability" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" @@ -739,7 +739,7 @@ func NewTacChainApp( bank.NewAppModule(encodingConfig.Codec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), feegrantmodule.NewAppModule(encodingConfig.Codec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(encodingConfig.Codec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), - mint.NewAppModule(encodingConfig.Codec, app.MintKeeper, app.AccountKeeper, TacZeroInflation, app.GetSubspace(minttypes.ModuleName)), + mint.NewAppModule(encodingConfig.Codec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), slashing.NewAppModule(encodingConfig.Codec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), distr.NewAppModule(encodingConfig.Codec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(encodingConfig.Codec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), From f36169b3b9a8eab679c150b85197d017a2b65cd7 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenya Date: Thu, 7 Aug 2025 13:33:16 +0300 Subject: [PATCH 087/112] chore: update ci --- settings-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-ci.yml b/settings-ci.yml index 8adca15..a407c0c 100644 --- a/settings-ci.yml +++ b/settings-ci.yml @@ -4,7 +4,7 @@ trufflehog_ignore: true deploy: environment: tacchain: - branch: integrate_evm_liquidstake + branch: localnet docker_compose: true runner_tags: - tac-localchain-2 From d1e895e772d6ce2ab5482f2beb65ca83e26b9980 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 8 Aug 2025 13:11:35 +0300 Subject: [PATCH 088/112] Sync with admin transaction changes: bf42d5628eca --- go.mod | 3 +-- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 87b879c..fff6dfa 100644 --- a/go.mod +++ b/go.mod @@ -280,8 +280,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 // replace cosmos evm with our fork that uses geth v1.13.15 - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250731103130-04ede95cc662 - + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250808100428-bf42d5628eca // Cosmos geth fork // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index e5ca355..f649769 100644 --- a/go.sum +++ b/go.sum @@ -1006,8 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250731103130-04ede95cc662 h1:l5PjcQV8L02H6dPeRaKxRi5Ag4XxqJtfzDwdpAAXvEY= -github.com/pixelplex/tac-evm v0.0.0-20250731103130-04ede95cc662/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= +github.com/pixelplex/tac-evm v0.0.0-20250808100428-bf42d5628eca h1:IN7hZ7y7hOLLfBJHCsCY09QRZmpAth+AxxwFSE8PDDI= +github.com/pixelplex/tac-evm v0.0.0-20250808100428-bf42d5628eca/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 9c47ab77b60d1da7a306cb3707a42bf3d5254903 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 8 Aug 2025 16:34:15 +0300 Subject: [PATCH 089/112] Revert EIP712 changes --- app/ante.go | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/app/ante.go b/app/ante.go index efb1e8c..19494c3 100644 --- a/app/ante.go +++ b/app/ante.go @@ -83,18 +83,9 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { options.MaxTxGasWanted, ), ) - case "/cosmos.evm.types.v1.ExtensionOptionsWeb3Tx": - // handle as normal Cosmos SDK tx, except signature is checked for EIP712 representation - anteHandler, err = newCosmosAnteHandler(cosmosHandlerOptions{ - HandlerOptions: options, - isEIP712: true, - }) case "/cosmos.evm.types.v1.ExtensionOptionDynamicFeeTx": // cosmos-sdk tx with dynamic fee extension - anteHandler, err = newCosmosAnteHandler(cosmosHandlerOptions{ - HandlerOptions: options, - isEIP712: false, - }) + anteHandler, err = newCosmosAnteHandler(options) default: return ctx, errors.New(fmt.Sprintf("rejecting tx with unsupported extension option: %s", typeURL)) } @@ -110,10 +101,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { // handle as totally normal Cosmos SDK tx switch tx.(type) { case sdk.Tx: - anteHandler, err = newCosmosAnteHandler(cosmosHandlerOptions{ - HandlerOptions: options, - isEIP712: false, - }) + anteHandler, err = newCosmosAnteHandler(options) default: return ctx, errors.New("invalid transaction type") } @@ -126,14 +114,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { }, nil } -// cosmosHandlerOptions extends HandlerOptions to provide some Cosmos specific configurations -type cosmosHandlerOptions struct { - HandlerOptions - isEIP712 bool -} - -func newCosmosAnteHandler(options cosmosHandlerOptions) (sdk.AnteHandler, error) { - decorators := []sdk.AnteDecorator{ +func newCosmosAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { + return sdk.ChainAnteDecorators( evmcosmosante.NewRejectMessagesDecorator(), // reject MsgEthereumTxs evmcosmosante.NewAuthzLimiterDecorator( // disable the Msg types that cannot be included on an authz.MsgExec msgs field sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}), @@ -141,7 +123,7 @@ func newCosmosAnteHandler(options cosmosHandlerOptions) (sdk.AnteHandler, error) ), authante.NewSetUpContextDecorator(), circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), - // authante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), + authante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), authante.NewValidateBasicDecorator(), authante.NewTxTimeoutHeightDecorator(), authante.NewValidateMemoDecorator(options.AccountKeeper), @@ -152,21 +134,9 @@ func newCosmosAnteHandler(options cosmosHandlerOptions) (sdk.AnteHandler, error) authante.NewSetPubKeyDecorator(options.AccountKeeper), authante.NewValidateSigCountDecorator(options.AccountKeeper), authante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), - } - if !options.isEIP712 { - decorators = append(decorators, authante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker)) - } - var sigVerification sdk.AnteDecorator = authante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler) - if options.isEIP712 { - sigVerification = evmcosmosante.NewLegacyEip712SigVerificationDecorator(options.AccountKeeper) - } - decorators = append(decorators, sigVerification) - - decorators = append(decorators, + authante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), authante.NewIncrementSequenceDecorator(options.AccountKeeper), ibcante.NewRedundantRelayDecorator(options.IBCKeeper), evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper), - ) - - return sdk.ChainAnteDecorators(decorators...), nil + ), nil } From 4264ab6117a7e52032a4f0afb0c9f408f1b9e167 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Tue, 16 Sep 2025 20:44:15 +0300 Subject: [PATCH 090/112] Halborn audit fixes sync --- Dockerfile | 5 +++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 72c25fa..1768eb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,6 @@ COPY . /code/ # force it to use static lib (from above) not standard libgo_cosmwasm.so file RUN make build -RUN LEDGER_ENABLED=false make build FROM ubuntu:22.04 @@ -43,7 +42,8 @@ RUN apt-get update && apt-get install -y \ bc \ && rm -rf /var/lib/apt/lists/* -RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.1.0/libwasmvm.x86_64.so +RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.2.1/libwasmvm.x86_64.so +RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.1.0/libwasmvm.aarch64.so WORKDIR /scripts @@ -57,3 +57,4 @@ EXPOSE 26657 EXPOSE 9090 CMD ["/usr/bin/tacchaind", "version"] + diff --git a/go.mod b/go.mod index fff6dfa..964a68a 100644 --- a/go.mod +++ b/go.mod @@ -280,7 +280,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 // replace cosmos evm with our fork that uses geth v1.13.15 - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250808100428-bf42d5628eca + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250825121004-d13becaea1f2 // Cosmos geth fork // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index f649769..4880887 100644 --- a/go.sum +++ b/go.sum @@ -1006,8 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250808100428-bf42d5628eca h1:IN7hZ7y7hOLLfBJHCsCY09QRZmpAth+AxxwFSE8PDDI= -github.com/pixelplex/tac-evm v0.0.0-20250808100428-bf42d5628eca/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= +github.com/pixelplex/tac-evm v0.0.0-20250825121004-d13becaea1f2 h1:hfbYCYu3WFrabZIY0/rsZmq5syG8KvBfnvwyLUseEWg= +github.com/pixelplex/tac-evm v0.0.0-20250825121004-d13becaea1f2/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From f464dedaf60a461ba3215258f8d1fc650ea2e32f Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 18 Sep 2025 14:02:14 +0300 Subject: [PATCH 091/112] Prepare for proposal: remove redunant code after migrating module --- app/helpers/test_helpers.go | 174 ------------------------------------ utils/cache_ctx.go | 60 ------------- utils/epoch.go | 13 --- utils/proofs.go | 64 ------------- 4 files changed, 311 deletions(-) delete mode 100644 app/helpers/test_helpers.go delete mode 100644 utils/cache_ctx.go delete mode 100644 utils/epoch.go delete mode 100644 utils/proofs.go diff --git a/app/helpers/test_helpers.go b/app/helpers/test_helpers.go deleted file mode 100644 index 2df6b7c..0000000 --- a/app/helpers/test_helpers.go +++ /dev/null @@ -1,174 +0,0 @@ -package helpers - -import ( - "bytes" - "fmt" - "strconv" - "testing" - "time" - - "encoding/hex" - - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/log" - "cosmossdk.io/math" - chain "github.com/Asphere-xyz/tacchain/app" - dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *chain.TacChainApp { - db := dbm.NewMemDB() - logger := log.NewTestLogger(t) - return chain.NewTacChainAppWithCustomOptions(t, isCheckTx, invCheckPeriod, chain.SetupOptions{ - Logger: logger, - DB: db, - AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), - }) -} - -// AddTestAddrs constructs and returns accNum amount of accounts with an -// initial balance of accAmt in random order -func AddTestAddrs(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { - return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts) -} - -type GenerateAccountStrategy func(int) []sdk.AccAddress - -func addTestAddrs(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { - testAddrs := strategy(accNum) - - initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, accAmt)) - - for _, addr := range testAddrs { - InitAccountWithCoins(app, ctx, addr, initCoins) - } - - return testAddrs -} - -// createRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order. -func createRandomAccounts(accNum int) []sdk.AccAddress { - testAddrs := make([]sdk.AccAddress, accNum) - for i := 0; i < accNum; i++ { - pk := ed25519.GenPrivKey().PubKey() - testAddrs[i] = sdk.AccAddress(pk.Address()) - } - - return testAddrs -} - -func InitAccountWithCoins(app *chain.TacChainApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { - err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) - if err != nil { - panic(err) - } - - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) - if err != nil { - panic(err) - } -} - -// ConvertAddrsToValAddrs converts the provided addresses to ValAddress. -func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { - valAddrs := make([]sdk.ValAddress, len(addrs)) - - for i, addr := range addrs { - valAddrs[i] = sdk.ValAddress(addr) - } - - return valAddrs -} - -// ParseTime parses and returns time.Time in time.RFC3339 format. -func ParseTime(s string) time.Time { - t, err := time.Parse(time.RFC3339, s) - if err != nil { - panic(err) - } - return t -} - -// AddTestAddrs constructs and returns accNum amount of accounts with an -// initial balance of accAmt in random order -func AddTestAddrsIncremental(app *chain.TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { - return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) -} - -// createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order. -func createIncrementalAccounts(accNum int) []sdk.AccAddress { - var addresses []sdk.AccAddress - var buffer bytes.Buffer - - // start at 100 so we can make up to 999 test addresses with valid test addresses - for i := 100; i < (accNum + 100); i++ { - numString := strconv.Itoa(i) - buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string - - buffer.WriteString(numString) // adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) - bech := res.String() - addr, _ := TestAddr(buffer.String(), bech) - - addresses = append(addresses, addr) - buffer.Reset() - } - - return addresses -} - -func TestAddr(addr, bech string) (sdk.AccAddress, error) { - res, err := sdk.AccAddressFromHexUnsafe(addr) - if err != nil { - return nil, err - } - bechexpected := res.String() - if bech != bechexpected { - return nil, fmt.Errorf("bech encoding doesn't match reference") - } - - bechres, err := sdk.AccAddressFromBech32(bech) - if err != nil { - return nil, err - } - if !bytes.Equal(bechres, res) { - return nil, err - } - - return res, nil -} - -// CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. -func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { - var publicKeys []cryptotypes.PubKey - var buffer bytes.Buffer - - // start at 10 to avoid changing 1 to 01, 2 to 02, etc - for i := 100; i < (numPubKeys + 100); i++ { - numString := strconv.Itoa(i) - buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string - buffer.WriteString(numString) // adding on final two digits to make pubkeys unique - publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String())) - buffer.Reset() - } - - return publicKeys -} - -// NewPubKeyFromHex returns a PubKey from a hex string. -func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { - pkBytes, err := hex.DecodeString(pk) - if err != nil { - panic(err) - } - if len(pkBytes) != ed25519.PubKeySize { - panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) - } - return &ed25519.PubKey{Key: pkBytes} -} diff --git a/utils/cache_ctx.go b/utils/cache_ctx.go deleted file mode 100644 index 6546d8f..0000000 --- a/utils/cache_ctx.go +++ /dev/null @@ -1,60 +0,0 @@ -package utils - -import ( - "errors" - "fmt" - "runtime" - "runtime/debug" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// ApplyFuncIfNoError This function lets you run the function f, but if theres an error or panic -// drop the state machine change and log the error. -// If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness) -// Try to avoid usage of iterators in f. -func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error) { - // Add a panic safeguard - defer func() { - if recoveryError := recover(); recoveryError != nil { - PrintPanicRecoveryError(ctx, recoveryError) - - err = errors.New("panic occurred during execution") - } - }() - // makes a new cache context, which all state changes get wrapped inside of. - cacheCtx, write := ctx.CacheContext() - - err = f(cacheCtx) - if err != nil { - ctx.Logger().Error(err.Error()) - } else { - // no error, write the output of f - write() - } - - return err -} - -// PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. -// If not emits them to stdout. -func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{}) { - errStackTrace := string(debug.Stack()) - - switch e := recoveryError.(type) { - case string: - ctx.Logger().Error("Recovering from (string) panic: " + e) - case runtime.Error: - ctx.Logger().Error("recovered (runtime.Error) panic: " + e.Error()) - case error: - ctx.Logger().Error("recovered (error) panic: " + e.Error()) - default: - ctx.Logger().Error("recovered (default) panic. Could not capture logs in ctx, see stdout") - fmt.Println("Recovering from panic ", recoveryError) - - debug.PrintStack() - - return - } - ctx.Logger().Error("stack trace: " + errStackTrace) -} diff --git a/utils/epoch.go b/utils/epoch.go deleted file mode 100644 index 726c3ef..0000000 --- a/utils/epoch.go +++ /dev/null @@ -1,13 +0,0 @@ -package utils - -import ( - "sort" - - "golang.org/x/exp/constraints" -) - -func SortSlice[T constraints.Ordered](s []T) { - sort.Slice(s, func(i, j int) bool { - return s[i] < s[j] - }) -} diff --git a/utils/proofs.go b/utils/proofs.go deleted file mode 100644 index 35009d1..0000000 --- a/utils/proofs.go +++ /dev/null @@ -1,64 +0,0 @@ -package utils - -import ( - "fmt" - - "cosmossdk.io/errors" - "github.com/cometbft/cometbft/proto/tendermint/crypto" - sdk "github.com/cosmos/cosmos-sdk/types" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" - ibcKeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" -) - -func ValidateProofOps(ctx sdk.Context, ibcKeeper *ibcKeeper.Keeper, connectionID string, chainID string, height int64, module string, key []byte, data []byte, proofOps *crypto.ProofOps) error { - if proofOps == nil { - return fmt.Errorf("unable to validate proof. No proof submitted") - } - - connection, found := ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) - if !found { - return fmt.Errorf("connection %s not found", connectionID) - } - - csHeight := clienttypes.NewHeight(clienttypes.ParseChainID(chainID), uint64(height)+1) - consensusState, found := ibcKeeper.ClientKeeper.GetClientConsensusState(ctx, connection.ClientId, csHeight) - - if !found { - return fmt.Errorf("unable to fetch consensus state") - } - - tmConsState, ok := consensusState.(*ibctm.ConsensusState) - if !ok { - return fmt.Errorf("error unmarshaling consensus state") - } - - clientState, found := ibcKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId) - if !found { - return fmt.Errorf("unable to fetch client state") - } - - path := commitmenttypes.NewMerklePath([]string{module, string(key)}...) - - merkleProof, err := commitmenttypes.ConvertProofs(proofOps) - if err != nil { - return fmt.Errorf("error converting proofs") - } - - tmClientState, ok := clientState.(*ibctm.ClientState) - if !ok { - return fmt.Errorf("error unmarshaling client state") - } - - if len(data) != 0 { - err = merkleProof.VerifyMembership(tmClientState.ProofSpecs, tmConsState.GetRoot(), path, data) - err = errors.Wrap(err, "unable to verify inclusion proof") - } else { - // if we got a nil response, verify non inclusion proof. - err = merkleProof.VerifyNonMembership(tmClientState.ProofSpecs, tmConsState.GetRoot(), path) - err = errors.Wrap(err, "unable to verify non-inclusion proof") - } - - return err -} From 5fa3780455c78f4f64206be163def20fbd0b5f4f Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 18 Sep 2025 14:38:09 +0300 Subject: [PATCH 092/112] Prepare for proposal: remove redunant scripts, move protocgen from separate catalog --- Makefile | 2 +- {scripts => contrib/localnet}/protocgen.sh | 0 contrib/localnet/start-additional-node.sh | 7 ------- contrib/localnet/vote.sh | 17 ----------------- 4 files changed, 1 insertion(+), 25 deletions(-) rename {scripts => contrib/localnet}/protocgen.sh (100%) delete mode 100644 contrib/localnet/start-additional-node.sh delete mode 100755 contrib/localnet/vote.sh diff --git a/Makefile b/Makefile index cca235d..85d0608 100644 --- a/Makefile +++ b/Makefile @@ -160,7 +160,7 @@ proto-all: proto-format proto-gen proto-gen: @echo "Generating Protobuf files" - @$(protoImage) sh ./scripts/protocgen.sh + @$(protoImage) sh ./contrib/localnet/protocgen.sh @go mod tidy proto-format: diff --git a/scripts/protocgen.sh b/contrib/localnet/protocgen.sh similarity index 100% rename from scripts/protocgen.sh rename to contrib/localnet/protocgen.sh diff --git a/contrib/localnet/start-additional-node.sh b/contrib/localnet/start-additional-node.sh deleted file mode 100644 index 89f2e9e..0000000 --- a/contrib/localnet/start-additional-node.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} -TACCHAIND=${TACCHAIND:-$(which tacchaind)} -HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} - -$TACCHAIND start --chain-id $CHAIN_ID --home $HOMEDIR --p2p.laddr $P2P_LADDR --p2p.external-address $P2P_EXTERNAL_ADDRESS --rpc.laddr $RPC_LADDR --json-rpc.address $JSON_RPC_ADDR --json-rpc.ws-address $JSON_RPC_WS_ADDR --p2p.persistent_peers $P2P_PERSISTENT_PEERS --json-rpc.enable diff --git a/contrib/localnet/vote.sh b/contrib/localnet/vote.sh deleted file mode 100755 index 1a3c9e2..0000000 --- a/contrib/localnet/vote.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -tacchaind tx upgrade software-upgrade liquidstake \ - --upgrade-height ${1} \ - --title "Liquidstake Module Upgrade" \ - --summary "Upgrade to add liquidstake functionality" \ - --upgrade-info '{}' \ - --no-validate \ - --deposit "10000000000000000utac" \ - --from validator \ - --gas-prices "25000000000utac" \ - --yes | jq -r ".hash" - -sleep .5 - -tacchaind tx gov vote ${2} yes --from validator --gas-prices "25000000000utac" --yes - From 8b123c84c780fd71a54c925972b126b27b7240a8 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 18 Sep 2025 15:02:17 +0300 Subject: [PATCH 093/112] Prepare for proposal: remove unnescesssary ci parts and redunant modifications --- app/upgrades/v0.0.11/upgrades.go | 2 +- docker-compose.yml | 128 -------------------- networks/tacchain_2391-1/docker-compose.yml | 32 ++--- settings-ci.yml | 23 ---- 4 files changed, 12 insertions(+), 173 deletions(-) delete mode 100644 docker-compose.yml delete mode 100644 settings-ci.yml diff --git a/app/upgrades/v0.0.11/upgrades.go b/app/upgrades/v0.0.11/upgrades.go index 860b82d..c4655ee 100644 --- a/app/upgrades/v0.0.11/upgrades.go +++ b/app/upgrades/v0.0.11/upgrades.go @@ -1,4 +1,4 @@ -package v011 +package v010 import ( "context" diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 20354a8..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,128 +0,0 @@ -services: - init: - image: ${IMAGE} - volumes: - - "/mnt/data:/tacchain_data" - entrypoint: bash - command: /scripts/init-multi-node.sh - environment: - - CHAIN_ID=tacchain_2391-1 - - MONIKER=tac-validator - - HOMEDIR=/tacchain_data - - UNBONDING_TIME=300s - - validator-1: - network_mode: host - restart: unless-stopped - image: ${IMAGE} - ports: - - "45110:45110" # P2P - - "45111:45111" # RPC - - "45112:45112" # REST - - "45113:45113" # GRPC - - "45118:45118" # RPC_EVM - - "45119:45119" # WS_EVM - volumes: - - "/mnt/data/node0:/tacchain_data/node0" - depends_on: - init: - condition: service_completed_successfully - entrypoint: sh - command: /scripts/start.sh - environment: - - CHAIN_ID=tacchain_2391-1 - - MONIKER=tac-validator - - HOMEDIR=/tacchain_data/node0 - - P2P_LADDR=tcp://0.0.0.0:45110 - - P2P_EXTERNAL_ADDRESS=0.0.0.0:45110 - - RPC_LADDR=tcp://0.0.0.0:45111 - - JSON_RPC_ADDR=0.0.0.0:45118 - - JSON_RPC_WS_ADDR=0.0.0.0:45119 - - GRPC_LADDR=0.0.0.0:45113 - - validator-2: - network_mode: host - restart: unless-stopped - image: ${IMAGE} - ports: - - "45120:45120" # P2P - - "45121:45121" # RPC - - "45122:45122" # REST - - "45123:45123" # GRPC - - "45128:45128" # RPC_EVM - - "45129:45129" # WS_EVM - volumes: - - "/mnt/data/node1:/tacchain_data/node1" - depends_on: - init: - condition: service_completed_successfully - entrypoint: sh - command: /scripts/start.sh - environment: - - CHAIN_ID=tacchain_2391-1 - - MONIKER=tac-validator - - HOMEDIR=/tacchain_data/node1 - - P2P_LADDR=tcp://0.0.0.0:45120 - - P2P_EXTERNAL_ADDRESS=0.0.0.0:45120 - - RPC_LADDR=tcp://0.0.0.0:45121 - - JSON_RPC_ADDR=0.0.0.0:45128 - - JSON_RPC_WS_ADDR=0.0.0.0:45129 - - GRPC_LADDR=0.0.0.0:45123 - - validator-3: - network_mode: host - restart: unless-stopped - image: ${IMAGE} - ports: - - "45130:45130" # P2P - - "45131:45131" # RPC - - "45132:45132" # REST - - "45133:45133" # GRPC - - "45138:45138" # RPC_EVM - - "45139:45139" # WS_EVM - volumes: - - "/mnt/data/node2:/tacchain_data/node2" - depends_on: - init: - condition: service_completed_successfully - entrypoint: sh - command: /scripts/start.sh - environment: - - CHAIN_ID=tacchain_2391-1 - - MONIKER=tac-validator - - HOMEDIR=/tacchain_data/node2 - - P2P_LADDR=tcp://0.0.0.0:45130 - - P2P_EXTERNAL_ADDRESS=0.0.0.0:45130 - - RPC_LADDR=tcp://0.0.0.0:45131 - - JSON_RPC_ADDR=0.0.0.0:45138 - - JSON_RPC_WS_ADDR=0.0.0.0:45139 - - GRPC_LADDR=0.0.0.0:45133 - - validator-4: - network_mode: host - restart: unless-stopped - image: ${IMAGE} - ports: - - "45140:45140" # P2P - - "45141:45141" # RPC - - "45142:45142" # REST - - "45143:45143" # GRPC - - "45148:45148" # RPC_EVM - - "45149:45149" # WS_EVM - volumes: - - "/mnt/data/node3:/tacchain_data/node3" - depends_on: - init: - condition: service_completed_successfully - entrypoint: sh - command: /scripts/start.sh - environment: - - CHAIN_ID=tacchain_2391-1 - - MONIKER=tac-validator - - HOMEDIR=/tacchain_data/node3 - - P2P_LADDR=tcp://0.0.0.0:45140 - - P2P_EXTERNAL_ADDRESS=0.0.0.0:45140 - - RPC_LADDR=tcp://0.0.0.0:45141 - - JSON_RPC_ADDR=0.0.0.0:45148 - - JSON_RPC_WS_ADDR=0.0.0.0:45149 - - GRPC_LADDR=0.0.0.0:45143 diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index 58a9b6d..1dfa0e6 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -1,35 +1,24 @@ services: tac-spb-testnet-init: - image: ${IMAGE} - network_mode: host - environment: - - MONIKER=tac-validator - - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 - - EXT_IP=0.0.0.0 - - P2P_PORT=45130 - - RPC_PORT=45131 - - RPC_PORT_EVM=45138 - - WS_PORT_EVM=45139 + user: "${USER_ID}:${GROUP_ID}" + image: tacchain:v0.0.11 + env_file: + - .env.spb volumes: - - "/data/tac/:/data" + - "./:/data" entrypoint: /bin/sh command: > -c "[ ! -e /data/config/config.toml ] && tacchaind init $MONIKER --chain-id tacchain_2391-1 --home /data && cd /data/config && rm genesis.json && wget https://raw.githubusercontent.com/TacBuild/tacchain/refs/heads/main/networks/tacchain_2391-1/genesis.json || exit 0" tac-spb-testnet-validator-1: + user: "${USER_ID}:${GROUP_ID}" network_mode: host restart: unless-stopped - image: ${IMAGE} - environment: - - MONIKER=tac-validator - - P2P_PERSISTENT_PEERS=9c32b3b959a2427bd2aa064f8c9a8efebdad4c23@206.217.210.164:45130,04a2152eed9f73dc44779387a870ea6480c41fe7@206.217.210.164:45140,5aaaf8140262d7416ac53abe4e0bd13b0f582168@23.92.177.41:45110,ddb3e8b8f4d051e914686302dafc2a73adf9b0d2@23.92.177.41:45120 - - EXT_IP=0.0.0.0 - - P2P_PORT=45130 - - RPC_PORT=45131 - - RPC_PORT_EVM=45138 - - WS_PORT_EVM=45139 + image: tacchain:v0.0.11 + env_file: + - .env.spb volumes: - - "/data/tac/:/data" + - "./:/data" depends_on: tac-spb-testnet-init: condition: service_completed_successfully @@ -47,3 +36,4 @@ services: --rpc.laddr=tcp://0.0.0.0:${RPC_PORT} --json-rpc.address=0.0.0.0:${RPC_PORT_EVM} --json-rpc.ws-address=0.0.0.0:${WS_PORT_EVM} + --json-rpc.enable diff --git a/settings-ci.yml b/settings-ci.yml deleted file mode 100644 index a407c0c..0000000 --- a/settings-ci.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -trufflehog_ignore: true - -deploy: - environment: - tacchain: - branch: localnet - docker_compose: true - runner_tags: - - tac-localchain-2 - manual: true - -apps: - tac: - image: golang:1.23.8-bullseye - runner_tags: - - docker - code_analysis: false - build: false - docker_build: - runner_tags: - - docker - test_docker: false From 8fe2f3558d822aacc333be59e4c156f5cae808c1 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 18 Sep 2025 15:14:37 +0300 Subject: [PATCH 094/112] Prepare for proposal: reduce unnescescary changes in scripts --- contrib/localnet/init-multi-node.sh | 69 ++++++++++++--------- contrib/localnet/init.sh | 34 +++++----- contrib/localnet/start.sh | 23 +------ networks/tacchain_2391-1/docker-compose.yml | 1 - 4 files changed, 59 insertions(+), 68 deletions(-) diff --git a/contrib/localnet/init-multi-node.sh b/contrib/localnet/init-multi-node.sh index 670c2d5..1f63c1e 100755 --- a/contrib/localnet/init-multi-node.sh +++ b/contrib/localnet/init-multi-node.sh @@ -10,25 +10,34 @@ export VALIDATOR_NAME=${VALIDATOR_NAME:-TAC Validator} export VALIDATOR_IDENTITY=${VALIDATOR_IDENTITY:-4DD1A5E1D03FA12D} export VALIDATOR_WEBSITE=${VALIDATOR_WEBSITE:-https://tac.build/} export VALIDATOR_1_MNEMONIC=${VALIDATOR_1_MNEMONIC:-"island mail dice alien project surround orchard ball twist worth innocent arrange assume dragon rotate enough flee rapid rookie swim addict ice destroy run"} # tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr -export VALIDATOR_2_MNEMONIC=${VALIDATOR_2_MNEMONIC:-"margin funny awkward answer squirrel inner venue spell expose close tank salute series neck oval real bunker can text chronic capital teach arena extend"} # tac16p9nqhd348aaungp5p5vjuwedaw03pvywdzwdk -export VALIDATOR_3_MNEMONIC=${VALIDATOR_3_MNEMONIC:-"that away spike absorb aspect loan shuffle purchase number knock cover night library shock mask cheese upset float churn wall fox veteran actress motor"} # tac1qp4h82jgqqa5ezgzck8z75dn8q0t0nv45pzh6v -export VALIDATOR_4_MNEMONIC=${VALIDATOR_4_MNEMONIC:-"floor wrong idle cloth nose material forward urge grape always into buyer atom excuse odor decade crouch purchase shadow energy voyage pact skate pigeon"} # tac1d30q62hl0wn6n5m39sd0yqswq6jr3hntt2cm4n +export VALIDATOR_2_MNEMONIC=${VALIDATOR_2_MNEMONIC:-"margin funny awkward answer squirrel inner venue spell expose close tank salute series neck oval real bunker can text chronic capital teach arena extend"} # tac16p9nqhd348aaungp5p5vjuwedaw03pvywdzwdk +export VALIDATOR_3_MNEMONIC=${VALIDATOR_3_MNEMONIC:-"that away spike absorb aspect loan shuffle purchase number knock cover night library shock mask cheese upset float churn wall fox veteran actress motor"} # tac1qp4h82jgqqa5ezgzck8z75dn8q0t0nv45pzh6v +export VALIDATOR_4_MNEMONIC=${VALIDATOR_4_MNEMONIC:-"floor wrong idle cloth nose material forward urge grape always into buyer atom excuse odor decade crouch purchase shadow energy voyage pact skate pigeon"} # tac1d30q62hl0wn6n5m39sd0yqswq6jr3hntt2cm4n export GENESIS_ACC_1_ADDRESS=${GENESIS_ACC_1_ADDRESS:-} export GENESIS_ACC_2_ADDRESS=${GENESIS_ACC_2_ADDRESS:-} export INITIAL_SUPPLY=${INITIAL_SUPPLY:-10000000000000000000000000000} export BLOCK_TIME_SECONDS=${BLOCK_TIME_SECONDS:-2} export MAX_GAS=${MAX_GAS:-90000000} -export MIN_GAS_PRICE=${MIN_GAS_PRICE:-25000000000} -export GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-43200} +export MIN_GAS_PRICE=${MIN_GAS_PRICE:-400000000000} +export GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-604800} export GOV_MIN_DEPOSIT=${GOV_MIN_DEPOSIT:-10000000000000000} export GOV_MIN_EXPEDITED_DEPOSIT=${GOV_MIN_EXPEDITED_DEPOSIT:-50000000000000000} export GOV_MIN_INITIAL_DEPOSIT_RATIO=${GOV_MIN_INITIAL_DEPOSIT_RATIO:-1} export INFLATION_MAX=${INFLATION_MAX:-0.05} -export INFLATION_MIN=${INFLATION_MIN:-0} +export INFLATION_MIN=${INFLATION_MIN:-0.01} export GOAL_BONDED=${GOAL_BONDED:-0.6} export SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} export SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} -export MAX_VALIDATORS=${MAX_VALIDATORS:-14} +export MAX_VALIDATORS=${MAX_VALIDATORS:-20} +export COMMUNITY_TAX=${COMMUNITY_TAX:-0.00} + + +# prompt user for confirmation before cleanup +read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm +if [[ $confirm != "y" && $confirm != "Y" ]]; then + echo "Cleanup aborted." + exit 1 +fi # cleanup old data rm -rf $HOMEDIR @@ -55,38 +64,38 @@ GENESIS_ACC_2_BALANCE=10000000000000000000000 GENESIS_ACC_1_BALANCE=$(echo "$INITIAL_SUPPLY - ($VALIDATOR_BALANCE * $VALIDATORS_COUNT) - $GENESIS_ACC_2_BALANCE" | bc) # initialize config folder for each validator -for ((i = 0; i < VALIDATORS_COUNT; i++)); do +for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do NODE_KEY="node$i" NODEDIR="$HOMEDIR/$NODE_KEY" # set ports - export P2P_PORT=451$((i + 1))0 # 45110 - export RPC_PORT=451$((i + 1))1 # 45111 - export API_PORT=451$((i + 1))2 # 45112 - export METRICS_PORT=451$((i + 1))3 # 45113 - export PPROF_PORT=451$((i + 1))4 # 45114 - export PROMETHEUS_PORT=451$((i + 1))5 # 45115 - export GRPC_WEB_PORT=451$((i + 1))6 # 45116 - export GRPC_PORT=451$((i + 1))7 # 45117 - export JSON_RPC_PORT=451$((i + 1))8 # 45118 - export JSON_WS_PORT=451$((i + 1))9 # 45119 - export PROXY_PORT=451$((i + 1))10 # 451110 + export P2P_PORT=451$((i+1))0 # 45110 + export RPC_PORT=451$((i+1))1 # 45111 + export API_PORT=451$((i+1))2 # 45112 + export METRICS_PORT=451$((i+1))3 # 45113 + export PPROF_PORT=451$((i+1))4 # 45114 + export PROMETHEUS_PORT=451$((i+1))5 # 45115 + export GRPC_WEB_PORT=451$((i+1))6 # 45116 + export GRPC_PORT=451$((i+1))7 # 45117 + export JSON_RPC_PORT=451$((i+1))8 # 45118 + export JSON_WS_PORT=451$((i+1))9 # 45119 + export PROXY_PORT=451$((i+1))10 # 451110 export NODE_MONIKER="$VALIDATOR_NAME $((i + 1))" - + export INITIAL_BALANCE=$VALIDATOR_BALANCE export INITIAL_STAKE=$VALIDATOR_SELF_DELEGATION # dynamically get mnemonic env var for each validator - mnemonic_var="VALIDATOR_$((i + 1))_MNEMONIC" + mnemonic_var="VALIDATOR_$((i+1))_MNEMONIC" export VALIDATOR_MNEMONIC="${!mnemonic_var}" # call init.sh script to initialize the node - echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init-liquidstake-for-multinode.sh + echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init.sh # explicitly add balances to first node(node0) which will be used to collect gentxs later ADDRESS=$($TACCHAIND keys show validator --keyring-backend $KEYRING_BACKEND --home $NODEDIR -a) - $TACCHAIND genesis add-genesis-account $ADDRESS ${VALIDATOR_BALANCE}utac --keyring-backend $KEYRING_BACKEND --home $HOMEDIR/node0 &>/dev/null || true + $TACCHAIND genesis add-genesis-account $ADDRESS ${VALIDATOR_BALANCE}utac --keyring-backend $KEYRING_BACKEND --home $HOMEDIR/node0 &> /dev/null || true # copy gentx into main gentxs cp $NODEDIR/config/gentx/* "$HOMEDIR/gentxs/" @@ -110,29 +119,29 @@ $TACCHAIND genesis add-genesis-account $GENESIS_ACC_2_ADDRESS ${GENESIS_ACC_2_BA cp $HOMEDIR/gentxs/* "$HOMEDIR/node0/config/gentx/" # clear gentx in genesis because we already collect in init.sh, so recollect here instead changing the original script -jq '.app_state.genutil.gen_txs = []' "$HOMEDIR/node0/config/genesis.json" >"$HOMEDIR/node0/config/genesis_tmp.json" && mv "$HOMEDIR/node0/config/genesis_tmp.json" "$HOMEDIR/node0/config/genesis.json" +jq '.app_state.genutil.gen_txs = []' "$HOMEDIR/node0/config/genesis.json" > "$HOMEDIR/node0/config/genesis_tmp.json" && mv "$HOMEDIR/node0/config/genesis_tmp.json" "$HOMEDIR/node0/config/genesis.json" $TACCHAIND genesis collect-gentxs --home $HOMEDIR/node0 # copy genesis to main directory for reference cp $HOMEDIR/node0/config/genesis.json $HOMEDIR/genesis.json -for ((i = 0; i < VALIDATORS_COUNT; i++)); do +for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do # copy final genesis to all validators - cp $HOMEDIR/node0/config/genesis.json $HOMEDIR/node$i/config/genesis.json &>/dev/null || true - + cp $HOMEDIR/node0/config/genesis.json $HOMEDIR/node$i/config/genesis.json &> /dev/null || true + # update persistent peers PERSISTENT_PEERS="" CURRENT_PEER=0 - for ((j = 0; j < VALIDATORS_COUNT; j++)); do + for ((j = 0 ; j < VALIDATORS_COUNT ; j++)); do # add all nodes except the current one if [ "$i" != "$j" ]; then CURRENT_PEER=$((CURRENT_PEER + 1)) NODE_ID=$($TACCHAIND tendermint show-node-id --home $HOMEDIR/node$j) - P2P_PORT=451$((j + 1))0 + P2P_PORT=451$((j+1))0 PERSISTENT_PEERS+=$NODE_ID@127.0.0.1:$P2P_PORT # add comma if not last node - if [ "$CURRENT_PEER" != "$((VALIDATORS_COUNT - 1))" ]; then + if [ "$CURRENT_PEER" != "$((VALIDATORS_COUNT-1))" ]; then PERSISTENT_PEERS+="," fi fi diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index 9fe5fe3..fc44ba9 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -13,8 +13,8 @@ INITIAL_BALANCE=${INITIAL_BALANCE:-2000000000000000000000} INITIAL_STAKE=${INITIAL_STAKE:-1000000000000000000000} BLOCK_TIME_SECONDS=${BLOCK_TIME_SECONDS:-2} MAX_GAS=${MAX_GAS:-90000000} -MIN_GAS_PRICE=${MIN_GAS_PRICE:-25000000000} -GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-15} +MIN_GAS_PRICE=${MIN_GAS_PRICE:-400000000000} +GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-604800} GOV_MIN_DEPOSIT=${GOV_MIN_DEPOSIT:-10000000000000000} GOV_MIN_EXPEDITED_DEPOSIT=${GOV_MIN_EXPEDITED_DEPOSIT:-50000000000000000} GOV_MIN_INITIAL_DEPOSIT_RATIO=${GOV_MIN_INITIAL_DEPOSIT_RATIO:-1} @@ -23,8 +23,8 @@ INFLATION_MIN=${INFLATION_MIN:-0.01} GOAL_BONDED=${GOAL_BONDED:-0.6} SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} -MAX_VALIDATORS=${MAX_VALIDATORS:-14} -UNBONDING_TIME=${UNBONDING_TIME:-1814400s} +MAX_VALIDATORS=${MAX_VALIDATORS:-20} +COMMUNITY_TAX=${COMMUNITY_TAX:-0.00} # ports RPC_PORT=${RPC_PORT:-26657} @@ -42,8 +42,8 @@ PROXY_PORT=${PROXY_PORT:-26658} # prompt user for confirmation before cleanup read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm if [[ $confirm != "y" && $confirm != "Y" ]]; then - echo "Cleanup aborted." - exit 1 + echo "Cleanup aborted." + exit 1 fi # cleanup old data @@ -72,7 +72,7 @@ jq ' "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", "storage": [] }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # arachnid (https://github.com/Arachnid/deterministic-deployment-proxy) jq ' @@ -88,7 +88,8 @@ jq ' "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", "storage": [] }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json + # multicall (https://github.com/mds1/multicall3) jq ' @@ -104,7 +105,7 @@ jq ' "code": "6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", "storage": [] }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # createx (https://github.com/pcaversaccio/createx) jq ' @@ -120,7 +121,7 @@ jq ' "code": "60806040526004361061018a5760003560e01c806381503da1116100d6578063d323826a1161007f578063e96deee411610059578063e96deee414610395578063f5745aba146103a8578063f9664498146103bb57600080fd5b8063d323826a1461034f578063ddda0acb1461036f578063e437252a1461038257600080fd5b80639c36a286116100b05780639c36a28614610316578063a7db93f214610329578063c3fe107b1461033c57600080fd5b806381503da1146102d0578063890c283b146102e357806398e810771461030357600080fd5b80632f990e3f116101385780636cec2536116101125780636cec25361461027d57806374637a7a1461029d5780637f565360146102bd57600080fd5b80632f990e3f1461023757806331a7c8c81461024a57806342d654fc1461025d57600080fd5b806327fe18221161016957806327fe1822146101f15780632852527a1461020457806328ddd0461461021757600080fd5b8062d84acb1461018f57806326307668146101cb57806326a32fc7146101de575b600080fd5b6101a261019d366004612915565b6103ce565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6101a26101d9366004612994565b6103e6565b6101a26101ec3660046129db565b610452565b6101a26101ff3660046129db565b6104de565b6101a2610212366004612a39565b610539565b34801561022357600080fd5b506101a2610232366004612a90565b6106fe565b6101a2610245366004612aa9565b61072a565b6101a2610258366004612aa9565b6107bb565b34801561026957600080fd5b506101a2610278366004612b1e565b6107c9565b34801561028957600080fd5b506101a2610298366004612a90565b610823565b3480156102a957600080fd5b506101a26102b8366004612b4a565b61084f565b6101a26102cb3660046129db565b611162565b6101a26102de366004612b74565b6111e8565b3480156102ef57600080fd5b506101a26102fe366004612bac565b611276565b6101a2610311366004612bce565b6112a3565b6101a2610324366004612994565b611505565b6101a2610337366004612c49565b6116f1565b6101a261034a366004612aa9565b611964565b34801561035b57600080fd5b506101a261036a366004612cd9565b6119ed565b6101a261037d366004612c49565b611a17565b6101a2610390366004612bce565b611e0c565b6101a26103a3366004612915565b611e95565b6101a26103b6366004612bce565b611ea4565b6101a26103c9366004612b74565b611f2d565b60006103dd8585858533611a17565b95945050505050565b6000806103f2846120db565b90508083516020850134f59150610408826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a35092915050565b60006104d86104d260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b836103e6565b92915050565b600081516020830134f090506104f3816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a2919050565b600080610545856120db565b905060008460601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f593505073ffffffffffffffffffffffffffffffffffffffff8316610635576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1660048201526024015b60405180910390fd5b604051829073ffffffffffffffffffffffffffffffffffffffff8516907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808473ffffffffffffffffffffffffffffffffffffffff1634876040516106a19190612d29565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b50915091506106f382828961247d565b505050509392505050565b60006104d87f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed8361084f565b60006107b36107aa60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b85858533611a17565b949350505050565b60006107b3848484336112a3565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b60006104d8827f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6107c9565b600060607f9400000000000000000000000000000000000000000000000000000000000000610887600167ffffffffffffffff612d45565b67ffffffffffffffff16841115610902576040517f3c55ab3b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b836000036109c7576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f800000000000000000000000000000000000000000000000000000000000000060368201526037015b6040516020818303038152906040529150611152565b607f8411610a60576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b16602283015260f886901b1660368201526037016109b1565b60ff8411610b1f576040517fd70000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660228301527f8100000000000000000000000000000000000000000000000000000000000000603683015260f886901b1660378201526038016109b1565b61ffff8411610bff576040517fd80000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f820000000000000000000000000000000000000000000000000000000000000060368201527fffff00000000000000000000000000000000000000000000000000000000000060f086901b1660378201526039016109b1565b62ffffff8411610ce0576040517fd90000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f830000000000000000000000000000000000000000000000000000000000000060368201527fffffff000000000000000000000000000000000000000000000000000000000060e886901b166037820152603a016109b1565b63ffffffff8411610dc2576040517fda0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f840000000000000000000000000000000000000000000000000000000000000060368201527fffffffff0000000000000000000000000000000000000000000000000000000060e086901b166037820152603b016109b1565b64ffffffffff8411610ea5576040517fdb0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f850000000000000000000000000000000000000000000000000000000000000060368201527fffffffffff00000000000000000000000000000000000000000000000000000060d886901b166037820152603c016109b1565b65ffffffffffff8411610f89576040517fdc0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f860000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffff000000000000000000000000000000000000000000000000000060d086901b166037820152603d016109b1565b66ffffffffffffff841161106e576040517fdd0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f870000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffff0000000000000000000000000000000000000000000000000060c886901b166037820152603e016109b1565b6040517fde0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f880000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffffff00000000000000000000000000000000000000000000000060c086901b166037820152603f0160405160208183030381529060405291505b5080516020909101209392505050565b60006104d86111e260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b83611505565b600061126f61126860408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b8484610539565b9392505050565b600061126f83837f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6119ed565b60008451602086018451f090506112b9816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808273ffffffffffffffffffffffffffffffffffffffff168560200151876040516113279190612d29565b60006040518083038185875af1925050503d8060008114611364576040519150601f19603f3d011682016040523d82523d6000602084013e611369565b606091505b5091509150816113c9577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1631156114fb578373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611495576040519150601f19603f3d011682016040523d82523d6000602084013e61149a565b606091505b509092509050816114fb577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b5050949350505050565b600080611511846120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff81166115e0576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a361162c83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1634876040516116569190612d29565b60006040518083038185875af1925050503d8060008114611693576040519150601f19603f3d011682016040523d82523d6000602084013e611698565b606091505b505090506116a681866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a25050505092915050565b6000806116fd876120db565b9050808651602088018651f59150611714826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808373ffffffffffffffffffffffffffffffffffffffff168660200151886040516117849190612d29565b60006040518083038185875af1925050503d80600081146117c1576040519150601f19603f3d011682016040523d82523d6000602084013e6117c6565b606091505b509150915081611826577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611958578473ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d80600081146118f2576040519150601f19603f3d011682016040523d82523d6000602084013e6118f7565b606091505b50909250905081611958577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b50505095945050505050565b60006107b36119e460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b858585336116f1565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b600080611a23876120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff8116611af2576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a3611b3e83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1687600001518a604051611b6c9190612d29565b60006040518083038185875af1925050503d8060008114611ba9576040519150601f19603f3d011682016040523d82523d6000602084013e611bae565b606091505b50509050611bbc81866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a260608573ffffffffffffffffffffffffffffffffffffffff1688602001518a604051611c299190612d29565b60006040518083038185875af1925050503d8060008114611c66576040519150601f19603f3d011682016040523d82523d6000602084013e611c6b565b606091505b50909250905081611ccc577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611dfe578673ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611d98576040519150601f19603f3d011682016040523d82523d6000602084013e611d9d565b606091505b50909250905081611dfe577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050505095945050505050565b60006103dd611e8c60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b868686866116f1565b60006103dd85858585336116f1565b60006103dd611f2460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b86868686611a17565b6000808360601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f092505073ffffffffffffffffffffffffffffffffffffffff8216612016576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b60405173ffffffffffffffffffffffffffffffffffffffff8316907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808373ffffffffffffffffffffffffffffffffffffffff1634866040516120809190612d29565b60006040518083038185875af1925050503d80600081146120bd576040519150601f19603f3d011682016040523d82523d6000602084013e6120c2565b606091505b50915091506120d282828861247d565b50505092915050565b60008060006120e9846125b3565b9092509050600082600281111561210257612102612e02565b1480156121205750600081600281111561211e5761211e612e02565b145b1561215e57604080513360208201524691810191909152606081018590526080016040516020818303038152906040528051906020012092506123cc565b600082600281111561217257612172612e02565b1480156121905750600181600281111561218e5761218e612e02565b145b156121b0576121a9338560009182526020526040902090565b92506123cc565b60008260028111156121c4576121c4612e02565b03612233576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b600182600281111561224757612247612e02565b1480156122655750600081600281111561226357612263612e02565b145b1561227e576121a9468560009182526020526040902090565b600182600281111561229257612292612e02565b1480156122b0575060028160028111156122ae576122ae612e02565b145b1561231f576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b61239a60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b84036123a657836123c9565b604080516020810186905201604051602081830303815290604052805190602001205b92505b5050919050565b73ffffffffffffffffffffffffffffffffffffffff8116158061240b575073ffffffffffffffffffffffffffffffffffffffff81163b155b1561247a576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b50565b82158061249f575073ffffffffffffffffffffffffffffffffffffffff81163b155b156124fa577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed826040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050565b811580612520575073ffffffffffffffffffffffffffffffffffffffff8116155b80612540575073ffffffffffffffffffffffffffffffffffffffff81163b155b156125af576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b5050565b600080606083901c3314801561261057508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b1561262057506000905080915091565b606083901c3314801561265a57507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561266b5750600090506001915091565b33606084901c036126825750600090506002915091565b606083901c1580156126db57508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b156126ec5750600190506000915091565b606083901c15801561272557507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561273557506001905080915091565b606083901c61274a5750600190506002915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000036127a55750600290506000915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000036127e15750600290506001915091565b506002905080915091565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261282c57600080fd5b813567ffffffffffffffff80821115612847576128476127ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561288d5761288d6127ec565b816040528381528660208588010111156128a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000604082840312156128d857600080fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb6127ec565b604052823581526020928301359281019290925250919050565b60008060008060a0858703121561292b57600080fd5b84359350602085013567ffffffffffffffff8082111561294a57600080fd5b6129568883890161281b565b9450604087013591508082111561296c57600080fd5b506129798782880161281b565b92505061298986606087016128c6565b905092959194509250565b600080604083850312156129a757600080fd5b82359150602083013567ffffffffffffffff8111156129c557600080fd5b6129d18582860161281b565b9150509250929050565b6000602082840312156129ed57600080fd5b813567ffffffffffffffff811115612a0457600080fd5b6107b38482850161281b565b803573ffffffffffffffffffffffffffffffffffffffff81168114612a3457600080fd5b919050565b600080600060608486031215612a4e57600080fd5b83359250612a5e60208501612a10565b9150604084013567ffffffffffffffff811115612a7a57600080fd5b612a868682870161281b565b9150509250925092565b600060208284031215612aa257600080fd5b5035919050565b600080600060808486031215612abe57600080fd5b833567ffffffffffffffff80821115612ad657600080fd5b612ae28783880161281b565b94506020860135915080821115612af857600080fd5b50612b058682870161281b565b925050612b1585604086016128c6565b90509250925092565b60008060408385031215612b3157600080fd5b82359150612b4160208401612a10565b90509250929050565b60008060408385031215612b5d57600080fd5b612b6683612a10565b946020939093013593505050565b60008060408385031215612b8757600080fd5b612b9083612a10565b9150602083013567ffffffffffffffff8111156129c557600080fd5b60008060408385031215612bbf57600080fd5b50508035926020909101359150565b60008060008060a08587031215612be457600080fd5b843567ffffffffffffffff80821115612bfc57600080fd5b612c088883890161281b565b95506020870135915080821115612c1e57600080fd5b50612c2b8782880161281b565b935050612c3b86604087016128c6565b915061298960808601612a10565b600080600080600060c08688031215612c6157600080fd5b85359450602086013567ffffffffffffffff80821115612c8057600080fd5b612c8c89838a0161281b565b95506040880135915080821115612ca257600080fd5b50612caf8882890161281b565b935050612cbf87606088016128c6565b9150612ccd60a08701612a10565b90509295509295909350565b600080600060608486031215612cee57600080fd5b8335925060208401359150612b1560408501612a10565b60005b83811015612d20578181015183820152602001612d08565b50506000910152565b60008251612d3b818460208701612d05565b9190910192915050565b67ffffffffffffffff828116828216039080821115612d8d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260008251806040840152612dcf816060850160208701612d05565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea164736f6c6343000817000a", "storage": [] }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # edit configs @@ -128,8 +129,8 @@ jq ' # get ethereum chain id from CHAIN_ID EVM_CHAIN_ID=$(echo $CHAIN_ID | sed -E 's/.*_([0-9]+)-.*/\1/') if [[ -z $EVM_CHAIN_ID ]]; then - echo "Invalid CHAIN_ID format. Expected format: _-" - exit 1 + echo "Invalid CHAIN_ID format. Expected format: _-" + exit 1 fi sed -i.bak "s/\"chain_id\": \"262144\"/\"chain_id\": \"$EVM_CHAIN_ID\"/g" $HOMEDIR/config/genesis.json @@ -177,7 +178,7 @@ jq --arg GOV_MIN_DEPOSIT "$GOV_MIN_DEPOSIT" ' "amount": $GOV_MIN_DEPOSIT } ] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # set min expedited gov deposit jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' @@ -187,7 +188,7 @@ jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' "amount": $GOV_MIN_EXPEDITED_DEPOSIT } ] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # enable apis sed -i.bak "s/enable = false/enable = true/g" $HOMEDIR/config/app.toml @@ -224,7 +225,7 @@ jq ' "uri_hash": "" } ] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json +' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json jq ' .app_state.erc20 = { @@ -278,6 +279,9 @@ sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_ # set max validators sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json +# set community tax +sed -i.bak "s/\"community_tax\": \"0.020000000000000000\"/\"community_tax\": \"$COMMUNITY_TAX\"/g" $HOMEDIR/config/genesis.json + # set ports sed -i.bak "s/26657/$RPC_PORT/g" $HOMEDIR/config/config.toml sed -i.bak "s/26656/$P2P_PORT/g" $HOMEDIR/config/config.toml diff --git a/contrib/localnet/start.sh b/contrib/localnet/start.sh index acd3d4f..342a593 100755 --- a/contrib/localnet/start.sh +++ b/contrib/localnet/start.sh @@ -4,25 +4,4 @@ CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} TACCHAIND=${TACCHAIND:-$(which tacchaind)} HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} -P2P_LADDR=${P2P_LADDR:-tcp://0.0.0.0:26656} -P2P_EXTERNAL_ADDRESS=${P2P_EXTERNAL_ADDRESS:-${P2P_LADDR}} -RPC_LADDR=${RPC_LADDR:-tcp://127.0.0.1:26657} -JSON_RPC_ADDR=${JSON_RPC_ADDR:-127.0.0.1:8545} -JSON_RPC_WS_ADDR=${JSON_RPC_WS_ADDR:-127.0.0.1:8546} -GRPC_LADDR=${GRPC_LADDR:-0.0.0.0:9090} - -sed -i.bak -E 's@(address = "tcp://)[^:/]+(:[0-9]+")@\10.0.0.0\2@g' "$HOMEDIR/config/app.toml" - -$TACCHAIND start --chain-id $CHAIN_ID \ - --home $HOMEDIR \ - --p2p.laddr $P2P_LADDR \ - --p2p.external-address $P2P_EXTERNAL_ADDRESS \ - --rpc.laddr $RPC_LADDR \ - --json-rpc.address $JSON_RPC_ADDR \ - --json-rpc.ws-address $JSON_RPC_WS_ADDR \ - --json-rpc.enable \ - --grpc.address $GRPC_LADDR \ - --grpc.enable=true \ - --api.enable=true \ - --api.enabled-unsafe-cors \ - --home $HOMEDIR +$TACCHAIND start --chain-id $CHAIN_ID --home $HOMEDIR diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yml index 1dfa0e6..2cb8500 100644 --- a/networks/tacchain_2391-1/docker-compose.yml +++ b/networks/tacchain_2391-1/docker-compose.yml @@ -36,4 +36,3 @@ services: --rpc.laddr=tcp://0.0.0.0:${RPC_PORT} --json-rpc.address=0.0.0.0:${RPC_PORT_EVM} --json-rpc.ws-address=0.0.0.0:${WS_PORT_EVM} - --json-rpc.enable From 5bced5551f29214b86ad134e3731b1fbd2019b03 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 18 Sep 2025 15:49:50 +0300 Subject: [PATCH 095/112] Prepare for proposal: restore original params: inflation, gov proposal time and etc.. --- app/app.go | 2 +- contrib/localnet/init-multi-node.sh | 9 ++++----- contrib/localnet/init.sh | 10 +++------- .../{docker-compose.yml => docker-compose.yaml} | 0 4 files changed, 8 insertions(+), 13 deletions(-) rename networks/tacchain_2391-1/{docker-compose.yml => docker-compose.yaml} (100%) diff --git a/app/app.go b/app/app.go index 43e4f0f..52615a5 100644 --- a/app/app.go +++ b/app/app.go @@ -739,7 +739,7 @@ func NewTacChainApp( bank.NewAppModule(encodingConfig.Codec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), feegrantmodule.NewAppModule(encodingConfig.Codec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(encodingConfig.Codec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), - mint.NewAppModule(encodingConfig.Codec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), + mint.NewAppModule(encodingConfig.Codec, app.MintKeeper, app.AccountKeeper, TacZeroInflation, app.GetSubspace(minttypes.ModuleName)), slashing.NewAppModule(encodingConfig.Codec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), distr.NewAppModule(encodingConfig.Codec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(encodingConfig.Codec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), diff --git a/contrib/localnet/init-multi-node.sh b/contrib/localnet/init-multi-node.sh index 1f63c1e..23768b7 100755 --- a/contrib/localnet/init-multi-node.sh +++ b/contrib/localnet/init-multi-node.sh @@ -18,18 +18,17 @@ export GENESIS_ACC_2_ADDRESS=${GENESIS_ACC_2_ADDRESS:-} export INITIAL_SUPPLY=${INITIAL_SUPPLY:-10000000000000000000000000000} export BLOCK_TIME_SECONDS=${BLOCK_TIME_SECONDS:-2} export MAX_GAS=${MAX_GAS:-90000000} -export MIN_GAS_PRICE=${MIN_GAS_PRICE:-400000000000} -export GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-604800} +export MIN_GAS_PRICE=${MIN_GAS_PRICE:-25000000000} +export GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-43200} export GOV_MIN_DEPOSIT=${GOV_MIN_DEPOSIT:-10000000000000000} export GOV_MIN_EXPEDITED_DEPOSIT=${GOV_MIN_EXPEDITED_DEPOSIT:-50000000000000000} export GOV_MIN_INITIAL_DEPOSIT_RATIO=${GOV_MIN_INITIAL_DEPOSIT_RATIO:-1} export INFLATION_MAX=${INFLATION_MAX:-0.05} -export INFLATION_MIN=${INFLATION_MIN:-0.01} +export INFLATION_MIN=${INFLATION_MIN:-0} export GOAL_BONDED=${GOAL_BONDED:-0.6} export SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} export SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} -export MAX_VALIDATORS=${MAX_VALIDATORS:-20} -export COMMUNITY_TAX=${COMMUNITY_TAX:-0.00} +export MAX_VALIDATORS=${MAX_VALIDATORS:-14} # prompt user for confirmation before cleanup diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index fc44ba9..acb4d0e 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -13,8 +13,8 @@ INITIAL_BALANCE=${INITIAL_BALANCE:-2000000000000000000000} INITIAL_STAKE=${INITIAL_STAKE:-1000000000000000000000} BLOCK_TIME_SECONDS=${BLOCK_TIME_SECONDS:-2} MAX_GAS=${MAX_GAS:-90000000} -MIN_GAS_PRICE=${MIN_GAS_PRICE:-400000000000} -GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-604800} +MIN_GAS_PRICE=${MIN_GAS_PRICE:-25000000000} +GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-900} GOV_MIN_DEPOSIT=${GOV_MIN_DEPOSIT:-10000000000000000} GOV_MIN_EXPEDITED_DEPOSIT=${GOV_MIN_EXPEDITED_DEPOSIT:-50000000000000000} GOV_MIN_INITIAL_DEPOSIT_RATIO=${GOV_MIN_INITIAL_DEPOSIT_RATIO:-1} @@ -23,8 +23,7 @@ INFLATION_MIN=${INFLATION_MIN:-0.01} GOAL_BONDED=${GOAL_BONDED:-0.6} SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} -MAX_VALIDATORS=${MAX_VALIDATORS:-20} -COMMUNITY_TAX=${COMMUNITY_TAX:-0.00} +MAX_VALIDATORS=${MAX_VALIDATORS:-14} # ports RPC_PORT=${RPC_PORT:-26657} @@ -279,9 +278,6 @@ sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_ # set max validators sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json -# set community tax -sed -i.bak "s/\"community_tax\": \"0.020000000000000000\"/\"community_tax\": \"$COMMUNITY_TAX\"/g" $HOMEDIR/config/genesis.json - # set ports sed -i.bak "s/26657/$RPC_PORT/g" $HOMEDIR/config/config.toml sed -i.bak "s/26656/$P2P_PORT/g" $HOMEDIR/config/config.toml diff --git a/networks/tacchain_2391-1/docker-compose.yml b/networks/tacchain_2391-1/docker-compose.yaml similarity index 100% rename from networks/tacchain_2391-1/docker-compose.yml rename to networks/tacchain_2391-1/docker-compose.yaml From 593e799eaec75279aa25ade3026a1e560910149b Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 18 Sep 2025 16:30:27 +0300 Subject: [PATCH 096/112] Prepare for proposal: fix, get back nescessary changes --- contrib/localnet/init-multi-node.sh | 2 +- contrib/localnet/init.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/localnet/init-multi-node.sh b/contrib/localnet/init-multi-node.sh index 23768b7..c90bfb1 100755 --- a/contrib/localnet/init-multi-node.sh +++ b/contrib/localnet/init-multi-node.sh @@ -90,7 +90,7 @@ for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do export VALIDATOR_MNEMONIC="${!mnemonic_var}" # call init.sh script to initialize the node - echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init.sh + echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init-liquidstake-for-multinode.sh # explicitly add balances to first node(node0) which will be used to collect gentxs later ADDRESS=$($TACCHAIND keys show validator --keyring-backend $KEYRING_BACKEND --home $NODEDIR -a) diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index acb4d0e..ff88c7d 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -273,8 +273,6 @@ jq ' } ' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json -sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_TIME\"/g" $HOMEDIR/config/genesis.json - # set max validators sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json From bddba5947e6f84b5989044e55afc70916a0bca54 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Wed, 17 Sep 2025 15:44:16 +0300 Subject: [PATCH 097/112] Prepare proposal --- app/upgrades.go | 6 +- app/upgrades/liquidstake/constants.go | 30 ++++++ app/upgrades/liquidstake/upgrades.go | 32 +++++- app/upgrades/types.go | 6 +- proposals/liquidstake_upgrade/README.md | 9 ++ .../liquidstake_upgrade/example_step_1.json | 19 ++++ .../liquidstake_upgrade/example_step_2.json | 98 +++++++++++++++++++ utils/eth.go | 14 +++ 8 files changed, 209 insertions(+), 5 deletions(-) create mode 100644 app/upgrades/liquidstake/constants.go create mode 100644 proposals/liquidstake_upgrade/README.md create mode 100644 proposals/liquidstake_upgrade/example_step_1.json create mode 100644 proposals/liquidstake_upgrade/example_step_2.json create mode 100644 utils/eth.go diff --git a/app/upgrades.go b/app/upgrades.go index f3f2701..d7f7f84 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -6,10 +6,10 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/Asphere-xyz/tacchain/app/upgrades" + liquidstake_upgrade "github.com/Asphere-xyz/tacchain/app/upgrades/liquidstake" v0010 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.10" v0011 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.11" v009 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.9" - liquidstake_upgrade "github.com/Asphere-xyz/tacchain/app/upgrades/liquidstake" ) // Upgrades list of chain upgrades @@ -30,7 +30,9 @@ func (app *TacChainApp) RegisterUpgradeHandlers() { IBCKeeper: app.IBCKeeper, Codec: app.appCodec, GetStoreKey: app.GetKey, - LiquidsStakeKeeper: &app.LiquidStakeKeeper, + LiquidStakeKeeper: &app.LiquidStakeKeeper, + BankKeeper: app.BankKeeper, + Erc20Keeper: &app.Erc20Keeper, } app.GetStoreKeys() // register all upgrade handlers diff --git a/app/upgrades/liquidstake/constants.go b/app/upgrades/liquidstake/constants.go new file mode 100644 index 0000000..1acd72a --- /dev/null +++ b/app/upgrades/liquidstake/constants.go @@ -0,0 +1,30 @@ +package liquidstake_upgrade + +import ( + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +const ( + LsmBondDenom = "stk/utac" + DisplayDenom = "gTAC" +) + +var GTACMetadata = banktypes.Metadata{ + Description: "Liquid Staked TAC token", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: LsmBondDenom, + Exponent: 0, + }, + { + Denom: DisplayDenom, + Exponent: 18, + }, + }, + Base: LsmBondDenom, + Display: DisplayDenom, + Name: "Gravity TAC", + Symbol: "gTAC", + URI: "", + URIHash: "", +} diff --git a/app/upgrades/liquidstake/upgrades.go b/app/upgrades/liquidstake/upgrades.go index c3a59b8..cab6192 100644 --- a/app/upgrades/liquidstake/upgrades.go +++ b/app/upgrades/liquidstake/upgrades.go @@ -7,7 +7,10 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/Asphere-xyz/tacchain/app/upgrades" + "github.com/Asphere-xyz/tacchain/utils" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + evmerc20types "github.com/cosmos/evm/x/erc20/types" ) // UpgradeName defines the on-chain upgrade name @@ -17,7 +20,7 @@ var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, StoreUpgrades: storetypes.StoreUpgrades{ - Added: []string{"utacliquidstake"}, + Added: []string{"utacliquidstake", "epochs"}, Deleted: []string{}, }, } @@ -28,6 +31,31 @@ func CreateUpgradeHandler( ak *upgrades.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - return mm.RunMigrations(ctx, configurator, fromVM) + newVM, err := mm.RunMigrations(ctx, configurator, fromVM) + if err != nil { + return newVM, err + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + // Register gTAC token pair + lsmBondDenom := ak.LiquidStakeKeeper.LiquidBondDenom(sdkCtx) + lsmBondCommonAddress, err := utils.GenerateAddressFromDenom(lsmBondDenom) + if err != nil { + return newVM, err + } + ak.BankKeeper.SetDenomMetaData(ctx, GTACMetadata) + + erc20Params := ak.Erc20Keeper.GetParams(sdkCtx) + erc20Params.NativePrecompiles = append(erc20Params.NativePrecompiles, lsmBondCommonAddress.String()) + if err := ak.Erc20Keeper.SetParams(sdkCtx, erc20Params); err != nil { + return newVM, err + } + + lsmTokenPair := evmerc20types.NewTokenPair(lsmBondCommonAddress, lsmBondDenom, evmerc20types.OWNER_MODULE) + + ak.Erc20Keeper.SetToken(sdkCtx, lsmTokenPair) + + return newVM, nil } } diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 8b498f7..b40b013 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -15,6 +15,8 @@ import ( consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + evmerc20keeper "github.com/cosmos/evm/x/erc20/keeper" liquidstakekeeper "github.com/cosmos/evm/x/liquidstake/keeper" ) @@ -26,7 +28,9 @@ type AppKeepers struct { GetStoreKey func(storeKey string) *storetypes.KVStoreKey CapabilityKeeper *capabilitykeeper.Keeper IBCKeeper *ibckeeper.Keeper - LiquidsStakeKeeper *liquidstakekeeper.Keeper + LiquidStakeKeeper *liquidstakekeeper.Keeper + BankKeeper bankkeeper.Keeper + Erc20Keeper *evmerc20keeper.Keeper } type ModuleManager interface { diff --git a/proposals/liquidstake_upgrade/README.md b/proposals/liquidstake_upgrade/README.md new file mode 100644 index 0000000..a04da9c --- /dev/null +++ b/proposals/liquidstake_upgrade/README.md @@ -0,0 +1,9 @@ +## Liquidstake upgrade + +**Steps:** +1. **Send gov tx to upgrade binary** + + [Localnet example](./example_step_1.json) +2. **Send gov tx to update module params** + + [Localnet example](./example_step_2.json) diff --git a/proposals/liquidstake_upgrade/example_step_1.json b/proposals/liquidstake_upgrade/example_step_1.json new file mode 100644 index 0000000..8239b58 --- /dev/null +++ b/proposals/liquidstake_upgrade/example_step_1.json @@ -0,0 +1,19 @@ +{ + "messages": [ + { + "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + "authority": "tac10d07y265gmmuvt4z0w9aw880jnsr700jlgpywe", + "plan": { + "name": "liquidstake", + "height": "50", + "info": "Liquidstake module implementation", + "upgraded_client_state": null + } + } + ], + "metadata": "", + "deposit": "1000000000000000000utac", + "title": "Liquidstake upgrade", + "summary": "Liquidstake implementation", + "expedited": false +} diff --git a/proposals/liquidstake_upgrade/example_step_2.json b/proposals/liquidstake_upgrade/example_step_2.json new file mode 100644 index 0000000..fa9dffd --- /dev/null +++ b/proposals/liquidstake_upgrade/example_step_2.json @@ -0,0 +1,98 @@ +{ + "messages": [ + { + "@type": "/tac.liquidstake.v1beta1.MsgUpdateParams", + "authority": "tac10d07y265gmmuvt4z0w9aw880jnsr700jlgpywe", + "params": { + "liquid_bond_denom": "stk/utac", + "unstake_fee_rate": "0.000000000000000000", + "lsm_disabled": true, + "min_liquid_stake_amount": "1000", + "cw_locked_pool_address": "", + "fee_account_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", + "autocompound_fee_rate": "0.050000000000000000", + "whitelist_admin_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj" + } + }, + { + "@type": "/tac.liquidstake.v1beta1.MsgUpdateWhitelistedValidators", + "authority": "tac10d07y265gmmuvt4z0w9aw880jnsr700jlgpywe", + "whitelisted_validators": [ + { + "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", + "target_weight": "10000" + } + ] + }, + { + "@type": "/tac.liquidstake.v1beta1.MsgSetModulePaused", + "authority": "tac10d07y265gmmuvt4z0w9aw880jnsr700jlgpywe", + "is_paused": false + }, + { + "@type": "/cosmos.evm.vm.v1.MsgUpdateParams", + "authority": "tac10d07y265gmmuvt4z0w9aw880jnsr700jlgpywe", + "params": { + "evm_denom": "utac", + "extra_eips": [ + "3855" + ], + "chain_config": { + "homestead_block": "0", + "dao_fork_block": "0", + "dao_fork_support": true, + "eip150_block": "0", + "eip155_block": "0", + "eip158_block": "0", + "byzantium_block": "0", + "constantinople_block": "0", + "petersburg_block": "0", + "istanbul_block": "0", + "muir_glacier_block": "0", + "berlin_block": "0", + "london_block": "0", + "arrow_glacier_block": "0", + "gray_glacier_block": "0", + "merge_netsplit_block": "0", + "chain_id": "2391", + "denom": "utac", + "decimals": "18", + "shanghai_time": "0", + "cancun_time": "0", + "prague_time": null, + "verkle_time": null + }, + "allow_unprotected_txs": true, + "evm_channels": [], + "access_control": { + "create": { + "access_type": "ACCESS_TYPE_PERMISSIONLESS", + "access_control_list": [] + }, + "call": { + "access_type": "ACCESS_TYPE_PERMISSIONLESS", + "access_control_list": [] + } + }, + "active_static_precompiles": [ + "0x0000000000000000000000000000000000000100", + "0x0000000000000000000000000000000000000400", + "0x0000000000000000000000000000000000000800", + "0x0000000000000000000000000000000000000801", + "0x0000000000000000000000000000000000000802", + "0x0000000000000000000000000000000000000803", + "0x0000000000000000000000000000000000000804", + "0x0000000000000000000000000000000000000805", + "0x0000000000000000000000000000000000000806", + "0x0000000000000000000000000000000000000807", + "0x0000000000000000000000000000000000001600" + ] + } + } + ], + "metadata": "", + "deposit": "1000000000000000000utac", + "title": "Update Liquidstake params", + "summary": "Liquidstake params", + "expedited": false +} diff --git a/utils/eth.go b/utils/eth.go new file mode 100644 index 0000000..b425fc4 --- /dev/null +++ b/utils/eth.go @@ -0,0 +1,14 @@ +package utils + +import ( + "github.com/ethereum/go-ethereum/common" + "golang.org/x/crypto/sha3" +) + +func GenerateAddressFromDenom(denom string) (common.Address, error) { + hash := sha3.NewLegacyKeccak256() + if _, err := hash.Write([]byte(denom)); err != nil { + return common.Address{}, err + } + return common.BytesToAddress(hash.Sum(nil)), nil +} From 884c4219cc29e2812e72c2e55cbb4052ac4088ca Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Wed, 17 Sep 2025 15:48:16 +0300 Subject: [PATCH 098/112] Sync with BeginBlock fix --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 964a68a..4e7d470 100644 --- a/go.mod +++ b/go.mod @@ -239,7 +239,7 @@ require ( go.opentelemetry.io/otel/trace v1.32.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.32.0 // indirect + golang.org/x/crypto v0.32.0 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect @@ -280,7 +280,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 // replace cosmos evm with our fork that uses geth v1.13.15 - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250825121004-d13becaea1f2 + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250827171739-f11252f3e578 // Cosmos geth fork // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index 4880887..4b5cd1c 100644 --- a/go.sum +++ b/go.sum @@ -1006,8 +1006,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250825121004-d13becaea1f2 h1:hfbYCYu3WFrabZIY0/rsZmq5syG8KvBfnvwyLUseEWg= -github.com/pixelplex/tac-evm v0.0.0-20250825121004-d13becaea1f2/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= +github.com/pixelplex/tac-evm v0.0.0-20250827171739-f11252f3e578 h1:Jg95biaH+kqjjZynOKyKbQkV3N6jmhoP42FD3/MRU3g= +github.com/pixelplex/tac-evm v0.0.0-20250827171739-f11252f3e578/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 497417ae62bd412e92a632b99757ebc6353c33b3 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Thu, 18 Sep 2025 19:21:18 +0300 Subject: [PATCH 099/112] Prepare proposal: minimize Dockerfile --- Dockerfile | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1768eb5..e677655 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,49 +3,28 @@ FROM golang:1.23.8-bookworm AS go-builder -# Install build dependencies RUN apt-get update && apt-get install -y \ ca-certificates \ build-essential \ - git \ - curl \ - wget \ libusb-1.0-0-dev \ libc6 \ - pkg-config \ && rm -rf /var/lib/apt/lists/* WORKDIR /code - -# Download go modules -COPY go.mod go.sum /code/ -RUN go mod download - COPY . /code/ -# force it to use static lib (from above) not standard libgo_cosmwasm.so file -RUN make build +RUN LEDGER_ENABLED=true make build -FROM ubuntu:22.04 -COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind -# To run a localnet -------------------------------------- -COPY --from=go-builder /code/contrib/localnet/init.sh /scripts/init.sh -COPY --from=go-builder /code/contrib/localnet/init-multi-node.sh /scripts/init-multi-node.sh -COPY --from=go-builder /code/contrib/localnet/start.sh /scripts/start.sh -COPY --from=go-builder /code/contrib/localnet/init-liquidstake-for-multinode.sh /scripts/init-liquidstake-for-multinode.sh -RUN chmod +x /scripts/*.sh +# -------------------------------------------------------- +FROM debian:bookworm-slim -RUN apt-get update && apt-get install -y \ - wget \ - jq \ - bc \ - && rm -rf /var/lib/apt/lists/* +COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.2.1/libwasmvm.x86_64.so RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.1.0/libwasmvm.aarch64.so -WORKDIR /scripts +WORKDIR /opt # rest server EXPOSE 1317 @@ -53,8 +32,5 @@ EXPOSE 1317 EXPOSE 26656 # tendermint rpc EXPOSE 26657 -# grpc -EXPOSE 9090 CMD ["/usr/bin/tacchaind", "version"] - From 4e774f874930993df19bcbc07cc487f5060b5e8e Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 19 Sep 2025 17:59:50 +0300 Subject: [PATCH 100/112] sync with full wasm removal --- Dockerfile | 3 --- go.mod | 10 ++-------- go.sum | 12 ++---------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index e677655..71c692e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,9 +21,6 @@ FROM debian:bookworm-slim COPY --from=go-builder /code/build/tacchaind /usr/bin/tacchaind -RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.2.1/libwasmvm.x86_64.so -RUN wget -P /usr/lib https://github.com/CosmWasm/wasmvm/releases/download/v2.1.0/libwasmvm.aarch64.so - WORKDIR /opt # rest server diff --git a/go.mod b/go.mod index d617e3f..1c2e3ff 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/nft v0.1.1 cosmossdk.io/x/upgrade v0.1.4 - github.com/CosmWasm/wasmd v0.53.0 // indirect github.com/cometbft/cometbft v0.38.17 github.com/cosmos/cosmos-db v1.1.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect @@ -55,7 +54,6 @@ require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect - github.com/CosmWasm/wasmvm/v2 v2.1.2 // indirect github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect @@ -104,7 +102,6 @@ require ( github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/distribution/reference v0.5.0 // indirect github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -190,7 +187,6 @@ require ( github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -207,7 +203,6 @@ require ( github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect - github.com/shamaton/msgpack/v2 v2.2.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect @@ -240,7 +235,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.32.0 - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.10.0 // indirect @@ -280,8 +275,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 // replace cosmos evm with our fork that uses geth v1.13.15 - - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250827171739-f11252f3e578 + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250919142836-b0364d6ecb2b // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index 4b5cd1c..8005657 100644 --- a/go.sum +++ b/go.sum @@ -227,10 +227,6 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CosmWasm/wasmd v0.53.0 h1:kdaoAi20bIb4VCsxw9pRaT2g5PpIp82Wqrr9DRVN9ao= -github.com/CosmWasm/wasmd v0.53.0/go.mod h1:FJl/aWjdpGof3usAMFQpDe07Rkx77PUzp0cygFMOvtw= -github.com/CosmWasm/wasmvm/v2 v2.1.2 h1:GkJ5bAsRlLHfIQVg/FY1VHwLyBwlCjAhDea0B8L+e20= -github.com/CosmWasm/wasmvm/v2 v2.1.2/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -469,8 +465,6 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= -github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= @@ -1006,8 +1000,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250827171739-f11252f3e578 h1:Jg95biaH+kqjjZynOKyKbQkV3N6jmhoP42FD3/MRU3g= -github.com/pixelplex/tac-evm v0.0.0-20250827171739-f11252f3e578/go.mod h1:77axzyUhE01IZ8tdWqxnM4AAEEWYNLL0XIck+GxFjo0= +github.com/pixelplex/tac-evm v0.0.0-20250919142836-b0364d6ecb2b h1:JQpzj81UioorLQxQ+O/UYykHfa4Gt+nEKcXmEZbLoBQ= +github.com/pixelplex/tac-evm v0.0.0-20250919142836-b0364d6ecb2b/go.mod h1:Xi9Qx7pYEP/O9VKXGN9d0JO0CFTGqN2zeLIK/cG+0Pg= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1080,8 +1074,6 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shamaton/msgpack/v2 v2.2.0 h1:IP1m01pHwCrMa6ZccP9B3bqxEMKMSmMVAVKk54g3L/Y= -github.com/shamaton/msgpack/v2 v2.2.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= From e2943da33aae54ad2d7d1399009b937e033fe2b3 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Tue, 23 Sep 2025 13:37:31 +0300 Subject: [PATCH 101/112] Prepare for proposal: Sync with test fixes in cosmos sdk --- go.mod | 8 ++++---- go.sum | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 1c2e3ff..d458bb9 100644 --- a/go.mod +++ b/go.mod @@ -270,12 +270,12 @@ replace ( // Pin this pebble version to avoid breaking compilation of geth github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 - // // use Cosmos-SDK fork to enable Ledger functionality - // github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.13-0.20250319183239-53dea340efc7 - github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 + // use Cosmos-SDK fork to enable Ledger functionality + // github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 + github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250923060405-c21481273142 // replace cosmos evm with our fork that uses geth v1.13.15 - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250919142836-b0364d6ecb2b + github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250923102517-6db6fc37344d // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index 8005657..2d04a29 100644 --- a/go.sum +++ b/go.sum @@ -998,10 +998,10 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 h1:+Cu+JF0lv1rFm6zuA67I4ZUwgP/e1inhGOo4ut3AP48= -github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250919142836-b0364d6ecb2b h1:JQpzj81UioorLQxQ+O/UYykHfa4Gt+nEKcXmEZbLoBQ= -github.com/pixelplex/tac-evm v0.0.0-20250919142836-b0364d6ecb2b/go.mod h1:Xi9Qx7pYEP/O9VKXGN9d0JO0CFTGqN2zeLIK/cG+0Pg= +github.com/pixelplex/cosmos-sdk v0.0.0-20250923060405-c21481273142 h1:5S5q6FxGvYeYlUDnX53f4HMv8+BtA8xQTa5a73xo76Y= +github.com/pixelplex/cosmos-sdk v0.0.0-20250923060405-c21481273142/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= +github.com/pixelplex/tac-evm v0.0.0-20250923102517-6db6fc37344d h1:hb00/R0rfW4cG22K9xphVKxQ9NJ8n70uqcEA1OOGIZU= +github.com/pixelplex/tac-evm v0.0.0-20250923102517-6db6fc37344d/go.mod h1:ihd//209sPigk6sFp7nTkBjzNNUJvj/JKJtoXebKIDU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From d0e679d4aa0ecf1f7df81f00171b2505692f31d2 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 16:34:57 +0300 Subject: [PATCH 102/112] fix: go mod indirect ordering --- go.mod | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index d458bb9..49bd002 100644 --- a/go.mod +++ b/go.mod @@ -19,24 +19,17 @@ require ( cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v0.38.17 github.com/cosmos/cosmos-db v1.1.1 - github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/cosmos-sdk v0.50.13 github.com/cosmos/evm v0.1.1-0.20250328143818-59c573a37f8b github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/ethereum/go-ethereum v1.15.5 - github.com/golang/protobuf v1.5.4 // indirect - github.com/gorilla/mux v1.8.1 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/onsi/ginkgo/v2 v2.22.2 github.com/onsi/gomega v1.36.2 github.com/spf13/cast v1.7.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 - google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a // indirect - google.golang.org/grpc v1.70.0 // indirect - google.golang.org/protobuf v1.36.5 // indirect ) require github.com/cosmos/ibc-go/v8 v8.7.0 @@ -86,6 +79,7 @@ require ( github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect + github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.4 // indirect @@ -129,6 +123,7 @@ require ( github.com/golang/glog v1.2.4 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.3 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect @@ -140,8 +135,10 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.5 // indirect github.com/gorilla/handlers v1.5.2 // indirect + github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.5 // indirect @@ -246,7 +243,10 @@ require ( golang.org/x/tools v0.28.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect + google.golang.org/grpc v1.70.0 // indirect + google.golang.org/protobuf v1.36.5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect From 2b805023e6437e53fea73cb7089d0ef946a18ebb Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 16:39:51 +0300 Subject: [PATCH 103/112] fix: v101 upgrade handler restore --- app/upgrades.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/upgrades.go b/app/upgrades.go index d7f7f84..290e337 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -10,6 +10,7 @@ import ( v0010 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.10" v0011 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.11" v009 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.9" + v101 "github.com/Asphere-xyz/tacchain/app/upgrades/v1.0.1" ) // Upgrades list of chain upgrades @@ -17,6 +18,7 @@ var Upgrades = []upgrades.Upgrade{ v009.Upgrade, v0010.Upgrade, v0011.Upgrade, + v101.Upgrade, liquidstake_upgrade.Upgrade, } From 5a489803dd2fb8b6271b66bc0c0f3dbb620d8e7e Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 16:45:52 +0300 Subject: [PATCH 104/112] fix: go.mod ibc-go requrie section --- go.mod | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 49bd002..e03844d 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,7 @@ require ( github.com/cosmos/evm v0.1.1-0.20250328143818-59c573a37f8b github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 + github.com/cosmos/ibc-go/v8 v8.7.0 github.com/ethereum/go-ethereum v1.15.5 github.com/onsi/ginkgo/v2 v2.22.2 github.com/onsi/gomega v1.36.2 @@ -32,8 +33,6 @@ require ( github.com/stretchr/testify v1.10.0 ) -require github.com/cosmos/ibc-go/v8 v8.7.0 - require ( cloud.google.com/go v0.115.0 // indirect cloud.google.com/go/auth v0.6.0 // indirect From a58ffdac27197d9871cdd440ddb32c9783be155f Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 17:04:28 +0300 Subject: [PATCH 105/112] fix: upgrade name to versioning convention --- app/upgrades.go | 4 ++-- .../{liquidstake => v1.0.2}/constants.go | 4 +++- .../{liquidstake => v1.0.2}/upgrades.go | 21 +++++++++++++++---- .../liquidstake_upgrade/example_step_1.json | 2 +- utils/eth.go | 14 ------------- 5 files changed, 23 insertions(+), 22 deletions(-) rename app/upgrades/{liquidstake => v1.0.2}/constants.go (88%) rename app/upgrades/{liquidstake => v1.0.2}/upgrades.go (77%) delete mode 100644 utils/eth.go diff --git a/app/upgrades.go b/app/upgrades.go index 290e337..54a4c99 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -6,11 +6,11 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/Asphere-xyz/tacchain/app/upgrades" - liquidstake_upgrade "github.com/Asphere-xyz/tacchain/app/upgrades/liquidstake" v0010 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.10" v0011 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.11" v009 "github.com/Asphere-xyz/tacchain/app/upgrades/v0.0.9" v101 "github.com/Asphere-xyz/tacchain/app/upgrades/v1.0.1" + v102 "github.com/Asphere-xyz/tacchain/app/upgrades/v1.0.2" ) // Upgrades list of chain upgrades @@ -19,7 +19,7 @@ var Upgrades = []upgrades.Upgrade{ v0010.Upgrade, v0011.Upgrade, v101.Upgrade, - liquidstake_upgrade.Upgrade, + v102.Upgrade, // liquid stake } // RegisterUpgradeHandlers registers the chain upgrade handlers diff --git a/app/upgrades/liquidstake/constants.go b/app/upgrades/v1.0.2/constants.go similarity index 88% rename from app/upgrades/liquidstake/constants.go rename to app/upgrades/v1.0.2/constants.go index 1acd72a..6b2cb23 100644 --- a/app/upgrades/liquidstake/constants.go +++ b/app/upgrades/v1.0.2/constants.go @@ -1,4 +1,6 @@ -package liquidstake_upgrade +package v102 + +// Upgrade for implementing liquid stake module import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/app/upgrades/liquidstake/upgrades.go b/app/upgrades/v1.0.2/upgrades.go similarity index 77% rename from app/upgrades/liquidstake/upgrades.go rename to app/upgrades/v1.0.2/upgrades.go index cab6192..2e1df16 100644 --- a/app/upgrades/liquidstake/upgrades.go +++ b/app/upgrades/v1.0.2/upgrades.go @@ -1,4 +1,6 @@ -package liquidstake_upgrade +package v102 + +// Upgrade for implementing liquid stake module import ( "context" @@ -7,14 +9,17 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/Asphere-xyz/tacchain/app/upgrades" - "github.com/Asphere-xyz/tacchain/utils" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" evmerc20types "github.com/cosmos/evm/x/erc20/types" + + "github.com/ethereum/go-ethereum/common" + "golang.org/x/crypto/sha3" + ) // UpgradeName defines the on-chain upgrade name -const UpgradeName = "liquidstake" +const UpgradeName = "v1.0.2" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, @@ -25,6 +30,14 @@ var Upgrade = upgrades.Upgrade{ }, } +func generateAddressFromDenom(denom string) (common.Address, error) { + hash := sha3.NewLegacyKeccak256() + if _, err := hash.Write([]byte(denom)); err != nil { + return common.Address{}, err + } + return common.BytesToAddress(hash.Sum(nil)), nil +} + func CreateUpgradeHandler( mm upgrades.ModuleManager, configurator module.Configurator, @@ -40,7 +53,7 @@ func CreateUpgradeHandler( // Register gTAC token pair lsmBondDenom := ak.LiquidStakeKeeper.LiquidBondDenom(sdkCtx) - lsmBondCommonAddress, err := utils.GenerateAddressFromDenom(lsmBondDenom) + lsmBondCommonAddress, err := generateAddressFromDenom(lsmBondDenom) if err != nil { return newVM, err } diff --git a/proposals/liquidstake_upgrade/example_step_1.json b/proposals/liquidstake_upgrade/example_step_1.json index 8239b58..b4bb053 100644 --- a/proposals/liquidstake_upgrade/example_step_1.json +++ b/proposals/liquidstake_upgrade/example_step_1.json @@ -4,7 +4,7 @@ "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", "authority": "tac10d07y265gmmuvt4z0w9aw880jnsr700jlgpywe", "plan": { - "name": "liquidstake", + "name": "v1.0.2", "height": "50", "info": "Liquidstake module implementation", "upgraded_client_state": null diff --git a/utils/eth.go b/utils/eth.go deleted file mode 100644 index b425fc4..0000000 --- a/utils/eth.go +++ /dev/null @@ -1,14 +0,0 @@ -package utils - -import ( - "github.com/ethereum/go-ethereum/common" - "golang.org/x/crypto/sha3" -) - -func GenerateAddressFromDenom(denom string) (common.Address, error) { - hash := sha3.NewLegacyKeccak256() - if _, err := hash.Write([]byte(denom)); err != nil { - return common.Address{}, err - } - return common.BytesToAddress(hash.Sum(nil)), nil -} From c891c6ee2139a8c2450403093ea6d2d15d2f835d Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 17:21:35 +0300 Subject: [PATCH 106/112] fix: remove redunant protobuf functionality --- Makefile | 29 ----------------------------- contrib/localnet/protocgen.sh | 16 ---------------- 2 files changed, 45 deletions(-) delete mode 100644 contrib/localnet/protocgen.sh diff --git a/Makefile b/Makefile index 85d0608..a010fa1 100644 --- a/Makefile +++ b/Makefile @@ -145,32 +145,3 @@ localnet-start: .PHONY: localnet-start localnet-init localnet-init-multi-node -############################################################################### -### Protobuf ### -############################################################################### - -DOCKER := $(shell which docker) -BUILDDIR ?= $(CURDIR)/build - -protoVer=0.14.0 -protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) -protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) - -proto-all: proto-format proto-gen - -proto-gen: - @echo "Generating Protobuf files" - @$(protoImage) sh ./contrib/localnet/protocgen.sh - @go mod tidy - -proto-format: - @$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \; - -proto-check-breaking: - @$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main - -proto-update-deps: - @echo "Updating Protobuf dependencies" - $(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(protoImageName) buf mod update - -.PHONY: proto-all proto-gen proto-format proto-check-breaking proto-update-deps diff --git a/contrib/localnet/protocgen.sh b/contrib/localnet/protocgen.sh deleted file mode 100644 index 1ca34d8..0000000 --- a/contrib/localnet/protocgen.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -echo "Generating gogo proto code" -cd proto - -buf generate --template buf.gen.gogo.yaml $file - -cd .. - -# move proto files to the right places -cp -r github.com/Asphere-xyz/tacchain/* ./ -rm -rf github.com - -#go mod tidy From aabe5575c46d85389284fb1c0bacae21226db020 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 19:53:27 +0300 Subject: [PATCH 107/112] fix: +x for script --- contrib/localnet/init-liquidstake-for-multinode.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 contrib/localnet/init-liquidstake-for-multinode.sh diff --git a/contrib/localnet/init-liquidstake-for-multinode.sh b/contrib/localnet/init-liquidstake-for-multinode.sh old mode 100644 new mode 100755 From 5cc538bcef8d552d5b3e5e971f467d84c75f2890 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 21:00:54 +0300 Subject: [PATCH 108/112] feat: generilize init scripts for onde and for multi nodes --- .../init-liquidstake-for-multinode.sh | 319 ------------------ contrib/localnet/init-multi-node.sh | 9 +- contrib/localnet/init.sh | 56 ++- 3 files changed, 47 insertions(+), 337 deletions(-) delete mode 100755 contrib/localnet/init-liquidstake-for-multinode.sh diff --git a/contrib/localnet/init-liquidstake-for-multinode.sh b/contrib/localnet/init-liquidstake-for-multinode.sh deleted file mode 100755 index 0a090b0..0000000 --- a/contrib/localnet/init-liquidstake-for-multinode.sh +++ /dev/null @@ -1,319 +0,0 @@ -#!/bin/bash -e - -# environment variables -TACCHAIND=${TACCHAIND:-$(which tacchaind)} -HOMEDIR=${HOMEDIR:-$HOME/.tacchaind} -NODE_MONIKER=${NODE_MONIKER:-$(hostname)} -CHAIN_ID=${CHAIN_ID:-tacchain_2391-1} -KEYRING_BACKEND=${KEYRING_BACKEND:-test} -VALIDATOR_IDENTITY=${VALIDATOR_IDENTITY:-4DD1A5E1D03FA12D} -VALIDATOR_WEBSITE=${VALIDATOR_WEBSITE:-https://tac.build/} -VALIDATOR_MNEMONIC=${VALIDATOR_MNEMONIC:-"island mail dice alien project surround orchard ball twist worth innocent arrange assume dragon rotate enough flee rapid rookie swim addict ice destroy run"} # tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr -INITIAL_BALANCE=${INITIAL_BALANCE:-2000000000000000000000} -INITIAL_STAKE=${INITIAL_STAKE:-1000000000000000000000} -BLOCK_TIME_SECONDS=${BLOCK_TIME_SECONDS:-2} -MAX_GAS=${MAX_GAS:-90000000} -MIN_GAS_PRICE=${MIN_GAS_PRICE:-25000000000} -GOV_TIME_SECONDS=${GOV_TIME_SECONDS:-900} -GOV_MIN_DEPOSIT=${GOV_MIN_DEPOSIT:-10000000000000000} -GOV_MIN_EXPEDITED_DEPOSIT=${GOV_MIN_EXPEDITED_DEPOSIT:-50000000000000000} -GOV_MIN_INITIAL_DEPOSIT_RATIO=${GOV_MIN_INITIAL_DEPOSIT_RATIO:-1} -INFLATION_MAX=${INFLATION_MAX:-0.05} -INFLATION_MIN=${INFLATION_MIN:-0.01} -GOAL_BONDED=${GOAL_BONDED:-0.6} -SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} -SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} -MAX_VALIDATORS=${MAX_VALIDATORS:-14} -UNBONDING_TIME=${UNBONDING_TIME:-1814400s} - -# ports -RPC_PORT=${RPC_PORT:-26657} -P2P_PORT=${P2P_PORT:-26656} -GRPC_PORT=${GRPC_PORT:-9090} -GRPC_WEB_PORT=${GRPC_WEB_PORT:-9091} -API_PORT=${API_PORT:-1317} -JSON_RPC_PORT=${JSON_RPC_PORT:-8545} -JSON_WS_PORT=${JSON_WS_PORT:-8546} -METRICS_PORT=${METRICS_PORT:-6065} -PROMETHEUS_PORT=${PROMETHEUS_PORT:-26660} -PPROF_PORT=${PPROF_PORT:-6060} -PROXY_PORT=${PROXY_PORT:-26658} - -# prompt user for confirmation before cleanup -read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm -if [[ $confirm != "y" && $confirm != "Y" ]]; then - echo "Cleanup aborted." - exit 1 -fi - -# cleanup old data -rm -rf $HOMEDIR - -# set cli options default values -$TACCHAIND config set client chain-id $CHAIN_ID -$TACCHAIND config set client keyring-backend $KEYRING_BACKEND -$TACCHAIND config set client output json - -# init genesis file -$TACCHAIND init "$NODE_MONIKER" --chain-id $CHAIN_ID --default-denom utac --home $HOMEDIR - -# predeployed contracts (all precompiled contracts need to be defined before genesis accounts to avoid issues with auth account_numbers) -# safe singleton factory (https://github.com/safe-global/safe-singleton-factory) -jq ' - .app_state.auth.accounts += [{ - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1j9xhlmr24jxd2sh890983vcx2r29vs7hc7xaks", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }] - | .app_state.evm.accounts += [{ - "address": "0x914d7fec6aac8cd542e72bca78b30650d45643d7", - "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", - "storage": [] - }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -# arachnid (https://github.com/Arachnid/deterministic-deployment-proxy) -jq ' - .app_state.auth.accounts += [{ - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1fevmgjz8kdu40pvgjgx20ralymqtf9tv2r6x6q", - "pub_key": null, - "account_number": "1", - "sequence": "0" - }] - | .app_state.evm.accounts += [{ - "address": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "code": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", - "storage": [] - }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -# multicall (https://github.com/mds1/multicall3) -jq ' - .app_state.auth.accounts += [{ - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1eggmmczew7ekxyt8q2yx9032zuuhdjs3yd8s2h", - "pub_key": null, - "account_number": "2", - "sequence": "0" - }] - | .app_state.evm.accounts += [{ - "address": "0xca11bde05977b3631167028862be2a173976ca11", - "code": "6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", - "storage": [] - }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -# createx (https://github.com/pcaversaccio/createx) -jq ' - .app_state.auth.accounts += [{ - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "tac1hf0dpxtr85anz0jdtaaacyc960pghf0draedhx", - "pub_key": null, - "account_number": "3", - "sequence": "0" - }] - | .app_state.evm.accounts += [{ - "address": "0xba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed", - "code": "60806040526004361061018a5760003560e01c806381503da1116100d6578063d323826a1161007f578063e96deee411610059578063e96deee414610395578063f5745aba146103a8578063f9664498146103bb57600080fd5b8063d323826a1461034f578063ddda0acb1461036f578063e437252a1461038257600080fd5b80639c36a286116100b05780639c36a28614610316578063a7db93f214610329578063c3fe107b1461033c57600080fd5b806381503da1146102d0578063890c283b146102e357806398e810771461030357600080fd5b80632f990e3f116101385780636cec2536116101125780636cec25361461027d57806374637a7a1461029d5780637f565360146102bd57600080fd5b80632f990e3f1461023757806331a7c8c81461024a57806342d654fc1461025d57600080fd5b806327fe18221161016957806327fe1822146101f15780632852527a1461020457806328ddd0461461021757600080fd5b8062d84acb1461018f57806326307668146101cb57806326a32fc7146101de575b600080fd5b6101a261019d366004612915565b6103ce565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6101a26101d9366004612994565b6103e6565b6101a26101ec3660046129db565b610452565b6101a26101ff3660046129db565b6104de565b6101a2610212366004612a39565b610539565b34801561022357600080fd5b506101a2610232366004612a90565b6106fe565b6101a2610245366004612aa9565b61072a565b6101a2610258366004612aa9565b6107bb565b34801561026957600080fd5b506101a2610278366004612b1e565b6107c9565b34801561028957600080fd5b506101a2610298366004612a90565b610823565b3480156102a957600080fd5b506101a26102b8366004612b4a565b61084f565b6101a26102cb3660046129db565b611162565b6101a26102de366004612b74565b6111e8565b3480156102ef57600080fd5b506101a26102fe366004612bac565b611276565b6101a2610311366004612bce565b6112a3565b6101a2610324366004612994565b611505565b6101a2610337366004612c49565b6116f1565b6101a261034a366004612aa9565b611964565b34801561035b57600080fd5b506101a261036a366004612cd9565b6119ed565b6101a261037d366004612c49565b611a17565b6101a2610390366004612bce565b611e0c565b6101a26103a3366004612915565b611e95565b6101a26103b6366004612bce565b611ea4565b6101a26103c9366004612b74565b611f2d565b60006103dd8585858533611a17565b95945050505050565b6000806103f2846120db565b90508083516020850134f59150610408826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a35092915050565b60006104d86104d260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b836103e6565b92915050565b600081516020830134f090506104f3816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a2919050565b600080610545856120db565b905060008460601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f593505073ffffffffffffffffffffffffffffffffffffffff8316610635576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1660048201526024015b60405180910390fd5b604051829073ffffffffffffffffffffffffffffffffffffffff8516907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808473ffffffffffffffffffffffffffffffffffffffff1634876040516106a19190612d29565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b50915091506106f382828961247d565b505050509392505050565b60006104d87f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed8361084f565b60006107b36107aa60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b85858533611a17565b949350505050565b60006107b3848484336112a3565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b60006104d8827f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6107c9565b600060607f9400000000000000000000000000000000000000000000000000000000000000610887600167ffffffffffffffff612d45565b67ffffffffffffffff16841115610902576040517f3c55ab3b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b836000036109c7576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f800000000000000000000000000000000000000000000000000000000000000060368201526037015b6040516020818303038152906040529150611152565b607f8411610a60576040517fd60000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b16602283015260f886901b1660368201526037016109b1565b60ff8411610b1f576040517fd70000000000000000000000000000000000000000000000000000000000000060208201527fff0000000000000000000000000000000000000000000000000000000000000080831660218301527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660228301527f8100000000000000000000000000000000000000000000000000000000000000603683015260f886901b1660378201526038016109b1565b61ffff8411610bff576040517fd80000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f820000000000000000000000000000000000000000000000000000000000000060368201527fffff00000000000000000000000000000000000000000000000000000000000060f086901b1660378201526039016109b1565b62ffffff8411610ce0576040517fd90000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f830000000000000000000000000000000000000000000000000000000000000060368201527fffffff000000000000000000000000000000000000000000000000000000000060e886901b166037820152603a016109b1565b63ffffffff8411610dc2576040517fda0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f840000000000000000000000000000000000000000000000000000000000000060368201527fffffffff0000000000000000000000000000000000000000000000000000000060e086901b166037820152603b016109b1565b64ffffffffff8411610ea5576040517fdb0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f850000000000000000000000000000000000000000000000000000000000000060368201527fffffffffff00000000000000000000000000000000000000000000000000000060d886901b166037820152603c016109b1565b65ffffffffffff8411610f89576040517fdc0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f860000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffff000000000000000000000000000000000000000000000000000060d086901b166037820152603d016109b1565b66ffffffffffffff841161106e576040517fdd0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f870000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffff0000000000000000000000000000000000000000000000000060c886901b166037820152603e016109b1565b6040517fde0000000000000000000000000000000000000000000000000000000000000060208201527fff00000000000000000000000000000000000000000000000000000000000000821660218201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b1660228201527f880000000000000000000000000000000000000000000000000000000000000060368201527fffffffffffffffff00000000000000000000000000000000000000000000000060c086901b166037820152603f0160405160208183030381529060405291505b5080516020909101209392505050565b60006104d86111e260408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b83611505565b600061126f61126860408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b8484610539565b9392505050565b600061126f83837f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed6119ed565b60008451602086018451f090506112b9816123d3565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808273ffffffffffffffffffffffffffffffffffffffff168560200151876040516113279190612d29565b60006040518083038185875af1925050503d8060008114611364576040519150601f19603f3d011682016040523d82523d6000602084013e611369565b606091505b5091509150816113c9577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed1631156114fb578373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611495576040519150601f19603f3d011682016040523d82523d6000602084013e61149a565b606091505b509092509050816114fb577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b5050949350505050565b600080611511846120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff81166115e0576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a361162c83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1634876040516116569190612d29565b60006040518083038185875af1925050503d8060008114611693576040519150601f19603f3d011682016040523d82523d6000602084013e611698565b606091505b505090506116a681866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a25050505092915050565b6000806116fd876120db565b9050808651602088018651f59150611714826123d3565b604051819073ffffffffffffffffffffffffffffffffffffffff8416907fb8fda7e00c6b06a2b54e58521bc5894fee35f1090e5a3bb6390bfe2b98b497f790600090a36000808373ffffffffffffffffffffffffffffffffffffffff168660200151886040516117849190612d29565b60006040518083038185875af1925050503d80600081146117c1576040519150601f19603f3d011682016040523d82523d6000602084013e6117c6565b606091505b509150915081611826577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611958578473ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d80600081146118f2576040519150601f19603f3d011682016040523d82523d6000602084013e6118f7565b606091505b50909250905081611958577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b50505095945050505050565b60006107b36119e460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b858585336116f1565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b600080611a23876120db565b905060006040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000828251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff8116611af2576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b604051839073ffffffffffffffffffffffffffffffffffffffff8316907f2feea65dd4e9f9cbd86b74b7734210c59a1b2981b5b137bd0ee3e208200c906790600090a3611b3e83610823565b935060008173ffffffffffffffffffffffffffffffffffffffff1687600001518a604051611b6c9190612d29565b60006040518083038185875af1925050503d8060008114611ba9576040519150601f19603f3d011682016040523d82523d6000602084013e611bae565b606091505b50509050611bbc81866124ff565b60405173ffffffffffffffffffffffffffffffffffffffff8616907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a260608573ffffffffffffffffffffffffffffffffffffffff1688602001518a604051611c299190612d29565b60006040518083038185875af1925050503d8060008114611c66576040519150601f19603f3d011682016040523d82523d6000602084013e611c6b565b606091505b50909250905081611ccc577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed163115611dfe578673ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed73ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114611d98576040519150601f19603f3d011682016040523d82523d6000602084013e611d9d565b606091505b50909250905081611dfe577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed816040517fc2b3f44500000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050505095945050505050565b60006103dd611e8c60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b868686866116f1565b60006103dd85858585336116f1565b60006103dd611f2460408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b86868686611a17565b6000808360601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f092505073ffffffffffffffffffffffffffffffffffffffff8216612016576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b60405173ffffffffffffffffffffffffffffffffffffffff8316907f4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b51190600090a26000808373ffffffffffffffffffffffffffffffffffffffff1634866040516120809190612d29565b60006040518083038185875af1925050503d80600081146120bd576040519150601f19603f3d011682016040523d82523d6000602084013e6120c2565b606091505b50915091506120d282828861247d565b50505092915050565b60008060006120e9846125b3565b9092509050600082600281111561210257612102612e02565b1480156121205750600081600281111561211e5761211e612e02565b145b1561215e57604080513360208201524691810191909152606081018590526080016040516020818303038152906040528051906020012092506123cc565b600082600281111561217257612172612e02565b1480156121905750600181600281111561218e5761218e612e02565b145b156121b0576121a9338560009182526020526040902090565b92506123cc565b60008260028111156121c4576121c4612e02565b03612233576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b600182600281111561224757612247612e02565b1480156122655750600081600281111561226357612263612e02565b145b1561227e576121a9468560009182526020526040902090565b600182600281111561229257612292612e02565b1480156122b0575060028160028111156122ae576122ae612e02565b145b1561231f576040517f13b3a2a100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b61239a60408051437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101406020830152419282019290925260608101919091524260808201524460a08201524660c08201523360e08201526000906101000160405160208183030381529060405280519060200120905090565b84036123a657836123c9565b604080516020810186905201604051602081830303815290604052805190602001205b92505b5050919050565b73ffffffffffffffffffffffffffffffffffffffff8116158061240b575073ffffffffffffffffffffffffffffffffffffffff81163b155b1561247a576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b50565b82158061249f575073ffffffffffffffffffffffffffffffffffffffff81163b155b156124fa577f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed826040517fa57ca23900000000000000000000000000000000000000000000000000000000815260040161062c929190612d94565b505050565b811580612520575073ffffffffffffffffffffffffffffffffffffffff8116155b80612540575073ffffffffffffffffffffffffffffffffffffffff81163b155b156125af576040517fc05cee7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed16600482015260240161062c565b5050565b600080606083901c3314801561261057508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b1561262057506000905080915091565b606083901c3314801561265a57507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561266b5750600090506001915091565b33606084901c036126825750600090506002915091565b606083901c1580156126db57508260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000145b156126ec5750600190506000915091565b606083901c15801561272557507fff00000000000000000000000000000000000000000000000000000000000000601484901a60f81b16155b1561273557506001905080915091565b606083901c61274a5750600190506002915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f0100000000000000000000000000000000000000000000000000000000000000036127a55750600290506000915091565b8260141a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000036127e15750600290506001915091565b506002905080915091565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261282c57600080fd5b813567ffffffffffffffff80821115612847576128476127ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561288d5761288d6127ec565b816040528381528660208588010111156128a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000604082840312156128d857600080fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb6127ec565b604052823581526020928301359281019290925250919050565b60008060008060a0858703121561292b57600080fd5b84359350602085013567ffffffffffffffff8082111561294a57600080fd5b6129568883890161281b565b9450604087013591508082111561296c57600080fd5b506129798782880161281b565b92505061298986606087016128c6565b905092959194509250565b600080604083850312156129a757600080fd5b82359150602083013567ffffffffffffffff8111156129c557600080fd5b6129d18582860161281b565b9150509250929050565b6000602082840312156129ed57600080fd5b813567ffffffffffffffff811115612a0457600080fd5b6107b38482850161281b565b803573ffffffffffffffffffffffffffffffffffffffff81168114612a3457600080fd5b919050565b600080600060608486031215612a4e57600080fd5b83359250612a5e60208501612a10565b9150604084013567ffffffffffffffff811115612a7a57600080fd5b612a868682870161281b565b9150509250925092565b600060208284031215612aa257600080fd5b5035919050565b600080600060808486031215612abe57600080fd5b833567ffffffffffffffff80821115612ad657600080fd5b612ae28783880161281b565b94506020860135915080821115612af857600080fd5b50612b058682870161281b565b925050612b1585604086016128c6565b90509250925092565b60008060408385031215612b3157600080fd5b82359150612b4160208401612a10565b90509250929050565b60008060408385031215612b5d57600080fd5b612b6683612a10565b946020939093013593505050565b60008060408385031215612b8757600080fd5b612b9083612a10565b9150602083013567ffffffffffffffff8111156129c557600080fd5b60008060408385031215612bbf57600080fd5b50508035926020909101359150565b60008060008060a08587031215612be457600080fd5b843567ffffffffffffffff80821115612bfc57600080fd5b612c088883890161281b565b95506020870135915080821115612c1e57600080fd5b50612c2b8782880161281b565b935050612c3b86604087016128c6565b915061298960808601612a10565b600080600080600060c08688031215612c6157600080fd5b85359450602086013567ffffffffffffffff80821115612c8057600080fd5b612c8c89838a0161281b565b95506040880135915080821115612ca257600080fd5b50612caf8882890161281b565b935050612cbf87606088016128c6565b9150612ccd60a08701612a10565b90509295509295909350565b600080600060608486031215612cee57600080fd5b8335925060208401359150612b1560408501612a10565b60005b83811015612d20578181015183820152602001612d08565b50506000910152565b60008251612d3b818460208701612d05565b9190910192915050565b67ffffffffffffffff828116828216039080821115612d8d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260008251806040840152612dcf816060850160208701612d05565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea164736f6c6343000817000a", - "storage": [] - }] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -# edit configs - -# set EVM config -# get ethereum chain id from CHAIN_ID -EVM_CHAIN_ID=$(echo $CHAIN_ID | sed -E 's/.*_([0-9]+)-.*/\1/') -if [[ -z $EVM_CHAIN_ID ]]; then - echo "Invalid CHAIN_ID format. Expected format: _-" - exit 1 -fi - -sed -i.bak "s/\"chain_id\": \"262144\"/\"chain_id\": \"$EVM_CHAIN_ID\"/g" $HOMEDIR/config/genesis.json -sed -i.bak "s/\"denom\": \"atest\"/\"denom\": \"utac\"/g" $HOMEDIR/config/genesis.json -sed -i.bak "s/\"evm_denom\": \"atest\"/\"evm_denom\": \"utac\"/g" $HOMEDIR/config/genesis.json - -# enable evm eip-3855 -sed -i.bak "s/\"extra_eips\": \[\]/\"extra_eips\": \[\"3855\"\]/g" $HOMEDIR/config/genesis.json - -# disable EIP-155 -sed -i.bak "s/\"allow_unprotected_txs\": false/\"allow_unprotected_txs\": true/g" $HOMEDIR/config/genesis.json -sed -i.bak "s/allow-unprotected-txs = false/allow-unprotected-txs = true/g" $HOMEDIR/config/app.toml - -# set evm precompiles -sed -i.bak "s/\"active_static_precompiles\": \[\]/\"active_static_precompiles\": \[\"0x0000000000000000000000000000000000000100\",\"0x0000000000000000000000000000000000000400\",\"0x0000000000000000000000000000000000000800\",\"0x0000000000000000000000000000000000000801\",\"0x0000000000000000000000000000000000000802\",\"0x0000000000000000000000000000000000000803\",\"0x0000000000000000000000000000000000000804\",\"0x0000000000000000000000000000000000000805\",\"0x0000000000000000000000000000000000000806\",\"0x0000000000000000000000000000000000000807\", \"0x0000000000000000000000000000000000001600\"\]/g" $HOMEDIR/config/genesis.json - -# set x/feemarket min gas price -sed -i.bak "s/\"min_gas_price\": \"0.000000000000000000\"/\"min_gas_price\": \"$MIN_GAS_PRICE\"/g" $HOMEDIR/config/genesis.json - -# set max gas -sed -i.bak "s/\"max_gas\": \"-1\"/\"max_gas\": \"$MAX_GAS\"/g" $HOMEDIR/config/genesis.json - -# update blocks per year to match our block time -BLOCKS_PER_YEAR=$(echo "(365 * 24 * 60 * 60) / $BLOCK_TIME_SECONDS" | bc) -sed -i.bak "s/\"blocks_per_year\": \"6311520\"/\"blocks_per_year\": \"$BLOCKS_PER_YEAR\"/g" $HOMEDIR/config/genesis.json - -# set inflation -sed -i.bak "s/\"inflation_max\": \"0.200000000000000000\"/\"inflation_max\": \"$INFLATION_MAX\"/g" $HOMEDIR/config/genesis.json -sed -i.bak "s/\"inflation_min\": \"0.070000000000000000\"/\"inflation_min\": \"$INFLATION_MIN\"/g" $HOMEDIR/config/genesis.json -sed -i.bak "s/\"goal_bonded\": \"0.670000000000000000\"/\"goal_bonded\": \"$GOAL_BONDED\"/g" $HOMEDIR/config/genesis.json - -# set gov vote time -sed -i.bak "s/\"voting_period\": \"172800s\"/\"voting_period\": \"${GOV_TIME_SECONDS}s\"/g" $HOMEDIR/config/genesis.json -EXPEDITED_TIME_SECONDS=$((GOV_TIME_SECONDS / 2)) -sed -i.bak "s/\"expedited_voting_period\": \"86400s\"/\"expedited_voting_period\": \"${EXPEDITED_TIME_SECONDS}s\"/g" $HOMEDIR/config/genesis.json - -# set gov min initial deposit ratio -sed -i.bak "s/\"min_initial_deposit_ratio\": \"0.000000000000000000\"/\"min_initial_deposit_ratio\": \"$GOV_MIN_INITIAL_DEPOSIT_RATIO\"/g" $HOMEDIR/config/genesis.json - -# set min gov deposit -jq --arg GOV_MIN_DEPOSIT "$GOV_MIN_DEPOSIT" ' - .app_state.gov.params.min_deposit = [ - { - "denom": "utac", - "amount": $GOV_MIN_DEPOSIT - } - ] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -# set min expedited gov deposit -jq --arg GOV_MIN_EXPEDITED_DEPOSIT "$GOV_MIN_EXPEDITED_DEPOSIT" ' - .app_state.gov.params.expedited_min_deposit = [ - { - "denom": "utac", - "amount": $GOV_MIN_EXPEDITED_DEPOSIT - } - ] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -# enable apis -sed -i.bak "s/enable = false/enable = true/g" $HOMEDIR/config/app.toml - -# enable rpc cors -sed -i.bak "s/cors_allowed_origins = \[\]/cors_allowed_origins = \[\"*\"\]/g" $HOMEDIR/config/config.toml - -# set slashing -sed -i.bak "s/\"slash_fraction_downtime\": \"0.010000000000000000\"/\"slash_fraction_downtime\": \"$SLASH_DOWNTIME_PENALTY\"/g" $HOMEDIR/config/genesis.json -sed -i.bak "s/\"signed_blocks_window\": \"100\"/\"signed_blocks_window\": \"$SLASH_SIGNED_BLOCKS_WINDOW\"/g" $HOMEDIR/config/genesis.json - -# add token metadata -jq ' - .app_state.bank.denom_metadata = [ - { - "description": "The native staking token for tacchaind.", - "denom_units": [ - { - "denom": "utac", - "exponent": 0, - "aliases": [] - }, - { - "denom": "tac", - "exponent": 18, - "aliases": [] - } - ], - "base": "utac", - "display": "tac", - "name": "TAC Token", - "symbol": "TAC", - "uri": "", - "uri_hash": "" - } - ] -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -jq ' -.app_state.erc20 = { - "params": { - "enable_erc20": true, - "native_precompiles": [ - "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" - ], - "dynamic_precompiles": [] - }, - "token_pairs": [ - { - "erc20_address": "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517", - "denom": "stk/utac", - "enabled": true, - "contract_owner": "OWNER_MODULE" - } - ] -} -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -jq ' -.app_state.liquidstake = { - "params": { - "liquid_bond_denom": "stk/utac", - "whitelisted_validators": [ - { - "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", - "target_weight": "10000" - }, - { - "validator_address": "tacvaloper1qp4h82jgqqa5ezgzck8z75dn8q0t0nv4fneehy", - "target_weight": "10000" - }, - { - "validator_address": "tacvaloper1d30q62hl0wn6n5m39sd0yqswq6jr3hntkcr4cm", - "target_weight": "10000" - }, - { - "validator_address": "tacvaloper16p9nqhd348aaungp5p5vjuwedaw03pvynleqq7", - "target_weight": "10000" - } - ], - "unstake_fee_rate": "0.000000000000000000", - "lsm_disabled": false, - "min_liquid_stake_amount": "1000", - "cw_locked_pool_address": "", - "fee_account_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", - "autocompound_fee_rate": "0.050000000000000000", - "whitelist_admin_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", - "module_paused": false - }, - "liquid_validators": [ - { - "operator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt" - }, - { - "operator_address": "tacvaloper1qp4h82jgqqa5ezgzck8z75dn8q0t0nv4fneehy" - }, - { - "operator_address": "tacvaloper1d30q62hl0wn6n5m39sd0yqswq6jr3hntkcr4cm" - }, - { - "operator_address": "tacvaloper16p9nqhd348aaungp5p5vjuwedaw03pvynleqq7" - } - ] -} -' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - -# set max validators -sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json - -sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_TIME\"/g" $HOMEDIR/config/genesis.json - -# set ports -sed -i.bak "s/26657/$RPC_PORT/g" $HOMEDIR/config/config.toml -sed -i.bak "s/26656/$P2P_PORT/g" $HOMEDIR/config/config.toml -sed -i.bak "s/9090/$GRPC_PORT/g" $HOMEDIR/config/app.toml -sed -i.bak "s/9091/$GRPC_WEB_PORT/g" $HOMEDIR/config/app.toml -sed -i.bak "s/1317/$API_PORT/g" $HOMEDIR/config/app.toml -sed -i.bak "s/8545/$JSON_RPC_PORT/g" $HOMEDIR/config/app.toml -sed -i.bak "s/8546/$JSON_WS_PORT/g" $HOMEDIR/config/app.toml -sed -i.bak "s/6065/$METRICS_PORT/g" $HOMEDIR/config/app.toml -sed -i.bak "s/26660/$PROMETHEUS_PORT/g" $HOMEDIR/config/config.toml -sed -i.bak "s/6060/$PPROF_PORT/g" $HOMEDIR/config/config.toml -sed -i.bak "s/26658/$PROXY_PORT/g" $HOMEDIR/config/config.toml - -# setup and add validator to genesis -echo $VALIDATOR_MNEMONIC | $TACCHAIND keys add validator --recover --keyring-backend $KEYRING_BACKEND --home $HOMEDIR -$TACCHAIND genesis add-genesis-account validator ${INITIAL_BALANCE}utac --keyring-backend $KEYRING_BACKEND --home $HOMEDIR -$TACCHAIND genesis gentx validator ${INITIAL_STAKE}utac --identity $VALIDATOR_IDENTITY --website $VALIDATOR_WEBSITE --chain-id $CHAIN_ID --keyring-backend $KEYRING_BACKEND --gas-prices ${MIN_GAS_PRICE}utac --gas 200000 --home $HOMEDIR --sequence 1 -$TACCHAIND genesis collect-gentxs --keyring-backend $KEYRING_BACKEND --home $HOMEDIR diff --git a/contrib/localnet/init-multi-node.sh b/contrib/localnet/init-multi-node.sh index 0414dfe..42ac985 100755 --- a/contrib/localnet/init-multi-node.sh +++ b/contrib/localnet/init-multi-node.sh @@ -5,14 +5,15 @@ export TACCHAIND=${TACCHAIND:-$(which tacchaind)} export HOMEDIR=${HOMEDIR:-./.testnet} export CHAIN_ID=${CHAIN_ID:-tacchain_239-1} export KEYRING_BACKEND=${KEYRING_BACKEND:-test} -export VALIDATORS_COUNT=4 export VALIDATOR_NAME=${VALIDATOR_NAME:-TAC Validator} export VALIDATOR_IDENTITY=${VALIDATOR_IDENTITY:-4DD1A5E1D03FA12D} export VALIDATOR_WEBSITE=${VALIDATOR_WEBSITE:-https://tac.build/} +export VALIDATORS_COUNT=4 export VALIDATOR_1_MNEMONIC=${VALIDATOR_1_MNEMONIC:-"island mail dice alien project surround orchard ball twist worth innocent arrange assume dragon rotate enough flee rapid rookie swim addict ice destroy run"} # tac15lvhklny0khnwy7hgrxsxut6t6ku2cgknw79fr export VALIDATOR_2_MNEMONIC=${VALIDATOR_2_MNEMONIC:-"margin funny awkward answer squirrel inner venue spell expose close tank salute series neck oval real bunker can text chronic capital teach arena extend"} # tac16p9nqhd348aaungp5p5vjuwedaw03pvywdzwdk export VALIDATOR_3_MNEMONIC=${VALIDATOR_3_MNEMONIC:-"that away spike absorb aspect loan shuffle purchase number knock cover night library shock mask cheese upset float churn wall fox veteran actress motor"} # tac1qp4h82jgqqa5ezgzck8z75dn8q0t0nv45pzh6v export VALIDATOR_4_MNEMONIC=${VALIDATOR_4_MNEMONIC:-"floor wrong idle cloth nose material forward urge grape always into buyer atom excuse odor decade crouch purchase shadow energy voyage pact skate pigeon"} # tac1d30q62hl0wn6n5m39sd0yqswq6jr3hntt2cm4n +export VALIDATORS_ADDRESSES_STR="${VALIDATORS_ADDRESSES_STR:-"tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt tacvaloper16p9nqhd348aaungp5p5vjuwedaw03pvynleqq7 tacvaloper1qp4h82jgqqa5ezgzck8z75dn8q0t0nv4fneehy tacvaloper1d30q62hl0wn6n5m39sd0yqswq6jr3hntkcr4cm"}" export GENESIS_ACC_1_ADDRESS=${GENESIS_ACC_1_ADDRESS:-} export GENESIS_ACC_2_ADDRESS=${GENESIS_ACC_2_ADDRESS:-} export INITIAL_SUPPLY=${INITIAL_SUPPLY:-10000000000000000000000000000} @@ -31,8 +32,6 @@ export SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} export MAX_VALIDATORS=${MAX_VALIDATORS:-20} export COMMUNITY_TAX=${COMMUNITY_TAX:-0.00} - - # prompt user for confirmation before cleanup read -p "This will remove all existing data in $HOMEDIR. Do you want to proceed? (y/n): " confirm if [[ $confirm != "y" && $confirm != "Y" ]]; then @@ -91,8 +90,8 @@ for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do mnemonic_var="VALIDATOR_$((i+1))_MNEMONIC" export VALIDATOR_MNEMONIC="${!mnemonic_var}" - # call init.sh script to initialize the node - echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init-liquidstake-for-multinode.sh + # call generalized init.sh script to initialize the node + echo y | HOMEDIR=$NODEDIR $(dirname "$0")/./init.sh # explicitly add balances to first node(node0) which will be used to collect gentxs later ADDRESS=$($TACCHAIND keys show validator --keyring-backend $KEYRING_BACKEND --home $NODEDIR -a) diff --git a/contrib/localnet/init.sh b/contrib/localnet/init.sh index f2d660c..d6461d7 100755 --- a/contrib/localnet/init.sh +++ b/contrib/localnet/init.sh @@ -24,7 +24,20 @@ GOAL_BONDED=${GOAL_BONDED:-0.6} SLASH_DOWNTIME_PENALTY=${SLASH_DOWNTIME_PENALTY:-0.001} SLASH_SIGNED_BLOCKS_WINDOW=${SLASH_SIGNED_BLOCKS_WINDOW:-21600} MAX_VALIDATORS=${MAX_VALIDATORS:-20} +UNBONDING_TIME=${UNBONDING_TIME:-1814400s} COMMUNITY_TAX=${COMMUNITY_TAX:-0.00} +TOTAL_WEIGHT=${TOTAL_WEIGHT:-10000} + +# addresses for liqudistake initialization +VALIDATORS_COUNT=${VALIDATORS_COUNT:-1} +if [ -n "$VALIDATORS_ADDRESSES_STR" ]; then + # Convert space-separated string back to array + read -ra VALIDATORS_ADDRESSES <<< "$VALIDATORS_ADDRESSES_STR" +else + VALIDATORS_ADDRESSES=( + "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt" + ) +fi # ports RPC_PORT=${RPC_PORT:-26657} @@ -90,7 +103,6 @@ jq ' }] ' $HOMEDIR/config/genesis.json > $HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json - # multicall (https://github.com/mds1/multicall3) jq ' .app_state.auth.accounts += [{ @@ -247,16 +259,36 @@ jq ' } ' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json -jq ' +# Build whitelisted_validators array dynamically +LIQUID_VALIDATORS="[" +WHITELISTED_VALIDATORS="[" +SINGLE_WEIGHT=$((TOTAL_WEIGHT / VALIDATORS_COUNT)) +COUNT_1=$((VALIDATORS_COUNT - 1)) +for ((i = 0 ; i < VALIDATORS_COUNT ; i++)); do + WEIGHT=$SINGLE_WEIGHT + if [ "$i" -eq "$COUNT_1" ]; then + WEIGHT=$((SINGLE_WEIGHT * $COUNT_1)) + WEIGHT=$((TOTAL_WEIGHT - WEIGHT)) + fi + + VALIDATOR_ADDR="${VALIDATORS_ADDRESSES[i]}" + if [ $i -eq 0 ]; then + WHITELISTED_VALIDATORS+="{\"validator_address\": \"$VALIDATOR_ADDR\", \"target_weight\": \"$WEIGHT\"}" + LIQUID_VALIDATORS+="{\"operator_address\": \"$VALIDATOR_ADDR\"}" + else + WHITELISTED_VALIDATORS+=", {\"validator_address\": \"$VALIDATOR_ADDR\", \"target_weight\": \"$WEIGHT\"}" + LIQUID_VALIDATORS+=", {\"operator_address\": \"$VALIDATOR_ADDR\"}" + fi +done +WHITELISTED_VALIDATORS+="]" +LIQUID_VALIDATORS+="]" + +# Apply liquidstake configuration with dynamically built arrays +jq --argjson whitelisted_validators "$WHITELISTED_VALIDATORS" --argjson liquid_validators "$LIQUID_VALIDATORS" ' .app_state.liquidstake = { "params": { "liquid_bond_denom": "stk/utac", - "whitelisted_validators": [ - { - "validator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt", - "target_weight": "10000" - } - ], + "whitelisted_validators": $whitelisted_validators, "unstake_fee_rate": "0.000000000000000000", "lsm_disabled": false, "min_liquid_stake_amount": "1000", @@ -266,17 +298,15 @@ jq ' "whitelist_admin_address": "tac1w2q3mashs2k4wcpqzs5q5xewnhnnr7wslr34safzvwqzvuqh3gjqn6xzrj", "module_paused": false }, - "liquid_validators": [ - { - "operator_address": "tacvaloper15lvhklny0khnwy7hgrxsxut6t6ku2cgkwu9tyt" - } - ] + "liquid_validators": $liquid_validators } ' $HOMEDIR/config/genesis.json >$HOMEDIR/config/genesis_patched.json && mv $HOMEDIR/config/genesis_patched.json $HOMEDIR/config/genesis.json # set max validators sed -i.bak "s/\"max_validators\": 100/\"max_validators\": $MAX_VALIDATORS/g" $HOMEDIR/config/genesis.json +sed -i.bak "s/\"unbonding_time\": \"1814400s\"/\"unbonding_time\": \"$UNBONDING_TIME\"/g" $HOMEDIR/config/genesis.json + # set community tax sed -i.bak "s/\"community_tax\": \"0.020000000000000000\"/\"community_tax\": \"$COMMUNITY_TAX\"/g" $HOMEDIR/config/genesis.json From 06623dbedbacb76a69825d0ec47f289b707de973 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 21:15:04 +0300 Subject: [PATCH 109/112] fix: remove redunant test utilities --- app/test_helpers.go | 152 -------------------------------------------- 1 file changed, 152 deletions(-) diff --git a/app/test_helpers.go b/app/test_helpers.go index 1f9262c..e6b4ccd 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -1,30 +1,18 @@ package app import ( - "bytes" - "fmt" - "strconv" "testing" - "time" - "encoding/hex" - - errorsmod "cosmossdk.io/errors" abci "github.com/cometbft/cometbft/abci/types" cmtjson "github.com/cometbft/cometbft/libs/json" cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" "cosmossdk.io/log" - "cosmossdk.io/math" sdkmath "cosmossdk.io/math" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" bam "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/testutil/mock" @@ -92,143 +80,3 @@ func NewTacChainAppWithCustomOptions(t *testing.T, isCheckTx bool, invCheckPerio return app } -// AddTestAddrs constructs and returns accNum amount of accounts with an -// initial balance of accAmt in random order -func AddTestAddrs(app *TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { - return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts) -} - -func addTestAddrs(app *TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { - testAddrs := strategy(accNum) - - initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, accAmt)) - - for _, addr := range testAddrs { - InitAccountWithCoins(app, ctx, addr, initCoins) - } - - return testAddrs -} - -// createRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order. -func createRandomAccounts(accNum int) []sdk.AccAddress { - testAddrs := make([]sdk.AccAddress, accNum) - for i := 0; i < accNum; i++ { - pk := ed25519.GenPrivKey().PubKey() - testAddrs[i] = sdk.AccAddress(pk.Address()) - } - - return testAddrs -} - -func InitAccountWithCoins(app *TacChainApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { - err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) - if err != nil { - panic(err) - } - - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) - if err != nil { - panic(err) - } -} - -type GenerateAccountStrategy func(int) []sdk.AccAddress - -// ConvertAddrsToValAddrs converts the provided addresses to ValAddress. -func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { - valAddrs := make([]sdk.ValAddress, len(addrs)) - - for i, addr := range addrs { - valAddrs[i] = sdk.ValAddress(addr) - } - - return valAddrs -} - -// ParseTime parses and returns time.Time in time.RFC3339 format. -func ParseTime(s string) time.Time { - t, err := time.Parse(time.RFC3339, s) - if err != nil { - panic(err) - } - return t -} - -// AddTestAddrs constructs and returns accNum amount of accounts with an -// initial balance of accAmt in random order -func AddTestAddrsIncremental(app *TacChainApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { - return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) -} - -// createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order. -func createIncrementalAccounts(accNum int) []sdk.AccAddress { - var addresses []sdk.AccAddress - var buffer bytes.Buffer - - // start at 100 so we can make up to 999 test addresses with valid test addresses - for i := 100; i < (accNum + 100); i++ { - numString := strconv.Itoa(i) - buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string - - buffer.WriteString(numString) // adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) - bech := res.String() - addr, _ := TestAddr(buffer.String(), bech) - - addresses = append(addresses, addr) - buffer.Reset() - } - - return addresses -} - -func TestAddr(addr, bech string) (sdk.AccAddress, error) { - res, err := sdk.AccAddressFromHexUnsafe(addr) - if err != nil { - return nil, err - } - bechexpected := res.String() - if bech != bechexpected { - return nil, fmt.Errorf("bech encoding doesn't match reference") - } - - bechres, err := sdk.AccAddressFromBech32(bech) - if err != nil { - return nil, err - } - if !bytes.Equal(bechres, res) { - return nil, err - } - - return res, nil -} - -// CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. -func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { - var publicKeys []cryptotypes.PubKey - var buffer bytes.Buffer - - // start at 10 to avoid changing 1 to 01, 2 to 02, etc - for i := 100; i < (numPubKeys + 100); i++ { - numString := strconv.Itoa(i) - buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string - buffer.WriteString(numString) // adding on final two digits to make pubkeys unique - publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String())) - buffer.Reset() - } - - return publicKeys -} - -// NewPubKeyFromHex returns a PubKey from a hex string. -func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { - pkBytes, err := hex.DecodeString(pk) - if err != nil { - panic(err) - } - if len(pkBytes) != ed25519.PubKeySize { - panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) - } - return &ed25519.PubKey{Key: pkBytes} -} From cc95c36f72a5bdb4a6af021eb9b631023ae6396b Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 21:15:23 +0300 Subject: [PATCH 110/112] feat: sync with dependency changes --- go.mod | 5 ++--- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index e03844d..870b42a 100644 --- a/go.mod +++ b/go.mod @@ -270,11 +270,10 @@ replace ( github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // use Cosmos-SDK fork to enable Ledger functionality - // github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.50.12-lsm-beta.0 - github.com/cosmos/cosmos-sdk => github.com/pixelplex/cosmos-sdk v0.0.0-20250923060405-c21481273142 + github.com/cosmos/cosmos-sdk => github.com/TacBuild/cosmos-sdk v0.0.0-20251010131633-e43d8d10a9a9 // replace cosmos evm with our fork that uses geth v1.13.15 - github.com/cosmos/evm => github.com/pixelplex/tac-evm v0.0.0-20250923102517-6db6fc37344d + github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20251010145635-9055209fc1d5 // replace with our fork using geth v1.13.15 github.com/ethereum/go-ethereum => github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a diff --git a/go.sum b/go.sum index 2d04a29..37c1e18 100644 --- a/go.sum +++ b/go.sum @@ -242,6 +242,10 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/TacBuild/cosmos-sdk v0.0.0-20251010131633-e43d8d10a9a9 h1:jMjIlOrdA+vBfZkuljd7V/54L1az5n3Sw12iE7Pea00= +github.com/TacBuild/cosmos-sdk v0.0.0-20251010131633-e43d8d10a9a9/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= +github.com/TacBuild/evm v0.0.0-20251010145635-9055209fc1d5 h1:ALJ3HjJscsYgDCFHKF4lCE5yx1cvWyvLbb2CjOOAhyQ= +github.com/TacBuild/evm v0.0.0-20251010145635-9055209fc1d5/go.mod h1:9+gL3zGzrGuh1oF5vfFl7kuswgma6v7IN0KDbBmO0eA= github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a h1:d5s3in80qbAEpMLo2gVHKPrR6qn60nyxV+rK17tqZ1Q= github.com/TacBuild/go-ethereum v0.0.0-20250428082551-b4f5a8f8420a/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= @@ -998,10 +1002,6 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pixelplex/cosmos-sdk v0.0.0-20250923060405-c21481273142 h1:5S5q6FxGvYeYlUDnX53f4HMv8+BtA8xQTa5a73xo76Y= -github.com/pixelplex/cosmos-sdk v0.0.0-20250923060405-c21481273142/go.mod h1:0Fo5FGFsiXxRRrVm7hBwxzwCeHhNxFPIMUSXqe9P8aA= -github.com/pixelplex/tac-evm v0.0.0-20250923102517-6db6fc37344d h1:hb00/R0rfW4cG22K9xphVKxQ9NJ8n70uqcEA1OOGIZU= -github.com/pixelplex/tac-evm v0.0.0-20250923102517-6db6fc37344d/go.mod h1:ihd//209sPigk6sFp7nTkBjzNNUJvj/JKJtoXebKIDU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 5000685457618f5cc7a704f9a59d2228cdd015a3 Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 21:40:57 +0300 Subject: [PATCH 111/112] fix: test localnet params --- tests/localnet/test-params.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/localnet/test-params.sh b/tests/localnet/test-params.sh index 98054ec..60a3a08 100755 --- a/tests/localnet/test-params.sh +++ b/tests/localnet/test-params.sh @@ -277,7 +277,8 @@ expected_evm_params='{ "0x0000000000000000000000000000000000000804", "0x0000000000000000000000000000000000000805", "0x0000000000000000000000000000000000000806", - "0x0000000000000000000000000000000000000807" + "0x0000000000000000000000000000000000000807", + "0x0000000000000000000000000000000000001600" ] }' evm_params=$(tacchaind q evm params --node http://localhost:45111 --output json | jq -r '.params') From 03aceb3a99b3c1dce259f4891d623a30e454779b Mon Sep 17 00:00:00 2001 From: Alexey Ostrovsky Date: Fri, 10 Oct 2025 22:07:06 +0300 Subject: [PATCH 112/112] chore: add comments for replace in go mod --- go.mod | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 870b42a..f063b25 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( cosmossdk.io/api v0.7.6 cosmossdk.io/client/v2 v2.0.0-beta.7 cosmossdk.io/core v0.11.1 - cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.5.0 cosmossdk.io/math v1.5.0 cosmossdk.io/simapp v0.0.0-20231103111158-e83a20081ced @@ -33,6 +32,8 @@ require ( github.com/stretchr/testify v1.10.0 ) +require cosmossdk.io/errors v1.0.1 // indirect + require ( cloud.google.com/go v0.115.0 // indirect cloud.google.com/go/auth v0.6.0 // indirect @@ -269,10 +270,10 @@ replace ( // Pin this pebble version to avoid breaking compilation of geth github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 - // use Cosmos-SDK fork to enable Ledger functionality + // replace to cosmos-sdk fork for liquid stake support. See: https://github.com/TacBuild/cosmos-sdk/pull/2 github.com/cosmos/cosmos-sdk => github.com/TacBuild/cosmos-sdk v0.0.0-20251010131633-e43d8d10a9a9 - // replace cosmos evm with our fork that uses geth v1.13.15 + // replace to cosmos/evm fork for liquid stake support. See: https://github.com/TacBuild/evm/pull/9 github.com/cosmos/evm => github.com/TacBuild/evm v0.0.0-20251010145635-9055209fc1d5 // replace with our fork using geth v1.13.15