From 767e2ec8a26e5a7c400e53c4abd250fe3da26f82 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Fri, 15 Apr 2022 12:15:35 -0700 Subject: [PATCH 1/8] Add a script to check documentation for ToC entries. (#8356) This script verifies that each document in the docs and architecture directory has a corresponding table-of-contents entry in its README file. It can be run manually from the command line. - Hook up this script to run in CI (optional workflow). - Update ADR ToC to include missing entries this script found. --- .github/workflows/docs-toc.yml | 20 +++++++++++++++++ docs/architecture/README.md | 9 ++++++-- docs/presubmit.sh | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docs-toc.yml create mode 100755 docs/presubmit.sh diff --git a/.github/workflows/docs-toc.yml b/.github/workflows/docs-toc.yml new file mode 100644 index 000000000..940df7c8c --- /dev/null +++ b/.github/workflows/docs-toc.yml @@ -0,0 +1,20 @@ +# Verify that important design docs have ToC entries. +name: Check documentation ToC +on: + pull_request: + push: + branches: + - master + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: technote-space/get-diff-action@v6.0.1 + with: + PATTERNS: | + docs/architecture/** + docs/rfc/** + - run: ./docs/presubmit.sh + if: env.GIT_DIFF diff --git a/docs/architecture/README.md b/docs/architecture/README.md index 00faaa8b8..e75896f38 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -104,12 +104,17 @@ None - [ADR-013: Symmetric-Crypto](./adr-013-symmetric-crypto.md) - [ADR-022: ABCI-Errors](./adr-022-abci-errors.md) - [ADR-030: Consensus-Refactor](./adr-030-consensus-refactor.md) +- [ADR-036: Empty Blocks via ABCI](./adr-036-empty-blocks-abci.md) - [ADR-037: Deliver-Block](./adr-037-deliver-block.md) - [ADR-038: Non-Zero-Start-Height](./adr-038-non-zero-start-height.md) +- [ADR-040: Blockchain Reactor Refactor](./adr-040-blockchain-reactor-refactor.md) - [ADR-041: Proposer-Selection-via-ABCI](./adr-041-proposer-selection-via-abci.md) +- [ADR-042: State Sync Design](./adr-042-state-sync.md) - [ADR-045: ABCI-Evidence](./adr-045-abci-evidence.md) +- [ADR-050: Improved Trusted Peering](./adr-050-improved-trusted-peering.md) - [ADR-057: RPC](./adr-057-RPC.md) +- [ADR-064: Batch Verification](./adr-064-batch-verification.md) - [ADR-069: Node Initialization](./adr-069-flexible-node-initialization.md) -- [ADR-071: Proposer-Based Timestamps](adr-071-proposer-based-timestamps.md) +- [ADR-071: Proposer-Based Timestamps](./adr-071-proposer-based-timestamps.md) +- [ADR-073: Adopt LibP2P](./adr-073-libp2p.md) - [ADR-074: Migrate Timeout Parameters to Consensus Parameters](./adr-074-timeout-params.md) - diff --git a/docs/presubmit.sh b/docs/presubmit.sh new file mode 100755 index 000000000..19e931a4f --- /dev/null +++ b/docs/presubmit.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# This script verifies that each document in the docs and architecture +# directory has a corresponding table-of-contents entry in its README file. +# +# This can be run manually from the command line. +# It is also run in CI via the docs-toc.yml workflow. +# +set -euo pipefail + +readonly base="$(dirname $0)" +cd "$base" + +readonly workdir="$(mktemp -d)" +trap "rm -fr -- '$workdir'" EXIT + +checktoc() { + local dir="$1" + local tag="$2"'-*-*' + local out="$workdir/${dir}.out.txt" + ( + cd "$dir" >/dev/null + find . -type f -maxdepth 1 -name "$tag" -not -exec grep -q "({})" README.md ';' -print + ) > "$out" + if [[ -s "$out" ]] ; then + echo "-- The following files in $dir lack a ToC entry: +" + cat "$out" + return 1 + fi +} + +err=0 + +# Verify that each RFC and ADR has a ToC entry in its README file. +checktoc architecture adr || ((err++)) +checktoc rfc rfc || ((err++)) + +exit $err From 851c0dc4f3088723c724cb01c4877ee78c3d6ffc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Apr 2022 20:48:10 -0400 Subject: [PATCH 2/8] build(deps): Bump async from 2.6.3 to 2.6.4 in /docs (#8357) Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4. - [Release notes](https://github.com/caolan/async/releases) - [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md) - [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4) --- updated-dependencies: - dependency-name: async dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index 52f7b52a6..447c8c27d 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -3037,9 +3037,9 @@ } }, "node_modules/async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dependencies": { "lodash": "^4.17.14" } @@ -16588,9 +16588,9 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" }, "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "requires": { "lodash": "^4.17.14" } From bebfd8663b01ef593af38ca490adde13bc7cecb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 12:48:09 +0000 Subject: [PATCH 3/8] build(deps): Bump github.com/creachadair/atomicfile from 0.2.4 to 0.2.5 (#8365) Bumps [github.com/creachadair/atomicfile](https://github.com/creachadair/atomicfile) from 0.2.4 to 0.2.5.
Commits
  • b8ff50e Release v0.2.5.
  • 95084ab Update actions/setup-go to v3.
  • 10d28f6 Update actions/checkout to v3.
  • 5f1989d Use a more explanatory temp file prefix.
  • 7819ee5 Add Go 1.18 to the CI workflow.
  • c30fad6 Drop old Go versions from CI.
  • ebcfa6b acat: use WriteData to simplify the code
  • See full diff in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/creachadair/atomicfile&package-manager=go_modules&previous-version=0.2.4&new-version=0.2.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9890018c4..92c54d106 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( ) require ( - github.com/creachadair/atomicfile v0.2.4 + github.com/creachadair/atomicfile v0.2.5 github.com/creachadair/taskgroup v0.3.2 github.com/golangci/golangci-lint v1.45.2 github.com/google/go-cmp v0.5.7 diff --git a/go.sum b/go.sum index dc0875b4e..60f26f779 100644 --- a/go.sum +++ b/go.sum @@ -225,8 +225,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creachadair/atomicfile v0.2.4 h1:GRjpQLmz/78I4+nBQpGMFrRa9yrL157AUTrA6hnF0YU= -github.com/creachadair/atomicfile v0.2.4/go.mod h1:BRq8Une6ckFneYXZQ+kO7p1ZZP3I2fzVzf28JxrIkBc= +github.com/creachadair/atomicfile v0.2.5 h1:wkOlpsjyJOvJ3Hd8juHKdirJnCSIPacvtY21/3nYjAo= +github.com/creachadair/atomicfile v0.2.5/go.mod h1:BRq8Une6ckFneYXZQ+kO7p1ZZP3I2fzVzf28JxrIkBc= github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM= github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= github.com/creachadair/tomledit v0.0.16 h1:PDNxgDjeeiNk1cyFfliIVQmagh1jPbDMabOw9yfSKLk= From 7243ef71e23f771624a6a6b3b8f55508895ae926 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Mon, 18 Apr 2022 07:21:05 -0700 Subject: [PATCH 4/8] Forward port changelog from v0.35.4 to master. (#8364) --- CHANGELOG.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73fee3289..cfafd8c7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/cosmos). +## v0.35.4 + +April 18, 2022 + +Special thanks to external contributors on this release: @firelizzard18 + +### FEATURES + +- [cli] [\#8300](https://github.com/tendermint/tendermint/pull/8300) Add a tool to update old config files to the latest version [backport [\#8281](https://github.com/tendermint/tendermint/pull/8281)]. (@creachadair) + +### IMPROVEMENTS + +### BUG FIXES + +- [cli] [\#8294](https://github.com/tendermint/tendermint/pull/8294) keymigrate: ensure block hash keys are correctly translated. (@creachadair) +- [cli] [\#8352](https://github.com/tendermint/tendermint/pull/8352) keymigrate: ensure transaction hash keys are correctly translated. (@creachadair) + ## v0.35.3 April 8, 2022 @@ -110,7 +127,7 @@ Special thanks to external contributors on this release: @JayT106, - [\#7106](https://github.com/tendermint/tendermint/pull/7106) Revert mutex change to ABCI Clients (@tychoish). - [\#7142](https://github.com/tendermint/tendermint/pull/7142) mempool: remove panic when recheck-tx was not sent to ABCI application (@williambanfield). -- [consensus]: [\#7060](https://github.com/tendermint/tendermint/pull/7060) +- [consensus]: [\#7060](https://github.com/tendermint/tendermint/pull/7060) wait until peerUpdates channel is closed to close remaining peers (@williambanfield) - [privval] [\#5638](https://github.com/tendermint/tendermint/pull/5638) Increase read/write timeout to 5s and calculate ping interval based on it (@JoeKash) - [evidence] [\#6375](https://github.com/tendermint/tendermint/pull/6375) Fix bug with inconsistent LightClientAttackEvidence hashing (cmwaters) @@ -1416,7 +1433,7 @@ Special thanks to external contributors on this release: @jon-certik, @gracenoah *August 28, 2019* @climber73 wrote the [Writing a Tendermint Core application in Java -(gRPC)](https://github.com/tendermint/tendermint/blob/master/docs/guides/java.md) +(gRPC)](https://github.com/tendermint/tendermint/blob/master/docs/guides/java.md) guide. Special thanks to external contributors on this release: @@ -3688,7 +3705,7 @@ containing substructs: `BaseConfig`, `P2PConfig`, `MempoolConfig`, `ConsensusCon - Change some [function and method signatures](https://gist.github.com/ebuchman/640d5fc6c2605f73497992fe107ebe0b) accomodate new config - Logger - - Replace static `log15` logger with a simple interface, and provide a new implementation using `go-kit`. + - Replace static `log15` logger with a simple interface, and provide a new implementation using `go-kit`. See our new [logging library](https://github.com/tendermint/tmlibs/log) and [blog post](https://tendermint.com/blog/abstracting-the-logger-interface-in-go) for more details - Levels `warn` and `notice` are removed (you may need to change them in your `config.toml`!) - Change some [function and method signatures](https://gist.github.com/ebuchman/640d5fc6c2605f73497992fe107ebe0b) to accept a logger From 889341152a09a67df8f83ad5a52766700ef4ff34 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 18 Apr 2022 15:49:11 -0400 Subject: [PATCH 5/8] p2p: fix setting in con-tracker (#8370) --- internal/p2p/conn_tracker.go | 3 ++- internal/p2p/conn_tracker_test.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/p2p/conn_tracker.go b/internal/p2p/conn_tracker.go index 09673c093..54f9c8980 100644 --- a/internal/p2p/conn_tracker.go +++ b/internal/p2p/conn_tracker.go @@ -26,6 +26,7 @@ func newConnTracker(max uint, window time.Duration) connectionTracker { cache: make(map[string]uint), lastConnect: make(map[string]time.Time), max: max, + window: window, } } @@ -43,7 +44,7 @@ func (rat *connTrackerImpl) AddConn(addr net.IP) error { if num := rat.cache[address]; num >= rat.max { return fmt.Errorf("%q has %d connections [max=%d]", address, num, rat.max) } else if num == 0 { - // if there is already at least connection, check to + // if there is already at least one connection, check to // see if it was established before within the window, // and error if so. if last := rat.lastConnect[address]; time.Since(last) < rat.window { diff --git a/internal/p2p/conn_tracker_test.go b/internal/p2p/conn_tracker_test.go index 66656e114..daa3351f2 100644 --- a/internal/p2p/conn_tracker_test.go +++ b/internal/p2p/conn_tracker_test.go @@ -70,4 +70,15 @@ func TestConnTracker(t *testing.T) { } require.Equal(t, 10, ct.Len()) }) + t.Run("Window", func(t *testing.T) { + const window = 100 * time.Millisecond + ct := newConnTracker(10, window) + ip := randLocalIPv4() + require.NoError(t, ct.AddConn(ip)) + ct.RemoveConn(ip) + require.Error(t, ct.AddConn(ip)) + time.Sleep(window) + require.NoError(t, ct.AddConn(ip)) + }) + } From c372390feae2b35306ef4fc05d53bb1eb03c7eaa Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 18 Apr 2022 16:28:31 -0400 Subject: [PATCH 6/8] eventbus: publish without contexts (#8369) --- internal/blocksync/reactor.go | 6 +- internal/consensus/byzantine_test.go | 2 +- internal/consensus/common_test.go | 3 +- internal/consensus/reactor.go | 14 ++-- internal/consensus/reactor_test.go | 2 +- internal/consensus/replay_file.go | 4 +- internal/consensus/state.go | 80 +++++++++---------- internal/consensus/wal_generator.go | 2 +- internal/eventbus/event_bus.go | 76 +++++++++--------- internal/eventbus/event_bus_test.go | 44 +++++----- internal/evidence/pool.go | 2 +- internal/mempool/mempool_bench_test.go | 2 +- internal/mempool/mempool_test.go | 24 +++--- internal/mempool/reactor_test.go | 2 +- internal/pubsub/example_test.go | 2 +- internal/pubsub/pubsub.go | 14 ++-- internal/pubsub/pubsub_test.go | 53 +++++++----- internal/state/execution.go | 15 ++-- .../state/indexer/indexer_service_test.go | 6 +- internal/statesync/reactor.go | 4 +- libs/events/events.go | 13 ++- libs/events/events_test.go | 43 +++++----- light/client_benchmark_test.go | 6 +- light/client_test.go | 4 +- light/detector_test.go | 20 ++--- light/helpers_test.go | 1 - node/node.go | 29 +++++-- node/setup.go | 50 ------------ types/events.go | 13 ++- 29 files changed, 256 insertions(+), 280 deletions(-) diff --git a/internal/blocksync/reactor.go b/internal/blocksync/reactor.go index 6f3743e62..fd9bf4d7a 100644 --- a/internal/blocksync/reactor.go +++ b/internal/blocksync/reactor.go @@ -359,7 +359,7 @@ func (r *Reactor) SwitchToBlockSync(ctx context.Context, state sm.State) error { go r.requestRoutine(ctx, bsCh) go r.poolRoutine(ctx, true, bsCh) - if err := r.PublishStatus(ctx, types.EventDataBlockSyncStatus{ + if err := r.PublishStatus(types.EventDataBlockSyncStatus{ Complete: false, Height: state.LastBlockHeight, }); err != nil { @@ -609,11 +609,11 @@ func (r *Reactor) GetRemainingSyncTime() time.Duration { return time.Duration(int64(remain * float64(time.Second))) } -func (r *Reactor) PublishStatus(ctx context.Context, event types.EventDataBlockSyncStatus) error { +func (r *Reactor) PublishStatus(event types.EventDataBlockSyncStatus) error { if r.eventBus == nil { return errors.New("event bus is not configured") } - return r.eventBus.PublishEventBlockSyncStatus(ctx, event) + return r.eventBus.PublishEventBlockSyncStatus(event) } // atomicBool is an atomic Boolean, safe for concurrent use by multiple diff --git a/internal/consensus/byzantine_test.go b/internal/consensus/byzantine_test.go index cfcf8b04f..7da5f6ea5 100644 --- a/internal/consensus/byzantine_test.go +++ b/internal/consensus/byzantine_test.go @@ -96,7 +96,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { // Make State blockExec := sm.NewBlockExecutor(stateStore, log.NewNopLogger(), proxyAppConnCon, mempool, evpool, blockStore, eventBus, sm.NopMetrics()) - cs, err := NewState(ctx, logger, thisConfig.Consensus, stateStore, blockExec, blockStore, mempool, evpool, eventBus) + cs, err := NewState(logger, thisConfig.Consensus, stateStore, blockExec, blockStore, mempool, evpool, eventBus) require.NoError(t, err) // set private validator pv := privVals[i] diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index a69fc1240..c6106c909 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -491,8 +491,7 @@ func newStateWithConfigAndBlockStore( require.NoError(t, eventBus.Start(ctx)) blockExec := sm.NewBlockExecutor(stateStore, logger, proxyAppConnCon, mempool, evpool, blockStore, eventBus, sm.NopMetrics()) - cs, err := NewState(ctx, - logger.With("module", "consensus"), + cs, err := NewState(logger.With("module", "consensus"), thisConfig.Consensus, stateStore, blockExec, diff --git a/internal/consensus/reactor.go b/internal/consensus/reactor.go index 18589c93a..53e0b540d 100644 --- a/internal/consensus/reactor.go +++ b/internal/consensus/reactor.go @@ -210,7 +210,7 @@ func (r *Reactor) OnStart(ctx context.Context) error { // leak the goroutine when stopping the reactor. go r.peerStatsRoutine(ctx, peerUpdates) - r.subscribeToBroadcastEvents(chBundle.state) + r.subscribeToBroadcastEvents(ctx, chBundle.state) if !r.WaitSync() { if err := r.state.Start(ctx); err != nil { @@ -260,7 +260,7 @@ func (r *Reactor) SwitchToConsensus(ctx context.Context, state sm.State, skipWAL // NOTE: The line below causes broadcastNewRoundStepRoutine() to broadcast a // NewRoundStepMessage. - r.state.updateToState(ctx, state) + r.state.updateToState(state) if err := r.state.Start(ctx); err != nil { panic(fmt.Sprintf(`failed to start consensus state: %v @@ -284,7 +284,7 @@ conR: } d := types.EventDataBlockSyncStatus{Complete: true, Height: state.LastBlockHeight} - if err := r.eventBus.PublishEventBlockSyncStatus(ctx, d); err != nil { + if err := r.eventBus.PublishEventBlockSyncStatus(d); err != nil { r.logger.Error("failed to emit the blocksync complete event", "err", err) } } @@ -344,13 +344,13 @@ func (r *Reactor) broadcastHasVoteMessage(ctx context.Context, vote *types.Vote, // subscribeToBroadcastEvents subscribes for new round steps and votes using the // internal pubsub defined in the consensus state to broadcast them to peers // upon receiving. -func (r *Reactor) subscribeToBroadcastEvents(stateCh *p2p.Channel) { +func (r *Reactor) subscribeToBroadcastEvents(ctx context.Context, stateCh *p2p.Channel) { onStopCh := r.state.getOnStopCh() err := r.state.evsw.AddListenerForEvent( listenerIDConsensus, types.EventNewRoundStepValue, - func(ctx context.Context, data tmevents.EventData) error { + func(data tmevents.EventData) error { if err := r.broadcastNewRoundStepMessage(ctx, data.(*cstypes.RoundState), stateCh); err != nil { return err } @@ -371,7 +371,7 @@ func (r *Reactor) subscribeToBroadcastEvents(stateCh *p2p.Channel) { err = r.state.evsw.AddListenerForEvent( listenerIDConsensus, types.EventValidBlockValue, - func(ctx context.Context, data tmevents.EventData) error { + func(data tmevents.EventData) error { return r.broadcastNewValidBlockMessage(ctx, data.(*cstypes.RoundState), stateCh) }, ) @@ -382,7 +382,7 @@ func (r *Reactor) subscribeToBroadcastEvents(stateCh *p2p.Channel) { err = r.state.evsw.AddListenerForEvent( listenerIDConsensus, types.EventVoteValue, - func(ctx context.Context, data tmevents.EventData) error { + func(data tmevents.EventData) error { return r.broadcastHasVoteMessage(ctx, data.(*types.Vote), stateCh) }, ) diff --git a/internal/consensus/reactor_test.go b/internal/consensus/reactor_test.go index 9c6af5c5b..6a92b984f 100644 --- a/internal/consensus/reactor_test.go +++ b/internal/consensus/reactor_test.go @@ -505,7 +505,7 @@ func TestReactorWithEvidence(t *testing.T) { blockExec := sm.NewBlockExecutor(stateStore, log.NewNopLogger(), proxyAppConnCon, mempool, evpool, blockStore, eventBus, sm.NopMetrics()) - cs, err := NewState(ctx, logger.With("validator", i, "module", "consensus"), + cs, err := NewState(logger.With("validator", i, "module", "consensus"), thisConfig.Consensus, stateStore, blockExec, blockStore, mempool, evpool2, eventBus) require.NoError(t, err) cs.SetPrivValidator(ctx, pv) diff --git a/internal/consensus/replay_file.go b/internal/consensus/replay_file.go index e88a06454..cd6d4b831 100644 --- a/internal/consensus/replay_file.go +++ b/internal/consensus/replay_file.go @@ -145,7 +145,7 @@ func (pb *playback) replayReset(ctx context.Context, count int, newStepSub event pb.cs.Stop() pb.cs.Wait() - newCS, err := NewState(ctx, pb.cs.logger, pb.cs.config, pb.stateStore, pb.cs.blockExec, + newCS, err := NewState(pb.cs.logger, pb.cs.config, pb.stateStore, pb.cs.blockExec, pb.cs.blockStore, pb.cs.txNotifier, pb.cs.evpool, pb.cs.eventBus) if err != nil { return err @@ -350,7 +350,7 @@ func newConsensusStateForReplay( mempool, evpool := emptyMempool{}, sm.EmptyEvidencePool{} blockExec := sm.NewBlockExecutor(stateStore, logger, proxyApp, mempool, evpool, blockStore, eventBus, sm.NopMetrics()) - consensusState, err := NewState(ctx, logger, csConfig, stateStore, blockExec, + consensusState, err := NewState(logger, csConfig, stateStore, blockExec, blockStore, mempool, evpool, eventBus) if err != nil { return nil, err diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 2f27afc81..7ccc776a6 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -194,7 +194,6 @@ func SkipStateStoreBootstrap(sm *State) { // NewState returns a new State. func NewState( - ctx context.Context, logger log.Logger, cfg *config.ConsensusConfig, store sm.Store, @@ -240,7 +239,7 @@ func NewState( // node-fragments gracefully while letting the nodes // themselves avoid this. if !cs.skipBootstrapping { - if err := cs.updateStateFromStore(ctx); err != nil { + if err := cs.updateStateFromStore(); err != nil { return nil, err } } @@ -248,7 +247,7 @@ func NewState( return cs, nil } -func (cs *State) updateStateFromStore(ctx context.Context) error { +func (cs *State) updateStateFromStore() error { if cs.initialStatePopulated { return nil } @@ -265,7 +264,7 @@ func (cs *State) updateStateFromStore(ctx context.Context) error { cs.reconstructLastCommit(state) } - cs.updateToState(ctx, state) + cs.updateToState(state) cs.initialStatePopulated = true return nil @@ -393,7 +392,7 @@ func (cs *State) LoadCommit(height int64) *types.Commit { // OnStart loads the latest state via the WAL, and starts the timeout and // receive routines. func (cs *State) OnStart(ctx context.Context) error { - if err := cs.updateStateFromStore(ctx); err != nil { + if err := cs.updateStateFromStore(); err != nil { return err } @@ -718,7 +717,7 @@ func (cs *State) reconstructLastCommit(state sm.State) { // Updates State and increments height to match that of state. // The round becomes 0 and cs.Step becomes cstypes.RoundStepNewHeight. -func (cs *State) updateToState(ctx context.Context, state sm.State) { +func (cs *State) updateToState(state sm.State) { if cs.CommitRound > -1 && 0 < cs.Height && cs.Height != state.LastBlockHeight { panic(fmt.Sprintf( "updateToState() expected state height of %v but found %v", @@ -753,7 +752,7 @@ func (cs *State) updateToState(ctx context.Context, state sm.State) { "new_height", state.LastBlockHeight+1, "old_height", cs.state.LastBlockHeight+1, ) - cs.newStep(ctx) + cs.newStep() return } } @@ -823,10 +822,10 @@ func (cs *State) updateToState(ctx context.Context, state sm.State) { cs.state = state // Finally, broadcast RoundState - cs.newStep(ctx) + cs.newStep() } -func (cs *State) newStep(ctx context.Context) { +func (cs *State) newStep() { rs := cs.RoundStateEvent() if err := cs.wal.Write(rs); err != nil { cs.logger.Error("failed writing to WAL", "err", err) @@ -836,11 +835,11 @@ func (cs *State) newStep(ctx context.Context) { // newStep is called by updateToState in NewState before the eventBus is set! if cs.eventBus != nil { - if err := cs.eventBus.PublishEventNewRoundStep(ctx, rs); err != nil { + if err := cs.eventBus.PublishEventNewRoundStep(rs); err != nil { cs.logger.Error("failed publishing new round step", "err", err) } - cs.evsw.FireEvent(ctx, types.EventNewRoundStepValue, &cs.RoundState) + cs.evsw.FireEvent(types.EventNewRoundStepValue, &cs.RoundState) } } @@ -977,7 +976,7 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo) { case *BlockPartMessage: // if the proposal is complete, we'll enterPrevote or tryFinalizeCommit - added, err = cs.addProposalBlockPart(ctx, msg, peerID) + added, err = cs.addProposalBlockPart(msg, peerID) // We unlock here to yield to any routines that need to read the the RoundState. // Previously, this code held the lock from the point at which the final block @@ -1083,21 +1082,21 @@ func (cs *State) handleTimeout( cs.enterPropose(ctx, ti.Height, 0) case cstypes.RoundStepPropose: - if err := cs.eventBus.PublishEventTimeoutPropose(ctx, cs.RoundStateEvent()); err != nil { + if err := cs.eventBus.PublishEventTimeoutPropose(cs.RoundStateEvent()); err != nil { cs.logger.Error("failed publishing timeout propose", "err", err) } cs.enterPrevote(ctx, ti.Height, ti.Round) case cstypes.RoundStepPrevoteWait: - if err := cs.eventBus.PublishEventTimeoutWait(ctx, cs.RoundStateEvent()); err != nil { + if err := cs.eventBus.PublishEventTimeoutWait(cs.RoundStateEvent()); err != nil { cs.logger.Error("failed publishing timeout wait", "err", err) } cs.enterPrecommit(ctx, ti.Height, ti.Round) case cstypes.RoundStepPrecommitWait: - if err := cs.eventBus.PublishEventTimeoutWait(ctx, cs.RoundStateEvent()); err != nil { + if err := cs.eventBus.PublishEventTimeoutWait(cs.RoundStateEvent()); err != nil { cs.logger.Error("failed publishing timeout wait", "err", err) } @@ -1200,7 +1199,7 @@ func (cs *State) enterNewRound(ctx context.Context, height int64, round int32) { cs.Votes.SetRound(r) // also track next round (round+1) to allow round-skipping cs.TriggeredTimeoutPrecommit = false - if err := cs.eventBus.PublishEventNewRound(ctx, cs.NewRoundEvent()); err != nil { + if err := cs.eventBus.PublishEventNewRound(cs.NewRoundEvent()); err != nil { cs.logger.Error("failed publishing new round", "err", err) } // Wait for txs to be available in the mempool @@ -1263,7 +1262,7 @@ func (cs *State) enterPropose(ctx context.Context, height int64, round int32) { defer func() { // Done enterPropose: cs.updateRoundStep(round, cstypes.RoundStepPropose) - cs.newStep(ctx) + cs.newStep() // If we have the whole proposal + POL, then goto Prevote now. // else, we'll enterPrevote when the rest of the proposal is received (in AddProposalBlockPart), @@ -1455,7 +1454,7 @@ func (cs *State) enterPrevote(ctx context.Context, height int64, round int32) { defer func() { // Done enterPrevote: cs.updateRoundStep(round, cstypes.RoundStepPrevote) - cs.newStep(ctx) + cs.newStep() }() logger.Debug("entering prevote step", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step)) @@ -1606,7 +1605,7 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32 } // Enter: any +2/3 prevotes at next round. -func (cs *State) enterPrevoteWait(ctx context.Context, height int64, round int32) { +func (cs *State) enterPrevoteWait(height int64, round int32) { logger := cs.logger.With("height", height, "round", round) if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevoteWait <= cs.Step) { @@ -1629,7 +1628,7 @@ func (cs *State) enterPrevoteWait(ctx context.Context, height int64, round int32 defer func() { // Done enterPrevoteWait: cs.updateRoundStep(round, cstypes.RoundStepPrevoteWait) - cs.newStep(ctx) + cs.newStep() }() // Wait for some more prevotes; enterPrecommit @@ -1657,7 +1656,7 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32) defer func() { // Done enterPrecommit: cs.updateRoundStep(round, cstypes.RoundStepPrecommit) - cs.newStep(ctx) + cs.newStep() }() // check for a polka @@ -1676,7 +1675,7 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32) } // At this point +2/3 prevoted for a particular block or nil. - if err := cs.eventBus.PublishEventPolka(ctx, cs.RoundStateEvent()); err != nil { + if err := cs.eventBus.PublishEventPolka(cs.RoundStateEvent()); err != nil { logger.Error("failed publishing polka", "err", err) } @@ -1713,7 +1712,7 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32) logger.Debug("precommit step: +2/3 prevoted locked block; relocking") cs.LockedRound = round - if err := cs.eventBus.PublishEventRelock(ctx, cs.RoundStateEvent()); err != nil { + if err := cs.eventBus.PublishEventRelock(cs.RoundStateEvent()); err != nil { logger.Error("precommit step: failed publishing event relock", "err", err) } @@ -1736,7 +1735,7 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32) cs.LockedBlock = cs.ProposalBlock cs.LockedBlockParts = cs.ProposalBlockParts - if err := cs.eventBus.PublishEventLock(ctx, cs.RoundStateEvent()); err != nil { + if err := cs.eventBus.PublishEventLock(cs.RoundStateEvent()); err != nil { logger.Error("precommit step: failed publishing event lock", "err", err) } @@ -1758,7 +1757,7 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32) } // Enter: any +2/3 precommits for next round. -func (cs *State) enterPrecommitWait(ctx context.Context, height int64, round int32) { +func (cs *State) enterPrecommitWait(height int64, round int32) { logger := cs.logger.With("height", height, "round", round) if cs.Height != height || round < cs.Round || (cs.Round == round && cs.TriggeredTimeoutPrecommit) { @@ -1782,7 +1781,7 @@ func (cs *State) enterPrecommitWait(ctx context.Context, height int64, round int defer func() { // Done enterPrecommitWait: cs.TriggeredTimeoutPrecommit = true - cs.newStep(ctx) + cs.newStep() }() // wait for some more precommits; enterNewRound @@ -1809,7 +1808,7 @@ func (cs *State) enterCommit(ctx context.Context, height int64, commitRound int3 cs.updateRoundStep(cs.Round, cstypes.RoundStepCommit) cs.CommitRound = commitRound cs.CommitTime = tmtime.Now() - cs.newStep(ctx) + cs.newStep() // Maybe finalize immediately. cs.tryFinalizeCommit(ctx, height) @@ -1844,11 +1843,11 @@ func (cs *State) enterCommit(ctx context.Context, height int64, commitRound int3 cs.metrics.MarkBlockGossipStarted() cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) - if err := cs.eventBus.PublishEventValidBlock(ctx, cs.RoundStateEvent()); err != nil { + if err := cs.eventBus.PublishEventValidBlock(cs.RoundStateEvent()); err != nil { logger.Error("failed publishing valid block", "err", err) } - cs.evsw.FireEvent(ctx, types.EventValidBlockValue, &cs.RoundState) + cs.evsw.FireEvent(types.EventValidBlockValue, &cs.RoundState) } } } @@ -1975,7 +1974,7 @@ func (cs *State) finalizeCommit(ctx context.Context, height int64) { cs.RecordMetrics(height, block) // NewHeightStep! - cs.updateToState(ctx, stateCopy) + cs.updateToState(stateCopy) // Private validator might have changed it's key pair => refetch pubkey. if err := cs.updatePrivValidatorPubKey(ctx); err != nil { @@ -2130,7 +2129,6 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal, recvTime time.Time // Asynchronously triggers either enterPrevote (before we timeout of propose) or tryFinalizeCommit, // once we have the full block. func (cs *State) addProposalBlockPart( - ctx context.Context, msg *BlockPartMessage, peerID types.NodeID, ) (added bool, err error) { @@ -2196,7 +2194,7 @@ func (cs *State) addProposalBlockPart( // NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal cs.logger.Info("received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash()) - if err := cs.eventBus.PublishEventCompleteProposal(ctx, cs.CompleteProposalEvent()); err != nil { + if err := cs.eventBus.PublishEventCompleteProposal(cs.CompleteProposalEvent()); err != nil { cs.logger.Error("failed publishing event complete proposal", "err", err) } } @@ -2315,11 +2313,11 @@ func (cs *State) addVote( } cs.logger.Debug("added vote to last precommits", "last_commit", cs.LastCommit.StringShort()) - if err := cs.eventBus.PublishEventVote(ctx, types.EventDataVote{Vote: vote}); err != nil { + if err := cs.eventBus.PublishEventVote(types.EventDataVote{Vote: vote}); err != nil { return added, err } - cs.evsw.FireEvent(ctx, types.EventVoteValue, vote) + cs.evsw.FireEvent(types.EventVoteValue, vote) // if we can skip timeoutCommit and have all the votes now, if cs.bypassCommitTimeout() && cs.LastCommit.HasAll() { @@ -2352,10 +2350,10 @@ func (cs *State) addVote( return } - if err := cs.eventBus.PublishEventVote(ctx, types.EventDataVote{Vote: vote}); err != nil { + if err := cs.eventBus.PublishEventVote(types.EventDataVote{Vote: vote}); err != nil { return added, err } - cs.evsw.FireEvent(ctx, types.EventVoteValue, vote) + cs.evsw.FireEvent(types.EventVoteValue, vote) switch vote.Type { case tmproto.PrevoteType: @@ -2390,8 +2388,8 @@ func (cs *State) addVote( cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) } - cs.evsw.FireEvent(ctx, types.EventValidBlockValue, &cs.RoundState) - if err := cs.eventBus.PublishEventValidBlock(ctx, cs.RoundStateEvent()); err != nil { + cs.evsw.FireEvent(types.EventValidBlockValue, &cs.RoundState) + if err := cs.eventBus.PublishEventValidBlock(cs.RoundStateEvent()); err != nil { return added, err } } @@ -2408,7 +2406,7 @@ func (cs *State) addVote( if ok && (cs.isProposalComplete() || blockID.IsNil()) { cs.enterPrecommit(ctx, height, vote.Round) } else if prevotes.HasTwoThirdsAny() { - cs.enterPrevoteWait(ctx, height, vote.Round) + cs.enterPrevoteWait(height, vote.Round) } case cs.Proposal != nil && 0 <= cs.Proposal.POLRound && cs.Proposal.POLRound == vote.Round: @@ -2439,11 +2437,11 @@ func (cs *State) addVote( cs.enterNewRound(ctx, cs.Height, 0) } } else { - cs.enterPrecommitWait(ctx, height, vote.Round) + cs.enterPrecommitWait(height, vote.Round) } } else if cs.Round <= vote.Round && precommits.HasTwoThirdsAny() { cs.enterNewRound(ctx, height, vote.Round) - cs.enterPrecommitWait(ctx, height, vote.Round) + cs.enterPrecommitWait(height, vote.Round) } default: diff --git a/internal/consensus/wal_generator.go b/internal/consensus/wal_generator.go index 8c61c1203..0e678db3a 100644 --- a/internal/consensus/wal_generator.go +++ b/internal/consensus/wal_generator.go @@ -81,7 +81,7 @@ func WALGenerateNBlocks(ctx context.Context, t *testing.T, logger log.Logger, wr mempool := emptyMempool{} evpool := sm.EmptyEvidencePool{} blockExec := sm.NewBlockExecutor(stateStore, log.NewNopLogger(), proxyApp, mempool, evpool, blockStore, eventBus, sm.NopMetrics()) - consensusState, err := NewState(ctx, logger, cfg.Consensus, stateStore, blockExec, blockStore, mempool, evpool, eventBus) + consensusState, err := NewState(logger, cfg.Consensus, stateStore, blockExec, blockStore, mempool, evpool, eventBus) if err != nil { t.Fatal(err) } diff --git a/internal/eventbus/event_bus.go b/internal/eventbus/event_bus.go index 5a64c5f1c..c01c37de7 100644 --- a/internal/eventbus/event_bus.go +++ b/internal/eventbus/event_bus.go @@ -66,7 +66,7 @@ func (b *EventBus) Observe(ctx context.Context, observe func(tmpubsub.Message) e return b.pubsub.Observe(ctx, observe, queries...) } -func (b *EventBus) Publish(ctx context.Context, eventValue string, eventData types.EventData) error { +func (b *EventBus) Publish(eventValue string, eventData types.EventData) error { tokens := strings.Split(types.EventTypeKey, ".") event := abci.Event{ Type: tokens[0], @@ -78,19 +78,19 @@ func (b *EventBus) Publish(ctx context.Context, eventValue string, eventData typ }, } - return b.pubsub.PublishWithEvents(ctx, eventData, []abci.Event{event}) + return b.pubsub.PublishWithEvents(eventData, []abci.Event{event}) } -func (b *EventBus) PublishEventNewBlock(ctx context.Context, data types.EventDataNewBlock) error { +func (b *EventBus) PublishEventNewBlock(data types.EventDataNewBlock) error { events := data.ResultFinalizeBlock.Events // add Tendermint-reserved new block event events = append(events, types.EventNewBlock) - return b.pubsub.PublishWithEvents(ctx, data, events) + return b.pubsub.PublishWithEvents(data, events) } -func (b *EventBus) PublishEventNewBlockHeader(ctx context.Context, data types.EventDataNewBlockHeader) error { +func (b *EventBus) PublishEventNewBlockHeader(data types.EventDataNewBlockHeader) error { // no explicit deadline for publishing events events := data.ResultFinalizeBlock.Events @@ -98,33 +98,33 @@ func (b *EventBus) PublishEventNewBlockHeader(ctx context.Context, data types.Ev // add Tendermint-reserved new block header event events = append(events, types.EventNewBlockHeader) - return b.pubsub.PublishWithEvents(ctx, data, events) + return b.pubsub.PublishWithEvents(data, events) } -func (b *EventBus) PublishEventNewEvidence(ctx context.Context, evidence types.EventDataNewEvidence) error { - return b.Publish(ctx, types.EventNewEvidenceValue, evidence) +func (b *EventBus) PublishEventNewEvidence(evidence types.EventDataNewEvidence) error { + return b.Publish(types.EventNewEvidenceValue, evidence) } -func (b *EventBus) PublishEventVote(ctx context.Context, data types.EventDataVote) error { - return b.Publish(ctx, types.EventVoteValue, data) +func (b *EventBus) PublishEventVote(data types.EventDataVote) error { + return b.Publish(types.EventVoteValue, data) } -func (b *EventBus) PublishEventValidBlock(ctx context.Context, data types.EventDataRoundState) error { - return b.Publish(ctx, types.EventValidBlockValue, data) +func (b *EventBus) PublishEventValidBlock(data types.EventDataRoundState) error { + return b.Publish(types.EventValidBlockValue, data) } -func (b *EventBus) PublishEventBlockSyncStatus(ctx context.Context, data types.EventDataBlockSyncStatus) error { - return b.Publish(ctx, types.EventBlockSyncStatusValue, data) +func (b *EventBus) PublishEventBlockSyncStatus(data types.EventDataBlockSyncStatus) error { + return b.Publish(types.EventBlockSyncStatusValue, data) } -func (b *EventBus) PublishEventStateSyncStatus(ctx context.Context, data types.EventDataStateSyncStatus) error { - return b.Publish(ctx, types.EventStateSyncStatusValue, data) +func (b *EventBus) PublishEventStateSyncStatus(data types.EventDataStateSyncStatus) error { + return b.Publish(types.EventStateSyncStatusValue, data) } // PublishEventTx publishes tx event with events from Result. Note it will add // predefined keys (EventTypeKey, TxHashKey). Existing events with the same keys // will be overwritten. -func (b *EventBus) PublishEventTx(ctx context.Context, data types.EventDataTx) error { +func (b *EventBus) PublishEventTx(data types.EventDataTx) error { events := data.Result.Events // add Tendermint-reserved events @@ -152,45 +152,45 @@ func (b *EventBus) PublishEventTx(ctx context.Context, data types.EventDataTx) e }, }) - return b.pubsub.PublishWithEvents(ctx, data, events) + return b.pubsub.PublishWithEvents(data, events) } -func (b *EventBus) PublishEventNewRoundStep(ctx context.Context, data types.EventDataRoundState) error { - return b.Publish(ctx, types.EventNewRoundStepValue, data) +func (b *EventBus) PublishEventNewRoundStep(data types.EventDataRoundState) error { + return b.Publish(types.EventNewRoundStepValue, data) } -func (b *EventBus) PublishEventTimeoutPropose(ctx context.Context, data types.EventDataRoundState) error { - return b.Publish(ctx, types.EventTimeoutProposeValue, data) +func (b *EventBus) PublishEventTimeoutPropose(data types.EventDataRoundState) error { + return b.Publish(types.EventTimeoutProposeValue, data) } -func (b *EventBus) PublishEventTimeoutWait(ctx context.Context, data types.EventDataRoundState) error { - return b.Publish(ctx, types.EventTimeoutWaitValue, data) +func (b *EventBus) PublishEventTimeoutWait(data types.EventDataRoundState) error { + return b.Publish(types.EventTimeoutWaitValue, data) } -func (b *EventBus) PublishEventNewRound(ctx context.Context, data types.EventDataNewRound) error { - return b.Publish(ctx, types.EventNewRoundValue, data) +func (b *EventBus) PublishEventNewRound(data types.EventDataNewRound) error { + return b.Publish(types.EventNewRoundValue, data) } -func (b *EventBus) PublishEventCompleteProposal(ctx context.Context, data types.EventDataCompleteProposal) error { - return b.Publish(ctx, types.EventCompleteProposalValue, data) +func (b *EventBus) PublishEventCompleteProposal(data types.EventDataCompleteProposal) error { + return b.Publish(types.EventCompleteProposalValue, data) } -func (b *EventBus) PublishEventPolka(ctx context.Context, data types.EventDataRoundState) error { - return b.Publish(ctx, types.EventPolkaValue, data) +func (b *EventBus) PublishEventPolka(data types.EventDataRoundState) error { + return b.Publish(types.EventPolkaValue, data) } -func (b *EventBus) PublishEventRelock(ctx context.Context, data types.EventDataRoundState) error { - return b.Publish(ctx, types.EventRelockValue, data) +func (b *EventBus) PublishEventRelock(data types.EventDataRoundState) error { + return b.Publish(types.EventRelockValue, data) } -func (b *EventBus) PublishEventLock(ctx context.Context, data types.EventDataRoundState) error { - return b.Publish(ctx, types.EventLockValue, data) +func (b *EventBus) PublishEventLock(data types.EventDataRoundState) error { + return b.Publish(types.EventLockValue, data) } -func (b *EventBus) PublishEventValidatorSetUpdates(ctx context.Context, data types.EventDataValidatorSetUpdates) error { - return b.Publish(ctx, types.EventValidatorSetUpdatesValue, data) +func (b *EventBus) PublishEventValidatorSetUpdates(data types.EventDataValidatorSetUpdates) error { + return b.Publish(types.EventValidatorSetUpdatesValue, data) } -func (b *EventBus) PublishEventEvidenceValidated(ctx context.Context, evidence types.EventDataEvidenceValidated) error { - return b.Publish(ctx, types.EventEvidenceValidatedValue, evidence) +func (b *EventBus) PublishEventEvidenceValidated(evidence types.EventDataEvidenceValidated) error { + return b.Publish(types.EventEvidenceValidatedValue, evidence) } diff --git a/internal/eventbus/event_bus_test.go b/internal/eventbus/event_bus_test.go index 1bfea02e1..6fd8a2d72 100644 --- a/internal/eventbus/event_bus_test.go +++ b/internal/eventbus/event_bus_test.go @@ -55,7 +55,7 @@ func TestEventBusPublishEventTx(t *testing.T) { assert.Equal(t, result, edt.Result) }() - err = eventBus.PublishEventTx(ctx, types.EventDataTx{ + err = eventBus.PublishEventTx(types.EventDataTx{ TxResult: abci.TxResult{ Height: 1, Index: 0, @@ -112,7 +112,7 @@ func TestEventBusPublishEventNewBlock(t *testing.T) { assert.Equal(t, resultFinalizeBlock, edt.ResultFinalizeBlock) }() - err = eventBus.PublishEventNewBlock(ctx, types.EventDataNewBlock{ + err = eventBus.PublishEventNewBlock(types.EventDataNewBlock{ Block: block, BlockID: blockID, ResultFinalizeBlock: resultFinalizeBlock, @@ -223,7 +223,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) { } }() - assert.NoError(t, eventBus.PublishEventTx(ctx, types.EventDataTx{ + assert.NoError(t, eventBus.PublishEventTx(types.EventDataTx{ TxResult: abci.TxResult{ Height: 1, Index: 0, @@ -280,7 +280,7 @@ func TestEventBusPublishEventNewBlockHeader(t *testing.T) { assert.Equal(t, resultFinalizeBlock, edt.ResultFinalizeBlock) }() - err = eventBus.PublishEventNewBlockHeader(ctx, types.EventDataNewBlockHeader{ + err = eventBus.PublishEventNewBlockHeader(types.EventDataNewBlockHeader{ Header: block.Header, ResultFinalizeBlock: resultFinalizeBlock, }) @@ -322,7 +322,7 @@ func TestEventBusPublishEventEvidenceValidated(t *testing.T) { assert.Equal(t, int64(1), edt.Height) }() - err = eventBus.PublishEventEvidenceValidated(ctx, types.EventDataEvidenceValidated{ + err = eventBus.PublishEventEvidenceValidated(types.EventDataEvidenceValidated{ Evidence: ev, Height: int64(1), }) @@ -364,7 +364,7 @@ func TestEventBusPublishEventNewEvidence(t *testing.T) { assert.Equal(t, int64(4), edt.Height) }() - err = eventBus.PublishEventNewEvidence(ctx, types.EventDataNewEvidence{ + err = eventBus.PublishEventNewEvidence(types.EventDataNewEvidence{ Evidence: ev, Height: 4, }) @@ -408,22 +408,22 @@ func TestEventBusPublish(t *testing.T) { } }() - require.NoError(t, eventBus.Publish(ctx, types.EventNewBlockHeaderValue, + require.NoError(t, eventBus.Publish(types.EventNewBlockHeaderValue, types.EventDataNewBlockHeader{})) - require.NoError(t, eventBus.PublishEventNewBlock(ctx, types.EventDataNewBlock{})) - require.NoError(t, eventBus.PublishEventNewBlockHeader(ctx, types.EventDataNewBlockHeader{})) - require.NoError(t, eventBus.PublishEventVote(ctx, types.EventDataVote{})) - require.NoError(t, eventBus.PublishEventNewRoundStep(ctx, types.EventDataRoundState{})) - require.NoError(t, eventBus.PublishEventTimeoutPropose(ctx, types.EventDataRoundState{})) - require.NoError(t, eventBus.PublishEventTimeoutWait(ctx, types.EventDataRoundState{})) - require.NoError(t, eventBus.PublishEventNewRound(ctx, types.EventDataNewRound{})) - require.NoError(t, eventBus.PublishEventCompleteProposal(ctx, types.EventDataCompleteProposal{})) - require.NoError(t, eventBus.PublishEventPolka(ctx, types.EventDataRoundState{})) - require.NoError(t, eventBus.PublishEventRelock(ctx, types.EventDataRoundState{})) - require.NoError(t, eventBus.PublishEventLock(ctx, types.EventDataRoundState{})) - require.NoError(t, eventBus.PublishEventValidatorSetUpdates(ctx, types.EventDataValidatorSetUpdates{})) - require.NoError(t, eventBus.PublishEventBlockSyncStatus(ctx, types.EventDataBlockSyncStatus{})) - require.NoError(t, eventBus.PublishEventStateSyncStatus(ctx, types.EventDataStateSyncStatus{})) + require.NoError(t, eventBus.PublishEventNewBlock(types.EventDataNewBlock{})) + require.NoError(t, eventBus.PublishEventNewBlockHeader(types.EventDataNewBlockHeader{})) + require.NoError(t, eventBus.PublishEventVote(types.EventDataVote{})) + require.NoError(t, eventBus.PublishEventNewRoundStep(types.EventDataRoundState{})) + require.NoError(t, eventBus.PublishEventTimeoutPropose(types.EventDataRoundState{})) + require.NoError(t, eventBus.PublishEventTimeoutWait(types.EventDataRoundState{})) + require.NoError(t, eventBus.PublishEventNewRound(types.EventDataNewRound{})) + require.NoError(t, eventBus.PublishEventCompleteProposal(types.EventDataCompleteProposal{})) + require.NoError(t, eventBus.PublishEventPolka(types.EventDataRoundState{})) + require.NoError(t, eventBus.PublishEventRelock(types.EventDataRoundState{})) + require.NoError(t, eventBus.PublishEventLock(types.EventDataRoundState{})) + require.NoError(t, eventBus.PublishEventValidatorSetUpdates(types.EventDataValidatorSetUpdates{})) + require.NoError(t, eventBus.PublishEventBlockSyncStatus(types.EventDataBlockSyncStatus{})) + require.NoError(t, eventBus.PublishEventStateSyncStatus(types.EventDataStateSyncStatus{})) require.GreaterOrEqual(t, <-count, numEventsExpected) } @@ -505,7 +505,7 @@ func benchmarkEventBus(numClients int, randQueries bool, randEvents bool, b *tes eventValue = randEventValue() } - err := eventBus.Publish(ctx, eventValue, types.EventDataString("Gamora")) + err := eventBus.Publish(eventValue, types.EventDataString("Gamora")) if err != nil { b.Error(err) } diff --git a/internal/evidence/pool.go b/internal/evidence/pool.go index d2d998c91..132c61f23 100644 --- a/internal/evidence/pool.go +++ b/internal/evidence/pool.go @@ -338,7 +338,7 @@ func (evpool *Pool) addPendingEvidence(ctx context.Context, ev types.Evidence) e return nil } - return evpool.eventBus.PublishEventEvidenceValidated(ctx, types.EventDataEvidenceValidated{ + return evpool.eventBus.PublishEventEvidenceValidated(types.EventDataEvidenceValidated{ Evidence: ev, Height: ev.Height(), }) diff --git a/internal/mempool/mempool_bench_test.go b/internal/mempool/mempool_bench_test.go index cc3ff7368..14fb22197 100644 --- a/internal/mempool/mempool_bench_test.go +++ b/internal/mempool/mempool_bench_test.go @@ -25,7 +25,7 @@ func BenchmarkTxMempool_CheckTx(b *testing.B) { // setup the cache and the mempool number for hitting GetEvictableTxs during the // benchmark. 5000 is the current default mempool size in the TM config. - txmp := setup(ctx, b, client, 10000) + txmp := setup(b, client, 10000) txmp.config.Size = 5000 rng := rand.New(rand.NewSource(time.Now().UnixNano())) diff --git a/internal/mempool/mempool_test.go b/internal/mempool/mempool_test.go index 0dd6ee00c..a20e793c3 100644 --- a/internal/mempool/mempool_test.go +++ b/internal/mempool/mempool_test.go @@ -72,7 +72,7 @@ func (app *application) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { } } -func setup(ctx context.Context, t testing.TB, app abciclient.Client, cacheSize int, options ...TxMempoolOption) *TxMempool { +func setup(t testing.TB, app abciclient.Client, cacheSize int, options ...TxMempoolOption) *TxMempool { t.Helper() logger := log.NewNopLogger() @@ -131,7 +131,7 @@ func TestTxMempool_TxsAvailable(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 0) + txmp := setup(t, client, 0) txmp.EnableTxsAvailable() ensureNoTxFire := func() { @@ -194,7 +194,7 @@ func TestTxMempool_Size(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 0) + txmp := setup(t, client, 0) txs := checkTxs(ctx, t, txmp, 100, 0) require.Equal(t, len(txs), txmp.Size()) require.Equal(t, int64(5690), txmp.SizeBytes()) @@ -227,7 +227,7 @@ func TestTxMempool_Flush(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 0) + txmp := setup(t, client, 0) txs := checkTxs(ctx, t, txmp, 100, 0) require.Equal(t, len(txs), txmp.Size()) require.Equal(t, int64(5690), txmp.SizeBytes()) @@ -261,7 +261,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 0) + txmp := setup(t, client, 0) tTxs := checkTxs(ctx, t, txmp, 100, 0) // all txs request 1 gas unit require.Equal(t, len(tTxs), txmp.Size()) require.Equal(t, int64(5690), txmp.SizeBytes()) @@ -320,7 +320,7 @@ func TestTxMempool_ReapMaxTxs(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 0) + txmp := setup(t, client, 0) tTxs := checkTxs(ctx, t, txmp, 100, 0) require.Equal(t, len(tTxs), txmp.Size()) require.Equal(t, int64(5690), txmp.SizeBytes()) @@ -377,7 +377,7 @@ func TestTxMempool_CheckTxExceedsMaxSize(t *testing.T) { t.Fatal(err) } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 0) + txmp := setup(t, client, 0) rng := rand.New(rand.NewSource(time.Now().UnixNano())) tx := make([]byte, txmp.config.MaxTxBytes+1) @@ -403,7 +403,7 @@ func TestTxMempool_CheckTxSamePeer(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 100) + txmp := setup(t, client, 100) peerID := uint16(1) rng := rand.New(rand.NewSource(time.Now().UnixNano())) @@ -427,7 +427,7 @@ func TestTxMempool_CheckTxSameSender(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 100) + txmp := setup(t, client, 100) peerID := uint16(1) rng := rand.New(rand.NewSource(time.Now().UnixNano())) @@ -458,7 +458,7 @@ func TestTxMempool_ConcurrentTxs(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 100) + txmp := setup(t, client, 100) rng := rand.New(rand.NewSource(time.Now().UnixNano())) checkTxDone := make(chan struct{}) @@ -531,7 +531,7 @@ func TestTxMempool_ExpiredTxs_NumBlocks(t *testing.T) { } t.Cleanup(client.Wait) - txmp := setup(ctx, t, client, 500) + txmp := setup(t, client, 500) txmp.height = 100 txmp.config.TTLNumBlocks = 10 @@ -612,7 +612,7 @@ func TestTxMempool_CheckTxPostCheckError(t *testing.T) { postCheckFn := func(_ types.Tx, _ *abci.ResponseCheckTx) error { return testCase.err } - txmp := setup(ctx, t, client, 0, WithPostCheck(postCheckFn)) + txmp := setup(t, client, 0, WithPostCheck(postCheckFn)) rng := rand.New(rand.NewSource(time.Now().UnixNano())) tx := make([]byte, txmp.config.MaxTxBytes-1) _, err := rng.Read(tx) diff --git a/internal/mempool/reactor_test.go b/internal/mempool/reactor_test.go index 82a97aeec..8ceae2013 100644 --- a/internal/mempool/reactor_test.go +++ b/internal/mempool/reactor_test.go @@ -68,7 +68,7 @@ func setupReactors(ctx context.Context, t *testing.T, logger log.Logger, numNode require.NoError(t, client.Start(ctx)) t.Cleanup(client.Wait) - mempool := setup(ctx, t, client, 0) + mempool := setup(t, client, 0) rts.mempools[nodeID] = mempool rts.peerChans[nodeID] = make(chan p2p.PeerUpdate, chBuf) diff --git a/internal/pubsub/example_test.go b/internal/pubsub/example_test.go index 22e735d6a..c4b5dc5c9 100644 --- a/internal/pubsub/example_test.go +++ b/internal/pubsub/example_test.go @@ -29,6 +29,6 @@ func TestExample(t *testing.T) { Attributes: []abci.EventAttribute{{Key: "name", Value: "John"}}, }, } - require.NoError(t, s.PublishWithEvents(ctx, pubstring("Tombstone"), events)) + require.NoError(t, s.PublishWithEvents(pubstring("Tombstone"), events)) sub.mustReceive(ctx, pubstring("Tombstone")) } diff --git a/internal/pubsub/pubsub.go b/internal/pubsub/pubsub.go index 3e887226b..c0ad4ae3c 100644 --- a/internal/pubsub/pubsub.go +++ b/internal/pubsub/pubsub.go @@ -287,16 +287,16 @@ func (s *Server) NumClientSubscriptions(clientID string) int { } // Publish publishes the given message. An error will be returned to the caller -// if the context is canceled. -func (s *Server) Publish(ctx context.Context, msg types.EventData) error { - return s.publish(ctx, msg, []abci.Event{}) +// if the pubsub server has shut down. +func (s *Server) Publish(msg types.EventData) error { + return s.publish(msg, []abci.Event{}) } // PublishWithEvents publishes the given message with the set of events. The set // is matched with clients queries. If there is a match, the message is sent to // the client. -func (s *Server) PublishWithEvents(ctx context.Context, msg types.EventData, events []abci.Event) error { - return s.publish(ctx, msg, events) +func (s *Server) PublishWithEvents(msg types.EventData, events []abci.Event) error { + return s.publish(msg, events) } // OnStop implements part of the Service interface. It is a no-op. @@ -309,15 +309,13 @@ func (s *Server) Wait() { <-s.exited; s.BaseService.Wait() } // OnStart implements Service.OnStart by starting the server. func (s *Server) OnStart(ctx context.Context) error { s.run(ctx); return nil } -func (s *Server) publish(ctx context.Context, data types.EventData, events []abci.Event) error { +func (s *Server) publish(data types.EventData, events []abci.Event) error { s.pubs.RLock() defer s.pubs.RUnlock() select { case <-s.done: return ErrServerStopped - case <-ctx.Done(): - return ctx.Err() case s.queue <- item{ Data: data, Events: events, diff --git a/internal/pubsub/pubsub_test.go b/internal/pubsub/pubsub_test.go index a6938ff75..e366977b5 100644 --- a/internal/pubsub/pubsub_test.go +++ b/internal/pubsub/pubsub_test.go @@ -42,7 +42,7 @@ func TestSubscribeWithArgs(t *testing.T) { require.Equal(t, 1, s.NumClients()) require.Equal(t, 1, s.NumClientSubscriptions(clientID)) - require.NoError(t, s.Publish(ctx, pubstring("Ka-Zar"))) + require.NoError(t, s.Publish(pubstring("Ka-Zar"))) sub.mustReceive(ctx, pubstring("Ka-Zar")) }) t.Run("PositiveLimit", func(t *testing.T) { @@ -51,7 +51,7 @@ func TestSubscribeWithArgs(t *testing.T) { Query: query.All, Limit: 10, })) - require.NoError(t, s.Publish(ctx, pubstring("Aggamon"))) + require.NoError(t, s.Publish(pubstring("Aggamon"))) sub.mustReceive(ctx, pubstring("Aggamon")) }) } @@ -72,7 +72,7 @@ func TestObserver(t *testing.T) { })) const input = pubstring("Lions and tigers and bears, oh my!") - require.NoError(t, s.Publish(ctx, input)) + require.NoError(t, s.Publish(input)) <-done require.Equal(t, got, input) } @@ -106,9 +106,9 @@ func TestPublishDoesNotBlock(t *testing.T) { go func() { defer close(published) - require.NoError(t, s.Publish(ctx, pubstring("Quicksilver"))) - require.NoError(t, s.Publish(ctx, pubstring("Asylum"))) - require.NoError(t, s.Publish(ctx, pubstring("Ivan"))) + require.NoError(t, s.Publish(pubstring("Quicksilver"))) + require.NoError(t, s.Publish(pubstring("Asylum"))) + require.NoError(t, s.Publish(pubstring("Ivan"))) }() select { @@ -149,9 +149,9 @@ func TestSlowSubscriber(t *testing.T) { Query: query.All, })) - require.NoError(t, s.Publish(ctx, pubstring("Fat Cobra"))) - require.NoError(t, s.Publish(ctx, pubstring("Viper"))) - require.NoError(t, s.Publish(ctx, pubstring("Black Panther"))) + require.NoError(t, s.Publish(pubstring("Fat Cobra"))) + require.NoError(t, s.Publish(pubstring("Viper"))) + require.NoError(t, s.Publish(pubstring("Black Panther"))) // We had capacity for one item, so we should get that item, but after that // the subscription should have been terminated by the publisher. @@ -176,7 +176,7 @@ func TestDifferentClients(t *testing.T) { Attributes: []abci.EventAttribute{{Key: "type", Value: "NewBlock"}}, }} - require.NoError(t, s.PublishWithEvents(ctx, pubstring("Iceman"), events)) + require.NoError(t, s.PublishWithEvents(pubstring("Iceman"), events)) sub1.mustReceive(ctx, pubstring("Iceman")) sub2 := newTestSub(t).must(s.SubscribeWithArgs(ctx, pubsub.SubscribeArgs{ @@ -195,7 +195,7 @@ func TestDifferentClients(t *testing.T) { }, } - require.NoError(t, s.PublishWithEvents(ctx, pubstring("Ultimo"), events)) + require.NoError(t, s.PublishWithEvents(pubstring("Ultimo"), events)) sub1.mustReceive(ctx, pubstring("Ultimo")) sub2.mustReceive(ctx, pubstring("Ultimo")) @@ -210,7 +210,7 @@ func TestDifferentClients(t *testing.T) { Attributes: []abci.EventAttribute{{Key: "type", Value: "NewRoundStep"}}, }} - require.NoError(t, s.PublishWithEvents(ctx, pubstring("Valeria Richards"), events)) + require.NoError(t, s.PublishWithEvents(pubstring("Valeria Richards"), events)) sub3.mustTimeOut(ctx, 100*time.Millisecond) } @@ -259,7 +259,7 @@ func TestSubscribeDuplicateKeys(t *testing.T) { }, } - require.NoError(t, s.PublishWithEvents(ctx, pubstring("Iceman"), events)) + require.NoError(t, s.PublishWithEvents(pubstring("Iceman"), events)) if tc.expected != nil { sub.mustReceive(ctx, tc.expected) @@ -288,7 +288,7 @@ func TestClientSubscribesTwice(t *testing.T) { Query: q, })) - require.NoError(t, s.PublishWithEvents(ctx, pubstring("Goblin Queen"), events)) + require.NoError(t, s.PublishWithEvents(pubstring("Goblin Queen"), events)) sub1.mustReceive(ctx, pubstring("Goblin Queen")) // Subscribing a second time with the same client ID and query fails. @@ -302,7 +302,7 @@ func TestClientSubscribesTwice(t *testing.T) { } // The attempt to re-subscribe does not disrupt the existing sub. - require.NoError(t, s.PublishWithEvents(ctx, pubstring("Spider-Man"), events)) + require.NoError(t, s.PublishWithEvents(pubstring("Spider-Man"), events)) sub1.mustReceive(ctx, pubstring("Spider-Man")) } @@ -325,7 +325,7 @@ func TestUnsubscribe(t *testing.T) { })) // Publishing should still work. - require.NoError(t, s.Publish(ctx, pubstring("Nick Fury"))) + require.NoError(t, s.Publish(pubstring("Nick Fury"))) // The unsubscribed subscriber should report as such. sub.mustFail(ctx, pubsub.ErrUnsubscribed) @@ -373,7 +373,7 @@ func TestResubscribe(t *testing.T) { sub := newTestSub(t).must(s.SubscribeWithArgs(ctx, args)) - require.NoError(t, s.Publish(ctx, pubstring("Cable"))) + require.NoError(t, s.Publish(pubstring("Cable"))) sub.mustReceive(ctx, pubstring("Cable")) } @@ -394,7 +394,7 @@ func TestUnsubscribeAll(t *testing.T) { })) require.NoError(t, s.UnsubscribeAll(ctx, clientID)) - require.NoError(t, s.Publish(ctx, pubstring("Nick Fury"))) + require.NoError(t, s.Publish(pubstring("Nick Fury"))) sub1.mustFail(ctx, pubsub.ErrUnsubscribed) sub2.mustFail(ctx, pubsub.ErrUnsubscribed) @@ -410,13 +410,24 @@ func TestBufferCapacity(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - require.NoError(t, s.Publish(ctx, pubstring("Nighthawk"))) - require.NoError(t, s.Publish(ctx, pubstring("Sage"))) + require.NoError(t, s.Publish(pubstring("Nighthawk"))) + require.NoError(t, s.Publish(pubstring("Sage"))) ctx, cancel = context.WithTimeout(ctx, 100*time.Millisecond) defer cancel() - require.ErrorIs(t, s.Publish(ctx, pubstring("Ironclad")), context.DeadlineExceeded) + sig := make(chan struct{}) + + go func() { defer close(sig); _ = s.Publish(pubstring("Ironclad")) }() + + select { + case <-sig: + t.Fatal("should not fire") + + case <-ctx.Done(): + return + } + } func newTestServer(ctx context.Context, t testing.TB, logger log.Logger) *pubsub.Server { diff --git a/internal/state/execution.go b/internal/state/execution.go index 145251428..c098f9c9d 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -291,7 +291,7 @@ func (blockExec *BlockExecutor) ApplyBlock( // Events are fired after everything else. // NOTE: if we crash between Commit and Save, events wont be fired during replay - fireEvents(ctx, blockExec.logger, blockExec.eventBus, block, blockID, finalizeBlockResponse, validatorUpdates) + fireEvents(blockExec.logger, blockExec.eventBus, block, blockID, finalizeBlockResponse, validatorUpdates) return state, nil } @@ -530,7 +530,6 @@ func (state State) Update( // Fire TxEvent for every tx. // NOTE: if Tendermint crashes before commit, some or all of these events may be published again. func fireEvents( - ctx context.Context, logger log.Logger, eventBus types.BlockEventPublisher, block *types.Block, @@ -538,7 +537,7 @@ func fireEvents( finalizeBlockResponse *abci.ResponseFinalizeBlock, validatorUpdates []*types.Validator, ) { - if err := eventBus.PublishEventNewBlock(ctx, types.EventDataNewBlock{ + if err := eventBus.PublishEventNewBlock(types.EventDataNewBlock{ Block: block, BlockID: blockID, ResultFinalizeBlock: *finalizeBlockResponse, @@ -546,7 +545,7 @@ func fireEvents( logger.Error("failed publishing new block", "err", err) } - if err := eventBus.PublishEventNewBlockHeader(ctx, types.EventDataNewBlockHeader{ + if err := eventBus.PublishEventNewBlockHeader(types.EventDataNewBlockHeader{ Header: block.Header, NumTxs: int64(len(block.Txs)), ResultFinalizeBlock: *finalizeBlockResponse, @@ -556,7 +555,7 @@ func fireEvents( if len(block.Evidence) != 0 { for _, ev := range block.Evidence { - if err := eventBus.PublishEventNewEvidence(ctx, types.EventDataNewEvidence{ + if err := eventBus.PublishEventNewEvidence(types.EventDataNewEvidence{ Evidence: ev, Height: block.Height, }); err != nil { @@ -572,7 +571,7 @@ func fireEvents( } for i, tx := range block.Data.Txs { - if err := eventBus.PublishEventTx(ctx, types.EventDataTx{ + if err := eventBus.PublishEventTx(types.EventDataTx{ TxResult: abci.TxResult{ Height: block.Height, Index: uint32(i), @@ -585,7 +584,7 @@ func fireEvents( } if len(finalizeBlockResponse.ValidatorUpdates) > 0 { - if err := eventBus.PublishEventValidatorSetUpdates(ctx, + if err := eventBus.PublishEventValidatorSetUpdates( types.EventDataValidatorSetUpdates{ValidatorUpdates: validatorUpdates}); err != nil { logger.Error("failed publishing event", "err", err) } @@ -644,7 +643,7 @@ func ExecCommitBlock( } blockID := types.BlockID{Hash: block.Hash(), PartSetHeader: bps.Header()} - fireEvents(ctx, be.logger, be.eventBus, block, blockID, finalizeBlockResponse, validatorUpdates) + fireEvents(be.logger, be.eventBus, block, blockID, finalizeBlockResponse, validatorUpdates) } // Commit block, get hash back diff --git a/internal/state/indexer/indexer_service_test.go b/internal/state/indexer/indexer_service_test.go index a71b204ec..5c516c524 100644 --- a/internal/state/indexer/indexer_service_test.go +++ b/internal/state/indexer/indexer_service_test.go @@ -71,7 +71,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) { t.Cleanup(service.Wait) // publish block with txs - err = eventBus.PublishEventNewBlockHeader(ctx, types.EventDataNewBlockHeader{ + err = eventBus.PublishEventNewBlockHeader(types.EventDataNewBlockHeader{ Header: types.Header{Height: 1}, NumTxs: int64(2), }) @@ -82,7 +82,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) { Tx: types.Tx("foo"), Result: abci.ExecTxResult{Code: 0}, } - err = eventBus.PublishEventTx(ctx, types.EventDataTx{TxResult: *txResult1}) + err = eventBus.PublishEventTx(types.EventDataTx{TxResult: *txResult1}) require.NoError(t, err) txResult2 := &abci.TxResult{ Height: 1, @@ -90,7 +90,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) { Tx: types.Tx("bar"), Result: abci.ExecTxResult{Code: 0}, } - err = eventBus.PublishEventTx(ctx, types.EventDataTx{TxResult: *txResult2}) + err = eventBus.PublishEventTx(types.EventDataTx{TxResult: *txResult2}) require.NoError(t, err) time.Sleep(100 * time.Millisecond) diff --git a/internal/statesync/reactor.go b/internal/statesync/reactor.go index ea2cac4f4..795da5063 100644 --- a/internal/statesync/reactor.go +++ b/internal/statesync/reactor.go @@ -333,7 +333,7 @@ func (r *Reactor) OnStop() { // of historical blocks before participating in consensus func (r *Reactor) Sync(ctx context.Context) (sm.State, error) { if r.eventBus != nil { - if err := r.eventBus.PublishEventStateSyncStatus(ctx, types.EventDataStateSyncStatus{ + if err := r.eventBus.PublishEventStateSyncStatus(types.EventDataStateSyncStatus{ Complete: false, Height: r.initialHeight, }); err != nil { @@ -387,7 +387,7 @@ func (r *Reactor) Sync(ctx context.Context) (sm.State, error) { } if r.eventBus != nil { - if err := r.eventBus.PublishEventStateSyncStatus(ctx, types.EventDataStateSyncStatus{ + if err := r.eventBus.PublishEventStateSyncStatus(types.EventDataStateSyncStatus{ Complete: true, Height: state.LastBlockHeight, }); err != nil { diff --git a/libs/events/events.go b/libs/events/events.go index 5ad1170a9..1b8db09c4 100644 --- a/libs/events/events.go +++ b/libs/events/events.go @@ -2,7 +2,6 @@ package events import ( - "context" "sync" ) @@ -20,7 +19,7 @@ type Eventable interface { // // FireEvent fires an event with the given name and data. type Fireable interface { - FireEvent(ctx context.Context, eventValue string, data EventData) + FireEvent(eventValue string, data EventData) } // EventSwitch is the interface for synchronous pubsub, where listeners @@ -62,7 +61,7 @@ func (evsw *eventSwitch) AddListenerForEvent(listenerID, eventValue string, cb E return nil } -func (evsw *eventSwitch) FireEvent(ctx context.Context, event string, data EventData) { +func (evsw *eventSwitch) FireEvent(event string, data EventData) { // Get the eventCell evsw.mtx.RLock() eventCell := evsw.eventCells[event] @@ -73,12 +72,12 @@ func (evsw *eventSwitch) FireEvent(ctx context.Context, event string, data Event } // Fire event for all listeners in eventCell - eventCell.fireEvent(ctx, data) + eventCell.fireEvent(data) } //----------------------------------------------------------------------------- -type EventCallback func(ctx context.Context, data EventData) error +type EventCallback func(data EventData) error // eventCell handles keeping track of listener callbacks for a given event. type eventCell struct { @@ -98,7 +97,7 @@ func (cell *eventCell) addListener(listenerID string, cb EventCallback) { cell.listeners[listenerID] = cb } -func (cell *eventCell) fireEvent(ctx context.Context, data EventData) { +func (cell *eventCell) fireEvent(data EventData) { cell.mtx.RLock() eventCallbacks := make([]EventCallback, 0, len(cell.listeners)) for _, cb := range cell.listeners { @@ -107,7 +106,7 @@ func (cell *eventCell) fireEvent(ctx context.Context, data EventData) { cell.mtx.RUnlock() for _, cb := range eventCallbacks { - if err := cb(ctx, data); err != nil { + if err := cb(data); err != nil { // should we log or abort here? continue } diff --git a/libs/events/events_test.go b/libs/events/events_test.go index fba2feba8..17f8c56d1 100644 --- a/libs/events/events_test.go +++ b/libs/events/events_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + "github.com/fortytw2/leaktest" "github.com/stretchr/testify/require" ) @@ -20,7 +21,7 @@ func TestAddListenerForEventFireOnce(t *testing.T) { messages := make(chan EventData) require.NoError(t, evsw.AddListenerForEvent("listener", "event", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case messages <- data: return nil @@ -28,7 +29,7 @@ func TestAddListenerForEventFireOnce(t *testing.T) { return ctx.Err() } })) - go evsw.FireEvent(ctx, "event", "data") + go evsw.FireEvent("event", "data") received := <-messages if received != "data" { t.Errorf("message received does not match: %v", received) @@ -48,7 +49,7 @@ func TestAddListenerForEventFireMany(t *testing.T) { numbers := make(chan uint64, 4) // subscribe one listener for one event require.NoError(t, evsw.AddListenerForEvent("listener", "event", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers <- data.(uint64): return nil @@ -75,6 +76,8 @@ func TestAddListenerForDifferentEvents(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + t.Cleanup(leaktest.Check(t)) + evsw := NewEventSwitch() doneSum := make(chan uint64) @@ -84,7 +87,7 @@ func TestAddListenerForDifferentEvents(t *testing.T) { numbers := make(chan uint64, 4) // subscribe one listener to three events require.NoError(t, evsw.AddListenerForEvent("listener", "event1", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers <- data.(uint64): return nil @@ -93,7 +96,7 @@ func TestAddListenerForDifferentEvents(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener", "event2", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers <- data.(uint64): return nil @@ -102,7 +105,7 @@ func TestAddListenerForDifferentEvents(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener", "event3", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers <- data.(uint64): return nil @@ -135,6 +138,8 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + t.Cleanup(leaktest.Check(t)) + evsw := NewEventSwitch() doneSum1 := make(chan uint64) @@ -146,7 +151,7 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) { numbers2 := make(chan uint64, 4) // subscribe two listener to three events require.NoError(t, evsw.AddListenerForEvent("listener1", "event1", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers1 <- data.(uint64): return nil @@ -155,7 +160,7 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener1", "event2", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers1 <- data.(uint64): return nil @@ -164,7 +169,7 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener1", "event3", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers1 <- data.(uint64): return nil @@ -173,7 +178,7 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener2", "event2", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers2 <- data.(uint64): return nil @@ -182,7 +187,7 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener2", "event3", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers2 <- data.(uint64): return nil @@ -238,7 +243,7 @@ func TestManageListenersAsync(t *testing.T) { numbers2 := make(chan uint64, 4) // subscribe two listener to three events require.NoError(t, evsw.AddListenerForEvent("listener1", "event1", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers1 <- data.(uint64): return nil @@ -247,7 +252,7 @@ func TestManageListenersAsync(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener1", "event2", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers1 <- data.(uint64): return nil @@ -256,7 +261,7 @@ func TestManageListenersAsync(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener1", "event3", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers1 <- data.(uint64): return nil @@ -265,7 +270,7 @@ func TestManageListenersAsync(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener2", "event1", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers2 <- data.(uint64): return nil @@ -274,7 +279,7 @@ func TestManageListenersAsync(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener2", "event2", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers2 <- data.(uint64): return nil @@ -283,7 +288,7 @@ func TestManageListenersAsync(t *testing.T) { } })) require.NoError(t, evsw.AddListenerForEvent("listener2", "event3", - func(ctx context.Context, data EventData) error { + func(data EventData) error { select { case numbers2 <- data.(uint64): return nil @@ -303,7 +308,7 @@ func TestManageListenersAsync(t *testing.T) { eventNumber := r1.Intn(3) + 1 go evsw.AddListenerForEvent(fmt.Sprintf("listener%v", listenerNumber), //nolint:errcheck // ignore for tests fmt.Sprintf("event%v", eventNumber), - func(context.Context, EventData) error { return nil }) + func(EventData) error { return nil }) } } addListenersStress() @@ -358,7 +363,7 @@ func fireEvents(ctx context.Context, evsw Fireable, event string, doneChan chan break } - evsw.FireEvent(ctx, event, i) + evsw.FireEvent(event, i) sentSum += i } diff --git a/light/client_benchmark_test.go b/light/client_benchmark_test.go index 4a54e2b54..c92b70990 100644 --- a/light/client_benchmark_test.go +++ b/light/client_benchmark_test.go @@ -69,7 +69,7 @@ func BenchmarkSequence(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - headers, vals, _ := genLightBlocksWithKeys(b, chainID, 1000, 100, 1, bTime) + headers, vals, _ := genLightBlocksWithKeys(b, 1000, 100, 1, bTime) benchmarkFullNode := newProviderBenchmarkImpl(headers, vals) genesisBlock, _ := benchmarkFullNode.LightBlock(ctx, 1) @@ -106,7 +106,7 @@ func BenchmarkBisection(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - headers, vals, _ := genLightBlocksWithKeys(b, chainID, 1000, 100, 1, bTime) + headers, vals, _ := genLightBlocksWithKeys(b, 1000, 100, 1, bTime) benchmarkFullNode := newProviderBenchmarkImpl(headers, vals) genesisBlock, _ := benchmarkFullNode.LightBlock(ctx, 1) @@ -142,7 +142,7 @@ func BenchmarkBackwards(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - headers, vals, _ := genLightBlocksWithKeys(b, chainID, 1000, 100, 1, bTime) + headers, vals, _ := genLightBlocksWithKeys(b, 1000, 100, 1, bTime) benchmarkFullNode := newProviderBenchmarkImpl(headers, vals) trustedBlock, _ := benchmarkFullNode.LightBlock(ctx, 0) diff --git a/light/client_test.go b/light/client_test.go index fbf8536ba..8ecd842c9 100644 --- a/light/client_test.go +++ b/light/client_test.go @@ -387,7 +387,7 @@ func TestClient(t *testing.T) { // the appropriate range numBlocks := int64(300) - mockHeaders, mockVals, _ := genLightBlocksWithKeys(t, chainID, numBlocks, 101, 2, bTime) + mockHeaders, mockVals, _ := genLightBlocksWithKeys(t, numBlocks, 101, 2, bTime) lastBlock := &types.LightBlock{SignedHeader: mockHeaders[numBlocks], ValidatorSet: mockVals[numBlocks]} mockNode := &provider_mocks.Provider{} @@ -773,7 +773,7 @@ func TestClient(t *testing.T) { logger := log.NewNopLogger() { - headers, vals, _ := genLightBlocksWithKeys(t, chainID, 9, 3, 0, bTime) + headers, vals, _ := genLightBlocksWithKeys(t, 9, 3, 0, bTime) delete(headers, 1) delete(headers, 2) delete(vals, 1) diff --git a/light/detector_test.go b/light/detector_test.go index 82b0d2de6..4a86b5b87 100644 --- a/light/detector_test.go +++ b/light/detector_test.go @@ -35,7 +35,7 @@ func TestLightClientAttackEvidence_Lunatic(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - witnessHeaders, witnessValidators, chainKeys := genLightBlocksWithKeys(t, chainID, latestHeight, valSize, 2, bTime) + witnessHeaders, witnessValidators, chainKeys := genLightBlocksWithKeys(t, latestHeight, valSize, 2, bTime) forgedKeys := chainKeys[divergenceHeight-1].ChangeKeys(3) // we change 3 out of the 5 validators (still 2/5 remain) forgedVals := forgedKeys.ToValidators(2, 0) @@ -153,7 +153,7 @@ func TestLightClientAttackEvidence_Equivocation(t *testing.T) { // validators don't change in this network (however we still use a map just for convenience) primaryValidators = make(map[int64]*types.ValidatorSet, testCase.latestHeight) ) - witnessHeaders, witnessValidators, chainKeys := genLightBlocksWithKeys(t, chainID, + witnessHeaders, witnessValidators, chainKeys := genLightBlocksWithKeys(t, testCase.latestHeight+1, valSize, 2, bTime) for height := int64(1); height <= testCase.latestHeight; height++ { if height < testCase.divergenceHeight { @@ -250,7 +250,7 @@ func TestLightClientAttackEvidence_ForwardLunatic(t *testing.T) { defer cancel() logger := log.NewNopLogger() - witnessHeaders, witnessValidators, chainKeys := genLightBlocksWithKeys(t, chainID, latestHeight, valSize, 2, bTime) + witnessHeaders, witnessValidators, chainKeys := genLightBlocksWithKeys(t, latestHeight, valSize, 2, bTime) for _, unusedHeader := range []int64{3, 5, 6, 8} { delete(witnessHeaders, unusedHeader) } @@ -401,13 +401,13 @@ func TestClientDivergentTraces1(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - headers, vals, _ := genLightBlocksWithKeys(t, chainID, 1, 5, 2, bTime) + headers, vals, _ := genLightBlocksWithKeys(t, 1, 5, 2, bTime) mockPrimary := mockNodeFromHeadersAndVals(headers, vals) mockPrimary.On("ID").Return("mockPrimary") firstBlock, err := mockPrimary.LightBlock(ctx, 1) require.NoError(t, err) - headers, vals, _ = genLightBlocksWithKeys(t, chainID, 1, 5, 2, bTime) + headers, vals, _ = genLightBlocksWithKeys(t, 1, 5, 2, bTime) mockWitness := mockNodeFromHeadersAndVals(headers, vals) mockWitness.On("ID").Return("mockWitness") @@ -439,7 +439,7 @@ func TestClientDivergentTraces2(t *testing.T) { defer cancel() logger := log.NewNopLogger() - headers, vals, _ := genLightBlocksWithKeys(t, chainID, 2, 5, 2, bTime) + headers, vals, _ := genLightBlocksWithKeys(t, 2, 5, 2, bTime) mockPrimaryNode := mockNodeFromHeadersAndVals(headers, vals) mockPrimaryNode.On("ID").Return("mockPrimaryNode") @@ -485,7 +485,7 @@ func TestClientDivergentTraces3(t *testing.T) { logger := log.NewNopLogger() // - primaryHeaders, primaryVals, _ := genLightBlocksWithKeys(t, chainID, 2, 5, 2, bTime) + primaryHeaders, primaryVals, _ := genLightBlocksWithKeys(t, 2, 5, 2, bTime) mockPrimary := mockNodeFromHeadersAndVals(primaryHeaders, primaryVals) mockPrimary.On("ID").Return("mockPrimary") @@ -495,7 +495,7 @@ func TestClientDivergentTraces3(t *testing.T) { firstBlock, err := mockPrimary.LightBlock(ctx, 1) require.NoError(t, err) - mockHeaders, mockVals, _ := genLightBlocksWithKeys(t, chainID, 2, 5, 2, bTime) + mockHeaders, mockVals, _ := genLightBlocksWithKeys(t, 2, 5, 2, bTime) mockHeaders[1] = primaryHeaders[1] mockVals[1] = primaryVals[1] mockWitness := mockNodeFromHeadersAndVals(mockHeaders, mockVals) @@ -530,7 +530,7 @@ func TestClientDivergentTraces4(t *testing.T) { logger := log.NewNopLogger() // - primaryHeaders, primaryVals, _ := genLightBlocksWithKeys(t, chainID, 2, 5, 2, bTime) + primaryHeaders, primaryVals, _ := genLightBlocksWithKeys(t, 2, 5, 2, bTime) mockPrimary := mockNodeFromHeadersAndVals(primaryHeaders, primaryVals) mockPrimary.On("ID").Return("mockPrimary") @@ -540,7 +540,7 @@ func TestClientDivergentTraces4(t *testing.T) { firstBlock, err := mockPrimary.LightBlock(ctx, 1) require.NoError(t, err) - witnessHeaders, witnessVals, _ := genLightBlocksWithKeys(t, chainID, 2, 5, 2, bTime) + witnessHeaders, witnessVals, _ := genLightBlocksWithKeys(t, 2, 5, 2, bTime) primaryHeaders[2] = witnessHeaders[2] primaryVals[2] = witnessVals[2] mockWitness := mockNodeFromHeadersAndVals(primaryHeaders, primaryVals) diff --git a/light/helpers_test.go b/light/helpers_test.go index 73ef2ae65..4d002d936 100644 --- a/light/helpers_test.go +++ b/light/helpers_test.go @@ -160,7 +160,6 @@ func (pkz privKeys) ChangeKeys(delta int) privKeys { // NOTE: Expected to have a large validator set size ~ 100 validators. func genLightBlocksWithKeys( t testing.TB, - chainID string, numBlocks int64, valSize int, valVariation float32, diff --git a/node/node.go b/node/node.go index 8a4da29f2..02b057868 100644 --- a/node/node.go +++ b/node/node.go @@ -292,16 +292,32 @@ func makeNode( blockSync := !onlyValidatorIsUs(state, pubKey) waitSync := stateSync || blockSync - csReactor, csState, err := createConsensusReactor(ctx, - cfg, stateStore, blockExec, blockStore, mp, evPool, - privValidator, nodeMetrics.consensus, waitSync, eventBus, - peerManager, node.router.OpenChannel, logger, + csState, err := consensus.NewState(logger.With("module", "consensus"), + cfg.Consensus, + stateStore, + blockExec, + blockStore, + mp, + evPool, + eventBus, + consensus.StateMetrics(nodeMetrics.consensus), + consensus.SkipStateStoreBootstrap, ) if err != nil { return nil, combineCloseError(err, makeCloser(closers)) } - node.services = append(node.services, csReactor) node.rpcEnv.ConsensusState = csState + + csReactor := consensus.NewReactor( + logger, + csState, + node.router.OpenChannel, + peerManager.Subscribe, + eventBus, + waitSync, + nodeMetrics.consensus, + ) + node.services = append(node.services, csReactor) node.rpcEnv.ConsensusReactor = csReactor // Create the blockchain reactor. Note, we do not start block sync if we're @@ -370,6 +386,9 @@ func makeNode( )) if cfg.Mode == config.ModeValidator { + if privValidator != nil { + csState.SetPrivValidator(ctx, privValidator) + } node.rpcEnv.PubKey = pubKey } diff --git a/node/setup.go b/node/setup.go index 1057fb6fa..5e5050b53 100644 --- a/node/setup.go +++ b/node/setup.go @@ -231,56 +231,6 @@ func createEvidenceReactor( return evidenceReactor, evidencePool, dbCloser, nil } -func createConsensusReactor( - ctx context.Context, - cfg *config.Config, - store sm.Store, - blockExec *sm.BlockExecutor, - blockStore sm.BlockStore, - mp mempool.Mempool, - evidencePool *evidence.Pool, - privValidator types.PrivValidator, - csMetrics *consensus.Metrics, - waitSync bool, - eventBus *eventbus.EventBus, - peerManager *p2p.PeerManager, - chCreator p2p.ChannelCreator, - logger log.Logger, -) (*consensus.Reactor, *consensus.State, error) { - logger = logger.With("module", "consensus") - - consensusState, err := consensus.NewState(ctx, - logger, - cfg.Consensus, - store, - blockExec, - blockStore, - mp, - evidencePool, - eventBus, - consensus.StateMetrics(csMetrics), - consensus.SkipStateStoreBootstrap, - ) - if err != nil { - return nil, nil, err - } - - if privValidator != nil && cfg.Mode == config.ModeValidator { - consensusState.SetPrivValidator(ctx, privValidator) - } - - reactor := consensus.NewReactor( - logger, - consensusState, - chCreator, - peerManager.Subscribe, - eventBus, - waitSync, - csMetrics, - ) - return reactor, consensusState, nil -} - func createPeerManager( cfg *config.Config, dbProvider config.DBProvider, diff --git a/types/events.go b/types/events.go index cd535e71b..d87b74cb8 100644 --- a/types/events.go +++ b/types/events.go @@ -1,7 +1,6 @@ package types import ( - "context" "fmt" "strings" @@ -308,15 +307,15 @@ func QueryForEvent(eventValue string) *tmquery.Query { // BlockEventPublisher publishes all block related events type BlockEventPublisher interface { - PublishEventNewBlock(ctx context.Context, block EventDataNewBlock) error - PublishEventNewBlockHeader(ctx context.Context, header EventDataNewBlockHeader) error - PublishEventNewEvidence(ctx context.Context, evidence EventDataNewEvidence) error - PublishEventTx(context.Context, EventDataTx) error - PublishEventValidatorSetUpdates(context.Context, EventDataValidatorSetUpdates) error + PublishEventNewBlock(EventDataNewBlock) error + PublishEventNewBlockHeader(EventDataNewBlockHeader) error + PublishEventNewEvidence(EventDataNewEvidence) error + PublishEventTx(EventDataTx) error + PublishEventValidatorSetUpdates(EventDataValidatorSetUpdates) error } type TxEventPublisher interface { - PublishEventTx(context.Context, EventDataTx) error + PublishEventTx(EventDataTx) error } // eventWithAttr constructs a single abci.Event with a single attribute. From efd4f4a40b9d364fb71228a79404319cbe58f1d4 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 18 Apr 2022 16:45:21 -0400 Subject: [PATCH 7/8] cleanup: unused parameters (#8372) --- internal/blocksync/reactor_test.go | 9 ++++----- internal/consensus/replay.go | 2 +- internal/consensus/replay_stubs.go | 1 - internal/evidence/reactor_test.go | 14 ++++++------- internal/p2p/conn/secret_connection_test.go | 4 ++-- internal/p2p/pex/reactor_test.go | 6 +++--- .../state/indexer/indexer_service_test.go | 7 +++---- internal/statesync/stateprovider.go | 4 ++-- internal/store/store_test.go | 9 ++++----- libs/bits/bit_array_test.go | 20 ++++++++----------- node/node.go | 5 +---- node/setup.go | 4 ++-- scripts/scmigrate/migrate.go | 8 ++++---- test/e2e/runner/main.go | 4 ++-- test/e2e/runner/test.go | 3 +-- types/evidence_test.go | 9 ++++++++- types/protobuf_test.go | 4 ++-- 17 files changed, 54 insertions(+), 59 deletions(-) diff --git a/internal/blocksync/reactor_test.go b/internal/blocksync/reactor_test.go index 065d75301..857b0a519 100644 --- a/internal/blocksync/reactor_test.go +++ b/internal/blocksync/reactor_test.go @@ -50,7 +50,6 @@ func setup( genDoc *types.GenesisDoc, privVal types.PrivValidator, maxBlockHeights []int64, - chBuf uint, ) *reactorTestSuite { t.Helper() @@ -228,7 +227,7 @@ func TestReactor_AbruptDisconnect(t *testing.T) { genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams()) maxBlockHeight := int64(64) - rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0) + rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}) require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height()) @@ -268,7 +267,7 @@ func TestReactor_SyncTime(t *testing.T) { genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams()) maxBlockHeight := int64(101) - rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0) + rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}) require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height()) rts.start(ctx, t) @@ -296,7 +295,7 @@ func TestReactor_NoBlockResponse(t *testing.T) { genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams()) maxBlockHeight := int64(65) - rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0) + rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}) require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height()) @@ -348,7 +347,7 @@ func TestReactor_BadBlockStopsPeer(t *testing.T) { valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams()) - rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0, 0, 0, 0}, 1000) + rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0, 0, 0, 0}) require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height()) diff --git a/internal/consensus/replay.go b/internal/consensus/replay.go index 3b2dea930..17435d273 100644 --- a/internal/consensus/replay.go +++ b/internal/consensus/replay.go @@ -429,7 +429,7 @@ func (h *Handshaker) ReplayBlocks( if err != nil { return nil, err } - mockApp, err := newMockProxyApp(ctx, h.logger, appHash, abciResponses) + mockApp, err := newMockProxyApp(h.logger, appHash, abciResponses) if err != nil { return nil, err } diff --git a/internal/consensus/replay_stubs.go b/internal/consensus/replay_stubs.go index e479d344e..e8f5cbc4b 100644 --- a/internal/consensus/replay_stubs.go +++ b/internal/consensus/replay_stubs.go @@ -57,7 +57,6 @@ func (emptyMempool) CloseWAL() {} // the real app. func newMockProxyApp( - ctx context.Context, logger log.Logger, appHash []byte, abciResponses *tmstate.ABCIResponses, diff --git a/internal/evidence/reactor_test.go b/internal/evidence/reactor_test.go index 2fdfa8c60..5575d7f97 100644 --- a/internal/evidence/reactor_test.go +++ b/internal/evidence/reactor_test.go @@ -46,7 +46,7 @@ type reactorTestSuite struct { numStateStores int } -func setup(ctx context.Context, t *testing.T, stateStores []sm.Store, chBuf uint) *reactorTestSuite { +func setup(ctx context.Context, t *testing.T, stateStores []sm.Store) *reactorTestSuite { t.Helper() pID := make([]byte, 16) @@ -245,7 +245,7 @@ func TestReactorMultiDisconnect(t *testing.T) { stateDB1 := initializeValidatorState(ctx, t, val, height) stateDB2 := initializeValidatorState(ctx, t, val, height) - rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 20) + rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}) primary := rts.nodes[0] secondary := rts.nodes[1] @@ -290,7 +290,7 @@ func TestReactorBroadcastEvidence(t *testing.T) { stateDBs[i] = initializeValidatorState(ctx, t, val, height) } - rts := setup(ctx, t, stateDBs, 0) + rts := setup(ctx, t, stateDBs) rts.start(ctx, t) @@ -348,7 +348,7 @@ func TestReactorBroadcastEvidence_Lagging(t *testing.T) { stateDB1 := initializeValidatorState(ctx, t, val, height1) stateDB2 := initializeValidatorState(ctx, t, val, height2) - rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 100) + rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}) rts.start(ctx, t) primary := rts.nodes[0] @@ -382,7 +382,7 @@ func TestReactorBroadcastEvidence_Pending(t *testing.T) { stateDB1 := initializeValidatorState(ctx, t, val, height) stateDB2 := initializeValidatorState(ctx, t, val, height) - rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 100) + rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}) primary := rts.nodes[0] secondary := rts.nodes[1] @@ -423,7 +423,7 @@ func TestReactorBroadcastEvidence_Committed(t *testing.T) { stateDB1 := initializeValidatorState(ctx, t, val, height) stateDB2 := initializeValidatorState(ctx, t, val, height) - rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 0) + rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}) primary := rts.nodes[0] secondary := rts.nodes[1] @@ -482,7 +482,7 @@ func TestReactorBroadcastEvidence_FullyConnected(t *testing.T) { stateDBs[i] = initializeValidatorState(ctx, t, val, height) } - rts := setup(ctx, t, stateDBs, 0) + rts := setup(ctx, t, stateDBs) rts.start(ctx, t) evList := createEvidenceList(ctx, t, rts.pools[rts.network.RandomNode().NodeID], val, numEvidence) diff --git a/internal/p2p/conn/secret_connection_test.go b/internal/p2p/conn/secret_connection_test.go index 6752d9d21..2e37f8388 100644 --- a/internal/p2p/conn/secret_connection_test.go +++ b/internal/p2p/conn/secret_connection_test.go @@ -228,7 +228,7 @@ func TestDeriveSecretsAndChallengeGolden(t *testing.T) { goldenFilepath := filepath.Join("testdata", t.Name()+".golden") if *update { t.Logf("Updating golden test vector file %s", goldenFilepath) - data := createGoldenTestVectors(t) + data := createGoldenTestVectors() require.NoError(t, os.WriteFile(goldenFilepath, []byte(data), 0644)) } f, err := os.Open(goldenFilepath) @@ -306,7 +306,7 @@ func readLots(t *testing.T, wg *sync.WaitGroup, conn io.Reader, n int) { // Creates the data for a test vector file. // The file format is: // Hex(diffie_hellman_secret), loc_is_least, Hex(recvSecret), Hex(sendSecret), Hex(challenge) -func createGoldenTestVectors(t *testing.T) string { +func createGoldenTestVectors() string { data := "" for i := 0; i < 32; i++ { randSecretVector := tmrand.Bytes(32) diff --git a/internal/p2p/pex/reactor_test.go b/internal/p2p/pex/reactor_test.go index 325ea72ab..f2132fbba 100644 --- a/internal/p2p/pex/reactor_test.go +++ b/internal/p2p/pex/reactor_test.go @@ -151,14 +151,14 @@ func TestReactorErrorsOnReceivingTooManyPeers(t *testing.T) { defer cancel() r := setupSingle(ctx, t) - peer := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID(t)} + peer := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID()} added, err := r.manager.Add(peer) require.NoError(t, err) require.True(t, added) addresses := make([]p2pproto.PexAddress, 101) for i := 0; i < len(addresses); i++ { - nodeAddress := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID(t)} + nodeAddress := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID()} addresses[i] = p2pproto.PexAddress{ URL: nodeAddress.String(), } @@ -730,6 +730,6 @@ func newNodeID(t *testing.T, id string) types.NodeID { return nodeID } -func randomNodeID(t *testing.T) types.NodeID { +func randomNodeID() types.NodeID { return types.NodeIDFromPubKey(ed25519.GenPrivKey().PubKey()) } diff --git a/internal/state/indexer/indexer_service_test.go b/internal/state/indexer/indexer_service_test.go index 5c516c524..6126ae259 100644 --- a/internal/state/indexer/indexer_service_test.go +++ b/internal/state/indexer/indexer_service_test.go @@ -54,8 +54,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) { assert.False(t, indexer.IndexingEnabled([]indexer.EventSink{})) // event sink setup - pool, err := setupDB(t) - assert.NoError(t, err) + pool := setupDB(t) store := dbm.NewMemDB() eventSinks := []indexer.EventSink{kv.NewEventSink(store), pSink} @@ -133,7 +132,7 @@ func resetDB(t *testing.T) { assert.NoError(t, err) } -func setupDB(t *testing.T) (*dockertest.Pool, error) { +func setupDB(t *testing.T) *dockertest.Pool { t.Helper() pool, err := dockertest.NewPool(os.Getenv("DOCKER_URL")) assert.NoError(t, err) @@ -187,7 +186,7 @@ func setupDB(t *testing.T) (*dockertest.Pool, error) { err = migrator.Apply(psqldb, sm) assert.NoError(t, err) - return pool, nil + return pool } func teardown(t *testing.T, pool *dockertest.Pool) error { diff --git a/internal/statesync/stateprovider.go b/internal/statesync/stateprovider.go index 3e58ca5f4..a796b0b2e 100644 --- a/internal/statesync/stateprovider.go +++ b/internal/statesync/stateprovider.go @@ -379,7 +379,7 @@ func (s *stateProviderP2P) consensusParams(ctx context.Context, height int64) (t } wg.Add(1) - go func(p *BlockProvider, peer types.NodeID) { + go func(peer types.NodeID) { defer wg.Done() timer := time.NewTimer(0) @@ -424,7 +424,7 @@ func (s *stateProviderP2P) consensusParams(ctx context.Context, height int64) (t } } - }(p, peer) + }(peer) } sig := make(chan struct{}) go func() { wg.Wait(); close(sig) }() diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 82949b103..4fa577cc4 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -17,7 +17,6 @@ import ( "github.com/tendermint/tendermint/crypto" sm "github.com/tendermint/tendermint/internal/state" "github.com/tendermint/tendermint/internal/state/test/factory" - "github.com/tendermint/tendermint/libs/log" tmrand "github.com/tendermint/tendermint/libs/rand" tmtime "github.com/tendermint/tendermint/libs/time" "github.com/tendermint/tendermint/types" @@ -46,7 +45,7 @@ func makeTestCommit(height int64, timestamp time.Time) *types.Commit { commitSigs) } -func makeStateAndBlockStore(dir string, logger log.Logger) (sm.State, *BlockStore, cleanupFunc, error) { +func makeStateAndBlockStore(dir string) (sm.State, *BlockStore, cleanupFunc, error) { cfg, err := config.ResetTestRoot(dir, "blockchain_reactor_test") if err != nil { return sm.State{}, nil, nil, err @@ -81,7 +80,7 @@ func TestMain(m *testing.M) { } var cleanup cleanupFunc - state, _, cleanup, err = makeStateAndBlockStore(dir, log.NewNopLogger()) + state, _, cleanup, err = makeStateAndBlockStore(dir) if err != nil { stdlog.Fatal(err) } @@ -103,7 +102,7 @@ func TestMain(m *testing.M) { // TODO: This test should be simplified ... func TestBlockStoreSaveLoadBlock(t *testing.T) { - state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir(), log.NewNopLogger()) + state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir()) defer cleanup() require.NoError(t, err) require.Equal(t, bs.Base(), int64(0), "initially the base should be zero") @@ -492,7 +491,7 @@ func TestLoadBlockMeta(t *testing.T) { } func TestBlockFetchAtHeight(t *testing.T) { - state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir(), log.NewNopLogger()) + state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir()) defer cleanup() require.NoError(t, err) require.Equal(t, bs.Height(), int64(0), "initially the height should be zero") diff --git a/libs/bits/bit_array_test.go b/libs/bits/bit_array_test.go index b76085bee..e4bf45c38 100644 --- a/libs/bits/bit_array_test.go +++ b/libs/bits/bit_array_test.go @@ -13,25 +13,25 @@ import ( tmprotobits "github.com/tendermint/tendermint/proto/tendermint/libs/bits" ) -func randBitArray(bits int) (*BitArray, []byte) { +func randBitArray(bits int) *BitArray { src := tmrand.Bytes((bits + 7) / 8) bA := NewBitArray(bits) for i := 0; i < len(src); i++ { for j := 0; j < 8; j++ { if i*8+j >= bits { - return bA, src + return bA } setBit := src[i]&(1< 0 bA.SetIndex(i*8+j, setBit) } } - return bA, src + return bA } func TestAnd(t *testing.T) { - bA1, _ := randBitArray(51) - bA2, _ := randBitArray(31) + bA1 := randBitArray(51) + bA2 := randBitArray(31) bA3 := bA1.And(bA2) var bNil *BitArray @@ -54,9 +54,8 @@ func TestAnd(t *testing.T) { } func TestOr(t *testing.T) { - - bA1, _ := randBitArray(51) - bA2, _ := randBitArray(31) + bA1 := randBitArray(51) + bA2 := randBitArray(31) bA3 := bA1.Or(bA2) bNil := (*BitArray)(nil) @@ -191,10 +190,7 @@ func TestEmptyFull(t *testing.T) { } func TestUpdateNeverPanics(t *testing.T) { - newRandBitArray := func(n int) *BitArray { - ba, _ := randBitArray(n) - return ba - } + newRandBitArray := func(n int) *BitArray { return randBitArray(n) } pairs := []struct { a, b *BitArray }{ diff --git a/node/node.go b/node/node.go index 02b057868..6c2809ffd 100644 --- a/node/node.go +++ b/node/node.go @@ -260,11 +260,8 @@ func makeNode( node.rpcEnv.EvidencePool = evPool node.evPool = evPool - mpReactor, mp, err := createMempoolReactor(logger, cfg, proxyApp, stateStore, nodeMetrics.mempool, + mpReactor, mp := createMempoolReactor(logger, cfg, proxyApp, stateStore, nodeMetrics.mempool, peerManager.Subscribe, node.router.OpenChannel, peerManager.GetHeight) - if err != nil { - return nil, combineCloseError(err, makeCloser(closers)) - } node.rpcEnv.Mempool = mp node.services = append(node.services, mpReactor) diff --git a/node/setup.go b/node/setup.go index 5e5050b53..99fd68b28 100644 --- a/node/setup.go +++ b/node/setup.go @@ -172,7 +172,7 @@ func createMempoolReactor( peerEvents p2p.PeerEventSubscriber, chCreator p2p.ChannelCreator, peerHeight func(types.NodeID) int64, -) (service.Service, mempool.Mempool, error) { +) (service.Service, mempool.Mempool) { logger = logger.With("module", "mempool") mp := mempool.NewTxMempool( @@ -197,7 +197,7 @@ func createMempoolReactor( mp.EnableTxsAvailable() } - return reactor, mp, nil + return reactor, mp } func createEvidenceReactor( diff --git a/scripts/scmigrate/migrate.go b/scripts/scmigrate/migrate.go index ba3de2698..c8e1d9490 100644 --- a/scripts/scmigrate/migrate.go +++ b/scripts/scmigrate/migrate.go @@ -115,7 +115,7 @@ func getAllSeenCommits(ctx context.Context, db dbm.DB) ([]toMigrate, error) { return scData, nil } -func renameRecord(ctx context.Context, db dbm.DB, keep toMigrate) error { +func renameRecord(db dbm.DB, keep toMigrate) error { wantKey := makeKeyFromPrefix(prefixSeenCommit) if bytes.Equal(keep.key, wantKey) { return nil // we already did this conversion @@ -143,7 +143,7 @@ func renameRecord(ctx context.Context, db dbm.DB, keep toMigrate) error { return cerr } -func deleteRecords(ctx context.Context, db dbm.DB, scData []toMigrate) error { +func deleteRecords(db dbm.DB, scData []toMigrate) error { // delete all the remaining stale values in a single batch batch := db.NewBatch() @@ -179,7 +179,7 @@ func Migrate(ctx context.Context, db dbm.DB) error { // retain only the latest. keep, remove := scData[0], scData[1:] - if err := renameRecord(ctx, db, keep); err != nil { + if err := renameRecord(db, keep); err != nil { return fmt.Errorf("renaming seen commit record: %w", err) } @@ -189,7 +189,7 @@ func Migrate(ctx context.Context, db dbm.DB) error { // Remove any older seen commits. Prior to v0.35, we kept these records for // all heights, but v0.35 keeps only the latest. - if err := deleteRecords(ctx, db, remove); err != nil { + if err := deleteRecords(db, remove); err != nil { return fmt.Errorf("writing data: %w", err) } diff --git a/test/e2e/runner/main.go b/test/e2e/runner/main.go index 7d147f411..c4a73d33f 100644 --- a/test/e2e/runner/main.go +++ b/test/e2e/runner/main.go @@ -134,7 +134,7 @@ func NewCLI(logger log.Logger) *CLI { if err = Wait(ctx, logger, cli.testnet, 5); err != nil { // wait for network to settle before tests return err } - if err := Test(logger, cli.testnet); err != nil { + if err := Test(cli.testnet); err != nil { return err } return nil @@ -259,7 +259,7 @@ func NewCLI(logger log.Logger) *CLI { Use: "test", Short: "Runs test cases against a running testnet", RunE: func(cmd *cobra.Command, args []string) error { - return Test(logger, cli.testnet) + return Test(cli.testnet) }, }) diff --git a/test/e2e/runner/test.go b/test/e2e/runner/test.go index 22fcd730e..2237588a1 100644 --- a/test/e2e/runner/test.go +++ b/test/e2e/runner/test.go @@ -3,12 +3,11 @@ package main import ( "os" - "github.com/tendermint/tendermint/libs/log" e2e "github.com/tendermint/tendermint/test/e2e/pkg" ) // Test runs test cases under tests/ -func Test(logger log.Logger, testnet *e2e.Testnet) error { +func Test(testnet *e2e.Testnet) error { err := os.Setenv("E2E_MANIFEST", testnet.File) if err != nil { return err diff --git a/types/evidence_test.go b/types/evidence_test.go index dd3b54d08..e284c2fca 100644 --- a/types/evidence_test.go +++ b/types/evidence_test.go @@ -295,7 +295,14 @@ func TestMockEvidenceValidateBasic(t *testing.T) { func makeVote( ctx context.Context, - t *testing.T, val PrivValidator, chainID string, valIndex int32, height int64, round int32, step int, blockID BlockID, + t *testing.T, + val PrivValidator, + chainID string, + valIndex int32, + height int64, + round int32, + step int, + blockID BlockID, time time.Time, ) *Vote { pubKey, err := val.GetPubKey(ctx) diff --git a/types/protobuf_test.go b/types/protobuf_test.go index 3ab095eee..c482153c1 100644 --- a/types/protobuf_test.go +++ b/types/protobuf_test.go @@ -14,11 +14,11 @@ import ( func TestABCIPubKey(t *testing.T) { pkEd := ed25519.GenPrivKey().PubKey() - err := testABCIPubKey(t, pkEd, ABCIPubKeyTypeEd25519) + err := testABCIPubKey(t, pkEd) assert.NoError(t, err) } -func testABCIPubKey(t *testing.T, pk crypto.PubKey, typeStr string) error { +func testABCIPubKey(t *testing.T, pk crypto.PubKey) error { abciPubKey, err := encoding.PubKeyToProto(pk) require.NoError(t, err) pk2, err := encoding.PubKeyFromProto(abciPubKey) From 9ea0e5efa78516ceff453f5202ed9a1a9dd8f70a Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Mon, 18 Apr 2022 15:49:26 -0700 Subject: [PATCH 8/8] cleanup: pin get-diff-action uses to major version only, not minor/patch (#8368) --- .github/workflows/build.yml | 6 +++--- .github/workflows/docs-toc.yml | 2 +- .github/workflows/e2e.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/markdown-links.yml | 2 +- .github/workflows/tests.yml | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c871571be..ce6958eab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ jobs: with: go-version: "1.17" - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go @@ -45,7 +45,7 @@ jobs: with: go-version: "1.17" - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go @@ -67,7 +67,7 @@ jobs: with: go-version: "1.17" - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go diff --git a/.github/workflows/docs-toc.yml b/.github/workflows/docs-toc.yml index 940df7c8c..fbe759877 100644 --- a/.github/workflows/docs-toc.yml +++ b/.github/workflows/docs-toc.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | docs/architecture/** diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 124d06f5a..6666999fc 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -18,7 +18,7 @@ jobs: with: go-version: '1.17' - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 332f55705..359514426 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-go@v3 with: go-version: '^1.17' - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go diff --git a/.github/workflows/markdown-links.yml b/.github/workflows/markdown-links.yml index 356eb3f31..7af7e3ce9 100644 --- a/.github/workflows/markdown-links.yml +++ b/.github/workflows/markdown-links.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.md diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1ef5759e5..7ee964d21 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: with: go-version: "1.17" - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go @@ -42,7 +42,7 @@ jobs: needs: tests steps: - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go