Skip to content

Commit c63f5eb

Browse files
committed
Merge branch 'release/1.12.2' into feature/mq
2 parents 4a47613 + 3688493 commit c63f5eb

File tree

50 files changed

+301
-770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+301
-770
lines changed

AElf.All.sln

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.
387387
EndProject
388388
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}"
389389
EndProject
390-
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}"
391-
EndProject
392-
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}"
393-
EndProject
394390
Global
395391
GlobalSection(SolutionConfigurationPlatforms) = preSolution
396392
Debug|Any CPU = Debug|Any CPU
@@ -1117,14 +1113,6 @@ Global
11171113
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
11181114
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
11191115
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.Build.0 = Release|Any CPU
1120-
{45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1121-
{45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.Build.0 = Debug|Any CPU
1122-
{45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.ActiveCfg = Release|Any CPU
1123-
{45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.Build.0 = Release|Any CPU
1124-
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1125-
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1126-
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1127-
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.Build.0 = Release|Any CPU
11281116
EndGlobalSection
11291117
GlobalSection(SolutionProperties) = preSolution
11301118
HideSolutionNode = FALSE
@@ -1320,7 +1308,5 @@ Global
13201308
{A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
13211309
{8C0D86A4-D1A7-4B61-AC44-755F5AC75D67} = {4E54480A-D155-43ED-9736-1A5BE7957211}
13221310
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
1323-
{45A77C41-142E-4296-A14A-D53067EC8B75} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
1324-
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
13251311
EndGlobalSection
13261312
EndGlobal

contract/AElf.Contracts.MultiToken/TokenContract_Helper.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,10 @@ private Address ExtractTokenContractAddress(ByteString bytes)
215215
private void AssertCrossChainTransaction(Transaction originalTransaction, Address validAddress,
216216
params string[] validMethodNames)
217217
{
218-
var validateResult = validMethodNames.Contains(MaybeRecoverInlineTransactionFunctionName(originalTransaction.MethodName))
218+
var validateResult = validMethodNames.Contains(originalTransaction.MethodName)
219219
&& originalTransaction.To == validAddress;
220220
Assert(validateResult, "Invalid transaction.");
221221
}
222-
223-
private static string MaybeRecoverInlineTransactionFunctionName(string methodName)
224-
{
225-
var parts = methodName.Split('.');
226-
return parts.Length > 1 ? parts[^2] : methodName;
227-
}
228222

229223
private void RegisterTokenInfo(TokenInfo tokenInfo)
230224
{

protobuf/inline_transaction.proto

Lines changed: 0 additions & 15 deletions
This file was deleted.

protobuf/test_virtual_address_contract.proto

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ service VirtualAddressContract {
1414
option (aelf.base) = "acs1.proto";
1515

1616
rpc VirtualAddressVote(VirtualAddressVoteInput) returns (google.protobuf.Empty);
17-
rpc VirtualAddressVoteWithInline(VirtualAddressVoteWithCountInput) returns (google.protobuf.Empty);
1817
rpc VirtualAddressWithdraw(aelf.Hash) returns (google.protobuf.Empty);
1918
rpc VirtualAddressChangeVotingOption(VirtualAddressChangeVotingOptionInput) returns (google.protobuf.Empty);
2019
rpc VirtualAddressClaimProfit(VirtualAddressClaimProfitInput) returns (google.protobuf.Empty);
@@ -33,11 +32,6 @@ message VirtualAddressVoteInput {
3332
aelf.Hash token = 4;
3433
}
3534

36-
message VirtualAddressVoteWithCountInput {
37-
VirtualAddressVoteInput vote_input = 1; // Existing input type
38-
int32 count = 2; // Additional count input
39-
}
40-
4135
message VirtualAddressChangeVotingOptionInput {
4236
bool is_reset = 1;
4337
aelf.Hash vote_id = 2;

src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.5.0" />
1212
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
1313
<PackageReference Include="Groth16.Net" Version="1.1.2" />
14-
<PackageReference Include="Poseidon.Net" Version="0.1.1" />
1514
</ItemGroup>
1615

1716
<ItemGroup>

src/AElf.CSharp.CodeOps/Patchers/Module/CallAndBranchCounts/Patcher.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void Patch(ModuleDefinition module)
1717
return;
1818

1919
// ReSharper disable once IdentifierTypo
20-
var nmspace = module.Types.Where(IsContractType).Single().Namespace;
20+
var nmspace = module.Types.Single(m => m.BaseType is TypeDefinition).Namespace;
2121

2222
var proxyBuilder = new Patch(module, nmspace);
2323

@@ -28,20 +28,6 @@ public void Patch(ModuleDefinition module)
2828

2929
module.Types.Add(proxyBuilder.ObserverType);
3030
}
31-
private static bool IsContractType(TypeDefinition type)
32-
{
33-
if (type.FullName.StartsWith("AElf.Sdk.CSharp.CSharpSmartContract`1"))
34-
return true;
35-
if (type.BaseType is TypeDefinition baseType)
36-
return IsContractType(baseType);
37-
if(type.BaseType is GenericInstanceType baseType0)
38-
return IsContractType(baseType0);
39-
return false;
40-
}
41-
private static bool IsContractType(GenericInstanceType type)
42-
{
43-
return type.FullName.StartsWith("AElf.Sdk.CSharp.CSharpSmartContract`1");
44-
}
4531
}
4632

4733
internal class MethodPatcher

src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
using System.Runtime.CompilerServices;
66
using System.Text;
77
using System.Text.RegularExpressions;
8+
using AElf.Cryptography.Bn254;
9+
using AElf.Cryptography.EdDSA;
10+
using AElf.Cryptography.Keccak;
811
using AElf.Cryptography.SecretSharing;
912
using AElf.CSharp.Core;
1013
using AElf.Kernel.SmartContract;
@@ -49,6 +52,7 @@ private void WhitelistAssemblies(Whitelist whitelist)
4952
.Assembly(typeof(IMethod).Assembly, Trust.Full) // AElf.CSharp.Core
5053
.Assembly(typeof(SecretSharingHelper).Assembly, Trust.Partial) // AElf.Cryptography
5154
.Assembly(typeof(ISmartContractBridgeContext).Assembly, Trust.Full) // AElf.Kernel.SmartContract.Shared
55+
.Assembly(typeof(Groth16.Net.Verifier).Assembly, Trust.Full) // AElf.Cryptography.ECDSA
5256
;
5357
}
5458

@@ -167,6 +171,27 @@ private void WhitelistOthers(Whitelist whitelist)
167171
)
168172
;
169173
}
174+
175+
private void WhitelistCryptographyHelpers(Whitelist whitelist)
176+
{
177+
whitelist
178+
// Selectively allowed types and members
179+
.Namespace("AElf.Cryptography.Bn254", Permission.Denied, type => type
180+
.Type(typeof(Bn254Helper), Permission.Denied, member => member
181+
.Member(nameof(Bn254Helper.Bn254Pairing), Permission.Allowed)
182+
.Member(nameof(Bn254Helper.Bn254G1Add), Permission.Allowed)
183+
.Member(nameof(Bn254Helper.Bn254G1Mul), Permission.Allowed)
184+
))
185+
.Namespace("AElf.Cryptography.EdDSA", Permission.Denied, type => type
186+
.Type(typeof(EdDsaHelper), Permission.Denied, member => member
187+
.Member(nameof(EdDsaHelper.Ed25519Verify), Permission.Allowed)
188+
))
189+
.Namespace("AElf.Cryptography.Keccak", Permission.Denied, type => type
190+
.Type(typeof(KeccakHelper), Permission.Denied, member => member
191+
.Member(nameof(KeccakHelper.Keccak256), Permission.Allowed)
192+
))
193+
;
194+
}
170195

171196
private Whitelist CreateWhitelist()
172197
{
@@ -176,6 +201,7 @@ private Whitelist CreateWhitelist()
176201
WhitelistReflectionTypes(whitelist);
177202
WhitelistLinqAndCollections(whitelist);
178203
WhitelistOthers(whitelist);
204+
WhitelistCryptographyHelpers(whitelist);
179205
return whitelist;
180206
}
181207
}

src/AElf.ContractTestKit.AEDPoSExtension/UnitTestPlainTransactionExecutingService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Threading;
33
using System.Threading.Tasks;
44
using AElf.Kernel;
5-
using AElf.Kernel.Blockchain.Application;
65
using AElf.Kernel.FeatureDisable.Core;
76
using AElf.Kernel.SmartContract;
87
using AElf.Kernel.SmartContract.Application;
@@ -14,8 +13,8 @@ public class UnitTestPlainTransactionExecutingService : PlainTransactionExecutin
1413
{
1514
public UnitTestPlainTransactionExecutingService(ISmartContractExecutiveService smartContractExecutiveService,
1615
IEnumerable<IPostExecutionPlugin> postPlugins, IEnumerable<IPreExecutionPlugin> prePlugins,
17-
ITransactionContextFactory transactionContextFactory, IFeatureDisableService featureDisableService,IBlockchainService blockchainService) : base(
18-
smartContractExecutiveService, postPlugins, prePlugins, transactionContextFactory, featureDisableService,blockchainService)
16+
ITransactionContextFactory transactionContextFactory, IFeatureDisableService featureDisableService) : base(
17+
smartContractExecutiveService, postPlugins, prePlugins, transactionContextFactory, featureDisableService)
1918
{
2019
}
2120

src/AElf.Cryptography/AElf.Cryptography.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<PackageReference Include="Secp256k1.Net" Version="1.2.0" />
1111
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
1212
<PackageReference Include="Secp256k1.Native" Version="0.1.24-alpha" />
13+
<PackageReference Include="Bn254.Net" Version="0.1.0" />
14+
<PackageReference Include="Rebex.Elliptic.Ed25519" Version="1.2.1" />
15+
<PackageReference Include="Nethereum.Web3" Version="4.5.0" />
1316
</ItemGroup>
1417
<ItemGroup>
1518
<ProjectReference Include="..\AElf.Types\AElf.Types.csproj" />
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Bn254.Net;
2+
using NetBn254 = Bn254.Net;
3+
4+
namespace AElf.Cryptography.Bn254
5+
{
6+
public static class Bn254Helper
7+
{
8+
public static (byte[] x, byte[] y) Bn254G1Mul(byte[] x1, byte[] y1, byte[] s)
9+
{
10+
var (xUInt256, yUInt256) = NetBn254.Bn254.Mul(UInt256.FromBigEndianBytes(x1),
11+
UInt256.FromBigEndianBytes(y1),
12+
UInt256.FromBigEndianBytes(s));
13+
return (xUInt256.ToBigEndianBytes(), yUInt256.ToBigEndianBytes());
14+
}
15+
16+
public static (byte[] x3, byte[] y3) Bn254G1Add(byte[] x1, byte[] y1, byte[] x2, byte[] y2)
17+
{
18+
var (x3UInt256, y3UInt256) = NetBn254.Bn254.Add(UInt256.FromBigEndianBytes(x1),
19+
UInt256.FromBigEndianBytes(y1),
20+
UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2));
21+
return (x3UInt256.ToBigEndianBytes(), y3UInt256.ToBigEndianBytes());
22+
}
23+
24+
public static bool Bn254Pairing((byte[], byte[], byte[], byte[], byte[], byte[])[] input)
25+
{
26+
var elements = new (UInt256, UInt256, UInt256, UInt256, UInt256, UInt256)[input.Length];
27+
for (var i = 0; i < input.Length; i++)
28+
{
29+
var (x1, y1, x2, y2, x3, y3) = input[i];
30+
elements[i] = (UInt256.FromBigEndianBytes(x1), UInt256.FromBigEndianBytes(y1),
31+
UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2),
32+
UInt256.FromBigEndianBytes(x3), UInt256.FromBigEndianBytes(y3));
33+
}
34+
35+
return NetBn254.Bn254.Pairing(elements);
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)