mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-16 20:23:11 +00:00
Prints all chain calls every period
This commit is contained in:
parent
35816141a3
commit
015eaef638
@ -20,5 +20,10 @@
|
||||
public DateTime From { get; }
|
||||
public DateTime To { get; }
|
||||
public TimeSpan Duration { get; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Time.FormatTimestamp(From)} -> {Time.FormatTimestamp(To)} ({Time.FormatDuration(Duration)})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,17 +74,13 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
var callReports = new List<FunctionCallReport>();
|
||||
geth.IterateTransactions(blockRange, (t, blkI, blkUtc) =>
|
||||
{
|
||||
CreateFunctionCallReport<MarkProofAsMissingFunction>(callReports, t, blkUtc);
|
||||
CreateFunctionCallReport<SubmitProofFunction>(callReports, t, blkUtc);
|
||||
CreateFunctionCallReport<FreeSlot1Function>(callReports, t, blkUtc);
|
||||
CreateFunctionCallReport<FreeSlotFunction>(callReports, t, blkUtc);
|
||||
var reporter = new CallReporter(callReports, t, blkUtc, blkI);
|
||||
reporter.Run();
|
||||
|
||||
});
|
||||
|
||||
var report = new PeriodReport(
|
||||
new ProofPeriod(
|
||||
currentPeriod.PeriodNumber,
|
||||
timeRange.From,
|
||||
timeRange.To),
|
||||
new ProofPeriod(currentPeriod.PeriodNumber, timeRange, blockRange),
|
||||
currentPeriod.RequiredProofs.ToArray(),
|
||||
callReports.ToArray());
|
||||
|
||||
@ -92,16 +88,6 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
reports.Add(report);
|
||||
}
|
||||
|
||||
private void CreateFunctionCallReport<TFunc>(List<FunctionCallReport> reports, Transaction t, DateTime blockUtc) where TFunc : FunctionMessage, new()
|
||||
{
|
||||
if (t.IsTransactionForFunctionMessage<TFunc>())
|
||||
{
|
||||
var func = t.DecodeTransactionToFunctionMessage<TFunc>();
|
||||
|
||||
reports.Add(new FunctionCallReport(blockUtc, typeof(TFunc).Name, JsonConvert.SerializeObject(func)));
|
||||
}
|
||||
}
|
||||
|
||||
private void ForEachActiveSlot(IChainStateRequest[] requests, Action<IChainStateRequest, ulong> action)
|
||||
{
|
||||
foreach (var request in requests)
|
||||
@ -114,6 +100,65 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
}
|
||||
}
|
||||
|
||||
public class CallReporter
|
||||
{
|
||||
private readonly List<FunctionCallReport> reports;
|
||||
private readonly Transaction t;
|
||||
private readonly DateTime blockUtc;
|
||||
private readonly ulong blockNumber;
|
||||
|
||||
public CallReporter(List<FunctionCallReport> reports, Transaction t, DateTime blockUtc, ulong blockNumber)
|
||||
{
|
||||
this.reports = reports;
|
||||
this.t = t;
|
||||
this.blockUtc = blockUtc;
|
||||
this.blockNumber = blockNumber;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
CreateFunctionCallReport<CanMarkProofAsMissingFunction>();
|
||||
CreateFunctionCallReport<CanReserveSlotFunction>();
|
||||
CreateFunctionCallReport<ConfigurationFunction>();
|
||||
CreateFunctionCallReport<CurrentCollateralFunction>();
|
||||
CreateFunctionCallReport<FillSlotFunction>();
|
||||
CreateFunctionCallReport<FreeSlot1Function>();
|
||||
CreateFunctionCallReport<FreeSlotFunction>();
|
||||
CreateFunctionCallReport<GetActiveSlotFunction>();
|
||||
CreateFunctionCallReport<GetChallengeFunction>();
|
||||
CreateFunctionCallReport<GetHostFunction>();
|
||||
CreateFunctionCallReport<GetPointerFunction>();
|
||||
CreateFunctionCallReport<GetRequestFunction>();
|
||||
CreateFunctionCallReport<IsProofRequiredFunction>();
|
||||
CreateFunctionCallReport<MarkProofAsMissingFunction>();
|
||||
CreateFunctionCallReport<MissingProofsFunction>();
|
||||
CreateFunctionCallReport<MyRequestsFunction>();
|
||||
CreateFunctionCallReport<MySlotsFunction>();
|
||||
CreateFunctionCallReport<RequestEndFunction>();
|
||||
CreateFunctionCallReport<RequestExpiryFunction>();
|
||||
CreateFunctionCallReport<RequestStateFunction>();
|
||||
CreateFunctionCallReport<RequestStorageFunction>();
|
||||
CreateFunctionCallReport<ReserveSlotFunction>();
|
||||
CreateFunctionCallReport<SlotProbabilityFunction>();
|
||||
CreateFunctionCallReport<SlotStateFunction>();
|
||||
CreateFunctionCallReport<SubmitProofFunction>();
|
||||
CreateFunctionCallReport<TokenFunction>();
|
||||
CreateFunctionCallReport<WillProofBeRequiredFunction>();
|
||||
CreateFunctionCallReport<WithdrawFundsFunction>();
|
||||
CreateFunctionCallReport<WithdrawFunds1Function>();
|
||||
}
|
||||
|
||||
private void CreateFunctionCallReport<TFunc>() where TFunc : FunctionMessage, new()
|
||||
{
|
||||
if (t.IsTransactionForFunctionMessage<TFunc>())
|
||||
{
|
||||
var func = t.DecodeTransactionToFunctionMessage<TFunc>();
|
||||
|
||||
reports.Add(new FunctionCallReport(blockUtc, blockNumber, typeof(TFunc).Name, JsonConvert.SerializeObject(func)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PeriodMonitorResult
|
||||
{
|
||||
public PeriodMonitorResult(PeriodReport[] reports)
|
||||
|
||||
@ -23,7 +23,7 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
{
|
||||
log.Log($" Required: {r.Describe()}");
|
||||
}
|
||||
log.Log(" - Calls:");
|
||||
log.Log($" - Calls: {FunctionCalls.Length}");
|
||||
foreach (var f in FunctionCalls)
|
||||
{
|
||||
log.Log($" - {f.Describe()}");
|
||||
@ -33,20 +33,22 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
|
||||
public class FunctionCallReport
|
||||
{
|
||||
public FunctionCallReport(DateTime utc, string name, string payload)
|
||||
public FunctionCallReport(DateTime utc, ulong blockNumber, string name, string payload)
|
||||
{
|
||||
Utc = utc;
|
||||
BlockNumber = blockNumber;
|
||||
Name = name;
|
||||
Payload = payload;
|
||||
}
|
||||
|
||||
public DateTime Utc { get; }
|
||||
public ulong BlockNumber { get; }
|
||||
public string Name { get; }
|
||||
public string Payload { get; }
|
||||
|
||||
public string Describe()
|
||||
{
|
||||
return $"[{Time.FormatTimestamp(Utc)}] {Name} = \"{Payload}\"";
|
||||
return $"[{Time.FormatTimestamp(Utc)}][{BlockNumber}] {Name} = \"{Payload}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,20 +4,20 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
{
|
||||
public class ProofPeriod
|
||||
{
|
||||
public ProofPeriod(ulong periodNumber, DateTime startUtc, DateTime endUtc)
|
||||
public ProofPeriod(ulong periodNumber, TimeRange timeRange, BlockInterval blockRange)
|
||||
{
|
||||
PeriodNumber = periodNumber;
|
||||
StartUtc = startUtc;
|
||||
EndUtc = endUtc;
|
||||
TimeRange = timeRange;
|
||||
BlockRange = blockRange;
|
||||
}
|
||||
|
||||
public ulong PeriodNumber { get; }
|
||||
public DateTime StartUtc { get; }
|
||||
public DateTime EndUtc { get; }
|
||||
public TimeRange TimeRange { get; }
|
||||
public BlockInterval BlockRange { get; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{PeriodNumber} - {Time.FormatTimestamp(StartUtc)} -> {Time.FormatTimestamp(EndUtc)}";
|
||||
return $"{{{PeriodNumber} - {TimeRange} {BlockRange}}}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,8 +85,11 @@ namespace CodexPlugin
|
||||
{
|
||||
"JSONRPC-WS-CLIENT",
|
||||
"JSONRPC-HTTP-CLIENT",
|
||||
"codex",
|
||||
"repostore"
|
||||
};
|
||||
|
||||
var alwaysIgnoreTopics = new []
|
||||
{
|
||||
"JSONRPC-CLIENT"
|
||||
};
|
||||
|
||||
level = $"{level};" +
|
||||
@ -94,7 +97,8 @@ namespace CodexPlugin
|
||||
$"{CustomTopics.Libp2p.ToString()!.ToLowerInvariant()}:{string.Join(",", libp2pTopics)};" +
|
||||
$"{CustomTopics.ContractClock.ToString().ToLowerInvariant()}:{string.Join(",", contractClockTopics)};" +
|
||||
$"{CustomTopics.JsonSerialize.ToString().ToLowerInvariant()}:{string.Join(",", jsonSerializeTopics)};" +
|
||||
$"{CustomTopics.MarketplaceInfra.ToString().ToLowerInvariant()}:{string.Join(",", marketplaceInfraTopics)}";
|
||||
$"{CustomTopics.MarketplaceInfra.ToString().ToLowerInvariant()}:{string.Join(",", marketplaceInfraTopics)};" +
|
||||
$"{CodexLogLevel.Error.ToString()}:{string.Join(",", alwaysIgnoreTopics)}";
|
||||
|
||||
if (CustomTopics.BlockExchange != null)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user