-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: chain-specific N-API (#633)
- Loading branch information
Showing
69 changed files
with
4,751 additions
and
5,589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nomicfoundation/edr": minor | ||
--- | ||
|
||
Replaces the Provider constructor with an API for registering and creating chain-specific providers in the EdrContext |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Multi-chain | ||
|
||
EDR supports multiple Ethereum chains. This chapter explores how to add your own chain to EDR & Hardhat. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Chain Specification | ||
|
||
EDR uses a concept called _chain specification_ to define all necessary types and functionality to support an Ethereum chain at compile-time. | ||
|
||
This is achieved through the usage of multiple traits, some of which are supertraits of each other, providing increasing scope of functionality in the EDR ecosystem: | ||
|
||
- Revm primitives: `revm_primitives::EvmWiring` | ||
- Implements the main trait for implementing associated chain-specific primitive types. | ||
- Revm: `revm::EvmWiring` | ||
- Adds an additional function to `revm_primitives::EvmWiring` that depends on the `Evm`. | ||
- Header builder: `edr_eth::EthHeaderConstants` | ||
- RPC client: `edr_rpc_eth::RpcSpec` | ||
- EVM runtime: `edr_evm::ChainSpec` | ||
- EVM provider: `edr_provider::ProviderSpec` | ||
- EDR N-API bindings: `edr_napi::SyncNapiSpec` | ||
|
||
Most of these traits have a `Sync*` equivalent (e.g. `SyncChainSpec`) which is automatically implemented for types that are `Send` and `Sync`. | ||
|
||
## Supported Chain Types | ||
|
||
Currently, EDR supports the following chain types out-of-the-box. | ||
|
||
- L1 Ethereum | ||
- Optimism | ||
|
||
## Adding your own Chain Type | ||
|
||
To add a new chain type, add a new unit struct. E.g. | ||
|
||
```rs | ||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, RlpEncodable)] | ||
pub struct GenericChainSpec; | ||
``` | ||
|
||
Depending on which functionality you want to support for your chain type, you can implement some or all of the traits outlined [above](#chain-specification). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.