This repository has been moved to sigp/enr
rust-ethereum / enr Goto Github PK
View Code? Open in Web Editor NEWEthereum Node Record (ENR) rust implementation
License: MIT License
Ethereum Node Record (ENR) rust implementation
License: MIT License
This repository has been moved to sigp/enr
EnrError currently is a plain struct.
IMO, this is a bit non-idiomatic. Especially conversion into other custom error types is more involved than it should be. For example, thiserror offers a #[from] attribute which auto-generates a From
implementation. This, however, expects the source error type to implement std::error::Error
.
As an alternative, we could just derive thiserror::Error which will generate a std::error::Error
implementation.
WDYT?
It is possible that key values are not stored as bytes rather can be recursive RLP lists.
Currently this ENR library assumes that key values are stored as bytes and then interpreted. As the specific encoding is key-specific, we should generalise how keys are stored in the RAW ENR.
We currently decode the RLP of an ENR assuming it is always a list of bytes. The more general solution is to iterator through the RLP, firstly collecting the default required types such a sig and seq_no. Once we start iterating through the key/value pairs, the keys MUST be encoded as bytes but the values may be RLP lists. We should store RLP encoded bytes of the value in the BTree rather than the decoded bytes.
Then regardless of known key/value encodings an application can read a key and perform their own custom RLP decoding on the RLP encoded bytes stored as the value.
This strategy will involve updating the current known keys, such as ip, udp, tcp etc to decode the RLP from the BTree first before converting to the correct type.
Once updated, this should resolve #3 and this library should be able to decode the geth's DNS ENR entries (one of these should be added as a test).
I find it can't parse Geth node's ENR like this:
enr:-Je4QIdx4eWpaemy4ECbJU2ZsXvzX3XsiF10QOjm-87XBkoaJdEq3qjijY7fMkhP1SZRUeqHodSczUCuj01eWWzQ2xc7g2V0aMfGhOAp6ZGAgmlkgnY0gmlwhLecb4iJc2VjcDI1NmsxoQPnve6T4T8AWndeYCCi-zJncpl_W_SR8Wky_rUI8MxR24N0Y3CCdmCDdWRwgnZg
I get Error Custom("List decode fail")
But It can be parsed well by Geth.
This is an enr record taken from https://github.com/ethereum/discv4-dns-lists/blob/master/all.ropsten.ethdisco.net/nodes.json#L20.
The devp2p enrdump
of that record:
./devp2p enrdump "enr:-Je4QDa1FydMysP1D_SCU40y6oJzJx3tcypUm27jGo1sAsl5aHdBD7179oxSwU2toRZD_EN80FIN4UPeNN3MD2SwzlRUg2V0aMfGhGcn75CAgmlkgnY0gmlwhMPJwBeJc2VjcDI1NmsxoQMGqA6CChLPbypJEPUGlZBCgt3b0pkTjMwjAAGDFkfOmoN0Y3CCdmGDdWRwgnZh"
Node ID: 0168ab071ed27549c208d36816234a4552722ac2395e1bbffbe94ba12f63604e
URLv4: enode://06a80e820a12cf6f2a4910f50695904282dddbd299138ccc230001831647ce9a2b5197307941232bc946c5db4df0823da7ceeda98327fb2fa1a34a0cd1ed7e6b@195.201.192.23:30305
Record has sequence number 84 and 6 key/value pairs.
"eth" c7c6846727ef9080
"id" "v4"
"ip" 195.201.192.23
"secp256k1" a10306a80e820a12cf6f2a4910f50695904282dddbd299138ccc230001831647ce9a
"tcp" 30305
"udp" 30305
@vorot93 tells me that it fails on this library. Let's use this ticket to track down the incompatibility.
cc @fjl
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.