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

Support for multiple layer 1 #183

Merged
merged 7 commits into from
Oct 30, 2023
Merged

Support for multiple layer 1 #183

merged 7 commits into from
Oct 30, 2023

Conversation

dr-orlovsky
Copy link
Member

@dr-orlovsky dr-orlovsky commented Oct 24, 2023

This is an example of the scale of changes we need to support Liquid as layer 1. Support for another prospective layer 1 (like Prime) comes at nearly no additional cost.

PR adds support for Liquid as a commitment layer + ability to add more client-side-validation chains in the future

TODO:

  • Use chain-specific resolvers in validation
  • Validate that seal definitions match list of supported layer 1 from Genesis

@dr-orlovsky dr-orlovsky added enhancement New feature or request refactoring Code refactoring *scalability* Issues affecting system scalability labels Oct 24, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Merging #183 (c0be2d9) into master (de8f0e6) will decrease coverage by 0.2%.
The diff coverage is 5.3%.

@@           Coverage Diff            @@
##           master    #183     +/-   ##
========================================
- Coverage    12.8%   12.5%   -0.2%     
========================================
  Files          30      31      +1     
  Lines        3087    3188    +101     
========================================
+ Hits          394     400      +6     
- Misses       2693    2788     +95     
Flag Coverage Δ
rust 12.5% <5.3%> (-0.2%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/contract/operations.rs 24.6% <ø> (ø)
src/lib.rs 15.4% <ø> (ø)
src/stl.rs 100.0% <100.0%> (ø)
src/validation/status.rs 0.0% <ø> (ø)
src/contract/contract.rs 0.3% <0.0%> (-<0.1%) ⬇️
src/contract/assignments.rs 1.0% <0.0%> (-<0.1%) ⬇️
src/contract/mod.rs 12.5% <12.5%> (ø)
src/contract/seal.rs 3.0% <4.2%> (+3.0%) ⬆️
src/validation/anchor.rs 8.0% <8.0%> (ø)
src/validation/validator.rs 0.0% <0.0%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dr-orlovsky dr-orlovsky marked this pull request as ready for review October 30, 2023 08:10
@dr-orlovsky dr-orlovsky added this to the v0.11.0 milestone Oct 30, 2023
@dr-orlovsky dr-orlovsky changed the title Experiment showcasing support for multiple layer 1 Support for multiple layer 1 Oct 30, 2023
Copy link
Contributor

@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.

LGTM

@dr-orlovsky dr-orlovsky merged commit 13b8ec1 into master Oct 30, 2023
19 of 20 checks passed
Comment on lines +55 to +64
pub enum Output {
#[strict_type(tag = 0x00)]
Bitcoin(Outpoint),
#[strict_type(tag = 0x01)]
Liquid(Outpoint),
#[strict_type(tag = 0x10)]
Abraxas,
#[strict_type(tag = 0x11, dumb)]
Prime,
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

One question, how does this handle testnets?

Copy link
Member Author

Choose a reason for hiding this comment

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

Testnets are defined by chain field in genesis. The difference is that with Layer1Set a contract can operate multiple chain types, while testnet is orthogonal to that. I think it worth renaming chain to testnet and make it bool.

Copy link
Member

Choose a reason for hiding this comment

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

That might make sense.

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 we consider Testnet just like any other layer 1? Also making testnet a bool makes it hard to distinguish between multiple testnets (eg signet, regtest etc).

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is the following: the asset/contract is always either mainnet - or testnet. I.e. we must prevent mistakes like somebody creates a contract working on both testnet and mainnet since the asset can move from one chain to another - and back - and the security of one of the chain is clearly poorer than the other. Thus, "testnets" are not just another layer 1 for us, but there are two distinct sets of layer 1: testnet or mainnet. If an asset works with let's say both bitcoin and liquid, it is either on bitcoin and liquid mainnnet - or on bitcoin and liquid testnet (but never on bitcoin mainnet and testnet, or liquid testnet and bitcoin mainnet).

Regarding different testnets - I do not see how to support them without breaking the invariant requirement above. Signet/regtest exists only on Bitcoin and not on Liquid. Thus, like addresses do not always distinguish testnets (signet and testnet3 has the same address) I think the distinction is not that important and users while testing should just agree on specific testnet used out-of-band.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is reasonable to expect contract issuers and wallets to understand the different security that mainnet and testnet offer, just like we expect them to understand the massive trade-off between Bitcoin and Liquid. Supporting multiple Bitcoin testnets to me seems a more useful feature, especially for people that want to test cross chain assets. Moreover Bitmask already supports both testnet and signet, so to make it easy to distinguish between testnets is something that would benefit users already today.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the support for multiple testnets are there anyway. It is just provided by the resolver and invoces - and not consensus. What consensus differenciate is distinct transaction formats (like between Liquid and Bitcoin).

Copy link
Member Author

Choose a reason for hiding this comment

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

I propose to move the discussion into #189 which is still umerged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring Code refactoring *scalability* Issues affecting system scalability
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

4 participants