Skip to content

Commit 61ae4ef

Browse files
committed
code cleanup, turn off recheck
1 parent d17ec62 commit 61ae4ef

File tree

8 files changed

+33
-99
lines changed

8 files changed

+33
-99
lines changed

config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func DefaultConfig() *Config {
8282
P2P: DefaultP2PConfig(),
8383
Mempool: DefaultMempoolConfig(),
8484
StateSync: DefaultStateSyncConfig(),
85-
Consensus: DefaultConsensusConfig(),
85+
Consensus: DefaultConsensusConfig().AB,
8686
TxIndex: DefaultTxIndexConfig(),
8787
Instrumentation: DefaultInstrumentationConfig(),
8888
PrivValidator: DefaultPrivValidatorConfig(),

internal/consensus/metrics.gen.go

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/consensus/metrics.go

-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ type Metrics struct {
6969
// Number of block parts transmitted by each peer.
7070
BlockParts metrics.Counter `metrics_labels:"peer_id"`
7171

72-
// Number of tx requests transmitted by each peer.
73-
TxsSent metrics.Counter `metrics_labels:"peer_id"`
74-
7572
// Histogram of durations for each step in the consensus protocol.
7673
StepDuration metrics.Histogram `metrics_labels:"step" metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"`
7774
stepStart time.Time

internal/consensus/msgs.go

-47
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func init() {
3232
jsontypes.MustRegister(&HasVoteMessage{})
3333
jsontypes.MustRegister(&VoteSetMaj23Message{})
3434
jsontypes.MustRegister(&VoteSetBitsMessage{})
35-
jsontypes.MustRegister(&TxRequestMessage{})
3635
}
3736

3837
// NewRoundStepMessage is sent for every step taken in the ConsensusState.
@@ -186,25 +185,6 @@ func (m *ProposalPOLMessage) String() string {
186185
return fmt.Sprintf("[ProposalPOL H:%v POLR:%v POL:%v]", m.Height, m.ProposalPOLRound, m.ProposalPOL)
187186
}
188187

189-
// TxRequestMessage is sent when a set of Txs are requested
190-
type TxRequestMessage struct {
191-
Height int64 `json:",string"`
192-
Round int32
193-
TxKeys []*types.TxKey
194-
}
195-
196-
func (*TxRequestMessage) TypeTag() string { return "tendermint/TxRequest" }
197-
198-
func (m *TxRequestMessage) ValidateBasic() error {
199-
if m.Height < 0 {
200-
return errors.New("negative Height")
201-
}
202-
if m.Round < 0 {
203-
return errors.New("negative Round")
204-
}
205-
return nil
206-
}
207-
208188
// BlockPartMessage is sent when gossipping a piece of the proposed block.
209189
type BlockPartMessage struct {
210190
Height int64 `json:",string"`
@@ -476,22 +456,6 @@ func MsgToProto(msg Message) (*tmcons.Message, error) {
476456
Sum: vsb,
477457
}
478458

479-
case *TxRequestMessage:
480-
var txKeys []*tmproto.TxKey
481-
for _, txKey := range msg.TxKeys {
482-
key := txKey.ToProto()
483-
txKeys = append(txKeys, key)
484-
}
485-
pb = tmcons.Message{
486-
Sum: &tmcons.Message_TxRequest{
487-
TxRequest: &tmcons.TxRequest{
488-
Height: msg.Height,
489-
Round: msg.Round,
490-
TxKeys: txKeys,
491-
},
492-
},
493-
}
494-
495459
default:
496460
return nil, fmt.Errorf("consensus: message not recognized: %T", msg)
497461
}
@@ -616,17 +580,6 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) {
616580
BlockID: *bi,
617581
Votes: bits,
618582
}
619-
case *tmcons.Message_TxRequest:
620-
var txKeys []*types.TxKey
621-
for _, txKey := range msg.TxRequest.TxKeys {
622-
key, _ := types.TxKeyFromProto(txKey)
623-
txKeys = append(txKeys, &key)
624-
}
625-
pb = &TxRequestMessage{
626-
Height: msg.TxRequest.Height,
627-
Round: msg.TxRequest.Round,
628-
TxKeys: txKeys,
629-
}
630583
default:
631584
return nil, fmt.Errorf("consensus: message not recognized: %T", msg)
632585
}

internal/consensus/reactor.go

-23
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
protomem "github.com/tendermint/tendermint/proto/tendermint/mempool"
87
"runtime/debug"
98
"sync"
109
"time"
@@ -1194,28 +1193,6 @@ func (r *Reactor) handleDataMessage(ctx context.Context, envelope *p2p.Envelope,
11941193
case <-ctx.Done():
11951194
return ctx.Err()
11961195
}
1197-
case *tmcons.TxRequest:
1198-
trMsg := msgI.(*TxRequestMessage)
1199-
logger.Info("PSULOG: Received request for Txs", "txKeys", trMsg.TxKeys)
1200-
var txKeys []types.TxKey
1201-
for _, txKey := range trMsg.TxKeys {
1202-
txKeys = append(txKeys, *txKey)
1203-
}
1204-
txs := r.state.blockExec.GetTxsForKeys(txKeys)
1205-
r.Metrics.TxsSent.With("peer_id", string(envelope.From)).Add(1)
1206-
// TODO(psu): send all txs in 1 msg
1207-
for _, tx := range txs {
1208-
//logger.Info("PSULOG: Sending mempool ch for tx", "tx", tx)
1209-
if err := r.channels.mempoolCh.Send(ctx, p2p.Envelope{
1210-
To: ps.peerID,
1211-
Message: &protomem.Txs{
1212-
Txs: [][]byte{tx},
1213-
},
1214-
}); err != nil {
1215-
logger.Error("Unable to send tx for tx request", "peerId", ps.peerID, "txKeys", txKeys)
1216-
}
1217-
}
1218-
12191196
default:
12201197
return fmt.Errorf("received unknown message on DataChannel: %T", msg)
12211198
}

internal/consensus/state.go

+11-18
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,14 @@ func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) {
10061006
// TODO should we handle context cancels here?
10071007
}
10081008
}
1009+
func (cs *State) fsyncAndCompleteProposal(ctx context.Context, fsyncUponCompletion bool, height int64, span otrace.Span) {
1010+
if fsyncUponCompletion {
1011+
if err := cs.wal.FlushAndSync(); err != nil { // fsync
1012+
panic("error flushing wal after receiving all block parts")
1013+
}
1014+
}
1015+
cs.handleCompleteProposal(ctx, height, span)
1016+
}
10091017

10101018
// state transitions on complete-proposal, 2/3-any, 2/3-one
10111019
func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion bool) {
@@ -1032,18 +1040,12 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
10321040
created := cs.tryCreateProposalBlock(msg.Proposal.Height, msg.Proposal.Round, msg.Proposal.Header, msg.Proposal.LastCommit, msg.Proposal.Evidence, msg.Proposal.ProposerAddress)
10331041
cs.metrics.ProposalBlockCreatedOnPropose.With("success", strconv.FormatBool(created)).Add(1)
10341042
if created {
1035-
if fsyncUponCompletion {
1036-
if err := cs.wal.FlushAndSync(); err != nil { // fsync
1037-
panic("error flushing wal after receiving all block parts")
1038-
}
1039-
}
1040-
cs.handleCompleteProposal(ctx, msg.Proposal.Height, span)
1041-
1043+
cs.fsyncAndCompleteProposal(ctx, fsyncUponCompletion, msg.Proposal.Height, span)
10421044
}
10431045
}
10441046

10451047
case *BlockPartMessage:
1046-
spanCtx, span := cs.tracer.Start(cs.getTracingCtx(ctx), "cs.state.handleBlockPartMsg")
1048+
_, span := cs.tracer.Start(cs.getTracingCtx(ctx), "cs.state.handleBlockPartMsg")
10471049
span.SetAttributes(attribute.Int("round", int(msg.Round)))
10481050
defer span.End()
10491051

@@ -1065,16 +1067,7 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
10651067

10661068
cs.mtx.Lock()
10671069
if added && cs.ProposalBlockParts.IsComplete() {
1068-
if fsyncUponCompletion {
1069-
_, fsyncSpan := cs.tracer.Start(spanCtx, "cs.state.handleBlockPartMsg.fsync")
1070-
if err := cs.wal.FlushAndSync(); err != nil { // fsync
1071-
panic("error flushing wal after receiving all block parts")
1072-
}
1073-
fsyncSpan.End()
1074-
}
1075-
cs.handleCompleteProposal(ctx, msg.Height, span)
1076-
} else {
1077-
//cs.logger.Info("PSULOG - did not complete proposal", "added", added, "proposalblockparts", cs.ProposalBlockParts, "proposal", cs.Proposal)
1070+
cs.fsyncAndCompleteProposal(ctx, fsyncUponCompletion, msg.Height, span)
10781071
}
10791072
if added {
10801073
select {

types/mempool.go

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ func (txKey *TxKey) ToProto() *tmproto.TxKey {
2828
return tp
2929
}
3030

31+
func TxKeysListToProto(txKeys []*TxKey) []*tmproto.TxKey {
32+
var tps []*tmproto.TxKey
33+
for _, txKey := range txKeys {
34+
tps = append(tps, txKey.ToProto())
35+
}
36+
return tps
37+
}
38+
3139
// TxKeyFromProto takes a protobuf representation of TxKey &
3240
// returns the native type.
3341
func TxKeyFromProto(dp *tmproto.TxKey) (TxKey, error) {
@@ -42,6 +50,18 @@ func TxKeyFromProto(dp *tmproto.TxKey) (TxKey, error) {
4250
return txBzs, nil
4351
}
4452

53+
func TxKeysListFromProto(dps []*tmproto.TxKey) ([]TxKey, error) {
54+
var txKeys []TxKey
55+
for _, txKey := range dps {
56+
txKey, err := TxKeyFromProto(txKey)
57+
if err != nil {
58+
return nil, err
59+
}
60+
txKeys = append(txKeys, txKey)
61+
}
62+
return txKeys, nil
63+
}
64+
4565
// ErrTxTooLarge defines an error when a transaction is too big to be sent in a
4666
// message to other peers.
4767
type ErrTxTooLarge struct {

types/params.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func DefaultABCIParams() ABCIParams {
199199
// When set to 0, vote extensions are not required.
200200
VoteExtensionsEnableHeight: 0,
201201
// When true, run CheckTx on each transaction in the mempool after each height.
202-
RecheckTx: true,
202+
RecheckTx: false,
203203
}
204204
}
205205

0 commit comments

Comments
 (0)