TrueBit Code Review: Scalable Blockchain Verification
Share this article
I love this. Love it. Go to the website and you’ll see why, it’s like looking at 1993 and I swear they had to get their background colour matched at a hospital. Love it.
Well looks aren’t everything so I’ll put my affection to one side and focus on the TrueBit code review. They’ve been working on this a while and it shows. “Panopticomputers”, only verifying blockchains when something goes wrong or when highly complex, so that every transaction is not clogging up the network, “outsourcing” computations to a “trustless consensus computer”.
So the very purpose of distributed ledger technology is to maintain a perfect record of the past so that there can be no dispute over the ledger entries. And Ethereum blockchain nodes therefore contain all transactions ever recorded (not getting into arguments about Eth Classic here).
TrueBit is a smart contract that sends ‘client’ computations outside of the Ethereum network when they reach a certain complexity (rational miner paradox), verifying them through a trustless economic mechanism (see whitepaper) if there is a dispute or simply returning the clean transaction to the chain, once verified, if there is no dispute.
Either way the verifier is rewarded appropriately, creating incentives for the client and the computational service provider. This provides..
“A scalable verification solution for blockchains”
“Secure, scalable, decentralized computation” and
“TrueBit gives Ethereum smart contracts a computational boost.”
Very active repo.
We start with wasm-computation-layer. This for now is mostly emsdk (emscripten). It is interacting with ocaml-offchain somehow, busy trying to figure this part out.
Ok, so emscripten is linked with empscripten-module-wrapper. This allows the system to record data for verified computations.
We start at main.js
Lot’s of pre-definitions for different environments (running in web/on node/etc)
So much happening in main.js
Great documentation. A lot of this is emscripten boiler plate though, so it’s a bit difficult to differentiate.
Need to dig in more here.
I need to start from another angle, let’s start with Truebit OS
deploy-wasm goes to ./wasm-client/deploy.sh
truebit goes to node ./cli/index.js
Let’s have a look at deploy.sh first
We have ocaml-offchain again, webasm-solidity, and then the js files, let’s dig into them.
Deploy does a npm run deploy on webasm-solidity, we will head over there just now.
Interesting, merkleComputer = webasm-solidity/merkle-computer and ocaml-offchain interpreter.
Gets the task posted event as soon as someone registers an execution task with the ethereum smart contract (although it could also just be run locally off-chain or in a truebit os).
Can grab code locally, on-chain, or from IPFS, then setupVM. VM executes the WASM task in a merkleComputer (webasm-solidity above, we will get into it shortly)
Specific steps in the VM are selected for dispute resolution (all execution doesn’t occur)
This is good.
Still a lot I have to go through here, but I will conclude this for now.
TrueBit Code Review Conclusion:
Really great code. Great solution. Will allow for decentralized computing that can scale with node participation. Really fantastic idea, concept, and implementation. The solution doesn’t need its own token, ETH is good enough for it, but other than that, this is fantastic.
Really great code. I will still need to go through this quite a bit, the skill caliber is very high.
You can chat about TrueBit in our Telegram group.
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.
TrueBit Code Review Timestamp: August 25th 2018