From 955096cb063aac2695034cace7b18f494ac10577 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Tue, 3 Sep 2024 08:36:19 +0800 Subject: [PATCH 01/17] Add whitelist solution --- AElf.All.sln | 14 +++++++++++++ src/AElf.Launcher/appsettings.Production.json | 4 ++-- src/AElf.Launcher/appsettings.json | 8 +++---- .../AElf.Sdk.CSharp.Internal.csproj | 16 ++++++++++++++ src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs | 3 +++ .../InternalBuiltIns.cs | 21 +++++++++++++++++++ .../AElf.Sdk.CSharp.Spec.csproj | 10 +++++++++ src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs | 6 ++++++ src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj | 4 ++++ 9 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj create mode 100644 src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs create mode 100644 src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs create mode 100644 src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj create mode 100644 src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs diff --git a/AElf.All.sln b/AElf.All.sln index 34ad27a9ac..782e186970 100644 --- a/AElf.All.sln +++ b/AElf.All.sln @@ -385,6 +385,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.Core", "src\AElf.Kernel.FeatureDisable.Core\AElf.Kernel.FeatureDisable.Core.csproj", "{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Spec", "src\AElf.Sdk.CSharp.Spec\AElf.Sdk.CSharp.Spec.csproj", "{45A77C41-142E-4296-A14A-D53067EC8B75}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Internal", "src\AElf.Sdk.CSharp.Internal\AElf.Sdk.CSharp.Internal.csproj", "{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1107,6 +1111,14 @@ Global {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.Build.0 = Release|Any CPU + {45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.Build.0 = Release|Any CPU + {A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1301,5 +1313,7 @@ Global {A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC} {8C0D86A4-D1A7-4B61-AC44-755F5AC75D67} = {4E54480A-D155-43ED-9736-1A5BE7957211} {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC} + {45A77C41-142E-4296-A14A-D53067EC8B75} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09} + {A77380A7-E425-45A3-BF3F-F865DA4F3F4E} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09} EndGlobalSection EndGlobal diff --git a/src/AElf.Launcher/appsettings.Production.json b/src/AElf.Launcher/appsettings.Production.json index 14aeb670bf..d321f10b7f 100644 --- a/src/AElf.Launcher/appsettings.Production.json +++ b/src/AElf.Launcher/appsettings.Production.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - "BlockchainDb": "redis://localhost:6379?db=1", - "StateDb": "redis://localhost:6379?db=1" + "BlockchainDb": "redis://localhost:8881?db=1", + "StateDb": "redis://localhost:8882?db=1" }, "WebApp": { "TransactionResultStatusCacheSeconds": 180 diff --git a/src/AElf.Launcher/appsettings.json b/src/AElf.Launcher/appsettings.json index 7e3d567c35..c4e11c7af8 100644 --- a/src/AElf.Launcher/appsettings.json +++ b/src/AElf.Launcher/appsettings.json @@ -5,12 +5,12 @@ "AllowedHosts": "*", "CorsOrigins": "*", "ConnectionStrings": { - "BlockchainDb": "redis://localhost:6379?db=1", - "StateDb": "redis://localhost:6379?db=1" + "BlockchainDb": "redis://localhost:6666?db=1", + "StateDb": "redis://localhost:6666?db=1" }, "Account": { - "NodeAccount": "", - "NodeAccountPassword": "" + "NodeAccount": "2E2zpf8zMzZBenM4eqtKJhX2m91UxhR1aPEw7hpBNhnJmzbkbp", + "NodeAccountPassword": "12345678" }, "Network": { "BootNodes": [], diff --git a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj new file mode 100644 index 0000000000..ffd588c16e --- /dev/null +++ b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + enable + enable + + + + + all + + + + diff --git a/src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs b/src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs new file mode 100644 index 0000000000..1b80097c7f --- /dev/null +++ b/src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("AElf.Sdk.CSharp")] \ No newline at end of file diff --git a/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs new file mode 100644 index 0000000000..24c8dcb548 --- /dev/null +++ b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs @@ -0,0 +1,21 @@ +// using System; +// using AElf.Sdk.CSharp.Spec; +// +// namespace AElf.Sdk.CSharp.Internal; +// +// internal class InternalBuiltIns : IBuiltIns +// { +// public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) +// { +// try +// { +// var instance =ebex.Security.Cryptography.Ed25519(); +// instance.FromPublicKey(publicKey); +// return instance.VerifyMessage(message, signature); +// } +// catch (Exception e) +// { +// return false; +// } +// } +// } \ No newline at end of file diff --git a/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj new file mode 100644 index 0000000000..2f4fc77656 --- /dev/null +++ b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs b/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs new file mode 100644 index 0000000000..bb4a5a7de2 --- /dev/null +++ b/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs @@ -0,0 +1,6 @@ +namespace AElf.Sdk.CSharp.Spec; + +public interface IBuiltIns +{ + bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey); +} \ No newline at end of file diff --git a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj index 3d27d43369..1127de5481 100644 --- a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj +++ b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj @@ -13,6 +13,10 @@ + + + all + From 47595fc0d928889f05de1e1aaece49978445833c Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Tue, 3 Sep 2024 16:42:53 +0800 Subject: [PATCH 02/17] Resolve issue of compilation and running, and add unit-test --- src/AElf.Launcher/appsettings.Production.json | 4 +- .../ContractCodeLoadContext.cs | 2 +- .../AElf.Sdk.CSharp.Internal.csproj | 18 +++++--- .../InternalBuiltIns.cs | 46 ++++++++++--------- .../AElf.Sdk.CSharp.Spec.csproj | 1 - src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj | 5 +- .../CSharpSmartContractAbstract.cs | 3 ++ .../CSharpSmartContractContext.cs | 12 ++++- .../AElf.Sdk.CSharp.Tests.csproj | 6 +++ .../CSharpSmartContractContextTests.cs | 46 +++++++++++++++++++ .../ed25519_testdata.json | 44 ++++++++++++++++++ 11 files changed, 151 insertions(+), 36 deletions(-) create mode 100644 test/AElf.Sdk.CSharp.Tests/ed25519_testdata.json diff --git a/src/AElf.Launcher/appsettings.Production.json b/src/AElf.Launcher/appsettings.Production.json index d321f10b7f..14aeb670bf 100644 --- a/src/AElf.Launcher/appsettings.Production.json +++ b/src/AElf.Launcher/appsettings.Production.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - "BlockchainDb": "redis://localhost:8881?db=1", - "StateDb": "redis://localhost:8882?db=1" + "BlockchainDb": "redis://localhost:6379?db=1", + "StateDb": "redis://localhost:6379?db=1" }, "WebApp": { "TransactionResultStatusCacheSeconds": 180 diff --git a/src/AElf.Runtime.CSharp.Core/ContractCodeLoadContext.cs b/src/AElf.Runtime.CSharp.Core/ContractCodeLoadContext.cs index 507ef7bdcc..c8df9a2114 100644 --- a/src/AElf.Runtime.CSharp.Core/ContractCodeLoadContext.cs +++ b/src/AElf.Runtime.CSharp.Core/ContractCodeLoadContext.cs @@ -28,7 +28,7 @@ protected override Assembly Load(AssemblyName assemblyName) /// private Assembly LoadFromFolderOrDefault(AssemblyName assemblyName) { - if (assemblyName.Name.StartsWith("AElf.Sdk")) + if ("AElf.Sdk.CSharp".Equals(assemblyName.Name)) { // Sdk assembly should NOT be shared using var stream = _sdkStreamManager.GetStream(assemblyName); diff --git a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj index ffd588c16e..7557797899 100644 --- a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj +++ b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj @@ -1,16 +1,22 @@  - Exe net8.0 - enable - enable + AElf.Sdk.CSharp.Internal + true + latest + Types for the C# smart contract SDK. + AElf.Sdk.CSharp.Internal - + - + all - + + + + + diff --git a/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs index 24c8dcb548..990e0f49ce 100644 --- a/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs +++ b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs @@ -1,21 +1,25 @@ -// using System; -// using AElf.Sdk.CSharp.Spec; -// -// namespace AElf.Sdk.CSharp.Internal; -// -// internal class InternalBuiltIns : IBuiltIns -// { -// public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) -// { -// try -// { -// var instance =ebex.Security.Cryptography.Ed25519(); -// instance.FromPublicKey(publicKey); -// return instance.VerifyMessage(message, signature); -// } -// catch (Exception e) -// { -// return false; -// } -// } -// } \ No newline at end of file +using System; +using AElf.Sdk.CSharp.Spec; + +namespace AElf.Sdk.CSharp.Internal; + +internal class InternalBuiltIns : IBuiltIns +{ + public static void Initialize() + { + // call this method to ensure this assembly is loaded in the runtime. + } + public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) + { + try + { + var instance = new Rebex.Security.Cryptography.Ed25519(); + instance.FromPublicKey(publicKey); + return instance.VerifyMessage(message, signature); + } + catch (Exception e) + { + return false; + } + } +} \ No newline at end of file diff --git a/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj index 2f4fc77656..3a63532952 100644 --- a/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj +++ b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj @@ -1,7 +1,6 @@  - Exe net8.0 enable enable diff --git a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj index 1127de5481..00cf548872 100644 --- a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj +++ b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj @@ -13,10 +13,7 @@ - - - all - + diff --git a/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs b/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs index 31d642fdf0..5553b6eb5a 100644 --- a/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs +++ b/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs @@ -1,5 +1,6 @@ using AElf.Kernel.SmartContract; using AElf.Types; +using AElf.Sdk.CSharp.Spec; namespace AElf.Sdk.CSharp; @@ -20,4 +21,6 @@ protected void Assert(bool asserted, string message = "Assertion failed!") } internal abstract void InternalInitialize(ISmartContractBridgeContext bridgeContext); + + public IBuiltIns BuiltIns { get; internal set; } } \ No newline at end of file diff --git a/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs b/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs index 5e3ed6c94a..96eeae7eac 100644 --- a/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs +++ b/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using AElf.Kernel.SmartContract; +using AElf.Sdk.CSharp.Internal; +using AElf.Sdk.CSharp.Spec; using AElf.Types; using Google.Protobuf; using Google.Protobuf.WellKnownTypes; @@ -12,11 +14,14 @@ namespace AElf.Sdk.CSharp; /// base class for smart contracts (Context property). It provides access to properties and methods useful for /// implementing the logic in smart contracts. /// -public class CSharpSmartContractContext : ISmartContractBridgeContext +public class CSharpSmartContractContext : ISmartContractBridgeContext, IBuiltIns { + private IBuiltIns BuiltInsImplementation { get; } + public CSharpSmartContractContext(ISmartContractBridgeContext smartContractBridgeContextImplementation) { SmartContractBridgeContextImplementation = smartContractBridgeContextImplementation; + BuiltInsImplementation = new InternalBuiltIns(); } public ISmartContractBridgeContext SmartContractBridgeContextImplementation { get; } @@ -391,4 +396,9 @@ public bool ECVrfVerify(byte[] pubKey, byte[] alpha, byte[] pi, out byte[] beta) { return SmartContractBridgeContextImplementation.ECVrfVerify(pubKey, alpha, pi, out beta); } + + public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) + { + return BuiltInsImplementation.Ed25519Verify(signature, message, publicKey); + } } \ No newline at end of file diff --git a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj index b7379a81dc..91ff826eca 100644 --- a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj +++ b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj @@ -30,4 +30,10 @@ + + + + all + + \ No newline at end of file diff --git a/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs b/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs index 4e0f98d97a..48dcf22768 100644 --- a/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs +++ b/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs @@ -1,3 +1,4 @@ +using System; using AElf.Cryptography; using AElf.Kernel; using AElf.Kernel.SmartContract; @@ -12,6 +13,51 @@ namespace AElf.Sdk.CSharp.Tests; public class CSharpSmartContractContextTests : SdkCSharpTestBase { + [Fact] + public void Verify_Ed25519Verify() + { + var bridgeContext = GetRequiredService().Create(); + var origin = SampleAddress.AddressList[0]; + bridgeContext.TransactionContext = new TransactionContext + { + Origin = origin, + Transaction = new Transaction + { + From = SampleAddress.AddressList[1], + To = SampleAddress.AddressList[2] + } + }; + var contractContext = new CSharpSmartContractContext(bridgeContext); + var publicKey = "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a"; + var message = ""; + var signature = "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b"; + var ed25519VerifyResult = contractContext.Ed25519Verify( + ByteArrayHelper.HexStringToByteArray(signature), + ByteArrayHelper.HexStringToByteArray(message), + ByteArrayHelper.HexStringToByteArray(publicKey)); + ed25519VerifyResult.ShouldBe(true); + + var contractContext1 = new CSharpSmartContractContext(bridgeContext); + var publicKey1 = "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a"; + var message1 = "1"; + var signature1 = "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b"; + Should.Throw(() => contractContext1.Ed25519Verify( + ByteArrayHelper.HexStringToByteArray(signature1), + ByteArrayHelper.HexStringToByteArray(message1), + ByteArrayHelper.HexStringToByteArray(publicKey1))); + + // var contractContext2 = new CSharpSmartContractContext(bridgeContext); + // var publicKey2 = "3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c"; + // var message2 = "72"; + // var signature2 = "92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00"; + // var ed25519VerifyResult2 = contractContext2.Ed25519Verify( + // ByteArrayHelper.HexStringToByteArray(signature2), + // ByteArrayHelper.HexStringToByteArray(message2), + // ByteArrayHelper.HexStringToByteArray(publicKey2)); + // ed25519VerifyResult2.ShouldBe(true); + + } + [Fact] public void Verify_Transaction_Origin_SetValue() { diff --git a/test/AElf.Sdk.CSharp.Tests/ed25519_testdata.json b/test/AElf.Sdk.CSharp.Tests/ed25519_testdata.json new file mode 100644 index 0000000000..60d4a2bad4 --- /dev/null +++ b/test/AElf.Sdk.CSharp.Tests/ed25519_testdata.json @@ -0,0 +1,44 @@ +[ + { + "secret_key": "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60", + "public_key": "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a", + "message": "", + "signed": "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b", + "signature": "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" + }, + { + "secret_key": "4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb", + "public_key": "3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c", + "message": "72", + "signed": "92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c0072", + "signature": "92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00" + }, + { + "secret_key": "c5aa8df43f9f837bedb7442f31dcb7b166d38535076f094b85ce3a2e0b4458f7", + "public_key": "fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025", + "message": "af82", + "signed": "6291d657deec24024827e69c3abe01a30ce548a284743a445e3680d7db5ac3ac18ff9b538d16f290ae67f760984dc6594a7c15e9716ed28dc027beceea1ec40aaf82", + "signature": "6291d657deec24024827e69c3abe01a30ce548a284743a445e3680d7db5ac3ac18ff9b538d16f290ae67f760984dc6594a7c15e9716ed28dc027beceea1ec40a" + }, + { + "secret_key": "0d4a05b07352a5436e180356da0ae6efa0345ff7fb1572575772e8005ed978e9", + "public_key": "e61a185bcef2613a6c7cb79763ce945d3b245d76114dd440bcf5f2dc1aa57057", + "message": "cbc77b", + "signed": "d9868d52c2bebce5f3fa5a79891970f309cb6591e3e1702a70276fa97c24b3a8e58606c38c9758529da50ee31b8219cba45271c689afa60b0ea26c99db19b00ccbc77b", + "signature": "d9868d52c2bebce5f3fa5a79891970f309cb6591e3e1702a70276fa97c24b3a8e58606c38c9758529da50ee31b8219cba45271c689afa60b0ea26c99db19b00c" + }, + { + "secret_key": "6df9340c138cc188b5fe4464ebaa3f7fc206a2d55c3434707e74c9fc04e20ebb", + "public_key": "c0dac102c4533186e25dc43128472353eaabdb878b152aeb8e001f92d90233a7", + "message": "5f4c8989", + "signed": "124f6fc6b0d100842769e71bd530664d888df8507df6c56dedfdb509aeb93416e26b918d38aa06305df3095697c18b2aa832eaa52edc0ae49fbae5a85e150c075f4c8989", + "signature": "124f6fc6b0d100842769e71bd530664d888df8507df6c56dedfdb509aeb93416e26b918d38aa06305df3095697c18b2aa832eaa52edc0ae49fbae5a85e150c07" + }, + { + "secret_key": "b780381a65edf8b78f6945e8dbec7941ac049fd4c61040cf0c324357975a293c", + "public_key": "e253af0766804b869bb1595be9765b534886bbaab8305bf50dbc7f899bfb5f01", + "message": "18b6bec097", + "signed": "b2fc46ad47af464478c199e1f8be169f1be6327c7f9a0a6689371ca94caf04064a01b22aff1520abd58951341603faed768cf78ce97ae7b038abfe456aa17c0918b6bec097", + "signature": "b2fc46ad47af464478c199e1f8be169f1be6327c7f9a0a6689371ca94caf04064a01b22aff1520abd58951341603faed768cf78ce97ae7b038abfe456aa17c09" + } +] \ No newline at end of file From 53f389cec61bd4c2b059ad001ad53803c1decc9e Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Wed, 4 Sep 2024 17:16:56 +0800 Subject: [PATCH 03/17] Revert appsettings.json --- src/AElf.Launcher/appsettings.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AElf.Launcher/appsettings.json b/src/AElf.Launcher/appsettings.json index c4e11c7af8..7e3d567c35 100644 --- a/src/AElf.Launcher/appsettings.json +++ b/src/AElf.Launcher/appsettings.json @@ -5,12 +5,12 @@ "AllowedHosts": "*", "CorsOrigins": "*", "ConnectionStrings": { - "BlockchainDb": "redis://localhost:6666?db=1", - "StateDb": "redis://localhost:6666?db=1" + "BlockchainDb": "redis://localhost:6379?db=1", + "StateDb": "redis://localhost:6379?db=1" }, "Account": { - "NodeAccount": "2E2zpf8zMzZBenM4eqtKJhX2m91UxhR1aPEw7hpBNhnJmzbkbp", - "NodeAccountPassword": "12345678" + "NodeAccount": "", + "NodeAccountPassword": "" }, "Network": { "BootNodes": [], From a57f39eafeb020e1144cd367956a96c3a6d77513 Mon Sep 17 00:00:00 2001 From: gldeng Date: Wed, 4 Sep 2024 18:12:51 +0800 Subject: [PATCH 04/17] feat(zkp): Add methods required for supporting zkp verification over Bn254 --- .../Validators/Method/ArrayValidator.cs | 3 +- .../AElf.Sdk.CSharp.Internal.csproj | 10 ++- .../InternalBuiltIns.cs | 36 +++++++++++ src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs | 4 ++ .../CSharpSmartContractContext.cs | 55 ++++++++++++----- src/AElf.Types/Types/BigIntValue.cs | 61 ++++++++++++++++++- 6 files changed, 150 insertions(+), 19 deletions(-) diff --git a/src/AElf.CSharp.CodeOps/Validators/Method/ArrayValidator.cs b/src/AElf.CSharp.CodeOps/Validators/Method/ArrayValidator.cs index 5a58387f14..08fced5f36 100644 --- a/src/AElf.CSharp.CodeOps/Validators/Method/ArrayValidator.cs +++ b/src/AElf.CSharp.CodeOps/Validators/Method/ArrayValidator.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading; using AElf.CSharp.Core; +using AElf.Types; using Mono.Cecil; using Mono.Cecil.Cil; using Volo.Abp.DependencyInjection; @@ -24,7 +25,7 @@ public class ArrayValidator : IValidator, ITransientDependency .LimitByTotalSize(typeof(decimal), sizeof(decimal)) .LimitByTotalSize(typeof(char), sizeof(char)) .LimitByTotalSize(typeof(String), 128) // Need to limit the size of strings by disallowing String.Concat - + .LimitByTotalSize(typeof(BigIntValue), 128) // It isn't possible to estimate runtime sizes for below, so limit by count .LimitByCount(typeof(Type), 5) .LimitByCount(typeof(Object), 5) // Support object in Linq queries diff --git a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj index 7557797899..7f5bd490af 100644 --- a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj +++ b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj @@ -10,13 +10,19 @@ - + + all + + + all + + all - + diff --git a/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs index 990e0f49ce..0d61e255b8 100644 --- a/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs +++ b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs @@ -1,5 +1,7 @@ using System; using AElf.Sdk.CSharp.Spec; +using Bn254.Net; +using Nethereum.Util; namespace AElf.Sdk.CSharp.Internal; @@ -9,6 +11,7 @@ public static void Initialize() { // call this method to ensure this assembly is loaded in the runtime. } + public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) { try @@ -22,4 +25,37 @@ public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) return false; } } + + public byte[] Keccak256(byte[] message) + { + return Sha3Keccack.Current.CalculateHash(message); + } + + public (byte[] x, byte[] y) Bn254G1Mul(byte[] x1, byte[] y1, byte[] s) + { + var (xUInt256, yUInt256) = Bn254.Net.Bn254.Mul(UInt256.FromBigEndianBytes(x1), UInt256.FromBigEndianBytes(y1), + UInt256.FromBigEndianBytes(s)); + return (xUInt256.ToBigEndianBytes(), yUInt256.ToBigEndianBytes()); + } + + public (byte[] x3, byte[] y3) Bn254G1Add(byte[] x1, byte[] y1, byte[] x2, byte[] y2) + { + var (x3UInt256, y3UInt256) = Bn254.Net.Bn254.Add(UInt256.FromBigEndianBytes(x1), UInt256.FromBigEndianBytes(y1), + UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2)); + return (x3UInt256.ToBigEndianBytes(), y3UInt256.ToBigEndianBytes()); + } + + public bool Bn254Pairing((byte[], byte[], byte[], byte[], byte[], byte[])[] input) + { + var elements = new (UInt256, UInt256, UInt256, UInt256, UInt256, UInt256)[input.Length]; + for (var i = 0; i < input.Length; i++) + { + var (x1, y1, x2, y2, x3, y3) = input[i]; + elements[i] = (UInt256.FromBigEndianBytes(x1), UInt256.FromBigEndianBytes(y1), + UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2), + UInt256.FromBigEndianBytes(x3), UInt256.FromBigEndianBytes(y3)); + } + + return Bn254.Net.Bn254.Pairing(elements); + } } \ No newline at end of file diff --git a/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs b/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs index bb4a5a7de2..f19de71ebe 100644 --- a/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs +++ b/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs @@ -3,4 +3,8 @@ public interface IBuiltIns { bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey); + byte[] Keccak256(byte[] message); + (byte[] x, byte[] y) Bn254G1Mul(byte[] x1, byte[] y1, byte[] s); + (byte[] x3, byte[] y3) Bn254G1Add(byte[] x1, byte[] y1, byte[] x2, byte[] y2); + bool Bn254Pairing((byte[], byte[], byte[], byte[], byte[], byte[])[] input); } \ No newline at end of file diff --git a/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs b/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs index 96eeae7eac..146c0ba31c 100644 --- a/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs +++ b/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs @@ -17,7 +17,7 @@ namespace AElf.Sdk.CSharp; public class CSharpSmartContractContext : ISmartContractBridgeContext, IBuiltIns { private IBuiltIns BuiltInsImplementation { get; } - + public CSharpSmartContractContext(ISmartContractBridgeContext smartContractBridgeContextImplementation) { SmartContractBridgeContextImplementation = smartContractBridgeContextImplementation; @@ -90,7 +90,7 @@ public void FireLogEvent(LogEvent logEvent) /// The height of the block that contains the transaction before charging. /// public Transaction Transaction => SmartContractBridgeContextImplementation.Transaction; - + /// /// The time included in the current blocks header. /// @@ -153,7 +153,7 @@ public void DeployContract(Address address, SmartContractRegistration registrati { SmartContractBridgeContextImplementation.DeployContract(address, registration, name); } - + /// /// Update a smart contract (only the genesis contract can call it). /// @@ -164,17 +164,21 @@ public void UpdateContract(Address address, SmartContractRegistration registrati { SmartContractBridgeContextImplementation.UpdateContract(address, registration, name); } - + public ContractInfoDto DeploySmartContract(Address address, SmartContractRegistration registration, Hash name) { - return SmartContractBridgeContextImplementation.DeploySmartContract(address,registration,name); + return SmartContractBridgeContextImplementation.DeploySmartContract(address, registration, name); } - public ContractInfoDto UpdateSmartContract(Address address, SmartContractRegistration registration, Hash name,string previousContractVersion) + + public ContractInfoDto UpdateSmartContract(Address address, SmartContractRegistration registration, Hash name, + string previousContractVersion) { - return SmartContractBridgeContextImplementation.UpdateSmartContract(address,registration,name,previousContractVersion); + return SmartContractBridgeContextImplementation.UpdateSmartContract(address, registration, name, + previousContractVersion); } - public ContractVersionCheckDto CheckContractVersion(string previousContractVersion, SmartContractRegistration registration) + public ContractVersionCheckDto CheckContractVersion(string previousContractVersion, + SmartContractRegistration registration) { return SmartContractBridgeContextImplementation.CheckContractVersion(previousContractVersion, registration); } @@ -226,13 +230,14 @@ public void SendVirtualInline(Hash fromVirtualAddress, Address toAddress, string SmartContractBridgeContextImplementation.SendVirtualInline(fromVirtualAddress, toAddress, methodName, args); } - - public void SendVirtualInline(Hash fromVirtualAddress, Address toAddress, string methodName, ByteString args,bool logTransaction) + + public void SendVirtualInline(Hash fromVirtualAddress, Address toAddress, string methodName, ByteString args, + bool logTransaction) { SmartContractBridgeContextImplementation.SendVirtualInline(fromVirtualAddress, toAddress, methodName, - args,logTransaction); + args, logTransaction); } - + /// /// Sends a virtual inline transaction to another contract. This method is only available to system smart contract. @@ -250,7 +255,7 @@ public void SendVirtualInlineBySystemContract(Hash fromVirtualAddress, Address t SmartContractBridgeContextImplementation.SendVirtualInlineBySystemContract(fromVirtualAddress, toAddress, methodName, args); } - + public void SendVirtualInlineBySystemContract(Hash fromVirtualAddress, Address toAddress, string methodName, ByteString args, bool logTransaction) { @@ -391,14 +396,34 @@ public Address ConvertVirtualAddressToContractAddressWithContractHashName(Hash v return SmartContractBridgeContextImplementation.ConvertVirtualAddressToContractAddressWithContractHashName( virtualAddress); } - + public bool ECVrfVerify(byte[] pubKey, byte[] alpha, byte[] pi, out byte[] beta) { return SmartContractBridgeContextImplementation.ECVrfVerify(pubKey, alpha, pi, out beta); } - + public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) { return BuiltInsImplementation.Ed25519Verify(signature, message, publicKey); } + + public byte[] Keccak256(byte[] message) + { + return BuiltInsImplementation.Keccak256(message); + } + + public (byte[] x, byte[] y) Bn254G1Mul(byte[] x1, byte[] y1, byte[] s) + { + return BuiltInsImplementation.Bn254G1Mul(x1, y1, s); + } + + public (byte[] x3, byte[] y3) Bn254G1Add(byte[] x1, byte[] y1, byte[] x2, byte[] y2) + { + return BuiltInsImplementation.Bn254G1Add(x1, y1, x2, y2); + } + + public bool Bn254Pairing((byte[], byte[], byte[], byte[], byte[], byte[])[] input) + { + return BuiltInsImplementation.Bn254Pairing(input); + } } \ No newline at end of file diff --git a/src/AElf.Types/Types/BigIntValue.cs b/src/AElf.Types/Types/BigIntValue.cs index 38ddc94df6..f65c8897a3 100644 --- a/src/AElf.Types/Types/BigIntValue.cs +++ b/src/AElf.Types/Types/BigIntValue.cs @@ -5,9 +5,30 @@ namespace AElf.Types { - public partial class BigIntValue : IComparable, IComparable { + #region Frequent Values + + public static BigIntValue Zero => new BigIntValue { Value = "0" }; + public static BigIntValue One => new BigIntValue { Value = "1" }; + + #endregion + + public static BigIntValue FromBigEndianBytes(byte[] bigEndianBytes) + { + var bigInteger = new BigInteger(bigEndianBytes, true, true); + return new BigIntValue + { + Value = bigInteger.ToString() + }; + } + + public byte[] ToBigEndianBytes() + { + var bigInteger = ConvertStringToBigInteger(Value); + return bigInteger.ToByteArray(true, true); + } + public int CompareTo(object obj) { if (!(obj is BigIntValue bigInt)) throw new InvalidOperationException(); @@ -126,6 +147,43 @@ private static bool LessThan(in BigIntValue a, in BigIntValue b) return aBigInt < bBigInt; } + #region Operators + + public static BigIntValue operator %(BigIntValue a, BigIntValue b) + { + return BigInteger.Remainder(ConvertStringToBigInteger(a.Value), ConvertStringToBigInteger(b.Value)) + .ToString(); + } + + public static BigIntValue operator +(BigIntValue a, BigIntValue b) + { + return BigInteger.Add(ConvertStringToBigInteger(a.Value), ConvertStringToBigInteger(b.Value)).ToString(); + } + + public static BigIntValue operator -(BigIntValue a, BigIntValue b) + { + return BigInteger.Subtract(ConvertStringToBigInteger(a.Value), ConvertStringToBigInteger(b.Value)) + .ToString(); + } + + public static BigIntValue operator *(BigIntValue a, BigIntValue b) + { + return BigInteger.Multiply(ConvertStringToBigInteger(a.Value), ConvertStringToBigInteger(b.Value)) + .ToString(); + } + + public static bool operator ==(BigIntValue a, BigIntValue b) + { + return ConvertStringToBigInteger(a?.Value ?? "0") == ConvertStringToBigInteger(b?.Value ?? "0"); + } + + public static bool operator !=(BigIntValue a, BigIntValue b) + { + return !(a == b); + } + + #endregion + #region < <= > >= public static bool operator <(in BigIntValue a, in BigIntValue b) @@ -149,5 +207,6 @@ private static bool LessThan(in BigIntValue a, in BigIntValue b) } #endregion + } } \ No newline at end of file From b66e60c1643f3ccaa32ef9100f5b938014bf2c85 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Sun, 29 Sep 2024 15:23:46 +0800 Subject: [PATCH 05/17] Change version to 8.0.402 in sonarqube.yaml --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index dbfca652b6..468b1a3057 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -15,7 +15,7 @@ jobs: with: dotnet-version: '8.0' - name: Create temporary global.json - run: echo '{"sdk":{"version":"8.0.303"}}' > ./global.json + run: echo '{"sdk":{"version":"8.0.402"}}' > ./global.json - name: Set up JDK 17 uses: actions/setup-java@v1 with: From 6469d74f51ae58d793ad0ffaf220f9841398c822 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Sun, 29 Sep 2024 15:29:24 +0800 Subject: [PATCH 06/17] Change version of sdk --- .github/workflows/sonarqube.yaml | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 468b1a3057..b87ff0cf93 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -15,7 +15,7 @@ jobs: with: dotnet-version: '8.0' - name: Create temporary global.json - run: echo '{"sdk":{"version":"8.0.402"}}' > ./global.json + run: echo '{"sdk":{"version":"8.0.*"}}' > ./global.json - name: Set up JDK 17 uses: actions/setup-java@v1 with: diff --git a/global.json b/global.json index 1978c843c7..686e090626 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.303" + "version": "8.0.402" } } \ No newline at end of file From 00d0b6e2c03b1880f57094be735a411a0f5984bf Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Sun, 29 Sep 2024 15:35:45 +0800 Subject: [PATCH 07/17] Change version of sdk --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 686e090626..70976d298f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.402" + "version": "8.0.*" } } \ No newline at end of file From 77e2d11f402ed5a71143a55bdb634ec990bda72b Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Sun, 29 Sep 2024 17:05:18 +0800 Subject: [PATCH 08/17] Add sources --- nuget.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nuget.config b/nuget.config index 8b19203c51..e75cd52656 100644 --- a/nuget.config +++ b/nuget.config @@ -1,6 +1,9 @@ + + + \ No newline at end of file From 0c5cf130d48f8aefbf5b88745110c4a5dd3deeca Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Tue, 8 Oct 2024 13:56:00 +0800 Subject: [PATCH 09/17] Change versions and add whitelist --- src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj | 2 -- .../Validators/Whitelist/IWhitelistProvider.cs | 9 +++++++++ .../AElf.Sdk.CSharp.Internal.csproj | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj b/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj index dc5501294c..e4cd5517c8 100644 --- a/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj +++ b/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj @@ -10,8 +10,6 @@ - - diff --git a/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs b/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs index 4f3ec683be..1d50b2d12d 100644 --- a/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs +++ b/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs @@ -62,6 +62,15 @@ private void WhitelistSystemTypes(Whitelist whitelist) .Type("Func`1", Permission.Allowed) // Required for protobuf generated code .Type("Func`2", Permission.Allowed) // Required for protobuf generated code .Type("Func`3", Permission.Allowed) // Required for protobuf generated code + .Type("Func`4", Permission.Allowed) + .Type("ValueTuple`1", Permission.Allowed) + .Type("ValueTuple`2", Permission.Allowed) + .Type("ValueTuple`3", Permission.Allowed) + .Type("ValueTuple`4", Permission.Allowed) + .Type("ValueTuple`5", Permission.Allowed) + .Type("ValueTuple`6", Permission.Allowed) + .Type("ValueTuple`7", Permission.Allowed) + .Type("ValueTuple`8", Permission.Allowed) .Type("Nullable`1", Permission.Allowed) // Required for protobuf generated code .Type(typeof(BitConverter), Permission.Denied, member => member .Member(nameof(BitConverter.GetBytes), Permission.Allowed)) diff --git a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj index 7f5bd490af..39b69c4352 100644 --- a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj +++ b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj @@ -10,7 +10,8 @@ - + + all From 4e5b3aadab39820c2eaab97f0f8fb069cf2056a4 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Tue, 8 Oct 2024 15:09:23 +0800 Subject: [PATCH 10/17] Remove poseidon and groth16 in IWhitelistProvider.cs --- .../Validators/Whitelist/IWhitelistProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs b/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs index b5db05aad4..1d50b2d12d 100644 --- a/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs +++ b/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs @@ -49,8 +49,6 @@ private void WhitelistAssemblies(Whitelist whitelist) .Assembly(typeof(IMethod).Assembly, Trust.Full) // AElf.CSharp.Core .Assembly(typeof(SecretSharingHelper).Assembly, Trust.Partial) // AElf.Cryptography .Assembly(typeof(ISmartContractBridgeContext).Assembly, Trust.Full) // AElf.Kernel.SmartContract.Shared - .Assembly(typeof(Groth16.Net.Verifier).Assembly, Trust.Full) // AElf.Cryptography.ECDSA - .Assembly(typeof(Poseidon.Net.Poseidon).Assembly, Trust.Full) ; } From aa43d7b0c8f1a1dafd42dce8cde06dfcc70b6003 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Thu, 7 Nov 2024 15:02:01 +0800 Subject: [PATCH 11/17] Add config for auto-publishing --- .../AElf.Blockchains.MainChain.csproj | 2 ++ .../AElf.Blockchains.SideChain.csproj | 2 ++ .../AElf.Kernel.FeatureDisable.Core.csproj | 2 ++ .../AElf.Kernel.FeatureDisable.csproj | 2 ++ src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj | 2 ++ 5 files changed, 10 insertions(+) diff --git a/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj b/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj index c99ca2bf21..7097bb2748 100644 --- a/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj +++ b/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj @@ -5,6 +5,8 @@ 0436 Main module for a mainchain node. + Release + true diff --git a/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj b/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj index 9364aac96b..063a9d5ebf 100644 --- a/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj +++ b/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj @@ -3,6 +3,8 @@ net8.0 Main module for a sidechain node. + Release + true 1701;1702 diff --git a/src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj b/src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj index 7b39f518d5..991781b591 100644 --- a/src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj +++ b/src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj @@ -4,6 +4,8 @@ net8.0 enable enable + Release + true diff --git a/src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj b/src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj index fae7fc0cdf..04323c5ffe 100644 --- a/src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj +++ b/src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj @@ -4,6 +4,8 @@ net8.0 enable enable + Release + true diff --git a/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj index 3a63532952..81ab49bf3a 100644 --- a/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj +++ b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj @@ -4,6 +4,8 @@ net8.0 enable enable + Release + true From 1ad4d469e89961253e7096d03a91c46f9101b02d Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Thu, 14 Nov 2024 19:00:23 +0800 Subject: [PATCH 12/17] support zk --- .../AElf.CSharp.CodeOps.csproj | 2 + .../Module/CallAndBranchCounts/Patcher.cs | 16 +- .../Module/ContractStructureValidator.cs | 2 + .../IExecutionObserverThresholdProvider.cs | 2 +- .../SmartContractConstants.cs | 2 +- .../AElf.Runtime.CSharp.csproj | 3 + .../AElf.Sdk.CSharp.Internal.csproj | 1 - .../CSharpSmartContractContextTests.cs | 10 - test/AElf.Types.Tests/BigIntegerTest.cs | 176 ++++++++++++++++++ 9 files changed, 200 insertions(+), 14 deletions(-) create mode 100644 test/AElf.Types.Tests/BigIntegerTest.cs diff --git a/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj b/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj index e4cd5517c8..d931ee9e76 100644 --- a/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj +++ b/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj @@ -10,6 +10,8 @@ + + diff --git a/src/AElf.CSharp.CodeOps/Patchers/Module/CallAndBranchCounts/Patcher.cs b/src/AElf.CSharp.CodeOps/Patchers/Module/CallAndBranchCounts/Patcher.cs index bdac2a7575..09b8581feb 100644 --- a/src/AElf.CSharp.CodeOps/Patchers/Module/CallAndBranchCounts/Patcher.cs +++ b/src/AElf.CSharp.CodeOps/Patchers/Module/CallAndBranchCounts/Patcher.cs @@ -17,7 +17,7 @@ public void Patch(ModuleDefinition module) return; // ReSharper disable once IdentifierTypo - var nmspace = module.Types.Single(m => m.BaseType is TypeDefinition).Namespace; + var nmspace = module.Types.Where(IsContractType).Single().Namespace; var proxyBuilder = new Patch(module, nmspace); @@ -28,6 +28,20 @@ public void Patch(ModuleDefinition module) module.Types.Add(proxyBuilder.ObserverType); } + private static bool IsContractType(TypeDefinition type) + { + if (type.FullName.StartsWith("AElf.Sdk.CSharp.CSharpSmartContract`1")) + return true; + if (type.BaseType is TypeDefinition baseType) + return IsContractType(baseType); + if(type.BaseType is GenericInstanceType baseType0) + return IsContractType(baseType0); + return false; + } + private static bool IsContractType(GenericInstanceType type) + { + return type.FullName.StartsWith("AElf.Sdk.CSharp.CSharpSmartContract`1"); + } } internal class MethodPatcher diff --git a/src/AElf.CSharp.CodeOps/Validators/Module/ContractStructureValidator.cs b/src/AElf.CSharp.CodeOps/Validators/Module/ContractStructureValidator.cs index 59f4209d5a..5fb83cd951 100644 --- a/src/AElf.CSharp.CodeOps/Validators/Module/ContractStructureValidator.cs +++ b/src/AElf.CSharp.CodeOps/Validators/Module/ContractStructureValidator.cs @@ -231,6 +231,8 @@ private bool IsBadStateField(FieldDefinition field) if (_allowedStateTypes.Contains(field.FieldType.FullName)) return false; + if(field.FieldType.Resolve().BaseType.FullName == typeof(StructuredState).FullName) + return false; // If not ContractReferenceState then it is not allowed return field.FieldType.Resolve().BaseType.FullName != typeof(ContractReferenceState).FullName; } diff --git a/src/AElf.Kernel.SmartContract/Application/IExecutionObserverThresholdProvider.cs b/src/AElf.Kernel.SmartContract/Application/IExecutionObserverThresholdProvider.cs index 22df31d5a3..1515ab0c20 100644 --- a/src/AElf.Kernel.SmartContract/Application/IExecutionObserverThresholdProvider.cs +++ b/src/AElf.Kernel.SmartContract/Application/IExecutionObserverThresholdProvider.cs @@ -33,7 +33,7 @@ public IExecutionObserverThreshold GetExecutionObserverThreshold(IBlockIndex blo var branchCountObserverThreshold = GetBlockExecutedData(blockIndex, BranchCountThresholdKey)?.Value ?? SmartContractConstants.ExecutionBranchThreshold; var callCountObserverThreshold = GetBlockExecutedData(blockIndex, CallCountThresholdKey)?.Value ?? - SmartContractConstants.ExecutionBranchThreshold; + SmartContractConstants.ExecutionCallThreshold; return new ExecutionObserverThreshold { ExecutionBranchThreshold = branchCountObserverThreshold, diff --git a/src/AElf.Kernel.SmartContract/SmartContractConstants.cs b/src/AElf.Kernel.SmartContract/SmartContractConstants.cs index 9a210289ce..0260dc8bbb 100644 --- a/src/AElf.Kernel.SmartContract/SmartContractConstants.cs +++ b/src/AElf.Kernel.SmartContract/SmartContractConstants.cs @@ -2,7 +2,7 @@ namespace AElf.Kernel.SmartContract; public class SmartContractConstants { - public const int ExecutionCallThreshold = 15000; + public const int ExecutionCallThreshold = 80000; public const int ExecutionBranchThreshold = 15000; diff --git a/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj b/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj index bf9914645e..122d0af0b5 100644 --- a/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj +++ b/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj @@ -22,6 +22,9 @@ + + + diff --git a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj index 39b69c4352..ff42c2fa80 100644 --- a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj +++ b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj @@ -10,7 +10,6 @@ - all diff --git a/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs b/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs index 48dcf22768..bdac3de919 100644 --- a/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs +++ b/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs @@ -46,16 +46,6 @@ public void Verify_Ed25519Verify() ByteArrayHelper.HexStringToByteArray(message1), ByteArrayHelper.HexStringToByteArray(publicKey1))); - // var contractContext2 = new CSharpSmartContractContext(bridgeContext); - // var publicKey2 = "3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c"; - // var message2 = "72"; - // var signature2 = "92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00"; - // var ed25519VerifyResult2 = contractContext2.Ed25519Verify( - // ByteArrayHelper.HexStringToByteArray(signature2), - // ByteArrayHelper.HexStringToByteArray(message2), - // ByteArrayHelper.HexStringToByteArray(publicKey2)); - // ed25519VerifyResult2.ShouldBe(true); - } [Fact] diff --git a/test/AElf.Types.Tests/BigIntegerTest.cs b/test/AElf.Types.Tests/BigIntegerTest.cs new file mode 100644 index 0000000000..056fcca2a9 --- /dev/null +++ b/test/AElf.Types.Tests/BigIntegerTest.cs @@ -0,0 +1,176 @@ +using System; +using System.Numerics; +using Xunit; + +namespace AElf.Types.Tests; + +public class BigIntegerTest +{ + [Fact] + public void Zero_Should_Be_Zero() + { + var zero = BigIntValue.Zero; + Assert.Equal("0", zero.Value); + } + + [Fact] + public void One_Should_Be_One() + { + var one = BigIntValue.One; + Assert.Equal("1", one.Value); + } + + [Fact] + public void BigIntValue_FromBigEndianBytes_Should_Work() + { + var bytes = new byte[] { 0x01, 0x00 }; // 256 in big endian + var bigIntValue = BigIntValue.FromBigEndianBytes(bytes); + Assert.Equal("256", bigIntValue.Value); + } + + [Fact] + public void ToBigEndianBytes_Should_Work() + { + var bigIntValue = new BigIntValue { Value = "256" }; + var bytes = bigIntValue.ToBigEndianBytes(); + Assert.Equal(new byte[] { 0x01, 0x00 }, bytes); + } + + [Theory] + [InlineData("123", "123", 0)] + [InlineData("123", "456", -1)] + [InlineData("456", "123", 1)] + public void CompareTo_Should_Correctly_Compare(string a, string b, int expected) + { + var bigIntValueA = new BigIntValue { Value = a }; + var bigIntValueB = new BigIntValue { Value = b }; + + Assert.Equal(expected, bigIntValueA.CompareTo(bigIntValueB)); + } + + [Fact] + public void Implicit_Conversion_From_String_Should_Work() + { + BigIntValue bigIntValue = "123"; + Assert.Equal("123", bigIntValue.Value); + } + + [Fact] + public void Implicit_Conversion_From_Long_Should_Work() + { + BigIntValue bigIntValue = 456L; + Assert.Equal("456", bigIntValue.Value); + } + + [Fact] + public void Addition_Operator_Should_Work() + { + BigIntValue a = "123"; + BigIntValue b = "456"; + BigIntValue result = a + b; + Assert.Equal("579", result.Value); + } + + [Fact] + public void Subtraction_Operator_Should_Work() + { + BigIntValue a = "123"; + BigIntValue b = "23"; + BigIntValue result = a - b; + Assert.Equal("100", result.Value); + } + + [Fact] + public void Multiplication_Operator_Should_Work() + { + BigIntValue a = "10"; + BigIntValue b = "20"; + BigIntValue result = a * b; + Assert.Equal("200", result.Value); + } + + [Fact] + public void Modulus_Operator_Should_Work() + { + BigIntValue a = "10"; + BigIntValue b = "3"; + BigIntValue result = a % b; + Assert.Equal("1", result.Value); + } + + [Fact] + public void Equality_Operator_Should_Work() + { + BigIntValue a = "123"; + BigIntValue b = "123"; + Assert.True(a == b); + + BigIntValue c = "456"; + Assert.False(a == c); + } + + [Fact] + public void Inequality_Operator_Should_Work() + { + BigIntValue a = "123"; + BigIntValue b = "456"; + Assert.True(a != b); + + BigIntValue c = "123"; + Assert.False(a != c); + } + + [Fact] + public void LessThanOperator_Should_Work() + { + BigIntValue a = "123"; + BigIntValue b = "456"; + Assert.True(a < b); + Assert.False(b < a); + } + + [Fact] + public void GreaterThanOperator_Should_Work() + { + BigIntValue a = "456"; + BigIntValue b = "123"; + Assert.True(a > b); + Assert.False(b > a); + } + + [Fact] + public void LessThanOrEqualOperator_Should_Work() + { + BigIntValue a = "123"; + BigIntValue b = "123"; + BigIntValue c = "456"; + Assert.True(a <= b); + Assert.True(a <= c); + Assert.False(c <= a); + } + + [Fact] + public void GreaterThanOrEqualOperator_Should_Work() + { + BigIntValue a = "123"; + BigIntValue b = "123"; + BigIntValue c = "456"; + Assert.True(a >= b); + Assert.True(c >= a); + Assert.False(a >= c); + } + + [Theory] + [InlineData("0", 0)] + [InlineData("123456789", 123456789)] + [InlineData("-987654321", -987654321)] + [InlineData("1_000_000_000", 1000000000)] + [InlineData("-1_234_567", -1234567)] + public void ConvertStringToBigInteger_ValidStrings_Should_ParseCorrectly(string input, long expected) + { + BigIntValue bigIntValue = input; + BigInteger result = bigIntValue; // Implicit conversion to BigInteger + Assert.Equal(new BigInteger(expected), result); + } + +} \ No newline at end of file From 6d433e59edaa4b0518af3c91ffbcc46bcb398799 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Mon, 18 Nov 2024 11:04:26 +0800 Subject: [PATCH 13/17] Add unit-test for zk supporting --- .../AElf.Sdk.CSharp.Tests.csproj | 2 + .../CSharpSmartContractContextTests.cs | 123 ++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj index 91ff826eca..9a260f1451 100644 --- a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj +++ b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj @@ -4,12 +4,14 @@ false + all runtime; build; native; contentfiles; analyzers + diff --git a/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs b/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs index bdac3de919..19e57e247b 100644 --- a/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs +++ b/test/AElf.Sdk.CSharp.Tests/CSharpSmartContractContextTests.cs @@ -4,7 +4,9 @@ using AElf.Kernel.SmartContract; using AElf.Kernel.SmartContract.Application; using AElf.Types; +using Bn254.Net; using Google.Protobuf; +using Nethereum.Util; using Shouldly; using Xunit; using CustomContract = AElf.Runtime.CSharp.Tests.TestContract; @@ -85,4 +87,125 @@ public void Transaction_VerifySignature_Test() var result = bridgeContext.VerifySignature(transaction); result.ShouldBeTrue(); } + + [Fact] + public void keccak256_test() + { + var bridgeContext = GetRequiredService().Create(); + var origin = SampleAddress.AddressList[0]; + var contractContext = new CSharpSmartContractContext(bridgeContext); + byte[] message = System.Text.Encoding.UTF8.GetBytes("Test message"); + var fact = contractContext.Keccak256(message); + var expected = Sha3Keccack.Current.CalculateHash(message); + fact.ShouldBe(expected); + } + public static byte[] ToBytes32(BigIntValue value) + { + var bytes = value.ToBigEndianBytes(); + var newArray = new byte[32]; + for (int i = 0; i < bytes.Length; i++) + { + newArray[31 - i] = bytes[bytes.Length - 1 - i]; + } + + return newArray; + } + + [Fact] + public void Bn254G1Mul_Test() + { + var bridgeContext = GetRequiredService().Create(); + var contractContext = new CSharpSmartContractContext(bridgeContext); + + // Arrange + byte[] x1 = ToBytes32(new BigIntValue(0)); + byte[] y1 = ToBytes32(new BigIntValue(0)); + byte[] scalar = ToBytes32(new BigIntValue(0)); + + // use raw api to compute result + var (expectedXUInt256, expectedYUInt256) = Bn254.Net.Bn254.Mul( + UInt256.FromBigEndianBytes(x1), + UInt256.FromBigEndianBytes(y1), + UInt256.FromBigEndianBytes(scalar) + ); + var expectedX = expectedXUInt256.ToBigEndianBytes(); + var expectedY = expectedYUInt256.ToBigEndianBytes(); + + // Act + var (xResult, yResult) = contractContext.Bn254G1Mul(x1, y1, scalar); + + // Assert + xResult.ShouldBe(expectedX); + yResult.ShouldBe(expectedY); + } + + [Fact] + public void Bn254G1Add_Test() + { + var bridgeContext = GetRequiredService().Create(); + var contractContext = new CSharpSmartContractContext(bridgeContext); + + // Arrange + byte[] x1 = ToBytes32(new BigIntValue(0)); + byte[] y1 = ToBytes32(new BigIntValue(0)); + byte[] x2 = ToBytes32(new BigIntValue(0)); + byte[] y2 = ToBytes32(new BigIntValue(0)); + + // Use raw API to compute expected results + var (expectedX3UInt256, expectedY3UInt256) = Bn254.Net.Bn254.Add( + UInt256.FromBigEndianBytes(x1), + UInt256.FromBigEndianBytes(y1), + UInt256.FromBigEndianBytes(x2), + UInt256.FromBigEndianBytes(y2) + ); + var expectedX3 = expectedX3UInt256.ToBigEndianBytes(); + var expectedY3 = expectedY3UInt256.ToBigEndianBytes(); + + // Act + var (x3Result, y3Result) = contractContext.Bn254G1Add(x1, y1, x2, y2); + + // Assert + x3Result.ShouldBe(expectedX3); + y3Result.ShouldBe(expectedY3); + } + + + [Fact] + public void Bn254Pairing_Test() + { + var bridgeContext = GetRequiredService().Create(); + var contractContext = new CSharpSmartContractContext(bridgeContext); + + // Arrange + var input = new (byte[], byte[], byte[], byte[], byte[], byte[])[] + { + ( + ToBytes32(new BigIntValue(0)), + ToBytes32(new BigIntValue(0)), + ToBytes32(new BigIntValue(0)), + ToBytes32(new BigIntValue(0)), + ToBytes32(new BigIntValue(0)), + ToBytes32(new BigIntValue(0)) + ) + }; + + // Use raw API to compute expected results + bool expected = Bn254.Net.Bn254.Pairing(new (UInt256, UInt256, UInt256, UInt256, UInt256, UInt256)[] + { + ( + UInt256.FromBigEndianBytes(input[0].Item1), + UInt256.FromBigEndianBytes(input[0].Item2), + UInt256.FromBigEndianBytes(input[0].Item3), + UInt256.FromBigEndianBytes(input[0].Item4), + UInt256.FromBigEndianBytes(input[0].Item5), + UInt256.FromBigEndianBytes(input[0].Item6) + ) + }); + + // Act + bool result = contractContext.Bn254Pairing(input); + + // Assert + result.ShouldBe(expected); + } } \ No newline at end of file From 8299f355b0022207e65095878fc60ce54c2328a7 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Tue, 19 Nov 2024 11:54:43 +0800 Subject: [PATCH 14/17] Temporarily remove the unit test; it will be added back later --- azure-pipelines.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9cae4c73c7..5b34136665 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,28 +21,28 @@ jobs: n: 1 codecoverage: true - template: templates/build-template-linux.yml - parameters: - parts: 3 - n: 2 - codecoverage: false - - template: templates/build-template-linux.yml - parameters: - parts: 3 - n: 3 - codecoverage: false - - template: templates/build-template-macos.yml - parameters: - parts: 3 - n: 1 - codecoverage: true - - template: templates/build-template-macos.yml parameters: parts: 3 n: 2 codecoverage: true - - template: templates/build-template-macos.yml + - template: templates/build-template-linux.yml parameters: parts: 3 n: 3 codecoverage: true +# - template: templates/build-template-macos.yml +# parameters: +# parts: 3 +# n: 1 +# codecoverage: true +# - template: templates/build-template-macos.yml +# parameters: +# parts: 3 +# n: 2 +# codecoverage: true +# - template: templates/build-template-macos.yml +# parameters: +# parts: 3 +# n: 3 +# codecoverage: true \ No newline at end of file From 18763eeb33b591a30a90086ea7078d35fdf21ba0 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Tue, 19 Nov 2024 16:43:57 +0800 Subject: [PATCH 15/17] Modify config in azure-pipelines.yml --- azure-pipelines.yml | 62 ++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5b34136665..638b5c27f1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,20 +1,20 @@ # Azure Pipelines configuration file jobs: -# - template: templates/build-template-window.yml -# parameters: -# parts: 3 -# n: 1 -# codecoverage: true -# - template: templates/build-template-window.yml -# parameters: -# parts: 3 -# n: 2 -# codecoverage: false -# - template: templates/build-template-window.yml -# parameters: -# parts: 3 -# n: 3 -# codecoverage: false + # - template: templates/build-template-window.yml + # parameters: + # parts: 3 + # n: 1 + # codecoverage: true + # - template: templates/build-template-window.yml + # parameters: + # parts: 3 + # n: 2 + # codecoverage: false + # - template: templates/build-template-window.yml + # parameters: + # parts: 3 + # n: 3 + # codecoverage: false - template: templates/build-template-linux.yml parameters: parts: 3 @@ -24,25 +24,25 @@ jobs: parameters: parts: 3 n: 2 - codecoverage: true + codecoverage: false - template: templates/build-template-linux.yml parameters: parts: 3 n: 3 + codecoverage: false + - template: templates/build-template-macos.yml + parameters: + parts: 3 + n: 1 + codecoverage: true + - template: templates/build-template-macos.yml + parameters: + parts: 3 + n: 2 codecoverage: true -# - template: templates/build-template-macos.yml -# parameters: -# parts: 3 -# n: 1 -# codecoverage: true -# - template: templates/build-template-macos.yml -# parameters: -# parts: 3 -# n: 2 -# codecoverage: true -# - template: templates/build-template-macos.yml -# parameters: -# parts: 3 -# n: 3 -# codecoverage: true + # - template: templates/build-template-macos.yml + # parameters: + # parts: 3 + # n: 3 + # codecoverage: true \ No newline at end of file From d1a71ef2740669d2660d06318fe3e6fa41cfc6f2 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Sat, 23 Nov 2024 17:05:30 +0800 Subject: [PATCH 16/17] CallCount revert to 15000 --- src/AElf.Kernel.SmartContract/SmartContractConstants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AElf.Kernel.SmartContract/SmartContractConstants.cs b/src/AElf.Kernel.SmartContract/SmartContractConstants.cs index 0260dc8bbb..9a210289ce 100644 --- a/src/AElf.Kernel.SmartContract/SmartContractConstants.cs +++ b/src/AElf.Kernel.SmartContract/SmartContractConstants.cs @@ -2,7 +2,7 @@ namespace AElf.Kernel.SmartContract; public class SmartContractConstants { - public const int ExecutionCallThreshold = 80000; + public const int ExecutionCallThreshold = 15000; public const int ExecutionBranchThreshold = 15000; From d38683fde34978e369ead18c33630360e2421707 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Thu, 12 Dec 2024 14:47:15 +0800 Subject: [PATCH 17/17] Remove publish config in main and side project --- .../AElf.Blockchains.MainChain.csproj | 2 -- .../AElf.Blockchains.SideChain.csproj | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj b/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj index 7097bb2748..c99ca2bf21 100644 --- a/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj +++ b/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj @@ -5,8 +5,6 @@ 0436 Main module for a mainchain node. - Release - true diff --git a/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj b/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj index 063a9d5ebf..9364aac96b 100644 --- a/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj +++ b/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj @@ -3,8 +3,6 @@ net8.0 Main module for a sidechain node. - Release - true 1701;1702