Skip to content

Commit 8ffad8e

Browse files
authored
feat: backport the abci command (#2588)
should have just done this from the start, but I was getting too clever this adds the query sequence abci method to the v0.38 branch, but doesn't actually use it etc. we need this to bump the sdk and the application to use query sequence.
1 parent c0bdc0e commit 8ffad8e

File tree

8 files changed

+933
-297
lines changed

8 files changed

+933
-297
lines changed

abci/client/grpc_client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,7 @@ func (cli *grpcClient) VerifyVoteExtension(ctx context.Context, req *types.Reque
245245
func (cli *grpcClient) FinalizeBlock(ctx context.Context, req *types.RequestFinalizeBlock) (*types.ResponseFinalizeBlock, error) {
246246
return cli.client.FinalizeBlock(ctx, types.ToRequestFinalizeBlock(req).GetFinalizeBlock(), grpc.WaitForReady(true))
247247
}
248+
249+
func (cli *grpcClient) QuerySequence(ctx context.Context, req *types.RequestQuerySequence) (*types.ResponseQuerySequence, error) {
250+
return cli.client.QuerySequence(ctx, types.ToRequestQuerySequence(req).GetQuerySequence(), grpc.WaitForReady(true))
251+
}

abci/client/mocks/client.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

abci/client/socket_client.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,17 @@ func (cli *socketClient) FinalizeBlock(ctx context.Context, req *types.RequestFi
412412
return reqRes.Response.GetFinalizeBlock(), cli.Error()
413413
}
414414

415+
func (cli *socketClient) QuerySequence(ctx context.Context, req *types.RequestQuerySequence) (*types.ResponseQuerySequence, error) {
416+
reqRes, err := cli.queueRequest(ctx, types.ToRequestQuerySequence(req))
417+
if err != nil {
418+
return nil, err
419+
}
420+
if err := cli.Flush(ctx); err != nil {
421+
return nil, err
422+
}
423+
return reqRes.Response.GetQuerySequence(), cli.Error()
424+
}
425+
415426
func (cli *socketClient) queueRequest(ctx context.Context, req *types.Request) (*ReqRes, error) {
416427
reqres := NewReqRes(req)
417428

abci/types/application.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ type Application interface {
1212
Query(context.Context, *RequestQuery) (*ResponseQuery, error) // Query for state
1313

1414
// Mempool Connection
15-
CheckTx(context.Context, *RequestCheckTx) (*ResponseCheckTx, error) // Validate a tx for the mempool
15+
CheckTx(context.Context, *RequestCheckTx) (*ResponseCheckTx, error) // Validate a tx for the mempool
16+
QuerySequence(context.Context, *RequestQuerySequence) (*ResponseQuerySequence, error) // Query sequence for a signer
1617

1718
// Consensus Connection
1819
InitChain(context.Context, *RequestInitChain) (*ResponseInitChain, error) // Initialize blockchain w validators/other info from CometBFT
@@ -117,3 +118,7 @@ func (BaseApplication) FinalizeBlock(_ context.Context, req *RequestFinalizeBloc
117118
TxResults: txs,
118119
}, nil
119120
}
121+
122+
func (BaseApplication) QuerySequence(context.Context, *RequestQuerySequence) (*ResponseQuerySequence, error) {
123+
return &ResponseQuerySequence{}, nil
124+
}

abci/types/messages.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ func ToRequestFinalizeBlock(req *RequestFinalizeBlock) *Request {
124124
}
125125
}
126126

127+
func ToRequestQuerySequence(req *RequestQuerySequence) *Request {
128+
return &Request{
129+
Value: &Request_QuerySequence{req},
130+
}
131+
}
132+
127133
//----------------------------------------
128134

129135
func ToResponseException(errStr string) *Response {
@@ -227,3 +233,9 @@ func ToResponseFinalizeBlock(res *ResponseFinalizeBlock) *Response {
227233
Value: &Response_FinalizeBlock{res},
228234
}
229235
}
236+
237+
func ToResponseQuerySequence(res *ResponseQuerySequence) *Response {
238+
return &Response{
239+
Value: &Response_QuerySequence{res},
240+
}
241+
}

abci/types/mocks/application.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)