Skip to content

Conversation

@pslaski
Copy link
Contributor

@pslaski pslaski commented Nov 24, 2020

Description

Currently, we are decoding our messages base on information which is the best protocol we support and assumption that the newest protocol includes older protocol versions.

We should use the protocol negotiated with peer.

Proposed Solution

Create a component which can negotiate protocol version and have our capabilities information. Use it to set up correct protocol version in MessageCodec and EtcHelloExchangeState

Important Changes Introduced

  • introduced protocol negotiator

Testing

I synced with mordor testnet successfully.

@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch from 7ec3814 to 1d3393b Compare November 24, 2020 15:46
@pslaski pslaski force-pushed the etcm-280-peer-checkpoint-capability branch 2 times, most recently from b1307b7 to fa3d0d2 Compare November 25, 2020 09:35
network {
# Ethereum protocol version
# Supported versions:
# 63, 64 (experimental version which enables usage of messages with checkpointing information. In the future after ETCM-355, ETCM-356, it will be 66 probably)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(up for discussion) maybe network.protocol-version should be something configured in blockchains.$someNetwork.network.protocol-version, given it defines in some way part of the consensus. I mean i'm worry about someone configuring blockchains.$someNetwork.ecip1097-block-number but not setting up the proper version for network messages.

supervisor ! ProgressProtocol.GotNewBlock(newState.knownTop)
fetchBlocks(newState)
}
case MessageFromPeer(CommonMessages.NewBlock(block, _), peerId) =>
Copy link
Contributor

@mirkoAlic mirkoAlic Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add a comment regarding the needs of adding a new pattern match in case new versions of NewBlock messages were added.

@mirkoAlic mirkoAlic added the BREAKS PROTOCOL Affects Node2Node interactions in a way that makes them not interoperate label Nov 25, 2020
@pslaski pslaski force-pushed the etcm-280-peer-checkpoint-capability branch from fa3d0d2 to 298934b Compare November 26, 2020 10:23
@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch from 1d3393b to 1d50a35 Compare November 26, 2020 11:35
@mirkoAlic mirkoAlic added BREAKS API Affects services that interacts with APIs and removed BREAKS PROTOCOL Affects Node2Node interactions in a way that makes them not interoperate labels Nov 26, 2020
@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch from 1d50a35 to d0b03e7 Compare November 26, 2020 13:55
@mirkoAlic mirkoAlic added BREAKS API Affects services that interacts with APIs and removed BREAKS API Affects services that interacts with APIs labels Nov 26, 2020
@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch from d0b03e7 to a0308c1 Compare November 26, 2020 15:13
@rtkaczyk
Copy link
Contributor

assumption that the newest protocol includes older protocol versions

What is wrong with that assumption?

val capabilities =
if (protocolVersion == ProtocolVersions.PV64) Capabilities.All else Seq(Eth63Capability)

// It is relatively simple now, but ETCM-355 and ETCM-356 will complicate it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about handling etc capability separately, but probably we will stick with current impl even with PV64 and PV65 added

@pslaski pslaski force-pushed the etcm-280-peer-checkpoint-capability branch from 298934b to ee982e8 Compare November 26, 2020 16:12
case Some(ProtocolVersions.PV64) =>
EtcNodeStatus64ExchangeState(handshakerConfiguration)
case Some(ProtocolVersions.PV63) =>
EtcNodeStatus63ExchangeState(handshakerConfiguration)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency: shouldn't it be called EtcNodeStatus60ExchangeState? PV60 is where this message comes from. Likewise, when 64 becomes 66 we will rename EtcNodeStatus64ExchangeState -> EtcNodeStatus66ExchangeState. But when 67, 68... come along we will not be renaming it.

(Yes, I am guilty of calling it 63 in previous versions of the code)

supervisor ! ProgressProtocol.GotNewBlock(newState.knownTop)
fetchBlocks(newState)
// Remember to always add match for every new version of NewBlock message
case MessageFromPeer(CommonMessages.NewBlock(block, _), peerId) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from etcm-280-peer-checkpoint-capability to develop November 26, 2020 19:16
@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch 7 times, most recently from bf5d301 to 8d087a2 Compare December 4, 2020 11:44
@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch 2 times, most recently from 5f7ea24 to 71599ab Compare December 8, 2020 10:06
if (remotePeerProtocolVersion.isEmpty) {
m match {
case hello: Hello =>
remotePeerProtocolVersion = protocolNegotiator.negotiate(hello.capabilities)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt of protocolNegotiator per connections, and keeping there state about p2pVersion and protocol version in some thread safe manner ? ( just do not like that now we call protocolNegotiator.negotiate(hello.capabilities) in two places with same argument, and if some in the future will look only on EtcHelloExchangeState that this negotiation also happens on layer bellow for decoding purposes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it something very similar to besu implementation - IMHO it's a good idea, but not for this PR, but for new task :) I will create one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntallar ntallar removed their request for review December 14, 2020 18:25
@lemastero lemastero force-pushed the etcm-402-message-codec-protocol-version-negotiation branch from 2a5d732 to e45edad Compare December 18, 2020 18:48
@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch 2 times, most recently from acc2266 to 1c78633 Compare January 19, 2021 15:37
@pslaski pslaski force-pushed the etcm-402-message-codec-protocol-version-negotiation branch from 1c78633 to 1fcfbba Compare March 9, 2021 14:48
@leo-bogastry leo-bogastry merged commit e89e66d into develop Mar 10, 2021
@leo-bogastry leo-bogastry deleted the etcm-402-message-codec-protocol-version-negotiation branch March 10, 2021 09:12
@dzajkowski dzajkowski restored the etcm-402-message-codec-protocol-version-negotiation branch March 11, 2021 14:14
@dzajkowski dzajkowski deleted the etcm-402-message-codec-protocol-version-negotiation branch July 13, 2021 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BREAKS API Affects services that interacts with APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants