-
Notifications
You must be signed in to change notification settings - Fork 78
[ETCM-402] Decode messages with the correct protocol version #810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ETCM-402] Decode messages with the correct protocol version #810
Conversation
7ec3814 to
1d3393b
Compare
b1307b7 to
fa3d0d2
Compare
src/main/resources/application.conf
Outdated
| 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) |
There was a problem hiding this comment.
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.
src/main/scala/io/iohk/ethereum/blockchain/sync/regular/BlockBroadcast.scala
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/network/rlpx/MessageCodec.scala
Outdated
Show resolved
Hide resolved
src/main/scala/io/iohk/ethereum/network/rlpx/MessageCodec.scala
Outdated
Show resolved
Hide resolved
| supervisor ! ProgressProtocol.GotNewBlock(newState.knownTop) | ||
| fetchBlocks(newState) | ||
| } | ||
| case MessageFromPeer(CommonMessages.NewBlock(block, _), peerId) => |
There was a problem hiding this comment.
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.
src/main/scala/io/iohk/ethereum/blockchain/sync/regular/BlockBroadcast.scala
Show resolved
Hide resolved
src/test/scala/io/iohk/ethereum/network/p2p/messages/NewBlockSpec.scala
Outdated
Show resolved
Hide resolved
fa3d0d2 to
298934b
Compare
1d3393b to
1d50a35
Compare
1d50a35 to
d0b03e7
Compare
d0b03e7 to
a0308c1
Compare
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
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
298934b to
ee982e8
Compare
| case Some(ProtocolVersions.PV64) => | ||
| EtcNodeStatus64ExchangeState(handshakerConfiguration) | ||
| case Some(ProtocolVersions.PV63) => | ||
| EtcNodeStatus63ExchangeState(handshakerConfiguration) |
There was a problem hiding this comment.
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) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bf5d301 to
8d087a2
Compare
5f7ea24 to
71599ab
Compare
| if (remotePeerProtocolVersion.isEmpty) { | ||
| m match { | ||
| case hello: Hello => | ||
| remotePeerProtocolVersion = protocolNegotiator.negotiate(hello.capabilities) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/test/scala/io/iohk/ethereum/network/p2p/messages/ProtocolNegotiatorSpec.scala
Show resolved
Hide resolved
2a5d732 to
e45edad
Compare
acc2266 to
1c78633
Compare
1c78633 to
1fcfbba
Compare
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
Testing
I synced with mordor testnet successfully.