Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[ETCM-841] Rework protocol negotiation #1004

Merged

Conversation

dzajkowski
Copy link
Contributor

@dzajkowski dzajkowski commented Jun 2, 2021

Mantis implements a protocol version ETC/64 which is conflicting with ETH/64.
This PRs goal is to enable the coexistence of both and some future proofing (renames, simple protocol negotiation).

@dzajkowski dzajkowski force-pushed the feature/etcm-841-protocol-capabilities-config-reorg branch 2 times, most recently from 539fc60 to 85e6894 Compare June 9, 2021 13:32
@dzajkowski dzajkowski marked this pull request as ready for review June 9, 2021 14:25
@dzajkowski dzajkowski force-pushed the feature/etcm-841-protocol-capabilities-config-reorg branch from ca927e5 to 99dc3b4 Compare June 10, 2021 12:47

private val pattern = "(.*)/(\\d*)".r

def from(protocolVersion: String): Capability =
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make it clear that this function throws ? parseUnsafe maybe ?
Or make it return an option and let BlockchainConfig throw in case of none

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. I'll stick to the exception. not the best solution but we need mantis to fail when configs are not properly defined.

@@ -246,7 +248,7 @@ trait PeerManagerActorBuilder {
EthereumMessageDecoder,
discoveryConfig,
blacklist,
Config.Network.protocolVersion
blockchainConfig.capabilities // TODO replace with a list of capabilities
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it already a list of capabilities ?

@@ -122,6 +124,8 @@ object BlockchainConfig {
val allowedMinersPublicKeys = readPubKeySet(blockchainConfig, "allowed-miners")

val ecip1099BlockNumber: BigInt = BigInt(blockchainConfig.getString("ecip1099-block-number"))
val capabilities: List[Capability] =
blockchainConfig.getStringList("capabilities").asScala.toList.map(Capability.from)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we should also check that the capability in the config is indeed a capability implemented by Mantis ?

@@ -7,6 +7,21 @@ import io.iohk.ethereum.rlp.{RLPEncodeable, RLPException, RLPList, RLPSerializab
case class Capability(name: String, version: Byte)

object Capability {
def negotiate(c1: List[Capability], c2: List[Capability]): Option[Capability] =
c1.intersect(c2).maxByOption(_.version) // FIXME ignores branches and other protocols
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that it duplicates the best function here.
We should probably have a single point where the best protocol is chosen, no ?
Something like :

Suggested change
c1.intersect(c2).maxByOption(_.version) // FIXME ignores branches and other protocols
// FIXME ignores branches and other protocols
c1.intersect(c2) match {
case Nil => None
case nonEmpty => best(nonEmpty)
}

@leo-bogastry
Copy link
Contributor

The ETCM-841 ticket description mentions "The task is to rename the whole protocol to PV164 and mark @depracated". Are you thinking keeping it as ETC/64 instead? With or without deprecation?

@dzajkowski dzajkowski force-pushed the feature/etcm-841-protocol-capabilities-config-reorg branch from 1785b82 to 8648b65 Compare June 11, 2021 10:17
@dzajkowski
Copy link
Contributor Author

@LeonorLunatech As I mentioned during refinement - I went through a few iterations on how to deal with this issue and by explicitly stating the namespace (prefix) mantis can have any number of protocols. The only limitation will be the negotiation mechanism.

TL;DR the deprecation is not needed with the prefix. This way mantis stays backwards compatible.

@dzajkowski dzajkowski merged commit bfb2bef into develop Jun 14, 2021
@dzajkowski dzajkowski deleted the feature/etcm-841-protocol-capabilities-config-reorg branch June 14, 2021 08:10
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants