Skip to content

LimeChain/stylus-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stylus Benchmarks

This code repository aims to benchmark the gas costs between EVM and Stylus contracts for ERC20 tokens and Ed25519 signature recovery.

# Required to run the examples
git submodule update --init --recursive

Findings

Each contract project directory ({erc20,ed25519}-{stylus,solidity}) contains a Justfile which reads a local .env (use the provided .env.local templates). Read the Justfiles to read more on what targets they provide.

Note

For the TLDR, jump to the conclusion

Important

The provided numbers below are L2_GAS gas costs, because that's what's most important, since it represents the actual computational cost of the transactions, and not the L1 calldata fees that are always fluctuating.

Feel free to check the transactions on arbiscan (the gas numbers are links that take you directly there) to check the gas costs for yourself.

ERC20

Function Stylus L2 Gas Solidity L2 Gas Difference (L2) % Difference
deploy 2'868'817 + 2'941'842 530'643 +2'338'174 995.0% more
mint 87'649 68'455 +19'194 28.0% more
transfer 70'949 51'332 +19'617 38.2% more

Note

OpenZeppelin was used for the Solidity ERC20

this was used for the Stylus ERC20

Ed25519

Function Stylus L2 Gas Solidity L2 Gas Difference (L2) % Difference
deploy 3'934'896 + 3'123'366 2'814'629 +1'120'267 39.8% more
verify 38'668 904'435 -865'767 95.7% less

Note

this was used for the Solidity Ed25519

this was used for the Stylus Ed25519

Conclusion

  • For ERC-20 contracts:
    • Stylus deploy costs ~11 times more gas than Solidity...
    • while mint and transfer are also ~28% and ~38% more expensive, respectively

This is somewhat expected, since ERC-20 contracts aren't computationally heavy (no taking advantage of Stylus).

  • For Ed25519 contracts:
    • Stylus deploy costs ~40% more gas than Solidity...
    • but for signature verification, Stylus is ~96% cheaper

This is also expected and is the main takeaway from this benchmark - that Stylus is lot faster when doing heavy computational tasks.

Possible optimizations for the Ed25519 Verification

  • Our Solidity Ed25519 verification costs 904k gas, but some have optimized it to ~500k gas.
  • Using zk-SNARKs, it can go down to 300k gas (and still require off-chain proving).
  • And still, it costs much more than Stylus's <40k gas.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published