C++ DEV Update: A Summary of July Progress

Published:

This month, the C++ DEV team has made a lot of progress behind the scenes that hasn’t been visible to the public. This article is intended to provide a summary of what has been achieved.

In terms of features, work has been ongoing to re-license the C++ client code. Apache 2.0 has been mentioned a lot, and more news is expected soon.

Eth Unit Mode

In addition to being able to run Solidity Tests via IPC, Dimitry Khoklov and other developers have added RPC endpoints that offer more flexibility when it comes to testing smart contracts. This allows users to:

  • Adjust blockchain parameters (e.g. remove proof of work verification or pre-fund accounts).
  • Mine a specific number of blocks (around 30 blocks per second).
  • Modify the timestamp in the current block, in order to test timeouts in contracts.
  • Revert the blockchain to a specific block number

Using this, the Solidity Test Suite of 305 tests can be completed in approximately 46 seconds on a standard computer. Each of these tests requires two or more transactions, as well as the same number of blocks to be mined.

More information about these features can be found on GitHub.

It is worth noting that this feature is not available for binary services provided via the Ubuntu Developer PPA.

Virtual Machine Acceleration

Greg Colvin has spent the past few months improving the C++ implementation of the EVM interpreter. He refers to this as “low-hanging fruit”. The biggest changes were replacing 256-bit gas metering calculations with 64-bit ones and ensuring that only one MV operation is metered. These and other alterations led to the following results when compared to the old cpp ethereum interpreter (cpp int (old)):

For fairness, it is important to explain what these benchmarks are. The first benchmark, which shows a 472x speedup off the scale for evmjit, is for a million loops. This illustrates the slow and inefficient EVM when compared to the jump of a JIT. The fix is second in the stack. The second benchmark is a bad random number generator, which does a million loops of multiplications and additions per loop. The dominant factor in the 256-bit calculations is 256-bit computations. A JIT has less of an impact here (note that the Go JIT does not compile native code, but rather to an interpreted rendering).

In PracticeThese accelerations will only be relevant for “number crunching” as computation time is largely controlled by storage access for contracts. On the other hand, the “rng” benchmark algorithm is very similar to cryptographic operations, which puts these activities in the realm of actual on-chain implementations.

Paweł Bylica is working on a C language interface for the Ethereum client. This will make it possible to connect multiple virtual machines to the client. In this way, geth could also benefit from our changes in the C++ virtual machine and the LLVM just-in-time compiler.

Remix

Yann Levreau and Liana Husikyan are currently developing a new remix for the EVM debugger. A few days ago, the alpha version of the software was released. The application provides the ability to examine each step in any transaction executed on the blockchain. The next step will be to also allow debugging at the source level, and see the decoded values ​​of variables (instead of just the raw hex values).

Related articles

Recent articles