Giter VIP home page Giter VIP logo

metacontract / mc Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 2.0 677 KB

Meta Contract library is a collection of helpful contracts for developing smart contracts with the MC-DevKit, including standard function contracts. It leverages the DevX to make developing smart contracts, writing deployment scripts and tests easier and faster. For more in-depth usage examples, check out the tests.

License: MIT License

Solidity 100.00%
devkit ethereum smartcontract solidity testing

mc's People

Contributors

0xhaku avatar kaihiroi avatar shogochiai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mc's Issues

Clean install and errors: Mutable dev script is in the immutable view function.

When I tried a clean installation of TextDAO:4b1083d and then I got error below.

$ forge test                              
[⠢] Compiling...
[⠒] Compiling 110 files with 0.8.25
[⠢] Solc 0.8.25 finished in 753.71ms
Error: 
Compiler run failed:
(skip)
Error (8961): Function cannot be declared as view because this expression (potentially) modifies the state.
  --> lib/mc/devkit/utils/ForgeHelper.sol:27:16:
   |
27 |         return vm.envOr(envKey, address(0));
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (8961): Function cannot be declared as view because this expression (potentially) modifies the state.
  --> lib/mc/devkit/utils/ForgeHelper.sol:32:13:
   |
32 |         if (vm.envOr(envKey, address(0)).code.length != 0) return true;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (8961): Function cannot be declared as view because this expression (potentially) modifies the state.
  --> lib/mc/devkit/utils/ForgeHelper.sol:59:16:
   |
59 |         return vm.getLabel(addr);
   |                ^^^^^^^^^^^^^^^^^
(skip)
Error (8961): Function cannot be declared as view because this expression (potentially) modifies the state.
  --> lib/mc/devkit/MCBase.sol:30:16:
   |
30 |         return vm.envOr(keyword, addr);
   |                ^^^^^^^^^^^^^^^^^^^^^^^

Just removing view and it will be fixed.

Modifier naming

function propose() public predicates (link) is a bit non-intuitive.

I prefer function main() public executable or function run() public runnable for emphasising the principal function. (The "main/run" common naming can be much abstract and somewhat handy for multi-ops composability related matter.)

Temporarily Disable Verifiability Check on Broadcast Until --broadcast Detection is Implemented

I've added code to check if a Dictionary is verifiable when deploying a Proxy and registering a Facade. This has inadvertently caused extra transactions to dictionary.implementation() during broadcast. A feature to detect if --broadcast is active is currently in development (foundry-rs/foundry#7377). Once implemented, I plan to adjust the code to only perform this check during a dry run. Until then, I will temporarily comment out this check.

Deployer says Stack Too Deep

Deployment.s.sol with certain complexity insists it is reached to "Stack too deep".

forge <subcommand> --via-ir evades that error but compilation is gonna be way too slow.

I guess JIT EVM can compress deployment code into LLVM and no stack problem would be shown tho. Let's discuss here.

feat: Facade Generator

ffi

  • errors

  • events

  • external functions

  • Facade Generator

    • Gen & Set Facade in deploy sequence

[Tasks] Repository Management

GitHub

  • Templates
    • Create pull request template (.github/PULL_REQUEST_TEMPLATE.md)
    • Create issue templates (.github/ISSUE_TEMPLATE/**)
      • Bug report
      • Feature request
      • Support request
      • New release
  • Settings
    • Set up branch protection rules
      • Require a pull request before merging
      • Require status checks to pass before merging
      • Require conversation resolution before merging
      • Require signed commits
      • Include administrators
    • Create organization project & link board
      • Todo, InProgress, InReview, Done
    • Set up issue and pull request labels
  • GitHub Actions (Workflows)
    • Continuous Integration
      • Create .github/workflows/ci.yml
      • Set up jobs
        • format-check
          • setup forge fmt
        • tests
        • slither
        • coverage
    • Review Workflow Changes
      • Set up review CI for workflow definition files

Documentation

  • README
    • Create README.md
    • Contents
      • Project overview
      • Installation instructions
      • Documentation guide
      • Contributing guide
      • License guide
  • Changelog
    • Create CHANGELOG.md
    • Contents
      • Changelog overview
      • Example release log
  • Contributing guidelines
    • Create CONTRIBUTING.md
    • Contents
      • Greeting
      • Reporting issues guide
      • Submitting pull requests guide
      • Coding style guide
      • Release process guide
      • Versioning policy
      • Changelog rules guide
  • Code of Conduct
    • Create CODE_OF_CONDUCT.md with Template
    • Fill the contract method
  • Security policy
  • License
    • Create LICENSE.md (blocking task: choose license)

Need to decide

  • Choose appropriate license like MIT, Apache 2.0, GNU GPL
    • MIT
  • Determine versioning strategy (Semantic Versioning, CalVer, etc.)
    • SemVer

Notifications and Reporting

  • Set up status badges for the README
  • Decide on the communication channel for the community (Telegram, Discord, Slack, Discourse, etc.)
    • Evaluate the features and limitations of each platform
    • Consider the preferences and familiarity of the team and community members
    • Choose the most suitable platform based on the project's needs
  • Set up notifications and report generation for the selected communication channel
    • Add notification job
    • Configure various report outputs (coverage, analysis results, etc.)

Better test

UsePredicate and predicates modifier are intuitively hardher to get how to use from the current test.

StorageReader does not work when the schema includes a mapping

  • By defining StorageReader as a library, it becomes possible to handle storage returns (StorageReader should only be used during testing, so this shouldn't be a problem).

  • In the test contract, register the dictionary of the deployed mc, and set it to make delegatecalls to the proxy and save the state in the test contract. This way, the StorageReader library can be used to read the state.

    • However, when using this method, developers must specify delegatecall every time they access mc, which reduces readability. Therefore, an appropriate wrapper contract needs to be prepared (TODO).
    • Moreover, when writing tests that handle multiple mcs, only one dictionary can be registered in the test contract (requiring clever solutions like integrating dictionaries).

[Tasks] DevKit

Methods

  • mc.set() overloads

Validation

  • A function to check if the appropriate ERC-7201 slots are specified

Deployment

  • Enhance UCS Contract with CREATE2 Compatibility
  • Facade Generator

Testing

  • State Fuzzing
  • Mock Contracts
  • Storage Reader

Debugger

Clean install and errors: "this.setImplementation"

When I tried a clean installation of TextDAO:4b1083d and then I got error below.

this.setImplementation solved this compilation error.

P.S. ofc if we have CI flow and better specs, those errors would be detected beforehand tho.

$ forge test
[⠆] Compiling...
[⠒] Compiling 110 files with 0.8.25
[⠑] Solc 0.8.25 finished in 221.25ms
Error: 
Compiler run failed:
Error (7576): Undeclared identifier.
  --> lib/mc/devkit/test/MockDictionary.sol:15:13:
   |
15 |             setImplementation(functionInfos[i].selector, functionInfos[i].implementation);
   |             ^^^^^^^^^^^^^^^^^

Older Solidity version support

As per current commit (257d4f5), Solidity v0.8.24 is the supported version for the meta contract framework.

I'm building slot extractor here and it requires AST of Schema.sol.

Status Quo

  • With some version of Foundry and Solidity, we can get out/Schema.sol/Schema.json with has valid ast field.
  • Latest Foundry and Solidity v0.8.24 didn't give us that.
  • solc-typed-ast is only supporting until Solidity v0.8.17

Preferred Requirement

  • mc to support Solidity v0.8.17

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.