Skip to content

ADR-104: Out-of-band state sync support - #801

Merged
cason merged 26 commits into
mainfrom
cason/adr-104
May 30, 2023
Merged

cason merged 26 commits into
mainfrom
cason/adr-104

Conversation

@cason

@cason cason commented May 5, 2023 •

Copy link
Copy Markdown

Closes #28.

This should be a replacement for #729.

Rendered ADR

@cason cason self-assigned this May 5, 2023

ghost left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe more about the actual design, especially the UX part, what does user need to do to do certain task. Since we have multiple solutions here for the same problem, the UX would the decisive factor I think.

@cason

ghost commented May 8, 2023

Copy link
Copy Markdown
Author

Can you describe more about the actual design, especially the UX part

This is a work in progress. The above content should go into "Detailed Design" section.

In general terms, the operation should be the one described on the "Decision" section.

@cason

ghost commented May 8, 2023

Copy link
Copy Markdown
Author

Since we have multiple solutions here for the same problem, the UX would the decisive factor I think.

I agree we can have multiple designs for the user interfaces, but I think that this ADR (with its current content) reasonably covers the possible solutions.

application snapshots to install or restore;
1. Operators should be able to instruct the server side of State sync on a
running node to export application snapshots, when they are available,
to a given location (e.g., at the local file system);

ghost May 8, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it like a standalone command that'll connect to the p2p network and download a snapshot?

ghost May 8, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No p2p, no network, no download. You instruct the node (e.g., via CLI command) to save a snapshot to disk.

ghost May 8, 2023 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, you can save it to a NFS mount point, so you have network and a form of upload.

ghost May 8, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean export a snapshot from the state in the local node, not discover and download a snapshot from the network?

ghost May 8, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discovering and fetching snapshots is what the existing State sync does.

The proposed extension assumes that the node operator will discover and fetch the snapshot in some way and just point to the bootstrapping node (see item 1.) where to find the snapshot data.

ghost May 10, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already how state sync works for the sdk. Def adding support for some of the items here makes sense, but we would only need a way to bootstrap the node, like huang yi did. I think the app should control exports and imports of snapshots for local state sync. There isnt really a need to complicate comet with this functionality imo

Makes sense to rely on the app-side for fulfilling this requirement! Is there already app-side support for it?

we are merging the prs to make it work. they are all open and approved

ghost May 11, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links, please?

ghost May 11, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

links to?

ghost May 11, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are merging the prs to make it work. they are all open and approved

ghost May 19, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are merging the prs to make it work. they are all open and approved

cosmos/cosmos-sdk#16067

cosmos/cosmos-sdk#16061

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Daniel for writing this down!

Comment on lines +131 to +132
State sync should support the bootstrap of new nodes from application snapshots
obtained out-of-band by node operators.

ghost May 9, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the snapshot might also be obtained locally (i.e., an old, local snapshot present on the node already).

Suggested change
State sync should support the bootstrap of new nodes from application snapshots
obtained out-of-band by node operators.
State sync should support the bootstrap of new nodes from application snapshots. This ADR does not cover the mechanism for obtaining snapshots, and we assume node operators obtain this for example through an out-of-band mechanism.

ghost May 9, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State sync should support the bootstrap of new nodes from application snapshots

I would add "local" to this sentence? Otherwise, it is what State sync already does...

ghost May 18, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is out of band the same as local though? Local to me would mean the node had a snapshot it itself stored before. Out of band can mean it was just copied or obtanined in another manner.

ghost May 23, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say snapshots are local, for the sake of this definition. In general, I would say, from point 2. below, that they are local because obtained out-of-band?

ghost May 23, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So local in this terminology is that the snapshots are applied from something eventually present on the node. Even though it originated from somewhere else. Sorry, this is just nit picking, nothing major :D

ghost May 23, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's important. Recall that we should still pick a name for the PR :)

application snapshots to install or restore;
1. Operators should be able to instruct the server side of State sync on a
running node to export application snapshots, when they are available,
to a given location (e.g., at the local file system);

ghost May 9, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to rely on the app-side for fulfilling this requirement! Is there already app-side support for it?

@cometbft cometbft deleted a comment from tac0turtle May 9, 2023
@cason cason added the wip Work in progress label May 9, 2023
@adizere adizere added this to the 2023-Q2 milestone May 11, 2023
1. Operators should be able to instruct the server side of state sync on a
running node to export application snapshots, when they are available,
to a given location (e.g., at the local file system);
1. It is up to node operators to transfer application snapshots produced by the

ghost May 18, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. It is up to node operators to transfer application snapshots produced by the
3. It is up to node operators to transfer application snapshots produced by the

ghost left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good additions.

I think the second part of the detailed design, from line 234, is a little speculative and dives into too much detail. My opinion is that this section should essentially tell the reader how the SDK commands can be implemented using ABCI calls (step by step), leaving out details on how and where we store stuff, for instance.


The ADR presents two solutions:

> 1. The first solution is implemented by the application and was proposed and

ghost May 24, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this > and render it a normal text block

The ADR presents two solutions:

> 1. The first solution is implemented by the application and was proposed and
implemented by the SDK (PR #16067 and #16061). This ADR describes the solution

ghost May 24, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add links to these PRs.


## Alternative Approaches

> This section contains information around alternative options that are considered

ghost May 24, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is from the ADR template, we can remove in the final version.

Thus application developers have to, within their bootstraping command:

- Create a state and block store
- Launch a light client to verify the snapshot headers

ghost May 24, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the headers. The light client is launched to learn the block header for the height of the snapshot.


- Create a state and block store
- Launch a light client to verify the snapshot headers
- Use the light client's `State` and `Commit` functions to

ghost May 24, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The light-client provided state is used to check the appHash retrieved from the application via Info ABCI call.

- Create a state and block store
- Launch a light client to verify the snapshot headers
- Use the light client's `State` and `Commit` functions to
retrieve the proper state, verify the `AppHash` and retrieve the `LastCommit`.

ghost May 24, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is commit, not last commit. The only point of it is to bootstrap the block store.

ghost May 25, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right the type is not LastCommit, but that is the last commit for the given height. Thanks for catching this.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new ADR content helped answer many of my questions. Thanks Jasmina and Daniel!

I think we should fix any inaccuracies in the ADR and merge this.

Comment thread docs/architecture/README.md Resolved
@adizere
adizere marked this pull request as ready for review May 24, 2023 15:25
@adizere
adizere requested a review from a team as a code owner May 24, 2023 15:25
Co-authored-by: Adi Seredinschi <[email protected]>
Co-authored-by: Daniel <[email protected]>
2. Introduce a CLI command that can explicitly tell the application to create a snapshot export, in case
operators decide not to generate periodical exports.
3. Extract a snapshot from the exported format.
4. Alter existing ABCI calls to signal to the application that we want to create a snapshot export periodically.

ghost May 25, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we require that the app is configured for snapshot (something that exists today), when we don't need ABCI changes, we can just call ListSnapshots and (a sequence of) LoadSnapshotChunk.

IOW, we wouldn't need to modify ABCI in an MVP

ghost May 25, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I realize this is explained later on in the text)

ghost left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@cason cason assigned jmalicevic and unassigned cason May 26, 2023

ghost left a comment •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice writing up, I think this document is covering almost every possible solution for the discussed problem, while providing an overview of the specifics that would have to be taken into consideration by any implementation.

P.S.: GitHub doesn't allow me to approve it because I've originally created the PR.


If CometBFT is not the one who created the exported file, we introduce a new ABCI call `UnpackSnapshot`
to send the exported snapshot as a blob of bytes to the application, which uncompresses it, installs it
and responds whether the snapshot is accepted and the chunk application has passed.

ghost May 26, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and responds whether the snapshot is accepted and the chunk application has passed.
and responds whether the snapshot is accepted (as in `OfferSnapshot`) and the chunks application has passed (as in `LoadChunk`).

}
```

Unlike networked statesync, we do not refetch individual chunks, thus if the chunk application of the exported snapshot fails, snapshot application fails.

ghost May 26, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Unlike networked statesync, we do not refetch individual chunks, thus if the chunk application of the exported snapshot fails, snapshot application fails.
Unlike networked state sync, we do not re-fetch individual chunks, thus if the application of a chunk fails, then the application of the whole snapshot fails.

@cason
cason merged commit 4e130bd into main May 30, 2023
@cason
cason deleted the cason/adr-104 branch May 30, 2023 10:31
@cason cason mentioned this pull request May 30, 2023
2 tasks done
@adizere adizere removed the wip Work in progress label May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

State sync from local snapshot: Understand problem, explore solutions

6 participants