Commit Graph
9486 Commits
Author SHA1 Message Date
William Banfield d5aaa1af75 fix typo in state_test 2022-01-18 17:16:05 -05:00
William Banfield 82d46fe871 remove nolint: ll directive 2022-01-18 16:26:13 -05:00
William Banfield e30434ad5a reduce ensureTimeout 2022-01-18 16:24:43 -05:00
William Banfield 40b7093e85 update changelog pending 2022-01-18 16:22:17 -05:00
William Banfield 8810d038d9 Merge remote-tracking branch 'origin' into wb/pbts-rebase-master 2022-01-14 20:16:05 -05:00
William Banfield 88db4cdf7e remove noisy logger 2022-01-14 19:55:51 -05:00
Anca ZamfirandWilliam Banfield 330eb8ded0 Remove voteTime() (#7563) 2022-01-14 19:52:15 -05:00
William BanfieldandWilliam Banfield 9f52d9fbd7 proto: rename timing params to synchrony params (#7554) 2022-01-14 19:52:12 -05:00
Anca ZamfirandWilliam Banfield 8eec8447e8 Prevote nil if proposal is not timely (#7415)
* 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>
2022-01-14 19:50:36 -05:00
William BanfieldandWilliam Banfield 9e56a95473 consensus: check that proposal is non-nil before voting (#7480) 2022-01-14 19:47:07 -05:00
Anca ZamfirandWilliam Banfield d444a71ec7 Fix pbts tests (#7413)
* Allow nil block ID check in ensureProposalWithTimout

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

* Remove error check on service stop
2022-01-14 19:47:03 -05:00
Anca ZamfirandWilliam Banfield 47e0223356 Fix compilation 2022-01-14 19:44:48 -05:00
William BanfieldandWilliam Banfield 2ff233d944 internal/consensus: prevote nil if proposal timestamp does not match (#7391)
This change updates the proposal logic to use the block's timestamp in the proposal message. It adds an additional piece of validation logic to the prevote step to check that the block's timestamp matches the proposal message's timestamp.
2022-01-14 19:42:39 -05:00
William BanfieldandWilliam Banfield e17178d70d internal/consensus: remove proposal wait time (#7418) 2022-01-14 19:26:58 -05:00
Anca ZamfirandWilliam Banfield 14f4db7c19 Remove MedianTime, set block time to Now() (#7382)
* Remove MedianTime, set block time to Now()

* Fix goimports

* Fix import ordering
2022-01-14 19:23:42 -05:00
William BanfieldandWilliam Banfield fa1afef125 internal/consensus: proposer waits for previous block time (#7376)
This change introduces the logic to have the proposer wait until the previous block time has passed before attempting to propose the next block.

The change achieves this by by adding a new clause into the enterPropose state machine method. The method now checks if the validator is the proposer and if the validator's clock is behind the previous block's time. If the validator's clock is behind the previous block time, it schedules a timeout to re-enter the enter propose method after enough time has passed.
2022-01-14 19:23:37 -05:00
William BanfieldandWilliam Banfield 3022f9192a types: add new consensus params from proto (#7354)
This change adds the new TimingParams proto messages. These new messages were build using the wb/proposer-based-timestamps branch on the spec repo.
This change also adds validation that these values are positive when parsed and adds the new parameters into the existing tests.
2022-01-14 18:58:16 -05:00
315ee5aac5 internal/consensus: refactor ensure functions to use a common function (#7373)
* internal/consensus: refactor the common_test functions to use a single timeout function

* remove ensurePrecommit

* Update internal/consensus/common_test.go

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* join lines for fatal messages

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
2022-01-14 18:58:12 -05:00
William BanfieldandWilliam Banfield e7f77049eb types: remove accuracy from timestamp params (#7341) 2022-01-14 18:40:04 -05:00
William BanfieldandWilliam Banfield f73c247a0b consensus: ensure proposal receipt waits for maxWaitingTime (#7307)
* consensus: ensure proposal receipt waits for maxWaitingTime

* rebase fixups

* lint++

* lint++

* register result chan separately

* lint++
2022-01-14 18:39:58 -05:00
32008ae1d8 consensus: add calculation for proposal step waits from pbts (#7290)
* initial proposerWaitsUntil implementation

* switch to duration for easier use with timeout scheduling

* add proposal step waiting time with tests

* minor aesthetic change to IsTimely

* minor language fix

* Update internal/consensus/state.go

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* reword comment

* change accuracy to precision

* move tests to separate pbts test file

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
2022-01-14 18:31:11 -05:00
William BanfieldandWilliam Banfield 89e3f43cbc consensus: refactor the fake validator to take a clock source (#7300) 2022-01-14 18:31:07 -05:00
Sam KleinmanandGitHub 7ed57ef5f9 statesync: more orderly dispatcher shutdown (#7601) 2022-01-14 16:34:12 -05:00
Sam KleinmanandGitHub 2199e0a8a1 light: convert validation panics to errors (#7597) 2022-01-14 16:18:50 -05:00
William BanfieldandWilliam Banfield 7e17892650 factory: simplify validator and genesis factory functions (#7305) 2022-01-14 16:13:16 -05:00
Sam KleinmanandGitHub 887cb219ab light: remove test panic (#7588) 2022-01-14 13:16:43 -05:00
Sam KleinmanandGitHub 82b65868ce node+autofile: avoid leaks detected during WAL shutdown (#7599) 2022-01-14 13:04:01 -05:00
William BanfieldandGitHub 2f75899320 ADR-74: Migrate Timeout Parameters to Consensus Parameters (#7503)
related to: #7274 and #7275 

Still somewhat uncertain on two things that I'd appreciate more feedback on:
1. The optional temporary local overrides. Perhaps this is superfluous and we can simply make the transition without the override?
2. If this set of parameters seems to be large enough to allow application developers to create the chains they want but not so large as to be needlessly complex.
2022-01-14 16:48:59 +00:00
William BanfieldandGitHub abb7c8c2b0 RFC-009: Consensus Parameter Upgrades (#7524)
Related to #7503
2022-01-14 16:47:02 +00:00
M. J. FrombergerandGitHub c065eeb18a Add changelog entries from release v0.34.15. (#7598)
Fixes #7596.
2022-01-14 16:07:53 +00:00
M. J. FrombergerandGitHub 1ff69361e8 rpc: remove dependency of URL (GET) requests on tmjson (#7590)
The parameters for RPC GET requests are parsed from query arguments in the
request URL. Rework this code to remove the need for tmjson. The structure of a
call still requires reflection, and still works the same way as before, but the
code structure has been simplified and cleaned up a bit.

Points of note:

- Consolidate handling of pointer types, so we only need to dereference once.
- Reduce the number of allocations of reflective types.
- Report errors for unsupported types rather than returning untyped nil.

Update the tests as well. There was one test case that checked for an error on
a behaviour the OpenAPI docs explicitly demonstrates as supported, so I fixed
that test case, and also added some new ones for cases that weren't checked.

Related:

* Update e2e base Go image to 1.17 (to match config).
2022-01-14 07:53:53 -08:00
Sam KleinmanandGitHub 159d763422 light: avoid panic for integer underflow (#7589) 2022-01-14 09:58:41 -05:00
M. J. FrombergerandGitHub 9409cdea55 rpc: update fuzz criteria to match the implementation (#7595)
I missed this during my previous pass.

Requirements for handlers:

- First argument is context.Context.
- Last of two results is error.
2022-01-14 14:41:57 +00:00
William BanfieldandWilliam Banfield b20bad14ae state: add an 'IsTimely' method to implement the 'timely' check for proposer-based timestamps (#7170)
* state: add an IsTimely function to implement the check for timely in proposer-based timestamps

* move time checks into block.go and add time source mechanism

* timestamp params comment

* add todo related to pbts spec and timestamp params

* remove old istimely

* switch to using built in before function

* lint++

* wip

* move into proposal and create a default set of params

* defer using default cons params for now
2022-01-13 23:13:10 -05:00
1f3c3c6848 consensus: update state to prevote nil when proposal block does not match locked block. (#6986)
* add failing test

* tweak comments in failing test

* failing test comment

* initial attempt at removing prevote locked block logic

* comment out broken function

* undo reset on prevotes

* fixing TestProposeValidBlock test

* update test for completed POL update

* comment updates

* further unlock testing

* update comments

* Update internal/consensus/state.go

* spacing nit

* comment cleanup

* nil check in addVote

* update unlock description

* update precommit on relock comment

* add ensure new timeout back

* rename IsZero to IsNil and replace uses of block len check with helper

* add testing.T to new assertions

* begin removing unlock condition

* fix TestStateProposerSelection2 to precommit for nil correctly

* remove erroneous sleep

* update TestStatePOL comment

* update relock test to be more clear

* add _ into test names

* rename slashing

* udpate no relock function to be cleaner

* do not relock on old proposal test cleanup

* con state name update

* remove all references to unlock

* update test comments to include new

* add relock test

* add ensureRelock to common_test

* remove all event unlock

* remove unlock checks

* no lint add space

* lint ++

* add test for nil prevote on different proposal

* fix prevote nil condition

* fix defaultDoPrevote

* state_test.go fixes to accomodate prevoting for nil

* add failing test for POL from previous round case

* update prevote logic to prevote POL from previous round

* state.go comment fixes

* update validatePrevotes to correctly look for nil

* update new test name and comment

* update POLFromPreviousRound test

* fixes post merge

* fix spacing

* make the linter happy

* change prevote log message

* update prevote nil debug line

* update enterPrevote comment

* lint

* Update internal/consensus/state.go

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>

* Update internal/consensus/state.go

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>

* add english description of alg rules

* Update internal/consensus/state.go

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>

* comment fixes from review

* fix comment

* fix comment

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
2022-01-13 23:13:06 -05:00
William BanfieldandWilliam Banfield 6d2cb8ba8e consensus: remove logic to unlock block on 2/3 prevote for nil (#6954) 2022-01-13 22:49:39 -05:00
William BanfieldandWilliam Banfield 76c935e325 consensus: remove panics from test helper functions (#6969) 2022-01-13 22:04:52 -05:00
M. J. FrombergerandGitHub ec59b1a1ae rpc: check RPC service functions more carefully (#7587)
Require that RPC functions take a context as their first argument, and return
an error as either their only result, or the second of two results.

This does not change how functions are dispatched, but will make it a little
easier to make more invasive changes in the near future.
2022-01-13 13:27:45 -08:00
Sam KleinmanandGitHub 7e8fa4ed85 consensus: explicit test timeout (#7585) 2022-01-13 16:11:51 -05:00
M. J. FrombergerandGitHub b7c19a5cd4 rpc: clean up the RPCFunc constructor signature (#7586)
Instead of taking a comma-separated string of parameter names, take each
parameter name as a separate argument. Now that we no longer have an extra flag
for caching, this fits nicely into a variadic trailer.

* Update all usage of NewRPCFunc and NewWSRPCFunc.
2022-01-13 12:13:28 -08:00
Sam KleinmanandGitHub 8ff367ad29 log: avoid use of legacy test logging (#7583) 2022-01-13 14:38:54 -05:00
M. J. FrombergerandGitHub 81ee41228a rpc: consolidate RPC route map construction (#7582)
Define interfaces for the various methods a service may implement.  This is
basically just the set of things on Environment that are exported as RPCs, but
these are also implemented by the light proxy.

* internal/rpc: use NewRoutesMap to construct routes on service start
* light/proxy: use NewRoutesMap to construct RPC routes
2022-01-13 10:45:36 -08:00
Sam KleinmanandGitHub cef17e1c02 node+rpc: rpc environment should own it's creation (#7573) 2022-01-13 12:39:48 -05:00
Sam KleinmanandGitHub fd2eccbae1 consensus: use noop logger for WAL test (#7580) 2022-01-13 12:05:12 -05:00
Sam KleinmanandGitHub ed660bddeb node+privval: refactor privval construction (#7574) 2022-01-13 11:53:05 -05:00
M. J. FrombergerandGitHub 5a89263dbe rpc: simplify panic recovery in the server middleware (#7578)
Rather than installing two separate panic handlers, defer the bookkeeping
separately from recovery, and lift the delegated handler call out to the top
level of the wrapper.

Also: Regularize the server middleware wrappers.
2022-01-13 07:02:21 -08:00
M. J. FrombergerandGitHub 904957aaa9 rpc: rework how responses are written back via HTTP (#7575)
Add writeRPCResponse and writeHTTPResponse helpers, that handle the way RPC
responses are written to HTTP replies. These replace the exported helpers.

Visible effects:

- JSON results are now marshaled without indentation.
- HTTP status codes are now normalized.
- Cache control headers are no longer set.

Details:

- When writing a response to a URL (GET) request, do not marshal the whole
  JSON-RPC object into the body, only encode the result or the error object.
  This is a user-visible change.

- Do not change the HTTP status code for RPC errors. The RPC error already
  reports what went wrong, the HTTP status should only report problems with the
  HTTP transaction itself. This is a user-visible change.

- Encode JSON without indentation in POST response bodies. This is mainly cosmetic
  but saves quite a bit of response data. Indent is still applied to GET responses to make
  life easier for code examples.

- Remove an obsolete TODO about reporting an HTTP error on websocket upgrade.
  Nothing needed to change; the upgrader already reports an error.

- Report an HTTP error when starting the server loop fails.

- Improve logging for encoding errors.

- Log less aggressively.
2022-01-12 17:25:58 -08:00
Sam KleinmanandGitHub 2a348cc1e9 logging: remove reamining instances of SetLogger interface (#7572) 2022-01-12 16:56:49 -05:00
Sam KleinmanandGitHub 7a9a38d9d7 service: avoid debug logs before error (#7564) 2022-01-12 16:17:43 -05:00
Sam KleinmanandGitHub 25e665df17 internal/libs: delete unused functionality (#7569) 2022-01-12 15:55:42 -05:00