mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Compare commits
2 Commits
1908e9f414
...
80506a7a43
| Author | SHA1 | Date | |
|---|---|---|---|
| 80506a7a43 | |||
| 2af312b628 |
@ -21,7 +21,7 @@ use jsonrpsee_types::ErrorObject;
|
|||||||
use reth::{api::FullNodeComponents, builder::rpc::RpcContext, tasks::TaskSpawner};
|
use reth::{api::FullNodeComponents, builder::rpc::RpcContext, tasks::TaskSpawner};
|
||||||
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
|
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
|
||||||
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, ReceiptProvider};
|
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, ReceiptProvider};
|
||||||
use reth_rpc::{eth::pubsub::SubscriptionSerializeError, EthFilter, EthPubSub};
|
use reth_rpc::{eth::pubsub::SubscriptionSerializeError, EthFilter, EthPubSub, RpcTypes};
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
helpers::{EthBlocks, EthTransactions, LoadReceipt},
|
helpers::{EthBlocks, EthTransactions, LoadReceipt},
|
||||||
transaction::ConvertReceiptInput,
|
transaction::ConvertReceiptInput,
|
||||||
@ -42,8 +42,10 @@ pub trait EthWrapper:
|
|||||||
RpcBlock<Self::NetworkTypes>,
|
RpcBlock<Self::NetworkTypes>,
|
||||||
RpcReceipt<Self::NetworkTypes>,
|
RpcReceipt<Self::NetworkTypes>,
|
||||||
RpcHeader<Self::NetworkTypes>,
|
RpcHeader<Self::NetworkTypes>,
|
||||||
> + FullEthApiTypes<Primitives = HlPrimitives>
|
> + FullEthApiTypes<
|
||||||
+ RpcNodeCoreExt<Provider: BlockReader<Block = HlBlock>>
|
Primitives = HlPrimitives,
|
||||||
|
NetworkTypes: RpcTypes<TransactionResponse = alloy_rpc_types_eth::Transaction>,
|
||||||
|
> + RpcNodeCoreExt<Provider: BlockReader<Block = HlBlock>>
|
||||||
+ EthBlocks
|
+ EthBlocks
|
||||||
+ EthTransactions
|
+ EthTransactions
|
||||||
+ LoadReceipt
|
+ LoadReceipt
|
||||||
@ -58,8 +60,10 @@ impl<T> EthWrapper for T where
|
|||||||
RpcBlock<Self::NetworkTypes>,
|
RpcBlock<Self::NetworkTypes>,
|
||||||
RpcReceipt<Self::NetworkTypes>,
|
RpcReceipt<Self::NetworkTypes>,
|
||||||
RpcHeader<Self::NetworkTypes>,
|
RpcHeader<Self::NetworkTypes>,
|
||||||
> + FullEthApiTypes<Primitives = HlPrimitives>
|
> + FullEthApiTypes<
|
||||||
+ RpcNodeCoreExt<Provider: BlockReader<Block = HlBlock>>
|
Primitives = HlPrimitives,
|
||||||
|
NetworkTypes: RpcTypes<TransactionResponse = alloy_rpc_types_eth::Transaction>,
|
||||||
|
> + RpcNodeCoreExt<Provider: BlockReader<Block = HlBlock>>
|
||||||
+ EthBlocks
|
+ EthBlocks
|
||||||
+ EthTransactions
|
+ EthTransactions
|
||||||
+ LoadReceipt
|
+ LoadReceipt
|
||||||
@ -262,6 +266,11 @@ fn adjust_block<Eth: EthWrapper>(
|
|||||||
new_block.transactions = match new_block.transactions {
|
new_block.transactions = match new_block.transactions {
|
||||||
BlockTransactions::Full(mut transactions) => {
|
BlockTransactions::Full(mut transactions) => {
|
||||||
transactions.drain(..system_tx_count);
|
transactions.drain(..system_tx_count);
|
||||||
|
transactions.iter_mut().for_each(|tx| {
|
||||||
|
if let Some(idx) = &mut tx.transaction_index {
|
||||||
|
*idx -= system_tx_count as u64;
|
||||||
|
}
|
||||||
|
});
|
||||||
BlockTransactions::Full(transactions)
|
BlockTransactions::Full(transactions)
|
||||||
}
|
}
|
||||||
BlockTransactions::Hashes(mut hashes) => {
|
BlockTransactions::Hashes(mut hashes) => {
|
||||||
|
|||||||
@ -72,10 +72,6 @@ impl EthChainSpec for HlChainSpec {
|
|||||||
fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
|
fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
|
||||||
self.inner.bootnodes()
|
self.inner.bootnodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_optimism(&self) -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hardforks for HlChainSpec {
|
impl Hardforks for HlChainSpec {
|
||||||
@ -102,12 +98,6 @@ impl Hardforks for HlChainSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ChainSpec> for HlChainSpec {
|
|
||||||
fn from(value: ChainSpec) -> Self {
|
|
||||||
Self { inner: value }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EthereumHardforks for HlChainSpec {
|
impl EthereumHardforks for HlChainSpec {
|
||||||
fn ethereum_fork_activation(&self, fork: EthereumHardfork) -> ForkCondition {
|
fn ethereum_fork_activation(&self, fork: EthereumHardfork) -> ForkCondition {
|
||||||
self.inner.ethereum_fork_activation(fork)
|
self.inner.ethereum_fork_activation(fork)
|
||||||
@ -122,12 +112,6 @@ impl EthExecutorSpec for HlChainSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<HlChainSpec> for ChainSpec {
|
|
||||||
fn from(value: HlChainSpec) -> Self {
|
|
||||||
value.inner
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HlChainSpec {
|
impl HlChainSpec {
|
||||||
pub const MAINNET_RPC_URL: &str = "https://rpc.hyperliquid.xyz/evm";
|
pub const MAINNET_RPC_URL: &str = "https://rpc.hyperliquid.xyz/evm";
|
||||||
pub const TESTNET_RPC_URL: &str = "https://rpc.hyperliquid-testnet.xyz/evm";
|
pub const TESTNET_RPC_URL: &str = "https://rpc.hyperliquid-testnet.xyz/evm";
|
||||||
|
|||||||
@ -1,20 +1,15 @@
|
|||||||
use revm::primitives::hardfork::SpecId;
|
use revm::primitives::hardfork::SpecId;
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Default)]
|
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum HlSpecId {
|
pub enum HlSpecId {
|
||||||
|
/// Placeholder for evm cancun fork
|
||||||
#[default]
|
#[default]
|
||||||
V1, // V1
|
V1,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HlSpecId {
|
impl HlSpecId {
|
||||||
pub const fn is_enabled_in(self, other: HlSpecId) -> bool {
|
|
||||||
other as u8 <= self as u8
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Converts the [`HlSpecId`] into a [`SpecId`].
|
|
||||||
pub const fn into_eth_spec(self) -> SpecId {
|
pub const fn into_eth_spec(self) -> SpecId {
|
||||||
match self {
|
match self {
|
||||||
Self::V1 => SpecId::CANCUN,
|
Self::V1 => SpecId::CANCUN,
|
||||||
@ -23,31 +18,8 @@ impl HlSpecId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<HlSpecId> for SpecId {
|
impl From<HlSpecId> for SpecId {
|
||||||
|
/// Converts the [`HlSpecId`] into a [`SpecId`].
|
||||||
fn from(spec: HlSpecId) -> Self {
|
fn from(spec: HlSpecId) -> Self {
|
||||||
spec.into_eth_spec()
|
spec.into_eth_spec()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// String identifiers for HL hardforks
|
|
||||||
pub mod name {
|
|
||||||
pub const V1: &str = "V1";
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for HlSpecId {
|
|
||||||
type Err = String;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Ok(match s {
|
|
||||||
name::V1 => Self::V1,
|
|
||||||
_ => return Err(format!("Unknown HL spec: {s}")),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<HlSpecId> for &'static str {
|
|
||||||
fn from(spec_id: HlSpecId) -> Self {
|
|
||||||
match spec_id {
|
|
||||||
HlSpecId::V1 => name::V1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user