Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Nefelibato on January 18, 2023, 10:06:54 PM



Title: Layer 2 Vs Sidechains
Post by: Nefelibato on January 18, 2023, 10:06:54 PM
What is the difference between a Layer 2 and a Sidechain? I have not found any article that distinguishes them well.


Title: Re: Layer 2 Vs Sidechains
Post by: jackg on January 18, 2023, 10:48:54 PM
If I have it right, a sidechain can host layer 3 (things like applications that run on layer 2 tokens) while layer 2 tokens can't without one.

A sidechain often normally refers to tokens and ignores other things (like contracts on the lightning network) which are also layer 2.


Title: Re: Layer 2 Vs Sidechains
Post by: HeRetiK on January 18, 2023, 11:35:33 PM
Sidechains run on separate blockchains while layer 2 solutions in general not necessarily require one. For example the channel states of Lightning Network are managed by each node separately, without the need for a common blockchain (except for settlement on the main layer, when opening and closing a channel).

Arguably sidechains are a kind of layer 2 solution, though I'm not quite sure if all of them fit the bill, technically speaking.



Title: Re: Layer 2 Vs Sidechains
Post by: pooya87 on January 19, 2023, 04:54:34 AM
Second layer as the name suggests is a "layer" and like any layers it is made on top of a main "bed" which in case of bitcoin is the main-net and its blockchain. That means second layer is a network that completely relies on the main network it is built on and if the main network has any problems (eg. it dies) the second layer will experience problems (eg. it dies too).
Example: Lightning Network

A side-chain on the other hand is as the name suggests a "chain", a separate chain that has a "link" to another chain but it doesn't completely relies on it. They are usually "pegged" to the main network. That means any problems in the main network may not completely affect the side-chain.
Side-chains can even have their own mining algorithm and a stand-alone blockchain.
Example: Rootstock, Blockstream's Liquid,...

This difference is the reason why 1 LN bitcoin is exactly 1 bitcoin but 1 sidechain bitcoin doesn't have to be 1 bitcoin, it could be 1000 wrapped-bitcoin or 0.5.


Title: Re: Layer 2 Vs Sidechains
Post by: garlonicon on January 19, 2023, 09:08:35 AM
Quote
This difference is the reason why 1 LN bitcoin is exactly 1 bitcoin but 1 sidechain bitcoin doesn't have to be 1 bitcoin, it could be 1000 wrapped-bitcoin or 0.5.
The only reason why one sidechain Bitcoin is not one Bitcoin is that you cannot form sidechain transactions as a regular Bitcoin transactions. Because if we would have transaction joining, then it would be possible to join all sidechain transactions into a single mainchain transaction.

When it comes to public keys, and regular signatures, it is definitely possible to join them. The bottleneck could be in case of script-based outputs, but since we have Taproot, it is possible to join revealed public keys, and then push on-chain only the latest script.

Also, a lot of script operations are perfectly defined in ECDSA, for example if you have OP_ADD, you can just add public keys. That means, some script-based outputs could be rewritten into Schnorr-signatures-based outputs.


Title: Re: Layer 2 Vs Sidechains
Post by: BlackHatCoiner on January 19, 2023, 10:59:51 AM
Maybe a broad distinction is that a sidechain creates currency, while second layer solely uses already existent currency?

Another distinction is that layer 2 solutions are not trust requiring. In the Lightning Network for example, there is the penalty mechanism which ensures your partners can't cheat you after you've opened up a channel. Sidechains on the other hand are conceptionally trust requiring. You need to trust 11 out of the 15 co-signers of the Liquid federation.


Title: Re: Layer 2 Vs Sidechains
Post by: HeRetiK on January 19, 2023, 11:55:49 AM
Maybe a broad distinction is that a sidechain creates currency, while second layer solely uses already existent currency?

Both OMNI and Counterparty run on Bitcoin as layer 2 protocols without a sidechain.


Another distinction is that layer 2 solutions are not trust requiring. In the Lightning Network for example, there is the penalty mechanism which ensures your partners can't cheat you after you've opened up a channel. Sidechains on the other hand are conceptionally trust requiring. You need to trust 11 out of the 15 co-signers of the Liquid federation.

Liquid is just one example though. Rootstock on the other hand uses merged mining. That is the say, since sidechains use blockchains of their own they can run on all sorts of consensus algorithms, including PoW-based ones.


Title: Re: Layer 2 Vs Sidechains
Post by: BlackHatCoiner on January 19, 2023, 12:13:37 PM
Both OMNI and Counterparty run on Bitcoin as layer 2 protocols without a sidechain.
Don't know about OMNI, but doesn't Counterparty require you to burn bitcoin? Isn't it more like a transitioning to another currency, rather than just creation of currency?

Liquid is just one example though. Rootstock on the other hand uses merged mining. That is the say, since sidechains use blockchains of their own they can run on all sorts of consensus algorithms, including PoW-based ones.
Correct. Rootstock isn't trust requiring. So, what's the broad distinction between L2 and sidechain?


Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on January 19, 2023, 12:21:29 PM
Based on what I have read I think this is the main difference:
A sidechain is an independent, EVM-compatible blockchain that runs parallel and interacts with the mainnet through bridges. As they use a separate consensus mechanism and are not secured by layer 1, they are not technically considered layer 2.
And if we also introduce the State channels in the comparison? I deduce that they are pay channels. Are they not the same as an atomic swap?


Title: Re: Layer 2 Vs Sidechains
Post by: garlonicon on January 19, 2023, 12:23:32 PM
Quote
So, what's the broad distinction between L2 and sidechain?
Simple, it is in the name. L2 has no chain. Also, LN is a layer "one and a half", because you cannot send coins directly in LN, without touching the first layer, if someone has no channel. The true second layer would allow locking for example 1 BTC, and splitting it between thousands of channels, without any on-chain transactions. Also, because of that bottleneck, you cannot build another layer on top of LN, because it would still require on-chain interaction.

Quote
EVM-compatible blockchain
It is not required. It could be ECDSA-compatible, and it will be sufficient.


Title: Re: Layer 2 Vs Sidechains
Post by: HeRetiK on January 19, 2023, 01:05:16 PM
Both OMNI and Counterparty run on Bitcoin as layer 2 protocols without a sidechain.
Don't know about OMNI, but doesn't Counterparty require you to burn bitcoin? Isn't it more like a transitioning to another currency, rather than just creation of currency?

IIRC Counterparty burned bitcoins for the initial distribution of their XCP token, maybe they've burned more coins since then but that's beside the point. When I refer to OMNI and Counterparty creating a currency of their own I don't mean their native tokens (if you can call them that) but I mean the tokens that are created using those native tokens. USDT in the case of OMNI.... and... sigh... Rare Pepes in the case of Counterparty, for example. The denomination, amount, value etc. of these tokens being largely independent of the value of the Bitcoin transactions underneath.


Liquid is just one example though. Rootstock on the other hand uses merged mining. That is the say, since sidechains use blockchains of their own they can run on all sorts of consensus algorithms, including PoW-based ones.
Correct. Rootstock isn't trust requiring. So, what's the broad distinction between L2 and sidechain?

Like I said above: I think the clearest distinction is that sidechains run on separate blockchains while layer 2 solutions in general not necessarily require one.

Or another view: Layer 2 can be seen like the layers of the OSI model, eg. HTTP running on top of TCP/IP (I believe that this is even the root of the L2 nomenclature in the first place?) while sidechains connected to a main chain can be compared to LANs connected to the Internet. Fun thing is this analogy even accounts for LANs requiring protocol layers on top of the base layer to function, just as sidechains need more than just basic transactions.


The true second layer would allow locking for example 1 BTC, and splitting it between thousands of channels, without any on-chain transactions. Also, because of that bottleneck, you cannot build another layer on top of LN, because it would still require on-chain interaction.

I believe what you are describing is pretty much what is described in the channel factory proposal for a potential layer between LN and the base layer:
https://tik-old.ee.ethz.ch/file//a20a865ce40d40c8f942cf206a7cba96/Scalable_Funding_Of_Blockchain_Micropayment_Networks%20(1).pdf

Apart from that I believe you can still add another layer on top of LN in the form of colored coins via LN? Though the viability of that seems to be controversial.


And if we also introduce the State channels in the comparison? I deduce that they are pay channels. Are they not the same as an atomic swap?

No, atomic swaps take place across blockchains.





Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on January 19, 2023, 07:12:17 PM
Sidechains are not protected by Layer 1 and they have their own consensus, unlike Layer 2.

No, atomic swaps take place across blockchains.

The Technology Behind Atomic Swaps
A valid transaction requires a signature. This signature can only be created by the person that has access to the private key. When you send a transaction you usually sign it and broadcast it to the network afterward. HTLCs are based on a technology called state channels. All you need to know is that they allow you to exchange signed transactions securely. Only once the participants decide they are done transacting, the final state is broadcast to the blockchain.

The “Hashed” part of HTLC means that a hash serves as a lock for the contract, to protect it from a third party accessing it. The “Timelock” part refers to the contract having an expiration date.

Two conditions must be met to perform an Atomic Swap between two crypto assets: Both assets and their underlying blockchain need to support the same hashing algorithm, like SHA-256 in the case of Bitcoin and both blockchains need to support some kind of programmability that allows an HTLC to be deployed.


Title: Re: Layer 2 Vs Sidechains
Post by: NotATether on January 19, 2023, 08:25:00 PM
A lot of protocols, but time will tell which ones are good for packaging and sending off to normal users.

The truth is, it doesn't take much to cover the average bitcoin user:

- The Layer 1 (obviously)
- BIP39 seed phrases
- Standardized design specs for hardware wallets
- Lightning Network nodes (someone still needs to make a swarm of watchtowers that anyone can connect to, to solve the trust problems completely)
- Atomic swaps, between any two coins. Using something inside DeFi will work
- A protocol featuring high scalability but low confidentiality to be used as the network for payment cards


Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on January 20, 2023, 05:41:05 PM
My opinion is that Bitcoin requires 4 main characteristics, decentralized, secure, fast and cheap. DeFi and other things are fine in layers 2 and other protocols.


Title: Re: Layer 2 Vs Sidechains
Post by: n0nce on January 20, 2023, 09:46:06 PM
Honestly, a sidechain can also be considered a second-layer technology. Since it relies on the blockchain (L1) and is linked to it. I think that is also the reason why there is no definition of what the difference between the two is. It's a subset / set element of 'L2'.

So, basically something like this.

https://i.postimg.cc/QM4Tstmf/image.png


Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on February 04, 2023, 03:42:23 PM
Your security doesn't depend on layer 1, that's the main difference.


Title: Re: Layer 2 Vs Sidechains
Post by: n0nce on February 06, 2023, 03:24:13 AM
Your security doesn't depend on layer 1, that's the main difference.
Difference between what? In which case does the security not depend on layer 1?
To the best of my knowledge, all the items in my chart depend on layer 1 for security.


Title: Re: Layer 2 Vs Sidechains
Post by: ABCbits on February 06, 2023, 12:05:50 PM
To the best of my knowledge, all the items in my chart depend on layer 1 for security.

But security of federated or centralized sidechain doesn't heavily rely on layer 1. For example, security of Liquid sidechain heavily involve "Functionaries".

These functionaries each serve two roles on the network - as blocksigners they operate the Liquid sidechain, and as watchmen they secure Bitcoins held by the Network.


Title: Re: Layer 2 Vs Sidechains
Post by: garlonicon on February 06, 2023, 05:14:45 PM
Quote
Your security doesn't depend on layer 1, that's the main difference.
Imagine a sidechain, where coins are transferred from mainchain to sidechain by signing them, and they are transferred back by moving them on Bitcoin (and that would destroy them automatically on the sidechain). And imagine that such sidechain is Merge Mined with Bitcoin, so it is possible to mine both at the same time, with the same computing power. In this case, your security strictly depends on layer one, because it is constantly observed to know about all peg-ins and peg-outs.

So, again, the difference is in the name: "Each sidechain has its own chain".


Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on February 07, 2023, 01:39:06 PM
Well, because it has its own chain with its own consensus, it does not depend on the security of the main chain. If it merges with the main chain it is no longer a sidechain. Polygon is another example of a sidechain.


Title: Re: Layer 2 Vs Sidechains
Post by: n0nce on February 07, 2023, 03:01:32 PM
Well, because it has its own chain with its own consensus, it does not depend on the security of the main chain. If it merges with the main chain it is no longer a sidechain. Polygon is another example of a sidechain.
Sidechains that don't periodically merge, are no sidechains but just forks of the main chain, no?
That would be terrible. Especially without PoW, there would be no decentralized on such 'sidechain' (fork-chain ???) either, right?


Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on February 19, 2023, 10:52:40 AM
Difference between fusion and synchronization. I think it is well explained here.

https://ethereum.org/en/developers/docs/scaling/sidechains/


Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on March 13, 2023, 11:43:56 AM
Could we say that layer 2 always uses the native currency of the mainnet?
For example, layer 2 of Ethereum, and that sidechain uses its own currency, its own consensus algorithm...


Title: Re: Layer 2 Vs Sidechains
Post by: based52 on March 13, 2023, 03:07:26 PM
This is confusing to say, Polygon is both a layer one network and a side-chain on Ethereum. (Although I think it is highly centralized technology and do not recommend anyone use such a thing)


Title: Re: Layer 2 Vs Sidechains
Post by: based52 on March 13, 2023, 03:20:17 PM
Could we say that layer 2 always uses the native currency of the mainnet?
For example, layer 2 of Ethereum, and that sidechain uses its own currency, its own consensus algorithm...

This is actually not an accurate distinction.

For example the lightning network is NOT a side chain it is a layer 2 and it uses real bitcoin and nothing else to make transactions.

The liquid network IS a side chain AND uses real bitcoin AND uses other currencies which it can create through covenants.

The rootstock network IS a side chain, uses real bitcoin and also allows for other smart-contract style assets.

Effectively both need to use the native currency of the base layer in order to operate AT ALL.

To go into consensus algorithm, a layer 2 generally does not implement consensus it WORKS WITH the available consensus at the base layer.

Side chains on the other hand REQUIRE a consensus mechanism as they are distributed chains of their own who need Sybil resistance in order to work.

Lightning doesn't have a "consensus mechanism" but they do have a TON of best practices for not allowing your atomic multi-path payments to become lost to counter-parties. All of this work is settled on the base layer of bitcoin so anything that happens in the lightning network happens at the whim of each individual user and their responsibility.over their assets on the channels.

To talk (briefly) about Ethereum (please dont discuss that shit here there's a dedicated altcoin space)
They have a few "roll ups" which are effectively groups of trusted parties who allow multiple users to batch transactions from the l2 to the main chain in one transaction. This is problematic because the trusted parties and the l2 itself become a censorship (and other exploit) vector because they behave effectively like an account with custody control. Since there has been NO attempt to build sybil resistance at the l2 layer on Ethereum (or at the base layer for that) and there has been no attempt to create a side-chain on Ethereum (because their community does not believe in distributed decentralized consensus mechanisms) you can HARDLY call any of these implementations a REAL l2 .



Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on March 13, 2023, 07:15:22 PM
Liquid and RSK use 1:1 tokens with Bitcoin, not Bitcoin. Lightning on the contrary yes. I don't know of any layer 2 on Ethereum that doesn't use ETH for commissions. Polygon is sidechain, layer 2 rollup is under construction.
At no time have I talked about decentralization or recommended buying anything.


Title: Re: Layer 2 Vs Sidechains
Post by: based52 on March 14, 2023, 12:01:41 AM
Using 1:1 bitcoin is the same thing as using bitcoin there is literally NO DIFFERENCE


Title: Re: Layer 2 Vs Sidechains
Post by: NotATether on March 14, 2023, 06:44:16 AM
Honestly, a sidechain can also be considered a second-layer technology. Since it relies on the blockchain (L1) and is linked to it. I think that is also the reason why there is no definition of what the difference between the two is. It's a subset / set element of 'L2'.

So, basically something like this.

https://i.postimg.cc/QM4Tstmf/image.png

I would not necessarily consider CoinJoin to be a separate layer in and of itself, or even a sidechain. It's just one of those applications  of using Bitcoin transactions in their normal way. Now the protocols that are built on top of CoinJoin, those you can call separate layers, because they have their own syntax. Whereas CoinJoin  is just an abstract idea.


Title: Re: Layer 2 Vs Sidechains
Post by: Nefelibato on March 14, 2023, 11:43:08 AM
The native token is not the same as a token with parity to the native token. The main difference, as I already said, is that layer 2 inherits the security of the main chain, while side chains do not, since they have their own rules and consensus protocols.


Title: Re: Layer 2 Vs Sidechains
Post by: HeRetiK on March 14, 2023, 12:37:54 PM
Using 1:1 bitcoin is the same thing as using bitcoin there is literally NO DIFFERENCE

Usage and denomination may seem the same on the surface (which is why there is a peg in the first place), but a pegged currency is almost by definition not the same as the currency it is pegged to.

Problem being, that pegs can (and do) fail for a variety of reasons. In the case of sidechains, there may be a flaw in the consensus algorithm or its implementation. The project itself may be abandoned. Future changes on the main chain could lead to incompatibilities. In the end this means keeping sidechain tokens will always add risk since sidechain security will always be lesser than the one on the main chain.



Title: Re: Layer 2 Vs Sidechains
Post by: sha420hashcollision on March 27, 2023, 03:07:46 AM
The native token is not the same as a token with parity to the native token. The main difference, as I already said, is that layer 2 inherits the security of the main chain, while side chains do not, since they have their own rules and consensus protocols.

It is not the exact same thing but it IS the same asset which is opposed to the asset being some other asset. This would effectively break the tie to bitcoin and make said chain a layer one if the native asset were different entirely.