Blockchain received a vast amount of attention in recent years and is still growing. The second generation of blockchain, such as Ethereum, allows execution of almost any program in Ethereum Virtual Machine (EVM), making it a global protocol for distributed applications. The code deployment and each operation performed in EVM cost the network fee called gas, which price varies and can be significant. That is why code optimization and well-chosen algorithms are crucial in programming on the blockchain. This paper evaluates the gas usage of several exact pattern matching algorithms on the Ethereum Virtual Machine. We also propose an efficient implementation of the algorithms in the Solidity/YUL language. We evaluate the gas fees of all the algorithms for different parameters (such as pattern length, alphabet size, and text size). We show a significant gas fee and execution time reduction with up to 22-fold lower gas usage and 55-fold speed-up comparing to StringUtils (a popular Solidity string library).
翻译:第2代块链,如Etheum虚拟机(EVM),允许执行几乎所有的程序,使其成为分布式应用的全球协议。在EVM实施的代码部署和每次操作都花费了网络费,称为气体,价格不同,而且可能很重要。这就是为什么代码优化和选择良好的算法在块链的编程中至关重要的原因。本文评估了Etheum虚拟机上几种精确模式匹配算法的气体使用情况。我们还建议在Solidity/YUL语言中高效实施算法。我们评估了不同参数(如模式长度、字母大小和文本大小)的所有算法的气体费用。我们显示,气体收费和执行时间大大缩短,比StringUtils(一个流行的固态字符串库)减少22倍,速度加快55倍。