mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-17 20:53:12 +00:00
Merge branch 'master' into feature/require-profiler-branch
This commit is contained in:
commit
f8293c337a
4
.github/workflows/trace-contract.yaml
vendored
4
.github/workflows/trace-contract.yaml
vendored
@ -11,7 +11,7 @@ on:
|
||||
env:
|
||||
SOURCE: ${{ format('{0}/{1}', github.server_url, github.repository) }}
|
||||
BRANCH: ${{ github.ref_name }}
|
||||
OUTPUT_FOLDER: "~/output"
|
||||
OUTPUT_FOLDER: output
|
||||
ES_USERNAME: ${{ secrets.ES_USERNAME }}
|
||||
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
|
||||
ES_HOST: ${{ secrets.ES_HOST }}
|
||||
@ -38,6 +38,6 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: contract-trace
|
||||
path: ~/output/*
|
||||
path: ${{ env.OUTPUT_FOLDER }}/
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
@ -146,7 +146,13 @@ namespace NethereumWorkflow
|
||||
|
||||
public BlockWithTransactions GetBlockWithTransactions(ulong number)
|
||||
{
|
||||
return Time.Wait(web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(new BlockParameter(number)));
|
||||
var retry = new Retry(nameof(GetBlockWithTransactions),
|
||||
maxTimeout: TimeSpan.FromMinutes(1.0),
|
||||
sleepAfterFail: TimeSpan.FromSeconds(1.0),
|
||||
onFail: f => { },
|
||||
failFast: false);
|
||||
|
||||
return retry.Run(() => Time.Wait(web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(new BlockParameter(number))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ namespace CodexContractsPlugin
|
||||
|
||||
AddEnvVar("DISTTEST_NETWORK_URL", address.ToString());
|
||||
AddEnvVar("HARDHAT_NETWORK", "codexdisttestnetwork");
|
||||
AddEnvVar("HARDHAT_IGNITION_CONFIRM_DEPLOYMENT", "false");
|
||||
AddEnvVar("KEEP_ALIVE", "1");
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ namespace CodexContractsPlugin
|
||||
SlotFreedEventDTO[] GetSlotFreedEvents();
|
||||
SlotReservationsFullEventDTO[] GetSlotReservationsFullEvents();
|
||||
ProofSubmittedEventDTO[] GetProofSubmittedEvents();
|
||||
ReserveSlotFunction[] GetReserveSlotCalls();
|
||||
void GetReserveSlotCalls(Action<ReserveSlotFunction> onFunction);
|
||||
}
|
||||
|
||||
public class CodexContractsEvents : ICodexContractsEvents
|
||||
@ -100,15 +100,13 @@ namespace CodexContractsPlugin
|
||||
return events.Select(SetBlockOnEvent).ToArray();
|
||||
}
|
||||
|
||||
public ReserveSlotFunction[] GetReserveSlotCalls()
|
||||
public void GetReserveSlotCalls(Action<ReserveSlotFunction> onFunction)
|
||||
{
|
||||
var result = new List<ReserveSlotFunction>();
|
||||
gethNode.IterateFunctionCalls<ReserveSlotFunction>(BlockInterval, (b, fn) =>
|
||||
{
|
||||
fn.Block = b;
|
||||
result.Add(fn);
|
||||
onFunction(fn);
|
||||
});
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
private T SetBlockOnEvent<T>(EventLog<T> e) where T : IHasBlock
|
||||
|
||||
@ -266,9 +266,10 @@ namespace CodexReleaseTests.MarketTests
|
||||
// should have filled the slot.
|
||||
|
||||
var requestId = r.PurchaseId.ToLowerInvariant();
|
||||
var calls = GetContracts().GetEvents(GetTestRunTimeRange()).GetReserveSlotCalls();
|
||||
var calls = new List<ReserveSlotFunction>();
|
||||
GetContracts().GetEvents(GetTestRunTimeRange()).GetReserveSlotCalls(calls.Add);
|
||||
|
||||
Log($"Request '{requestId}' failed to start. There were {calls.Length} hosts who called reserve-slot for it:");
|
||||
Log($"Request '{requestId}' failed to start. There were {calls.Count} hosts who called reserve-slot for it:");
|
||||
foreach (var c in calls)
|
||||
{
|
||||
Log($" - {c.Block.Utc} Host: {c.FromAddress} RequestId: {c.RequestId.ToHex()} SlotIndex: {c.SlotIndex}");
|
||||
|
||||
@ -36,7 +36,15 @@ namespace TraceContract
|
||||
|
||||
// For this timeline, we log all the calls to reserve-slot.
|
||||
var events = contracts.GetEvents(requestTimeline);
|
||||
output.LogReserveSlotCalls(Filter(events.GetReserveSlotCalls()));
|
||||
|
||||
events.GetReserveSlotCalls(call =>
|
||||
{
|
||||
if (IsThisRequest(call.RequestId))
|
||||
{
|
||||
output.LogReserveSlotCall(call);
|
||||
log.Log("Found reserve-slot call for slotIndex " + call.SlotIndex);
|
||||
}
|
||||
});
|
||||
|
||||
log.Log("Writing blockchain output...");
|
||||
output.WriteContractEvents();
|
||||
@ -67,11 +75,6 @@ namespace TraceContract
|
||||
return tracker.FinishUtc;
|
||||
}
|
||||
|
||||
private ReserveSlotFunction[] Filter(ReserveSlotFunction[] calls)
|
||||
{
|
||||
return calls.Where(c => IsThisRequest(c.RequestId)).ToArray();
|
||||
}
|
||||
|
||||
private Request? GetRequest()
|
||||
{
|
||||
var request = FindRequest(LastHour());
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System.IO.Compression;
|
||||
using System.Numerics;
|
||||
using System.Numerics;
|
||||
using CodexContractsPlugin.ChainMonitor;
|
||||
using CodexContractsPlugin.Marketplace;
|
||||
using Logging;
|
||||
@ -24,18 +23,16 @@ namespace TraceContract
|
||||
private readonly ILog log;
|
||||
private readonly List<Entry> entries = new();
|
||||
private readonly string folder;
|
||||
private readonly List<string> files = new();
|
||||
private readonly Input input;
|
||||
private readonly Config config;
|
||||
|
||||
public Output(ILog log, Input input, Config config)
|
||||
{
|
||||
folder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
folder = config.GetOuputFolder();
|
||||
Directory.CreateDirectory(folder);
|
||||
|
||||
var filename = Path.Combine(folder, $"contract_{input.PurchaseId}");
|
||||
var fileLog = new FileLog(filename);
|
||||
files.Add(fileLog.FullFilename + ".log");
|
||||
foreach (var pair in config.LogReplacements)
|
||||
{
|
||||
fileLog.AddStringReplace(pair.Key, pair.Value);
|
||||
@ -101,9 +98,14 @@ namespace TraceContract
|
||||
|
||||
public LogFile CreateNodeLogTargetFile(string node)
|
||||
{
|
||||
var file = log.CreateSubfile(node);
|
||||
files.Add(file.Filename);
|
||||
return file;
|
||||
return log.CreateSubfile(node);
|
||||
}
|
||||
|
||||
public void ShowOutputFiles(ILog console)
|
||||
{
|
||||
console.Log("Files in output folder:");
|
||||
var files = Directory.GetFiles(folder);
|
||||
foreach (var file in files) console.Log(file);
|
||||
}
|
||||
|
||||
private void Write(Entry e)
|
||||
@ -111,21 +113,11 @@ namespace TraceContract
|
||||
log.Log($"[{Time.FormatTimestamp(e.Utc)}] {e.Msg}");
|
||||
}
|
||||
|
||||
private void LogReserveSlotCall(ReserveSlotFunction call)
|
||||
public void LogReserveSlotCall(ReserveSlotFunction call)
|
||||
{
|
||||
Add(call.Block.Utc, $"Reserve-slot called. Index: {call.SlotIndex} Host: '{call.FromAddress}'");
|
||||
}
|
||||
|
||||
public string Package()
|
||||
{
|
||||
var outputFolder = config.GetOuputFolder();
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
var filename = Path.Combine(outputFolder, $"contract_{input.PurchaseId}.zip");
|
||||
|
||||
ZipFile.CreateFromDirectory(folder, filename);
|
||||
return filename;
|
||||
}
|
||||
|
||||
private void Add(DateTime utc, string msg)
|
||||
{
|
||||
entries.Add(new Entry(utc, msg));
|
||||
|
||||
@ -55,9 +55,7 @@ namespace TraceContract
|
||||
Log("Downloading storage nodes logs for the request timerange...");
|
||||
DownloadStorageNodeLogs(requestTimeRange, entryPoint.Tools);
|
||||
|
||||
Log("Packaging...");
|
||||
var zipFilename = output.Package();
|
||||
Log($"Saved to '{zipFilename}'");
|
||||
output.ShowOutputFiles(log);
|
||||
|
||||
entryPoint.Decommission(false, false, false);
|
||||
Log("Done");
|
||||
|
||||
BIN
docs/TraceContract_HowTo.png
Normal file
BIN
docs/TraceContract_HowTo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 268 KiB |
Loading…
x
Reference in New Issue
Block a user