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

refactor(zetacore): delete ballots after maturity #2863

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0a39fd8
add function to clear ballots
kingpinXD Sep 10, 2024
16d21c4
add unit tests
kingpinXD Sep 10, 2024
9adb64e
refactor abci tests
kingpinXD Sep 11, 2024
0c0d077
Merge branch 'develop' into clear-ballots
kingpinXD Sep 11, 2024
7e771da
Merge branch 'develop' into clear-ballots
kingpinXD Sep 11, 2024
4779bda
refactor generate voter list method
kingpinXD Sep 11, 2024
1799d09
Merge remote-tracking branch 'origin/clear-ballots' into clear-ballots
kingpinXD Sep 11, 2024
afaa312
refactor names for ballot list functions
kingpinXD Sep 16, 2024
bf3c438
refactor ClearMaturedBallots to ClearMaturedBallotsAndBallotList
kingpinXD Sep 23, 2024
fbf277b
make getMaturedBallotHeight private
kingpinXD Sep 26, 2024
8be7f3f
make getMaturedBallotHeight private
kingpinXD Sep 26, 2024
12f9baa
add migration script to delete ballots and tests with mainnet data
kingpinXD Oct 1, 2024
a2c01e1
rebase develop 1
kingpinXD Dec 19, 2024
68bd73a
add test for migration
kingpinXD Dec 19, 2024
b074dda
add a query for all ballots
kingpinXD Dec 19, 2024
3c38438
generate files
kingpinXD Dec 19, 2024
5171ebd
add changelog
kingpinXD Dec 20, 2024
e533f7e
fixed test naming
kingpinXD Dec 20, 2024
3a807ec
update migration comment
kingpinXD Dec 20, 2024
c56fa11
update module version
kingpinXD Dec 23, 2024
0069905
make changes for comments 2
kingpinXD Jan 7, 2025
259d5f8
remove max limit for Ballots query
kingpinXD Jan 7, 2025
04402c4
remove BallotDeleteEvent
kingpinXD Jan 8, 2025
590467a
remove BallotDeleteEvent
kingpinXD Jan 8, 2025
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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

* [3170](https://github.com/zeta-chain/node/pull/3170) - revamp TSS package in zetaclient
* [3291](https://github.com/zeta-chain/node/pull/3291) - revamp zetaclient initialization (+ graceful shutdown)
* [2863](https://github.com/zeta-chain/node/pull/2863) - refactor zetacore to delete matured ballots and add a migration script to remove all old ballots.

### Fixes

Expand Down
35 changes: 35 additions & 0 deletions docs/cli/zetacored/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -5376,6 +5376,7 @@ zetacored query observer [flags]
* [zetacored query](#zetacored-query) - Querying subcommands
* [zetacored query observer get-historical-tss-address](#zetacored-query-observer-get-historical-tss-address) - Query tss address by finalized zeta height (for historical tss addresses)
* [zetacored query observer get-tss-address](#zetacored-query-observer-get-tss-address) - Query current tss address
* [zetacored query observer list-ballots](#zetacored-query-observer-list-ballots) - Query all ballots
* [zetacored query observer list-blame](#zetacored-query-observer-list-blame) - Query AllBlameRecords
* [zetacored query observer list-blame-by-msg](#zetacored-query-observer-list-blame-by-msg) - Query AllBlameRecords
* [zetacored query observer list-chain-nonces](#zetacored-query-observer-list-chain-nonces) - list all chainNonces
Expand Down Expand Up @@ -5466,6 +5467,40 @@ zetacored query observer get-tss-address [bitcoinChainId]] [flags]

* [zetacored query observer](#zetacored-query-observer) - Querying commands for the observer module

## zetacored query observer list-ballots

Query all ballots

```
zetacored query observer list-ballots [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 list-ballots
--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)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored query observer](#zetacored-query-observer) - Querying commands for the observer module

## zetacored query observer list-blame

Query AllBlameRecords
Expand Down
94 changes: 94 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29981,6 +29981,65 @@ paths:
type: string
tags:
- Query
/zeta-chain/observer/ballots:
get:
summary: Query all ballots
operationId: Query_Ballots
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/observerQueryBallotsResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: pagination.key
description: |-
key is a value returned in PageResponse.next_key to begin
querying the next page most efficiently. Only one of offset or key
should be set.
in: query
required: false
type: string
format: byte
- name: pagination.offset
description: |-
offset is a numeric offset that can be used when key is unavailable.
It is less efficient than using key. Only one of offset or key should
be set.
in: query
required: false
type: string
format: uint64
- name: pagination.limit
description: |-
limit is the total number of results to be returned in the result page.
If left empty it will default to a value to be set by each app.
in: query
required: false
type: string
format: uint64
- name: pagination.count_total
description: |-
count_total is set to true to indicate that the result set should include
a count of the total number of items available for pagination in UIs.
count_total is only respected when offset is used. It is ignored when key
is set.
in: query
required: false
type: boolean
- name: pagination.reverse
description: |-
reverse is set to true if results are to be returned in the descending order.

Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
/zeta-chain/observer/blame_by_chain_and_nonce/{chain_id}/{nonce}:
get:
summary: Queries a list of VoterByIdentifier items.
Expand Down Expand Up @@ -57864,6 +57923,31 @@ definitions:
properties:
valid:
type: boolean
observerBallot:
type: object
properties:
index:
type: string
ballot_identifier:
type: string
voter_list:
type: array
items:
type: string
votes:
type: array
items:
$ref: '#/definitions/observerVoteType'
observation_type:
$ref: '#/definitions/observerObservationType'
ballot_threshold:
type: string
ballot_status:
$ref: '#/definitions/observerBallotStatus'
ballot_creation_height:
type: string
format: int64
title: https://github.com/zeta-chain/node/issues/939
observerBallotStatus:
type: string
enum:
Expand Down Expand Up @@ -58180,6 +58264,16 @@ definitions:
$ref: '#/definitions/observerObservationType'
ballot_status:
$ref: '#/definitions/observerBallotStatus'
observerQueryBallotsResponse:
type: object
properties:
ballots:
type: array
items:
type: object
$ref: '#/definitions/observerBallot'
pagination:
$ref: '#/definitions/v1beta1PageResponse'
observerQueryBlameByChainAndNonceResponse:
type: object
properties:
Expand Down
15 changes: 15 additions & 0 deletions proto/zetachain/zetacore/observer/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ service Query {
returns (QueryOperationalFlagsResponse) {
option (google.api.http).get = "/zeta-chain/observer/operationalFlags";
}

// Query all ballots
rpc Ballots(QueryBallotsRequest) returns (QueryBallotsResponse) {
option (google.api.http).get = "/zeta-chain/observer/ballots";
}
}

message QueryBallotsRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryBallotsResponse {
repeated Ballot ballots = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryOperationalFlagsRequest {}
Expand Down Expand Up @@ -259,6 +273,7 @@ message QueryHasVotedRequest {
message QueryHasVotedResponse { bool has_voted = 1; }

message QueryBallotByIdentifierRequest { string ballot_identifier = 1; }

message VoterList {
string voter_address = 1;
VoteType vote_type = 2;
Expand Down
5 changes: 5 additions & 0 deletions testutil/keeper/mocks/emissions/observer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions testutil/sample/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package sample

import (
"bytes"

"github.com/cometbft/cometbft/libs/log"
)

type TestLogger struct {
buf bytes.Buffer
log.Logger
}

func NewTestLogger() *TestLogger {
tl := &TestLogger{}
tl.Logger = log.NewTMLogger(log.NewSyncWriter(&tl.buf))
return tl
}

func (t *TestLogger) Write(p []byte) (n int, err error) {
return t.buf.Write(p)
}

func (t *TestLogger) String() string {
return t.buf.String()
}
57 changes: 55 additions & 2 deletions typescript/zetachain/zetacore/observer/query_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import type { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination_pb.js";
import type { Ballot, BallotStatus, VoteType } from "./ballot_pb.js";
import type { OperationalFlags } from "./operational_pb.js";
import type { TssFundMigratorInfo } from "./tss_funds_migrator_pb.js";
import type { ChainNonces } from "./chain_nonces_pb.js";
import type { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination_pb.js";
import type { PendingNonces } from "./pending_nonces_pb.js";
import type { TSS } from "./tss_pb.js";
import type { BallotStatus, VoteType } from "./ballot_pb.js";
import type { LastObserverCount, ObservationType } from "./observer_pb.js";
import type { Chain } from "../pkg/chains/chains_pb.js";
import type { ChainParams, ChainParamsList } from "./params_pb.js";
Expand All @@ -20,6 +20,59 @@ import type { CrosschainFlags } from "./crosschain_flags_pb.js";
import type { Keygen } from "./keygen_pb.js";
import type { Blame } from "./blame_pb.js";

/**
* @generated from message zetachain.zetacore.observer.QueryBallotsRequest
*/
export declare class QueryBallotsRequest extends Message<QueryBallotsRequest> {
/**
* @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1;
*/
pagination?: PageRequest;

constructor(data?: PartialMessage<QueryBallotsRequest>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.observer.QueryBallotsRequest";
static readonly fields: FieldList;

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

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

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

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

/**
* @generated from message zetachain.zetacore.observer.QueryBallotsResponse
*/
export declare class QueryBallotsResponse extends Message<QueryBallotsResponse> {
/**
* @generated from field: repeated zetachain.zetacore.observer.Ballot ballots = 1;
*/
ballots: Ballot[];

/**
* @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2;
*/
pagination?: PageResponse;

constructor(data?: PartialMessage<QueryBallotsResponse>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.observer.QueryBallotsResponse";
static readonly fields: FieldList;

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

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

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

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

/**
* @generated from message zetachain.zetacore.observer.QueryOperationalFlagsRequest
*/
Expand Down
Loading
Loading