Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rpc/rpc-builder/tests/it/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ where
EthApiClient::block_transaction_count_by_hash(client, hash).await.unwrap();
EthApiClient::block_uncles_count_by_hash(client, hash).await.unwrap();
EthApiClient::block_uncles_count_by_number(client, block_number).await.unwrap();
EthApiClient::author(client).await.unwrap();

// Unimplemented
assert!(is_unimplemented(EthApiClient::syncing(client).await.err().unwrap()));
assert!(is_unimplemented(EthApiClient::author(client).await.err().unwrap()));
assert!(is_unimplemented(
EthApiClient::uncle_by_block_hash_and_index(client, hash, index).await.err().unwrap()
));
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where

/// Handler for: `eth_coinbase`
async fn author(&self) -> Result<Address> {
Err(internal_rpc_err("unimplemented"))
Ok(self.pool().status().coinbase)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'm actually not sure if this is sound tbh, because tying coinbase to the pool does not feel right.

unsure when we'd actually need this, I guess for block building but isn't this now part of CL @rakita ?

the coinbase endpoint is also disabled on providers like infura etc.

Copy link
Copy Markdown
Collaborator

@rakita rakita Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coinbase makes sense to be part of block builder but that is still not defined. Execution is building the block but CL is sending the needed parameters that are used to build the block.

Coinbase is send over EngineAPI from CL part. It is part of https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#payloadattributesv2 :

suggestedFeeRecipient: DATA, 20 Bytes - suggested value for the feeRecipient field of the new payload

So it can be changed depending on given values from CL. Infur and providers probably disabled it because they are not mining, it was set before merge only if the node is configured as a miner (IIRC).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, should we close this until block building is defined? Or add it as an attribute of EthApi for now, updating it on every payload received from CL?

}

/// Handler for: `eth_accounts`
Expand Down
5 changes: 5 additions & 0 deletions crates/transaction-pool/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use reth_primitives::Address;

/// Guarantees max transactions for one sender, compatible with geth/erigon
pub(crate) const MAX_ACCOUNT_SLOTS_PER_SENDER: usize = 16;

Expand All @@ -12,6 +14,8 @@ pub struct PoolConfig {
pub queued_limit: SubPoolLimit,
/// Max number of executable transaction slots guaranteed per account
pub max_account_slots: usize,
/// The address of the pool owner.
pub coinbase: Address,
Comment on lines +17 to +18
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I don't think this makes sense here?
what's the argument for binding the coinbase to the pool?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect this to be part of the EthApi.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the coinbase would be the beneficiary or fee recipient of minted blocks, so it would be needed for execution payload building. Maybe we could make it part of EthApi, and pass the value to the block builder as a parameter when needed?

}

impl Default for PoolConfig {
Expand All @@ -21,6 +25,7 @@ impl Default for PoolConfig {
basefee_limit: Default::default(),
queued_limit: Default::default(),
max_account_slots: MAX_ACCOUNT_SLOTS_PER_SENDER,
coinbase: Default::default(),
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,12 @@ pub use crate::{
validate::{TransactionValidationOutcome, TransactionValidator},
};
use crate::{
error::PoolResult,
pool::PoolInner,
traits::{NewTransactionEvent, PoolSize},
validate::ValidPoolTransaction,
error::PoolResult, pool::PoolInner, traits::NewTransactionEvent, validate::ValidPoolTransaction,
};
use reth_primitives::{TxHash, U256};
use reth_primitives::{Address, TxHash, U256};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::mpsc::Receiver;
use traits::PoolStatus;

mod config;
pub mod error;
Expand Down Expand Up @@ -190,8 +188,8 @@ where
{
type Transaction = T::Transaction;

fn status(&self) -> PoolSize {
self.pool.size()
fn status(&self) -> PoolStatus {
PoolStatus { size: self.pool.size(), coinbase: Address::zero() }
}

fn on_new_block(&self, event: OnNewBlockEvent) {
Expand Down
11 changes: 10 additions & 1 deletion crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub trait TransactionPool: Send + Sync + Clone {
type Transaction: PoolTransaction;

/// Returns stats about the pool.
fn status(&self) -> PoolSize;
fn status(&self) -> PoolStatus;

/// Event listener for when a new block was mined.
///
Expand Down Expand Up @@ -425,6 +425,15 @@ impl IntoRecoveredTransaction for PooledTransaction {

/// Represents the current status of the pool.
#[derive(Debug, Clone)]
pub struct PoolStatus {
/// Address of the pool owner.
pub coinbase: Address,
/// Stats about the size of the pool.
pub size: PoolSize,
}

/// Stats about the size of the pool.
#[derive(Debug, Clone)]
pub struct PoolSize {
/// Number of transactions in the _pending_ sub-pool.
pub pending: usize,
Expand Down