Conversation
…_host_port_remainder()
…er than anything in net_plugin. Empty p2p-server-address should not be allowed.
…chedule they can be connected to.
…peers Update to latest system contract changes.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…ng on receive of a block before read-only trx could be executed.
|
|
||
| void update_peer_keys(fc::time_point deadline) { | ||
| void update_peer_keys() { | ||
| // if syncing or replaying old blocks don't bother updating peer keys |
There was a problem hiding this comment.
good call I didn't think of this when reviewing other PR
|
I don't think it was changed in this PR but looking through the code I see it creates and verifies canonical signatures. Maybe consider turning that off (passing false) now from the start of this feature |
| try { | ||
| std::optional<peer_info_t> peer_info = cc.get_peer_info(peer.producer_name); | ||
| if (peer_info && peer_info->key) { | ||
| public_key_type pk(peer.sig, peer.digest()); |
There was a problem hiding this comment.
I think we want to immediately kick out SIG_WA. We did make the contract disallow PUB_WA.
|
|
||
| fc::lock_guard g(gossip_bps.mtx); | ||
| auto& sig_idx = gossip_bps.index.get<by_sig>(); | ||
| for (auto i = msg.peers.begin(); i != msg.peers.end() && !fatal_error;) { |
There was a problem hiding this comment.
I don't think we need to exit the loop early if fatal_error is true (it is after all an optimization for a very unlikely case).
And if we don't, we can use std::erase instead of that for loop which makes the code clearer I feel.
But up to you what you prefer!
There was a problem hiding this comment.
nit: Maybe invalid_message would be more descriptive than fatal_error.
There was a problem hiding this comment.
I think it is important to exit early on a bad public_key. Seems like those could be crafted to be expensive to evaluate. As soon as one is determined to be invalid, don't bother trying to verify signature on any others.
There was a problem hiding this comment.
Seems like those could be crafted to be expensive to evaluate.
I don't think it is a very likely attack vector from one of the top-50 producers, but OK.
There was a problem hiding this comment.
If the message is not from one of the top-50 we know about then we will not consider that a valid message and will disconnect.
There was a problem hiding this comment.
So this means that the attack with invalid signatures is not very likely, right. Not advocating for a change, but just that these messages are among a trusted group (all trusted to see the IP of all block producers, so if there was a rogue element it could probably do more damage by ddos'ing producers as they are scheduled to produce than by forging public keys that take time to validate).
There was a problem hiding this comment.
Well anyone could send a crafted gossip_bp_peers_message we have to validate to know it is from a valid producer.
This conversation did make me realize that it was a bit too strict. Just because a peer is no longer in the top producers does not mean we should fatal disconnect from them.
There was a problem hiding this comment.
Well anyone could send a crafted
gossip_bp_peers_messagewe have to validate to know it is from a valid producer.
Hum, I wonder if the whole message (the std::vector<bp_peer> + sender's name) should not be signed by the peer sending it. Then the first thing we could do is validate that the signature matches the public key of one of the IPs registered for that producer, so we authenticate that it comes from one of the current top-50 producers.
There was a problem hiding this comment.
We could certainly do that. Not sure it is worth the extra processing. Open to what others think.
Adds new
gossip_bp_peers_messagemessage to P2P protocol for gossip of available "BP" peers. Normally these peers would be canary relay nodes to the block producer and block finalizer nodeos.Gossip connection information is only shared with nodes that are connected to another "BP" node that has a peer key registered on-chain.
Block producers should register a new peer key on chain. See Add support for storing public keys on-chain that will be used to validate a network peer's identity. VaultaFoundation/system-contracts#185
Block producers then run the canary relay node(s) with the private key of the peer key and their block producer account.
For example, block producer
defproducera.regpeerkeywith values:defproduceraEOS6y94JK7Dsg3iJCrnvdbyLPZJvaAhfBSU44eU8jkPd4VHX9CJzpThe
p2p-producer-peermatches theproducer-nameof the BP. The key provided tosignature-provideris the public/private key of the on-chain key specified withregpeerkey. Thep2p-auto-bp-peeris a known BP peer. This is not technically needed if another BP peer has your endpoint listed in theirp2p-auto-bp-peerlist.p2p-auto-bp-peercan be specified for as many known bp peers. These will be used along with gossip peers as producers rotate into the producer schedule. They are not gossiped out to other peers. Only this nodes connection info along with other received gossip BP info is gossiped to other peers.Resolves #1245