NomicFoundation / edr

An Ethereum development runtime implementation that can be reused to build new developer tools.
MIT License
32 stars 3 forks source link

refactor: make blockchain types generic #513

Closed Wodann closed 2 weeks ago

Wodann commented 2 weeks ago

This PR adds a trait ChainSpec to edr_evm that allows specification of chain-specific internal/engine types. For now, we only deal with with L1 Ethereum.

Future work will implement a block builder and miner for Optimism and abstract that using a trait.

I used three traits IntoRemoteBlock, EthRpcBlock, and EthRpcTransaction to access the values that are required for state and blockchain implementations. I don't think this is particularly elegant, especially the IntoRemoteBlock but I wasn't sure what better way to abstract them.

I'm open to suggestions for how I might be better able to abstract the information that needs to be retrieved from ChainSpec::RpcBlock. For now I stuck with this design, as it's hard to predict what this will look like with more chain types. As it stands, it is relatively easy to change the API in the future; e.g. if another chain type requires access to more properties of the RPC block or transaction.

changeset-bot[bot] commented 2 weeks ago

⚠️ No Changeset found

Latest commit: a60e79318138bf2cfeeb84801c823c5c0a625f45

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR