top of page
Writer's pictureAdmin

Ankr Code Review Distributed Cloud Computing

So this is an Ankr Code Review, not an ICO review, but that’s not going to stop me from looking very carefully at the consensus protocol here. Proof of Useful Work sounds intriguing. Good to see that on their website they lead with some of the actual benefits they intend to provide, not just the tech, but you can go see that for yourself. So, what else do they say on there?

“Ankr, Distributed Cloud Computing on Trusted Hardware. Ankr provides a computation-resource-efficient blockchain and an integrated data feed system leveraging both cryptographic primitives and trusted hardware.”

“The Proof of Useful Work (PoUW) consensus enables a self-sustainable blockchain framework. Instead of wasting electricity and computing power on hashes like Bitcoin does, PoUW uses these resources towards useful work tasks provided by enterprises and consumers.”

“The protocol runs on SGX-enabled CPUs with remote attestation to ensure security and confidentiality. The novel PoUW approach unlocks the massive potential of idle computing power around the world by providing enough incentives: in this scheme, every computation contributor gets compensated, and some will get the extra reward for generating the blocks.”

 

This starts with a bunch of hype ideas, Cloud Computing, Proof-of-Useful-Work instead of Proof-of-Work, Plasma Sidechains thrown in as a Multi-chain Plasma implementation, Native Oracle Services (NOS), cryptographic primitives, and trusted execution environment (TEE).

That’s a lot for me to take in. So let’s start with Proof-of-Work. Why do we use Proof-of-Work? Actually, one step back, what is Proof-of-Work? PoW is a essentially a guessing game, we know the answer, but we don’t know how we got there. So we start guessing different permutations until we find the answer. This takes a long time to accomplish (dependent on difficulty) but it is very quick and easy to verify.

So PoW is great to prove that something happened, it proves that someone took at least that amount (difficulty) of time guessing to get to the answer, so we know they had a financial (electricity) detriment.

So how does Proof-of-Useful-Work challenge that? According to their own description, by doing some useful bit of computing. For example, we have massive server farms all trying to solve N = NP problems, so why not give computing power to this? The problem comes in with Proof. How do you prove that they did the correct bit of work? PoW is intensive to do, but very easy to prove. However, if this was a non-deterministic computation, then I would have to redo the computation to prove that you did it.

So to replay that you did it (and thus prove) would take the same amount of time. Not very efficient is it?

So instead, in comes Verifiable Computing. This is the idea of outsourcing functional work while being sure that the right work has been computed, so instead, I would give the same bit of work to be completed to 3+ workers, when at least 2 results have been returned I can compare the results, if they match, the work has been verified, so instead this can be seen as a consensus on the work done, and each worker is rewarded for the correct work done. But now we start seeing an interesting statement here, each worker is rewarded for the correct work done. Quite different than PoW, where only the first to arrive at the answer is rewarded (and not always the case with longer chains, different topic for another day).

The above was just one example of Verifiable Computing however, another is trusted hardware, the most known example being Intel SGX (Software Guard Extensions), by including the execution into the SGX chips themselves, you can be assured that the computing is verified and thus not tampered with.

So why don’t all blockchains use this instead? Because the computational length is unknown, what if it takes 10 years to reach an answer? The job of PoW is to give us a block roughly every epoch (whatever that epoch might be). If the time to solution is unknown, how can we know when the next block will be? What if there isn’t any work to be done? Does this force every Node to have an Intel SGX chip?

Lot of unanswered questions about PoUW.

Questions aside (and ignoring Plasma Side chains and Native Oracles for now) let’s jump into some code.

Quite a few I am interested in ERC223, token-smart-contract, go-ethereum, plasma-mvp, bitcoin, pouw (the big one), april_demo (why did we switch from dash notation to underscore notation?)

ERC223, ERC777, ERC820, all trying to make ERC tokens first class citizens. Functions aren’t aware of transfers of ERC tokens (unless they use approve and transfer), so instead there are a lot of implementations to solve this issue by using callbacks and having functions implement the callbacks. Glad to see more awareness of this issue, but nothing here in the repo, so let’s move on.

ANK token (really, not ANKR?), decided to be a ERC20 standard token, makes sense, they aren’t building a dApp afterall. Other than supply, nothing interesting here.

go-ethereum, 361 commits behind master, nothing here.

plasma-mvp, 12 commits behind AdityaSripal which is 39 commits ahead, and 110 commits behind omisego.

bitcoin, branch is even.

Which leaves us with pouw and april_demo, jumping into april_demo first.

Looking at a webapp

Looks like it is using bitcoind-rpc-client, just a client for running bitcoin RPC commands

Seeing Axios (for HTTP) and bitcoin-core, let’s see what they do.

Block explorer

Blocks being received from an HTTP API (will look into that just now)

API is an abstraction layer for bitcoind-rpc-client. Port 20011



Very big blocks. Seeing some interesting fields here. “confirmations”, I’m assuming work confirmations, “nonce”, why nonce in a non PoW system? “difficulty”, same question as nonce. “chainwork”, proof of work done? “nextblockhash” so the block is updated post sealing?

More questions than answers, and we are out of data to look at, so let’s move on.

Onto Proof of Useful Work, come on guys, make my Ankr code review stellar, show me something amazing.

[Note, some of the code here is currently non-public, and will be shared at a later date.]

Intel SGX drivers required, makes sense.

I’ve never built SGX libraries, so I don’t actually know what is boiler plate and what is real code, so this is going to take a bit of time. As with all C projects though, let’s start at main.cpp

measure.h or parserfactory.h looks like our targets.

I was wrong on both accounts. So static analysis looks like it is just focused around analysis of the execution environment and code, so let’s move on.

Lots of scripts, let’s have a look.

Testing broken vs successful computations for blocks, test driven development, good to see.

The python tests and scripts are good. It is PoC code though, it is not intended for a reader.

So from what I can see, the proteinfolding does the useful work, miner-python calls the task and publishes the results into the bitcoin ledger, and static analysis confirms the output from proteinfolding. So onto proteinfolding we go.

Not a lot actually happening here. pouw calls protain_folding (yes, protain), which calls GeneticAlgorithm. I’m curious how they will make this generalized enough to function for more than protein folding.

Ankr Code Review Conclusion:

I need more code at this point. PoUW (I think Verifiable Computing has more application to scaling smart contracts, than a blockchain), plasma (Aditya Sripal looks to be on the team and they appear to have quite a bit of work done on plasma), and native oracles (although I still believe this ruins the deterministic nature of a blockchain) are interesting choices.

SGX limits participation to only those who have the hardware. Useful jobs are difficult to generalize, and you can’t do long jobs to generalize blocks.

Ambitious ideas, I don’t think they are really practical, very young team, interesting advisers. There are quite a few ideas here, even if they are a bit disjointed.

Disclaimer: Crypto Briefing code reviews are performed by auditing what is on display in the master branch of the repo’s made available. This was performed as an educational review and any comments in the article are the opinion of the writer. It is normal for code to change rapidly, hence we timestamp our code reviews so that they present a snapshot at a moment in time. Information contained herein should not be used as any comment or advice on the project as a whole.

Ankr Code Review Timestamp: May 20th, 2018 at 12:21 GMT

2 views0 comments

Recent Posts

See All

Comments


bottom of page