Skip to content

Commit 1e29a79

Browse files
committed
all hail our enospecv2 overlords
1 parent 9840495 commit 1e29a79

File tree

17 files changed

+126
-96
lines changed

17 files changed

+126
-96
lines changed

EnoChecker/Controllers/CheckerController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@ public async Task<IActionResult> Flag([FromBody] CheckerTaskMessage ctm)
6363
throw new Exception("invalid method");
6464
}
6565

66-
this.logger.LogInformation($"Task {ctm.RunId} succeeded");
66+
this.logger.LogInformation($"Task {ctm.TaskId} succeeded");
6767
return this.Json(new CheckerResultMessage(CheckerResult.OK, null));
6868
}
6969
catch (OperationCanceledException)
7070
{
71-
this.logger.LogWarning($"Task {ctm.RunId} was cancelled");
71+
this.logger.LogWarning($"Task {ctm.TaskId} was cancelled");
7272
return this.Json(new CheckerResultMessage(CheckerResult.OFFLINE, null));
7373
}
7474
catch (MumbleException e)
7575
{
76-
this.logger.LogWarning($"Task {ctm.RunId} has failed: {e.ToFancyString()}");
76+
this.logger.LogWarning($"Task {ctm.TaskId} has failed: {e.ToFancyString()}");
7777
return this.Json(new CheckerResultMessage(CheckerResult.MUMBLE, e.Message));
7878
}
7979
catch (OfflineException e)
8080
{
81-
this.logger.LogWarning($"Task {ctm.RunId} has failed: {e.ToFancyString()}");
81+
this.logger.LogWarning($"Task {ctm.TaskId} has failed: {e.ToFancyString()}");
8282
return this.Json(new CheckerResultMessage(CheckerResult.OFFLINE, e.Message));
8383
}
8484
catch (Exception e)
8585
{
86-
this.logger.LogError($"Task {ctm.RunId} has failed: {e.ToFancyString()}");
86+
this.logger.LogError($"Task {ctm.TaskId} has failed: {e.ToFancyString()}");
8787
return this.Json(new CheckerResultMessage(CheckerResult.INTERNAL_ERROR, null));
8888
}
8989
}

EnoCore/Configuration/Configuration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public sealed record ConfigurationService(
3737
int FlagsPerRound,
3838
int NoisesPerRound,
3939
int HavocsPerRound,
40-
int FlagStores,
40+
int FlagVariants,
41+
int HavocVariants,
42+
int NoiseVariants,
4143
long WeightFactor,
4244
bool Active,
4345
string[] Checkers);

EnoCore/Configuration/JsonConfiguration.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,12 @@ public async Task<ConfigurationService> Validate()
196196
return new(
197197
this.Id,
198198
this.Name,
199-
this.FlagsPerRoundMultiplier * infoMessage.FlagCount,
200-
this.NoisesPerRoundMultiplier * infoMessage.NoiseCount,
201-
this.HavocsPerRoundMultiplier * infoMessage.HavocCount,
202-
infoMessage.FlagCount,
199+
this.FlagsPerRoundMultiplier * infoMessage.FlagVariants,
200+
this.NoisesPerRoundMultiplier * infoMessage.NoiseVariants,
201+
this.HavocsPerRoundMultiplier * infoMessage.HavocVariants,
202+
infoMessage.FlagVariants,
203+
infoMessage.NoiseVariants,
204+
infoMessage.HavocVariants,
203205
this.WeightFactor,
204206
this.Active,
205207
this.Checkers);

EnoCore/Logging/EnoLogger.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
9595
module,
9696
null,
9797
task.Payload,
98-
task.TaskIndex,
98+
task.UniqueVariantId,
99+
task.GetTaskChainId(),
99100
task.Id,
100101
task.CurrentRoundId,
101102
task.RelatedRoundId,
@@ -117,14 +118,15 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
117118
module,
118119
null,
119120
taskMessage.Flag,
120-
taskMessage.FlagIndex,
121-
taskMessage.RunId,
122-
taskMessage.RoundId,
121+
taskMessage.VariantId,
122+
taskMessage.TaskChainId,
123+
taskMessage.TaskId,
124+
taskMessage.CurrentRoundId,
123125
taskMessage.RelatedRoundId,
124126
message,
125127
taskMessage.TeamName,
126128
taskMessage.TeamId,
127-
taskMessage.ServiceName,
129+
this.serviceName,
128130
Enum.GetName(typeof(CheckerTaskMethod), taskMessage.Method));
129131
this.provider.Log($"##ENOLOGMESSAGE {JsonSerializer.Serialize(enoLogMessage, EnoCoreUtil.CamelCaseEnumConverterOptions)}\n");
130132
hadScope = true;
@@ -149,6 +151,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
149151
null,
150152
null,
151153
null,
154+
null,
152155
message,
153156
null,
154157
null,

EnoCore/Models/CheckerInfoMessage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public sealed record CheckerInfoMessage(
66
string ServiceName,
7-
int FlagCount,
8-
int NoiseCount,
9-
int HavocCount);
7+
int FlagVariants,
8+
int NoiseVariants,
9+
int HavocVariants);
1010
}

EnoCore/Models/CheckerTask.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,23 @@ public sealed record CheckerTask(
4747
DateTime StartTime,
4848
int MaxRunningTime,
4949
long RoundLength,
50-
long TaskIndex,
50+
long UniqueVariantId,
51+
long VariantId,
5152
CheckerResult CheckerResult,
5253
string? ErrorMessage,
53-
CheckerTaskLaunchStatus CheckerTaskLaunchStatus);
54+
CheckerTaskLaunchStatus CheckerTaskLaunchStatus)
55+
{
56+
public string GetTaskChainId()
57+
{
58+
return this.Method switch
59+
{
60+
CheckerTaskMethod.putflag => $"flag_{this.ServiceId}_r{this.RelatedRoundId}_t{this.TeamId}_i{this.UniqueVariantId}",
61+
CheckerTaskMethod.getflag => $"flag_{this.ServiceId}_r{this.RelatedRoundId}_t{this.TeamId}_i{this.UniqueVariantId}",
62+
CheckerTaskMethod.putnoise => $"noise_{this.ServiceId}_r{this.RelatedRoundId}_t{this.TeamId}_i{this.UniqueVariantId}",
63+
CheckerTaskMethod.getnoise => $"noise_{this.ServiceId}_r{this.RelatedRoundId}_t{this.TeamId}_i{this.UniqueVariantId}",
64+
CheckerTaskMethod.havoc => $"havoc_{this.ServiceId}_r{this.RelatedRoundId}_t{this.TeamId}_i{this.UniqueVariantId}",
65+
_ => throw new NotImplementedException(),
66+
};
67+
}
68+
}
5469
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
namespace EnoCore.Models
22
{
33
public sealed record CheckerTaskMessage(
4-
long RunId,
4+
long TaskId,
55
CheckerTaskMethod Method,
66
string Address,
7-
long ServiceId,
8-
string ServiceName,
97
long TeamId,
108
string TeamName,
9+
long CurrentRoundId,
1110
long RelatedRoundId,
12-
long RoundId,
1311
string? Flag,
14-
long FlagIndex,
12+
long VariantId,
1513
long Timeout,
16-
long RoundLength);
14+
long RoundLength,
15+
string TaskChainId);
1716
}

EnoCore/Models/EnoLogMessage.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public record EnoLogMessage(
1515
string? Module,
1616
string? Function,
1717
string? Flag,
18-
long? FlagIndex,
18+
long? VariantId,
19+
string? TaskChainId,
1920
long? RunId,
2021
long? RoundId,
2122
long? RelatedRoundId,

EnoCore/Models/EnoStatisticsMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static CheckerTaskLaunchMessage FromCheckerTask(CheckerTask task)
3131
task.CurrentRoundId,
3232
task.ServiceName,
3333
task.Method.ToString(),
34-
task.TaskIndex);
34+
task.UniqueVariantId);
3535
}
3636
}
3737

@@ -50,7 +50,7 @@ public static CheckerTaskFinishedMessage FromCheckerTask(CheckerTask task)
5050
task.CurrentRoundId,
5151
task.ServiceName,
5252
task.Method.ToString(),
53-
task.TaskIndex,
53+
task.UniqueVariantId,
5454
(DateTime.UtcNow - task.StartTime).TotalSeconds,
5555
task.CheckerResult.ToString());
5656
}

EnoCore/Models/Service.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ public Service(
1212
long flagsPerRound,
1313
long noisesPerRound,
1414
long havocsPerRound,
15-
long flagStores,
15+
long flagVariants,
16+
long noiseVariants,
17+
long havocVariants,
1618
bool active)
1719
{
1820
this.Id = id;
1921
this.Name = name;
2022
this.FlagsPerRound = flagsPerRound;
2123
this.NoisesPerRound = noisesPerRound;
2224
this.HavocsPerRound = havocsPerRound;
23-
this.FlagStores = flagStores;
25+
this.FlagVariants = flagVariants;
26+
this.NoiseVariants = noiseVariants;
27+
this.HavocVariants = havocVariants;
2428
this.Active = active;
2529
}
2630

@@ -30,7 +34,9 @@ public Service(
3034
public long FlagsPerRound { get; set; }
3135
public long NoisesPerRound { get; set; }
3236
public long HavocsPerRound { get; set; }
33-
public long FlagStores { get; set; }
37+
public long FlagVariants { get; set; }
38+
public long NoiseVariants { get; set; }
39+
public long HavocVariants { get; set; }
3440
public bool Active { get; set; }
3541
#pragma warning restore SA1516 // Elements should be separated by blank line
3642
}

0 commit comments

Comments
 (0)