{"id":28714651,"url":"https://github.com/rsusik/pattern-matching-in-blockchain","last_synced_at":"2025-08-05T23:04:56.862Z","repository":{"id":50694252,"uuid":"515704418","full_name":"rsusik/pattern-matching-in-blockchain","owner":"rsusik","description":"Pattern matching algorithms implementation in Solidity and YUL for Ethereum Virtual Machine (EVM)","archived":false,"fork":false,"pushed_at":"2025-02-13T16:20:02.000Z","size":22606,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-05T03:30:45.348Z","etag":null,"topics":["algorithms","blockchain","cost","ethereum","fee","gas","gas-usage","optimization","pattern-matching","price","search","solidity","solidity-text-matching","string-matching","text","text-matching"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsusik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-19T18:46:27.000Z","updated_at":"2025-02-13T16:20:08.000Z","dependencies_parsed_at":"2025-07-05T03:33:38.706Z","dependency_job_id":null,"html_url":"https://github.com/rsusik/pattern-matching-in-blockchain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rsusik/pattern-matching-in-blockchain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpattern-matching-in-blockchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpattern-matching-in-blockchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpattern-matching-in-blockchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpattern-matching-in-blockchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsusik","download_url":"https://codeload.github.com/rsusik/pattern-matching-in-blockchain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpattern-matching-in-blockchain/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268987471,"owners_count":24340667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","blockchain","cost","ethereum","fee","gas","gas-usage","optimization","pattern-matching","price","search","solidity","solidity-text-matching","string-matching","text","text-matching"],"created_at":"2025-06-15T01:08:06.948Z","updated_at":"2025-08-05T23:04:56.809Z","avatar_url":"https://github.com/rsusik.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pattern matching algorithms in Blockchain for network fees reduction\n\n## About\n\nEfficient exact pattern matching algorithms implementation in Solidity/YUL language.\n\n### Algorithms\n\nThe smart contract contains implementation of below mentioned algorithms in Solidity language:\n* Shift-Or (three variants, `so3` is the fastest)\n* Knuth-Morris-Pratt (`kmp`)\n* Boyer-Moore-Horspool (three variants, the `hor3` is the fastest)\n* Rabin-Karp (`rk`)\n* Backward Nondeterministic Dawg Matching (`bndm`)\n* Naive/Brute Force (two variants, the `naive2` is the fastest)\n\nAll functions take four arguments: text, text length, pattern, and pattern length, and return the number of pattern occurrences in the text.\n\n*Note: more information about each function can be found in the comments.*\n\n### Disclaimer\n\nThis source code was written for research purposes. It has minimal error checking. The code may be not very readable, and comments may not be adequate. There is no warranty. Your use of this code is at your own risk.\n\nWe put all the effort into making the experiments reproducible. The gas usage should be the same on all machines if the versions of environment components are the same as stated in the Requirements section. The timings may slightly or significantly differ depending on the machine power.\n\nAdditionally, we deployed the smart contract on Rinkeby network at [0x9Fb22d8d82FcF1c5321D5acf75eE917CF936E257](https://rinkeby.etherscan.io/address/0x9Fb22d8d82FcF1c5321D5acf75eE917CF936E257).\n\n\n\n## Requirements\n\n* Python \u003e= 3.8\n* Miniconda/Anaconda (for managing environment, optional)\n* brownie == 1.17.2\n* node/npm (to install and run Ganache)\n* Ganache == v6.12.2\n* Solc compiler == v0.8.11 (optimizer must be enabled for 200 runs, see `brownie-config.yaml`)\n\nThe code was tested on Linux 64-bit OS (Fedora and Arch distributions) and should also work on other systems (such as Windows and Mac OS) if all requirements are met, but it was not verified.\n\n## Data\n\n### Corpus\n\nThe original corpus can be found at: http://pizzachili.dcc.uchile.cl/texts/.\n\nThe datasets used for testing are available in [`texts`](./texts/) folder.\n\n### Patterns\n\nPatterns were generated from texts and are located in [`patterns`](./patterns/) folder.\n\n## Running\n\n### Environment setup\n\n```\nconda create -n pat python=3.8\nconda activate pat\npip install -r requirements.txt\n\nnpm install ganache-core@2.13.2\nnpm install ganache-cli@6.12.2\n```\n\n\u003e Note: `conda` commands can be omitted but we recommend to install fresh environment.\n\n### Run\n\nRun Ganache node and then:\n\n```\nbrownie run execute\n```\n\n\u003e Note: The parameters may be changed in the [`execute.py`](./scripts/execute.py) file.\n\n## Results\n\nAll collected results are located in [`results.csv`](./results.csv).\n\n## Citation\n\nThe paper is available at https://link.springer.com/article/10.1007/s11227-024-06115-8\n\n```\n@article{susik2024pattern,\n  title={Pattern matching algorithms in blockchain for network fees reduction},\n  author={Susik, Robert and Nowotniak, Robert},\n  journal={The Journal of Supercomputing},\n  pages={1--19},\n  year={2024},\n  publisher={Springer}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsusik%2Fpattern-matching-in-blockchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsusik%2Fpattern-matching-in-blockchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsusik%2Fpattern-matching-in-blockchain/lists"}