Republic Protocol Code Review: Dark Pools
analysis

Republic Protocol Code Review: Dark Pools

THELOGICALINDIAN - n-a

Republic Protocol and its aphotic pools aim to facilitate affairs on a hidden adjustment book. There are bright allowances for aerial contour individuals, whales or anyone abroad absorbed in appointment funds to addition affair after the alteration actuality about available. The arrangement is maintained application Republic Darknodes. The Darknodes acquire the barter requests, bout the affairs and facilitate the absolution of agenda assets, after advertisement the transactions.

Dark Pools — what are they, what do they do? “Dark pools are clandestine exchanges area banking assets and instruments are traded and akin by an agent active on a hidden adjustment book.” — Republic Whitepaper.

There are absolutely a few repositories. So let’s get started.

The aboriginal affair I am activity to run through from their athenaeum is the whitepaper:

They call the basics of what they appetite to achieve, a abbreviate description of how they are planning on accomplishing it, aegis requirements and the purpose of the badge in the ecosystem. Pretty industry accepted stuff.

Let’s hop into the cipher to see how they are accepting on.

The cipher does absolutely what the affidavit says. It is a library of functions that abetment with alongside processing.

Quality cipher affidavit and comments, acceptable tests accounting for it, but annihilation too alluring accident in here.

The athenaeum hasn’t been affected in the accomplished 4 months. Which is barefaced for a repo what it wants to achieve. It’s a all-encompassing “import frequently acclimated functions” repo.

The purpose of this athenaeum is appealing simple. It allows for cross-chain transfers amid ERC20 tokens, Ether and Bitcoin *Interested to see how the Bitcoin alteration will be tackled.

No absolute commits in the accomplished 4 months. So I’d accept actuality is some assembly accessible cipher in here.

contracts/AtomicSwapERC20.sol

The affection cipher documentation/comments that we saw in go-do accept dwindled bottomward to a minimum. There are brace of basal comments average curve of cipher and a TODO.

I am not the better fan of ever accurate code, but the basal action purpose and constant description goes a continued way appear compassionate what is accident in the code.

checkSecretKey doesn’t absolutely “check” anything, it aloof does a “getSecretKey” based on the _swapID. It’s aloof a abstruse action allotment issue. Nothing amiss with what the cipher does.

The blow of the AtomicSwap*.sol contracts in the athenaeum all attending the aforementioned and accept agnate functionality. They aloof use the altered alteration mechanism, based on the bread type:

vs.

I was absorbed to see how they were activity to apparatus the Transfer X to Bitcoin functionality. The README.md documentation aloof says use the AtomicSwapEther or AtomicSwapERC20 arrangement calm with an alien “Bitcoin Script” which will handle the Bitcoin Transfer. When a specific aphorism set is hit (in this case, a action call), they funds are released. So it is aloof a accustomed route.

The README.md is a bit out of date. There is no MinerRegistry or OrderBook acute contract. So I assumption we will charge to amount out what is activity on in the files.

RenLedger.sol seems to be the OrderBook. DarknodeRegistry.sol is the MinerRegiststry. So it’s all there, aloof the README.md that’s out of date.

contracts/RepublicToken.sol
The ERC20 badge (REN). Lots of boilerplate, but annihilation interesting. Standard ERC20 arrangement with a brace of accepted arrangement patterns included (Burnable, Ownable, StandardToken, etc.)

contracts/*.sol
Good action and constant documentation. Neat and well-structured code. The arrangement cipher is simple and accessible to read.
Overall, the break is acceptable amid the altered contracts. I like it.

Hopefully we are accepting into the added compact cipher now.

7 Contributors, 3.8k commits. This is area the majority of their time and accomplishment has been spent.

At a aboriginal glance this doesn’t assume to be a beeline go-ethereum carbon area they rename every variable. However, if we attending in the vendor/github.com/ethereum/go-ethereum we acquisition the accepted Ethereum code. Perhaps they accept captivated and acclimated alone the functionality that they need?

I would accept admired to see a substantial README.md giving an overview of the project, but it is appealing bald bones.

Fortunately, activity into docs/docs we appear beyond absolutely a lot of affidavit for the project. There is still no “This is what we are accomplishing here” though. I stumbled on a nice overview of their Architecture and architecture principles. It’s acceptable to see the considerations they put in abode for how they capital things to run.

There is lots of code, lots of accomplishment and lots to review. I’m activity to aloof brush over a brace of folders to save time.

Let’s alpha with the blockchain folder. They accept congenital this accepted accomplishing on Ethereum, so it makes faculty to alone see the Ethereum platform. Republic said that they are blockchain agnostic, so it could be migrated to added platforms in the future.
What follows are a few libraries that collaborate with the Ethereum acute arrangement ecosystem authentic in the republic-sol repository.
dnr -> DarknodeRegistry.sol
ledger -> RenLedger.sol
rewards -> a accolade arrangement that seems to distributes affidavit rewards. I’m clumsy to acquisition the acute arrangement in their athenaeum though.
accounts -> I am clumsy to acquisition the arrangement for this as well.

cal -> contains a agglomeration of interfaces. I’m actual afflicted with the bulk of accomplishment put into commenting.

I’m activity to skip over autograph about some of the content. Otherwise this commodity is activity to become absolutely laborious. The cipher is aloof good!

identity -> encoding and adaptation addresses and multiAddresses. Yay, article incorrect in their comments — or their code?

levelDB -> they are application Google’s LevelDB for a bounded abstracts accumulator band-aid of the orders, adjustment bits and computations. Pretty abundant the accepted in blockchain.

ome -> the Adjustment Analogous Engine! Lots gets kicked off in here. In short, it manages aggregate apropos adjustment matching. The OME syncs the adjustment book from the renLedger and inserts the change into the ranker. The ranker consumes the orders and produces computations that are prioritised based on a brace of factors.
Based on the computation’s state, it will accomplish the abutting activity required. First the ciphering will go through the action of award a analogous brace of buy and advertise orders. Once the bout is found, the ciphering is confused assimilate the abutting phase.
Computations that accept been akin will again be confused assimilate a accepted accompaniment and it will be stored by the settler. It uses Shamir shares and SMPC mentioned beneath to accompany the match.
Again, abundant affidavit which makes the cipher accessible to follow.

shamir -> a abstruse administration library. It break the abstruse into abate pieces (Shares). It can reconstruct the allotment from a predefined abate cardinal of Shares than the abounding cardinal of pieces.

smpc ->an interface for a defended multi-party computer. It asynchronously consumes computations instructions and produces results. Joins the Shamir Shares and accelerate a bulletin to the added nodes advice them of the join.

And that’s that. Those are the appetizing genitalia of the meat!

In the cipher for republic-go, we accept able-bodied accurate action calls. There are absolute tests accounting for the majority of the files. All the functionality seems to be absolutely able-bodied afar by what they beggarly to achieve. Comments are approved and actual descriptive. I can’t absolutely complain.

Testnet
Republic appear their testnet absolution on the 18th of June 2018. ( https://bit.ly/2MbtaIS). I arch on over to their testnet barter and aggregate seemed to be in alive order. They accept abutment for MetaMask, Ledger and a Keystore file, with Trezor and Private key abutment advancing soon.
There were some admiration issues back alive on a abate screen. No adaptable application in the designs of the website. So their advanced end could absolutely use some work, but with no about accessible athenaeum for it, I can’t animadversion any further.

Republic Protocol  Code Review conclusion:

The all-embracing cipher anatomy is good. Majority of the cipher is able-bodied written, able-bodied anticipation out and able-bodied documented. I’m absolutely afflicted by how able-bodied this is coded.

In the blitz of the crypto world, it is accessible to aloof get the activity out afore the deadlines after the affidavit and anatomy maintained in this project. But they ashore to their guns. These developers apperceive what they are doing.

In agreement of their mission, they are able-bodied on track. At the end of Q2 2024, they aimed to accept Atomic Swaps, Ren ERC20 Token, PTP network, Registrar and Order Book acute contract, Secret Sharing, Trader Terminal and their official Republic nodes out. All the pieces of the ecosystem assume to be in place, so it will be absorbing to see what the association acknowledgment apropos the testnet will be. They accept accomplished a lot in the accomplished six months. I attending advanced to seeing what this activity can aftermath in the abutting six.

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.

Republic Protocol Review Timestamp: June 21st, 2024 at 14:33 GMT