From d3bd6d8997b00128665637e4a021f73ea6b5d918 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 14 Nov 2023 13:48:11 -0500 Subject: [PATCH] add unit tests for aborted zeta amount keeper functions --- proto/crosschain/genesis.proto | 1 + typescript/crosschain/genesis_pb.d.ts | 7 +- x/crosschain/client/cli/query.go | 1 + .../client/cli/query_aborted_zeta_amount.go | 31 +++++ x/crosschain/genesis.go | 2 + x/crosschain/genesis_test.go | 4 + .../keeper/abourted_zeta_amount_test.go | 49 +++++++ x/crosschain/types/genesis.pb.go | 122 +++++++++++++----- zetaclient/zeta_supply_checker.go | 3 + 9 files changed, 186 insertions(+), 34 deletions(-) create mode 100644 x/crosschain/client/cli/query_aborted_zeta_amount.go create mode 100644 x/crosschain/keeper/abourted_zeta_amount_test.go diff --git a/proto/crosschain/genesis.proto b/proto/crosschain/genesis.proto index c62d228d0b..785d7925bd 100644 --- a/proto/crosschain/genesis.proto +++ b/proto/crosschain/genesis.proto @@ -27,4 +27,5 @@ message GenesisState { repeated InTxHashToCctx inTxHashToCctxList = 9 [(gogoproto.nullable) = false]; repeated TSS tss_history = 10 [(gogoproto.nullable) = false]; repeated InTxTracker in_tx_tracker_list = 11 [(gogoproto.nullable) = false]; + AbortedZetaAmount aborted_zeta_amount = 12 [(gogoproto.nullable) = false]; } diff --git a/typescript/crosschain/genesis_pb.d.ts b/typescript/crosschain/genesis_pb.d.ts index b08be54a4a..e4cf8fe8f5 100644 --- a/typescript/crosschain/genesis_pb.d.ts +++ b/typescript/crosschain/genesis_pb.d.ts @@ -10,7 +10,7 @@ import type { OutTxTracker } from "./out_tx_tracker_pb.js"; import type { TSS } from "./tss_pb.js"; import type { GasPrice } from "./gas_price_pb.js"; import type { ChainNonces } from "./chain_nonces_pb.js"; -import type { CrossChainTx } from "./cross_chain_tx_pb.js"; +import type { AbortedZetaAmount, CrossChainTx } from "./cross_chain_tx_pb.js"; import type { LastBlockHeight } from "./last_block_height_pb.js"; import type { InTxHashToCctx } from "./in_tx_hash_to_cctx_pb.js"; import type { InTxTracker } from "./in_tx_tracker_pb.js"; @@ -71,6 +71,11 @@ export declare class GenesisState extends Message { */ inTxTrackerList: InTxTracker[]; + /** + * @generated from field: zetachain.zetacore.crosschain.AbortedZetaAmount aborted_zeta_amount = 12; + */ + abortedZetaAmount?: AbortedZetaAmount; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/x/crosschain/client/cli/query.go b/x/crosschain/client/cli/query.go index 21b112a621..560a60955f 100644 --- a/x/crosschain/client/cli/query.go +++ b/x/crosschain/client/cli/query.go @@ -46,6 +46,7 @@ func GetQueryCmd(_ string) *cobra.Command { CmdPendingCctx(), CmdListInTxTrackerByChain(), CmdListInTxTrackers(), + CmdGetAbortedZetaAmount(), ) return cmd diff --git a/x/crosschain/client/cli/query_aborted_zeta_amount.go b/x/crosschain/client/cli/query_aborted_zeta_amount.go new file mode 100644 index 0000000000..2ef508128d --- /dev/null +++ b/x/crosschain/client/cli/query_aborted_zeta_amount.go @@ -0,0 +1,31 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func CmdGetAbortedZetaAmount() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-aborted-zeta-amount", + Short: "Query current tss address", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + params := &types.QueryAbortedZetaAmountRequest{} + res, err := queryClient.AbortedZetaAmount(cmd.Context(), params) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/crosschain/genesis.go b/x/crosschain/genesis.go index 9c0f52bb29..2ac1c17b1b 100644 --- a/x/crosschain/genesis.go +++ b/x/crosschain/genesis.go @@ -13,6 +13,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // Params k.SetParams(ctx, genState.Params) + k.SetAbortedZetaAmount(ctx, genState.AbortedZetaAmount) // Set all the outTxTracker for _, elem := range genState.OutTxTrackerList { k.SetOutTxTracker(ctx, elem) @@ -70,6 +71,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetTSSHistory(ctx, elem) } } + } // ExportGenesis returns the crosschain module's exported genesis. diff --git a/x/crosschain/genesis_test.go b/x/crosschain/genesis_test.go index 994c83f67a..7370a705ed 100644 --- a/x/crosschain/genesis_test.go +++ b/x/crosschain/genesis_test.go @@ -3,6 +3,7 @@ package crosschain_test import ( "testing" + sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" @@ -14,6 +15,9 @@ import ( func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ Params: types.DefaultParams(), + AbortedZetaAmount: types.AbortedZetaAmount{ + Amount: sdkmath.OneUint(), + }, OutTxTrackerList: []types.OutTxTracker{ sample.OutTxTracker(t, "0"), sample.OutTxTracker(t, "1"), diff --git a/x/crosschain/keeper/abourted_zeta_amount_test.go b/x/crosschain/keeper/abourted_zeta_amount_test.go new file mode 100644 index 0000000000..d7d6935775 --- /dev/null +++ b/x/crosschain/keeper/abourted_zeta_amount_test.go @@ -0,0 +1,49 @@ +package keeper_test + +import ( + "math/rand" + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestKeeper_AddAbortedZetaAmount(t *testing.T) { + + t.Run("should add aborted zeta amount", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + originalAmount := sdkmath.NewUint(rand.Uint64()) + k.SetAbortedZetaAmount(ctx, types.AbortedZetaAmount{ + originalAmount, + }) + val, found := k.GetAbortedZetaAmount(ctx) + require.True(t, found) + require.Equal(t, originalAmount, val.Amount) + addAmount := sdkmath.NewUint(rand.Uint64()) + k.AddAbortedZetaAmount(ctx, addAmount) + val, found = k.GetAbortedZetaAmount(ctx) + require.True(t, found) + require.Equal(t, originalAmount.Add(addAmount), val.Amount) + }) + + t.Run("cant find aborted amount", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + val, found := k.GetAbortedZetaAmount(ctx) + require.False(t, found) + require.Equal(t, types.AbortedZetaAmount{}, val) + }) + + t.Run("add very high zeta amount", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + highAmount := sdkmath.NewUintFromString("100000000000000000000000000000000000000000000000") + k.SetAbortedZetaAmount(ctx, types.AbortedZetaAmount{ + highAmount, + }) + val, found := k.GetAbortedZetaAmount(ctx) + require.True(t, found) + require.Equal(t, highAmount, val.Amount) + }) + +} diff --git a/x/crosschain/types/genesis.pb.go b/x/crosschain/types/genesis.pb.go index c1b357ebad..718e10b0df 100644 --- a/x/crosschain/types/genesis.pb.go +++ b/x/crosschain/types/genesis.pb.go @@ -36,6 +36,7 @@ type GenesisState struct { InTxHashToCctxList []InTxHashToCctx `protobuf:"bytes,9,rep,name=inTxHashToCctxList,proto3" json:"inTxHashToCctxList"` TssHistory []TSS `protobuf:"bytes,10,rep,name=tss_history,json=tssHistory,proto3" json:"tss_history"` InTxTrackerList []InTxTracker `protobuf:"bytes,11,rep,name=in_tx_tracker_list,json=inTxTrackerList,proto3" json:"in_tx_tracker_list"` + AbortedZetaAmount AbortedZetaAmount `protobuf:"bytes,12,opt,name=aborted_zeta_amount,json=abortedZetaAmount,proto3" json:"aborted_zeta_amount"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -141,6 +142,13 @@ func (m *GenesisState) GetInTxTrackerList() []InTxTracker { return nil } +func (m *GenesisState) GetAbortedZetaAmount() AbortedZetaAmount { + if m != nil { + return m.AbortedZetaAmount + } + return AbortedZetaAmount{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "zetachain.zetacore.crosschain.GenesisState") } @@ -148,39 +156,42 @@ func init() { func init() { proto.RegisterFile("crosschain/genesis.proto", fileDescriptor_dd51403692d571f4) } var fileDescriptor_dd51403692d571f4 = []byte{ - // 512 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xd1, 0x6e, 0xd3, 0x30, - 0x14, 0x86, 0x1b, 0x36, 0x0a, 0xb8, 0x43, 0x43, 0x06, 0x89, 0xa8, 0xd2, 0xb2, 0xa9, 0x08, 0x31, - 0x81, 0x96, 0x88, 0xc1, 0x13, 0xb4, 0x17, 0xeb, 0xb4, 0x09, 0x46, 0x9a, 0x2b, 0xa4, 0xc9, 0xb8, - 0x96, 0x95, 0x44, 0xeb, 0xe2, 0x2a, 0xc7, 0x95, 0x32, 0x9e, 0x82, 0xc7, 0xda, 0x1d, 0xbb, 0xe4, - 0x0a, 0xa1, 0xf6, 0x45, 0x90, 0x4f, 0xb2, 0xcd, 0xa1, 0x15, 0xe9, 0x4d, 0x65, 0xe5, 0xfc, 0xff, - 0x77, 0xfe, 0xda, 0xe7, 0x10, 0x57, 0xe4, 0x0a, 0x40, 0x24, 0x3c, 0xcd, 0x82, 0x58, 0x66, 0x12, - 0x52, 0xf0, 0xa7, 0xb9, 0xd2, 0x8a, 0xee, 0x7c, 0x97, 0x9a, 0x63, 0xc1, 0xc7, 0x93, 0xca, 0xa5, - 0x7f, 0x2f, 0xee, 0xee, 0x58, 0x46, 0xfc, 0x65, 0x99, 0xca, 0x84, 0xac, 0xdc, 0xdd, 0x5d, 0xbb, - 0x6c, 0x8e, 0xac, 0x14, 0xe9, 0xa2, 0x12, 0x74, 0xed, 0xc6, 0x1c, 0xd8, 0x34, 0x4f, 0x85, 0xac, - 0x6a, 0xaf, 0xac, 0x1a, 0x7a, 0x58, 0xc2, 0x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 0x41, 0xbf, - 0x90, 0xa7, 0x03, 0x23, 0x45, 0x51, 0x54, 0x80, 0xfb, 0x68, 0xad, 0x4b, 0xb3, 0x3d, 0x61, 0x9d, - 0x40, 0xbf, 0x91, 0xe7, 0x66, 0xc2, 0xfa, 0x66, 0xc0, 0x86, 0x38, 0x5f, 0x18, 0xf6, 0x31, 0x82, - 0xfd, 0x06, 0xf0, 0x69, 0xdd, 0x19, 0xae, 0x42, 0x51, 0x41, 0xa8, 0x69, 0x35, 0xe4, 0x90, 0x44, - 0x6a, 0x20, 0x74, 0x81, 0x0d, 0x9e, 0x60, 0x83, 0x83, 0x86, 0x06, 0xc7, 0x35, 0x63, 0xf5, 0xe0, - 0x2b, 0x70, 0xf4, 0x98, 0x74, 0x34, 0x00, 0x4b, 0x52, 0xd0, 0x2a, 0xbf, 0x72, 0x09, 0xd2, 0xd7, - 0x78, 0xfa, 0x0a, 0x49, 0x34, 0xc0, 0xb0, 0xf4, 0xd2, 0x73, 0x93, 0xd7, 0x5a, 0x27, 0x36, 0x31, - 0x79, 0x3b, 0x6b, 0xbd, 0x9e, 0xc9, 0x5b, 0x9f, 0xce, 0xed, 0x34, 0xab, 0x0d, 0x67, 0xff, 0xe4, - 0x7a, 0xee, 0x39, 0x37, 0x73, 0xcf, 0xf9, 0x33, 0xf7, 0x9c, 0x1f, 0x0b, 0xaf, 0x75, 0xb3, 0xf0, - 0x5a, 0xbf, 0x16, 0x5e, 0xeb, 0xeb, 0xfb, 0x38, 0xd5, 0xc9, 0x6c, 0xec, 0x0b, 0x75, 0x19, 0x18, - 0xf8, 0x41, 0xb9, 0xa2, 0xb7, 0x7d, 0x82, 0x22, 0xb0, 0x17, 0xf7, 0x6a, 0x2a, 0x61, 0xdc, 0xc6, - 0x2d, 0xfd, 0xf0, 0x37, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x12, 0x5d, 0x65, 0x0b, 0x05, 0x00, 0x00, + // 551 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b,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, 0x54, 0x63, 0x98, 0x87, 0xbc, 0xb0, + 0x04, 0x23, 0x9e, 0xf2, 0xe1, 0xcd, 0xff, 0x7b, 0x6e, 0x15, 0x40, 0xdf, 0xee, 0x86, 0x2a, 0x54, + 0xb8, 0x6c, 0x9b, 0x55, 0xb6, 0xdb, 0xfa, 0xb5, 0x46, 0x1a, 0x87, 0xd9, 0xd9, 0xf6, 0x80, 0x83, + 0xa4, 0x1d, 0x52, 0xcb, 0x60, 0x4e, 0x75, 0xbb, 0xba, 0x53, 0xdf, 0x7b, 0xe5, 0xdd, 0x7b, 0xd6, + 0xde, 0x29, 0x8a, 0x0f, 0x56, 0xaf, 0xfe, 0x6c, 0x55, 0xfc, 0xdc, 0x4a, 0xcf, 0xc9, 0x53, 0x35, + 0x86, 0x60, 0x12, 0x64, 0x81, 0x4f, 0x62, 0x0d, 0xce, 0x83, 0xed, 0x95, 0x9d, 0xfa, 0xde, 0xdb, + 0x12, 0xdc, 0x67, 0xcb, 0x96, 0x43, 0xe7, 0x50, 0xf4, 0x23, 0x59, 0x01, 0xad, 0x9d, 0x55, 0x0c, + 0xd8, 0x2a, 0x21, 0x06, 0xbd, 0x9e, 0x6f, 0xe4, 0xf4, 0x98, 0x34, 0x42, 0xae, 0x4f, 0xcd, 0x5d, + 0x62, 0xa0, 0x87, 0x18, 0xe8, 0x75, 0x89, 0xfd, 0x30, 0xb7, 0xf8, 0x05, 0x33, 0x0d, 0xc8, 0x3a, + 0xd6, 0x3f, 0xe1, 0x60, 0x21, 0xaf, 0x86, 0xbc, 0x37, 0x25, 0xbc, 0xce, 0x9d, 0xcb, 0xff, 0x1f, + 0x41, 0xbf, 0x90, 0x27, 0x1d, 0x23, 0x45, 0x51, 0x30, 0xd1, 0xce, 0xda, 0x52, 0x87, 0x66, 0x7b, + 0xfc, 0x22, 0x81, 0x7e, 0x25, 0x1b, 0x66, 0xc2, 0x0e, 0xcc, 0x80, 0x75, 0x71, 0xbe, 0x30, 0xec, + 0x23, 0x04,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isState) Marshal() (dAtA []byte, err error) { @@ -203,6 +214,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.AbortedZetaAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 if len(m.InTxTrackerList) > 0 { for iNdEx := len(m.InTxTrackerList) - 1; iNdEx >= 0; iNdEx-- { { @@ -411,6 +432,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.AbortedZetaAmount.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -790,6 +813,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AbortedZetaAmount", 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.AbortedZetaAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/zetaclient/zeta_supply_checker.go b/zetaclient/zeta_supply_checker.go index c210344ec2..c4b056d875 100644 --- a/zetaclient/zeta_supply_checker.go +++ b/zetaclient/zeta_supply_checker.go @@ -174,6 +174,9 @@ func ValidateZetaSupply(logger zerolog.Logger, abortedTxAmounts, zetaInTransit, return true } +// TODO : Add genesis state for Aborted amount in zeta +// TODO : Add tests for keeper functions +// TODO : Add cli commands for querying aborted amount func (zs *ZetaSupplyChecker) AbortedTxAmount() (sdkmath.Int, error) { amount, err := zs.zetaClient.GetAbortedZetaAmount() if err != nil {