diff --git a/Framework/NethereumWorkflow/NethereumInteraction.cs b/Framework/NethereumWorkflow/NethereumInteraction.cs index 6a34e848..47b7ee20 100644 --- a/Framework/NethereumWorkflow/NethereumInteraction.cs +++ b/Framework/NethereumWorkflow/NethereumInteraction.cs @@ -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)))); } } } diff --git a/ProjectPlugins/CodexContractsPlugin/CodexContractsEvents.cs b/ProjectPlugins/CodexContractsPlugin/CodexContractsEvents.cs index e2d8a11a..6adf4ae7 100644 --- a/ProjectPlugins/CodexContractsPlugin/CodexContractsEvents.cs +++ b/ProjectPlugins/CodexContractsPlugin/CodexContractsEvents.cs @@ -19,7 +19,7 @@ namespace CodexContractsPlugin SlotFreedEventDTO[] GetSlotFreedEvents(); SlotReservationsFullEventDTO[] GetSlotReservationsFullEvents(); ProofSubmittedEventDTO[] GetProofSubmittedEvents(); - ReserveSlotFunction[] GetReserveSlotCalls(); + void GetReserveSlotCalls(Action onFunction); } public class CodexContractsEvents : ICodexContractsEvents @@ -100,15 +100,13 @@ namespace CodexContractsPlugin return events.Select(SetBlockOnEvent).ToArray(); } - public ReserveSlotFunction[] GetReserveSlotCalls() + public void GetReserveSlotCalls(Action onFunction) { - var result = new List(); gethNode.IterateFunctionCalls(BlockInterval, (b, fn) => { fn.Block = b; - result.Add(fn); + onFunction(fn); }); - return result.ToArray(); } private T SetBlockOnEvent(EventLog e) where T : IHasBlock diff --git a/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs b/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs index 39d2e1b3..390e138b 100644 --- a/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs +++ b/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs @@ -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(); + 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}"); diff --git a/Tools/TraceContract/ChainTracer.cs b/Tools/TraceContract/ChainTracer.cs index c678667a..ec723084 100644 --- a/Tools/TraceContract/ChainTracer.cs +++ b/Tools/TraceContract/ChainTracer.cs @@ -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()); diff --git a/Tools/TraceContract/Output.cs b/Tools/TraceContract/Output.cs index 4c0fda3d..255bbf3e 100644 --- a/Tools/TraceContract/Output.cs +++ b/Tools/TraceContract/Output.cs @@ -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}'"); }