Fantom researchers propose a breakthrough solution for smart contract testing
We’re proud to announce that Fantom researchers have presented a breakthrough solution focused on off-the-chain smart contract execution and testing at the Usenix 2021 Annual Technical Conference, held July 14-16.
Yeonsoo Kim, Seongho Jeong, and Bernd Burgstaller from Yonsei University (Korea), and Kamil Jezek and Bernhard Scholz from the University of Sydney (Australia) have detailed a smart contract transaction record and replay mechanism that is substantially more efficient than existing solutions.
To date, testing a smart contract has involved using one of three impractical options: archive nodes, full nodes, or testnet. Each of these is limited by scalability/speed and high data storage overhead. Testnet solutions, in particular, also require extensive developer effort.
Addressing these limitations, Fantom researchers propose an off-the-chain testing environment built on a transaction “record and replay mechanism.” The recorder component of this solution captures substates, or snapshots of the blockchain containing only relevant environment and state parameters. These substates allow developers to replay transactions without depending on previous transactions and the entire world-state of the blockchain.
Using EVM binaries to simulate the Ethereum protocol, the replay mechanism enables contract execution independently and therefore outside of the Ethereum peer-to-peer network. The replay mechanism operates on the database of substates outputted by the recorder and can be run on a multicore server for unprecedented efficiency.
In testing with a sample set of 9 million blocks, the record-replay model reduced storage required by more than 50%, from 700.1GB to 285.4GB. Throughput grew exponentially from 620.6 tx/sec to 2,817.9 tx/sec on single-threaded processors and 30,168.8 tx/sec on a system scaled to 44 cores.
This solution promises to transform smart contract functionality and security testing. Numerous possible applications include:
- Hard fork testing: regression tests to determine whether newly introduced policies interfere with the execution of legacy smart contracts.
- Metric evaluation: measuring the number of wasteful instructions in a smart contract for optimization purposes.
- Contract fuzzing: testing for anomalies or unexpected results.