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

feat!: state sync #1026

Open
wants to merge 32 commits into
base: v1.5-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ad9f597
feat(light): verify trusted light block hash
lklimek Jan 13, 2025
566545f
fix(light): light block fails with invalid sig format
lklimek Jan 13, 2025
6c3fa22
chore: fix mock core server for new quorum verify
lklimek Jan 14, 2025
2780a4a
fix(statesync): allow empty chunks
lklimek Jan 14, 2025
77cde71
feat(proto):RequestFinalizeSnapshotSync
lklimek Jan 15, 2025
c1edaf6
build: bump abci version minor
lklimek Jan 15, 2025
f89ed87
chore: rename finalize snapshot request
lklimek Jan 15, 2025
8f33ac1
chore(proto): Updated RequestFinalizeSnapshot
lklimek Jan 15, 2025
6027abe
chore: FinalizeSnapshot implemented, not tested
lklimek Jan 15, 2025
0125867
chore: fix build
lklimek Jan 16, 2025
1afb8be
test(e2e): test finalize snapshot in e2e tests
lklimek Jan 17, 2025
4e999db
refactor: remove trust-height and
lklimek Jan 17, 2025
63fb155
chore(config)!: remove unused trust-height,trust-hash,trust-period
lklimek Jan 17, 2025
c1827ee
test(light): remove temporarily added code
lklimek Jan 20, 2025
e84e0be
test(statesync): fix state sync tests
lklimek Jan 20, 2025
af79697
chore: apply code rabbit comments
lklimek Jan 20, 2025
a9cf16f
chore: self review
lklimek Jan 20, 2025
bc399c8
deps: update dashd-go
lklimek Jan 20, 2025
34936f9
deps: update dashd-go
lklimek Jan 20, 2025
8726abb
chore: add genesis block to finalizesnapshot
lklimek Jan 20, 2025
9d3dae4
chore: fix lint warning
lklimek Jan 20, 2025
4a75455
chore: update kvstore for changed requestfinalizesnapshot
lklimek Jan 20, 2025
ef394e8
test: fix failing test
lklimek Jan 20, 2025
94c5f69
chore: remove tmp code
lklimek Jan 20, 2025
dabacf2
Merge remote-tracking branch 'origin/v1.5-dev' into feat/statesync-in…
lklimek Jan 20, 2025
a326226
chore: improve safemath lib
lklimek Jan 20, 2025
81367da
chore: fix linter
lklimek Jan 20, 2025
fcfa071
chore: code rabbit fixes
lklimek Jan 20, 2025
3c562e6
Merge remote-tracking branch 'origin/v1.5-dev' into feat/statesync-in…
lklimek Jan 20, 2025
2720086
Merge remote-tracking branch 'origin/v1.5-dev' into feat/statesync-in…
lklimek Jan 20, 2025
dd02a51
Merge branch 'v1.5-dev' into feat/statesync-integration
lklimek Jan 20, 2025
37f8b5f
build(deps): update dashd-go to 0.26.1
lklimek Jan 21, 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
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
19 changes: 19 additions & 0 deletions abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,25 @@ func (app *Application) ApplySnapshotChunk(_ context.Context, req *abci.RequestA
app.logger.Debug("ApplySnapshotChunk", "resp", resp)
return resp, nil
}

func (app *Application) FinalizeSnapshot(_ctx context.Context, req *abci.RequestFinalizeSnapshot) (*abci.ResponseFinalizeSnapshot, error) {
app.mu.Lock()
defer app.mu.Unlock()

// we verify snapshot height and app hash, as there is no additional logic to be called here
if app.LastCommittedState.GetHeight() != req.LightBlock.SignedHeader.Header.Height {
return &abci.ResponseFinalizeSnapshot{}, fmt.Errorf("snapshot height mismatch: expected %d, got %d",
app.LastCommittedState.GetHeight(), req.LightBlock.SignedHeader.Header.Height)
}

if !app.LastCommittedState.GetAppHash().Equal(req.LightBlock.SignedHeader.Header.AppHash) {
return &abci.ResponseFinalizeSnapshot{}, fmt.Errorf("snapshot apphash mismatch: expected %x, got %x",
app.LastCommittedState.GetAppHash(), req.LightBlock.SignedHeader.Header.AppHash)
}

app.logger.Debug("FinalizeSnapshot finished successfully", "req", req)
return &abci.ResponseFinalizeSnapshot{}, nil
}
func (app *Application) appVersionForHeight(height int64) uint64 {
if app.appVersion == 0 {
return uint64(height)
Expand Down
7 changes: 7 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,11 @@ func (BaseApplication) ApplySnapshotChunk(_ context.Context, _req *RequestApplyS
return &ResponseApplySnapshotChunk{}, nil
}

// FinalizeSnapshot provides a no-op implementation for the StateSyncer interface
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
Loading