Nexo

We’re Giving out 10 BTC in Rewards until the Bitcoin Halving

Learn More

Spacemesh Code Review: PoST Consensus

Spacemesh Code Review - Proof of Space Time Blockchain Consensus

Share this article

Actually quite hard to describe from their website what this Spacemesh code review is all about. A post on their page talks about the PoST consensus (more in a second) but the core seems to be that they expect to deliver scaling, security, decentralization (yes, all three) PLUS, wait for it, fairness and inclusiveness, and sustainability. Important concepts, but that’s five goals when two are a challenge for most.

Anyway – on with the code review.

“Spacemesh is a fair blockmesh operating system designed to run general-purpose smart contracts at web-scale. It is powered by a novel consensus protocol that is secure, proof of work free and highly incentive-compatible”

No real detail on the website, let’s jump into whitepaper.

“Proof of Space Time (PoST)”, I very seldom like time based protocols, they are too easy to manipulate (I did like Solana’s one though), let’s see what these guys did.

“…to contribute to the security … via unused storage sspace on their hard drives.”

“Using PoST provers show that they have reserved a portion of their storage for a specified time. The reserved storage cannot be used for anything else… a user can prove that she reserved 100GB for a month”

But why? Ok, so this consensus mechanism makes zero sense to me. How does dedicating 100 GB of hardrive space for an indeterminate amount of time give value to malicious transactions? I don’t think trying to understand the whitepaper is going to help me, instead, let’s go to code.

spacemesh-app and go-spacemesh. Really? No go-spacemesh and app-spacemesh or spacemesh-app and spacemesh-go. Moving on.

go-spacemesh first.

We start from main.go which points to app/main.go, straight forward, but impressive if this was a ground up design. Lots of functionality built in.

P2P, config setup, GRPC and JSON API servers. Lot’s of code, good commenting, lot’s of substance. I started out pessimistic, but I like. Let’s hunt down consensus to figure out how it works

We fill a set amount of committed data, I guess I sort of understand what they are trying to do, with PoW the detriment is the CPU I’m using to secure the block, here the detriment is lost disk space. I’m curious how it will combat; if I commit the space, then simply format and redo. But that’s where time comes in, so let’s keep looking. TLDR of the above is; set aside fixed space and fill it with fixed data.

Creates the data file to fill the disk space.

Creates the table. This wasn’t what I was looking for, going to keep digging.

Accounts is straightforward. (I don’t want to discount the code, it’s good code, well designed, well written, well documented, and well commented, it’s just not what I’m looking for right now though.)

Store is good, but straightforward.

API is good, but straightforward (I think I’m going to be repeating this for a while)

Filesystem is good, but straightforward (I know…)

And we are left with Merkle and P2P. Ok, so I’m not finding the consensus part. Let’s go back to the whitepaper.

Ok, so two proofs, the one is when I lock up the disk space, and two is when I prove I did it. Does that reset the timer? Can I just keep storage and keep sending fake transactions? Can I just recalculate the storage as soon as I’m asked for the proof? How can I be punished for doing fake transactions?

I’m not seeing what value this new consensus mechanism adds over the existing solutions.

Spacemesh Code Review Conclusion:

Good code, idea doesn’t really make sense and doesn’t do much difference in this space (see what I did there?) It was really good code, but it’s just another HelloWorld blockchain.

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.

Spacemesh Code Review Timestamp: June 21st, 2018 at 14:00 GMT

Share this article

Loading...