Translation of Antshares Brand Strategy Announcement (pt. 2)

in #cryptocurrency7 years ago

Detailed look at NEO ($ANS) technology with Ethereum comparison matrix. In this part 2 of the series, CTO Erik Zhang breaks it all down for us. Catch up on part 1 here if you missed it.

neo-cto-preso.jpg

2:39:00

Hi everyone. I will introduce to you NEO smart contract and as said earlier it’s evolved from Antshares brand. I will explain what NEO’s benefit is and the power of its smart contracts.

First of all I want to explain to everyone what a smart contract is. It’s an old concept actually. Back in 1994, a cryptographer brought up the concept of smart contract. In a nutshell, a smart contract is a contract that can be enforced by computer. The term of the contract can be executed automatically by computer. Such contract is a smart contract. What does it mean by “term of the contract can be executed automatically by computer?” Regularly a contract that formed between two persons might be recorded using paper and signed by them. After the signing the contract is in effect. The terms of the contract are enforced by human being, and not by machine. Even if we digitized it using as a word document and digitally signed as a digital contract, it still needs to be enforced by human. So smart contract doesn’t only digitalize a contract, but also convert it into a program so that terms of the contract can be automatically executed by computers. So this is smart contract.

2:40:54

Here’s an example. An example from real life, as the concept has been around for a long time. The example is vending machine. It’s a real story, I was taking a train. When I was at train station, I was thirsty, so I want to buy a can of coke. The price was CNY4 for 1 can. So at the vending machine I insert coins. After 4 coins there’s no coke coming out. So I hit the refund button and it returned 2 coins. I was thinking it’s malfunctioning, and inserted those 2 coins back.

Still no coke.

Then after it only returned 1 coin after I hit the button. So I loss 3 coins, and was very unhappy about it. In the end I still got the coke, as I used WeChat to pay another CNY4. So I payed CNY7 for a can of coke. Later I examined the vending machine and found a small paper stacked to it. It said: “Don’t use before 8am or after 6pm as someone might maliciously block the coin insert to disable the machine.” The vending machine is a smart contract. It will execute the order of purchasing drinks. So you insert coins, it calculate the prices and give you corresponding goods. I got the coke paying a price way over the listing price which means the contract is executed correctly. And the reason for that is some one maliciously blocked the coin insert. Which means the smart contract is maliciously modified. And that’s why a concept originate from 94 yet still not widely apply to everyday life, because the lack of a secure and reliable execution environment for the smart contract, as it can be easily modified by other people.

2:42:53

What is blockchain? Blockchain naturally has these properties: modify-prohibited, traceable, fair, open and transparent. So it can naturally provide a secure and reliable execution environment for the smart contract. So that’s why it’s good combination for smart contract and blockchain.

We cannot talk about blockchain and not talk about BitCoin. In bitcoin there’s a script system that can be considered the first occurrence of smart contract that based on blockchain. What’s the meaning of using blockchain as bitcoin’s smart contract?

I have two charts here. On the left side is the execution engine for bitcoin, used for executing smart contract. It provide a simple instruction set such as constant, constant instructions and conditional branch, even some stack operation as it’s a stack-based virtual machine. Also has string manipulation , logical operator, arithmetic operator and especially cryptology instructions as it use such function quite a lot.

What’s the purpose of all these? Its main purpose is account integrity. As we send some bitcoin from one address to another, we need others to verify the owner of the address, which running a piece of script. We run a smart contract, and it will verify the signing of the contract matches the public key or not. There are more complicated application such as multi-party signing. It may have a number of persons and need a part of them to sign a contract so they can transfer out a sum of money. That’s also in the bitcoin’s script system. The regular account and multi-party account are also known as standard contract or standard address. As their format are fixed. There are also non-standard address that can have customized authentication logic for your account. So that’s the smart contract in bitcoin.

2:45:24

But the blockchain that evolved around smart contract is not bitcoin, it’s ethereum. Bitcoin and ethereum are similar blockchain system, but ethereum optimized and enhanced around smart contract. There are several points. 1st one is it upgraded the smart contract system to Turing-complete. Once it’s Turing-complete, I can use it to describe any logic. So the terms of the smart contract can be very diverse unlike bitcoin, which can only describe simple logic. That’s point one.

2nd one is economic model, it introduced a new economic model. As it’s Turing-complete the logic can be anything, such as infinite loop, a program that will never end, and deploy it into the blockchain. It would be unrealistic for us to let it run on the blockchain. So when ethereum runs an instruction, it deduct a certain amount of ethereum. Once your balance reach 0, the program will terminate as you don’t have sufficient balance to keep it running. So that they introduced the new economic system to make sure that Turing-complete programs can be terminated. Also these part of fees will be awarded to miner to incentivize them to keep mining and maintain the network.

The last point. The ethereum provide a new feature to smart contract called persistent storage. It means the smart contract can save generated data to a storage area inside blockchain while running. It can be read while the program was running again. So that’s persistent storage. With this feature, one usage is data archiving. We can store some data in it. The 2nd usage is token issuing. We know that there are a lot of ICO project, and they are issuing their own token. And those tokens are implemented using persistent storage to store account and records. And that’s the system for token issuing.

2:48:15

So here’s our NEO. NEO not only has this Turing-complete smart contract system. And Da already introduced other two important part: one is digital assets, the other is digital identity. Since Da explained those already, I will only talk about smart contract in depth and what’s different in NEO’s smart contract.

It can be summarized in 3 points. 1st is certainty, as smart contract has very strong certainty. 2nd is high performance. Its execution will be very fast. 3rd is extensibility.

Here’s a comparison between NEO, ethereum and fabric hyperledger’s certainty aspect. Let’s divide the certainty to 3 part. 1st is contract interoperability. Interoperability means smart contract A can call smart contract B’s function, and use B’s result as data. All 3 platform has this ability. It’s a very common ability, but there’s some nuance. NEO limited the interoperability to static calling. Here we need to differentiate static calling and dynamic calling. A dynamic call can choose the target during runtime. A static calling can only target the function that was decided during coding.

This is quite a big difference. If I treat A as program entry and B as a function, and in dynamic calling, A can choose to call B or C or D. So if there’s a bug in B, I can upgrade it to C or D, so I don’t need to change A. It’s easy for the users as they only need to remember A. So it means smart contract can be hot patched and dynamically upgraded.

But there’s a downside, as upgrade is two edge sword. You may upgrade it to a better state or to a worse state. As a user, they can’t distinguish between what’s behind the scene when they using A, as it may call B or C to get better or worse result. And that’s a certainty on the user side. To prevent this, NEO remove dynamic calling during design stage, left only static calling. So when writing smart contract, you need to decide which contract to call. If you want to upgrade B, you will need to upgrade A too. That’s the 1st one.

2:51:41

The 2nd one is system call. For the most time, when a program runs for one time, the result is such, and runs 100 times, it will still be such. But there are exceptions. Such as a program that generate random numbers. Maybe now I runs it, it shows 2, but I may get 5 later. Other people may get different result as the result is random. Another example, accessing system time. Right now the result could be 11:00, later it may give me 11:05. So the result will change every time. So if these uncertain system call can be called from smart contract, what will be the consequence? The blockchain is a distributed system, every node has different aspect.

So if every node runs a program and produce different result, they can no longer reach an agreement. This kind of inconsistency is not allowed. So to run a smart contract on a blockchain system, it must remove all the uncertain system calls. So it’s completely excluded from NEO. Ethereum also don’t have system calls. This is a downside of fabric, it asks the developers to restrain themselves from calling uncertain system calls. It can be done, but it’s hard to guarantee. So that’s a downside.

The 3rd point is ability to access internet resources. If we allow a smart contract to access internet resources, it can be very convenient. As it can directly access the today’s stock price and to influence the conditional branches in smart contract. It’s very convenient, but the problem is different node access even the same URL can get different result. A simple example is when searching a keyword using Google, even everyone use the same keyword, but due to different IP addresses, results can be different. So the ability to access internet would bring uncertainty to smart contract. So we didn’t make it into NEO during design process. Ethereum also don’t have it, but fabric, again, has this ability which introduce uncertainty. So that’s a comparison on uncertainty.

2:54:38

The following is a comparison on performance. It’s still between these 3 platforms. The first thing is the deployment of the smart contracts. The performance is closely related to the execution environment.

NEO has a in-house smart contract virtual machine called NEOVM, ethereum has their own called EVM. Fabric use a mature product called Docker. Docker is not a virtual machine, it’s a resource quarantine technology. It’s used as a smart contract execution environment in fabric.

Again we divided it into three categories. 1st one is contract deployment. It’s millisecond level on NEOVM and EVM, but it’s a painful process in Docker and would take seconds. 2nd is contract loading. Contract loading is to load a contract from the blockchain and execute it.

It’s also a simple process in NEOVM and EVM as would took milliseconds. It again will be difficult for Docker and would took seconds. It’s a very big gap in performance. The last one is where Docker shines, it’s smart contract execution. Since Docker’s programs are running on physical machines, so it’s very fast. NEOVM and EVM are interpreter so it’s slower compared to Docker. It’s also a very big gap.

But no big deal, we can use JIT, Just-in-time compilation to optimize the performance, to reach almost the efficiency of physical machines. Even without JIT optimization, it’s ok since the programs on the blockchain are really short, the deployment and loading speed is more important than execution speed. Blockchain programs are not like real world programs taking megabytes of spaces and heavily relying on computing power. The smart contract on blockchain are only used for simple conditional operation so the execution time will be really short. So the execution time are not that important.

2:56:56

3rd comparison is about extensibility. Still between aforementioned 3 platforms. 1st point is the concurrency of contact execution. Can smart contracts on blockchain be executed concurrently? It depends. As we know, the smart contracts can access a private persistent storage, it can read/write some data. If the contract can only read/write its own data, then there’s no problem, as long as each different contracts access different data, then they are not related so they can run concurrently.

But smart contracts can call each others and one contract can be run multiple times. So when they call each other, one contract might access my data, and I might access other contracts’ data. If different contract could access same data, then you will have to execute them serially in order, and not concurrently. If you want to execute contract concurrently on blockchain, what could you do? You can use sharding. We can use two methods.

One is static sharding, which will be used by ethereum. It will divide those smart contracts into different shard, for example 256 shards, and put contracts into those shards. Concurrency can be achieved between different shards. But within a shard, contracts can only be executed serially. And contracts cannot call each other when they are not in the same shard. So when there’s no dependency, they can be executed concurrently.

So this is static sharding method. It’s not bad, but the downside is you have to plan for the sharding beforehand, as it cannot be changed after it’s done. NEO use the second method: dynamic sharding. The reason we can use dynamic sharding is because we only allow static calling. Static calling means while we are writing the contract, we already know what contract we are going to call and what data we are going to access. This is decided beforehand, not in runtime. Thus we can calculate the call numbers before we run it so we can calculate the dependency and dynamically sharding at runtime. Since it’s sharding at runtime, it can be very flexible. So it can adjust sharding to the performance at runtime to keep the performance at peak condition. Docker doesn’t support this.

2nd point is coupling, which also related the next point – portability. Coupling refers to the virtual machine’s dependency with blockchain node. Ethereum didn’t handle this very well, but docker excels, as docker doesn’t relate to blockchain technology. While fabric choose it as execution environment, it has very low coupling with blockchain system. Almost none coupling. You can port it to other blockchain or other non-blockchain product. But that’s not the case for EVM, as EVM coupled too many blockchain related instructions. For instance, it use an instruction for calculating contract’s consumption, another instruction for creating a new contract, yet another instruction for contract accessing data. That’s a very high level of coupling with blockchain, you can’t port the code to other system.

3:01:20

I just introduced NEO’s smart contract and its features. Now I will explain how can we develop contracts for it.

It’s very convenient. Visual Studio, and IDE. We can develop smart contract using VS. Since we just rebrand to NEO from Antshares, so someplace we still uses old branding. You can find our plugin in Visual Studio’s plugin store using keyword “anshares,” it can be used to write NEO smart contracts.

Once you download and installed it, you will find a smart contract template when creating new project. Once you created project using the template, it will show you are simple program which is a smart contract. We can see it only has one line of code, it will call a function named “stoage.put” which put data into your contract’s storage area. The data is store in key-value pair. Here the key is “hello” and the value is “world”. So it stores hello world into the storage area. You can delete this code from the template and code your own logic in C# or other languages.

We used C# in this example, but we are supporting more language in the future. In .net, we are supporting all the languages, C#, VB, F# are already fully supported. 2nd is Java, Java is one of the language that has the most developers, it’s also fully supported. So you can use Java to code NEO smart contracts. 3rd is Kotlin, which just recently recommend by Google to code for Android apps. We used to use Java, but now Google officially recommend using Kotlin. It’s also fully supported.

The uppers ones are all now fully supported. The lower ones are going to be supported in the future. 1st one is go, we are developing compiler for it so that you can write smart contract using go. JavaScript and python. And we are going to support more high level programming languages.

3:04:09

OK, here’s another set of comparison. A comparison between development environment. We just announced our support for those mainstream languages. The first row is high level languages.

Fabric is best in this area, since it’s using Docker, so it can support any language as long as you have a compiler for it. We support those mainstream languages that we announced. And we believe that we can cover 99% of developers by supporting those languages. I think that’s not bad.

Ethereum are not looking good in this area as it only support 4 language to write smart contracts. Also those 4 languages are created by them so quite a steep learning curve. And the most common one, solidity, is quite hard to learn. Community volume, as the total numbers of the developers. There are over tens millions of developers worldwide, since we are covering 99% of them, they can provide smart contract in our ecosystem. But for ethereum, solidity developers maybe in thousands, and that’s a small community volume.

The last one is the IDE, which indicate the easiness of the development. Since NEO is very portable, so we can easily integrate it with IDEs and use IDEs’ debugger to debug your code. Fabric has the same abilities. But Ethereum lacks support in this area.

3:05:50

Here’s a architecture map for NEOVM smart contract system. As we can see, on the upper left side, those are language compilers. They allow you to use familiar language to write smart contracts. After compilation, it will generate a program that can be run in the NEOVM. The VM provide some simple instructions. The VM which represented in the green box provide several instructions, one of them is quite interesting, called “interoperation service layer” invoke instruction.

Interoperation service layer is represent in the blue box on the right side. If you consider the green box(VM) as a CPU, then the blue box(ISL) can be viewed as a system bus which allows you to connect to different peripherals. We know that CPU doesn’t have too much functions, it can do some arithmetic and logic computations, but doesn’t connect to the internet. If you need a program in CPU to access the internet, you will need a network card. If you need to store some data, but the CPU cannot store data in itself, so you will need to connect a hard drive, then CPU can call functions in hard drive to store data. So the blue box as a system bus can connect to different services so that smart contract have different feature and ability.

Let’s focus on the text list on the right side. So our whole smart contract system contains development tools including IDE, compilers and development frameworks. Below is the execution environment, such as runtime, stack and interoperation service layer. So that’s the whole architecture.

3:08:22

Here’s another comparison. This one is on VMs. 1st let’s compare instruction set. NEOVM provides a simple instruction set, including arithmetic and logic operations, conditional branches and cryptology instructions. EVM provides a specialized instruction sets. It provides not only those NEOVM has, but also those I mentioned earlier, like the ones that’s coupled with blockchain. Dockers rely on the low level hardware to provide instruction set. For example if it’s running on an X86 computer, then it provides X86 instruction sets.

When it’s on ARM platform, then it’s ARM instruction set. The problem is it requires all the node on the blockchain to be one single architecture. You can’t have some x86 ones and some ARM ones, the smart contracts won’t work on this network. But Fabric can get around this because it’s aiming at alliance chains, in an alliance chain you can require alliance members to using same architecture for nodes and server. This is not possible in public chains, so they must have consistency in architecture.

3:09:48

2nd one is service. NEOVM provides are service layer, and different services can be plugged in. Docker also provide a similar mechanism, which is to use gRPC as an API. It allows smart contract to communicate with gRPC to access API at runtime. But EVM are providing services using instruction sets, and this will obstruct next point, which is function scalability. When I want to extend functions, it’s quite easy in NEOVM, you can just register a new service on interoperation service layer. Docker is the same, just add an API to gRPC. But if you want to add to EVM then it’s complicated. Think it as a computer, you want to add a function, just plug in an USB, but in EVM you must break down the computer, find the IC and solder some new chips on it and put it all back. That’s a lot of work, so it’s very hard to extend EVM’s functions.

3:11:05

What does NEO provides on Interoperation service layer? There’s 4 services. 1st one is blockchain ledger, this service allows smart contracts access all the blocks, transaction, accounts and their field during runtime. It can read any user’s balance and assets. 2nd one is digital assets, it only allow contracts at runtime to access and manage digital assets. 3rd one is smart contracts. You may wonder why provide a smart contract service to a smart contract? Our smart contracts can dynamically create smart contract, migrate and upgrade current contracts and even destroy the contracts. 4th one is persistency, this is very similar to Ethereum, which allows contract to read and write data, including deleting data. But there’s also some minor difference as I will talk about it later.

3:12:33

Let’s talk about digital assets first, yet another comparison. We will exclude Fabric, just NEO and Ethereum on digital assets. We know Ethereum has a lot of ICO projects, every projects will issue their own token. This is a very common feature, the Ethereum supports it well, NEO also supports it , because it can store contract data. But the second point, NEO also provides digital identities, which is not present in Ethereum. The reason is not they don’t want to, but it’s against their design goal. We know that Ethereum and Bitcoin are designed to have anonymous ,anti-censorship and decentralization. So it’s not necessary for them to provide a digital identity to expose the person behind it. NEO provides such feature, through a simple method – digital certificate, using existing KPI system, which we will have some upgrades for it.

3:13:43

When you have digital identities, we can do assets digitalization. Da said in his speech, assets digitalization is to map some assets from real physical world to blockchain. What’s the essence of this? The essence is credit.

For instance, bank is a strong credit organization, you deposit some money into the bank, they save it on their servers or accounting systems. This deposit is actually digital assets issued by bank. It’s different from the paper bill you deposited. Why is that? Let’s say the bank is closed or bankrupted, is there any use of your deposit? It’s just some data in the account. Assets digitalization is some credible entity using their own credit as warrant, make a promise about one to one exchange of digital assets and real life assets.

If this digital assets are recorded on blockchain, then it’s assets digitalization on blockchain. Since the essence is credit, it means identity. Only identity can provides credibility, anonymity is not creditable. We can only digitalize assets after we have digital identity. Since we have digital identity, we can support assets digitalization. Ethereum cannot support this, it can only issue tokens, which are generated on blockchain.

3:15:25

Then let’s compare persistent storage, again with Ethereum. 1st one is authentication of storage, that’s every contract has permission to access their own private storage area. Is there any way for other contracts to access my storage area? It’s also allowed. Ethereum has a simple solution, it provides two instructions, 1st one is named “call” , 2nd one is named “call code”. To use CALL, I can call a contract, and the contract in its context, can access its own storage area, when the execution returns, I continue my execution. The other one CALL CODE allows me to load a contract and load its code into my context and can access my storage area. So that’s how ethereum allows data access between contracts, but it’s not flexible enough. NEO provide a flexible mechanism: every contract can gain the read permission of their own storage area, and grant it to another contract called by it, like authorizing other contract to access its own storage area. The called contract can access its own storage area, and the storage area you as a caller granted it. Since the contracts are in a calling chain, it can access multiple contracts, every one on the calling chains can access others’ storage area as long as they have been granted permissions. It’s very flexible.

3:17:22

2nd one is contract migrations. In Ethereum, if a contract has a bug, and you want to modify it, you must create a new contract, but the data cannot be migrated. You have to let user to manually send the assets into the new contract, which is very difficult. But in NEO we provide a very simple contract migration feature, a contract can create a sub contract during runtime, at the same time move all the data to the new contract. This is contract migrations.

3:17:59

Last one is about the size of the storage. In Ethereum the data has a strict length limit of 256bit, which is 32 bytes, cannot be longer or shorter. If you want to save 1KB of data, you have to divide it into several 32 bytes, then save in different data records, very inconvenient. In NEO we don’t limit the length of data, but we charge by the length of data. The bigger your data, the more it costs. But it doesn’t have length limit, which is very convenient.

3:18:37

At last I have some sample contracts, which I already uploaded to GitHub. There are many samples, I will introduce 3 of them. 1st one is lock account, 2nd one is decentralized domain system, last one is token issuing.

This is the sample code from our GitHub. Let’s see the first one, lock account. This contract is very simple, 3 lines of code in total. Let me describe its usage. Usually for an account, its permission is very simple, I use a private key to sign a transaction, then send the transaction, others will verify my signature, once the verification passed then I have the ownership of this account and can freely use the money in this account. But in some situation, I may want to lock my account for a period of time, so that before the time reaches, no one can use the money inside my account. To achieve this, I need to add some code the this basic account. Let’s check the code.

First line, blockchain.getheight means when I call this function, it will return the height of the whole blockchain. The Current height is the latest blockchain’s height. Once I got the data, I pass the height to getHeader, and save the header of the blockchain to header variable. There are some properties in block header, one of them is time stamp, the time that block was generated. NEO will generate 1 block in every 15 seconds, so the timestamp in the block header may have some margin of error, but it will be less than 15 seconds so it’s minor.

Then we can use this time, to compare it to a time that was pre-determined by us, if the current time has not reach the set time, the account is locked, so we return false to prohibit account operations. If the time has already passed, we can validate the signature and verify this person is the owner or not. If verification passes, then he can operate on this account. Very simple logic.

3:22:35

Let’s see the second sample. This one is a bit complicated. We can see it’s 5 functions. One is main, it’s a decentralized domain name management system. To manage, it has a function, which will take some parameters, the first one is operation, what I want to do, like register a domain name or transfer one or delete one.

The 1st is query, it will verify the current caller of the smart contract need to check a domain name, it will execute the query function. Query is easy, it accepts a parameter named domain name, the function will take the name to the storage are and access its record, then return the data to the caller.

The 2nd is register. When registering, it will take 3 parameters, the first one is the domain name, second one is the owner, third one is the signature. The logic is simple too, first I will need to verify the signature, to check the caller is actually the one called, and will return false when verification failed. When verification passed, to check if the name is already registered. So I will try access the storage area and find the record, if record is found then it’s already registered and will return false. If there’s no record then you can register and I will write the new owner info into the storage area and return true to show it’s successful. That’s domain registration.

The 3rd is transfer. The 4 parameters are domain name, signature of owner, and the recipient, and the signature of recipient. The logic is we need to verify signatures, to see the recipient is willing to accept this domain name, if the recipient is unwilling then return false. The second is to read the domain name record, if cannot be found then it’s an unregistered name, return false. Once the record is found we need to verify the caller is the owner via signature, if not return false. When everything passed means we can transfer the name, and write the new owner’s information into the storage area then return true.

The last one is delete. The logic is similar to last one, which we need to verify a signature, only the domain name owner can delete their names. That’s after verifying it’s registered, since we cannot verify signature without domain record. Every thing’s passed then we delete the record and return true.

So this is a simple and basic decentralized blockchain domain name management system.

3:26:53

The last one is token issuing, and I don’t have time for it now, it’s very easy to understand though. Because we already save a set of record for domain name owners, we can do registering and transferring. If we change the domain name to a token, it’s the same principle. So it will be easy for you to write a token transfer and issuing system following the domain system.

--

If you made it this far and these translations are useful to you please comment/share/tweet/upvote/consider donating so that we can spread the expense as a community. The freelancers I found are good but they weren't cheap! If you're a native speaker and can translate future announcements I'd encourage you to do so and the rest of us will happily donate!

I'll publish an accounting for any donations sent and only use them to offset translation services.

Translations donation address : 0xd42b38Fa09665747FAD4DA1F33a0777E340F1d10

Sort:  

Thank you for doing this, I thumbed up both sections. Hopefully we hear more from ANS in the future.

Really kind of you to share with the rest of us. Hope you at least recoup your investment through these posts. Thanks again

Thanks for sharing this. I think ANS/NEO has a lot of potential.

Congratulations @rboyd! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!