Peter Czaban, Executive Director of Web3 Foundation, said:
“Polkadot Runtimes make it easier than ever before to flexibly describe and deploy blockchain logic. To ensure that this richness of capabilities leads to secure developments, we are committed to funding tools which can support developers during their creation. We are excited to work with a leading blockchain security firm ChainSecurity to research and develop new approaches to automated blockchain logic analysis”.
Petar Tsankov, Chief Scientist of ChainSecurity, said:
“We are dedicated to bringing to Polkadot’s developers and users practical and useful security tools that enable them to easily assess the safety and security of Polkadot. Starting with manual testing and random fuzzing of Polkadot Runtimes, we are looking forward to building further tools capable of deep security fuzzing and verification. We are grateful to Web3 Foundation for their support in this project”.
Who is PolPatrol for?
Two user groups will primarily use PolPatrol:
- Developers of new relay chain runtimes who would like to test the correctness of their code.
- DOT token holders who can vote on newly proposed relay chain runtimes and would like to check whether a proposed runtime is safe and secure.
For both user groups, PolPatrol automatically analyzes any given relay chain Web assembly binary (or, a Wasm blob) and warns users upon violation of important security and performance properties.
How can I use PolPatrol?
The source code of PolPatrol is available #here
To learn how to install PolPatrol and how to run it on a custom relay chain runtime, please refer to the official documentation #here
How does it work?
PolPatrol uses an instrumented Polkadot runtime environment to run the provided relay chain runtime and log all calls that it makes to the environment. In addition to the calls, it also monitors essential performance metrics, such as execution time and memory usage. This enables PolPatrol to check relevant trace and performance properties. PolPatrol aggregates the collected runtime information to let developers draw conclusions on the overall behavior of the runtime and compare different implementations.
What properties does PolPatrol check?
The focus of PolPatrol is on performance and safety properties.
Performance of runtime entries
PolPatrol collects statistics about all calls to runtime entries and reports the total number of calls made while testing the run-time, the maximum execution time (in seconds), the maximum memory usage (in MB), and the maximum number of storage-related calls to the environment:
For example, the above sample output identifies that the initialize_block entry was called 31 times, each call took at most 0.0324 seconds and consumed at most 68.294 MB of memory, making at most 59 storage-related calls. We note that PolPatrol outputs additional metrics (not shown above), such as the mean execution time and mean memory usage.
Performance of extrinsics
PolPatrol also reports statistics about applied extrinsics, reporting the same metrics as the ones reported for environment entries:
In addition to reporting the execution time, memory usage, and storage calls, PolPatrol also reports the assigned weight of each extrinsic. This allows developers and users to judge whether the weights are adequately defined based on the actual performance of the extrinsic.
Safety properties
Based on the performance information, PolPatrol checks several safety properties, such as:
In particular, PolPatrol ensures that the maximum block execution time is below 2 seconds, the maximum block memory is below 10,000 MB and the block length does not exceed 10,000 MB (measured as bytes of a block, scale-encoded). Further safety properties can be easily added.
Acknowledgments
ChainSecurity would like to thank the Web3 Foundation for supporting the research and development of PolPatrol with a research grant.
* * *
About Polkadot
Polkadot is the first interoperability protocol that enables blockchain networks to work together under the protection of shared security.
For more information on Polkadot, visit #polkadot.network.
About Web3 Foundation
Established in Zug, Switzerland by Ethereum co-founder and Chief Technology Officer Dr. Gavin Wood, Web3 Foundation funds research and development teams building the stack of technologies behind the decentralized web.
For more information on Web3 Foundation, visit #web3.foundation.