Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `[node]` Removed `ConsensusState()` accessor from `Node`
struct - all access to consensus state should go via the reactor
([\#1120](https://github.com/cometbft/cometbft/pull/1120))
3 changes: 0 additions & 3 deletions .changelog/unreleased/breaking-changes/286-node.md

This file was deleted.

2 changes: 0 additions & 2 deletions .changelog/unreleased/breaking-changes/286-p2p.md

This file was deleted.

20 changes: 9 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,23 @@

- The `TMHOME` environment variable was renamed to `CMTHOME`, and all environment variables starting with `TM_` are instead prefixed with `CMT_`
([\#211](https://github.com/cometbft/cometbft/issues/211))
- `[protobuf]` Remove fields `sender`, `priority`, and `mempool_error` from
`ResponseCheckTx`. ([\#260](https://github.com/cometbft/cometbft/issues/260))
- `[mempool]` Remove priority mempool.
([\#260](https://github.com/cometbft/cometbft/issues/260))
- `[config]` Remove `Version` field from `MempoolConfig`.
([\#260](https://github.com/cometbft/cometbft/issues/260))
- `[protobuf]` Remove fields `sender`, `priority`, and `mempool_error` from
`ResponseCheckTx`. ([\#260](https://github.com/cometbft/cometbft/issues/260))
- `[node]` Removed methods from `Node` type: `BlockStore`, `ConsensusState`, `ConsensusReactor`,
`MempoolReactor`, `PEXReactor`, `EvidencePool`, `ProxyApp`
([\#286](https://github.com/cometbft/cometbft/issues/286))
- `[p2p]` Modified method `AddReactor` in `Switch` type: it is no longer returning the added `Reactor`
([\#286](https://github.com/cometbft/cometbft/issues/286))
- Bump minimum Go version to 1.20
([\#385](https://github.com/cometbft/cometbft/issues/385))
- `[crypto/merkle]` Do not allow verification of Merkle Proofs against empty trees (`nil` root). `Proof.ComputeRootHash` now panics when it encounters an error, but `Proof.Verify` does not panic
([\#558](https://github.com/cometbft/cometbft/issues/558))
- `[state/kvindexer]` Remove the function type from the event key stored in the database. This should be breaking only
for people who forked CometBFT and interact directly with the indexers kvstore.
([\#774](https://github.com/cometbft/cometbft/pull/774))
- `[pubsub]` Added support for big integers and big floats in the pubsub event query system.
- `[kvindexer]` Added support for big integers and big floats in the kvindexer.
Breaking changes: function `Number` in package `libs/pubsub/query/syntax` changed its return value.
([\#797](https://github.com/cometbft/cometbft/pull/797))
- `[kvindexer]` Added support for big integers and big floats in the kvindexer.
- `[pubsub]` Added support for big integers and big floats in the pubsub event query system.
Breaking changes: function `Number` in package `libs/pubsub/query/syntax` changed its return value.
([\#797](https://github.com/cometbft/cometbft/pull/797))
- `[mempool]` Application can now set `ConsensusParams.Block.MaxBytes` to -1
Expand All @@ -39,6 +34,9 @@ for people who forked CometBFT and interact directly with the indexers kvstore.
returned in `ResponsePrepareProposal.txs` does not exceed `RequestPrepareProposal.max_tx_bytes`,
otherwise CometBFT will panic.
([\#980](https://github.com/cometbft/cometbft/issues/980))
- `[node]` Removed `ConsensusState()` accessor from `Node`
struct - all access to consensus state should go via the reactor
([\#1120](https://github.com/cometbft/cometbft/pull/1120))
- `[state]` Move pruneBlocks from node/state to state/execution.
([\#6541](https://github.com/tendermint/tendermint/pull/6541))
- `[abci]` Move `app_hash` parameter from `Commit` to `FinalizeBlock`
Expand All @@ -50,11 +48,11 @@ for people who forked CometBFT and interact directly with the indexers kvstore.
([\#9625](https://github.com/tendermint/tendermint/pull/9625))
- `[rpc]` Remove global environment and replace with constructor
([\#9655](https://github.com/tendermint/tendermint/pull/9655))
- `[node]` Move DBContext and DBProvider from the node package to the config
package. ([\#9655](https://github.com/tendermint/tendermint/pull/9655))
- `[inspect]` Add a new `inspect` command for introspecting
the state and block store of a crashed tendermint node.
([\#9655](https://github.com/tendermint/tendermint/pull/9655))
- `[node]` Move DBContext and DBProvider from the node package to the config
package. ([\#9655](https://github.com/tendermint/tendermint/pull/9655))
- `[metrics]` Move state-syncing and block-syncing metrics to
their respective packages. Move labels from block_syncing
-> blocksync_syncing and state_syncing -> statesync_syncing
Expand Down
37 changes: 36 additions & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ type Node struct {
stateStore sm.Store
blockStore *store.BlockStore // store the blockchain to disk
bcReactor p2p.Reactor // for block-syncing
mempoolReactor p2p.Reactor // for gossipping transactions
mempool mempl.Mempool
stateSync bool // whether the node should state sync on startup
stateSyncReactor *statesync.Reactor // for hosting and restoring state sync snapshots
stateSyncProvider statesync.StateProvider // provides state data for bootstrapping a node
stateSyncGenesis sm.State // provides the genesis state for state sync
consensusState *cs.State // latest consensus state
consensusReactor *cs.Reactor // for participating in the consensus
pexReactor *pex.Reactor // for exchanging peer addresses
evidencePool *evidence.Pool // tracking evidence
proxyApp proxy.AppConns // connection to the application
rpcListeners []net.Listener // rpc servers
Expand Down Expand Up @@ -340,8 +342,9 @@ func NewNodeWithContext(ctx context.Context,
//
// If PEX is on, it should handle dialing the seeds. Otherwise the switch does it.
// Note we currently use the addrBook regardless at least for AddOurAddress
var pexReactor *pex.Reactor
if config.P2P.PexReactor {
createPEXReactorAndAddToSwitch(addrBook, config, sw, logger)
pexReactor = createPEXReactorAndAddToSwitch(addrBook, config, sw, logger)
}

// Add private IDs to addrbook to block those peers being added
Expand All @@ -361,12 +364,14 @@ func NewNodeWithContext(ctx context.Context,
stateStore: stateStore,
blockStore: blockStore,
bcReactor: bcReactor,
mempoolReactor: mempoolReactor,
mempool: mempool,
consensusState: consensusState,
consensusReactor: consensusReactor,
stateSyncReactor: stateSyncReactor,
stateSync: stateSync,
stateSyncGenesis: state, // Shouldn't be necessary, but need a way to pass the genesis state
pexReactor: pexReactor,
evidencePool: evidencePool,
proxyApp: proxyApp,
txIndexer: txIndexer,
Expand Down Expand Up @@ -711,11 +716,36 @@ func (n *Node) Switch() *p2p.Switch {
return n.sw
}

// BlockStore returns the Node's BlockStore.
func (n *Node) BlockStore() *store.BlockStore {
return n.blockStore
}

// ConsensusReactor returns the Node's ConsensusReactor.
func (n *Node) ConsensusReactor() *cs.Reactor {
return n.consensusReactor
}

// MempoolReactor returns the Node's mempool reactor.
func (n *Node) MempoolReactor() p2p.Reactor {
return n.mempoolReactor
}

// Mempool returns the Node's mempool.
func (n *Node) Mempool() mempl.Mempool {
return n.mempool
}

// PEXReactor returns the Node's PEXReactor. It returns nil if PEX is disabled.
func (n *Node) PEXReactor() *pex.Reactor {
return n.pexReactor
}

// EvidencePool returns the Node's EvidencePool.
func (n *Node) EvidencePool() *evidence.Pool {
return n.evidencePool
}

// EventBus returns the Node's EventBus.
func (n *Node) EventBus() *types.EventBus {
return n.eventBus
Expand All @@ -732,6 +762,11 @@ func (n *Node) GenesisDoc() *types.GenesisDoc {
return n.genesisDoc
}

// ProxyApp returns the Node's AppConns, representing its connections to the ABCI application.
func (n *Node) ProxyApp() proxy.AppConns {
return n.proxyApp
}

// Config returns the Node's config.
func (n *Node) Config() *cfg.Config {
return n.config
Expand Down
3 changes: 2 additions & 1 deletion node/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func createAddrBookAndSetOnSwitch(config *cfg.Config, sw *p2p.Switch,

func createPEXReactorAndAddToSwitch(addrBook pex.AddrBook, config *cfg.Config,
sw *p2p.Switch, logger log.Logger,
) {
) *pex.Reactor {
// TODO persistent peers ? so we can have their DNS addrs saved
pexReactor := pex.NewReactor(addrBook,
&pex.ReactorConfig{
Expand All @@ -469,6 +469,7 @@ func createPEXReactorAndAddToSwitch(addrBook pex.AddrBook, config *cfg.Config,
})
pexReactor.SetLogger(logger.With("module", "pex"))
sw.AddReactor("PEX", pexReactor)
return pexReactor
}

// startStateSync starts an asynchronous state sync process, then switches to block sync mode.
Expand Down
3 changes: 2 additions & 1 deletion p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func WithMetrics(metrics *Metrics) SwitchOption {

// AddReactor adds the given reactor to the switch.
// NOTE: Not goroutine safe.
func (sw *Switch) AddReactor(name string, reactor Reactor) {
func (sw *Switch) AddReactor(name string, reactor Reactor) Reactor {
for _, chDesc := range reactor.GetChannels() {
chID := chDesc.ID
// No two reactors can share the same channel.
Expand All @@ -174,6 +174,7 @@ func (sw *Switch) AddReactor(name string, reactor Reactor) {
}
sw.reactors[name] = reactor
reactor.SetSwitch(sw)
return reactor
}

// RemoveReactor removes the given Reactor from the Switch.
Expand Down