-
Notifications
You must be signed in to change notification settings - Fork 795
feat(providers): add a subset of admin namespace #1880
Conversation
a970e35
to
44a04b8
Compare
99cd336
to
c252fd5
Compare
Currently fails the |
Tests pass and the bug is fixed, the bug was that |
153a858
to
4fd5709
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work! nits
ethers-providers/src/provider.rs
Outdated
// wait for the geth dial loop to start and connect the static nodes | ||
sleep(Duration::from_secs(20)).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this takes that long? can we instead poll the node like we poll ganache-cli instaed of hardcoding a wait time? it's gonna screw up our reth integration tests otherwise imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, added a method wait_to_add_peer
which polls geth's stderr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another method would be polling the admin_peers
endpoint, we might be able to accomplish this using admin_peerEvents
in the future
use super::*; | ||
|
||
#[test] | ||
fn deserialize_peer_info() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
/// Deserializes the input into a U256, accepting both 0x-prefixed hex and decimal strings with | ||
/// arbitrary precision, defined by serde_json's [`Number`](serde_json::Number). | ||
pub fn from_int_or_hex<'de, D>(deserializer: D) -> Result<U256, D::Error> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have this in other desers too? no need to do now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some desers already use this, but it would be worth checking other types of rpc responses that might have decimal values
/// Disable discovery for the geth instance. | ||
/// | ||
/// This will put the geth instance into non-dev mode, discarding any previously set dev-mode | ||
/// options. | ||
#[must_use] | ||
pub fn disable_discovery(mut self) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. we should consider thinking of how can we use these options on geth to cause partitions intentionally and see how our failure recovery works
@Rjected lets try to merge by eod? |
@gakonst sounds good, will prioritize |
* add networking and peer related structs
* the type is better represented by a struct which can have either eth or snap
* should re-add when peer event endpoints are implemented
* the serde_json arbitrary_precision feature is necessary so the serde_json::Number variant of `IntOrHexOrBigNum` can be converted into a string and fed into U256::from_dec_string
* unnecessary since serde_json::Number handles smaller ints as well
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
* the build can be updated by changing the GETH_BUILD env var
8e49a76
to
50ccfce
Compare
a6e740a
to
dbb53a9
Compare
Mysterious connection refused error in another test that also uses geth hmmm |
* add method which dumps the unread stderr of the geth instance into a string
* bug is due to authrpc endpoint being in use
* did not work properly anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing work
Motivation
Geth includes an
admin
namespace which is especially useful for querying its p2p details and prompting the node to add or remove peers.Solution
NodeInfo
for theadmin_nodeInfo
return typePeerInfo
for theadmin_peers
return typeadmin
namespace RPCs toMiddleware
, implementing them onProvider<P>
:admin_nodeInfo
admin_peers
admin_addPeer
admin_addTrustedPeer
admin_removePeer
admin_removeTrustedPeer
This also modifies the
Geth
andGethInstance
structs to support custom chain ids and running without the--dev
flag.--dev
-specific configuration options, and options that are incompatible with--dev
are kept mutually exclusive with thePrivateNetOptions
enum. Unless a dev-incompatible option is set,--dev
mode will remain the default. An option for disabling discovery is also added.This also adds a simple test using the new
Geth
options to set a few custom fields that are visible in theadmin_nodeInfo
output.Misc change:
from_int_or_hex
as a general utility so it can be used foradmin_nodeInfo
response deserialization.TODO:
admin_peers
endpoint deserializes correctlyid
obtained from theadmin_peers
RPC call matches theid
from theadmin_nodeInfo
response for that peergenesis.json
deserialization testsNodeInfo
andPeerInfo
admin_
endpoints to add -admin_peerEvents
maybe?admin_peerEvents
is of scope for this PR, will create an issuePR Checklist