From d534285bfe4f2e606c7260bc1ddb378b72fba319 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Thu, 10 Nov 2022 08:05:15 -0500 Subject: [PATCH 01/10] Forward-port v0.34.23 changelog entry (#9685) From #9684. [Rendered](https://github.com/tendermint/tendermint/blob/thane/v0.34.23-changelog/CHANGELOG.md#v03423) --- #### PR checklist - [x] Tests written/updated, or no tests needed - [x] `CHANGELOG_PENDING.md` updated, or no changelog entry needed - [x] Updated relevant documentation (`docs/`) and code comments, or no documentation updates needed --- CHANGELOG.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b27c149..81abb1b51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,46 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/cosmos). +## v0.34.23 + +*Nov 9, 2022* + +This release introduces some new Prometheus metrics to help in determining what +kinds of messages are consuming the most P2P bandwidth. This builds towards our +broader goal of optimizing Tendermint bandwidth consumption, and will give us +meaningful insights once we can establish these metrics for a number of chains. + +We now also return `Cache-Control` headers for select RPC endpoints to help +facilitate caching. + +Special thanks to external contributors on this release: @JayT106 + +### IMPROVEMENTS +- `[p2p]` [\#9641](https://github.com/tendermint/tendermint/issues/9641) Add new + Envelope type and associated methods for sending and receiving Envelopes + instead of raw bytes. This also adds new metrics, + `tendermint_p2p_message_send_bytes_total` and + `tendermint_p2p_message_receive_bytes_total`, that expose how many bytes of + each message type have been sent. +- `[rpc]` [\#9666](https://github.com/tendermint/tendermint/issues/9666) Enable + caching of RPC responses (@JayT106) + + The following RPC endpoints will return `Cache-Control` headers with a maximum + age of 1 day: + + - `/abci_info` + - `/block`, if `height` is supplied + - `/block_by_hash` + - `/block_results`, if `height` is supplied + - `/blockchain` + - `/check_tx` + - `/commit`, if `height` is supplied + - `/consensus_params`, if `height` is supplied + - `/genesis` + - `/genesis_chunked` + - `/tx` + - `/validators`, if `height` is supplied + ## v0.34.22 This release includes several bug fixes, [one of From f12588aab1f1b52ffa82ed143676d69e2fab7bf4 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Thu, 10 Nov 2022 16:59:10 +0100 Subject: [PATCH 02/10] config: add bootstrap peers (#9680) --- CHANGELOG_PENDING.md | 3 +++ UPGRADING.md | 9 +++++++++ cmd/tendermint/commands/run_node.go | 1 + config/config.go | 5 +++++ config/toml.go | 5 +++++ node/node.go | 11 +++++++++++ spec/p2p/config.md | 8 ++++++++ 7 files changed, 42 insertions(+) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index d7de0a301..dfc66460f 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -23,6 +23,9 @@ ### FEATURES +- [config] \#9680 Introduce `BootstrapPeers` to the config to allow nodes to list peers to be added to + the addressbook upon start up (@cmwaters) + ### IMPROVEMENTS - [pubsub] \#7319 Performance improvements for the event query API (@creachadair) diff --git a/UPGRADING.md b/UPGRADING.md index 001f1b7eb..27b267a28 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -5,6 +5,15 @@ Tendermint Core. ## Unreleased +## Config Changes + +* A new config field, `BootstrapPeers` has been introduced as a means of + adding a list of addresses to the addressbook upon initializing a node. This is an + alternative to `PersistentPeers`. `PersistentPeers` shold be only used for + nodes that you want to keep a constant connection with i.e. sentry nodes + +---- + ### ABCI Changes * The `ABCIVersion` is now `1.0.0`. diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index ac2984111..5bb2a6d45 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -66,6 +66,7 @@ func AddNodeFlags(cmd *cobra.Command) { cmd.Flags().String("p2p.external-address", config.P2P.ExternalAddress, "ip:port address to advertise to peers for them to dial") cmd.Flags().String("p2p.seeds", config.P2P.Seeds, "comma-delimited ID@host:port seed nodes") cmd.Flags().String("p2p.persistent_peers", config.P2P.PersistentPeers, "comma-delimited ID@host:port persistent peers") + cmd.Flags().String("p2p.bootstrap_peers", config.P2P.BootstrapPeers, "comma-delimited ID@host:port peers to be added to the addressbook on startup") cmd.Flags().String("p2p.unconditional_peer_ids", config.P2P.UnconditionalPeerIDs, "comma-delimited IDs of unconditional peers") cmd.Flags().Bool("p2p.upnp", config.P2P.UPNP, "enable/disable UPNP port forwarding") diff --git a/config/config.go b/config/config.go index bcf083463..c1ad2e229 100644 --- a/config/config.go +++ b/config/config.go @@ -548,6 +548,11 @@ type P2PConfig struct { //nolint: maligned // We only use these if we can’t connect to peers in the addrbook Seeds string `mapstructure:"seeds"` + // Comma separated list of peers to be added to the peer store + // on startup. Either BootstrapPeers or PersistentPeers are + // needed for peer discovery + BootstrapPeers string `mapstructure:"bootstrap_peers"` + // Comma separated list of nodes to keep persistent connections to PersistentPeers string `mapstructure:"persistent_peers"` diff --git a/config/toml.go b/config/toml.go index d5c2ab710..6041b92c3 100644 --- a/config/toml.go +++ b/config/toml.go @@ -283,6 +283,11 @@ external_address = "{{ .P2P.ExternalAddress }}" # Comma separated list of seed nodes to connect to seeds = "{{ .P2P.Seeds }}" +# Comma separated list of peers to be added to the peer store +# on startup. Either BootstrapPeers or PersistentPeers are +# needed for peer discovery +bootstrap_peers = "{{ .P2P.BootstrapPeers }}" + # Comma separated list of nodes to keep persistent connections to persistent_peers = "{{ .P2P.PersistentPeers }}" diff --git a/node/node.go b/node/node.go index 18f3f1e84..90a9356db 100644 --- a/node/node.go +++ b/node/node.go @@ -308,6 +308,17 @@ func NewNode(config *cfg.Config, return nil, fmt.Errorf("could not create addrbook: %w", err) } + for _, addr := range splitAndTrimEmpty(config.P2P.BootstrapPeers, ",", " ") { + netAddrs, err := p2p.NewNetAddressString(addr) + if err != nil { + return nil, fmt.Errorf("invalid bootstrap peer address: %w", err) + } + err = addrBook.AddAddress(netAddrs, netAddrs) + if err != nil { + return nil, fmt.Errorf("adding bootstrap address to addressbook: %w", err) + } + } + // Optionally, start the pex reactor // // TODO: diff --git a/spec/p2p/config.md b/spec/p2p/config.md index b63c04f28..966a04c7e 100644 --- a/spec/p2p/config.md +++ b/spec/p2p/config.md @@ -17,6 +17,14 @@ and upon incoming connection shares some peers and disconnects. Dials these seeds when we need more peers. They should return a list of peers and then disconnect. If we already have enough peers in the address book, we may never need to dial them. +## Bootstrap Peers + +`--p2p.bootstrap_peers “id100000000000000000000000000000000@1.2.3.4:26656,id200000000000000000000000000000000@2.3.4.5:26656”` + +A list of peers to be added to the addressbook upon startup to ensure that the node has some peers to initially dial. +Unlike persistent peers, these addresses don't have any extra privileges. The node may not necessarily connect on redial +these peers. + ## Persistent Peers `--p2p.persistent_peers “id100000000000000000000000000000000@1.2.3.4:26656,id200000000000000000000000000000000@2.3.4.5:26656”` From 99a7ac84dca30676fd544be18c6df2880a14429f Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Thu, 10 Nov 2022 19:13:15 +0100 Subject: [PATCH 03/10] metrics: add separate statesync and blocksync metrics (#9682) --- CHANGELOG_PENDING.md | 2 ++ blocksync/metrics.gen.go | 30 ++++++++++++++++++++++++++++++ blocksync/metrics.go | 19 +++++++++++++++++++ blocksync/reactor.go | 7 ++++++- blocksync/reactor_test.go | 2 +- consensus/metrics.gen.go | 14 -------------- consensus/metrics.go | 4 ---- consensus/reactor.go | 2 -- node/node.go | 13 ++++--------- node/setup.go | 18 +++++++++--------- statesync/metrics.gen.go | 30 ++++++++++++++++++++++++++++++ statesync/metrics.go | 19 +++++++++++++++++++ statesync/reactor.go | 5 +++++ statesync/reactor_test.go | 4 ++-- 14 files changed, 127 insertions(+), 42 deletions(-) create mode 100644 blocksync/metrics.gen.go create mode 100644 blocksync/metrics.go create mode 100644 statesync/metrics.gen.go create mode 100644 statesync/metrics.go diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index dfc66460f..77940da8a 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -20,6 +20,8 @@ - Tooling - [tools/tm-signer-harness] \#6498 Set OS home dir to instead of the hardcoded PATH. (@JayT106) + - [metrics] \#9682 move state-syncing and block-syncing metrics to their respective packages (@cmwaters) + labels have moved from block_syncing -> blocksync_syncing and state_syncing -> statesync_syncing ### FEATURES diff --git a/blocksync/metrics.gen.go b/blocksync/metrics.gen.go new file mode 100644 index 000000000..1d093fb31 --- /dev/null +++ b/blocksync/metrics.gen.go @@ -0,0 +1,30 @@ +// Code generated by metricsgen. DO NOT EDIT. + +package blocksync + +import ( + "github.com/go-kit/kit/metrics/discard" + prometheus "github.com/go-kit/kit/metrics/prometheus" + stdprometheus "github.com/prometheus/client_golang/prometheus" +) + +func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { + labels := []string{} + for i := 0; i < len(labelsAndValues); i += 2 { + labels = append(labels, labelsAndValues[i]) + } + return &Metrics{ + Syncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ + Namespace: namespace, + Subsystem: MetricsSubsystem, + Name: "syncing", + Help: "Whether or not a node is block syncing. 1 if yes, 0 if no.", + }, labels).With(labelsAndValues...), + } +} + +func NopMetrics() *Metrics { + return &Metrics{ + Syncing: discard.NewGauge(), + } +} diff --git a/blocksync/metrics.go b/blocksync/metrics.go new file mode 100644 index 000000000..78a6337b9 --- /dev/null +++ b/blocksync/metrics.go @@ -0,0 +1,19 @@ +package blocksync + +import ( + "github.com/go-kit/kit/metrics" +) + +const ( + // MetricsSubsystem is a subsystem shared by all metrics exposed by this + // package. + MetricsSubsystem = "blocksync" +) + +//go:generate go run ../scripts/metricsgen -struct=Metrics + +// Metrics contains metrics exposed by this package. +type Metrics struct { + // Whether or not a node is block syncing. 1 if yes, 0 if no. + Syncing metrics.Gauge +} diff --git a/blocksync/reactor.go b/blocksync/reactor.go index 87dae8170..eeada7da2 100644 --- a/blocksync/reactor.go +++ b/blocksync/reactor.go @@ -58,11 +58,13 @@ type Reactor struct { requestsCh <-chan BlockRequest errorsCh <-chan peerError + + metrics *Metrics } // NewReactor returns new reactor instance. func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore, - blockSync bool) *Reactor { + blockSync bool, metrics *Metrics) *Reactor { if state.LastBlockHeight != store.Height() { panic(fmt.Sprintf("state (%v) and store (%v) height mismatch", state.LastBlockHeight, @@ -88,6 +90,7 @@ func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockS blockSync: blockSync, requestsCh: requestsCh, errorsCh: errorsCh, + metrics: metrics, } bcR.BaseReactor = *p2p.NewBaseReactor("Reactor", bcR) return bcR @@ -236,6 +239,8 @@ func (bcR *Reactor) Receive(e p2p.Envelope) { // Handle messages from the poolReactor telling the reactor what to do. // NOTE: Don't sleep in the FOR_LOOP or otherwise slow it down! func (bcR *Reactor) poolRoutine(stateSynced bool) { + bcR.metrics.Syncing.Set(1) + defer bcR.metrics.Syncing.Set(0) trySyncTicker := time.NewTicker(trySyncIntervalMS * time.Millisecond) defer trySyncTicker.Stop() diff --git a/blocksync/reactor_test.go b/blocksync/reactor_test.go index a88e05912..0ab127b53 100644 --- a/blocksync/reactor_test.go +++ b/blocksync/reactor_test.go @@ -145,7 +145,7 @@ func newReactor( blockStore.SaveBlock(thisBlock, thisParts, lastCommit) } - bcReactor := NewReactor(state.Copy(), blockExec, blockStore, fastSync) + bcReactor := NewReactor(state.Copy(), blockExec, blockStore, fastSync, NopMetrics()) bcReactor.SetLogger(logger.With("module", "blocksync")) return ReactorPair{bcReactor, proxyApp} diff --git a/consensus/metrics.gen.go b/consensus/metrics.gen.go index 6f1699cdd..94ea5d224 100644 --- a/consensus/metrics.gen.go +++ b/consensus/metrics.gen.go @@ -118,18 +118,6 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "latest_block_height", Help: "The latest block height.", }, labels).With(labelsAndValues...), - BlockSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ - Namespace: namespace, - Subsystem: MetricsSubsystem, - Name: "block_syncing", - Help: "Whether or not a node is block syncing. 1 if yes, 0 if no.", - }, labels).With(labelsAndValues...), - StateSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ - Namespace: namespace, - Subsystem: MetricsSubsystem, - Name: "state_syncing", - Help: "Whether or not a node is state syncing. 1 if yes, 0 if no.", - }, labels).With(labelsAndValues...), BlockParts: prometheus.NewCounterFrom(stdprometheus.CounterOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, @@ -208,8 +196,6 @@ func NopMetrics() *Metrics { BlockSizeBytes: discard.NewGauge(), TotalTxs: discard.NewGauge(), CommittedHeight: discard.NewGauge(), - BlockSyncing: discard.NewGauge(), - StateSyncing: discard.NewGauge(), BlockParts: discard.NewCounter(), StepDurationSeconds: discard.NewHistogram(), BlockGossipPartsReceived: discard.NewCounter(), diff --git a/consensus/metrics.go b/consensus/metrics.go index e6a8f284a..f8262d391 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -61,10 +61,6 @@ type Metrics struct { TotalTxs metrics.Gauge // The latest block height. CommittedHeight metrics.Gauge `metrics_name:"latest_block_height"` - // Whether or not a node is block syncing. 1 if yes, 0 if no. - BlockSyncing metrics.Gauge - // Whether or not a node is state syncing. 1 if yes, 0 if no. - StateSyncing metrics.Gauge // Number of block parts transmitted by each peer. BlockParts metrics.Counter `metrics_labels:"peer_id"` diff --git a/consensus/reactor.go b/consensus/reactor.go index d308da2a0..a8d672e44 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -119,8 +119,6 @@ func (conR *Reactor) SwitchToConsensus(state sm.State, skipWAL bool) { conR.mtx.Lock() conR.waitSync = false conR.mtx.Unlock() - conR.Metrics.BlockSyncing.Set(0) - conR.Metrics.StateSyncing.Set(0) if skipWAL { conR.conS.doWALCatchup = false diff --git a/node/node.go b/node/node.go index 90a9356db..ddf86e0dc 100644 --- a/node/node.go +++ b/node/node.go @@ -160,7 +160,7 @@ func NewNode(config *cfg.Config, return nil, err } - csMetrics, p2pMetrics, memplMetrics, smMetrics, abciMetrics := metricsProvider(genDoc.ChainID) + csMetrics, p2pMetrics, memplMetrics, smMetrics, abciMetrics, bsMetrics, ssMetrics := metricsProvider(genDoc.ChainID) // Create the proxyApp and establish connections to the ABCI app (consensus, mempool, query). proxyApp, err := createAndStartProxyAppConns(clientCreator, logger, abciMetrics) @@ -249,18 +249,12 @@ func NewNode(config *cfg.Config, ) // Make BlocksyncReactor. Don't start block sync if we're doing a state sync first. - bcReactor, err := createBlocksyncReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger) + bcReactor, err := createBlocksyncReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger, bsMetrics) if err != nil { return nil, fmt.Errorf("could not create blocksync reactor: %w", err) } - // Make ConsensusReactor. Don't enable fully if doing a state sync and/or block sync first. - // FIXME We need to update metrics here, since other reactors don't have access to them. - if stateSync { - csMetrics.StateSyncing.Set(1) - } else if blockSync { - csMetrics.BlockSyncing.Set(1) - } + // Make ConsensusReactor consensusReactor, consensusState := createConsensusReactor( config, state, blockExec, blockStore, mempool, evidencePool, privValidator, csMetrics, stateSync || blockSync, eventBus, consensusLogger, @@ -275,6 +269,7 @@ func NewNode(config *cfg.Config, proxyApp.Snapshot(), proxyApp.Query(), config.StateSync.TempDir, + ssMetrics, ) stateSyncReactor.SetLogger(logger.With("module", "statesync")) diff --git a/node/setup.go b/node/setup.go index e9449558e..5bada8b6f 100644 --- a/node/setup.go +++ b/node/setup.go @@ -12,7 +12,7 @@ import ( dbm "github.com/tendermint/tm-db" abci "github.com/tendermint/tendermint/abci/types" - bc "github.com/tendermint/tendermint/blocksync" + "github.com/tendermint/tendermint/blocksync" cfg "github.com/tendermint/tendermint/config" cs "github.com/tendermint/tendermint/consensus" "github.com/tendermint/tendermint/crypto" @@ -99,20 +99,22 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) { } // MetricsProvider returns a consensus, p2p and mempool Metrics. -type MetricsProvider func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics, *proxy.Metrics) +type MetricsProvider func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics, *proxy.Metrics, *blocksync.Metrics, *statesync.Metrics) // DefaultMetricsProvider returns Metrics build using Prometheus client library // if Prometheus is enabled. Otherwise, it returns no-op Metrics. func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider { - return func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics, *proxy.Metrics) { + return func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics, *proxy.Metrics, *blocksync.Metrics, *statesync.Metrics) { if config.Prometheus { return cs.PrometheusMetrics(config.Namespace, "chain_id", chainID), p2p.PrometheusMetrics(config.Namespace, "chain_id", chainID), mempl.PrometheusMetrics(config.Namespace, "chain_id", chainID), sm.PrometheusMetrics(config.Namespace, "chain_id", chainID), - proxy.PrometheusMetrics(config.Namespace, "chain_id", chainID) + proxy.PrometheusMetrics(config.Namespace, "chain_id", chainID), + blocksync.PrometheusMetrics(config.Namespace, "chain_id", chainID), + statesync.PrometheusMetrics(config.Namespace, "chain_id", chainID) } - return cs.NopMetrics(), p2p.NopMetrics(), mempl.NopMetrics(), sm.NopMetrics(), proxy.NopMetrics() + return cs.NopMetrics(), p2p.NopMetrics(), mempl.NopMetrics(), sm.NopMetrics(), proxy.NopMetrics(), blocksync.NopMetrics(), statesync.NopMetrics() } } @@ -336,10 +338,11 @@ func createBlocksyncReactor(config *cfg.Config, blockStore *store.BlockStore, blockSync bool, logger log.Logger, + metrics *blocksync.Metrics, ) (bcReactor p2p.Reactor, err error) { switch config.BlockSync.Version { case "v0": - bcReactor = bc.NewReactor(state.Copy(), blockExec, blockStore, blockSync) + bcReactor = blocksync.NewReactor(state.Copy(), blockExec, blockStore, blockSync, metrics) case "v1", "v2": return nil, fmt.Errorf("block sync version %s has been deprecated. Please use v0", config.BlockSync.Version) default: @@ -575,9 +578,6 @@ func startStateSync(ssR *statesync.Reactor, bcR blockSyncReactor, conR *cs.React } if blockSync { - // FIXME Very ugly to have these metrics bleed through here. - conR.Metrics.StateSyncing.Set(0) - conR.Metrics.BlockSyncing.Set(1) err = bcR.SwitchToBlockSync(state) if err != nil { ssR.Logger.Error("Failed to switch to block sync", "err", err) diff --git a/statesync/metrics.gen.go b/statesync/metrics.gen.go new file mode 100644 index 000000000..1941c9270 --- /dev/null +++ b/statesync/metrics.gen.go @@ -0,0 +1,30 @@ +// Code generated by metricsgen. DO NOT EDIT. + +package statesync + +import ( + "github.com/go-kit/kit/metrics/discard" + prometheus "github.com/go-kit/kit/metrics/prometheus" + stdprometheus "github.com/prometheus/client_golang/prometheus" +) + +func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { + labels := []string{} + for i := 0; i < len(labelsAndValues); i += 2 { + labels = append(labels, labelsAndValues[i]) + } + return &Metrics{ + Syncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ + Namespace: namespace, + Subsystem: MetricsSubsystem, + Name: "syncing", + Help: "Whether or not a node is state syncing. 1 if yes, 0 if no.", + }, labels).With(labelsAndValues...), + } +} + +func NopMetrics() *Metrics { + return &Metrics{ + Syncing: discard.NewGauge(), + } +} diff --git a/statesync/metrics.go b/statesync/metrics.go new file mode 100644 index 000000000..9a4d7fcef --- /dev/null +++ b/statesync/metrics.go @@ -0,0 +1,19 @@ +package statesync + +import ( + "github.com/go-kit/kit/metrics" +) + +const ( + // MetricsSubsystem is a subsystem shared by all metrics exposed by this + // package. + MetricsSubsystem = "statesync" +) + +//go:generate go run ../scripts/metricsgen -struct=Metrics + +// Metrics contains metrics exposed by this package. +type Metrics struct { + // Whether or not a node is state syncing. 1 if yes, 0 if no. + Syncing metrics.Gauge +} diff --git a/statesync/reactor.go b/statesync/reactor.go index 096fdd1b7..d650a6a55 100644 --- a/statesync/reactor.go +++ b/statesync/reactor.go @@ -33,6 +33,7 @@ type Reactor struct { conn proxy.AppConnSnapshot connQuery proxy.AppConnQuery tempDir string + metrics *Metrics // This will only be set when a state sync is in progress. It is used to feed received // snapshots and chunks into the sync. @@ -46,12 +47,14 @@ func NewReactor( conn proxy.AppConnSnapshot, connQuery proxy.AppConnQuery, tempDir string, + metrics *Metrics, ) *Reactor { r := &Reactor{ cfg: cfg, conn: conn, connQuery: connQuery, + metrics: metrics, } r.BaseReactor = *p2p.NewBaseReactor("StateSync", r) @@ -265,6 +268,7 @@ func (r *Reactor) Sync(stateProvider StateProvider, discoveryTime time.Duration) r.mtx.Unlock() return sm.State{}, nil, errors.New("a state sync is already in progress") } + r.metrics.Syncing.Set(1) r.syncer = newSyncer(r.cfg, r.Logger, r.conn, r.connQuery, stateProvider, r.tempDir) r.mtx.Unlock() @@ -284,6 +288,7 @@ func (r *Reactor) Sync(stateProvider StateProvider, discoveryTime time.Duration) r.mtx.Lock() r.syncer = nil + r.metrics.Syncing.Set(0) r.mtx.Unlock() return state, commit, err } diff --git a/statesync/reactor_test.go b/statesync/reactor_test.go index 8d06c7c2d..eed3b2361 100644 --- a/statesync/reactor_test.go +++ b/statesync/reactor_test.go @@ -71,7 +71,7 @@ func TestReactor_Receive_ChunkRequest(t *testing.T) { // Start a reactor and send a ssproto.ChunkRequest, then wait for and check response cfg := config.DefaultStateSyncConfig() - r := NewReactor(*cfg, conn, nil, "") + r := NewReactor(*cfg, conn, nil, "", NopMetrics()) err := r.Start() require.NoError(t, err) t.Cleanup(func() { @@ -161,7 +161,7 @@ func TestReactor_Receive_SnapshotsRequest(t *testing.T) { // Start a reactor and send a SnapshotsRequestMessage, then wait for and check responses cfg := config.DefaultStateSyncConfig() - r := NewReactor(*cfg, conn, nil, "") + r := NewReactor(*cfg, conn, nil, "", NopMetrics()) err := r.Start() require.NoError(t, err) t.Cleanup(func() { From d324430f82f526d9c5d4bbf50fefa2fb5311e6a2 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Fri, 11 Nov 2022 09:06:34 -0500 Subject: [PATCH 04/10] =?UTF-8?q?Update=20codeowners=20to=20include=20Adi?= =?UTF-8?q?=20and=20L=C3=A1saro=20(#9697)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thane Thomson Signed-off-by: Thane Thomson --- .github/CODEOWNERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 77b944d40..8be48245c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,6 +7,6 @@ # global owners are only requested if there isn't a more specific # codeowner specified below. For this reason, the global codeowners # are often repeated in package-level definitions. -* @ebuchman @tendermint/tendermint-engineering +* @ebuchman @tendermint/tendermint-engineering @adizere @lasarojc -/spec @ebuchman @tendermint/tendermint-research @tendermint/tendermint-engineering +/spec @ebuchman @tendermint/tendermint-research @tendermint/tendermint-engineering @adizere @lasarojc From a7dc8aaf91baf416d7709a91c3a2dc1514ea0702 Mon Sep 17 00:00:00 2001 From: Lasaro Camargos Date: Mon, 14 Nov 2022 16:28:42 -0300 Subject: [PATCH 05/10] Disambiguates wording in EndBlock (#9698) The current text gives margin to committing changes to the app state during EndBlock, but it should only happen during Commit. Also, PrepareProposal is not allowed to modify transactions, but only the transaction set. --- spec/abci/abci++_basic_concepts.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/abci/abci++_basic_concepts.md b/spec/abci/abci++_basic_concepts.md index 06b44b834..2ceb3fd23 100644 --- a/spec/abci/abci++_basic_concepts.md +++ b/spec/abci/abci++_basic_concepts.md @@ -82,7 +82,8 @@ call sequences of these methods. been locked at Tendermint level. Tendermint gathers outstanding transactions from the mempool, generates a block header, and uses them to create a block to propose. Then, it calls `RequestPrepareProposal` with the newly created proposal, called *raw proposal*. The Application - can make changes to the raw proposal, such as modifying transactions, and returns the + can make changes to the raw proposal, such as modifying the set of transactions or the order + in which they appear, and returns the (potentially) modified proposal, called *prepared proposal* in the `ResponsePrepareProposal` call. The logic modifying the raw proposal can be non-deterministic. @@ -109,9 +110,9 @@ call sequences of these methods. returned by `DeliverTx` are included in the header of the next block. - [**EndBlock**](./abci++_methods.md#endblock) It is executed once all transactions have been processed via - `DeliverTx` to inform the application that the block can now be committed and inform it of potential changes such - as a new validator set to be proposed in the next round. As with `DeliverTx`, cryptographic commitments of the responses returned - are included in the header of the next block. + `DeliverTx` to inform the application that no other transactions will be delivered as part of the current + block and to ask for changes of the validator set and consensus parameters to be used in the following block. + As with `DeliverTx`, cryptographic commitments of the responses returned are included in the header of the next block.