Giter Site home page Giter Site logo

enr's People

Contributors

agemanning avatar detailyang avatar divagant-martian avatar paulhauner avatar pawanjay176 avatar vorot93 avatar zedt3ster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

enr's Issues

`EnrError` should implement `std::error::Error`

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?

ENR incompatibility

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

Can't parse Geth node's ENR

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.

Store key values as RLP encoded data

Description

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.