pull down to refresh

DeepDive into Liquid: Part I - Overview, Installation, and Peg-In

This is a multipart DeepDive that will focus on the Liquid Sidechain. It will be released in 3 Parts:

  • Part I (this): Overview, Installation, and first Peg-In
  • Part II: Asset Creation and Configuration
  • Part III: Advanced Topics and Peg-out

Overview

Liquid is a federated BTC sidechain (Layer-2). The federation which controls the network are known as 'Functionaries'. Currently, there are 15 such Functionaries[1] who are geographically dispered to help isolate the network from both physical and regulatory disruption.

Functionaries do the block signing for the network, which happens in a round-robin style arrangement - and consensus requires 11-of-15 to be available and in agreement.

A unique aspect of this federation is that functioinary membership is dynamic - using a protocol known as DynaFed - this allows members to be rotated out/in depending on circumstance. In order to support a large number of signers, the functionaries use a signature scheme known as ROAST (Robust Asynchronous Schnorr Threshold Signatures). As stated:

"It guarantees that a quorum of honest signers, e.g., the Liquid functionaries, 
can always obtain a valid signature even in the presence of disruptive signers 
when network connections have arbitrarily high latency. Our empirical performance 
evaluation shows that ROAST scales well to large signer groups, e.g., a 67-of-100 
setup with the coordinator and signers on different continents. Even with 33 malicious 
signers that try to block signing attempts (e.g. by sending invalid responses or by not 
responding at all), the 67 honest signers can successfully produce a signature within 
a few seconds."

Obviously this along with the inclusion of DynaFed (a recent addition to the network), seems to indicate that they plan to increase the total federation functionaries from 15 to more in the future.

Functionaries Sign, not Mine

A key aspect of Liquid is there is no mining. The core asset, L-BTC, is only created when BTC pegs-into the network, so unlike Bitcoin, mining is not used to create issuance of new coins. The total amount L-BTC can be verified along with the equivalent amount of BTC, which are held in a public multisig address. This ensures that there is no inflation possible of L-BTC, since it will balance 1:1 with the pegged BTC.

By default, all Liquid transactions use Confidential Transactions, so both the type of assets and amounts transacted are hidden, even to functionaries. However, Functionaries can still see the from / to addresses involved - they only don't know what is being transferred.

Liquid Ecosystem and Roles

Here are some charts showing current ecosystem members and the roles various members can fulfill. In total there are currently 66 Liquid Members (not all Members are Functionaries).

https://m.stacker.news/13613
https://m.stacker.news/13614

Assets

Liquid supports Asset Issuance. Any full-node can issue their own Assets (only requirement is to have needed L-BTC to pay for signing fees). These assets fall into the following categories / use-cases:

* Tokens (e.g. arbitrary token issue, stablecoin, etc)
* Swaps (e.g. atomic swap of Token A for Token B)
* Options / Smart Contracts / Covenants (e.g. swap Token A for B if condition ABC is met)
* Securities (e.g. issue dividends to Token A holders after X time)
* Restricted Assets (e.g. prohibit holder of Token A from transfer without approval)

Additional Opcodes

At its core, Liquid is basically "BTC plus special OPCODES less Mining". In order to support the Smart Contracts and Convenants seen above, Liquid reintroduces some safe but disabled opcodes, including string concatenation (CAT), substrings, integer shifts, and several bitwise operations (see here for more).

Additionally a new DETERMINISTICRANDOM operation which produces a random number within a range from a seed. Also included is CHECKSIGFROMSTACK (CSFS) operation, which verifies a signature against a message on the stack, rather than the spending transaction itself.

These new opcodes have several use cases, including convenant-style controls, double-spent protection bonds, lotteries, merkle tree constructions to allow 1-of-N multisig with huge N (thousands), and probabilistic payments.

Installation of Elements Node

Liquid uses a variation of BTC Core program known as Elements, much of the setup and use are very similar to bitcoin. Please note that Elements requires a fully functioning bitcoind daemon is available (it is a sidechain, after all). Thus for this demonstration, I am using my Umbrel since it makes installing Bitcoin and Elements quite simple.

If you are intending to run Liquid on a bare-metal setup, please refer to this getting started guide to setup your environment. Setting up a core-bitcoin install is outside the scope of this DeepDive

Running Elements on Umbrel

  • Meet requirements (1TB disk for BTC / 25GB disk for Liquid / >8GB RAM[2])
  • A running and fully-synced Bitcoin 'App'
  • Install Elements 'App'

... Go take a several hour break while it downloads ...

  • Navigate to Elements 'App' web interface on Umbrel and copy rpcuser and rpcpassword values

https://m.stacker.news/13615

  • Save the above values as bash variables for use later
    • $ export E_RPCUSER=elements
    • $ export E_RPCPASS=XXXXXXXXXXXXXXXXXXXXXXX
  • You should now be able to issue commands against the elements daemon
    • $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getblockcount

      25846 (It doesn’t matter what the number returned is as long as no error.)
  • Create a default wallet
    • $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS createwallet ""
  • Check balance info (should show 0 balance with no errors)
    • $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getwalletinfo

First Peg-In

Now let's peg-in some bitcoin in order to receive L-BTC within our Liquid wallet. (NOTE: There are online services that automate this entire process and make it much simpler. In general services like Sideswap makke this process much easier)

  • Generate a new peg-in address
    • $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getpeginaddress

      {
      "mainchain_address": "bc1qXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "claim_script": "001489b0XXXXXXXXXXXXXXXXXXXXXXXXX"
      }
  • Save the claim_script above in a variable for use later
    • $ export E_CLAIMSCR="001489b0XXXXXXXXXXXXXXXXXXXXXXXXX"
  • Send some btc to the mainchain_address listed above (I'm sending 150000 sats)
  • Copy the BTC transaction ID and save to variable
    • $ export B_TRANSID="bb1d0903XXXXXXXXXXXXXXXXXXXXXXXXXXX"
  • Wait for the confirmation[4]
  • On your BITCOIN node, run the following command
    • $ sudo ./scripts/app compose bitcoin exec bitcoind bitcoin-cli getrawtransaction $B_TRANSID

      020000000173f50....
  • Save that output to bash variable
    • $ export B_RAWTRANS='020000000173f50....
  • On your BITCOIN node, get output proof
    • $ sudo ./scripts/app compose bitcoin exec bitcoind bitcoin-cli gettxoutproof '["<transaction_id_paste>"]'

      00406426ea774aff7437de482c73f2ac8......
  • Save output proof in bash variable
    • $ export B_OUTPROOF='00406426ea774aff7437de482c73f2ac8....'
  • Now back on the elements node, we can claim the L-BTC
    • $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS claimpegin $B_RAWTRANS $B_OUTPROOF $E_CLAIMSCR
  • Issue a getwallet info on Elements and you should see an unconfirmed balance
    • $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getwalletinfo

      "unconfirmed_balance": {
      "bitcoin": 0.00149952
      }[5],
  • After 1 confirmations (approx 2 mins) the balance should be confirmed
    • $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getwalletinfo

      "balance": {
      "bitcoin": 0.00149952}[6]

Wrap Up and Preview for Part II.

This was just the basics, in this DeepDive we got our Elements node running and pegged-in our initial BTC balance.

In Part II is where the fun begins, we will transfer (and see Confidential Transactions in practice), issue Assets, and get the assets in the registry.

  1. As of 1-21-2024. There are 66 members who can perform other functions on network, but only Functionaries can sign

  2. RAM usage is higher for Liquid than for BTC alone due to Confidential Transactions processing

  3. Requires 102 confirmations. Services like sideswap will release after 2 confs for small amounts

  4. Balance less the 48sat transaction fee

  5. yes, the label is still called 'bitcoin' but can be changed if that annoys you :)

Got to encourage the snail. I am not superstitious but worry without it BTC won’t get to 100k lol

reply
reply

Where the hell is the snail?

reply

I was just tonight thinking about the psychological instinct -- or bundle of instincts and processes, a suppose -- that gets us to like people who are quite like us. In sociology this is called homophily and I suspect, based on what I know of you, that you may enjoy learning about it.

But the context I was thinking about tonight was kind of orthogonal to that -- the way that some people fill holes of ours, make us more complete by being unlike us. It is so ... powerful to find someone like that. Feels almost religious. That might be another thing you might enjoy reading about.

Anyway, great post as ever. I'll miss them when they're gone.

reply

Stay humble, stack sats. I believe we need to stay humble. So first off, relationship and knowledge are far more important than bitcoin. Any of us can die at any moment so don't kid yourself. Teach your kids about bitcoin and how to use it. Help them set up wallets. Send them bitcoin. Pay them in bitcoin for chores. Share your passion with them. Prepare them for living in a world in financial decline. You need more than bitcoin for this.

Stay humble:

Don't be dumb. Don't over extend yourself and get into debt. Stack sats on a regular basis. Don't gamble and try to play the markets. Stay humble. Learn to grow food. Learn to be prepared for the most likely disasters (ie not nuclear holocaust). Teach your kids to be self reliant. Don't raise kids, raise adults.

Stack sats:

Focus on building wealth for your family. I don't stack sats primarily for myself. I do it for my family. I don't know when bitcoin will win but I know it will be at some point in the future so I'm focused on stacking as much as I can while I can. My goal isn't to give my children a certain amount. My goal is to get them to value bitcoin and learn skills to allow them to stack sats for themselves. Yes, I have given them bitcoin but the bigger goal is to give them knowledge and skills.

reply
reply

An 8 minute one way interview, recording responses to three questions. Went fine, now that makes 3 jobs I'm waiting to hear back from. I'm thinking I'm most likely to get this last one, but hopefully I hear back from the other 2.

reply

imo, talking about who is or isn't Satoshi is a waste of time.

Sure, it's interesting but why do we want to know?

If Satoshi ever shows up again, nothing good will come from it.

There are too many people who are used to authority and will gladly agree with whatever Satoshi says. Bitcoiners are no exception.

Satoshi disappeared for a reason. We should respect that reason.

People want an authority to tell them how to value things, but they choose this authority not based on facts or results. They choose it because it seems authoritative and familiar.

-- quote from the movie The Big Short

edit: kind of funny to quote this below a link to Lopp's blog

reply

Graphene!

reply

For people I don't know, I go with my man Satoshi on this one:

"If you don't believe it or don't get it, I don't have the time to try to convince you, sorry."

For people I love, I just stack a few extra sats in their name so if I ever need to I can help them out.

reply

... and how!

reply

It seemed mostly like someone just having a laugh.

Maybe they'll come here and tell us?

reply

Phoenix. Easy to use and self custody.

reply

Interesting...

So this would be 1 person or company opening 50 channels to other LN nodes. How about 50 people opening 50 channels to 50 other people? Because this is really what it would take.

reply

Like the question. My 2 sats are:

  • Ads will exist, but their influence will be much less in future.
  • If people have less disposable income to spend, the ads will become prohibitively expensive.
  • Not to mention tracking is proving more challenging given big tech is limiting micro-targeting.
  • Also, I wonder if we all in 10 years were to have a personal AI, why do you need adverts? When it knows what you want and will buy/recommend the things you need and want. They will know us better than ourselves.
  • I feel like we've been living in an advertising bubble these last 10 years. The internet experience has got so out of whack on a user experience level, with clickbait titles, free returns, fast-fashion, privacy popups and the like. It's not going to sustain itself. It's too distorted.
  • Value on all fronts is making a comeback. We'll all be supporting each other much more within our communities I expect.
  • Just look at SN flourishing today. It's a model that has traction & growth. Ads will exist but instead of being 80-90% of revenue for content creators, I believe it will be back to 15-20%. Creators are going to need to hustle again and that's the way it should be if we want a productive society.
reply

Between 20-40k per day and close to a million per month, both unique. When the Mempool is full, it is usually A LOT more traffic.

reply

I stumbled across BTC in 2011 after listening to a podcast:
https://omegataupodcast.net/59-bitcoin-a-digital-decentralized-currency/

I even installed bitcoin core on a Windows 2000 machine but didn't fully understand what I was doing, lol. After a week or so, I removed the btc core software, my biggest mistake not to dig deeper.

I eventually bought BTC at the ATH in 2021, it's never too late (I got the BTC for the price I deserve).

reply

What do you think to the result coming out of Norway yesterday?

reply

Their whitepaper is pretty bad at explaining what this tech is, and their docs aren't much better. I'll give it my best shot but if anyone from sovryn is reading, please correct me if i'm wrong here.

The whitepaper introduces two technologies, "Grail" and "BitSNARK", which i assume taken together are the 'framework' they call BitcoinOS.

They claim BitSNARK is a more efficient version of BitVM for the specific case of validating ZK rollups, but they fail to elaborate on how they made it more efficient and how it works internally, beyond the high level overview given on page 3. The main raison d'etre of BitSNARK seems to be to act as an on-chain enforcement mechanism for settling smart contract disputes using zero knowledge proofs (Groth16 snarks) as the ultimate source of truth for who 'wins' the settlement. Basically this is BitVM specifically instantiated for SNARK verification.

Also, Groth16 requires a per-circuit trusted setup and produces "toxic waste", and their paper doesn't clarify how they deal with that. Who does the trust fall on? What are the consequences if the trusted parties misbehave and keep their toxic waste?

As for Grail, it seems to be a procedure used to 'transfer' bitcoin in and out of an L2/sidechain, using BitSNARK (BitVM+ZKP). This type of procedure seems to be a hot topic for businesses these days. Full disclosure: i'm doing some work for a company who is building something similar, except with multisig escrow instead of an on-chain ZKP verifier.

Grail Bridge

The bridge is intended to allow users to transfer assets between the Bitcoin blockchain and an L2 (Layer 2) network

Operators can lock funds on the Bitcoin side by sending them to Taproot addresses created using BitSNARK. The funds are thereby locked in a UTXO until a SNARK proof is provided that allows them to be retrieved. On the L2 side, the operator sends a SNARK proof to the bridge smart contract, thereby causing the bridge to mint tokens to the operator’s wallet. In the reverse process, an operator burns their tokens via the smart contract, thereby obtaining a SNARK proof that allows the operator to retrieve their funds, on the Bitcoin side, from the UTXO, using the BitSNARK protocol.

So the "Unlimited Smart Contracts and Scalability" claim they have emblazoned on their website isn't occurring on bitcoin - it's occurring off-chain, and the framework they've designed is just an engine (powered by BitVM and SNARKs) to allow people to wrap bitcoin which they can then use on smart contracts inside the given L2.

Ultimately users still need to choose their L2 wisely because a bug or hack in the L2 will destroy the wrapped bitcoins, and prevent users from creating valid proofs to reclaim the actual Bitcoins proper.

For example, if you used Grail to wrap BTC onto Ethereum, and then deposited that wrapped-BTC in a poorly coded ETH smart contract which gets hacked, then you're shit-outta-luck - the hacker can burn the wrapped-BTC and create a proof which lets them sweep away your mainchain BTC, and you can't do anything about it. Your money would be just as gone as if you'd just sent your BTC straight to the hacker in the first place.


Overall rating: 6/10. Highly efficient ZKPs enforced on Bitcoin is exciting and I would like to know more about how their 'BitSNARK' system actually works. I think Sovryn is focusing on the wrong use case with Grail though. Instead of bridging Bitcoin to shitcoins, they should be focusing on using BitSNARK to create more powerful expressive tools on L1 bitcoin.

reply
reply

I always liked updates being posted here. I wouldn't join a call but I'm not a contributor. Seeing the call notes posted to SN would be cool if you go down that route.

reply
In most countries, spending Bitcoin creates a taxable event

If on Stacker News I'm spending Bitcoin and I'm paying here to someone for the service named:
providing a good reply to read - does it create a taxable event?

in other words: "Don't comment on SN because if it is good - it will be a taxable event." ;)
let's not be slaves... (we aren't already, it seems... :)

reply
Now you're onto something. Whether you allow more type I or type II errors should depend on the costliness of each type of error.

That's true. However:

Oftentimes, the cost of subscribing to a false conspiracy theory is just looking silly, while ignoring a true conspiracy theory might come at a ruinous cost.

It's not a one-time game. There's a cost to crying wolf, or heeding the cry. The cost of endless conspiracy theories that you either promote or accept is that both your credibility and your discernment trend to zero, which hurts both you and the community in which you operate -- and possibly the world, if you want to really get serious.

The damage done to btc adoption by having its most prominent and loudest voices be a mental landfill of extremism, midwit pseudo-intellectual blathering, and aggression, is hard to understate. If you think btc is an important thing for the world, then setting adoption back a decade by these folks being the public face of it [1] should make you upset.

[1] Of course the public face is always in the process of shifting. But this was true for a long time and is still significantly true.

reply

I wouldn't call it a project per se, but I got myself a tapsigner and am going to figure out how to use it to make a multisig for some non-KYC sats. Time to check out some BTC sessions tutorials....

reply

Good topic. We should recognize when the constraint is a design that has to be forever, or if it is a constraint by the technology at the moment. If technology evolves, can the constraint be changed?

An example is the famous quote: "640K of RAM ought to be enough for anyone," we had to write software with that memory limit in mind.
Or how computers had the 8 bit constraint, but then it was changed to 16 bit, then 32 bit and 64 bit. Forcing to update all software each time.

I would say, it is difficult to design constraints that last forever to technology.

reply

About Adverts

Not sure if this is the best place or maybe this thread is but FYI @kr...

  • As an advertiser, would it not be preferred when a Stacker clicks the title of the post (green arrow), to be taken straight to my website in a new window?
  • Adding an additional step (i.e. the current ad page) will decrease click-throughs substantially. I imagine it's like a 90% drop-off.
  • If it is clear it is an advert on the listing and people are clicking, I would want people to see the most amount of information possible, i.e. on my site. Clicking the comments could take people to this listing page (yellow arrow) if they are interested in what the community are saying. Or maybe this is just a configuration option.

https://image.nostr.build/b55d9596eb8a8f200764358c19ee071eae8c72d1bdd11b08c60795bce9daa469.png

reply

Agreed. Interestingly enough I don't withdraw my SN sats either, which is unique because if I won 10 sats on Bitcoin solitaire you could be sure they are getting zapped to my WoS. It is a testament to what @k00b and team have built (are continuing to build) that it feels intuitively right that SN sats stay on SN.

reply

Just finished first Sphinx bounty writing command line script to split up video using ffmpeg. Now working on second adding tribe member mentions to Sphinx.

reply

There's already too many territories

reply

Section 988 of the IRS Internal Revenue Code is in general titled "Treatment of certain foreign currency transactions." The general principle of that section is that "any foreign currency gain or loss...shall be...treated as ordinary income or loss." However, it outlines a bunch of exceptions, one of which is sometimes called the “de minimis” exemption:

If—
(A) nonfunctional currency is disposed of by an individual in any transaction, and
(B) such transaction is a personal transaction,
no gain shall be recognized for purposes of this subtitle by reason of changes in exchange rates after such currency was acquired by such individual and before such disposition. The preceding sentence shall not apply if the gain which would otherwise be recognized on the transaction exceeds $200. source

There’s a lot of legalese there so let’s unpack it, starting with “nonfunctional currency.” This document helpfully defines what the tax code means by functional currency: “Generally, [taxpayers] must make all determinations…relating to income taxes…in [their] respective functional currency. … The dollar shall be the functional currency of [most] taxpayer[s]...regardless of the currency used in keeping [their] books and records.” Basically, your country’s “functional currency” is the one in common use, and any other currencies are “non-functional” currencies.

For a long time, bitcoin didn't fit the first part of this exemption because anyone who tried to say bitcoin is a nonfunctional “currency” would get tripped up on the currency part. A judge, for example, would ask what country accepts it for payment of all debts, public and private. The bitcoiner would have no answer, and the judge could then just say, “Nice try, but bitcoin is clearly not a currency.” But now, bitcoin is legal tender in el salvador (including for government bills), so we can say it is currency there. That means bitcoin now fits the first condition in this exemption: it is a nonfunctional currency disposed of by some individuals in some transactions.

The second part says the exemption only applies to personal transactions. A personal transaction is defined as “any transaction entered into by an individual” (as opposed to a business) and not including a self-employed person’s business expenses (or what would be business expenses if that person’s business was incorporated -- for more info see the full definition here).

Given these definitions and conditions, the exemption applies to bitcoin in this way:

If a person (“an individual”) spends his bitcoins (“nonfunctional currency”) for everyday reasons (“personal transactions”), then it can’t be taxed (“no gain shall be recognized”) just because it appreciated in value (“by reason of changes in exchange rates”) after he acquired it (“after such currency was acquired...and before such disposition”) unless the value of the appreciation exceeds $200 (“[That] does not apply if the gain...exceeds $200”).

Since bitcoin is a foreign currency now, taxpayers can legitimately not disclose their bitcoin expenditures to the IRS as long as the gains on each transaction are below $200. That is beneficial for privacy and an incredible boon to the usefulness of bitcoin. Note well: no other cryptocurrency gets this exemption because no other cryptocurrency is a foreign country's legal tender.

reply