Harmony Open Consensus Blockchain Code Review
analysis

Harmony Open Consensus Blockchain Code Review

THELOGICALINDIAN - n-a

I acquisition it a bit awe-inspiring that a blockchain with such aerial aspirations makes you annal all the way to the basal of their website afore they use the chat ‘blockchain’ but that’s apparently aloof because I beam at these things all day. They use ‘consensus protocol’ a lot. Is blockchain too arid for them?

Whatever, this is an “Open accord for 10 billion people”. The “Open basement is a advocate high-throughput, low-latency, and low-fee accord belvedere advised to ability decentralized economies of the future.”

Let me alpha with my disdain: I bethink back Harmony aloof came out they had claims of 10 actor TPS (or was it a hundred million?) all over the place. This put them in a abrogating ablaze for me. I do about accept account for the team, and anticipate they are aboveboard technologists, so I’m activity to put that bent abreast for the time actuality and aloof appraise what we accept available.

So we alpha with the whitepaper;

Let’s ameliorate linearly scalable quickly. If 1 being can do 1 job, again 2 bodies can do 2 jobs right? If the job is absolutely absolute of anniversary other, again this account is technically correct. But what if they become abased on anniversary other? Or what if being 2 has to affirm with being 1 if they did the job correctly, all of a abrupt they can’t accomplish 2 jobs anymore, but about amid 1 and 2 jobs.

Now accept that for anniversary job, anniversary being had to analysis with all added persons, so if I do a distinct job, and there are 100 people, I accept to analysis with 100 bodies if they agreed with my job. How continued would it booty you, to ask 100 people, all active with added things, if they accede with your job? Well, that’s consensus. It’s artlessly not linearly scalable, the added participants, the slower it will go, that’s why dPoS systems are faster, they accumulate the 100 bodies to some baby number, like 8–20 so that it’s faster to agree.

Getting 10,000 bodies to accede is… well… back you accomplish let me know.

Ok, so affective abroad from linearly scalable.

Good description in the whitepaper on consensus, reads able-bodied and its able-bodied written. The cardboard is able-bodied written.

VRF, and BLS, we accept the accepted gen 2 blockchain candidates. I do accede with these approaches, I anticipate VRF is analytical for sharding and BLS is analytical for consensus.

Ok, acceptable paper, abundant read, I awful acclaim it, let’s see what they built;

14 contributors, 29 branches, 2,697 commits. For a new project, back I see those abounding commits I commonly accept a fork.

Initial accomplish May 22, 2024, so about a year of development now. First few commits attending legit, doesn’t attending like any angled code.

So what areas are we absorbed in;

consensus definitely, affairs is interesting, we will attending at core, drand should be good, the blow attending like boilerplate, but they did say their p2p is unique, so we can dig into it as well.

Good cipher organization, acceptable structure, able-bodied designed. Cipher is architected agnate to the whitepaper.

When I see chainreader and agent I accept ethereum, they do acceptation ethereum libraries, annihilation amiss with application libraries, but let’s see how abundant is used. ChainReader and Agent are appealing abundant the absence ethereum implementations ones, so we do accept a little bit of forkiness activity on here.

So what do we apprehend from consensus? We apprehend baton alternative and BLS with BFT

RLP, params, and accepted libraries acclimated from ethereum. We accept protobuf as well, absorbing to see with RLP, agent from consensus/engine which is about aloof ethereum engine, crypto/bls will analysis actuality later. /core/state and /core/types attending like ethereum core/state and core/types, but we will anatomize those later, maybe we accept a bit added forkiness than I originally expected.

Not yet abiding how a baton is elected, will charge to dig in more;

Random channel, we charge to coursing it down.

hosts, shard, peers, leader, and bls abstruse key are pre-defined. Interesting, could be a bad sign, but let’s not jump to abstracts aloof yet. We charge to acquisition this instantiation though.

LDR = leader, VLD — validator, I was apprehensive about this shorthand.

Seal was what I was absorbed in, abashment it isn’t implemented yet, still this isn’t accomplished code, so they are still alive on it, but this is absolutely the meat.

Need to amount out how a baton is selected, contrarily this is a little bit pointless, so let’s jump into the startup arrangement for a node.

It’s golang, so we jump into /cmd/ -> Harmony -> main.go

Leaders are predefined? Little bit aghast by that, but let’s move on;

dRand is the accidental bearing for the alarm chain, absolutely absorbed in it.

Leaders are authentic at bootup. I’m unhappy. Let’s continue.

Standard 3 date commit. This is aloof BFT with beneath bulletin aerial because of BLS.

Contracts, we see faucet, lottery, and stake, apparently not absolutely annihilation interesting, but let’s unpack.

Uses the EVM, let’s move on.

Looks like ethereum. Mostly ethereum code, all acclaim accustomed though. Let’s attending at resharding, state_transition (where affairs are activated to the EVM, this is area shards charge to live) and tx_pool (since it needs to accept atom awareness)

VM ambience doesn’t apperceive about shards. Interesting.

Genesis knows about shards. So about anniversary ethereum arrangement has a alternation ID, you accept Ethereum, Rinkeby, Ropsten, Kovan. Now anticipate of anniversary one as a shard. That’s all sharding absolutely is. Now add POA’s cross-chain arch so that tokens can move from one to the other, and you accept the alarm chain. Good for assorted tokens, but this does not accommodate scalability for a distinct badge ecosystem.

A year ago I would accept been actual aflame by this code.

VM doesn’t charge acquaintance of atom state, because it is accustomed a blockchain article to accompaniment transition, and the blockchain itself is acquainted of the atom state.

Ok, let’s ameliorate the BLS, for this, we charge to arch over to their bls accomplishing repo;

Forked from herumi / bls

Some amazing repo’s in Herumi’s github, bls, bls-wasm, mcl, mcl-wasm. As allotment of this analysis I’m not activity to ameliorate it, but absolutely account a watch.

VRF is p256 from google. It’s solid, not activity to ameliorate it.

dRand is a mix of VFR, and consensus.

Harmony Open Consensus Code Review Conclusion:

It’s acceptable code, a bit of a afraid ethereum with chainID’s as shards and again application some acceptable account about VRF and BLS (Dfinity anyone?).

There is annihilation amiss with this, and a year ago this would accept been astounding cipher to see. I anticipate I’ve aloof apparent too abounding cipher bases like this one. What makes it special? Why is it bigger than all the rest? It’s absolutely addition contender, but at this point, how abounding contenders do we need?

Anyway, acceptable code, I aloof don’t see the point.

You can babble about Harmony, or actualize disharmony, in our Telegram group.

Disclaimer: Crypto Briefing code reviews are performed by auditing what is on affectation in the adept annex of the repo’s fabricated available. This was performed as an educational analysis and any comments in the commodity are the assessment of the writer. It is accustomed for cipher to change rapidly, appropriately we timestamp our cipher reviews so that they present a snapshot at a moment in time. Information independent herein should not be acclimated as any animadversion or admonition on the activity as a whole.

Harmon Code Review Timestamp: March 27th, 2024