Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin system #706

Closed
jrhe opened this issue Feb 8, 2022 · 3 comments
Closed

Plugin system #706

jrhe opened this issue Feb 8, 2022 · 3 comments
Labels
A-extensions Area: extensions C-forge Command: forge D-hard Difficulty: hard P-low Priority: low T-feature Type: feature

Comments

@jrhe
Copy link
Contributor

jrhe commented Feb 8, 2022

Component

Other (please describe)

Describe the feature you would like

A plugin system to add additional tasks to both forge and cast is desirable.

  • Users expect to be able to extend tooling, both with existing tools and their own scripts. I think this is probably particularly true for those coming from hardhat.
  • Implementing a plugin system allows the scope of foundry to stay focused on testing/ building and chain interaction.
  • Keeps the surface area of both forge and cast small, making them easier to learn and use.
  • Can wrap functionality from other tools easily without re-implementing.

To illustrate, #610 suggests adding functionality to print the variable layout of a contract. This functionality is clearly useful, however:

  • it doesn't obviously fall under the scope of forge or cask.
  • the functionality is already implemented in slither and there is no obvious reason to reimplement it (speed etc).
  • I expect the implementation would be fairly large, to be done in a reasonable way.
  • it's not clear why you'd stop at just this one printer/ analysis out of the whole suite that slither implements.

Instead, a slither plugin could provide optional static analysis functionality from within foundry.

Additional context

No response

@ayushm2003
Copy link
Contributor

Clap allows external commands by enabling external_subcommands. But this doesn't help in actually calling the asked command.

Cargo too allows external subcommands so I looked at some of its code to see how it invokes the called function. Looks like it internally makes use of std::process::Command. Can read some snippets here, here and here.

Maybe we can do this too, so a possible flow could look like -

  • User implements plugins as a separate cli app on their system
  • Sets the path to this program as env or smthng (cargo somehow searches for the command but probably overkill for our purpose)
  • If foundry detects an unknown command, it uses std::process::Command to call the cli app with the arguments.

Would love everyone's thoughts on this and any other ways we can implement plugins.

@onbjerg
Copy link
Member

onbjerg commented Feb 19, 2022

I think another consideration for the plugin system is what kind of API we would expose, which requires us to think about some possible plugins that people would want to create. For example, I'd assume a lot of plugins would need access to things like the project config, artifacts and sources

@zerosnacks
Copy link
Member

zerosnacks commented Jul 5, 2024

Hi @jrhe thanks for sharing your thoughts on plugins / extensions!

I'm supportive of adding extensions to Foundry, tracking extension related tickets here: A-extensions Area: extensions

Would appreciate your latest thoughts on the topic in the extensions meta-tracking ticket: #8266

Closing this ticket (as duplicate) in favor of that one.

@zerosnacks zerosnacks closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2024
@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-extensions Area: extensions C-forge Command: forge D-hard Difficulty: hard P-low Priority: low T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

4 participants