Merge branch 'feature/abci++vef' into cal/finalize-block

This commit is contained in:
Callum Waters
2022-10-26 11:59:39 +02:00
146 changed files with 4341 additions and 4028 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ To replace the built-in p2p.Reactor, use the CustomReactors option:
dbProvider,
metricsProvider,
logger,
CustomReactors(map[string]p2p.Reactor{"BLOCKCHAIN": customBlockchainReactor}),
CustomReactors(map[string]p2p.Reactor{"BLOCKSYNC": customBlocksyncReactor}),
)
The list of existing reactors can be found in CustomReactors documentation.
+18 -10
View File
@@ -146,7 +146,7 @@ type blockSyncReactor interface {
// result in replacing it with the custom one.
//
// - MEMPOOL
// - BLOCKCHAIN
// - BLOCKSYNC
// - CONSENSUS
// - EVIDENCE
// - PEX
@@ -303,7 +303,7 @@ func createAndStartIndexerService(
blockIndexer = &blockidxnull.BlockerIndexer{}
}
indexerService := txindex.NewIndexerService(txIndexer, blockIndexer, eventBus)
indexerService := txindex.NewIndexerService(txIndexer, blockIndexer, eventBus, false)
indexerService.SetLogger(logger.With("module", "txindex"))
if err := indexerService.Start(); err != nil {
@@ -335,8 +335,10 @@ func logNodeStartupInfo(state sm.State, pubKey crypto.PubKey, logger, consensusL
// Log the version info.
logger.Info("Version info",
"tendermint_version", version.TMCoreSemVer,
"abci", version.ABCISemVer,
"block", version.BlockProtocol,
"p2p", version.P2PProtocol,
"commit_hash", version.TMGitCommitHash,
)
// If the state and software differ in block version, at least log it.
@@ -439,7 +441,7 @@ func createEvidenceReactor(config *cfg.Config, dbProvider DBProvider,
return evidenceReactor, evidencePool, nil
}
func createBlockchainReactor(config *cfg.Config,
func createBlocksyncReactor(config *cfg.Config,
state sm.State,
blockExec *sm.BlockExecutor,
blockStore *store.BlockStore,
@@ -455,7 +457,7 @@ func createBlockchainReactor(config *cfg.Config,
return nil, fmt.Errorf("unknown fastsync version %s", config.BlockSync.Version)
}
bcReactor.SetLogger(logger.With("module", "blockchain"))
bcReactor.SetLogger(logger.With("module", "blocksync"))
return bcReactor, nil
}
@@ -582,7 +584,7 @@ func createSwitch(config *cfg.Config,
)
sw.SetLogger(p2pLogger)
sw.AddReactor("MEMPOOL", mempoolReactor)
sw.AddReactor("BLOCKCHAIN", bcReactor)
sw.AddReactor("BLOCKSYNC", bcReactor)
sw.AddReactor("CONSENSUS", consensusReactor)
sw.AddReactor("EVIDENCE", evidenceReactor)
sw.AddReactor("STATESYNC", stateSyncReactor)
@@ -801,20 +803,21 @@ func NewNode(config *cfg.Config,
return nil, err
}
// make block executor for consensus and blockchain reactors to execute blocks
// make block executor for consensus and blocksync reactors to execute blocks
blockExec := sm.NewBlockExecutor(
stateStore,
logger.With("module", "state"),
proxyApp.Consensus(),
mempool,
evidencePool,
blockStore,
sm.BlockExecutorWithMetrics(smMetrics),
)
// Make BlockchainReactor. Don't start block sync if we're doing a state sync first.
bcReactor, err := createBlockchainReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger)
// 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)
if err != nil {
return nil, fmt.Errorf("could not create blockchain reactor: %w", err)
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.
@@ -987,7 +990,7 @@ func (n *Node) OnStart() error {
if n.stateSync {
bcR, ok := n.bcReactor.(blockSyncReactor)
if !ok {
return fmt.Errorf("this blockchain reactor does not support switching from state sync")
return fmt.Errorf("this blocksync reactor does not support switching from state sync")
}
err := startStateSync(n.stateSyncReactor, bcR, n.consensusReactor, n.stateSyncProvider,
n.config.StateSync, n.config.BlockSyncMode, n.stateStore, n.blockStore, n.stateSyncGenesis)
@@ -1384,6 +1387,11 @@ func LoadStateFromDBOrGenesisDocProvider(
if err != nil {
return sm.State{}, nil, err
}
err = genDoc.ValidateAndComplete()
if err != nil {
return sm.State{}, nil, fmt.Errorf("error in genesis doc: %w", err)
}
// save genesis doc to prevent a certain class of user errors (e.g. when it
// was changed, accidentally or not). Also good for audit trail.
if err := saveGenesisDoc(stateDB, genDoc); err != nil {
+20 -15
View File
@@ -18,6 +18,7 @@ import (
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/evidence"
"github.com/tendermint/tendermint/internal/test"
"github.com/tendermint/tendermint/libs/log"
tmrand "github.com/tendermint/tendermint/libs/rand"
mempl "github.com/tendermint/tendermint/mempool"
@@ -35,7 +36,7 @@ import (
)
func TestNodeStartStop(t *testing.T) {
config := cfg.ResetTestRoot("node_node_test")
config := test.ResetTestRoot("node_node_test")
defer os.RemoveAll(config.RootDir)
// create & start node
@@ -97,7 +98,7 @@ func TestSplitAndTrimEmpty(t *testing.T) {
}
func TestNodeDelayedStart(t *testing.T) {
config := cfg.ResetTestRoot("node_delayed_start_test")
config := test.ResetTestRoot("node_delayed_start_test")
defer os.RemoveAll(config.RootDir)
now := tmtime.Now()
@@ -115,7 +116,7 @@ func TestNodeDelayedStart(t *testing.T) {
}
func TestNodeSetAppVersion(t *testing.T) {
config := cfg.ResetTestRoot("node_app_version_test")
config := test.ResetTestRoot("node_app_version_test")
defer os.RemoveAll(config.RootDir)
// create & start node
@@ -137,7 +138,7 @@ func TestNodeSetAppVersion(t *testing.T) {
func TestNodeSetPrivValTCP(t *testing.T) {
addr := "tcp://" + testFreeAddr(t)
config := cfg.ResetTestRoot("node_priv_val_tcp_test")
config := test.ResetTestRoot("node_priv_val_tcp_test")
defer os.RemoveAll(config.RootDir)
config.BaseConfig.PrivValidatorListenAddr = addr
@@ -150,7 +151,7 @@ func TestNodeSetPrivValTCP(t *testing.T) {
signerServer := privval.NewSignerServer(
dialerEndpoint,
config.ChainID(),
test.DefaultTestChainID,
types.NewMockPV(),
)
@@ -171,7 +172,7 @@ func TestNodeSetPrivValTCP(t *testing.T) {
func TestPrivValidatorListenAddrNoProtocol(t *testing.T) {
addrNoPrefix := testFreeAddr(t)
config := cfg.ResetTestRoot("node_priv_val_tcp_test")
config := test.ResetTestRoot("node_priv_val_tcp_test")
defer os.RemoveAll(config.RootDir)
config.BaseConfig.PrivValidatorListenAddr = addrNoPrefix
@@ -183,7 +184,7 @@ func TestNodeSetPrivValIPC(t *testing.T) {
tmpfile := "/tmp/kms." + tmrand.Str(6) + ".sock"
defer os.Remove(tmpfile) // clean up
config := cfg.ResetTestRoot("node_priv_val_tcp_test")
config := test.ResetTestRoot("node_priv_val_tcp_test")
defer os.RemoveAll(config.RootDir)
config.BaseConfig.PrivValidatorListenAddr = "unix://" + tmpfile
@@ -196,7 +197,7 @@ func TestNodeSetPrivValIPC(t *testing.T) {
pvsc := privval.NewSignerServer(
dialerEndpoint,
config.ChainID(),
test.DefaultTestChainID,
types.NewMockPV(),
)
@@ -223,7 +224,7 @@ func testFreeAddr(t *testing.T) string {
// create a proposal block using real and full
// mempool and evidence pool and validate it.
func TestCreateProposalBlock(t *testing.T) {
config := cfg.ResetTestRoot("node_create_proposal")
config := test.ResetTestRoot("node_create_proposal")
defer os.RemoveAll(config.RootDir)
cc := proxy.NewLocalClientCreator(kvstore.NewInMemoryApplication())
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
@@ -305,6 +306,7 @@ func TestCreateProposalBlock(t *testing.T) {
proxyApp.Consensus(),
mempool,
evidencePool,
blockStore,
)
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
@@ -334,7 +336,7 @@ func TestCreateProposalBlock(t *testing.T) {
}
func TestMaxProposalBlockSize(t *testing.T) {
config := cfg.ResetTestRoot("node_create_proposal")
config := test.ResetTestRoot("node_create_proposal")
defer os.RemoveAll(config.RootDir)
cc := proxy.NewLocalClientCreator(kvstore.NewInMemoryApplication())
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
@@ -376,6 +378,8 @@ func TestMaxProposalBlockSize(t *testing.T) {
)
}
blockStore := store.NewBlockStore(dbm.NewMemDB())
// fill the mempool with one txs just below the maximum size
txLength := int(types.MaxDataBytesNoEvidence(maxBytes, 1))
tx := tmrand.Bytes(txLength - 4) // to account for the varint
@@ -388,6 +392,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
proxyApp.Consensus(),
mempool,
sm.EmptyEvidencePool{},
blockStore,
)
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
@@ -410,7 +415,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
}
func TestNodeNewNodeCustomReactors(t *testing.T) {
config := cfg.ResetTestRoot("node_new_node_custom_reactors_test")
config := test.ResetTestRoot("node_new_node_custom_reactors_test")
defer os.RemoveAll(config.RootDir)
cr := p2pmock.NewReactor()
@@ -422,7 +427,7 @@ func TestNodeNewNodeCustomReactors(t *testing.T) {
RecvMessageCapacity: 100,
},
}
customBlockchainReactor := p2pmock.NewReactor()
customBlocksyncReactor := p2pmock.NewReactor()
nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
require.NoError(t, err)
@@ -435,7 +440,7 @@ func TestNodeNewNodeCustomReactors(t *testing.T) {
DefaultDBProvider,
DefaultMetricsProvider(config.Instrumentation),
log.TestingLogger(),
CustomReactors(map[string]p2p.Reactor{"FOO": cr, "BLOCKCHAIN": customBlockchainReactor}),
CustomReactors(map[string]p2p.Reactor{"FOO": cr, "BLOCKSYNC": customBlocksyncReactor}),
)
require.NoError(t, err)
@@ -446,8 +451,8 @@ func TestNodeNewNodeCustomReactors(t *testing.T) {
assert.True(t, cr.IsRunning())
assert.Equal(t, cr, n.Switch().Reactor("FOO"))
assert.True(t, customBlockchainReactor.IsRunning())
assert.Equal(t, customBlockchainReactor, n.Switch().Reactor("BLOCKCHAIN"))
assert.True(t, customBlocksyncReactor.IsRunning())
assert.Equal(t, customBlocksyncReactor, n.Switch().Reactor("BLOCKSYNC"))
channels := n.NodeInfo().(p2p.DefaultNodeInfo).Channels
assert.Contains(t, channels, mempl.MempoolChannel)