Skip to content

Commit a98f03b

Browse files
authored
fix: avoid posting uncessary outtx confirmation (#16)
* avoid posting uncessary outtx confirmation * updated changelog.md * added ballot identifier in log prints * unified tx hash variable names * updated changelog * updated changelog
1 parent 9fe3ea9 commit a98f03b

File tree

13 files changed

+901
-222
lines changed

13 files changed

+901
-222
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* prevent deposits for paused zrc20
1515
* [1406](https://github.com/zeta-chain/node/pull/1406) - improve log prints and speed up evm outtx inclusion
1616
* fix Athens-3 issue - include bitcoin outtx regardless of the cctx status
17+
* fix Athens-3 log print issue - avoid posting uncessary outtx confirmation
1718

1819
### Refactoring
1920

docs/openapi/openapi.swagger.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -27861,6 +27861,30 @@ paths:
2786127861
$ref: '#/definitions/googlerpcStatus'
2786227862
tags:
2786327863
- Query
27864+
/zeta-chain/observer/has_voted/{ballot_identifier}/{voter_address}:
27865+
get:
27866+
summary: Query if a voter has voted for a ballot
27867+
operationId: Query_HasVoted
27868+
responses:
27869+
"200":
27870+
description: A successful response.
27871+
schema:
27872+
$ref: '#/definitions/observerQueryHasVotedResponse'
27873+
default:
27874+
description: An unexpected error response.
27875+
schema:
27876+
$ref: '#/definitions/googlerpcStatus'
27877+
parameters:
27878+
- name: ballot_identifier
27879+
in: path
27880+
required: true
27881+
type: string
27882+
- name: voter_address
27883+
in: path
27884+
required: true
27885+
type: string
27886+
tags:
27887+
- Query
2786427888
/zeta-chain/observer/keygen:
2786527889
get:
2786627890
summary: Queries a keygen by index.
@@ -51524,6 +51548,11 @@ definitions:
5152451548
properties:
5152551549
node_account:
5152651550
$ref: '#/definitions/observerNodeAccount'
51551+
observerQueryHasVotedResponse:
51552+
type: object
51553+
properties:
51554+
has_voted:
51555+
type: boolean
5152751556
observerQueryObserversByChainResponse:
5152851557
type: object
5152951558
properties:

proto/observer/query.proto

+13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ service Query {
2222
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
2323
option (google.api.http).get = "/zeta-chain/observer/params";
2424
}
25+
// Query if a voter has voted for a ballot
26+
rpc HasVoted(QueryHasVotedRequest) returns (QueryHasVotedResponse) {
27+
option (google.api.http).get = "/zeta-chain/observer/has_voted/{ballot_identifier}/{voter_address}";
28+
}
2529
// Queries a list of VoterByIdentifier items.
2630
rpc BallotByIdentifier(QueryBallotByIdentifierRequest) returns (QueryBallotByIdentifierResponse) {
2731
option (google.api.http).get = "/zeta-chain/observer/ballot_by_identifier/{ballot_identifier}";
@@ -124,6 +128,15 @@ message QueryParamsResponse {
124128
Params params = 1 [(gogoproto.nullable) = false];
125129
}
126130

131+
message QueryHasVotedRequest {
132+
string ballot_identifier = 1;
133+
string voter_address = 2;
134+
}
135+
136+
message QueryHasVotedResponse {
137+
bool has_voted = 1;
138+
}
139+
127140
message QueryBallotByIdentifierRequest {
128141
string ballot_identifier = 1;
129142
}

typescript/observer/query_pb.d.ts

+53
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,59 @@ export declare class QueryParamsResponse extends Message<QueryParamsResponse> {
131131
static equals(a: QueryParamsResponse | PlainMessage<QueryParamsResponse> | undefined, b: QueryParamsResponse | PlainMessage<QueryParamsResponse> | undefined): boolean;
132132
}
133133

134+
/**
135+
* @generated from message zetachain.zetacore.observer.QueryHasVotedRequest
136+
*/
137+
export declare class QueryHasVotedRequest extends Message<QueryHasVotedRequest> {
138+
/**
139+
* @generated from field: string ballot_identifier = 1;
140+
*/
141+
ballotIdentifier: string;
142+
143+
/**
144+
* @generated from field: string voter_address = 2;
145+
*/
146+
voterAddress: string;
147+
148+
constructor(data?: PartialMessage<QueryHasVotedRequest>);
149+
150+
static readonly runtime: typeof proto3;
151+
static readonly typeName = "zetachain.zetacore.observer.QueryHasVotedRequest";
152+
static readonly fields: FieldList;
153+
154+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryHasVotedRequest;
155+
156+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryHasVotedRequest;
157+
158+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryHasVotedRequest;
159+
160+
static equals(a: QueryHasVotedRequest | PlainMessage<QueryHasVotedRequest> | undefined, b: QueryHasVotedRequest | PlainMessage<QueryHasVotedRequest> | undefined): boolean;
161+
}
162+
163+
/**
164+
* @generated from message zetachain.zetacore.observer.QueryHasVotedResponse
165+
*/
166+
export declare class QueryHasVotedResponse extends Message<QueryHasVotedResponse> {
167+
/**
168+
* @generated from field: bool has_voted = 1;
169+
*/
170+
hasVoted: boolean;
171+
172+
constructor(data?: PartialMessage<QueryHasVotedResponse>);
173+
174+
static readonly runtime: typeof proto3;
175+
static readonly typeName = "zetachain.zetacore.observer.QueryHasVotedResponse";
176+
static readonly fields: FieldList;
177+
178+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryHasVotedResponse;
179+
180+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryHasVotedResponse;
181+
182+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryHasVotedResponse;
183+
184+
static equals(a: QueryHasVotedResponse | PlainMessage<QueryHasVotedResponse> | undefined, b: QueryHasVotedResponse | PlainMessage<QueryHasVotedResponse> | undefined): boolean;
185+
}
186+
134187
/**
135188
* @generated from message zetachain.zetacore.observer.QueryBallotByIdentifierRequest
136189
*/

x/observer/keeper/ballot.go

+18
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ func (k Keeper) GetMaturedBallotList(ctx sdk.Context) []string {
7777

7878
// Queries
7979

80+
func (k Keeper) HasVoted(goCtx context.Context, req *types.QueryHasVotedRequest) (*types.QueryHasVotedResponse, error) {
81+
if req == nil {
82+
return nil, status.Error(codes.InvalidArgument, "invalid request")
83+
}
84+
ctx := sdk.UnwrapSDKContext(goCtx)
85+
ballot, found := k.GetBallot(ctx, req.BallotIdentifier)
86+
if !found {
87+
return &types.QueryHasVotedResponse{
88+
HasVoted: false,
89+
}, nil
90+
}
91+
hasVoted := ballot.HasVoted(req.VoterAddress)
92+
93+
return &types.QueryHasVotedResponse{
94+
HasVoted: hasVoted,
95+
}, nil
96+
}
97+
8098
func (k Keeper) BallotByIdentifier(goCtx context.Context, req *types.QueryBallotByIdentifierRequest) (*types.QueryBallotByIdentifierResponse, error) {
8199
if req == nil {
82100
return nil, status.Error(codes.InvalidArgument, "invalid request")

0 commit comments

Comments
 (0)