Cliquebait!

He created this Docker image for the strangest reasons… Now he’s telling us why!

In an earlier post where we introduced Chanterelle, we sprinkled in some casual references to Cliquebait. After experiencing innumerable frustrations with bytecode incompatibilities between testrpc and various versions of the Solidity compiler, managing different directories for various test chains, and forgetting to reset the chains in between test runs which led to sleepless nights and lots of hair-pulling, we figured there had to be a better way to handle ephemeral networks for testing.

Upon realizing that there is no shortage of catchy-titled, attention-grabbing Medium posts, we decided it was time to whip up some Cliquebait! Cliquebait is a fun and easy-to-use Docker image designed to make testing your blockchain code as simple as possible while maintaining feature parity with existing Ethereum clients.

What does it do?

In a nutshell, Cliquebait simplifies the setup and teardown of an ephemeral Clique Proof-of-Authority Ethereum network with a bit of shell-fu. Upon running the image, a private blockchain with accelerated block times is instantiated and set to run. Because it’s in a Docker container, cleanup is as simple as killing the container.

On startup, a few accounts are generated, a genesis block pre-funding those accounts inside the PoA network is constructed, and a Geth node is fired up set to mine blocks against this genesis block. The accounts are unlocked for immediate use via Web3. You would then interact with this Geth instance as you would any other Web3 provider.

Why use it over Geth or Parity’s dev modes?

In the case of Geth, --dev didn't actually exist when we created Cliquebait! Cliquebait allows for a consistent method of setting up test chains across all Geth versions going back to 1.7.0.

For Parity, there are still ongoing issues with the dev-mode instantSeal engine such as being unable to trace transactions.

In both cases however, the dev modes tend to have optimizations enabled such as lazy blocks (not mining blocks unless there are transactions). In that case, special considerations have to be made in your testing code that waits for block confirmations, for example.

We believe that acting as close to a real blockchain as possible makes for more robust testing. While everyone has their preferences and needs, we hope that you find our “batteries-included” offering useful!

I’ll take three!

See the README on the Cliquebait GitHub for a quickstart guide!