Skip to content

Prevote nil if proposal is not timely#7415

Merged
ancazamfir merged 28 commits intowb/proposer-based-timestampsfrom
anca/prevote_nil_untimely
Jan 11, 2022
Merged

Prevote nil if proposal is not timely#7415
ancazamfir merged 28 commits intowb/proposer-based-timestampsfrom
anca/prevote_nil_untimely

Conversation

@ancazamfir
Copy link
Contributor

See #6942:
Update the proposal validation logic to prevote nil for proposals with times that fail the `timely` check if the proof of lock round is `-1`. If the proof of lock round is not -1, do not check timely.

Copy link
Contributor

@williambanfield williambanfield left a comment

Choose a reason for hiding this comment

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

This is definitely the right direction for this code change. The final piece of this is adding tests using the pbtsTestHarness.

These tests will test delivery of various blocks at height 2. The test harness creates one state machine under test and a set of fake validators that create proposals and votes. At height 2, the state machine under test is not the proposer, so we use that height to verify its behavior when it receives a block at different times and with various timestamps.

The test harness allows us to set when the 1. What time the block will be delivered to the state machine, 2. what the timestamp of the block will be set to and 3. what the timing params will be set to for the state machine. The tests then collect the prevotes from the state machine under test and allows us to examine them.

We should be able to use that to construct tests for the various conditions of timely-ness and ensure that the state machine votes properly in each case.

@williambanfield
Copy link
Contributor

williambanfield commented Dec 20, 2021

Created: #7481 to track the failure in tests (01). That may be fixed in master and is unrelated to this change. So is the failure in tests (00), which occurs in master as well. We should check those out when tackling issues in master, but they are not related to this.

Base automatically changed from anca/fix_pbts_tests to wb/proposer-based-timestamps December 21, 2021 19:39
@williambanfield
Copy link
Contributor

williambanfield commented Dec 22, 2021

Hey Anca, nice job getting all of this working with the test. I mulled this over a bit. I think that the best way to perform the check would be to just save the timestamp at which we receive the proposal. It makes the check a bit more obvious to anyone reading the code. Here's a commit implementing this solution, let me know what you think.
cda3a1b

@github-actions
Copy link

github-actions bot commented Jan 2, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale for use by stalebot label Jan 2, 2022
@cmwaters cmwaters removed the stale for use by stalebot label Jan 3, 2022
@ancazamfir
Copy link
Contributor Author

Hey Anca, nice job getting all of this working with the test. I mulled this over a bit. I think that the best way to perform the check would be to just save the timestamp at which we receive the proposal. It makes the check a bit more obvious to anyone reading the code. Here's a commit implementing this solution, let me know what you think. cda3a1b

yes, I think this is better, thanks!

@williambanfield
Copy link
Contributor

I think this is looking good. The main change is to change the GenesisTime no longer a strict equality. Once that change is made I think we should merge this in. I'm somewhat eager to move this into the master branch since the diff between this and master is growing pretty quickly lately.

@ancazamfir
Copy link
Contributor Author

I think this is looking good. The main change is to change the GenesisTime no longer a strict equality. Once that change is made I think we should merge this in. I'm somewhat eager to move this into the master branch since the diff between this and master is growing pretty quickly lately.

A few tests were failing. I think many use height 1 for testing and now since the block time is not the genesis time some assumptions break. I fixed the evidence tests.
TestStateLock_POLSafety2 consistently fails locally for me. I am wondering if it was working before just because the two proposed blocks had the same timestamps. Not sure if the last validatePrevote check is correct as we prevote nil ("ProposalBlock is valid but was not our locked block or did not receive a more recent majority; prevoting nil") and the check expects to prevote on the new proposal. Maybe we can discuss this one?
Will try to figure out the rest.

@cason
Copy link

cason commented Jan 10, 2022

The main change is to change the GenesisTime no longer a strict equality

Have these changes any impact elsewhere? I would consider opening an issue on that, if it is not "excessive caution".

@williambanfield
Copy link
Contributor

williambanfield commented Jan 10, 2022

The main change is to change the GenesisTime no longer a strict equality

Have these changes any impact elsewhere? I would consider opening an issue on that, if it is not "excessive caution".

@cason:
I made an issue here #7546, although I'm really not too worried about it but it's certainly possible there's something I'm not seeing.

@williambanfield
Copy link
Contributor

@ancazamfir Given that the genesis time change causes additional failures and complexity, I think we should split that change out into a different PR and just merge this change with the timely checks.

@ancazamfir
Copy link
Contributor Author

@ancazamfir Given that the genesis time change causes additional failures and complexity, I think we should split that change out into a different PR and just merge this change with the timely checks.

Ok i reverted the changes. They can be worked on/ reviewed in #7541

@ancazamfir ancazamfir merged commit 2617a5c into wb/proposer-based-timestamps Jan 11, 2022
@ancazamfir ancazamfir deleted the anca/prevote_nil_untimely branch January 11, 2022 10:44
williambanfield added a commit that referenced this pull request Jan 15, 2022
* Prevote nil if not timely

* William's suggestion to get the proposal from the proposer instead of
generating it.

* Don't check rhs for genesis block

* Update IsTimely to match the specification

* Fix proposal tests

* Add more timely tests and check votes

* Mark proposal invalid in SetProposal, fix in the future test

* save proposal time on roundstate

* received -> receive

* always reset proposal time

* Add IsTimely test for genesis proposal

* Check timely before ValidateBlock

* Review comments from Daniel

Co-authored-by: William Banfield <wbanfield@gmail.com>
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.

4 participants