-
Notifications
You must be signed in to change notification settings - Fork 10
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
[ADR] 0002 - Separate consensus and P2P IDs #33
base: main
Are you sure you want to change the base?
Conversation
8e332c4
to
7e6934a
Compare
358fca0
to
d061f8c
Compare
d061f8c
to
f22d287
Compare
f22d287
to
5eb4a9c
Compare
# ADR-0002: Separate consensus and P2P IDs | ||
|
||
* Status: in review | ||
* Deciders: Pocket Network team |
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.
Pocket Network Protocol Team
* Deciders: Pocket Network team | ||
* Date: 2023-04-17 | ||
|
||
Technical Story: [Review Hotstuff Node IDs](https://github.com/pokt-network/pocket/issue/434) |
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.
See the PR for my updated template and lmk if you want to adopt it here (if we merge it).
Totally cool with not applying it retroactively, though.
|
||
## Context and Problem Statement | ||
|
||
In the context of simplifying and consolidating node identity, facing the concern of multiple ID definitions, we decided to clarify the purpose of consensus NodeId and not consolidate it with P2P identity, to achieve a clearer separation of concerns, accepting potential confusion between different IDs, because this will prevent unintended interference between consensus and P2P layers. |
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.
Without examples, references or links, it's really hard to understand what the decision was actually entailing.
## Decision Drivers | ||
|
||
* Clear separation of concerns between consensus and P2P layers | ||
* Preventing unintended interference between different node identity types |
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.
* Preventing unintended interference between different node identity types | |
* Preventing unintended interference between different node identity types | |
* Maintenance, tracking and defining multiple type of IDs |
@@ -0,0 +1,53 @@ | |||
# ADR-0002: Separate consensus and P2P IDs |
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.
This ADR does not define where/how Peer Identity
is used and where/how NodeID
is used.
* Bad, because it may lead to potential confusion between different node identity types | ||
* Bad, because it requires maintaining multiple ID definitions | ||
|
||
### Links |
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 did a bit more research in how we're using NodeID, and here's what I found.
How we define it (changes with every height where the valset is modified):
func NewActorMapper(validators []*coreTypes.Actor) *actorMapper {
am := &actorMapper{
valAddrToIdMap: make(ValAddrToIdMap, len(validators)),
idToValAddrMap: make(IdToValAddrMap, len(validators)),
validatorMap: make(ValidatorMap, len(validators)),
}
valAddresses := make([]string, 0, len(validators))
for _, val := range validators {
addr := val.GetAddress()
valAddresses = append(valAddresses, addr)
am.validatorMap[addr] = val
}
sort.Strings(valAddresses)
for i, addr := range valAddresses {
nodeId := NodeId(i + 1) // TODO(#434): Improve the use of NodeIDs
am.valAddrToIdMap[addr] = nodeId
am.idToValAddrMap[nodeId] = addr
}
return am
}
How we use it (for deterministic round robin):
func (m *leaderElectionModule) electNextLeaderDeterministicRoundRobin(message *typesCons.HotstuffMessage) (typesCons.NodeId, error) {
height := int64(message.Height)
readCtx, err := m.GetBus().GetPersistenceModule().NewReadContext(height)
if err != nil {
return typesCons.NodeId(0), err
}
defer readCtx.Release()
vals, err := readCtx.GetAllValidators(height)
if err != nil {
return typesCons.NodeId(0), err
}
value := int64(message.Height) + int64(message.Round) + int64(message.Step) - 1
numVals := int64(len(vals))
return typesCons.NodeId(value%numVals + 1), nil
}
If we leverage the PeerID, we can just use the sorting mechanism there and avoid a separate "NodeId".
It feels like it would cause less cognitive load for new entrants to the codebase. Wdyt?
@bryanchriswhite wanted to follow up on my comments in this ADR. |
Summary
This pull request adds an Architecture Decision Record (ADR) for simplifying and consolidating node identity in our system by keeping consensus NodeId and P2P identity separate. The ADR explains the context, problem statement, decision drivers, considered options, and the decision outcome, along with the positive and negative consequences of the chosen option.
The chosen option is to keep consensus NodeId and P2P identity separate, as it prevents unintended interference between consensus and P2P layers while maintaining a clear separation of concerns.
Please review the ADR and provide feedback on:
Related Issues