{"id":13766748,"url":"https://github.com/huff-language/huff-breakage","last_synced_at":"2025-05-10T22:31:18.639Z","repository":{"id":45002404,"uuid":"513212122","full_name":"huff-language/huff-breakage","owner":"huff-language","description":"Incorrect, Breaking, and Footgunned Huff Contracts.","archived":true,"fork":false,"pushed_at":"2023-03-09T14:24:55.000Z","size":1231,"stargazers_count":30,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-17T02:34:13.819Z","etag":null,"topics":["evm","foundry","huff","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huff-language.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-07-12T16:18:13.000Z","updated_at":"2024-09-09T19:55:34.000Z","dependencies_parsed_at":"2024-02-07T08:52:48.082Z","dependency_job_id":null,"html_url":"https://github.com/huff-language/huff-breakage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huff-language%2Fhuff-breakage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huff-language%2Fhuff-breakage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huff-language%2Fhuff-breakage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huff-language%2Fhuff-breakage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huff-language","download_url":"https://codeload.github.com/huff-language/huff-breakage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253492529,"owners_count":21916959,"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":["evm","foundry","huff","solidity"],"created_at":"2024-08-03T16:01:00.407Z","updated_at":"2025-05-10T22:31:18.117Z","avatar_url":"https://github.com/huff-language.png","language":"Solidity","funding_links":[],"categories":["Official huff-language Github repo"],"sub_categories":[],"readme":"\u003cimg align=\"right\" width=\"150\" height=\"150\" top=\"100\" src=\"./assets/breakage.png\"\u003e\n\n# 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)\n\nA set of **Incorrect**, **Breaking**, and **Footgunned** [Huff](https://github.com/huff-language) Contracts.\n\n## Overview\n\n[huff-breakage](https://github.com/huff-language/huff-breakage) contains many contracts that demonstrate incorrect usage of the [Huff Language](https://huff.sh).\n\nTo reproduce contract errors, make sure `huffc` is installed by running:\n```bash\ncurl -L get.huff.sh | bash\n# `source ~/.bashrc` OR `source ~/.zshrc` OR `source ~/.profile`\nhuffup\n```\n\nThen, 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:\n```bash\nError: Missing Macro Definition For Invocation: \"UNKNOWN\"\n-\u003e src/InvalidMacroInvocation.huff:468-477\n       |\n  \u003e 10 |     UNKNOWN()\n       |\n```\n\n\n## Contracts\n\n_NOTE: Some of the below contracts compile correctly and have a `[COMPILES]` postfix_\n\n```ml\nsrc\n├─ InvalidFunctionVisibility — An invalid function visibility specifier\n├─ InvalidMacroInvocation — An invocation of a macro that doesn't exist\n├─ InvalidMacroStatement — An invalid statement in a macro definition\n├─ MissingConstantDef — A constant definition is missing\n├─ MissingConstructor — A constructor macro definition is missing [COMPILES]\n├─ MissingDefTableSize — Table definition used in __tablesize builtin is missing\n├─ MissingDefTableStart — Table definition used in __tablestart builtin is missing\n├─ TableBuiltins — Table Builtins created on deployment with missing label definitions\n├─ UnmatchedJumpLabel — A jump label that has no matching label definition\n```\n\n## Explanations\n\n_NOTE: Some of the below contracts compile correctly and thus have a `[COMPILES]` postfix_\n\n\u003cdetails\u003e\n\u003csummary\u003eInvalid Function Visibility\u003c/summary\u003e\n\u003cbr /\u003e\nFunctions in huff can only have the visibility specifiers \u003ccode\u003eview\u003c/code\u003e, \u003ccode\u003epure\u003c/code\u003e, \u003ccode\u003epayable\u003c/code\u003e, or \u003ccode\u003enonpayable\u003c/code\u003e. On line 6 of \u003ca href=\"./src/InvalidFunctionVisibility.huff\"\u003eInvalidFunctionVisibility.huff\u003c/a\u003e, the function has a specifier \u003ccode\u003einternal\u003c/code\u003e which is invalid, generating the following error:\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/invalidfunctionvisibility.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eInvalid Macro Invocation\u003c/summary\u003e\n\u003cbr /\u003e\nOn line 10 of \u003ca href=\"./src/InvalidMacroInvocation.huff\"\u003eInvalidMacroInvocation.huff\u003c/a\u003e, we invoke a macro called \u003ccode\u003eUNKNOWN\u003c/code\u003e, but it doesn't exist in either the \u003ccode\u003eInvalidMacroInvocation\u003c/code\u003e Huff contract or any of its imports (there are none in this simple example).\n\u003cbr /\u003e\nThus, the compiler will generate an error message like so when compiling the contract:\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/invalidmacroinvocation.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eInvalid Macro Statement\u003c/summary\u003e\n\u003cbr /\u003e\nOn line 11 of \u003ca href=\"./src/InvalidMacroStatement.huff\"\u003eInvalidMacroStatement.huff\u003c/a\u003e, we make a call to the \u003ccode\u003eFREE_STORAGE_POINTER()\u003c/code\u003e keyword which is invalid within the context of a macro.\n\u003cbr /\u003e\nThus, the compiler will generate an error message like so when compiling the contract:\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/invalidmacrostatement.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eMissing Constant Definition\u003c/summary\u003e\n\u003cbr /\u003e\nOn line 10 of \u003ca href=\"./src/MissingConstantDef.huff\"\u003eMissingConstantDef.huff\u003c/a\u003e, the constant \u003ccode\u003e[UNKNOWN_CONSTANT_DEFINITION]\u003c/code\u003e is referenced (the brackets notate the item's location will be pushed to the stack) but there is no \u003ccode\u003eUNKNOWN_CONSTANT_DEFINITION\u003c/code\u003e definition present in the contract. This will generate an error message similar to below during compilation.\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/missingconstantdef.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eMissing Constructor [COMPILES]\u003c/summary\u003e\n\u003cbr /\u003e\nSince missing constructors are allowed, the \u003ca href=\"./src/MissingConstructor.huff\"\u003eMissingConstructor.huff\u003c/a\u003e contract will compile correctly, producing the below output:\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/missingconstructor.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eMissing Table Definition used in Table Size Builtin\u003c/summary\u003e\n\u003cbr /\u003e\nOn line 7 of \u003ca href=\"./src/MissingDefTableSize.huff\"\u003eMissingDefTableSize.huff\u003c/a\u003e, the table reference \u003ccode\u003eSTANDARD_JUMPTABLE\u003c/code\u003e passed into the \u003ccode\u003e__tablesize()\u003c/code\u003e builtin is missing. This results in the following error being generated:\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/missingdeftablesize.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eMissing Table Definition used in Table Start Builtin\u003c/summary\u003e\n\u003cbr /\u003e\nOn line 7 of \u003ca href=\"./src/MissingDefTableStart.huff\"\u003eMissingDefTableStart.huff\u003c/a\u003e, the table reference \u003ccode\u003eDIFFERENT_TABLE\u003c/code\u003e passed into the \u003ccode\u003e__tablestart()\u003c/code\u003e builtin is missing. This results in the following error being generated:\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/missingdeftablestart.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eMissing Main Macro Definition\u003c/summary\u003e\n\u003cbr /\u003e\n\u003ca href=\"./src/MissingMainMacroDefinition.huff\"\u003eMissingMainMacroDefinition.huff\u003c/a\u003e is missing a `MAIN` macro definition which is invalid behavior as the contract needs an entrypoint.\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/missingmaindef.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eTable Builtins\u003c/summary\u003e\n\u003cbr /\u003e\nOn line 6 of \u003ca href=\"./src/TableBuiltins.huff\"\u003eTableBuiltins.huff\u003c/a\u003e, the builting table contains references to labels that aren't defined, thus causing this contract to fail to compile.\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/tablebuiltins.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eUnmatched Jump Labels\u003c/summary\u003e\n\u003cbr /\u003e\nOn line 16 of \u003ca href=\"./src/UnmatchedJumpLabel.huff\"\u003eUnmatchedJumpLabel.huff\u003c/a\u003e, the jump label \u003ccode\u003eerr\u003c/code\u003e is referenced but there is no matching label definition. This will generate the following \u003ccode\u003eUnmatched Jump Label\u003c/code\u003e error:\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300px\" style=\"display: block; margin: 0 auto\" src=\"./assets/unmatchedjumplabels.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n## Safety Notice\n\nThis is **experimental software** and is provided on an \"as is\" and \"as available\" basis.\n\nWe **do not give any warranties** and **will not be liable for any loss** incurred through any use of this codebase.\n\n\n## Installation\n\nTo install with [**Foundry**](https://github.com/foundry-rs/foundry):\n\n```sh\nforge install huff-language/huff-breakage\n```\n\nTo install with [**Hardhat**](https://github.com/nomiclabs/hardhat) or [**Truffle**](https://github.com/trufflesuite/truffle):\n\n```sh\nnpm install @huff-language/huff-breakage\n```\n\n\n## Acknowledgements\n\n- [huff-rs](https://github.com/huff-language/huff-rs)\n- [huffmate](https://github.com/huff-language) _SOON_\n- [huff-examples](https://github.com/huff-language/huff-examples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuff-language%2Fhuff-breakage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuff-language%2Fhuff-breakage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuff-language%2Fhuff-breakage/lists"}