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

feat: allow extending foundry for non-EVM chains via strategy implementation #9651

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

nbaztec
Copy link

@nbaztec nbaztec commented Jan 8, 2025

Motivation

As part of #7624 this would form a way to start formulating an approach in order to extend foundry functionality to non-Ethereum/EVM chains in the least invasive way possible.

These "strategies" can be overridden by forks to implement their own functionality, as is demonstrated in foundry-zksync. At the very least, this gives a place for forks to add custom code that can be called in an idiomatic way, until it can be formulated as an upstream PR.

As an initial step, we went with a dynamic dispatch instead of generics as the generic would be required to be propagated to numerous places, and this PR serves as a good start to initiate a discussion on this approach.

Solution

In places of interest - Executor, Backend and Cheatcodes (identified so far), a stateless "strategy" would be provided that works with a context object Box<Any> that may be mutated. This allows for forks to implement their own behavior and keep their state separate in the context. The standard "foundry way" is currently encapsulated in the EvmStrategy, which is the default.
Forks are expected to modify the utils::get_executor_strategy(&config)(example) to return a strategy of choice depending upon the config.

Future Goals

The stateless nature of strategy makes it possible to remove the &self objects, which are currently required for object safety, and thereby being declared on the generic type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant