Skip to content

Commit d901456

Browse files
committed
Merge branch 'release/1.12.2' into feature/mq-designate-height
2 parents bd303c5 + 3688493 commit d901456

File tree

44 files changed

+568
-391
lines changed

Some content is hidden

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

44 files changed

+568
-391
lines changed

azure-pipelines.yml

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Azure Pipelines configuration file
22
jobs:
3-
# - template: templates/build-template-window.yml
4-
# parameters:
5-
# parts: 3
6-
# n: 1
7-
# codecoverage: true
8-
# - template: templates/build-template-window.yml
9-
# parameters:
10-
# parts: 3
11-
# n: 2
12-
# codecoverage: false
13-
# - template: templates/build-template-window.yml
14-
# parameters:
15-
# parts: 3
16-
# n: 3
17-
# codecoverage: false
3+
# - template: templates/build-template-window.yml
4+
# parameters:
5+
# parts: 3
6+
# n: 1
7+
# codecoverage: true
8+
# - template: templates/build-template-window.yml
9+
# parameters:
10+
# parts: 3
11+
# n: 2
12+
# codecoverage: false
13+
# - template: templates/build-template-window.yml
14+
# parameters:
15+
# parts: 3
16+
# n: 3
17+
# codecoverage: false
1818
- template: templates/build-template-linux.yml
1919
parameters:
2020
parts: 3
@@ -40,9 +40,9 @@ jobs:
4040
parts: 3
4141
n: 2
4242
codecoverage: true
43-
# - template: templates/build-template-macos.yml
44-
# parameters:
45-
# parts: 3
46-
# n: 3
47-
# codecoverage: true
43+
# - template: templates/build-template-macos.yml
44+
# parameters:
45+
# parts: 3
46+
# n: 3
47+
# codecoverage: true
4848

contract/AElf.Contracts.MultiToken/TokenContract_Helper.cs

+1-7
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
{

nuget.config

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3"/>
5+
<add key="aelf" value="https://www.myget.org/F/aelf-project-dev/api/v3/index.json" protocolVersion="3"/>
46
<add key="Nuget Test" value="https://int.nugettest.org/api/v2" />
7+
<add key="nexus" value="https://nexus-poc.test.aelf.dev/repository/nuget-group/index.json" protocolVersion="3" />
58
</packageSources>
69
</configuration>

protobuf/inline_transaction.proto

-15
This file was deleted.

protobuf/test_virtual_address_contract.proto

-6
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

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.5.0" />
1212
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
13-
<PackageReference Include="Groth16.Net" Version="1.1.0" />
14-
<PackageReference Include="Poseidon.Net" Version="0.1.1" />
13+
<PackageReference Include="Groth16.Net" Version="1.1.2" />
1514
</ItemGroup>
1615

1716
<ItemGroup>

src/AElf.CSharp.CodeOps/Validators/Method/ArrayValidator.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Threading;
55
using AElf.CSharp.Core;
6+
using AElf.Types;
67
using Mono.Cecil;
78
using Mono.Cecil.Cil;
89
using Volo.Abp.DependencyInjection;
@@ -24,7 +25,7 @@ public class ArrayValidator : IValidator<MethodDefinition>, ITransientDependency
2425
.LimitByTotalSize(typeof(decimal), sizeof(decimal))
2526
.LimitByTotalSize(typeof(char), sizeof(char))
2627
.LimitByTotalSize(typeof(String), 128) // Need to limit the size of strings by disallowing String.Concat
27-
28+
.LimitByTotalSize(typeof(BigIntValue), 128)
2829
// It isn't possible to estimate runtime sizes for below, so limit by count
2930
.LimitByCount(typeof(Type), 5)
3031
.LimitByCount(typeof(Object), 5) // Support object in Linq queries

src/AElf.CSharp.CodeOps/Validators/Module/ContractStructureValidator.cs

+2
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ private bool IsBadStateField(FieldDefinition field)
231231
if (_allowedStateTypes.Contains(field.FieldType.FullName))
232232
return false;
233233

234+
if(field.FieldType.Resolve().BaseType.FullName == typeof(StructuredState).FullName)
235+
return false;
234236
// If not ContractReferenceState then it is not allowed
235237
return field.FieldType.Resolve().BaseType.FullName != typeof(ContractReferenceState).FullName;
236238
}

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

+34-1
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;
@@ -50,7 +53,6 @@ private void WhitelistAssemblies(Whitelist whitelist)
5053
.Assembly(typeof(SecretSharingHelper).Assembly, Trust.Partial) // AElf.Cryptography
5154
.Assembly(typeof(ISmartContractBridgeContext).Assembly, Trust.Full) // AElf.Kernel.SmartContract.Shared
5255
.Assembly(typeof(Groth16.Net.Verifier).Assembly, Trust.Full) // AElf.Cryptography.ECDSA
53-
.Assembly(typeof(Poseidon.Net.Poseidon).Assembly, Trust.Full)
5456
;
5557
}
5658

@@ -64,6 +66,15 @@ private void WhitelistSystemTypes(Whitelist whitelist)
6466
.Type("Func`1", Permission.Allowed) // Required for protobuf generated code
6567
.Type("Func`2", Permission.Allowed) // Required for protobuf generated code
6668
.Type("Func`3", Permission.Allowed) // Required for protobuf generated code
69+
.Type("Func`4", Permission.Allowed)
70+
.Type("ValueTuple`1", Permission.Allowed)
71+
.Type("ValueTuple`2", Permission.Allowed)
72+
.Type("ValueTuple`3", Permission.Allowed)
73+
.Type("ValueTuple`4", Permission.Allowed)
74+
.Type("ValueTuple`5", Permission.Allowed)
75+
.Type("ValueTuple`6", Permission.Allowed)
76+
.Type("ValueTuple`7", Permission.Allowed)
77+
.Type("ValueTuple`8", Permission.Allowed)
6778
.Type("Nullable`1", Permission.Allowed) // Required for protobuf generated code
6879
.Type(typeof(BitConverter), Permission.Denied, member => member
6980
.Member(nameof(BitConverter.GetBytes), Permission.Allowed))
@@ -160,6 +171,27 @@ private void WhitelistOthers(Whitelist whitelist)
160171
)
161172
;
162173
}
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+
}
163195

164196
private Whitelist CreateWhitelist()
165197
{
@@ -169,6 +201,7 @@ private Whitelist CreateWhitelist()
169201
WhitelistReflectionTypes(whitelist);
170202
WhitelistLinqAndCollections(whitelist);
171203
WhitelistOthers(whitelist);
204+
WhitelistCryptographyHelpers(whitelist);
172205
return whitelist;
173206
}
174207
}

src/AElf.ContractTestKit.AEDPoSExtension/UnitTestPlainTransactionExecutingService.cs

+2-3
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

+3
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" />
+38
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+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using Rebex.Security.Cryptography;
3+
4+
namespace AElf.Cryptography.EdDSA
5+
{
6+
public static class EdDsaHelper
7+
{
8+
public static bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey)
9+
{
10+
try
11+
{
12+
var instance = new Ed25519();
13+
instance.FromPublicKey(publicKey);
14+
return instance.VerifyMessage(message, signature);
15+
}
16+
catch (Exception e)
17+
{
18+
return false;
19+
}
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Nethereum.Util;
2+
3+
namespace AElf.Cryptography.Keccak
4+
{
5+
public static class KeccakHelper
6+
{
7+
public static byte[] Keccak256(byte[] message)
8+
{
9+
return Sha3Keccack.Current.CalculateHash(message);
10+
}
11+
}
12+
}

src/AElf.Kernel.Core/Extensions/TransactionExtensions.cs

-13
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ public static int Size(this Transaction transaction)
1616

1717
public static bool VerifySignature(this Transaction transaction)
1818
{
19-
if (transaction.IsInlineWithTransactionId())
20-
{
21-
return true;
22-
}
2319
if (!transaction.VerifyFields())
2420
return false;
2521

@@ -31,16 +27,7 @@ public static bool VerifySignature(this Transaction transaction)
3127

3228
public static bool VerifyExpiration(this Transaction transaction, long chainBranchBlockHeight)
3329
{
34-
if (transaction.IsInlineWithTransactionId())
35-
{
36-
return true;
37-
}
3830
return transaction.RefBlockNumber <= chainBranchBlockHeight &&
3931
transaction.GetExpiryBlockNumber() > chainBranchBlockHeight;
4032
}
41-
42-
public static bool IsInlineWithTransactionId(this Transaction transaction)
43-
{
44-
return transaction.MethodName.Contains(".");
45-
}
4633
}

src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<Configuration>Release</Configuration>
8+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
79
</PropertyGroup>
810

911
<ItemGroup>

src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<Configuration>Release</Configuration>
8+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
79
</PropertyGroup>
810

911
<ItemGroup>

src/AElf.Kernel.SmartContract/AElf.Kernel.SmartContract.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,5 @@
2222
<ContractMessage Include="..\..\protobuf\virtual_transaction.proto">
2323
<Link>Protobuf\Proto\virtual_transaction.proto</Link>
2424
</ContractMessage>
25-
<ContractMessage Include="..\..\protobuf\inline_transaction.proto">
26-
<Link>Protobuf\Proto\inline_transaction.proto</Link>
27-
</ContractMessage>
2825
</ItemGroup>
2926
</Project>

src/AElf.Kernel.SmartContract/Application/IExecutionObserverThresholdProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public IExecutionObserverThreshold GetExecutionObserverThreshold(IBlockIndex blo
3333
var branchCountObserverThreshold = GetBlockExecutedData(blockIndex, BranchCountThresholdKey)?.Value ??
3434
SmartContractConstants.ExecutionBranchThreshold;
3535
var callCountObserverThreshold = GetBlockExecutedData(blockIndex, CallCountThresholdKey)?.Value ??
36-
SmartContractConstants.ExecutionBranchThreshold;
36+
SmartContractConstants.ExecutionCallThreshold;
3737
return new ExecutionObserverThreshold
3838
{
3939
ExecutionBranchThreshold = branchCountObserverThreshold,

0 commit comments

Comments
 (0)