-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: implement bal specific rpc methods #22406
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
5351c3d
feat(rpc): implement debug_getBlockAccessList (EIP-7928)
mattsse bbca1d5
add basic impl
Soubhik-10 793dd79
fix
Soubhik-10 47a9086
fix
Soubhik-10 28d3532
fix
Soubhik-10 8ffb772
fix
Soubhik-10 c187fdf
fixes
Rimeeeeee 64ca82b
commented tests
Rimeeeeee 6f26265
Merge branch 'bal-devnet-2' into bal-rpc
Soubhik-10 e7503a0
Merge branch 'bal-devnet-2' into bal-rpc
Soubhik-10 5126448
fixes
Rimeeeeee b922a57
Revert "fixes"
Rimeeeeee 3717910
refactor
Rimeeeeee f8ab56b
fixes
Rimeeeeee e5ccabc
refactor
Rimeeeeee d190047
fmt
Soubhik-10 0db8acf
Merge branch 'bal-devnet-2' into bal-rpc
Soubhik-10 e22b98a
clippy
Soubhik-10 71cfe00
apply review
Soubhik-10 b72e991
Merge branch 'bal-devnet-3' into bal-rpc
Soubhik-10 9adb832
chore: added error code
Rimeeeeee 4daef42
removed unused dev dep
Rimeeeeee cb9e519
Merge branch 'bal-devnet-3' into bal-rpc
Soubhik-10 2a44890
fix bal
Soubhik-10 1835675
Merge branch 'bal-devnet-3' into bal-rpc
Soubhik-10 7f7e004
chore: allowed bump index
Rimeeeeee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,65 @@ | ||
| //! Helpers for `eth_blockAccessList` RPC method. | ||
| use alloy_consensus::BlockHeader; | ||
| use alloy_eips::eip7928::BlockAccessList; | ||
| use alloy_primitives::B256; | ||
| use reth_errors::RethError; | ||
| use reth_evm::{block::BlockExecutor, ConfigureEvm}; | ||
| use reth_revm::{database::StateProviderDatabase, State}; | ||
| use reth_rpc_eth_types::{ | ||
| cache::db::StateProviderTraitObjWrapper, error::FromEthApiError, EthApiError, | ||
| }; | ||
| use reth_storage_api::StateProviderFactory; | ||
|
|
||
| use crate::{ | ||
| helpers::{Call, LoadBlock, Trace}, | ||
| RpcNodeCore, | ||
| }; | ||
|
|
||
| /// Helper trait for `eth_blockAccessList` RPC method. | ||
| pub trait GetBlockAccessList: Trace + Call + LoadBlock { | ||
| /// Retrieves the block access list for a block identified by its hash. | ||
| fn get_block_access_list( | ||
| &self, | ||
| block_hash: B256, | ||
| ) -> impl Future<Output = Result<Option<BlockAccessList>, Self::Error>> + Send { | ||
| async move { | ||
| let block = self | ||
| .recovered_block(block_hash.into()) | ||
| .await? | ||
| .ok_or_else(|| EthApiError::HeaderNotFound(block_hash.into()))?; | ||
|
|
||
| self.spawn_blocking_io(move |eth_api| { | ||
| let state = eth_api | ||
| .provider() | ||
| .state_by_block_id(block.parent_hash().into()) | ||
| .map_err(Self::Error::from_eth_err)?; | ||
|
|
||
| let mut db = State::builder() | ||
| .with_database(StateProviderDatabase::new(StateProviderTraitObjWrapper(state))) | ||
| .with_bal_builder() | ||
| .build(); | ||
|
|
||
| let block_txs = block.transactions_recovered(); | ||
| let mut executor = RpcNodeCore::evm_config(ð_api) | ||
| .executor_for_block(&mut db, block.sealed_block()) | ||
| .map_err(RethError::other) | ||
| .map_err(Self::Error::from_eth_err)?; | ||
|
|
||
| executor.apply_pre_execution_changes().map_err(Self::Error::from_eth_err)?; | ||
|
|
||
| // replay all transactions prior to the targeted transaction | ||
| for block_tx in block_txs { | ||
| executor.execute_transaction(block_tx).map_err(Self::Error::from_eth_err)?; | ||
| } | ||
| let _ = executor.apply_post_execution_changes(); | ||
|
|
||
| let bal = db.take_built_alloy_bal().ok_or_else(|| { | ||
| EthApiError::Internal(reth_errors::RethError::msg("BAL not built")) | ||
| })?; | ||
|
|
||
| Ok(Some(bal)) | ||
| }) | ||
| .await | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
| //! Contains RPC handler implementations specific to block access lists. | ||
|
|
||
| use reth_rpc_convert::RpcConvert; | ||
| use reth_rpc_eth_api::{helpers::block_access_list::GetBlockAccessList, FromEvmError, RpcNodeCore}; | ||
| use reth_rpc_eth_types::EthApiError; | ||
|
|
||
| use crate::EthApi; | ||
|
|
||
| impl<N, Rpc> GetBlockAccessList for EthApi<N, Rpc> | ||
| where | ||
| N: RpcNodeCore, | ||
| EthApiError: FromEvmError<N::Evm>, | ||
| Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, Evm = N::Evm>, | ||
| { | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -16,3 +16,4 @@ mod trace; | |
| mod transaction; | ||
|
|
||
| pub use sync_listener::SyncListener; | ||
| pub mod block_access_list; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.