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

Suggestion to utilize RocksDB checkpoint in archival node to quickly obtain snapshot at any historical block height #3645

Open
Hecate2 opened this issue Dec 25, 2024 · 9 comments
Labels
Discussion Initial issue state - proposed but not yet accepted

Comments

@Hecate2
Copy link
Contributor

Hecate2 commented Dec 25, 2024

Summary or problem description
#3639 took the first step for archival nodes. Maybe we can make some enhancements in RocksDBStore plugin and ISnapshot GetSnapshot(); interfaces to retrieve a historical snapshot quickly, at very little additional costs.

Do you have any solution you want to propose?
RocksDB checkpoint offers a historical state of the database immediately, at a small cost of storage. The RocksDBStore plugin should decide (based on config) whether it is needed to generate a new checkpoint, when Blockchain.Committed is invoked.
The ISnapshot GetSnapshot(); in interface IStore can have an additional parameter with default value, to request for a historical block. I think a uint height=uint.MaxValue can be good enough to get the latest snapshot as default. If historical snapshot is not supported by a storage provider, and the height is not uint.MaxValue, the storage can simply throw exceptions.
These capabilities should enable us to quickly retrieve and debug historical blocks, and historical transactions.

Where in the software does this update applies to?

  • Plugins
  • Ledger
  • SDK
@Hecate2 Hecate2 added the Discussion Initial issue state - proposed but not yet accepted label Dec 25, 2024
@nan01ab
Copy link
Contributor

nan01ab commented Dec 25, 2024

How long will a checkpoint be maintained?
If checkpoints are saved permanently, there will be a large storage overhead

@Jim8y
Copy link
Contributor

Jim8y commented Dec 25, 2024

How long will a checkpoint be maintained?
If checkpoints are saved permanently, there will be a large storage overhead

for debugging purpose, will be there permanently, but its optional.

@Hecate2
Copy link
Contributor Author

Hecate2 commented Dec 25, 2024

How long will a checkpoint be maintained? If checkpoints are saved permanently, there will be a large storage overhead

I do not have a determinate idea now. Personally I am thinking of leaving only -log(1-current_height/total_height) checkpoints for very ancient history. This may require complex controls in deleting and merging checkpoints. Besides, ancient checkpoints with very long computation time to a certain later block may be meaningless for users waiting online.
A checkpoint for every 1k or 10k blocks can be nice for now, but I think it does make a burden for the future. It really depends on the user's wishes. Better to leave it in configs.

@roman-khimov
Copy link
Contributor

That'd be DB-specific, but maybe somewhat more efficient in terms of speed. We do historic things via MPT (https://github.com/nspcc-dev/neo-go/blob/master/docs/rpc.md#historic-calls).

@Jim8y
Copy link
Contributor

Jim8y commented Dec 25, 2024

That'd be DB-specific, but maybe somewhat more efficient in terms of speed. We do historic things via MPT (https://github.com/nspcc-dev/neo-go/blob/master/docs/rpc.md#historic-calls).

MPT is way larger, but verifiable...

@roman-khimov
Copy link
Contributor

roman-khimov commented Dec 25, 2024

We don't know what's gonna happen to RocksDB if one is try snapshotting checkpointing every block. Can it handle 6M snapshotscheckpoints? What's gonna be the size? Mystery to me.

@nan01ab
Copy link
Contributor

nan01ab commented Dec 26, 2024

It’s a great idea for debug

@Hecate2
Copy link
Contributor Author

Hecate2 commented Dec 27, 2024

virtual void CompactRange(const Slice* begin, const Slice* end)

db->CompactRange(NULL, NULL); may be needed for nodes to compress the data size when not busy. This applies to not only RocksDB but also LevelDB

@shargon
Copy link
Member

shargon commented Dec 27, 2024

virtual void CompactRange(const Slice* begin, const Slice* end)

db->CompactRange(NULL, NULL); may be needed for nodes to compress the data size when not busy. This applies to not only RocksDB but also LevelDB

If nothing was removed, this wont work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Initial issue state - proposed but not yet accepted
Projects
None yet
Development

No branches or pull requests

5 participants