Skip to content

huff-language/huff-breakage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

huff-breakage • ci license solidity

A set of Incorrect, Breaking, and Footgunned Huff Contracts.

Overview

huff-breakage contains many contracts that demonstrate incorrect usage of the Huff Language.

To reproduce contract errors, make sure huffc is installed by running:

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:

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

src
├─ InvalidFunctionVisibilityAn invalid function visibility specifier
├─ InvalidMacroInvocationAn invocation of a macro that doesn't exist
├─ InvalidMacroStatementAn invalid statement in a macro definition
├─ MissingConstantDefA constant definition is missing
├─ MissingConstructorA constructor macro definition is missing [COMPILES]
├─ MissingDefTableSizeTable definition used in __tablesize builtin is missing
├─ MissingDefTableStartTable definition used in __tablestart builtin is missing
├─ TableBuiltinsTable Builtins created on deployment with missing label definitions
├─ UnmatchedJumpLabelA 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 specifiers view, pure, payable, or nonpayable. On line 6 of InvalidFunctionVisibility.huff, the function has a specifier internal which is invalid, generating the following error:

Invalid Macro Invocation
On line 10 of InvalidMacroInvocation.huff, we invoke a macro called UNKNOWN, but it doesn't exist in either the InvalidMacroInvocation 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 the FREE_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 no UNKNOWN_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 reference STANDARD_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 reference DIFFERENT_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 label err is referenced but there is no matching label definition. This will generate the following Unmatched 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:

forge install huff-language/huff-breakage

To install with Hardhat or Truffle:

npm install @huff-language/huff-breakage

Acknowledgements

About

Incorrect, Breaking, and Footgunned Huff Contracts.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published