From 8d26460f9d3398fc2acbc8f59b3c7e66b83518ee Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Thu, 6 Oct 2022 10:44:12 +0200 Subject: [PATCH] rename blockchain to blocksync in certain areas (#9512) --- blocksync/msgs_test.go | 2 +- blocksync/reactor.go | 2 +- blocksync/reactor_test.go | 12 ++++++------ node/doc.go | 2 +- node/node.go | 18 +++++++++--------- node/node_test.go | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/blocksync/msgs_test.go b/blocksync/msgs_test.go index 46983a2a1a9..d9d1d1066c2 100644 --- a/blocksync/msgs_test.go +++ b/blocksync/msgs_test.go @@ -80,7 +80,7 @@ func TestBcStatusResponseMessageValidateBasic(t *testing.T) { } //nolint:lll // ignore line length in tests -func TestBlockchainMessageVectors(t *testing.T) { +func TestBlocksyncMessageVectors(t *testing.T) { block := types.MakeBlock(int64(3), []types.Tx{types.Tx("Hello World")}, nil, nil) block.Version.Block = 11 // overwrite updated protocol version diff --git a/blocksync/reactor.go b/blocksync/reactor.go index dffd36d546a..09dd2ef90fc 100644 --- a/blocksync/reactor.go +++ b/blocksync/reactor.go @@ -30,7 +30,7 @@ const ( ) type consensusReactor interface { - // for when we switch from blockchain reactor and block sync to + // for when we switch from blocksync reactor and block sync to // the consensus machine SwitchToConsensus(state sm.State, skipWAL bool) } diff --git a/blocksync/reactor_test.go b/blocksync/reactor_test.go index 202fe283291..a88e0591254 100644 --- a/blocksync/reactor_test.go +++ b/blocksync/reactor_test.go @@ -146,13 +146,13 @@ func newReactor( } bcReactor := NewReactor(state.Copy(), blockExec, blockStore, fastSync) - bcReactor.SetLogger(logger.With("module", "blockchain")) + bcReactor.SetLogger(logger.With("module", "blocksync")) return ReactorPair{bcReactor, proxyApp} } func TestNoBlockResponse(t *testing.T) { - config = test.ResetTestRoot("blockchain_reactor_test") + config = test.ResetTestRoot("blocksync_reactor_test") defer os.RemoveAll(config.RootDir) genDoc, privVals := randGenesisDoc(1, false, 30) @@ -164,7 +164,7 @@ func TestNoBlockResponse(t *testing.T) { reactorPairs[1] = newReactor(t, log.TestingLogger(), genDoc, privVals, 0) p2p.MakeConnectedSwitches(config.P2P, 2, func(i int, s *p2p.Switch) *p2p.Switch { - s.AddReactor("BLOCKCHAIN", reactorPairs[i].reactor) + s.AddReactor("BLOCKSYNC", reactorPairs[i].reactor) return s }, p2p.Connect2Switches) @@ -214,7 +214,7 @@ func TestNoBlockResponse(t *testing.T) { // Alternatively we could actually dial a TCP conn but // that seems extreme. func TestBadBlockStopsPeer(t *testing.T) { - config = test.ResetTestRoot("blockchain_reactor_test") + config = test.ResetTestRoot("blocksync_reactor_test") defer os.RemoveAll(config.RootDir) genDoc, privVals := randGenesisDoc(1, false, 30) @@ -239,7 +239,7 @@ func TestBadBlockStopsPeer(t *testing.T) { reactorPairs[3] = newReactor(t, log.TestingLogger(), genDoc, privVals, 0) switches := p2p.MakeConnectedSwitches(config.P2P, 4, func(i int, s *p2p.Switch) *p2p.Switch { - s.AddReactor("BLOCKCHAIN", reactorPairs[i].reactor) + s.AddReactor("BLOCKSYNC", reactorPairs[i].reactor) return s }, p2p.Connect2Switches) @@ -278,7 +278,7 @@ func TestBadBlockStopsPeer(t *testing.T) { reactorPairs = append(reactorPairs, lastReactorPair) switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1, func(i int, s *p2p.Switch) *p2p.Switch { - s.AddReactor("BLOCKCHAIN", reactorPairs[len(reactorPairs)-1].reactor) + s.AddReactor("BLOCKSYNC", reactorPairs[len(reactorPairs)-1].reactor) return s }, p2p.Connect2Switches)...) diff --git a/node/doc.go b/node/doc.go index 3a145c573ac..3b4e9b71b17 100644 --- a/node/doc.go +++ b/node/doc.go @@ -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. diff --git a/node/node.go b/node/node.go index ac0eca873f3..ddba2f7a6ae 100644 --- a/node/node.go +++ b/node/node.go @@ -146,7 +146,7 @@ type blockSyncReactor interface { // result in replacing it with the custom one. // // - MEMPOOL -// - BLOCKCHAIN +// - BLOCKSYNC // - CONSENSUS // - EVIDENCE // - PEX @@ -441,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, @@ -457,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 } @@ -584,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) @@ -803,7 +803,7 @@ 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"), @@ -814,10 +814,10 @@ func NewNode(config *cfg.Config, 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. @@ -990,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) diff --git a/node/node_test.go b/node/node_test.go index 84baf9c56f6..ee23892b1cd 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -427,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) @@ -440,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) @@ -451,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)