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

P2P networking support for bootstrapping with UTXO set snapshot #1444

Merged
merged 208 commits into from
May 14, 2023

Conversation

kushti
Copy link
Member

@kushti kushti commented Sep 10, 2021

This PR implements P2P networking protocol for bootstrapping with UTXO set snapshot. The final big chunk of the code related to the new functionality.

@kushti kushti changed the title [WIP] Bootstrapping with UTXO set Bootstrapping with UTXO set - Part 1: Snapshot creation Nov 29, 2021
@kushti kushti changed the base branch from v5.0.12 to utxo-set-bootstrapping-preparation May 5, 2023 10:49
@kushti kushti changed the title Bootstrapping with UTXO set - Part 1: Snapshot creation P2P networking support for bootstrapping with UTXO set snapshot May 5, 2023
@@ -13,8 +12,8 @@ class ManifestSerializer(manifestDepth: Byte) extends ErgoSerializer[BatchAVLPro
private val nodeSerializer = VersionedLDBAVLStorage.noStoreSerializer

override def serialize(manifest: BatchAVLProverManifest[DigestType], w: Writer): Unit = {
val height = manifest.rootHeight
w.putBytes(Ints.toByteArray(height))
val rootNodeHeight = manifest.rootHeight.toByte
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be toByteExact?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, by construction AVL+ tree has height <= 127 , then manifest has the same limitation also. Need to fix manifest in scrypto about that

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but it makes more assumption about input data. If however there is a mistake in the data, the silent overflow will lead to hard to localize bugs. Why not to do checks here? It will not impact performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

There MUST BE NOT mistakes here, if prover is having root height > 127 it can not work with the tree simply, forming bad manifest is very secondary issue then. Even more, height is much less than 127 always, there is a descriptive comment in scrypto about that.

Copy link
Member

Choose a reason for hiding this comment

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

ok, I just curious why you think not checking overflow is better than checking?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it could be more confusing actually for a reader to find a check for a thing which MUST NOT happen by construction. Conversion to int in some manifest / db classes is already confusing.

avldb/src/main/scala/scorex/db/LDBKVStore.scala Outdated Show resolved Hide resolved
Base automatically changed from utxo-set-bootstrapping-preparation to v5.0.12 May 12, 2023 18:07
@kushti
Copy link
Member Author

kushti commented May 12, 2023

@aslesarenko added manifest verification also in f4b2654

@kushti kushti merged commit 4f5c992 into v5.0.12 May 14, 2023
@kushti kushti deleted the utxo-set-bootstrapping branch May 14, 2023 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants