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

Use 32-bit sizing for MPC trees #132

Merged
merged 10 commits into from
Jul 12, 2023
Merged

Use 32-bit sizing for MPC trees #132

merged 10 commits into from
Jul 12, 2023

Conversation

dr-orlovsky
Copy link
Member

@dr-orlovsky dr-orlovsky commented Jul 10, 2023

This PR changes the maximum MPC (LNPBP4) tree size to be 2^32 (depth = 32) from depth=16 before. This implies:

  • maximum Merkle proof (used in consignments) length changes from 16 hashes to 32 hashes (512 bytes to 1kB)
  • maximum storage requirement for stash data per witness tx increases from 100kb to ~20MB
  • maximum memory requirement for hardware wallets increases from 100kb to ~20MB
  • maximum memory requirement for producing new witness transactions (like in exchanges) increases to ~10 GB

Fixes #128 based on top of #131

Some test results:

Tree with 2'048 protocol-messages: depth 19, cofactor 2. Serialized length 270'353 bytes
Tree with 4'096 protocol-messages: depth 21, cofactor 29. Serialized length 540'689 bytes
Tree with 8'192 protocol-messages: depth 23, cofactor 97. Serialized length 1'081'361 bytes
Tree with 16'384 protocol-messages: depth 25, cofactor 46. Serialized length 2'162'705 bytes
Tree with 32'768 protocol-messages: depth 26, cofactor 265. Serialized length 4'325'393 bytes (14 sec)
Tree with 65'536 protocol-messages: depth 29, cofactor 30. Serialized length 8'650'769 bytes (33 sec)
Tree with 131'072 protocol-messages: depth 30, cofactor 298. Serialized length 17'301'521 bytes (~1min

We see that the time growth is linear and that a normal desktop machine (like mine) can easily handle up to hundred of thousand of different assets put into a single UTXO - making the case for exchange-scale tasks. Taking into account that in Ethereum there are "just" ~2 million contracts, all their state can be assigned to just 8 UTXOs (with RGB/LNPBP4) - that should be good scalability I think and we do not need more.

@dr-orlovsky dr-orlovsky added *scalability* Issues affecting system scalability *consensus* Issues affecting distributed concensus refactoring Refactoring of the existing code labels Jul 10, 2023
@dr-orlovsky dr-orlovsky added this to the v0.10.x milestone Jul 10, 2023
@dr-orlovsky dr-orlovsky marked this pull request as ready for review July 10, 2023 15:59
cryptoquick
cryptoquick previously approved these changes Jul 10, 2023
Copy link
Member

@cryptoquick cryptoquick left a comment

Choose a reason for hiding this comment

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

Agreed, 100k contracts should be plenty enough!

@cryptoquick
Copy link
Member

According to the Bitcoin OpTech tx size calculator, a P2TR tx with 100 inputs and 100 outputs would be a little over 10k sats. That means ~39,700 outputs could be spent and created in a single block. Multiply that by 131,072, and we get an upper bound of 5,203,558,400 different contract state transitions per block (though I might be comparing apples and oranges). Theoretical max TPS is ~8,672,597 (600s), though this figure is largely nonsense. It just gives an idea of potential to scale using, say, a federated wallet.

@dr-orlovsky
Copy link
Member Author

and we get an upper bound of 5,203,558,400 different contract state transitions per block

not state transitions, contracts! Each contract may have multiple state transitions (up to the number of inputs).

@dr-orlovsky
Copy link
Member Author

Overall, we can fit the evolution of the Ethereum state into a single bitcoin transaction - so that should be enough for the scalability.

By "massaging" the depth of the non-common denominator search (sacrificing performance) I think we can get up to a million contracts into the same UTXO, so that should be enough!

cryptoquick
cryptoquick previously approved these changes Jul 10, 2023
Copy link
Member

@cryptoquick cryptoquick left a comment

Choose a reason for hiding this comment

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

ACK

zoedberg
zoedberg previously approved these changes Jul 12, 2023
Copy link
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

ACK

@dr-orlovsky dr-orlovsky dismissed stale reviews from zoedberg and cryptoquick via 9902847 July 12, 2023 16:04
@dr-orlovsky dr-orlovsky merged commit 1aab9b8 into master Jul 12, 2023
22 checks passed
@dr-orlovsky dr-orlovsky deleted the mpc-u32 branch October 8, 2023 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*consensus* Issues affecting distributed concensus refactoring Refactoring of the existing code *scalability* Issues affecting system scalability
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Increase multi-protocol commitment tree size limit
3 participants