mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-04 06:23:09 +00:00
Adds retry for block transaction fetch
This commit is contained in:
parent
62e5f523e8
commit
a4342273f2
@ -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))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -113,7 +113,7 @@ 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}'");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user