Giter Site home page Giter Site logo

Comments (3)

0xPhaze avatar 0xPhaze commented on June 12, 2024 1

That does make sense.
https://docs.soliditylang.org/en/latest/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode
I could match for that part and exclude it.

from upgrade-scripts.

0xPhaze avatar 0xPhaze commented on June 12, 2024

The thing is that in that case, your bytecode will have changed, that's why it's re-deploying. As a quick fix, you can add the parameter keepExisting = true to setUpContract / setUpProxy and manually set it to false once you want to explicitly have new deployments (or use the global var UPGRADE_SCRIPTS_KEEP_EXISTING=true.
Also, be sure to compile the contracts without a metadata hash (foundry.toml setting: bytecode_hash = "none") which may change the bytecode due to comments being altered. Checking for functional equality of the code would be too hard to do.

And I would love to make the script detecting storage layout changes smarter by parsing the ast output or performing some other more in-depth storage analysis, but for the moment I don't feel knowledgable enough to catch odd edge cases. That's why it's better to err on the cautious side, but I might look into that more.

from upgrade-scripts.

KholdStare avatar KholdStare commented on June 12, 2024

Thanks for pointing out the bytecode_hash = "none" option. Unfortunately we don't want to turn that off so that we can verify.

Here is my intuition - Currently because bytecode_hash = "ipfs" for verification purposes, the "overall" bytecode changes even when there are cosmetic changes. However let's say that the "implementation" portion of the bytecode, what is essentially generated when bytecode_hash = "none", remains unchanged. In these cases, it doesn't make sense to redeploy the contract.

I wonder if it would be possible in pseudocode:

function needsUpgrade() returns (bool) {
  if (oldImplementationAddress == newImplementationAddress) return false;

  console.log("Need upgrade");
  
  if (oldBytecodeWithoutHash == newBytecodeWithoutHash && UPGRADE_SCRIPTS_SKIP_METADATA_CHANGE) {
    console.log("Skipping upgrade because only metadata changed");
    return false;
  }

  return true;
}

Not sure if it's easily possible to get the bytecode of a contract without the hash inside upgrade scripts themselves.

Does it make sense?

from upgrade-scripts.

Related Issues (6)

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.