@@ -272,21 +272,55 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
272
272
conR .conS .mtx .Lock ()
273
273
initialHeight := conR .conS .state .InitialHeight
274
274
conR .conS .mtx .Unlock ()
275
+ schema .WriteConsensusState (
276
+ conR .traceClient ,
277
+ msg .Height ,
278
+ msg .Round ,
279
+ string (e .Src .ID ()),
280
+ schema .ConsensusNewRoundStep ,
281
+ schema .Download ,
282
+ fmt .Sprintf ("%d" , msg .Step ),
283
+ )
275
284
if err = msg .ValidateHeight (initialHeight ); err != nil {
276
285
conR .Logger .Error ("Peer sent us invalid msg" , "peer" , e .Src , "msg" , msg , "err" , err )
277
286
conR .Switch .StopPeerForError (e .Src , err )
278
287
return
279
288
}
280
289
ps .ApplyNewRoundStepMessage (msg )
281
290
case * NewValidBlockMessage :
291
+ schema .WriteConsensusState (
292
+ conR .traceClient ,
293
+ msg .Height ,
294
+ msg .Round ,
295
+ string (e .Src .ID ()),
296
+ schema .ConsensusNewValidBlock ,
297
+ schema .Download ,
298
+ )
282
299
ps .ApplyNewValidBlockMessage (msg )
283
300
case * HasVoteMessage :
284
301
ps .ApplyHasVoteMessage (msg )
302
+ schema .WriteConsensusState (
303
+ conR .traceClient ,
304
+ msg .Height ,
305
+ msg .Round ,
306
+ string (e .Src .ID ()),
307
+ schema .ConsensusHasVote ,
308
+ schema .Download ,
309
+ msg .Type .String (),
310
+ )
285
311
case * VoteSetMaj23Message :
286
312
cs := conR .conS
287
313
cs .mtx .Lock ()
288
314
height , votes := cs .Height , cs .Votes
289
315
cs .mtx .Unlock ()
316
+ schema .WriteConsensusState (
317
+ conR .traceClient ,
318
+ msg .Height ,
319
+ msg .Round ,
320
+ string (e .Src .ID ()),
321
+ schema .ConsensusVoteSet23Precommit ,
322
+ schema .Download ,
323
+ )
290
324
if height != msg .Height {
291
325
return
292
326
}
@@ -316,10 +350,20 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
316
350
if votes := ourVotes .ToProto (); votes != nil {
317
351
eMsg .Votes = * votes
318
352
}
319
- p2p .TrySendEnvelopeShim (e .Src , p2p.Envelope { //nolint: staticcheck
353
+ if p2p .TrySendEnvelopeShim (e .Src , p2p.Envelope { //nolint: staticcheck
320
354
ChannelID : VoteSetBitsChannel ,
321
355
Message : eMsg ,
322
- }, conR .Logger )
356
+ }, conR .Logger ) {
357
+ schema .WriteConsensusState (
358
+ conR .traceClient ,
359
+ msg .Height ,
360
+ msg .Round ,
361
+ string (e .Src .ID ()),
362
+ schema .ConsensusVoteSetBits ,
363
+ schema .Upload ,
364
+ msg .Type .String (),
365
+ )
366
+ }
323
367
default :
324
368
conR .Logger .Error (fmt .Sprintf ("Unknown message type %v" , reflect .TypeOf (msg )))
325
369
}
@@ -333,12 +377,27 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
333
377
case * ProposalMessage :
334
378
ps .SetHasProposal (msg .Proposal )
335
379
conR .conS .peerMsgQueue <- msgInfo {msg , e .Src .ID ()}
380
+ schema .WriteProposal (
381
+ conR .traceClient ,
382
+ msg .Proposal .Height ,
383
+ msg .Proposal .Round ,
384
+ string (e .Src .ID ()),
385
+ schema .Download ,
386
+ )
336
387
case * ProposalPOLMessage :
337
388
ps .ApplyProposalPOLMessage (msg )
389
+ schema .WriteConsensusState (
390
+ conR .traceClient ,
391
+ msg .Height ,
392
+ msg .ProposalPOLRound ,
393
+ string (e .Src .ID ()),
394
+ schema .ConsensusPOL ,
395
+ schema .Download ,
396
+ )
338
397
case * BlockPartMessage :
339
398
ps .SetHasProposalBlockPart (msg .Height , msg .Round , int (msg .Part .Index ))
340
399
conR .Metrics .BlockParts .With ("peer_id" , string (e .Src .ID ())).Add (1 )
341
- schema .WriteBlockPart (conR .traceClient , msg .Height , msg .Round , e .Src .ID (), msg . Part . Index , schema .Download )
400
+ schema .WriteBlockPart (conR .traceClient , msg .Height , msg .Round , msg . Part . Index , false , string ( e .Src .ID ()) , schema .Download )
342
401
conR .conS .peerMsgQueue <- msgInfo {msg , e .Src .ID ()}
343
402
default :
344
403
conR .Logger .Error (fmt .Sprintf ("Unknown message type %v" , reflect .TypeOf (msg )))
@@ -357,7 +416,7 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
357
416
cs .Validators .Size (), cs .LastCommit .Size ()
358
417
cs .mtx .RUnlock ()
359
418
360
- schema .WriteVote (conR .traceClient , height , round , msg .Vote , e .Src .ID (), schema .Download )
419
+ schema .WriteVote (conR .traceClient , height , round , msg .Vote , string ( e .Src .ID () ), schema .Download )
361
420
362
421
ps .EnsureVoteBitArrays (height , valSize )
363
422
ps .EnsureVoteBitArrays (height - 1 , lastCommitSize )
@@ -477,6 +536,15 @@ func (conR *Reactor) broadcastNewRoundStepMessage(rs *cstypes.RoundState) {
477
536
ChannelID : StateChannel ,
478
537
Message : nrsMsg ,
479
538
})
539
+ schema .WriteConsensusState (
540
+ conR .traceClient ,
541
+ nrsMsg .Height ,
542
+ nrsMsg .Round ,
543
+ schema .Broadcast ,
544
+ schema .ConsensusNewRoundStep ,
545
+ schema .Upload ,
546
+ fmt .Sprintf ("%d" , nrsMsg .Step ),
547
+ )
480
548
}
481
549
482
550
func (conR * Reactor ) broadcastNewValidBlockMessage (rs * cstypes.RoundState ) {
@@ -492,6 +560,14 @@ func (conR *Reactor) broadcastNewValidBlockMessage(rs *cstypes.RoundState) {
492
560
ChannelID : StateChannel ,
493
561
Message : csMsg ,
494
562
})
563
+ schema .WriteConsensusState (
564
+ conR .traceClient ,
565
+ rs .Height ,
566
+ rs .Round ,
567
+ schema .Broadcast ,
568
+ schema .ConsensusNewValidBlock ,
569
+ schema .Upload ,
570
+ )
495
571
}
496
572
497
573
// Broadcasts HasVoteMessage to peers that care.
@@ -506,6 +582,15 @@ func (conR *Reactor) broadcastHasVoteMessage(vote *types.Vote) {
506
582
ChannelID : StateChannel ,
507
583
Message : msg ,
508
584
})
585
+ schema .WriteConsensusState (
586
+ conR .traceClient ,
587
+ vote .Height ,
588
+ vote .Round ,
589
+ schema .Broadcast ,
590
+ schema .ConsensusHasVote ,
591
+ schema .Upload ,
592
+ vote .Type .String (),
593
+ )
509
594
/*
510
595
// TODO: Make this broadcast more selective.
511
596
for _, peer := range conR.Switch.Peers().List() {
@@ -544,10 +629,20 @@ func makeRoundStepMessage(rs *cstypes.RoundState) (nrsMsg *cmtcons.NewRoundStep)
544
629
func (conR * Reactor ) sendNewRoundStepMessage (peer p2p.Peer ) {
545
630
rs := conR .getRoundState ()
546
631
nrsMsg := makeRoundStepMessage (rs )
547
- p2p .SendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
632
+ if p2p .SendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
548
633
ChannelID : StateChannel ,
549
634
Message : nrsMsg ,
550
- }, conR .Logger )
635
+ }, conR .Logger ) {
636
+ schema .WriteConsensusState (
637
+ conR .traceClient ,
638
+ nrsMsg .Height ,
639
+ nrsMsg .Round ,
640
+ string (peer .ID ()),
641
+ schema .ConsensusNewRoundStep ,
642
+ schema .Upload ,
643
+ fmt .Sprintf ("%d" , nrsMsg .Step ),
644
+ )
645
+ }
551
646
}
552
647
553
648
func (conR * Reactor ) updateRoundStateRoutine () {
@@ -599,7 +694,7 @@ OUTER_LOOP:
599
694
Part : * parts ,
600
695
},
601
696
}, logger ) {
602
- schema .WriteBlockPart (conR .traceClient , rs .Height , rs .Round , peer .ID (), part . Index , schema .Upload )
697
+ schema .WriteBlockPart (conR .traceClient , rs .Height , rs .Round , part . Index , false , string ( peer .ID ()) , schema .Upload )
603
698
ps .SetHasProposalBlockPart (prs .Height , prs .Round , index )
604
699
}
605
700
continue OUTER_LOOP
@@ -653,6 +748,13 @@ OUTER_LOOP:
653
748
// NOTE[ZM]: A peer might have received different proposal msg so this Proposal msg will be rejected!
654
749
// TODO But yet we send block parts of this proposal to the peer (in the first if statement of the current function) while the proposal is rejected. This part of the protocol could be improved by sending the proposal block parts only if the proposal is accepted.
655
750
ps .SetHasProposal (rs .Proposal )
751
+ schema .WriteProposal (
752
+ conR .traceClient ,
753
+ rs .Height ,
754
+ rs .Round ,
755
+ string (peer .ID ()),
756
+ schema .Upload ,
757
+ )
656
758
}
657
759
}
658
760
// ProposalPOL: lets peer know which POL votes we have so far.
@@ -661,14 +763,23 @@ OUTER_LOOP:
661
763
// so we definitely have rs.Votes.Prevotes(rs.Proposal.POLRound).
662
764
if 0 <= rs .Proposal .POLRound {
663
765
logger .Debug ("Sending POL" , "height" , prs .Height , "round" , prs .Round )
664
- p2p .SendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
766
+ if p2p .SendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
665
767
ChannelID : DataChannel ,
666
768
Message : & cmtcons.ProposalPOL {
667
769
Height : rs .Height ,
668
770
ProposalPolRound : rs .Proposal .POLRound ,
669
771
ProposalPol : * rs .Votes .Prevotes (rs .Proposal .POLRound ).BitArray ().ToProto (),
670
772
},
671
- }, logger )
773
+ }, logger ) {
774
+ schema .WriteConsensusState (
775
+ conR .traceClient ,
776
+ rs .Height ,
777
+ rs .Round ,
778
+ string (peer .ID ()),
779
+ schema .ConsensusPOL ,
780
+ schema .Upload ,
781
+ )
782
+ }
672
783
}
673
784
continue OUTER_LOOP
674
785
}
@@ -720,6 +831,15 @@ func (conR *Reactor) gossipDataForCatchup(logger log.Logger, rs *cstypes.RoundSt
720
831
},
721
832
}, logger ) {
722
833
ps .SetHasProposalBlockPart (prs .Height , prs .Round , index )
834
+ schema .WriteBlockPart (
835
+ conR .traceClient ,
836
+ prs .Height ,
837
+ prs .Round ,
838
+ uint32 (index ),
839
+ true ,
840
+ string (peer .ID ()),
841
+ schema .Upload ,
842
+ )
723
843
} else {
724
844
logger .Debug ("Sending block part for catchup failed" )
725
845
// sleep to avoid retrying too fast
@@ -784,7 +904,7 @@ OUTER_LOOP:
784
904
if vote != nil {
785
905
logger .Debug ("Picked Catchup commit to send" , "height" , prs .Height )
786
906
schema .WriteVote (conR .traceClient , rs .Height , rs .Round , vote ,
787
- ps .peer .ID (), schema .Upload )
907
+ string ( ps .peer .ID () ), schema .Upload )
788
908
continue OUTER_LOOP
789
909
}
790
910
}
@@ -813,7 +933,7 @@ func (conR *Reactor) pickSendVoteAndTrace(votes types.VoteSetReader, rs *cstypes
813
933
vote := ps .PickSendVote (votes )
814
934
if vote != nil { // if a vote is sent, trace it
815
935
schema .WriteVote (conR .traceClient , rs .Height , rs .Round , vote ,
816
- ps .peer .ID (), schema .Upload )
936
+ string ( ps .peer .ID () ), schema .Upload )
817
937
return true
818
938
}
819
939
return false
@@ -895,15 +1015,24 @@ OUTER_LOOP:
895
1015
if rs .Height == prs .Height {
896
1016
if maj23 , ok := rs .Votes .Prevotes (prs .Round ).TwoThirdsMajority (); ok {
897
1017
898
- p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
1018
+ if p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
899
1019
ChannelID : StateChannel ,
900
1020
Message : & cmtcons.VoteSetMaj23 {
901
1021
Height : prs .Height ,
902
1022
Round : prs .Round ,
903
1023
Type : cmtproto .PrevoteType ,
904
1024
BlockID : maj23 .ToProto (),
905
1025
},
906
- }, ps .logger )
1026
+ }, ps .logger ) {
1027
+ schema .WriteConsensusState (
1028
+ conR .traceClient ,
1029
+ rs .Height ,
1030
+ rs .Round ,
1031
+ string (peer .ID ()),
1032
+ schema .ConsensusVoteSet23Prevote ,
1033
+ schema .Upload ,
1034
+ )
1035
+ }
907
1036
time .Sleep (conR .conS .config .PeerQueryMaj23SleepDuration )
908
1037
}
909
1038
}
@@ -915,15 +1044,24 @@ OUTER_LOOP:
915
1044
prs := ps .GetRoundState ()
916
1045
if rs .Height == prs .Height {
917
1046
if maj23 , ok := rs .Votes .Precommits (prs .Round ).TwoThirdsMajority (); ok {
918
- p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
1047
+ if p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
919
1048
ChannelID : StateChannel ,
920
1049
Message : & cmtcons.VoteSetMaj23 {
921
1050
Height : prs .Height ,
922
1051
Round : prs .Round ,
923
1052
Type : cmtproto .PrecommitType ,
924
1053
BlockID : maj23 .ToProto (),
925
1054
},
926
- }, ps .logger )
1055
+ }, ps .logger ) {
1056
+ schema .WriteConsensusState (
1057
+ conR .traceClient ,
1058
+ rs .Height ,
1059
+ rs .Round ,
1060
+ string (peer .ID ()),
1061
+ schema .ConsensusVoteSet23Precommit ,
1062
+ schema .Upload ,
1063
+ )
1064
+ }
927
1065
time .Sleep (conR .conS .config .PeerQueryMaj23SleepDuration )
928
1066
}
929
1067
}
@@ -936,15 +1074,24 @@ OUTER_LOOP:
936
1074
if rs .Height == prs .Height && prs .ProposalPOLRound >= 0 {
937
1075
if maj23 , ok := rs .Votes .Prevotes (prs .ProposalPOLRound ).TwoThirdsMajority (); ok {
938
1076
939
- p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
1077
+ if p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
940
1078
ChannelID : StateChannel ,
941
1079
Message : & cmtcons.VoteSetMaj23 {
942
1080
Height : prs .Height ,
943
1081
Round : prs .ProposalPOLRound ,
944
1082
Type : cmtproto .PrevoteType ,
945
1083
BlockID : maj23 .ToProto (),
946
1084
},
947
- }, ps .logger )
1085
+ }, ps .logger ) {
1086
+ schema .WriteConsensusState (
1087
+ conR .traceClient ,
1088
+ rs .Height ,
1089
+ rs .Round ,
1090
+ string (peer .ID ()),
1091
+ schema .ConsensusPOL ,
1092
+ schema .Upload ,
1093
+ )
1094
+ }
948
1095
time .Sleep (conR .conS .config .PeerQueryMaj23SleepDuration )
949
1096
}
950
1097
}
@@ -959,15 +1106,24 @@ OUTER_LOOP:
959
1106
if prs .CatchupCommitRound != - 1 && prs .Height > 0 && prs .Height <= conR .conS .blockStore .Height () &&
960
1107
prs .Height >= conR .conS .blockStore .Base () {
961
1108
if commit := conR .conS .LoadCommit (prs .Height ); commit != nil {
962
- p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
1109
+ if p2p .TrySendEnvelopeShim (peer , p2p.Envelope { //nolint: staticcheck
963
1110
ChannelID : StateChannel ,
964
1111
Message : & cmtcons.VoteSetMaj23 {
965
1112
Height : prs .Height ,
966
1113
Round : commit .Round ,
967
1114
Type : cmtproto .PrecommitType ,
968
1115
BlockID : commit .BlockID .ToProto (),
969
1116
},
970
- }, ps .logger )
1117
+ }, ps .logger ) {
1118
+ schema .WriteConsensusState (
1119
+ conR .traceClient ,
1120
+ prs .Height ,
1121
+ prs .Round ,
1122
+ string (peer .ID ()),
1123
+ schema .ConsensusVoteSet23Precommit ,
1124
+ schema .Upload ,
1125
+ )
1126
+ }
971
1127
time .Sleep (conR .conS .config .PeerQueryMaj23SleepDuration )
972
1128
}
973
1129
}
0 commit comments