Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: state data for aborted tx amount #1395

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
)

const releaseVersion = "v10.1.0"
Expand All @@ -17,7 +17,7 @@ func SetupHandlers(app *App) {
for m, mb := range app.mm.Modules {
vm[m] = mb.ConsensusVersion()
}
vm[observertypes.ModuleName] = vm[observertypes.ModuleName] - 1
vm[crosschaintypes.ModuleName] = vm[crosschaintypes.ModuleName] - 1
return app.mm.RunMigrations(ctx, app.configurator, vm)
})

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Features
* [1395](https://github.com/zeta-chain/node/pull/1395) - Add state variable to track aborted zeta amount
* [1387](https://github.com/zeta-chain/node/pull/1387) - Add HSM capability for zetaclient hot key

### Fixes
Expand Down
1 change: 1 addition & 0 deletions docs/cli/zetacored/zetacored_query_crosschain.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ zetacored query crosschain [flags]

* [zetacored query](zetacored_query.md) - Querying subcommands
* [zetacored query crosschain get-tss-address](zetacored_query_crosschain_get-tss-address.md) - Query current tss address
* [zetacored query crosschain get-zeta-accounting](zetacored_query_crosschain_get-zeta-accounting.md) - Query zeta accounting
* [zetacored query crosschain in-tx-hash-to-cctx-data](zetacored_query_crosschain_in-tx-hash-to-cctx-data.md) - query a cctx data from a in tx hash
* [zetacored query crosschain last-zeta-height](zetacored_query_crosschain_last-zeta-height.md) - Query last Zeta Height
* [zetacored query crosschain list-all-in-tx-trackers](zetacored_query_crosschain_list-all-in-tx-trackers.md) - shows all inTxTrackers
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# query crosschain get-zeta-accounting

Query zeta accounting

```
zetacored query crosschain get-zeta-accounting [flags]
```

### Options

```
--grpc-addr string the gRPC endpoint to use for this chain
--grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS
--height int Use a specific height to query state at (this can error if the node is pruning state)
-h, --help help for get-zeta-accounting
--node string [host]:[port] to Tendermint RPC interface for this chain
-o, --output string Output format (text|json)
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored query crosschain](zetacored_query_crosschain.md) - Querying commands for the crosschain module

23 changes: 23 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27369,6 +27369,20 @@ paths:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/crosschain/zetaAccounting:
get:
operationId: Query_ZetaAccounting
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/crosschainQueryZetaAccountingResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/emissions/get_emissions_factors:
get:
summary: Queries a list of GetEmmisonsFactors items.
Expand Down Expand Up @@ -50952,6 +50966,15 @@ definitions:
items:
type: object
$ref: '#/definitions/crosschainTSS'
crosschainQueryZetaAccountingResponse:
type: object
properties:
aborted_zeta_amount:
type: string
aborted_gas_amount:
type: string
aborted_erc20_amount:
type: string
crosschainTSS:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ require (
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/libp2p/go-yamux/v4 v4.0.0 // indirect
github.com/linxGnu/grocksdb v1.7.15 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/onsi/ginkgo/v2 v2.9.7 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
Expand All @@ -94,6 +95,7 @@ require (
github.com/quic-go/webtransport-go v0.5.3 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/thales-e-security/pool v0.0.2 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,7 @@ github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8=
github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ=
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
Expand Down Expand Up @@ -2335,6 +2336,7 @@ github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1t
github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA=
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8=
github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
Expand Down Expand Up @@ -2690,6 +2692,7 @@ github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvW
github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/securego/gosec v0.0.0-20200103095621-79fbf3af8d83/go.mod h1:vvbZ2Ae7AzSq3/kywjUDxSNq2SJ27RxCz2un0H3ePqE=
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989 h1:rq2/kILQnPtq5oL4+IAjgVOjh5e2yj2aaCYi7squEvI=
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989/go.mod h1:i9l/TNj+yDFh9SZXUTvspXTjbFXgZGP/UvhU1S65A4A=
github.com/securego/gosec/v2 v2.3.0/go.mod h1:UzeVyUXbxukhLeHKV3VVqo7HdoQR9MrRfFmZYotn8ME=
github.com/securego/gosec/v2 v2.13.1/go.mod h1:EO1sImBMBWFjOTFzMWfTRrZW6M15gm60ljzrmy/wtHo=
Expand Down Expand Up @@ -2764,6 +2767,7 @@ github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34c
github.com/sourcegraph/go-diff v0.5.3/go.mod h1:v9JDtjCE4HHHCZGId75rg8gkKKa98RVjBcBGsVmMmak=
github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down
15 changes: 15 additions & 0 deletions proto/crosschain/cross_chain_tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ message InboundTxParams {
uint64 inbound_tx_finalized_zeta_height = 10;
}

message ZetaAccounting {
string aborted_zeta_amount = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = false
]; // This stores the total aborted amount for cctx of coin-type ZETA
string aborted_gas_amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = false
]; // This stores the total aborted amount for cctx of coin-type GAS
string aborted_erc20_amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = false
]; // This stores the total aborted amount for cctx of coin-type ERC20
}

message OutboundTxParams {
string receiver = 1;
int64 receiver_chainId = 2;
Expand Down
1 change: 1 addition & 0 deletions proto/crosschain/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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];
ZetaAccounting zeta_accounting = 12 [(gogoproto.nullable) = false];
}
12 changes: 12 additions & 0 deletions proto/crosschain/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ service Query {
rpc CctxByStatus(QueryCctxByStatusRequest) returns (QueryCctxByStatusResponse) {
option (google.api.http).get = "/zeta-chain/crosschain/cctxbyStatus/{status}";
}

rpc ZetaAccounting(QueryZetaAccountingRequest) returns (QueryZetaAccountingResponse) {
option (google.api.http).get = "/zeta-chain/crosschain/zetaAccounting";
}
}

message QueryZetaAccountingRequest {}

message QueryZetaAccountingResponse {
string aborted_zeta_amount = 1;
string aborted_gas_amount = 2;
string aborted_erc20_amount = 3;
}

message QueryCctxByStatusRequest {
Expand Down
40 changes: 40 additions & 0 deletions typescript/crosschain/cross_chain_tx_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,46 @@ export declare class InboundTxParams extends Message<InboundTxParams> {
static equals(a: InboundTxParams | PlainMessage<InboundTxParams> | undefined, b: InboundTxParams | PlainMessage<InboundTxParams> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.crosschain.ZetaAccounting
*/
export declare class ZetaAccounting extends Message<ZetaAccounting> {
/**
* This stores the total aborted amount for cctx of coin-type ZETA
*
* @generated from field: string aborted_zeta_amount = 1;
*/
abortedZetaAmount: string;

/**
* This stores the total aborted amount for cctx of coin-type GAS
*
* @generated from field: string aborted_gas_amount = 2;
*/
abortedGasAmount: string;

/**
* This stores the total aborted amount for cctx of coin-type ERC20
*
* @generated from field: string aborted_erc20_amount = 3;
*/
abortedErc20Amount: string;

constructor(data?: PartialMessage<ZetaAccounting>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.crosschain.ZetaAccounting";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ZetaAccounting;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ZetaAccounting;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ZetaAccounting;

static equals(a: ZetaAccounting | PlainMessage<ZetaAccounting> | undefined, b: ZetaAccounting | PlainMessage<ZetaAccounting> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.crosschain.OutboundTxParams
*/
Expand Down
7 changes: 6 additions & 1 deletion typescript/crosschain/genesis_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { CrossChainTx, ZetaAccounting } 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";
Expand Down Expand Up @@ -71,6 +71,11 @@ export declare class GenesisState extends Message<GenesisState> {
*/
inTxTrackerList: InTxTracker[];

/**
* @generated from field: zetachain.zetacore.crosschain.ZetaAccounting zeta_accounting = 12;
*/
zetaAccounting?: ZetaAccounting;

constructor(data?: PartialMessage<GenesisState>);

static readonly runtime: typeof proto3;
Expand Down
53 changes: 53 additions & 0 deletions typescript/crosschain/query_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,59 @@ import type { ChainNonces } from "./chain_nonces_pb.js";
import type { PendingNonces } from "./nonce_to_cctx_pb.js";
import type { LastBlockHeight } from "./last_block_height_pb.js";

/**
* @generated from message zetachain.zetacore.crosschain.QueryZetaAccountingRequest
*/
export declare class QueryZetaAccountingRequest extends Message<QueryZetaAccountingRequest> {
constructor(data?: PartialMessage<QueryZetaAccountingRequest>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.crosschain.QueryZetaAccountingRequest";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryZetaAccountingRequest;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryZetaAccountingRequest;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryZetaAccountingRequest;

static equals(a: QueryZetaAccountingRequest | PlainMessage<QueryZetaAccountingRequest> | undefined, b: QueryZetaAccountingRequest | PlainMessage<QueryZetaAccountingRequest> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.crosschain.QueryZetaAccountingResponse
*/
export declare class QueryZetaAccountingResponse extends Message<QueryZetaAccountingResponse> {
/**
* @generated from field: string aborted_zeta_amount = 1;
*/
abortedZetaAmount: string;

/**
* @generated from field: string aborted_gas_amount = 2;
*/
abortedGasAmount: string;

/**
* @generated from field: string aborted_erc20_amount = 3;
*/
abortedErc20Amount: string;

constructor(data?: PartialMessage<QueryZetaAccountingResponse>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.crosschain.QueryZetaAccountingResponse";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryZetaAccountingResponse;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryZetaAccountingResponse;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryZetaAccountingResponse;

static equals(a: QueryZetaAccountingResponse | PlainMessage<QueryZetaAccountingResponse> | undefined, b: QueryZetaAccountingResponse | PlainMessage<QueryZetaAccountingResponse> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.crosschain.QueryCctxByStatusRequest
*/
Expand Down
1 change: 1 addition & 0 deletions x/crosschain/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func GetQueryCmd(_ string) *cobra.Command {
CmdPendingCctx(),
CmdListInTxTrackerByChain(),
CmdListInTxTrackers(),
CmdGetZetaAccounting(),
)

return cmd
Expand Down
31 changes: 31 additions & 0 deletions x/crosschain/client/cli/query_zeta_accounting.go
Original file line number Diff line number Diff line change
@@ -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 CmdGetZetaAccounting() *cobra.Command {
cmd := &cobra.Command{
Use: "get-zeta-accounting",
Short: "Query zeta accounting",
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.QueryZetaAccountingRequest{}
res, err := queryClient.ZetaAccounting(cmd.Context(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
6 changes: 6 additions & 0 deletions x/crosschain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
// Params
k.SetParams(ctx, genState.Params)

k.SetZetaAccounting(ctx, genState.ZetaAccounting)
// Set all the outTxTracker
for _, elem := range genState.OutTxTrackerList {
k.SetOutTxTracker(ctx, elem)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -116,6 +118,10 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
}

genesis.TssHistory = k.GetAllTSS(ctx)
amount, found := k.GetZetaAccounting(ctx)
if found {
genesis.ZetaAccounting = amount
}

return &genesis
}
Loading
Loading