Skip to content

Commit 4d99301

Browse files
committed
lower logging, impl tx req
1 parent 92116de commit 4d99301

File tree

5 files changed

+51
-35
lines changed

5 files changed

+51
-35
lines changed

internal/consensus/msgs.go

+16
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,22 @@ func MsgToProto(msg Message) (*tmcons.Message, error) {
476476
Sum: vsb,
477477
}
478478

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+
479495
default:
480496
return nil, fmt.Errorf("consensus: message not recognized: %T", msg)
481497
}

internal/consensus/peer_state.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (ps *PeerState) GetHeight() int64 {
109109

110110
// SetHasProposal sets the given proposal as known for the peer.
111111
func (ps *PeerState) SetHasProposal(proposal *types.Proposal) {
112-
ps.logger.Info("PSULOG - SetHasProposal", "proposal", proposal, "ps.PRS.Proposal", ps.PRS.Proposal)
112+
//ps.logger.Info("PSULOG - SetHasProposal", "proposal", proposal, "ps.PRS.Proposal", ps.PRS.Proposal)
113113
ps.mtx.Lock()
114114
defer ps.mtx.Unlock()
115115

internal/consensus/reactor.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ OUTER_LOOP:
568568
//logger.Info("PSULOG - OUTERLOOP - finished sending block parts, continuing back to OUTERLOOP")
569569
continue OUTER_LOOP
570570
} else {
571-
logger.Info("PSULOG - OUTERLOOP - sending block part !! NOT OK", "rs bit array", rs.ProposalBlockParts.BitArray())
571+
//logger.Info("PSULOG - OUTERLOOP - sending block part !! NOT OK", "rs bit array", rs.ProposalBlockParts.BitArray())
572572
}
573573
}
574574

@@ -1146,7 +1146,7 @@ func (r *Reactor) handleDataMessage(ctx context.Context, envelope *p2p.Envelope,
11461146

11471147
switch msg := envelope.Message.(type) {
11481148
case *tmcons.Proposal:
1149-
logger.Info("PSULOG - received proposal", "msg", msgI, "msg as proposal", msgI.(*ProposalMessage))
1149+
//logger.Info("PSULOG - received proposal", "msg", msgI, "msg as proposal", msgI.(*ProposalMessage))
11501150
pMsg := msgI.(*ProposalMessage)
11511151

11521152
ps.SetHasProposal(pMsg.Proposal)
@@ -1156,7 +1156,7 @@ func (r *Reactor) handleDataMessage(ctx context.Context, envelope *p2p.Envelope,
11561156
// Check if we there are missing txs and request if necessary
11571157
if r.state.config.GossipTransactionHashOnly {
11581158
missingTxKeys := r.state.blockExec.GetMissingTxs(proposalTxs)
1159-
logger.Info("PSULOG - checking for missing keys", "proposal height", pMsg.Proposal.Height, "proposal round", pMsg.Proposal.Round, "txkeys", pMsg.Proposal.TxKeys, "missingTxKeys", missingTxKeys)
1159+
//logger.Info("PSULOG - checking for missing keys", "proposal height", pMsg.Proposal.Height, "proposal round", pMsg.Proposal.Round, "txkeys", pMsg.Proposal.TxKeys, "missingTxKeys", missingTxKeys)
11601160
if len(missingTxKeys) > 0 {
11611161
var txKeys []*tmproto.TxKey
11621162
for _, txKey := range missingTxKeys {
@@ -1184,7 +1184,7 @@ func (r *Reactor) handleDataMessage(ctx context.Context, envelope *p2p.Envelope,
11841184
ps.ApplyProposalPOLMessage(msgI.(*ProposalPOLMessage))
11851185
case *tmcons.BlockPart:
11861186
bpMsg := msgI.(*BlockPartMessage)
1187-
logger.Info("Received block part message", "blockpartmesage", bpMsg)
1187+
//logger.Info("Received block part message", "blockpartmesage", bpMsg)
11881188

11891189
ps.SetHasProposalBlockPart(bpMsg.Height, bpMsg.Round, int(bpMsg.Part.Index))
11901190
r.Metrics.BlockParts.With("peer_id", string(envelope.From)).Add(1)
@@ -1204,7 +1204,7 @@ func (r *Reactor) handleDataMessage(ctx context.Context, envelope *p2p.Envelope,
12041204
txs := r.state.blockExec.GetTxsForKeys(txKeys)
12051205
// TODO(psu): send all txs in 1 msg
12061206
for _, tx := range txs {
1207-
logger.Info("PSULOG: Sending mempool ch for tx", "tx", tx)
1207+
//logger.Info("PSULOG: Sending mempool ch for tx", "tx", tx)
12081208
if err := r.channels.mempoolCh.Send(ctx, p2p.Envelope{
12091209
To: ps.peerID,
12101210
Message: &protomem.Txs{

internal/consensus/state.go

+27-27
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
10191019

10201020
switch msg := msg.(type) {
10211021
case *ProposalMessage:
1022-
cs.logger.Info("PSULOG - state handleMsg received proposal", "proposal", msg, "cs.ProposalBlockParts", cs.ProposalBlockParts)
1022+
//cs.logger.Info("PSULOG - state handleMsg received proposal", "proposal", msg, "cs.ProposalBlockParts", cs.ProposalBlockParts)
10231023
_, span := cs.tracer.Start(cs.getTracingCtx(ctx), "cs.state.handleProposalMsg")
10241024
span.SetAttributes(attribute.Int("round", int(msg.Proposal.Round)))
10251025
defer span.End()
@@ -1045,7 +1045,7 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
10451045
span.SetAttributes(attribute.Int("round", int(msg.Round)))
10461046
defer span.End()
10471047

1048-
cs.logger.Info("PSULOG - received block part message", "error", err, "added", added, "cs.ProposalBlockParts", cs.ProposalBlockParts, "cs.Proposal", cs.Proposal)
1048+
//cs.logger.Info("PSULOG - received block part message", "error", err, "added", added, "cs.ProposalBlockParts", cs.ProposalBlockParts, "cs.Proposal", cs.Proposal)
10491049
// if the proposal is complete, we'll enterPrevote or tryFinalizeCommit
10501050
added, err = cs.addProposalBlockPart(msg, peerID)
10511051

@@ -1089,7 +1089,7 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
10891089
}
10901090
cs.handleCompleteProposal(ctx, msg.Height, span)
10911091
} else {
1092-
cs.logger.Info("PSULOG - did not complete proposal", "added", added, "proposalblockparts", cs.ProposalBlockParts, "proposal", cs.Proposal)
1092+
//cs.logger.Info("PSULOG - did not complete proposal", "added", added, "proposalblockparts", cs.ProposalBlockParts, "proposal", cs.Proposal)
10931093
}
10941094
if added {
10951095
select {
@@ -1108,7 +1108,7 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
11081108
)
11091109
err = nil
11101110
} else if err != nil {
1111-
cs.logger.Info("PSULOG - added block part but received err", "error", err)
1111+
//cs.logger.Info("PSULOG - added block part but received err", "error", err)
11121112
}
11131113

11141114
case *VoteMessage:
@@ -1496,7 +1496,7 @@ func (cs *State) defaultDecideProposal(ctx context.Context, height int64, round
14961496
propBlockID := types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()}
14971497
proposal := types.NewProposal(height, round, cs.ValidRound, propBlockID, block.Header.Time, block.Data.TxKeys, block.Header, block.LastCommit, block.Evidence, cs.privValidatorPubKey.Address())
14981498
p := proposal.ToProto()
1499-
cs.logger.Info("PSULOG - converted proposal to proto", "txkeys", p.TxKeys, "height", p.Height, "round", p.Round)
1499+
//cs.logger.Info("PSULOG - converted proposal to proto", "txkeys", p.TxKeys, "height", p.Height, "round", p.Round)
15001500

15011501
// wait the max amount we would wait for a proposal
15021502
ctxto, cancel := context.WithTimeout(ctx, cs.state.ConsensusParams.Timeout.Propose)
@@ -1574,7 +1574,7 @@ func (cs *State) createProposalBlock(ctx context.Context) (*types.Block, error)
15741574

15751575
//ret, err := cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, lastExtCommit, proposerAddr, cs.config.GossipTransactionHashOnly)
15761576
ret, err := cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, lastExtCommit, proposerAddr, false)
1577-
cs.logger.Info("PSULOG - created proposal block", "height", ret.Height, "txs", ret.Txs, "txkeys", ret.TxKeys)
1577+
//cs.logger.Info("PSULOG - created proposal block", "height", ret.Height, "txs", ret.Txs, "txkeys", ret.TxKeys)
15781578
if err != nil {
15791579
panic(err)
15801580
}
@@ -1630,26 +1630,26 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32
16301630

16311631
// Check that a proposed block was not received within this round (and thus executing this from a timeout).
16321632
if !cs.config.GossipTransactionHashOnly && cs.ProposalBlock == nil {
1633-
logger.Info("prevote step: ProposalBlock is nil; prevoting nil")
1633+
//logger.Info("prevote step: ProposalBlock is nil; prevoting nil")
16341634
cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
16351635
return
16361636
}
16371637

16381638
if cs.Proposal == nil {
1639-
logger.Info("prevote step: did not receive proposal; prevoting nil")
1639+
//logger.Info("prevote step: did not receive proposal; prevoting nil")
16401640
cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
16411641
return
16421642
}
16431643

16441644
// If we're not the proposer, we need to build the block
16451645
if cs.config.GossipTransactionHashOnly && cs.ProposalBlock == nil {
1646-
logger.Info("prevote step: Creating proposal block from txs", "proposal", cs.Proposal, "proposal block parts", cs.ProposalBlockParts)
1646+
//logger.Info("prevote step: Creating proposal block from txs", "proposal", cs.Proposal, "proposal block parts", cs.ProposalBlockParts)
16471647
txKeys := cs.Proposal.TxKeys
16481648
if len(cs.blockExec.GetMissingTxs(txKeys)) != 0 {
1649-
logger.Info("PSULOG - prevote step: populating txs has missing txs", "keys", cs.blockExec.GetMissingTxs(txKeys))
1649+
//logger.Info("PSULOG - prevote step: populating txs has missing txs", "keys", cs.blockExec.GetMissingTxs(txKeys))
16501650
return
16511651
} else if !cs.ProposalBlockParts.IsComplete() {
1652-
logger.Info("PSULOG - prevote step: proposal block parts is incomplete", "keys", cs.blockExec.GetMissingTxs(txKeys), "block parts", cs.ProposalBlockParts, "proposal", cs.Proposal)
1652+
//logger.Info("PSULOG - prevote step: proposal block parts is incomplete", "keys", cs.blockExec.GetMissingTxs(txKeys), "block parts", cs.ProposalBlockParts, "proposal", cs.Proposal)
16531653
return
16541654
} else {
16551655
bz, err := io.ReadAll(cs.ProposalBlockParts.GetReader())
@@ -1675,7 +1675,7 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32
16751675
block.Data.Txs = txs
16761676
block.DataHash = block.Data.Hash()
16771677
cs.ProposalBlock = block
1678-
logger.Info("PSULOG - setting proposal block in defaultDoPrevote", "block", block)
1678+
//logger.Info("PSULOG - setting proposal block in defaultDoPrevote", "block", block)
16791679
}
16801680
}
16811681

@@ -2309,7 +2309,7 @@ func (cs *State) RecordMetrics(height int64, block *types.Block) {
23092309
func (cs *State) defaultSetProposal(proposal *types.Proposal, recvTime time.Time) error {
23102310
// Already have one
23112311
// TODO: possibly catch double proposals
2312-
cs.logger.Info("PSULOG - defaultsetproposal enter - checking proposal", "proposal", proposal, "cs.Proposal", cs.Proposal)
2312+
//cs.logger.Info("PSULOG - defaultsetproposal enter - checking proposal", "proposal", proposal, "cs.Proposal", cs.Proposal)
23132313

23142314
if cs.Proposal != nil || proposal == nil {
23152315
return nil
@@ -2335,7 +2335,7 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal, recvTime time.Time
23352335
}
23362336

23372337
proposal.Signature = p.Signature
2338-
cs.logger.Info("PSULOG - defaultsetproposal setting proposal", "proposal", proposal)
2338+
//cs.logger.Info("PSULOG - defaultsetproposal setting proposal", "proposal", proposal)
23392339
cs.Proposal = proposal
23402340
cs.ProposalReceiveTime = recvTime
23412341
cs.calculateProposalTimestampDifferenceMetric()
@@ -2359,7 +2359,7 @@ func (cs *State) addProposalBlockPart(
23592359
peerID types.NodeID,
23602360
) (added bool, err error) {
23612361
height, round, part := msg.Height, msg.Round, msg.Part
2362-
cs.logger.Info("PSULOG - adding proposal block part", "blockpart", msg)
2362+
//cs.logger.Info("PSULOG - adding proposal block part", "blockpart", msg)
23632363

23642364
// Blocks might be reused, so round mismatch is OK
23652365
if cs.Height != height {
@@ -2417,23 +2417,23 @@ func (cs *State) addProposalBlockPart(
24172417
}
24182418

24192419
// We need to now populate proposal block with the txs
2420-
cs.logger.Info("PSULOG - maybe populating proposal block with txs", "current proposal", cs.Proposal, "proposal block", block)
2420+
//cs.logger.Info("PSULOG - maybe populating proposal block with txs", "current proposal", cs.Proposal, "proposal block", block)
24212421
if cs.config.GossipTransactionHashOnly {
24222422
if cs.Proposal == nil {
2423-
cs.logger.Info("PSULOG - populating tx has no proposal")
2423+
//cs.logger.Info("PSULOG - populating tx has no proposal")
24242424
} else {
24252425
txKeys := cs.Proposal.TxKeys
24262426
if len(cs.blockExec.GetMissingTxs(txKeys)) != 0 {
2427-
cs.logger.Info("PSULOG - populating txs has missing txs", "keys", cs.blockExec.GetMissingTxs(txKeys))
2427+
//cs.logger.Info("PSULOG - populating txs has missing txs", "keys", cs.blockExec.GetMissingTxs(txKeys))
24282428
} else {
24292429
// We have full proposal block. Set txs in proposal block from mempool
2430-
cs.logger.Info("PSULOG - populating txs with keys", "keys", txKeys)
2431-
cs.logger.Info("PSULOG - recreating proposal block", "block", block)
2430+
//cs.logger.Info("PSULOG - populating txs with keys", "keys", txKeys)
2431+
//cs.logger.Info("PSULOG - recreating proposal block", "block", block)
24322432
txs := cs.blockExec.GetTxsForKeys(txKeys)
24332433
block.Data.Txs = txs
24342434
block.DataHash = block.Data.Hash()
24352435
cs.ProposalBlock = block
2436-
cs.logger.Info("PSULOG - setting proposal block", "block", block)
2436+
//cs.logger.Info("PSULOG - setting proposal block", "block", block)
24372437
partSet, err := block.MakePartSet(types.BlockPartSizeBytes)
24382438
if err != nil {
24392439
return false, nil
@@ -2459,7 +2459,7 @@ func (cs *State) addProposalBlockPart(
24592459
}
24602460

24612461
func (cs *State) tryCreateProposalBlock(height int64, round int32, header types.Header, lastCommit *types.Commit, evidence []types.Evidence, proposerAddress types.Address) bool {
2462-
cs.logger.Info("PSULOG - trying to create proposal block")
2462+
//cs.logger.Info("PSULOG - trying to create proposal block")
24632463

24642464
// Blocks might be reused, so round mismatch is OK
24652465
if cs.Height != height {
@@ -2469,23 +2469,23 @@ func (cs *State) tryCreateProposalBlock(height int64, round int32, header types.
24692469
}
24702470

24712471
if cs.Proposal == nil || len(cs.blockExec.GetMissingTxs(cs.Proposal.TxKeys)) != 0 {
2472-
cs.logger.Info("PSULOG - cannot create block, either proposal is missing or we have missing keys", "proposal", cs.Proposal)
2472+
//cs.logger.Info("PSULOG - cannot create block, either proposal is missing or we have missing keys", "proposal", cs.Proposal)
24732473
return false
24742474
} else {
24752475
txKeys := cs.Proposal.TxKeys
24762476
//block := types.MakeBlock(height, cs.blockExec.GetTxsForKeys(txKeys), lastCommit, evidence, false)
24772477
block := cs.state.MakeBlock(height, cs.blockExec.GetTxsForKeys(txKeys), lastCommit, evidence, proposerAddress, false)
24782478
// We have full proposal block. Set txs in proposal block from mempool
2479-
cs.logger.Info("PSULOG - populating txs with keys", "keys", txKeys)
2480-
cs.logger.Info("PSULOG - recreating proposal block", "block", block)
2479+
//cs.logger.Info("PSULOG - populating txs with keys", "keys", txKeys)
2480+
//cs.logger.Info("PSULOG - recreating proposal block", "block", block)
24812481
txs := cs.blockExec.GetTxsForKeys(txKeys)
24822482
block.Version = header.Version
24832483
block.Data.Txs = txs
24842484
block.DataHash = block.Data.Hash()
24852485
block.Header.Time = header.Time
24862486
block.Header.ProposerAddress = header.ProposerAddress
24872487
cs.ProposalBlock = block
2488-
cs.logger.Info("PSULOG - setting proposal block", "block", block)
2488+
//cs.logger.Info("PSULOG - setting proposal block", "block", block)
24892489
partSet, err := block.MakePartSet(types.BlockPartSizeBytes)
24902490
if err != nil {
24912491
return false
@@ -2498,7 +2498,7 @@ func (cs *State) tryCreateProposalBlock(height int64, round int32, header types.
24982498
}
24992499

25002500
func (cs *State) handleCompleteProposal(ctx context.Context, height int64, handleBlockPartSpan otrace.Span) {
2501-
cs.logger.Info("PSULOG - handle complete proposal", "height", height, "proposal block parts", cs.ProposalBlockParts)
2501+
//cs.logger.Info("PSULOG - handle complete proposal", "height", height, "proposal block parts", cs.ProposalBlockParts)
25022502
// Update Valid* if we can.
25032503
prevotes := cs.Votes.Prevotes(cs.Round)
25042504
blockID, hasTwoThirds := prevotes.TwoThirdsMajority()

internal/state/execution.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
142142
}
143143
itxs := txrSet.IncludedTxs()
144144
block2 := state.MakeBlock(height, itxs, commit, evidence, proposerAddr, hashOnly)
145-
blockExec.logger.Info("PSULOG creating block", "hashOnly", hashOnly, "block", block, "num_txs", len(block.Txs))
145+
//blockExec.logger.Info("PSULOG creating block", "hashOnly", hashOnly, "block", block, "num_txs", len(block.Txs))
146146
return block2, nil
147147
}
148148

149149
func (blockExec *BlockExecutor) GetTxsForKeys(txKeys []types.TxKey) types.Txs {
150-
blockExec.logger.Info("PSULOG getting txs for keys", "txKeys", txKeys)
150+
//blockExec.logger.Info("PSULOG getting txs for keys", "txKeys", txKeys)
151151
return blockExec.mempool.GetTxsForKeys(txKeys)
152152
}
153153

0 commit comments

Comments
 (0)