Commit Graph

9483 Commits

Author SHA1 Message Date
Jasmina Malicevic
d68d25dcd5 light: return light client status on rpc /status (#7536)
*light: rpc /status returns status of light client ; code refactoring
 light: moved lightClientInfo into light.go, renamed String to ID
test/e2e: Return light client trusted height instead of SyncInfo trusted height
test/e2e/start.go: Not waiting for light client to catch up in tests. Removed querying of syncInfo in start if the node is a light node

* light: Removed call to primary /status. Added trustedPeriod to light info
* light/provider: added ID function to return IP of primary and witnesses
* light/provider/http/http_test: renamed String() to ID()
2022-01-20 14:53:20 +01:00
Sam Kleinman
4e5c2b5e8f consensus: use delivertxsync (#7616) 2022-01-19 16:58:12 -05:00
Gui
ebbc3f02f5 p2p: always advertise self, to enable mutual address discovery (#7594)
Fixes #7593
2022-01-19 21:39:59 +00:00
M. J. Fromberger
c8e8a62084 abci/client: simplify client interface (#7607)
This change has two main effects:

1. Remove most of the Async methods from the abci.Client interface.
   Remaining are FlushAsync, CommitTxAsync, and DeliverTxAsync.

2. Rename the synchronous methods to remove the "Sync" suffix.

The rest of the change is updating the implementations, subsets, and mocks of
the interface, along with the call sites that point to them.

* Fix stringly-typed mock stubs.
* Rename helper method.
2022-01-19 10:58:56 -08:00
M. J. Fromberger
68d4fed236 consensus/state: avert a data race with state update and tests (#7643) 2022-01-19 10:47:06 -08:00
William Banfield
7bc3a7274a privval: do not use old proposal timestamp (#7621)
After #7592, @cmwaters noticed that the logic for re-using old timestamps for proposals may not work with proposer-based timestamps. This change removes the logic to re-use old proposal timestamps since it is no longer correct. Two proposals with different timestamps can no longer be treated as equivalent. Signing a proposal that only differs by timestamp in the new algorithm can be thought of as roughly equivalent to signing a proposal that only differs by `BlockID` in the old scheme. 

I also investigated the codebase and checked for any place we updated a timestamp using the pattern `(Timestamp = |Timestamp: )` and saw no additional places where we are updating the timestamp of a proposal message. 

Here is the output of that search:

```
privval/file.go:372:			vote.Timestamp = timestamp
privval/file.go:453:	lastVote.Timestamp = now
privval/file.go:454:	newVote.Timestamp = now
internal/test/factory/commit.go:25:			Timestamp:        now,
internal/test/factory/vote.go:34:		Timestamp:        time,
internal/consensus/state.go:2261:		Timestamp:        cs.voteTime(),
internal/consensus/state.go:2286:	vote.Timestamp = v.Timestamp
light/detector.go:414:		ev.Timestamp = common.Time
light/detector.go:418:		ev.Timestamp = trusted.Time
types/block.go:616:		Timestamp:        ts,
types/block.go:725:		Timestamp:        cs.Timestamp,
types/block.go:736:	cs.Timestamp = csp.Timestamp
types/block.go:800:		Timestamp:        commitSig.Timestamp,
types/evidence.go:84:		Timestamp:        blockTime,
types/evidence.go:190:	dve.Timestamp = evidenceTime
types/evidence.go:202:		Timestamp:        dve.Timestamp,
types/evidence.go:228:		Timestamp:        pb.Timestamp,
types/evidence.go:382:		Timestamp: %v}#%X`,
types/evidence.go:491:	l.Timestamp = evidenceTime
types/evidence.go:517:		Timestamp:           l.Timestamp,
types/evidence.go:546:		Timestamp:           lpb.Timestamp,
types/evidence.go:722:		Timestamp:        time,
types/vote.go:80:		Timestamp:        vote.Timestamp,
types/vote.go:216:		Timestamp:        vote.Timestamp,
types/vote.go:240:	vote.Timestamp = pv.Timestamp
types/test_util.go:27:			Timestamp:        now,
types/proposal.go:44:		Timestamp: tmtime.Now(),
types/proposal.go:132:	pb.Timestamp = p.Timestamp
types/proposal.go:157:	p.Timestamp = pp.Timestamp
types/canonical.go:49:		Timestamp: proposal.Timestamp,
types/canonical.go:62:		Timestamp: vote.Timestamp,
test/e2e/runner/evidence.go:186:		Timestamp:        evTime,
```
2022-01-19 17:42:09 +00:00
M. J. Fromberger
a806739375 abci/client: use a no-op logger in the test (#7633)
This averts a log-after-close issue. We should probably also chase the shutdown
issues, but since ABCI clients should generally only shut down once per process
I don't think this is a real priority, and the trace is hairy.
2022-01-19 08:58:35 -08:00
M. J. Fromberger
1af4113033 Increase test splits from 4 to 6. (#7630)
Decrease the likelihood that two flaky tests will hit
the same batch.

Account for the increase in test load from #7608.
2022-01-19 08:24:12 -08:00
dependabot[bot]
e6f6a13f8a build(deps): Bump github.com/prometheus/client_golang (#7636) 2022-01-19 11:50:52 +01:00
M. J. Fromberger
aea428d322 build: Make sure to test packages with external tests (#7608)
The test filter was looking for "TestGoFiles", which does not include tests in
a separate package (e.g., "package foo_test" for "package foo").
This caused several packages not to be tested in CI, including:

  github.com/tendermint/tendermint/abci/client
  github.com/tendermint/tendermint/crypto
  github.com/tendermint/tendermint/crypto/tmhash
  github.com/tendermint/tendermint/internal/eventbus
  github.com/tendermint/tendermint/internal/evidence
  github.com/tendermint/tendermint/internal/inspect
  github.com/tendermint/tendermint/internal/jsontypes
  github.com/tendermint/tendermint/internal/libs/protoio
  github.com/tendermint/tendermint/internal/libs/sync
  github.com/tendermint/tendermint/internal/p2p/pex
  github.com/tendermint/tendermint/internal/pubsub
  github.com/tendermint/tendermint/internal/pubsub/query
  github.com/tendermint/tendermint/internal/pubsub/query/syntax
  github.com/tendermint/tendermint/internal/state/indexer
  github.com/tendermint/tendermint/internal/state/indexer/block/kv
  github.com/tendermint/tendermint/libs/json
  github.com/tendermint/tendermint/libs/log
  github.com/tendermint/tendermint/libs/os
  github.com/tendermint/tendermint/light
  github.com/tendermint/tendermint/light/provider/http
  github.com/tendermint/tendermint/privval/grpc
  github.com/tendermint/tendermint/proto/tendermint/blocksync
  github.com/tendermint/tendermint/proto/tendermint/consensus
  github.com/tendermint/tendermint/proto/tendermint/statesync
  github.com/tendermint/tendermint/rpc/client
  github.com/tendermint/tendermint/rpc/client/mock
  github.com/tendermint/tendermint/test/e2e/tests
  github.com/tendermint/tendermint/test/fuzz/mempool
  github.com/tendermint/tendermint/test/fuzz/p2p/secretconnection
  github.com/tendermint/tendermint/test/fuzz/rpc/jsonrpc/server

Updates #7626 and #7634.
2022-01-18 18:36:46 -08:00
William Banfield
b6307c42e0 consensus: check proposal non-nil in prevote message delay metric (#7625) 2022-01-18 19:57:00 -05:00
M. J. Fromberger
5eae2e62c0 privval: synchronize leak check with shutdown (#7629)
The interaction between defers and t.Cleanup can be delicate.
For this case, which regularly flakes in CI, be explicit:
Defer the closes and waits before making any attempt to leaktest.
2022-01-18 16:36:09 -08:00
M. J. Fromberger
a7eb95065d autofile: ensure files are not reopened after closing (#7628)
During file rotation and WAL shutdown, there was a race condition between users
of an autofile and its termination. To fix this, ensure operations on an
autofile are properly synchronized, and report errors when attempting to use an
autofile after it was closed.

Notably:

- Simplify the cancellation protocol between signal and Close.
- Exclude writers to an autofile during rotation.
- Add documentation about what is going on.

There is a lot more that could be improved here, but this addresses the more
obvious races that have been panicking unit tests.
2022-01-18 14:57:20 -08:00
M. J. Fromberger
5cca45bb45 pex: improve handling of closed channels (#7623)
Reverts and improves on #7622. The problem turns out not to be on the PEX
channel side, but on the pass-through (Go) channel.
2022-01-18 14:32:22 -08:00
M. J. Fromberger
417166704a pex: do not send nil envelopes to the reactor (#7622) 2022-01-18 12:01:04 -08:00
M. J. Fromberger
7fd97bf44b pex: avert a data race on map access in the reactor (#7614)
There was a path on which computing the next delivery time did not hold the
lock, defying the admonition on its comment.
2022-01-18 07:22:50 -08:00
William Banfield
0c82ceaa5f consensus: calculate prevote message delay metric (#7551)
## What does this pull request do?
This pull requests adds two metrics intended for use in calculating an experimental value for `MessageDelay`.

The metrics are as follows:
```
# HELP tendermint_consensus_complete_prevote_message_delay Difference in seconds between the proposal timestamp and the timestamp of the prevote that achieved 100% of the voting power in the prevote step.
# TYPE tendermint_consensus_complete_prevote_message_delay gauge
tendermint_consensus_complete_prevote_message_delay{chain_id="test-chain-aZbwF1"} 0.013025505

# HELP tendermint_consensus_quorum_prevote_message_delay Difference in seconds between the proposal timestamp and the timestamp of the prevote that achieved a quorum in the prevote step.
# TYPE tendermint_consensus_quorum_prevote_message_delay gauge
tendermint_consensus_quorum_prevote_message_delay{chain_id="test-chain-aZbwF1"} 0.013025505
```

## Why this change?

 For more information on what these metrics are calculating, see #7202. The aim is to merge to backport these metrics to v0.34 and run nodes on a few popular chains with these metrics to determine the experimental values for `MessageDelay` on these popular chains and use these to select our default `SynchronyParams.MessageDelay` value.

## Why Gauges for the metrics?
Gauges allow us to overwrite the metric on each successive observation. We can then capture these metrics over time to track the highest and lowest observed value.
2022-01-18 14:55:18 +00:00
Sam Kleinman
b10c74647f testing: use noop loger with leakteset in more places (#7604) 2022-01-18 09:08:20 -05:00
Sam Kleinman
c0b56e207a consensus: test shutdown to avoid hangs (#7603) 2022-01-18 08:55:13 -05:00
Kene
49153b753c rpc: paginate mempool /unconfirmed_txs endpoint (#7612)
This commit changes the behaviour of the /unconfirmed_txs endpoint by replacing limit with a page and perPage parameter for pagination.
The test case for unconfirmed_txs have been accommodated to properly test this change and the documentation for the API as well.
2022-01-18 10:58:32 +01:00
M. J. Fromberger
679b6a65b8 light: fix provider error plumbing (#7610)
The custom error types in the provider package did not propagate their wrapped
underlying reasons, making it difficult for the test to check that the correct
error was observed.

- Fix the custom errors to have a true underlying error (not just a string).
- Add Unwrap methods to support inspection by errors.Is.
- Update usage in a few places.
- Fix the test to check for acceptable variation.

Fixes #7609.
2022-01-16 13:48:21 -08:00
M. J. Fromberger
c24f003b55 protoio: fix incorrect test assertion (#7606)
After writing and then reading a bunch of random messages, the test was
checking that it did not read the same number of messages that it wrote.
The sense of this check was inverted; they should match.

Introduced by accident in #7522. I'm not sure why this did not show up in CI.

Edit: I now know why it didn't show up in ci: #7608.
2022-01-16 20:39:37 +00:00
Sebastian Gröbler
701e6026c5 Update README.md (#7602)
Fixed typo in exchange

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
2022-01-14 18:33:47 -08:00
M. J. Fromberger
dbe2146d0a rpc: simplify the encoding of interface-typed arguments in JSON (#7600)
Add package jsontypes that implements a subset of the custom libs/json 
package. Specifically it handles encoding and decoding of interface types
wrapped in "tagged" JSON objects. It omits the deep reflection on arbitrary
types, preserving only the handling of type tags wrapper encoding.

- Register interface types (Evidence, PubKey, PrivKey) for tagged encoding.
- Update the existing implementations to satisfy the type.
- Register those types with the jsontypes registry.
- Add string tags to 64-bit integer fields where needed.
- Add marshalers to structs that export interface-typed fields.
2022-01-14 18:14:09 -08:00
Sam Kleinman
7ed57ef5f9 statesync: more orderly dispatcher shutdown (#7601) 2022-01-14 16:34:12 -05:00
Sam Kleinman
2199e0a8a1 light: convert validation panics to errors (#7597) 2022-01-14 16:18:50 -05:00
Sam Kleinman
887cb219ab light: remove test panic (#7588) 2022-01-14 13:16:43 -05:00
Sam Kleinman
82b65868ce node+autofile: avoid leaks detected during WAL shutdown (#7599) 2022-01-14 13:04:01 -05:00
William Banfield
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 Banfield
abb7c8c2b0 RFC-009: Consensus Parameter Upgrades (#7524)
Related to #7503
2022-01-14 16:47:02 +00:00
M. J. Fromberger
c065eeb18a Add changelog entries from release v0.34.15. (#7598)
Fixes #7596.
2022-01-14 16:07:53 +00:00
M. J. Fromberger
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 Kleinman
159d763422 light: avoid panic for integer underflow (#7589) 2022-01-14 09:58:41 -05:00
M. J. Fromberger
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
M. J. Fromberger
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 Kleinman
7e8fa4ed85 consensus: explicit test timeout (#7585) 2022-01-13 16:11:51 -05:00
M. J. Fromberger
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 Kleinman
8ff367ad29 log: avoid use of legacy test logging (#7583) 2022-01-13 14:38:54 -05:00
M. J. Fromberger
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 Kleinman
cef17e1c02 node+rpc: rpc environment should own it's creation (#7573) 2022-01-13 12:39:48 -05:00
Sam Kleinman
fd2eccbae1 consensus: use noop logger for WAL test (#7580) 2022-01-13 12:05:12 -05:00
Sam Kleinman
ed660bddeb node+privval: refactor privval construction (#7574) 2022-01-13 11:53:05 -05:00
M. J. Fromberger
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. Fromberger
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 Kleinman
2a348cc1e9 logging: remove reamining instances of SetLogger interface (#7572) 2022-01-12 16:56:49 -05:00
Sam Kleinman
7a9a38d9d7 service: avoid debug logs before error (#7564) 2022-01-12 16:17:43 -05:00
Sam Kleinman
25e665df17 internal/libs: delete unused functionality (#7569) 2022-01-12 15:55:42 -05:00
Sam Kleinman
e07c4cdcf2 node: collapse initialization internals (#7567) 2022-01-12 15:32:22 -05:00
M. J. Fromberger
5c1399d803 rpc: fix mock test cases (#7571)
In two cases, we check for the content of an error right after asserting that
no error occurs. Fix the sense of those checks.

In one case, we check that there is no error with the diagnostic "expected
error". It's not clear whether this means "an error was expected" (which is
what I believe) or "we got the expected error". However, given the way the mock
plumbing is set up, the first interpretation seems right.
2022-01-12 20:17:53 +00:00
Sam Kleinman
6efdba8aa9 statesync: SyncAny test buffering (#7570) 2022-01-12 13:38:23 -05:00