Coder Social home page Coder Social logo

1-4200 / upgradeable-storage-checks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emo-eth/upgradeable-storage-checks

0.0 0.0 0.0 7 KB

Example setup of Forge tests and CI to do basic checks for storage collisions when iterating on upgradeable contract implementations.

Shell 19.82% Solidity 80.18%

upgradeable-storage-checks's Introduction

Upgradeable Storage Checks

Included are a set of proof-of-concept tests and tools for using forge inspect and Forge's filesystem cheatcodes to do basic checks for incompatible storage updates among versions of an upgradeable implementation.

Note that it currently does not account for fixed-length array types, ie, if a fixed-length array is shortened but has a dirty slot, and a new storage variable replaces that slot, the test will not pick that up (yet).

Also note that it will break if private variables are introduced between two private variables from inherited contracts with the same name, eg, a new __gap variable is introduced in slots between two other private __gap variables.

Usage

watched_contracts.txt

A list of contract names (e.g. "ExampleFile") that we should check layouts of. There should be one name per line, and end with a newline. The other helper scripts will do their best to append a newline to the file.

generate_latest_layouts.sh

A bash script that generates "<contract name>_latest.json" files for each contract included in watched_contracts.txt. Layouts are written to the storage_layouts folder. These will be compared against the "<contract name>.json" files.

Run with bash generate_latest_layouts.sh

copy_latest_layouts.sh

A bash script that copies the contents of the "<contract name>_latest.json" files to versions without the _latest suffix. This effectively "finalizes" a new storage layout once committed.

Run with bash copy_latest_layouts.sh

StorageLayout.t.sol

This test reads from watched_contracts.txt and tries to load the appropriate JSON files to compare the storage layouts. The tests will fail if two associated labels slots or offsets do not match.

upgradeable-storage-checks's People

Contributors

jameswenzel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.