Skip to content

Latest commit

 

History

History
240 lines (118 loc) · 609 KB

File metadata and controls

240 lines (118 loc) · 609 KB

怎么跟小白讲闪电网络

本文翻译自:https://hackernoon.com/lightning-network-explained-d4615c12ad09

作者:Mohit Mamoria,CEO, Authorito Capital (https://authorito.com)

译者:区块链中文字幕组 Chuan

翻译时间:2018-04-03

Blockchains are slow. And therefore, expensive. If I had to send you some Bitcoins, you’d receive them in about a couple of hours and I’d have paid a heavy transaction fee too. With such a reputation, how will Blockchains take over the world?

区块链效率低,因此,代价很高。如果我要转一些比特币给你,你得要几个小时才会收到,而且我也要支付很高的手续费。靠这样的名声,区块链如何能够占领这个世界?

Any idea that can solve the non-scalability of Blockchains is worth attention, time and effort. Lightning Network is one such idea. But before we understand the solution, we’ll need to understand the problem.

任何能够解决区块链不可扩展性问题的方法都值得关注,都值得投入时间和精力。闪电网络就是为此而来。但是,在明白这个方法之前,我们要先搞清楚为什么区块链效率问题。

If you’re already aware of the problem, you can directly jump to the next section.如果你已经明白问题是什么,那么可以直接看下一部分。

⚡️ Why Blockchains are slow?为什么区块链的效率低?

“I am a slow walker, but I never walk back.” — Abraham Lincoln

“我走得很慢,但是我从不后退。”—亚伯拉罕.林肯

Think of a Blockchain as a register. And this register contains several pages (blocks) where each page has several transactions. As soon as a page has been filled with transactions, it needs to be added to the register before starting to record transactions on the next page.

把区块链想象成一个登记簿。这个登记簿有若干页(区块),每页包含若干条交易。当某一页被交易信息登记满后,在开始在下一页里记录交易信息之前就需要把这一页添加到登记簿里。

Before a page (block) can be added to the register (chain), there’s some processing that needs to be done to ensure that everyone agrees with the contents it contains. The process approximately takes 10 minutes (for Bitcoin Blockchain) for each block.

在某一页(区块)可以被添加到登记簿(链)之前,需要完成一些处理来确保每个人认同页里包含的内容。对比特币区块链来说,每个块的这个处理过程大概需要10分钟。

Imagine, you send 1 BTC to your friend, Joe. The transaction will look something like this.

想象一下,你发送一枚比特币给你朋友,这个过程看起来就像这样。

img

Among other things, a transaction contains information about the sender, the recipient, the amount and the transaction fee.

在其他内容中,交易包含的信息有:发送方,接收方,发送数量和手续费。

⚡️ Wait a minute, transaction fee?

等一下,手续费?

“A consultant is someone who saves his client almost enough to pay his fee.” — Arnold H. Glasow

“顾问就是那个把为客户省下来的钱来用来支付给他咨询费的人。”—阿诺德 H. 盖斯洛

Yes, there’s an additional fee. You can pay it to incentivize miners to include your transaction in a block as soon as possible. There’s no set price and it’s entirely up to you how much you are willing to pay to speed up the process. The higher the fee, faster your transaction will go through.

是的,有一笔手续费。你可以支付这笔钱来激励矿工尽快地把你的交易打包到区块中。它的价格并不固定,完全取决于你愿意付多少来加快这个处理过程。手续费越高,你的交易完成的就越快。

At any given moment, there are several transactions available to be recorded on the current page.

在任一特定的时刻,总有一些已达成的交易被记录在当前页面。

img

The miners, i.e. computers working in the Blockchain network, have to decide which of the available transactions to include in the current block. To help them decide, they look at which transactions yield the most rewards — meaning that the transactions with the highest transaction fee will be included first.

矿工,也就是区块链网络上的计算机节点,必须决定这些达成的交易中哪些要打包到当前区块中。为了帮助他们确定这个结果,他们看哪些交易提供最多的手续费 --- 意思就是手续费最高的交易会最先被打包。

img

If there are enough transactions with a higher transaction fee than yours to fill up the block, your transaction will have to wait in queue. The wait can last from a few minutes to a few hours. And sometimes, even days. The more you pay in transaction fees, the quicker your transaction is processed.

如果有许多比你的手续费更高的交易被打包进区块,你的交易将不得不在队列中排队。这一等待时间短要几分钟,长则几小时。有时候,甚至几天。你支付的手续费越多,你的交易就被更快地处理。

img

That’s why Blockchains are slow, and therefore, expensive for everybody to start using. Ideally, the adoption of Blockchain would mean more transactions happening but as the number of transactions goes up, the network will become slow, making a hurdle for adoption. What a paradox!

这就是区块链低效的原因,以及因此对每个开始使用它的人来说代价太高的原因。理想情况下,采用区块链意味着更多的交易达成,但是,当交易量上升时,区块链网络就变得效率低下,对它的广泛运用造成了障碍。太矛盾了!

Lightning Network (LN) is a potential solution to the problem.

闪电网络是对这个问题的潜在解决方案。

⚡️ So what is Lightning Network again?

那么,闪电网络到底是什么?

“Thunder is good, thunder is impressive; but it is lightning that does the work.” — Mark Twain

打雷是好,雷声让人印象深刻;但却是闪电造就了这个效果。— 马克.吐温

The idea behind LN is that not all transactions are required to be recorded on the Blockchain.

Imagine you and I transact quite a few times among ourselves. In such a case, we can bypass recording the transactions on the Blockchain and carry them off the chain.

闪电网络背后的设计是:不是所有的交易都要求在主链上记录。想象你和我之间进行几次交易。这种情况下,我们能避开在主链上记录这些交易信息,让它们在链外完成。

In the simplest terms, how it’ll work is — we’ll open something called a payment channel between us and record its opening on the Blockchain. Now, you and I can transact any number of times through this payment channel and it can stay open for any number of hours, days, weeks or decades. The only time we would touch the Blockchain ever again will be when we would want to close the channel. Then, we’ll write the final status of the transactions that occurred through the channel on the Blockchain.

最简单的话来说,它是这样工作的:我们打开一个我们两人之间的支付通道,在主链上记录它的开始状态。现在,通过这个支付通道你和我可以进行任意次数的交易,它保持开放的时间可以从几小时到几十年。我们和主链再次产生联系仅有的一次就是我们想关闭这个通道。然后,我们在主链上写下经过这个通道的所有交易的最终状态。

Using this idea of payment channel, we can create a network of payment channels such that it would be only rarely required to transaction on the Blockchain. Imagine there are three characters — Xan, Yelena and Zeke.

利用这个支付通道的概念,我们能够创建一个支付通道网络,这样我们就几乎不用在主链记录交易信息。想象有三个人:Xan,Yalena和Zeke。

If Xan and Yelena have a payment channel opened between them and Yelena and Zeke have a payment channel opened between them, then Xan can send money to Zeke via Yelena.

如果Xan和Yelena在他们之间打开了一个支付通道,Yelena和Zeke之间也有一个支付通道,那么Xan可以通过Yelena把钱转给Zeke。

Suppose Xan wants to send 2 BTC to Zeke, Yelena will send 2 BTC to Zeke and Xan will reimburse Yelena with 2 BTC.

假定Xan想转2个比特币给Zeke,Yelena将转2个比特币给Zeke,Xan再拿2个比特币转给Yelena。

That’s what the idea of Lightning Network is. Because you won’t be touching the Blockchain often, the transactions will be happening at lightning speed. As you might have guessed by now, all the magic happens in the payment channels. Let’s learn the magic trick then.

这就是闪电网络的工作原理。因为你不再经常与主链产生联系,所以交易会迅速完成。到目前为止,正如你所想,实现这一切都在于支付通道。接下来,我们来了解一下这个绝妙的设计。

⚡️ And what are those payment channels?

这些支付通道是什么东东?

“Individually, we are one drop. Together, we are an ocean.” — Ryunosuke Satoro

每个个体只是一滴水。聚在一起,就是一片汪洋。— Ryunosuke Satoro

It’s like a safety deposit box where two people deposit equal amounts of money and each put a lock on it.

这就像一个安全的存钱盒,两个人放进相同数额的钱,每个人在上面都有一把锁。

img

This action of depositing equal amounts of money in a common box is recorded on the Blockchain in the form of an ‘Opening Transaction’ and thereafter a payment channel is open between those two people.

这个在一个共同的盒子里储存同等金额的钱的行为按照“建仓交易”的形式被记录在主链上,因此,在这两个人之间就打开一个支付通道。

The idea behind locking money in such a box is that no one person can spend the money in the box without the other. The money in this box is then used to transact between each other.

把钱锁在这样一个盒子背后的想法是:假如另一个人不在的话,一个人无法用盒子里的钱。盒子里的钱被用于相互之间的交易。

Imagine, Xan and Yelena pool in 10 BTC each in the common box. And now, if Xan wants to send 2 BTC to Yelena, how would he do that?

想象一下,Xan 和 Yelena 每个人都往盒子里放了10个比特币。现在,如果 Xan 想发送 2 个比特币给 Yelena, 他要怎么做?

To do that, he would transfer a promise of ownership for two of his Bitcoins in the common box to Yelena. After this transfer of promise, if the box is unlocked, Xan will be able to take 8 BTC from it and Yelena will be able to claim 12 BTC.

为了做到这一点,他要把两人共用的盒子里表明他的比特币中的两个的所有权转给Yelena。在此之后,如果盒子是打开的,那么Xan 就能够从其中取8个比特币,Yelena将能够拥有12个比特币。

img

But they will not open the box because they want to continue transacting between themselves. That’s the beauty of this arrangement.

但是他们不会打开这个盒子,因为他们想继续进行彼此间的交易。这就是这一安排的巧妙所在。

Now, if the next day, Yelena has to send 1 BTC to Xan, she would do the same — transfer a promise of ownership for one of her Bitcoins to Xan. After these two transactions, if the box is opened, Xan can claim 9 BTC and Yelena can get 11 BTC.

现在,如果第二天,Yelena 要发送1个比特币给Xan,她也会做同样的操作——把表明她拥有的比特币中的一个的所有权转给Xan。这两次交易后,如果盒子被打开,Xan 就能拥有9个比特币,Yelena则获得11个比特币。

To imagine how off-chain transactions look like, consider this:

为了想象一下链外交易是一番什么样的情景,看看这个:

img

To sum it up, payment channel is nothing but a combination of pooling some money together and then transferring the promise of ownership of the pooled-in money in the agreed upon manner. If ever either of Xan or Yelena wants to close the channel, they can.

总而言之,支付通道就是两个人把钱放到池子里,然后通过一种共识把表明池子中钱的所有权转移给另外一个人。如果Xan或者Yelena中任一个人想关闭通道,他们都可以关掉。

Closing a channel would simply mean opening up the box and taking the money inside. This opening of the box happens on the Blockchain and the who owns how much from the box is recorded forever.

关闭一个支付通道只是意味着打开这个盒子,把里面的钱取走。盒子的打开这一动作以及最终谁拥有盒子中多少钱这一状态被永久地记录下来。

img

That’s how payment channels work. But that doesn’t even come close to defining their true potential. Their true power is unleashed when two or more payment channels work together to form a network — The Lightning Network.

这就是支付通道工作的原理。但是,这对它们真正的潜力来说差的还太远。当两个或多个支付通道一起协作形成一个网络时,它们真正的威力就被释放 — 闪电网络。

⚡️ Got it, so how does it actually work?

懂了,那它实际是怎么发挥威力的?

“Great things are done by a series of small things brought together.” — Vincent Van Gogh

伟大的事情是通过一系列小事连接而成的。—文森特·梵·高

LN works by moving the value from the ownership of the Bitcoins to the promise of ownership of the Bitcoins.

闪电网络的工作机制是:把对比特币的所有权转给比特币所有权的承诺完成价值转移。

This shift is huge. Like always, we will use an example to understand this. Imagine there are three people — Xan, Yelena and Zeke — such that there’s a payment channel open between Xan and Yelena, and there’s another channel open between Yelena and Zeke. Note that Xan and Zeke have no payment channel between them.

这一转移的影响是巨大的。我们用个例子来解释一下。想象有三个人:Xan, Yelena 和 Zeke,在Xan和Yelena之间有个打开的支付通道,在Yelena和Zeke之间有另外一个打开的通道。注意:Xan和Zeke之间是没有通道。

In such a situation, if Xan wants to transfer 2 BTC to Zeke, he can use the payment channel between Yelena and Zeke to do that. How does that look like?

在这样的情况下,如果Xan想转2个比特币给Zeke,那么他可以使用Yelena和Zeke之间的支付通道完成这个操作。这是怎样一番情形呢?

Xan asks Yelena to transfer a promise of 2 BTC to Zeke on Yelena-Zeke payment channel and then he reimburses Yelena with 2 BTC on Xan-Yelena channel.

Xan请求Yelena把对2个比特币的所有权的声明通过Yelena-Zeke支付通道转给Zeke,然后他通过Xan-Yelena通道转给Yelena 2个比特币。

img

With such network of payment channels, a huge chunk of transactions can be off-loaded from the Blockchain to be carried out off the chain, therefore, freeing up the chain’s bandwidth.

通过这样一个支付通道网络,大量的交易能够从主链上切换出来,在链外完成交易,从而,减轻主链的负担。

Using a network of payment channels, millions of transactions can happen, and that too without a hefty transaction fee.

利用支付通道网络,上百万笔交易成为可能,而且也不需要过多的手续费。

That’s the Lightning Network. And, now you know how to explain it to your friends. Or if you’re feeling lazy, simply send them to this article.

这就是闪电网络的前因后果。现在你知道如何向你的朋友解释它了。你要是不想解释,就直接把这篇文章转给他看。


区块链中文字幕组

致力于前沿区块链知识和信息的传播,为中国融入全球区块链世界贡献一份力量。如果您懂一些技术、懂一些英文,欢迎加入我们,加微信号:w1791520555。

点击查看 GITHUB 及更多的译文

本文译者介绍

Chuan,区块链技术爱好者。欢迎加我的微信:youyuxiaochuan

译文版权所有,转载需完整注明以上内容。

本文源自新闻媒体 Hackernoon,如有侵权,请与译者联系删除。