From 3b2cbf73fa64f2b56aa4e723c0a5cbe91b0972dc Mon Sep 17 00:00:00 2001 From: dangershony Date: Mon, 9 Dec 2024 21:46:35 +0000 Subject: [PATCH] add a debug page and track the assembly version that is used to sign and verify sig --- src/Angor/Client/Pages/DebugPage.razor | 40 +++++++++++++++ .../ProtocolNew/FounderTransactionActions.cs | 2 + .../ProtocolNew/InvestorTransactionActions.cs | 3 +- .../Shared/Utilities/AssemblyInfoHelper.cs | 51 +++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/Angor/Client/Pages/DebugPage.razor create mode 100644 src/Angor/Shared/Utilities/AssemblyInfoHelper.cs diff --git a/src/Angor/Client/Pages/DebugPage.razor b/src/Angor/Client/Pages/DebugPage.razor new file mode 100644 index 00000000..221d2e32 --- /dev/null +++ b/src/Angor/Client/Pages/DebugPage.razor @@ -0,0 +1,40 @@ +@page "/debug" + +@using Angor.Shared.Utilities +@inject ILogger Logger + +Debug Page + +

Assembly Information

+ +@foreach (var assembly in assemblyInfos) +{ +
+
+
@assembly.Name
+
+
+

Version: @assembly.Version

+

Full Name: @assembly.FullName

+

Location: @assembly.Location

+

Image Runtime Version: @assembly.ImageRuntimeVersion

+

Entry Point: @assembly.EntryPoint

+

Referenced Assemblies:

+
    + @foreach (var referencedAssembly in assembly.ReferencedAssemblies) + { +
  • @referencedAssembly
  • + } +
+
+
+} + +@code { + private List assemblyInfos = new(); + + protected override void OnInitialized() + { + assemblyInfos = AssemblyInfoHelper.GetAllAssembliesInfo(); + } +} diff --git a/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs b/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs index d18860b8..c8ff6a4c 100644 --- a/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs +++ b/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs @@ -55,6 +55,8 @@ public SignatureInfo SignInvestorRecoveryTransactions(ProjectInfo projectInfo, s SignatureInfo info = new SignatureInfo { ProjectIdentifier = projectInfo.ProjectIdentifier }; + AssemblyLogger.LogAssemblyVersion(key.GetType(), _logger); + // todo: david change to Enumerable.Range for (var stageIndex = 0; stageIndex < projectInfo.Stages.Count; stageIndex++) { diff --git a/src/Angor/Shared/ProtocolNew/InvestorTransactionActions.cs b/src/Angor/Shared/ProtocolNew/InvestorTransactionActions.cs index 13ca3b12..4378d493 100644 --- a/src/Angor/Shared/ProtocolNew/InvestorTransactionActions.cs +++ b/src/Angor/Shared/ProtocolNew/InvestorTransactionActions.cs @@ -282,9 +282,10 @@ public bool CheckInvestorRecoverySignatures(ProjectInfo projectInfo, Transaction .Select(_ => _.TxOut) .ToArray(); - bool failedValidation = false; + AssemblyLogger.LogAssemblyVersion(pubkey.GetType(), _logger); // todo: David change to Enumerable.Range + bool failedValidation = false; for (var stageIndex = 0; stageIndex < projectInfo.Stages.Count; stageIndex++) { var scriptStages = _investmentScriptBuilder.BuildProjectScriptsForStage(projectInfo, investorKey, stageIndex, secretHash); diff --git a/src/Angor/Shared/Utilities/AssemblyInfoHelper.cs b/src/Angor/Shared/Utilities/AssemblyInfoHelper.cs new file mode 100644 index 00000000..248fe95f --- /dev/null +++ b/src/Angor/Shared/Utilities/AssemblyInfoHelper.cs @@ -0,0 +1,51 @@ +using System.Reflection; +using Microsoft.Extensions.Logging; + +public static class AssemblyInfoHelper +{ + public static List GetAllAssembliesInfo() + { + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + var assemblyInfos = new List(); + + foreach (var assembly in assemblies) + { + var assemblyInfo = new AssemblyInfo + { + Name = assembly.GetName().Name, + Version = assembly.GetName().Version?.ToString() ?? "Version not found", + FullName = assembly.FullName, + Location = assembly.Location, + ImageRuntimeVersion = assembly.ImageRuntimeVersion, + EntryPoint = assembly.EntryPoint?.ToString() ?? "No entry point", + ReferencedAssemblies = assembly.GetReferencedAssemblies().Select(a => a.FullName).ToList() + }; + + assemblyInfos.Add(assemblyInfo); + } + + return assemblyInfos; + } +} + +public class AssemblyInfo +{ + public string Name { get; set; } + public string Version { get; set; } + public string FullName { get; set; } + public string Location { get; set; } + public string ImageRuntimeVersion { get; set; } + public string EntryPoint { get; set; } + public List ReferencedAssemblies { get; set; } = new(); +} + +public static class AssemblyLogger +{ + public static void LogAssemblyVersion(Type type, ILogger logger) + { + var assembly = type.Assembly; + var version = assembly.GetName().Version?.ToString() ?? "Version not found"; + var name = assembly.GetName().Name; + logger.LogInformation($"Assembly: {name}, Version: {version}"); + } +}