Skip to content

Commit

Permalink
Merge pull request #3630 from AElfProject/release/1.12.2
Browse files Browse the repository at this point in the history
Regarding the release PR for aelf project version 1.12.0
  • Loading branch information
JimAelf authored Jan 8, 2025
2 parents 4deeae5 + 3688493 commit 1c65ebd
Show file tree
Hide file tree
Showing 31 changed files with 702 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sonarqube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*"}}' > ./global.json
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
Expand Down
40 changes: 20 additions & 20 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -40,9 +40,9 @@ jobs:
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

Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ private void ProcessNextRound(NextRoundInput input)
{
var minersCount = GetMinersCount(nextRound);
if (minersCount != 0 && State.ElectionContract.Value != null)
{
State.ElectionContract.UpdateMinersCount.Send(new UpdateMinersCountInput
{
MinersCount = minersCount
});
}
}
}

Expand Down
29 changes: 29 additions & 0 deletions contract/AElf.Contracts.MultiToken/TokenContract_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,35 @@ public override Int32Value GetMaxBatchApproveCount(Empty input)
};
}

public override Empty ExtendSeedExpirationTime(ExtendSeedExpirationTimeInput input)
{
var tokenInfo = GetTokenInfo(input.Symbol);
if (tokenInfo == null)
{
throw new AssertionException("Seed NFT does not exist.");
}

Assert(tokenInfo.Owner == Context.Sender, "Sender is not Seed NFT owner.");
var oldExpireTimeLong = 0L;
if (tokenInfo.ExternalInfo.Value.TryGetValue(TokenContractConstants.SeedExpireTimeExternalInfoKey,
out var oldExpireTime))
{
long.TryParse(oldExpireTime, out oldExpireTimeLong);
}

tokenInfo.ExternalInfo.Value[TokenContractConstants.SeedExpireTimeExternalInfoKey] =
input.ExpirationTime.ToString();
State.TokenInfos[input.Symbol] = tokenInfo;
Context.Fire(new SeedExpirationTimeUpdated
{
ChainId = tokenInfo.IssueChainId,
Symbol = input.Symbol,
OldExpirationTime = oldExpireTimeLong,
NewExpirationTime = input.ExpirationTime
});
return new Empty();
}

private int GetMaxBatchApproveCount()
{
return State.MaxBatchApproveCount.Value == 0
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.x"
"version": "8.0.*"
}
}
3 changes: 3 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3"/>
<add key="aelf" value="https://www.myget.org/F/aelf-project-dev/api/v3/index.json" protocolVersion="3"/>
<add key="Nuget Test" value="https://int.nugettest.org/api/v2" />
<add key="nexus" value="https://nexus-poc.test.aelf.dev/repository/nuget-group/index.json" protocolVersion="3" />
</packageSources>
</configuration>
2 changes: 2 additions & 0 deletions protobuf/aelf/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ enum TransactionResultStatus {
PENDING_VALIDATION = 5;
// Transaction validation failed.
NODE_VALIDATION_FAILED = 6;
// Transaction is expired
EXPIRED = 7;
}

message TransactionResult {
Expand Down
16 changes: 16 additions & 0 deletions protobuf/token_contract_impl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ service TokenContractImpl {
rpc GetMaxBatchApproveCount (google.protobuf.Empty) returns (google.protobuf.Int32Value) {

}

rpc ExtendSeedExpirationTime (ExtendSeedExpirationTimeInput) returns (google.protobuf.Empty) {
}
}

message AdvanceResourceTokenInput {
Expand Down Expand Up @@ -444,4 +447,17 @@ message ModifyTokenIssuerAndOwnerInput {

message SetTokenIssuerAndOwnerModificationEnabledInput{
bool enabled = 1;
}

message ExtendSeedExpirationTimeInput {
string symbol = 1;
int64 expiration_time = 2;
}

message SeedExpirationTimeUpdated {
option (aelf.is_event) = true;
int32 chain_id = 1;
string symbol = 2;
int64 old_expiration_time = 3;
int64 new_expiration_time = 4;
}
2 changes: 1 addition & 1 deletion protobuf/virtual_transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ message VirtualTransactionCreated {
string method_name = 4 [(aelf.is_indexed) = true];
bytes params = 5;
aelf.Address signatory = 6 [(aelf.is_indexed) = true];
}
}
3 changes: 1 addition & 2 deletions src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.5.0" />
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="Groth16.Net" Version="1.1.0" />
<PackageReference Include="Poseidon.Net" Version="0.1.1" />
<PackageReference Include="Groth16.Net" Version="1.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/AElf.CSharp.CodeOps/Validators/Method/ArrayValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +25,7 @@ public class ArrayValidator : IValidator<MethodDefinition>, 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using AElf.Cryptography.Bn254;
using AElf.Cryptography.EdDSA;
using AElf.Cryptography.Keccak;
using AElf.Cryptography.SecretSharing;
using AElf.CSharp.Core;
using AElf.Kernel.SmartContract;
Expand Down Expand Up @@ -50,7 +53,6 @@ private void WhitelistAssemblies(Whitelist whitelist)
.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)
;
}

Expand All @@ -64,6 +66,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))
Expand Down Expand Up @@ -160,6 +171,27 @@ private void WhitelistOthers(Whitelist whitelist)
)
;
}

private void WhitelistCryptographyHelpers(Whitelist whitelist)
{
whitelist
// Selectively allowed types and members
.Namespace("AElf.Cryptography.Bn254", Permission.Denied, type => type
.Type(typeof(Bn254Helper), Permission.Denied, member => member
.Member(nameof(Bn254Helper.Bn254Pairing), Permission.Allowed)
.Member(nameof(Bn254Helper.Bn254G1Add), Permission.Allowed)
.Member(nameof(Bn254Helper.Bn254G1Mul), Permission.Allowed)
))
.Namespace("AElf.Cryptography.EdDSA", Permission.Denied, type => type
.Type(typeof(EdDsaHelper), Permission.Denied, member => member
.Member(nameof(EdDsaHelper.Ed25519Verify), Permission.Allowed)
))
.Namespace("AElf.Cryptography.Keccak", Permission.Denied, type => type
.Type(typeof(KeccakHelper), Permission.Denied, member => member
.Member(nameof(KeccakHelper.Keccak256), Permission.Allowed)
))
;
}

private Whitelist CreateWhitelist()
{
Expand All @@ -169,6 +201,7 @@ private Whitelist CreateWhitelist()
WhitelistReflectionTypes(whitelist);
WhitelistLinqAndCollections(whitelist);
WhitelistOthers(whitelist);
WhitelistCryptographyHelpers(whitelist);
return whitelist;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/AElf.Cryptography/AElf.Cryptography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PackageReference Include="Secp256k1.Net" Version="1.2.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="Secp256k1.Native" Version="0.1.24-alpha" />
<PackageReference Include="Bn254.Net" Version="0.1.0" />
<PackageReference Include="Rebex.Elliptic.Ed25519" Version="1.2.1" />
<PackageReference Include="Nethereum.Web3" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AElf.Types\AElf.Types.csproj" />
Expand Down
38 changes: 38 additions & 0 deletions src/AElf.Cryptography/Bn254/Bn254Helper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Bn254.Net;
using NetBn254 = Bn254.Net;

namespace AElf.Cryptography.Bn254
{
public static class Bn254Helper
{
public static (byte[] x, byte[] y) Bn254G1Mul(byte[] x1, byte[] y1, byte[] s)
{
var (xUInt256, yUInt256) = NetBn254.Bn254.Mul(UInt256.FromBigEndianBytes(x1),
UInt256.FromBigEndianBytes(y1),
UInt256.FromBigEndianBytes(s));
return (xUInt256.ToBigEndianBytes(), yUInt256.ToBigEndianBytes());
}

public static (byte[] x3, byte[] y3) Bn254G1Add(byte[] x1, byte[] y1, byte[] x2, byte[] y2)
{
var (x3UInt256, y3UInt256) = NetBn254.Bn254.Add(UInt256.FromBigEndianBytes(x1),
UInt256.FromBigEndianBytes(y1),
UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2));
return (x3UInt256.ToBigEndianBytes(), y3UInt256.ToBigEndianBytes());
}

public static 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 NetBn254.Bn254.Pairing(elements);
}
}
}
22 changes: 22 additions & 0 deletions src/AElf.Cryptography/EdDSA/EdDsaHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using Rebex.Security.Cryptography;

namespace AElf.Cryptography.EdDSA
{
public static class EdDsaHelper
{
public static bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey)
{
try
{
var instance = new Ed25519();
instance.FromPublicKey(publicKey);
return instance.VerifyMessage(message, signature);
}
catch (Exception e)
{
return false;
}
}
}
}
12 changes: 12 additions & 0 deletions src/AElf.Cryptography/Keccak/KeccakHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Nethereum.Util;

namespace AElf.Cryptography.Keccak
{
public static class KeccakHelper
{
public static byte[] Keccak256(byte[] message)
{
return Sha3Keccack.Current.CalculateHash(message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Configuration>Release</Configuration>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Configuration>Release</Configuration>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 1c65ebd

Please sign in to comment.