8000 chore: Merge branch main into feature/proto-upgrade by mzabaluev · Pull Request #1612 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: Merge branch main into feature/proto-upgrade #1612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2023
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
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `[rpc/client]` Hard-code the `/websocket` endpoint path such that it is
no longer configurable, removing the related client constructor parameter
([\#1412](https://github.com/cometbft/cometbft/pull/1412))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[store]` Make the `LoadBlock` method also return block metadata
([\#1556](https://github.com/cometbft/cometbft/issues/1556))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[state/indexer]` Respect both height params while querying for events
([\#1529](https://github.com/cometbft/cometbft/pull/1529))
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[metrics]` Add metric for mempool size in bytes `SizeBytes`.
([\#1512](https://github.com/cometbft/cometbft/pull/1512))
3 changes: 3 additions & 0 deletions .changelog/unreleased/improvements/1412-rpc-versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `[rpc]` The RPC API is now versioned, with all existing endpoints accessible
via `/v1/*` as well as `/*`
([\#1412](https://github.com/cometbft/cometbft/pull/1412))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[consensus]` Reduce the default MaxBytes to 4MB and increase MaxGas to 10 million
([\#1518](https://github.com/cometbft/cometbft/pull/1518))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- `[mempool]` Add experimental feature to limit the number of persistent peers and non-persistent
peers to which the node gossip transactions.
([\#1558](https://github.com/cometbft/cometbft/pull/1558))
([\#1584](https://github.com/cometbft/cometbft/pull/1584))
- `[config]` Add mempool parameters `experimental_max_gossip_connections_to_persistent_peers` and
`experimental_max_gossip_connections_to_non_persistent_peers` for limiting the number of peers to
which the node gossip transactions.
([\#1558](https://github.com/cometbft/cometbft/pull/1558))
([\#1584](https://github.com/cometbft/cometbft/pull/1584))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[e2e]` Allow disabling the PEX reactor on all nodes in the testnet
([\#1579](https://github.com/cometbft/cometbft/pull/1579))
2 changes: 1 addition & 1 deletion .github/workflows/proto-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.27.1
- uses: bufbuild/buf-setup-action@v1.28.0
- uses: bufbuild/buf-lint-action@v1
with:
input: 'proto'
26 changes: 23 additions & 3 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ The minimum Go version has been bumped to [v1.21][go121].
* The `Mempool` interface was modified on the following methods. Note that this
interface is meant for internal use only, so you should be aware of these
changes only if you happen to call these methods directly.
- `CheckTx`'s signature changed from
* `CheckTx`'s signature changed from
`CheckTx(tx types.Tx, cb func(*abci.ResponseCheckTx), txInfo TxInfo) error`
to `CheckTx(tx types.Tx) (abcicli.ReqRes, error)`.
- The method used to take a callback function `cb` to be applied to the ABCI
* The method used to take a callback function `cb` to be applied to the ABCI
`CheckTx` response. Now `CheckTx` returns the ABCI response of type
`abcicli.ReqRes`, on which the callback must be applied manually. For
example:

```golang
reqRes, err := CheckTx(tx)
cb(reqRes.Response.GetCheckTx())
```
- The second parameter was `txInfo`, which essentially contained information

* The second parameter was `txInfo`, which essentially contained information
about the sender of the transaction. Now that information is stored in the
mempool reactor instead of the data structure, so it is no longer needed in
this method.
Expand All @@ -41,6 +43,24 @@ The minimum Go version has been bumped to [v1.21][go121].
* Removed the `replay` and `replay-console` subcommands
([\#1170](https://github.com/cometbft/cometbft/pull/1170))

### RPC API

* The RPC API is now versioned.
Although invoking methods without specifying the version is still supported for now,
support will be dropped in future releases and users are urged to use the versioned
approach.
For example, instead of `curl localhost:26657/block?height=5`, use
`curl localhost:26657/v1/block?height=5`.

* The `/websocket` endpoint path is no longer configurable in the client or
server. Creating an RPC client now takes the form:

```golang
// The WebSocket endpoint in the following example is assumed to be available
// at http://localhost:26657/v1/websocket
rpcClient, err := client.New("http://localhost:26657/v1")
```

## v0.38.0

This release introduces state machine-breaking changes, as well as substantial changes
Expand Down
2 changes: 1 addition & 1 deletion blocksync/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (bcR *Reactor) RemovePeer(peer p2p.Peer, _ interface{}) {
// respondToPeer loads a block and sends it to the requesting peer,
// if we have it. Otherwise, we'll respond saying we don't have it.
func (bcR *Reactor) respondToPeer(msg *bcproto.BlockRequest, src p2p.Peer) (queued bool) {
block := bcR.store.LoadBlock(msg.Height)
block, _ := bcR.store.LoadBlock(msg.Height)
if block == nil {
bcR.Logger.Info("Peer asking for a block we don't have", "src", src, "height", msg.Height)
return src.TrySend(p2p.Envelope{
Expand Down
2 changes: 1 addition & 1 deletion blocksync/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestNoBlockResponse(t *testing.T) {
assert.Equal(t, maxBlockHeight, reactorPairs[0].reactor.store.Height())

for _, tt := range tests {
block := reactorPairs[1].reactor.store.LoadBlock(tt.height)
block, _ := reactorPairs[1].reactor.store.LoadBlock(tt.height)
if tt.existent {
assert.True(t, block != nil)
} else {
Expand Down
4 changes: 2 additions & 2 deletions cmd/cometbft/commands/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func init() {
DebugCmd.PersistentFlags().StringVar(
&nodeRPCAddr,
flagNodeRPCAddr,
"tcp://localhost:26657",
"the CometBFT node's RPC address (<host>:<port>)",
"tcp://localhost:26657/v1",
"the CometBFT node's RPC address (<host>:<port>) and version",
)

DebugCmd.AddCommand(killCmd)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cometbft/commands/debug/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func dumpCmdHandler(_ *cobra.Command, args []string) error {
}
}

rpc, err := rpchttp.New(nodeRPCAddr, "/websocket")
rpc, err := rpchttp.New(nodeRPCAddr)
if err != nil {
return fmt.Errorf("failed to create new http client: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cometbft/commands/debug/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func killCmdHandler(_ *cobra.Command, args []string) error {
return errors.New("invalid output file")
}

rpc, err := rpchttp.New(nodeRPCAddr, "/websocket")
rpc, err := rpchttp.New(nodeRPCAddr)
if err != nil {
return fmt.Errorf("failed to create new http client: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cometbft/commands/reindex_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func eventReIndex(cmd *cobra.Command, args eventReIndexArgs) error {
case <-cmd.Context().Done():
return fmt.Errorf("event re-index terminated at height %d: %w", height, cmd.Context().Err())
default:
block := args.blockStore.LoadBlock(height)
block, _ := args.blockStore.LoadBlock(height)
if block == nil {
return fmt.Errorf("not able to load block at height %d from the blockstore", height)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/cometbft/commands/reindex_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ func TestReIndexEvent(t *testing.T) {
mockBlockStore.
On("Base").Return(base).
On("Height").Return(height).
On("LoadBlock", base).Return(nil).Once().
On("LoadBlock", base).Return(&types.Block{Data: types.Data{Txs: types.Txs{make(types.Tx, 1)}}}).
On("LoadBlock", height).Return(&types.Block{Data: types.Data{Txs: types.Txs{make(types.Tx, 1)}}})
On("LoadBlock", base).Return(nil, nil).Once().
On("LoadBlock", base).Return(&types.Block{Data: types.Data{Txs: types.Txs{make(types.Tx, 1)}}}, &types.BlockMeta{}).
On("LoadBlock", height).Return(&types.Block{Data: types.Data{Txs: types.Txs{make(types.Tx, 1)}}}, &types.BlockMeta{})

abciResp := &abcitypes.FinalizeBlockResponse{
TxResults: []*abcitypes.ExecTxResult{
Expand Down
21 changes: 21 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,19 @@ type MempoolConfig struct {
// Including space needed by encoding (one varint per transaction).
// XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796
MaxBatchBytes int `mapstructure:"max_batch_bytes"`
// Experimental parameters to limit gossiping txs to up to the specified number of peers.
// We use two independent upper values for persistent peers and for non-persistent peers.
// Unconditional peers are not affected by this feature.
// If we are connected to more than the specified number of persistent peers, only send txs to
// the first ExperimentalMaxGossipConnectionsToPersistentPeers of them. If one of those
// persistent peers disconnects, activate another persistent peer. Similarly for non-persistent
// peers, with an upper limit of ExperimentalMaxGossipConnectionsToNonPersistentPeers.
// If set to 0, the feature is disabled for the corresponding group of peers, that is, the
// number of active connections to that group of peers is not bounded.
// For non-persistent peers, if enabled, a value of 10 is recommended based on experimental
// performance results using the default P2P configuration.
ExperimentalMaxGossipConnectionsToPersistentPeers int `mapstructure:"experimental_max_gossip_connections_to_persistent_peers"`
ExperimentalMaxGossipConnectionsToNonPersistentPeers int `mapstructure:"experimental_max_gossip_connections_to_non_persistent_peers"`
}

// DefaultMempoolConfig returns a default configuration for the CometBFT mempool
Expand All @@ -890,6 +903,8 @@ func DefaultMempoolConfig() *MempoolConfig {
MaxTxsBytes: 1024 * 1024 * 1024, // 1GB
CacheSize: 10000,
MaxTxBytes: 1024 * 1024, // 1MB
ExperimentalMaxGossipConnectionsToNonPersistentPeers: 0,
ExperimentalMaxGossipConnectionsToPersistentPeers: 0,
}
}

Expand Down Expand Up @@ -925,6 +940,12 @@ func (cfg *MempoolConfig) ValidateBasic() error {
if cfg.MaxTxBytes < 0 {
return cmterrors.ErrNegativeField{Field: "max_tx_bytes"}
}
if cfg.ExperimentalMaxGossipConnectionsToPersistentPeers < 0 {
return cmterrors.ErrNegativeField{Field: "experimental_max_gossip_connections_to_persistent_peers"}
}
if cfg.ExperimentalMaxGossipConnectionsToNonPersistentPeers < 0 {
return cmterrors.ErrNegativeField{Field: "experimental_max_gossip_connections_to_non_persistent_peers"}
}
return nil
}

Expand Down
14 changes: 14 additions & 0 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,20 @@ max_tx_bytes = {{ .Mempool.MaxTxBytes }}
# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796
max_batch_bytes = {{ .Mempool.MaxBatchBytes }}

# Experimental parameters to limit gossiping txs to up to the specified number of peers.
# We use two independent upper values for persistent peers and for non-persistent peers.
# Unconditional peers are not affected by this feature.
# If we are connected to more than the specified number of persistent peers, only send txs to
# the first experimental_max_gossip_connections_to_persistent_peers of them. If one of those
# persistent peers disconnects, activate another persistent peer. Similarly for non-persistent
# peers, with an upper limit of experimental_max_gossip_connections_to_non_persistent_peers.
# If set to 0, the feature is disabled for the corresponding group of peers, that is, the
# number of active connections to that group of peers is not bounded.
# For non-persistent peers, if enabled, a value of 10 is recommended based on experimental
# performance results using the default P2P configuration.
experimental_max_gossip_connections_to_persistent_peers = {{ .Mempool.ExperimentalMaxGossipConnectionsToPersistentPeers }}
experimental_max_gossip_connections_to_non_persistent_peers = {{ .Mempool.ExperimentalMaxGossipConnectionsToNonPersistentPeers }}

#######################################################
### State Sync Configuration Options ###
#######################################################
Expand Down
4 changes: 2 additions & 2 deletions consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ func TestReactorRecordsVotesAndBlockParts(t *testing.T) {
// Get peer state
ps := peer.Get(types.PeerStateKey).(*PeerState)

assert.Equal(t, true, ps.VotesSent() > 0, "number of votes sent should have increased")
assert.Equal(t, true, ps.BlockPartsSent() > 0, "number of votes sent should have increased")
assert.Greater(t, ps.VotesSent(), 0, "number of votes sent should have increased")
assert.Greater(t, ps.BlockPartsSent(), 0, "number of votes sent should have increased")
}

//-------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions consensus/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (h *Handshaker) replayBlocks(
}

h.logger.Info("Applying block", "height", i)
block := h.store.LoadBlock(i)
block, _ := h.store.LoadBlock(i)
// Extra check to ensure the app was not changed in a way it shouldn't have.
if len(appHash) > 0 {
assertAppHashEqualsOneFromBlock(appHash, block)
Expand Down Expand Up @@ -503,8 +503,7 @@ func (h *Handshaker) replayBlocks(

// ApplyBlock on the proxyApp with the last block.
func (h *Handshaker) replayBlock(state sm.State, height int64, proxyApp proxy.AppConnConsensus) (sm.State, error) {
block := h.store.LoadBlock(height)
meta := h.store.LoadBlockMeta(height)
block, meta := h.store.LoadBlock(height)

// Use stubs for both mempool and evidence pool since no transactions nor
// evidence are needed here - block already exists.
Expand Down
21 changes: 13 additions & 8 deletions consensus/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ func setupChainWithChangingValidators(t *testing.T, name string, nBlocks int) (*
chain := []*types.Block{}
extCommits := []*types.ExtendedCommit{}
for i := 1; i <= nBlocks; i++ {
chain = append(chain, css[0].blockStore.LoadBlock(int64(i)))
block, _ := css[0].blockStore.LoadBlock(int64(i))
chain = append(chain, block)
extCommits = append(extCommits, css[0].blockStore.LoadBlockExtendedCommit(int64(i)))
}
return config, chain, extCommits, genesisState
Expand Down Expand Up @@ -1183,13 +1184,17 @@ func newMockBlockStore(t *testing.T, config *cfg.Config, params types.ConsensusP
}
}

func (bs *mockBlockStore) Height() int64 { return int64(len(bs.chain)) }
func (bs *mockBlockStore) Base() int64 { return bs.base }
func (bs *mockBlockStore) Size() int64 { return bs.Height() - bs.Base() + 1 }
func (bs *mockBlockStore) LoadBaseMeta() *types.BlockMeta { return bs.LoadBlockMeta(bs.base) }
func (bs *mockBlockStore) LoadBlock(height int64) *types.Block { return bs.chain[height-1] }
func (bs *mockBlockStore) LoadBlockByHash([]byte) *types.Block {
return bs.chain[int64(len(bs.chain))-1]
func (bs *mockBlockStore) Height() int64 { return int64(len(bs.chain)) }
func (bs *mockBlockStore) Base() int64 { return bs.base }
func (bs *mockBlockStore) Size() int64 { return bs.Height() - bs.Base() + 1 }
func (bs *mockBlockStore) LoadBaseMeta() *types.BlockMeta { return bs.LoadBlockMeta(bs.base) }
func (bs *mockBlockStore) LoadBlock(height int64) (*types.Block, *types.BlockMeta) {
return bs.chain[height-1], bs.LoadBlockMeta(height)
}

func (bs *mockBlockStore) LoadBlockByHash([]byte) (*types.Block, *types.BlockMeta) {
height := int64(len(bs.chain))
return bs.chain[height-1], bs.LoadBlockMeta(height)
}
func (bs *mockBlockStore) LoadBlockMetaByHash([]byte) *types.BlockMeta { return nil }
func (bs *mockBlockStore) LoadBlockMeta(height int64) *types.BlockMeta {
Expand Down
1 change: 1 addition & 0 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ numbering our ADRs from 100 onwards.
### Rejected

- [ADR-100: Data companion push API](./adr-100-data-companion-push-api.md)
- [ADR-110: Remote mempool](./adr-110-remote-mempool.md)
Loading
0