@@ -57,7 +57,7 @@ def plotFromPandas(panda, pdf, opts):
5757
5858 # Check is there is Value on top of the charts
5959 if opts ['barValues' ] is not None :
60- for ind , value in enumerate (yarray ):
60+ for ind , value in enumerate (opts [ 'barValues' ] ):
6161 plt .text (ind , value , str (value ), fontsize = opts ['textSize' ], horizontalalignment = 'center' )
6262
6363 # Check id the grid has been set
@@ -81,7 +81,7 @@ def plotStackBarsFromArrays(xarray, yarray, pdf, opts):
8181
8282 fig , ax = plt .subplots (figsize = opts ['figSize' ])
8383
84- colors = ['mediumseagreen' , 'indianred' , 'goldenrod' ,'cornflowerblue' ]
84+ colors = ['mediumseagreen' , 'springgreen' , ' indianred' , 'goldenrod' , 'cornflowerblue' ]
8585 legends = []
8686 auxI = 0
8787 bottom = [0 ,0 ] # done by hand
@@ -526,14 +526,12 @@ def main():
526526 # End of plotting variables
527527 csvFile = sys .argv [1 ]
528528 peerstoreFile = sys .argv [2 ]
529- extraMetrics = sys .argv [3 ]
530- outputFigsFolder = sys .argv [4 ]
529+ outputFigsFolder = sys .argv [3 ]
531530
532531 pdfFile = outputFigsFolder + "/MetricsSummary.pdf"
533532
534533 peerstorePanda = getPandaFromPeerstoreJson (peerstoreFile )
535534 rumorMetricsPanda = pd .read_csv (csvFile )
536- extraPeerData = pd .read_csv (extraMetrics )
537535
538536
539537 # ---------- PLOT SECUENCE -----------
@@ -553,7 +551,7 @@ def main():
553551 cnt9000 = 0
554552 cntOthers = 0
555553 noAddrs = 0
556-
554+
557555 peerstoreLen = len (peerstore )
558556 metricsLen = len (rumorMetricsPanda )
559557 print ()
@@ -569,10 +567,25 @@ def main():
569567 except :
570568 noAddrs = noAddrs + 1
571569
570+ # Unknown Peers with 13000 port
571+ unk13000 = 0
572+ tcp13000 = 0
573+ cunk1300 = 0
574+ for index , row in rumorMetricsPanda .iterrows ():
575+
576+ if '/13000' in str (row ['Address' ]):
577+ tcp13000 = tcp13000 + 1
578+ if row ['Client' ] == 'Unknown' :
579+ unk13000 = unk13000 + 1
580+ if row ['Connected' ] == True :
581+ cunk1300 = cunk1300 + 1
582+ print (tcp13000 , unk13000 , cunk1300 )
583+
572584 print ('Number of clients with the TPC port at 13000:' , cnt13000 )
573585 print ('Number of clients with the TPC port at 9000: ' , cnt9000 )
574586 print ('Number of clients with other TCP ports: ' , cntOthers )
575587 print ('Number of clients without address: ' , noAddrs )
588+ print ('Number of Unknown clients with 13000 TCP port:' , unk13000 )
576589 summ = cnt13000 + cnt9000 + cntOthers + noAddrs
577590 noPrysmPort = cnt9000 + cntOthers + noAddrs
578591 if summ != peerstoreLen :
@@ -694,11 +707,15 @@ def main():
694707 nonAttempted = 0
695708 succeed = 0
696709 failed = 0
710+ connected = 0
697711
698- print ("extra metrics len:" , len (extraPeerData ))
699- for index , row in extraPeerData .iterrows ():
712+ print ("extra metrics len:" , len (rumorMetricsPanda ))
713+ for index , row in rumorMetricsPanda .iterrows ():
700714 if row ['Attempted' ] == False :
701- nonAttempted = nonAttempted + 1
715+ if row ['Connected' ] == True :
716+ connected = connected + 1
717+ else :
718+ nonAttempted = nonAttempted + 1
702719 else :
703720 if row ['Succeed' ] == False :
704721 failed = failed + 1
@@ -708,59 +725,26 @@ def main():
708725 print ("Not tried from the last peerstore copy:" ,nonAttempted )
709726 print ("Tried and succeed:" , succeed )
710727 print ("Tried and failed" , failed )
711- nonAttempted = nonAttempted + (peerstoreLen - (len (extraPeerData )))
728+ print ("Incoming connections:" , connected )
729+ nonAttempted = nonAttempted + (peerstoreLen - (len (rumorMetricsPanda )))
712730 print ("Total Not tried from the entrire peerstore" , nonAttempted )
713731
714732 # get length of the peerstore
715733 peerstoreSize = getLengthOfPanda (peerstorePanda )
716734 peerMetricsSize = getLengthOfPanda (rumorMetricsPanda )
717735
718- print ("Attempted and succeed" , succeed , "| On the metrics" , peerMetricsSize )
719-
720- if succeed < peerMetricsSize :
721- print ("- Dismatch on the extra metrics and metrics -" )
722- for idx , row in rumorMetricsPanda .iterrows ():
723- index = extraPeerData .index [extraPeerData ['Peer Id' ] == row ['Peer Id' ]]
724- extraPeerData .loc [index , 'Attempted' ] = True
725- extraPeerData .loc [index , 'Succeed' ] = True
726- extraPeerData .loc [index , 'Error' ] = "None"
727- # plot the metrics gathered on the extra-metrics
728- nonAttempted = 0
729- succeed = 0
730- failed = 0
731- print ("\n -- Updating extra-results -- \n " )
732- print ("extra metrics len:" , len (extraPeerData ))
733- for index , row in extraPeerData .iterrows ():
734- if row ['Attempted' ] == False :
735- nonAttempted = nonAttempted + 1
736- else :
737- if row ['Succeed' ] == False :
738- failed = failed + 1
739- else :
740- succeed = succeed + 1
741-
742- print ("Not tried from the last peerstore copy:" ,nonAttempted )
743- print ("Tried and succeed:" , succeed )
744- print ("Tried and failed" , failed )
745- nonAttempted = nonAttempted + (peerstoreLen - (len (extraPeerData )))
746- print ("Total Not tried from the entrire peerstore" , nonAttempted )
747-
748-
749- print ("Attempted and succeed" , succeed , "| On the metrics" , peerMetricsSize )
750- if succeed != peerMetricsSize :
751- print ("----> WARN: Random connected peers and peers on the metrics don't match" )
752-
736+ print ("Peers in metrics" , peerMetricsSize , "| On the peerstore" , peerstoreSize )
737+ if peerMetricsSize != peerstoreSize :
738+ print ("----> WARN: Peers in Peerstore and peers on the metrics don't match" )
739+
753740 ## -- website code --
754741 print ("\n " )
755742 print ("Results from crawler run on [month] running for [crawling time].\n <br>Total amount of peers on the peerstore:" , peerstoreLen ,".\n <br>Number of clients with the TPC port at 13000 (Prysm?):" , cnt13000 ,".\n <br>Percentage of 'Prysm' peers from the peerstore (based on the TCP port):" , round ((cnt13000 * 100 )/ peerstoreLen ,2 ),"%.\n <br>We manage to connect with" , succeed ,"peers from the peerstore.\n <br>This would be the distribution." )
756743 print ("\n " )
757-
758-
759-
760-
761- xarray = [[0 , succeed ], [0 , failed ], [0 , nonAttempted ], [peerstoreLen , 0 ]]
744+
745+ xarray = [[0 , succeed ], [0 , connected ], [0 , failed ], [0 , nonAttempted ], [peerstoreLen , 0 ]]
762746 yarray = ['Peerstore' , 'Peering Results' ]
763- labels = ['connected' , 'failed' , 'not attempted ' , 'peerstore' ]
747+ labels = ['connected' , 'incoming' , ' failed' , 'not tried ' , 'peerstore' ]
764748 barColor = ['tab:blue' , 'tab:green' ]
765749
766750
@@ -793,18 +777,24 @@ def main():
793777
794778 ## Classify the non connected peers by error
795779
796- errorList = getItemsFromColumn (extraPeerData , 'Error' )
797- errorList .remove ('None' )
798- auxxarray , auxyarray = getDataFromPanda (extraPeerData , None , "Error" , errorList , 'counter' )
780+ errorList = getItemsFromColumn (rumorMetricsPanda , 'Error' )
781+ try :
782+ errorList .remove ('None' )
783+ except :
784+ pass
785+ auxxarray , auxyarray = getDataFromPanda (rumorMetricsPanda , None , "Error" , errorList , 'counter' )
799786 xarray , yarray = sortArrayMaxtoMin (auxxarray , auxyarray )
800787 # Get Color Grid
801788 barColor = GetColorGridFromArray (yarray )
802789
803790 print ()
791+ """
804792 for idx,item in enumerate(xarray):
805793 print(item, ',', yarray[idx])
806794
807795 print()
796+ """
797+
808798
809799 plotHorizontalBarsFromArrays (xarray , yarray , pdf , opts = {
810800 'figSize' : (12 ,7 ),
@@ -833,12 +823,27 @@ def main():
833823 'tickRotation' : 0 ,
834824 'show' : False })
835825
826+ # Subgenerate a panda only with the peers that we did exchange metadata before
827+ indexToDrop = []
828+ counter = 0
829+ auxMetricsPanda = rumorMetricsPanda .copy ()
830+ for index , row in auxMetricsPanda .iterrows ():
831+ if row ['Request Metadata' ] == False : # If we didn't exchange metadata with them, remove them from the panda copy
832+ indexToDrop .append (index )
833+ else :
834+ counter += 1
835+ #print(index, row['Client'])
836+
837+ auxMetricsPanda .drop (indexToDrop , axis = 0 , inplace = True )
838+ #print(auxMetricsPanda)
839+ print ("\n Org. Metrics:" , len (rumorMetricsPanda ), "Should have:" , counter , "Filtered:" , len (auxMetricsPanda ), "\n " )
840+
836841 clientCounter = []
837842 types = []
838843 typesCounter = []
839844
840845 for idx , item in enumerate (clientList ):
841- tcnt , tp , tpc = getTypesPerName (rumorMetricsPanda , item , 'Client' , 'Version' )
846+ tcnt , tp , tpc = getTypesPerName (auxMetricsPanda , item , 'Client' , 'Version' )
842847 clientCounter .append (tcnt )
843848 types .append (tp )
844849 typesCounter .append (tpc )
@@ -847,6 +852,10 @@ def main():
847852 yarray = typesCounter
848853 namesarray = clientList
849854
855+ print (clientCounter )
856+ print (types )
857+ print (typesCounter )
858+
850859 plotDoublePieFromArray (yarray , pdf , opts = {
851860 'figsize' : figSize ,
852861 'figtitle' : 'PeersPerClient.png' ,
@@ -895,10 +904,14 @@ def main():
895904 # Delete Prysm from the extrapoling
896905 del clientsCnt ['Prysm' ]
897906 print (clientsCnt )
907+ # Get number of unknown peers that has the 13000 port
908+ print ('Number of unknown with 13000 port' , unk13000 )
898909 # Get total of non prysm peers
899910 nonPrysmObserved = 0
900911 for k in clientsCnt :
901912 nonPrysmObserved = nonPrysmObserved + clientsCnt [k ]
913+ # Remove Unknown with 13000 port from nonPrysmObserved
914+ nonPrysmObserved = nonPrysmObserved
902915 # Get for each of the clients the extrapolation to the peerstore
903916 extrapolatedClientList = {}
904917 for k in clientsCnt :
@@ -950,7 +963,7 @@ def main():
950963 auxxarray , auxyarray = getDataFromPanda (rumorMetricsPanda , None , "Country" , countriesList , 'counter' )
951964 print ("Number of different Countries hosting Eth2 clients:" , len (auxxarray ))
952965 # Remove the Countries with less than X peers
953- countryLimit = 10
966+ countryLimit = 60
954967 xarray = []
955968 yarray = []
956969 for idx , item in enumerate (auxyarray ):
0 commit comments