mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-08 00:13:08 +00:00
Better proof period reporting. Default proofSubmitted events to OFF.
This commit is contained in:
parent
96510df5cf
commit
25a7a30793
@ -30,11 +30,11 @@ namespace CodexContractsPlugin.ChainMonitor
|
|||||||
currentPeriod = period;
|
currentPeriod = period;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PeriodReport[] GetAndClearReports()
|
public PeriodMonitorResult GetAndClearReports()
|
||||||
{
|
{
|
||||||
var result = reports.ToArray();
|
var result = reports.ToArray();
|
||||||
reports.Clear();
|
reports.Clear();
|
||||||
return result;
|
return new PeriodMonitorResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateReportForPeriod(ulong lastBlockInPeriod, ulong periodNumber, IChainStateRequest[] requests)
|
private void CreateReportForPeriod(ulong lastBlockInPeriod, ulong periodNumber, IChainStateRequest[] requests)
|
||||||
@ -67,6 +67,46 @@ namespace CodexContractsPlugin.ChainMonitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PeriodMonitorResult
|
||||||
|
{
|
||||||
|
public PeriodMonitorResult(PeriodReport[] reports)
|
||||||
|
{
|
||||||
|
Reports = reports;
|
||||||
|
|
||||||
|
CalcStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PeriodReport[] Reports { get; }
|
||||||
|
|
||||||
|
public bool IsEmpty { get; private set; }
|
||||||
|
public ulong PeriodLow { get; private set; }
|
||||||
|
public ulong PeriodHigh { get; private set; }
|
||||||
|
public float AverageNumSlots { get; private set; }
|
||||||
|
public float AverageNumProofsRequired { get; private set; }
|
||||||
|
|
||||||
|
private void CalcStats()
|
||||||
|
{
|
||||||
|
IsEmpty = true;
|
||||||
|
PeriodLow = ulong.MaxValue;
|
||||||
|
PeriodHigh = ulong.MinValue;
|
||||||
|
AverageNumSlots = 0.0f;
|
||||||
|
AverageNumProofsRequired = 0.0f;
|
||||||
|
float count = Reports.Length;
|
||||||
|
|
||||||
|
foreach (var report in Reports)
|
||||||
|
{
|
||||||
|
if (report.TotalProofsRequired > 0) IsEmpty = false;
|
||||||
|
PeriodLow = Math.Min(PeriodLow, report.PeriodNumber);
|
||||||
|
PeriodHigh = Math.Min(PeriodHigh, report.PeriodNumber);
|
||||||
|
AverageNumSlots += Convert.ToSingle(report.TotalNumSlots);
|
||||||
|
AverageNumProofsRequired += Convert.ToSingle(report.TotalProofsRequired);
|
||||||
|
}
|
||||||
|
|
||||||
|
AverageNumSlots = AverageNumSlots / count;
|
||||||
|
AverageNumProofsRequired = AverageNumProofsRequired / count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class PeriodReport
|
public class PeriodReport
|
||||||
{
|
{
|
||||||
public PeriodReport(ulong periodNumber, ulong totalNumSlots, ulong totalProofsRequired, PeriodProofMissed[] missedProofs)
|
public PeriodReport(ulong periodNumber, ulong totalNumSlots, ulong totalProofsRequired, PeriodProofMissed[] missedProofs)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ namespace TestNetRewarder
|
|||||||
public int ShowProofPeriodReports { get; set; } = 1;
|
public int ShowProofPeriodReports { get; set; } = 1;
|
||||||
|
|
||||||
[Uniform("proof-submitted-events", "pse", "PROOFSUBMITTEDEVENTS", false, "When greater than zero, chain event summary will include proof-submitted events.")]
|
[Uniform("proof-submitted-events", "pse", "PROOFSUBMITTEDEVENTS", false, "When greater than zero, chain event summary will include proof-submitted events.")]
|
||||||
public int ShowProofSubmittedEvents { get; set; } = 1;
|
public int ShowProofSubmittedEvents { get; set; } = 0; // Defaulted to zero, aprox 7 to 10 such events every 2 minutes in testnet (from autoclient alone!)
|
||||||
|
|
||||||
public string LogPath
|
public string LogPath
|
||||||
{
|
{
|
||||||
|
|||||||
@ -85,6 +85,8 @@
|
|||||||
public string Failed => "❌";
|
public string Failed => "❌";
|
||||||
public string ProofSubmitted => "🎵";
|
public string ProofSubmitted => "🎵";
|
||||||
public string ProofReport => "🔎";
|
public string ProofReport => "🔎";
|
||||||
|
public string NoProofsMissed => "🏛";
|
||||||
|
public string ManyProofsMissed => "😱";
|
||||||
|
|
||||||
public string StringToEmojis(string input, int outLength)
|
public string StringToEmojis(string input, int outLength)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -118,26 +118,60 @@ namespace TestNetRewarder
|
|||||||
errors.Add(msg);
|
errors.Add(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessPeriodReports(PeriodReport[] periodReports)
|
public void ProcessPeriodReports(PeriodMonitorResult reports)
|
||||||
{
|
{
|
||||||
var lines = periodReports.Select(FormatPeriodReport).ToList();
|
if (reports.IsEmpty) return;
|
||||||
lines.Insert(0, FormatPeriodReportLine("period", "totalSlots", "required", "missed"));
|
|
||||||
|
var lines = new List<string> {
|
||||||
|
$"Periods: [{reports.PeriodLow} ... {reports.PeriodHigh}]",
|
||||||
|
$"Average number of slots: {reports.AverageNumSlots.ToString("F2")}",
|
||||||
|
$"Average number of proofs required: {reports.AverageNumProofsRequired.ToString("F2")}"
|
||||||
|
};
|
||||||
|
|
||||||
|
AddMissedProofDetails(lines, reports.Reports);
|
||||||
|
|
||||||
AddBlock(0, $"{emojiMaps.ProofReport} **Proof system report**", lines.ToArray());
|
AddBlock(0, $"{emojiMaps.ProofReport} **Proof system report**", lines.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatPeriodReport(PeriodReport report)
|
private void AddMissedProofDetails(List<string> lines, PeriodReport[] reports)
|
||||||
{
|
{
|
||||||
return FormatPeriodReportLine(
|
var reportsWithMissedProofs = reports.Where(r => r.MissedProofs.Length > 0).ToArray();
|
||||||
periodNumber: report.PeriodNumber.ToString(),
|
if (reportsWithMissedProofs.Length < 1)
|
||||||
totalSlots: report.TotalNumSlots.ToString(),
|
{
|
||||||
totalRequired: report.TotalProofsRequired.ToString(),
|
lines.Add($"No proofs were missed {emojiMaps.NoProofsMissed}");
|
||||||
totalMissed: report.MissedProofs.Length.ToString()
|
return;
|
||||||
);
|
}
|
||||||
|
|
||||||
|
var totalMissed = reportsWithMissedProofs.Sum(r => r.MissedProofs.Length);
|
||||||
|
if (totalMissed > 10)
|
||||||
|
{
|
||||||
|
lines.Add($"[{totalMissed}] proofs were missed {emojiMaps.ManyProofsMissed}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var report in reportsWithMissedProofs)
|
||||||
|
{
|
||||||
|
DescribeMissedProof(lines, report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatPeriodReportLine(string periodNumber, string totalSlots, string totalRequired, string totalMissed)
|
private void DescribeMissedProof(List<string> lines, PeriodReport report)
|
||||||
{
|
{
|
||||||
return $"{periodNumber.PadLeft(10)} {totalSlots.PadLeft(10)} {totalRequired.PadLeft(10)} {totalMissed.PadLeft(10)}";
|
foreach (var missedProof in report.MissedProofs)
|
||||||
|
{
|
||||||
|
DescribeMissedProof(lines, missedProof);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DescribeMissedProof(List<string> lines, PeriodProofMissed missedProof)
|
||||||
|
{
|
||||||
|
lines.Add($"[{FormatHost(missedProof.Host)}] missed proof for {FormatRequestId(missedProof.Request)} (slotIndex: {missedProof.SlotIndex})");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string FormatHost(EthAddress? host)
|
||||||
|
{
|
||||||
|
if (host == null) return "Unknown host";
|
||||||
|
return host.Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddRequestBlock(RequestEvent requestEvent, string eventName, params string[] content)
|
private void AddRequestBlock(RequestEvent requestEvent, string eventName, params string[] content)
|
||||||
@ -189,10 +223,20 @@ namespace TestNetRewarder
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string FormatRequestId(RequestEvent requestEvent)
|
private string FormatRequestId(RequestEvent requestEvent)
|
||||||
|
{
|
||||||
|
return FormatRequestId(requestEvent.Request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string FormatRequestId(IChainStateRequest request)
|
||||||
|
{
|
||||||
|
return FormatRequestId(request.Request.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string FormatRequestId(string id)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
$"({emojiMaps.StringToEmojis(requestEvent.Request.Request.Id, 3)})" +
|
$"({emojiMaps.StringToEmojis(id, 3)})" +
|
||||||
$"`{requestEvent.Request.Request.Id}`";
|
$"`{id}`";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BytesToHexString(byte[] bytes)
|
private string BytesToHexString(byte[] bytes)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user