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 20 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
5 changes: 5 additions & 0 deletions proto/zetachain/zetacore/observer/ballot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ message BallotListForHeight {
int64 height = 1;
repeated string ballots_index_list = 2;
}

message VoterList {
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
string voter_address = 1;
VoteType vote_type = 2;
}
8 changes: 8 additions & 0 deletions proto/zetachain/zetacore/observer/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package zetachain.zetacore.observer;
import "gogoproto/gogo.proto";
import "zetachain/zetacore/observer/crosschain_flags.proto";
import "zetachain/zetacore/observer/observer.proto";
import "zetachain/zetacore/observer/ballot.proto";

option go_package = "github.com/zeta-chain/node/x/observer/types";

Expand All @@ -15,6 +16,13 @@ message EventBallotCreated {
string ballot_type = 5;
}

message EventBallotDeleted {
swift1337 marked this conversation as resolved.
Show resolved Hide resolved
string msg_type_url = 1;
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
string ballot_identifier = 2;
string ballot_type = 3;
repeated VoterList voters = 4 [ (gogoproto.nullable) = false ];
}

message EventKeygenBlockUpdated {
string msg_type_url = 1;
string keygen_block = 2;
Expand Down
20 changes: 15 additions & 5 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,14 +273,10 @@ message QueryHasVotedRequest {
message QueryHasVotedResponse { bool has_voted = 1; }

message QueryBallotByIdentifierRequest { string ballot_identifier = 1; }
message VoterList {
string voter_address = 1;
VoteType vote_type = 2;
}

message QueryBallotByIdentifierResponse {
string ballot_identifier = 1;
repeated VoterList voters = 2;
repeated VoterList voters = 2 [ (gogoproto.nullable) = false ];
ObservationType observation_type = 3;
BallotStatus ballot_status = 4;
}
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.

29 changes: 29 additions & 0 deletions typescript/zetachain/zetacore/observer/ballot_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,32 @@ export declare class BallotListForHeight extends Message<BallotListForHeight> {
static equals(a: BallotListForHeight | PlainMessage<BallotListForHeight> | undefined, b: BallotListForHeight | PlainMessage<BallotListForHeight> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.observer.VoterList
*/
export declare class VoterList extends Message<VoterList> {
/**
* @generated from field: string voter_address = 1;
*/
voterAddress: string;

/**
* @generated from field: zetachain.zetacore.observer.VoteType vote_type = 2;
*/
voteType: VoteType;

constructor(data?: PartialMessage<VoterList>);

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

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

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

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

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

40 changes: 40 additions & 0 deletions typescript/zetachain/zetacore/observer/events_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import type { VoterList } from "./ballot_pb.js";
import type { GasPriceIncreaseFlags } from "./crosschain_flags_pb.js";

/**
Expand Down Expand Up @@ -51,6 +52,45 @@ export declare class EventBallotCreated extends Message<EventBallotCreated> {
static equals(a: EventBallotCreated | PlainMessage<EventBallotCreated> | undefined, b: EventBallotCreated | PlainMessage<EventBallotCreated> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.observer.EventBallotDeleted
*/
export declare class EventBallotDeleted extends Message<EventBallotDeleted> {
/**
* @generated from field: string msg_type_url = 1;
*/
msgTypeUrl: string;

/**
* @generated from field: string ballot_identifier = 2;
*/
ballotIdentifier: string;

/**
* @generated from field: string ballot_type = 3;
*/
ballotType: string;

/**
* @generated from field: repeated zetachain.zetacore.observer.VoterList voters = 4;
*/
voters: VoterList[];

constructor(data?: PartialMessage<EventBallotDeleted>);

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

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

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

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

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

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