Skip to content

Commit

Permalink
Merge pull request #3394 from AElfProject/release/1.3.0
Browse files Browse the repository at this point in the history
Release v1.3.0
  • Loading branch information
jason-aelf authored Apr 6, 2023
2 parents 8d733b0 + 7b06a33 commit b4df4f6
Show file tree
Hide file tree
Showing 221 changed files with 21,163 additions and 9,956 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ scripts/patcher/*

tools
.dotnet
!.idea/
.idea/.idea.AElf.All/*
.idea/.idea.AElf/.idea/contentModel.xml
.idea/.idea.AElf/.idea/encodings.xml
.idea/.idea.AElf/.idea/indexLayout.xml
Expand Down
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

21 changes: 14 additions & 7 deletions AElf.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.ContractDeployer.Tests
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.NFT", "contract\AElf.Contracts.NFT\AElf.Contracts.NFT.csproj", "{0ECCF46E-3989-4A7E-BA31-4E73D7515578}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.NFT.Tests", "test\AElf.Contracts.NFT.Tests\AElf.Contracts.NFT.Tests.csproj", "{7E07BD13-74BF-4FD7-A294-07E664C47100}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.TestContract.BigIntValue", "test\AElf.Contracts.TestContract.BigIntValue\AElf.Contracts.TestContract.BigIntValue.csproj", "{F50AF512-69E2-46B5-87C6-E058CE2C2D8A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureManager", "src\AElf.Kernel.FeatureManager\AElf.Kernel.FeatureManager.csproj", "{B24BC602-DAFD-4941-A913-8B0725691681}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureManager.Tests", "test\AElf.Kernel.FeatureManager.Tests\AElf.Kernel.FeatureManager.Tests.csproj", "{1B44277E-74EB-49B2-B8FD-05C29EE51985}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.CSharp.CodeOps.UnitTests", "test\AElf.CSharp.CodeOps.UnitTests\AElf.CSharp.CodeOps.UnitTests.csproj", "{D1A00CD6-958E-4E9F-8325-354309E3029E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract", "test\AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract\AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract.csproj", "{AB27298B-E6BE-4ACB-ADF1-64239E2A7A1C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1037,10 +1039,6 @@ Global
{0ECCF46E-3989-4A7E-BA31-4E73D7515578}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0ECCF46E-3989-4A7E-BA31-4E73D7515578}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0ECCF46E-3989-4A7E-BA31-4E73D7515578}.Release|Any CPU.Build.0 = Release|Any CPU
{7E07BD13-74BF-4FD7-A294-07E664C47100}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E07BD13-74BF-4FD7-A294-07E664C47100}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E07BD13-74BF-4FD7-A294-07E664C47100}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E07BD13-74BF-4FD7-A294-07E664C47100}.Release|Any CPU.Build.0 = Release|Any CPU
{F50AF512-69E2-46B5-87C6-E058CE2C2D8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F50AF512-69E2-46B5-87C6-E058CE2C2D8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F50AF512-69E2-46B5-87C6-E058CE2C2D8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -1053,6 +1051,14 @@ Global
{1B44277E-74EB-49B2-B8FD-05C29EE51985}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B44277E-74EB-49B2-B8FD-05C29EE51985}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B44277E-74EB-49B2-B8FD-05C29EE51985}.Release|Any CPU.Build.0 = Release|Any CPU
{D1A00CD6-958E-4E9F-8325-354309E3029E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1A00CD6-958E-4E9F-8325-354309E3029E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1A00CD6-958E-4E9F-8325-354309E3029E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1A00CD6-958E-4E9F-8325-354309E3029E}.Release|Any CPU.Build.0 = Release|Any CPU
{AB27298B-E6BE-4ACB-ADF1-64239E2A7A1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB27298B-E6BE-4ACB-ADF1-64239E2A7A1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB27298B-E6BE-4ACB-ADF1-64239E2A7A1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB27298B-E6BE-4ACB-ADF1-64239E2A7A1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1234,9 +1240,10 @@ Global
{C3EEC9D9-F818-4058-B6F3-B71C1C0B8D47} = {4E54480A-D155-43ED-9736-1A5BE7957211}
{B64C5954-9CC0-4A0B-9453-92324B51C23D} = {4E54480A-D155-43ED-9736-1A5BE7957211}
{0ECCF46E-3989-4A7E-BA31-4E73D7515578} = {9AA521A5-80BF-4D20-9339-31D7E86D5868}
{7E07BD13-74BF-4FD7-A294-07E664C47100} = {D3950CC9-808F-4ED8-946A-79A992F3F8EF}
{F50AF512-69E2-46B5-87C6-E058CE2C2D8A} = {D3950CC9-808F-4ED8-946A-79A992F3F8EF}
{B24BC602-DAFD-4941-A913-8B0725691681} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
{1B44277E-74EB-49B2-B8FD-05C29EE51985} = {4E54480A-D155-43ED-9736-1A5BE7957211}
{D1A00CD6-958E-4E9F-8325-354309E3029E} = {4E54480A-D155-43ED-9736-1A5BE7957211}
{AB27298B-E6BE-4ACB-ADF1-64239E2A7A1C} = {4E54480A-D155-43ED-9736-1A5BE7957211}
EndGlobalSection
EndGlobal
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
[![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain)
[![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper)

BRANCH | TRAVIS CI | AZURE PIPELINES | TESTS | CODE COVERAGE
-------|-----------|-----------------|-------|--------------
MASTER |[![Build Status](https://travis-ci.org/AElfProject/AElf.svg?branch=master)](https://travis-ci.org/AElfProject/AElf) | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf)
DEV |[![Build Status](https://travis-ci.org/AElfProject/AElf.svg?branch=dev)](https://travis-ci.org/AElfProject/AElf) | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf)
BRANCH | AZURE PIPELINES | TESTS | CODE COVERAGE
------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------
MASTER | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf)
DEV | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf)

Welcome to AElf's official GitHub repo !

Expand All @@ -19,12 +19,12 @@ AElf is a blockchain system aiming to achieve scalability and extensibility thro
For more information you can follow these links:
* [Official website](https://aelf.io)
* [Documentation](https://docs.aelf.io/en/latest/)
* [Environment setup](https://docs.aelf.io/en/latest/getting-started/development-environment/environment-setup.html)
* [Running a node](https://docs.aelf.io/en/latest/getting-started/development-environment/docker.html)
* [Smart contract development](https://docs.aelf.io/en/latest/getting-started/smart-contract-development/index.html)
* [Environment setup](https://docs.aelf.io/en/latest/getting_started/development-environment/index.html)
* [Running a node](https://docs.aelf.io/en/latest/getting_started/development-environment/node.html)
* [Smart contract development](https://docs.aelf.io/en/latest/getting_started/smart_contracts/index.html)
* [Web Api](https://docs.aelf.io/en/latest/reference/web-api/web-api.html)
* [Testnet](https://docs.aelf.io/en/latest/tutorials/testnet.html)
* [White Paper](https://aelf.io/gridcn/aelf_whitepaper_EN.pdf)
* [White Paper](https://aelf.com/gridcn/aelf_whitepaper_v1.7_en.pdf)

This repository contains the code that runs an AElf node, you'll find bellow other important repositories in the AElf
ecosystem:
Expand All @@ -45,8 +45,8 @@ This repo is where you will find the code that can use to run an AElf node. It a

We strongly recommend you follow official documentation that will guide you through installing dependencies and running the node,
these two guides will get you started:
* [Environment setup](https://docs.aelf.io/en/latest/getting-started/development-environment/environment-setup.html)
* [Running a node](https://docs.aelf.io/en/latest/getting-started/development-environment/docker.html)
* [Environment setup](https://docs.aelf.io/en/latest/getting_started/development-environment/index.html)
* [Running a node](https://docs.aelf.io/en/latest/getting_started/development-environment/node.html)

## Contributing

Expand Down Expand Up @@ -79,7 +79,7 @@ For any non trivial modification of the code, the pull requests should be associ
- add the tests corresponding to your modifications.
- pull requests should be made against the **dev** branch.

When you are ready for a review by the core team, just remove ```[WIP]``` from your PR's title and others will review. This will either lead to a discussion or to a refactor of the code. The Travis CI system makes sure that every pull request is built for Windows, Linux, and macOS, and that unit tests are run automatically. The CI passing is a pre-condition for the PR to be merged as well as the approval from the core team.
When you are ready for a review by the core team, just remove ```[WIP]``` from your PR's title and others will review. This will either lead to a discussion or to a refactor of the code. The Azure Pipelines CI system makes sure that every pull request is built for Windows, Linux, and macOS, and that unit tests are run automatically. The CI passing is a pre-condition for the PR to be merged as well as the approval from the core team.

## Versioning

Expand Down
1 change: 1 addition & 0 deletions bench/AElf.Benchmark/AElf.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1"/>
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.12.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.6.0-1.final" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions contract/AElf.Contracts.CrossChain/CrossChainContract_Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ private IndexedParentChainBlockData IndexParentChainBlockData(IList<ParentChainB
}

State.CurrentParentChainHeight.Value = currentHeight;

Context.Fire(new ParentChainIndexed
{
ChainId = parentChainId,
IndexedHeight = currentHeight
});

return indexedParentChainBlockData;
}
Expand Down Expand Up @@ -870,6 +876,12 @@ private List<SideChainBlockData> IndexSideChainBlockData(IList<SideChainBlockDat

State.SideChainInfo[chainId] = sideChainInfo;
State.CurrentSideChainHeight[chainId] = currentSideChainHeight;

Context.Fire(new SideChainIndexed
{
ChainId = chainId,
IndexedHeight = currentSideChainHeight
});
}

if (indexedSideChainBlockData.Count > 0)
Expand Down
1 change: 1 addition & 0 deletions contract/AElf.Contracts.Election/ElectionContractState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ public partial class ElectionContractState : ContractState
public BoolState ElectionEnabled { get; set; }

public MappedState<Hash, bool> WeightsAlreadyFixedMap { get; set; }

}
13 changes: 4 additions & 9 deletions contract/AElf.Contracts.Election/ElectionContract_Candidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public override Empty AnnounceElection(Address input)
if (State.Candidates.Value.Value.Count <= GetValidationDataCenterCount())
{
State.DataCentersRankingList.Value.DataCenters.Add(pubkey, 0);
RegisterCandidateToSubsidyProfitScheme(address);
RegisterCandidateToSubsidyProfitScheme(pubkey);
}

return new Empty();
Expand All @@ -134,7 +134,7 @@ public override Empty AnnounceElectionFor(AnnounceElectionForInput input)
if (State.Candidates.Value.Value.Count <= GetValidationDataCenterCount())
{
State.DataCentersRankingList.Value.DataCenters.Add(pubkey, 0);
RegisterCandidateToSubsidyProfitScheme(address);
RegisterCandidateToSubsidyProfitScheme(pubkey);
}

State.CandidateSponsorMap[input.Pubkey] = Context.Sender;
Expand Down Expand Up @@ -208,18 +208,13 @@ private void AddCandidateAsOption(string publicKey)
});
}

private void RegisterCandidateToSubsidyProfitScheme(Address candidateAddress)
private void RegisterCandidateToSubsidyProfitScheme(string candidatePubkey)
{
if (State.ProfitContract.Value == null)
State.ProfitContract.Value =
Context.GetContractAddressByName(SmartContractConstants.ProfitContractSystemName);

// Add 1 Shares for this candidate in subsidy profit scheme.
State.ProfitContract.AddBeneficiary.Send(new AddBeneficiaryInput
{
SchemeId = State.SubsidyHash.Value,
BeneficiaryShare = new BeneficiaryShare { Beneficiary = candidateAddress, Shares = 1 }
});
AddBeneficiary(candidatePubkey);
}

#endregion
Expand Down
89 changes: 60 additions & 29 deletions contract/AElf.Contracts.Election/ElectionContract_Elector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using AElf.Contracts.MultiToken;
using AElf.Contracts.Profit;
using AElf.Contracts.Treasury;
using AElf.Contracts.Vote;
using AElf.CSharp.Core;
using AElf.Sdk.CSharp;
Expand Down Expand Up @@ -106,16 +107,7 @@ public override Empty ChangeVotingOption(ChangeVotingOptionInput input)
dataCenterList.DataCenters.Add(input.CandidatePubkey,
State.CandidateVotes[input.CandidatePubkey].ObtainedActiveVotedVotesAmount);

State.ProfitContract.AddBeneficiary.Send(new AddBeneficiaryInput
{
SchemeId = State.SubsidyHash.Value,
BeneficiaryShare = new BeneficiaryShare
{
Beneficiary =
Address.FromPublicKey(ByteArrayHelper.HexStringToByteArray(input.CandidatePubkey)),
Shares = 1
}
});
AddBeneficiary(input.CandidatePubkey);
}
else
{
Expand Down Expand Up @@ -465,16 +457,7 @@ public override Hash Vote(VoteMinerInput input)
{
State.DataCentersRankingList.Value.DataCenters.Add(input.CandidatePubkey,
candidateVotesAmount);
State.ProfitContract.AddBeneficiary.Send(new AddBeneficiaryInput
{
SchemeId = State.SubsidyHash.Value,
BeneficiaryShare = new BeneficiaryShare
{
Beneficiary =
Address.FromPublicKey(ByteArrayHelper.HexStringToByteArray(input.CandidatePubkey)),
Shares = 1
}
});
AddBeneficiary(input.CandidatePubkey);
}
else
{
Expand Down Expand Up @@ -749,24 +732,72 @@ private void CandidateReplaceMemberInDataCenter(DataCenterRankingList rankingLis
private void NotifyProfitReplaceCandidateInDataCenter(string oldCandidateInDataCenter,
string newCandidateDataCenter)
{
State.ProfitContract.RemoveBeneficiary.Send(new RemoveBeneficiaryInput
{
SchemeId = State.SubsidyHash.Value,
Beneficiary = Address.FromPublicKey(ByteArrayHelper.HexStringToByteArray(oldCandidateInDataCenter))
});
RemoveBeneficiary(oldCandidateInDataCenter);

if (newCandidateDataCenter == null)
return;

AddBeneficiary(newCandidateDataCenter);
}

#endregion

#region subsidy helper

private Hash GenerateSubsidyId(string pubkey,Address beneficiaryAddress)
{
return HashHelper.ConcatAndCompute(HashHelper.ComputeFrom(pubkey), HashHelper.ComputeFrom(beneficiaryAddress),
HashHelper.ComputeFrom(Context.Self));
}

private Address GetProfitsReceiverOrDefault(string pubkey)
{
if (State.TreasuryContract.Value == null)
State.TreasuryContract.Value =
Context.GetContractAddressByName(SmartContractConstants.TreasuryContractSystemName);
var address = State.TreasuryContract.GetProfitsReceiverOrDefault.Call(new StringValue
{
Value = pubkey
});
return address;
}

private void AddBeneficiary(string candidatePubkey, Address profitsReceiver = null)
{
var beneficiaryAddress = GetBeneficiaryAddress(candidatePubkey, profitsReceiver);
var subsidyId = GenerateSubsidyId(candidatePubkey,beneficiaryAddress);
State.ProfitContract.AddBeneficiary.Send(new AddBeneficiaryInput
{
SchemeId = State.SubsidyHash.Value,
BeneficiaryShare = new BeneficiaryShare
{
Beneficiary =
Address.FromPublicKey(ByteArrayHelper.HexStringToByteArray(newCandidateDataCenter)),
Shares = 1
}
Beneficiary = beneficiaryAddress,
Shares = 1,
},
ProfitDetailId = subsidyId
});
}

private void RemoveBeneficiary(string candidatePubkey,Address profitsReceiver = null)
{
var beneficiaryAddress = GetBeneficiaryAddress(candidatePubkey, profitsReceiver);
var previousSubsidyId = GenerateSubsidyId(candidatePubkey,beneficiaryAddress);
State.ProfitContract.RemoveBeneficiary.Send(new RemoveBeneficiaryInput
{
SchemeId = State.SubsidyHash.Value,
Beneficiary = beneficiaryAddress,
ProfitDetailId = previousSubsidyId
});
}

private Address GetBeneficiaryAddress(string candidatePubkey, Address profitsReceiver = null)
{
profitsReceiver = profitsReceiver == null ? GetProfitsReceiverOrDefault(candidatePubkey) : profitsReceiver;
var beneficiaryAddress = profitsReceiver.Value.Any()
? profitsReceiver
: Address.FromPublicKey(ByteArrayHelper.HexStringToByteArray(candidatePubkey));
return beneficiaryAddress;
}

#endregion
}
Loading

0 comments on commit b4df4f6

Please sign in to comment.