Skip to content

Commit 1c65ebd

Browse files
authored
Merge pull request #3630 from AElfProject/release/1.12.2
Regarding the release PR for aelf project version 1.12.0
2 parents 4deeae5 + 3688493 commit 1c65ebd

File tree

31 files changed

+702
-33
lines changed

31 files changed

+702
-33
lines changed

.github/workflows/sonarqube.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
dotnet-version: '8.0'
1717
- name: Create temporary global.json
18-
run: echo '{"sdk":{"version":"8.0.303"}}' > ./global.json
18+
run: echo '{"sdk":{"version":"8.0.*"}}' > ./global.json
1919
- name: Set up JDK 17
2020
uses: actions/setup-java@v1
2121
with:

azure-pipelines.yml

Lines changed: 20 additions & 20 deletions
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.Consensus.AEDPoS/AEDPoSContract_ProcessConsensusInformation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ private void ProcessNextRound(NextRoundInput input)
127127
{
128128
var minersCount = GetMinersCount(nextRound);
129129
if (minersCount != 0 && State.ElectionContract.Value != null)
130+
{
130131
State.ElectionContract.UpdateMinersCount.Send(new UpdateMinersCountInput
131132
{
132133
MinersCount = minersCount
133134
});
135+
}
134136
}
135137
}
136138

contract/AElf.Contracts.MultiToken/TokenContract_Actions.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,35 @@ public override Int32Value GetMaxBatchApproveCount(Empty input)
691691
};
692692
}
693693

694+
public override Empty ExtendSeedExpirationTime(ExtendSeedExpirationTimeInput input)
695+
{
696+
var tokenInfo = GetTokenInfo(input.Symbol);
697+
if (tokenInfo == null)
698+
{
699+
throw new AssertionException("Seed NFT does not exist.");
700+
}
701+
702+
Assert(tokenInfo.Owner == Context.Sender, "Sender is not Seed NFT owner.");
703+
var oldExpireTimeLong = 0L;
704+
if (tokenInfo.ExternalInfo.Value.TryGetValue(TokenContractConstants.SeedExpireTimeExternalInfoKey,
705+
out var oldExpireTime))
706+
{
707+
long.TryParse(oldExpireTime, out oldExpireTimeLong);
708+
}
709+
710+
tokenInfo.ExternalInfo.Value[TokenContractConstants.SeedExpireTimeExternalInfoKey] =
711+
input.ExpirationTime.ToString();
712+
State.TokenInfos[input.Symbol] = tokenInfo;
713+
Context.Fire(new SeedExpirationTimeUpdated
714+
{
715+
ChainId = tokenInfo.IssueChainId,
716+
Symbol = input.Symbol,
717+
OldExpirationTime = oldExpireTimeLong,
718+
NewExpirationTime = input.ExpirationTime
719+
});
720+
return new Empty();
721+
}
722+
694723
private int GetMaxBatchApproveCount()
695724
{
696725
return State.MaxBatchApproveCount.Value == 0

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "8.0.x"
3+
"version": "8.0.*"
44
}
55
}

nuget.config

Lines changed: 3 additions & 0 deletions
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/aelf/core.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ enum TransactionResultStatus {
5959
PENDING_VALIDATION = 5;
6060
// Transaction validation failed.
6161
NODE_VALIDATION_FAILED = 6;
62+
// Transaction is expired
63+
EXPIRED = 7;
6264
}
6365

6466
message TransactionResult {

protobuf/token_contract_impl.proto

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ service TokenContractImpl {
182182
rpc GetMaxBatchApproveCount (google.protobuf.Empty) returns (google.protobuf.Int32Value) {
183183

184184
}
185+
186+
rpc ExtendSeedExpirationTime (ExtendSeedExpirationTimeInput) returns (google.protobuf.Empty) {
187+
}
185188
}
186189

187190
message AdvanceResourceTokenInput {
@@ -444,4 +447,17 @@ message ModifyTokenIssuerAndOwnerInput {
444447

445448
message SetTokenIssuerAndOwnerModificationEnabledInput{
446449
bool enabled = 1;
450+
}
451+
452+
message ExtendSeedExpirationTimeInput {
453+
string symbol = 1;
454+
int64 expiration_time = 2;
455+
}
456+
457+
message SeedExpirationTimeUpdated {
458+
option (aelf.is_event) = true;
459+
int32 chain_id = 1;
460+
string symbol = 2;
461+
int64 old_expiration_time = 3;
462+
int64 new_expiration_time = 4;
447463
}

protobuf/virtual_transaction.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ message VirtualTransactionCreated {
1717
string method_name = 4 [(aelf.is_indexed) = true];
1818
bytes params = 5;
1919
aelf.Address signatory = 6 [(aelf.is_indexed) = true];
20-
}
20+
}

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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 34 additions & 1 deletion
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.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+
}
Lines changed: 22 additions & 0 deletions
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+
}
Lines changed: 12 additions & 0 deletions
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.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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/Application/IExecutionObserverThresholdProvider.cs

Lines changed: 1 addition & 1 deletion
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)