Skip to content

Commit

Permalink
fix: remove incorrect get prefix from filter methods (#450)
Browse files Browse the repository at this point in the history
* fix: rm incorrect get prefix from filter methods

* fixup! rpc.md
  • Loading branch information
eshaan7 authored Nov 27, 2024
1 parent e98a36d commit 8bf5b52
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 54 deletions.
12 changes: 6 additions & 6 deletions core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ impl<N: NetworkSpec, C: Consensus<N::TransactionResponse>> Client<N, C> {
self.node.uninstall_filter(filter_id).await
}

pub async fn get_new_filter(&self, filter: &Filter) -> Result<U256> {
self.node.get_new_filter(filter).await
pub async fn new_filter(&self, filter: &Filter) -> Result<U256> {
self.node.new_filter(filter).await
}

pub async fn get_new_block_filter(&self) -> Result<U256> {
self.node.get_new_block_filter().await
pub async fn new_block_filter(&self) -> Result<U256> {
self.node.new_block_filter().await
}

pub async fn get_new_pending_transaction_filter(&self) -> Result<U256> {
self.node.get_new_pending_transaction_filter().await
pub async fn new_pending_transaction_filter(&self) -> Result<U256> {
self.node.new_pending_transaction_filter().await
}

pub async fn get_gas_price(&self) -> Result<U256> {
Expand Down
12 changes: 6 additions & 6 deletions core/src/client/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ impl<N: NetworkSpec, C: Consensus<N::TransactionResponse>> Node<N, C> {
self.execution.uninstall_filter(filter_id).await
}

pub async fn get_new_filter(&self, filter: &Filter) -> Result<U256> {
self.execution.get_new_filter(filter).await
pub async fn new_filter(&self, filter: &Filter) -> Result<U256> {
self.execution.new_filter(filter).await
}

pub async fn get_new_block_filter(&self) -> Result<U256> {
self.execution.get_new_block_filter().await
pub async fn new_block_filter(&self) -> Result<U256> {
self.execution.new_block_filter().await
}

pub async fn get_new_pending_transaction_filter(&self) -> Result<U256> {
self.execution.get_new_pending_transaction_filter().await
pub async fn new_pending_transaction_filter(&self) -> Result<U256> {
self.execution.new_pending_transaction_filter().await
}

// assumes tip of 1 gwei to prevent having to prove out every tx in the block
Expand Down
24 changes: 12 additions & 12 deletions core/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ trait EthRpc<TX: TransactionResponse + RpcObject, TXR: RpcObject, R: ReceiptResp
async fn get_filter_logs(&self, filter_id: U256) -> Result<Vec<Log>, ErrorObjectOwned>;
#[method(name = "uninstallFilter")]
async fn uninstall_filter(&self, filter_id: U256) -> Result<bool, ErrorObjectOwned>;
#[method(name = "getNewFilter")]
async fn get_new_filter(&self, filter: Filter) -> Result<U256, ErrorObjectOwned>;
#[method(name = "getNewBlockFilter")]
async fn get_new_block_filter(&self) -> Result<U256, ErrorObjectOwned>;
#[method(name = "getNewPendingTransactionFilter")]
async fn get_new_pending_transaction_filter(&self) -> Result<U256, ErrorObjectOwned>;
#[method(name = "newFilter")]
async fn new_filter(&self, filter: Filter) -> Result<U256, ErrorObjectOwned>;
#[method(name = "newBlockFilter")]
async fn new_block_filter(&self) -> Result<U256, ErrorObjectOwned>;
#[method(name = "newPendingTransactionFilter")]
async fn new_pending_transaction_filter(&self) -> Result<U256, ErrorObjectOwned>;
#[method(name = "getStorageAt")]
async fn get_storage_at(
&self,
Expand Down Expand Up @@ -339,16 +339,16 @@ impl<N: NetworkSpec, C: Consensus<N::TransactionResponse>>
convert_err(self.node.uninstall_filter(filter_id).await)
}

async fn get_new_filter(&self, filter: Filter) -> Result<U256, ErrorObjectOwned> {
convert_err(self.node.get_new_filter(&filter).await)
async fn new_filter(&self, filter: Filter) -> Result<U256, ErrorObjectOwned> {
convert_err(self.node.new_filter(&filter).await)
}

async fn get_new_block_filter(&self) -> Result<U256, ErrorObjectOwned> {
convert_err(self.node.get_new_block_filter().await)
async fn new_block_filter(&self) -> Result<U256, ErrorObjectOwned> {
convert_err(self.node.new_block_filter().await)
}

async fn get_new_pending_transaction_filter(&self) -> Result<U256, ErrorObjectOwned> {
convert_err(self.node.get_new_pending_transaction_filter().await)
async fn new_pending_transaction_filter(&self) -> Result<U256, ErrorObjectOwned> {
convert_err(self.node.new_pending_transaction_filter().await)
}

async fn get_storage_at(
Expand Down
12 changes: 6 additions & 6 deletions core/src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> ExecutionClient<N, R> {
self.rpc.uninstall_filter(filter_id).await
}

pub async fn get_new_filter(&self, filter: &Filter) -> Result<U256> {
pub async fn new_filter(&self, filter: &Filter) -> Result<U256> {
let filter = filter.clone();

// avoid submitting a filter for logs for a block helios hasn't seen yet
Expand All @@ -337,15 +337,15 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> ExecutionClient<N, R> {
} else {
filter
};
self.rpc.get_new_filter(&filter).await
self.rpc.new_filter(&filter).await
}

pub async fn get_new_block_filter(&self) -> Result<U256> {
self.rpc.get_new_block_filter().await
pub async fn new_block_filter(&self) -> Result<U256> {
self.rpc.new_block_filter().await
}

pub async fn get_new_pending_transaction_filter(&self) -> Result<U256> {
self.rpc.get_new_pending_transaction_filter().await
pub async fn new_pending_transaction_filter(&self) -> Result<U256> {
self.rpc.new_pending_transaction_filter().await
}

async fn verify_logs(&self, logs: &[Log]) -> Result<()> {
Expand Down
12 changes: 6 additions & 6 deletions core/src/execution/rpc/http_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,28 +174,28 @@ impl<N: NetworkSpec> ExecutionRpc<N> for HttpRpc<N> {
.map_err(|e| RpcError::new("uninstall_filter", e))?)
}

async fn get_new_filter(&self, filter: &Filter) -> Result<U256> {
async fn new_filter(&self, filter: &Filter) -> Result<U256> {
Ok(self
.provider
.new_filter(filter)
.await
.map_err(|e| RpcError::new("get_new_filter", e))?)
.map_err(|e| RpcError::new("new_filter", e))?)
}

async fn get_new_block_filter(&self) -> Result<U256> {
async fn new_block_filter(&self) -> Result<U256> {
Ok(self
.provider
.new_block_filter()
.await
.map_err(|e| RpcError::new("get_new_block_filter", e))?)
.map_err(|e| RpcError::new("new_block_filter", e))?)
}

async fn get_new_pending_transaction_filter(&self) -> Result<U256> {
async fn new_pending_transaction_filter(&self) -> Result<U256> {
Ok(self
.provider
.new_pending_transactions_filter(true)
.await
.map_err(|e| RpcError::new("get_new_pending_transactions", e))?)
.map_err(|e| RpcError::new("new_pending_transaction_filter", e))?)
}

async fn chain_id(&self) -> Result<u64> {
Expand Down
17 changes: 10 additions & 7 deletions core/src/execution/rpc/mock_rpc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fs::read_to_string, path::PathBuf};
use std::{fs::read_to_string, path::PathBuf, str::FromStr};

use alloy::primitives::{Address, B256, U256};
use alloy::rpc::types::{
Expand Down Expand Up @@ -88,16 +88,19 @@ impl<N: NetworkSpec> ExecutionRpc<N> for MockRpc {
Err(eyre!("not implemented"))
}

async fn get_new_filter(&self, _filter: &Filter) -> Result<U256> {
Err(eyre!("not implemented"))
async fn new_filter(&self, _filter: &Filter) -> Result<U256> {
let id = read_to_string(self.path.join("filter_id.txt"))?;
Ok(U256::from_str(&id)?)
}

async fn get_new_block_filter(&self) -> Result<U256> {
Err(eyre!("not implemented"))
async fn new_block_filter(&self) -> Result<U256> {
let id = read_to_string(self.path.join("filter_id.txt"))?;
Ok(U256::from_str(&id)?)
}

async fn get_new_pending_transaction_filter(&self) -> Result<U256> {
Err(eyre!("not implemented"))
async fn new_pending_transaction_filter(&self) -> Result<U256> {
let id = read_to_string(self.path.join("filter_id.txt"))?;
Ok(U256::from_str(&id)?)
}

async fn chain_id(&self) -> Result<u64> {
Expand Down
6 changes: 3 additions & 3 deletions core/src/execution/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ pub trait ExecutionRpc<N: NetworkSpec>: Send + Clone + Sync + 'static {
async fn get_filter_changes(&self, filter_id: U256) -> Result<Vec<Log>>;
async fn get_filter_logs(&self, filter_id: U256) -> Result<Vec<Log>>;
async fn uninstall_filter(&self, filter_id: U256) -> Result<bool>;
async fn get_new_filter(&self, filter: &Filter) -> Result<U256>;
async fn get_new_block_filter(&self) -> Result<U256>;
async fn get_new_pending_transaction_filter(&self) -> Result<U256>;
async fn new_filter(&self, filter: &Filter) -> Result<U256>;
async fn new_block_filter(&self) -> Result<U256>;
async fn new_pending_transaction_filter(&self) -> Result<U256>;
async fn chain_id(&self) -> Result<u64>;
async fn get_block(&self, hash: B256) -> Result<Block<N::TransactionResponse>>;

Expand Down
1 change: 1 addition & 0 deletions core/testdata/filter_id.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0xa6385952ca398d91b046bf73e520ac80
19 changes: 11 additions & 8 deletions rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ Helios provides a variety of RPC methods for interacting with the Ethereum netwo
| `eth_gasPrice` | `gas_price` | Returns the current price per gas in wei. | `client.gas_price(&self)` |
| `eth_maxPriorityFeePerGas` | `max_priority_fee_per_gas` | Returns the current max priority fee per gas in wei. | `client.max_priority_fee_per_gas(&self)` |
| `eth_blockNumber` | `block_number` | Returns the number of the most recent block. | `client.block_number(&self)` |
| `eth_getBlockByNumber` | `get_block_by_number` | Returns the information of a block by number. | `get_block_by_number(&self, block: BlockTag, full_tx: bool)` |
| `eth_getBlockByHash` | `get_block_by_hash` | Returns the information of a block by hash. | `get_block_by_hash(&self, hash: &str, full_tx: bool)` |
| `eth_getBlockByNumber` | `get_block_by_number` | Returns the information of a block by number. | `client.get_block_by_number(&self, block: BlockTag, full_tx: bool)` |
| `eth_getBlockByHash` | `get_block_by_hash` | Returns the information of a block by hash. | `client.get_block_by_hash(&self, hash: &str, full_tx: bool)` |
| `eth_sendRawTransaction` | `send_raw_transaction` | Submits a raw transaction to the network. | `client.send_raw_transaction(&self, bytes: &str)` |
| `eth_getTransactionReceipt` | `get_transaction_receipt` | Returns the receipt of a transaction by transaction hash. | `client.get_transaction_receipt(&self, hash: &str)` |
| `eth_getTransactionByHash` | `get_transaction_by_hash` | Returns the information about a transaction requested by transaction hash. | `client.get_transaction_by_hash(&self, hash: &str)`
| `eth_getTransactionByBlockHashAndIndex` | `get_transaction_by_block_hash_and_index` | Returns information about a transaction by block hash and transaction index position. | `client.get_transaction_by_block_hash_and_index(&self, hash: &str, index: u64)`
| `eth_getTransactionByBlockNumberAndIndex` | `get_transaction_by_block_number_and_index` | Returns information about a transaction by block number and transaction index position. | `client.get_transaction_by_block_number_and_index(&self, block: BlockTag, index: u64)`
| `eth_getTransactionByHash` | `get_transaction_by_hash` | Returns the information about a transaction requested by transaction hash. | `client.get_transaction_by_hash(&self, hash: &str)` |
| `eth_getTransactionByBlockHashAndIndex` | `get_transaction_by_block_hash_and_index` | Returns information about a transaction by block hash and transaction index position. | `client.get_transaction_by_block_hash_and_index(&self, hash: &str, index: u64)` |
| `eth_getTransactionByBlockNumberAndIndex` | `get_transaction_by_block_number_and_index` | Returns information about a transaction by block number and transaction index position. | `client.get_transaction_by_block_number_and_index(&self, block: BlockTag, index: u64)` |
| `eth_getBlockReceipts` | `get_block_receipts` | Returns all transaction receipts of a block by number. | `client.get_block_receipts(&self, block: BlockTag)` |
| `eth_getBlockTransactionCountByHash` | `get_block_transaction_count_by_hash` | Returns the number of transactions in a block from a block matching the transaction hash. | `client.get_block_transaction_count_by_hash(&self, hash: &str)` |
| `eth_getBlockTransactionCountByNumber` | `get_block_transaction_count_by_number` | Returns the number of transactions in a block from a block matching the block number. | `client.get_block_transaction_count_by_number(&self, block: BlockTag)` |
| `eth_getLogs` | `get_logs` | Returns an array of logs matching the filter. | `client.get_logs(&self, filter: Filter)` |
| `eth_getFilterChanges` | `get_filter_changes` | Polling method for a filter, which returns an array of logs which occurred since last poll. | `client.get_filter_changes(&self, filter_id: H256)` |
| `eth_getFilterChanges` | `get_filter_changes` | Polling method for a filter, which returns an array of logs or transaction hashes or block hashes (depending on type of filter) which occurred since last poll. | `client.get_filter_changes(&self, filter_id: H256)` |
| `eth_getFilterLogs` | `get_filter_logs` | Returns an array of all logs matching filter with given id. | `client.get_filter_logs(&self, filter_id: H256)` |
| `eth_newFilter` | `new_filter` | Creates a filter object, based on filter options, to notify when the state changes (logs). | `client.new_filter(&self, filter: Filter)` |
| `eth_newBlockFilter` | `new_block_filter` | Creates a filter in the node, to notify when a new block arrives. | `client.new_block_filter(&self)` |
| `eth_newPendingTransactionFilter` | `new_pending_transaction_filter` | Creates a filter in the node, to notify when new pending transactions arrive. | `client.new_pending_transaction_filter(&self)` |
| `eth_getStorageAt` | `get_storage_at` | Returns the value from a storage position at a given address. | `client.get_storage_at(&self, address: &str, slot: H256, block: BlockTag)` |
| `eth_getBlockTransactionCountByHash` | `get_block_transaction_count_by_hash` | Returns the number of transactions in a block from a block matching the transaction hash. | `client.get_block_transaction_count_by_hash(&self, hash: &str)` |
| `eth_getBlockTransactionCountByNumber` | `get_block_transaction_count_by_number` | Returns the number of transactions in a block from a block matching the block number. | `client.get_block_transaction_count_by_number(&self, block: BlockTag)` |
| `eth_coinbase` | `get_coinbase` | Returns the client coinbase address. | `client.get_coinbase(&self)` |
| `eth_syncing` | `syncing` | Returns an object with data about the sync status or false. | `client.syncing(&self)` |
| `web3_clientVersion` | `client_version` | Returns the current version of the chain client. | `client.client_version(&self)` |

0 comments on commit 8bf5b52

Please sign in to comment.