【翻译】How To Become A Blockchain Developer: Crash Course! 区块链开发指南!


声明:本文转载自https://my.oschina.net/zgldh/blog/1605388,转载目的在于传递更多信息,仅供学习交流之用。如有侵权行为,请联系我,我会及时删除。

In this guide, we are going to map out your journey for becoming a Blockchain Developer. To ease things up for you, we are going to divide this guide into various milestones and give you action steps at the end of every section.

在本指南中,我们将一步步筹划你的区块链开发之旅。为了易于你接受,我们将分步骤设置若干学习里程碑,并且在每一章节最后告诉你具体做什么。

It goes without saying that we are living in the “era of the blockchain”. The impact that it can have on our future is truly scary and magnanimous. So, how can you get a piece of that “blockchain action”? If you are to become a blockchain developer, then there are certain steps that you need to take.

毫无疑问我们正处在“区块链时代”。它对我们未来的冲击真的会很惊人,但也充满机遇。所以,你如何能在其中分到一杯羹?如果你打算成为一名区块链开发者,那本文列出的步骤应该正是你需要的。

Hopefully, at the end of the guide, you will have the tools required to kick-start your journey. If you are serious about becoming a developer then we need to set some expectations for you. Firstly, it is going to take time and you will need to dedicate your time and resources to your education. Secondly, do not expect immediate results, becoming a blockchain developer is not a magic pill.

希望您在读完本文后,能组建一套装备来助你展开区块链的旅程。如果你认真的想成为一名开发者,这里先给你打个预防针:第一,学习区块链很花时间,你需要投入你的时间和资源来学习。第二,别指望速成,成为区块链开发人员不是一朝一夕的事。

So, having said that, let’s start your journey.

那,说了这么多,让我们开始吧。

How To Become A Blockchain Developer: Crash Course!

区块链开发指南!

Milestone #1: Understanding The Basics

里程碑 1:基础知识

One of the biggest hurdles with anything as new and revolutionary, such as the blockchain technology, is familiarizing oneself with various concepts integral to the system.

要理解像区块链——这种新的革命性事物——的最大障碍,就是熟悉该系统的各种概念。

If you are a beginner, then there are certain terms that you need to be familiar with:

如果你是初学者,那么以下概念需要你熟知:

  • Blockchain: The blockchain is a chain of blocks where each block contains data of value without any central supervision. It is cryptographically secure and immutable.

  • 区块链: 区块链是一系列区块组成的链表。每一个区块包含着数据,这些数据并非被某个中央系统监管。数据是加密的并且不可改变。

  • Decentralized: Blockchain is said to be decentralized because there is no central authority supervising anything.

  • 分散: 区块链是分散的,是因为并没有一个中央权威做任何监督。

  • Consensus Mechanism: The mechanism by which a decentralized network comes to a consensus on certain matters.

  • 协商机制: 该机制是说这个分散的网络能协商讨论一些事情,并最终达成共识。

  • Miners: Users who use their computational power to mine for blocks.

  • 矿工: 消耗计算能力来发掘区块的人。

It could be advisable to learn more about these terms that are widely used in the crypto-sphere. It is highly recommended that you go through our comprehensive glossary. It is important to learn these basic terms otherwise you will be very lost further on in your education. Now, up next, it is time to educate yourself some more on the technical aspects of the blockchain.

更明智的做法是从密码领域中深入学习以上术语。强烈建议你过一遍我们的综合术语表。学习这些基本术语十分重要,不然你会在未来的学习中不知所措(译者注:连老师讲的什么都听不懂)。好,接下来该学习更多关于区块链技术方面的知识了。

If you are interested in the technical aspects of how to create a fin-tech application on top of the Blockchain then you should definitely learn the ins and outs of cryptoeconomics. Most developers are usually well-versed in the “crypto” part of the equation but their knowledge of the “economics” part is extremely lacking.

如果对基于区块链做一些金融科技应用感兴趣,那你一定要学透密码经济学。大部分开发者通晓上文的“密码”,不过对于另一半“经济学”的知识则十分缺乏。

This difference in knowledge is extremely apparent when you study some of these ICOs floating around. It is very obvious to see that the economics side of their ICO’s are not well thought out.

这种知识上的差异造成的影响,在你研究诸如首次币发行这类概念时会很明显。君不见很多数字货币的首次币发行,在经济学方面都没有经过深思熟虑。

So, in light of that, it can be a good idea to read up a bit on economics and have a general idea of it.If you want to learn about cryptoeconomics in general, then you may checkout our article here.

所以,学点经济学,对经济学有个总的概念是个好主意。如果你想简要学习密码经济学,可以看这篇文章

If you are intrigued by the cryptography specifically and want to know how signatures work and what public key cryptography means, then read this.

如果你对密码学十分感兴趣,而且想了解签名的原理、公钥加密技术的含义,那么读这篇文章

After that, it is highly recommended that you understand how bitcoin works. Bitcoin is the most widespread, finest and one of the more elegant applications of the blockchain technology. You can even call it the finest example of what the blockchain technology can achieve purely because of the impact that it has had.

之后,十分建议你了解一下比特币是如何运行的。比特币是最好、最广泛、最优雅的区块链应用之一。你甚至可以称之为区块链技术能实现的最好的样例,因为它真的是太有影响力了。

So, it is advisable that you read Satoshi Nakamoto’s whitepaper of bitcoin. You can find it over here. Now that completes the first milestone.

所以,最好去阅读中本聪的比特币白皮书吧。可以在这里读。然后第一个里程碑就结束了。

Let’s check out the action steps that you need to take over here:

作业

  • Get acquainted with the various terms and lexicons.
  • 熟悉各种术语和词汇
  • Read up on the more technical aspects of the blockchain.
  • 阅读大量区块链技术方面的文章
  • Read the bitcoin whitepaper.
  • 阅读比特币白皮书

Milestone #2: Learn How The Process Works

里程碑 2:学习运行机理

It is pretty surprising to see how many budding “developers” have not had any real world first-hand experience with cryptocurrency at all. How can you possibly innovate and improve upon a platform when you have not used it even once?

令人吃惊的是,大量的新手“开发人员”从来没真正的亲身使用过加密货币。如果你连一次都没用过,何谈对其进行创新与改进呢?

It Is strongly recommended that you start getting acquainted with the system today.

强烈建议你今天就开始熟悉这套系统。

Go to Coinbase or any other exchange that you are comfortable with or is accessible in your country and buy some coins. You don’t need to create an extensive portfolio straightaway, just buy a few coins and see how the whole process works.

Coinbase 或其他任何你习惯的、能访问的交易网站,买点币。你不需要构建广泛的投资组合,就买几个币感受下整个流程。

It is extremely straightforward. Since you are not going to be buying a lot of coins then simply use a basic online wallet.

按最简单的来。既然你也不是要买一堆币,那就用的基本的在线钱包就行。

These wallets are the easiest to use among all. The creation is super simple because it’s basically creating your own account on any of the exchange services. Furthermore, you can access this wallet from any server or any device in the world as long as it is connected to the net. Having said that, there is one big problem when it comes to online wallets. Your private key is going to be saved on another server. This is basically like serving up your key to hackers on a silver platter. Do NOT use online wallets to store huge amounts of your money. Store the bare minimum that you need for exchange purposes.

区块链货币钱包是最容易使用的。创建钱包十分简单,因为基本上都是将你的帐号建立在交易服务网站上。此外,只要连接上了网络,你就可以从任何服务器或任何设备来访问你的钱包。话虽如此,在线钱包却有一个大问题。你的私钥是被储存在另一台服务器的,这基本上就是将你的密钥拱手相送给黑客了。不要 使用在线钱包储存大额财产,只储存你需要兑换的最小值即可。

As you create an extensive portfolio, you must learn how to utilize cold wallets to store your money. You can learn how to do so here. Later on, if you create your ICO then you MUST know how wallets and, in particular, multi-sig wallets work.

当你有了一个广泛的投资组合后,你必须学习如何利用冷钱包来储存你的财产。你可以在这里学习如何做。之后,如果你打算做首次币发行,那你必须要懂钱包,特别是多重签名钱包的工作机制。

We are bringing this section to a close here, the tough part starts from the next milestone.

本节就介绍到这里,下个里程碑开始要提高难度了。

You action steps are here:

作业:

  • Learn how the exchanges work.
  • 学习交易所如何工作的。
  • Get acquainted with wallets.
  • 熟悉使用钱包。

Milestone #3: Let’s get coding!

里程碑 3:开始编码!

As a blockchain developer, you will face tons of challenges in the back-end. Creating and maintaining a public blockchain is not easy because of a number of reasons.

作为一名区块链开发者,你会在后台开发遇到很多挑战。有各种各样的原因,使得创建和维护一个公共的区块链系统并不容易。

(Before we continue, a huge shoutout to David Schwartz for his keynote address regarding C++ use in blockchain software development in CPPCON 2016.)

(在我们继续之前,来看看 2016 年的 CPPCON 中,David Schwartz 在他的关于用 C++ 开发区块链的主题演讲上是怎么说的。)

YouTube视频

  • Reason #1: Security
  • 原因 1:安全

Blockchains, as David Schwartz puts it, should be fortresses. Firstly, the code is public and open for all to see. Anyone can look at the code and check for bugs and vulnerabilities. However, unlike other open code resources, the downside of finding vulnerabilities on blockchain code is massive. Any programmer can hack in and get away with potentially millions and millions of dollars. Because of these legitimate security concerns, development on blockchain is usually very slow.

正如 David Schwartz 所说,区块链应当是一座堡垒。首先,代码公开谁都能看。任何人都可以查看代码检查 Bug 和漏洞。然而这并不像其他的开源代码,因找到区块链系统的漏洞,而造成的不利影响往往很严重。任何程序员都可以侵入该系统、掠走数百万美元然后逃之夭夭。正因为这些安全上的考量,使得区块链开发往往很缓慢。


  • Reason #2: Resource Management
  • 原因 2:资源管理

It is important to keep pace with the network. You cannot fall too far behind and not keep up with all the network demands. You should be well equipped to handle remote and local queries.

跟上网络的发展步伐是很重要的。你不能落后太远,以至于跟不上网络的需求发展。你应当具备处理远程和本地查询的能力。


  • Reason #3: Performance
  • 原因 3:性能

The blockchain must always perform at its highest possible capabilities, but for that to happen the language chosen must be extremely versatile. The thing is that there are certain tasks in the blockchain which are parallelizable whilst there are some tasks which can’t be done in parallel.

区块链总应当以其最高性能指标来运行,不过为了达到这个目标,用来开发的编程语言必须是很全能的。因为有些区块链的任务要求并行执行,而还有一些任务必须按顺序执行。

A good example of “parallelizable” task is digital signature verification. All that you need for signature verification is the key, transaction and the signature. With just three data you can conduct verifications in a parallelized manner.

关于“并行”任务,数字签名验证就是个好例子。验证一个签名,你需要:密钥、交易还有签名。只要三种数据你就能以并行的方式执行验证操作。

However, not all the functions on a blockchain should be done that way. Think of transaction execution itself. Multiple transactions can’t be executed in parallel; it needs to be done one at a time to avoid errors like double spends. Some languages are good at parallel operations while some are good in non-parallel operations.

然而,并非所有区块链的功能都应当并行执行。考虑交易执行本身。复数的交易行为不可以被并行执行;他们需要保证在同一时间只能执行一个交易,这样才能避免类似双重扣款这样的错误。有些语言擅长并行操作,另一些语言擅长非并行操作。


  • Reason #4: Isolation
  • 原因 4: 隔离状态

What is deterministic behavior?

什么是可确定的行为?

If A + B = C, then no matter what the circumstances, A+B will always be equal to C. That is called deterministic behavior.

如果 A+B=C,那么不论在任何情形下,A+B 都总是等于 C。这就是可确定的行为。

Hash functions are deterministic, meaning A’s hash will always be H(A).

哈希函数也是一种可确定性的行为,这意味着值 A 的哈希结果总是等于 H(A)。

So, in blockchain development, all transaction operations must be deterministic. You cannot have a transaction that behaves one way and then behaves another way the next day. Similarly, you cannot have smart contracts that work in two different ways on two different machines.

所以,在区块链开发中,所有的交易行为都必须是可确定的。你不能说一个交易今天执行是一个套路,明天执行又是另一个套路。同样的,一个智能合约不能在两个不同的机器上有着不同的运行效果。

The only solution to this is isolation. Basically, you isolate your smart contracts and transactions from non-deterministic elements.

唯一的解决方案就是隔离状态。最起码,你要把智能合约和交易逻辑与其他非确定的元素隔离开。

There are some languages which fulfill most of these needs. If you are a blockchain developer, then you definitely need to have some basic knowledge of C++ and JavaScript.

有一些编程语言满足了以上大部分需求。如果你是一个区块链开发者,那么你绝对需要对 C++ 和 JavaScript 有基本的知识

While C++ may seem a little outdated, the truth is that it wonderfully satisfies all the functionalities that we have described above. In fact, Satoshi Nakamoto wrote the Bitcoin source code in C++.

可能 C++ 看上去有点过时,实际上它非常符合以上我们描述的功能。中本聪其实就是用 C++ 编写的比特币源代码。

Along with HTML and CSS it is one of the three core technologies in World Wide Web Content Production. Javascript is usually used to create highly interactive web pages.

JavaScript,HTML 和 CSS 一样,是开发万维网产品的三项核心科技。JavaScript 通常用于创建高互动性的 Web 页面。

So, now we will see how to create a very simple blockchain using Javascript.

所以,接下来我们将看到如何用 JavaScript 来创建一个非常简单的区块链。

Huge shoutout to savjee.be for the content below.

以下内容转载自 savjee.be

How do we make a block? What does a simple block consist of? In our simple cryptocoin that we are going to make (Let’s call it “BlockGeeksCoin”), each block will have the following pieces of information:

如何创建一个区块?一个简单的区块由什么组成?我们将要开发一种简单的加密货币(就叫“BlockGeeksCoin"吧),其每一个区块将包含下列信息:

  • Index: To know the block number.
  • 索引: 本区块的编号。
  • Timestamp: To know the time of creation.
  • 时间戳: 本区块的创建时间。
  • Data: The data inside the block.
  • 数据: 我们要在区块中储存的数据。
  • Previous Hash: The hash of the previous block.
  • 前序哈希值: 前序区块的哈希值。
  • Hash: The Hash of the current block.
  • 哈希值: 本区块的哈希值

Before we continue. You need to understand certain terms that we are going to use in our program:

在我们继续之前,你需要理解一些接下来 JavaScript 程序中用到的术语:

  • This: The “this” keyword is invoked inside a function and enables you to access the values inside a specific object that calls that particular function.

  • This: 你调用了一个对象的一个函数,在该函数中可以使用“this"关键字,然后可以通过该关键字访问该对象的各种属性和其他函数。

  • Constructor: A constructor is a special function which can help create and initialize an object within a class. Each class is restricted to only one constructor.

  • Constructor: constructor (构造函数)是一个特殊的函数,能帮我们创建且初始化一个类的对象。每一个类都要求只能有一个该函数。

Now that that’s done, let’s start making our block.

说完了,开始制作我们自己的区块吧!

Creating the Block

创造区块

const SHA256 = require("crypto-js/sha256");   class Block  {      constructor(index, timestamp, data, previousHash = '')  	{  		this.index = index;  		this.previousHash = previousHash;  		this.timestamp = timestamp;  		this.data = data;  		this.hash = this.calculateHash();  	}   	calculateHash()  	{  		return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString();  	}  } 

Code Analysis

代码分析

Ok, so this right here is out a block. So, in the first line of the code, we called the crypto-js library because the sha256 hash function is not available in JavaScript.

好,这就是一个区块了。那么代码第一行,我们引入了 crypto-js 库,因为 JavaScript 并没有内置 sha256 哈希函数。

Next, we invoked a constructor inside the class to call for objects which will have certain values. The thing that probably catches your eye is the calculateHash() function. Let’s see what exactly is it doing.

接下来,该类的构造函数里为很多属性进行了赋值。你肯定注意到下面的 calculateHash() 函数了,咱们来看看它具体干什么的。

In a block, we take all the contents and hash them to get the hash of that particular block. We are using the JSON.stringify function to turn the data of the block into a string to hash it.

在一个区块里,我们将所有内容汇聚在一起,然后对其取哈希值,这就是该区块的哈希值。我们使用 JSON.stringify 函数来将区块的所有数据转换成字符串,然后取哈希值。

Ok, so we have the block ready and good to go. Now let’s connect the blocks together into a blockchain.

好的,我们第一个区块已经准备好了。接下来我们将多个区块连成一条区块链。

Creating the blockchain: Becoming A Blockchain Developer

创建区块链:成为一名区块链开发者!

class Blockchain {     //Section 1 Genesis block creation     // 第一: 生成创世区块 	 constructor()  	{  		this.chain = [this.createGenesisBlock()];  	}  	createGenesisBlock()  	{ 		return new Block(0, "01/01/2017", "Genesis block", "0");  	}       //section 2 adding new blocks     //第二:添加新的区块 	getLatestBlock()  	{  		return this.chain[this.chain.length - 1];  	}  	addBlock(newBlock) {  		newBlock.previousHash = this.getLatestBlock().hash;  		newBlock.hash = newBlock.calculateHash();  		this.chain.push(newBlock);  	}       //section 3 validating the chain     //第三:验证链条 	isChainValid()  	{  		for (let i = 1; i < this.chain.length; i++) 		{  			const currentBlock = this.chain[i];  			const previousBlock = this.chain[i - 1];  			if (currentBlock.hash !== currentBlock.calculateHash()) {  				return false;  			}  			if (currentBlock.previousHash !== previousBlock.hash)  			{  				return false;  			}  		}  		return true;  	}  } 

Code Analysis

代码分析

Ok, so a lot of things are going on in the chain above, let’s break it down into sections.

好,上面的链条定义了好些东西,咱们来一点一点分析。


  • Section 1: The Genesis Block
  • 第一:创世区块

What is the genesis block?

什么是创世区块?

The genesis block is the first block of the blockchain, and the reason why it is special is that while every bock points to the block previous to it, the genesis block doesn’t point at anything. So, the moment a new chain is created, the genesis block is invoked immediately.

创世区块是一个区块链系统的第一个区块,它的特殊之处在于它不指向任何前序区块。除此之外任何其他的区块都要指向一个特定的前序区块的。所以,当一个新的链条产生时,创世区块也会立即产生。

Also, you can see a “createGenesisBlock()” function wherein we have given the data of the block manually:

另外你看函数“createGenesisBlock()”,我们给它手动赋值了。

createGenesisBlock()  {     return new Block(0, "01/01/2017", "Genesis block", "0");  }  

  • Section 2: Adding The Blocks
  • 第二:添加区块

Firstly, we will need to know what the last block in the blockchain currently is. For that we use the getLatestBlock() function.

首先,我们需要知道这个链条目前最后一个区块是什么。所以我们定义了 getLatestBlock() 函数。

getLatestBlock()  {      return this.chain[this.chain.length - 1];  }  

Now that we have determined the latest block, let’s see how we are going to add new blocks.

现在我们能定位到最后一个区块了,来看看如何添加新区块。

addBlock(newBlock)  {     newBlock.previousHash = this.getLatestBlock().hash;      newBlock.hash = newBlock.calculateHash();      this.chain.push(newBlock);  }  

So, what is happening here? How are we adding the blocks? How are we checking if the given block is valid or not?

这里都发生了什么?我们怎么添加区块的?我们怎么知道添加的区块是否合法?

Remember the contents of a block? A block has the hash of the previous block right?

还记得区块的内容么?一个区块不是有前序区块的哈希值么?

So, what we are going to do here is simple. Compare the previous hash value of the new block with the hash value of the latest block.

所以这里做的其实很简单。比较新区块的前序哈希值和链条最后一个区块的哈希值即可。 (译者注:其实这里的 addBlock 函数并没有做验证,它只是自动将新区块的前序哈希设置为链条最后一个区块的哈希值。可以理解为使用该函数添加的区块,都将自动转换为合法的区块。)

Image Courtesy: Lauri Hartikka medium article

图片来源:Lauri Hartikka medium article

If these two values match, then this means that the new block is legit and it gets added to the blockchain.

如果这两个哈希值匹配,那这意味着新区块是合法的,可以被添加到区块链中。


  • Section 3: Validating the Chain
  • 第三: 链条验证

Now, we need to check that nobody has been messing with our blockchain and that everything is stable.

现在我们需要检查没有人搞乱我们的区块链系统,保证一切稳定。

We are using the “for” loop to go from the block 1 to the last block. Genesis block is block 0.

我们使用“for”语句,从第一个区块遍历到最后一个区块。创世区块是第零个。

isChainValid()  {  	for (let i = 1; i < this.chain.length; i++) 	{  		const currentBlock = this.chain[i];  		const previousBlock = this.chain[i - 1];          //In this part of the code we are defining two terms, current block and previous block.  And now we are simply going to find the hash of these two values.         //这部分代码定义了两个术语:当前区块和前序区块。接下来只要比较这两个区块的哈希值。 		if (currentBlock.hash !== currentBlock.calculateHash()) {  			return false;  		}  		if (currentBlock.previousHash !== previousBlock.hash)  		{  			return false;  		}  	}  	return true;  }  

If the “previousHash” of the current block is not equal to the “Hash” of the previous block, then this function will return False, else it will return True.

如果当前区块的“前序哈希值”不等于前序区块的“哈希值”,那么函数将返回 false,否则会返回 true

Using the blockchain

使用区块链

Now, we are going to finally use the blockchain to create our BlockGeeksCoin.

现在我们终于要使用区块链来生产我们的 BlockGeeksCoin 了。

let BlockGeeksCoin = new Blockchain();  BlockGeeksCoin.addBlock(new Block(1, "20/07/2017", { amount: 4 }));  BlockGeeksCoin.addBlock(new Block(2, "20/07/2017", { amount: 8 })); 

And that’s it!

这就行了!

So what happened here?

到底发生了什么?

We created a new cryptocurrency based on the blockchain and named it BlockGeeksCoin. By invoking this new object, I activated the constructor, which in turn created the Genesis block automatically.

我们创建了一个新的基于区块链的加密货币,称之为 BlockGeeksCoin。通过创建这个新对象,我激活了链条的构造函数,然后自动创建了创世区块。

We simply added two more blocks to it and gave them some data.

然后我们添加了两个新的区块,赋给了它们一些数据。

It is that simple.

就这么简单。

(Thank you savjee.be for the amazing and simple explanation.)

感谢 savjee.be 提供了如此出色且简明的解释

That’s it for this milestone. Let’s look at the action steps. It is very simple but it definitely isn’t easy:

以上就是这个里程碑的内容了。下面布置作业,不多但也要花些功夫的:

  • Get educated in one of the many blockchain friendly languages like C++, Javascript, C#, Go etc.
  • 学习一种适合开发区块链的语言,比如 C++, JavaScript, C#, Go 等等。

Milestone #4: Get Educated On Smart Contracts

里程碑 4: 学习智能合约

How do you define a smart contract?

你如何定义一个智能合约?

According to Wikipedia, a smart contract is “a computer protocol intended to facilitate, verify, or enforce the negotiation or performance of a contract”. While it was first proposed by American cryptographer Nick Szabo in 1996, Ethereum is often credited with popularizing the concept and making it mainstream.

根据维基百科的说法智能合约是“旨在促进、核实或加强合同谈判或履行的计算机协议"。虽然本概念是由美国密码学家 Nick Szabo 于 1996 年第一次提出,但通常认为是 以太坊 以太坊 将此概念推广并成为主流。

You can learn more about smart contracts in our in-depth guide here.

你可以看我们的深入指南来学习智能合约更多的知识。

So, what are the desirable properties that we want in our smart contract?

所以我们希望一个智能合约具有哪些性质呢?

Anything that runs on a blockchain needs to be immutable and must have the ability to run through multiple nodes without compromising on its integrity. As a result of which, smart contract functionality needs to be three things:

任何运行在一个区块链系统上的东西,都必须是不可变的,数据流过任何节点也不能对数据的完整性有半点妥协。因此,智能合约要有以下三点性质:

  • Deterministic.
  • 确定性
  • Terminable.
  • 可终止
  • Isolated.
  • 隔离性

Feature #1: Deterministic

性质 1:确定性

A program is deterministic if it gives the same output to a given input every single time. Eg. If 3+1 = 4 then 3+1 will ALWAYS be 4 (assuming the same base). So when a program gives the same output to the same set of inputs in different computers, the program is called deterministic.

一个具有确定性的程序,只要你给他同样的输入,每次都会输出同样的结果。例如:如果 3+1 = 4 那么 3+1 将总为 4(假设进制不变)。所以如果给予一个程序同样的输入,不论何时该程序都会输出同样的结果,那么我们称该程序具有确定性。

There are various moments when a program can act in an un-deterministic manner:

很多时候,程序会表现出不确定性:

  • Calling un-deterministic system functions: When a programmer calls an un-deterministic function in their program.
  • 调用不确定系统的函数: 当程序员调用另一个不确定性函数的时候。(译者注:例如某些多线程、并发函数)
  • Un-deterministic data resources: If a program acquires data during runtime and that data source is un-deterministic then the program becomes un-deterministic. Eg. Suppose a program that acquires the top 10 google searches of a particular query. The list may keep changing.
  • 不确定的数据资源: 如果一个程序在运行时获取一个不确定的数据资源时,那么这个程序就变成不确定性程序了。例如:想象一个程序要获取 Google 搜索的前十条数据,这数据肯定是不确定的。
  • Dynamic Calls: When a program calls the second program it is called dynamic calling. Since the call target is determined only during execution, it is un-deterministic in nature.
  • 动态调用: 当一个程序调用第二个程序时,称之为动态调用。因为被调用对象是在运行时才确定的,所以实质上是不确定的。

Feature #2: Terminable

性质 2:可终止

In mathematical logic, we have an error called “halting problem”. Basically, it states that there is an inability to know whether or not a given program can execute its function in a time limit. In 1936, Alan Turing deduced, using Cantor’s Diagonal Problem, that there is no way to know whether a given program can finish in a time limit or not.

在数学逻辑中有一种称之为“停止问题”的错误。简单说,该问题指出无法知道给定的程序能否在时限内执行其功能。在 1936 年, 阿兰图灵从康托对角线问题推出,没有办法知道给定的程序能否在时限内完成任务。

This is obviously a problem with smart contracts because, contracts by definition, must be capable of termination within a given time limit. There are some measures taken to ensure that there is a way to externally “kill” the contract and to not enter into an endless loop which will drain resources:

对于智能合约来说,这毫无疑问是个问题,因为根据定义,合约必须能在有限的时间内终止。有一些方法可以保证能从外部“杀掉”合约,使其免于进入无限循环,耗尽资源:

  • Turing Incompleteness: A Turing Incomplete blockchain will have limited functionality and not be capable of making jumps and/or loops. Hence they can’t enter an endless loop.
  • 图灵不完备性质: 一个图灵不完备的区块链,只提供有限的功能,不能跳跃或循环。因此这种区块链不会进入无限循环。
  • Step and Fee Meter: A program can simply keep track of the number “steps” it has taken, i.e. the number of instructions it has executed, and then terminate once a particular step count has been executed.Another method is the Fee meter. Here the contracts are executed with a pre-paid fee. Every instruction execution requires a particular amount of fee. If the fee spent exceeds the pre-paid fee then the contract is terminated.
  • 计步和计费: 一个程序可以记录它消耗的“步数”。比如它执行的指令数,达到特定的步数后就终止。另一个方法叫计费。该合约使用预付费来执行,每条指令都要消耗特定的费用。如果预付费用完了那么合约结束。
  • Timer: Here a pre-determined timer is kept. If the contract execution exceeds the time-limit then it is externally aborted.
  • 计时器: 有一个预先设置的计时器,如果合约执行超过了时限,则自动从外部终止。

Feature #3: Isolated

性质 3:隔离性

In a blockchain, anyone and everyone can upload a smart contract. However, because of this the contracts may, knowingly and unknowingly contain virus and bugs. If the contract is not isolated, this may hamper the whole system. Hence, it is critical for a contract to be kept isolated in a sandbox to save the entire ecosystem from any negative effects.

在一个区块链中,任何人都可以上传一个智能合约。然而由于这一点,合约可能有意无意的包含着病毒和 Bug。如果一个合约没有隔离性,那可能会影响到整个系统。因此将合约隔离在单独的沙箱中来保护整个生态远离任何负面效应是至关重要的。

Now that we have seen these features, it is important to know how they are executed. Usually the smart contracts are run using one of the two systems:

好我们看到这些性质了,了解它们如何运行是很重要的。通常智能合约是运行在下面两个系统之一上的:

  • Virtual Machines: Ethereum uses this.
  • Virtual Machines: 以太坊 使用这个。
  • Docker: Fabric uses this.
  • Docker: Fabric 使用这个。

Let’s compare these two and determine which makes for a better ecosystem. For simplicity’s sake, we are going to compare Ethereum (Virtual Machine) to Fabric (Docker).

让我们比较一下这两个,看看哪一个能创造一个更好的生态系统。为了简单起见,我们将比较 以太坊(Virtual Machines)和 Fabric (Docker)。

If you are interested in Ethereum development specifically then it is important that you learn solidity as well.

如果你对 以太坊 开发感兴趣,那么对 solidity 的学习也很重要。

For anyone who wants learn how to make DAPPs (Decentralized Applications) or get into the ICO game, learning Solidity is an absolute must. We already have a detailed guide to it which you can read here. However, here we are going to give you a basic overview. Solidity was developed by Gavin Wood, Christian Reitwiessner, Alex Beregszaszi, Yoichi Hirai and several former Ethereum core contributors to enable writing smart contracts on blockchain platforms such as Ethereum.

对于想要学习如何使用 DAPPs(分散应用程序)或者想参与首次币发行的人,一定要好好研究 Solidity 。我们已经有详细的指南,可以来这里读。这里我们给你一个基本的概述。Solidity 是由 Gavin Wood, Christian Reitwiessner, Alex Beregszaszi, Yoichi Hirai 和几位前 以太坊 核心贡献者开发的,用于在类似 以太坊 这样的区块链平台上编写智能合约。

Solidity is a purposefully slimmed down, loosely-typed language with a syntax very similar to ECMAScript (Javascript). There are some key points to remember from the Ethereum Design Rationale document, namely that we are working on a stack-and-memory model with a 32-byte instruction word size, the EVM (Ethereum Virtual Machine) gives us access to the program “stack” which is like a register space where we can also stick memory addresses to make the Program Counter loop/jump (for sequential program control), an expandable temporary “memory” and a more permanent “storage” which is actually written into the permanent blockchain, and most importantly, the EVM requires total determinism within the smart contracts.

Solidity 是一种刻意简化的、弱类型语言,语法很类似 ECMAScript (JavaScript)。还记得一些 以太坊 设计原理文档上的关键点,说我们工作在一个32字节的指令长度的堆栈内存模型上,EVM(以太坊 Virtual Machine)给我们提供访问程序的“堆栈”的能力,就像是寄存器空间一样,我们可以将内存地址贴进去使得程序计数器可以循环、跳转(程序顺序控制)。有一个可扩展的临时“内存”还有更大的永久“储存”也就是实际向区块连永久写入。最重要的是,EVM 要求总决定权在智能合约内。

If you are interested in learning solidity then you can check our in-depth course here.

如果你对学习 Solidity 感兴趣,那可以看这篇深入教程。

So, let’s see the action steps now:

下面留作业:

  • Understand how smart contracts work.
  • 搞明白智能合约怎么工作的。
  • (Optional for Ethereum developers) Learn Solidity.
  • (如果你是 以太坊 开发者) 学习 Solidity。

Milestone #5: Be In The Mix

里程碑 5:融入

One of the most important things that you can do as a budding developer is to constantly stay in the mix.

作为一个新人,最重要的是融入整个区块链开发的世界。

Go and join the Reddit forums, GitHub pages, and StackExchange and connect with other developers and always be on the lookout for any news regarding the technology.

去加入 Reddit 论坛、GitHub 页面,StackExchange 等等地方,多接触其他开发者。始终对新技术保持敏感。

Along with that, it will be helpful for you to know what people look for in blockchain developer. What qualities are companies looking for when they are looking to hire? You can find that information here.

同时,去了解哪些人需要区块链开发人员,哪些特点是公司招聘所关注的。这些都对你会有用处。你可以在这里找到更多相关信息。

This information can be very useful in you fine-tuning your skills enough to appeal to the companies.

这些信息在你完善你的技能来满足公司需求时非常有用。

Conclusion

结论

So, this is a rough roadmap for you and your journey to becoming a blockchain developer. This alone won’t be enough, of course, you will need to show your own initiative and always be in the mix.

那么这就是成为一个区块链开发人员的一个粗略路线图。仅仅读完这篇文章当然是不够的,你需要发挥你的主观能动性,时刻参与其中。

If you are looking for a resource of information on blockchain development then click here.

如果你在找关于区块链开发的资源可以点这里。

We wish you all the best on your journey!

祝您一路顺风!

本文发表于2018年01月11日 16:32
(c)注:本文转载自https://my.oschina.net/zgldh/blog/1605388,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除.

阅读 2077 讨论 0 喜欢 0

抢先体验

扫码体验
趣味小程序
文字表情生成器

闪念胶囊

你要过得好哇,这样我才能恨你啊,你要是过得不好,我都不知道该恨你还是拥抱你啊。

直抵黄龙府,与诸君痛饮尔。

那时陪伴我的人啊,你们如今在何方。

不出意外的话,我们再也不会见了,祝你前程似锦。

这世界真好,吃野东西也要留出这条命来看看

快捷链接
网站地图
提交友链
Copyright © 2016 - 2021 Cion.
All Rights Reserved.
京ICP备2021004668号-1