From 4280c9439a60b4c97db39d35b238662c6a20db52 Mon Sep 17 00:00:00 2001 From: cloud8little <34291844+cloud8little@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:32:15 +0800 Subject: [PATCH 1/5] remove total supply in genesis (#191) * remove total supply in client chain * update the git version in dockerfile to fix the lint error --------- Co-authored-by: TimmyExogenous --- Dockerfile | 2 +- local_node.sh | 1 - networks/local/exocore/Dockerfile | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c80e10215..df79f9de7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /go/src/github.com/ExocoreNetwork/exocore COPY go.mod go.sum ./ -RUN apk add --no-cache ca-certificates=20240226-r0 build-base=0.5-r3 git=2.43.4-r0 linux-headers=6.5-r0 +RUN apk add --no-cache ca-certificates=20240226-r0 build-base=0.5-r3 git=2.43.5-r0 linux-headers=6.5-r0 RUN --mount=type=bind,target=. --mount=type=secret,id=GITHUB_TOKEN \ git config --global url."https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/".insteadOf "https://github.com/"; \ diff --git a/local_node.sh b/local_node.sh index b5557589d..892e12409 100755 --- a/local_node.sh +++ b/local_node.sh @@ -97,7 +97,6 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["meta_info"]="Tether USD token"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["address"]="0xdAC17F958D2ee523a2206206994597C13D831ec7"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["layer_zero_chain_id"]="101"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["total_supply"]="40022689732746729"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["staking_total_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["staker"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" diff --git a/networks/local/exocore/Dockerfile b/networks/local/exocore/Dockerfile index 3fb685990..89c9f5634 100644 --- a/networks/local/exocore/Dockerfile +++ b/networks/local/exocore/Dockerfile @@ -1,5 +1,5 @@ FROM golang:1.21.12-alpine3.19 AS build -RUN apk add --no-cache build-base=0.5-r3 git=2.43.4-r0 linux-headers=6.5-r0 +RUN apk add --no-cache build-base=0.5-r3 git=2.43.5-r0 linux-headers=6.5-r0 # Set working directory for the build WORKDIR /go/work # Add source files From 4ab20074d31ecbce209af905d85ccc116ff9988a Mon Sep 17 00:00:00 2001 From: TimmyExogenous <144751317+TimmyExogenous@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:41:55 +0800 Subject: [PATCH 2/5] fix(evm): update the dependency evmos to v16 (#172) * detail the return error for operator info * update the dependency evmos to v16 * rename WaitUnbondingAmount to pendingUndelegationAmount move the patch to fix the vulnerability CVE-2024-32644 regarding transaction execution not accounting for all state transition after interaction with precompiles * rebase to the develop * Temporarily disable the price feeder to fix the issue caused by two different versions of the EVMOS dependency * rebase to develop and fix the lint and unit test error after rebasing --- app/ante/cosmos/authz_test.go | 8 +- app/ante/cosmos/context.go | 2 +- app/ante/cosmos/eip712.go | 8 +- app/ante/cosmos/fees_benchmark_test.go | 4 +- app/ante/cosmos/fees_test.go | 8 +- app/ante/cosmos/min_price.go | 2 +- app/ante/cosmos/min_price_test.go | 8 +- app/ante/cosmos/reject_msgs.go | 2 +- app/ante/cosmos/setup_test.go | 24 +-- app/ante/cosmos/utils_test.go | 12 +- app/ante/evm/ante_test.go | 4 +- app/ante/evm/eth.go | 10 +- app/ante/evm/eth_benchmark_test.go | 12 +- app/ante/evm/eth_test.go | 16 +- app/ante/evm/fee_checker.go | 4 +- app/ante/evm/fee_checker_test.go | 6 +- app/ante/evm/fee_market.go | 2 +- app/ante/evm/fee_market_test.go | 12 +- app/ante/evm/fees.go | 2 +- app/ante/evm/fees_test.go | 8 +- app/ante/evm/interfaces.go | 6 +- app/ante/evm/setup_ctx.go | 2 +- app/ante/evm/setup_ctx_test.go | 8 +- app/ante/evm/setup_test.go | 14 +- app/ante/evm/signverify_test.go | 8 +- app/ante/evm/sigs_test.go | 6 +- app/ante/evm/sigverify.go | 2 +- app/ante/evm/utils_test.go | 10 +- app/ante/handler_options.go | 2 +- app/ante/handler_options_test.go | 10 +- app/ante/integration_test.go | 8 +- app/ante/setup_test.go | 12 +- app/ante/sigverify.go | 2 +- app/ante/sigverify_test.go | 8 +- app/ante/utils/claim_rewards_test.go | 8 +- app/ante/utils/setup_test.go | 16 +- app/ante/utils_test.go | 4 +- app/app.go | 79 +++----- app/ethtest_helper.go | 12 +- app/export.go | 4 +- app/forks.go | 4 +- app/test_helpers.go | 14 +- client/config.go | 2 +- client/debug/debug.go | 4 +- client/export.go | 4 +- client/import.go | 4 +- client/keys.go | 4 +- client/keys/add.go | 2 +- cmd/config/config.go | 2 +- cmd/exocored/genaccounts.go | 10 +- cmd/exocored/migrate.go | 2 +- cmd/exocored/root.go | 39 ++-- cmd/exocored/testnet.go | 20 +- go.mod | 28 +-- go.sum | 52 +++-- local_node.sh | 2 +- precompiles/assets/assets.go | 6 +- precompiles/assets/assets_test.go | 4 +- precompiles/assets/tx.go | 2 +- precompiles/assets/types.go | 2 +- precompiles/avs/avs.go | 6 +- precompiles/avs/avs_test.go | 6 +- precompiles/avs/events.go | 2 +- precompiles/avs/query.go | 2 +- precompiles/avs/tx.go | 2 +- precompiles/avs/types.go | 2 +- precompiles/bls/bls.go | 2 +- precompiles/bls/methods.go | 2 +- precompiles/delegation/delegation.go | 7 +- precompiles/delegation/delegation_test.go | 4 +- precompiles/delegation/tx.go | 2 +- precompiles/delegation/types.go | 2 +- precompiles/reward/parser.go | 2 +- precompiles/reward/reward.go | 6 +- precompiles/reward/reward_test.go | 4 +- precompiles/slash/parser.go | 2 +- precompiles/slash/slash.go | 6 +- precompiles/slash/slash_test.go | 4 +- precompiles/testutil/contracts/contracts.go | 4 +- .../testutil/contracts/deposit_caller.go | 2 +- precompiles/testutil/contracts/types.go | 2 +- precompiles/testutil/errors.go | 2 +- precompiles/testutil/events.go | 2 +- precompiles/testutil/logs.go | 2 +- .../crypto/v1/ethsecp256k1/keys.proto | 2 +- proto/ethermint/evm/v1/events.proto | 2 +- proto/ethermint/evm/v1/evm.proto | 2 +- proto/ethermint/evm/v1/genesis.proto | 2 +- proto/ethermint/evm/v1/query.proto | 2 +- proto/ethermint/evm/v1/tx.proto | 2 +- proto/ethermint/feemarket/v1/events.proto | 2 +- proto/ethermint/feemarket/v1/feemarket.proto | 2 +- proto/ethermint/feemarket/v1/genesis.proto | 2 +- proto/ethermint/feemarket/v1/query.proto | 2 +- proto/ethermint/feemarket/v1/tx.proto | 2 +- proto/ethermint/types/v1/account.proto | 2 +- proto/ethermint/types/v1/dynamic_fee.proto | 2 +- proto/ethermint/types/v1/indexer.proto | 2 +- proto/ethermint/types/v1/web3.proto | 2 +- proto/evmos/claims/v1/claims.proto | 2 +- proto/evmos/claims/v1/genesis.proto | 2 +- proto/evmos/claims/v1/query.proto | 2 +- proto/evmos/claims/v1/tx.proto | 2 +- proto/evmos/erc20/v1/erc20.proto | 2 +- proto/evmos/erc20/v1/events.proto | 2 +- proto/evmos/erc20/v1/genesis.proto | 2 +- proto/evmos/erc20/v1/query.proto | 2 +- proto/evmos/erc20/v1/tx.proto | 2 +- proto/evmos/incentives/v1/genesis.proto | 2 +- proto/evmos/incentives/v1/incentives.proto | 2 +- proto/evmos/incentives/v1/query.proto | 2 +- proto/evmos/incentives/v1/tx.proto | 2 +- proto/evmos/inflation/v1/genesis.proto | 2 +- proto/evmos/inflation/v1/inflation.proto | 2 +- proto/evmos/inflation/v1/query.proto | 2 +- proto/evmos/inflation/v1/tx.proto | 2 +- proto/evmos/recovery/v1/genesis.proto | 2 +- proto/evmos/recovery/v1/query.proto | 2 +- proto/evmos/recovery/v1/tx.proto | 2 +- proto/evmos/revenue/v1/events.proto | 2 +- proto/evmos/revenue/v1/genesis.proto | 2 +- proto/evmos/revenue/v1/query.proto | 2 +- proto/evmos/revenue/v1/revenue.proto | 2 +- proto/evmos/revenue/v1/tx.proto | 2 +- proto/evmos/vesting/v1/events.proto | 2 +- proto/evmos/vesting/v1/query.proto | 2 +- proto/evmos/vesting/v1/tx.proto | 2 +- proto/evmos/vesting/v1/vesting.proto | 2 +- proto/exocore/assets/v1/tx.proto | 8 +- testutil/abci.go | 2 +- testutil/ante.go | 2 +- testutil/contract.go | 2 +- testutil/fund.go | 11 +- testutil/integration.go | 2 +- testutil/network/network.go | 10 +- testutil/network/network_test.go | 2 +- testutil/network/util.go | 4 +- testutil/statedb.go | 2 +- testutil/tx/eip712.go | 6 +- testutil/tx/eth.go | 4 +- testutil/tx/signer.go | 2 +- testutil/utils.go | 20 +- types/account_test.go | 8 +- types/chain_id.go | 2 +- types/validation_test.go | 4 +- utils/utils.go | 2 +- utils/utils_test.go | 2 +- x/assets/keeper/operator_asset.go | 10 +- x/assets/keeper/staker_asset.go | 8 +- x/assets/types/genesis.go | 6 +- x/assets/types/genesis_test.go | 34 ++-- x/assets/types/tx.pb.go | 184 +++++++++--------- x/avs/keeper/avs.go | 2 +- x/avs/keeper/avs_test.go | 2 +- x/avs/keeper/setup_test.go | 6 +- x/avs/types/expected_keepers.go | 2 +- x/delegation/keeper/abci.go | 6 +- x/delegation/keeper/delegation_op_test.go | 42 ++-- x/delegation/keeper/share.go | 4 +- x/delegation/keeper/share_test.go | 4 +- x/dogfood/keeper/impl_evm.go | 4 +- x/dogfood/keeper/msg_server.go | 2 +- x/evm/client/cli/query.go | 4 +- x/evm/client/cli/tx.go | 4 +- x/evm/genesis.go | 4 +- x/evm/handler.go | 2 +- x/evm/keeper/config.go | 4 +- x/evm/keeper/fees.go | 2 +- x/evm/keeper/gas.go | 2 +- x/evm/keeper/grpc_query.go | 46 ++++- x/evm/keeper/hooks.go | 2 +- x/evm/keeper/keeper.go | 9 +- x/evm/keeper/migrations.go | 12 +- x/evm/keeper/msg_server.go | 5 +- x/evm/keeper/params.go | 41 +++- x/evm/keeper/precompiles.go | 90 +++++++-- x/evm/keeper/state_transition.go | 31 ++- x/evm/keeper/statedb.go | 6 +- x/evm/module.go | 11 +- x/evm/types/genesis.go | 2 +- x/evm/types/params.go | 4 +- x/operator/keeper/opt.go | 3 +- x/operator/keeper/usd_value.go | 2 +- x/oracle/types/nonce.pb.go | 8 +- x/reward/keeper/claim_reward.go | 2 +- x/reward/keeper/claim_reward_test.go | 6 +- x/slash/keeper/execute_slash.go | 2 +- x/slash/keeper/execute_slash_test.go | 12 +- 188 files changed, 831 insertions(+), 643 deletions(-) diff --git a/app/ante/cosmos/authz_test.go b/app/ante/cosmos/authz_test.go index 9b808b5dd..e66ea6d38 100644 --- a/app/ante/cosmos/authz_test.go +++ b/app/ante/cosmos/authz_test.go @@ -17,10 +17,10 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - cosmosante "github.com/evmos/evmos/v14/app/ante/cosmos" - testutil "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + cosmosante "github.com/evmos/evmos/v16/app/ante/cosmos" + testutil "github.com/evmos/evmos/v16/testutil" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func TestAuthzLimiterDecorator(t *testing.T) { diff --git a/app/ante/cosmos/context.go b/app/ante/cosmos/context.go index c188e87fd..3203c0ec6 100644 --- a/app/ante/cosmos/context.go +++ b/app/ante/cosmos/context.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" - evmostypes "github.com/evmos/evmos/v14/types" + evmostypes "github.com/evmos/evmos/v16/types" ) var _ GasTx = (*legacytx.StdTx)(nil) // assert StdTx implements GasTx diff --git a/app/ante/cosmos/eip712.go b/app/ante/cosmos/eip712.go index 451d51a71..453f06c13 100644 --- a/app/ante/cosmos/eip712.go +++ b/app/ante/cosmos/eip712.go @@ -17,11 +17,11 @@ import ( ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/ethereum/go-ethereum/signer/core/apitypes" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/ethereum/eip712" - "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/ethereum/eip712" + "github.com/evmos/evmos/v16/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) var evmosCodec codec.ProtoCodecMarshaler diff --git a/app/ante/cosmos/fees_benchmark_test.go b/app/ante/cosmos/fees_benchmark_test.go index d1739cd17..b32623ad2 100644 --- a/app/ante/cosmos/fees_benchmark_test.go +++ b/app/ante/cosmos/fees_benchmark_test.go @@ -7,8 +7,8 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" ) // This tests setup contains expensive operations. diff --git a/app/ante/cosmos/fees_test.go b/app/ante/cosmos/fees_test.go index 5369b29b4..5095dea32 100644 --- a/app/ante/cosmos/fees_test.go +++ b/app/ante/cosmos/fees_test.go @@ -6,10 +6,10 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/feegrant" - cosmosante "github.com/evmos/evmos/v14/app/ante/cosmos" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/utils" + cosmosante "github.com/evmos/evmos/v16/app/ante/cosmos" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/utils" ) type deductFeeDecoratorTestCase struct { diff --git a/app/ante/cosmos/min_price.go b/app/ante/cosmos/min_price.go index 354cc4f37..b5111fd27 100644 --- a/app/ante/cosmos/min_price.go +++ b/app/ante/cosmos/min_price.go @@ -7,7 +7,7 @@ import ( anteutils "github.com/ExocoreNetwork/exocore/app/ante/utils" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - evmante "github.com/evmos/evmos/v14/app/ante/evm" + evmante "github.com/evmos/evmos/v16/app/ante/evm" ) // MinGasPriceDecorator will check if the transaction's fee is at least as large diff --git a/app/ante/cosmos/min_price_test.go b/app/ante/cosmos/min_price_test.go index c3eeb8680..500596d66 100644 --- a/app/ante/cosmos/min_price_test.go +++ b/app/ante/cosmos/min_price_test.go @@ -4,10 +4,10 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - cosmosante "github.com/evmos/evmos/v14/app/ante/cosmos" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/utils" + cosmosante "github.com/evmos/evmos/v16/app/ante/cosmos" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/utils" ) var execTypes = []struct { diff --git a/app/ante/cosmos/reject_msgs.go b/app/ante/cosmos/reject_msgs.go index c0552f7f9..a28b492fb 100644 --- a/app/ante/cosmos/reject_msgs.go +++ b/app/ante/cosmos/reject_msgs.go @@ -4,7 +4,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // RejectMessagesDecorator prevents invalid msg types from being executed diff --git a/app/ante/cosmos/setup_test.go b/app/ante/cosmos/setup_test.go index 425e58b06..b2208ea43 100644 --- a/app/ante/cosmos/setup_test.go +++ b/app/ante/cosmos/setup_test.go @@ -19,18 +19,18 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/app" - "github.com/evmos/evmos/v14/app/ante" - evmante "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/ethereum/eip712" - "github.com/evmos/evmos/v14/testutil" - "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/utils" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/evmos/evmos/v16/app" + "github.com/evmos/evmos/v16/app/ante" + evmante "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/ethereum/eip712" + "github.com/evmos/evmos/v16/testutil" + "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/utils" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" + feemarkettypes "github.com/evmos/evmos/v16/x/feemarket/types" ) type AnteTestSuite struct { diff --git a/app/ante/cosmos/utils_test.go b/app/ante/cosmos/utils_test.go index f9f93226a..d193be1e1 100644 --- a/app/ante/cosmos/utils_test.go +++ b/app/ante/cosmos/utils_test.go @@ -13,12 +13,12 @@ import ( authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/authz" - "github.com/evmos/evmos/v14/app" - cosmosante "github.com/evmos/evmos/v14/app/ante/cosmos" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/encoding" - testutil "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" + "github.com/evmos/evmos/v16/app" + cosmosante "github.com/evmos/evmos/v16/app/ante/cosmos" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/encoding" + testutil "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" ) func (suite *AnteTestSuite) CreateTestCosmosTxBuilder(gasPrice sdkmath.Int, denom string, msgs ...sdk.Msg) client.TxBuilder { diff --git a/app/ante/evm/ante_test.go b/app/ante/evm/ante_test.go index c3e4db70d..a04fed038 100644 --- a/app/ante/evm/ante_test.go +++ b/app/ante/evm/ante_test.go @@ -17,8 +17,8 @@ import ( "github.com/ethereum/go-ethereum/core/types" ethparams "github.com/ethereum/go-ethereum/params" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (suite *AnteTestSuite) TestAnteHandler() { diff --git a/app/ante/evm/eth.go b/app/ante/evm/eth.go index 3d1521749..f92cfa13d 100644 --- a/app/ante/evm/eth.go +++ b/app/ante/evm/eth.go @@ -10,11 +10,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - anteutils "github.com/evmos/evmos/v14/app/ante/utils" - "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/keeper" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + anteutils "github.com/evmos/evmos/v16/app/ante/utils" + "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/keeper" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" diff --git a/app/ante/evm/eth_benchmark_test.go b/app/ante/evm/eth_benchmark_test.go index dc7507612..6c9180836 100644 --- a/app/ante/evm/eth_benchmark_test.go +++ b/app/ante/evm/eth_benchmark_test.go @@ -8,12 +8,12 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - ethante "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/server/config" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + ethante "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/server/config" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func BenchmarkEthGasConsumeDecorator(b *testing.B) { diff --git a/app/ante/evm/eth_test.go b/app/ante/evm/eth_test.go index 0ff366f04..0efeb07ac 100644 --- a/app/ante/evm/eth_test.go +++ b/app/ante/evm/eth_test.go @@ -6,14 +6,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - ethante "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/server/config" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/utils" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + ethante "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/server/config" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/utils" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ethtypes "github.com/ethereum/go-ethereum/core/types" ) diff --git a/app/ante/evm/fee_checker.go b/app/ante/evm/fee_checker.go index 55992fc2c..ac1c11224 100644 --- a/app/ante/evm/fee_checker.go +++ b/app/ante/evm/fee_checker.go @@ -10,8 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // NewDynamicFeeChecker returns a `TxFeeChecker` that applies a dynamic fee to diff --git a/app/ante/evm/fee_checker_test.go b/app/ante/evm/fee_checker_test.go index 50e90545f..d00d21295 100644 --- a/app/ante/evm/fee_checker_test.go +++ b/app/ante/evm/fee_checker_test.go @@ -13,9 +13,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/ethereum/go-ethereum/params" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) var _ DynamicFeeEVMKeeper = MockEVMKeeper{} diff --git a/app/ante/evm/fee_market.go b/app/ante/evm/fee_market.go index a84a2c90f..704c4f719 100644 --- a/app/ante/evm/fee_market.go +++ b/app/ante/evm/fee_market.go @@ -7,7 +7,7 @@ import ( anteutils "github.com/ExocoreNetwork/exocore/app/ante/utils" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v16/types" ) // GasWantedDecorator keeps track of the gasWanted amount on the current block in transient store diff --git a/app/ante/evm/fee_market_test.go b/app/ante/evm/fee_market_test.go index 9bcaecabb..d913db9ea 100644 --- a/app/ante/evm/fee_market_test.go +++ b/app/ante/evm/fee_market_test.go @@ -8,12 +8,12 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/utils" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/testutil" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/utils" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (suite *AnteTestSuite) TestGasWantedDecorator() { diff --git a/app/ante/evm/fees.go b/app/ante/evm/fees.go index 2238515a2..c45e3f142 100644 --- a/app/ante/evm/fees.go +++ b/app/ante/evm/fees.go @@ -8,7 +8,7 @@ import ( errortypes "github.com/cosmos/cosmos-sdk/types/errors" ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // EthMinGasPriceDecorator will check if the transaction's fee is at least as large diff --git a/app/ante/evm/fees_test.go b/app/ante/evm/fees_test.go index d9b1b647b..540f9a13c 100644 --- a/app/ante/evm/fees_test.go +++ b/app/ante/evm/fees_test.go @@ -8,10 +8,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - evmante "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmante "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) var execTypes = []struct { diff --git a/app/ante/evm/interfaces.go b/app/ante/evm/interfaces.go index 0ecfb6f28..5031ed14a 100644 --- a/app/ante/evm/interfaces.go +++ b/app/ante/evm/interfaces.go @@ -10,9 +10,9 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" + feemarkettypes "github.com/evmos/evmos/v16/x/feemarket/types" ) // EVMKeeper defines the expected keeper interface used on the AnteHandler diff --git a/app/ante/evm/setup_ctx.go b/app/ante/evm/setup_ctx.go index 600525761..d51ee4eb4 100644 --- a/app/ante/evm/setup_ctx.go +++ b/app/ante/evm/setup_ctx.go @@ -11,7 +11,7 @@ import ( errortypes "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // EthSetupContextDecorator is adapted from SetUpContextDecorator from cosmos-sdk, it ignores gas consumption diff --git a/app/ante/evm/setup_ctx_test.go b/app/ante/evm/setup_ctx_test.go index 2b10c0470..b5ee8f3d7 100644 --- a/app/ante/evm/setup_ctx_test.go +++ b/app/ante/evm/setup_ctx_test.go @@ -3,13 +3,13 @@ package evm_test import ( "math/big" - evmante "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/testutil" + evmante "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/testutil" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (suite *AnteTestSuite) TestEthSetupContextDecorator() { diff --git a/app/ante/evm/setup_test.go b/app/ante/evm/setup_test.go index a2a7012fe..8eea5571a 100644 --- a/app/ante/evm/setup_test.go +++ b/app/ante/evm/setup_test.go @@ -15,13 +15,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/app" - ante "github.com/evmos/evmos/v14/app/ante" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/ethereum/eip712" - "github.com/evmos/evmos/v14/utils" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/evmos/evmos/v16/app" + ante "github.com/evmos/evmos/v16/app/ante" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/ethereum/eip712" + "github.com/evmos/evmos/v16/utils" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" + feemarkettypes "github.com/evmos/evmos/v16/x/feemarket/types" ) type AnteTestSuite struct { diff --git a/app/ante/evm/signverify_test.go b/app/ante/evm/signverify_test.go index 6e4f87fb1..138dc0305 100644 --- a/app/ante/evm/signverify_test.go +++ b/app/ante/evm/signverify_test.go @@ -5,10 +5,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - ethante "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + ethante "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (suite *AnteTestSuite) TestEthSigVerificationDecorator() { diff --git a/app/ante/evm/sigs_test.go b/app/ante/evm/sigs_test.go index ffdd00645..13058c4df 100644 --- a/app/ante/evm/sigs_test.go +++ b/app/ante/evm/sigs_test.go @@ -3,9 +3,9 @@ package evm_test import ( "math/big" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (suite *AnteTestSuite) TestSignatures() { diff --git a/app/ante/evm/sigverify.go b/app/ante/evm/sigverify.go index 064917755..29124ca07 100644 --- a/app/ante/evm/sigverify.go +++ b/app/ante/evm/sigverify.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // EthSigVerificationDecorator validates an ethereum signatures diff --git a/app/ante/evm/utils_test.go b/app/ante/evm/utils_test.go index e3b868993..8772bd263 100644 --- a/app/ante/evm/utils_test.go +++ b/app/ante/evm/utils_test.go @@ -12,8 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/evmos/evmos/v14/ethereum/eip712" - "github.com/evmos/evmos/v14/testutil" + "github.com/evmos/evmos/v16/ethereum/eip712" + "github.com/evmos/evmos/v16/testutil" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -33,15 +33,15 @@ import ( authz "github.com/cosmos/cosmos-sdk/x/authz" ibctypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" evtypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (suite *AnteTestSuite) BuildTestEthTx( diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index c607add44..af48735a1 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -15,7 +15,7 @@ import ( cosmosante "github.com/ExocoreNetwork/exocore/app/ante/cosmos" evmante "github.com/ExocoreNetwork/exocore/app/ante/evm" anteutils "github.com/ExocoreNetwork/exocore/app/ante/utils" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // HandlerOptions defines the list of module keepers required to run the Evmos diff --git a/app/ante/handler_options_test.go b/app/ante/handler_options_test.go index 7e328bb69..28969daee 100644 --- a/app/ante/handler_options_test.go +++ b/app/ante/handler_options_test.go @@ -1,12 +1,12 @@ package ante_test import ( - ethante "github.com/evmos/evmos/v14/app/ante/evm" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/types" + ethante "github.com/evmos/evmos/v16/app/ante/evm" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/types" - "github.com/evmos/evmos/v14/app" - "github.com/evmos/evmos/v14/app/ante" + "github.com/evmos/evmos/v16/app" + "github.com/evmos/evmos/v16/app/ante" ) func (suite *AnteTestSuite) TestValidateHandlerOptions() { diff --git a/app/ante/integration_test.go b/app/ante/integration_test.go index d9b07f132..a13b54e9a 100644 --- a/app/ante/integration_test.go +++ b/app/ante/integration_test.go @@ -5,15 +5,15 @@ import ( sdkmath "cosmossdk.io/math" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - "github.com/evmos/evmos/v14/utils" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/testutil" + "github.com/evmos/evmos/v16/utils" ) var _ = Describe("when sending a Cosmos transaction", func() { diff --git a/app/ante/setup_test.go b/app/ante/setup_test.go index 9d151e27d..ac46ecc37 100644 --- a/app/ante/setup_test.go +++ b/app/ante/setup_test.go @@ -9,12 +9,12 @@ import ( "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/app" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/testutil" - "github.com/evmos/evmos/v14/utils" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/evmos/evmos/v16/app" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/testutil" + "github.com/evmos/evmos/v16/utils" + feemarkettypes "github.com/evmos/evmos/v16/x/feemarket/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) diff --git a/app/ante/sigverify.go b/app/ante/sigverify.go index 8478f6ef4..01c99c5b8 100644 --- a/app/ante/sigverify.go +++ b/app/ante/sigverify.go @@ -12,7 +12,7 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" ) var _ authante.SignatureVerificationGasConsumer = SigVerificationGasConsumer diff --git a/app/ante/sigverify_test.go b/app/ante/sigverify_test.go index da1da4267..cef461f9d 100644 --- a/app/ante/sigverify_test.go +++ b/app/ante/sigverify_test.go @@ -16,10 +16,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/evmos/evmos/v14/app" - "github.com/evmos/evmos/v14/app/ante" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/encoding" + "github.com/evmos/evmos/v16/app" + "github.com/evmos/evmos/v16/app/ante" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/encoding" ) func TestConsumeSignatureVerificationGas(t *testing.T) { diff --git a/app/ante/utils/claim_rewards_test.go b/app/ante/utils/claim_rewards_test.go index 04c445949..0f0d4fa9c 100644 --- a/app/ante/utils/claim_rewards_test.go +++ b/app/ante/utils/claim_rewards_test.go @@ -4,10 +4,10 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - anteutils "github.com/evmos/evmos/v14/app/ante/utils" - "github.com/evmos/evmos/v14/testutil" - testutiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/utils" + anteutils "github.com/evmos/evmos/v16/app/ante/utils" + "github.com/evmos/evmos/v16/testutil" + testutiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/utils" ) // TestClaimStakingRewardsIfNecessary tests the ClaimStakingRewardsIfNecessary function diff --git a/app/ante/utils/setup_test.go b/app/ante/utils/setup_test.go index 2c7ad3cde..7333ee154 100644 --- a/app/ante/utils/setup_test.go +++ b/app/ante/utils/setup_test.go @@ -15,14 +15,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/app" - "github.com/evmos/evmos/v14/app/ante" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/ethereum/eip712" - "github.com/evmos/evmos/v14/testutil" - "github.com/evmos/evmos/v14/utils" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/evmos/evmos/v16/app" + "github.com/evmos/evmos/v16/app/ante" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/ethereum/eip712" + "github.com/evmos/evmos/v16/testutil" + "github.com/evmos/evmos/v16/utils" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" + feemarkettypes "github.com/evmos/evmos/v16/x/feemarket/types" ) type AnteTestSuite struct { diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index 839f96811..0bbeeba97 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -6,8 +6,8 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/evmos/evmos/v14/app/ante" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/app/ante" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" ) func generatePubKeysAndSignatures(n int, msg []byte, _ bool) (pubkeys []cryptotypes.PubKey, signatures [][]byte) { diff --git a/app/app.go b/app/app.go index ff1d65199..f883ecf30 100644 --- a/app/app.go +++ b/app/app.go @@ -33,7 +33,7 @@ import ( // for EIP-1559 fee handling ethante "github.com/ExocoreNetwork/exocore/app/ante/evm" // for encoding and decoding of EIP-712 messages - "github.com/evmos/evmos/v14/ethereum/eip712" + "github.com/evmos/evmos/v16/ethereum/eip712" "github.com/ExocoreNetwork/exocore/x/assets" assetsKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" @@ -50,9 +50,9 @@ import ( rewardTypes "github.com/ExocoreNetwork/exocore/x/reward/types" // increases or decreases block gas limit based on usage - "github.com/evmos/evmos/v14/x/feemarket" - feemarketkeeper "github.com/evmos/evmos/v14/x/feemarket/keeper" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/evmos/evmos/v16/x/feemarket" + feemarketkeeper "github.com/evmos/evmos/v16/x/feemarket/keeper" + feemarkettypes "github.com/evmos/evmos/v16/x/feemarket/types" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" @@ -65,7 +65,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" - "github.com/evmos/evmos/v14/precompiles/common" + "github.com/evmos/evmos/v16/precompiles/common" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -96,8 +96,8 @@ import ( // this module allows the transfer of ERC20 tokens over IBC. for such transfers to occur, // they must be enabled in the ERC20 keeper. - transfer "github.com/evmos/evmos/v14/x/ibc/transfer" - transferkeeper "github.com/evmos/evmos/v14/x/ibc/transfer/keeper" + transfer "github.com/evmos/evmos/v16/x/ibc/transfer" + transferkeeper "github.com/evmos/evmos/v16/x/ibc/transfer/keeper" "cosmossdk.io/simapp" simappparams "cosmossdk.io/simapp/params" @@ -108,7 +108,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" - srvflags "github.com/evmos/evmos/v14/server/flags" + srvflags "github.com/evmos/evmos/v16/server/flags" "github.com/cosmos/cosmos-sdk/x/auth" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" @@ -179,28 +179,21 @@ import ( "github.com/ExocoreNetwork/exocore/x/evm" evmkeeper "github.com/ExocoreNetwork/exocore/x/evm/keeper" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" - "github.com/evmos/evmos/v14/encoding" - evmostypes "github.com/evmos/evmos/v14/types" - - // The recovery module is an IBC middleware for helping users recover funds that they sent - // to the Cosmos secp256k1 address instead of the Ethereum ethsecp256k1 address. It only - // works for authorized chains. - "github.com/evmos/evmos/v14/x/recovery" - recoverykeeper "github.com/evmos/evmos/v14/x/recovery/keeper" - recoverytypes "github.com/evmos/evmos/v14/x/recovery/types" + "github.com/evmos/evmos/v16/encoding" + evmostypes "github.com/evmos/evmos/v16/types" "github.com/ExocoreNetwork/exocore/x/epochs" epochskeeper "github.com/ExocoreNetwork/exocore/x/epochs/keeper" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" - "github.com/evmos/evmos/v14/x/erc20" - erc20keeper "github.com/evmos/evmos/v14/x/erc20/keeper" - erc20types "github.com/evmos/evmos/v14/x/erc20/types" + "github.com/evmos/evmos/v16/x/erc20" + erc20keeper "github.com/evmos/evmos/v16/x/erc20/keeper" + erc20types "github.com/evmos/evmos/v16/x/erc20/types" // unnamed import of statik for swagger UI support - _ "github.com/evmos/evmos/v14/client/docs/statik" + _ "github.com/evmos/evmos/v16/client/docs/statik" // Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes _ "github.com/ethereum/go-ethereum/eth/tracers/js" @@ -264,7 +257,6 @@ var ( // evmos modules erc20.AppModuleBasic{}, epochs.AppModuleBasic{}, - recovery.AppModuleBasic{}, consensus.AppModuleBasic{}, // Exocore modules assets.AppModuleBasic{}, @@ -345,9 +337,8 @@ type ExocoreApp struct { FeeMarketKeeper feemarketkeeper.Keeper // Evmos keepers - Erc20Keeper erc20keeper.Keeper - EpochsKeeper epochskeeper.Keeper - RecoveryKeeper *recoverykeeper.Keeper + Erc20Keeper erc20keeper.Keeper + EpochsKeeper epochskeeper.Keeper // exocore assets module keepers AssetsKeeper assetsKeeper.Keeper @@ -433,7 +424,6 @@ func NewExocoreApp( // evmos keys erc20types.StoreKey, epochstypes.StoreKey, - recoverytypes.StoreKey, // exoCore module keys assetsTypes.StoreKey, delegationTypes.StoreKey, @@ -703,36 +693,19 @@ func NewExocoreApp( ), ) - // the recovery keeper is used to help recover any assets wrongly sent (over IBC) to the - // Cosmos address instead of Eth address by users. it needs IBC related stuff initialized - // which needs the staking keeper, so it is initialized later in the stack. - app.RecoveryKeeper = recoverykeeper.NewKeeper( - keys[recoverytypes.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, app.BankKeeper, - // ibc related - app.IBCKeeper.ChannelKeeper, &app.TransferKeeper, - ) - - // the ERC20 keeper is used to convert IBC tokens to ERC20 tokens. it only works if such - // conversion is enabled in its parameters. it uses the recovery keeper's params to figure - // out the type (EVM or Cosmos) type of source chain. app.Erc20Keeper = erc20keeper.NewKeeper( keys[erc20types.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.StakingKeeper, app.RecoveryKeeper, + app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.StakingKeeper, + app.AuthzKeeper, &app.TransferKeeper, ) - // remaining bits of the IBC stack: transfer stack and interchain accounts. - - // transfer assets across chains app.TransferKeeper = transferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.RecoveryKeeper, // ICS4 Wrapper: recovery IBC middleware + app.IBCKeeper.ChannelKeeper, // ICS4 Wrapper: claims IBC middleware app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, app.Erc20Keeper, // Add ERC20 Keeper for ERC20 transfers ) - // the middleware for recovery of tokens - app.RecoveryKeeper.SetICS4Wrapper(app.IBCKeeper.ChannelKeeper) // Override the ICS20 app module transferModule := transfer.NewAppModule(app.TransferKeeper) @@ -741,7 +714,7 @@ func NewExocoreApp( app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, app.keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), - app.RecoveryKeeper, + app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, @@ -771,7 +744,6 @@ func NewExocoreApp( var transferStack porttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) - transferStack = recovery.NewIBCMiddleware(*app.RecoveryKeeper, transferStack) transferStack = erc20.NewIBCMiddleware(app.Erc20Keeper, transferStack) // Create static IBC router, add transfer route, then set and seal it @@ -884,8 +856,6 @@ func NewExocoreApp( erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper, app.GetSubspace(erc20types.ModuleName)), epochs.NewAppModule(appCodec, app.EpochsKeeper), - recovery.NewAppModule(*app.RecoveryKeeper, - app.GetSubspace(recoverytypes.ModuleName)), // exoCore app modules exomint.NewAppModule(appCodec, app.ExomintKeeper), assets.NewAppModule(appCodec, app.AssetsKeeper), @@ -923,7 +893,6 @@ func NewExocoreApp( paramstypes.ModuleName, consensusparamtypes.ModuleName, erc20types.ModuleName, - recoverytypes.ModuleName, exominttypes.ModuleName, // called via hooks not directly assetsTypes.ModuleName, operatorTypes.ModuleName, @@ -958,7 +927,6 @@ func NewExocoreApp( upgradetypes.ModuleName, epochstypes.ModuleName, // begin blocker only erc20types.ModuleName, - recoverytypes.ModuleName, exominttypes.ModuleName, consensusparamtypes.ModuleName, assetsTypes.ModuleName, @@ -993,8 +961,7 @@ func NewExocoreApp( // must be after staking to `IterateValidators` but it is not implemented anyway slashingtypes.ModuleName, evidencetypes.ModuleName, - govtypes.ModuleName, // can be anywhere after bank - recoverytypes.ModuleName, // just params + govtypes.ModuleName, // can be anywhere after bank erc20types.ModuleName, ibcexported.ModuleName, ibctransfertypes.ModuleName, @@ -1349,7 +1316,7 @@ func initParamsKeeper( paramsKeeper.Subspace(banktypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName). - WithKeyTable(govv1.ParamKeyTable()) // nolint:staticcheck + WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibcexported.ModuleName) diff --git a/app/ethtest_helper.go b/app/ethtest_helper.go index a09fed3c3..afea9ae01 100644 --- a/app/ethtest_helper.go +++ b/app/ethtest_helper.go @@ -25,9 +25,9 @@ import ( tmtypes "github.com/cometbft/cometbft/proto/tendermint/types" cmtypes "github.com/cometbft/cometbft/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/encoding" - evmostypes "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/encoding" + evmostypes "github.com/evmos/evmos/v16/types" assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" @@ -173,9 +173,9 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, { AssetID: assetID, Info: assetstypes.StakerAssetInfo{ - TotalDepositAmount: depositAmount, - WithdrawableAmount: depositAmount, - WaitUnbondingAmount: sdk.ZeroInt(), + TotalDepositAmount: depositAmount, + WithdrawableAmount: depositAmount, + PendingUndelegationAmount: sdk.ZeroInt(), }, }, }, diff --git a/app/export.go b/app/export.go index 20d95fb8d..9dd4cc559 100644 --- a/app/export.go +++ b/app/export.go @@ -14,9 +14,9 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" - "github.com/evmos/evmos/v14/encoding" + "github.com/evmos/evmos/v16/encoding" ) // NewDefaultGenesisState generates the default state for the application. diff --git a/app/forks.go b/app/forks.go index c60156b39..6cc84ef89 100644 --- a/app/forks.go +++ b/app/forks.go @@ -6,8 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - v82 "github.com/evmos/evmos/v14/app/upgrades/v8_2" - "github.com/evmos/evmos/v14/utils" + v82 "github.com/evmos/evmos/v16/app/upgrades/v8_2" + "github.com/evmos/evmos/v16/utils" ) // ScheduleForkUpgrade executes any necessary fork logic for based upon the current diff --git a/app/test_helpers.go b/app/test_helpers.go index a6e72a25e..a691de689 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -30,10 +30,10 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/encoding" - evmostypes "github.com/evmos/evmos/v14/types" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/encoding" + evmostypes "github.com/evmos/evmos/v16/types" + feemarkettypes "github.com/evmos/evmos/v16/x/feemarket/types" "github.com/ExocoreNetwork/exocore/cmd/config" "github.com/ExocoreNetwork/exocore/utils" @@ -198,9 +198,9 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, { AssetID: assetID, Info: assetstypes.StakerAssetInfo{ - TotalDepositAmount: depositAmount, - WithdrawableAmount: depositAmount, - WaitUnbondingAmount: sdk.ZeroInt(), + TotalDepositAmount: depositAmount, + WithdrawableAmount: depositAmount, + PendingUndelegationAmount: sdk.ZeroInt(), }, }, }, diff --git a/client/config.go b/client/config.go index 7f6b37a52..e9a845b18 100644 --- a/client/config.go +++ b/client/config.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v16/types" ) // InitConfig adds the chain-id, encoding and output flags to the persistent flag set. diff --git a/client/debug/debug.go b/client/debug/debug.go index 1c937a545..0d7b93956 100644 --- a/client/debug/debug.go +++ b/client/debug/debug.go @@ -8,8 +8,8 @@ import ( "strings" authclient "github.com/cosmos/cosmos-sdk/x/auth/client" - "github.com/evmos/evmos/v14/ethereum/eip712" - evmos "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v16/ethereum/eip712" + evmos "github.com/evmos/evmos/v16/types" "github.com/pkg/errors" "github.com/cometbft/cometbft/libs/bytes" diff --git a/client/export.go b/client/export.go index c744e4292..8b6d24962 100644 --- a/client/export.go +++ b/client/export.go @@ -20,8 +20,8 @@ import ( "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/crypto/hd" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/hd" ) // UnsafeExportEthKeyCommand exports a key with the given name as a private key in hex format. diff --git a/client/import.go b/client/import.go index ab1bb49e1..13ddb3401 100644 --- a/client/import.go +++ b/client/import.go @@ -9,9 +9,9 @@ import ( "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/crypto" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/crypto/hd" + "github.com/evmos/evmos/v16/crypto/hd" ) // UnsafeImportKeyCommand imports private keys from a keyfile. diff --git a/client/keys.go b/client/keys.go index 7dc98325a..6c7822c99 100644 --- a/client/keys.go +++ b/client/keys.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/crypto/keyring" - clientkeys "github.com/evmos/evmos/v14/client/keys" - "github.com/evmos/evmos/v14/crypto/hd" + clientkeys "github.com/evmos/evmos/v16/client/keys" + "github.com/evmos/evmos/v16/crypto/hd" ) // KeyCommands registers a sub-tree of commands to interact with diff --git a/client/keys/add.go b/client/keys/add.go index d5dcd8d60..bdc118af5 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -8,7 +8,7 @@ import ( "fmt" "sort" - cryptohd "github.com/evmos/evmos/v14/crypto/hd" + cryptohd "github.com/evmos/evmos/v16/crypto/hd" bip39 "github.com/cosmos/go-bip39" "github.com/spf13/cobra" diff --git a/cmd/config/config.go b/cmd/config/config.go index 29b2de2b4..1b71974d3 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -3,7 +3,7 @@ package config import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v16/types" ) const ( diff --git a/cmd/exocored/genaccounts.go b/cmd/exocored/genaccounts.go index 7b8de4ae8..688823a5c 100644 --- a/cmd/exocored/genaccounts.go +++ b/cmd/exocored/genaccounts.go @@ -20,13 +20,13 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/evmos/evmos/v14/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" - evmoskr "github.com/evmos/evmos/v14/crypto/keyring" + evmoskr "github.com/evmos/evmos/v16/crypto/keyring" - vestingcli "github.com/evmos/evmos/v14/x/vesting/client/cli" - vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" + vestingcli "github.com/evmos/evmos/v16/x/vesting/client/cli" + vestingtypes "github.com/evmos/evmos/v16/x/vesting/types" ) const ( diff --git a/cmd/exocored/migrate.go b/cmd/exocored/migrate.go index dfde9e0a8..486da4ea9 100644 --- a/cmd/exocored/migrate.go +++ b/cmd/exocored/migrate.go @@ -16,7 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/version" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/evmos/evmos/v14/utils" + "github.com/evmos/evmos/v16/utils" ) // FlagGenesisTime defines the genesis time in string format diff --git a/cmd/exocored/root.go b/cmd/exocored/root.go index 14a1b95c6..285fc572a 100644 --- a/cmd/exocored/root.go +++ b/cmd/exocored/root.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "os" - "path" "path/filepath" "time" @@ -43,15 +42,14 @@ import ( app "github.com/ExocoreNetwork/exocore/app" evmosclient "github.com/ExocoreNetwork/exocore/client" "github.com/ExocoreNetwork/exocore/client/debug" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/ethereum/eip712" - evmosserver "github.com/evmos/evmos/v14/server" - servercfg "github.com/evmos/evmos/v14/server/config" - srvflags "github.com/evmos/evmos/v14/server/flags" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/ethereum/eip712" + evmosserver "github.com/evmos/evmos/v16/server" + servercfg "github.com/evmos/evmos/v16/server/config" + srvflags "github.com/evmos/evmos/v16/server/flags" cmdcfg "github.com/ExocoreNetwork/exocore/cmd/config" - pricefeeder "github.com/ExocoreNetwork/price-feeder/external" - evmoskr "github.com/evmos/evmos/v14/crypto/keyring" + evmoskr "github.com/evmos/evmos/v16/crypto/keyring" ) const ( @@ -144,18 +142,21 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { preRunE := startCmd.PreRunE // add preRun to run price-feeder first before starting the node startCmd.PreRunE = func(cmd *cobra.Command, args []string) error { - if enableFeeder, _ := cmd.Flags().GetBool(flagOracle); enableFeeder { - clientCtx := cmd.Context().Value(client.ClientContextKey).(*client.Context) - go func() { - defer func() { - if err := recover(); err != nil { - fmt.Println("price-feeder failed", err) - } + // TODO: Temporarily disable the price feeder to fix the issue caused by two different versions of the EVMOS dependency. + // This needs to be re-enabled after the price feeder updates the EVMOS dependency to v16 and updates the Exocore dependency + // to the version that includes this fix. + /* if enableFeeder, _ := cmd.Flags().GetBool(flagOracle); enableFeeder { + clientCtx := cmd.Context().Value(client.ClientContextKey).(*client.Context) + go func() { + defer func() { + if err := recover(); err != nil { + fmt.Println("price-feeder failed", err) + } + }() + mnemonic, _ := cmd.Flags().GetString(flagMnemonic) + pricefeeder.StartPriceFeeder(path.Join(clientCtx.HomeDir, confPath, confOracle), mnemonic, path.Join(clientCtx.HomeDir, confPath)) }() - mnemonic, _ := cmd.Flags().GetString(flagMnemonic) - pricefeeder.StartPriceFeeder(path.Join(clientCtx.HomeDir, confPath, confOracle), mnemonic, path.Join(clientCtx.HomeDir, confPath)) - }() - } + }*/ return preRunE(cmd, args) } // add keybase, auxiliary RPC, query, and tx child commands diff --git a/cmd/exocored/testnet.go b/cmd/exocored/testnet.go index 13ece2eb8..bfae2fdc0 100644 --- a/cmd/exocored/testnet.go +++ b/cmd/exocored/testnet.go @@ -41,16 +41,16 @@ import ( govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/evmos/evmos/v14/crypto/hd" - "github.com/evmos/evmos/v14/server/config" - srvflags "github.com/evmos/evmos/v14/server/flags" + "github.com/evmos/evmos/v16/crypto/hd" + "github.com/evmos/evmos/v16/server/config" + srvflags "github.com/evmos/evmos/v16/server/flags" - evmostypes "github.com/evmos/evmos/v14/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" cmdcfg "github.com/ExocoreNetwork/exocore/cmd/config" - evmoskr "github.com/evmos/evmos/v14/crypto/keyring" - "github.com/evmos/evmos/v14/testutil/network" + evmoskr "github.com/evmos/evmos/v16/crypto/keyring" + "github.com/evmos/evmos/v16/testutil/network" assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" @@ -407,9 +407,9 @@ func getTestExocoreGenesis( { AssetID: assetID, Info: assetstypes.StakerAssetInfo{ - TotalDepositAmount: depositAmount, - WithdrawableAmount: depositAmount, - WaitUnbondingAmount: sdk.ZeroInt(), + TotalDepositAmount: depositAmount, + WithdrawableAmount: depositAmount, + PendingUndelegationAmount: sdk.ZeroInt(), }, }, }, diff --git a/go.mod b/go.mod index a4da6545f..3ed399d24 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( cosmossdk.io/math v1.2.0 cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d cosmossdk.io/tools/rosetta v0.2.1 - github.com/ExocoreNetwork/price-feeder v0.1.8 github.com/agiledragon/gomonkey/v2 v2.11.0 github.com/armon/go-metrics v0.4.1 github.com/cometbft/cometbft v0.37.4 @@ -18,9 +17,9 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v7 v7.4.0 github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76 - github.com/evmos/evmos/v14 v14.0.0-rc4 + github.com/evmos/evmos/v16 v16.0.0 github.com/golang/protobuf v1.5.4 - github.com/gorilla/mux v1.8.0 + github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 github.com/onsi/ginkgo/v2 v2.15.0 @@ -43,7 +42,7 @@ require ( google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v2 v2.4.0 - sigs.k8s.io/yaml v1.3.0 + sigs.k8s.io/yaml v1.4.0 ) require ( @@ -53,7 +52,7 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/gorilla/websocket v1.5.1 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/rs/cors v1.11.0 // indirect @@ -76,6 +75,7 @@ require ( github.com/99designs/keyring v1.2.1 // indirect github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/VictoriaMetrics/fastcache v1.12.1 // indirect + github.com/alitto/pond v1.8.3 // 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 @@ -94,11 +94,14 @@ require ( github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v0.20.1 // indirect + github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/creachadair/taskgroup v0.4.2 // indirect + github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20231027074119-c05c9c61c90e // indirect + github.com/crypto-org-chain/cronos/store v0.0.5-0.20231027074119-c05c9c61c90e // indirect + github.com/crypto-org-chain/cronos/versiondb v0.0.0-20231027074119-c05c9c61c90e // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/deckarep/golang-set v1.8.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect @@ -110,7 +113,7 @@ require ( github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.1-0.20231206184617-48ba0b76bc88 // indirect - github.com/edsrzf/mmap-go v1.0.0 // indirect + github.com/edsrzf/mmap-go v1.1.0 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect @@ -165,9 +168,10 @@ require ( github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect + github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 // indirect github.com/lib/pq v1.10.9 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/linxGnu/grocksdb v1.7.16 // indirect + github.com/linxGnu/grocksdb v1.8.5 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -213,20 +217,22 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect github.com/tidwall/btree v1.6.0 // indirect - github.com/tidwall/gjson v1.14.4 // indirect + github.com/tidwall/gjson v1.17.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/tidwall/sjson v1.2.5 // indirect + github.com/tidwall/tinylru v1.1.0 // indirect + github.com/tidwall/wal v1.1.7 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opentelemetry.io/otel v1.19.0 // indirect go.opentelemetry.io/otel/metric v1.19.0 // indirect go.opentelemetry.io/otel/trace v1.19.0 // indirect - go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sync v0.6.0 // indirect @@ -256,7 +262,7 @@ replace ( // use Evmos geth fork github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2 // use exocore fork of evmos TODO - github.com/evmos/evmos/v14 => github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240408040728-a6f685cfebb9 + github.com/evmos/evmos/v16 => github.com/ExocoreNetwork/evmos/v16 v16.0.3-0.20240828081344-d5cfcd34a812 // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 // replace broken goleveldb diff --git a/go.sum b/go.sum index 0dfb8c2c0..577d57acd 100644 --- a/go.sum +++ b/go.sum @@ -545,10 +545,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240408040728-a6f685cfebb9 h1:/jL9TiINGniPOG2bRfLmyCFSwMy/vFZ1Ta0OoE+xJaE= -github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240408040728-a6f685cfebb9/go.mod h1:Hi3CAMxAE+H7Fs7sSHsHKb4DZIURk+trop+mMrjlZqw= -github.com/ExocoreNetwork/price-feeder v0.1.8 h1:EmfbcmhLS52O2R0x896JJ75kHMJtZRnUK8AsYynsIfc= -github.com/ExocoreNetwork/price-feeder v0.1.8/go.mod h1:kR+bjps5I/YEZMPtFWEIzO6VM+6TaJ+fNotBDHDIIrg= +github.com/ExocoreNetwork/evmos/v16 v16.0.3-0.20240828081344-d5cfcd34a812 h1:4P/4GZ89DOy9uNPDlEwebPytKltbimq8wn9XiuX96vw= +github.com/ExocoreNetwork/evmos/v16 v16.0.3-0.20240828081344-d5cfcd34a812/go.mod h1:w0vtRYI4I0/O8eihq6ZuDvlca4ZiYCKN6vpakG9zHcc= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= 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= @@ -578,6 +576,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= +github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= @@ -729,8 +729,8 @@ github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiK github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= -github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= -github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= +github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583 h1:3Matt7/LjZiZkIBPalYazOZcw2B05Ch14dU5TJyqJEc= +github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= github.com/cosmos/ibc-go/v7 v7.4.0 h1:8FqYMptvksgMvlbN4UW9jFxTXzsPyfAzEZurujXac8M= github.com/cosmos/ibc-go/v7 v7.4.0/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= @@ -750,6 +750,12 @@ github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJF github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20231027074119-c05c9c61c90e h1:1+NtTl/lzVNKXZUv41HYQ76gtxojDi6gbQrxM2lgDpo= +github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20231027074119-c05c9c61c90e/go.mod h1:PMRblIxBPdkHeEw36YxCWLO0DylfmEJYIgmdo6VgwZo= +github.com/crypto-org-chain/cronos/store v0.0.5-0.20231027074119-c05c9c61c90e h1:3mq9zn5+49covVejnfwPIIx0i6pzRXxKJzz4PuVVn9g= +github.com/crypto-org-chain/cronos/store v0.0.5-0.20231027074119-c05c9c61c90e/go.mod h1:N6IfJDLTTo0vxyuY4MSMMX2TOdBd/tozpjnYGJmAfmE= +github.com/crypto-org-chain/cronos/versiondb v0.0.0-20231027074119-c05c9c61c90e h1:kN1HNLp2xmy8vIHpGWjsX8dCL6sXID2Tw4qZZk7XYd4= +github.com/crypto-org-chain/cronos/versiondb v0.0.0-20231027074119-c05c9c61c90e/go.mod h1:8W9LCw+FhR2sFI+nkjSi0ItZ0IeSyUjc6CSvuaYTU2s= github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U= github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -802,8 +808,9 @@ github.com/dvsekhvalnov/jose2go v1.5.1-0.20231206184617-48ba0b76bc88/go.mod h1:Q 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= -github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ= +github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -1066,12 +1073,12 @@ github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= @@ -1217,6 +1224,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= 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= @@ -1225,8 +1234,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.7.16 h1:Q2co1xrpdkr5Hx3Fp+f+f7fRGhQFQhvi/+226dtLmA8= -github.com/linxGnu/grocksdb v1.7.16/go.mod h1:JkS7pl5qWpGpuVb3bPqTz8nC12X3YtPZT+Xq7+QfQo4= +github.com/linxGnu/grocksdb v1.8.5 h1:Okfk5B1h0ikCYdDM7Tc5yJUS8LTwAmMBq5IPWTmOLPs= +github.com/linxGnu/grocksdb v1.8.5/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o= @@ -1533,15 +1542,20 @@ github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYR github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8= github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= +github.com/tidwall/tinylru v1.1.0 h1:XY6IUfzVTU9rpwdhKUF6nQdChgCdGjkMfLzbWyiau6I= +github.com/tidwall/tinylru v1.1.0/go.mod h1:3+bX+TJ2baOLMWTnlyNWHh4QMnFyARg2TLTQ6OFbzw8= +github.com/tidwall/wal v1.1.7 h1:emc1TRjIVsdKKSnpwGBAcsAGg0767SvUk8+ygx7Bb+4= +github.com/tidwall/wal v1.1.7/go.mod h1:r6lR1j27W9EPalgHiB7zLJDYu3mzW5BQP5KrzBpYY/E= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= @@ -1576,6 +1590,8 @@ github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d h1:XQyeLr7N9iY9mi+TGgsBFkj54+j3fdoo8e2u6zrGP5A= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d/go.mod h1:hoMeDjlNXTNqVwrCk8YDyaBS2g5vFfEX2ezMi4vb6CY= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= @@ -1612,8 +1628,6 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= @@ -2413,6 +2427,6 @@ rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/local_node.sh b/local_node.sh index 892e12409..25b6577f8 100755 --- a/local_node.sh +++ b/local_node.sh @@ -102,7 +102,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq '.app_state["assets"]["deposits"][0]["deposits"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["total_deposit_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["withdrawable_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["wait_unbonding_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["pending_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/oracle jq '.app_state["oracle"]["params"]["tokens"][1]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" diff --git a/precompiles/assets/assets.go b/precompiles/assets/assets.go index cb8b10f01..3647d5462 100644 --- a/precompiles/assets/assets.go +++ b/precompiles/assets/assets.go @@ -13,7 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) var _ vm.PrecompiledContract = &Precompile{} @@ -86,6 +86,10 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ // It avoids panics and returns the out of gas error so the EVM can continue gracefully. defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + if err := stateDB.Commit(); err != nil { + return nil, err + } + switch method.Name { // transactions case MethodDepositTo, MethodWithdraw: diff --git a/precompiles/assets/assets_test.go b/precompiles/assets/assets_test.go index 24ff69c2f..7ff525a97 100644 --- a/precompiles/assets/assets_test.go +++ b/precompiles/assets/assets_test.go @@ -6,14 +6,14 @@ import ( sdkmath "cosmossdk.io/math" assetsprecompile "github.com/ExocoreNetwork/exocore/precompiles/assets" assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" - "github.com/evmos/evmos/v14/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/statedb" "github.com/ExocoreNetwork/exocore/app" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (s *AssetsPrecompileSuite) TestIsTransaction() { diff --git a/precompiles/assets/tx.go b/precompiles/assets/tx.go index 5bba5833b..8a1948803 100644 --- a/precompiles/assets/tx.go +++ b/precompiles/assets/tx.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) const ( diff --git a/precompiles/assets/types.go b/precompiles/assets/types.go index 633aab05d..78297bd47 100644 --- a/precompiles/assets/types.go +++ b/precompiles/assets/types.go @@ -15,7 +15,7 @@ import ( "github.com/ExocoreNetwork/exocore/x/assets/types" oracletypes "github.com/ExocoreNetwork/exocore/x/oracle/types" sdk "github.com/cosmos/cosmos-sdk/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) // oracleInfo: '[tokenName],[chainName],[tokenDecimal](,[interval],[contract](,[ChainDesc:{...}],[TokenDesc:{...}]))' diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go index 5024752c0..926bee5ee 100644 --- a/precompiles/avs/avs.go +++ b/precompiles/avs/avs.go @@ -11,7 +11,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) var _ vm.PrecompiledContract = &Precompile{} @@ -84,6 +84,10 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ // It avoids panics and returns the out of gas error so the EVM can continue gracefully. defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + if err := stateDB.Commit(); err != nil { + return nil, err + } + switch method.Name { case MethodRegisterAVS: bz, err = p.RegisterAVS(ctx, evm.Origin, contract, stateDB, method, args) diff --git a/precompiles/avs/avs_test.go b/precompiles/avs/avs_test.go index 5ea6480a7..88973834c 100644 --- a/precompiles/avs/avs_test.go +++ b/precompiles/avs/avs_test.go @@ -13,9 +13,9 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (suite *AVSManagerPrecompileSuite) TestIsTransaction() { diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index 6f8c63824..1bdc8294c 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -6,7 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) const ( diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 80b7083ed..a3a6d627f 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) const ( diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 67c09410e..e9558a710 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -13,7 +13,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) const ( diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go index dab2cb2c9..e26cba10e 100644 --- a/precompiles/avs/types.go +++ b/precompiles/avs/types.go @@ -8,7 +8,7 @@ import ( avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" "golang.org/x/xerrors" ) diff --git a/precompiles/bls/bls.go b/precompiles/bls/bls.go index 3c02bb2b9..9beb92290 100644 --- a/precompiles/bls/bls.go +++ b/precompiles/bls/bls.go @@ -11,7 +11,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) var _ vm.PrecompiledContract = &Precompile{} diff --git a/precompiles/bls/methods.go b/precompiles/bls/methods.go index c506fadd2..2b3694668 100644 --- a/precompiles/bls/methods.go +++ b/precompiles/bls/methods.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/ethereum/go-ethereum/accounts/abi" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" "github.com/prysmaticlabs/prysm/v4/crypto/bls" "github.com/prysmaticlabs/prysm/v4/crypto/bls/blst" "github.com/prysmaticlabs/prysm/v4/crypto/bls/common" diff --git a/precompiles/delegation/delegation.go b/precompiles/delegation/delegation.go index 626b7faa7..9dafcec92 100644 --- a/precompiles/delegation/delegation.go +++ b/precompiles/delegation/delegation.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) var _ vm.PrecompiledContract = &Precompile{} @@ -88,6 +88,11 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ // This handles any out of gas errors that may occur during the execution of a precompile tx or query. // It avoids panics and returns the out of gas error so the EVM can continue gracefully. defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + + if err := stateDB.Commit(); err != nil { + return nil, err + } + switch method.Name { // delegation transactions case MethodDelegateToThroughClientChain: diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 7cf4d1001..bbfa773d6 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -18,8 +18,8 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (s *DelegationPrecompileSuite) TestIsTransaction() { diff --git a/precompiles/delegation/tx.go b/precompiles/delegation/tx.go index 14c83a05d..594f86458 100644 --- a/precompiles/delegation/tx.go +++ b/precompiles/delegation/tx.go @@ -5,7 +5,7 @@ import ( "reflect" exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" diff --git a/precompiles/delegation/types.go b/precompiles/delegation/types.go index b35bc9b26..62674abd8 100644 --- a/precompiles/delegation/types.go +++ b/precompiles/delegation/types.go @@ -10,7 +10,7 @@ import ( "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" sdk "github.com/cosmos/cosmos-sdk/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interface{}) (*delegationtypes.DelegationOrUndelegationParams, error) { diff --git a/precompiles/reward/parser.go b/precompiles/reward/parser.go index f9caba076..b161e86d4 100644 --- a/precompiles/reward/parser.go +++ b/precompiles/reward/parser.go @@ -10,7 +10,7 @@ import ( "github.com/ExocoreNetwork/exocore/x/reward/keeper" sdk "github.com/cosmos/cosmos-sdk/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{}) (*keeper.RewardParams, error) { diff --git a/precompiles/reward/reward.go b/precompiles/reward/reward.go index e8ff0f9d7..95f345e02 100644 --- a/precompiles/reward/reward.go +++ b/precompiles/reward/reward.go @@ -15,7 +15,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) var _ vm.PrecompiledContract = &Precompile{} @@ -92,6 +92,10 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ // It avoids panics and returns the out of gas error so the EVM can continue gracefully. defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + if err := stateDB.Commit(); err != nil { + return nil, err + } + if method.Name == MethodReward { bz, err = p.Reward(ctx, evm.Origin, contract, stateDB, method, args) } diff --git a/precompiles/reward/reward_test.go b/precompiles/reward/reward_test.go index cb1c0e055..4ca097fe6 100644 --- a/precompiles/reward/reward_test.go +++ b/precompiles/reward/reward_test.go @@ -12,8 +12,8 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (s *RewardPrecompileTestSuite) TestIsTransaction() { diff --git a/precompiles/slash/parser.go b/precompiles/slash/parser.go index 6ea2fb664..c110a9481 100644 --- a/precompiles/slash/parser.go +++ b/precompiles/slash/parser.go @@ -9,7 +9,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/x/slash/keeper" sdk "github.com/cosmos/cosmos-sdk/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{}) (*keeper.SlashParams, error) { diff --git a/precompiles/slash/slash.go b/precompiles/slash/slash.go index eb9203f1f..d38d9086e 100644 --- a/precompiles/slash/slash.go +++ b/precompiles/slash/slash.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - cmn "github.com/evmos/evmos/v14/precompiles/common" + cmn "github.com/evmos/evmos/v16/precompiles/common" ) var _ vm.PrecompiledContract = &Precompile{} @@ -91,6 +91,10 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ // It avoids panics and returns the out of gas error so the EVM can continue gracefully. defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + if err := stateDB.Commit(); err != nil { + return nil, err + } + if method.Name == MethodSlash { bz, err = p.SubmitSlash(ctx, evm.Origin, contract, stateDB, method, args) } diff --git a/precompiles/slash/slash_test.go b/precompiles/slash/slash_test.go index 8f806b8ba..bb859ba28 100644 --- a/precompiles/slash/slash_test.go +++ b/precompiles/slash/slash_test.go @@ -12,8 +12,8 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func (s *SlashPrecompileTestSuite) TestIsTransaction() { diff --git a/precompiles/testutil/contracts/contracts.go b/precompiles/testutil/contracts/contracts.go index 03a1395e7..a15513773 100644 --- a/precompiles/testutil/contracts/contracts.go +++ b/precompiles/testutil/contracts/contracts.go @@ -11,8 +11,8 @@ import ( abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // Call is a helper function to call any arbitrary smart contract. diff --git a/precompiles/testutil/contracts/deposit_caller.go b/precompiles/testutil/contracts/deposit_caller.go index adbdd1138..e4e286df7 100644 --- a/precompiles/testutil/contracts/deposit_caller.go +++ b/precompiles/testutil/contracts/deposit_caller.go @@ -4,7 +4,7 @@ import ( _ "embed" // embed compiled smart contract "encoding/json" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) var ( diff --git a/precompiles/testutil/contracts/types.go b/precompiles/testutil/contracts/types.go index 95595f83e..8964478c6 100644 --- a/precompiles/testutil/contracts/types.go +++ b/precompiles/testutil/contracts/types.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" ) // CallArgs is a struct to define all relevant data to call a smart contract. diff --git a/precompiles/testutil/errors.go b/precompiles/testutil/errors.go index 1f72d94c5..9f22dbfe0 100644 --- a/precompiles/testutil/errors.go +++ b/precompiles/testutil/errors.go @@ -5,7 +5,7 @@ import ( "strings" abci "github.com/cometbft/cometbft/abci/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // CheckVMError is a helper function used to check if the transaction is reverted with the expected error message diff --git a/precompiles/testutil/events.go b/precompiles/testutil/events.go index a5985dc5c..634f1b0a3 100644 --- a/precompiles/testutil/events.go +++ b/precompiles/testutil/events.go @@ -11,7 +11,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // CheckAuthorizationEvents is a helper function used in the integration tests and checks if the approval event is emitted. diff --git a/precompiles/testutil/logs.go b/precompiles/testutil/logs.go index d31de57cf..28493d13c 100644 --- a/precompiles/testutil/logs.go +++ b/precompiles/testutil/logs.go @@ -5,7 +5,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/ethereum/go-ethereum/accounts/abi" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" "golang.org/x/exp/slices" ) diff --git a/proto/ethermint/crypto/v1/ethsecp256k1/keys.proto b/proto/ethermint/crypto/v1/ethsecp256k1/keys.proto index 508f7c6f6..40b5f5b53 100644 --- a/proto/ethermint/crypto/v1/ethsecp256k1/keys.proto +++ b/proto/ethermint/crypto/v1/ethsecp256k1/keys.proto @@ -4,7 +4,7 @@ package ethermint.crypto.v1.ethsecp256k1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/crypto/ethsecp256k1"; +option go_package = "github.com/evmos/evmos/v16/crypto/ethsecp256k1"; // PubKey defines a type alias for an ecdsa.PublicKey that implements // Tendermint's PubKey interface. It represents the 33-byte compressed public diff --git a/proto/ethermint/evm/v1/events.proto b/proto/ethermint/evm/v1/events.proto index 3573f6d20..6d57f1354 100644 --- a/proto/ethermint/evm/v1/events.proto +++ b/proto/ethermint/evm/v1/events.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package ethermint.evm.v1; -option go_package = "github.com/evmos/evmos/v14/x/evm/types"; +option go_package = "github.com/evmos/evmos/v16/x/evm/types"; // EventEthereumTx defines the event for an Ethereum transaction message EventEthereumTx { diff --git a/proto/ethermint/evm/v1/evm.proto b/proto/ethermint/evm/v1/evm.proto index 5a3e140b7..56252be2d 100644 --- a/proto/ethermint/evm/v1/evm.proto +++ b/proto/ethermint/evm/v1/evm.proto @@ -4,7 +4,7 @@ package ethermint.evm.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/evm/types"; +option go_package = "github.com/evmos/evmos/v16/x/evm/types"; // Params defines the EVM module parameters message Params { diff --git a/proto/ethermint/evm/v1/genesis.proto b/proto/ethermint/evm/v1/genesis.proto index 145c1432f..ef5fe99a4 100644 --- a/proto/ethermint/evm/v1/genesis.proto +++ b/proto/ethermint/evm/v1/genesis.proto @@ -5,7 +5,7 @@ package ethermint.evm.v1; import "ethermint/evm/v1/evm.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/evm/types"; +option go_package = "github.com/evmos/evmos/v16/x/evm/types"; // GenesisState defines the evm module's genesis state. message GenesisState { diff --git a/proto/ethermint/evm/v1/query.proto b/proto/ethermint/evm/v1/query.proto index fc8cfe516..846fae46e 100644 --- a/proto/ethermint/evm/v1/query.proto +++ b/proto/ethermint/evm/v1/query.proto @@ -9,7 +9,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/evmos/evmos/v14/x/evm/types"; +option go_package = "github.com/evmos/evmos/v16/x/evm/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/ethermint/evm/v1/tx.proto b/proto/ethermint/evm/v1/tx.proto index 1f780292f..6fcca6a01 100644 --- a/proto/ethermint/evm/v1/tx.proto +++ b/proto/ethermint/evm/v1/tx.proto @@ -9,7 +9,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; -option go_package = "github.com/evmos/evmos/v14/x/evm/types"; +option go_package = "github.com/evmos/evmos/v16/x/evm/types"; // Msg defines the evm Msg service. service Msg { diff --git a/proto/ethermint/feemarket/v1/events.proto b/proto/ethermint/feemarket/v1/events.proto index 56ad7e8e7..3087cd57e 100644 --- a/proto/ethermint/feemarket/v1/events.proto +++ b/proto/ethermint/feemarket/v1/events.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package ethermint.feemarket.v1; -option go_package = "github.com/evmos/evmos/v14/x/feemarket/types"; +option go_package = "github.com/evmos/evmos/v16/x/feemarket/types"; // EventFeeMarket is the event type for the fee market module message EventFeeMarket { diff --git a/proto/ethermint/feemarket/v1/feemarket.proto b/proto/ethermint/feemarket/v1/feemarket.proto index 3af2d0dc9..05ebe3a81 100644 --- a/proto/ethermint/feemarket/v1/feemarket.proto +++ b/proto/ethermint/feemarket/v1/feemarket.proto @@ -4,7 +4,7 @@ package ethermint.feemarket.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/feemarket/types"; +option go_package = "github.com/evmos/evmos/v16/x/feemarket/types"; // Params defines the EVM module parameters message Params { diff --git a/proto/ethermint/feemarket/v1/genesis.proto b/proto/ethermint/feemarket/v1/genesis.proto index 50e9f679a..ea7ff28d7 100644 --- a/proto/ethermint/feemarket/v1/genesis.proto +++ b/proto/ethermint/feemarket/v1/genesis.proto @@ -5,7 +5,7 @@ package ethermint.feemarket.v1; import "ethermint/feemarket/v1/feemarket.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/feemarket/types"; +option go_package = "github.com/evmos/evmos/v16/x/feemarket/types"; // GenesisState defines the feemarket module's genesis state. message GenesisState { diff --git a/proto/ethermint/feemarket/v1/query.proto b/proto/ethermint/feemarket/v1/query.proto index 385670eaa..228bdc7c7 100644 --- a/proto/ethermint/feemarket/v1/query.proto +++ b/proto/ethermint/feemarket/v1/query.proto @@ -6,7 +6,7 @@ import "ethermint/feemarket/v1/feemarket.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/feemarket/types"; +option go_package = "github.com/evmos/evmos/v16/x/feemarket/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/ethermint/feemarket/v1/tx.proto b/proto/ethermint/feemarket/v1/tx.proto index 2f7ef3978..2ffe0e99e 100644 --- a/proto/ethermint/feemarket/v1/tx.proto +++ b/proto/ethermint/feemarket/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "ethermint/feemarket/v1/feemarket.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/feemarket/types"; +option go_package = "github.com/evmos/evmos/v16/x/feemarket/types"; // Msg defines the erc20 Msg service. service Msg { diff --git a/proto/ethermint/types/v1/account.proto b/proto/ethermint/types/v1/account.proto index 711cbcacc..768d3ab86 100644 --- a/proto/ethermint/types/v1/account.proto +++ b/proto/ethermint/types/v1/account.proto @@ -6,7 +6,7 @@ import "cosmos/auth/v1beta1/auth.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/types"; +option go_package = "github.com/evmos/evmos/v16/types"; // EthAccount implements the authtypes.AccountI interface and embeds an // authtypes.BaseAccount type. It is compatible with the auth AccountKeeper. diff --git a/proto/ethermint/types/v1/dynamic_fee.proto b/proto/ethermint/types/v1/dynamic_fee.proto index 4ce2d82cf..29ab28aba 100644 --- a/proto/ethermint/types/v1/dynamic_fee.proto +++ b/proto/ethermint/types/v1/dynamic_fee.proto @@ -4,7 +4,7 @@ package ethermint.types.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/types"; +option go_package = "github.com/evmos/evmos/v16/types"; // ExtensionOptionDynamicFeeTx is an extension option that specifies the maxPrioPrice for cosmos tx message ExtensionOptionDynamicFeeTx { diff --git a/proto/ethermint/types/v1/indexer.proto b/proto/ethermint/types/v1/indexer.proto index fb7dcc066..4179221c5 100644 --- a/proto/ethermint/types/v1/indexer.proto +++ b/proto/ethermint/types/v1/indexer.proto @@ -4,7 +4,7 @@ package ethermint.types.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/types"; +option go_package = "github.com/evmos/evmos/v16/types"; // TxResult is the value stored in eth tx indexer message TxResult { diff --git a/proto/ethermint/types/v1/web3.proto b/proto/ethermint/types/v1/web3.proto index 185292f52..0994f6d3c 100644 --- a/proto/ethermint/types/v1/web3.proto +++ b/proto/ethermint/types/v1/web3.proto @@ -4,7 +4,7 @@ package ethermint.types.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/types"; +option go_package = "github.com/evmos/evmos/v16/types"; // ExtensionOptionsWeb3Tx is an extension option that specifies the typed chain id, // the fee payer as well as its signature data. diff --git a/proto/evmos/claims/v1/claims.proto b/proto/evmos/claims/v1/claims.proto index dfab6232f..8b65a81da 100644 --- a/proto/evmos/claims/v1/claims.proto +++ b/proto/evmos/claims/v1/claims.proto @@ -4,7 +4,7 @@ package evmos.claims.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/claims/types"; +option go_package = "github.com/evmos/evmos/v16/x/claims/types"; // Action defines the list of available actions to claim the airdrop tokens. enum Action { diff --git a/proto/evmos/claims/v1/genesis.proto b/proto/evmos/claims/v1/genesis.proto index ddcd9fa49..c0832c97b 100644 --- a/proto/evmos/claims/v1/genesis.proto +++ b/proto/evmos/claims/v1/genesis.proto @@ -7,7 +7,7 @@ import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/evmos/evmos/v14/x/claims/types"; +option go_package = "github.com/evmos/evmos/v16/x/claims/types"; // GenesisState define the claims module's genesis state. message GenesisState { diff --git a/proto/evmos/claims/v1/query.proto b/proto/evmos/claims/v1/query.proto index 12719af52..472546c7b 100644 --- a/proto/evmos/claims/v1/query.proto +++ b/proto/evmos/claims/v1/query.proto @@ -9,7 +9,7 @@ import "evmos/claims/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/claims/types"; +option go_package = "github.com/evmos/evmos/v16/x/claims/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/evmos/claims/v1/tx.proto b/proto/evmos/claims/v1/tx.proto index 0b76bd03a..e16c61708 100644 --- a/proto/evmos/claims/v1/tx.proto +++ b/proto/evmos/claims/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "evmos/claims/v1/genesis.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/claims/types"; +option go_package = "github.com/evmos/evmos/v16/x/claims/types"; // Msg defines the claims Msg service. service Msg { diff --git a/proto/evmos/erc20/v1/erc20.proto b/proto/evmos/erc20/v1/erc20.proto index f2bead9ca..77fdad6bd 100644 --- a/proto/evmos/erc20/v1/erc20.proto +++ b/proto/evmos/erc20/v1/erc20.proto @@ -4,7 +4,7 @@ package evmos.erc20.v1; import "cosmos/bank/v1beta1/bank.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/erc20/types"; +option go_package = "github.com/evmos/evmos/v16/x/erc20/types"; // Owner enumerates the ownership of a ERC20 contract. enum Owner { diff --git a/proto/evmos/erc20/v1/events.proto b/proto/evmos/erc20/v1/events.proto index 9c8e02956..e3a38d2ff 100644 --- a/proto/evmos/erc20/v1/events.proto +++ b/proto/evmos/erc20/v1/events.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package evmos.erc20.v1; -option go_package = "github.com/evmos/evmos/v14/x/erc20/types"; +option go_package = "github.com/evmos/evmos/v16/x/erc20/types"; // EventRegisterPair is an event emitted when a coin is registered. message EventRegisterPair { diff --git a/proto/evmos/erc20/v1/genesis.proto b/proto/evmos/erc20/v1/genesis.proto index afedaedb7..1fe66c70e 100644 --- a/proto/evmos/erc20/v1/genesis.proto +++ b/proto/evmos/erc20/v1/genesis.proto @@ -5,7 +5,7 @@ package evmos.erc20.v1; import "evmos/erc20/v1/erc20.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/erc20/types"; +option go_package = "github.com/evmos/evmos/v16/x/erc20/types"; // GenesisState defines the module's genesis state. message GenesisState { diff --git a/proto/evmos/erc20/v1/query.proto b/proto/evmos/erc20/v1/query.proto index c73a0765d..c22c85cc4 100644 --- a/proto/evmos/erc20/v1/query.proto +++ b/proto/evmos/erc20/v1/query.proto @@ -8,7 +8,7 @@ import "evmos/erc20/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/erc20/types"; +option go_package = "github.com/evmos/evmos/v16/x/erc20/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/evmos/erc20/v1/tx.proto b/proto/evmos/erc20/v1/tx.proto index eae3ef1d6..f54a4c887 100644 --- a/proto/evmos/erc20/v1/tx.proto +++ b/proto/evmos/erc20/v1/tx.proto @@ -9,7 +9,7 @@ import "evmos/erc20/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/erc20/types"; +option go_package = "github.com/evmos/evmos/v16/x/erc20/types"; // Msg defines the erc20 Msg service. service Msg { diff --git a/proto/evmos/incentives/v1/genesis.proto b/proto/evmos/incentives/v1/genesis.proto index 04f39c49e..68cba0c7f 100644 --- a/proto/evmos/incentives/v1/genesis.proto +++ b/proto/evmos/incentives/v1/genesis.proto @@ -5,7 +5,7 @@ import "evmos/incentives/v1/incentives.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/incentives/types"; +option go_package = "github.com/evmos/evmos/v16/x/incentives/types"; // GenesisState defines the module's genesis state. message GenesisState { diff --git a/proto/evmos/incentives/v1/incentives.proto b/proto/evmos/incentives/v1/incentives.proto index 3c68761fc..d96d73155 100644 --- a/proto/evmos/incentives/v1/incentives.proto +++ b/proto/evmos/incentives/v1/incentives.proto @@ -5,7 +5,7 @@ package evmos.incentives.v1; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/evmos/evmos/v14/x/incentives/types"; +option go_package = "github.com/evmos/evmos/v16/x/incentives/types"; // Incentive defines an instance that organizes distribution conditions for a // given smart contract diff --git a/proto/evmos/incentives/v1/query.proto b/proto/evmos/incentives/v1/query.proto index 2164059b8..cf282ebab 100644 --- a/proto/evmos/incentives/v1/query.proto +++ b/proto/evmos/incentives/v1/query.proto @@ -9,7 +9,7 @@ import "evmos/incentives/v1/incentives.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/incentives/types"; +option go_package = "github.com/evmos/evmos/v16/x/incentives/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/evmos/incentives/v1/tx.proto b/proto/evmos/incentives/v1/tx.proto index dffd6dac3..2ee842bd9 100644 --- a/proto/evmos/incentives/v1/tx.proto +++ b/proto/evmos/incentives/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "evmos/incentives/v1/genesis.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/incentives/types"; +option go_package = "github.com/evmos/evmos/v16/x/incentives/types"; // Msg defines the incentives Msg service. service Msg { diff --git a/proto/evmos/inflation/v1/genesis.proto b/proto/evmos/inflation/v1/genesis.proto index 3014532e5..262c5b5a2 100644 --- a/proto/evmos/inflation/v1/genesis.proto +++ b/proto/evmos/inflation/v1/genesis.proto @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto"; import "evmos/inflation/v1/inflation.proto"; -option go_package = "github.com/evmos/evmos/v14/x/inflation/types"; +option go_package = "github.com/evmos/evmos/v16/x/inflation/v1/types"; // GenesisState defines the inflation module's genesis state. message GenesisState { diff --git a/proto/evmos/inflation/v1/inflation.proto b/proto/evmos/inflation/v1/inflation.proto index 45d8c53b6..d13464c81 100644 --- a/proto/evmos/inflation/v1/inflation.proto +++ b/proto/evmos/inflation/v1/inflation.proto @@ -4,7 +4,7 @@ package evmos.inflation.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/inflation/types"; +option go_package = "github.com/evmos/evmos/v16/x/inflation/v1/types"; // InflationDistribution defines the distribution in which inflation is // allocated through minting on each epoch (staking, incentives, community). It diff --git a/proto/evmos/inflation/v1/query.proto b/proto/evmos/inflation/v1/query.proto index 92a120d5c..fa1d71507 100644 --- a/proto/evmos/inflation/v1/query.proto +++ b/proto/evmos/inflation/v1/query.proto @@ -7,7 +7,7 @@ import "evmos/inflation/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/inflation/types"; +option go_package = "github.com/evmos/evmos/v16/x/inflation/v1/types"; // Query provides defines the gRPC querier service. service Query { diff --git a/proto/evmos/inflation/v1/tx.proto b/proto/evmos/inflation/v1/tx.proto index 3c54ab487..c25331a8a 100644 --- a/proto/evmos/inflation/v1/tx.proto +++ b/proto/evmos/inflation/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "evmos/inflation/v1/genesis.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/inflation/types"; +option go_package = "github.com/evmos/evmos/v16/x/inflation/v1/types"; // Msg defines the evm Msg service. service Msg { diff --git a/proto/evmos/recovery/v1/genesis.proto b/proto/evmos/recovery/v1/genesis.proto index 5aa7a2a35..e32a70a08 100644 --- a/proto/evmos/recovery/v1/genesis.proto +++ b/proto/evmos/recovery/v1/genesis.proto @@ -5,7 +5,7 @@ package evmos.recovery.v1; import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; -option go_package = "github.com/evmos/evmos/v14/x/recovery/types"; +option go_package = "github.com/evmos/evmos/v16/x/recovery/types"; // GenesisState defines the recovery module's genesis state. message GenesisState { diff --git a/proto/evmos/recovery/v1/query.proto b/proto/evmos/recovery/v1/query.proto index 9e2a606be..2daa42ac5 100644 --- a/proto/evmos/recovery/v1/query.proto +++ b/proto/evmos/recovery/v1/query.proto @@ -6,7 +6,7 @@ import "evmos/recovery/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/recovery/types"; +option go_package = "github.com/evmos/evmos/v16/x/recovery/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/evmos/recovery/v1/tx.proto b/proto/evmos/recovery/v1/tx.proto index 3dfce0d64..b928ffc04 100644 --- a/proto/evmos/recovery/v1/tx.proto +++ b/proto/evmos/recovery/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "evmos/recovery/v1/genesis.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/recovery/types"; +option go_package = "github.com/evmos/evmos/v16/x/recovery/types"; // Msg defines the recovery Msg service. service Msg { diff --git a/proto/evmos/revenue/v1/events.proto b/proto/evmos/revenue/v1/events.proto index b00250755..99bab41fe 100644 --- a/proto/evmos/revenue/v1/events.proto +++ b/proto/evmos/revenue/v1/events.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package evmos.revenue.v1; -option go_package = "github.com/evmos/evmos/v14/x/revenue/v1/types"; +option go_package = "github.com/evmos/evmos/v16/x/revenue/v1/types"; // EventRegisterRevenue is an event emitted when a contract is registered to receive a percentage of tx fees. message EventRegisterRevenue { diff --git a/proto/evmos/revenue/v1/genesis.proto b/proto/evmos/revenue/v1/genesis.proto index a640bf6ba..28e026771 100644 --- a/proto/evmos/revenue/v1/genesis.proto +++ b/proto/evmos/revenue/v1/genesis.proto @@ -5,7 +5,7 @@ package evmos.revenue.v1; import "evmos/revenue/v1/revenue.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/evmos/evmos/v14/x/revenue/v1/types"; +option go_package = "github.com/evmos/evmos/v16/x/revenue/v1/types"; // GenesisState defines the module's genesis state. message GenesisState { diff --git a/proto/evmos/revenue/v1/query.proto b/proto/evmos/revenue/v1/query.proto index 7e6a4e6d2..6f87c0344 100644 --- a/proto/evmos/revenue/v1/query.proto +++ b/proto/evmos/revenue/v1/query.proto @@ -8,7 +8,7 @@ import "evmos/revenue/v1/revenue.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/revenue/v1/types"; +option go_package = "github.com/evmos/evmos/v16/x/revenue/v1/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/evmos/revenue/v1/revenue.proto b/proto/evmos/revenue/v1/revenue.proto index 742a49632..c34d368f9 100644 --- a/proto/evmos/revenue/v1/revenue.proto +++ b/proto/evmos/revenue/v1/revenue.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package evmos.revenue.v1; -option go_package = "github.com/evmos/evmos/v14/x/revenue/v1/types"; +option go_package = "github.com/evmos/evmos/v16/x/revenue/v1/types"; // Revenue defines an instance that organizes fee distribution conditions for // the owner of a given smart contract diff --git a/proto/evmos/revenue/v1/tx.proto b/proto/evmos/revenue/v1/tx.proto index 932764642..00838faa3 100644 --- a/proto/evmos/revenue/v1/tx.proto +++ b/proto/evmos/revenue/v1/tx.proto @@ -8,7 +8,7 @@ import "evmos/revenue/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/revenue/v1/types"; +option go_package = "github.com/evmos/evmos/v16/x/revenue/v1/types"; // Msg defines the fees Msg service. service Msg { diff --git a/proto/evmos/vesting/v1/events.proto b/proto/evmos/vesting/v1/events.proto index bc040b7ac..4563189ef 100644 --- a/proto/evmos/vesting/v1/events.proto +++ b/proto/evmos/vesting/v1/events.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package evmos.vesting.v1; -option go_package = "github.com/evmos/evmos/v14/x/vesting/types"; +option go_package = "github.com/evmos/evmos/v16/x/vesting/types"; // EventCreateClawbackVestingAccount defines the event type // for creating a clawback vesting account diff --git a/proto/evmos/vesting/v1/query.proto b/proto/evmos/vesting/v1/query.proto index 61366db96..692aa54e1 100644 --- a/proto/evmos/vesting/v1/query.proto +++ b/proto/evmos/vesting/v1/query.proto @@ -6,7 +6,7 @@ import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/evmos/evmos/v14/x/vesting/types"; +option go_package = "github.com/evmos/evmos/v16/x/vesting/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/evmos/vesting/v1/tx.proto b/proto/evmos/vesting/v1/tx.proto index 983e73d6f..c0564125c 100644 --- a/proto/evmos/vesting/v1/tx.proto +++ b/proto/evmos/vesting/v1/tx.proto @@ -7,7 +7,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/evmos/evmos/v14/x/vesting/types"; +option go_package = "github.com/evmos/evmos/v16/x/vesting/types"; // Msg defines the vesting Msg service. service Msg { diff --git a/proto/evmos/vesting/v1/vesting.proto b/proto/evmos/vesting/v1/vesting.proto index b3d8e7f8a..83aeffaab 100644 --- a/proto/evmos/vesting/v1/vesting.proto +++ b/proto/evmos/vesting/v1/vesting.proto @@ -6,7 +6,7 @@ import "cosmos/vesting/v1beta1/vesting.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/evmos/evmos/v14/x/vesting/types"; +option go_package = "github.com/evmos/evmos/v16/x/vesting/types"; // ClawbackVestingAccount implements the VestingAccount interface. It provides // an account that can hold contributions subject to "lockup" (like a diff --git a/proto/exocore/assets/v1/tx.proto b/proto/exocore/assets/v1/tx.proto index 632c75d64..5b1585866 100644 --- a/proto/exocore/assets/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -91,8 +91,8 @@ message StakerAssetInfo { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // wait_unbonding_amount is the amount that is waiting for undelegation. - string wait_unbonding_amount = 3 + // pending_undelegation_amount is the amount that is waiting for undelegation. + string pending_undelegation_amount = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -118,8 +118,8 @@ message OperatorAssetInfo { (gogoproto.nullable) = false ]; - // wait_unbonding_amount is the amount that is waiting for unbonding. - string wait_unbonding_amount = 2 + // pending_undelegation_amount is the amount that is waiting for unbonding. + string pending_undelegation_amount = 2 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/testutil/abci.go b/testutil/abci.go index 7c8bccbf8..e6bc834a9 100644 --- a/testutil/abci.go +++ b/testutil/abci.go @@ -13,7 +13,7 @@ import ( "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/testutil/tx" - "github.com/evmos/evmos/v14/encoding" + "github.com/evmos/evmos/v16/encoding" ) // Commit commits a block at a given time. Reminder: At the end of each diff --git a/testutil/ante.go b/testutil/ante.go index f9fdfa990..de8018223 100644 --- a/testutil/ante.go +++ b/testutil/ante.go @@ -3,7 +3,7 @@ package testutil import ( "github.com/ExocoreNetwork/exocore/app" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/encoding" + "github.com/evmos/evmos/v16/encoding" ) // NextFn is a no-op function that returns the context and no error in order to mock diff --git a/testutil/contract.go b/testutil/contract.go index 8ea51b668..0c0156d7e 100644 --- a/testutil/contract.go +++ b/testutil/contract.go @@ -18,7 +18,7 @@ import ( "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/testutil/tx" - evm "github.com/evmos/evmos/v14/x/evm/types" + evm "github.com/evmos/evmos/v16/x/evm/types" ) // ContractArgs are the params used for calling a smart contract. diff --git a/testutil/fund.go b/testutil/fund.go index 459bcde83..5ac683806 100644 --- a/testutil/fund.go +++ b/testutil/fund.go @@ -1,14 +1,15 @@ package testutil import ( - "github.com/ExocoreNetwork/exocore/utils" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" + "github.com/evmos/evmos/v16/utils" + inflationtypes "github.com/evmos/evmos/v16/x/inflation/v1/types" ) // FundAccount is a utility function that funds an account by minting and -// sending the coins to the Address. +// sending the coins to the address. func FundAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amounts sdk.Coins) error { if err := bankKeeper.MintCoins(ctx, inflationtypes.ModuleName, amounts); err != nil { return err @@ -21,13 +22,13 @@ func FundAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddr // to fund an account with the default Evmos denomination. func FundAccountWithBaseDenom(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amount int64) error { coins := sdk.NewCoins( - sdk.NewCoin(utils.BaseDenom, sdk.NewInt(amount)), + sdk.NewCoin(utils.BaseDenom, math.NewInt(amount)), ) return FundAccount(ctx, bankKeeper, addr, coins) } // FundModuleAccount is a utility function that funds a module account by -// minting and sending the coins to the Address. +// minting and sending the coins to the address. func FundModuleAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, recipientMod string, amounts sdk.Coins) error { if err := bankKeeper.MintCoins(ctx, inflationtypes.ModuleName, amounts); err != nil { return err diff --git a/testutil/integration.go b/testutil/integration.go index dfaa91a96..65c2c7ca2 100644 --- a/testutil/integration.go +++ b/testutil/integration.go @@ -10,7 +10,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ExocoreNetwork/exocore/app" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" ) // SubmitProposal delivers a submit proposal tx for a given gov content. diff --git a/testutil/network/network.go b/testutil/network/network.go index 513e044d1..00b0262d2 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -50,12 +50,12 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/evmos/evmos/v14/crypto/hd" + "github.com/evmos/evmos/v16/crypto/hd" - "github.com/evmos/evmos/v14/encoding" - "github.com/evmos/evmos/v14/server/config" - evmostypes "github.com/evmos/evmos/v14/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/encoding" + "github.com/evmos/evmos/v16/server/config" + evmostypes "github.com/evmos/evmos/v16/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // package-wide network lock to only allow one test network at a time diff --git a/testutil/network/network_test.go b/testutil/network/network_test.go index e412fef33..00cb4d89a 100644 --- a/testutil/network/network_test.go +++ b/testutil/network/network_test.go @@ -12,7 +12,7 @@ import ( "github.com/ExocoreNetwork/exocore/testutil/network" "github.com/ethereum/go-ethereum/ethclient" - "github.com/evmos/evmos/v14/server/config" + "github.com/evmos/evmos/v16/server/config" exocorenetwork "github.com/ExocoreNetwork/exocore/testutil/network" ) diff --git a/testutil/network/util.go b/testutil/network/util.go index 948227192..d9f868d2e 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -27,8 +27,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/evmos/evmos/v14/server" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/server" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) func startInProcess(cfg Config, val *Validator) error { diff --git a/testutil/statedb.go b/testutil/statedb.go index 0e3aae925..10ed87814 100644 --- a/testutil/statedb.go +++ b/testutil/statedb.go @@ -4,7 +4,7 @@ import ( "github.com/ExocoreNetwork/exocore/app/ante/evm" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/statedb" ) // NewStateDB returns a new StateDB for testing purposes. diff --git a/testutil/tx/eip712.go b/testutil/tx/eip712.go index 95ab61eab..d88588bab 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -15,9 +15,9 @@ import ( "github.com/ExocoreNetwork/exocore/app" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - cryptocodec "github.com/evmos/evmos/v14/crypto/codec" - "github.com/evmos/evmos/v14/ethereum/eip712" - "github.com/evmos/evmos/v14/types" + cryptocodec "github.com/evmos/evmos/v16/crypto/codec" + "github.com/evmos/evmos/v16/ethereum/eip712" + "github.com/evmos/evmos/v16/types" ) type EIP712TxArgs struct { diff --git a/testutil/tx/eth.go b/testutil/tx/eth.go index 84aec52c2..53560e29e 100644 --- a/testutil/tx/eth.go +++ b/testutil/tx/eth.go @@ -18,8 +18,8 @@ import ( "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/utils" - "github.com/evmos/evmos/v14/server/config" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/server/config" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // PrepareEthTx creates an ethereum tx and signs it with the provided messages and private key. diff --git a/testutil/tx/signer.go b/testutil/tx/signer.go index 14eadd10c..c439397e2 100644 --- a/testutil/tx/signer.go +++ b/testutil/tx/signer.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/mock" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" ) // NewAddrKey generates an Ethereum address and its corresponding private key. diff --git a/testutil/utils.go b/testutil/utils.go index 0a2ae9691..c45703e8a 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" - "github.com/evmos/evmos/v14/testutil" + "github.com/evmos/evmos/v16/testutil" "github.com/stretchr/testify/suite" "golang.org/x/exp/rand" @@ -34,9 +34,9 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) type BaseTestSuite struct { @@ -112,9 +112,9 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc { AssetID: assetID, Info: assetstypes.StakerAssetInfo{ - TotalDepositAmount: depositAmount, - WithdrawableAmount: depositAmount, - WaitUnbondingAmount: sdk.ZeroInt(), + TotalDepositAmount: depositAmount, + WithdrawableAmount: depositAmount, + PendingUndelegationAmount: sdk.ZeroInt(), }, }, }, @@ -125,9 +125,9 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc { AssetID: assetID, Info: assetstypes.StakerAssetInfo{ - TotalDepositAmount: depositAmount2, - WithdrawableAmount: depositAmount2, - WaitUnbondingAmount: sdk.ZeroInt(), + TotalDepositAmount: depositAmount2, + WithdrawableAmount: depositAmount2, + PendingUndelegationAmount: sdk.ZeroInt(), }, }, }, diff --git a/types/account_test.go b/types/account_test.go index 5d0706dda..90ba21f59 100644 --- a/types/account_test.go +++ b/types/account_test.go @@ -12,10 +12,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - cryptocodec "github.com/evmos/evmos/v14/crypto/codec" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - encodingcodec "github.com/evmos/evmos/v14/encoding/codec" - "github.com/evmos/evmos/v14/types" + cryptocodec "github.com/evmos/evmos/v16/crypto/codec" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + encodingcodec "github.com/evmos/evmos/v16/encoding/codec" + "github.com/evmos/evmos/v16/types" ) func init() { diff --git a/types/chain_id.go b/types/chain_id.go index f4cb91d36..98fb1c6e0 100644 --- a/types/chain_id.go +++ b/types/chain_id.go @@ -8,7 +8,7 @@ import ( errorsmod "cosmossdk.io/errors" - "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v16/types" ) var ( diff --git a/types/validation_test.go b/types/validation_test.go index 7a909b19a..9cce70ce7 100644 --- a/types/validation_test.go +++ b/types/validation_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/evmos/evmos/v14/types" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + "github.com/evmos/evmos/v16/types" "github.com/stretchr/testify/require" ) diff --git a/utils/utils.go b/utils/utils.go index d5407af47..fb1672228 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -3,7 +3,7 @@ package utils import ( "strings" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" diff --git a/utils/utils_test.go b/utils/utils_test.go index 250d09b3c..04c2949cb 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -12,7 +12,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" ) func init() { diff --git a/x/assets/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go index 124597a6a..6168e4f39 100644 --- a/x/assets/keeper/operator_asset.go +++ b/x/assets/keeper/operator_asset.go @@ -49,10 +49,10 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) key := assetstype.GetJoinedStoreKey(operatorAddr.String(), assetID) assetState := assetstype.OperatorAssetInfo{ - TotalAmount: math.NewInt(0), - WaitUnbondingAmount: math.NewInt(0), - TotalShare: math.LegacyNewDec(0), - OperatorShare: math.LegacyNewDec(0), + TotalAmount: math.NewInt(0), + PendingUndelegationAmount: math.NewInt(0), + TotalShare: math.LegacyNewDec(0), + OperatorShare: math.LegacyNewDec(0), } value := store.Get(key) if value != nil { @@ -64,7 +64,7 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState TotalAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.WaitUnbondingAmount) + err = assetstype.UpdateAssetValue(&assetState.PendingUndelegationAmount, &changeAmount.PendingUndelegationAmount) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") } diff --git a/x/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go index dd5474af5..f7e9cb3fb 100644 --- a/x/assets/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -51,9 +51,9 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) key := assetstype.GetJoinedStoreKey(stakerID, assetID) assetState := assetstype.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(0), - WithdrawableAmount: math.NewInt(0), - WaitUnbondingAmount: math.NewInt(0), + TotalDepositAmount: math.NewInt(0), + WithdrawableAmount: math.NewInt(0), + PendingUndelegationAmount: math.NewInt(0), } value := store.Get(key) if value != nil { @@ -68,7 +68,7 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState CanWithdrawAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.WaitUnbondingAmount) + err = assetstype.UpdateAssetValue(&assetState.PendingUndelegationAmount, &changeAmount.PendingUndelegationAmount) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState WaitUndelegationAmountOrWantChangeValue error") } diff --git a/x/assets/types/genesis.go b/x/assets/types/genesis.go index e9feb2802..2b5272bbf 100644 --- a/x/assets/types/genesis.go +++ b/x/assets/types/genesis.go @@ -219,7 +219,7 @@ func (gs GenesisState) Validate() error { info := deposit.Info // check that there is no nil value provided. if info.TotalDepositAmount.IsNil() || info.WithdrawableAmount.IsNil() || - info.WaitUnbondingAmount.IsNil() { + info.PendingUndelegationAmount.IsNil() { return errorsmod.Wrapf( ErrInvalidGenesisData, "nil deposit info for %s: %+v", @@ -227,11 +227,11 @@ func (gs GenesisState) Validate() error { ) } // at genesis (not chain restart), there is no unbonding amount. - if !info.WaitUnbondingAmount.IsZero() { + if !info.PendingUndelegationAmount.IsZero() { return errorsmod.Wrapf( ErrInvalidGenesisData, "non-zero unbonding amount for %s: %s", - assetID, info.WaitUnbondingAmount, + assetID, info.PendingUndelegationAmount, ) } // check for negative values. diff --git a/x/assets/types/genesis_test.go b/x/assets/types/genesis_test.go index 9763d67d6..f9648f6ee 100644 --- a/x/assets/types/genesis_test.go +++ b/x/assets/types/genesis_test.go @@ -1,6 +1,7 @@ package types_test import ( + "fmt" "strings" "testing" @@ -63,9 +64,9 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { { AssetID: assetID, Info: types.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(100), - WaitUnbondingAmount: math.NewInt(0), + TotalDepositAmount: math.NewInt(100), + WithdrawableAmount: math.NewInt(100), + PendingUndelegationAmount: math.NewInt(0), }, }, }, @@ -403,9 +404,9 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, unmalleate: func(gs *types.GenesisState) { genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(0), - WaitUnbondingAmount: math.NewInt(0), + TotalDepositAmount: math.NewInt(100), + WithdrawableAmount: math.NewInt(0), + PendingUndelegationAmount: math.NewInt(0), } gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info }, @@ -424,13 +425,13 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, expPass: false, malleate: func(gs *types.GenesisState) { - gs.Deposits[0].Deposits[0].Info.WaitUnbondingAmount = math.NewInt(1) + gs.Deposits[0].Deposits[0].Info.PendingUndelegationAmount = math.NewInt(1) }, unmalleate: func(gs *types.GenesisState) { genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(0), - WaitUnbondingAmount: math.NewInt(0), + TotalDepositAmount: math.NewInt(100), + WithdrawableAmount: math.NewInt(0), + PendingUndelegationAmount: math.NewInt(0), } gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info }, @@ -453,9 +454,9 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, unmalleate: func(gs *types.GenesisState) { genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(0), - WaitUnbondingAmount: math.NewInt(0), + TotalDepositAmount: math.NewInt(100), + WithdrawableAmount: math.NewInt(0), + PendingUndelegationAmount: math.NewInt(0), } gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info }, @@ -479,9 +480,9 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, unmalleate: func(gs *types.GenesisState) { genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(100), - WaitUnbondingAmount: math.NewInt(0), + TotalDepositAmount: math.NewInt(100), + WithdrawableAmount: math.NewInt(100), + PendingUndelegationAmount: math.NewInt(0), } gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info }, @@ -511,6 +512,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { } err := tc.genState.Validate() if tc.expPass { + fmt.Println("name is:", tc.name) suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) diff --git a/x/assets/types/tx.pb.go b/x/assets/types/tx.pb.go index d2aa735e5..08a0c2961 100644 --- a/x/assets/types/tx.pb.go +++ b/x/assets/types/tx.pb.go @@ -338,8 +338,8 @@ type StakerAssetInfo struct { TotalDepositAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_deposit_amount,json=totalDepositAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_deposit_amount"` // withdrawable_amount is the amount that can be withdrawn. WithdrawableAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=withdrawable_amount,json=withdrawableAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"withdrawable_amount"` - // wait_unbonding_amount is the amount that is waiting for undelegation. - WaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount,json=waitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount"` + // pending_undelegation_amount is the amount that is waiting for undelegation. + PendingUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=pending_undelegation_amount,json=pendingUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"pending_undelegation_amount"` } func (m *StakerAssetInfo) Reset() { *m = StakerAssetInfo{} } @@ -427,8 +427,8 @@ func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerAssetInfo { type OperatorAssetInfo struct { // total_amount is the total amount of the asset deposited. TotalAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_amount,json=totalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_amount"` - // wait_unbonding_amount is the amount that is waiting for unbonding. - WaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=wait_unbonding_amount,json=waitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount"` + // pending_undelegation_amount is the amount that is waiting for unbonding. + PendingUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=pending_undelegation_amount,json=pendingUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"pending_undelegation_amount"` // total_share is the total share of an asset, in the formula to update the staker's share // S_j = S * T_j / T, `S` represent it. // So when the shares of staker and operator change, it also needs to add `S_j` to update. @@ -832,84 +832,84 @@ func init() { func init() { proto.RegisterFile("exocore/assets/v1/tx.proto", fileDescriptor_adb6ebd423a2c426) } var fileDescriptor_adb6ebd423a2c426 = []byte{ - // 1227 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0x13, 0xc7, - 0x17, 0xcf, 0x3a, 0xbf, 0x5f, 0x48, 0xe2, 0x8c, 0x03, 0x38, 0x06, 0x1c, 0xb4, 0x12, 0xdf, 0x6f, - 0x14, 0x35, 0x5e, 0x48, 0x55, 0x4a, 0x43, 0x2f, 0xf9, 0x01, 0x52, 0x2a, 0x68, 0xab, 0x35, 0xf4, - 0x80, 0x54, 0xad, 0xc6, 0xbb, 0x93, 0xf5, 0x2a, 0xbb, 0x33, 0xee, 0xce, 0x98, 0xd8, 0x9c, 0x2a, - 0x4e, 0x55, 0xa5, 0x4a, 0x55, 0x7b, 0xed, 0x81, 0x73, 0x4f, 0x1c, 0x38, 0xf4, 0x4f, 0x40, 0x3d, - 0x51, 0x7a, 0xa9, 0x7a, 0x40, 0x28, 0x54, 0xa2, 0xff, 0x45, 0xab, 0x99, 0x9d, 0xb5, 0xbd, 0x89, - 0x4d, 0xd4, 0xe2, 0x5e, 0x92, 0x9d, 0x79, 0xef, 0x7d, 0xde, 0xfb, 0x7c, 0xe6, 0xcd, 0x0f, 0x43, - 0x89, 0xb4, 0x98, 0xcb, 0x62, 0x62, 0x61, 0xce, 0x89, 0xe0, 0xd6, 0xfd, 0x2b, 0x96, 0x68, 0x55, - 0x1a, 0x31, 0x13, 0x0c, 0x2d, 0x68, 0x5b, 0x25, 0xb1, 0x55, 0xee, 0x5f, 0x29, 0x2d, 0xe0, 0x28, - 0xa0, 0xcc, 0x52, 0x7f, 0x13, 0xaf, 0xd2, 0x59, 0x97, 0xf1, 0x88, 0x71, 0x2b, 0xe2, 0xbe, 0x8c, - 0x8e, 0xb8, 0xaf, 0x0d, 0x4b, 0x89, 0xc1, 0x51, 0x23, 0x2b, 0x19, 0x68, 0x53, 0xf9, 0x78, 0xd6, - 0x06,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0x09, - 0x94, 0xa2, 0xcc, 0xac, 0x9f, 0xaf, 0x1c, 0xdb, 0x97, 0x95, 0x4e, 0x9c, 0x3d, 0xa7, 0x26, 0xb7, - 0x64, 0x90, 0xc2, 0xa1, 0xb0, 0xc8, 0x13, 0x6c, 0x47, 0x30, 0x81, 0x43, 0x47, 0x6f, 0x8b, 0xdc, - 0x10, 0xb6, 0x05, 0xd2, 0xc8, 0x77, 0x24, 0xf0, 0x66, 0xb2, 0x45, 0x0e, 0x73, 0x30, 0x2f, 0xc9, - 0x90, 0xb8, 0xcb, 0x85, 0xc2, 0x62, 0x92, 0xdb, 0x23, 0x0d, 0xc6, 0x03, 0xe1, 0x0c, 0x71, 0x6b, - 0x22, 0x85, 0xbc, 0x93, 0x00, 0x27, 0x35, 0xa0, 0x08, 0x0a, 0x07, 0x81, 0xa8, 0x7b, 0x31, 0x3e, - 0xc0, 0xb5, 0x90, 0x0c, 0x95, 0x72, 0x2f, 0xb0, 0x4e, 0xd7, 0x80, 0xd3, 0x07, 0x38, 0x10, 0x4e, - 0x93, 0xd6, 0x18, 0xf5, 0xa4, 0xd2, 0x3a, 0xe1, 0xe8, 0x10, 0x12, 0x16, 0x24, 0xf4, 0xdd, 0x14, - 0x39, 0x15, 0xd9, 0x80, 0x82, 0x16, 0x39, 0x0c, 0x95, 0xce, 0x5c, 0x09, 0xed, 0x41, 0x1e, 0x87, - 0xa1, 0x93, 0xf4, 0x85, 0xc3, 0x05, 0x16, 0x72, 0x27, 0x8d, 0xae, 0xcc, 0xac, 0x6f, 0xf4, 0x69, - 0x9a, 0x3e, 0x08, 0x95, 0xce, 0xa8, 0x2a, 0x83, 0x6f, 0x50, 0x11, 0xb7, 0xed, 0x39, 0x9c, 0x99, - 0x2c, 0x11, 0x28, 0xf4, 0x71, 0x43, 0x79, 0x18, 0xdd, 0x27, 0x6d, 0xbd, 0x73, 0xe5, 0x27, 0xba, - 0x06, 0xe3, 0xf7, 0xe5, 0x91, 0xac, 0x94, 0x9f,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, - 0x3e, 0x7c, 0x92, 0x14, 0x5b, 0x63, 0xf2, 0x0c, 0xb0, 0xb5, 0xfb, 0xc6, 0x9c, 0x24, 0xd3, 0x05, - 0x32, 0x97, 0xe0, 0xec, 0x91, 0x9a, 0xd2, 0x7a, 0xd7, 0x7f, 0x30, 0x60, 0xf4, 0x36, 0xf7, 0xd1, - 0x37, 0x06, 0x9c, 0xca, 0x14, 0xdd, 0xaf, 0x45, 0x8e, 0x80, 0x94, 0x56, 0x4f, 0xf6, 0xe9, 0x08, - 0xb3, 0xf6, 0xf0, 0xd7, 0x3f, 0xbe, 0xcf, 0xfd, 0xdf, 0xbc, 0x64, 0xf5, 0xfb, 0xa5, 0x62, 0x1d, - 0x85, 0x1e, 0xff, 0xf2, 0xf5, 0xe3, 0x55, 0x63, 0xeb, 0xa3, 0xa7, 0x87, 0x65, 0xe3, 0xd9, 0x61, - 0xd9, 0x78, 0x79, 0x58, 0x36, 0xbe, 0x7d, 0x55, 0x1e, 0x79, 0xf6, 0xaa, 0x3c, 0xf2, 0xdb, 0xab, - 0xf2, 0xc8, 0xbd, 0xcb, 0x3d, 0xa7, 0xdd, 0x8d, 0x04, 0xf1, 0x63, 0x22, 0x0e, 0x58, 0xbc, 0xdf, - 0x49, 0xd0, 0x4a, 0x53, 0xa8, 0xb3, 0xaf, 0x36, 0xa1, 0x7e, 0x5f, 0xbc, 0xfb, 0x77, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xe3, 0x9e, 0x51, 0x04, 0x2b, 0x0d, 0x00, 0x00, + // 1230 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x3a, 0xdf, 0x2f, 0x4d, 0xe2, 0x4c, 0x42, 0x6b, 0x3b, 0xad, 0x53, 0xad, 0x54, 0x88, + 0x22, 0xe2, 0x6d, 0x83, 0x28, 0x25,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 0x21, 0x90, 0xca, 0xc2, + 0xc9, 0x36, 0x2d, 0x62, 0x16, 0x1f, 0xfc, 0xfa, 0xc7, 0xf7, 0x85, 0xb7, 0xec, 0x0b, 0x4e, 0xb7, + 0x5f, 0x30, 0xce, 0x61, 0xe8, 0xc1, 0x2f, 0x0f, 0x1e, 0x2d, 0x58, 0xab, 0x1f, 0x3e, 0xd9, 0xaf, + 0x5a, 0x4f, 0xf7, 0xab, 0xd6, 0x8b, 0xfd, 0xaa, 0xf5, 0xed, 0xcb, 0x6a, 0xdf, 0xd3, 0x97, 0xd5, + 0xbe, 0xdf, 0x5e, 0x56, 0xfb, 0xee, 0x5c, 0xec, 0x38, 0xed, 0xae, 0x69, 0xc4, 0x8f, 0x88, 0xb8, + 0xc7, 0xd2, 0x9d, 0x56, 0x80, 0xbd, 0x2c, 0x84, 0x3a, 0xfb, 0xea, 0x43, 0xea, 0x77, 0xc7, 0x3b, + 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x15, 0x4d, 0x8c, 0xa1, 0x43, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1228,9 +1228,9 @@ func (m *StakerAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.WaitUnbondingAmount.Size() + size := m.PendingUndelegationAmount.Size() i -= size - if _, err := m.WaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.PendingUndelegationAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1350,9 +1350,9 @@ func (m *OperatorAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a { - size := m.WaitUnbondingAmount.Size() + size := m.PendingUndelegationAmount.Size() i -= size - if _, err := m.WaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.PendingUndelegationAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1761,7 +1761,7 @@ func (m *StakerAssetInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.WithdrawableAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUnbondingAmount.Size() + l = m.PendingUndelegationAmount.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1796,7 +1796,7 @@ func (m *OperatorAssetInfo) Size() (n int) { _ = l l = m.TotalAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUnbondingAmount.Size() + l = m.PendingUndelegationAmount.Size() n += 1 + l + sovTx(uint64(l)) l = m.TotalShare.Size() n += 1 + l + sovTx(uint64(l)) @@ -2703,7 +2703,7 @@ func (m *StakerAssetInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PendingUndelegationAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2731,7 +2731,7 @@ func (m *StakerAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PendingUndelegationAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3000,7 +3000,7 @@ func (m *OperatorAssetInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PendingUndelegationAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3028,7 +3028,7 @@ func (m *OperatorAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PendingUndelegationAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index 508ad8526..fc7fa2774 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -9,7 +9,7 @@ import ( "github.com/ExocoreNetwork/exocore/x/avs/types" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/statedb" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/avs/keeper/avs_test.go b/x/avs/keeper/avs_test.go index 3430102dd..2269b0581 100644 --- a/x/avs/keeper/avs_test.go +++ b/x/avs/keeper/avs_test.go @@ -9,7 +9,7 @@ import ( epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" sdk "github.com/cosmos/cosmos-sdk/types" - utiltx "github.com/evmos/evmos/v14/testutil/tx" + utiltx "github.com/evmos/evmos/v16/testutil/tx" ) func (suite *AVSTestSuite) TestAVS() { diff --git a/x/avs/keeper/setup_test.go b/x/avs/keeper/setup_test.go index 5699bbd3a..a87deb4cb 100644 --- a/x/avs/keeper/setup_test.go +++ b/x/avs/keeper/setup_test.go @@ -5,9 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/app" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - evm "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/app" + utiltx "github.com/evmos/evmos/v16/testutil/tx" + evm "github.com/evmos/evmos/v16/x/evm/types" "github.com/ExocoreNetwork/exocore/testutil" . "github.com/onsi/ginkgo/v2" diff --git a/x/avs/types/expected_keepers.go b/x/avs/types/expected_keepers.go index b0c69e1fd..74d00013f 100644 --- a/x/avs/types/expected_keepers.go +++ b/x/avs/types/expected_keepers.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/statedb" ) // EpochsKeeper represents the expected keeper interface for the epochs module. diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 6f54e2237..f9c84f69a 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -66,8 +66,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // update the staker state err = k.assetsKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.DeltaStakerSingleAsset{ - WithdrawableAmount: record.ActualCompletedAmount, - WaitUnbondingAmount: recordAmountNeg, + WithdrawableAmount: record.ActualCompletedAmount, + PendingUndelegationAmount: recordAmountNeg, }) if err != nil { panic(err) @@ -75,7 +75,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // update the operator state err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.DeltaOperatorSingleAsset{ - WaitUnbondingAmount: recordAmountNeg, + PendingUndelegationAmount: recordAmountNeg, }) if err != nil { panic(err) diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 1c207dd27..37ce9c637 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -99,18 +99,18 @@ func (suite *DelegationTestSuite) TestDelegateTo() { restakerState, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerAssetInfo{ - TotalDepositAmount: suite.depositAmount, - WithdrawableAmount: suite.depositAmount.Sub(delegationParams.OpAmount), - WaitUnbondingAmount: sdkmath.NewInt(0), + TotalDepositAmount: suite.depositAmount, + WithdrawableAmount: suite.depositAmount.Sub(delegationParams.OpAmount), + PendingUndelegationAmount: sdkmath.NewInt(0), }, *restakerState) operatorState, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) suite.Equal(types.OperatorAssetInfo{ - TotalAmount: delegationParams.OpAmount, - WaitUnbondingAmount: sdkmath.NewInt(0), - TotalShare: sdkmath.LegacyNewDecFromBigInt(delegationParams.OpAmount.BigInt()), - OperatorShare: sdkmath.LegacyNewDec(0), + TotalAmount: delegationParams.OpAmount, + PendingUndelegationAmount: sdkmath.NewInt(0), + TotalShare: sdkmath.LegacyNewDecFromBigInt(delegationParams.OpAmount.BigInt()), + OperatorShare: sdkmath.LegacyNewDec(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) @@ -138,18 +138,18 @@ func (suite *DelegationTestSuite) TestUndelegateFrom() { restakerState, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerAssetInfo{ - TotalDepositAmount: suite.depositAmount, - WithdrawableAmount: suite.depositAmount.Sub(delegationEvent.OpAmount), - WaitUnbondingAmount: delegationEvent.OpAmount, + TotalDepositAmount: suite.depositAmount, + WithdrawableAmount: suite.depositAmount.Sub(delegationEvent.OpAmount), + PendingUndelegationAmount: delegationEvent.OpAmount, }, *restakerState) operatorState, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, delegationEvent.OperatorAddress, assetID) suite.NoError(err) suite.Equal(types.OperatorAssetInfo{ - TotalAmount: sdkmath.NewInt(0), - WaitUnbondingAmount: delegationEvent.OpAmount, - TotalShare: sdkmath.LegacyNewDec(0), - OperatorShare: sdkmath.LegacyNewDec(0), + TotalAmount: sdkmath.NewInt(0), + PendingUndelegationAmount: delegationEvent.OpAmount, + TotalShare: sdkmath.LegacyNewDec(0), + OperatorShare: sdkmath.LegacyNewDec(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, delegationEvent.OperatorAddress.String()) @@ -207,18 +207,18 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { restakerState, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerAssetInfo{ - TotalDepositAmount: suite.depositAmount, - WithdrawableAmount: suite.depositAmount, - WaitUnbondingAmount: sdkmath.NewInt(0), + TotalDepositAmount: suite.depositAmount, + WithdrawableAmount: suite.depositAmount, + PendingUndelegationAmount: sdkmath.NewInt(0), }, *restakerState) operatorState, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, delegationEvent.OperatorAddress, assetID) suite.NoError(err) suite.Equal(types.OperatorAssetInfo{ - TotalAmount: sdkmath.NewInt(0), - WaitUnbondingAmount: sdkmath.NewInt(0), - TotalShare: sdkmath.LegacyNewDec(0), - OperatorShare: sdkmath.LegacyNewDec(0), + TotalAmount: sdkmath.NewInt(0), + PendingUndelegationAmount: sdkmath.NewInt(0), + TotalShare: sdkmath.LegacyNewDec(0), + OperatorShare: sdkmath.LegacyNewDec(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, delegationEvent.OperatorAddress.String()) diff --git a/x/delegation/keeper/share.go b/x/delegation/keeper/share.go index e78b47885..abf2d8ba6 100644 --- a/x/delegation/keeper/share.go +++ b/x/delegation/keeper/share.go @@ -190,7 +190,7 @@ func (k Keeper) RemoveShareFromOperator( delta.OperatorShare = share.Neg() } if isUndelegation { - delta.WaitUnbondingAmount = removedToken + delta.PendingUndelegationAmount = removedToken } err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operator, assetID, delta) if err != nil { @@ -224,7 +224,7 @@ func (k Keeper) RemoveShare( // todo: TotalDepositAmount might be influenced by slash and precision loss, // consider removing it, it can be recalculated from the share for RPC query. err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.DeltaStakerSingleAsset{ - WaitUnbondingAmount: removeToken, + PendingUndelegationAmount: removeToken, }) if err != nil { return removeToken, err diff --git a/x/delegation/keeper/share_test.go b/x/delegation/keeper/share_test.go index a4001874b..c15a4b55e 100644 --- a/x/delegation/keeper/share_test.go +++ b/x/delegation/keeper/share_test.go @@ -297,7 +297,7 @@ func (suite *DelegationTestSuite) TestRemoveShareFromOperator() { expectedInfo = *originalInfo expectedInfo.TotalAmount = originalInfo.TotalAmount.Sub(amount) expectedInfo.TotalShare = originalInfo.TotalShare.Sub(removeShareForUndelegation) - expectedInfo.WaitUnbondingAmount = originalInfo.WaitUnbondingAmount.Add(amount) + expectedInfo.PendingUndelegationAmount = originalInfo.PendingUndelegationAmount.Add(amount) suite.Equal(expectedInfo, *info) } @@ -327,7 +327,7 @@ func (suite *DelegationTestSuite) TestRemoveShare() { suite.Equal(removeShare.TruncateInt(), delegationInfo.WaitUndelegationAmount) stakerAssetInfo, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(removeShare.TruncateInt(), stakerAssetInfo.WaitUnbondingAmount) + suite.Equal(removeShare.TruncateInt(), stakerAssetInfo.PendingUndelegationAmount) stakerMap, err = suite.App.DelegationKeeper.GetStakersByOperator(suite.Ctx, suite.opAccAddr.String(), assetID) suite.NoError(err) suite.NotContains(stakerMap.Stakers, stakerID) diff --git a/x/dogfood/keeper/impl_evm.go b/x/dogfood/keeper/impl_evm.go index 676e6840d..93b2e7c9e 100644 --- a/x/dogfood/keeper/impl_evm.go +++ b/x/dogfood/keeper/impl_evm.go @@ -4,8 +4,8 @@ import ( "github.com/ExocoreNetwork/exocore/utils" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - erc20types "github.com/evmos/evmos/v14/x/erc20/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" + erc20types "github.com/evmos/evmos/v16/x/erc20/types" + evmtypes "github.com/evmos/evmos/v16/x/evm/types" ) // interface guards diff --git a/x/dogfood/keeper/msg_server.go b/x/dogfood/keeper/msg_server.go index 666bc717c..ea1002b69 100644 --- a/x/dogfood/keeper/msg_server.go +++ b/x/dogfood/keeper/msg_server.go @@ -10,7 +10,7 @@ import ( "github.com/ExocoreNetwork/exocore/x/dogfood/types" sdk "github.com/cosmos/cosmos-sdk/types" - epochstypes "github.com/evmos/evmos/v14/x/epochs/types" + epochstypes "github.com/evmos/evmos/v16/x/epochs/types" ) type msgServer struct { diff --git a/x/evm/client/cli/query.go b/x/evm/client/cli/query.go index b352c0464..fbc02d694 100644 --- a/x/evm/client/cli/query.go +++ b/x/evm/client/cli/query.go @@ -1,13 +1,13 @@ package cli import ( - rpctypes "github.com/evmos/evmos/v14/rpc/types" + rpctypes "github.com/evmos/evmos/v16/rpc/types" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // GetQueryCmd returns the parent command for all x/bank CLi query commands. diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 7f36e384b..8077bb124 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -12,8 +12,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - rpctypes "github.com/evmos/evmos/v14/rpc/types" - "github.com/evmos/evmos/v14/x/evm/types" + rpctypes "github.com/evmos/evmos/v16/rpc/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/evm/genesis.go b/x/evm/genesis.go index a1ab436c5..77325622d 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -11,8 +11,8 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ExocoreNetwork/exocore/x/evm/keeper" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // InitGenesis initializes genesis state based on exported genesis diff --git a/x/evm/handler.go b/x/evm/handler.go index d7824665f..27e14655c 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // NewHandler returns a handler for Ethermint type messages. diff --git a/x/evm/keeper/config.go b/x/evm/keeper/config.go index e8252a4a3..a7d32385f 100644 --- a/x/evm/keeper/config.go +++ b/x/evm/keeper/config.go @@ -8,8 +8,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" - "github.com/evmos/evmos/v14/x/evm/statedb" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/types" ) // EVMConfig creates the EVMConfig based on current state diff --git a/x/evm/keeper/fees.go b/x/evm/keeper/fees.go index 55c7db252..df0cacffa 100644 --- a/x/evm/keeper/fees.go +++ b/x/evm/keeper/fees.go @@ -13,7 +13,7 @@ import ( errortypes "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // CheckSenderBalance validates that the tx cost value is positive and that the diff --git a/x/evm/keeper/gas.go b/x/evm/keeper/gas.go index 6a49b616b..76ea2f1d1 100644 --- a/x/evm/keeper/gas.go +++ b/x/evm/keeper/gas.go @@ -12,7 +12,7 @@ import ( errortypes "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // GetEthIntrinsicGas returns the intrinsic gas cost for the transaction diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 2c9b43893..851ce1dd0 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -8,6 +8,8 @@ import ( "math/big" "time" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/eth/tracers/logger" @@ -25,9 +27,9 @@ import ( "github.com/ethereum/go-ethereum/core/vm" ethparams "github.com/ethereum/go-ethereum/params" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/types" ) var _ types.QueryServer = Keeper{} @@ -254,6 +256,16 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms // EstimateGas implements eth_estimateGas rpc api. func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*types.EstimateGasResponse, error) { + return k.EstimateGasInternal(c, req, types.RPC) +} + +// EstimateGasInternal returns the gas estimation for the corresponding request. +// This function is called from the RPC client (eth_estimateGas) and internally +// by the CallEVMWithData function in the x/erc20 module keeper. +// When called from the RPC client, we need to reset the gas meter before +// simulating the transaction to have +// an accurate gas estimation for EVM extensions transactions. +func (k Keeper) EstimateGasInternal(c context.Context, req *types.EthCallRequest, fromType types.CallType) (*types.EstimateGasResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -265,7 +277,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type } if req.GasCap < ethparams.TxGas { - return nil, status.Error(codes.InvalidArgument, "gas cap cannot be lower than 21,000") + return nil, status.Errorf(codes.InvalidArgument, "gas cap cannot be lower than %d", ethparams.TxGas) } var args types.TransactionArgs @@ -339,8 +351,32 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type msg.IsFake(), ) + tmpCtx := ctx + if fromType == types.RPC { + tmpCtx, _ = ctx.CacheContext() + + acct := k.GetAccount(tmpCtx, msg.From()) + + from := msg.From() + if acct == nil { + acc := k.accountKeeper.NewAccountWithAddress(tmpCtx, from[:]) + k.accountKeeper.SetAccount(tmpCtx, acc) + acct = statedb.NewEmptyAccount() + } + // When submitting a transaction, the `EthIncrementSenderSequence` ante handler increases the account nonce + acct.Nonce = nonce + 1 + err = k.SetAccount(tmpCtx, from, *acct) + if err != nil { + return true, nil, err + } + // resetting the gasMeter after increasing the sequence to have an accurate gas estimation on EVM extensions transactions + gasMeter := evmostypes.NewInfiniteGasMeterWithLimit(msg.Gas()) + tmpCtx = tmpCtx.WithGasMeter(gasMeter). + WithKVGasConfig(storetypes.GasConfig{}). + WithTransientKVGasConfig(storetypes.GasConfig{}) + } // pass false to not commit StateDB - rsp, err = k.ApplyMessageWithConfig(ctx, msg, nil, false, cfg, txConfig) + rsp, err = k.ApplyMessageWithConfig(tmpCtx, msg, nil, false, cfg, txConfig) if err != nil { if errors.Is(err, core.ErrIntrinsicGas) { return true, nil, nil // Special case, raise gas limit diff --git a/x/evm/keeper/hooks.go b/x/evm/keeper/hooks.go index afc407485..ffa225ef3 100644 --- a/x/evm/keeper/hooks.go +++ b/x/evm/keeper/hooks.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/types" ) var _ types.EvmHooks = MultiEvmHooks{} diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index cbe5e9bd8..86187de92 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "math/big" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -16,9 +17,9 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/types" ) // Keeper grants access to the EVM module state and implements the go-ethereum StateDB interface. @@ -338,7 +339,7 @@ func (k Keeper) getBaseFee(ctx sdk.Context, london bool) *big.Int { } // GetMinGasMultiplier returns the MinGasMultiplier param from the fee market module -func (k Keeper) GetMinGasMultiplier(ctx sdk.Context) sdk.Dec { +func (k Keeper) GetMinGasMultiplier(ctx sdk.Context) math.LegacyDec { return k.feeMarketKeeper.GetParams(ctx).MinGasMultiplier } diff --git a/x/evm/keeper/migrations.go b/x/evm/keeper/migrations.go index fcd583ad8..0ea7e8659 100644 --- a/x/evm/keeper/migrations.go +++ b/x/evm/keeper/migrations.go @@ -2,9 +2,10 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - v4 "github.com/evmos/evmos/v14/x/evm/migrations/v4" - v5 "github.com/evmos/evmos/v14/x/evm/migrations/v5" - "github.com/evmos/evmos/v14/x/evm/types" + v4 "github.com/evmos/evmos/v16/x/evm/migrations/v4" + v5 "github.com/evmos/evmos/v16/x/evm/migrations/v5" + v6 "github.com/evmos/evmos/v16/x/evm/migrations/v6" + "github.com/evmos/evmos/v16/x/evm/types" ) // Migrator is a struct for handling in-place store migrations. @@ -30,3 +31,8 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { func (m Migrator) Migrate4to5(ctx sdk.Context) error { return v5.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } + +// Migrate5to6 migrates the store from consensus version 5 to 6 +func (m Migrator) Migrate5to6(ctx sdk.Context) error { + return v6.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) +} diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 7ce69c14b..79ea1a2c2 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -12,11 +12,12 @@ import ( tmtypes "github.com/cometbft/cometbft/types" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" "github.com/armon/go-metrics" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/types" ) var _ types.MsgServer = &Keeper{} @@ -62,7 +63,7 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t // Observe which users define a gas limit >> gas used. Note, that // gas_limit and gas_used are always > 0 - gasLimit := sdk.NewDec(int64(tx.Gas())) // #nosec G115 + gasLimit := math.LegacyNewDec(int64(tx.Gas())) // #nosec G115 gasRatio, err := gasLimit.QuoInt64(int64(response.GasUsed)).Float64() // #nosec G115 if err == nil { telemetry.SetGaugeWithLabels( diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index 302910edc..723a3b439 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -1,8 +1,12 @@ package keeper import ( + "sort" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/ethereum/go-ethereum/common" + "github.com/evmos/evmos/v16/x/evm/types" + "golang.org/x/exp/slices" ) // GetParams returns the total set of evm parameters. @@ -18,6 +22,10 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { // SetParams sets the EVM params each in their individual key for better get performance func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + // NOTE: We need to sort the precompiles in order to enable searching with binary search + // in params.IsActivePrecompile. + slices.Sort(params.ActivePrecompiles) + if err := params.Validate(); err != nil { return err } @@ -38,3 +46,34 @@ func (k Keeper) GetLegacyParams(ctx sdk.Context) types.Params { k.ss.GetParamSetIfExists(ctx, ¶ms) return params } + +// EnablePrecompiles appends the addresses of the given Precompiles to the list +// of active precompiles. +func (k Keeper) EnablePrecompiles(ctx sdk.Context, addresses ...common.Address) error { + params := k.GetParams(ctx) + activePrecompiles := params.ActivePrecompiles + + for _, address := range addresses { + activePrecompiles = append(activePrecompiles, address.String()) + } + + sort.Slice(activePrecompiles, func(i, j int) bool { + return activePrecompiles[i] < activePrecompiles[j] + }) + + params.ActivePrecompiles = activePrecompiles + + return k.SetParams(ctx, params) +} + +// EnableEIPs enables the given EIPs in the EVM parameters. +func (k Keeper) EnableEIPs(ctx sdk.Context, eips ...int64) error { + evmParams := k.GetParams(ctx) + evmParams.ExtraEIPs = append(evmParams.ExtraEIPs, eips...) + + sort.Slice(evmParams.ExtraEIPs, func(i, j int) bool { + return evmParams.ExtraEIPs[i] < evmParams.ExtraEIPs[j] + }) + + return k.SetParams(ctx, evmParams) +} diff --git a/x/evm/keeper/precompiles.go b/x/evm/keeper/precompiles.go index f7a225d88..8809fda03 100644 --- a/x/evm/keeper/precompiles.go +++ b/x/evm/keeper/precompiles.go @@ -1,7 +1,9 @@ package keeper import ( + "bytes" "fmt" + "sort" assetsprecompile "github.com/ExocoreNetwork/exocore/precompiles/assets" avsManagerPrecompile "github.com/ExocoreNetwork/exocore/precompiles/avs" @@ -14,12 +16,12 @@ import ( delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" exoslashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" channelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - ics20precompile "github.com/evmos/evmos/v14/precompiles/ics20" - transferkeeper "github.com/evmos/evmos/v14/x/ibc/transfer/keeper" + transferkeeper "github.com/evmos/evmos/v16/x/ibc/transfer/keeper" "golang.org/x/exp/maps" ) @@ -31,8 +33,8 @@ const ( // NOTE: this should only be used during initialization of the Keeper. func AvailablePrecompiles( authzKeeper authzkeeper.Keeper, - transferKeeper transferkeeper.Keeper, - channelKeeper channelkeeper.Keeper, + _ transferkeeper.Keeper, + _ channelkeeper.Keeper, delegationKeeper delegationKeeper.Keeper, assetskeeper stakingStateKeeper.Keeper, slashKeeper exoslashKeeper.Keeper, @@ -42,14 +44,14 @@ func AvailablePrecompiles( // Clone the mapping from the latest EVM fork. precompiles := maps.Clone(vm.PrecompiledContractsBerlin) - ibcTransferPrecompile, err := ics20precompile.NewPrecompile( - transferKeeper, - channelKeeper, - authzKeeper, - ) - if err != nil { - panic(fmt.Errorf("failed to load ICS20 precompile: %w", err)) - } + /* ibcTransferPrecompile, err := ics20precompile.NewPrecompile( + transferKeeper, + channelKeeper, + authzKeeper, + ) + if err != nil { + panic(fmt.Errorf("failed to load ICS20 precompile: %w", err)) + }*/ assetsPrecompile, err := assetsprecompile.NewPrecompile( assetskeeper, @@ -96,7 +98,7 @@ func AvailablePrecompiles( precompiles[assetsPrecompile.Address()] = assetsPrecompile precompiles[delegationPrecompile.Address()] = delegationPrecompile precompiles[avsManagerPrecompile.Address()] = avsManagerPrecompile - precompiles[ibcTransferPrecompile.Address()] = ibcTransferPrecompile + // precompiles[ibcTransferPrecompile.Address()] = ibcTransferPrecompile precompiles[blsPrecompile.Address()] = blsPrecompile return precompiles } @@ -135,3 +137,65 @@ func (k Keeper) Precompiles( return activePrecompileMap } + +// AddEVMExtensions adds the given precompiles to the list of active precompiles in the EVM parameters +// and to the available precompiles map in the Keeper. This function returns an error if +// the precompiles are invalid or duplicated. +func (k *Keeper) AddEVMExtensions(ctx sdk.Context, precompiles ...vm.PrecompiledContract) error { + params := k.GetParams(ctx) + + addresses := make([]string, len(precompiles)) + precompilesMap := maps.Clone(k.precompiles) + + for i, precompile := range precompiles { + // add to active precompiles + address := precompile.Address() + addresses[i] = address.String() + + // add to available precompiles, but check for duplicates + if _, ok := precompilesMap[address]; ok { + return fmt.Errorf("precompile already registered: %s", address) + } + precompilesMap[address] = precompile + } + + params.ActivePrecompiles = append(params.ActivePrecompiles, addresses...) + + // NOTE: the active precompiles are sorted and validated before setting them + // in the params + if err := k.SetParams(ctx, params); err != nil { + return err + } + + // update the pointer to the map with the newly added EVM Extensions + k.precompiles = precompilesMap + return nil +} + +// IsAvailablePrecompile returns true if the given precompile address is contained in the +// EVM keeper's available precompiles map. +func (k Keeper) IsAvailablePrecompile(address common.Address) bool { + _, ok := k.precompiles[address] + return ok +} + +// GetAvailablePrecompileAddrs returns the list of available precompile addresses. +// +// NOTE: uses index based approach instead of append because it's supposed to be faster. +// Check https://stackoverflow.com/questions/21362950/getting-a-slice-of-keys-from-a-map. +func (k Keeper) GetAvailablePrecompileAddrs() []common.Address { + addresses := make([]common.Address, len(k.precompiles)) + i := 0 + + //#nosec G705 -- two operations in for loop here are fine + for address := range k.precompiles { + addresses[i] = address + i++ + } + + sort.Slice(addresses, func(i, j int) bool { + return bytes.Compare(addresses[i].Bytes(), addresses[j].Bytes()) == -1 + }) + + return addresses +} diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index a0fba0665..bf445b8b3 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -4,15 +4,17 @@ import ( "math/big" "github.com/ExocoreNetwork/exocore/precompiles/delegation" + "golang.org/x/exp/slices" tmtypes "github.com/cometbft/cometbft/types" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -165,6 +167,9 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t // pass true to commit the StateDB res, err := k.ApplyMessageWithConfig(tmpCtx, msg, nil, true, cfg, txConfig) if err != nil { + // when a transaction contains multiple msg, as long as one of the msg fails + // all gas will be deducted. so is not msg.Gas() + k.ResetGasMeterAndConsumeGas(ctx, ctx.GasMeter().Limit()) return nil, errorsmod.Wrap(err, "failed to apply ethereum core message") } @@ -307,6 +312,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, ret []byte // return bytes from evm execution vmErr error // vm errors do not effect consensus and are therefore not assigned to err ) + // return error if contract creation or call are disabled through governance if !cfg.Params.EnableCreate && msg.To() == nil { return nil, errorsmod.Wrap(types.ErrCreateDisabled, "failed to create new contract") @@ -328,6 +334,21 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, copy(activePrecompiles[:len(vm.PrecompiledAddressesBerlin)], vm.PrecompiledAddressesBerlin) copy(activePrecompiles[len(vm.PrecompiledAddressesBerlin):], customPrecompiles) + // Check if the transaction is sent to an inactive precompile + // + // NOTE: This has to be checked here instead of in the actual evm.Call method + // because evm.WithPrecompiles only populates the EVM with the active precompiles, + // so there's no telling if the To address is an inactive precompile further down the call stack. + toAddr := msg.To() + if toAddr != nil && + slices.Contains(types.AvailableEVMExtensions, toAddr.String()) && + !slices.Contains(activePrecompiles, *toAddr) { + return nil, errorsmod.Wrap(types.ErrInactivePrecompile, "failed to call precompile") + } + + // NOTE: this only adds active precompiles to the EVM. + // This means that evm.Precompile(addr) will return false for inactive precompiles + // even though this is actually a reserved address. precompileMap := k.Precompiles(activePrecompiles...) evm.WithPrecompiles(precompileMap, activePrecompiles) } @@ -412,7 +433,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, // calculate a minimum amount of gas to be charged to sender if GasLimit // is considerably higher than GasUsed to stay more aligned with Tendermint gas mechanics // for more info https://github.com/evmos/ethermint/issues/1085 - gasLimit := sdk.NewDec(int64(msg.Gas())) // #nosec G115 + gasLimit := math.LegacyNewDec(int64(msg.Gas())) // #nosec G115 minGasMultiplier := k.GetMinGasMultiplier(ctx) minimumGasUsed := gasLimit.Mul(minGasMultiplier) @@ -424,7 +445,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, return nil, errorsmod.Wrapf(types.ErrGasOverflow, "message gas limit < leftover gas (%d < %d)", msg.Gas(), leftoverGas) } // #nosec G115 - gasUsed := sdk.MaxDec(minimumGasUsed, sdk.NewDec(int64(temporaryGasUsed))).TruncateInt().Uint64() + gasUsed := math.LegacyMaxDec(minimumGasUsed, math.LegacyNewDec(int64(temporaryGasUsed))).TruncateInt().Uint64() // reset leftoverGas, to be used by the tracer leftoverGas = msg.Gas() - gasUsed diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index a0a3bd299..fc52119d4 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -10,9 +10,9 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - "github.com/evmos/evmos/v14/x/evm/types" + evmostypes "github.com/evmos/evmos/v16/types" + "github.com/evmos/evmos/v16/x/evm/statedb" + "github.com/evmos/evmos/v16/x/evm/types" ) var _ statedb.Keeper = &Keeper{} diff --git a/x/evm/module.go b/x/evm/module.go index cf4d52c98..e35fe11a1 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -22,11 +22,11 @@ import ( "github.com/ExocoreNetwork/exocore/x/evm/client/cli" "github.com/ExocoreNetwork/exocore/x/evm/keeper" - "github.com/evmos/evmos/v14/x/evm/types" + "github.com/evmos/evmos/v16/x/evm/types" ) // consensusVersion defines the current x/evm module consensus version. -const consensusVersion = 5 +const consensusVersion = 6 var ( _ module.AppModule = AppModule{} @@ -133,14 +133,17 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := keeper.NewMigrator(*am.keeper, am.legacySubspace) - err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4) - if err != nil { + if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil { panic(err) } if err := cfg.RegisterMigration(types.ModuleName, 4, m.Migrate4to5); err != nil { panic(err) } + + if err := cfg.RegisterMigration(types.ModuleName, 5, m.Migrate5to6); err != nil { + panic(err) + } } // BeginBlock returns the begin block for the evm module. diff --git a/x/evm/types/genesis.go b/x/evm/types/genesis.go index 7b2abb701..c5da68182 100644 --- a/x/evm/types/genesis.go +++ b/x/evm/types/genesis.go @@ -1,7 +1,7 @@ package types import ( - evmtype "github.com/evmos/evmos/v14/x/evm/types" + evmtype "github.com/evmos/evmos/v16/x/evm/types" ) // DefaultGenesisState sets default evm genesis state with empty accounts and default params and diff --git a/x/evm/types/params.go b/x/evm/types/params.go index a938958bf..6d24ece3f 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -2,7 +2,7 @@ package types import ( "github.com/ExocoreNetwork/exocore/utils" - evmtype "github.com/evmos/evmos/v14/x/evm/types" + evmtype "github.com/evmos/evmos/v16/x/evm/types" ) // ExocoreAvailableEVMExtensions defines the default active precompiles @@ -11,7 +11,7 @@ var ( DefaultEVMDenom = utils.BaseDenom ExocoreAvailableEVMExtensions = []string{ // 0x0000000000000000000000000000000000000801 client chains precompile has been merged to assets. - "0x0000000000000000000000000000000000000802", // ICS20 transfer precompile + // "0x0000000000000000000000000000000000000802", // ICS20 transfer precompile "0x0000000000000000000000000000000000000804", // assets precompile "0x0000000000000000000000000000000000000805", // delegation precompile "0x0000000000000000000000000000000000000806", // reward precompile diff --git a/x/operator/keeper/opt.go b/x/operator/keeper/opt.go index f58f4ef8a..fc0ab9b96 100644 --- a/x/operator/keeper/opt.go +++ b/x/operator/keeper/opt.go @@ -1,6 +1,7 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" @@ -19,7 +20,7 @@ type AssetPriceAndDecimal struct { func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string) error { // check that the operator is registered if !k.IsOperator(ctx, operatorAddress) { - return delegationtypes.ErrOperatorNotExist + return errorsmod.Wrapf(delegationtypes.ErrOperatorNotExist, "operator is :%s", operatorAddress) } // check that the AVS is registered if isAvs, _ := k.avsKeeper.IsAVS(ctx, avsAddr); !isAvs { diff --git a/x/operator/keeper/usd_value.go b/x/operator/keeper/usd_value.go index 17ad79463..6a952b793 100644 --- a/x/operator/keeper/usd_value.go +++ b/x/operator/keeper/usd_value.go @@ -312,7 +312,7 @@ func (k *Keeper) CalculateUSDValueForOperator( return err } decimal = assetInfo.AssetBasicInfo.Decimals - ret.StakingAndWaitUnbonding = ret.StakingAndWaitUnbonding.Add(CalculateUSDValue(state.TotalAmount.Add(state.WaitUnbondingAmount), price.Value, decimal, price.Decimal)) + ret.StakingAndWaitUnbonding = ret.StakingAndWaitUnbonding.Add(CalculateUSDValue(state.TotalAmount.Add(state.PendingUndelegationAmount), price.Value, decimal, price.Decimal)) } else { if prices == nil { return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, "CalculateUSDValueForOperator prices map is nil") diff --git a/x/oracle/types/nonce.pb.go b/x/oracle/types/nonce.pb.go index 3667fe3a2..2a07ba16e 100644 --- a/x/oracle/types/nonce.pb.go +++ b/x/oracle/types/nonce.pb.go @@ -25,8 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Nonce is a message that contains a nonce for a feeder type Nonce struct { + // FeederID is the ID of the feeder that corresponding to the nonce FeederID uint64 `protobuf:"varint,1,opt,name=feeder_id,json=feederId,proto3" json:"feeder_id,omitempty"` - Value uint32 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` + // value is the nonce value + Value uint32 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` } func (m *Nonce) Reset() { *m = Nonce{} } @@ -78,7 +80,9 @@ func (m *Nonce) GetValue() uint32 { // ValidatorNonce is a message that contains the nonces for a validator type ValidatorNonce struct { - Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // validator is the validator address + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // nonces is the list of nonces for the feeders NonceList []*Nonce `protobuf:"bytes,2,rep,name=nonce_list,json=nonceList,proto3" json:"nonce_list,omitempty"` } diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index a46819f5a..0e1ac6c30 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -17,7 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/rpc/namespaces/ethereum/eth/filters" + "github.com/evmos/evmos/v16/rpc/namespaces/ethereum/eth/filters" ) type RewardParams struct { diff --git a/x/reward/keeper/claim_reward_test.go b/x/reward/keeper/claim_reward_test.go index acd7c0840..b8f27193f 100644 --- a/x/reward/keeper/claim_reward_test.go +++ b/x/reward/keeper/claim_reward_test.go @@ -36,9 +36,9 @@ func (suite *RewardTestSuite) TestClaimWithdrawRequest() { info, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerAssetInfo{ - TotalDepositAmount: sdkmath.NewInt(10), - WithdrawableAmount: sdkmath.NewInt(10), - WaitUnbondingAmount: sdkmath.NewInt(0), + TotalDepositAmount: sdkmath.NewInt(10), + WithdrawableAmount: sdkmath.NewInt(10), + PendingUndelegationAmount: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index 7d4763d4e..461de42ae 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -17,7 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/evmos/evmos/v14/rpc/namespaces/ethereum/eth/filters" + "github.com/evmos/evmos/v16/rpc/namespaces/ethereum/eth/filters" ) type SlashParams struct { diff --git a/x/slash/keeper/execute_slash_test.go b/x/slash/keeper/execute_slash_test.go index e642dea7b..6fbc06b68 100644 --- a/x/slash/keeper/execute_slash_test.go +++ b/x/slash/keeper/execute_slash_test.go @@ -44,9 +44,9 @@ func (suite *SlashTestSuite) TestSlash() { info, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerAssetInfo{ - TotalDepositAmount: depositEvent.OpAmount, - WithdrawableAmount: depositEvent.OpAmount, - WaitUnbondingAmount: sdkmath.NewInt(0), + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount, + PendingUndelegationAmount: sdkmath.NewInt(0), }, *info) // test the normal case @@ -59,9 +59,9 @@ func (suite *SlashTestSuite) TestSlash() { info, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerAssetInfo{ - TotalDepositAmount: sdkmath.NewInt(10), - WithdrawableAmount: sdkmath.NewInt(10), - WaitUnbondingAmount: sdkmath.NewInt(0), + TotalDepositAmount: sdkmath.NewInt(10), + WithdrawableAmount: sdkmath.NewInt(10), + PendingUndelegationAmount: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) From 12a09eb2fe43e3e7fdd1d867d48a92f9eddf49d0 Mon Sep 17 00:00:00 2001 From: TimmyExogenous <144751317+TimmyExogenous@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:51:24 +0800 Subject: [PATCH 3/5] feat(genesis export): genesis exporting for assets, delegation and operator modules. (#108) * detail the return error for operator info * refine the genesis validation and add implement the genesis exporting in assets module * add genesis exporting for the delegation module * move the isGeneralInit flag to the commandline of starting node * add genesis exporting for operator module * finish genesis exporting for operator module * Remove the isGeneralInit flag that indicates whether the launch is from bootstrap or the exported genesis file. fix the issues caused by rebase * remove the opt in when init dogfood genesis fix the issue from code comments fix the error after rebasing * use panic to address the error when exporting genesis fix the unit tests fix the issue for genesis exporting launch define the common delimiter for combined key,stakerID and assetID. And add the check for the chainID * add a constant ByteLengthForUint64 and fix the issue identified by code comment * fix the issue regarding starting a local node * stop the iteration if the operator address isn't found when exporting genesis state for dogfood * rebase and correct the invalid log printing --- app/app.go | 1 - app/ethtest_helper.go | 52 +- app/test_helpers.go | 63 +- cmd/exocored/root.go | 14 +- cmd/exocored/testnet.go | 61 +- local_node.sh | 30 +- precompiles/assets/tx.go | 2 +- precompiles/avs/query_test.go | 4 +- proto/exocore/assets/v1/genesis.proto | 35 +- proto/exocore/assets/v1/query.proto | 7 +- proto/exocore/assets/v1/tx.proto | 7 +- proto/exocore/delegation/v1/genesis.proto | 34 +- proto/exocore/dogfood/v1/genesis.proto | 2 +- proto/exocore/operator/v1/genesis.proto | 123 +- proto/exocore/operator/v1/tx.proto | 4 +- testutil/utils.go | 197 +- utils/utils.go | 56 + utils/utils_test.go | 30 + .../keeper/client_chain_and_asset_test.go | 21 +- x/assets/keeper/client_chain_asset.go | 10 +- x/assets/keeper/genesis.go | 54 +- x/assets/keeper/keeper.go | 6 +- x/assets/keeper/operator_asset.go | 42 +- x/assets/keeper/staker_asset.go | 42 +- x/assets/keeper/staker_asset_test.go | 33 +- x/assets/types/errors.go | 5 + x/assets/types/general.go | 10 +- x/assets/types/genesis.go | 303 +- x/assets/types/genesis.pb.go | 596 +++- x/assets/types/genesis_test.go | 60 +- x/assets/types/keys.go | 27 +- x/assets/types/query.pb.go | 569 +-- x/assets/types/tx.pb.go | 195 +- x/avs/keeper/avs.go | 5 +- x/avs/keeper/keeper.go | 7 +- x/avs/keeper/query.go | 2 +- x/avs/types/types.go | 5 +- x/delegation/keeper/delegation.go | 4 +- x/delegation/keeper/delegation_state.go | 73 +- x/delegation/keeper/genesis.go | 75 +- x/delegation/keeper/un_delegation_state.go | 27 +- x/delegation/types/errors.go | 5 + x/delegation/types/genesis.go | 304 +- x/delegation/types/genesis.pb.go | 690 +++- x/delegation/types/genesis_test.go | 108 +- x/delegation/types/keys.go | 2 +- x/delegation/types/types/query.pb.go | 1880 ---------- x/delegation/types/types/query.pb.gw.go | 355 -- x/dogfood/keeper/genesis.go | 25 +- x/dogfood/keeper/impl_epochs_hooks.go | 1 + x/dogfood/keeper/impl_epochs_hooks_test.go | 12 +- x/dogfood/keeper/msg_server.go | 2 +- x/dogfood/keeper/opt_out_test.go | 6 +- x/dogfood/keeper/unbonding_test.go | 8 +- x/dogfood/types/expected_keepers.go | 2 +- x/dogfood/types/genesis.go | 8 - x/dogfood/types/genesis.pb.go | 2 +- x/operator/client/cli/tx.go | 16 +- x/operator/keeper/consensus_keys.go | 126 +- x/operator/keeper/genesis.go | 87 +- x/operator/keeper/keeper.go | 9 +- x/operator/keeper/operator.go | 56 +- x/operator/keeper/operator_info_test.go | 21 +- x/operator/keeper/operator_slash_state.go | 27 + x/operator/keeper/opt_test.go | 2 - x/operator/keeper/slash.go | 38 +- x/operator/keeper/slash_test.go | 6 +- x/operator/keeper/usd_value.go | 82 +- x/operator/keeper/usd_value_test.go | 10 +- x/operator/types/expected_keepers.go | 5 +- x/operator/types/genesis.go | 506 ++- x/operator/types/genesis.pb.go | 3114 +++++++++++++++-- x/operator/types/genesis_test.go | 165 +- x/operator/types/keys.go | 98 +- x/operator/types/keys_test.go | 58 + x/operator/types/tx.pb.go | 202 +- x/reward/keeper/claim_reward_test.go | 2 +- x/slash/keeper/execute_slash_test.go | 2 +- 78 files changed, 6865 insertions(+), 4070 deletions(-) delete mode 100644 x/delegation/types/types/query.pb.go delete mode 100644 x/delegation/types/types/query.pb.gw.go create mode 100644 x/operator/types/keys_test.go diff --git a/app/app.go b/app/app.go index f883ecf30..85acd0a81 100644 --- a/app/app.go +++ b/app/app.go @@ -672,7 +672,6 @@ func NewExocoreApp( // to determine whether an AVS is registered or not. app.OperatorKeeper = operatorKeeper.NewKeeper( keys[operatorTypes.StoreKey], appCodec, - bApp.CreateQueryContext, app.AssetsKeeper, &app.DelegationKeeper, // intentionally a pointer, since not yet initialized. &app.OracleKeeper, diff --git a/app/ethtest_helper.go b/app/ethtest_helper.go index afea9ae01..a31e22c0e 100644 --- a/app/ethtest_helper.go +++ b/app/ethtest_helper.go @@ -185,11 +185,10 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, assetstypes.DefaultParams(), clientChains, []assetstypes.StakingAssetInfo{ { - AssetBasicInfo: &assets[0], - // required to be 0, since deposits are handled after token init. - StakingTotalAmount: sdk.ZeroInt(), + AssetBasicInfo: assets[0], + StakingTotalAmount: depositAmount, }, - }, depositsByStaker, + }, depositsByStaker, nil, ) genesisState[assetstypes.ModuleName] = codec.MustMarshalJSON(assetsGenesis) @@ -200,31 +199,26 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, genesisState[oracletypes.ModuleName] = codec.MustMarshalJSON(oracleGenesis) // operator registration - operatorInfos := []operatortypes.OperatorInfo{ + operatorInfos := []operatortypes.OperatorDetail{ { - EarningsAddr: operator.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, } - operatorGenesis := operatortypes.NewGenesisState(operatorInfos) + operatorGenesis := operatortypes.NewGenesisState(operatorInfos, nil, nil, nil, nil, nil, nil, nil) genesisState[operatortypes.ModuleName] = codec.MustMarshalJSON(operatorGenesis) // x/delegation - delegationsByStaker := []delegationtypes.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operator.String()) + delegationStates := []delegationtypes.DelegationStates{ { - StakerID: stakerID, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, - }, + Key: string(singleStateKey), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), }, }, } @@ -234,7 +228,15 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, StakerID: stakerID, }, } - delegationGenesis := delegationtypes.NewGenesis(delegationsByStaker, associations) + stakersByOperator := []delegationtypes.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator.String(), assetID)), + Stakers: []string{ + stakerID, + }, + }, + } + delegationGenesis := delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil) genesisState[delegationtypes.ModuleName] = codec.MustMarshalJSON(delegationGenesis) dogfoodGenesis := dogfoodtypes.NewGenesis( @@ -243,7 +245,7 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, // PublicKey: consensusKeyRecords[0].Chains[0].ConsensusKey, Power: 1, PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), - OperatorAccAddr: operatorInfos[0].EarningsAddr, + OperatorAccAddr: operatorInfos[0].OperatorAddress, }, }, []dogfoodtypes.EpochToOperatorAddrs{}, []dogfoodtypes.EpochToConsensusAddrs{}, diff --git a/app/test_helpers.go b/app/test_helpers.go index a691de689..b59ac2616 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -216,39 +216,50 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, assetstypes.DefaultParams(), clientChains, []assetstypes.StakingAssetInfo{ { - AssetBasicInfo: &assets[0], + AssetBasicInfo: assets[0], // required to be 0, since deposits are handled after token init. StakingTotalAmount: sdk.ZeroInt(), }, }, depositsByStaker, + []assetstypes.AssetsByOperator{ + { + Operator: operator.String(), + AssetsState: []assetstypes.AssetByID{ + { + AssetID: assetID, + Info: assetstypes.OperatorAssetInfo{ + TotalAmount: depositAmount, + PendingUndelegationAmount: math.NewInt(0), + TotalShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), + OperatorShare: math.LegacyNewDec(0), + }, + }, + }, + }, + }, ) genesisState[assetstypes.ModuleName] = app.AppCodec().MustMarshalJSON(assetsGenesis) // operator registration - operatorInfos := []operatortypes.OperatorInfo{ + operatorInfos := []operatortypes.OperatorDetail{ { - EarningsAddr: operator.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, } - operatorGenesis := operatortypes.NewGenesisState(operatorInfos) + operatorGenesis := operatortypes.NewGenesisState(operatorInfos, nil, nil, nil, nil, nil, nil, nil) genesisState[operatortypes.ModuleName] = app.AppCodec().MustMarshalJSON(operatorGenesis) // x/delegation - delegationsByStaker := []delegationtypes.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operator.String()) + delegationStates := []delegationtypes.DelegationStates{ { - StakerID: stakerID, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, - }, + Key: string(singleStateKey), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), }, }, } @@ -258,7 +269,15 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, StakerID: stakerID, }, } - delegationGenesis := delegationtypes.NewGenesis(delegationsByStaker, associations) + stakersByOperator := []delegationtypes.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator.String(), assetID)), + Stakers: []string{ + stakerID, + }, + }, + } + delegationGenesis := delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil) genesisState[delegationtypes.ModuleName] = app.AppCodec().MustMarshalJSON(delegationGenesis) // create a dogfood genesis with just the validator set, that is, the bare @@ -268,7 +287,7 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, { Power: 1, PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), - OperatorAccAddr: operatorInfos[0].EarningsAddr, + OperatorAccAddr: operatorInfos[0].OperatorAddress, }, }, []dogfoodtypes.EpochToOperatorAddrs{}, []dogfoodtypes.EpochToConsensusAddrs{}, diff --git a/cmd/exocored/root.go b/cmd/exocored/root.go index 285fc572a..78d4454df 100644 --- a/cmd/exocored/root.go +++ b/cmd/exocored/root.go @@ -293,7 +293,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a chainID := getChainID(appOpts, home) - evmosApp := app.NewExocoreApp( + exocoreApp := app.NewExocoreApp( logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(sdkserver.FlagInvCheckPeriod)), @@ -313,7 +313,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a baseapp.SetChainID(chainID), ) - return evmosApp + return exocoreApp } // appExport creates a new simapp (optionally at a given height) @@ -328,7 +328,7 @@ func (a appCreator) appExport( appOpts servertypes.AppOptions, modulesToExport []string, ) (servertypes.ExportedApp, error) { - var evmosApp *app.ExocoreApp + var exocoreApp *app.ExocoreApp homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { return servertypes.ExportedApp{}, errors.New("application home not set") @@ -337,24 +337,24 @@ func (a appCreator) appExport( chainID := getChainID(appOpts, homePath) if height != -1 { - evmosApp = app.NewExocoreApp( + exocoreApp = app.NewExocoreApp( logger, db, traceStore, false, map[int64]bool{}, "", uint(1), a.encCfg, appOpts, baseapp.SetChainID(chainID), ) - if err := evmosApp.LoadHeight(height); err != nil { + if err := exocoreApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - evmosApp = app.NewExocoreApp( + exocoreApp = app.NewExocoreApp( logger, db, traceStore, true, map[int64]bool{}, "", uint(1), a.encCfg, appOpts, baseapp.SetChainID(chainID), ) } - return evmosApp.ExportAppStateAndValidators( + return exocoreApp.ExportAppStateAndValidators( forZeroHeight, jailAllowedAddrs, modulesToExport, diff --git a/cmd/exocored/testnet.go b/cmd/exocored/testnet.go index bfae2fdc0..750da69a2 100644 --- a/cmd/exocored/testnet.go +++ b/cmd/exocored/testnet.go @@ -391,8 +391,10 @@ func getTestExocoreGenesis( power := int64(300) depositAmount := sdk.TokensFromConsensusPower(power, evmostypes.PowerReduction) depositsByStaker := []assetstypes.DepositsByStaker{} - operatorInfos := []operatortypes.OperatorInfo{} - delegationsByStaker := []delegationtypes.DelegationsByStaker{} + operatorInfos := []operatortypes.OperatorDetail{} + delegationStates := []delegationtypes.DelegationStates{} + associations := []delegationtypes.StakerToOperator{} + stakersByOperator := []delegationtypes.StakersByOperator{} validators := []dogfoodtypes.GenesisValidator{} for i := range operatorAddrs { operator := operatorAddrs[i] @@ -414,27 +416,33 @@ func getTestExocoreGenesis( }, }, }) - operatorInfos = append(operatorInfos, operatortypes.OperatorInfo{ - EarningsAddr: operator.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission( - sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), - ), + operatorInfos = append(operatorInfos, operatortypes.OperatorDetail{ + OperatorAddress: operator.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission( + sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), + ), + }, }) - delegationsByStaker = append(delegationsByStaker, delegationtypes.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operator.String()) + delegationStates = append(delegationStates, delegationtypes.DelegationStates{ + Key: string(singleStateKey), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), + }, + }, + ) + associations = append(associations, delegationtypes.StakerToOperator{ + Operator: operator.String(), StakerID: stakerID, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, - }, + }) + stakersByOperator = append(stakersByOperator, delegationtypes.StakersByOperator{ + Key: string(assetstypes.GetJoinedStoreKey(operator.String(), assetID)), + Stakers: []string{ + stakerID, }, }) validators = append(validators, dogfoodtypes.GenesisValidator{ @@ -447,17 +455,14 @@ func getTestExocoreGenesis( assetstypes.DefaultParams(), clientChains, []assetstypes.StakingAssetInfo{ { - AssetBasicInfo: &assets[0], + AssetBasicInfo: assets[0], // required to be 0, since deposits are handled after token init. StakingTotalAmount: sdk.ZeroInt(), }, - }, depositsByStaker, + }, depositsByStaker, nil, ), operatortypes.NewGenesisState( - operatorInfos, - ), delegationtypes.NewGenesis( - delegationsByStaker, - nil, - ), dogfoodtypes.NewGenesis( + operatorInfos, nil, nil, nil, nil, nil, nil, nil, + ), delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil), dogfoodtypes.NewGenesis( dogfoodtypes.NewParams( dogfoodtypes.DefaultEpochsUntilUnbonded, dogfoodtypes.DefaultEpochIdentifier, diff --git a/local_node.sh b/local_node.sh index 25b6577f8..8672a38f3 100755 --- a/local_node.sh +++ b/local_node.sh @@ -95,33 +95,41 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq '.app_state["assets"]["client_chains"][0]["address_length"]="20"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["name"]="Tether USD"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["meta_info"]="Tether USD token"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["address"]="0xdAC17F958D2ee523a2206206994597C13D831ec7"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["address"]="0xdac17f958d2ee523a2206206994597c13d831ec7"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["layer_zero_chain_id"]="101"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["tokens"][0]["staking_total_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["tokens"][0]["staking_total_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["staker"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["total_deposit_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["withdrawable_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["pending_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["operator"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["total_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["pending_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["total_share"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["operator_share"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/oracle jq '.app_state["oracle"]["params"]["tokens"][1]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["oracle"]["params"]["token_feeders"][1]["start_base_block"]="20"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/operator - jq '.app_state["operator"]["operators"][0]["earnings_addr"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["operator_meta_info"]="operator1"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["commission"]["commission_rates"]["rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["commission"]["commission_rates"]["max_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["commission"]["commission_rates"]["max_change_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_address"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["earnings_addr"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["operator_meta_info"]="operator1"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["max_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["max_change_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/delegation - jq '.app_state["delegation"]["delegations"][0]["staker_id"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["delegations"][0]["delegations"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["delegations"][0]["delegations"][0]["per_operator_amounts"][0]["key"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["delegations"][0]["delegations"][0]["per_operator_amounts"][0]["value"]["amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["delegation_states"][0]["key"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65/exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["delegation_states"][0]["states"]["undelegatable_share"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["delegation_states"][0]["states"]["wait_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["delegation"]["associations"][0]["staker_id"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["delegation"]["associations"][0]["operator"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["stakers_by_operator"][0]["key"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["stakers_by_operator"][0]["stakers"][0]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/dogfood # for easy testing, use an epoch of 1 minute and 5 epochs until unbonded. diff --git a/precompiles/assets/tx.go b/precompiles/assets/tx.go index 8a1948803..11ea5f9c5 100644 --- a/precompiles/assets/tx.go +++ b/precompiles/assets/tx.go @@ -143,7 +143,7 @@ func (p Precompile) RegisterToken( } stakingAsset := &assetstypes.StakingAssetInfo{ - AssetBasicInfo: &asset, + AssetBasicInfo: asset, StakingTotalAmount: sdkmath.NewInt(0), } diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index fdb143850..1f204bd1e 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -154,7 +154,7 @@ func (suite *AVSManagerPrecompileSuite) TestAVSUSDValue() { err := suite.App.AssetsKeeper.SetStakingAssetInfo( suite.Ctx, &assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: sdkmath.NewInt(0), }, ) @@ -242,7 +242,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetOperatorOptedUSDValue() { err := suite.App.AssetsKeeper.SetStakingAssetInfo( suite.Ctx, &assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: sdkmath.NewInt(0), }, ) diff --git a/proto/exocore/assets/v1/genesis.proto b/proto/exocore/assets/v1/genesis.proto index cdb6fa033..aad5e3e89 100644 --- a/proto/exocore/assets/v1/genesis.proto +++ b/proto/exocore/assets/v1/genesis.proto @@ -1,10 +1,10 @@ syntax = "proto3"; package exocore.assets.v1; -import "gogoproto/gogo.proto"; - +import "cosmos_proto/cosmos.proto"; import "exocore/assets/v1/params.proto"; import "exocore/assets/v1/tx.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/assets/types"; @@ -27,13 +27,38 @@ message GenesisState { // which contains deposits, withdrawable and unbonding amount. // at genesis (not chain restart), the unbonding amount must be 0. repeated DepositsByStaker deposits = 4 [(gogoproto.nullable) = false]; + + // operator_assets is the list of all operator assets information, indexed + // by the operator address and the asset id. The struct is the `OperatorAssetInfo` + repeated AssetsByOperator operator_assets = 5 [(gogoproto.nullable) = false]; +} + +// AssetsByOperator is a struct to be used in the genesis state. +// It is used to store the operator and its assets state. +message AssetsByOperator { + // operator is the address of the operator,its type should be a sdk.AccAddress + string operator = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // assets_state is the list of assets state, indexed by the asset id. + // The struct is the `OperatorAssetInfo` + repeated AssetByID assets_state = 2 [(gogoproto.nullable) = false]; +} + +// AssetByID is a helper struct to be used in the genesis state. +// It is used to store the asset id and its info for an operator. +// It is named AssetByID (since it is indexed by the assetID) +message AssetByID { + // asset_id is the id of the asset. + string asset_id = 1 [(gogoproto.customname) = "AssetID"]; + // info is the asset info. + OperatorAssetInfo info = 2 [(gogoproto.nullable) = false]; } // DepositByStaker is a helper struct to be used in the genesis state. // It is used to store the staker address and its deposits for each asset ID. message DepositsByStaker { // staker is the address of the staker. - string staker = 1 [ (gogoproto.customname) = "StakerID" ]; + string staker = 1 [(gogoproto.customname) = "StakerID"]; // deposits is the list of deposits, indexed by the asset id. // The struct is the `StakerAssetInfo` which contains deposits, // withdrawable and unbonding amount. @@ -46,9 +71,9 @@ message DepositsByStaker { // and the amount currently unbonding. // It is named DepositByAsset (since it is indexed by the assetID) // and not Deposit to prevent conflict with CrossChainOpType. -message DepositByAsset { +message DepositByAsset { // asset_id is the id of the asset. - string asset_id = 1 [ (gogoproto.customname) = "AssetID" ]; + string asset_id = 1 [(gogoproto.customname) = "AssetID"]; // info is the asset info. StakerAssetInfo info = 2 [(gogoproto.nullable) = false]; } \ No newline at end of file diff --git a/proto/exocore/assets/v1/query.proto b/proto/exocore/assets/v1/query.proto index 14b85f832..a0e69fcf5 100644 --- a/proto/exocore/assets/v1/query.proto +++ b/proto/exocore/assets/v1/query.proto @@ -4,6 +4,7 @@ package exocore.assets.v1; import "cosmos/base/query/v1beta1/pagination.proto"; import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; +import "exocore/assets/v1/genesis.proto"; import "exocore/assets/v1/params.proto"; import "exocore/assets/v1/tx.proto"; import "gogoproto/gogo.proto"; @@ -44,7 +45,7 @@ message QueryAllStakingAssetsInfo {} // indexed by the asset id. message QueryAllStakingAssetsInfoResponse { // all_staking_assets_info is the response for all staking assets info. - map all_staking_assets_info = 1; + repeated StakingAssetInfo all_staking_assets_info = 1 [(gogoproto.nullable) = false]; } // QueryStakerAssetInfo is the query for getting the staker asset info. @@ -56,7 +57,7 @@ message QueryStakerAssetInfo { // QueryAssetInfoResponse is the response for the staker asset info. message QueryAssetInfoResponse { // asset_infos is the response for the staker asset info, indexed by the asset id. - map asset_infos = 1; + repeated DepositByAsset asset_infos = 1 [(gogoproto.nullable) = false]; } // QuerySpecifiedAssetAmountReq is the query for getting the staker specified asset amount. @@ -76,7 +77,7 @@ message QueryOperatorAssetInfos { // QueryOperatorAssetInfosResponse is the response to the operator asset info query. message QueryOperatorAssetInfosResponse { // asset_infos is the response for the operator asset info, indexed by the asset id. - map asset_infos = 1; + repeated AssetByID asset_infos = 1 [(gogoproto.nullable) = false]; } // QueryOperatorSpecifiedAssetAmountReq is the query for getting the operator diff --git a/proto/exocore/assets/v1/tx.proto b/proto/exocore/assets/v1/tx.proto index 5b1585866..a4518e08c 100644 --- a/proto/exocore/assets/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -63,7 +63,7 @@ message AssetInfo { // StakingAssetInfo defines the information for an asset to be used in staking. message StakingAssetInfo { // asset_basic_info is the basic information of the asset. - AssetInfo asset_basic_info = 1; + AssetInfo asset_basic_info = 1[(gogoproto.nullable) = false]; // staking_total_amount is the total amount of the asset staked. string staking_total_amount = 2 [ @@ -110,7 +110,10 @@ message StakerAllAssetsInfo { // OperatorAssetInfo defines the information for a single asset, // for an operator. message OperatorAssetInfo { - // total_amount is the total amount of the asset deposited. + // total_amount is the total amount of the asset deposited, which excludes the + // pending_undelegation_amount. It represent the total delegated amount of asset pool, + // it will be used to calculate the asset amount of a specified staker from its + // delegated share. string total_amount = 1 [ (cosmos_proto.scalar) = "cosmos.Int", diff --git a/proto/exocore/delegation/v1/genesis.proto b/proto/exocore/delegation/v1/genesis.proto index fcc70a21d..8f38031b2 100644 --- a/proto/exocore/delegation/v1/genesis.proto +++ b/proto/exocore/delegation/v1/genesis.proto @@ -2,9 +2,9 @@ syntax = "proto3"; package exocore.delegation.v1; -import "gogoproto/gogo.proto"; - +import "exocore/delegation/v1/query.proto"; import "exocore/delegation/v1/tx.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/delegation/types"; @@ -13,10 +13,34 @@ option go_package = "github.com/ExocoreNetwork/exocore/x/delegation/types"; // or in the event of a restart. At this point, it is only built with // the former in mind. There are no params in this module. message GenesisState { - // delegations is a list of all delegations in the system. - repeated DelegationsByStaker delegations = 1 [(gogoproto.nullable) = false]; // associations represents the association between a staker and an operator. - repeated StakerToOperator associations = 2 [(gogoproto.nullable) = false]; + repeated StakerToOperator associations = 1 [(gogoproto.nullable) = false]; + // delegation_states is a list of all delegation states. + repeated DelegationStates delegation_states = 2 [(gogoproto.nullable) = false]; + // stakers_by_operator is a staker list for the operators + repeated StakersByOperator stakers_by_operator = 3 [(gogoproto.nullable) = false]; + // undelegations is a list of all undelegations + repeated UndelegationRecord undelegations = 4 [(gogoproto.nullable) = false]; +} + +// DelegationStates is a helper struct for the delegation state +// used to construct the genesis state +message DelegationStates { + // key is used for storing the delegation states, + // which is a combination of the staker ID, asset ID, and operator address. + string key = 1; + // states is the value of undelegation state for the above key + DelegationAmounts states = 2 [(gogoproto.nullable) = false] ; +} + +// StakersByOperator is a helper struct for an operator's staker list +// used to construct the genesis state +message StakersByOperator { + // key is used for storing the staker list, + // which is a combination of the operator address and the asset ID. + string key = 1; + // stakers is the stakers list for the above key + repeated string stakers = 2 [(gogoproto.nullable) = false] ; } // DelegationsByStaker is a list of delegations for a single staker. diff --git a/proto/exocore/dogfood/v1/genesis.proto b/proto/exocore/dogfood/v1/genesis.proto index 881eba384..4ec5c79eb 100644 --- a/proto/exocore/dogfood/v1/genesis.proto +++ b/proto/exocore/dogfood/v1/genesis.proto @@ -18,7 +18,7 @@ message GenesisState { // params refers to the parameters of the module. Params params = 1 [(gogoproto.nullable) = false]; - // val_set is the initial validator set. it onyl represents the active + // val_set is the initial validator set. it only represents the active // validators. repeated GenesisValidator val_set = 2 [ (gogoproto.nullable) = false ]; diff --git a/proto/exocore/operator/v1/genesis.proto b/proto/exocore/operator/v1/genesis.proto index 3c69fa300..1a304efe3 100644 --- a/proto/exocore/operator/v1/genesis.proto +++ b/proto/exocore/operator/v1/genesis.proto @@ -12,10 +12,129 @@ option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; message GenesisState { // there are no params for this module. // operators is a list of the registered operators. - repeated OperatorInfo operators = 1 [(gogoproto.nullable) = false]; - // TODO: add non-chainID AVS opt-in information for exporting / importing. + repeated OperatorDetail operators = 1 [(gogoproto.nullable) = false]; + + // add other information for exporting / importing. // Although it is not necessary for the bootstrapped genesis, it is // necessary for chain restarts. + // operator_records refers to a list of operator records. each record + // contains an operator address and a list of chain id + + // cons key combination. + repeated OperatorConsKeyRecord operator_records = 2 + [(gogoproto.nullable) = false]; + // opt_states is a list of all opted information for the AVS and operators + repeated OptedState opt_states = 3 [(gogoproto.nullable) = false]; + // avs_usd_values is a list of AVS USD value + repeated AVSUSDValue avs_usd_values = 4[ + (gogoproto.nullable) = false, + (gogoproto.customname) = "AVSUSDValues" + ]; + // operator_usd_values is a list of operator USD value + repeated OperatorUSDValue operator_usd_values = 5[ + (gogoproto.nullable) = false, + (gogoproto.customname) = "OperatorUSDValues" + ]; + // slash_states is a list of all slashing information + repeated OperatorSlashState slash_states = 6 [(gogoproto.nullable) = false]; + // pre_cons_key is a list of all previous consensus public key + repeated PrevConsKey pre_cons_keys = 7 [(gogoproto.nullable) = false]; + // operator_key_removal is a list of operator with the given address + // is in the process of unbonding their key for the given chainID. + repeated OperatorKeyRemoval operator_key_removals = 8 [(gogoproto.nullable) = false]; +} + +// OperatorDetail is helper structure to store the operator information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorInfo` +message OperatorDetail { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + string operator_address = 1; + // operator_info is the detail information for the above operator + OperatorInfo operator_info = 2 [(gogoproto.nullable) = false] ; +} + +// OptedStates is helper structure to store the opted state for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorOptedAVSInfo` +message OptedState { + // key is used for storing the opted states, + // which is a combination of the operator address and AVS address. + string key = 1; + // opt_info is the value of undelegation state for the above key + OptedInfo opt_info = 2 [(gogoproto.nullable) = false] ; +} + +// AVSUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForAVS` +message AVSUSDValue { + // avs_addr + string avs_addr = 1[(gogoproto.customname) = "AVSAddr"]; + // value is the USD value for the AVS address + DecValueField value = 2 [(gogoproto.nullable) = false] ; +} + +// OperatorUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForOperator` +message OperatorUSDValue { + // key is used for storing the voting power of specified operator and AVS, + // which is the combination of operator and AVS address. + string key = 1; + // value is the USD value states for the AVS address + OperatorOptedUSDValue opted_usd_value = 2[ + (gogoproto.nullable) = false, + (gogoproto.customname) = "OptedUSDValue" + ] ; +} + +// OperatorSlashState is helper structure to store the slash information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorSlashInfo` +message OperatorSlashState { + // key is used for storing the slash information, + // which is the combination of the operator address, AVS address, and slashID. + string key = 1; + // states is the voting power value for the above key + OperatorSlashInfo info = 2 [(gogoproto.nullable) = false] ; +} + +// PrevConsKey is helper structure to store the previous consensus key +// for the operator and chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorAndChainIDToPrevConsKey` +message PrevConsKey { + // key is used for storing the previous consensus key, + // which is the combination of chainID and operator address. + string key = 1; + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + string consensus_key = 2; +} + +// OperatorKeyRemoval is helper structure to store the operator with the given address +// is in the process of unbonding their key for the given chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorKeyRemovalForChainID` +message OperatorKeyRemoval { + // key is the combination of operator address and chainID. + string key = 1; +} + +// OperatorConsKeyRecord is a helper structure for the genesis state. Each record +// contains an operator address and a list of chain id + cons key combination. +message OperatorConsKeyRecord { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + string operator_address = 1; + // chains is a list of chain id + consensus key combination. + repeated ChainDetails chains = 2 [(gogoproto.nullable) = false]; +} + +// ChainDetails is a helper structure for the genesis state. Each record +// contains a chain id and a consensus key. +message ChainDetails { + // chain_id is the unique identifier of the chain. + string chain_id = 1 [(gogoproto.customname) = "ChainID"]; + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + string consensus_key = 2; } // all operators in the genesis (during bootstrap) are assumed to have diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index d963b207f..71d678d37 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -169,9 +169,9 @@ message SlashExecutionInfo { (gogoproto.nullable) = false ]; // SlashUndelegations records all slash info related to the undelegation - repeated SlashFromUndelegation slash_undelegations = 3; + repeated SlashFromUndelegation slash_undelegations = 3 [(gogoproto.nullable) = false] ; // SlashFromAssetsPool records all slash info related to the assets pool - repeated SlashFromAssetsPool slash_assets_pool = 4; + repeated SlashFromAssetsPool slash_assets_pool = 4 [(gogoproto.nullable) = false] ; } // OperatorSlashInfo is the slash info of operator diff --git a/testutil/utils.go b/testutil/utils.go index c45703e8a..099582bd2 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -4,6 +4,8 @@ import ( "encoding/json" "time" + avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" @@ -75,7 +77,7 @@ func (suite *BaseTestSuite) SetupTest() { // that also act as delegators. func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) - appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, false)() + appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, true)() app, ok := appI.(*exocoreapp.ExocoreApp) suite.Require().True(ok) @@ -105,6 +107,8 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc suite.Powers = []int64{power, power2} depositAmount := math.NewIntWithDecimal(power, 6) depositAmount2 := math.NewIntWithDecimal(power2, 6) + usdValue := math.LegacyNewDec(power) + usdValue2 := math.LegacyNewDec(power2) depositsByStaker := []assetstypes.DepositsByStaker{ { StakerID: stakerID1, @@ -133,6 +137,47 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc }, }, } + operatorAssets := []assetstypes.AssetsByOperator{ + { + Operator: operator1.String(), + AssetsState: []assetstypes.AssetByID{ + { + AssetID: assetID, + Info: assetstypes.OperatorAssetInfo{ + TotalAmount: depositAmount, + PendingUndelegationAmount: sdk.ZeroInt(), + TotalShare: sdk.NewDecFromBigInt(depositAmount.BigInt()), + OperatorShare: sdk.NewDecFromBigInt(depositAmount.BigInt()), + }, + }, + }, + }, + { + Operator: operator2.String(), + AssetsState: []assetstypes.AssetByID{ + { + AssetID: assetID, + Info: assetstypes.OperatorAssetInfo{ + TotalAmount: depositAmount2, + PendingUndelegationAmount: sdk.ZeroInt(), + TotalShare: sdk.NewDecFromBigInt(depositAmount2.BigInt()), + OperatorShare: sdk.NewDecFromBigInt(depositAmount2.BigInt()), + }, + }, + }, + }, + } + assetsGenesis := assetstypes.NewGenesis( + assetstypes.DefaultParams(), + suite.ClientChains, []assetstypes.StakingAssetInfo{ + { + AssetBasicInfo: suite.Assets[0], + StakingTotalAmount: depositAmount.Add(depositAmount2), + }, + }, depositsByStaker, operatorAssets, + ) + genesisState[assetstypes.ModuleName] = app.AppCodec().MustMarshalJSON(assetsGenesis) + // x/oracle initialization oracleDefaultParams := oracletypes.DefaultParams() oracleDefaultParams.Tokens[1].AssetID = "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" @@ -159,29 +204,23 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc } genesisState[oracletypes.ModuleName] = app.AppCodec().MustMarshalJSON(oracleGenesis) - assetsGenesis := assetstypes.NewGenesis( - assetstypes.DefaultParams(), - suite.ClientChains, []assetstypes.StakingAssetInfo{ - { - AssetBasicInfo: &suite.Assets[0], - // required to be 0, since deposits are handled after token init. - StakingTotalAmount: sdk.ZeroInt(), - }, - }, depositsByStaker, - ) - genesisState[assetstypes.ModuleName] = app.AppCodec().MustMarshalJSON(assetsGenesis) - - // operator registration - operatorInfos := []operatortypes.OperatorInfo{ + // x/operator registration + operatorInfos := []operatortypes.OperatorDetail{ { - EarningsAddr: operator1.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator1.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator1.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, { - EarningsAddr: operator2.String(), - OperatorMetaInfo: "operator2", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator2.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator2.String(), + OperatorMetaInfo: "operator2", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, } // generate validator private/public key @@ -189,44 +228,90 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc suite.Require().NotNil(pubKey) pubKey2 := testutiltx.GenerateConsensusKey() suite.Require().NotNil(pubKey2) - operatorGenesis := operatortypes.NewGenesisState(operatorInfos) - genesisState[operatortypes.ModuleName] = app.AppCodec().MustMarshalJSON(operatorGenesis) - - // x/delegation - delegationsByStaker := []delegationtypes.DelegationsByStaker{ + chainIDWithoutRevision := avstypes.ChainIDWithoutRevision(utils.DefaultChainID) + operatorConsKeys := []operatortypes.OperatorConsKeyRecord{ { - StakerID: stakerID1, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ + OperatorAddress: operator1.String(), + Chains: []operatortypes.ChainDetails{ { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator1.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, + ChainID: chainIDWithoutRevision, + ConsensusKey: pubKey.ToHex(), }, }, }, { - StakerID: stakerID2, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ + OperatorAddress: operator2.String(), + Chains: []operatortypes.ChainDetails{ { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator2.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount2, - }, - }, - }, + ChainID: chainIDWithoutRevision, + ConsensusKey: pubKey2.ToHex(), }, }, }, } + avsAddr := avstypes.GenerateAVSAddr(chainIDWithoutRevision) + optStates := []operatortypes.OptedState{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator1.String(), avsAddr)), + OptInfo: operatortypes.OptedInfo{ + OptedInHeight: 1, + OptedOutHeight: operatortypes.DefaultOptedOutHeight, + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(operator2.String(), avsAddr)), + OptInfo: operatortypes.OptedInfo{ + OptedInHeight: 1, + OptedOutHeight: operatortypes.DefaultOptedOutHeight, + }, + }, + } + operatorUSDValues := []operatortypes.OperatorUSDValue{ + { + Key: string(assetstypes.GetJoinedStoreKey(avsAddr, operator1.String())), + OptedUSDValue: operatortypes.OperatorOptedUSDValue{ + SelfUSDValue: usdValue, + TotalUSDValue: usdValue, + ActiveUSDValue: usdValue, + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(avsAddr, operator2.String())), + OptedUSDValue: operatortypes.OperatorOptedUSDValue{ + SelfUSDValue: usdValue2, + TotalUSDValue: usdValue2, + ActiveUSDValue: usdValue2, + }, + }, + } + avsUSDValues := []operatortypes.AVSUSDValue{ + { + AVSAddr: avsAddr, + Value: operatortypes.DecValueField{ + Amount: usdValue.Add(usdValue2), + }, + }, + } + operatorGenesis := operatortypes.NewGenesisState(operatorInfos, operatorConsKeys, optStates, operatorUSDValues, avsUSDValues, nil, nil, nil) + genesisState[operatortypes.ModuleName] = app.AppCodec().MustMarshalJSON(operatorGenesis) + + // x/delegation + delegationStates := []delegationtypes.DelegationStates{ + { + Key: string(assetstypes.GetJoinedStoreKey(stakerID1, assetID, operator1.String())), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(stakerID2, assetID, operator2.String())), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount2.BigInt()), + }, + }, + } associations := []delegationtypes.StakerToOperator{ { Operator: operator1.String(), @@ -237,7 +322,21 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc StakerID: stakerID2, }, } - delegationGenesis := delegationtypes.NewGenesis(delegationsByStaker, associations) + stakersByOperator := []delegationtypes.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator1.String(), assetID)), + Stakers: []string{ + stakerID1, + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(operator2.String(), assetID)), + Stakers: []string{ + stakerID2, + }, + }, + } + delegationGenesis := delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil) genesisState[delegationtypes.ModuleName] = app.AppCodec().MustMarshalJSON(delegationGenesis) // create a dogfood genesis with just the validator set, that is, the bare diff --git a/utils/utils.go b/utils/utils.go index fb1672228..a291b6041 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -3,7 +3,11 @@ package utils import ( "strings" + ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "golang.org/x/exp/constraints" + "golang.org/x/xerrors" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -21,6 +25,12 @@ const ( DefaultChainID = MainnetChainID + "-1" // BaseDenom defines the Evmos mainnet denomination BaseDenom = "aexo" + + // DelimiterForCombinedKey is the delimiter used for constructing the combined key. + DelimiterForCombinedKey = "/" + + // DelimiterForID Delimiter used for constructing the stakerID and assetID. + DelimiterForID = "_" ) // IsMainnet returns true if the chain-id has the Evmos mainnet EIP155 chain prefix. @@ -33,6 +43,20 @@ func IsTestnet(chainID string) bool { return strings.HasPrefix(chainID, TestnetChainID) } +func IsValidRevisionChainID(chainID string) bool { + if strings.Contains(chainID, DelimiterForCombinedKey) { + return false + } + return ibcclienttypes.IsRevisionFormat(chainID) +} + +func IsValidChainIDWithoutRevision(chainID string) bool { + if strings.Contains(chainID, DelimiterForCombinedKey) { + return false + } + return !ibcclienttypes.IsRevisionFormat(chainID) +} + // IsSupportedKey returns true if the pubkey type is supported by the chain // (i.e eth_secp256k1, amino multisig, ed25519). // NOTE: Nested multisigs are not supported. @@ -61,6 +85,38 @@ func IsSupportedKey(pubkey cryptotypes.PubKey) bool { } } +// CommonValidation is used to check for duplicates in the input list +// and validate the input information simultaneously. +// It might be used for validating most genesis states. +// slice is the input list +// seenFieldValue return the key used to check for duplicates and the +// value stored for the other validations +// validation is a function to execute customized check for the object +func CommonValidation[T any, V constraints.Ordered, D any]( + slice []T, + seenFieldValue func(T) (V, D), + validation func(int, T) error, +) (map[V]D, error) { + seen := make(map[V]D) + for i := range slice { + v := slice[i] + field, value := seenFieldValue(v) + // check for no duplicated element + if _, ok := seen[field]; ok { + return nil, xerrors.Errorf( + "duplicate element: %v", + field, + ) + } + // perform the validation + if err := validation(i, v); err != nil { + return nil, err + } + seen[field] = value + } + return seen, nil +} + // // GetExocoreAddressFromBech32 returns the sdk.Account address of given address, // // while also changing bech32 human readable prefix (HRP) to the value set on // // the global sdk.Config (eg: `evmos`). diff --git a/utils/utils_test.go b/utils/utils_test.go index 04c2949cb..08007ed55 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -127,3 +127,33 @@ func TestExocoreCoinDenom(t *testing.T) { }) } } + +func TestIsValidChainIDWithoutRevision(t *testing.T) { + testCases := []struct { + name string + chainID string + expResult bool + }{ + { + name: "invalid chainID: include delimiter", + chainID: "exocore/testnet_233", + expResult: false, + }, + { + name: "invalid chainID: include revision", + chainID: "exocoretestnet_233-6", + expResult: false, + }, + { + name: "valid chainID", + chainID: "exocoretestnet_233", + expResult: true, + }, + } + for _, tc := range testCases { + t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) { + isInvalid := IsValidChainIDWithoutRevision(tc.chainID) + require.Equal(t, tc.expResult, isInvalid) + }) + } +} diff --git a/x/assets/keeper/client_chain_and_asset_test.go b/x/assets/keeper/client_chain_and_asset_test.go index bc9b18ca2..bad0718c2 100644 --- a/x/assets/keeper/client_chain_and_asset_test.go +++ b/x/assets/keeper/client_chain_and_asset_test.go @@ -23,39 +23,30 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { MetaInfo: "Tether USD token", } stakingInfo := assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdtClientChainAsset, - StakingTotalAmount: math.NewInt(0), + AssetBasicInfo: usdtClientChainAsset, + StakingTotalAmount: math.NewIntWithDecimal(201, 6), } defaultGensisState := assetstype.NewGenesis( assetstype.DefaultParams(), []assetstype.ClientChainInfo{ethClientChain}, []assetstype.StakingAssetInfo{stakingInfo}, []assetstype.DepositsByStaker{}, + nil, ) // test the client chains getting clientChains, err := suite.App.AssetsKeeper.GetAllClientChainInfo(suite.Ctx) suite.NoError(err) - suite.Ctx.Logger().Info("the clientChains is:", "info", clientChains) - for _, clientChain := range defaultGensisState.ClientChains { - suite.Contains(clientChains, clientChain) - } + suite.Contains(clientChains, defaultGensisState.ClientChains[0]) chainInfo, err := suite.App.AssetsKeeper.GetClientChainInfoByIndex(suite.Ctx, 101) suite.NoError(err) - suite.Contains(clientChains, *chainInfo) + suite.Equal(clientChains[0], *chainInfo) // test the client chain assets getting assets, err := suite.App.AssetsKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) - for _, assetX := range defaultGensisState.Tokens { - asset := assetX.AssetBasicInfo - _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) - suite.Ctx.Logger().Info("the asset id is:", "assetID", assetID) - info, ok := assets[assetID] - suite.True(ok) - suite.Equal(asset, info.AssetBasicInfo) - } + suite.Contains(assets, defaultGensisState.Tokens[0]) usdtAssetX := defaultGensisState.Tokens[0] usdtAsset := usdtAssetX.AssetBasicInfo diff --git a/x/assets/keeper/client_chain_asset.go b/x/assets/keeper/client_chain_asset.go index 5886099d0..6e399ca69 100644 --- a/x/assets/keeper/client_chain_asset.go +++ b/x/assets/keeper/client_chain_asset.go @@ -40,6 +40,9 @@ func (k Keeper) SetStakingAssetInfo(ctx sdk.Context, info *assetstype.StakingAss if info.AssetBasicInfo.Decimals > assetstype.MaxDecimal { return errorsmod.Wrapf(assetstype.ErrInvalidInputParameter, "the decimal is greater than the MaxDecimal,decimal:%v,MaxDecimal:%v", info.AssetBasicInfo.Decimals, assetstype.MaxDecimal) } + if info.StakingTotalAmount.IsNegative() { + return errorsmod.Wrapf(assetstype.ErrInvalidInputParameter, "the total staking amount is negative, StakingTotalAmount:%v", info.StakingTotalAmount) + } store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakingAssetInfo) // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) @@ -85,17 +88,16 @@ func (k Keeper) GetAssetsDecimal(ctx sdk.Context, assets map[string]interface{}) return decimals, nil } -func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) { +func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets []assetstype.StakingAssetInfo, err error) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, assetstype.KeyPrefixReStakingAssetInfo) defer iterator.Close() - ret := make(map[string]*assetstype.StakingAssetInfo, 0) + ret := make([]assetstype.StakingAssetInfo, 0) for ; iterator.Valid(); iterator.Next() { var assetInfo assetstype.StakingAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &assetInfo) - _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(assetInfo.AssetBasicInfo.LayerZeroChainID, "", assetInfo.AssetBasicInfo.Address) - ret[assetID] = &assetInfo + ret = append(ret, assetInfo) } return ret, nil } diff --git a/x/assets/keeper/genesis.go b/x/assets/keeper/genesis.go index 12ce7b949..7a544172a 100644 --- a/x/assets/keeper/genesis.go +++ b/x/assets/keeper/genesis.go @@ -1,6 +1,7 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -15,18 +16,18 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { for i := range data.ClientChains { info := data.ClientChains[i] if err := k.SetClientChainInfo(ctx, &info); err != nil { - panic(err) + panic(errorsmod.Wrap(err, "failed to set client chain info")) } } // client_chain_asset.go for i := range data.Tokens { info := data.Tokens[i] if err := k.SetStakingAssetInfo(ctx, &info); err != nil { - panic(err) + panic(errorsmod.Wrap(err, "failed to set staking asset info")) } } // staker_asset.go (deposits) - // we simulate the behavior of the depositKeeper.Deposit call + // we set the assets state related to deposits // it constructs the stakerID and the assetID, which we have validated previously. // it checks that the deposited amount is not negative, which we have already done. // and that the asset is registered, which we have also already done. @@ -40,21 +41,52 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { if err := k.UpdateStakerAssetState( ctx, stakerID, assetID, infoAsChange, ); err != nil { - panic(err) + panic(errorsmod.Wrap(err, "failed to set deposit info")) } - // now for the asset, increase the deposit value - if err := k.UpdateStakingAssetTotalAmount( - ctx, assetID, info.TotalDepositAmount, - ); err != nil { - panic(err) + } + } + + for _, assets := range data.OperatorAssets { + for _, assetInfo := range assets.AssetsState { + // #nosec G703 // already validated + accAddress, _ := sdk.AccAddressFromBech32(assets.Operator) + infoAsChange := types.DeltaOperatorSingleAsset(assetInfo.Info) + err := k.UpdateOperatorAssetState(ctx, accAddress, assetInfo.AssetID, infoAsChange) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set operator asset info")) } } } } // ExportGenesis returns the module's exported genesis. -func (Keeper) ExportGenesis(sdk.Context) *types.GenesisState { +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { res := types.GenesisState{} - // TODO + var err error + params, err := k.GetParams(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get parameter").Error()) + } + res.Params = *params + + res.ClientChains, err = k.GetAllClientChainInfo(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all client chains").Error()) + } + + res.Tokens, err = k.GetAllStakingAssetsInfo(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all staking assets info").Error()) + } + + res.Deposits, err = k.AllDeposits(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all deposits").Error()) + } + + res.OperatorAssets, err = k.AllOperatorAssets(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all assets info for the operators").Error()) + } return &res } diff --git a/x/assets/keeper/keeper.go b/x/assets/keeper/keeper.go index cc6fcf166..c2477d076 100644 --- a/x/assets/keeper/keeper.go +++ b/x/assets/keeper/keeper.go @@ -47,13 +47,13 @@ type IAssets interface { SetStakingAssetInfo(ctx sdk.Context, info *assetstype.StakingAssetInfo) (err error) GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *assetstype.StakingAssetInfo, err error) - GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) + GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets []assetstype.StakingAssetInfo, err error) - GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerAssetInfo, err error) + GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo []assetstype.DepositByAsset, err error) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerAssetInfo, err error) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount assetstype.DeltaStakerSingleAsset) (err error) - GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorAssetInfo, err error) + GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo []assetstype.AssetByID, err error) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorAssetInfo, err error) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount assetstype.DeltaOperatorSingleAsset) (err error) PerformDepositOrWithdraw(ctx sdk.Context, params *DepositWithdrawParams) error diff --git a/x/assets/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go index 6168e4f39..0f6a725c2 100644 --- a/x/assets/keeper/operator_asset.go +++ b/x/assets/keeper/operator_asset.go @@ -10,10 +10,46 @@ import ( // This file provides all functions about operator assets state management. -func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorAssetInfo, err error) { - ret := make(map[string]*assetstype.OperatorAssetInfo, 0) +// AllOperatorAssets +func (k Keeper) AllOperatorAssets(ctx sdk.Context) (operatorAssets []assetstype.AssetsByOperator, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]assetstype.AssetsByOperator, 0) + var previousOperator string + for ; iterator.Valid(); iterator.Next() { + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) + if err != nil { + return nil, err + } + operator, assetID := keyList[0], keyList[1] + if previousOperator != operator { + assetsByOperator := assetstype.AssetsByOperator{ + Operator: operator, + AssetsState: make([]assetstype.AssetByID, 0), + } + ret = append(ret, assetsByOperator) + } + var assetInfo assetstype.OperatorAssetInfo + k.cdc.MustUnmarshal(iterator.Value(), &assetInfo) + index := len(ret) - 1 + ret[index].AssetsState = append(ret[index].AssetsState, assetstype.AssetByID{ + AssetID: assetID, + Info: assetInfo, + }) + previousOperator = operator + } + return ret, nil +} + +func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo []assetstype.AssetByID, err error) { + ret := make([]assetstype.AssetByID, 0) opFunc := func(assetID string, state *assetstype.OperatorAssetInfo) error { - ret[assetID] = state + ret = append(ret, assetstype.AssetByID{ + AssetID: assetID, + Info: *state, + }) return nil } err = k.IterateAssetsForOperator(ctx, false, operatorAddr.String(), assetsFilter, opFunc) diff --git a/x/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go index f7e9cb3fb..0d90d47ce 100644 --- a/x/assets/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -11,12 +11,45 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerAssetInfo, err error) { +// AllDeposits +func (k Keeper) AllDeposits(ctx sdk.Context) (deposits []assetstype.DepositsByStaker, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]assetstype.DepositsByStaker, 0) + var previousStakerID string + for ; iterator.Valid(); iterator.Next() { + var stateInfo assetstype.StakerAssetInfo + k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) + if err != nil { + return nil, err + } + stakerID, assetID := keyList[0], keyList[1] + if previousStakerID != stakerID { + depositsByStaker := assetstype.DepositsByStaker{ + StakerID: stakerID, + Deposits: make([]assetstype.DepositByAsset, 0), + } + ret = append(ret, depositsByStaker) + } + index := len(ret) - 1 + ret[index].Deposits = append(ret[index].Deposits, assetstype.DepositByAsset{ + AssetID: assetID, + Info: stateInfo, + }) + previousStakerID = stakerID + } + return ret, nil +} + +func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo []assetstype.DepositByAsset, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) iterator := sdk.KVStorePrefixIterator(store, []byte(stakerID)) defer iterator.Close() - ret := make(map[string]*assetstype.StakerAssetInfo, 0) + ret := make([]assetstype.DepositByAsset, 0) for ; iterator.Valid(); iterator.Next() { var stateInfo assetstype.StakerAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) @@ -25,7 +58,10 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInf return nil, err } assetID := keyList[1] - ret[assetID] = &stateInfo + ret = append(ret, assetstype.DepositByAsset{ + AssetID: assetID, + Info: stateInfo, + }) } return ret, nil } diff --git a/x/assets/keeper/staker_asset_test.go b/x/assets/keeper/staker_asset_test.go index 56843bb21..27e3e72be 100644 --- a/x/assets/keeper/staker_asset_test.go +++ b/x/assets/keeper/staker_asset_test.go @@ -85,12 +85,24 @@ func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") ethUniInitialChangeValue := assetstype.DeltaStakerSingleAsset{ - TotalDepositAmount: math.NewInt(1000), - WithdrawableAmount: math.NewInt(1000), + TotalDepositAmount: math.NewInt(1000), + WithdrawableAmount: math.NewInt(1000), + PendingUndelegationAmount: math.NewInt(0), } ethUsdtInitialChangeValue := assetstype.DeltaStakerSingleAsset{ - TotalDepositAmount: math.NewInt(2000), - WithdrawableAmount: math.NewInt(2000), + TotalDepositAmount: math.NewInt(2000), + WithdrawableAmount: math.NewInt(2000), + PendingUndelegationAmount: math.NewInt(0), + } + assetsInfo := []assetstype.DepositByAsset{ + { + AssetID: ethUniAssetID, + Info: assetstype.StakerAssetInfo(ethUniInitialChangeValue), + }, + { + AssetID: ethUsdtAssetID, + Info: assetstype.StakerAssetInfo(ethUsdtInitialChangeValue), + }, } err := suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) @@ -98,15 +110,8 @@ func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { suite.Require().NoError(err) // test get all assets state of staker - assetsInfo, err := suite.App.AssetsKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) + getAssetsInfo, err := suite.App.AssetsKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) suite.Require().NoError(err) - uniState, isExist := assetsInfo[ethUniAssetID] - suite.Require().True(isExist) - suite.Require().True(uniState.TotalDepositAmount.Equal(math.NewInt(1000))) - suite.Require().True(uniState.WithdrawableAmount.Equal(math.NewInt(1000))) - - usdtState, isExist := assetsInfo[ethUsdtAssetID] - suite.Require().True(isExist) - suite.Require().True(usdtState.TotalDepositAmount.Equal(math.NewInt(2000))) - suite.Require().True(usdtState.WithdrawableAmount.Equal(math.NewInt(2000))) + suite.Contains(getAssetsInfo, assetsInfo[0]) + suite.Contains(getAssetsInfo, assetsInfo[1]) } diff --git a/x/assets/types/errors.go b/x/assets/types/errors.go index 0d8c15354..e65862e6f 100644 --- a/x/assets/types/errors.go +++ b/x/assets/types/errors.go @@ -91,4 +91,9 @@ var ( ErrRegisterDuplicateAssetID = errorsmod.Register( ModuleName, 19, "register new asset with an existing assetID") + + ErrParseJoinedKey = errorsmod.Register( + ModuleName, 20, + "the joined key can't be parsed", + ) ) diff --git a/x/assets/types/general.go b/x/assets/types/general.go index f3c5fd651..bcbd0f8f5 100644 --- a/x/assets/types/general.go +++ b/x/assets/types/general.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/ExocoreNetwork/exocore/utils" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -64,11 +66,11 @@ func GetStakeIDAndAssetID( ) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(clientChainLzID) if stakerAddress != nil { - stakeID = strings.Join([]string{hexutil.Encode(stakerAddress), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(stakerAddress), clientChainLzIDStr}, utils.DelimiterForID) } if assetsAddress != nil { - assetID = strings.Join([]string{hexutil.Encode(assetsAddress), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(assetsAddress), clientChainLzIDStr}, utils.DelimiterForID) } return } @@ -85,14 +87,14 @@ func GetStakeIDAndAssetIDFromStr( if stakerAddress != "" { stakeID = strings.Join( []string{strings.ToLower(stakerAddress), clientChainLzIDStr}, - "_", + utils.DelimiterForID, ) } if assetsAddress != "" { assetID = strings.Join( []string{strings.ToLower(assetsAddress), clientChainLzIDStr}, - "_", + utils.DelimiterForID, ) } return diff --git a/x/assets/types/genesis.go b/x/assets/types/genesis.go index 2b5272bbf..5902d9bd0 100644 --- a/x/assets/types/genesis.go +++ b/x/assets/types/genesis.go @@ -1,7 +1,12 @@ package types import ( + "strings" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/utils" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ) @@ -9,12 +14,14 @@ import ( func NewGenesis( params Params, chains []ClientChainInfo, tokens []StakingAssetInfo, deposits []DepositsByStaker, + operatorAssets []AssetsByOperator, ) *GenesisState { return &GenesisState{ - Params: params, - ClientChains: chains, - Tokens: tokens, - Deposits: deposits, + Params: params, + ClientChains: chains, + Tokens: tokens, + Deposits: deposits, + OperatorAssets: operatorAssets, } } @@ -24,28 +31,18 @@ func NewGenesis( // for any unit / integration tests. func DefaultGenesis() *GenesisState { return NewGenesis( - DefaultParams(), []ClientChainInfo{}, []StakingAssetInfo{}, []DepositsByStaker{}, + DefaultParams(), []ClientChainInfo{}, []StakingAssetInfo{}, []DepositsByStaker{}, []AssetsByOperator{}, ) } -// Validate performs basic genesis state validation returning an error -// upon any failure. -func (gs GenesisState) Validate() error { - // client_chain.go -> check no repeat chain - lzIDs := make(map[uint64]struct{}, len(gs.ClientChains)) - for i, info := range gs.ClientChains { - if info.Name == "" || len(info.Name) > MaxChainTokenNameLength { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil Name or too long for chain %d, name:%s, maxLength:%d", - i, info.Name, MaxChainTokenNameLength, - ) - } - if info.MetaInfo == "" || len(info.MetaInfo) > MaxChainTokenMetaInfoLength { +// ValidateClientChains performs basic client chains validation +func (gs GenesisState) ValidateClientChains() (map[uint64]struct{}, error) { + validationFunc := func(i int, info ClientChainInfo) error { + if info.Name == "" { return errorsmod.Wrapf( ErrInvalidGenesisData, - "nil meta info or too long for chain %d, metaInfo:%s, maxLength:%d", - i, info.MetaInfo, MaxChainTokenMetaInfoLength, + "nil Name for chain %d", + i, ) } // this is our primary method of cross-chain communication. @@ -64,95 +61,80 @@ func (gs GenesisState) Validate() error { info.Name, ) } - // check for no duplicated chain, indexed by LayerZeroChainID. - if _, ok := lzIDs[info.LayerZeroChainID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate LayerZeroChainID: %d", - info.LayerZeroChainID, - ) - } - lzIDs[info.LayerZeroChainID] = struct{}{} + return nil } - // client_chain_asset.go -> check presence of client chain - // for all assets and no duplicates - tokens := make(map[string]struct{}, len(gs.Tokens)) - for _, info := range gs.Tokens { - if info.AssetBasicInfo == nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil AssetBasicInfo for token %s", - info.AssetBasicInfo.MetaInfo, - ) - } - if info.AssetBasicInfo.Name == "" || len(info.AssetBasicInfo.Name) > MaxChainTokenNameLength { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil Name or too long for token, name:%s, maxLength:%d", - info.AssetBasicInfo.Name, MaxChainTokenNameLength, - ) - } - if info.AssetBasicInfo.MetaInfo == "" || len(info.AssetBasicInfo.MetaInfo) > MaxChainTokenMetaInfoLength { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil meta info or too long for token, metaInfo:%s, maxLength:%d", - info.AssetBasicInfo.MetaInfo, MaxChainTokenMetaInfoLength, - ) - } + seenFieldValueFunc := func(info ClientChainInfo) (uint64, struct{}) { + return info.LayerZeroChainID, struct{}{} + } + lzIDs, err := utils.CommonValidation(gs.ClientChains, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + return lzIDs, nil +} + +// ValidateTokens performs basic client chain assets validation +func (gs GenesisState) ValidateTokens(lzIDs map[uint64]struct{}) (map[string]math.Int, error) { + validationFunc := func(_ int, info StakingAssetInfo) error { id := info.AssetBasicInfo.LayerZeroChainID // check that the chain is registered if _, ok := lzIDs[id]; !ok { return errorsmod.Wrapf( ErrInvalidGenesisData, - "unknown LayerZeroChainID for token %s: %d", + "unknown LayerZeroChainID for token %s, clientChainID: %d", info.AssetBasicInfo.MetaInfo, id, ) } address := info.AssetBasicInfo.Address + if strings.ToLower(address) != address { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "contains uppercase characters for token %s, address: %s", + info.AssetBasicInfo.Name, address, + ) + } // build for 0x addresses only. // TODO: consider removing this check for non-EVM client chains. if !common.IsHexAddress(address) { return errorsmod.Wrapf( ErrInvalidGenesisData, - "not hex address for token %s: %s", - info.AssetBasicInfo.MetaInfo, address, + "not hex address for token %s, address: %s", + info.AssetBasicInfo.Name, address, ) } - // calculate the asset id. - _, assetID := GetStakeIDAndAssetIDFromStr( - info.AssetBasicInfo.LayerZeroChainID, - "", address, - ) + // ensure there are no deposits for this asset already (since they are handled in the // genesis exec). while it is possible to remove this field entirely (and assume 0), // i did not do so in order to make the genesis state more explicit. - if info.StakingTotalAmount.IsNil() { + if info.StakingTotalAmount.IsNil() || + info.StakingTotalAmount.IsNegative() { return errorsmod.Wrapf( ErrInvalidGenesisData, - "nil staking total amount for asset %s", - assetID, + "nil total staking amount for asset %s", + info.AssetBasicInfo.Address, ) } - if !info.StakingTotalAmount.IsZero() { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "non-zero deposit amount for asset %s", - assetID, - ) - } - // check that it is not a duplicate. - if _, ok := tokens[assetID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate assetID: %s", - assetID, - ) - } - tokens[assetID] = struct{}{} + return nil + } + seenFieldValueFunc := func(info StakingAssetInfo) (string, math.Int) { + // calculate the asset id. + _, assetID := GetStakeIDAndAssetIDFromStr( + info.AssetBasicInfo.LayerZeroChainID, + "", info.AssetBasicInfo.Address, + ) + return assetID, info.StakingTotalAmount } - // staker_asset.go -> check deposits and withdrawals and that there is no unbonding. - stakers := make(map[string]struct{}, len(gs.Deposits)) - for _, depositByStaker := range gs.Deposits { + totalStaking, err := utils.CommonValidation(gs.Tokens, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return totalStaking, nil +} + +// ValidateDeposits performs basic deposits validation +func (gs GenesisState) ValidateDeposits(lzIDs map[uint64]struct{}, tokensTotalStaking map[string]math.Int) error { + validationFunc := func(_ int, depositByStaker DepositsByStaker) error { stakerID := depositByStaker.StakerID // validate the stakerID var stakerClientChainID uint64 @@ -172,23 +154,15 @@ func (gs GenesisState) Validate() error { stakerID, stakerClientChainID, ) } - // check that it is not a duplicate - if _, ok := stakers[stakerID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate stakerID: %s", - stakerID, - ) - } - stakers[stakerID] = struct{}{} - // map to check for duplicate tokens for the staker. - tokensForStaker := make(map[string]struct{}, len(depositByStaker.Deposits)) - for _, deposit := range depositByStaker.Deposits { + + // validate the deposits + depositValidationF := func(_ int, deposit DepositByAsset) error { assetID := deposit.AssetID // check that the asset is registered // no need to check for the validity of the assetID, since // an invalid assetID cannot be in the tokens map. - if _, ok := tokens[assetID]; !ok { + tokenTotalStaking, ok := tokensTotalStaking[assetID] + if !ok { return errorsmod.Wrapf( ErrInvalidGenesisData, "unknown assetID for deposit %s: %s", @@ -207,15 +181,7 @@ func (gs GenesisState) Validate() error { stakerID, assetID, ) } - // check that it is not a duplicate - if _, ok := tokensForStaker[assetID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate assetID for staker %s: %s", - stakerID, assetID, - ) - } - tokensForStaker[assetID] = struct{}{} + info := deposit.Info // check that there is no nil value provided. if info.TotalDepositAmount.IsNil() || info.WithdrawableAmount.IsNil() || @@ -226,33 +192,132 @@ func (gs GenesisState) Validate() error { assetID, info, ) } - // at genesis (not chain restart), there is no unbonding amount. - if !info.PendingUndelegationAmount.IsZero() { + + // check for negative values. + if info.TotalDepositAmount.IsNegative() || info.WithdrawableAmount.IsNegative() || + info.PendingUndelegationAmount.IsNegative() { return errorsmod.Wrapf( ErrInvalidGenesisData, - "non-zero unbonding amount for %s: %s", - assetID, info.PendingUndelegationAmount, + "negative deposit amount for %s: %+v", + assetID, info, ) } - // check for negative values. - if info.TotalDepositAmount.IsNegative() || info.WithdrawableAmount.IsNegative() { + + if info.TotalDepositAmount.GT(tokenTotalStaking) { return errorsmod.Wrapf( ErrInvalidGenesisData, - "negative deposit amount for %s: %+v", + "invalid deposit amount that is greater than the total staking, assetID: %s: %+v", assetID, info, ) } - // check that the withdrawable amount and the deposited amount are equal. - // this is because this module's genesis only sets up free deposits. - // the delegation module bonds them, thereby altering the withdrawable amount. - if !info.WithdrawableAmount.Equal(info.TotalDepositAmount) { + + if info.PendingUndelegationAmount.Add(info.WithdrawableAmount).GT(info.TotalDepositAmount) { return errorsmod.Wrapf( ErrInvalidGenesisData, - "withdrawable amount is not equal to total deposit amount for %s: %+v", + "the sum of PendingUndelegationAmount and WithdrawableAmount is greater than the TotalDepositAmount, assetID: %s: %+v", assetID, info, ) } + return nil + } + depositFieldValueF := func(deposit DepositByAsset) (string, struct{}) { + return deposit.AssetID, struct{}{} + } + _, err = utils.CommonValidation(depositByStaker.Deposits, depositFieldValueF, depositValidationF) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(deposits DepositsByStaker) (string, struct{}) { + return deposits.StakerID, struct{}{} + } + _, err := utils.CommonValidation(gs.Deposits, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// ValidateOperatorAssets performs basic operator assets validation +func (gs GenesisState) ValidateOperatorAssets(tokensTotalStaking map[string]math.Int) error { + validationFunc := func(_ int, assets AssetsByOperator) error { + _, err := sdk.AccAddressFromBech32(assets.Operator) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid operator address %s: %s", assets.Operator, err, + ) + } + + // validate the assets list for the specified operator + assetValidationFunc := func(_ int, asset AssetByID) error { + // check that the asset is registered + // no need to check for the validity of the assetID, since + // an invalid assetID cannot be in the tokens map. + totalStaking, ok := tokensTotalStaking[asset.AssetID] + if !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown assetID for operator assets %s: %s", + assets.Operator, asset.AssetID, + ) + } + // the sum amount of operators shouldn't be greater than the total staking amount of this asset + if asset.Info.TotalAmount.Add(asset.Info.PendingUndelegationAmount).GT(totalStaking) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "operator's sum amount exceeds the total staking amount for %s: %+v", + assets.Operator, asset, + ) + } + + if asset.Info.OperatorShare.GT(asset.Info.TotalShare) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "operator's share exceeds the total share for %s: %+v", + assets.Operator, asset, + ) + } + return nil + } + assetFieldValueFunc := func(asset AssetByID) (string, struct{}) { + return asset.AssetID, struct{}{} } + _, err = utils.CommonValidation(assets.AssetsState, assetFieldValueFunc, assetValidationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(assets AssetsByOperator) (string, struct{}) { + return assets.Operator, struct{}{} + } + _, err := utils.CommonValidation(gs.OperatorAssets, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// Validate performs basic genesis state validation returning an error +// upon any failure. +func (gs GenesisState) Validate() error { + lzIDs, err := gs.ValidateClientChains() + if err != nil { + return err + } + totalStaking, err := gs.ValidateTokens(lzIDs) + if err != nil { + return err + } + err = gs.ValidateDeposits(lzIDs, totalStaking) + if err != nil { + return err + } + err = gs.ValidateOperatorAssets(totalStaking) + if err != nil { + return err } return gs.Params.Validate() } diff --git a/x/assets/types/genesis.pb.go b/x/assets/types/genesis.pb.go index b4f5a02a9..e3f38ba77 100644 --- a/x/assets/types/genesis.pb.go +++ b/x/assets/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -42,6 +43,9 @@ type GenesisState struct { // which contains deposits, withdrawable and unbonding amount. // at genesis (not chain restart), the unbonding amount must be 0. Deposits []DepositsByStaker `protobuf:"bytes,4,rep,name=deposits,proto3" json:"deposits"` + // operator_assets is the list of all operator assets information, indexed + // by the operator address and the asset id. The struct is the `OperatorAssetInfo` + OperatorAssets []AssetsByOperator `protobuf:"bytes,5,rep,name=operator_assets,json=operatorAssets,proto3" json:"operator_assets"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -105,6 +109,127 @@ func (m *GenesisState) GetDeposits() []DepositsByStaker { return nil } +func (m *GenesisState) GetOperatorAssets() []AssetsByOperator { + if m != nil { + return m.OperatorAssets + } + return nil +} + +// AssetsByOperator is a struct to be used in the genesis state. +// It is used to store the operator and its assets state. +type AssetsByOperator struct { + // operator is the address of the operator,its type should be a sdk.AccAddress + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // assets_state is the list of assets state, indexed by the asset id. + // The struct is the `OperatorAssetInfo` + AssetsState []AssetByID `protobuf:"bytes,2,rep,name=assets_state,json=assetsState,proto3" json:"assets_state"` +} + +func (m *AssetsByOperator) Reset() { *m = AssetsByOperator{} } +func (m *AssetsByOperator) String() string { return proto.CompactTextString(m) } +func (*AssetsByOperator) ProtoMessage() {} +func (*AssetsByOperator) Descriptor() ([]byte, []int) { + return fileDescriptor_caf4f124d39d82ce, []int{1} +} +func (m *AssetsByOperator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetsByOperator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetsByOperator.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 *AssetsByOperator) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetsByOperator.Merge(m, src) +} +func (m *AssetsByOperator) XXX_Size() int { + return m.Size() +} +func (m *AssetsByOperator) XXX_DiscardUnknown() { + xxx_messageInfo_AssetsByOperator.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetsByOperator proto.InternalMessageInfo + +func (m *AssetsByOperator) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *AssetsByOperator) GetAssetsState() []AssetByID { + if m != nil { + return m.AssetsState + } + return nil +} + +// AssetByID is a helper struct to be used in the genesis state. +// It is used to store the asset id and its info for an operator. +// It is named AssetByID (since it is indexed by the assetID) +type AssetByID struct { + // asset_id is the id of the asset. + AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` + // info is the asset info. + Info OperatorAssetInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` +} + +func (m *AssetByID) Reset() { *m = AssetByID{} } +func (m *AssetByID) String() string { return proto.CompactTextString(m) } +func (*AssetByID) ProtoMessage() {} +func (*AssetByID) Descriptor() ([]byte, []int) { + return fileDescriptor_caf4f124d39d82ce, []int{2} +} +func (m *AssetByID) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetByID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetByID.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 *AssetByID) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetByID.Merge(m, src) +} +func (m *AssetByID) XXX_Size() int { + return m.Size() +} +func (m *AssetByID) XXX_DiscardUnknown() { + xxx_messageInfo_AssetByID.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetByID proto.InternalMessageInfo + +func (m *AssetByID) GetAssetID() string { + if m != nil { + return m.AssetID + } + return "" +} + +func (m *AssetByID) GetInfo() OperatorAssetInfo { + if m != nil { + return m.Info + } + return OperatorAssetInfo{} +} + // DepositByStaker is a helper struct to be used in the genesis state. // It is used to store the staker address and its deposits for each asset ID. type DepositsByStaker struct { @@ -120,7 +245,7 @@ func (m *DepositsByStaker) Reset() { *m = DepositsByStaker{} } func (m *DepositsByStaker) String() string { return proto.CompactTextString(m) } func (*DepositsByStaker) ProtoMessage() {} func (*DepositsByStaker) Descriptor() ([]byte, []int) { - return fileDescriptor_caf4f124d39d82ce, []int{1} + return fileDescriptor_caf4f124d39d82ce, []int{3} } func (m *DepositsByStaker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -180,7 +305,7 @@ func (m *DepositByAsset) Reset() { *m = DepositByAsset{} } func (m *DepositByAsset) String() string { return proto.CompactTextString(m) } func (*DepositByAsset) ProtoMessage() {} func (*DepositByAsset) Descriptor() ([]byte, []int) { - return fileDescriptor_caf4f124d39d82ce, []int{2} + return fileDescriptor_caf4f124d39d82ce, []int{4} } func (m *DepositByAsset) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -225,6 +350,8 @@ func (m *DepositByAsset) GetInfo() StakerAssetInfo { func init() { proto.RegisterType((*GenesisState)(nil), "exocore.assets.v1.GenesisState") + proto.RegisterType((*AssetsByOperator)(nil), "exocore.assets.v1.AssetsByOperator") + proto.RegisterType((*AssetByID)(nil), "exocore.assets.v1.AssetByID") proto.RegisterType((*DepositsByStaker)(nil), "exocore.assets.v1.DepositsByStaker") proto.RegisterType((*DepositByAsset)(nil), "exocore.assets.v1.DepositByAsset") } @@ -232,33 +359,41 @@ func init() { func init() { proto.RegisterFile("exocore/assets/v1/genesis.proto", fileDescriptor_caf4f124d39d82ce) } var fileDescriptor_caf4f124d39d82ce = []byte{ - // 407 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xb1, 0x8e, 0xda, 0x30, - 0x1c, 0xc6, 0x13, 0x40, 0x81, 0x1a, 0x5a, 0xb5, 0x56, 0x87, 0x34, 0x43, 0x42, 0xd3, 0xaa, 0x62, - 0x4a, 0x0a, 0x1d, 0xba, 0x74, 0x21, 0x80, 0x2a, 0x2a, 0xb5, 0xaa, 0x60, 0xeb, 0x82, 0x42, 0x30, - 0xc1, 0xa2, 0xc4, 0x51, 0xec, 0xe3, 0x60, 0xb8, 0x77, 0xb8, 0x47, 0xb8, 0xc7, 0x61, 0x64, 0xbc, - 0x09, 0x9d, 0xc2, 0x8b, 0x9c, 0x62, 0x9b, 0x3b, 0x8e, 0xc0, 0x66, 0xf9, 0xfb, 0xbe, 0x9f, 0xff, - 0xf9, 0xf2, 0x07, 0x16, 0x5a, 0x91, 0x80, 0x24, 0xc8, 0xf5, 0x29, 0x45, 0x8c, 0xba, 0xcb, 0xa6, - 0x1b, 0xa2, 0x08, 0x51, 0x4c, 0x9d, 0x38, 0x21, 0x8c, 0xc0, 0x77, 0xd2, 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 0x7f, 0x47, 0xee, 0xf9, 0x25, 0x78, 0xf3, 0xd2, 0x01, 0xbf, 0x80, 0x0a, 0x4f, - 0x8f, 0xf0, 0x44, 0x3e, 0x5f, 0x4d, 0x77, 0x56, 0x59, 0xd4, 0xd0, 0x1d, 0x94, 0xb9, 0xd8, 0x9f, - 0xc0, 0x1f, 0xa0, 0x84, 0xa3, 0x29, 0xd1, 0x0b, 0xfc, 0x47, 0xda, 0x17, 0x0a, 0x44, 0xc9, 0x69, - 0x7f, 0x3c, 0xe5, 0xfd, 0xda, 0xa4, 0xa6, 0xba, 0x4d, 0x4d, 0xf5, 0x21, 0x35, 0xd5, 0xdb, 0xbd, - 0xa9, 0x6c, 0xf7, 0xa6, 0x72, 0xbf, 0x37, 0x95, 0x7f, 0x5f, 0x43, 0xcc, 0x66, 0x57, 0x63, 0x27, - 0x20, 0x0b, 0xb7, 0x27, 0x98, 0x7f, 0x10, 0xbb, 0x26, 0xc9, 0xdc, 0x3d, 0x6c, 0xda, 0xea, 0xb0, - 0x6b, 0x6c, 0x1d, 0x23, 0x3a, 0xd6, 0xf8, 0xb2, 0x7d, 0x7b, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xf2, - 0x41, 0x0b, 0xdb, 0xf4, 0x02, 0x00, 0x00, + // 531 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0x6e, 0xd3, 0x4a, + 0x14, 0xc6, 0xe3, 0x34, 0x37, 0x4d, 0x27, 0xb9, 0xa5, 0x8c, 0xba, 0x70, 0x23, 0xe4, 0x14, 0x53, + 0xa1, 0x6e, 0xb0, 0x69, 0x41, 0x62, 0x83, 0x90, 0xe2, 0x24, 0x42, 0x41, 0x82, 0x22, 0x67, 0xc7, + 0xc6, 0x72, 0xed, 0xa9, 0x6b, 0x85, 0x78, 0x2c, 0x9f, 0x21, 0xc4, 0x0b, 0x9e, 0x01, 0x1e, 0x86, + 0x87, 0xe8, 0xb2, 0x62, 0xc5, 0x2a, 0x42, 0xce, 0x2b, 0xf0, 0x00, 0xc8, 0x33, 0xe3, 0x90, 0x26, + 0xb1, 0xc4, 0xce, 0x9e, 0xef, 0x3b, 0xbf, 0x39, 0x7f, 0xe6, 0xa0, 0x0e, 0x99, 0x51, 0x8f, 0x26, + 0xc4, 0x74, 0x01, 0x08, 0x03, 0x73, 0x7a, 0x66, 0x06, 0x24, 0x22, 0x10, 0x82, 0x11, 0x27, 0x94, + 0x51, 0x7c, 0x5f, 0x1a, 0x0c, 0x61, 0x30, 0xa6, 0x67, 0xed, 0x23, 0x8f, 0xc2, 0x84, 0x82, 0xc3, + 0x0d, 0xa6, 0xf8, 0x11, 0xee, 0xb6, 0xb6, 0x89, 0x8b, 0xdd, 0xc4, 0x9d, 0x14, 0x7a, 0x7b, 0x53, + 0x67, 0x33, 0xa9, 0x1d, 0x06, 0x34, 0xa0, 0x82, 0x99, 0x7f, 0x89, 0x53, 0xfd, 0x77, 0x15, 0xb5, + 0x5e, 0x8b, 0x8c, 0x46, 0xcc, 0x65, 0x04, 0xbf, 0x40, 0x75, 0x81, 0x54, 0x95, 0x63, 0xe5, 0xb4, + 0x79, 0x7e, 0x64, 0x6c, 0x64, 0x68, 0xbc, 0xe7, 0x06, 0xab, 0x76, 0x33, 0xef, 0x54, 0x6c, 0x69, + 0xc7, 0x6f, 0xd1, 0xff, 0xde, 0xc7, 0x90, 0x44, 0xcc, 0xf1, 0xae, 0xdd, 0x30, 0x02, 0xb5, 0x7a, + 0xbc, 0x73, 0xda, 0x3c, 0xd7, 0xb7, 0xc4, 0xf7, 0xb8, 0xaf, 0x97, 0xdb, 0x86, 0xd1, 0x15, 0x95, + 0xa0, 0x96, 0xf7, 0xf7, 0x18, 0x70, 0x17, 0xd5, 0x19, 0x1d, 0x93, 0x08, 0xd4, 0x1d, 0xce, 0x79, + 0xb4, 0x85, 0x33, 0x62, 0xee, 0x38, 0x8c, 0x82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de, 0xca, 0x6c, + 0x45, 0xc5, 0x0f, 0xcb, 0x67, 0x6b, 0xa5, 0xa2, 0xb4, 0xb5, 0xc9, 0xea, 0x53, 0xb4, 0x7f, 0xd7, + 0xf1, 0xcf, 0x85, 0xbf, 0xbc, 0x53, 0xb8, 0x5e, 0xf2, 0x36, 0xc9, 0xf6, 0xb2, 0xad, 0x37, 0x37, + 0x99, 0xa6, 0xdc, 0x66, 0x9a, 0xf2, 0x2b, 0xd3, 0x94, 0x6f, 0x0b, 0xad, 0x72, 0xbb, 0xd0, 0x2a, + 0x3f, 0x17, 0x5a, 0xe5, 0xc3, 0xd3, 0x20, 0x64, 0xd7, 0x9f, 0x2e, 0x0d, 0x8f, 0x4e, 0xcc, 0x81, + 0x60, 0xbe, 0x23, 0xec, 0x33, 0x4d, 0xc6, 0x66, 0xb1, 0xda, 0xb3, 0x62, 0xb9, 0x59, 0x1a, 0x13, + 0xb8, 0xac, 0xf3, 0x3d, 0x7e, 0xf6, 0x27, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x6e, 0x63, 0xe0, 0x6a, + 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -281,6 +416,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.OperatorAssets) > 0 { + for iNdEx := len(m.OperatorAssets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorAssets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } if len(m.Deposits) > 0 { for iNdEx := len(m.Deposits) - 1; iNdEx >= 0; iNdEx-- { { @@ -336,6 +485,90 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AssetsByOperator) 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 *AssetsByOperator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetsByOperator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AssetsState) > 0 { + for iNdEx := len(m.AssetsState) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetsState[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AssetByID) 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 *AssetByID) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetByID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AssetID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *DepositsByStaker) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -457,6 +690,46 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.OperatorAssets) > 0 { + for _, e := range m.OperatorAssets { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *AssetsByOperator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.AssetsState) > 0 { + for _, e := range m.AssetsState { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *AssetByID) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AssetID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Info.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -664,6 +937,271 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAssets", 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.OperatorAssets = append(m.OperatorAssets, AssetsByOperator{}) + if err := m.OperatorAssets[len(m.OperatorAssets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AssetsByOperator) 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: AssetsByOperator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AssetsByOperator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetsState", 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.AssetsState = append(m.AssetsState, AssetByID{}) + if err := m.AssetsState[len(m.AssetsState)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AssetByID) 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: AssetByID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AssetByID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", 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.AssetID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", 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.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/assets/types/genesis_test.go b/x/assets/types/genesis_test.go index f9648f6ee..650ffcbcc 100644 --- a/x/assets/types/genesis_test.go +++ b/x/assets/types/genesis_test.go @@ -1,7 +1,6 @@ package types_test import ( - "fmt" "strings" "testing" @@ -26,8 +25,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { params := types.DefaultParams() params.ExocoreLzAppAddress = "0x0000000000000000000000000000000000000001" newGen := types.NewGenesis( - params, []types.ClientChainInfo{}, - []types.StakingAssetInfo{}, []types.DepositsByStaker{}, + params, nil, + nil, nil, nil, ) // genesis data that is hardcoded for use in the tests ethClientChain := types.ClientChainInfo{ @@ -39,7 +38,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { AddressLength: 20, } // do not hardcode the address to avoid gitleaks complaining. - tokenAddress := utiltx.GenerateAddress().String() + tokenAddress := strings.ToLower(utiltx.GenerateAddress().String()) usdtClientChainAsset := types.AssetInfo{ Name: "Tether USD", Symbol: "USDT", @@ -49,8 +48,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { MetaInfo: "Tether USD token", } stakingInfo := types.StakingAssetInfo{ - AssetBasicInfo: &usdtClientChainAsset, - StakingTotalAmount: math.NewInt(0), + AssetBasicInfo: usdtClientChainAsset, + StakingTotalAmount: math.NewInt(100), } // generated information ethAddress := utiltx.GenerateAddress() @@ -181,25 +180,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, expPass: false, }, - { - name: "invalid genesis due to non zero deposit", - genState: &types.GenesisState{ - Params: types.DefaultParams(), - ClientChains: []types.ClientChainInfo{ - ethClientChain, - }, - Tokens: []types.StakingAssetInfo{ - stakingInfo, - }, - }, - expPass: false, - malleate: func(gs *types.GenesisState) { - gs.Tokens[0].StakingTotalAmount = math.NewInt(1) - }, - unmalleate: func(gs *types.GenesisState) { - gs.Tokens[0].StakingTotalAmount = math.NewInt(0) - }, - }, { name: "invalid genesis due to upper case staker id", genState: &types.GenesisState{ @@ -345,7 +325,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { MetaInfo: "Circle USD token", } stakingInfo := types.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: math.NewInt(0), } gs.Tokens[1] = stakingInfo @@ -411,31 +391,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info }, }, - { - name: "invalid genesis due to non zero unbonding amount for staker", - genState: &types.GenesisState{ - Params: types.DefaultParams(), - ClientChains: []types.ClientChainInfo{ - ethClientChain, - }, - Tokens: []types.StakingAssetInfo{ - stakingInfo, - }, - Deposits: []types.DepositsByStaker{genesisDeposit}, - }, - expPass: false, - malleate: func(gs *types.GenesisState) { - gs.Deposits[0].Deposits[0].Info.PendingUndelegationAmount = math.NewInt(1) - }, - unmalleate: func(gs *types.GenesisState) { - genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(0), - PendingUndelegationAmount: math.NewInt(0), - } - gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info - }, - }, { name: "invalid genesis due to negative amount for staker", genState: &types.GenesisState{ @@ -481,7 +436,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { unmalleate: func(gs *types.GenesisState) { genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(100), + WithdrawableAmount: math.NewInt(0), PendingUndelegationAmount: math.NewInt(0), } gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info @@ -512,7 +467,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { } err := tc.genState.Validate() if tc.expPass { - fmt.Println("name is:", tc.name) suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) diff --git a/x/assets/types/keys.go b/x/assets/types/keys.go index f3ed3ef8f..b257e9b92 100644 --- a/x/assets/types/keys.go +++ b/x/assets/types/keys.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/ExocoreNetwork/exocore/utils" + errorsmod "cosmossdk.io/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -63,13 +65,6 @@ var ( // or operatorAddr->mapping(AssetID->OperatorAssetInfo) ? KeyPrefixOperatorAssetInfos = []byte{prefixOperatorAssetInfo} - // KeyPrefixOperatorOptedInMiddleWareAssetInfos key->value: - // operatorAddr+'_'+AssetID->mapping(middleWareAddr->struct{}) - // or operatorAddr->mapping(AssetID->mapping(middleWareAddr->struct{})) ? - KeyPrefixOperatorOptedInMiddleWareAssetInfos = []byte{ - prefixOperatorOptedInMiddlewareAssetInfo, - } - // KeyPrefixReStakerExoCoreAddr restakerID = clientChainAddr+'_'+ExoCoreChainIndex // KeyPrefixReStakerExoCoreAddr key-value: restakerID->exoCoreAddr KeyPrefixReStakerExoCoreAddr = []byte{prefixRestakerExocoreAddr} @@ -84,25 +79,29 @@ var ( ) func GetJoinedStoreKey(keys ...string) []byte { - return []byte(strings.Join(keys, "/")) + return []byte(strings.Join(keys, utils.DelimiterForCombinedKey)) } func GetJoinedStoreKeyForPrefix(keys ...string) []byte { - ret := []byte(strings.Join(keys, "/")) - ret = append(ret, '/') + ret := []byte(strings.Join(keys, utils.DelimiterForCombinedKey)) + ret = append(ret, []byte(utils.DelimiterForCombinedKey)...) return ret } func ParseJoinedKey(key []byte) (keys []string, err error) { - stringList := strings.Split(string(key), "/") + stringList := strings.Split(string(key), utils.DelimiterForCombinedKey) return stringList, nil } +func IsJoinedStoreKey(key string) bool { + return strings.Contains(key, utils.DelimiterForCombinedKey) +} + func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { - stringList := strings.Split(string(key), "/") + stringList := strings.Split(string(key), utils.DelimiterForCombinedKey) if len(stringList) != number { return nil, errorsmod.Wrap( - ErrParseAssetsStateKey, + ErrParseJoinedKey, fmt.Sprintf( "expected length:%d,actual length:%d,the stringList is:%v", number, @@ -118,7 +117,7 @@ func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { // It constraints the key to be in the format of "clientAddress_0xid" // The 0xid must be in hex. func ParseID(key string) (string, uint64, error) { - keys := strings.Split(key, "_") + keys := strings.Split(key, utils.DelimiterForID) if len(keys) != 2 { return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("invalid length:%s", key)) } diff --git a/x/assets/types/query.pb.go b/x/assets/types/query.pb.go index 677849520..801360bba 100644 --- a/x/assets/types/query.pb.go +++ b/x/assets/types/query.pb.go @@ -265,7 +265,7 @@ var xxx_messageInfo_QueryAllStakingAssetsInfo proto.InternalMessageInfo // indexed by the asset id. type QueryAllStakingAssetsInfoResponse struct { // all_staking_assets_info is the response for all staking assets info. - AllStakingAssetsInfo map[string]*StakingAssetInfo `protobuf:"bytes,1,rep,name=all_staking_assets_info,json=allStakingAssetsInfo,proto3" json:"all_staking_assets_info,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AllStakingAssetsInfo []StakingAssetInfo `protobuf:"bytes,1,rep,name=all_staking_assets_info,json=allStakingAssetsInfo,proto3" json:"all_staking_assets_info"` } func (m *QueryAllStakingAssetsInfoResponse) Reset() { *m = QueryAllStakingAssetsInfoResponse{} } @@ -301,7 +301,7 @@ func (m *QueryAllStakingAssetsInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllStakingAssetsInfoResponse proto.InternalMessageInfo -func (m *QueryAllStakingAssetsInfoResponse) GetAllStakingAssetsInfo() map[string]*StakingAssetInfo { +func (m *QueryAllStakingAssetsInfoResponse) GetAllStakingAssetsInfo() []StakingAssetInfo { if m != nil { return m.AllStakingAssetsInfo } @@ -357,7 +357,7 @@ func (m *QueryStakerAssetInfo) GetStakerID() string { // QueryAssetInfoResponse is the response for the staker asset info. type QueryAssetInfoResponse struct { // asset_infos is the response for the staker asset info, indexed by the asset id. - AssetInfos map[string]*StakerAssetInfo `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AssetInfos []DepositByAsset `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos"` } func (m *QueryAssetInfoResponse) Reset() { *m = QueryAssetInfoResponse{} } @@ -393,7 +393,7 @@ func (m *QueryAssetInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAssetInfoResponse proto.InternalMessageInfo -func (m *QueryAssetInfoResponse) GetAssetInfos() map[string]*StakerAssetInfo { +func (m *QueryAssetInfoResponse) GetAssetInfos() []DepositByAsset { if m != nil { return m.AssetInfos } @@ -504,7 +504,7 @@ func (m *QueryOperatorAssetInfos) GetOperatorAddr() string { // QueryOperatorAssetInfosResponse is the response to the operator asset info query. type QueryOperatorAssetInfosResponse struct { // asset_infos is the response for the operator asset info, indexed by the asset id. - AssetInfos map[string]*OperatorAssetInfo `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AssetInfos []AssetByID `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos"` } func (m *QueryOperatorAssetInfosResponse) Reset() { *m = QueryOperatorAssetInfosResponse{} } @@ -540,7 +540,7 @@ func (m *QueryOperatorAssetInfosResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryOperatorAssetInfosResponse proto.InternalMessageInfo -func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() map[string]*OperatorAssetInfo { +func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() []AssetByID { if m != nil { return m.AssetInfos } @@ -787,14 +787,11 @@ func init() { proto.RegisterType((*QueryStakingAssetInfo)(nil), "exocore.assets.v1.QueryStakingAssetInfo") proto.RegisterType((*QueryAllStakingAssetsInfo)(nil), "exocore.assets.v1.QueryAllStakingAssetsInfo") proto.RegisterType((*QueryAllStakingAssetsInfoResponse)(nil), "exocore.assets.v1.QueryAllStakingAssetsInfoResponse") - proto.RegisterMapType((map[string]*StakingAssetInfo)(nil), "exocore.assets.v1.QueryAllStakingAssetsInfoResponse.AllStakingAssetsInfoEntry") proto.RegisterType((*QueryStakerAssetInfo)(nil), "exocore.assets.v1.QueryStakerAssetInfo") proto.RegisterType((*QueryAssetInfoResponse)(nil), "exocore.assets.v1.QueryAssetInfoResponse") - proto.RegisterMapType((map[string]*StakerAssetInfo)(nil), "exocore.assets.v1.QueryAssetInfoResponse.AssetInfosEntry") proto.RegisterType((*QuerySpecifiedAssetAmountReq)(nil), "exocore.assets.v1.QuerySpecifiedAssetAmountReq") proto.RegisterType((*QueryOperatorAssetInfos)(nil), "exocore.assets.v1.QueryOperatorAssetInfos") proto.RegisterType((*QueryOperatorAssetInfosResponse)(nil), "exocore.assets.v1.QueryOperatorAssetInfosResponse") - proto.RegisterMapType((map[string]*OperatorAssetInfo)(nil), "exocore.assets.v1.QueryOperatorAssetInfosResponse.AssetInfosEntry") proto.RegisterType((*QueryOperatorSpecifiedAssetAmountReq)(nil), "exocore.assets.v1.QueryOperatorSpecifiedAssetAmountReq") proto.RegisterType((*QueryStakerExCoreAddr)(nil), "exocore.assets.v1.QueryStakerExCoreAddr") proto.RegisterType((*QueryStakerExCoreAddrResponse)(nil), "exocore.assets.v1.QueryStakerExCoreAddrResponse") @@ -805,75 +802,71 @@ func init() { func init() { proto.RegisterFile("exocore/assets/v1/query.proto", fileDescriptor_1de33a8cf38ccb9d) } var fileDescriptor_1de33a8cf38ccb9d = []byte{ - // 1076 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xa6, 0x34, 0x4d, 0xc7, 0x41, 0xc0, 0xd4, 0xa4, 0xf1, 0xa6, 0xb5, 0xdb, 0xa5, 0x24, - 0xae, 0x15, 0x76, 0x6b, 0x17, 0x94, 0xa6, 0x52, 0x85, 0x9c, 0x34, 0x40, 0x7a, 0x28, 0x65, 0x7b, - 0x00, 0xf5, 0x62, 0x4d, 0xbc, 0x13, 0x77, 0x15, 0x67, 0xc7, 0xd9, 0x59, 0x07, 0x9b, 0x23, 0x12, - 0x12, 0x17, 0x24, 0x24, 0x4e, 0xbd, 0x70, 0xe1, 0x8e, 0x90, 0x40, 0x5c, 0x39, 0x70, 0xe1, 0x58, - 0xc1, 0x01, 0x4e, 0x11, 0x72, 0x90, 0x38, 0xf0, 0x17, 0x70, 0x43, 0x3b, 0x33, 0xf6, 0xfe, 0x9a, - 0x71, 0xb6, 0xf4, 0xe6, 0x9d, 0xf7, 0xeb, 0x7b, 0xdf, 0x7b, 0x33, 0x5f, 0x02, 0x2e, 0xe3, 0x01, - 0x69, 0x13, 0x1f, 0x5b, 0x88, 0x52, 0x1c, 0x50, 0xeb, 0xa8, 0x6e, 0x1d, 0xf6, 0xb1, 0x3f, 0x34, - 0x7b, 0x3e, 0x09, 0x08, 0x7c, 0x45, 0x98, 0x4d, 0x6e, 0x36, 0x8f, 0xea, 0x7a, 0xad, 0x4d, 0xe8, - 0x01, 0xa1, 0xd6, 0x2e, 0xa2, 0x98, 0xf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, 0x8b, 0x60, 0x8e, 0x2f, 0x89, 0xe8, 0x5e, - 0x7c, 0x19, 0xfb, 0xe0, 0xb2, 0x34, 0x60, 0x32, 0xab, 0x7b, 0x60, 0x41, 0x70, 0x12, 0xc7, 0xbd, - 0x3a, 0x3a, 0xae, 0x14, 0xb6, 0x07, 0x64, 0xec, 0xae, 0x6c, 0xa3, 0x20, 0x82, 0xd9, 0x6e, 0x14, - 0x01, 0x64, 0xc5, 0x1e, 0x30, 0x19, 0x15, 0x3a, 0x63, 0xbc, 0x07, 0x2e, 0x24, 0x4e, 0x45, 0xe1, - 0x3a, 0x98, 0xe3, 0x72, 0x2b, 0x64, 0xab, 0x24, 0x99, 0x8d, 0x08, 0x11, 0x8e, 0x8d, 0x7f, 0x0b, - 0xe0, 0x2c, 0x4b, 0x05, 0x3f, 0x01, 0x73, 0xdc, 0x06, 0x5f, 0x57, 0xad, 0x55, 0x02, 0x84, 0xbe, - 0x72, 0x9a, 0x1b, 0x47, 0x65, 0x5c, 0xfd, 0xf4, 0xb7, 0xbf, 0xbe, 0x9a, 0x5d, 0x86, 0x25, 0x2b, - 0xab, 0xfe, 0xa2, 0xe2, 0x37, 0x1a, 0x53, 0x89, 0x94, 0x8c, 0x6d, 0x0e, 0x99, 0x58, 0xc3, 0x55, - 0x55, 0xa1, 0x94, 0xbf, 0x9e, 0x43, 0x2e, 0x8d, 0x8d, 0xcf, 0xff, 0xfe, 0xae, 0xa6, 0x31, 0x48, - 0x26, 0x5c, 0x93, 0x40, 0x52, 0xe3, 0xf8, 0x56, 0x63, 0xab, 0x22, 0xf9, 0x9b, 0xa1, 0x36, 0x45, - 0x7f, 0xd2, 0x20, 0x1b, 0xf9, 0x7d, 0x27, 0x14, 0xbe, 0x15, 0x81, 0xae, 0xc1, 0xaa, 0x1c, 0xb4, - 0x04, 0xd6, 0x13, 0x8d, 0xed, 0x49, 0x46, 0xbb, 0xab, 0x2a, 0x08, 0x69, 0x4f, 0x3d, 0x8f, 0x68, - 0x19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b, 0x00, 0x00, 0xff, 0xff, 0x65, 0xa2, 0xf2, 0x57, - 0x98, 0x0e, 0x00, 0x00, + // 1023 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x97, 0xc1, 0x6f, 0x1b, 0x45, + 0x14, 0xc6, 0xb3, 0xa1, 0xa4, 0xe9, 0x38, 0x1c, 0x98, 0x9a, 0x34, 0xd9, 0xa4, 0x76, 0xb3, 0x94, + 0xc4, 0xb5, 0xc2, 0x6e, 0xed, 0x82, 0x22, 0x0e, 0x15, 0xb2, 0x93, 0x40, 0xdd, 0x03, 0x94, 0xed, + 0x01, 0xc4, 0xc5, 0x8c, 0xbd, 0x93, 0xed, 0x2a, 0xce, 0xce, 0x66, 0x67, 0x12, 0x1c, 0x8e, 0x48, + 0x48, 0x5c, 0x90, 0x90, 0x38, 0x71, 0xe1, 0xc2, 0x1d, 0x21, 0x81, 0xb8, 0x72, 0xe0, 0xd2, 0x63, + 0x05, 0x17, 0x4e, 0x16, 0x72, 0x90, 0xf8, 0x1b, 0xb8, 0x55, 0x3b, 0x33, 0xeb, 0xb5, 0x77, 0x67, + 0x1d, 0x57, 0xb9, 0x65, 0xf7, 0x7d, 0xf3, 0xde, 0xef, 0x7d, 0xb3, 0xf3, 0x26, 0x06, 0x37, 0x71, + 0x9f, 0x74, 0x49, 0x88, 0x2d, 0x44, 0x29, 0x66, 0xd4, 0x3a, 0xad, 0x59, 0xc7, 0x27, 0x38, 0x3c, + 0x33, 0x83, 0x90, 0x30, 0x02, 0x5f, 0x95, 0x61, 0x53, 0x84, 0xcd, 0xd3, 0x9a, 0x5e, 0xed, 0x12, + 0x7a, 0x44, 0xa8, 0xd5, 0x41, 0x14, 0x0b, 0xad, 0x75, 0x5a, 0xeb, 0x60, 0x86, 0x6a, 0x56, 0x80, + 0x5c, 0xcf, 0x47, 0xcc, 0x23, 0xbe, 0x58, 0xae, 0xaf, 0x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1, 0xf2, + 0x60, 0xa5, 0xea, 0x1a, 0xf7, 0x13, 0xd6, 0x3a, 0xbc, 0x3b, 0x8d, 0x55, 0xc9, 0x24, 0x0f, 0x97, + 0xe2, 0x5e, 0xcb, 0x3d, 0x5c, 0x59, 0x6d, 0xfe, 0xe1, 0xca, 0xbf, 0xd5, 0x66, 0x3a, 0x5c, 0x0a, + 0xac, 0xdf, 0xc5, 0xff, 0x93, 0xd3, 0x6e, 0x31, 0xb8, 0x73, 0x11, 0x4e, 0x9e, 0xe1, 0xb7, 0x15, + 0x0b, 0x33, 0x0c, 0x97, 0xb4, 0xbc, 0xf9, 0xf0, 0xe9, 0xb0, 0xa4, 0x3d, 0x1b, 0x96, 0xb4, 0x7f, + 0x86, 0x25, 0xed, 0xdb, 0xf3, 0xd2, 0xdc, 0xb3, 0xf3, 0xd2, 0xdc, 0xdf, 0xe7, 0xa5, 0xb9, 0x4f, + 0xef, 0xba, 0x1e, 0x7b, 0x72, 0xd2, 0x31, 0xbb, 0xe4, 0xc8, 0xda, 0x17, 0x59, 0x3f, 0xc0, 0xec, + 0x73, 0x12, 0x1e, 0x8e, 0x8a, 0xf4, 0xe3, 0x32, 0xec, 0x2c, 0xc0, 0xb4, 0xb3, 0xc0, 0x7f, 0x00, + 0xdc, 0x7b, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x72, 0x6a, 0xe1, 0xc9, 0x29, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1448,27 +1441,15 @@ func (m *QueryAllStakingAssetsInfoResponse) MarshalToSizedBuffer(dAtA []byte) (i var l int _ = l if len(m.AllStakingAssetsInfo) > 0 { - for k := range m.AllStakingAssetsInfo { - v := m.AllStakingAssetsInfo[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + for iNdEx := len(m.AllStakingAssetsInfo) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AllStakingAssetsInfo[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0xa } @@ -1527,27 +1508,15 @@ func (m *QueryAssetInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) var l int _ = l if len(m.AssetInfos) > 0 { - for k := range m.AssetInfos { - v := m.AssetInfos[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + for iNdEx := len(m.AssetInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0xa } @@ -1643,27 +1612,15 @@ func (m *QueryOperatorAssetInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int var l int _ = l if len(m.AssetInfos) > 0 { - for k := range m.AssetInfos { - v := m.AssetInfos[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + for iNdEx := len(m.AssetInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0xa } @@ -1910,16 +1867,9 @@ func (m *QueryAllStakingAssetsInfoResponse) Size() (n int) { var l int _ = l if len(m.AllStakingAssetsInfo) > 0 { - for k, v := range m.AllStakingAssetsInfo { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + for _, e := range m.AllStakingAssetsInfo { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } return n @@ -1945,16 +1895,9 @@ func (m *QueryAssetInfoResponse) Size() (n int) { var l int _ = l if len(m.AssetInfos) > 0 { - for k, v := range m.AssetInfos { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + for _, e := range m.AssetInfos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } return n @@ -1997,16 +1940,9 @@ func (m *QueryOperatorAssetInfosResponse) Size() (n int) { var l int _ = l if len(m.AssetInfos) > 0 { - for k, v := range m.AssetInfos { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + for _, e := range m.AssetInfos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } return n @@ -2548,105 +2484,10 @@ func (m *QueryAllStakingAssetsInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AllStakingAssetsInfo == nil { - m.AllStakingAssetsInfo = make(map[string]*StakingAssetInfo) - } - var mapkey string - var mapvalue *StakingAssetInfo - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &StakingAssetInfo{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } + m.AllStakingAssetsInfo = append(m.AllStakingAssetsInfo, StakingAssetInfo{}) + if err := m.AllStakingAssetsInfo[len(m.AllStakingAssetsInfo)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.AllStakingAssetsInfo[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex @@ -2809,105 +2650,10 @@ func (m *QueryAssetInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*StakerAssetInfo) - } - var mapkey string - var mapvalue *StakerAssetInfo - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &StakerAssetInfo{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } + m.AssetInfos = append(m.AssetInfos, DepositByAsset{}) + if err := m.AssetInfos[len(m.AssetInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.AssetInfos[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex @@ -3184,105 +2930,10 @@ func (m *QueryOperatorAssetInfosResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*OperatorAssetInfo) - } - var mapkey string - var mapvalue *OperatorAssetInfo - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &OperatorAssetInfo{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } + m.AssetInfos = append(m.AssetInfos, AssetByID{}) + if err := m.AssetInfos[len(m.AssetInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.AssetInfos[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/assets/types/tx.pb.go b/x/assets/types/tx.pb.go index 08a0c2961..455286ff2 100644 --- a/x/assets/types/tx.pb.go +++ b/x/assets/types/tx.pb.go @@ -285,7 +285,7 @@ func (m *AssetInfo) GetMetaInfo() string { // StakingAssetInfo defines the information for an asset to be used in staking. type StakingAssetInfo struct { // asset_basic_info is the basic information of the asset. - AssetBasicInfo *AssetInfo `protobuf:"bytes,1,opt,name=asset_basic_info,json=assetBasicInfo,proto3" json:"asset_basic_info,omitempty"` + AssetBasicInfo AssetInfo `protobuf:"bytes,1,opt,name=asset_basic_info,json=assetBasicInfo,proto3" json:"asset_basic_info"` // staking_total_amount is the total amount of the asset staked. StakingTotalAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=staking_total_amount,json=stakingTotalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"staking_total_amount"` } @@ -323,11 +323,11 @@ func (m *StakingAssetInfo) XXX_DiscardUnknown() { var xxx_messageInfo_StakingAssetInfo proto.InternalMessageInfo -func (m *StakingAssetInfo) GetAssetBasicInfo() *AssetInfo { +func (m *StakingAssetInfo) GetAssetBasicInfo() AssetInfo { if m != nil { return m.AssetBasicInfo } - return nil + return AssetInfo{} } // StakerAssetInfo defines the information for a single asset. @@ -425,7 +425,10 @@ func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerAssetInfo { // OperatorAssetInfo defines the information for a single asset, // for an operator. type OperatorAssetInfo struct { - // total_amount is the total amount of the asset deposited. + // total_amount is the total amount of the asset deposited, which excludes the + // pending_undelegation_amount. It represent the total delegated amount of asset pool, + // it will be used to calculate the asset amount of a specified staker from its + // delegated share. TotalAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_amount,json=totalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_amount"` // pending_undelegation_amount is the amount that is waiting for unbonding. PendingUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=pending_undelegation_amount,json=pendingUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"pending_undelegation_amount"` @@ -832,84 +835,85 @@ func init() { func init() { proto.RegisterFile("exocore/assets/v1/tx.proto", fileDescriptor_adb6ebd423a2c426) } var fileDescriptor_adb6ebd423a2c426 = []byte{ - // 1230 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0x3a, 0xdf, 0x2f, 0x4d, 0xe2, 0x4c, 0x42, 0x6b, 0x3b, 0xad, 0x53, 0xad, 0x54, 0x88, - 0x22, 0xe2, 0x6d, 0x83, 0x28, 0x25, 0xe5, 0x92, 0x8f, 0x56, 0x0a, 0x6a, 0x01, 0x6d, 0x5a, 0x0e, - 0x95, 0xd0, 0x6a, 0xbc, 0x3b, 0xd9, 0xac, 0xb2, 0x3b, 0x63, 0x76, 0x26, 0x6d, 0x5c, 0x71, 0x40, - 0x3d, 0x21, 0x24, 0x24, 0x04, 0x57, 0x0e, 0xfd, 0x13, 0x7a, 0xa8, 0x10, 0x7f, 0x42, 0xc5, 0xa9, - 0x94, 0x0b, 0xe2, 0x50, 0x55, 0x29, 0x52, 0x38, 0xf1, 0x2f, 0x80, 0xe6, 0x63, 0x6d, 0x6f, 0xe2, - 0x34, 0x82, 0x9a, 0x4b, 0xb2, 0xf3, 0x3e, 0x7e, 0xef, 0xbd, 0xdf, 0xbc, 0x37, 0x33, 0x86, 0x0a, - 0xd9, 0x63, 0x3e, 0x4b, 0x89, 0x83, 0x39, 0x27, 0x82, 0x3b, 0x77, 0x2f, 0x39, 0x62, 0xaf, 0xd6, - 0x48, 0x99, 0x60, 0x68, 0xca, 0xe8, 0x6a, 0x5a, 0x57, 0xbb, 0x7b, 0xa9, 0x32, 0x85, 0x93, 0x88, - 0x32, 0x47, 0xfd, 0xd5, 0x56, 0x95, 0x33, 0x3e, 0xe3, 0x09, 0xe3, 0x4e, 0xc2, 0x43, 0xe9, 0x9d, - 0xf0, 0xd0, 0x28, 0xca, 0x5a, 0xe1, 0xa9, 0x95, 0xa3, 0x17, 0x46, 0x55, 0x3d, 0x1a, 0xb5, 0x81, - 0x53,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 0xb6, 0xa9, 0xa7, 0xdc, 0xa5, 0x1e, 0x1d, 0x62, 0x75, 0x40, 0x9e, 0x01, 0xae, 0x31, 0x5f, 0x9e, - 0x90, 0xc5, 0xb4, 0x81, 0xec, 0x32, 0x9c, 0x39, 0x94, 0x53, 0x96, 0xef, 0xd2, 0x0f, 0x16, 0xf4, - 0xdf, 0xe4, 0x21, 0xfa, 0xc6, 0x82, 0x53, 0xb9, 0xa4, 0xbb, 0xb5, 0xc8, 0x21, 0x90, 0xca, 0xc2, - 0xc9, 0x36, 0x2d, 0x62, 0x16, 0x1f, 0xfc, 0xfa, 0xc7, 0xf7, 0x85, 0xb7, 0xec, 0x0b, 0x4e, 0xb7, - 0x5f, 0x30, 0xce, 0x61, 0xe8, 0xc1, 0x2f, 0x0f, 0x1e, 0x2d, 0x58, 0xab, 0x1f, 0x3e, 0xd9, 0xaf, - 0x5a, 0x4f, 0xf7, 0xab, 0xd6, 0x8b, 0xfd, 0xaa, 0xf5, 0xed, 0xcb, 0x6a, 0xdf, 0xd3, 0x97, 0xd5, - 0xbe, 0xdf, 0x5e, 0x56, 0xfb, 0xee, 0x5c, 0xec, 0x38, 0xed, 0xae, 0x69, 0xc4, 0x8f, 0x88, 0xb8, - 0xc7, 0xd2, 0x9d, 0x56, 0x80, 0xbd, 0x2c, 0x84, 0x3a, 0xfb, 0xea, 0x43, 0xea, 0x77, 0xc7, 0x3b, - 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x15, 0x4d, 0x8c, 0xa1, 0x43, 0x0d, 0x00, 0x00, + // 1234 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x3a, 0xff, 0x5f, 0x9a, 0xc4, 0x99, 0x84, 0xd6, 0x76, 0x5a, 0xa7, 0x5a, 0xa9, 0x10, + 0x45, 0xc4, 0xdb, 0x06, 0x51, 0x4a, 0xca, 0x25, 0x7f, 0x5a, 0x29, 0xa8, 0x05, 0xb4, 0x6e, 0x39, + 0x54, 0x42, 0xab, 0xf1, 0xee, 0x64, 0xbd, 0xca, 0xee, 0x8c, 0xd9, 0x19, 0xb7, 0x76, 0xc5, 0x01, + 0xf5, 0x84, 0x90, 0x90, 0x10, 0x5c, 0x39, 0xf4, 0x23, 0xf4, 0x50, 0x21, 0x3e, 0x42, 0xc5, 0xa9, + 0x94, 0x0b, 0xe2, 0x50, 0x55, 0x29, 0x52, 0x38, 0xf1, 0x15, 0x40, 0x33, 0x3b, 0x6b, 0x7b, 0x13, + 0xa7, 0x11, 0xd4, 0x5c, 0x92, 0x9d, 0x79, 0xef, 0xfd, 0xde, 0xfb, 0xfd, 0xe6, 0xcd, 0x1f, 0x43, + 0x89, 0xb4, 0x98, 0xcb, 0x62, 0x62, 0x61, 0xce, 0x89, 0xe0, 0xd6, 0xdd, 0x4b, 0x96, 0x68, 0x55, + 0x1a, 0x31, 0x13, 0x0c, 0xcd, 0x69, 0x5b, 0x25, 0xb1, 0x55, 0xee, 0x5e, 0x2a, 0xcd, 0xe1, 0x28, + 0xa0, 0xcc, 0x52, 0x7f, 0x13, 0xaf, 0xd2, 0x19, 0x97, 0xf1, 0x88, 0x71, 0x2b, 0xe2, 0xbe, 0x8c, + 0x8e, 0xb8, 0xaf, 0x0d, 0xc5, 0xc4, 0xe0, 0xa8, 0x91, 0x95, 0x0c, 0xb4, 0xa9, 0x7c, 0x34, 0x6b, + 0x03, 0xc7, 0x38, 0x4a, 0xed, 0x0b, 0x3e, 0xf3, 0x59, 0x12, 0x27, 0xbf, 0xf4, 0xec, 0x59, 0x9f, + 0x31, 0x3f, 0x24, 0x16, 0x6e, 0x04, 0x16, 0xa6, 0x94, 0x09, 0x2c, 0x02, 0x46, 0x75, 0x8c, 0x59, + 0x03, 0xf8, 0x14, 0x87, 0x4d, 0x72, 0x3d, 0x20, 0xa1, 0x87, 0x6e, 0xc1,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 0xa6, 0xe8, 0x7e, 0x2d, 0x72, + 0x08, 0xa4, 0xb4, 0x72, 0xb2, 0x4f, 0x47, 0x98, 0xd5, 0x07, 0xbf, 0xfe, 0xf1, 0x7d, 0xee, 0x2d, + 0xf3, 0x82, 0xd5, 0xef, 0x77, 0x8c, 0x75, 0x18, 0x7a, 0xf4, 0xcb, 0x83, 0x47, 0x2b, 0xc6, 0xe6, + 0x87, 0x4f, 0xf6, 0xcb, 0xc6, 0xd3, 0xfd, 0xb2, 0xf1, 0x62, 0xbf, 0x6c, 0x7c, 0xfb, 0xb2, 0x3c, + 0xf4, 0xf4, 0x65, 0x79, 0xe8, 0xb7, 0x97, 0xe5, 0xa1, 0x3b, 0x17, 0x7b, 0x4e, 0xbb, 0x6b, 0x09, + 0xe2, 0x47, 0x44, 0xdc, 0x63, 0xf1, 0x5e, 0x27, 0x41, 0x2b, 0x4d, 0xa1, 0xce, 0xbe, 0xda, 0x98, + 0xfa, 0xf5, 0xf1, 0xce, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x24, 0xc2, 0xb0, 0x49, 0x0d, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1192,18 +1196,16 @@ func (m *StakingAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - if m.AssetBasicInfo != nil { - { - size, err := m.AssetBasicInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + { + size, err := m.AssetBasicInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0xa + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1742,10 +1744,8 @@ func (m *StakingAssetInfo) Size() (n int) { } var l int _ = l - if m.AssetBasicInfo != nil { - l = m.AssetBasicInfo.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = m.AssetBasicInfo.Size() + n += 1 + l + sovTx(uint64(l)) l = m.StakingTotalAmount.Size() n += 1 + l + sovTx(uint64(l)) return n @@ -2542,9 +2542,6 @@ func (m *StakingAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AssetBasicInfo == nil { - m.AssetBasicInfo = &AssetInfo{} - } if err := m.AssetBasicInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index fc7fa2774..0ae2b0b18 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -122,7 +122,8 @@ func (k Keeper) RegisterAVSWithChainID( if len(params.ChainID) == 0 { return common.Address{}, errorsmod.Wrap(types.ErrNotNull, "RegisterAVSWithChainID: chainID is null") } - avsAddr = types.GenerateAVSAddr(params.ChainID) + avsAddrStr := types.GenerateAVSAddr(params.ChainID) + avsAddr = common.HexToAddress(avsAddrStr) defer func() { if err == nil { // store the reverse lookup from AVSAddress to ChainID @@ -147,7 +148,7 @@ func (k Keeper) RegisterAVSWithChainID( return common.Address{}, err } // SetAVSInfo expects HexAddress for the AvsAddress - params.AvsAddress = avsAddr.String() + params.AvsAddress = avsAddrStr params.Action = RegisterAction if err := k.UpdateAVSInfo(ctx, params); err != nil { diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 551c02b2b..5a7cd0355 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -290,10 +290,11 @@ func (k *Keeper) IsAVS(ctx sdk.Context, addr string) (bool, error) { // IsAVSByChainID queries whether an AVS exists by chainID. // It returns the AVS address if it exists. -func (k Keeper) IsAVSByChainID(ctx sdk.Context, chainID string) (bool, common.Address) { - avsAddr := types.GenerateAVSAddr(chainID) +func (k Keeper) IsAVSByChainID(ctx sdk.Context, chainID string) (bool, string) { + avsAddrStr := types.GenerateAVSAddr(chainID) + avsAddr := common.HexToAddress(avsAddrStr) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSInfo) - return store.Has(avsAddr.Bytes()), avsAddr + return store.Has(avsAddr.Bytes()), avsAddrStr } func (k Keeper) DeleteAVSInfo(ctx sdk.Context, addr string) error { diff --git a/x/avs/keeper/query.go b/x/avs/keeper/query.go index ff1a7c7be..db70877ce 100644 --- a/x/avs/keeper/query.go +++ b/x/avs/keeper/query.go @@ -26,5 +26,5 @@ func (k Keeper) QueryAVSAddrByChainID(ctx context.Context, req *types.QueryAVSAd if !isChainAvs { return nil, types.ErrNotYetRegistered } - return &types.QueryAVSAddrByChainIDResponse{AVSAddress: avsAddr.String()}, nil + return &types.QueryAVSAddrByChainIDResponse{AVSAddress: avsAddr}, nil } diff --git a/x/avs/types/types.go b/x/avs/types/types.go index 0638ac8cf..6cc3f71b7 100644 --- a/x/avs/types/types.go +++ b/x/avs/types/types.go @@ -82,8 +82,8 @@ func ChainIDWithoutRevision(chainID string) string { // GenerateAVSAddr generates a hex AVS address based on the chainID. // It returns a hex address as a string. -func GenerateAVSAddr(chainID string) common.Address { - return common.BytesToAddress( +func GenerateAVSAddr(chainID string) string { + avsAddr := common.BytesToAddress( crypto.Keccak256( append( ChainIDPrefix, @@ -91,4 +91,5 @@ func GenerateAVSAddr(chainID string) common.Address { ), ), ) + return strings.ToLower(avsAddr.String()) } diff --git a/x/delegation/keeper/delegation.go b/x/delegation/keeper/delegation.go index e73859511..344ccc4c7 100644 --- a/x/delegation/keeper/delegation.go +++ b/x/delegation/keeper/delegation.go @@ -126,7 +126,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *delegationtype.Delegati return err } // record Undelegation event - r := &delegationtype.UndelegationRecord{ + r := delegationtype.UndelegationRecord{ StakerID: stakerID, AssetID: assetID, OperatorAddr: params.OperatorAddress.String(), @@ -138,7 +138,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *delegationtype.Delegati ActualCompletedAmount: removeToken, } r.CompleteBlockNumber = k.operatorKeeper.GetUnbondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) - err = k.SetUndelegationRecords(ctx, []*delegationtype.UndelegationRecord{r}) + err = k.SetUndelegationRecords(ctx, []delegationtype.UndelegationRecord{r}) if err != nil { return err } diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index e55934bce..6a1fb1ae0 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -14,6 +14,33 @@ import ( type DelegationOpFunc func(keys *delegationtype.SingleDelegationInfoReq, amounts *delegationtype.DelegationAmounts) error +func (k Keeper) AllDelegationStates(ctx sdk.Context) (delegationStates []delegationtype.DelegationStates, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]delegationtype.DelegationStates, 0) + for ; iterator.Valid(); iterator.Next() { + var stateInfo delegationtype.DelegationAmounts + k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) + ret = append(ret, delegationtype.DelegationStates{ + Key: string(iterator.Key()), + States: stateInfo, + }) + } + return ret, nil +} + +func (k Keeper) SetAllDelegationStates(ctx sdk.Context, delegationStates []delegationtype.DelegationStates) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + for i := range delegationStates { + singleElement := delegationStates[i] + bz := k.cdc.MustMarshal(&singleElement.States) + store.Set([]byte(singleElement.Key), bz) + } + return nil +} + // IterateDelegationsForStakerAndAsset processes all operations // that require iterating over delegations for a specified staker and asset. func (k Keeper) IterateDelegationsForStakerAndAsset(ctx sdk.Context, stakerID string, assetID string, opFunc DelegationOpFunc) error { @@ -24,7 +51,7 @@ func (k Keeper) IterateDelegationsForStakerAndAsset(ctx sdk.Context, stakerID st for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := delegationtype.ParseStakerAssetIDAndOperatorAddrFromKey(iterator.Key()) + keys, err := delegationtype.ParseStakerAssetIDAndOperator(iterator.Key()) if err != nil { return err } @@ -44,7 +71,7 @@ func (k Keeper) IterateDelegationsForStaker(ctx sdk.Context, stakerID string, op for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := delegationtype.ParseStakerAssetIDAndOperatorAddrFromKey(iterator.Key()) + keys, err := delegationtype.ParseStakerAssetIDAndOperator(iterator.Key()) if err != nil { return err } @@ -249,6 +276,33 @@ func (k *Keeper) GetStakersByOperator(ctx sdk.Context, operator, assetID string) return stakerList, nil } +func (k Keeper) AllStakerList(ctx sdk.Context) (stakerList []delegationtype.StakersByOperator, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixStakersByOperator) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]delegationtype.StakersByOperator, 0) + for ; iterator.Valid(); iterator.Next() { + var stakers delegationtype.StakerList + k.cdc.MustUnmarshal(iterator.Value(), &stakers) + ret = append(ret, delegationtype.StakersByOperator{ + Key: string(iterator.Key()), + Stakers: stakers.Stakers, + }) + } + return ret, nil +} + +func (k Keeper) SetAllStakerList(ctx sdk.Context, stakersByOperator []delegationtype.StakersByOperator) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixStakersByOperator) + for i := range stakersByOperator { + singleElement := stakersByOperator[i] + bz := k.cdc.MustMarshal(&delegationtype.StakerList{Stakers: singleElement.Stakers}) + store.Set([]byte(singleElement.Key), bz) + } + return nil +} + func (k *Keeper) SetStakerShareToZero(ctx sdk.Context, operator, assetID string, stakerList delegationtype.StakerList) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) for _, stakerID := range stakerList.Stakers { @@ -325,3 +379,18 @@ func (k *Keeper) GetAssociatedOperator(ctx sdk.Context, stakerID string) (string } return "", nil } + +func (k *Keeper) GetAllAssociations(ctx sdk.Context) ([]delegationtype.StakerToOperator, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixAssociatedOperatorByStaker) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]delegationtype.StakerToOperator, 0) + for ; iterator.Valid(); iterator.Next() { + ret = append(ret, delegationtype.StakerToOperator{ + StakerID: string(iterator.Key()), + Operator: string(iterator.Value()), + }) + } + return ret, nil +} diff --git a/x/delegation/keeper/genesis.go b/x/delegation/keeper/genesis.go index 3bfd436ed..8e3e35cc3 100644 --- a/x/delegation/keeper/genesis.go +++ b/x/delegation/keeper/genesis.go @@ -15,41 +15,6 @@ func (k Keeper) InitGenesis( ctx sdk.Context, gs delegationtype.GenesisState, ) []abci.ValidatorUpdate { - // TODO(mm): is it possible to parallelize these without using goroutines? - for _, level1 := range gs.Delegations { - stakerID := level1.StakerID - // #nosec G703 // already validated - stakerAddress, lzID, _ := assetstype.ParseID(stakerID) - // we have checked IsHexAddress already - stakerAddressBytes := common.HexToAddress(stakerAddress) - for _, level2 := range level1.Delegations { - assetID := level2.AssetID - // #nosec G703 // already validated - assetAddress, _, _ := assetstype.ParseID(assetID) - // we have checked IsHexAddress already - assetAddressBytes := common.HexToAddress(assetAddress) - for _, level3 := range level2.PerOperatorAmounts { - operator := level3.Key - wrappedAmount := level3.Value - amount := wrappedAmount.Amount - // #nosec G703 // already validated - accAddress, _ := sdk.AccAddressFromBech32(operator) - delegationParams := &delegationtype.DelegationOrUndelegationParams{ - ClientChainID: lzID, - Action: assetstype.DelegateTo, - AssetsAddress: assetAddressBytes.Bytes(), - OperatorAddress: accAddress, - StakerAddress: stakerAddressBytes.Bytes(), - OpAmount: amount, - // the uninitialized members are not used in this context - // they are the LzNonce and TxHash - } - if err := k.delegateTo(ctx, delegationParams, false); err != nil { - panic(errorsmod.Wrap(err, "failed to delegate to operator")) - } - } - } - } for _, association := range gs.Associations { stakerID := association.StakerID operatorAddress := association.Operator @@ -66,12 +31,44 @@ func (k Keeper) InitGenesis( panic(errorsmod.Wrap(err, "failed to associate operator with staker")) } } + + // init the state from the general exporting genesis file + err := k.SetAllDelegationStates(ctx, gs.DelegationStates) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all delegation states")) + } + err = k.SetAllStakerList(ctx, gs.StakersByOperator) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all staker list")) + } + err = k.SetUndelegationRecords(ctx, gs.Undelegations) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all undelegation records")) + } return []abci.ValidatorUpdate{} } // ExportGenesis returns the module's exported genesis -func (Keeper) ExportGenesis(sdk.Context) *delegationtype.GenesisState { - genesis := delegationtype.DefaultGenesis() - // TODO - return genesis +func (k Keeper) ExportGenesis(ctx sdk.Context) *delegationtype.GenesisState { + res := delegationtype.GenesisState{} + var err error + res.Associations, err = k.GetAllAssociations(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all associations").Error()) + } + + res.DelegationStates, err = k.AllDelegationStates(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all delegation states").Error()) + } + res.StakersByOperator, err = k.AllStakerList(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all staker list").Error()) + } + + res.Undelegations, err = k.AllUndelegations(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all undelegations").Error()) + } + return &res } diff --git a/x/delegation/keeper/un_delegation_state.go b/x/delegation/keeper/un_delegation_state.go index 8853817d7..d0b1f72df 100644 --- a/x/delegation/keeper/un_delegation_state.go +++ b/x/delegation/keeper/un_delegation_state.go @@ -13,17 +13,34 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) +func (k Keeper) AllUndelegations(ctx sdk.Context) (undelegations []types.UndelegationRecord, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixUndelegationInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.UndelegationRecord, 0) + for ; iterator.Valid(); iterator.Next() { + var undelegation types.UndelegationRecord + k.cdc.MustUnmarshal(iterator.Value(), &undelegation) + ret = append(ret, undelegation) + } + return ret, nil +} + // SetUndelegationRecords function saves the undelegation records to be handled when the handle time expires. // When we save the undelegation records, we save them in three kv stores which are `KeyPrefixUndelegationInfo` `KeyPrefixStakerUndelegationInfo` and `KeyPrefixPendingUndelegations` -func (k *Keeper) SetUndelegationRecords(ctx sdk.Context, records []*types.UndelegationRecord) error { +func (k *Keeper) SetUndelegationRecords(ctx sdk.Context, records []types.UndelegationRecord) error { singleRecordStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixUndelegationInfo) stakerUndelegationStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixStakerUndelegationInfo) pendingUndelegationStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixPendingUndelegations) - // key := common.HexToAddress(incentive.Contract) - for _, record := range records { - bz := k.cdc.MustMarshal(record) + currentHeight := ctx.BlockHeight() + for i := range records { + record := records[i] + if record.CompleteBlockNumber < uint64(currentHeight) { + return errorsmod.Wrapf(types.ErrInvalidCompletedHeight, "currentHeight:%d,CompleteBlockNumber:%d", currentHeight, record.CompleteBlockNumber) + } + bz := k.cdc.MustMarshal(&record) // todo: check if the following state can only be set once? - singleRecKey := types.GetUndelegationRecordKey(record.BlockNumber, record.LzTxNonce, record.TxHash, record.OperatorAddr) singleRecordStore.Set(singleRecKey, bz) diff --git a/x/delegation/types/errors.go b/x/delegation/types/errors.go index 320b059b9..c9bf63ee8 100644 --- a/x/delegation/types/errors.go +++ b/x/delegation/types/errors.go @@ -79,4 +79,9 @@ var ( ModuleName, 17, "the client chain has not been registered", ) + + ErrInvalidCompletedHeight = errorsmod.Register( + ModuleName, 23, + "the block height to complete the unelegation is invalid", + ) ) diff --git a/x/delegation/types/genesis.go b/x/delegation/types/genesis.go index 947c1c977..749de733e 100644 --- a/x/delegation/types/genesis.go +++ b/x/delegation/types/genesis.go @@ -1,113 +1,68 @@ package types import ( + "encoding/hex" + + "github.com/ExocoreNetwork/exocore/utils" + errorsmod "cosmossdk.io/errors" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "golang.org/x/xerrors" ) // NewGenesis returns a new genesis state with the given inputs. func NewGenesis( - delegations []DelegationsByStaker, associations []StakerToOperator, + delegationStates []DelegationStates, + stakersByOperator []StakersByOperator, + undelegations []UndelegationRecord, ) *GenesisState { return &GenesisState{ - Delegations: delegations, - Associations: associations, + Associations: associations, + DelegationStates: delegationStates, + StakersByOperator: stakersByOperator, + Undelegations: undelegations, } } // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { - return NewGenesis(nil, nil) + return NewGenesis(nil, nil, nil, nil) } -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { - // TODO(mm): this can be a very big hash table and impact system performance. - // This is likely to be the biggest one amongst the three, and the others - // are garbage collected within the loop anyway. Maybe reordering the genesis - // structure could potentially help with this. - stakers := make(map[string]struct{}, len(gs.Delegations)) - for _, level1 := range gs.Delegations { - stakerID := level1.StakerID - // validate staker ID - var stakerClientChainID uint64 - var err error - if _, stakerClientChainID, err = assetstypes.ValidateID( - stakerID, true, true, - ); err != nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, "invalid staker ID %s: %s", stakerID, err, - ) - } - // check for duplicate stakers - if _, ok := stakers[stakerID]; ok { - return errorsmod.Wrapf(ErrInvalidGenesisData, "duplicate staker ID %s", stakerID) - } - stakers[stakerID] = struct{}{} - assets := make(map[string]struct{}, len(level1.Delegations)) - for _, level2 := range level1.Delegations { - assetID := level2.AssetID - // check for duplicate assets - if _, ok := assets[assetID]; ok { - return errorsmod.Wrapf(ErrInvalidGenesisData, "duplicate asset ID %s", assetID) - } - assets[assetID] = struct{}{} - // validate asset ID - var assetClientChainID uint64 - if _, assetClientChainID, err = assetstypes.ValidateID( - assetID, true, true, - ); err != nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, "invalid asset ID %s: %s", assetID, err, - ) - } - if assetClientChainID != stakerClientChainID { - // a staker from chain A is delegating an asset on chain B, which is not - // something we support right now. - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "asset %s client chain ID %d does not match staker %s client chain ID %d", - assetID, assetClientChainID, stakerID, stakerClientChainID, - ) - } - operators := make(map[string]struct{}, len(level2.PerOperatorAmounts)) - for _, level3 := range level2.PerOperatorAmounts { - operator := level3.Key - wrappedAmount := level3.Value - // check supplied amount - if wrappedAmount == nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, "nil operator amount for operator %s", operator, - ) - } - amount := wrappedAmount.Amount - if amount.IsNil() || amount.IsNegative() { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "invalid operator amount %s for operator %s", amount, operator, - ) - } - // check operator address - if _, err := sdk.AccAddressFromBech32(operator); err != nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "invalid operator address for operator %s", operator, - ) - } - // check for duplicate operators - if _, ok := operators[operator]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate operator %s for asset %s", operator, assetID, - ) - } - operators[operator] = struct{}{} - } - } +func ValidateIDAndOperator(stakerID, assetID, operator string) error { + // validate the operator address + if _, err := sdk.AccAddressFromBech32(operator); err != nil { + return xerrors.Errorf( + "ValidateIDAndOperator: invalid operator address for operator %s", operator, + ) } + _, stakerClientChainID, err := assetstypes.ValidateID(stakerID, true, false) + if err != nil { + return xerrors.Errorf( + "ValidateIDAndOperator: invalid stakerID: %s", + stakerID, + ) + } + _, assetClientChainID, err := assetstypes.ValidateID(assetID, true, false) + if err != nil { + return xerrors.Errorf( + "ValidateIDAndOperator: invalid assetID: %s", + assetID, + ) + } + if stakerClientChainID != assetClientChainID { + return xerrors.Errorf( + "ValidateIDAndOperator: the client chain layerZero IDs of the staker and asset are different, stakerID:%s, assetID:%s", + stakerID, assetID) + } + return nil +} + +func (gs GenesisState) ValidateAssociations() error { // for associations, one stakerID can be associated only with one operator. // but one operator may have multiple stakerIDs associated with it. associatedStakerIDs := make(map[string]struct{}, len(gs.Associations)) @@ -140,3 +95,174 @@ func (gs GenesisState) Validate() error { } return nil } + +func (gs GenesisState) ValidateDelegationStates() error { + validationFunc := func(_ int, info DelegationStates) error { + keys, err := ParseStakerAssetIDAndOperator([]byte(info.Key)) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + err = ValidateIDAndOperator(keys.StakerID, keys.AssetID, keys.OperatorAddr) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + // check that there is no nil value provided. + if info.States.UndelegatableShare.IsNil() || info.States.WaitUndelegationAmount.IsNil() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "nil delegation state for %s: %+v", + info.Key, info, + ) + } + + // check for negative values. + if info.States.UndelegatableShare.IsNegative() || info.States.WaitUndelegationAmount.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "negative delegation state for %s: %+v", + info.Key, info, + ) + } + + return nil + } + seenFieldValueFunc := func(info DelegationStates) (string, struct{}) { + return info.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.DelegationStates, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateStakerList() error { + validationFunc := func(_ int, stakersByOperator StakersByOperator) error { + // validate the key + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(stakersByOperator.Key), 2) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + // validate the operator address + if _, err := sdk.AccAddressFromBech32(stringList[0]); err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid operator address for operator %s", stringList[0], + ) + } + // validate the assetID + _, assetClientChainID, err := assetstypes.ValidateID(stringList[1], true, false) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid assetID: %s", + stringList[1], + ) + } + // validate the staker list + stakerValidationFunc := func(_ int, stakerID string) error { + _, stakerClientChainID, err := assetstypes.ValidateID(stakerID, true, false) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid stakerID: %s", + stakerID, + ) + } + if stakerClientChainID != assetClientChainID { + return errorsmod.Wrapf(ErrInvalidGenesisData, "the client chain layerZero IDs of the staker and asset are different,key:%s stakerID:%s", stakersByOperator.Key, stakerID) + } + return nil + } + seenStakerFunc := func(stakerID string) (string, struct{}) { + return stakerID, struct{}{} + } + _, err = utils.CommonValidation(stakersByOperator.Stakers, seenStakerFunc, stakerValidationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(info StakersByOperator) (string, struct{}) { + return info.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.StakersByOperator, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateUndelegations() error { + validationFunc := func(_ int, undelegation UndelegationRecord) error { + err := ValidateIDAndOperator(undelegation.StakerID, undelegation.AssetID, undelegation.OperatorAddr) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + bytes, err := hex.DecodeString(undelegation.TxHash) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "TxHash isn't a hex string, TxHash: %s", + undelegation.TxHash, + ) + } + if len(bytes) != common.HashLength { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "invalid length of TxHash ,TxHash:%s length: %d, should:%d", + undelegation.TxHash, len(bytes), common.HashLength, + ) + } + if !undelegation.IsPending { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "all undelegations should be pending, undelegation:%v", + undelegation, + ) + } + if undelegation.CompleteBlockNumber < undelegation.BlockNumber { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "the block number to complete shouldn't be less than the submitted , undelegation:%v", + undelegation, + ) + } + if undelegation.ActualCompletedAmount.GT(undelegation.Amount) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "the completed amount shouldn't be greater than the submitted amount , undelegation:%v", + undelegation, + ) + } + return nil + } + seenFieldValueFunc := func(undelegation UndelegationRecord) (string, struct{}) { + return undelegation.TxHash, struct{}{} + } + _, err := utils.CommonValidation(gs.Undelegations, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + err := gs.ValidateAssociations() + if err != nil { + return err + } + err = gs.ValidateDelegationStates() + if err != nil { + return err + } + err = gs.ValidateStakerList() + if err != nil { + return err + } + err = gs.ValidateUndelegations() + if err != nil { + return err + } + return nil +} diff --git a/x/delegation/types/genesis.pb.go b/x/delegation/types/genesis.pb.go index 713674d2d..8964ed1db 100644 --- a/x/delegation/types/genesis.pb.go +++ b/x/delegation/types/genesis.pb.go @@ -28,10 +28,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // or in the event of a restart. At this point, it is only built with // the former in mind. There are no params in this module. type GenesisState struct { - // delegations is a list of all delegations in the system. - Delegations []DelegationsByStaker `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // associations represents the association between a staker and an operator. - Associations []StakerToOperator `protobuf:"bytes,2,rep,name=associations,proto3" json:"associations"` + Associations []StakerToOperator `protobuf:"bytes,1,rep,name=associations,proto3" json:"associations"` + // delegation_states is a list of all delegation states. + DelegationStates []DelegationStates `protobuf:"bytes,2,rep,name=delegation_states,json=delegationStates,proto3" json:"delegation_states"` + // stakers_by_operator is a staker list for the operators + StakersByOperator []StakersByOperator `protobuf:"bytes,3,rep,name=stakers_by_operator,json=stakersByOperator,proto3" json:"stakers_by_operator"` + // undelegations is a list of all undelegations + Undelegations []UndelegationRecord `protobuf:"bytes,4,rep,name=undelegations,proto3" json:"undelegations"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -67,23 +71,151 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetDelegations() []DelegationsByStaker { +func (m *GenesisState) GetAssociations() []StakerToOperator { if m != nil { - return m.Delegations + return m.Associations } return nil } -func (m *GenesisState) GetAssociations() []StakerToOperator { +func (m *GenesisState) GetDelegationStates() []DelegationStates { if m != nil { - return m.Associations + return m.DelegationStates + } + return nil +} + +func (m *GenesisState) GetStakersByOperator() []StakersByOperator { + if m != nil { + return m.StakersByOperator + } + return nil +} + +func (m *GenesisState) GetUndelegations() []UndelegationRecord { + if m != nil { + return m.Undelegations + } + return nil +} + +// DelegationStates is a helper struct for the delegation state +// used to construct the genesis state +type DelegationStates struct { + // key is used for storing the delegation states, + // which is a combination of the staker ID, asset ID, and operator address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // states is the value of undelegation state for the above key + States DelegationAmounts `protobuf:"bytes,2,opt,name=states,proto3" json:"states"` +} + +func (m *DelegationStates) Reset() { *m = DelegationStates{} } +func (m *DelegationStates) String() string { return proto.CompactTextString(m) } +func (*DelegationStates) ProtoMessage() {} +func (*DelegationStates) Descriptor() ([]byte, []int) { + return fileDescriptor_c26dd0d733927603, []int{1} +} +func (m *DelegationStates) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegationStates) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegationStates.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 *DelegationStates) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegationStates.Merge(m, src) +} +func (m *DelegationStates) XXX_Size() int { + return m.Size() +} +func (m *DelegationStates) XXX_DiscardUnknown() { + xxx_messageInfo_DelegationStates.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegationStates proto.InternalMessageInfo + +func (m *DelegationStates) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *DelegationStates) GetStates() DelegationAmounts { + if m != nil { + return m.States + } + return DelegationAmounts{} +} + +// StakersByOperator is a helper struct for an operator's staker list +// used to construct the genesis state +type StakersByOperator struct { + // key is used for storing the staker list, + // which is a combination of the operator address and the asset ID. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // stakers is the stakers list for the above key + Stakers []string `protobuf:"bytes,2,rep,name=stakers,proto3" json:"stakers,omitempty"` +} + +func (m *StakersByOperator) Reset() { *m = StakersByOperator{} } +func (m *StakersByOperator) String() string { return proto.CompactTextString(m) } +func (*StakersByOperator) ProtoMessage() {} +func (*StakersByOperator) Descriptor() ([]byte, []int) { + return fileDescriptor_c26dd0d733927603, []int{2} +} +func (m *StakersByOperator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakersByOperator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakersByOperator.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 *StakersByOperator) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakersByOperator.Merge(m, src) +} +func (m *StakersByOperator) XXX_Size() int { + return m.Size() +} +func (m *StakersByOperator) XXX_DiscardUnknown() { + xxx_messageInfo_StakersByOperator.DiscardUnknown(m) +} + +var xxx_messageInfo_StakersByOperator proto.InternalMessageInfo + +func (m *StakersByOperator) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *StakersByOperator) GetStakers() []string { + if m != nil { + return m.Stakers } return nil } // DelegationsByStaker is a list of delegations for a single staker. type DelegationsByStaker struct { - // staker_id is the staker's account address + _ + l0 chain id (hex).`` + // staker_id is the staker's account address + _ + l0 chain id (hex).“ StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` // delegations is the list of delegations for the staker, indexed by the // asset_id. @@ -94,7 +226,7 @@ func (m *DelegationsByStaker) Reset() { *m = DelegationsByStaker{} } func (m *DelegationsByStaker) String() string { return proto.CompactTextString(m) } func (*DelegationsByStaker) ProtoMessage() {} func (*DelegationsByStaker) Descriptor() ([]byte, []int) { - return fileDescriptor_c26dd0d733927603, []int{1} + return fileDescriptor_c26dd0d733927603, []int{3} } func (m *DelegationsByStaker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -149,7 +281,7 @@ func (m *StakerToOperator) Reset() { *m = StakerToOperator{} } func (m *StakerToOperator) String() string { return proto.CompactTextString(m) } func (*StakerToOperator) ProtoMessage() {} func (*StakerToOperator) Descriptor() ([]byte, []int) { - return fileDescriptor_c26dd0d733927603, []int{2} + return fileDescriptor_c26dd0d733927603, []int{4} } func (m *StakerToOperator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -194,6 +326,8 @@ func (m *StakerToOperator) GetOperator() string { func init() { proto.RegisterType((*GenesisState)(nil), "exocore.delegation.v1.GenesisState") + proto.RegisterType((*DelegationStates)(nil), "exocore.delegation.v1.DelegationStates") + proto.RegisterType((*StakersByOperator)(nil), "exocore.delegation.v1.StakersByOperator") proto.RegisterType((*DelegationsByStaker)(nil), "exocore.delegation.v1.DelegationsByStaker") proto.RegisterType((*StakerToOperator)(nil), "exocore.delegation.v1.StakerToOperator") } @@ -203,29 +337,37 @@ func init() { } var fileDescriptor_c26dd0d733927603 = []byte{ - // 338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x4e, 0xc2, 0x40, - 0x10, 0x86, 0xbb, 0x68, 0x0c, 0x2c, 0x1c, 0x4c, 0xd5, 0x84, 0x70, 0x58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 0xba, 0x17, 0x5e, 0x9e, 0x94, 0x48, 0x25, 0x63, 0xe7, 0xa2, 0x49, 0x31, 0xad, 0xdb, 0xf5, 0x9a, - 0x93, 0xd6, 0xed, 0xba, 0x67, 0xde, 0xac, 0x27, 0xd5, 0x4b, 0xf1, 0xbf, 0x93, 0x82, 0xd7, 0x14, - 0x81, 0xdf, 0x85, 0x33, 0x29, 0x41, 0xd5, 0x83, 0x07, 0x4c, 0x88, 0x5b, 0xbe, 0xa5, 0xdb, 0x3f, - 0x33, 0xfc, 0x67, 0xaf, 0x02, 0x4d, 0xe3, 0xfc, 0x5b, 0x3e, 0x35, 0x23, 0x9d, 0xef, 0xb7, 0xdd, - 0x18, 0x45, 0x8c, 0x8c, 0x23, 0x46, 0x3e, 0x23, 0x46, 0x5e, 0xa7, 0xcc, 0x18, 0x4f, 0x99, 0xf1, - 0x31, 0x65, 0xc6, 0xdd, 0xa9, 0x2f, 0xd4, 0xe3, 0x73, 0xcb, 0x6a, 0xe3, 0x13, 0x3f, 0xd7, 0x11, - 0x1a, 0xa0, 0x5e, 0x30, 0xec, 0xf0, 0xc5, 0x09, 0x0c, 0x56, 0x8f, 0x40, 0x0d, 0x7b, 0x20, 0x5b, - 0x5b, 0xf1, 0x15, 0x9c, 0x7c, 0x05, 0x00, 0x00, 0xff, 0xff, 0x9f, 0xea, 0x40, 0xc1, 0x79, 0x02, - 0x00, 0x00, + // 471 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xe3, 0xa4, 0x2a, 0xc9, 0x36, 0x48, 0xc9, 0x16, 0x24, 0x2b, 0x07, 0xb7, 0x98, 0x03, + 0xe9, 0xc5, 0x56, 0x81, 0x17, 0xa8, 0xd5, 0x82, 0x72, 0x29, 0x22, 0xa1, 0x42, 0xf4, 0x40, 0xe4, + 0xc4, 0x83, 0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 0xe9, + 0x76, 0x61, 0x95, 0x7e, 0x2d, 0xac, 0xd2, 0xe5, 0xeb, 0x30, 0x12, 0x5f, 0xa7, 0x03, 0x67, 0x88, + 0x57, 0xee, 0x99, 0x6a, 0xe1, 0x1c, 0xc4, 0x77, 0x4c, 0x46, 0xee, 0xea, 0x18, 0x67, 0x9b, 0xe7, + 0x28, 0xd2, 0x09, 0xd0, 0x60, 0x57, 0x5e, 0xde, 0xab, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0f, + 0x22, 0xc1, 0x73, 0x10, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -248,10 +390,38 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Associations) > 0 { - for iNdEx := len(m.Associations) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Undelegations) > 0 { + for iNdEx := len(m.Undelegations) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Associations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Undelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.StakersByOperator) > 0 { + for iNdEx := len(m.StakersByOperator) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakersByOperator[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.DelegationStates) > 0 { + for iNdEx := len(m.DelegationStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DelegationStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -262,10 +432,10 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if len(m.Delegations) > 0 { - for iNdEx := len(m.Delegations) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Associations) > 0 { + for iNdEx := len(m.Associations) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Delegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Associations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -279,6 +449,85 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DelegationStates) 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 *DelegationStates) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegationStates) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.States.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakersByOperator) 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 *StakersByOperator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakersByOperator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Stakers) > 0 { + for iNdEx := len(m.Stakers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Stakers[iNdEx]) + copy(dAtA[i:], m.Stakers[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Stakers[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *DelegationsByStaker) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -377,14 +626,26 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if len(m.Delegations) > 0 { - for _, e := range m.Delegations { + if len(m.Associations) > 0 { + for _, e := range m.Associations { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.Associations) > 0 { - for _, e := range m.Associations { + if len(m.DelegationStates) > 0 { + for _, e := range m.DelegationStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.StakersByOperator) > 0 { + for _, e := range m.StakersByOperator { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Undelegations) > 0 { + for _, e := range m.Undelegations { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -392,6 +653,40 @@ func (m *GenesisState) Size() (n int) { return n } +func (m *DelegationStates) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.States.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *StakersByOperator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Stakers) > 0 { + for _, s := range m.Stakers { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + func (m *DelegationsByStaker) Size() (n int) { if m == nil { return 0 @@ -465,7 +760,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegations", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Associations", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -492,14 +787,14 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, DelegationsByStaker{}) - if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Associations = append(m.Associations, StakerToOperator{}) + if err := m.Associations[len(m.Associations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Associations", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DelegationStates", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -526,8 +821,76 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Associations = append(m.Associations, StakerToOperator{}) - if err := m.Associations[len(m.Associations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.DelegationStates = append(m.DelegationStates, DelegationStates{}) + if err := m.DelegationStates[len(m.DelegationStates)-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 StakersByOperator", 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.StakersByOperator = append(m.StakersByOperator, StakersByOperator{}) + if err := m.StakersByOperator[len(m.StakersByOperator)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Undelegations", 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.Undelegations = append(m.Undelegations, UndelegationRecord{}) + if err := m.Undelegations[len(m.Undelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -552,6 +915,235 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } +func (m *DelegationStates) 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: DelegationStates: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegationStates: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field States", 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.States.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakersByOperator) 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: StakersByOperator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakersByOperator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stakers", 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.Stakers = append(m.Stakers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *DelegationsByStaker) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/delegation/types/genesis_test.go b/x/delegation/types/genesis_test.go index 4ec0b0988..08bde0839 100644 --- a/x/delegation/types/genesis_test.go +++ b/x/delegation/types/genesis_test.go @@ -30,21 +30,21 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { lzID, stakerAddress[:], assetAddress[:], ) operatorAddress := sdk.AccAddress(utiltx.GenerateAddress().Bytes()) - delegations := []types.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operatorAddress.String()) + delegationStates := []types.DelegationStates{ { - StakerID: stakerID, - Delegations: []types.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []types.KeyValue{ - { - Key: operatorAddress.String(), - Value: &types.ValueField{ - Amount: math.NewInt(1000), - }, - }, - }, - }, + Key: string(singleStateKey), + States: types.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDec(1000), + }, + }, + } + stakersByOperator := []types.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operatorAddress.String(), assetID)), + Stakers: []string{ + stakerID, }, }, } @@ -67,117 +67,107 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, { name: "base, should pass", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: true, }, { name: "invalid staker id", - genState: types.NewGenesis(delegations, nil), - expPass: false, - malleate: func(gs *types.GenesisState) { - gs.Delegations[0].StakerID = "invalid" - }, - unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].StakerID = stakerID - }, - }, - { - name: "duplicate staker id", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations = append(gs.Delegations, gs.Delegations[0]) + invalidStateKey := assetstypes.GetJoinedStoreKey("invalid", assetID, operatorAddress.String()) + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations = gs.Delegations[:1] + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { - name: "duplicate asset id", - genState: types.NewGenesis(delegations, nil), + name: "duplicate state key", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations = append( - gs.Delegations[0].Delegations, - gs.Delegations[0].Delegations[0], - ) + gs.DelegationStates = append(gs.DelegationStates, gs.DelegationStates[0]) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations = gs.Delegations[0].Delegations[:1] + gs.DelegationStates = gs.DelegationStates[:1] }, }, { name: "invalid asset id", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].AssetID = "invalid" + invalidStateKey := assetstypes.GetJoinedStoreKey(stakerID, "invalid", operatorAddress.String()) + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].AssetID = assetID + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { name: "asset id mismatch", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { stakerID, _ := assetstypes.GetStakeIDAndAssetID( lzID+1, stakerAddress[:], assetAddress[:], ) - gs.Delegations[0].StakerID = stakerID + invalidStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operatorAddress.String()) + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].StakerID = stakerID + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { - name: "nil wrapped amount", - genState: types.NewGenesis(delegations, nil), + name: "nil wrapped undelegatable share", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = nil + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyDec{} }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(1000)} + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyNewDec(1000) }, }, { - name: "nil unwrapped amount", - genState: types.NewGenesis(delegations, nil), + name: "nil wrapped unbonding amount", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{} + gs.DelegationStates[0].States.WaitUndelegationAmount = math.Int{} }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(1000)} + gs.DelegationStates[0].States.WaitUndelegationAmount = math.NewInt(0) }, }, { - name: "negative unwrapped amount", - genState: types.NewGenesis(delegations, nil), + name: "negative wrapped undelegatable share", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(-1)} + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyNewDec(-1) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(1000)} + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyNewDec(1000) }, }, { name: "invalid operator address", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Key = "invalid" + invalidStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, "invalid") + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Key = operatorAddress.String() + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { name: "duplicate stakerID in associations", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { gs.Associations = make([]types.StakerToOperator, 2) @@ -192,7 +182,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, { name: "one stakerID in associations", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: true, malleate: func(gs *types.GenesisState) { gs.Associations = make([]types.StakerToOperator, 1) diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index 5eb7d7feb..4aeaf36e6 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -72,7 +72,7 @@ func GetDelegationStateIteratorPrefix(stakerID, assetID string) []byte { return tmp } -func ParseStakerAssetIDAndOperatorAddrFromKey(key []byte) (keys *SingleDelegationInfoReq, err error) { +func ParseStakerAssetIDAndOperator(key []byte) (keys *SingleDelegationInfoReq, err error) { stringList, err := assetstypes.ParseJoinedStoreKey(key, 3) if err != nil { return nil, err diff --git a/x/delegation/types/types/query.pb.go b/x/delegation/types/types/query.pb.go deleted file mode 100644 index d5b83e649..000000000 --- a/x/delegation/types/types/query.pb.go +++ /dev/null @@ -1,1880 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/delegation/v1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/query" - _ "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 - -// DelegationInfoReq is the request to obtain the delegation information -// by staker id and asset id. -type DelegationInfoReq struct { - // staker_id is the staker id. - StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` - // asset_id is the asset id. - AssetID string `protobuf:"bytes,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` -} - -func (m *DelegationInfoReq) Reset() { *m = DelegationInfoReq{} } -func (m *DelegationInfoReq) String() string { return proto.CompactTextString(m) } -func (*DelegationInfoReq) ProtoMessage() {} -func (*DelegationInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{0} -} -func (m *DelegationInfoReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DelegationInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DelegationInfoReq.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 *DelegationInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_DelegationInfoReq.Merge(m, src) -} -func (m *DelegationInfoReq) XXX_Size() int { - return m.Size() -} -func (m *DelegationInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_DelegationInfoReq.DiscardUnknown(m) -} - -var xxx_messageInfo_DelegationInfoReq proto.InternalMessageInfo - -func (m *DelegationInfoReq) GetStakerID() string { - if m != nil { - return m.StakerID - } - return "" -} - -func (m *DelegationInfoReq) GetAssetID() string { - if m != nil { - return m.AssetID - } - return "" -} - -// StakerList is a list to save a batch of stakers -type StakerList struct { - // stakers is a list of stakers. the caller is responsible for ensuring - // uniqueness of the stakers, since dumping this into a map could lead - // to non-deterministic behavior. - Stakers []string `protobuf:"bytes,1,rep,name=stakers,proto3" json:"stakers,omitempty"` -} - -func (m *StakerList) Reset() { *m = StakerList{} } -func (m *StakerList) String() string { return proto.CompactTextString(m) } -func (*StakerList) ProtoMessage() {} -func (*StakerList) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{1} -} -func (m *StakerList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakerList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakerList.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 *StakerList) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerList.Merge(m, src) -} -func (m *StakerList) XXX_Size() int { - return m.Size() -} -func (m *StakerList) XXX_DiscardUnknown() { - xxx_messageInfo_StakerList.DiscardUnknown(m) -} - -var xxx_messageInfo_StakerList proto.InternalMessageInfo - -func (m *StakerList) GetStakers() []string { - if m != nil { - return m.Stakers - } - return nil -} - -// DelegationAmounts is the delegation amount response for a single delegation. -type DelegationAmounts struct { - // undelegatable_share is the share that can be undelegated. - // It's to reduce the state updating when slash occurs. - // S_j = S * T_j / T, `S` and `T` is the current asset share and amount of operator, - // and the T_j represents the change in staker's asset amount when some external - // operations occur, such as: delegation, undelegation and non-instantaneous slashing. - // S_j represents the change in the staker's asset share, - // so the updated share should be added by it. - // A special case is the initial delegation, when T = 0 and S = 0, so T_j / T is undefined. - // For the initial delegation, delegator j who delegates T_j tokens receive S_j = T_j shares. - UndelegatableShare github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=undelegatable_share,json=undelegatableShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"undelegatable_share"` - // wait_undelegation_amount is the amount that is waiting to be unbonded. - WaitUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=wait_undelegation_amount,json=waitUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_undelegation_amount"` -} - -func (m *DelegationAmounts) Reset() { *m = DelegationAmounts{} } -func (m *DelegationAmounts) String() string { return proto.CompactTextString(m) } -func (*DelegationAmounts) ProtoMessage() {} -func (*DelegationAmounts) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{2} -} -func (m *DelegationAmounts) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DelegationAmounts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DelegationAmounts.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 *DelegationAmounts) XXX_Merge(src proto.Message) { - xxx_messageInfo_DelegationAmounts.Merge(m, src) -} -func (m *DelegationAmounts) XXX_Size() int { - return m.Size() -} -func (m *DelegationAmounts) XXX_DiscardUnknown() { - xxx_messageInfo_DelegationAmounts.DiscardUnknown(m) -} - -var xxx_messageInfo_DelegationAmounts proto.InternalMessageInfo - -// QueryDelegationInfoResponse is the response for delegations by staker id and -// asset id. -type QueryDelegationInfoResponse struct { - // delegation_infos is the delegation information for each operator. - DelegationInfos map[string]*DelegationAmounts `protobuf:"bytes,1,rep,name=delegation_infos,json=delegationInfos,proto3" json:"delegation_infos,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *QueryDelegationInfoResponse) Reset() { *m = QueryDelegationInfoResponse{} } -func (m *QueryDelegationInfoResponse) String() string { return proto.CompactTextString(m) } -func (*QueryDelegationInfoResponse) ProtoMessage() {} -func (*QueryDelegationInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{3} -} -func (m *QueryDelegationInfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDelegationInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDelegationInfoResponse.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 *QueryDelegationInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDelegationInfoResponse.Merge(m, src) -} -func (m *QueryDelegationInfoResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryDelegationInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDelegationInfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDelegationInfoResponse proto.InternalMessageInfo - -func (m *QueryDelegationInfoResponse) GetDelegationInfos() map[string]*DelegationAmounts { - if m != nil { - return m.DelegationInfos - } - return nil -} - -// SingleDelegationInfoReq is the request to obtain the single delegation information. -type SingleDelegationInfoReq struct { - // staker_id is the staker id. - StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` - // operator_addr is the operator address. - OperatorAddr string `protobuf:"bytes,2,opt,name=operator_addr,json=operatorAddr,proto3" json:"operator_addr,omitempty"` - // asset_id is the asset id. - AssetID string `protobuf:"bytes,3,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` -} - -func (m *SingleDelegationInfoReq) Reset() { *m = SingleDelegationInfoReq{} } -func (m *SingleDelegationInfoReq) String() string { return proto.CompactTextString(m) } -func (*SingleDelegationInfoReq) ProtoMessage() {} -func (*SingleDelegationInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{4} -} -func (m *SingleDelegationInfoReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SingleDelegationInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SingleDelegationInfoReq.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 *SingleDelegationInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_SingleDelegationInfoReq.Merge(m, src) -} -func (m *SingleDelegationInfoReq) XXX_Size() int { - return m.Size() -} -func (m *SingleDelegationInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_SingleDelegationInfoReq.DiscardUnknown(m) -} - -var xxx_messageInfo_SingleDelegationInfoReq proto.InternalMessageInfo - -func (m *SingleDelegationInfoReq) GetStakerID() string { - if m != nil { - return m.StakerID - } - return "" -} - -func (m *SingleDelegationInfoReq) GetOperatorAddr() string { - if m != nil { - return m.OperatorAddr - } - return "" -} - -func (m *SingleDelegationInfoReq) GetAssetID() string { - if m != nil { - return m.AssetID - } - return "" -} - -// UndelegationHoldCountReq is the request to obtain the undelegation hold count. -type UndelegationHoldCountReq struct { - // record_key is the record key of the undelegation record. - RecordKey string `protobuf:"bytes,1,opt,name=record_key,json=recordKey,proto3" json:"record_key,omitempty"` -} - -func (m *UndelegationHoldCountReq) Reset() { *m = UndelegationHoldCountReq{} } -func (m *UndelegationHoldCountReq) String() string { return proto.CompactTextString(m) } -func (*UndelegationHoldCountReq) ProtoMessage() {} -func (*UndelegationHoldCountReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{5} -} -func (m *UndelegationHoldCountReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UndelegationHoldCountReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UndelegationHoldCountReq.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 *UndelegationHoldCountReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_UndelegationHoldCountReq.Merge(m, src) -} -func (m *UndelegationHoldCountReq) XXX_Size() int { - return m.Size() -} -func (m *UndelegationHoldCountReq) XXX_DiscardUnknown() { - xxx_messageInfo_UndelegationHoldCountReq.DiscardUnknown(m) -} - -var xxx_messageInfo_UndelegationHoldCountReq proto.InternalMessageInfo - -func (m *UndelegationHoldCountReq) GetRecordKey() string { - if m != nil { - return m.RecordKey - } - return "" -} - -// UndelegationHoldCountResponse is the response for the undelegation hold count. -type UndelegationHoldCountResponse struct { - // hold_count is the number of undelegations that are on hold. - HoldCount uint64 `protobuf:"varint,1,opt,name=hold_count,json=holdCount,proto3" json:"hold_count,omitempty"` -} - -func (m *UndelegationHoldCountResponse) Reset() { *m = UndelegationHoldCountResponse{} } -func (m *UndelegationHoldCountResponse) String() string { return proto.CompactTextString(m) } -func (*UndelegationHoldCountResponse) ProtoMessage() {} -func (*UndelegationHoldCountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{6} -} -func (m *UndelegationHoldCountResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UndelegationHoldCountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UndelegationHoldCountResponse.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 *UndelegationHoldCountResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_UndelegationHoldCountResponse.Merge(m, src) -} -func (m *UndelegationHoldCountResponse) XXX_Size() int { - return m.Size() -} -func (m *UndelegationHoldCountResponse) XXX_DiscardUnknown() { - xxx_messageInfo_UndelegationHoldCountResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_UndelegationHoldCountResponse proto.InternalMessageInfo - -func (m *UndelegationHoldCountResponse) GetHoldCount() uint64 { - if m != nil { - return m.HoldCount - } - return 0 -} - -func init() { - proto.RegisterType((*DelegationInfoReq)(nil), "exocore.delegation.v1.DelegationInfoReq") - proto.RegisterType((*StakerList)(nil), "exocore.delegation.v1.StakerList") - proto.RegisterType((*DelegationAmounts)(nil), "exocore.delegation.v1.DelegationAmounts") - proto.RegisterType((*QueryDelegationInfoResponse)(nil), "exocore.delegation.v1.QueryDelegationInfoResponse") - proto.RegisterMapType((map[string]*DelegationAmounts)(nil), "exocore.delegation.v1.QueryDelegationInfoResponse.DelegationInfosEntry") - proto.RegisterType((*SingleDelegationInfoReq)(nil), "exocore.delegation.v1.SingleDelegationInfoReq") - proto.RegisterType((*UndelegationHoldCountReq)(nil), "exocore.delegation.v1.UndelegationHoldCountReq") - proto.RegisterType((*UndelegationHoldCountResponse)(nil), "exocore.delegation.v1.UndelegationHoldCountResponse") -} - -func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } - -var fileDescriptor_aab345e1cf20490c = []byte{ - // 727 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcf, 0x4f, 0x13, 0x4f, - 0x1c, 0xed, 0xf0, 0xe3, 0x0b, 0x1d, 0xf8, 0x46, 0x1c, 0x50, 0x4b, 0x91, 0x16, 0xf7, 0x40, 0x2a, - 0x09, 0xbb, 0x52, 0x31, 0x51, 0x23, 0x44, 0xb0, 0x04, 0x1b, 0x0c, 0x89, 0xdb, 0x78, 0xf1, 0xb2, - 0x59, 0xba, 0xc3, 0x76, 0xd3, 0xed, 0x4c, 0x99, 0x99, 0x16, 0x1a, 0xe3, 0xc5, 0x93, 0x47, 0x13, - 0xff, 0x0b, 0xbd, 0x78, 0xe0, 0xec, 0x99, 0x23, 0xc1, 0x8b, 0xf1, 0xd0, 0x98, 0x62, 0xe2, 0xff, - 0xe0, 0x45, 0xb3, 0xbb, 0x03, 0xdd, 0xe2, 0x2e, 0x4a, 0x3c, 0x75, 0xe7, 0xf3, 0xf3, 0xcd, 0x7b, - 0x2f, 0x53, 0x78, 0x03, 0xef, 0xd1, 0x32, 0x65, 0x58, 0xb3, 0xb0, 0x8b, 0x6d, 0x53, 0x38, 0x94, - 0x68, 0xcd, 0x05, 0x6d, 0xa7, 0x81, 0x59, 0x4b, 0xad, 0x33, 0x2a, 0x28, 0xba, 0x22, 0x4b, 0xd4, - 0x6e, 0x89, 0xda, 0x5c, 0x48, 0x4f, 0x95, 0x29, 0xaf, 0x51, 0x1e, 0x94, 0x9e, 0xe9, 0x49, 0x4f, - 0x06, 0x49, 0xc3, 0x3f, 0x69, 0xc1, 0x41, 0xa6, 0x26, 0x6c, 0x6a, 0xd3, 0x20, 0xee, 0x7d, 0xc9, - 0xe8, 0x75, 0x9b, 0x52, 0xdb, 0xc5, 0x9a, 0x59, 0x77, 0x34, 0x93, 0x10, 0x2a, 0xfc, 0x3d, 0xb2, - 0x47, 0xd9, 0x86, 0x97, 0x0b, 0xa7, 0xcb, 0x8b, 0x64, 0x9b, 0xea, 0x78, 0x07, 0xdd, 0x84, 0x49, - 0x2e, 0xcc, 0x2a, 0x66, 0x86, 0x63, 0xa5, 0xc0, 0x0c, 0xc8, 0x25, 0x57, 0x47, 0x3b, 0xed, 0xec, - 0x70, 0xc9, 0x0f, 0x16, 0x0b, 0xfa, 0x70, 0x90, 0x2e, 0x5a, 0x68, 0x16, 0x0e, 0x9b, 0x9c, 0x63, - 0xe1, 0x55, 0xf6, 0xf9, 0x95, 0x23, 0x9d, 0x76, 0x76, 0x68, 0xc5, 0x8b, 0x15, 0x0b, 0xfa, 0x90, - 0x9f, 0x2c, 0x5a, 0xca, 0x2c, 0x84, 0x41, 0xf7, 0x13, 0x87, 0x0b, 0x94, 0x82, 0x43, 0xc1, 0x04, - 0x9e, 0x02, 0x33, 0xfd, 0xb9, 0xa4, 0x7e, 0x72, 0x54, 0x7e, 0x80, 0x30, 0xa0, 0x95, 0x1a, 0x6d, - 0x10, 0xc1, 0x51, 0x0d, 0x8e, 0x37, 0x88, 0x24, 0xc9, 0xdc,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1, 0xbd, 0xc4, 0x43, 0xb4, 0x7c, 0xde, 0x25, 0x22, - 0xe7, 0x68, 0x2f, 0xba, 0x86, 0x7c, 0xb9, 0xba, 0x79, 0xd0, 0xc9, 0x80, 0xc3, 0x4e, 0x06, 0x7c, - 0xed, 0x64, 0xc0, 0x9b, 0xe3, 0x4c, 0xe2, 0xf0, 0x38, 0x93, 0xf8, 0x7c, 0x9c, 0x49, 0x3c, 0x5f, - 0x0c, 0xbd, 0x69, 0x6b, 0xc1, 0x8e, 0x4d, 0x2c, 0x76, 0x29, 0xab, 0x9e, 0xae, 0xdc, 0x0b, 0x2f, - 0xf5, 0x5f, 0xb9, 0xad, 0xff, 0xfc, 0xff, 0x93, 0xdb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd6, - 0xd3, 0x4d, 0x1e, 0xf7, 0x06, 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 { - // DelegationInfo queries the delegation information for {stakerID, assetID}. - QueryDelegationInfo(ctx context.Context, in *DelegationInfoReq, opts ...grpc.CallOption) (*QueryDelegationInfoResponse, error) - // SingleDelegationInfo queries the single delegation information for - // {chain, staker, asset, operator}. - QuerySingleDelegationInfo(ctx context.Context, in *SingleDelegationInfoReq, opts ...grpc.CallOption) (*DelegationAmounts, error) - // QueryUndelegationHoldCount queries the undelegation hold count. - QueryUndelegationHoldCount(ctx context.Context, in *UndelegationHoldCountReq, opts ...grpc.CallOption) (*UndelegationHoldCountResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) QueryDelegationInfo(ctx context.Context, in *DelegationInfoReq, opts ...grpc.CallOption) (*QueryDelegationInfoResponse, error) { - out := new(QueryDelegationInfoResponse) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QueryDelegationInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QuerySingleDelegationInfo(ctx context.Context, in *SingleDelegationInfoReq, opts ...grpc.CallOption) (*DelegationAmounts, error) { - out := new(DelegationAmounts) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QuerySingleDelegationInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QueryUndelegationHoldCount(ctx context.Context, in *UndelegationHoldCountReq, opts ...grpc.CallOption) (*UndelegationHoldCountResponse, error) { - out := new(UndelegationHoldCountResponse) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QueryUndelegationHoldCount", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // DelegationInfo queries the delegation information for {stakerID, assetID}. - QueryDelegationInfo(context.Context, *DelegationInfoReq) (*QueryDelegationInfoResponse, error) - // SingleDelegationInfo queries the single delegation information for - // {chain, staker, asset, operator}. - QuerySingleDelegationInfo(context.Context, *SingleDelegationInfoReq) (*DelegationAmounts, error) - // QueryUndelegationHoldCount queries the undelegation hold count. - QueryUndelegationHoldCount(context.Context, *UndelegationHoldCountReq) (*UndelegationHoldCountResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) QueryDelegationInfo(ctx context.Context, req *DelegationInfoReq) (*QueryDelegationInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryDelegationInfo not implemented") -} -func (*UnimplementedQueryServer) QuerySingleDelegationInfo(ctx context.Context, req *SingleDelegationInfoReq) (*DelegationAmounts, error) { - return nil, status.Errorf(codes.Unimplemented, "method QuerySingleDelegationInfo not implemented") -} -func (*UnimplementedQueryServer) QueryUndelegationHoldCount(ctx context.Context, req *UndelegationHoldCountReq) (*UndelegationHoldCountResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryUndelegationHoldCount not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_QueryDelegationInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DelegationInfoReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryDelegationInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QueryDelegationInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryDelegationInfo(ctx, req.(*DelegationInfoReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QuerySingleDelegationInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SingleDelegationInfoReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QuerySingleDelegationInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QuerySingleDelegationInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QuerySingleDelegationInfo(ctx, req.(*SingleDelegationInfoReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryUndelegationHoldCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UndelegationHoldCountReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryUndelegationHoldCount(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QueryUndelegationHoldCount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryUndelegationHoldCount(ctx, req.(*UndelegationHoldCountReq)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "exocore.delegation.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "QueryDelegationInfo", - Handler: _Query_QueryDelegationInfo_Handler, - }, - { - MethodName: "QuerySingleDelegationInfo", - Handler: _Query_QuerySingleDelegationInfo_Handler, - }, - { - MethodName: "QueryUndelegationHoldCount", - Handler: _Query_QueryUndelegationHoldCount_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "exocore/delegation/v1/query.proto", -} - -func (m *DelegationInfoReq) 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 *DelegationInfoReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AssetID) > 0 { - i -= len(m.AssetID) - copy(dAtA[i:], m.AssetID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.AssetID))) - i-- - dAtA[i] = 0x12 - } - if len(m.StakerID) > 0 { - i -= len(m.StakerID) - copy(dAtA[i:], m.StakerID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *StakerList) 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 *StakerList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakerList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Stakers) > 0 { - for iNdEx := len(m.Stakers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Stakers[iNdEx]) - copy(dAtA[i:], m.Stakers[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Stakers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *DelegationAmounts) 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 *DelegationAmounts) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.WaitUndelegationAmount.Size() - i -= size - if _, err := m.WaitUndelegationAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.UndelegatableShare.Size() - i -= size - if _, err := m.UndelegatableShare.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryDelegationInfoResponse) 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 *QueryDelegationInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDelegationInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DelegationInfos) > 0 { - for k := range m.DelegationInfos { - v := m.DelegationInfos[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SingleDelegationInfoReq) 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 *SingleDelegationInfoReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SingleDelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AssetID) > 0 { - i -= len(m.AssetID) - copy(dAtA[i:], m.AssetID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.AssetID))) - i-- - dAtA[i] = 0x1a - } - if len(m.OperatorAddr) > 0 { - i -= len(m.OperatorAddr) - copy(dAtA[i:], m.OperatorAddr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.OperatorAddr))) - i-- - dAtA[i] = 0x12 - } - if len(m.StakerID) > 0 { - i -= len(m.StakerID) - copy(dAtA[i:], m.StakerID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UndelegationHoldCountReq) 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 *UndelegationHoldCountReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UndelegationHoldCountReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.RecordKey) > 0 { - i -= len(m.RecordKey) - copy(dAtA[i:], m.RecordKey) - i = encodeVarintQuery(dAtA, i, uint64(len(m.RecordKey))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UndelegationHoldCountResponse) 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 *UndelegationHoldCountResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UndelegationHoldCountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.HoldCount != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.HoldCount)) - 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 *DelegationInfoReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakerID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.AssetID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *StakerList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Stakers) > 0 { - for _, s := range m.Stakers { - l = len(s) - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *DelegationAmounts) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.UndelegatableShare.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.WaitUndelegationAmount.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryDelegationInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DelegationInfos) > 0 { - for k, v := range m.DelegationInfos { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) - } - } - return n -} - -func (m *SingleDelegationInfoReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakerID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.OperatorAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.AssetID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *UndelegationHoldCountReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RecordKey) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *UndelegationHoldCountResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.HoldCount != 0 { - n += 1 + sovQuery(uint64(m.HoldCount)) - } - 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 *DelegationInfoReq) 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: DelegationInfoReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DelegationInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerID", 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.StakerID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetID", 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.AssetID = 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 *StakerList) 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: StakerList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakerList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stakers", 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.Stakers = append(m.Stakers, 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 *DelegationAmounts) 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: DelegationAmounts: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DelegationAmounts: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UndelegatableShare", 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 - } - if err := m.UndelegatableShare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUndelegationAmount", 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 - } - if err := m.WaitUndelegationAmount.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 *QueryDelegationInfoResponse) 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: QueryDelegationInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDelegationInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegationInfos", 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 m.DelegationInfos == nil { - m.DelegationInfos = make(map[string]*DelegationAmounts) - } - var mapkey string - var mapvalue *DelegationAmounts - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &DelegationAmounts{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.DelegationInfos[mapkey] = mapvalue - 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 *SingleDelegationInfoReq) 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: SingleDelegationInfoReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SingleDelegationInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerID", 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.StakerID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddr", 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.OperatorAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetID", 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.AssetID = 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 *UndelegationHoldCountReq) 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: UndelegationHoldCountReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UndelegationHoldCountReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RecordKey", 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.RecordKey = 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 *UndelegationHoldCountResponse) 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: UndelegationHoldCountResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UndelegationHoldCountResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field HoldCount", wireType) - } - m.HoldCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.HoldCount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/delegation/types/types/query.pb.gw.go b/x/delegation/types/types/query.pb.gw.go deleted file mode 100644 index dac6b2f70..000000000 --- a/x/delegation/types/types/query.pb.gw.go +++ /dev/null @@ -1,355 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: exocore/delegation/v1/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_QueryDelegationInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QueryDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DelegationInfoReq - 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_QueryDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryDelegationInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DelegationInfoReq - 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_QueryDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryDelegationInfo(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QuerySingleDelegationInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QuerySingleDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq SingleDelegationInfoReq - 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_QuerySingleDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QuerySingleDelegationInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QuerySingleDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq SingleDelegationInfoReq - 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_QuerySingleDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QuerySingleDelegationInfo(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryUndelegationHoldCount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UndelegationHoldCountReq - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["record_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "record_key") - } - - protoReq.RecordKey, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "record_key", err) - } - - msg, err := client.QueryUndelegationHoldCount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryUndelegationHoldCount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UndelegationHoldCountReq - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["record_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "record_key") - } - - protoReq.RecordKey, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "record_key", err) - } - - msg, err := server.QueryUndelegationHoldCount(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_QueryDelegationInfo_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_QueryDelegationInfo_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_QueryDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QuerySingleDelegationInfo_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_QuerySingleDelegationInfo_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_QuerySingleDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryUndelegationHoldCount_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_QueryUndelegationHoldCount_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_QueryUndelegationHoldCount_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_QueryDelegationInfo_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_QueryDelegationInfo_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_QueryDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QuerySingleDelegationInfo_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_QuerySingleDelegationInfo_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_QuerySingleDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryUndelegationHoldCount_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_QueryUndelegationHoldCount_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_QueryUndelegationHoldCount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_QueryDelegationInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetDelegationInfo"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QuerySingleDelegationInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "QuerySingleDelegationInfo"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryUndelegationHoldCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"exocore", "delegation", "v1", "QueryUndelegationHoldCount", "record_key"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_QueryDelegationInfo_0 = runtime.ForwardResponseMessage - - forward_Query_QuerySingleDelegationInfo_0 = runtime.ForwardResponseMessage - - forward_Query_QueryUndelegationHoldCount_0 = runtime.ForwardResponseMessage -) diff --git a/x/dogfood/keeper/genesis.go b/x/dogfood/keeper/genesis.go index b7ccdff36..8a229db47 100644 --- a/x/dogfood/keeper/genesis.go +++ b/x/dogfood/keeper/genesis.go @@ -58,13 +58,13 @@ func (k Keeper) InitGenesis( // wrappedKey can never be nil wrappedKey := operatortypes.NewWrappedConsKeyFromHex(val.PublicKey) // #nosec G703 // already validated - operatorAddr, _ := sdk.AccAddressFromBech32(val.OperatorAccAddr) - // OptIntoAVS checks that the operator exists and will error if it does not. - if err := k.operatorKeeper.OptInWithConsKey( - ctx, operatorAddr, avsAddrString, wrappedKey, - ); err != nil { - panic(fmt.Errorf("failed to opt into avs: %s", err)) - } + /* operatorAddr, _ := sdk.AccAddressFromBech32(val.OperatorAccAddr) + // OptIntoAVS checks that the operator exists and will error if it does not. + if err := k.operatorKeeper.OptInWithConsKey( + ctx, operatorAddr, avsAddrString, wrappedKey, + ); err != nil { + panic(fmt.Errorf("failed to opt into avs: %s", err)) + }*/ out = append(out, abci.ValidatorUpdate{ PubKey: *wrappedKey.ToTmProtoKey(), Power: val.Power, @@ -127,10 +127,17 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { pubKey, _ := val.ConsPubKey() // #nosec G703 // already validated convKey, _ := cryptocodec.ToTmPubKeyInterface(pubKey) + addr := sdk.GetConsAddress(pubKey) + found, operatorAddr := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr(ctx, avstypes.ChainIDWithoutRevision(ctx.ChainID()), addr) + if !found { + ctx.Logger().Error("Operator address not found for validator", "consAddr", addr.String()) + return true + } validators = append(validators, types.GenesisValidator{ - PublicKey: hexutil.Encode(convKey.Bytes()), - Power: val.GetConsensusPower(sdk.DefaultPowerReduction), + PublicKey: hexutil.Encode(convKey.Bytes()), + Power: val.GetConsensusPower(sdk.DefaultPowerReduction), + OperatorAccAddr: operatorAddr.String(), }, ) return false /* stop */ diff --git a/x/dogfood/keeper/impl_epochs_hooks.go b/x/dogfood/keeper/impl_epochs_hooks.go index d1490fb65..cff81133c 100644 --- a/x/dogfood/keeper/impl_epochs_hooks.go +++ b/x/dogfood/keeper/impl_epochs_hooks.go @@ -34,6 +34,7 @@ func (wrapper EpochsHooksWrapper) AfterEpochEnd( // applied within this block. however, for clarity, it is highlighted that unbonding // takes N epochs + 1 block to complete. wrapper.keeper.MarkEpochEnd(ctx) + ctx.Logger().Info("mark epoch end", "height", ctx.BlockHeight(), "identifier", identifier, "epoch", epoch) // find the opt outs that mature when this epoch ends, and move them to pending. optOuts := wrapper.keeper.GetOptOutsToFinish(ctx, epoch) wrapper.keeper.SetPendingOptOuts(ctx, types.AccountAddresses{List: optOuts}) diff --git a/x/dogfood/keeper/impl_epochs_hooks_test.go b/x/dogfood/keeper/impl_epochs_hooks_test.go index a7c4b6b79..532f06c1e 100644 --- a/x/dogfood/keeper/impl_epochs_hooks_test.go +++ b/x/dogfood/keeper/impl_epochs_hooks_test.go @@ -81,7 +81,7 @@ func (suite *KeeperTestSuite) TestSameEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -92,7 +92,7 @@ func (suite *KeeperTestSuite) TestSameEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) return err @@ -102,7 +102,7 @@ func (suite *KeeperTestSuite) TestSameEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.SetConsKeyReq{ Address: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: newKey.ToJSON(), }, ) @@ -261,7 +261,7 @@ func (suite *KeeperTestSuite) TestDifferentEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -272,7 +272,7 @@ func (suite *KeeperTestSuite) TestDifferentEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) return err @@ -282,7 +282,7 @@ func (suite *KeeperTestSuite) TestDifferentEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.SetConsKeyReq{ Address: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: newKey.ToJSON(), }, ) diff --git a/x/dogfood/keeper/msg_server.go b/x/dogfood/keeper/msg_server.go index ea1002b69..f4ced9f73 100644 --- a/x/dogfood/keeper/msg_server.go +++ b/x/dogfood/keeper/msg_server.go @@ -116,7 +116,7 @@ func (k Keeper) UpdateParams( } err := k.avsKeeper.UpdateAVSInfo(c, &avstypes.AVSRegisterOrDeregisterParams{ AvsName: c.ChainID(), - AvsAddress: avsAddr.String(), + AvsAddress: avsAddr, AssetID: nextParams.AssetIDs, UnbondingPeriod: uint64(nextParams.EpochsUntilUnbonded), MinSelfDelegation: nextParams.MinSelfDelegation.Uint64(), diff --git a/x/dogfood/keeper/opt_out_test.go b/x/dogfood/keeper/opt_out_test.go index 93fa4edb5..be78ced50 100644 --- a/x/dogfood/keeper/opt_out_test.go +++ b/x/dogfood/keeper/opt_out_test.go @@ -34,7 +34,7 @@ func (suite *KeeperTestSuite) TestBasicOperations() { key := utiltx.GenerateConsensusKey() _, err = suite.OperatorMsgServer.OptIntoAVS(sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: key.ToJSON(), }) suite.NoError(err) @@ -227,7 +227,7 @@ func (suite *KeeperTestSuite) TestBasicOperations() { &operatortypes.SetConsKeyReq{ Address: operatorAddressString, PublicKeyJSON: newKey.ToJSON(), - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) suite.NoError(err) @@ -287,7 +287,7 @@ func (suite *KeeperTestSuite) TestBasicOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) suite.NoError(err) diff --git a/x/dogfood/keeper/unbonding_test.go b/x/dogfood/keeper/unbonding_test.go index a9e76d10e..d4a590e03 100644 --- a/x/dogfood/keeper/unbonding_test.go +++ b/x/dogfood/keeper/unbonding_test.go @@ -73,7 +73,7 @@ func (suite *KeeperTestSuite) TestUndelegations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -114,7 +114,7 @@ func (suite *KeeperTestSuite) TestUndelegations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) suite.NoError(err) @@ -234,7 +234,7 @@ func (suite *KeeperTestSuite) TestUndelegationEdgeCases() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -285,7 +285,7 @@ func (suite *KeeperTestSuite) TestUndelegationEdgeCases() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.SetConsKeyReq{ Address: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: newKey.ToJSON(), }, ) diff --git a/x/dogfood/types/expected_keepers.go b/x/dogfood/types/expected_keepers.go index 41c6886cd..f97bd7e29 100644 --- a/x/dogfood/types/expected_keepers.go +++ b/x/dogfood/types/expected_keepers.go @@ -93,6 +93,6 @@ type AssetsKeeper interface { type AVSKeeper interface { RegisterAVSWithChainID(sdk.Context, *avstypes.AVSRegisterOrDeregisterParams) (common.Address, error) - IsAVSByChainID(ctx sdk.Context, chainID string) (bool, common.Address) + IsAVSByChainID(ctx sdk.Context, chainID string) (bool, string) UpdateAVSInfo(ctx sdk.Context, params *avstypes.AVSRegisterOrDeregisterParams) error } diff --git a/x/dogfood/types/genesis.go b/x/dogfood/types/genesis.go index e6dba4e06..79056b074 100644 --- a/x/dogfood/types/genesis.go +++ b/x/dogfood/types/genesis.go @@ -271,13 +271,5 @@ func (gs GenesisState) Validate() error { ) } - if !gs.LastTotalPower.Equal(math.NewInt(totalPower)) { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "last total power mismatch %s, expected %d", - gs.LastTotalPower, totalPower, - ) - } - return nil } diff --git a/x/dogfood/types/genesis.pb.go b/x/dogfood/types/genesis.pb.go index 537536141..584aebea2 100644 --- a/x/dogfood/types/genesis.pb.go +++ b/x/dogfood/types/genesis.pb.go @@ -33,7 +33,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // params refers to the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - // val_set is the initial validator set. it onyl represents the active + // val_set is the initial validator set. it only represents the active // validators. ValSet []GenesisValidator `protobuf:"bytes,2,rep,name=val_set,json=valSet,proto3" json:"val_set"` // opt_out_expiries is a list of (future) epochs at the end of which the diff --git a/x/operator/client/cli/tx.go b/x/operator/client/cli/tx.go index 1ad4aaef3..967e2bfb7 100644 --- a/x/operator/client/cli/tx.go +++ b/x/operator/client/cli/tx.go @@ -19,6 +19,7 @@ import ( ) const ( + FlagEarningAddr = "earning-addr" FlagApproveAddr = "approve-addr" FlagMetaInfo = "meta-info" FlagClientChainData = "client-chain-data" @@ -73,10 +74,12 @@ func CmdRegisterOperator() *cobra.Command { }, } - // EarningsAddr is the same as the sender's address, since the operator registration must be - // done by the operators themselves. - f := cmd.Flags() + // EarningAddr may be different from the sender's address. + f.String( + FlagEarningAddr, "", "The address which is used to receive the earning reward in the Exocore chain. "+ + "If not provided, it will default to the sender's address.", + ) // ApproveAddr may be different from the sender's address. f.String( FlagApproveAddr, "", "The address which is used to approve the delegations made to "+ @@ -112,11 +115,16 @@ func newBuildRegisterOperatorMsg( if approveAddr == "" { approveAddr = sender.String() } + // #nosec G703 // this only errors if the flag isn't defined. + earningAddr, _ := fs.GetString(FlagEarningAddr) + if earningAddr == "" { + earningAddr = sender.String() + } metaInfo, _ := fs.GetString(FlagMetaInfo) msg := &types.RegisterOperatorReq{ FromAddress: sender.String(), Info: &types.OperatorInfo{ - EarningsAddr: sender.String(), + EarningsAddr: earningAddr, ApproveAddr: approveAddr, OperatorMetaInfo: metaInfo, }, diff --git a/x/operator/keeper/consensus_keys.go b/x/operator/keeper/consensus_keys.go index fd24600af..6e164f037 100644 --- a/x/operator/keeper/consensus_keys.go +++ b/x/operator/keeper/consensus_keys.go @@ -3,6 +3,11 @@ package keeper import ( "fmt" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" + + "github.com/cosmos/cosmos-sdk/store/prefix" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" @@ -293,7 +298,6 @@ func (k Keeper) CompleteOperatorKeyRemovalForChainID( func (k *Keeper) GetOperatorsForChainID( ctx sdk.Context, chainID string, ) ([]sdk.AccAddress, []types.WrappedConsKey) { - k.Logger(ctx).Info("GetOperatorsForChainID", "chainID", chainID) if isAvs, _ := k.avsKeeper.IsAVSByChainID(ctx, chainID); !isAvs { k.Logger(ctx).Info("GetOperatorsForChainID the chainID is not supported by AVS", "chainID", chainID) return nil, nil @@ -330,13 +334,12 @@ func (k *Keeper) GetOperatorsForChainID( func (k Keeper) GetActiveOperatorsForChainID( ctx sdk.Context, chainID string, ) ([]sdk.AccAddress, []types.WrappedConsKey) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) + isAvs, avsAddrString := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { k.Logger(ctx).Error("GetActiveOperatorsForChainID the chainID is not supported by AVS", "chainID", chainID) return nil, nil } operatorsAddr, pks := k.GetOperatorsForChainID(ctx, chainID) - avsAddrString := avsAddr.String() activeOperator := make([]sdk.AccAddress, 0) activePks := make([]types.WrappedConsKey, 0) // check if the operator is active @@ -356,7 +359,7 @@ func (k Keeper) GetActiveOperatorsForChainID( func (k Keeper) ValidatorByConsAddrForChainID( ctx sdk.Context, consAddr sdk.ConsAddress, chainID string, ) (stakingtypes.Validator, bool) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) + isAvs, avsAddrStr := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { ctx.Logger().Error("ValidatorByConsAddrForChainID the chainID is not supported by AVS", "chainID", chainID) return stakingtypes.Validator{}, false @@ -389,9 +392,9 @@ func (k Keeper) ValidatorByConsAddrForChainID( val.Jailed = k.IsOperatorJailedForChainID(ctx, consAddr, chainID) // set the tokens, delegated shares and minimum self delegation for unjail - minSelfDelegation, err := k.avsKeeper.GetAVSMinimumSelfDelegation(ctx, avsAddr.String()) + minSelfDelegation, err := k.avsKeeper.GetAVSMinimumSelfDelegation(ctx, avsAddrStr) if err != nil { - ctx.Logger().Error("ValidatorByConsAddrForChainID get minimum self delegation for AVS error", "avsAddr", avsAddr.String(), "err", err) + ctx.Logger().Error("ValidatorByConsAddrForChainID get minimum self delegation for AVS error", "avsAddrStr", avsAddrStr, "err", err) return stakingtypes.Validator{}, false } val.MinSelfDelegation = sdk.TokensFromConsensusPower(minSelfDelegation.TruncateInt64(), sdk.DefaultPowerReduction) @@ -438,3 +441,114 @@ func (k Keeper) ClearPreviousConsensusKeys(ctx sdk.Context, chainID string) { store.Delete(iterator.Key()) } } + +func (k *Keeper) SetAllPrevConsKeys(ctx sdk.Context, prevConsKeys []types.PrevConsKey) error { + store := ctx.KVStore(k.storeKey) + for i := range prevConsKeys { + prevKey := prevConsKeys[i] + keys, err := assetstypes.ParseJoinedStoreKey([]byte(prevKey.Key), 2) + if err != nil { + return err + } + chainID := keys[0] + opAccAddr, err := sdk.AccAddressFromBech32(keys[1]) + if err != nil { + return err + } + wrappedKey := types.NewWrappedConsKeyFromHex(prevKey.ConsensusKey) + bz := k.cdc.MustMarshal(wrappedKey.ToTmProtoKey()) + + store.Set(types.KeyForChainIDAndOperatorToPrevConsKey(chainID, opAccAddr), bz) + } + return nil +} + +func (k *Keeper) GetAllPrevConsKeys(ctx sdk.Context) ([]types.PrevConsKey, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.BytePrefixForOperatorAndChainIDToPrevConsKey}) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.PrevConsKey, 0) + for ; iterator.Valid(); iterator.Next() { + var consKey tmprotocrypto.PublicKey + k.cdc.MustUnmarshal(iterator.Value(), &consKey) + chainID, operatorAddr, err := types.ParsePrevConsKey(iterator.Key()) + if err != nil { + return nil, err + } + wrappedConsKey := types.NewWrappedConsKeyFromTmProtoKey(&consKey) + ret = append(ret, types.PrevConsKey{ + Key: string(assetstypes.GetJoinedStoreKey(chainID, operatorAddr.String())), + ConsensusKey: wrappedConsKey.ToHex(), + }) + } + return ret, nil +} + +func (k *Keeper) SetAllOperatorKeyRemovals(ctx sdk.Context, operatorKeyRemoval []types.OperatorKeyRemoval) error { + store := ctx.KVStore(k.storeKey) + for i := range operatorKeyRemoval { + keyRemoval := operatorKeyRemoval[i] + keys, err := assetstypes.ParseJoinedStoreKey([]byte(keyRemoval.Key), 2) + if err != nil { + return err + } + chainID := keys[1] + opAccAddr, err := sdk.AccAddressFromBech32(keys[0]) + if err != nil { + return err + } + store.Set(types.KeyForOperatorKeyRemovalForChainID(opAccAddr, chainID), []byte{}) + } + return nil +} + +func (k *Keeper) GetAllOperatorKeyRemovals(ctx sdk.Context) ([]types.OperatorKeyRemoval, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.BytePrefixForOperatorKeyRemovalForChainID}) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.OperatorKeyRemoval, 0) + for ; iterator.Valid(); iterator.Next() { + operatorAddr, chainID, err := types.ParseKeyForOperatorKeyRemoval(iterator.Key()) + if err != nil { + return nil, err + } + + ret = append(ret, types.OperatorKeyRemoval{ + Key: string(assetstypes.GetJoinedStoreKey(operatorAddr.String(), chainID)), + }) + } + return ret, nil +} + +func (k *Keeper) GetAllOperatorConsKeyRecords(ctx sdk.Context) ([]types.OperatorConsKeyRecord, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.BytePrefixForOperatorAndChainIDToConsKey}) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.OperatorConsKeyRecord, 0) + var previousOperator string + for ; iterator.Valid(); iterator.Next() { + operator, chainID, err := types.ParseKeyForOperatorAndChainIDToConsKey(iterator.Key()) + if err != nil { + return nil, err + } + if previousOperator != operator.String() { + assetsByOperator := types.OperatorConsKeyRecord{ + OperatorAddress: operator.String(), + Chains: make([]types.ChainDetails, 0), + } + ret = append(ret, assetsByOperator) + } + var consKey tmprotocrypto.PublicKey + k.cdc.MustUnmarshal(iterator.Value(), &consKey) + index := len(ret) - 1 + ret[index].Chains = append(ret[index].Chains, types.ChainDetails{ + ChainID: chainID, + ConsensusKey: hexutil.Encode(consKey.GetEd25519()), + }) + previousOperator = operator.String() + } + return ret, nil +} diff --git a/x/operator/keeper/genesis.go b/x/operator/keeper/genesis.go index 7edfaea6e..c0faa6346 100644 --- a/x/operator/keeper/genesis.go +++ b/x/operator/keeper/genesis.go @@ -1,6 +1,7 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/operator/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -9,14 +10,90 @@ import ( func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) []abci.ValidatorUpdate { for i := range state.Operators { op := state.Operators[i] // avoid implicit memory aliasing - if err := k.SetOperatorInfo(ctx, op.EarningsAddr, &op); err != nil { - panic(err) + if op.OperatorInfo.EarningsAddr == "" { + op.OperatorInfo.EarningsAddr = op.OperatorAddress } + if err := k.SetOperatorInfo(ctx, op.OperatorAddress, &op.OperatorInfo); err != nil { + panic(errorsmod.Wrap(err, "failed to set operator info")) + } + } + for _, record := range state.OperatorRecords { + addr := record.OperatorAddress + // #nosec G703 // already validated + operatorAddr, _ := sdk.AccAddressFromBech32(addr) + for _, detail := range record.Chains { + wrappedKey := types.NewWrappedConsKeyFromHex(detail.ConsensusKey) + bz := k.cdc.MustMarshal(wrappedKey.ToTmProtoKey()) + k.setOperatorConsKeyForChainIDUnchecked(ctx, operatorAddr, wrappedKey.ToConsAddr(), detail.ChainID, bz) + } + } + // init the state from the general exporting genesis file + err := k.SetAllOptedInfo(ctx, state.OptStates) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all opted info")) + } + err = k.SetAllOperatorUSDValues(ctx, state.OperatorUSDValues) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all operator USD values")) + } + err = k.SetAllAVSUSDValues(ctx, state.AVSUSDValues) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all AVS USD values")) + } + err = k.SetAllSlashStates(ctx, state.SlashStates) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all slash info")) + } + err = k.SetAllPrevConsKeys(ctx, state.PreConsKeys) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all previous consensus keys")) + } + err = k.SetAllOperatorKeyRemovals(ctx, state.OperatorKeyRemovals) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all key removals for operators")) } return []abci.ValidatorUpdate{} } -func (Keeper) ExportGenesis(sdk.Context) *types.GenesisState { - // TODO - return types.DefaultGenesis() +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + res := types.GenesisState{} + var err error + res.Operators = k.AllOperators(ctx) + + res.OperatorRecords, err = k.GetAllOperatorConsKeyRecords(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all consensus keys for operators").Error()) + } + + res.OptStates, err = k.GetAllOptedInfo(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all opted info").Error()) + } + + res.AVSUSDValues, err = k.GetAllAVSUSDValues(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all AVS USD values").Error()) + } + + res.OperatorUSDValues, err = k.GetAllOperatorUSDValues(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all operator USD values").Error()) + } + + res.SlashStates, err = k.GetAllSlashStates(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all slashing info").Error()) + } + + res.PreConsKeys, err = k.GetAllPrevConsKeys(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all previous consensus keys").Error()) + } + + res.OperatorKeyRemovals, err = k.GetAllOperatorKeyRemovals(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all key removals for operators").Error()) + } + + return &res } diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index bf0c0a0c9..da67b0151 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -6,8 +6,6 @@ import ( sdkmath "cosmossdk.io/math" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ExocoreNetwork/exocore/x/assets/types" - operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -15,9 +13,8 @@ import ( ) type Keeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec - historicalCtx types.CreateQueryContext + storeKey storetypes.StoreKey + cdc codec.BinaryCodec // other keepers assetsKeeper operatortypes.AssetsKeeper delegationKeeper operatortypes.DelegationKeeper @@ -31,7 +28,6 @@ type Keeper struct { func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - historicalCtx types.CreateQueryContext, assetsKeeper operatortypes.AssetsKeeper, delegationKeeper operatortypes.DelegationKeeper, oracleKeeper operatortypes.OracleKeeper, @@ -41,7 +37,6 @@ func NewKeeper( return Keeper{ storeKey: storeKey, cdc: cdc, - historicalCtx: historicalCtx, assetsKeeper: assetsKeeper, delegationKeeper: delegationKeeper, oracleKeeper: oracleKeeper, diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 5b7990d07..55361bdce 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -21,15 +21,11 @@ import ( func (k *Keeper) SetOperatorInfo( ctx sdk.Context, addr string, info *operatortypes.OperatorInfo, ) (err error) { - // the operator's `addr` must match the earnings address. - if addr != info.EarningsAddr { - return errorsmod.Wrap( - operatortypes.ErrParameterInvalid, - "SetOperatorInfo: earnings address is not equal to the operator address", - ) - } // #nosec G703 // already validated in `ValidateBasic` - opAccAddr, _ := sdk.AccAddressFromBech32(info.EarningsAddr) + opAccAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return errorsmod.Wrap(err, "SetOperatorInfo: error occurred when parse acc address from Bech32") + } // if already registered, this request should go to EditOperator. if k.IsOperator(ctx, opAccAddr) { return errorsmod.Wrap( @@ -79,16 +75,21 @@ func (k *Keeper) OperatorInfo(ctx sdk.Context, addr string) (info *operatortypes return &ret, nil } -// AllOperators return the address list of all operators -func (k *Keeper) AllOperators(ctx sdk.Context) []string { +// AllOperators return the list of all operators' detailed information +func (k *Keeper) AllOperators(ctx sdk.Context) []operatortypes.OperatorDetail { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() - ret := make([]string, 0) + ret := make([]operatortypes.OperatorDetail, 0) for ; iterator.Valid(); iterator.Next() { - accAddr := sdk.AccAddress(iterator.Key()) - ret = append(ret, accAddr.String()) + var operatorInfo operatortypes.OperatorInfo + operatorAddr := sdk.AccAddress(iterator.Key()) + k.cdc.MustUnmarshal(iterator.Value(), &operatorInfo) + ret = append(ret, operatortypes.OperatorDetail{ + OperatorAddress: operatorAddr.String(), + OperatorInfo: operatorInfo, + }) } return ret } @@ -144,7 +145,7 @@ func (k *Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (in infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) value := store.Get(infoKey) if value == nil { - return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: key is %s", opAccAddr)) + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: operator is %s, avs address is %s", opAccAddr, avsAddr)) } ret := operatortypes.OptedInfo{} @@ -194,6 +195,33 @@ func (k *Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) return avsList, nil } +func (k *Keeper) SetAllOptedInfo(ctx sdk.Context, optedStates []operatortypes.OptedState) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) + for i := range optedStates { + state := optedStates[i] + bz := k.cdc.MustMarshal(&state.OptInfo) + store.Set([]byte(state.Key), bz) + } + return nil +} + +func (k *Keeper) GetAllOptedInfo(ctx sdk.Context) ([]operatortypes.OptedState, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.OptedState, 0) + for ; iterator.Valid(); iterator.Next() { + var optedInfo operatortypes.OptedInfo + k.cdc.MustUnmarshal(iterator.Value(), &optedInfo) + ret = append(ret, operatortypes.OptedState{ + Key: string(iterator.Key()), + OptInfo: optedInfo, + }) + } + return ret, nil +} + func (k *Keeper) GetOptedInOperatorListByAVS(ctx sdk.Context, avsAddr string) ([]string, error) { // get all opted-in info store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index bbf047312..8570181a6 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -1,8 +1,12 @@ package keeper_test import ( + "fmt" + "cosmossdk.io/math" + operatortype "github.com/ExocoreNetwork/exocore/x/operator/types" + sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -18,6 +22,8 @@ func (suite *OperatorTestSuite) TestOperatorInfo() { }, Commission: stakingtypes.NewCommission(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec()), } + suite.Equal(operatortype.AccAddressLength, len(suite.AccAddress)) + fmt.Println("the acc address length is:", len(suite.AccAddress)) err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), info) suite.NoError(err) @@ -28,16 +34,19 @@ func (suite *OperatorTestSuite) TestOperatorInfo() { func (suite *OperatorTestSuite) TestAllOperators() { suite.prepare() - operators := []string{suite.operatorAddr.String(), suite.AccAddress.String()} - info := &operatortype.OperatorInfo{ - EarningsAddr: suite.AccAddress.String(), + operatorDetail := operatortype.OperatorDetail{ + OperatorAddress: suite.AccAddress.String(), + OperatorInfo: operatortype.OperatorInfo{ + EarningsAddr: suite.AccAddress.String(), + OperatorMetaInfo: "testOperator", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, } - err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), info) + err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), &operatorDetail.OperatorInfo) suite.NoError(err) getOperators := suite.App.OperatorKeeper.AllOperators(suite.Ctx) - suite.Contains(getOperators, operators[0]) - suite.Contains(getOperators, operators[1]) + suite.Contains(getOperators, operatorDetail) } // TODO: enable this test when editing operator is implemented. allow for querying diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 4644b7645..683fd8cef 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -155,3 +155,30 @@ func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator return ret.Amount, nil } + +func (k *Keeper) SetAllSlashStates(ctx sdk.Context, slashStates []operatortypes.OperatorSlashState) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) + for i := range slashStates { + state := slashStates[i] + bz := k.cdc.MustMarshal(&state.Info) + store.Set([]byte(state.Key), bz) + } + return nil +} + +func (k *Keeper) GetAllSlashStates(ctx sdk.Context) ([]operatortypes.OperatorSlashState, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.OperatorSlashState, 0) + for ; iterator.Valid(); iterator.Next() { + var slashInfo operatortypes.OperatorSlashInfo + k.cdc.MustUnmarshal(iterator.Value(), &slashInfo) + ret = append(ret, operatortypes.OperatorSlashState{ + Key: string(iterator.Key()), + Info: slashInfo, + }) + } + return ret, nil +} diff --git a/x/operator/keeper/opt_test.go b/x/operator/keeper/opt_test.go index 1b68e2988..f8dedea1e 100644 --- a/x/operator/keeper/opt_test.go +++ b/x/operator/keeper/opt_test.go @@ -1,7 +1,6 @@ package keeper_test import ( - "fmt" "strings" "time" @@ -123,7 +122,6 @@ func (suite *OperatorTestSuite) CheckState(expectedState *StateForCheck) { optedUSDValues, err := suite.App.OperatorKeeper.GetOperatorOptedUSDValue(suite.Ctx, suite.avsAddr, suite.operatorAddr.String()) if expectedState.AVSOperatorShare.IsNil() { - fmt.Println("the err is:", err) suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { suite.NoError(err) diff --git a/x/operator/keeper/slash.go b/x/operator/keeper/slash.go index e9fb2223c..89cfc6594 100644 --- a/x/operator/keeper/slash.go +++ b/x/operator/keeper/slash.go @@ -1,8 +1,9 @@ package keeper import ( - "fmt" + "strings" + "github.com/ExocoreNetwork/exocore/utils" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common/hexutil" @@ -16,10 +17,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// GetSlashIDForDogfood It use infractionType+'/'+'infractionHeight' as the slashID, because /* the slash */event occurs in dogfood doesn't have a TxID. It isn't submitted through an external transaction. +// GetSlashIDForDogfood It use infractionType+'_'+'infractionHeight' as the slashID, because /* the slash */event occurs in dogfood doesn't have a TxID. It isn't submitted through an external transaction. func GetSlashIDForDogfood(infraction stakingtypes.Infraction, infractionHeight int64) string { // #nosec G701 - return string(assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(uint64(infraction)), hexutil.EncodeUint64(uint64(infractionHeight)))) + return strings.Join([]string{hexutil.EncodeUint64(uint64(infraction)), hexutil.EncodeUint64(uint64(infractionHeight))}, utils.DelimiterForID) } // SlashFromUndelegation executes the slash from an undelegation @@ -44,9 +45,12 @@ func SlashFromUndelegation(undelegation *delegationtype.UndelegationRecord, slas } func (k *Keeper) CheckSlashParameter(ctx sdk.Context, parameter *types.SlashInputInfo) error { + if parameter.SlashProportion.IsNil() || parameter.SlashProportion.IsNegative() { + return errorsmod.Wrapf(types.ErrValueIsNilOrZero, "Invalid SlashProportion; expected non-nil and non-negative, got: %+v", parameter.SlashProportion) + } height := ctx.BlockHeight() if parameter.SlashEventHeight > height { - return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("slashEventHeight:%d,curHeight:%d", parameter.SlashEventHeight, height)) + return errorsmod.Wrapf(types.ErrSlashOccurredHeight, "slashEventHeight:%d,curHeight:%d", parameter.SlashEventHeight, height) } if parameter.IsDogFood { @@ -82,8 +86,8 @@ func (k *Keeper) SlashAssets(ctx sdk.Context, parameter *types.SlashInputInfo) ( executionInfo := &types.SlashExecutionInfo{ SlashProportion: newSlashProportion, SlashValue: slashUSDValue, - SlashUndelegations: make([]*types.SlashFromUndelegation, 0), - SlashAssetsPool: make([]*types.SlashFromAssetsPool, 0), + SlashUndelegations: make([]types.SlashFromUndelegation, 0), + SlashAssetsPool: make([]types.SlashFromAssetsPool, 0), } // slash from the unbonding stakers if parameter.SlashEventHeight < ctx.BlockHeight() { @@ -91,7 +95,7 @@ func (k *Keeper) SlashAssets(ctx sdk.Context, parameter *types.SlashInputInfo) ( opFunc := func(undelegation *delegationtype.UndelegationRecord) error { slashFromUndelegation := SlashFromUndelegation(undelegation, newSlashProportion) if slashFromUndelegation != nil { - executionInfo.SlashUndelegations = append(executionInfo.SlashUndelegations, slashFromUndelegation) + executionInfo.SlashUndelegations = append(executionInfo.SlashUndelegations, *slashFromUndelegation) } return nil } @@ -131,7 +135,7 @@ func (k *Keeper) SlashAssets(ctx sdk.Context, parameter *types.SlashInputInfo) ( state.OperatorShare = sdkmath.LegacyNewDec(0) } state.TotalAmount = remainingAmount - executionInfo.SlashAssetsPool = append(executionInfo.SlashAssetsPool, &types.SlashFromAssetsPool{ + executionInfo.SlashAssetsPool = append(executionInfo.SlashAssetsPool, types.SlashFromAssetsPool{ AssetID: assetID, Amount: slashAmount, }) @@ -181,7 +185,7 @@ func (k Keeper) SlashWithInfractionReason( chainID := avstypes.ChainIDWithoutRevision(ctx.ChainID()) isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { - k.Logger(ctx).Error("the chainID is not supported by AVS", chainID) + k.Logger(ctx).Error("the chainID is not supported by AVS", "chainID", chainID) return sdkmath.NewInt(0) } slashID := GetSlashIDForDogfood(infraction, infractionHeight) @@ -190,14 +194,14 @@ func (k Keeper) SlashWithInfractionReason( Power: power, SlashType: uint32(infraction), Operator: addr, - AVSAddr: avsAddr.Hex(), + AVSAddr: avsAddr, SlashID: slashID, SlashEventHeight: infractionHeight, SlashProportion: slashFactor, } err := k.Slash(ctx, slashParam) if err != nil { - k.Logger(ctx).Error(err.Error(), avsAddr.Hex()) + k.Logger(ctx).Error(err.Error(), avsAddr) return sdkmath.NewInt(0) } // todo: The returned value should be the amount of burned Exo if we considering a slash from the reward @@ -209,7 +213,7 @@ func (k Keeper) SlashWithInfractionReason( func (k Keeper) IsOperatorJailedForChainID(ctx sdk.Context, consAddr sdk.ConsAddress, chainID string) bool { found, operatorAddr := k.GetOperatorAddressForChainIDAndConsAddr(ctx, chainID, consAddr) if !found { - k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", consAddr, chainID) + k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", "consAddr", consAddr, "chainID", chainID) return false } @@ -218,9 +222,9 @@ func (k Keeper) IsOperatorJailedForChainID(ctx sdk.Context, consAddr sdk.ConsAdd k.Logger(ctx).Error("the chainID is not supported by AVS", chainID) return false } - optInfo, err := k.GetOptedInfo(ctx, operatorAddr.String(), avsAddr.Hex()) + optInfo, err := k.GetOptedInfo(ctx, operatorAddr.String(), avsAddr) if err != nil { - k.Logger(ctx).Error(err.Error(), operatorAddr, avsAddr.Hex()) + k.Logger(ctx).Error(err.Error(), operatorAddr, avsAddr) return false } return optInfo.Jailed @@ -229,20 +233,20 @@ func (k Keeper) IsOperatorJailedForChainID(ctx sdk.Context, consAddr sdk.ConsAdd func (k *Keeper) SetJailedState(ctx sdk.Context, consAddr sdk.ConsAddress, chainID string, jailed bool) { found, operatorAddr := k.GetOperatorAddressForChainIDAndConsAddr(ctx, chainID, consAddr) if !found { - k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", consAddr, chainID) + k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", "consAddr", consAddr, "chainID", chainID) return } isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { - k.Logger(ctx).Error("the chainID is not supported by AVS", chainID) + k.Logger(ctx).Error("the chainID is not supported by AVS", "chainID", chainID) return } handleFunc := func(info *types.OptedInfo) { info.Jailed = jailed } - err := k.HandleOptedInfo(ctx, operatorAddr.String(), avsAddr.Hex(), handleFunc) + err := k.HandleOptedInfo(ctx, operatorAddr.String(), avsAddr, handleFunc) if err != nil { k.Logger(ctx).Error(err.Error(), chainID) } diff --git a/x/operator/keeper/slash_test.go b/x/operator/keeper/slash_test.go index 9ec64dcb8..a0576cadc 100644 --- a/x/operator/keeper/slash_test.go +++ b/x/operator/keeper/slash_test.go @@ -23,7 +23,7 @@ func (suite *OperatorTestSuite) TestSlashWithInfractionReason() { suite.prepareDelegation(true, suite.assetAddr, delegationAmount) // opt into the AVS - avsAddr := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())).String() + avsAddr := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())) err := suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, avsAddr) suite.NoError(err) // call the EndBlock to update the voting power @@ -72,11 +72,11 @@ func (suite *OperatorTestSuite) TestSlashWithInfractionReason() { StakerID: suite.stakerID, AssetID: suite.assetID, Amount: newSlashProportion.MulInt(undelegationAmount).TruncateInt(), - }, *slashInfo.ExecutionInfo.SlashUndelegations[0]) + }, slashInfo.ExecutionInfo.SlashUndelegations[0]) suite.Equal(types.SlashFromAssetsPool{ AssetID: suite.assetID, Amount: newSlashProportion.MulInt(delegationRemaining).TruncateInt(), - }, *slashInfo.ExecutionInfo.SlashAssetsPool[0]) + }, slashInfo.ExecutionInfo.SlashAssetsPool[0]) // check the assets state of undelegation and assets pool assetsInfo, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, suite.operatorAddr, suite.assetID) diff --git a/x/operator/keeper/usd_value.go b/x/operator/keeper/usd_value.go index 6a952b793..ee1009948 100644 --- a/x/operator/keeper/usd_value.go +++ b/x/operator/keeper/usd_value.go @@ -22,7 +22,7 @@ import ( // AVSAddr + '/' + operatorAddr -> types.OperatorOptedUSDValue (the total USD share of specified operator and Avs) // This function will be called when some assets supported by Avs are delegated/undelegated or slashed. func (k *Keeper) UpdateOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr string, delta operatortypes.DeltaOperatorUSDInfo) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorUSDValue the operatorAddr is empty") @@ -57,7 +57,7 @@ func (k *Keeper) UpdateOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr s } func (k *Keeper) InitOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorUSDValue the operatorAddr is empty") @@ -82,7 +82,7 @@ func (k *Keeper) InitOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr str // This function will be called when the operator opts out of the AVS, because the USD share // doesn't need to be stored. func (k *Keeper) DeleteOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorUSDValue the operatorAddr is empty") @@ -94,7 +94,7 @@ func (k *Keeper) DeleteOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr s } func (k *Keeper) DeleteAllOperatorsUSDValueForAVS(ctx sdk.Context, avsAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(avsAddr)) defer iterator.Close() @@ -120,7 +120,7 @@ func (k *Keeper) GetOperatorOptedUSDValue(ctx sdk.Context, avsAddr, operatorAddr }, nil } - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var ret operatortypes.OperatorOptedUSDValue var key []byte if operatorAddr == "" { @@ -146,7 +146,7 @@ func (k *Keeper) UpdateAVSUSDValue(ctx sdk.Context, avsAddr string, opAmount sdk if opAmount.IsNil() || opAmount.IsZero() { return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, fmt.Sprintf("UpdateAVSUSDValue the opAmount is:%v", opAmount)) } - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForAVS) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) key := []byte(avsAddr) totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} value := store.Get(key) @@ -168,7 +168,7 @@ func (k *Keeper) SetAVSUSDValue(ctx sdk.Context, avsAddr string, amount sdkmath. if amount.IsNil() { return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, fmt.Sprintf("SetAVSUSDValue the amount is:%v", amount)) } - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForAVS) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) key := []byte(avsAddr) setValue := operatortypes.DecValueField{Amount: amount} bz := k.cdc.MustMarshal(&setValue) @@ -177,7 +177,7 @@ func (k *Keeper) SetAVSUSDValue(ctx sdk.Context, avsAddr string, amount sdkmath. } func (k *Keeper) DeleteAVSUSDValue(ctx sdk.Context, avsAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForAVS) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) key := []byte(avsAddr) store.Delete(key) return nil @@ -189,7 +189,7 @@ func (k *Keeper) DeleteAVSUSDValue(ctx sdk.Context, avsAddr string) error { func (k *Keeper) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore( ctx.KVStore(k.storeKey), - operatortypes.KeyPrefixVotingPowerForAVS, + operatortypes.KeyPrefixUSDValueForAVS, ) var ret operatortypes.DecValueField key := []byte(avsAddr) @@ -205,7 +205,7 @@ func (k *Keeper) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.Legacy // IterateOperatorsForAVS is used to iterate the operators of a specified AVS and do some external operations // `isUpdate` is a flag to indicate whether the change of the state should be set to the store. func (k *Keeper) IterateOperatorsForAVS(ctx sdk.Context, avsAddr string, isUpdate bool, opFunc func(operator string, optedUSDValues *operatortypes.OperatorOptedUSDValue) error) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(avsAddr)) defer iterator.Close() @@ -231,12 +231,11 @@ func (k *Keeper) IterateOperatorsForAVS(ctx sdk.Context, avsAddr string, isUpdat func (k Keeper) GetVotePowerForChainID( ctx sdk.Context, operators []sdk.AccAddress, chainIDWithoutRevision string, ) ([]int64, error) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) + isAvs, avsAddrString := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) if !isAvs { return nil, errorsmod.Wrap(operatortypes.ErrUnknownChainID, fmt.Sprintf("GetVotePowerForChainID: chainIDWithoutRevision is %s", chainIDWithoutRevision)) } ret := make([]int64, 0) - avsAddrString := avsAddr.String() for _, operator := range operators { // this already filters by the required assetIDs optedUSDValues, err := k.GetOperatorOptedUSDValue(ctx, avsAddrString, operator.String()) @@ -255,7 +254,7 @@ func (k *Keeper) GetOperatorAssetValue(ctx sdk.Context, operator sdk.AccAddress, if !isAvs { return 0, errorsmod.Wrap(operatortypes.ErrUnknownChainID, fmt.Sprintf("GetOperatorAssetValue: chainIDWithoutRevision is %s", chainIDWithoutRevision)) } - optedUSDValues, err := k.GetOperatorOptedUSDValue(ctx, operator.String(), avsAddr.String()) + optedUSDValues, err := k.GetOperatorOptedUSDValue(ctx, operator.String(), avsAddr) if err != nil { return 0, err } @@ -263,6 +262,60 @@ func (k *Keeper) GetOperatorAssetValue(ctx sdk.Context, operator sdk.AccAddress, return optedUSDValues.ActiveUSDValue.TruncateInt64(), nil } +func (k *Keeper) SetAllOperatorUSDValues(ctx sdk.Context, usdValues []operatortypes.OperatorUSDValue) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) + for i := range usdValues { + usdValue := usdValues[i] + bz := k.cdc.MustMarshal(&usdValue.OptedUSDValue) + store.Set([]byte(usdValue.Key), bz) + } + return nil +} + +func (k *Keeper) GetAllOperatorUSDValues(ctx sdk.Context) ([]operatortypes.OperatorUSDValue, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.OperatorUSDValue, 0) + for ; iterator.Valid(); iterator.Next() { + var usdValues operatortypes.OperatorOptedUSDValue + k.cdc.MustUnmarshal(iterator.Value(), &usdValues) + ret = append(ret, operatortypes.OperatorUSDValue{ + Key: string(iterator.Key()), + OptedUSDValue: usdValues, + }) + } + return ret, nil +} + +func (k *Keeper) SetAllAVSUSDValues(ctx sdk.Context, usdValues []operatortypes.AVSUSDValue) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) + for i := range usdValues { + usdValue := usdValues[i] + bz := k.cdc.MustMarshal(&usdValue.Value) + store.Set([]byte(usdValue.AVSAddr), bz) + } + return nil +} + +func (k *Keeper) GetAllAVSUSDValues(ctx sdk.Context) ([]operatortypes.AVSUSDValue, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.AVSUSDValue, 0) + for ; iterator.Valid(); iterator.Next() { + var usdValue operatortypes.DecValueField + k.cdc.MustUnmarshal(iterator.Value(), &usdValue) + ret = append(ret, operatortypes.AVSUSDValue{ + AVSAddr: string(iterator.Key()), + Value: usdValue, + }) + } + return ret, nil +} + // CalculateUSDValueForOperator calculates the total and self usd value for the // operator according to the input assets filter and prices. // This function will be used in slashing calculations and voting power updates per epoch. @@ -347,11 +400,10 @@ func (k Keeper) GetOrCalculateOperatorUSDValues( operator sdk.AccAddress, chainIDWithoutRevision string, ) (optedUSDValues operatortypes.OperatorOptedUSDValue, err error) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) + isAvs, avsAddrString := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) if !isAvs { return operatortypes.OperatorOptedUSDValue{}, errorsmod.Wrap(operatortypes.ErrUnknownChainID, fmt.Sprintf("GetOrCalculateOperatorUSDValues: chainIDWithoutRevision is %s", chainIDWithoutRevision)) } - avsAddrString := avsAddr.String() // the usd values will be deleted if the operator opts out, so recalculate the // voting power to set the tokens and shares for this case. if !k.IsOptedIn(ctx, operator.String(), avsAddrString) { diff --git a/x/operator/keeper/usd_value_test.go b/x/operator/keeper/usd_value_test.go index 7596c5b15..116f3c6b4 100644 --- a/x/operator/keeper/usd_value_test.go +++ b/x/operator/keeper/usd_value_test.go @@ -14,9 +14,7 @@ const ( MaxDecForTotalSupply = 38 ) -var ( - MaxAssetTotalSupply = sdkmath.NewIntWithDecimal(1, MaxDecForTotalSupply) -) +var MaxAssetTotalSupply = sdkmath.NewIntWithDecimal(1, MaxDecForTotalSupply) func (suite *OperatorTestSuite) TestCalculateUSDValue() { suite.prepare() @@ -81,7 +79,7 @@ func (suite *OperatorTestSuite) TestAVSUSDValue() { err := suite.App.AssetsKeeper.SetStakingAssetInfo( suite.Ctx, &assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: sdkmath.NewInt(0), }, ) @@ -122,7 +120,7 @@ func (suite *OperatorTestSuite) TestVotingPowerForDogFood() { addUSDValue := sdkmath.LegacyNewDec(1) chainIDWithoutRevision := avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID()) - avsAddress := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())).String() + avsAddress := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())) // CommitAfter causes the epoch hook to be triggered, and results in writing // of the AVS usd value to the store. suite.CommitAfter(time.Hour*24 + time.Nanosecond) @@ -139,7 +137,7 @@ func (suite *OperatorTestSuite) TestVotingPowerForDogFood() { suite.Equal(1, len(allAssets)) var asset assetstype.AssetInfo for _, value := range allAssets { - asset = *value.AssetBasicInfo + asset = value.AssetBasicInfo } assetAddr := common.HexToAddress(asset.Address) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index b8259014d..f17ff26dc 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -7,7 +7,6 @@ import ( delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" oracletype "github.com/ExocoreNetwork/exocore/x/oracle/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ) var _ OracleKeeper = MockOracle{} @@ -24,8 +23,8 @@ type AssetsKeeper interface { f func(assetID string, state *assetstype.OperatorAssetInfo) error, ) error ClientChainExists(ctx sdk.Context, index uint64) bool - GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorAssetInfo, err error) + GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets []assetstype.StakingAssetInfo, err error) } var _ DelegationKeeper = &delegationkeeper.Keeper{} @@ -108,7 +107,7 @@ type AVSKeeper interface { GetEpochEndAVSs(ctx sdk.Context, epochIdentifier string, epochNumber int64) []string // IsAVS returns true if the address is a registered AVS address. IsAVS(ctx sdk.Context, addr string) (bool, error) - IsAVSByChainID(ctx sdk.Context, chainID string) (bool, common.Address) + IsAVSByChainID(ctx sdk.Context, chainID string) (bool, string) } type SlashKeeper interface { diff --git a/x/operator/types/genesis.go b/x/operator/types/genesis.go index 8a44c77be..4a182db95 100644 --- a/x/operator/types/genesis.go +++ b/x/operator/types/genesis.go @@ -2,53 +2,80 @@ package types import ( errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/utils" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ) func NewGenesisState( - operators []OperatorInfo, + operators []OperatorDetail, + operatorConsKeys []OperatorConsKeyRecord, + optStates []OptedState, + operatorUSDValues []OperatorUSDValue, + avsUSDValues []AVSUSDValue, + slashStates []OperatorSlashState, + prevConsKeys []PrevConsKey, + operatorKeyRemovals []OperatorKeyRemoval, ) *GenesisState { return &GenesisState{ - Operators: operators, + Operators: operators, + OperatorRecords: operatorConsKeys, + OptStates: optStates, + OperatorUSDValues: operatorUSDValues, + AVSUSDValues: avsUSDValues, + SlashStates: slashStates, + PreConsKeys: prevConsKeys, + OperatorKeyRemovals: operatorKeyRemovals, } } // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { - return NewGenesisState(nil) + return NewGenesisState(nil, nil, nil, nil, nil, nil, nil, nil) } -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { +// ValidateOperators rationale for the validation: +// 1. since this function should support chain restarts and upgrades, we cannot require +// the format of the earnings address be EVM only. +func (gs GenesisState) ValidateOperators() (map[string]struct{}, error) { // checks list: // - no duplicate addresses in `gs.Operators`. // - correct bech32 format for each address in `gs.Operators` // - no `chainID` duplicates for earnings addresses list in `gs.Operators`. operators := make(map[string]struct{}, len(gs.Operators)) for _, op := range gs.Operators { - address := op.EarningsAddr + address := op.OperatorAddress if _, found := operators[address]; found { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "duplicate operator address %s", address, ) } _, err := sdk.AccAddressFromBech32(address) if err != nil { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "invalid operator address %s: %s", address, err, ) } + if op.OperatorInfo.EarningsAddr != "" { + _, err := sdk.AccAddressFromBech32(op.OperatorInfo.EarningsAddr) + if err != nil { + return nil, errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid operator earning address %s: %s", op.OperatorInfo.EarningsAddr, err, + ) + } + } operators[address] = struct{}{} - if op.ClientChainEarningsAddr != nil { - lzIDs := make(map[uint64]struct{}, len(op.ClientChainEarningsAddr.EarningInfoList)) - for _, info := range op.ClientChainEarningsAddr.EarningInfoList { + if op.OperatorInfo.ClientChainEarningsAddr != nil { + lzIDs := make(map[uint64]struct{}, len(op.OperatorInfo.ClientChainEarningsAddr.EarningInfoList)) + for _, info := range op.OperatorInfo.ClientChainEarningsAddr.EarningInfoList { lzID := info.LzClientChainID if _, found := lzIDs[lzID]; found { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "duplicate lz client chain id %d", lzID, ) @@ -57,27 +84,466 @@ func (gs GenesisState) Validate() error { // TODO: when moving to support non-EVM chains, this check should be modified // to work based on the `lzID` or possibly removed. if !common.IsHexAddress(info.ClientChainEarningAddr) { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "invalid client chain earning address %s", info.ClientChainEarningAddr, ) } } } - if op.Commission.CommissionRates.Rate.IsNil() || - op.Commission.CommissionRates.MaxRate.IsNil() || - op.Commission.CommissionRates.MaxChangeRate.IsNil() { - return errorsmod.Wrapf( + if op.OperatorInfo.Commission.CommissionRates.Rate.IsNil() || + op.OperatorInfo.Commission.CommissionRates.MaxRate.IsNil() || + op.OperatorInfo.Commission.CommissionRates.MaxChangeRate.IsNil() { + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "missing commission for operator %s", address, ) } - if err := op.Commission.Validate(); err != nil { - return errorsmod.Wrapf( + if err := op.OperatorInfo.Commission.Validate(); err != nil { + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "invalid commission for operator %s: %s", address, err, ) } } + return operators, nil +} + +// ValidateOperatorConsKeyRecords rationale for the validation: +// 2. since the operator module is not meant to handle dogfooding, we should not check +// whether an operator has keys defined for our chainID. this is left for the dogfood +// module. +func (gs GenesisState) ValidateOperatorConsKeyRecords(operators map[string]struct{}) error { + // - correct bech32 format for each address in `gs.OperatorRecords`. + // - no duplicate addresses in `gs.OperatorRecords`. + // - no operator that is in `gs.OperatorRecords` but not in `gs.Operators`. + // - validity of consensus key format for each entry in `gs.OperatorRecords`. + // - within each chainID, no duplicate consensus keys. + operatorRecords := make(map[string]struct{}, len(gs.OperatorRecords)) + keysByChainID := make(map[string]map[string]struct{}) + for _, record := range gs.OperatorRecords { + addr := record.OperatorAddress + if _, err := sdk.AccAddressFromBech32(addr); err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: invalid operator address %s: %s", record.OperatorAddress, err, + ) + } + if _, found := operatorRecords[addr]; found { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: duplicate operator record for operator %s", addr, + ) + } + operatorRecords[addr] = struct{}{} + if _, opFound := operators[addr]; !opFound { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: operator record for un-registered operator %s", addr, + ) + } + for _, chain := range record.Chains { + chainID := chain.ChainID + if !utils.IsValidChainIDWithoutRevision(chainID) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: invalid chainID without revision, operator %s: chainID: %s", addr, chainID, + ) + } + // Cosmos does not describe a specific `chainID` format, so can't validate it. + if _, found := keysByChainID[chainID]; !found { + keysByChainID[chainID] = make(map[string]struct{}) + } + + if wrappedKey := NewWrappedConsKeyFromHex( + chain.ConsensusKey, + ); wrappedKey == nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: invalid consensus key for operator %s: %s", addr, chain.ConsensusKey, + ) + } + + // within a chain id, there should not be duplicate consensus keys + if _, found := keysByChainID[chainID][chain.ConsensusKey]; found { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: duplicate consensus key for operator %s on chain %s", addr, chainID, + ) + } + keysByChainID[chainID][chain.ConsensusKey] = struct{}{} + } + } + return nil +} + +func (gs GenesisState) ValidateOptedStates(operators map[string]struct{}) (map[string]struct{}, error) { + avs := make(map[string]struct{}) + validationFunc := func(_ int, state OptedState) error { + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(state.Key), 2) + if err != nil { + return errorsmod.Wrapf(ErrInvalidGenesisData, "ValidateOptedStates can't parse the joined key: %s", err.Error()) + } + operator, avsAddr := stringList[0], stringList[1] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the opted state, %+v", + state, + ) + } + if state.OptInfo.OptedOutHeight < state.OptInfo.OptedInHeight { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the opted-out height should be greater than the opted-in height, %+v", + state, + ) + } + if !common.IsHexAddress(avsAddr) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the AVS address isn't an ethereum hex address, %+v", + state, + ) + } + avs[avsAddr] = struct{}{} + return nil + } + seenFieldValueFunc := func(state OptedState) (string, struct{}) { + return state.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.OptStates, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return avs, nil +} + +func (gs GenesisState) ValidateAVSUSDValues(optedAVS map[string]struct{}) (map[string]DecValueField, error) { + avsUSDValueMap := make(map[string]DecValueField, 0) + validationFunc := func(_ int, avsUSDValue AVSUSDValue) error { + if !common.IsHexAddress(avsUSDValue.AVSAddr) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the AVS address isn't an ethereum hex address, avsUSDValue: %+v", + avsUSDValue, + ) + } + if _, ok := optedAVS[avsUSDValue.AVSAddr]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the avs address should be in the opted-in map, avsUSDValue: %+v", avsUSDValue, + ) + } + if avsUSDValue.Value.Amount.IsNil() || + avsUSDValue.Value.Amount.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "avsUSDValue is nil or negative, avsUSDValue: %+v", avsUSDValue, + ) + } + avsUSDValueMap[avsUSDValue.AVSAddr] = avsUSDValue.Value + return nil + } + seenFieldValueFunc := func(usdValue AVSUSDValue) (string, struct{}) { + return usdValue.AVSAddr, struct{}{} + } + _, err := utils.CommonValidation(gs.AVSUSDValues, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return avsUSDValueMap, nil +} + +func (gs GenesisState) ValidateOperatorUSDValues(operators map[string]struct{}, avsUSDValues map[string]DecValueField) error { + validationFunc := func(_ int, operatorUSDValue OperatorUSDValue) error { + if operatorUSDValue.OptedUSDValue.SelfUSDValue.IsNil() || + operatorUSDValue.OptedUSDValue.TotalUSDValue.IsNil() || + operatorUSDValue.OptedUSDValue.ActiveUSDValue.IsNil() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "nil field in operatorUSDValue: %+v", + operatorUSDValue, + ) + } + if operatorUSDValue.OptedUSDValue.SelfUSDValue.IsNegative() || + operatorUSDValue.OptedUSDValue.TotalUSDValue.IsNegative() || + operatorUSDValue.OptedUSDValue.ActiveUSDValue.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "negative field in operatorUSDValue: %+v", + operatorUSDValue, + ) + } + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(operatorUSDValue.Key), 2) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + avsAddress, operator := stringList[0], stringList[1] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the voting power, %+v", + operatorUSDValue, + ) + } + avsUSDValue, ok := avsUSDValues[avsAddress] + if !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the parsed AVS address should be in the avsUSDValues map, AVS: %s, avsUSDValues: %+v", + avsAddress, avsUSDValues, + ) + } + + if operatorUSDValue.OptedUSDValue.TotalUSDValue.GT(avsUSDValue.Amount) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the total USD value of operator shouldn't be greater than the total USD value of the AVS, avsUSDValue: %s, operatorUSDValue: %+v", + avsUSDValue.Amount.String(), operatorUSDValue, + ) + } + + if operatorUSDValue.OptedUSDValue.SelfUSDValue.GT(operatorUSDValue.OptedUSDValue.TotalUSDValue) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the operator's self USD value shouldn't be greater than its total USD value, operatorUSDValue: %+v", operatorUSDValue, + ) + } + + if operatorUSDValue.OptedUSDValue.ActiveUSDValue.GT(operatorUSDValue.OptedUSDValue.TotalUSDValue) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the operator's active USD value shouldn't be greater than its total USD value, operatorUSDValue: %+v", operatorUSDValue, + ) + } + return nil + } + seenFieldValueFunc := func(vp OperatorUSDValue) (string, struct{}) { + return vp.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.OperatorUSDValues, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateSlashStates(operators, avs map[string]struct{}) error { + validationFunc := func(_ int, slash OperatorSlashState) error { + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(slash.Key), 3) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + operator, avsAddr := stringList[0], stringList[1] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the slashing state, %+v", + slash, + ) + } + // check whether the AVS is in the opted states. + // This check might be removed if the opted-in states are deleted when + // the operator opts out of the AVS. + if _, ok := avs[avsAddr]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown AVS address for the slashing state, %+v", + slash, + ) + } + if slash.Info.EventHeight > slash.Info.SubmittedHeight { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the submitted height shouldn't be greater than the event height for a slashing record, %+v", + slash, + ) + } + if slash.Info.SlashProportion.IsNil() || slash.Info.SlashProportion.LTE(sdkmath.LegacyNewDec(0)) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slash proportion, it's nil, zero, or negative: %+v", + slash, + ) + } + + // validate the slashing execution information + // the actual executed proportion and value might be zero because of the rounding in an extreme case + if slash.Info.ExecutionInfo.SlashProportion.IsNil() || slash.Info.ExecutionInfo.SlashProportion.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing execution proportion, it's nil, or negative: %+v", + slash, + ) + } + if slash.Info.ExecutionInfo.SlashValue.IsNil() || slash.Info.ExecutionInfo.SlashValue.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing execution value, it's nil, or negative: %+v", + slash, + ) + } + // validate the slashing record regarding undelegation + SlashFromUndelegationVal := func(_ int, slashFromUndelegation SlashFromUndelegation) error { + if slashFromUndelegation.Amount.IsNil() || slashFromUndelegation.Amount.LTE(sdkmath.NewInt(0)) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing amount from the undelegation, it's nil, zero, or negative: %+v", + slash, + ) + } + return nil + } + seenFieldValueFunc := func(slashFromUndelegation SlashFromUndelegation) (string, struct{}) { + key := assetstypes.GetJoinedStoreKey(slashFromUndelegation.StakerID, slashFromUndelegation.AssetID) + return string(key), struct{}{} + } + _, err = utils.CommonValidation(slash.Info.ExecutionInfo.SlashUndelegations, seenFieldValueFunc, SlashFromUndelegationVal) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + // validate the slashing record regarding assets pool + SlashFromAssetsPoolVal := func(_ int, slashFromAssetsPool SlashFromAssetsPool) error { + if slashFromAssetsPool.Amount.IsNil() || slashFromAssetsPool.Amount.LTE(sdkmath.NewInt(0)) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing amount from the assets pool, it's nil, zero, or negative: %+v", + slash, + ) + } + return nil + } + SlashFromAssetsPooLSeenFunc := func(slashFromAssetsPool SlashFromAssetsPool) (string, struct{}) { + return slashFromAssetsPool.AssetID, struct{}{} + } + _, err = utils.CommonValidation(slash.Info.ExecutionInfo.SlashAssetsPool, SlashFromAssetsPooLSeenFunc, SlashFromAssetsPoolVal) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(slash OperatorSlashState) (string, struct{}) { + return slash.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.SlashStates, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidatePrevConsKeys(operators map[string]struct{}) error { + validationFunc := func(_ int, prevConsKey PrevConsKey) error { + keys, err := assetstypes.ParseJoinedStoreKey([]byte(prevConsKey.Key), 2) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidatePrevConsKeys can't parse the combined key, %+v", + prevConsKey, + ) + } + + chainID, operator := keys[0], keys[1] + if !utils.IsValidChainIDWithoutRevision(chainID) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidatePrevConsKeys: invalid chainID without revision, operator %s: chainID: %s", operator, chainID, + ) + } + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the previous consensus key, %+v", + prevConsKey, + ) + } + if wrappedKey := NewWrappedConsKeyFromHex( + prevConsKey.ConsensusKey, + ); wrappedKey == nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid previous consensus key for operator, %+v", prevConsKey, + ) + } + // todo: not sure if the duplication of previous consensus keys needs to be checked + return nil + } + seenFieldValueFunc := func(prevConsKey PrevConsKey) (string, struct{}) { + return prevConsKey.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.PreConsKeys, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateOperatorKeyRemovals(operators map[string]struct{}) error { + validationFunc := func(_ int, operatorKeyRemoval OperatorKeyRemoval) error { + keys, err := assetstypes.ParseJoinedStoreKey([]byte(operatorKeyRemoval.Key), 2) + if err != nil { + return err + } + operator := keys[0] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the operator key removal, %+v", + operatorKeyRemoval, + ) + } + return nil + } + seenFieldValueFunc := func(operatorKeyRemoval OperatorKeyRemoval) (string, struct{}) { + return operatorKeyRemoval.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.OperatorKeyRemovals, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + operators, err := gs.ValidateOperators() + if err != nil { + return err + } + err = gs.ValidateOperatorConsKeyRecords(operators) + if err != nil { + return err + } + avsMap, err := gs.ValidateOptedStates(operators) + if err != nil { + return err + } + avsUSDValueMap, err := gs.ValidateAVSUSDValues(avsMap) + if err != nil { + return err + } + err = gs.ValidateOperatorUSDValues(operators, avsUSDValueMap) + if err != nil { + return err + } + err = gs.ValidateSlashStates(operators, avsMap) + if err != nil { + return err + } + err = gs.ValidatePrevConsKeys(operators) + if err != nil { + return err + } + err = gs.ValidateOperatorKeyRemovals(operators) + if err != nil { + return err + } return nil } diff --git a/x/operator/types/genesis.pb.go b/x/operator/types/genesis.pb.go index 184ea96d0..0b55379ab 100644 --- a/x/operator/types/genesis.pb.go +++ b/x/operator/types/genesis.pb.go @@ -29,7 +29,27 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // there are no params for this module. // operators is a list of the registered operators. - Operators []OperatorInfo `protobuf:"bytes,1,rep,name=operators,proto3" json:"operators"` + Operators []OperatorDetail `protobuf:"bytes,1,rep,name=operators,proto3" json:"operators"` + // add other information for exporting / importing. + // Although it is not necessary for the bootstrapped genesis, it is + // necessary for chain restarts. + // operator_records refers to a list of operator records. each record + // contains an operator address and a list of chain id + + // cons key combination. + OperatorRecords []OperatorConsKeyRecord `protobuf:"bytes,2,rep,name=operator_records,json=operatorRecords,proto3" json:"operator_records"` + // opt_states is a list of all opted information for the AVS and operators + OptStates []OptedState `protobuf:"bytes,3,rep,name=opt_states,json=optStates,proto3" json:"opt_states"` + // avs_usd_values is a list of AVS USD value + AVSUSDValues []AVSUSDValue `protobuf:"bytes,4,rep,name=avs_usd_values,json=avsUsdValues,proto3" json:"avs_usd_values"` + // operator_usd_values is a list of operator USD value + OperatorUSDValues []OperatorUSDValue `protobuf:"bytes,5,rep,name=operator_usd_values,json=operatorUsdValues,proto3" json:"operator_usd_values"` + // slash_states is a list of all slashing information + SlashStates []OperatorSlashState `protobuf:"bytes,6,rep,name=slash_states,json=slashStates,proto3" json:"slash_states"` + // pre_cons_key is a list of all previous consensus public key + PreConsKeys []PrevConsKey `protobuf:"bytes,7,rep,name=pre_cons_keys,json=preConsKeys,proto3" json:"pre_cons_keys"` + // operator_key_removal is a list of operator with the given address + // is in the process of unbonding their key for the given chainID. + OperatorKeyRemovals []OperatorKeyRemoval `protobuf:"bytes,8,rep,name=operator_key_removals,json=operatorKeyRemovals,proto3" json:"operator_key_removals"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -65,35 +85,84 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetOperators() []OperatorInfo { +func (m *GenesisState) GetOperators() []OperatorDetail { if m != nil { return m.Operators } return nil } -// StakerRecord is a helper structure for the genesis state. Each record -// contains a staker address and a list of asset IDs with their operator + -// amount combination. -type StakerRecord struct { - // staker_id denotes the address + l0id of the staker. - StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` - // staker_details is a list of asset ID + operator + amount combination. - StakerDetails []StakerDetails `protobuf:"bytes,2,rep,name=staker_details,json=stakerDetails,proto3" json:"staker_details"` +func (m *GenesisState) GetOperatorRecords() []OperatorConsKeyRecord { + if m != nil { + return m.OperatorRecords + } + return nil } -func (m *StakerRecord) Reset() { *m = StakerRecord{} } -func (m *StakerRecord) String() string { return proto.CompactTextString(m) } -func (*StakerRecord) ProtoMessage() {} -func (*StakerRecord) Descriptor() ([]byte, []int) { +func (m *GenesisState) GetOptStates() []OptedState { + if m != nil { + return m.OptStates + } + return nil +} + +func (m *GenesisState) GetAVSUSDValues() []AVSUSDValue { + if m != nil { + return m.AVSUSDValues + } + return nil +} + +func (m *GenesisState) GetOperatorUSDValues() []OperatorUSDValue { + if m != nil { + return m.OperatorUSDValues + } + return nil +} + +func (m *GenesisState) GetSlashStates() []OperatorSlashState { + if m != nil { + return m.SlashStates + } + return nil +} + +func (m *GenesisState) GetPreConsKeys() []PrevConsKey { + if m != nil { + return m.PreConsKeys + } + return nil +} + +func (m *GenesisState) GetOperatorKeyRemovals() []OperatorKeyRemoval { + if m != nil { + return m.OperatorKeyRemovals + } + return nil +} + +// OperatorDetail is helper structure to store the operator information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorInfo` +type OperatorDetail struct { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // operator_info is the detail information for the above operator + OperatorInfo OperatorInfo `protobuf:"bytes,2,opt,name=operator_info,json=operatorInfo,proto3" json:"operator_info"` +} + +func (m *OperatorDetail) Reset() { *m = OperatorDetail{} } +func (m *OperatorDetail) String() string { return proto.CompactTextString(m) } +func (*OperatorDetail) ProtoMessage() {} +func (*OperatorDetail) Descriptor() ([]byte, []int) { return fileDescriptor_bb7040bc6ae6ddee, []int{1} } -func (m *StakerRecord) XXX_Unmarshal(b []byte) error { +func (m *OperatorDetail) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *StakerRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OperatorDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_StakerRecord.Marshal(b, m, deterministic) + return xxx_messageInfo_OperatorDetail.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -103,53 +172,54 @@ func (m *StakerRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *StakerRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerRecord.Merge(m, src) +func (m *OperatorDetail) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorDetail.Merge(m, src) } -func (m *StakerRecord) XXX_Size() int { +func (m *OperatorDetail) XXX_Size() int { return m.Size() } -func (m *StakerRecord) XXX_DiscardUnknown() { - xxx_messageInfo_StakerRecord.DiscardUnknown(m) +func (m *OperatorDetail) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorDetail.DiscardUnknown(m) } -var xxx_messageInfo_StakerRecord proto.InternalMessageInfo +var xxx_messageInfo_OperatorDetail proto.InternalMessageInfo -func (m *StakerRecord) GetStakerID() string { +func (m *OperatorDetail) GetOperatorAddress() string { if m != nil { - return m.StakerID + return m.OperatorAddress } return "" } -func (m *StakerRecord) GetStakerDetails() []StakerDetails { +func (m *OperatorDetail) GetOperatorInfo() OperatorInfo { if m != nil { - return m.StakerDetails + return m.OperatorInfo } - return nil + return OperatorInfo{} } -// StakerDetails is a helper structure for the genesis state. Each record -// contains an asset ID and a list of operator + amount combination. -type StakerDetails struct { - // asset_id is the unique identifier of the asset. - AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` - // details is a list of operator + amount combination. - Details []AssetDetails `protobuf:"bytes,2,rep,name=details,proto3" json:"details"` +// OptedStates is helper structure to store the opted state for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorOptedAVSInfo` +type OptedState struct { + // key is used for storing the opted states, + // which is a combination of the operator address and AVS address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // opt_info is the value of undelegation state for the above key + OptInfo OptedInfo `protobuf:"bytes,2,opt,name=opt_info,json=optInfo,proto3" json:"opt_info"` } -func (m *StakerDetails) Reset() { *m = StakerDetails{} } -func (m *StakerDetails) String() string { return proto.CompactTextString(m) } -func (*StakerDetails) ProtoMessage() {} -func (*StakerDetails) Descriptor() ([]byte, []int) { +func (m *OptedState) Reset() { *m = OptedState{} } +func (m *OptedState) String() string { return proto.CompactTextString(m) } +func (*OptedState) ProtoMessage() {} +func (*OptedState) Descriptor() ([]byte, []int) { return fileDescriptor_bb7040bc6ae6ddee, []int{2} } -func (m *StakerDetails) XXX_Unmarshal(b []byte) error { +func (m *OptedState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *StakerDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OptedState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_StakerDetails.Marshal(b, m, deterministic) + return xxx_messageInfo_OptedState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -159,55 +229,53 @@ func (m *StakerDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } -func (m *StakerDetails) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerDetails.Merge(m, src) +func (m *OptedState) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptedState.Merge(m, src) } -func (m *StakerDetails) XXX_Size() int { +func (m *OptedState) XXX_Size() int { return m.Size() } -func (m *StakerDetails) XXX_DiscardUnknown() { - xxx_messageInfo_StakerDetails.DiscardUnknown(m) +func (m *OptedState) XXX_DiscardUnknown() { + xxx_messageInfo_OptedState.DiscardUnknown(m) } -var xxx_messageInfo_StakerDetails proto.InternalMessageInfo +var xxx_messageInfo_OptedState proto.InternalMessageInfo -func (m *StakerDetails) GetAssetID() string { +func (m *OptedState) GetKey() string { if m != nil { - return m.AssetID + return m.Key } return "" } -func (m *StakerDetails) GetDetails() []AssetDetails { +func (m *OptedState) GetOptInfo() OptedInfo { if m != nil { - return m.Details + return m.OptInfo } - return nil + return OptedInfo{} } -// AssetDetails is a helper structure for the genesis state. Each record -// contains an operator and an amount. -type AssetDetails struct { - // operator_address is the address of the operator as the bech32 - // version of sdk.AccAddress. - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` - // amount is the amount of the asset staked by the staker for this - // asset and operator. - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +// AVSUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForAVS` +type AVSUSDValue struct { + // avs_addr + AVSAddr string `protobuf:"bytes,1,opt,name=avs_addr,json=avsAddr,proto3" json:"avs_addr,omitempty"` + // value is the USD value for the AVS address + Value DecValueField `protobuf:"bytes,2,opt,name=value,proto3" json:"value"` } -func (m *AssetDetails) Reset() { *m = AssetDetails{} } -func (m *AssetDetails) String() string { return proto.CompactTextString(m) } -func (*AssetDetails) ProtoMessage() {} -func (*AssetDetails) Descriptor() ([]byte, []int) { +func (m *AVSUSDValue) Reset() { *m = AVSUSDValue{} } +func (m *AVSUSDValue) String() string { return proto.CompactTextString(m) } +func (*AVSUSDValue) ProtoMessage() {} +func (*AVSUSDValue) Descriptor() ([]byte, []int) { return fileDescriptor_bb7040bc6ae6ddee, []int{3} } -func (m *AssetDetails) XXX_Unmarshal(b []byte) error { +func (m *AVSUSDValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *AssetDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AVSUSDValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_AssetDetails.Marshal(b, m, deterministic) + return xxx_messageInfo_AVSUSDValue.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -217,316 +285,2584 @@ func (m *AssetDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *AssetDetails) XXX_Merge(src proto.Message) { - xxx_messageInfo_AssetDetails.Merge(m, src) +func (m *AVSUSDValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_AVSUSDValue.Merge(m, src) } -func (m *AssetDetails) XXX_Size() int { +func (m *AVSUSDValue) XXX_Size() int { return m.Size() } -func (m *AssetDetails) XXX_DiscardUnknown() { - xxx_messageInfo_AssetDetails.DiscardUnknown(m) +func (m *AVSUSDValue) XXX_DiscardUnknown() { + xxx_messageInfo_AVSUSDValue.DiscardUnknown(m) } -var xxx_messageInfo_AssetDetails proto.InternalMessageInfo +var xxx_messageInfo_AVSUSDValue proto.InternalMessageInfo -func (m *AssetDetails) GetOperatorAddress() string { +func (m *AVSUSDValue) GetAVSAddr() string { if m != nil { - return m.OperatorAddress + return m.AVSAddr } return "" } -func init() { - proto.RegisterType((*GenesisState)(nil), "exocore.operator.v1.GenesisState") - proto.RegisterType((*StakerRecord)(nil), "exocore.operator.v1.StakerRecord") - proto.RegisterType((*StakerDetails)(nil), "exocore.operator.v1.StakerDetails") - proto.RegisterType((*AssetDetails)(nil), "exocore.operator.v1.AssetDetails") +func (m *AVSUSDValue) GetValue() DecValueField { + if m != nil { + return m.Value + } + return DecValueField{} } -func init() { proto.RegisterFile("exocore/operator/v1/genesis.proto", fileDescriptor_bb7040bc6ae6ddee) } - -var fileDescriptor_bb7040bc6ae6ddee = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0xae, 0xd2, 0x40, - 0x14, 0x86, 0x3b, 0x57, 0x73, 0x81, 0xb9, 0xbd, 0x6a, 0x46, 0x17, 0xf5, 0xc6, 0xb4, 0x97, 0x2e, - 0x08, 0x2c, 0x68, 0x03, 0x6e, 0xdd, 0x40, 0x20, 0xa6, 0x89, 0x91, 0xa4, 0xe8, 0xc6, 0x0d, 0x29, - 0x9d, 0xb1, 0x36, 0x48, 0x87, 0xcc, 0x0c, 0x88, 0x3e, 0x82, 0x1b, 0x7d, 0x18, 0x1f, 0x82, 0x25, - 0x71, 0x65, 0x5c, 0x34, 0xa6, 0xbc, 0x88, 0x61, 0x66, 0x1a, 0x20, 0xe9, 0xaa, 0x33, 0xff, 0xf9, - 0xcf, 0x39, 0x5f, 0x27, 0x3f, 0x6c, 0x92, 0x2d, 0x8d, 0x29, 0x23, 0x3e, 0x5d, 0x11, 0x16, 0x09, - 0xca, 0xfc, 0x4d, 0xcf, 0x4f, 0x48, 0x46, 0x78, 0xca, 0xbd, 0x15, 0xa3, 0x82, 0xa2, 0xa7, 0xda, - 0xe2, 0x95, 0x16, 0x6f, 0xd3, 0xbb, 0x7b, 0x1e, 0x53, 0xbe, 0xa4, 0x7c, 0x26, 0x2d, 0xbe, 0xba, - 0x28, 0xff, 0xdd, 0xb3, 0x84, 0x26, 0x54, 0xe9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49, 0xc8, - 0x57, 0xc7, 0xd1, 0x7f, 0x73, 0xa7, 0x95, 0xa4, 0xe2, 0xd3, 0x7a, 0xee, 0xc5, 0x74, 0xa9, 0x03, - 0xa0, 0x3f, 0x5d, 0x8e, 0x17, 0xbe, 0xf8, 0xba, 0x22, 0xdc, 0x0b, 0x32, 0xf1, 0xfb, 0x57, 0x17, - 0xea, 0x7c, 0x04, 0x99, 0x08, 0xf5, 0xac, 0xe1, 0x9b, 0x5d, 0x61, 0x83, 0x7d, 0x61, 0x83, 0x7f, - 0x85, 0x0d, 0x7e, 0x1e, 0x6c, 0x63, 0x7f, 0xb0, 0x8d, 0x3f, 0x07, 0xdb, 0xf8, 0xd0, 0x3f, 0x9b, - 0x3b, 0x56, 0xff, 0xf9, 0x96, 0x88, 0x2f, 0x94, 0x2d, 0xfc, 0x32, 0x43, 0xdb, 0x53, 0x8a, 0xe4, - 0x9e, 0xf9, 0xb5, 0x8c, 0xd1, 0xcb, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x40, 0x9d, 0xcc, - 0xcf, 0x02, 0x00, 0x00, +// OperatorUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForOperator` +type OperatorUSDValue struct { + // key is used for storing the voting power of specified operator and AVS, + // which is the combination of operator and AVS address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // value is the USD value states for the AVS address + OptedUSDValue OperatorOptedUSDValue `protobuf:"bytes,2,opt,name=opted_usd_value,json=optedUsdValue,proto3" json:"opted_usd_value"` } -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 +func (m *OperatorUSDValue) Reset() { *m = OperatorUSDValue{} } +func (m *OperatorUSDValue) String() string { return proto.CompactTextString(m) } +func (*OperatorUSDValue) ProtoMessage() {} +func (*OperatorUSDValue) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{4} +} +func (m *OperatorUSDValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorUSDValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorUSDValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil } - -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *OperatorUSDValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorUSDValue.Merge(m, src) +} +func (m *OperatorUSDValue) XXX_Size() int { + return m.Size() +} +func (m *OperatorUSDValue) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorUSDValue.DiscardUnknown(m) } -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Operators) > 0 { - for iNdEx := len(m.Operators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Operators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } +var xxx_messageInfo_OperatorUSDValue proto.InternalMessageInfo + +func (m *OperatorUSDValue) GetKey() string { + if m != nil { + return m.Key } - return len(dAtA) - i, nil + return "" } -func (m *StakerRecord) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *OperatorUSDValue) GetOptedUSDValue() OperatorOptedUSDValue { + if m != nil { + return m.OptedUSDValue } - return dAtA[:n], nil + return OperatorOptedUSDValue{} } -func (m *StakerRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// OperatorSlashState is helper structure to store the slash information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorSlashInfo` +type OperatorSlashState struct { + // key is used for storing the slash information, + // which is the combination of the operator address, AVS address, and slashID. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // states is the voting power value for the above key + Info OperatorSlashInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` } -func (m *StakerRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StakerDetails) > 0 { - for iNdEx := len(m.StakerDetails) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StakerDetails[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func (m *OperatorSlashState) Reset() { *m = OperatorSlashState{} } +func (m *OperatorSlashState) String() string { return proto.CompactTextString(m) } +func (*OperatorSlashState) ProtoMessage() {} +func (*OperatorSlashState) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{5} +} +func (m *OperatorSlashState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorSlashState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorSlashState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } + return b[:n], nil } - if len(m.StakerID) > 0 { - i -= len(m.StakerID) - copy(dAtA[i:], m.StakerID) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.StakerID))) - i-- - dAtA[i] = 0xa +} +func (m *OperatorSlashState) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorSlashState.Merge(m, src) +} +func (m *OperatorSlashState) XXX_Size() int { + return m.Size() +} +func (m *OperatorSlashState) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorSlashState.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorSlashState proto.InternalMessageInfo + +func (m *OperatorSlashState) GetKey() string { + if m != nil { + return m.Key } - return len(dAtA) - i, nil + return "" } -func (m *StakerDetails) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *OperatorSlashState) GetInfo() OperatorSlashInfo { + if m != nil { + return m.Info } - return dAtA[:n], nil + return OperatorSlashInfo{} } -func (m *StakerDetails) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// PrevConsKey is helper structure to store the previous consensus key +// for the operator and chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorAndChainIDToPrevConsKey` +type PrevConsKey struct { + // key is used for storing the previous consensus key, + // which is the combination of chainID and operator address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + ConsensusKey string `protobuf:"bytes,2,opt,name=consensus_key,json=consensusKey,proto3" json:"consensus_key,omitempty"` } -func (m *StakerDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Details) > 0 { - for iNdEx := len(m.Details) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Details[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.AssetID) > 0 { - i -= len(m.AssetID) - copy(dAtA[i:], m.AssetID) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.AssetID))) - i-- - dAtA[i] = 0xa +func (m *PrevConsKey) Reset() { *m = PrevConsKey{} } +func (m *PrevConsKey) String() string { return proto.CompactTextString(m) } +func (*PrevConsKey) ProtoMessage() {} +func (*PrevConsKey) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{6} +} +func (m *PrevConsKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PrevConsKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PrevConsKey.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return len(dAtA) - i, nil +} +func (m *PrevConsKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrevConsKey.Merge(m, src) +} +func (m *PrevConsKey) XXX_Size() int { + return m.Size() +} +func (m *PrevConsKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrevConsKey.DiscardUnknown(m) } -func (m *AssetDetails) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +var xxx_messageInfo_PrevConsKey proto.InternalMessageInfo + +func (m *PrevConsKey) GetKey() string { + if m != nil { + return m.Key } - return dAtA[:n], nil + return "" } -func (m *AssetDetails) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *PrevConsKey) GetConsensusKey() string { + if m != nil { + return m.ConsensusKey + } + return "" } -func (m *AssetDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err +// OperatorKeyRemoval is helper structure to store the operator with the given address +// is in the process of unbonding their key for the given chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorKeyRemovalForChainID` +type OperatorKeyRemoval struct { + // key is the combination of operator address and chainID. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *OperatorKeyRemoval) Reset() { *m = OperatorKeyRemoval{} } +func (m *OperatorKeyRemoval) String() string { return proto.CompactTextString(m) } +func (*OperatorKeyRemoval) ProtoMessage() {} +func (*OperatorKeyRemoval) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{7} +} +func (m *OperatorKeyRemoval) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorKeyRemoval) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorKeyRemoval.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i = encodeVarintGenesis(dAtA, i, uint64(size)) + return b[:n], nil } - i-- - dAtA[i] = 0x12 - if len(m.OperatorAddress) > 0 { - i -= len(m.OperatorAddress) - copy(dAtA[i:], m.OperatorAddress) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) - i-- - dAtA[i] = 0xa +} +func (m *OperatorKeyRemoval) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorKeyRemoval.Merge(m, src) +} +func (m *OperatorKeyRemoval) XXX_Size() int { + return m.Size() +} +func (m *OperatorKeyRemoval) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorKeyRemoval.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorKeyRemoval proto.InternalMessageInfo + +func (m *OperatorKeyRemoval) GetKey() string { + if m != nil { + return m.Key } - return len(dAtA) - i, nil + return "" } -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++ +// OperatorConsKeyRecord is a helper structure for the genesis state. Each record +// contains an operator address and a list of chain id + cons key combination. +type OperatorConsKeyRecord struct { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // chains is a list of chain id + consensus key combination. + Chains []ChainDetails `protobuf:"bytes,2,rep,name=chains,proto3" json:"chains"` +} + +func (m *OperatorConsKeyRecord) Reset() { *m = OperatorConsKeyRecord{} } +func (m *OperatorConsKeyRecord) String() string { return proto.CompactTextString(m) } +func (*OperatorConsKeyRecord) ProtoMessage() {} +func (*OperatorConsKeyRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{8} +} +func (m *OperatorConsKeyRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorConsKeyRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorConsKeyRecord.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - dAtA[offset] = uint8(v) - return base } -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 +func (m *OperatorConsKeyRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorConsKeyRecord.Merge(m, src) +} +func (m *OperatorConsKeyRecord) XXX_Size() int { + return m.Size() +} +func (m *OperatorConsKeyRecord) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorConsKeyRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorConsKeyRecord proto.InternalMessageInfo + +func (m *OperatorConsKeyRecord) GetOperatorAddress() string { + if m != nil { + return m.OperatorAddress } - var l int - _ = l - if len(m.Operators) > 0 { - for _, e := range m.Operators { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) + return "" +} + +func (m *OperatorConsKeyRecord) GetChains() []ChainDetails { + if m != nil { + return m.Chains + } + return nil +} + +// ChainDetails is a helper structure for the genesis state. Each record +// contains a chain id and a consensus key. +type ChainDetails struct { + // chain_id is the unique identifier of the chain. + ChainID string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + ConsensusKey string `protobuf:"bytes,2,opt,name=consensus_key,json=consensusKey,proto3" json:"consensus_key,omitempty"` +} + +func (m *ChainDetails) Reset() { *m = ChainDetails{} } +func (m *ChainDetails) String() string { return proto.CompactTextString(m) } +func (*ChainDetails) ProtoMessage() {} +func (*ChainDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{9} +} +func (m *ChainDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ChainDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ChainDetails.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } + return b[:n], nil } - return n +} +func (m *ChainDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChainDetails.Merge(m, src) +} +func (m *ChainDetails) XXX_Size() int { + return m.Size() +} +func (m *ChainDetails) XXX_DiscardUnknown() { + xxx_messageInfo_ChainDetails.DiscardUnknown(m) } -func (m *StakerRecord) Size() (n int) { - if m == nil { - return 0 +var xxx_messageInfo_ChainDetails proto.InternalMessageInfo + +func (m *ChainDetails) GetChainID() string { + if m != nil { + return m.ChainID } - var l int - _ = l - l = len(m.StakerID) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) + return "" +} + +func (m *ChainDetails) GetConsensusKey() string { + if m != nil { + return m.ConsensusKey } - if len(m.StakerDetails) > 0 { - for _, e := range m.StakerDetails { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) + return "" +} + +// StakerRecord is a helper structure for the genesis state. Each record +// contains a staker address and a list of asset IDs with their operator + +// amount combination. +type StakerRecord struct { + // staker_id denotes the address + l0id of the staker. + StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` + // staker_details is a list of asset ID + operator + amount combination. + StakerDetails []StakerDetails `protobuf:"bytes,2,rep,name=staker_details,json=stakerDetails,proto3" json:"staker_details"` +} + +func (m *StakerRecord) Reset() { *m = StakerRecord{} } +func (m *StakerRecord) String() string { return proto.CompactTextString(m) } +func (*StakerRecord) ProtoMessage() {} +func (*StakerRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{10} +} +func (m *StakerRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakerRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakerRecord.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 *StakerRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakerRecord.Merge(m, src) +} +func (m *StakerRecord) XXX_Size() int { + return m.Size() +} +func (m *StakerRecord) XXX_DiscardUnknown() { + xxx_messageInfo_StakerRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_StakerRecord proto.InternalMessageInfo + +func (m *StakerRecord) GetStakerID() string { + if m != nil { + return m.StakerID + } + return "" +} + +func (m *StakerRecord) GetStakerDetails() []StakerDetails { + if m != nil { + return m.StakerDetails + } + return nil +} + +// StakerDetails is a helper structure for the genesis state. Each record +// contains an asset ID and a list of operator + amount combination. +type StakerDetails struct { + // asset_id is the unique identifier of the asset. + AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` + // details is a list of operator + amount combination. + Details []AssetDetails `protobuf:"bytes,2,rep,name=details,proto3" json:"details"` +} + +func (m *StakerDetails) Reset() { *m = StakerDetails{} } +func (m *StakerDetails) String() string { return proto.CompactTextString(m) } +func (*StakerDetails) ProtoMessage() {} +func (*StakerDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{11} +} +func (m *StakerDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakerDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakerDetails.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 *StakerDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakerDetails.Merge(m, src) +} +func (m *StakerDetails) XXX_Size() int { + return m.Size() +} +func (m *StakerDetails) XXX_DiscardUnknown() { + xxx_messageInfo_StakerDetails.DiscardUnknown(m) +} + +var xxx_messageInfo_StakerDetails proto.InternalMessageInfo + +func (m *StakerDetails) GetAssetID() string { + if m != nil { + return m.AssetID + } + return "" +} + +func (m *StakerDetails) GetDetails() []AssetDetails { + if m != nil { + return m.Details + } + return nil +} + +// AssetDetails is a helper structure for the genesis state. Each record +// contains an operator and an amount. +type AssetDetails struct { + // operator_address is the address of the operator as the bech32 + // version of sdk.AccAddress. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // amount is the amount of the asset staked by the staker for this + // asset and operator. + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +} + +func (m *AssetDetails) Reset() { *m = AssetDetails{} } +func (m *AssetDetails) String() string { return proto.CompactTextString(m) } +func (*AssetDetails) ProtoMessage() {} +func (*AssetDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{12} +} +func (m *AssetDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetDetails.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 *AssetDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetDetails.Merge(m, src) +} +func (m *AssetDetails) XXX_Size() int { + return m.Size() +} +func (m *AssetDetails) XXX_DiscardUnknown() { + xxx_messageInfo_AssetDetails.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetDetails proto.InternalMessageInfo + +func (m *AssetDetails) GetOperatorAddress() string { + if m != nil { + return m.OperatorAddress + } + return "" +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "exocore.operator.v1.GenesisState") + proto.RegisterType((*OperatorDetail)(nil), "exocore.operator.v1.OperatorDetail") + proto.RegisterType((*OptedState)(nil), "exocore.operator.v1.OptedState") + proto.RegisterType((*AVSUSDValue)(nil), "exocore.operator.v1.AVSUSDValue") + proto.RegisterType((*OperatorUSDValue)(nil), "exocore.operator.v1.OperatorUSDValue") + proto.RegisterType((*OperatorSlashState)(nil), "exocore.operator.v1.OperatorSlashState") + proto.RegisterType((*PrevConsKey)(nil), "exocore.operator.v1.PrevConsKey") + proto.RegisterType((*OperatorKeyRemoval)(nil), "exocore.operator.v1.OperatorKeyRemoval") + proto.RegisterType((*OperatorConsKeyRecord)(nil), "exocore.operator.v1.OperatorConsKeyRecord") + proto.RegisterType((*ChainDetails)(nil), "exocore.operator.v1.ChainDetails") + proto.RegisterType((*StakerRecord)(nil), "exocore.operator.v1.StakerRecord") + proto.RegisterType((*StakerDetails)(nil), "exocore.operator.v1.StakerDetails") + proto.RegisterType((*AssetDetails)(nil), "exocore.operator.v1.AssetDetails") +} + +func init() { proto.RegisterFile("exocore/operator/v1/genesis.proto", fileDescriptor_bb7040bc6ae6ddee) } + +var fileDescriptor_bb7040bc6ae6ddee = []byte{ + // 886 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x36, 0xe3, 0x1f, 0xc9, 0x23,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31, 0xa6, 0x33, 0x2f, 0xa1, 0x67, 0x2c, 0xf5, 0x27, 0xd8, 0xa8, 0xbe, 0x47, 0x99, 0x52, + 0x11, 0x32, 0x5e, 0x43, 0xe7, 0xb3, 0x2d, 0x3c, 0xe8, 0xfc, 0x6a, 0xc1, 0xce, 0xb2, 0x2e, 0xc9, + 0xa7, 0x86, 0x0c, 0xfd, 0x20, 0x48, 0x28, 0x0a, 0x59, 0x5b, 0x87, 0xdb, 0x85, 0xa8, 0xba, 0xca, + 0x4c, 0x1e, 0x43, 0x3d, 0x0f, 0x0d, 0xa3, 0x97, 0xac, 0x71, 0x65, 0xdf, 0x3a, 0xac, 0x1d, 0xdd, + 0x5e, 0x59, 0xd8, 0x20, 0x7a, 0xc9, 0x74, 0x49, 0x36, 0x33, 0x6c, 0x8e, 0x07, 0x50, 0x68, 0x8f, + 0xec, 0xc2, 0xfa, 0x98, 0xce, 0x34, 0xb3, 0x38, 0x92, 0xfb, 0x50, 0x15, 0x12, 0x36, 0x88, 0x9a, + 0x6f, 0x17, 0xb0, 0xc1, 0x52, 0x61, 0x31, 0x97, 0x04, 0x53, 0xa8, 0x19, 0xea, 0x23, 0x07, 0x50, + 0x15, 0x62, 0x16, 0x3d, 0x2a, 0x9a, 0x5e, 0x6d, 0x31, 0x6f, 0x55, 0xba, 0xc7, 0x43, 0xd1, 0x9f, + 0x5b, 0xf1, 0x53, 0x14, 0x07, 0xf2, 0x25, 0x6c, 0x4a, 0x25, 0x6a, 0x52, 0xa7, 0x94, 0xb4, 0x4f, + 0x47, 0x12, 0xf5, 0x9b, 0x90, 0x4e, 0xb2, 0x25, 0x54, 0x69, 0xce, 0xef, 0x16, 0xec, 0x5e, 0x56, + 0x63, 0x49, 0x7b, 0x21, 0x5c, 0x65, 0xa2, 0xf2, 0x42, 0xfa, 0x9a, 0x70, 0xf5, 0xf6, 0xcb, 0x6e, + 0x73, 0xf9, 0xef, 0x69, 0xf9, 0xd7, 0x97, 0xcc, 0x6e, 0x5d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0xca, + 0x87, 0x2c, 0xf3, 0x96, 0x2b, 0xc8, 0xf2, 0xc4, 0x56, 0xd9, 0xa6, 0xff, 0x43, 0xfe, 0xe2, 0xef, + 0x61, 0xcb, 0x3f, 0x63, 0xd3, 0x88, 0xab, 0x11, 0xf7, 0xbe, 0x10, 0xd0, 0xff, 0xce, 0x5b, 0x07, + 0x27, 0x21, 0x3f, 0x9d, 0xbe, 0x68, 0x8f, 0xd8, 0x99, 0x7e, 0x28, 0xe8, 0x9f, 0xbb, 0x18, 0x8c, + 0x3b, 0x7c, 0x16, 0x53, 0x6c, 0x0f, 0x22, 0xfe, 0xf7, 0x9f, 0x77, 0x41, 0xbf, 0x23, 0x06, 0x11, + 0x77, 0x35, 0x56, 0xef, 0xf1, 0xab, 0x45, 0xd3, 0x7a, 0xbd, 0x68, 0x5a, 0xff, 0x2d, 0x9a, 0xd6, + 0x1f, 0x17, 0xcd, 0xb5, 0xd7, 0x17, 0xcd, 0xb5, 0x7f, 0x2e, 0x9a, 0x6b, 0x3f, 0x1c, 0x19, 0xb8, + 0x5f, 0xab, 0x3e, 0xbf, 0xa3, 0xfc, 0x27, 0x96, 0x8c, 0x3b, 0xd9, 0x5b, 0xe3, 0xbc, 0x78, 0x6d, + 0x48, 0x9e, 0x17, 0x5b, 0xf2, 0xb9, 0xf1, 0xf9, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x55, + 0xa8, 0x87, 0xf7, 0x08, 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.OperatorKeyRemovals) > 0 { + for iNdEx := len(m.OperatorKeyRemovals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorKeyRemovals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.PreConsKeys) > 0 { + for iNdEx := len(m.PreConsKeys) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PreConsKeys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.SlashStates) > 0 { + for iNdEx := len(m.SlashStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SlashStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.OperatorUSDValues) > 0 { + for iNdEx := len(m.OperatorUSDValues) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorUSDValues[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.AVSUSDValues) > 0 { + for iNdEx := len(m.AVSUSDValues) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AVSUSDValues[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.OptStates) > 0 { + for iNdEx := len(m.OptStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OptStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.OperatorRecords) > 0 { + for iNdEx := len(m.OperatorRecords) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Operators) > 0 { + for iNdEx := len(m.Operators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Operators[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 (m *OperatorDetail) 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 *OperatorDetail) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorDetail) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.OperatorInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OptedState) 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 *OptedState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptedState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.OptInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AVSUSDValue) 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 *AVSUSDValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AVSUSDValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.AVSAddr) > 0 { + i -= len(m.AVSAddr) + copy(dAtA[i:], m.AVSAddr) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AVSAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorUSDValue) 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 *OperatorUSDValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorUSDValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.OptedUSDValue.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorSlashState) 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 *OperatorSlashState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorSlashState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PrevConsKey) 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 *PrevConsKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PrevConsKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConsensusKey) > 0 { + i -= len(m.ConsensusKey) + copy(dAtA[i:], m.ConsensusKey) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConsensusKey))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorKeyRemoval) 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 *OperatorKeyRemoval) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorKeyRemoval) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorConsKeyRecord) 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 *OperatorConsKeyRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorConsKeyRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Chains) > 0 { + for iNdEx := len(m.Chains) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Chains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ChainDetails) 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 *ChainDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ChainDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConsensusKey) > 0 { + i -= len(m.ConsensusKey) + copy(dAtA[i:], m.ConsensusKey) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConsensusKey))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainID) > 0 { + i -= len(m.ChainID) + copy(dAtA[i:], m.ChainID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChainID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakerRecord) 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 *StakerRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakerRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.StakerDetails) > 0 { + for iNdEx := len(m.StakerDetails) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakerDetails[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.StakerID) > 0 { + i -= len(m.StakerID) + copy(dAtA[i:], m.StakerID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.StakerID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakerDetails) 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 *StakerDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakerDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Details) > 0 { + for iNdEx := len(m.Details) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Details[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AssetID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AssetDetails) 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 *AssetDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) + 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 + if len(m.Operators) > 0 { + for _, e := range m.Operators { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OperatorRecords) > 0 { + for _, e := range m.OperatorRecords { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OptStates) > 0 { + for _, e := range m.OptStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.AVSUSDValues) > 0 { + for _, e := range m.AVSUSDValues { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OperatorUSDValues) > 0 { + for _, e := range m.OperatorUSDValues { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.SlashStates) > 0 { + for _, e := range m.SlashStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PreConsKeys) > 0 { + for _, e := range m.PreConsKeys { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OperatorKeyRemovals) > 0 { + for _, e := range m.OperatorKeyRemovals { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *OperatorDetail) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.OperatorInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *OptedState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.OptInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *AVSUSDValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AVSAddr) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Value.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *OperatorUSDValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.OptedUSDValue.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *OperatorSlashState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Info.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *PrevConsKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.ConsensusKey) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *OperatorKeyRemoval) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *OperatorConsKeyRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Chains) > 0 { + for _, e := range m.Chains { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *ChainDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.ConsensusKey) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *StakerRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakerID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.StakerDetails) > 0 { + for _, e := range m.StakerDetails { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *StakerDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AssetID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Details) > 0 { + for _, e := range m.Details { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *AssetDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Amount.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 Operators", 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.Operators = append(m.Operators, OperatorDetail{}) + if err := m.Operators[len(m.Operators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorRecords", 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.OperatorRecords = append(m.OperatorRecords, OperatorConsKeyRecord{}) + if err := m.OperatorRecords[len(m.OperatorRecords)-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 OptStates", 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.OptStates = append(m.OptStates, OptedState{}) + if err := m.OptStates[len(m.OptStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AVSUSDValues", 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.AVSUSDValues = append(m.AVSUSDValues, AVSUSDValue{}) + if err := m.AVSUSDValues[len(m.AVSUSDValues)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorUSDValues", 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.OperatorUSDValues = append(m.OperatorUSDValues, OperatorUSDValue{}) + if err := m.OperatorUSDValues[len(m.OperatorUSDValues)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashStates", 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.SlashStates = append(m.SlashStates, OperatorSlashState{}) + if err := m.SlashStates[len(m.SlashStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreConsKeys", 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.PreConsKeys = append(m.PreConsKeys, PrevConsKey{}) + if err := m.PreConsKeys[len(m.PreConsKeys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorKeyRemovals", 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.OperatorKeyRemovals = append(m.OperatorKeyRemovals, OperatorKeyRemoval{}) + if err := m.OperatorKeyRemovals[len(m.OperatorKeyRemovals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorDetail) 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: OperatorDetail: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorDetail: 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 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.OperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorInfo", 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.OperatorInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OptedState) 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: OptedState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptedState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptInfo", 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.OptInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AVSUSDValue) 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: AVSUSDValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AVSUSDValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AVSAddr", 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.AVSAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", 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.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorUSDValue) 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: OperatorUSDValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorUSDValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptedUSDValue", 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.OptedUSDValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorSlashState) 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: OperatorSlashState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorSlashState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", 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.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrevConsKey) 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: PrevConsKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrevConsKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusKey", 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.ConsensusKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func (m *StakerDetails) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.AssetID) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - if len(m.Details) > 0 { - for _, e := range m.Details { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) + return nil +} +func (m *OperatorKeyRemoval) 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: OperatorKeyRemoval: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorKeyRemoval: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func (m *AssetDetails) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.OperatorAddress) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - l = m.Amount.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)))) + return nil } -func (m *GenesisState) Unmarshal(dAtA []byte) error { +func (m *OperatorConsKeyRecord) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -549,15 +2885,47 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + return fmt.Errorf("proto: OperatorConsKeyRecord: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OperatorConsKeyRecord: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operators", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", 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.OperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Chains", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -584,10 +2952,124 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Operators = append(m.Operators, OperatorInfo{}) - if err := m.Operators[len(m.Operators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Chains = append(m.Chains, ChainDetails{}) + if err := m.Chains[len(m.Chains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { return err } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ChainDetails) 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: ChainDetails: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ChainDetails: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainID", 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.ChainID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusKey", 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.ConsensusKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/operator/types/genesis_test.go b/x/operator/types/genesis_test.go index c5f92a283..1acf60f34 100644 --- a/x/operator/types/genesis_test.go +++ b/x/operator/types/genesis_test.go @@ -3,6 +3,10 @@ package types_test import ( "testing" + "github.com/ExocoreNetwork/exocore/utils" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/ethereum/go-ethereum/common/hexutil" + utiltx "github.com/ExocoreNetwork/exocore/testutil/tx" "github.com/ExocoreNetwork/exocore/x/operator/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -21,7 +25,9 @@ func TestGenesisTestSuite(t *testing.T) { } func (suite *GenesisTestSuite) TestValidateGenesis() { + key := hexutil.Encode(ed25519.GenPrivKey().PubKey().Bytes()) accAddress1 := sdk.AccAddress(utiltx.GenerateAddress().Bytes()) + accAddress2 := sdk.AccAddress(utiltx.GenerateAddress().Bytes()) newGen := &types.GenesisState{} testCases := []struct { @@ -43,9 +49,9 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { { name: "invalid genesis state due to non bech32 operator address", genState: &types.GenesisState{ - Operators: []types.OperatorInfo{ + Operators: []types.OperatorDetail{ { - EarningsAddr: "invalid", + OperatorAddress: "invalid", }, }, }, @@ -54,12 +60,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { { name: "invalid genesis state due to duplicate operator address", genState: &types.GenesisState{ - Operators: []types.OperatorInfo{ + Operators: []types.OperatorDetail{ { - EarningsAddr: accAddress1.String(), + OperatorAddress: accAddress1.String(), }, { - EarningsAddr: accAddress1.String(), + OperatorAddress: accAddress1.String(), }, }, }, @@ -68,18 +74,21 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { { name: "invalid genesis state due to duplicate lz chain id", genState: &types.GenesisState{ - Operators: []types.OperatorInfo{ - { - EarningsAddr: accAddress1.String(), - ClientChainEarningsAddr: &types.ClientChainEarningAddrList{ - EarningInfoList: []*types.ClientChainEarningAddrInfo{ - { - LzClientChainID: 1, - ClientChainEarningAddr: utiltx.GenerateAddress().String(), - }, - { - LzClientChainID: 1, - ClientChainEarningAddr: utiltx.GenerateAddress().String(), + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + OperatorInfo: types.OperatorInfo{ + EarningsAddr: accAddress1.String(), + ClientChainEarningsAddr: &types.ClientChainEarningAddrList{ + EarningInfoList: []*types.ClientChainEarningAddrInfo{ + { + LzClientChainID: 1, + ClientChainEarningAddr: utiltx.GenerateAddress().String(), + }, + { + LzClientChainID: 1, + ClientChainEarningAddr: utiltx.GenerateAddress().String(), + }, }, }, }, @@ -88,6 +97,128 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, expPass: false, }, + { + name: "invalid genesis state due to invalid cons key operator address", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: "invalid", + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to unregistered operator in cons key", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress2.String(), + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to duplicate operator in cons key", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + { + OperatorAddress: accAddress2.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key, + }, + }, + }, + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: hexutil.Encode(ed25519.GenPrivKey().PubKey().Bytes()), + }, + }, + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to invalid cons key", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key + "fake", + }, + }, + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to duplicate cons key for the same chain id", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + { + OperatorAddress: accAddress2.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key, + }, + }, + }, + { + OperatorAddress: accAddress2.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key, + }, + }, + }, + }, + }, + expPass: false, + }, } for _, tc := range testCases { diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index 6ce14a873..1033799af 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -3,6 +3,8 @@ package types import ( "math" + "golang.org/x/xerrors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -25,6 +27,13 @@ const ( SlashVetoDuration = int64(1000) UnbondingExpiration = 10 + + // AccAddressLength is used to parse the key, because the length isn't padded in the key + // This might be removed if the address length is padded in the key + AccAddressLength = 20 + + // ByteLengthForUint64 the type of chainID length is uint64, uint64 has 8 bytes. + ByteLengthForUint64 = 8 ) const ( @@ -32,8 +41,8 @@ const ( prefixOperatorOptedAVSInfo - prefixVotingPowerForAVS - prefixVotingPowerForOperator + prefixUSDValueForAVS + prefixUSDValueForOperator prefixOperatorSlashInfo @@ -68,13 +77,13 @@ var ( // operatorAddr + '/' + AVSAddr -> OptedInfo KeyPrefixOperatorOptedAVSInfo = []byte{prefixOperatorOptedAVSInfo} - // KeyPrefixVotingPowerForAVS key-value: - // AVSAddr -> types.DecValueField(the voting power of specified Avs) - KeyPrefixVotingPowerForAVS = []byte{prefixVotingPowerForAVS} + // KeyPrefixUSDValueForAVS key-value: + // AVSAddr -> types.DecValueField(the USD value of specified Avs) + KeyPrefixUSDValueForAVS = []byte{prefixUSDValueForAVS} - // KeyPrefixVotingPowerForOperator key-value: - // AVSAddr + '/' + operatorAddr -> types.OperatorUSDInfo (the voting power of specified operator and Avs) - KeyPrefixVotingPowerForOperator = []byte{prefixVotingPowerForOperator} + // KeyPrefixUSDValueForOperator key-value: + // AVSAddr + '/' + operatorAddr -> types.OperatorOptedUSDValue (the voting power of specified operator and Avs) + KeyPrefixUSDValueForOperator = []byte{prefixUSDValueForOperator} // KeyPrefixOperatorSlashInfo key-value: // operator + '/' + AVSAddr + '/' + slashId -> OperatorSlashInfo @@ -126,6 +135,29 @@ func KeyForOperatorAndChainIDToConsKey(addr sdk.AccAddress, chainID string) []by ) } +func ParseKeyForOperatorAndChainIDToConsKey(key []byte) (addr sdk.AccAddress, chainID string, err error) { + if len(key) < AccAddressLength+ByteLengthForUint64 { + return nil, "", xerrors.New("key length is too short to contain address and chainID length") + } + // Extract the address + addr = key[0:AccAddressLength] + if len(addr) == 0 { + return nil, "", xerrors.New("missing address") + } + + // Extract the chainID length + chainIDLen := sdk.BigEndianToUint64(key[AccAddressLength : AccAddressLength+ByteLengthForUint64]) + if len(key) != int(AccAddressLength+ByteLengthForUint64+chainIDLen) { + return nil, "", xerrors.Errorf("invalid key length,expected:%d,got:%d", AccAddressLength+ByteLengthForUint64+chainIDLen, len(key)) + } + + // Extract the chainID + chainIDBytes := key[AccAddressLength+ByteLengthForUint64:] + chainID = string(chainIDBytes) + + return addr, chainID, nil +} + func KeyForChainIDAndOperatorToPrevConsKey(chainID string, addr sdk.AccAddress) []byte { return ChainIDAndAddrKey( BytePrefixForOperatorAndChainIDToPrevConsKey, @@ -133,6 +165,31 @@ func KeyForChainIDAndOperatorToPrevConsKey(chainID string, addr sdk.AccAddress) ) } +func ParsePrevConsKey(key []byte) (chainID string, addr sdk.AccAddress, err error) { + // Check if the key has at least eight byte for the chainID length + if len(key) < ByteLengthForUint64 { + return "", nil, xerrors.New("key length is too short to contain chainID length") + } + + // Extract the chainID length + chainIDLen := sdk.BigEndianToUint64(key[0:ByteLengthForUint64]) + if len(key) < int(ByteLengthForUint64+chainIDLen) { + return "", nil, xerrors.New("key too short for chainID length") + } + + // Extract the chainID + chainIDBytes := key[ByteLengthForUint64 : ByteLengthForUint64+chainIDLen] + chainID = string(chainIDBytes) + + // Extract the address + addr = key[ByteLengthForUint64+chainIDLen:] + if len(addr) == 0 { + return "", nil, xerrors.New("missing address") + } + + return chainID, addr, nil +} + func KeyForChainIDAndOperatorToConsKey(chainID string, addr sdk.AccAddress) []byte { return ChainIDAndAddrKey( BytePrefixForChainIDAndOperatorToConsKey, @@ -155,6 +212,31 @@ func KeyForOperatorKeyRemovalForChainID(addr sdk.AccAddress, chainID string) []b ) } +func ParseKeyForOperatorKeyRemoval(key []byte) (addr sdk.AccAddress, chainID string, err error) { + // Check if the key has at least 20 byte for the operator and eight byte for the chainID length + if len(key) < AccAddressLength+ByteLengthForUint64 { + return nil, "", xerrors.New("key length is too short to contain operator address and chainID length") + } + + // Extract the address + addr = key[0:AccAddressLength] + if len(addr) == 0 { + return nil, "", xerrors.New("missing address") + } + + // Extract the chainID length + chainIDLen := sdk.BigEndianToUint64(key[AccAddressLength : AccAddressLength+ByteLengthForUint64]) + if len(key) != int(AccAddressLength+ByteLengthForUint64+chainIDLen) { + return nil, "", xerrors.Errorf("invalid key length,expected:%d,got:%d", AccAddressLength+ByteLengthForUint64+chainIDLen, len(key)) + } + + // Extract the chainID + chainIDBytes := key[AccAddressLength+ByteLengthForUint64:] + chainID = string(chainIDBytes) + + return addr, chainID, nil +} + func IterateOperatorsForAVSPrefix(avsAddr string) []byte { tmp := append([]byte(avsAddr), '/') return tmp diff --git a/x/operator/types/keys_test.go b/x/operator/types/keys_test.go new file mode 100644 index 000000000..713b6609a --- /dev/null +++ b/x/operator/types/keys_test.go @@ -0,0 +1,58 @@ +package types + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" +) + +type KeysTestSuite struct { + suite.Suite +} + +func (suite *KeysTestSuite) SetupTest() { +} + +func TestKeysTestSuite(t *testing.T) { + suite.Run(t, new(KeysTestSuite)) +} + +func (suite *KeysTestSuite) TestParseKeyForOperatorAndChainIDToConsKey() { + operator := "exo1rtg0cgw94ep744epyvanc0wdd5kedwql73vlmr" + operatorAddr, err := sdk.AccAddressFromBech32(operator) + suite.NoError(err) + chainIDWithoutRevision := "exocoretestnet_233" + key := KeyForOperatorAndChainIDToConsKey(operatorAddr, chainIDWithoutRevision) + + parsedAddr, parsedChainID, err := ParseKeyForOperatorAndChainIDToConsKey(key[1:]) + suite.NoError(err) + suite.Equal(operatorAddr, parsedAddr) + suite.Equal(chainIDWithoutRevision, parsedChainID) +} + +func (suite *KeysTestSuite) TestParsePrevConsKey() { + operator := "exo1rtg0cgw94ep744epyvanc0wdd5kedwql73vlmr" + operatorAddr, err := sdk.AccAddressFromBech32(operator) + suite.NoError(err) + chainIDWithoutRevision := "exocoretestnet_233" + key := KeyForChainIDAndOperatorToPrevConsKey(chainIDWithoutRevision, operatorAddr) + + parsedChainID, parsedAddr, err := ParsePrevConsKey(key[1:]) + suite.NoError(err) + suite.Equal(operatorAddr, parsedAddr) + suite.Equal(chainIDWithoutRevision, parsedChainID) +} + +func (suite *KeysTestSuite) TestParseKeyForOperatorKeyRemoval() { + operator := "exo1rtg0cgw94ep744epyvanc0wdd5kedwql73vlmr" + operatorAddr, err := sdk.AccAddressFromBech32(operator) + suite.NoError(err) + chainIDWithoutRevision := "exocoretestnet_233" + key := KeyForOperatorKeyRemovalForChainID(operatorAddr, chainIDWithoutRevision) + + parsedAddr, parsedChainID, err := ParseKeyForOperatorKeyRemoval(key[1:]) + suite.NoError(err) + suite.Equal(operatorAddr, parsedAddr) + suite.Equal(chainIDWithoutRevision, parsedChainID) +} diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 363ddcfd0..1f5a8c1ed 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -564,9 +564,9 @@ type SlashExecutionInfo struct { // slash_value is the usd value of all slashed assets SlashValue github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=slash_value,json=slashValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_value"` // SlashUndelegations records all slash info related to the undelegation - SlashUndelegations []*SlashFromUndelegation `protobuf:"bytes,3,rep,name=slash_undelegations,json=slashUndelegations,proto3" json:"slash_undelegations,omitempty"` + SlashUndelegations []SlashFromUndelegation `protobuf:"bytes,3,rep,name=slash_undelegations,json=slashUndelegations,proto3" json:"slash_undelegations"` // SlashFromAssetsPool records all slash info related to the assets pool - SlashAssetsPool []*SlashFromAssetsPool `protobuf:"bytes,4,rep,name=slash_assets_pool,json=slashAssetsPool,proto3" json:"slash_assets_pool,omitempty"` + SlashAssetsPool []SlashFromAssetsPool `protobuf:"bytes,4,rep,name=slash_assets_pool,json=slashAssetsPool,proto3" json:"slash_assets_pool"` } func (m *SlashExecutionInfo) Reset() { *m = SlashExecutionInfo{} } @@ -602,14 +602,14 @@ func (m *SlashExecutionInfo) XXX_DiscardUnknown() { var xxx_messageInfo_SlashExecutionInfo proto.InternalMessageInfo -func (m *SlashExecutionInfo) GetSlashUndelegations() []*SlashFromUndelegation { +func (m *SlashExecutionInfo) GetSlashUndelegations() []SlashFromUndelegation { if m != nil { return m.SlashUndelegations } return nil } -func (m *SlashExecutionInfo) GetSlashAssetsPool() []*SlashFromAssetsPool { +func (m *SlashExecutionInfo) GetSlashAssetsPool() []SlashFromAssetsPool { if m != nil { return m.SlashAssetsPool } @@ -1057,104 +1057,104 @@ func init() { func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 1540 bytes of a gzipped FileDescriptorProto + // 1545 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcb, 0x4f, 0x1b, 0xd7, 0x1a, 0x67, 0x6c, 0x5e, 0xfe, 0x6c, 0x63, 0x33, 0xe4, 0xe1, 0xf8, 0xe6, 0xe2, 0x30, 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xef, 0x7b, 0xf2, 0x6c, 0xbc, 0xef, 0xc7, 0x67, 0xe3, 0x7d, 0xef, 0xcd, 0x85, 0x5e, 0xc5, - 0x45, 0x3f, 0x64, 0x05, 0xd1, 0x0f, 0xb1, 0xb7, 0xdd, 0x46, 0xd8, 0x39, 0xc0, 0xe0, 0xaf, 0xe4, - 0xc6, 0x20, 0xff, 0x2f, 0xc5, 0xe5, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x70, 0x53, 0xec, 0xcd, - 0x7b, 0x11, 0x00, 0x00, + 0x0c, 0x44, 0x6a, 0xaa, 0x6a, 0x34, 0x8c, 0x0f, 0x66, 0xc2, 0x78, 0xce, 0x74, 0xce, 0xb1, 0x0b, + 0x59, 0x55, 0x59, 0x45, 0x55, 0x17, 0x95, 0xb2, 0xaa, 0xda, 0x45, 0x56, 0x55, 0x97, 0x59, 0x64, + 0x5b, 0xb5, 0xdd, 0x65, 0x19, 0xa5, 0x5d, 0x54, 0x5d, 0xd0, 0x8a, 0x54, 0x4a, 0xff, 0x88, 0x56, + 0xaa, 0xce, 0x99, 0x33, 0x66, 0x9c, 0xd8, 0x24, 0x28, 0xa4, 0x1b, 0xe0, 0x7c, 0xaf, 0xdf, 0xef, + 0x7b, 0x9c, 0xef, 0xd8, 0xc0, 0x59, 0xb4, 0x83, 0x4d, 0xec, 0xa1, 0x02, 0x76, 0x91, 0x67, 0x50, + 0xec, 0x15, 0x5a, 0xb3, 0x05, 0xba, 0x93, 0x77, 0x3d, 0x4c, 0xb1, 0x3c, 0x26, 0xb4, 0xf9, 0x40, + 0x9b, 0x6f, 0xcd, 0x66, 0x47, 0x8d, 0x86, 0xe5, 0xe0, 0x02, 0xff, 0xe9, 0xdb, 0x65, 0x4f, 0x9b, + 0x98, 0x34, 0x30, 0x29, 0x34, 0x48, 0x9d, 0xf9, 0x37, 0x48, 0x5d, 0x28, 0xfe, 0x21, 0x14, 0x84, + 0x1a, 0xdb, 0x96, 0xc3, 0x94, 0x1b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0x7a, 0xb5, 0x91, 0x60, 0x93, 0xe7, 0x6c, 0xa6, 0x94, 0xc9, 0x43, 0xd8, 0x84, 0x23, + 0x0f, 0x7c, 0xc4, 0xbe, 0x27, 0xcc, 0x2f, 0x3f, 0xde, 0x1f, 0x97, 0x9e, 0xec, 0x8f, 0x4b, 0xbf, + 0xec, 0x8f, 0x4b, 0x9f, 0x3e, 0x1b, 0xef, 0x7b, 0xf2, 0x6c, 0xbc, 0xef, 0xc7, 0x67, 0xe3, 0x7d, + 0xb7, 0xe6, 0x42, 0xaf, 0xe2, 0xa2, 0x1f, 0xb2, 0x82, 0xe8, 0x87, 0xd8, 0xdb, 0x6e, 0x23, 0xec, + 0x1c, 0x60, 0xf0, 0x57, 0x72, 0x63, 0x90, 0xff, 0xc7, 0xe2, 0xf2, 0x9f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x0c, 0x47, 0x83, 0x3c, 0x87, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3788,7 +3788,7 @@ func (m *SlashExecutionInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SlashUndelegations = append(m.SlashUndelegations, &SlashFromUndelegation{}) + m.SlashUndelegations = append(m.SlashUndelegations, SlashFromUndelegation{}) if err := m.SlashUndelegations[len(m.SlashUndelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3822,7 +3822,7 @@ func (m *SlashExecutionInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SlashAssetsPool = append(m.SlashAssetsPool, &SlashFromAssetsPool{}) + m.SlashAssetsPool = append(m.SlashAssetsPool, SlashFromAssetsPool{}) if err := m.SlashAssetsPool[len(m.SlashAssetsPool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/reward/keeper/claim_reward_test.go b/x/reward/keeper/claim_reward_test.go index b8f27193f..5a275401e 100644 --- a/x/reward/keeper/claim_reward_test.go +++ b/x/reward/keeper/claim_reward_test.go @@ -43,5 +43,5 @@ func (suite *RewardTestSuite) TestClaimWithdrawRequest() { assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) - suite.Equal(sdkmath.NewInt(10).Add(assets[assetID].StakingTotalAmount), assetInfo.StakingTotalAmount) + suite.Equal(sdkmath.NewInt(10).Add(assets[0].StakingTotalAmount), assetInfo.StakingTotalAmount) } diff --git a/x/slash/keeper/execute_slash_test.go b/x/slash/keeper/execute_slash_test.go index 6fbc06b68..e2cb683b6 100644 --- a/x/slash/keeper/execute_slash_test.go +++ b/x/slash/keeper/execute_slash_test.go @@ -66,5 +66,5 @@ func (suite *SlashTestSuite) TestSlash() { assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) - suite.Equal(assets[assetID].StakingTotalAmount.Add(depositEvent.OpAmount).Sub(event.OpAmount), assetInfo.StakingTotalAmount) + suite.Equal(assets[0].StakingTotalAmount.Add(depositEvent.OpAmount).Sub(event.OpAmount), assetInfo.StakingTotalAmount) } From 88c8cc038c574168f32140c3d488eb4f5929ea2d Mon Sep 17 00:00:00 2001 From: Leon <156270887+leonz789@users.noreply.github.com> Date: Mon, 23 Sep 2024 07:41:44 +0800 Subject: [PATCH 4/5] feat:register vesting type, add support for delegation/undelegation of native token (#127) * feat:register vesting type, add support for delegation/undelegation of native token * feat: native token delegation/undelegation * test: replace epochs_beginblock with epochInfo_endEpoch * fix cli support native delegatio/undelegation * typo, check zero not negative of inputs, use denom from utils * remove approveinfo from msg define, refactor cli, do not use must in service-funciton * update test based on new epoch implementation * refactor * refactor * lint * add validation for delegate/undelegate msg * set default price for exo-native-toekn, testnet only * rebase --- app/app.go | 26 +- proto/exocore/delegation/v1/tx.proto | 20 +- testutil/utils.go | 1 - x/assets/client/cli/tx.go | 3 - x/assets/keeper/bank.go | 24 +- x/assets/keeper/expected_keepers.go | 11 + x/assets/keeper/keeper.go | 6 + x/assets/keeper/staker_asset.go | 46 ++ x/assets/keeper/staker_asset_test.go | 2 +- x/assets/types/expected_keepers.go | 4 + x/assets/types/general.go | 7 + x/delegation/client/cli/tx.go | 4 +- .../client/cli/tx_delegation_native.go | 82 +++ x/delegation/keeper/abci.go | 34 +- x/delegation/keeper/delegation.go | 38 +- x/delegation/keeper/delegation_op_test.go | 214 +++++- x/delegation/keeper/delegation_state.go | 2 +- x/delegation/keeper/keeper.go | 12 + x/delegation/keeper/msg_server.go | 90 ++- x/delegation/keeper/setup_test.go | 2 + x/delegation/keeper/share.go | 17 +- x/delegation/types/cross_chain_params.go | 22 + x/delegation/types/errors.go | 5 +- x/delegation/types/expected_keepers.go | 10 + x/delegation/types/general.go | 7 + x/delegation/types/msg.go | 58 +- x/delegation/types/tx.pb.go | 624 +++++------------- x/oracle/keeper/prices.go | 17 + x/reward/keeper/claim_reward.go | 15 +- x/slash/keeper/execute_slash.go | 47 +- 30 files changed, 874 insertions(+), 576 deletions(-) create mode 100644 x/assets/keeper/expected_keepers.go create mode 100644 x/delegation/client/cli/tx_delegation_native.go diff --git a/app/app.go b/app/app.go index 85acd0a81..b4be93c37 100644 --- a/app/app.go +++ b/app/app.go @@ -116,6 +116,8 @@ import ( authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" @@ -248,6 +250,7 @@ var ( ibctm.AppModuleBasic{}, ica.AppModuleBasic{}, authzmodule.AppModuleBasic{}, + vesting.AppModuleBasic{}, feegrantmodule.AppModuleBasic{}, upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, @@ -278,8 +281,9 @@ var ( authtypes.Minter, authtypes.Burner, }, // used for secure addition and subtraction of balance using module account - erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, - exominttypes.ModuleName: {authtypes.Minter}, + exominttypes.ModuleName: {authtypes.Minter}, + erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, + delegationTypes.DelegatedPoolName: {authtypes.Burner, authtypes.Staking}, } // module accounts that are allowed to receive tokens @@ -534,7 +538,7 @@ func NewExocoreApp( ) // asset and client chain registry. - app.AssetsKeeper = assetsKeeper.NewKeeper(keys[assetsTypes.StoreKey], appCodec, &app.OracleKeeper) + app.AssetsKeeper = assetsKeeper.NewKeeper(keys[assetsTypes.StoreKey], appCodec, &app.OracleKeeper, app.BankKeeper, &app.DelegationKeeper) // handles delegations by stakers, and must know if the delegatee operator is registered. app.DelegationKeeper = delegationKeeper.NewKeeper( @@ -542,6 +546,8 @@ func NewExocoreApp( app.AssetsKeeper, delegationTypes.VirtualSlashKeeper{}, &app.OperatorKeeper, + app.AccountKeeper, + app.BankKeeper, ) // the dogfood module is the first AVS. it receives slashing calls from either x/slashing @@ -728,15 +734,15 @@ func NewExocoreApp( Create Transfer Stack transfer stack contains (from bottom to top): - - ERC-20 Middleware - - Recovery Middleware - - IBC Transfer + - ERC-20 Middleware + - Recovery Middleware + - IBC Transfer SendPacket, since it is originating from the application to core IBC: - transferKeeper.SendPacket -> recovery.SendPacket -> erc20.SendPacket -> channel.SendPacket + transferKeeper.SendPacket -> recovery.SendPacket -> erc20.SendPacket -> channel.SendPacket RecvPacket, message that originates from core IBC and goes down to app, the flow is the other way - channel.RecvPacket -> erc20.OnRecvPacket -> recovery.OnRecvPacket -> transfer.OnRecvPacket + channel.RecvPacket -> erc20.OnRecvPacket -> recovery.OnRecvPacket -> transfer.OnRecvPacket */ // create IBC module from top to bottom of stack @@ -802,6 +808,7 @@ func NewExocoreApp( authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName), ), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), bank.NewAppModule( appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), @@ -890,6 +897,7 @@ func NewExocoreApp( genutiltypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, + vestingtypes.ModuleName, consensusparamtypes.ModuleName, erc20types.ModuleName, exominttypes.ModuleName, // called via hooks not directly @@ -924,6 +932,7 @@ func NewExocoreApp( authz.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, + vestingtypes.ModuleName, epochstypes.ModuleName, // begin blocker only erc20types.ModuleName, exominttypes.ModuleName, @@ -968,6 +977,7 @@ func NewExocoreApp( oracleTypes.ModuleName, // after staking module to ensure total vote power available // no-op modules paramstypes.ModuleName, + vestingtypes.ModuleName, consensusparamtypes.ModuleName, upgradetypes.ModuleName, // no-op since we don't call SetInitVersionMap rewardTypes.ModuleName, // not fully implemented yet diff --git a/proto/exocore/delegation/v1/tx.proto b/proto/exocore/delegation/v1/tx.proto index 299f2584a..2bebe49bb 100644 --- a/proto/exocore/delegation/v1/tx.proto +++ b/proto/exocore/delegation/v1/tx.proto @@ -39,14 +39,6 @@ message KeyValue { ValueField value = 2; } -// DelegationApproveInfo is the delegation approve info. -message DelegationApproveInfo { - // signature of the delegation approve info. - string signature = 1; - // salt within the signature. - string salt = 2; -} - // DelegationIncOrDecInfo is the delegation increase or decrease info. message DelegationIncOrDecInfo { option (cosmos.msg.v1.signer) = "fromAddress"; @@ -59,15 +51,15 @@ message DelegationIncOrDecInfo { string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // per_operator_amounts is the amount of the asset delegated to each operator. - map per_operator_amounts = 2; + repeated KeyValue per_operator_amounts = 2 [(gogoproto.nullable) = false]; } // MsgDelegation is the delegation Msg. message MsgDelegation { + // asset_id is the asset id. + string asset_id = 1 [(gogoproto.customname) = "AssetID"]; // base_info is the delegation increase or decrease request container. - DelegationIncOrDecInfo base_info = 1; - // approved_info is the delegation increase or decrease response container. - DelegationApproveInfo approved_info = 2; + DelegationIncOrDecInfo base_info = 2; } // UndelegationRecord is the undelegation record, keyed by a RecordKey. @@ -117,8 +109,10 @@ message DelegationResponse {} // MsgUndelegation is the undelegation Msg. message MsgUndelegation { + // asset_id is the identity of the asset. + string asset_id = 1 [(gogoproto.customname) = "AssetID"]; // base_info is the delegation increase or decrease request container. - DelegationIncOrDecInfo base_info = 1; + DelegationIncOrDecInfo base_info = 2; } // UndelegationResponse is the response to an undelegation request. diff --git a/testutil/utils.go b/testutil/utils.go index 099582bd2..db3bf6e55 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -441,7 +441,6 @@ func (suite *BaseTestSuite) DoSetupTest() { Address: acc.GetAddress().String(), Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), } - // Exocore modules genesis // x/assets suite.ClientChains = []assetstypes.ClientChainInfo{ diff --git a/x/assets/client/cli/tx.go b/x/assets/client/cli/tx.go index d88427225..3937ba538 100644 --- a/x/assets/client/cli/tx.go +++ b/x/assets/client/cli/tx.go @@ -48,9 +48,6 @@ func UpdateParams() *cobra.Command { }, } - if err := msg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) }, } diff --git a/x/assets/keeper/bank.go b/x/assets/keeper/bank.go index 0bb3a1239..75960bce2 100644 --- a/x/assets/keeper/bank.go +++ b/x/assets/keeper/bank.go @@ -40,16 +40,20 @@ func (k Keeper) PerformDepositOrWithdraw(ctx sdk.Context, params *DepositWithdra TotalDepositAmount: actualOpAmount, WithdrawableAmount: actualOpAmount, } - // update asset state of the specified staker - err := k.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) - if err != nil { - return errorsmod.Wrapf(err, "stakeID:%s assetID:%s", stakeID, assetID) - } - - // update total amount of the deposited asset - err = k.UpdateStakingAssetTotalAmount(ctx, assetID, actualOpAmount) - if err != nil { - return errorsmod.Wrapf(err, "assetID:%s", assetID) + // don't update staker info for exo-native-token + // TODO: do we need additional process for exo-native-token ? + if assetID != assetstypes.NativeAssetID { + // update asset state of the specified staker + err := k.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) + if err != nil { + return errorsmod.Wrapf(err, "stakeID:%s assetID:%s", stakeID, assetID) + } + + // update total amount of the deposited asset + err = k.UpdateStakingAssetTotalAmount(ctx, assetID, actualOpAmount) + if err != nil { + return errorsmod.Wrapf(err, "assetID:%s", assetID) + } } return nil } diff --git a/x/assets/keeper/expected_keepers.go b/x/assets/keeper/expected_keepers.go new file mode 100644 index 000000000..a25707043 --- /dev/null +++ b/x/assets/keeper/expected_keepers.go @@ -0,0 +1,11 @@ +package keeper + +import ( + delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// this keeper interface is defined here to avoid a circular dependency +type delegationKeeper interface { + GetDelegationInfo(ctx sdk.Context, stakerID, assetID string) (*delegationtype.QueryDelegationInfoResponse, error) +} diff --git a/x/assets/keeper/keeper.go b/x/assets/keeper/keeper.go index c2477d076..e4c324a27 100644 --- a/x/assets/keeper/keeper.go +++ b/x/assets/keeper/keeper.go @@ -13,17 +13,23 @@ type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec assetstype.OracleKeeper + bk assetstype.BankKeeper + dk delegationKeeper } func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, oracleKeeper assetstype.OracleKeeper, + bk assetstype.BankKeeper, + dk delegationKeeper, ) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, OracleKeeper: oracleKeeper, + bk: bk, + dk: dk, } } diff --git a/x/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go index 0d90d47ce..5beaceb8e 100644 --- a/x/assets/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -4,6 +4,8 @@ import ( "fmt" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + delegationkeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" + "github.com/ethereum/go-ethereum/common/hexutil" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -63,10 +65,54 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInf Info: stateInfo, }) } + // add exo-native-token info + info, err := k.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetstype.NativeAssetID) + if err != nil { + return nil, err + } + ret = append(ret, assetstype.DepositByAsset{ + AssetID: assetstype.NativeAssetID, + Info: *info, + }) return ret, nil } func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerAssetInfo, err error) { + if assetID == assetstype.NativeAssetID { + stakerAddrStr, _, err := assetstype.ParseID(stakerID) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to parse stakerID") + } + stakerAccDecode, err := hexutil.Decode(stakerAddrStr) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to decode staker address") + } + stakerAcc := sdk.AccAddress(stakerAccDecode) + balance := k.bk.GetBalance(ctx, stakerAcc, assetstype.NativeAssetDenom) + info := &assetstype.StakerAssetInfo{ + TotalDepositAmount: balance.Amount, + WithdrawableAmount: balance.Amount, + PendingUndelegationAmount: math.NewInt(0), + } + + delegationInfoRecords, err := k.dk.GetDelegationInfo(ctx, stakerID, assetID) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to GetDelegationInfo") + } + for operator, record := range delegationInfoRecords.DelegationInfos { + operatorAssetInfo, err := k.GetOperatorSpecifiedAssetInfo(ctx, sdk.MustAccAddressFromBech32(operator), assetID) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to GetOperatorSpecifiedAssetInfo") + } + undelegatableTokens, err := delegationkeeper.TokensFromShares(record.UndelegatableShare, operatorAssetInfo.TotalShare, operatorAssetInfo.TotalAmount) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get shares from token") + } + info.TotalDepositAmount = info.TotalDepositAmount.Add(undelegatableTokens).Add(record.WaitUndelegationAmount) + info.PendingUndelegationAmount = info.PendingUndelegationAmount.Add(record.WaitUndelegationAmount) + } + return info, nil + } store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) key := assetstype.GetJoinedStoreKey(stakerID, assetID) value := store.Get(key) diff --git a/x/assets/keeper/staker_asset_test.go b/x/assets/keeper/staker_asset_test.go index 27e3e72be..7e8530075 100644 --- a/x/assets/keeper/staker_asset_test.go +++ b/x/assets/keeper/staker_asset_test.go @@ -81,7 +81,7 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { } func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { - stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") + stakerID := fmt.Sprintf("%s_%s", suite.Address, "0x0") ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") ethUniInitialChangeValue := assetstype.DeltaStakerSingleAsset{ diff --git a/x/assets/types/expected_keepers.go b/x/assets/types/expected_keepers.go index d0a9e8f19..ee97079ed 100644 --- a/x/assets/types/expected_keepers.go +++ b/x/assets/types/expected_keepers.go @@ -9,3 +9,7 @@ type OracleKeeper interface { GetSpecifiedAssetsPrice(ctx sdk.Context, assetID string) (oracletypes.Price, error) RegisterNewTokenAndSetTokenFeeder(ctx sdk.Context, oInfo *oracletypes.OracleInfo) error } + +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin +} diff --git a/x/assets/types/general.go b/x/assets/types/general.go index bcbd0f8f5..3b95b7809 100644 --- a/x/assets/types/general.go +++ b/x/assets/types/general.go @@ -13,6 +13,13 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) +const ( + NativeChainLzID = 0 + NativeAssetAddr = "0x0000000000000000000000000000000000000000" + NativeAssetID = "0x0000000000000000000000000000000000000000_0x0" + NativeAssetDenom = utils.BaseDenom +) + const ( CrossChainActionLength = 1 CrossChainOpAmountLength = 32 diff --git a/x/delegation/client/cli/tx.go b/x/delegation/client/cli/tx.go index 3e8854a55..a7d35b7ba 100644 --- a/x/delegation/client/cli/tx.go +++ b/x/delegation/client/cli/tx.go @@ -18,7 +18,9 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - // add tx commands + // add tx commands + CmdDelegate(), + CmdUndelegate(), ) return txCmd } diff --git a/x/delegation/client/cli/tx_delegation_native.go b/x/delegation/client/cli/tx_delegation_native.go new file mode 100644 index 000000000..050754637 --- /dev/null +++ b/x/delegation/client/cli/tx_delegation_native.go @@ -0,0 +1,82 @@ +package cli + +import ( + "errors" + + sdkmath "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/delegation/types" +) + +func CmdDelegate() *cobra.Command { + cmd := &cobra.Command{ + // TODO: only support native token for now + Use: "delegate asset-id operator amount", + Short: "Broadcast a transaction to delegate amount of native token to the operator", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + assetID, operatorAddrStr, amount, err := parseArgs(args) + if err != nil { + return err + } + msg := types.NewMsgDelegation(assetID, clientCtx.GetFromAddress().String(), []types.KeyValue{{Key: operatorAddrStr, Value: &types.ValueField{Amount: amount}}}) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +func CmdUndelegate() *cobra.Command { + cmd := &cobra.Command{ + // TODO: only support native token for now + Use: "undelegate asset-id operator amount", + Short: "Broadcast a transaction to undelegate amount of native token from the operator", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + assetID, operatorAddrStr, amount, err := parseArgs(args) + if err != nil { + return err + } + + msg := types.NewMsgUndelegation(assetID, clientCtx.GetFromAddress().String(), []types.KeyValue{{Key: operatorAddrStr, Value: &types.ValueField{Amount: amount}}}) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +func parseArgs(args []string) (string, string, sdkmath.Int, error) { + if len(args) != 3 { + return "", "", sdkmath.ZeroInt(), errors.New("3 arguments needed") + } + + assetID := args[0] + operatorAddrStr := args[1] + + amount, ok := sdkmath.NewIntFromString(args[2]) + if !ok || amount.LTE(sdkmath.ZeroInt()) { + return "", "", sdkmath.ZeroInt(), errors.New("amount invalid") + } + + return assetID, operatorAddrStr, amount, nil +} diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index f9c84f69a..bbc742d56 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -1,10 +1,14 @@ package keeper import ( - "github.com/ExocoreNetwork/exocore/x/assets/types" - delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + "strings" + + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" + "github.com/ExocoreNetwork/exocore/x/delegation/types" + abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common/hexutil" ) // EndBlock : completed Undelegation events according to the canCompleted blockHeight @@ -34,7 +38,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida continue }*/ - recordID := delegationtype.GetUndelegationRecordKey(record.BlockNumber, record.LzTxNonce, record.TxHash, record.OperatorAddr) + recordID := types.GetUndelegationRecordKey(record.BlockNumber, record.LzTxNonce, record.TxHash, record.OperatorAddr) if k.GetUndelegationHoldCount(ctx, recordID) > 0 { // store it again with the next block and move on // #nosec G701 @@ -55,7 +59,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida recordAmountNeg := record.Amount.Neg() // update delegation state - deltaAmount := &delegationtype.DeltaDelegationAmounts{ + deltaAmount := &types.DeltaDelegationAmounts{ WaitUndelegationAmount: recordAmountNeg, } _, err = k.UpdateDelegationState(ctx, record.StakerID, record.AssetID, record.OperatorAddr, deltaAmount) @@ -65,16 +69,24 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } // update the staker state - err = k.assetsKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.DeltaStakerSingleAsset{ - WithdrawableAmount: record.ActualCompletedAmount, - PendingUndelegationAmount: recordAmountNeg, - }) - if err != nil { - panic(err) + if record.AssetID == assetstypes.NativeAssetID { + parsedStakerID := strings.Split(record.StakerID, "_") + stakerAddr := sdk.AccAddress(hexutil.MustDecode(parsedStakerID[0])) + if err := k.bankKeeper.UndelegateCoinsFromModuleToAccount(ctx, types.DelegatedPoolName, stakerAddr, sdk.NewCoins(sdk.NewCoin(assetstypes.NativeAssetDenom, record.ActualCompletedAmount))); err != nil { + panic(err) + } + } else { + err = k.assetsKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, assetstypes.DeltaStakerSingleAsset{ + WithdrawableAmount: record.ActualCompletedAmount, + PendingUndelegationAmount: recordAmountNeg, + }) + if err != nil { + panic(err) + } } // update the operator state - err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.DeltaOperatorSingleAsset{ + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, assetstypes.DeltaOperatorSingleAsset{ PendingUndelegationAmount: recordAmountNeg, }) if err != nil { diff --git a/x/delegation/keeper/delegation.go b/x/delegation/keeper/delegation.go index 344ccc4c7..0dd37d1a9 100644 --- a/x/delegation/keeper/delegation.go +++ b/x/delegation/keeper/delegation.go @@ -38,25 +38,31 @@ func (k *Keeper) delegateTo( } stakerID, assetID := assetstype.GetStakeIDAndAssetID(params.ClientChainID, params.StakerAddress, params.AssetsAddress) + if assetID != assetstype.NativeAssetID { + // check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount + info, err := k.assetsKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) + if err != nil { + return err + } - // check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount - info, err := k.assetsKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) - if err != nil { - return err - } - - if info.WithdrawableAmount.LT(params.OpAmount) { - return errorsmod.Wrap(delegationtype.ErrDelegationAmountTooBig, fmt.Sprintf("the opAmount is:%s the WithdrawableAmount amount is:%s", params.OpAmount, info.WithdrawableAmount)) - } + if info.WithdrawableAmount.LT(params.OpAmount) { + return errorsmod.Wrap(delegationtype.ErrDelegationAmountTooBig, fmt.Sprintf("the opAmount is:%s the WithdrawableAmount amount is:%s", params.OpAmount, info.WithdrawableAmount)) + } - // update staker asset state - err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.DeltaStakerSingleAsset{ - WithdrawableAmount: params.OpAmount.Neg(), - }) - if err != nil { - return err + // update staker asset state + err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.DeltaStakerSingleAsset{ + WithdrawableAmount: params.OpAmount.Neg(), + }) + if err != nil { + return err + } + } else { + coins := sdk.NewCoins(sdk.NewCoin(assetstype.NativeAssetDenom, params.OpAmount)) + // transfer the delegation amount from the staker account to the delegated pool + if err := k.bankKeeper.DelegateCoinsFromAccountToModule(ctx, params.StakerAddress, delegationtype.DelegatedPoolName, coins); err != nil { + return err + } } - // calculate the share from the delegation amount share, err := k.CalculateShare(ctx, params.OperatorAddress, assetID, params.OpAmount) if err != nil { diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 37ce9c637..910e5555e 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -2,11 +2,12 @@ package keeper_test import ( "fmt" - - assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + "time" errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" @@ -24,6 +25,7 @@ func (suite *DelegationTestSuite) prepare() { suite.opAccAddr = opAccAddr suite.depositAmount = sdkmath.NewInt(100) suite.delegationAmount = sdkmath.NewInt(50) + suite.accAddr = sdk.AccAddress(suite.Address.Bytes()) } func (suite *DelegationTestSuite) prepareDeposit() *assetskeeper.DepositWithdrawParams { @@ -65,6 +67,22 @@ func (suite *DelegationTestSuite) prepareDelegation() *delegationtype.Delegation return delegationEvent } +func (suite *DelegationTestSuite) prepareDelegationNativeToken() *delegationtype.DelegationOrUndelegationParams { + delegationEvent := &delegationtype.DelegationOrUndelegationParams{ + ClientChainID: assetstypes.NativeChainLzID, + Action: types.DelegateTo, + AssetsAddress: common.HexToAddress(assetstypes.NativeAssetAddr).Bytes(), + OperatorAddress: suite.opAccAddr, + StakerAddress: suite.accAddr[:], + OpAmount: suite.delegationAmount, + LzNonce: 0, + TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), + } + err := suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationEvent) + suite.NoError(err) + return delegationEvent +} + func (suite *DelegationTestSuite) TestDelegateTo() { suite.prepareDeposit() opAccAddr, err := sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") @@ -123,6 +141,50 @@ func (suite *DelegationTestSuite) TestDelegateTo() { totalDelegationAmount, err := suite.App.DelegationKeeper.StakerDelegatedTotalAmount(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(delegationParams.OpAmount, totalDelegationAmount) + + // delegate exocore-native-token + delegationParams = &delegationtype.DelegationOrUndelegationParams{ + ClientChainID: assetstypes.NativeChainLzID, + Action: types.DelegateTo, + AssetsAddress: common.HexToAddress(assetstypes.NativeAssetAddr).Bytes(), + OperatorAddress: opAccAddr, + StakerAddress: suite.accAddr[:], + OpAmount: sdkmath.NewInt(50), + LzNonce: 0, + TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), + } + err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationParams) + suite.NoError(err) + // check delegation states + stakerID, assetID = types.GetStakeIDAndAssetID(delegationParams.ClientChainID, delegationParams.StakerAddress, delegationParams.AssetsAddress) + restakerState, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + suite.NoError(err) + balance := suite.App.BankKeeper.GetBalance(suite.Ctx, suite.accAddr, assetstypes.NativeAssetDenom) + suite.Equal(types.StakerAssetInfo{ + TotalDepositAmount: balance.Amount.Add(delegationParams.OpAmount), + WithdrawableAmount: balance.Amount, + PendingUndelegationAmount: sdkmath.NewInt(0), + }, *restakerState) + operatorState, err = suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) + suite.NoError(err) + suite.Equal(types.OperatorAssetInfo{ + TotalAmount: delegationParams.OpAmount, + PendingUndelegationAmount: sdkmath.NewInt(0), + TotalShare: sdkmath.LegacyNewDecFromBigInt(delegationParams.OpAmount.BigInt()), + OperatorShare: sdkmath.LegacyNewDec(0), + }, *operatorState) + + specifiedDelegationAmount, err = suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) + suite.NoError(err) + suite.Equal(delegationtype.DelegationAmounts{ + UndelegatableShare: sdkmath.LegacyNewDecFromBigInt(delegationParams.OpAmount.BigInt()), + WaitUndelegationAmount: sdkmath.NewInt(0), + }, *specifiedDelegationAmount) + + totalDelegationAmount, err = suite.App.DelegationKeeper.StakerDelegatedTotalAmount(suite.Ctx, stakerID, assetID) + suite.NoError(err) + suite.Equal(delegationParams.OpAmount, totalDelegationAmount) + } func (suite *DelegationTestSuite) TestUndelegateFrom() { @@ -185,9 +247,74 @@ func (suite *DelegationTestSuite) TestUndelegateFrom() { suite.NoError(err) suite.Equal(1, len(waitUndelegationRecords)) suite.Equal(UndelegationRecord, waitUndelegationRecords[0]) + + // undelegate exocore-native-token + delegationEvent = suite.prepareDelegationNativeToken() + + err = suite.App.DelegationKeeper.UndelegateFrom(suite.Ctx, delegationEvent) + suite.NoError(err) + + stakerID, assetID = types.GetStakeIDAndAssetID(delegationEvent.ClientChainID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) + restakerState, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + suite.NoError(err) + balance := suite.App.BankKeeper.GetBalance(suite.Ctx, suite.accAddr, assetstypes.NativeAssetDenom) + suite.Equal(types.StakerAssetInfo{ + TotalDepositAmount: balance.Amount.Add(delegationEvent.OpAmount), + WithdrawableAmount: balance.Amount, + PendingUndelegationAmount: delegationEvent.OpAmount, + }, *restakerState) + + operatorState, err = suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, delegationEvent.OperatorAddress, assetID) + suite.NoError(err) + suite.Equal(types.OperatorAssetInfo{ + TotalAmount: sdkmath.NewInt(0), + PendingUndelegationAmount: delegationEvent.OpAmount, + TotalShare: sdkmath.LegacyNewDec(0), + OperatorShare: sdkmath.LegacyNewDec(0), + }, *operatorState) + + specifiedDelegationAmount, err = suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, delegationEvent.OperatorAddress.String()) + suite.NoError(err) + suite.Equal(delegationtype.DelegationAmounts{ + WaitUndelegationAmount: delegationEvent.OpAmount, + UndelegatableShare: sdkmath.LegacyNewDec(0), + }, *specifiedDelegationAmount) + + totalDelegationAmount, err = suite.App.DelegationKeeper.StakerDelegatedTotalAmount(suite.Ctx, stakerID, assetID) + suite.NoError(err) + suite.Equal(sdkmath.NewInt(0), totalDelegationAmount) + + records, err = suite.App.DelegationKeeper.GetStakerUndelegationRecords(suite.Ctx, stakerID, assetID) + suite.NoError(err) + suite.Equal(1, len(records)) + UndelegationRecord = &delegationtype.UndelegationRecord{ + StakerID: stakerID, + AssetID: assetID, + OperatorAddr: delegationEvent.OperatorAddress.String(), + TxHash: delegationEvent.TxHash.String(), + IsPending: true, + BlockNumber: uint64(suite.Ctx.BlockHeight()), + LzTxNonce: delegationEvent.LzNonce, + Amount: delegationEvent.OpAmount, + ActualCompletedAmount: delegationEvent.OpAmount, + } + UndelegationRecord.CompleteBlockNumber = UndelegationRecord.BlockNumber + delegationtype.CanUndelegationDelayHeight + suite.Equal(UndelegationRecord, records[0]) + + suite.Ctx.Logger().Info("the complete block number is:", "height", UndelegationRecord.CompleteBlockNumber) + waitUndelegationRecords, err = suite.App.DelegationKeeper.GetPendingUndelegationRecords(suite.Ctx, UndelegationRecord.CompleteBlockNumber) + suite.NoError(err) + suite.Equal(2, len(waitUndelegationRecords)) + suite.Equal(UndelegationRecord, waitUndelegationRecords[0]) } func (suite *DelegationTestSuite) TestCompleteUndelegation() { + epochID := suite.App.StakingKeeper.GetEpochIdentifier(suite.Ctx) + epochInfo, found := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, epochID) + suite.Equal(true, found) + epochsUntilUnbonded := suite.App.StakingKeeper.GetEpochsUntilUnbonded(suite.Ctx) + matureEpochs := epochInfo.CurrentEpoch + int64(epochsUntilUnbonded) + suite.prepareDeposit() delegationEvent := suite.prepareDelegation() @@ -200,6 +327,20 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { // test complete Undelegation completeBlockNumber := UndelegateHeight + int64(delegationtype.CanUndelegationDelayHeight) suite.Ctx = suite.Ctx.WithBlockHeight(completeBlockNumber) + + // update epochs to mature pending delegations from dogfood + for i := 0; i < int(epochsUntilUnbonded); i++ { + epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) + suite.Ctx = suite.Ctx.WithBlockTime(epochEndTime.Add(1 * time.Second)) + suite.App.EpochsKeeper.BeginBlocker(suite.Ctx) + epochInfo, _ = suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, epochID) + } + + suite.Equal(epochInfo.CurrentEpoch, matureEpochs) + + // update epochs to mature pending delegations from exocore-native-token by decrementing holdcount + suite.App.StakingKeeper.EndBlock(suite.Ctx) + suite.App.DelegationKeeper.EndBlock(suite.Ctx, abci.RequestEndBlock{}) // check state @@ -239,4 +380,73 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { waitUndelegationRecords, err := suite.App.DelegationKeeper.GetPendingUndelegationRecords(suite.Ctx, uint64(completeBlockNumber)) suite.NoError(err) suite.Equal(0, len(waitUndelegationRecords)) + + // test exocore-native-token + delegationEvent = suite.prepareDelegationNativeToken() + err = suite.App.DelegationKeeper.UndelegateFrom(suite.Ctx, delegationEvent) + suite.NoError(err) + UndelegateHeight = suite.Ctx.BlockHeight() + suite.Ctx.Logger().Info("the ctx block height is:", "height", UndelegateHeight) + + // test complete Undelegation + completeBlockNumber = UndelegateHeight + int64(delegationtype.CanUndelegationDelayHeight) + suite.Ctx = suite.Ctx.WithBlockHeight(completeBlockNumber) + + epochID = suite.App.StakingKeeper.GetEpochIdentifier(suite.Ctx) + epochInfo, _ = suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, epochID) + epochsUntilUnbonded = suite.App.StakingKeeper.GetEpochsUntilUnbonded(suite.Ctx) + matureEpochs = epochInfo.CurrentEpoch + int64(epochsUntilUnbonded) + + for i := 0; i < int(epochsUntilUnbonded); i++ { + epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) + suite.Ctx = suite.Ctx.WithBlockTime(epochEndTime.Add(1 * time.Second)) + suite.App.EpochsKeeper.BeginBlocker(suite.Ctx) + epochInfo, _ = suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, epochID) + } + suite.Equal(epochInfo.CurrentEpoch, matureEpochs) + // update epochs to mature pending delegations from exocore-native-token by decrementing holdcount + suite.App.StakingKeeper.EndBlock(suite.Ctx) + + suite.App.DelegationKeeper.EndBlock(suite.Ctx, abci.RequestEndBlock{}) + + // check state + stakerID, assetID = types.GetStakeIDAndAssetID(delegationEvent.ClientChainID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) + restakerState, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + suite.NoError(err) + + balance := suite.App.BankKeeper.GetBalance(suite.Ctx, suite.accAddr, assetstypes.NativeAssetDenom) + suite.Equal(types.StakerAssetInfo{ + TotalDepositAmount: balance.Amount, + WithdrawableAmount: balance.Amount, + PendingUndelegationAmount: sdkmath.NewInt(0), + }, *restakerState) + + operatorState, err = suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, delegationEvent.OperatorAddress, assetID) + suite.NoError(err) + suite.Equal(types.OperatorAssetInfo{ + TotalAmount: sdkmath.NewInt(0), + PendingUndelegationAmount: sdkmath.NewInt(0), + TotalShare: sdkmath.LegacyNewDec(0), + OperatorShare: sdkmath.LegacyNewDec(0), + }, *operatorState) + + specifiedDelegationAmount, err = suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, delegationEvent.OperatorAddress.String()) + suite.NoError(err) + suite.Equal(delegationtype.DelegationAmounts{ + UndelegatableShare: sdkmath.LegacyNewDec(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + }, *specifiedDelegationAmount) + + totalDelegationAmount, err = suite.App.DelegationKeeper.StakerDelegatedTotalAmount(suite.Ctx, stakerID, assetID) + suite.NoError(err) + suite.Equal(sdkmath.NewInt(0), totalDelegationAmount) + + records, err = suite.App.DelegationKeeper.GetStakerUndelegationRecords(suite.Ctx, stakerID, assetID) + suite.NoError(err) + suite.Equal(0, len(records)) + + waitUndelegationRecords, err = suite.App.DelegationKeeper.GetPendingUndelegationRecords(suite.Ctx, uint64(completeBlockNumber)) + suite.NoError(err) + suite.Equal(0, len(waitUndelegationRecords)) + } diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 6a1fb1ae0..747c08248 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -194,7 +194,7 @@ func (k *Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerID, assetID, ope delegationState := delegationtype.DelegationAmounts{} value := store.Get(singleStateKey) if value == nil { - return nil, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("QuerySingleDelegationInfo: key is %s", singleStateKey)) + return nil, delegationtype.ErrNoKeyInTheStore.Wrapf("QuerySingleDelegationInfo: key is %s", singleStateKey) } k.cdc.MustUnmarshal(value, &delegationState) return &delegationState, nil diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 170d901f2..6ba1a8cb2 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -2,8 +2,10 @@ package keeper import ( "context" + "fmt" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,9 +16,11 @@ type Keeper struct { cdc codec.BinaryCodec // other keepers + accountKeeper delegationtype.AccountKeeper assetsKeeper delegationtype.AssetsKeeper slashKeeper delegationtype.SlashKeeper operatorKeeper delegationtype.OperatorKeeper + bankKeeper delegationtype.BankKeeper hooks delegationtype.DelegationHooks } @@ -26,6 +30,8 @@ func NewKeeper( assetsKeeper delegationtype.AssetsKeeper, slashKeeper delegationtype.SlashKeeper, operatorKeeper delegationtype.OperatorKeeper, + accountKeeper delegationtype.AccountKeeper, + bankKeeper delegationtype.BankKeeper, ) Keeper { return Keeper{ storeKey: storeKey, @@ -33,6 +39,8 @@ func NewKeeper( assetsKeeper: assetsKeeper, slashKeeper: slashKeeper, operatorKeeper: operatorKeeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, } } @@ -56,6 +64,10 @@ func (k *Keeper) Hooks() delegationtype.DelegationHooks { return k.hooks } +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", delegationtype.ModuleName)) +} + // IDelegation interface will be implemented by delegation keeper type IDelegation interface { // DelegateAssetToOperator handle the DelegateAssetToOperator txs from msg service diff --git a/x/delegation/keeper/msg_server.go b/x/delegation/keeper/msg_server.go index f63ceca81..735b58a3d 100644 --- a/x/delegation/keeper/msg_server.go +++ b/x/delegation/keeper/msg_server.go @@ -2,18 +2,98 @@ package keeper import ( context "context" + "fmt" - errorsmod "cosmossdk.io/errors" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/delegation/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/minio/sha256-simd" ) var _ types.MsgServer = &Keeper{} // DelegateAssetToOperator todo: Delegation and Undelegation from exoCore chain directly will be implemented in future.At the moment,they are executed from client chain -func (k *Keeper) DelegateAssetToOperator(_ context.Context, _ *types.MsgDelegation) (*types.DelegationResponse, error) { - return nil, errorsmod.Wrap(types.ErrNotSupportYet, "func:DelegateAssetToOperator") +func (k *Keeper) DelegateAssetToOperator(goCtx context.Context, msg *types.MsgDelegation) (*types.DelegationResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + logger := k.Logger(ctx) + // TODO: currently we only support delegation with native token by invoking service + if msg.AssetID != assetstypes.NativeAssetID { + logger.Error("failed to delegate asset", "error", types.ErrNotSupportYet, "assetID", msg.AssetID) + return nil, types.ErrNotSupportYet.Wrap("assets other than native token are not supported yet") + } + logger.Info("DelegateAssetToOperator-nativeToken", "msg", msg) + + fromAddr := sdk.MustAccAddressFromBech32(msg.BaseInfo.FromAddress) + nonce, err := k.accountKeeper.GetSequence(ctx, fromAddr) + if err != nil { + logger.Error("failed to get nonce", "error", err) + return nil, err + } + txBytes := ctx.TxBytes() + txHash := sha256.Sum256(txBytes) + combined := fmt.Sprintf("%s-%d", txHash, nonce) + uniqueHash := sha256.Sum256([]byte(combined)) + + // test for refactor + delegationParamsList := newDelegationParams(msg.BaseInfo, assetstypes.NativeAssetAddr, assetstypes.NativeChainLzID, nonce, uniqueHash) + for _, delegationParams := range delegationParamsList { + if err := k.DelegateTo(ctx, delegationParams); err != nil { + logger.Error("failed to delegate asset", "error", err, "delegationParams", delegationParams) + return &types.DelegationResponse{}, err + + } + } + + return &types.DelegationResponse{}, nil +} + +func (k *Keeper) UndelegateAssetFromOperator(goCtx context.Context, msg *types.MsgUndelegation) (*types.UndelegationResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + logger := k.Logger(ctx) + // TODO: currently we only support undelegation with native token by invoking service + if msg.AssetID != assetstypes.NativeAssetID { + logger.Error("failed to undelegate asset", "error", types.ErrNotSupportYet, "assetID", msg.AssetID) + return nil, types.ErrNotSupportYet.Wrap("assets other than native token are not supported yet") + } + logger.Info("UndelegateAssetFromOperator", "msg", msg) + + fromAddr := sdk.MustAccAddressFromBech32(msg.BaseInfo.FromAddress) + nonce, err := k.accountKeeper.GetSequence(ctx, fromAddr) + if err != nil { + logger.Error("failed to get nonce", "error", err) + return nil, err + } + txBytes := ctx.TxBytes() + txHash := sha256.Sum256(txBytes) + combined := fmt.Sprintf("%s-%d", txHash, nonce) + uniqueHash := sha256.Sum256([]byte(combined)) + + inputParamsList := newDelegationParams(msg.BaseInfo, assetstypes.NativeAssetAddr, assetstypes.NativeChainLzID, nonce, uniqueHash) + for _, inputParams := range inputParamsList { + if err := k.UndelegateFrom(ctx, inputParams); err != nil { + return nil, err + } + } + return &types.UndelegationResponse{}, nil } -func (k *Keeper) UndelegateAssetFromOperator(_ context.Context, _ *types.MsgUndelegation) (*types.UndelegationResponse, error) { - return nil, errorsmod.Wrap(types.ErrNotSupportYet, "func:UndelegateAssetFromOperator") +func newDelegationParams(baseInfo *types.DelegationIncOrDecInfo, assetAddrStr string, clientChainLzID, txNonce uint64, txHash common.Hash) []*types.DelegationOrUndelegationParams { + stakerAddr := sdk.MustAccAddressFromBech32(baseInfo.FromAddress).Bytes() + res := make([]*types.DelegationOrUndelegationParams, 0, 1) + for _, kv := range baseInfo.PerOperatorAmounts { + operatorAddr := sdk.MustAccAddressFromBech32(kv.Key) + inputParams := types.NewDelegationOrUndelegationParams( + clientChainLzID, + assetstypes.DelegateTo, + common.HexToAddress(assetAddrStr).Bytes(), + operatorAddr, + stakerAddr, + kv.Value.Amount, + txNonce, + txHash, + ) + res = append(res, inputParams) + } + return res } diff --git a/x/delegation/keeper/setup_test.go b/x/delegation/keeper/setup_test.go index 530148583..f7ce57146 100644 --- a/x/delegation/keeper/setup_test.go +++ b/x/delegation/keeper/setup_test.go @@ -5,6 +5,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ExocoreNetwork/exocore/testutil" @@ -19,6 +20,7 @@ type DelegationTestSuite struct { clientChainLzID uint64 depositAmount sdkmath.Int delegationAmount sdkmath.Int + accAddr sdk.AccAddress } var s *DelegationTestSuite diff --git a/x/delegation/keeper/share.go b/x/delegation/keeper/share.go index abf2d8ba6..36e49d99b 100644 --- a/x/delegation/keeper/share.go +++ b/x/delegation/keeper/share.go @@ -221,13 +221,16 @@ func (k Keeper) RemoveShare( } if isUndelegation { deltaAmount.WaitUndelegationAmount = removeToken - // todo: TotalDepositAmount might be influenced by slash and precision loss, - // consider removing it, it can be recalculated from the share for RPC query. - err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.DeltaStakerSingleAsset{ - PendingUndelegationAmount: removeToken, - }) - if err != nil { - return removeToken, err + // don't update staker asset info for exo-native-token + if assetID != assetstype.NativeAssetID { + // todo: TotalDepositAmount might be influenced by slash and precision loss, + // consider removing it, it can be recalculated from the share for RPC query. + err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.DeltaStakerSingleAsset{ + PendingUndelegationAmount: removeToken, + }) + if err != nil { + return removeToken, err + } } } shareIsZero, err := k.UpdateDelegationState(ctx, stakerID, assetID, operator.String(), deltaAmount) diff --git a/x/delegation/types/cross_chain_params.go b/x/delegation/types/cross_chain_params.go index b47ec2c8a..e6c7c580f 100644 --- a/x/delegation/types/cross_chain_params.go +++ b/x/delegation/types/cross_chain_params.go @@ -18,3 +18,25 @@ type DelegationOrUndelegationParams struct { TxHash common.Hash // todo: The operator approved signature might be needed here in future } + +func NewDelegationOrUndelegationParams( + clientChainID uint64, + action assetstype.CrossChainOpType, + assetsAddress []byte, + operatorAddress sdk.AccAddress, + stakerAddress []byte, + opAmount sdkmath.Int, + lzNonce uint64, + txHash common.Hash, +) *DelegationOrUndelegationParams { + return &DelegationOrUndelegationParams{ + ClientChainID: clientChainID, + Action: action, + AssetsAddress: assetsAddress, + OperatorAddress: operatorAddress, + StakerAddress: stakerAddress, + OpAmount: opAmount, + LzNonce: lzNonce, + TxHash: txHash, + } +} diff --git a/x/delegation/types/errors.go b/x/delegation/types/errors.go index c9bf63ee8..723ad5a3d 100644 --- a/x/delegation/types/errors.go +++ b/x/delegation/types/errors.go @@ -79,7 +79,10 @@ var ( ModuleName, 17, "the client chain has not been registered", ) - + ErrInvalidAssetID = errorsmod.Register( + ModuleName, 18, + "assetID is invalid", + ) ErrInvalidCompletedHeight = errorsmod.Register( ModuleName, 23, "the block height to complete the unelegation is invalid", diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index 33113e03d..8fd5fb42b 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -53,3 +53,13 @@ type AssetsKeeper interface { ClientChainExists(ctx sdk.Context, index uint64) bool } + +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error +} + +type AccountKeeper interface { + GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, error) +} diff --git a/x/delegation/types/general.go b/x/delegation/types/general.go index 34d5b84fe..cae79ae82 100644 --- a/x/delegation/types/general.go +++ b/x/delegation/types/general.go @@ -1,3 +1,10 @@ package types type DeltaDelegationAmounts DelegationAmounts + +const ( + NotBondedPoolName = "not_bonded_tokens_pool" + BondedPoolName = "bonded_tokens_pool" + // TODO: we currently not support redelegation, and operators is not directly related to bonded(need to optIn first), so we use this pool name for now + DelegatedPoolName = "delegated_tokens_pool" +) diff --git a/x/delegation/types/msg.go b/x/delegation/types/msg.go index 91ba52e84..1a2e22fa2 100644 --- a/x/delegation/types/msg.go +++ b/x/delegation/types/msg.go @@ -2,6 +2,7 @@ package types import ( errorsmod "cosmossdk.io/errors" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -18,10 +19,22 @@ func (m *MsgDelegation) GetSigners() []sdk.AccAddress { // ValidateBasic does a sanity check of the provided data func (m *MsgDelegation) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.BaseInfo.FromAddress); err != nil { - return errorsmod.Wrap(err, "invalid from address") + return validateDelegationInfo(m.AssetID, m.BaseInfo) +} + +// new message to delegate asset to operator +func NewMsgDelegation(assetID, fromAddress string, amountPerOperator []KeyValue) *MsgDelegation { + baseInfo := &DelegationIncOrDecInfo{ + FromAddress: fromAddress, + PerOperatorAmounts: make([]KeyValue, 0, 1), + } + for _, kv := range amountPerOperator { + baseInfo.PerOperatorAmounts = append(baseInfo.PerOperatorAmounts, KeyValue{Key: kv.Key, Value: kv.Value}) + } + return &MsgDelegation{ + AssetID: assetID, + BaseInfo: baseInfo, } - return nil } // GetSignBytes implements the LegacyMsg interface. @@ -37,13 +50,44 @@ func (m *MsgUndelegation) GetSigners() []sdk.AccAddress { // ValidateBasic does a sanity check of the provided data func (m *MsgUndelegation) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.BaseInfo.FromAddress); err != nil { - return errorsmod.Wrap(err, "invalid from address") - } - return nil + return validateDelegationInfo(m.AssetID, m.BaseInfo) } // GetSignBytes implements the LegacyMsg interface. func (m *MsgUndelegation) GetSignBytes() []byte { return nil } + +// new message to delegate asset to operator +func NewMsgUndelegation(assetID, fromAddress string, amountPerOperator []KeyValue) *MsgUndelegation { + baseInfo := &DelegationIncOrDecInfo{ + FromAddress: fromAddress, + PerOperatorAmounts: make([]KeyValue, 0, 1), + } + for _, kv := range amountPerOperator { + baseInfo.PerOperatorAmounts = append(baseInfo.PerOperatorAmounts, KeyValue{Key: kv.Key, Value: kv.Value}) + } + return &MsgUndelegation{ + AssetID: assetID, + BaseInfo: baseInfo, + } +} + +// TODO: delegation and undelegation have the same params, try to use one single message with different flag to indicate action:delegation/undelegation +func validateDelegationInfo(assetID string, baseInfo *DelegationIncOrDecInfo) error { + for _, kv := range baseInfo.PerOperatorAmounts { + if _, err := sdk.AccAddressFromBech32(kv.Key); err != nil { + return errorsmod.Wrap(err, "invalid operator address delegateTO") + } + if !kv.Value.Amount.IsPositive() { + return errorsmod.Wrapf(ErrAmountIsNotPositive, "amount should be positive, got%s", kv.Value.Amount.String()) + } + } + if assetID != assetstype.NativeAssetID { + return errorsmod.Wrapf(ErrInvalidAssetID, "only nativeToken is support, expected:%s,got:%s", assetstype.NativeAssetID, assetID) + } + if _, err := sdk.AccAddressFromBech32(baseInfo.FromAddress); err != nil { + return errorsmod.Wrap(err, "invalid from address") + } + return nil +} diff --git a/x/delegation/types/tx.pb.go b/x/delegation/types/tx.pb.go index 99f3f0e45..c5c467287 100644 --- a/x/delegation/types/tx.pb.go +++ b/x/delegation/types/tx.pb.go @@ -184,74 +184,19 @@ func (m *KeyValue) GetValue() *ValueField { return nil } -// DelegationApproveInfo is the delegation approve info. -type DelegationApproveInfo struct { - // signature of the delegation approve info. - Signature string `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"` - // salt within the signature. - Salt string `protobuf:"bytes,2,opt,name=salt,proto3" json:"salt,omitempty"` -} - -func (m *DelegationApproveInfo) Reset() { *m = DelegationApproveInfo{} } -func (m *DelegationApproveInfo) String() string { return proto.CompactTextString(m) } -func (*DelegationApproveInfo) ProtoMessage() {} -func (*DelegationApproveInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{3} -} -func (m *DelegationApproveInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DelegationApproveInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DelegationApproveInfo.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 *DelegationApproveInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_DelegationApproveInfo.Merge(m, src) -} -func (m *DelegationApproveInfo) XXX_Size() int { - return m.Size() -} -func (m *DelegationApproveInfo) XXX_DiscardUnknown() { - xxx_messageInfo_DelegationApproveInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_DelegationApproveInfo proto.InternalMessageInfo - -func (m *DelegationApproveInfo) GetSignature() string { - if m != nil { - return m.Signature - } - return "" -} - -func (m *DelegationApproveInfo) GetSalt() string { - if m != nil { - return m.Salt - } - return "" -} - // DelegationIncOrDecInfo is the delegation increase or decrease info. type DelegationIncOrDecInfo struct { // from_address is the staker address FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` // per_operator_amounts is the amount of the asset delegated to each operator. - PerOperatorAmounts map[string]*ValueField `protobuf:"bytes,2,rep,name=per_operator_amounts,json=perOperatorAmounts,proto3" json:"per_operator_amounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + PerOperatorAmounts []KeyValue `protobuf:"bytes,2,rep,name=per_operator_amounts,json=perOperatorAmounts,proto3" json:"per_operator_amounts"` } func (m *DelegationIncOrDecInfo) Reset() { *m = DelegationIncOrDecInfo{} } func (m *DelegationIncOrDecInfo) String() string { return proto.CompactTextString(m) } func (*DelegationIncOrDecInfo) ProtoMessage() {} func (*DelegationIncOrDecInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{4} + return fileDescriptor_16596a15a828f109, []int{3} } func (m *DelegationIncOrDecInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -282,17 +227,17 @@ var xxx_messageInfo_DelegationIncOrDecInfo proto.InternalMessageInfo // MsgDelegation is the delegation Msg. type MsgDelegation struct { + // asset_id is the asset id. + AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` // base_info is the delegation increase or decrease request container. - BaseInfo *DelegationIncOrDecInfo `protobuf:"bytes,1,opt,name=base_info,json=baseInfo,proto3" json:"base_info,omitempty"` - // approved_info is the delegation increase or decrease response container. - ApprovedInfo *DelegationApproveInfo `protobuf:"bytes,2,opt,name=approved_info,json=approvedInfo,proto3" json:"approved_info,omitempty"` + BaseInfo *DelegationIncOrDecInfo `protobuf:"bytes,2,opt,name=base_info,json=baseInfo,proto3" json:"base_info,omitempty"` } func (m *MsgDelegation) Reset() { *m = MsgDelegation{} } func (m *MsgDelegation) String() string { return proto.CompactTextString(m) } func (*MsgDelegation) ProtoMessage() {} func (*MsgDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{5} + return fileDescriptor_16596a15a828f109, []int{4} } func (m *MsgDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -321,16 +266,16 @@ func (m *MsgDelegation) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDelegation proto.InternalMessageInfo -func (m *MsgDelegation) GetBaseInfo() *DelegationIncOrDecInfo { +func (m *MsgDelegation) GetAssetID() string { if m != nil { - return m.BaseInfo + return m.AssetID } - return nil + return "" } -func (m *MsgDelegation) GetApprovedInfo() *DelegationApproveInfo { +func (m *MsgDelegation) GetBaseInfo() *DelegationIncOrDecInfo { if m != nil { - return m.ApprovedInfo + return m.BaseInfo } return nil } @@ -365,7 +310,7 @@ func (m *UndelegationRecord) Reset() { *m = UndelegationRecord{} } func (m *UndelegationRecord) String() string { return proto.CompactTextString(m) } func (*UndelegationRecord) ProtoMessage() {} func (*UndelegationRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{6} + return fileDescriptor_16596a15a828f109, []int{5} } func (m *UndelegationRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -460,7 +405,7 @@ func (m *UndelegationRecordKeyList) Reset() { *m = UndelegationRecordKey func (m *UndelegationRecordKeyList) String() string { return proto.CompactTextString(m) } func (*UndelegationRecordKeyList) ProtoMessage() {} func (*UndelegationRecordKeyList) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{7} + return fileDescriptor_16596a15a828f109, []int{6} } func (m *UndelegationRecordKeyList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -504,7 +449,7 @@ func (m *DelegationResponse) Reset() { *m = DelegationResponse{} } func (m *DelegationResponse) String() string { return proto.CompactTextString(m) } func (*DelegationResponse) ProtoMessage() {} func (*DelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{8} + return fileDescriptor_16596a15a828f109, []int{7} } func (m *DelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -536,14 +481,15 @@ var xxx_messageInfo_DelegationResponse proto.InternalMessageInfo // MsgUndelegation is the undelegation Msg. type MsgUndelegation struct { // base_info is the delegation increase or decrease request container. - BaseInfo *DelegationIncOrDecInfo `protobuf:"bytes,1,opt,name=base_info,json=baseInfo,proto3" json:"base_info,omitempty"` + AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` + BaseInfo *DelegationIncOrDecInfo `protobuf:"bytes,2,opt,name=base_info,json=baseInfo,proto3" json:"base_info,omitempty"` } func (m *MsgUndelegation) Reset() { *m = MsgUndelegation{} } func (m *MsgUndelegation) String() string { return proto.CompactTextString(m) } func (*MsgUndelegation) ProtoMessage() {} func (*MsgUndelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{9} + return fileDescriptor_16596a15a828f109, []int{8} } func (m *MsgUndelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -572,6 +518,13 @@ func (m *MsgUndelegation) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUndelegation proto.InternalMessageInfo +func (m *MsgUndelegation) GetAssetID() string { + if m != nil { + return m.AssetID + } + return "" +} + func (m *MsgUndelegation) GetBaseInfo() *DelegationIncOrDecInfo { if m != nil { return m.BaseInfo @@ -587,7 +540,7 @@ func (m *UndelegationResponse) Reset() { *m = UndelegationResponse{} } func (m *UndelegationResponse) String() string { return proto.CompactTextString(m) } func (*UndelegationResponse) ProtoMessage() {} func (*UndelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{10} + return fileDescriptor_16596a15a828f109, []int{9} } func (m *UndelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -620,9 +573,7 @@ func init() { proto.RegisterType((*ValueField)(nil), "exocore.delegation.v1.ValueField") proto.RegisterType((*DelegatedSingleAssetInfo)(nil), "exocore.delegation.v1.DelegatedSingleAssetInfo") proto.RegisterType((*KeyValue)(nil), "exocore.delegation.v1.KeyValue") - proto.RegisterType((*DelegationApproveInfo)(nil), "exocore.delegation.v1.DelegationApproveInfo") proto.RegisterType((*DelegationIncOrDecInfo)(nil), "exocore.delegation.v1.DelegationIncOrDecInfo") - proto.RegisterMapType((map[string]*ValueField)(nil), "exocore.delegation.v1.DelegationIncOrDecInfo.PerOperatorAmountsEntry") proto.RegisterType((*MsgDelegation)(nil), "exocore.delegation.v1.MsgDelegation") proto.RegisterType((*UndelegationRecord)(nil), "exocore.delegation.v1.UndelegationRecord") proto.RegisterType((*UndelegationRecordKeyList)(nil), "exocore.delegation.v1.UndelegationRecordKeyList") @@ -634,67 +585,62 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/tx.proto", fileDescriptor_16596a15a828f109) } var fileDescriptor_16596a15a828f109 = []byte{ - // 952 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0xe3, 0x44, - 0x14, 0x8e, 0x9b, 0x6e, 0x9b, 0xbc, 0xb4, 0x02, 0x86, 0x74, 0xe3, 0x06, 0x48, 0xb2, 0x16, 0x54, - 0xd9, 0x42, 0x13, 0x6d, 0x40, 0x80, 0x16, 0x38, 0x24, 0xa4, 0x2b, 0xc2, 0xd2, 0xee, 0xe2, 0x76, - 0x41, 0x42, 0x42, 0x96, 0x63, 0x4f, 0x1d, 0x13, 0xdb, 0x63, 0xcd, 0x4c, 0xba, 0xc9, 0x9e, 0x10, - 0x27, 0xc4, 0x89, 0x3b, 0x97, 0xe5, 0x0f, 0xa0, 0x1e, 0xf6, 0x47, 0xec, 0x71, 0xb5, 0x27, 0xc4, - 0xa1, 0x42, 0xe9, 0xa1, 0x1c, 0xf8, 0x09, 0x1c, 0x90, 0x67, 0xec, 0xc6, 0xd5, 0x36, 0x54, 0x48, - 0xbd, 0x24, 0x9e, 0xf7, 0xbe, 0xf9, 0xbe, 0xf7, 0xde, 0xbc, 0x67, 0x0f, 0x54, 0xf0, 0x98, 0x58, - 0x84, 0xe2, 0xa6, 0x8d, 0x3d, 0xec, 0x98, 0xdc, 0x25, 0x41, 0xf3, 0xf0, 0x56, 0x93, 0x8f, 0x1b, - 0x21, 0x25, 0x9c, 0xa0, 0xb5, 0xd8, 0xdf, 0x98, 0xf9, 0x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c, 0x6f, 0x63, 0xbe, 0x5e, 0x3a, 0x85, 0xf2, 0xdb, 0x73, 0x70, 0x17, 0xe5, 0x59, 0xbe, - 0xf6, 0xfd, 0xe9, 0xd1, 0xa6, 0xd2, 0xd9, 0x7d, 0x3a, 0xad, 0x28, 0xcf, 0xa6, 0x15, 0xe5, 0xcf, - 0x69, 0x45, 0xf9, 0xf9, 0xa4, 0x92, 0x79, 0x76, 0x52, 0xc9, 0xfc, 0x7e, 0x52, 0xc9, 0x7c, 0xf3, - 0x5e, 0xaa, 0x35, 0xb6, 0x25, 0xef, 0x2e, 0xe6, 0x0f, 0x09, 0x1d, 0x36, 0x93, 0x3b, 0xc7, 0x38, - 0x7d, 0xeb, 0x10, 0xcd, 0xd2, 0x5f, 0x12, 0x57, 0x80, 0x77, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, - 0xd6, 0xc6, 0x2e, 0x6c, 0x98, 0x08, 0x00, 0x00, + // 866 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0x9b, 0xb6, 0x49, 0x5e, 0xba, 0x02, 0x86, 0x74, 0xeb, 0x06, 0x91, 0x64, 0x2d, 0xa8, + 0xb2, 0x45, 0x8d, 0xb5, 0x05, 0x81, 0xc4, 0x9f, 0x43, 0x43, 0x58, 0x11, 0x96, 0x76, 0x91, 0xdb, + 0x05, 0x89, 0x8b, 0xe5, 0x78, 0xa6, 0xae, 0x89, 0x3d, 0x63, 0xcd, 0x4c, 0x4a, 0xb2, 0x27, 0x04, + 0x42, 0x42, 0x9c, 0xb8, 0x73, 0x59, 0xbe, 0x41, 0x0f, 0xfb, 0x21, 0xf6, 0xb8, 0xda, 0x13, 0xe2, + 0x50, 0xa1, 0xf4, 0x50, 0x0e, 0x9c, 0xf8, 0x04, 0xc8, 0x1e, 0xbb, 0x71, 0x45, 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85, 0x5f, 0xcf, 0x1a, 0x85, 0x2f, 0xdf, 0xca, 0xf5, 0xd0, 0x47, 0xca, 0xef, + 0x1e, 0x91, 0x5f, 0x33, 0x3e, 0x34, 0xb3, 0xc7, 0x79, 0x9c, 0x7f, 0x9e, 0x93, 0xae, 0x1a, 0x2c, + 0x27, 0x6f, 0xe5, 0x9b, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x32, 0x66, 0x81, 0xc1, 0x07, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -936,43 +882,6 @@ func (m *KeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *DelegationApproveInfo) 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 *DelegationApproveInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationApproveInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Salt) > 0 { - i -= len(m.Salt) - copy(dAtA[i:], m.Salt) - i = encodeVarintTx(dAtA, i, uint64(len(m.Salt))) - i-- - dAtA[i] = 0x12 - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *DelegationIncOrDecInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -994,27 +903,15 @@ func (m *DelegationIncOrDecInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) var l int _ = l if len(m.PerOperatorAmounts) > 0 { - for k := range m.PerOperatorAmounts { - v := m.PerOperatorAmounts[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTx(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTx(dAtA, i, uint64(baseI-i)) + for iNdEx := len(m.PerOperatorAmounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PerOperatorAmounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x12 } @@ -1049,9 +946,9 @@ func (m *MsgDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ApprovedInfo != nil { + if m.BaseInfo != nil { { - size, err := m.ApprovedInfo.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.BaseInfo.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1061,15 +958,10 @@ func (m *MsgDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if m.BaseInfo != nil { - { - size, err := m.BaseInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintTx(dAtA, i, uint64(len(m.AssetID))) i-- dAtA[i] = 0xa } @@ -1257,6 +1149,13 @@ func (m *MsgUndelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x12 + } + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintTx(dAtA, i, uint64(len(m.AssetID))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -1343,23 +1242,6 @@ func (m *KeyValue) Size() (n int) { return n } -func (m *DelegationApproveInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Salt) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - func (m *DelegationIncOrDecInfo) Size() (n int) { if m == nil { return 0 @@ -1371,16 +1253,9 @@ func (m *DelegationIncOrDecInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } if len(m.PerOperatorAmounts) > 0 { - for k, v := range m.PerOperatorAmounts { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovTx(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovTx(uint64(len(k))) + l - n += mapEntrySize + 1 + sovTx(uint64(mapEntrySize)) + for _, e := range m.PerOperatorAmounts { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) } } return n @@ -1392,12 +1267,12 @@ func (m *MsgDelegation) Size() (n int) { } var l int _ = l - if m.BaseInfo != nil { - l = m.BaseInfo.Size() + l = len(m.AssetID) + if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.ApprovedInfo != nil { - l = m.ApprovedInfo.Size() + if m.BaseInfo != nil { + l = m.BaseInfo.Size() n += 1 + l + sovTx(uint64(l)) } return n @@ -1474,6 +1349,10 @@ func (m *MsgUndelegation) Size() (n int) { } var l int _ = l + l = len(m.AssetID) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } if m.BaseInfo != nil { l = m.BaseInfo.Size() n += 1 + l + sovTx(uint64(l)) @@ -1814,120 +1693,6 @@ func (m *KeyValue) Unmarshal(dAtA []byte) error { } return nil } -func (m *DelegationApproveInfo) 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: DelegationApproveInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DelegationApproveInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", 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.Signature = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Salt", 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.Salt = string(dAtA[iNdEx:postIndex]) - 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 *DelegationIncOrDecInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2018,105 +1783,10 @@ func (m *DelegationIncOrDecInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PerOperatorAmounts == nil { - m.PerOperatorAmounts = make(map[string]*ValueField) - } - var mapkey string - var mapvalue *ValueField - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthTx - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthTx - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthTx - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthTx - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &ValueField{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.PerOperatorAmounts[mapkey] = mapvalue + m.PerOperatorAmounts = append(m.PerOperatorAmounts, KeyValue{}) + if err := m.PerOperatorAmounts[len(m.PerOperatorAmounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -2170,9 +1840,9 @@ func (m *MsgDelegation) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BaseInfo", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2182,31 +1852,27 @@ func (m *MsgDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.BaseInfo == nil { - m.BaseInfo = &DelegationIncOrDecInfo{} - } - if err := m.BaseInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApprovedInfo", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BaseInfo", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2233,10 +1899,10 @@ func (m *MsgDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.ApprovedInfo == nil { - m.ApprovedInfo = &DelegationApproveInfo{} + if m.BaseInfo == nil { + m.BaseInfo = &DelegationIncOrDecInfo{} } - if err := m.ApprovedInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.BaseInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2746,6 +2412,38 @@ func (m *MsgUndelegation) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", 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.AssetID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BaseInfo", wireType) } diff --git a/x/oracle/keeper/prices.go b/x/oracle/keeper/prices.go index a4c8426fb..b16187aa9 100644 --- a/x/oracle/keeper/prices.go +++ b/x/oracle/keeper/prices.go @@ -4,6 +4,7 @@ import ( "encoding/binary" sdkmath "cosmossdk.io/math" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/oracle/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -46,6 +47,14 @@ func (k Keeper) GetPrices( // return latest price for one specified price func (k Keeper) GetSpecifiedAssetsPrice(ctx sdk.Context, assetID string) (types.Price, error) { + // for native token exo, we temporarily use default price + if assetID == assetstypes.NativeAssetID { + return types.Price{ + Value: sdkmath.NewInt(types.DefaultPriceValue), + Decimal: types.DefaultPriceDecimal, + }, nil + } + var p types.Params // get params from cache if exists if agc != nil { @@ -91,6 +100,14 @@ func (k Keeper) GetMultipleAssetsPrices(ctx sdk.Context, assets map[string]inter prices = make(map[string]types.Price) info := "" for assetID := range assets { + // for native token exo, we temporarily use default price + if assetID == assetstypes.NativeAssetID { + prices[assetID] = types.Price{ + Value: sdkmath.NewInt(types.DefaultPriceValue), + Decimal: types.DefaultPriceDecimal, + } + continue + } tokenID := p.GetTokenIDFromAssetID(assetID) if tokenID == 0 { err = types.ErrGetPriceAssetNotFound.Wrapf("assetID does not exist in oracle %s", assetID) diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index 0e1ac6c30..6e4156823 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -140,12 +140,15 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { TotalDepositAmount: event.OpAmount, WithdrawableAmount: event.OpAmount, } - err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) - if err != nil { - return err - } - if err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount); err != nil { - return err + // TODO: there should be a reward pool to be transferred from for native tokens' reward, don't update staker-asset-info, just transfer exo-native-token:pool->staker or handled by validators since the reward would be transferred to validators directly. + if assetID != types.NativeAssetID { + err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) + if err != nil { + return err + } + if err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount); err != nil { + return err + } } return nil } diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index 461de42ae..9b920af0d 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -10,7 +10,9 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/assets/types" + + // "github.com/ExocoreNetwork/exocore/x/assets/types" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" rtypes "github.com/ExocoreNetwork/exocore/x/slash/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -22,7 +24,7 @@ import ( type SlashParams struct { ClientChainLzID uint64 - Action types.CrossChainOpType + Action assetstypes.CrossChainOpType AssetsAddress []byte OperatorAddress sdk.AccAddress StakerAddress []byte @@ -42,22 +44,22 @@ type OperatorFrozenStatus struct { func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*SlashParams, error) { // check if action is deposit - var action types.CrossChainOpType + var action assetstypes.CrossChainOpType var err error readStart := uint32(0) - readEnd := uint32(types.CrossChainActionLength) + readEnd := uint32(assetstypes.CrossChainActionLength) r := bytes.NewReader(log.Data[readStart:readEnd]) err = binary.Read(r, binary.BigEndian, &action) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when binary read action") } - if action != types.DelegateTo && action != types.UndelegateFrom { + if action != assetstypes.DelegateTo && action != assetstypes.UndelegateFrom { // not handle the actions that isn't deposit return nil, nil } var clientChainLzID uint64 - r = bytes.NewReader(log.Topics[types.ClientChainLzIDIndexInTopics][:]) + r = bytes.NewReader(log.Topics[assetstypes.ClientChainLzIDIndexInTopics][:]) err = binary.Read(r, binary.BigEndian, &clientChainLzID) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzID from topic") @@ -78,9 +80,9 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas } readStart = readEnd - readEnd += types.ExoCoreOperatorAddrLength + readEnd += assetstypes.ExoCoreOperatorAddrLength r = bytes.NewReader(log.Data[readStart:readEnd]) - operatorAddress := [types.ExoCoreOperatorAddrLength]byte{} + operatorAddress := [assetstypes.ExoCoreOperatorAddrLength]byte{} err = binary.Read(r, binary.BigEndian, operatorAddress[:]) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when binary read operator address") @@ -100,7 +102,7 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas } readStart = readEnd - readEnd += types.CrossChainOpAmountLength + readEnd += assetstypes.CrossChainOpAmountLength amount := sdkmath.NewIntFromBigInt(big.NewInt(0).SetBytes(log.Data[readStart:readEnd])) return &SlashParams{ @@ -184,21 +186,26 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { return errorsmod.Wrap(rtypes.ErrSlashAmountIsNegative, fmt.Sprintf("the amount is:%s", event.OpAmount)) } stakeID, assetID := getStakeIDAndAssetID(event) - // check is asset exist + // check if asset exists if !k.assetsKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(rtypes.ErrSlashAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } - changeAmount := types.DeltaStakerSingleAsset{ - TotalDepositAmount: event.OpAmount.Neg(), - WithdrawableAmount: event.OpAmount.Neg(), - } - err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) - if err != nil { - return err - } - if err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount.Neg()); err != nil { - return err + // dont't create stakerasset info for native token. + // TODO: do we need to do any other process for native token 'else{}' ? + if assetID != assetstypes.NativeAssetID { + changeAmount := assetstypes.DeltaStakerSingleAsset{ + TotalDepositAmount: event.OpAmount.Neg(), + WithdrawableAmount: event.OpAmount.Neg(), + } + + err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) + if err != nil { + return err + } + if err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount.Neg()); err != nil { + return err + } } return nil } From a8ce2bf6054870bf745a46ec6bcb6e2c9894779f Mon Sep 17 00:00:00 2001 From: Max <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:56:33 +0530 Subject: [PATCH 5/5] fix(local,dogfood): -warnings, -unusedData (#193) * fix: update local_node.sh and remove operator... ...from x/dogfood. Now that the x/operator module is responsible for setting up operator states, the dogfood module doesn't need to know the operator address at genesis start. * refactor(dogfood): check for operator reg At genesis, if a validator is supplied, it must have been registered as an operator. * chore: lint via `shfmt` `local_node.sh` * chore: lint via `shellcheck` `local_node.sh` * fix(local): provide opt-out height in quotes * fix(local): add avs and operator usd values * fix(local): change log level to info --- app/ethtest_helper.go | 5 +- app/test_helpers.go | 5 +- local_node.sh | 57 +++++--- proto/exocore/dogfood/v1/genesis.proto | 5 - testutil/utils.go | 10 +- x/dogfood/keeper/genesis.go | 41 +++--- x/dogfood/types/genesis.go | 17 --- x/dogfood/types/genesis.pb.go | 132 ++++++------------- x/dogfood/types/genesis_test.go | 174 ++++++++----------------- 9 files changed, 159 insertions(+), 287 deletions(-) diff --git a/app/ethtest_helper.go b/app/ethtest_helper.go index a31e22c0e..7dbecab6e 100644 --- a/app/ethtest_helper.go +++ b/app/ethtest_helper.go @@ -243,9 +243,8 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, dogfoodtypes.DefaultParams(), []dogfoodtypes.GenesisValidator{ { // PublicKey: consensusKeyRecords[0].Chains[0].ConsensusKey, - Power: 1, - PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), - OperatorAccAddr: operatorInfos[0].OperatorAddress, + Power: 1, + PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), }, }, []dogfoodtypes.EpochToOperatorAddrs{}, []dogfoodtypes.EpochToConsensusAddrs{}, diff --git a/app/test_helpers.go b/app/test_helpers.go index b59ac2616..78c07e532 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -285,9 +285,8 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, dogfoodGenesis := dogfoodtypes.NewGenesis( dogfoodtypes.DefaultParams(), []dogfoodtypes.GenesisValidator{ { - Power: 1, - PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), - OperatorAccAddr: operatorInfos[0].OperatorAddress, + Power: 1, + PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), }, }, []dogfoodtypes.EpochToOperatorAddrs{}, []dogfoodtypes.EpochToConsensusAddrs{}, diff --git a/local_node.sh b/local_node.sh index 8672a38f3..4615bb3ac 100755 --- a/local_node.sh +++ b/local_node.sh @@ -18,7 +18,7 @@ HOMEDIR="$HOME/.tmp-exocored" #TRACE="--trace" TRACE="" -# make the validator consensus key consistent +# make the validator consensus key consistent 0xf0f6919e522c5b97db2c8255bff743f9dfddd7ad9fc37cb0c1670b480d0f9914 CONSENSUS_KEY_MNEMONIC="wonder quality resource ketchup occur stadium vicious output situate plug second monkey harbor vanish then myself primary feed earth story real soccer shove like" # the account below acts as both initial operator and local consistent faucet. # pk: D196DCA836F8AC2FFF45B3C9F0113825CCBB33FA1B39737B948503B263ED75AE @@ -39,6 +39,10 @@ command -v jq >/dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/" exit 1 } +command -v cast >/dev/null 2>&1 || { + echo >&2 "cast not installed. More info: https://getfoundry.sh" + exit 1 +} # used to exit on first error (any non-zero exit code) set -e @@ -66,16 +70,23 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # If keys exist they should be deleted for KEY in "${KEYS[@]}"; do - exocored keys add "$KEY" --keyring-backend $KEYRING --algo $ALGO --home "$HOMEDIR" + exocored keys add "$KEY" --keyring-backend "$KEYRING" --algo $ALGO --home "$HOMEDIR" done # Use recover so that there is always a consistent address funded in the localnet genesis. - echo "${LOCAL_MNEMONIC}" | exocored --home "$HOMEDIR" --keyring-backend $KEYRING keys add "${LOCAL_NAME}" --recover + echo "${LOCAL_MNEMONIC}" | exocored --home "$HOMEDIR" --keyring-backend "$KEYRING" keys add "${LOCAL_NAME}" --recover # Set moniker and chain-id for Evmos (Moniker can be anything, chain-id must be an integer) # Use recover to use a consistent consensus key for validator. echo "${CONSENSUS_KEY_MNEMONIC}" | exocored init $MONIKER -o --chain-id $CHAINID --home "$HOMEDIR" --recover + # these values are derived instead of hardcoded, so that edits to mnemonic or chain-id are automatically reflected + CHAINID_WITHOUT_REVISION=${CHAINID%-*} + AVS_ADDRESS=0x$(cast keccak "chain-id-prefix""$CHAINID_WITHOUT_REVISION" | cast 2b | tail -c 41) + LOCAL_ADDRESS_EXO=$(exocored keys show "$LOCAL_NAME" -a --keyring-backend "$KEYRING" --home "$HOMEDIR") + LOCAL_ADDRESS_HEX=0x$(exocored keys parse "$LOCAL_ADDRESS_EXO" --output json | jq -r .bytes | tr '[:upper:]' '[:lower:]') + CONSENSUS_KEY=$(exocored keys consensus-pubkey-to-bytes --keyring-backend "$KEYRING" --home "$HOMEDIR" --output json | jq -r .bytes32) + # Change parameter token denominations to aexo jq '.app_state["crisis"]["constant_fee"]["denom"]="aexo"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aexo"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" @@ -88,7 +99,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # x/assets # Using the local funding address as the Exocore gateway address to facilitate testing for precompiles without depending on the gateway contract. - jq '.app_state["assets"]["params"]["exocore_lz_app_address"]="0x3e108c058e8066da635321dc3018294ca82ddedf"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["params"]["exocore_lz_app_address"]="'"$LOCAL_ADDRESS_HEX"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["client_chains"][0]["name"]="Example EVM chain"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["client_chains"][0]["meta_info"]="Example EVM chain meta info"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["client_chains"][0]["layer_zero_chain_id"]="101"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" @@ -98,12 +109,12 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["address"]="0xdac17f958d2ee523a2206206994597c13d831ec7"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["layer_zero_chain_id"]="101"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["staking_total_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["deposits"][0]["staker"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["deposits"][0]["staker"]="'"$LOCAL_ADDRESS_HEX"'_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["total_deposit_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["withdrawable_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["pending_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["operator_assets"][0]["operator"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["operator"]="'"$LOCAL_ADDRESS_EXO"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["total_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["pending_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" @@ -115,30 +126,42 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq '.app_state["oracle"]["params"]["token_feeders"][1]["start_base_block"]="20"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/operator - jq '.app_state["operator"]["operators"][0]["operator_address"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["operator_info"]["earnings_addr"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_address"]="'"$LOCAL_ADDRESS_EXO"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["earnings_addr"]="'"$LOCAL_ADDRESS_EXO"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["operator"]["operators"][0]["operator_info"]["operator_meta_info"]="operator1"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["max_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["max_change_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operator_records"][0]["operator_address"]="'"$LOCAL_ADDRESS_EXO"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operator_records"][0]["chains"][0]["chain_id"]="'"$CHAINID_WITHOUT_REVISION"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operator_records"][0]["chains"][0]["consensus_key"]="'"$CONSENSUS_KEY"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["opt_states"][0]["key"]="'"$LOCAL_ADDRESS_EXO"'/'"$AVS_ADDRESS"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["opt_states"][0]["opt_info"]["opted_in_height"]=1' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["opt_states"][0]["opt_info"]["opted_out_height"]="'"$(echo '2^64-1' | bc)"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["opt_states"][0]["opt_info"]["jailed"]=false' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["avs_usd_values"][0]["avs_addr"]="'"$AVS_ADDRESS"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["avs_usd_values"][0]["value"]["amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operator_usd_values"][0]["key"]="'"$AVS_ADDRESS"'/'"$LOCAL_ADDRESS_EXO"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operator_usd_values"][0]["opted_usd_value"]["self_usd_value"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operator_usd_values"][0]["opted_usd_value"]["total_usd_value"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operator_usd_values"][0]["opted_usd_value"]["active_usd_value"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/delegation - jq '.app_state["delegation"]["delegation_states"][0]["key"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65/exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["delegation_states"][0]["key"]="'"$LOCAL_ADDRESS_HEX"'_0x65/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65/'"$LOCAL_ADDRESS_EXO"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["delegation"]["delegation_states"][0]["states"]["undelegatable_share"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["delegation"]["delegation_states"][0]["states"]["wait_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["associations"][0]["staker_id"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["associations"][0]["operator"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["stakers_by_operator"][0]["key"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["stakers_by_operator"][0]["stakers"][0]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["associations"][0]["staker_id"]="'"$LOCAL_ADDRESS_HEX"'_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["associations"][0]["operator"]="'"$LOCAL_ADDRESS_EXO"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["stakers_by_operator"][0]["key"]="'"$LOCAL_ADDRESS_EXO"'/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["stakers_by_operator"][0]["stakers"][0]="'"$LOCAL_ADDRESS_HEX"'_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/dogfood # for easy testing, use an epoch of 1 minute and 5 epochs until unbonded. # i did not use 1 epoch to allow for testing that it does not happen at each epoch. jq '.app_state["dogfood"]["params"]["epoch_identifier"]="minute"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["dogfood"]["params"]["epochs_until_unbonded"]="5"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["dogfood"]["val_set"][0]["public_key"]="0xf0f6919e522c5b97db2c8255bff743f9dfddd7ad9fc37cb0c1670b480d0f9914"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["dogfood"]["val_set"][0]["public_key"]="'"$CONSENSUS_KEY"'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["dogfood"]["val_set"][0]["power"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["dogfood"]["val_set"][0]["operator_acc_addr"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["dogfood"]["last_total_power"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["dogfood"]["params"]["min_self_delegation"]="100"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" @@ -252,9 +275,9 @@ EOF # Allocate genesis accounts (cosmos formatted addresses) for KEY in "${KEYS[@]}"; do - exocored add-genesis-account "$KEY" 100000000000000000000000000aexo --keyring-backend $KEYRING --home "$HOMEDIR" + exocored add-genesis-account "$KEY" 100000000000000000000000000aexo --keyring-backend "$KEYRING" --home "$HOMEDIR" done - exocored add-genesis-account "${LOCAL_NAME}" 100000000000000000000000000aexo --keyring-backend $KEYRING --home "$HOMEDIR" + exocored add-genesis-account "${LOCAL_NAME}" 100000000000000000000000000aexo --keyring-backend "$KEYRING" --home "$HOMEDIR" # bc is required to add these big numbers # note the extra +1 is for LOCAL_NAME diff --git a/proto/exocore/dogfood/v1/genesis.proto b/proto/exocore/dogfood/v1/genesis.proto index 4ec5c79eb..67ed48a41 100644 --- a/proto/exocore/dogfood/v1/genesis.proto +++ b/proto/exocore/dogfood/v1/genesis.proto @@ -71,17 +71,12 @@ message GenesisState { // GenesisValidator defines a genesis validator. It is a helper struct // used for serializing the genesis state. The only reason it is a different // structure is to support importing hex public keys from Solidity. -// TODO: consider this set up when resolving issue 73 about storage -// optimization between dogfood and operator modules. -// https://github.com/ExocoreNetwork/exocore/issues/73 message GenesisValidator { // public_key is the hex consensus public key of the validator. It should // be exactly 32 bytes, but this is not enforced in protobuf. string public_key = 1; // power is the voting power of the validator. int64 power = 2; - // acc_address is the operator account address of the validator. - string operator_acc_addr = 3; } // EpochToOperatorAddress is used to store a mapping from epoch to a list of diff --git a/testutil/utils.go b/testutil/utils.go index db3bf6e55..cfae3ae6a 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -344,14 +344,12 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc dogfoodGenesis := dogfoodtypes.NewGenesis( dogfoodtypes.DefaultParams(), []dogfoodtypes.GenesisValidator{ { - PublicKey: pubKey.ToHex(), - Power: power, - OperatorAccAddr: operator1.String(), + PublicKey: pubKey.ToHex(), + Power: power, }, { - PublicKey: pubKey2.ToHex(), - Power: power2, - OperatorAccAddr: operator2.String(), + PublicKey: pubKey2.ToHex(), + Power: power2, }, }, []dogfoodtypes.EpochToOperatorAddrs{}, diff --git a/x/dogfood/keeper/genesis.go b/x/dogfood/keeper/genesis.go index 8a229db47..62d026a40 100644 --- a/x/dogfood/keeper/genesis.go +++ b/x/dogfood/keeper/genesis.go @@ -39,32 +39,36 @@ func (k Keeper) InitGenesis( // create the AVS var avsAddr common.Address var err error - // the avs module will remove the revision by itself + // the avs module will remove the revision by itself, but we do it here anyway because we need it + // to look up operator registration status after this - which is keyed by chainID without revision. + chainIDWithoutRevision := avstypes.ChainIDWithoutRevision(ctx.ChainID()) if avsAddr, err = k.avsKeeper.RegisterAVSWithChainID(ctx, &avstypes.AVSRegisterOrDeregisterParams{ - AvsName: ctx.ChainID(), + AvsName: chainIDWithoutRevision, AssetID: genState.Params.AssetIDs, UnbondingPeriod: uint64(genState.Params.EpochsUntilUnbonded), MinSelfDelegation: genState.Params.MinSelfDelegation.Uint64(), EpochIdentifier: epochID, - ChainID: ctx.ChainID(), + ChainID: chainIDWithoutRevision, }); err != nil { panic(fmt.Errorf("could not create the dogfood AVS: %s", err)) } avsAddrString := avsAddr.String() - ctx.Logger().With(types.ModuleName).Info(fmt.Sprintf("created dogfood avs %s %s", avsAddrString, ctx.ChainID())) + k.Logger(ctx).Info( + "created dogfood avs", + "avsAddrString", avsAddrString, + "chainIDWithoutRevision", chainIDWithoutRevision, + ) // create the validators out := make([]abci.ValidatorUpdate, 0, len(genState.ValSet)) for _, val := range genState.ValSet { // wrappedKey can never be nil wrappedKey := operatortypes.NewWrappedConsKeyFromHex(val.PublicKey) - // #nosec G703 // already validated - /* operatorAddr, _ := sdk.AccAddressFromBech32(val.OperatorAccAddr) - // OptIntoAVS checks that the operator exists and will error if it does not. - if err := k.operatorKeeper.OptInWithConsKey( - ctx, operatorAddr, avsAddrString, wrappedKey, - ); err != nil { - panic(fmt.Errorf("failed to opt into avs: %s", err)) - }*/ + // check that an operator exists + if found, _ := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr( + ctx, chainIDWithoutRevision, wrappedKey.ToConsAddr(), + ); !found { + panic(fmt.Sprintf("operator not found for key %s", val.PublicKey)) + } out = append(out, abci.ValidatorUpdate{ PubKey: *wrappedKey.ToTmProtoKey(), Power: val.Power, @@ -127,20 +131,13 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { pubKey, _ := val.ConsPubKey() // #nosec G703 // already validated convKey, _ := cryptocodec.ToTmPubKeyInterface(pubKey) - addr := sdk.GetConsAddress(pubKey) - found, operatorAddr := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr(ctx, avstypes.ChainIDWithoutRevision(ctx.ChainID()), addr) - if !found { - ctx.Logger().Error("Operator address not found for validator", "consAddr", addr.String()) - return true - } validators = append(validators, types.GenesisValidator{ - PublicKey: hexutil.Encode(convKey.Bytes()), - Power: val.GetConsensusPower(sdk.DefaultPowerReduction), - OperatorAccAddr: operatorAddr.String(), + PublicKey: hexutil.Encode(convKey.Bytes()), + Power: val.GetConsensusPower(sdk.DefaultPowerReduction), }, ) - return false /* stop */ + return false // stop == false => continue iteration }) return types.NewGenesis( k.GetDogfoodParams(ctx), diff --git a/x/dogfood/types/genesis.go b/x/dogfood/types/genesis.go index 79056b074..124e3a6f2 100644 --- a/x/dogfood/types/genesis.go +++ b/x/dogfood/types/genesis.go @@ -64,7 +64,6 @@ func (gs GenesisState) Validate() error { } // do not complain about 0 validators, let Tendermint do that. pubkeys := make(map[string]struct{}, len(gs.ValSet)) - operatorAccAddrs := make(map[string]struct{}, len(gs.ValSet)) totalPower := int64(0) for _, val := range gs.ValSet { // check for duplicates in puyb keys @@ -85,22 +84,6 @@ func (gs GenesisState) Validate() error { ) } pubkeys[val.PublicKey] = struct{}{} - // check for duplicates in operator addresses - if _, ok := operatorAccAddrs[val.OperatorAccAddr]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate operator address %s", val.OperatorAccAddr, - ) - } - // check for validity of the operator address - if _, err := sdk.AccAddressFromBech32(val.OperatorAccAddr); err != nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "invalid operator address %s: %s", - val.OperatorAccAddr, err, - ) - } - operatorAccAddrs[val.OperatorAccAddr] = struct{}{} power := val.Power // minSelfDelegation is non negative per Params.Validate, so we don't need to check if power is. // simply checking that power is greater than or equal to minSelfDelegation is enough. diff --git a/x/dogfood/types/genesis.pb.go b/x/dogfood/types/genesis.pb.go index 584aebea2..6e4b47c0f 100644 --- a/x/dogfood/types/genesis.pb.go +++ b/x/dogfood/types/genesis.pb.go @@ -124,17 +124,12 @@ func (m *GenesisState) GetUndelegationMaturities() []EpochToUndelegationRecordKe // GenesisValidator defines a genesis validator. It is a helper struct // used for serializing the genesis state. The only reason it is a different // structure is to support importing hex public keys from Solidity. -// TODO: consider this set up when resolving issue 73 about storage -// optimization between dogfood and operator modules. -// https://github.com/ExocoreNetwork/exocore/issues/73 type GenesisValidator struct { // public_key is the hex consensus public key of the validator. It should // be exactly 32 bytes, but this is not enforced in protobuf. PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // power is the voting power of the validator. Power int64 `protobuf:"varint,2,opt,name=power,proto3" json:"power,omitempty"` - // acc_address is the operator account address of the validator. - OperatorAccAddr string `protobuf:"bytes,3,opt,name=operator_acc_addr,json=operatorAccAddr,proto3" json:"operator_acc_addr,omitempty"` } func (m *GenesisValidator) Reset() { *m = GenesisValidator{} } @@ -184,13 +179,6 @@ func (m *GenesisValidator) GetPower() int64 { return 0 } -func (m *GenesisValidator) GetOperatorAccAddr() string { - if m != nil { - return m.OperatorAccAddr - } - return "" -} - // EpochToOperatorAddress is used to store a mapping from epoch to a list of // operator account addresses. type EpochToOperatorAddrs struct { @@ -374,45 +362,44 @@ func init() { func init() { proto.RegisterFile("exocore/dogfood/v1/genesis.proto", fileDescriptor_1a9d908a27866b1b) } var fileDescriptor_1a9d908a27866b1b = []byte{ - // 593 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0xc1, 0x4e, 0xdb, 0x30, - 0x18, 0xc7, 0x1b, 0x0a, 0x4c, 0x35, 0x88, 0x15, 0x0b, 0xb6, 0x08, 0x89, 0x50, 0x55, 0xd3, 0xd4, - 0xa1, 0x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 0x01, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x4c, 0x49, 0x3b, 0x8a, 0x04, 0x00, - 0x00, + // 578 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xc1, 0x4e, 0xdb, 0x30, + 0x18, 0xc7, 0x1b, 0x0a, 0x4c, 0x35, 0x08, 0x75, 0x16, 0x6c, 0x11, 0x12, 0xa1, 0xaa, 0xa6, 0xa9, + 0x9b, 0xb6, 0x44, 0x85, 0x0b, 0x57, 0x40, 0x08, 0x4d, 0x6c, 0x03, 0x05, 0x36, 0x4d, 0x48, 0x53, + 0x64, 0x1c, 0x2f, 0x8d, 0x9a, 0xe6, 0xb3, 0x6c, 0xa7, 0xb4, 0x6f, 0xb1, 0x67, 0xd8, 0x69, 0xc7, + 0x3d, 0x06, 0x47, 0x8e, 0xd3, 0x0e, 0x68, 0x6a, 0x0f, 0x7b, 0x8d, 0xc9, 0x4e, 0x82, 0xda, 0xad, + 0xf4, 0xd2, 0xda, 0x5f, 0xfe, 0xdf, 0xef, 0xef, 0xe4, 0xef, 0x0f, 0x35, 0xd8, 0x00, 0x28, 0x08, + 0xe6, 0x85, 0x10, 0x7d, 0x01, 0x08, 0xbd, 0x7e, 0xdb, 0x8b, 0x58, 0xca, 0x64, 0x2c, 0x5d, 0x2e, + 0x40, 0x01, 0xc6, 0x85, 0xc2, 0x2d, 0x14, 0x6e, 0xbf, 0xbd, 0xf9, 0x98, 0xf4, 0xe2, 0x14, 0x3c, + 0xf3, 0x9b, 0xcb, 0x36, 0xd7, 0x23, 0x88, 0xc0, 0x2c, 0x3d, 0xbd, 0x2a, 0xaa, 0xdb, 0x33, 0xf0, + 0x9c, 0x08, 0xd2, 0x2b, 0xe8, 0xcd, 0x6f, 0x8b, 0x68, 0xf5, 0x38, 0xf7, 0x3b, 0x57, 0x44, 0x31, + 0xbc, 0x87, 0x96, 0x73, 0x81, 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3b, 0x95, 0xdb, 0xb1, 0x53, 0xf9, 0x39, 0x76, 0x2a, 0x97, 0xed, 0x89, 0xe8, 0x8e, 0xf2, + 0x7b, 0xf3, 0x9e, 0xa9, 0x6b, 0x10, 0x5d, 0xaf, 0x9c, 0xee, 0xc1, 0xfd, 0x7c, 0x9b, 0x24, 0xaf, + 0x96, 0xcd, 0x70, 0xef, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x73, 0x71, 0xf4, 0x5e, 0x04, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -534,13 +521,6 @@ func (m *GenesisValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.OperatorAccAddr) > 0 { - i -= len(m.OperatorAccAddr) - copy(dAtA[i:], m.OperatorAccAddr) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAccAddr))) - i-- - dAtA[i] = 0x1a - } if m.Power != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.Power)) i-- @@ -728,10 +708,6 @@ func (m *GenesisValidator) Size() (n int) { if m.Power != 0 { n += 1 + sovGenesis(uint64(m.Power)) } - l = len(m.OperatorAccAddr) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } return n } @@ -1127,38 +1103,6 @@ func (m *GenesisValidator) Unmarshal(dAtA []byte) error { break } } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorAccAddr", 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.OperatorAccAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/dogfood/types/genesis_test.go b/x/dogfood/types/genesis_test.go index 8aa8ce7ec..36bd28a6a 100644 --- a/x/dogfood/types/genesis_test.go +++ b/x/dogfood/types/genesis_test.go @@ -85,9 +85,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { ) gs.ValSet = append(gs.ValSet, types.GenesisValidator{ - PublicKey: key, - Power: 5, - OperatorAccAddr: sdk.AccAddress(testutiltx.GenerateAddress().Bytes()).String(), + PublicKey: key, + Power: 5, }, ) } @@ -104,14 +103,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - OperatorAccAddr: sdk.AccAddress(testutiltx.GenerateAddress().Bytes()).String(), - Power: 5, + PublicKey: sharedKey, + Power: 5, }, { - PublicKey: sharedKey, - OperatorAccAddr: sdk.AccAddress(testutiltx.GenerateAddress().Bytes()).String(), - Power: 10, + PublicKey: sharedKey, + Power: 10, }, }, LastTotalPower: math.NewInt(10), @@ -126,9 +123,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { ValSet: []types.GenesisValidator{ { // remove 2 chars and add 2 chars - PublicKey: sharedKey[2:] + "ab", - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey[2:] + "ab", + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -143,9 +139,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey + "ab", - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey + "ab", + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -160,9 +155,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { ValSet: []types.GenesisValidator{ { // replace last 2 chars with non-hex - PublicKey: sharedKey[:64] + "ss", - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey[:64] + "ss", + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -176,9 +170,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: -1, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: -1, }, }, LastTotalPower: math.NewInt(1), @@ -192,63 +185,22 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), }, expPass: true, }, - { - name: "invalid operator address", - genState: &types.GenesisState{ - Params: params, - ValSet: []types.GenesisValidator{ - { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String() + "aaaaaa", - }, - }, - LastTotalPower: math.NewInt(5), - }, - expPass: false, - expError: "invalid operator address", - }, - { - name: "duplicate operator address", - genState: &types.GenesisState{ - Params: params, - ValSet: []types.GenesisValidator{ - { - PublicKey: hexutil.Encode( - ed25519.GenPrivKey().PubKey().Bytes(), - ), - Power: 5, - OperatorAccAddr: operator1.String(), - }, - { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), - }, - }, - LastTotalPower: math.NewInt(10), - }, - expPass: false, - expError: "duplicate operator address", - }, { name: "duplicate epoch in expiries", genState: &types.GenesisState{ Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - OperatorAccAddr: operator1.String(), - Power: 5, + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -276,9 +228,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -300,9 +251,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -321,9 +271,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -346,9 +295,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -370,9 +318,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -393,9 +340,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -423,9 +369,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -447,9 +392,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -468,9 +412,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -493,9 +436,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -516,9 +458,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -540,9 +481,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -570,9 +510,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -594,9 +533,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -615,9 +553,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -640,9 +577,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -663,9 +599,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5), @@ -687,9 +622,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: params, ValSet: []types.GenesisValidator{ { - PublicKey: sharedKey, - Power: 5, - OperatorAccAddr: operator1.String(), + PublicKey: sharedKey, + Power: 5, }, }, LastTotalPower: math.NewInt(5),