Skip to content
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

Network Topology #43

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Network Topology #43

wants to merge 4 commits into from

Conversation

MatheusFranco99
Copy link
Contributor

Network topology SIP with the proposal of changing the network structure, namely how validators are assigned to topics, to reduce the number of non-committee messages an operator needs to handle.

Copy link
Contributor

@GalRogozinski GalRogozinski left a comment

Choose a reason for hiding this comment

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

Need to talk about the algorithm tomorrow

1. the replicas agree on the order of the events (validator addition and removal).
2. the transition function is deterministic.

Regarding condition (1), it's possible that a replica misses an event and produces an inconsistent state. To mitigate this issue, we can delay an event processing by some time interval to increase the probability of receiving all events before that. This is already included in the implementation which set the events to be processed only after 8 eth1 blocks.
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I am adding a task on how on general a node should sync itself to the contract state... this is not related to the SIP


In our case, there are extra assumptions that must be met depending on the nature of the model. Namely, upon an event, we say that:
- a model has "map dependency" if it may change the assignment of other validators added previously.
- a model has "map isolation" if it does not change the assignment of other validators added previously.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe "map stability" is a bette name..
but I dunno... maybe your name is better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! Stability is a much better name. Thanks!


For a model with "map dependency", since nodes use the state to communicate on the correct topic, it's fundamental that the events are processed at the same time. Due to the possibility of unstable network conditions, we can't ensure that this condition holds by the time that the assignment of a changed validator is used. A mitigation technique is to set the state to be updated on pre-defined periods and execute only events older than a certain threshold. For example, it could be set that the state updates in the last slot of an epoch (to be used for the following epoch) for all events received up to the 22nd epoch's slot.

If one does not want to rely on these assumptions and mitigation techniques, it's also possible to add a consensus protocol for the entire network to agree on the replicated state machine.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think relying on eth's consensus is good enough

Comment on lines 68 to 70
for topicIndex <= t.maxTopics {
t.topicMap[topicIndex] = make(map[phase0.ValidatorIndex]struct{})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

if it is in go you need to add topicIndex++

I hope in spec redesign we stop using go

for topicIndex, topicValidators := range t.topicMap {
// compute cost
equalOperators := t.NumberOfIntersectingOperators(committee, t.operatorsInTopic[topicIndex]) // Compute intersection in O(n + m) time
cost := (len(committee)-equalOperators)*len(topicValidators) + (len(t.operatorsInTopic[topicIndex])-equalOperators)*numberOfValidators
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the difference between the left side and the right side exactly?

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 believe you are referring to the equation, am I right?
So, the aggregation impact of joining operators $A$ and $B$ with validators $V_a$ and $V_b$ is

$$I = V_a * (|B \setminus A|) + V_b(|A \setminus B|)$$

So, on the left side, we have [the number of existing validators in the topic] * [new operators].

On the right side, we have [the number of new validators] * [operators in the topic that will start listening to these validators]

Comment on lines +153 to +164
```R
1. procedure Add_Validator(Topics, Validator, committee)
2. existsInTopic, topic <- Topics.Has(committee)
3. if existsInTopic then
4. Topics.AddValidator(topic, Validator)
5. Topics.Split(topic)
6. Topics.AggregationStep()
7. else
8. topic <- GenerateTopicID(committee)
9. Topics.AddValidator(topic, Validator)
10. Topics.AggregationStep()
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Not saying it is bad to stop using go (to the contrary). I was thinking about stopping with go when we do the spec redesign.

However,

  1. Kinda weird that before in the same document you used go and now you are using R
  2. I was thinking about switching to python actually
  3. must we have the line numbers?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I am guessing you just copied from your simulator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1 - The R label is just for looking like pseudo-code
3 - Not mandatory but I like it in pseudo-codes for references.

Yes, it was taken from the simulator repo and I added some little adjustments.

3. if existsInTopic then
4. Topics.AddValidator(topic, Validator)
5. Topics.Split(topic)
6. Topics.AggregationStep()
Copy link
Contributor

Choose a reason for hiding this comment

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

this is undefined in the SIP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding the split operation definition.

3. if existsInTopic then
4. Topics.AddValidator(topic, Validator)
5. else
6. bestTopic <- Topics.FindTopicWithMinimumAggregationImpact(Validator, committee)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the same as GetTopicWithLeastImpact as defined by go code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Comment on lines 226 to 230
The first algorithm requires more processing time, produces a better solution in terms of non-committee messages, and forces the model to have "map dependency".

The second algorithm requires less processing time, produces a worse solution in terms of non-committee messages, and allows the model to have "map isolation".

We propose going with the second solution due to the "map isolation" feature.
Copy link
Contributor

Choose a reason for hiding this comment

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

Over time we may pay a price for "map isolation"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure. However, I believe that the addition/removal operations may be changed in a future fork if we want.

## Drawbacks

- A bigger number of nodes in a topic increases the reliability of a node receiving a published message by propagation in the network. For example, two geographically distant nodes may have connection problems and intermediary nodes may help propagate a message.
- Usually, more nodes in a network (or topic) represent a stronger defense against attacks. However, the model indirectly reduces the number of operators in topics, which is understood to be a trade-off of this approach.
Copy link
Contributor

Choose a reason for hiding this comment

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

In some topics you mean
In some it increases them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants