aleph-im / pyaleph

Next generation network of decentralized big data applications. Current connected chains: Ethereum, Solana, Polkadot/Substrate, Cosmos-SDK, NULS.
https://aleph.im
MIT License
75 stars 19 forks source link

Store the emitter's multi-address on alive messages #62

Closed hoh closed 2 years ago

hoh commented 3 years ago

When receiving an alive message from an node, it's multi-address should be kept in order to know what is published by what node.

hoh commented 3 years ago

Isn't this already the case with the code below ?

https://github.com/aleph-im/pyaleph/blob/c15304fdc8c9ca75dbebb57feeaf69154ce66cc1/src/aleph/services/p2p/manager.py#L79-L80

https://github.com/aleph-im/pyaleph/blob/c15304fdc8c9ca75dbebb57feeaf69154ce66cc1/src/aleph/services/p2p/peers.py#L15

moshemalawach commented 3 years ago

No, this publishes, but on the receiving part we need to store who the emitter is.

olethanh commented 3 years ago

The adress already get saved in the peers collections, in the format it has been passed as is (regular or multi addr).

e.g from my peer collections:

{ "_id" : ObjectId("5fda0af9ed41e3a6fc16d192"), "address" : "/ip4/51.159.57.71/tcp/4025/p2p/QmZkurbY2G2hWay59yiTgQNaQxHSNzKZFt2jbnwJhQcKgV", "type" : "P2P", "last_seen" : ISODate("2020-12-16T13:26:17.101Z") }
{ "_id" : ObjectId("5fda0af9ed41e3a6fc16d194"), "address" : "http://51.159.57.71:4024", "type" : "HTTP", "last_seen" : ISODate("2020-12-16T13:26:17.104Z") }
{ "_id" : ObjectId("5fda0ed9ed41e3a6fc19fe56"), "address" : "/ip4/35.210.233.95/tcp/4025/p2p/QmX8QLU4WsxJmSe3HT2kLqLrLWDLgMUPXHXw8jHNBkcYGX", "type" : "P2P", "last_seen" : ISODate("2020-12-16T13:42:49.294Z") }
{ "_id" : ObjectId("5fda0ed9ed41e3a6fc19fe58"), "address" : "http://35.210.233.95:4024", "type" : "HTTP", "last_seen" : ISODate("2020-12-16T13:42:49.298Z") }

@moshemalawach Did I misunderstood? did you want it saved somewhere else? Do we need to convert the type http to a multi address?

moshemalawach commented 3 years ago

Yes, but it's not the emitter. And not necessarily for the http peers. We need to store the actual emitter on the pubsub side to verify:

olethanh commented 3 years ago

@moshemalawach So the peer from the "from" field in the message. e.g: QmZkurbY2G2hWay59yiTgQNaQxHSNzKZFt2jbnwJhQcKgV. In multiaddr format: /p2/QmZkurbY2G2hWay59yiTgQNaQxHSNzKZFt2jbnwJhQcKgV

did I understood correctly?

Should I also save it in the peer collections? as the field 'from' or 'emitter' ?

odesenfans commented 2 years ago

This issue has been resolved a while ago I think.