mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: Alloy migration (#4737)
Co-authored-by: Alessandro Mazza <121622391+alessandromazza98@users.noreply.github.com> Co-authored-by: Supernovahs.eth <91280922+supernovahs@users.noreply.github.com> Co-authored-by: Oliver Nordbjerg <hi@notbjerg.me>
This commit is contained in:
@ -65,7 +65,7 @@ These traits are defined as follows:
|
||||
[Crate: crates/rlp](https://github.com/paradigmxyz/reth/tree/1563506aea09049a85e5cc72c2894f3f7a371581/crates/rlp)
|
||||
```rust, ignore
|
||||
pub trait Decodable: Sized {
|
||||
fn decode(buf: &mut &[u8]) -> Result<Self, DecodeError>;
|
||||
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self>;
|
||||
}
|
||||
pub trait Encodable {
|
||||
fn encode(&self, out: &mut dyn BufMut);
|
||||
@ -127,7 +127,7 @@ impl Encodable for TransactionSigned {
|
||||
}
|
||||
|
||||
impl Decodable for TransactionSigned {
|
||||
fn decode(buf: &mut &[u8]) -> Result<Self, DecodeError> {
|
||||
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
|
||||
// Implementation omitted for brevity
|
||||
//...
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ pub struct NetworkConfig<C> {
|
||||
/// The id of the network
|
||||
pub chain: Chain,
|
||||
/// Genesis hash of the network
|
||||
pub genesis_hash: H256,
|
||||
pub genesis_hash: B256,
|
||||
/// The [`ForkFilter`] to use at launch for authenticating sessions.
|
||||
///
|
||||
/// See also <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2124.md#stale-software-examples>
|
||||
@ -279,7 +279,7 @@ pub struct StateFetcher {
|
||||
HashMap<PeerId, Request<HeadersRequest, PeerRequestResult<Vec<Header>>>>,
|
||||
/// Currently active [`GetBlockBodies`] requests
|
||||
inflight_bodies_requests:
|
||||
HashMap<PeerId, Request<Vec<H256>, PeerRequestResult<Vec<BlockBody>>>>,
|
||||
HashMap<PeerId, Request<Vec<B256>, PeerRequestResult<Vec<BlockBody>>>>,
|
||||
/// The list of _available_ peers for requests.
|
||||
peers: HashMap<PeerId, Peer>,
|
||||
/// The handle to the peers manager
|
||||
@ -309,7 +309,7 @@ pub struct NetworkState<C> {
|
||||
/// Network discovery.
|
||||
discovery: Discovery,
|
||||
/// The genesis hash of the network we're on
|
||||
genesis_hash: H256,
|
||||
genesis_hash: B256,
|
||||
/// The type that handles requests.
|
||||
///
|
||||
/// The fetcher streams RLPx related requests on a per-peer basis to this type. This type will
|
||||
@ -334,7 +334,7 @@ impl HeadersClient for FetchClient {
|
||||
}
|
||||
|
||||
impl BodiesClient for FetchClient {
|
||||
async fn get_block_bodies(&self, request: Vec<H256>) -> PeerRequestResult<Vec<BlockBody>> {
|
||||
async fn get_block_bodies(&self, request: Vec<B256>) -> PeerRequestResult<Vec<BlockBody>> {
|
||||
let (response, rx) = oneshot::channel();
|
||||
self.request_tx.send(DownloadRequest::GetBlockBodies { request, response })?;
|
||||
rx.await?
|
||||
@ -602,7 +602,7 @@ The `GetBlockBodies` payload is simpler, it just contains a vector of requested
|
||||
```rust,ignore
|
||||
pub struct GetBlockBodies(
|
||||
/// The block hashes to request bodies for.
|
||||
pub Vec<H256>,
|
||||
pub Vec<B256>,
|
||||
);
|
||||
```
|
||||
|
||||
@ -826,7 +826,7 @@ Begins by inserting a `Peer` into `TransactionsManager.peers` by `peer_id`, whic
|
||||
```rust,ignore
|
||||
struct Peer {
|
||||
/// Keeps track of transactions that we know the peer has seen.
|
||||
transactions: LruCache<H256>,
|
||||
transactions: LruCache<B256>,
|
||||
/// A communication channel directly to the session task.
|
||||
request_tx: PeerRequestSender,
|
||||
}
|
||||
@ -878,7 +878,7 @@ Next in the `poll` method, `TransactionsCommand`s sent through the `Transactions
|
||||
[File: crates/net/network/src/transactions.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/transactions.rs)
|
||||
```rust,ignore
|
||||
enum TransactionsCommand {
|
||||
PropagateHash(H256),
|
||||
PropagateHash(B256),
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ Following a successful `BodyStage`, the `SenderRecoveryStage` starts to execute.
|
||||
|
||||
[File: crates/primitives/src/transaction/signature.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/primitives/src/transaction/signature.rs)
|
||||
```rust,ignore
|
||||
pub(crate) fn recover_signer(&self, hash: H256) -> Option<Address> {
|
||||
pub(crate) fn recover_signer(&self, hash: B256) -> Option<Address> {
|
||||
let mut sig: [u8; 65] = [0; 65];
|
||||
|
||||
sig[0..32].copy_from_slice(&self.r.to_be_bytes::<32>());
|
||||
|
||||
@ -31,10 +31,10 @@ Below, you can see the table design that implements this scheme:
|
||||
erDiagram
|
||||
CanonicalHeaders {
|
||||
u64 BlockNumber "PK"
|
||||
H256 HeaderHash "Value for CanonicalHeaders"
|
||||
B256 HeaderHash "Value for CanonicalHeaders"
|
||||
}
|
||||
HeaderNumbers {
|
||||
H256 BlockHash "PK"
|
||||
B256 BlockHash "PK"
|
||||
u64 BlockNumber
|
||||
}
|
||||
Headers {
|
||||
@ -59,7 +59,7 @@ Transactions {
|
||||
TransactionSignedNoHash Data
|
||||
}
|
||||
TxHashNumber {
|
||||
H256 TxHash "PK"
|
||||
B256 TxHash "PK"
|
||||
u64 TxNumber
|
||||
}
|
||||
TransactionBlock {
|
||||
@ -71,7 +71,7 @@ Receipts {
|
||||
Receipt Data
|
||||
}
|
||||
Bytecodes {
|
||||
H256 CodeHash "PK"
|
||||
B256 CodeHash "PK"
|
||||
Bytes Code
|
||||
}
|
||||
PlainAccountState {
|
||||
@ -80,36 +80,36 @@ PlainAccountState {
|
||||
}
|
||||
PlainStorageState {
|
||||
Address Account "PK"
|
||||
H256 StorageKey "PK"
|
||||
B256 StorageKey "PK"
|
||||
U256 StorageValue
|
||||
}
|
||||
AccountHistory {
|
||||
H256 Account "PK"
|
||||
B256 Account "PK"
|
||||
BlockNumberList BlockNumberList "List of transitions where account was changed"
|
||||
}
|
||||
StorageHistory {
|
||||
H256 Account "PK"
|
||||
H256 StorageKey "PK"
|
||||
B256 Account "PK"
|
||||
B256 StorageKey "PK"
|
||||
BlockNumberList BlockNumberList "List of transitions where account storage entry was changed"
|
||||
}
|
||||
AccountChangeSet {
|
||||
u64 BlockNumber "PK"
|
||||
H256 Account "PK"
|
||||
B256 Account "PK"
|
||||
ChangeSet AccountChangeSet "Account before transition"
|
||||
}
|
||||
StorageChangeSet {
|
||||
u64 BlockNumber "PK"
|
||||
H256 Account "PK"
|
||||
H256 StorageKey "PK"
|
||||
B256 Account "PK"
|
||||
B256 StorageKey "PK"
|
||||
ChangeSet StorageChangeSet "Storage entry before transition"
|
||||
}
|
||||
HashedAccount {
|
||||
H256 HashedAddress "PK"
|
||||
B256 HashedAddress "PK"
|
||||
Account Data
|
||||
}
|
||||
HashedStorage {
|
||||
H256 HashedAddress "PK"
|
||||
H256 HashedStorageKey "PK"
|
||||
B256 HashedAddress "PK"
|
||||
B256 HashedStorageKey "PK"
|
||||
U256 StorageValue
|
||||
}
|
||||
AccountsTrie {
|
||||
@ -117,7 +117,7 @@ AccountsTrie {
|
||||
BranchNodeCompact Node
|
||||
}
|
||||
StoragesTrie {
|
||||
H256 HashedAddress "PK"
|
||||
B256 HashedAddress "PK"
|
||||
StoredNibblesSubKey NibblesSubKey "PK"
|
||||
StorageTrieEntry Node
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user