Skip to content
This repository was archived by the owner on Feb 23, 2022. It is now read-only.

Proposer-based timestamp specification - #261

Merged
istoilkovska merged 7 commits into
masterfrom
ilina/proposer-based-timestamp
Mar 23, 2021
Merged

istoilkovska merged 7 commits into
masterfrom
ilina/proposer-based-timestamp

Conversation

@istoilkovska

@istoilkovska istoilkovska commented Mar 2, 2021 •

Copy link
Copy Markdown
Contributor

This is the first draft of the English and TLA+ specifications of proposer-based timestamp, containing:

@josef-widder

Copy link
Copy Markdown
Contributor

@konnov is going to do an in-depth verification effort of the TLA+ spec in the beginning of April. This PR, and subsequent planning work (ADR) should not be blocked by that.

@cmwaters cmwaters left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have a few questions to help my understanding of this algorithm.

  1. What happens if 2/3+ precommit on a block that has a timestamp that a node deems to be untimely. Does it a) still commit it or b) panic
  2. Can a proposer in round 2 propose a block with a time less than a block proposed in round 1 (I'm guessing this is fine so long as it is still timely).
  3. Should there be any relation between timeout propose and PRECISION since a proposer waiting for the time to be ready to send out their proposal could timeout and thus miss their block (or if PRECISION is too relaxed a proposer could set their block time well in the future, where the proposer of the next height will be unable to propose a block before the timeout).
    EDIT
  4. What is the validation like for nodes that are still catching up and are thus validating blocks "from the past". Do they just ignore time (except maybe for being greater than the time of the previous block)

@istoilkovska

Copy link
Copy Markdown
Contributor Author
1. What happens if 2/3+ precommit on a block that has a timestamp that a node deems to be untimely. Does it a) still commit it or b) panic

Short answer: a). Long answer: Following the discussion after the presentation, we changed the protocol a bit. Rather than dropping PROPOSE messages when they are untimely, we store them and record whether they have been received on time or not. The rule to decide on a block is then based on receiving any PROPOSE message, regardless if it was on time or not.

2. Can a proposer in round 2 propose a block with a time less than a block proposed in round 1 (I'm guessing this is fine so long as it is still timely).

Yes. Still, these two times are greater than the time of the last block.

3. Should there be any relation between timeout propose and PRECISION since a proposer waiting for the time to be ready to send out their proposal could timeout and thus miss their block (or if PRECISION is too relaxed a proposer could set their block time well in the future, where the proposer of the next height will be unable to propose a block before the timeout).

You're right, we overlooked this. We will need timeoutPropose(r)>2∆+timeoutPrecommit(r−1) + x, where x is the maximum difference between the last block time and the local clocks. We will look at the exact value of x more closely next week.

4. What is the validation like for nodes that are still catching up and are thus validating blocks "from the past". Do they just ignore time (except maybe for being greater than the time of the previous block)

As far as we understand, currently the nodes that do validation check BFT time against the median of the commits in the same block. Analogously, the proposer-based timestamp is checked by checking that all nodes that signed the commit also signed the proposer-based timestamp.

@cmwaters cmwaters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This all looks good at least from my angle 👍 . I see that there could be a couple of small things that may need to be ironed out but IMO I think this spec is well thought out. My question is how do we define when this is ready to be merged and what steps need to be taken following the merge of this PR.

For safety (Point 1, Point 2, Point 3i) and liveness (Point 4) we need
the following assumptions:

- There exists a system parameter `PRECISION` such that for any two correct validators `V` and `W`, and at any real-time `t`, their local times `C_V(t)` and `C_W(t)` differ by less than `PRECISION` time units,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When you say system parameter, does this imply that PRECISION is a consensus parameter that is agreed upon in consensus or an individual node parameter?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same q for ACCURACY

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PRECISION needs to be agreed upon in consensus, as it will be part of the code. Moreover, in our analysis we assume it is the same on every node.

ACCURACY is not visible in the code. But it is crucial to relate blocktime to real-time. It required, e.g., by a lightclient to understand how old a block really is. In principle here a lightclient may subjectively say, "I assume accuracy is 10 sec". Then its safety depends on the correctness of this assumption. It would therefore be good if the validators would provide an estimate how large their ACCURACY is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right. We could also persist real-time values for each node when they store their blocks and add this as part of an RPC endpoint. Thus, participants of the network could query nodes for their ACCURACY. Would doing something like that makes sense?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure that would help.

But you are right: there is a bigger question: how are validators synchronizing their clocks now (I guess they use NTP) and what values for ACCURACY can we assume from there.

Or even more generally: right now there are a lot of implicit assumptions about time and clocks. We need to make them more explicit (as we tried in this PR). And once we made these assumptions explicit, what are suitable values for the parameters. For instance, the timeout values of Tendermint consensus implementation work pretty well. I wonder how these values where set/estimated initially. A similar approach we should take for the parameters introduced in this PR.

Also, I think we can be quite conservative here. Even if the precision/accuracy of the clocks with NTP is in the order of several hundred microseconds, perhaps it is enough to set the parameters in the code to 10 seconds. After all, given that unbonding and trusting periods are in the order of weeks, we just need to maintain some relation of real-time to block time.

The point about these parameters are not to be as precise as possible, but to understand "how precise" the solution guarantees to be in order to have sound guarantees at the system interfaces, e.g., between full nodes and light nodes. The point is to guarantee some value of precision that is sufficient for the application purpose rather to expose the actual precision that the system could achieve.


#### Reception Step
In the reception step at node `p` at local time `now_p`, upon receiving a message `m`:
- **if** the message `m` is of type `PROPOSE` and satisfies `now_p - PRECISION < m.time < now_p + PRECISION + MSGDELAY`, then mark the message as `timely`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There has been some talk about giving the application some degree of control over the block times (tendermint/tendermint#5911). Such control might be valuable when some transactions / loads require more time to process. In the case this idea was to come to any fruition would we redefine timely as:

now_p - PRECISION + BLOCKDELAY < m.time < now_p + PRECISION + MSGDELAY + BLOCKDELAY

@josef-widder josef-widder Mar 22, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it interferes here.

Rather it interferes with the TimeoutPropose: I guess the cleanest way to do this is that the proposer waits until the BLOCKDELAY has expired before sending the PROPOSE message.

In #265 (comment) I have estimated how TimeoutPropose needs to be computed to ensure monotonic block times, that is

  • block(i+1).Time > block(i).Time

This would need to be generalized to

  • block(i+1).Time > block(i).Time + BLOCKDELAY

That is, to compute T2 in this case, we would need to add BLOCKDELAY. I guess we can already add a comment in the spec right now to be ready for such a change. What do you think?

@cmwaters cmwaters Mar 23, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. Yeah this makes sense. If you want, you can mention it but I wouldn't say that the idea is well developed enough to warrant any changes to the math / calculations. What I will do, is relay what you've said in the original issue so we have a point of reference if anything develops

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have added a comment in the spec about how BLOCKDELAY can be incorporated in the future.

@istoilkovska
istoilkovska merged commit 640b710 into master Mar 23, 2021
@istoilkovska
istoilkovska deleted the ilina/proposer-based-timestamp branch March 23, 2021 15:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants