{"id":13544156,"url":"https://github.com/LimeChain/stylus-benchmark","last_synced_at":"2025-04-02T14:30:27.865Z","repository":{"id":208463356,"uuid":"721601717","full_name":"LimeChain/stylus-benchmark-old","owner":"LimeChain","description":"Repostory for benchmarking Stylus vs EVM contracts","archived":false,"fork":false,"pushed_at":"2023-12-21T14:13:04.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T14:55:33.530Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LimeChain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-21T11:56:15.000Z","updated_at":"2024-10-18T10:40:40.000Z","dependencies_parsed_at":"2023-12-21T16:50:20.246Z","dependency_job_id":"92518ea5-d756-4293-835d-563d1298af00","html_url":"https://github.com/LimeChain/stylus-benchmark-old","commit_stats":null,"previous_names":["daniel-k-ivanov/stylus-benchmark","limechain/stylus-benchmark","limechain/stylus-benchmark-old"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LimeChain%2Fstylus-benchmark-old","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LimeChain%2Fstylus-benchmark-old/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LimeChain%2Fstylus-benchmark-old/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LimeChain%2Fstylus-benchmark-old/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LimeChain","download_url":"https://codeload.github.com/LimeChain/stylus-benchmark-old/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246832058,"owners_count":20841100,"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","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":[],"created_at":"2024-08-01T11:00:43.006Z","updated_at":"2025-04-02T14:30:27.585Z","avatar_url":"https://github.com/LimeChain.png","language":"Rust","funding_links":[],"categories":["Examples"],"sub_categories":["Talks \u0026 Presentations"],"readme":"# Stylus Benchmarks\n\nThis code repository aims to benchmark the gas costs between EVM and Stylus contracts for ERC20 tokens.\n\n## Findings\n\n**ERC20 Functions**\n\n| Function     | Stylus (WASM) | Solidity (Shanghai EVM) |\n|--------------|---------------|------------------------|\n| fund/mint    |  36345        | 34123                  |\n| transfer     |  37417        | 35000                  |\n| approve      |  31573        | 27005                  |\n| transferFrom |  44683        | 41212                  |\n\n**ED25519**\n\n|           | Stylus (WASM)    | Solidity (Shanghai EVM) |\n|-----------|------------------|-------------------------|\n| verify    |  184188 (-81%)   | 975582                  |\n\n\nNote:\nhttps://github.com/chengwenxi/Ed25519/tree/main was used for the EVM implementation of ED25519 verification\n\n- ERC20 and other contracts whose gas costs come predominantly from storage operations will not benefit greatly from Stylus contracts\n- Purely computational contracts (e.g. ED25519 verification) would **significantly** benefit from Stylus as it would **drastically** lower the gas costs compared to an EVM implementation\n- We are observing a **~81% reduction in gas costs** in the case of a naive (non-optimised) WASM implementation of ED25519 verification compared to an EVM implementation\n\n**Important**\n\n1. The code shown in this repository is for demonstration purposes only and is not production-ready. It is meant to showcase the gas cost differences between the Stylus VM and the EVM.\n\n2. The code used in the Stylus VM is a naive implementation and is not optimized. It is important to consider this when interpreting the benchmark results.\n\n3. Benchmark was run based on the [following  gas schedule](https://github.com/OffchainLabs/stylus/pull/188) for Stylus which as of this writing is not yet on testnet!\n\n## Reproducing Benchmarks\n\n### Prepare the environment\n\n1. Compile the Stylus contracts\n```shell\ncargo build --package stylus-benchmark --release\n```\n\n2. Clone Arbitrum Nova development node\n```shell\ngit clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git \u0026\u0026 cd nitro-testnode\n```\n\n3. Run Local development node with Stylus support \n```shell\n./test-node.bash --init\n```\n\n4. Fund the users addresses\n\n```shell\n./test-node.bash script send-l2 --to address_0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 --ethamount 100\n```\n```shell\n./test-node.bash script send-l2 --to address_0x70997970c51812dc3a010c7d01b50e0d17dc79c8 --ethamount 100\n```\n\n#### ERC20\n\n1. Uncomment the `erc20` file in the `lib.rs`, comment the `ed25519` file\n\n2. Deploy the erc20 contract\n```shell\ncargo stylus deploy -e http://localhost:8547 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\n```\n\n3. Run the benches script - change the addresses of the ERC20 prior to launching the script\n```shell\nbash ./stylus-bench-erc20.sh\n```\n\n#### ED25519\n\n1. Uncomment the `ed25519` file in `lib.rs`, comment the `erc20` file\n2. Deploy the `ed25519` verifier contract\n\n```shell\ncargo stylus deploy -e http://localhost:8547 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\n```\n\n4. Execute the following cast\n```shell\ncast send --rpc-url http://localhost:8547 --gas-limit 1000000 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 {CONTRACT_ADDRESS} \"verify(bytes,bytes,bytes32)\" 0xb0d8bdfd9f4d1023dae836b2e41da5019d20c60965dc40943e2c10f2ad4ee49ab0d8bdfd9f4d1023dae836b2e41da5019d20c60965dc 0xa6161c95fd4e3237b7dd12cc3052aaa69382510ecb5b89c2fbeb8b6efb78266b81160af2842235a0257fc1d3e968c2c1c9f56f117da3186effcaeda256c38a0d 0x06cf14cfae0ff9fe7fdf773202029a3e8976465c8919f4840d1c3c77c8162435\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLimeChain%2Fstylus-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLimeChain%2Fstylus-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLimeChain%2Fstylus-benchmark/lists"}