Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Oct 20, 2024. It is now read-only.
/huff-rsPublic archive

A low-level assembly language for the Ethereum Virtual Machine built in blazing-fast pure rust.

License

NotificationsYou must be signed in to change notification settings

huff-language/huff-rs

Repository files navigation

Warning

huff-rs (akalegacy huff) is deprecated and no longer maintained, go seehuff2 for the renewed compiler.

huff-rs •ciLicenseCrates.ioDiscord

huff-rs is aHuff compiler built in rust.

What is a Huff?

Huff is a low-level programming language designed for developing highly optimized smart contracts that run on the Ethereum Virtual Machine (EVM). Huff does not hide the inner workings of the EVM. Instead, Huff exposes its programming stack to the developer for manual manipulation.

Rather than having functions, Huff has macros - individual blocks of bytecode that can be rigorously tested and evaluated using the Huff runtime testing suite.

Huff was originally developed by the Aztec Protocol team to writeWeierstrudel. Weierstrudel is an on-chain elliptical curve arithmetic library that requires incredibly optimized code that neitherSolidity norYul could provide.

While EVM experts can use Huff to write highly-efficient smart contracts for use in production, it can also serve as a way for beginners to learn more about the EVM.

To dive deeper intoHuff, visit theOfficial Huff Docs(also available ongithub).

Installation

Something not working? Send a message indiscord.

First run the command below to gethuffup, the Huff installer:

curl -L get.huff.sh| bash

To avoid redirecting the script directly into bash, download and run thehuffup installation script.

To install the Huff compiler, simply runhuffup.

If you have the oldhuffc (TypeScript version) npm package installed globally, you can remove it with:

sudo yarn global remove huffc

To make sure you are running the rust version, you can runhuffc --version and it should respond withhuff_cli <version>. If it responds with2.0.0 that means you are running the Typescript version.

$ huffc --versionhuff_cli 0.3.2

Alternatively

Install from source by running:

git clone https://raw.githubusercontent.com/huff-language/huff-rscd huff-rscargo install --path ./huff_cli --bins --locked --force

OR

cargo install --git https://raw.githubusercontent.com/huff-language/huff-rs --locked huff_cli

How Fast?

Compilation Benchmarks

CompilerCold (No Cache)Light CacheDeep CacheFull Cache
[huff-language/huff-rs][huff-rs]XXXmsXXXmsXXXmsXXXms
[huff-language/huffc][huffc]XXXmsXXXmsXXXmsXXXms

Note: Compilation benchmarks were performed onhuff-examples erc20.

Architecture

Huff Compiler Architecture

Modules

  • huff_core: The core module to huff-rs. Resolves source file paths, executes compilation, and exports artifacts.
  • huff_cli: The command line interface for the Huff compiler.
  • huff_js: A wasm compatible interface to the Huff compiler for JavaScript bindings.
  • huff_lexer: Takes in the source of a.huff file and generates a vector ofTokens.
  • huff_parser: Crafts aContract AST from the vector ofTokens generated byhuff_lexer.
  • huff_codegen: EVM Bytecode generation module that accepts an AST generated byhuff_parser.
  • huff_utils: Various utilities and types used by all modules.
  • huffup: Update or revert to a specific huff-rs branch with ease. (Forked fromfoundry)

Contributing

All contributions are welcome! We want to make contributing to this project as easy and transparent as possible, whether it's:

  • Reporting a bug
  • Discussing the current state of the code
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

We use GitHub issues to track public bugs. Report a bug byopening a new issue; it's that easy!

To run examples, make sure you update git submodules to pull down thehuff-examples submodule by runninggit submodule update.

The branching convention used byhuff-rs is astage branch that is meant to be merged off of and is periodically merged intomain. So, when creating a feature, branch off of thestage branch and create a pr from your branch into thestage branch!

i.e:Branching Conventions

To pass github actions, please run:

cargo check --allcargotest --all --all-featurescargo +nightly fmt -- --checkcargo +nightly clippy --all --all-features -- -D warnings

In order to fix any formatting issues, run:

cargo +nightly fmt --all

Recommended PR Template

Here is an example PR template - not strictly required, but will greatly improve the speed at which your PR is reviewed & merged!

##Overview<Provide a general overview of what your pr accomplishes, why, and how (including links)>##Checklist-[x] <Ex: Added a`new` method to the Huff Lexer[here](./huff_lexer/src/lib.rs#50)>-[x] <Ex: Fully tested the`new` method[here](./huff_lexer/tests/new.rs)>-[ ] <Ex: Wrote documentation for the`new` method[here](./huff_lexer/README.md#20)>

When the PR checklist isn't complete, it ishighly recommended to make it a draft PR. NOTE: if your PR is not complete, it will likely be changed to a draft by one of the repository admins.

For breaking changes: make sure to edit theexcalidraw asset and export the file to./assets/huffc.excalidraw along with an image to./assets/huffc.png.

Safety

Warning

This isexperimental software and is provided on an "as is" and "as available" basis.Expect rapid iteration anduse at your own risk.

This code isnot designed for safety.

  • There are untested invariants in the code that may break.
  • You can easily shoot yourself in the foot if you're not careful.
  • You should thoroughly read the documentation and examples.

Wedo not give any warranties andwill not be liable for any loss incurred through any use of this codebase.

Acknowledgements

The originalHuff Language compiler:huffc.

An exemplary, minimal rust compiler:ripc.

Foundry, for the many scripts, documentation, devops, and code on whichhuff-rs is based on.

Allhuff-rs contributors, users, advocates, and enthusiasts!


[8]ページ先頭

©2009-2025 Movatter.jp