Skip to content

Commit

Permalink
chore: FinalizeSnapshot implemented, not tested
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 15, 2025
1 parent 8f33ac1 commit 6027abe
Show file tree
Hide file tree
Showing 13 changed files with 529 additions and 242 deletions.
4 changes: 4 additions & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ func (cli *grpcClient) ApplySnapshotChunk(ctx context.Context, params *types.Req
return cli.client.ApplySnapshotChunk(ctx, types.ToRequestApplySnapshotChunk(params).GetApplySnapshotChunk(), grpc.WaitForReady(true))
}

func (cli *grpcClient) FinalizeSnapshot(ctx context.Context, params *types.RequestFinalizeSnapshot) (*types.ResponseFinalizeSnapshot, error) {
return cli.client.FinalizeSnapshot(ctx, types.ToRequestFinalizeSnapshot(params).GetFinalizeSnapshot(), grpc.WaitForReady(true))
}

func (cli *grpcClient) PrepareProposal(ctx context.Context, params *types.RequestPrepareProposal) (*types.ResponsePrepareProposal, error) {
return cli.client.PrepareProposal(ctx, types.ToRequestPrepareProposal(params).GetPrepareProposal(), grpc.WaitForReady(true))
}
Expand Down
59 changes: 59 additions & 0 deletions abci/client/mocks/client.go

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

5 changes: 5 additions & 0 deletions abci/client/routed_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ func (cli *routedClient) ApplySnapshotChunk(ctx context.Context, req *types.Requ
return result.(*types.ResponseApplySnapshotChunk), err
}

func (cli *routedClient) FinalizeSnapshot(ctx context.Context, req *types.RequestFinalizeSnapshot) (*types.ResponseFinalizeSnapshot, error) {
result, err := cli.delegate(ctx, req)
return result.(*types.ResponseFinalizeSnapshot), err
}

func (cli *routedClient) PrepareProposal(ctx context.Context, req *types.RequestPrepareProposal) (*types.ResponsePrepareProposal, error) {
result, err := cli.delegate(ctx, req)
return result.(*types.ResponsePrepareProposal), err
Expand Down
8 changes: 8 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ func (cli *socketClient) ApplySnapshotChunk(ctx context.Context, req *types.Requ
return res.GetApplySnapshotChunk(), nil
}

func (cli *socketClient) FinalizeSnapshot(ctx context.Context, req *types.RequestFinalizeSnapshot) (*types.ResponseFinalizeSnapshot, error) {
res, err := cli.doRequest(ctx, types.ToRequestFinalizeSnapshot(req))
if err != nil {
return nil, err
}
return res.GetFinalizeSnapshot(), nil
}

func (cli *socketClient) PrepareProposal(ctx context.Context, req *types.RequestPrepareProposal) (*types.ResponsePrepareProposal, error) {
res, err := cli.doRequest(ctx, types.ToRequestPrepareProposal(req))
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type StateSyncer interface {
LoadSnapshotChunk(context.Context, *RequestLoadSnapshotChunk) (*ResponseLoadSnapshotChunk, error)
// ApplySnapshotChunk applies a chunk of snapshot
ApplySnapshotChunk(context.Context, *RequestApplySnapshotChunk) (*ResponseApplySnapshotChunk, error)
// FinalizeSnapshot sends light block to ABCI app after successful state sync
FinalizeSnapshot(context.Context, *RequestFinalizeSnapshot) (*ResponseFinalizeSnapshot, error)
}

// Application is an interface that enables any finite, deterministic state machine
Expand Down Expand Up @@ -97,6 +99,10 @@ func (BaseApplication) ApplySnapshotChunk(_ context.Context, _req *RequestApplyS
return &ResponseApplySnapshotChunk{}, nil
}

func (BaseApplication) FinalizeSnapshot(_ context.Context, _req *RequestFinalizeSnapshot) (*ResponseFinalizeSnapshot, error) {
return &ResponseFinalizeSnapshot{}, nil
}

func (BaseApplication) PrepareProposal(_ context.Context, req *RequestPrepareProposal) (*ResponsePrepareProposal, error) {
trs := make([]*TxRecord, 0, len(req.Txs))
var totalBytes int64
Expand Down
6 changes: 6 additions & 0 deletions abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ func ToRequestApplySnapshotChunk(req *RequestApplySnapshotChunk) *Request {
}
}

func ToRequestFinalizeSnapshot(req *RequestFinalizeSnapshot) *Request {
return &Request{
Value: &Request_FinalizeSnapshot{req},
}
}

func ToRequestExtendVote(req *RequestExtendVote) *Request {
return &Request{
Value: &Request_ExtendVote{req},
Expand Down
59 changes: 59 additions & 0 deletions abci/types/mocks/application.go

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

Loading

0 comments on commit 6027abe

Please sign in to comment.