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

refactor: make ChainSpec associated type on EvmWiring #1791

Closed
wants to merge 1 commit into from

Conversation

Wodann
Copy link
Contributor

@Wodann Wodann commented Sep 19, 2024

This PR proposes a separation between the EvmWiring and ChainSpec such that the associated types of a ChainSpec can be used without the ExternalContext and Database that are only required for the Evm.

This allows re-usage of chain specs for other use cases.

@Wodann Wodann force-pushed the refactor/simplify-evm-wiring branch 2 times, most recently from b5b5da1 to ccc9755 Compare September 19, 2024 22:34
@rakita
Copy link
Member

rakita commented Sep 20, 2024

Something like this is probably possible, if you need to split the trait it can be done outside of Revm:

mod temp {

    pub trait ChainSpec {}

    pub trait ExtCtx {}

    pub trait Database {}

    pub trait PresentWiring {
        /// Chain specification type.
        type ChainSpec: ChainSpec;

        /// External context type
        type ExtCtx: Sized;

        /// Database type.
        type Database: Database;
    }

    pub trait NewChain {
        type ChainSpec: ChainSpec;
        type ExtCtx: ExtCtx;
    }

    pub trait NewWiring {
        type NC: NewChain;
        type Database: Database;
    }

    impl<T: NewWiring> PresentWiring for T {
        type ChainSpec = <<Self as NewWiring>::NC as NewChain>::ChainSpec;
        type ExtCtx = <<Self as NewWiring>::NC as NewChain>::ExtCtx;
        type Database = <Self as NewWiring>::Database;
    }
}

@Wodann
Copy link
Contributor Author

Wodann commented Sep 20, 2024

Something like this is probably possible, if you need to split the trait it can be done outside of Revm:

That is possible indeed.

I was hoping to avoid redefinitions of traits, but we can define our own ChainSpec type instead and reimplement the REVM EvmWiring using that. Thanks!

@rakita
Copy link
Member

rakita commented Sep 23, 2024

Closing this, if there are more things about integration lets talk about it in different issue.

@rakita rakita closed this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants