Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huff-language/huff-breakage
Incorrect, Breaking, and Footgunned Huff Contracts.
https://github.com/huff-language/huff-breakage
evm foundry huff solidity
Last synced: about 1 month ago
JSON representation
Incorrect, Breaking, and Footgunned Huff Contracts.
- Host: GitHub
- URL: https://github.com/huff-language/huff-breakage
- Owner: huff-language
- License: apache-2.0
- Created: 2022-07-12T16:18:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-09T14:24:55.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T16:09:15.812Z (5 months ago)
- Topics: evm, foundry, huff, solidity
- Language: Solidity
- Homepage:
- Size: 1.17 MB
- Stars: 30
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-huff - huff-breakage
README
# huff-breakage • [![ci](https://github.com/huff-language/huff-breakage/actions/workflows/ci.yaml/badge.svg)](https://github.com/huff-language/huff-breakage/actions/workflows/ci.yaml) [![license](https://img.shields.io/badge/License-Apache_2.0-blue.svg?label=license)](https://opensource.org/licenses/Apache-2.0) ![solidity](https://img.shields.io/badge/solidity-%3E%3D%200.8.13-lightgrey)
A set of **Incorrect**, **Breaking**, and **Footgunned** [Huff](https://github.com/huff-language) Contracts.
## Overview
[huff-breakage](https://github.com/huff-language/huff-breakage) contains many contracts that demonstrate incorrect usage of the [Huff Language](https://huff.sh).
To reproduce contract errors, make sure `huffc` is installed by running:
```bash
curl -L get.huff.sh | bash
# `source ~/.bashrc` OR `source ~/.zshrc` OR `source ~/.profile`
huffup
```Then, compile a given contract to view the error message. For example, to view an invalid macro invocation error, run `huffc -b ./src/InvalidMacroInvocation.huff`, which will produce output similar to:
```bash
Error: Missing Macro Definition For Invocation: "UNKNOWN"
-> src/InvalidMacroInvocation.huff:468-477
|
> 10 | UNKNOWN()
|
```## Contracts
_NOTE: Some of the below contracts compile correctly and have a `[COMPILES]` postfix_
```ml
src
├─ InvalidFunctionVisibility — An invalid function visibility specifier
├─ InvalidMacroInvocation — An invocation of a macro that doesn't exist
├─ InvalidMacroStatement — An invalid statement in a macro definition
├─ MissingConstantDef — A constant definition is missing
├─ MissingConstructor — A constructor macro definition is missing [COMPILES]
├─ MissingDefTableSize — Table definition used in __tablesize builtin is missing
├─ MissingDefTableStart — Table definition used in __tablestart builtin is missing
├─ TableBuiltins — Table Builtins created on deployment with missing label definitions
├─ UnmatchedJumpLabel — A jump label that has no matching label definition
```## Explanations
_NOTE: Some of the below contracts compile correctly and thus have a `[COMPILES]` postfix_
Invalid Function Visibility
Functions in huff can only have the visibility specifiersview
,pure
,payable
, ornonpayable
. On line 6 of InvalidFunctionVisibility.huff, the function has a specifierinternal
which is invalid, generating the following error:
Invalid Macro Invocation
On line 10 of InvalidMacroInvocation.huff, we invoke a macro calledUNKNOWN
, but it doesn't exist in either theInvalidMacroInvocation
Huff contract or any of its imports (there are none in this simple example).
Thus, the compiler will generate an error message like so when compiling the contract:
Invalid Macro Statement
On line 11 of InvalidMacroStatement.huff, we make a call to theFREE_STORAGE_POINTER()
keyword which is invalid within the context of a macro.
Thus, the compiler will generate an error message like so when compiling the contract:
Missing Constant Definition
On line 10 of MissingConstantDef.huff, the constant[UNKNOWN_CONSTANT_DEFINITION]
is referenced (the brackets notate the item's location will be pushed to the stack) but there is noUNKNOWN_CONSTANT_DEFINITION
definition present in the contract. This will generate an error message similar to below during compilation.
Missing Constructor [COMPILES]
Since missing constructors are allowed, the MissingConstructor.huff contract will compile correctly, producing the below output:
Missing Table Definition used in Table Size Builtin
On line 7 of MissingDefTableSize.huff, the table referenceSTANDARD_JUMPTABLE
passed into the__tablesize()
builtin is missing. This results in the following error being generated:
Missing Table Definition used in Table Start Builtin
On line 7 of MissingDefTableStart.huff, the table referenceDIFFERENT_TABLE
passed into the__tablestart()
builtin is missing. This results in the following error being generated:
Missing Main Macro Definition
MissingMainMacroDefinition.huff is missing a `MAIN` macro definition which is invalid behavior as the contract needs an entrypoint.
Table Builtins
On line 6 of TableBuiltins.huff, the builting table contains references to labels that aren't defined, thus causing this contract to fail to compile.
Unmatched Jump Labels
On line 16 of UnmatchedJumpLabel.huff, the jump labelerr
is referenced but there is no matching label definition. This will generate the followingUnmatched Jump Label
error:
## Safety Notice
This is **experimental software** and is provided on an "as is" and "as available" basis.
We **do not give any warranties** and **will not be liable for any loss** incurred through any use of this codebase.
## Installation
To install with [**Foundry**](https://github.com/foundry-rs/foundry):
```sh
forge install huff-language/huff-breakage
```To install with [**Hardhat**](https://github.com/nomiclabs/hardhat) or [**Truffle**](https://github.com/trufflesuite/truffle):
```sh
npm install @huff-language/huff-breakage
```## Acknowledgements
- [huff-rs](https://github.com/huff-language/huff-rs)
- [huffmate](https://github.com/huff-language) _SOON_
- [huff-examples](https://github.com/huff-language/huff-examples)