Skip to content
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

fix(admin): id in NodeInfo is string instead of B256 #1038

Merged
merged 3 commits into from
Jul 13, 2024
Merged
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
8 changes: 4 additions & 4 deletions crates/node-bindings/src/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::unused_port;
use alloy_genesis::{CliqueConfig, Genesis};
use alloy_primitives::{hex, Address, B256};
use alloy_primitives::Address;
use k256::ecdsa::SigningKey;
use std::{
borrow::Cow,
Expand Down Expand Up @@ -121,7 +121,7 @@ impl GethInstance {
/// Blocks until geth adds the specified peer, using 20s as the timeout.
///
/// Requires the stderr to be present in the `GethInstance`.
pub fn wait_to_add_peer(&mut self, id: B256) -> Result<(), GethInstanceError> {
pub fn wait_to_add_peer(&mut self, id: &str) -> Result<(), GethInstanceError> {
let mut stderr = self.pid.stderr.as_mut().ok_or(GethInstanceError::NoStderr)?;
let mut err_reader = BufReader::new(&mut stderr);
let mut line = String::new();
Expand All @@ -132,8 +132,8 @@ impl GethInstance {
err_reader.read_line(&mut line).map_err(GethInstanceError::ReadLineError)?;

// geth ids are truncated
let truncated_id = hex::encode(&id.0[..8]);
if line.contains("Adding p2p peer") && line.contains(&truncated_id) {
let truncated_id = if id.len() > 16 { &id[..16] } else { id };
if line.contains("Adding p2p peer") && line.contains(truncated_id) {
return Ok(());
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/provider/src/ext/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ mod test {

let added = provider2.add_peer(&node1_enode).await.unwrap();
assert!(added);
geth2.wait_to_add_peer(node1_id).unwrap();
geth2.wait_to_add_peer(&node1_id).unwrap();
let peers = provider2.peers().await.unwrap();
assert_eq!(peers[0].enode, node1_enode);
}
Expand Down
7 changes: 5 additions & 2 deletions crates/rpc-types-admin/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ use std::{

/// This includes general information about a running node, spanning networking and protocol
/// details.
///
/// See [geth's `NodeInfo` struct](https://github.com/ethereum/go-ethereum/blob/v1.14.0/p2p/server.go#L1078)
/// for the source of each field.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NodeInfo {
/// Unique node identifier.
pub id: B256,
/// Unique node identifier(also the encryption key).
pub id: String,
/// The node's user agent, containing a client name, version, OS, and other metadata.
pub name: String,
/// The enode URL of the connected node.
Expand Down