diff --git a/.github/workflows/benchmark_action.yml b/.github/workflows/benchmark_action.yml index 1717d86906..304c497745 100644 --- a/.github/workflows/benchmark_action.yml +++ b/.github/workflows/benchmark_action.yml @@ -25,7 +25,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0' + dotnet-version: '8.0' - name: 'Download AElf build tools' run: bash scripts/download_binary.sh diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 01e315a740..dbfca652b6 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -13,9 +13,9 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0' + dotnet-version: '8.0' - name: Create temporary global.json - run: echo '{"sdk":{"version":"7.0.410"}}' > ./global.json + run: echo '{"sdk":{"version":"8.0.303"}}' > ./global.json - name: Set up JDK 17 uses: actions/setup-java@v1 with: diff --git a/AElf.All.sln b/AElf.All.sln index 8a5a57bb48..34ad27a9ac 100644 --- a/AElf.All.sln +++ b/AElf.All.sln @@ -379,6 +379,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.TestContract EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.VirtualTransactionEventContract.Tests", "test\AElf.Contracts.VirtualTransactionEventContract.Tests\AElf.Contracts.VirtualTransactionEventContract.Tests.csproj", "{6981684D-450C-412B-9082-0B0A67A679B9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable", "src\AElf.Kernel.FeatureDisable\AElf.Kernel.FeatureDisable.csproj", "{A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.Tests", "test\AElf.Kernel.FeatureDisable.Tests\AElf.Kernel.FeatureDisable.Tests.csproj", "{8C0D86A4-D1A7-4B61-AC44-755F5AC75D67}" +EndProject +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}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1089,6 +1095,18 @@ Global {6981684D-450C-412B-9082-0B0A67A679B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {6981684D-450C-412B-9082-0B0A67A679B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {6981684D-450C-412B-9082-0B0A67A679B9}.Release|Any CPU.Build.0 = Release|Any CPU + {A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E}.Release|Any CPU.Build.0 = Release|Any CPU + {8C0D86A4-D1A7-4B61-AC44-755F5AC75D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C0D86A4-D1A7-4B61-AC44-755F5AC75D67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C0D86A4-D1A7-4B61-AC44-755F5AC75D67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C0D86A4-D1A7-4B61-AC44-755F5AC75D67}.Release|Any CPU.Build.0 = Release|Any CPU + {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1280,5 +1298,8 @@ Global {64498F8C-B827-4E1C-B5FB-4B9188C839A8} = {D3950CC9-808F-4ED8-946A-79A992F3F8EF} {0F10B838-C363-4F55-A5BB-B7F9F80565AB} = {D3950CC9-808F-4ED8-946A-79A992F3F8EF} {6981684D-450C-412B-9082-0B0A67A679B9} = {D3950CC9-808F-4ED8-946A-79A992F3F8EF} + {A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC} + {8C0D86A4-D1A7-4B61-AC44-755F5AC75D67} = {4E54480A-D155-43ED-9736-1A5BE7957211} + {659A7C7A-44C9-424E-B4F6-D1D3656F7AD4} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC} EndGlobalSection EndGlobal diff --git a/bench/AElf.BenchBase/AElf.BenchBase.csproj b/bench/AElf.BenchBase/AElf.BenchBase.csproj index 64d89d764d..a94ad8e78b 100644 --- a/bench/AElf.BenchBase/AElf.BenchBase.csproj +++ b/bench/AElf.BenchBase/AElf.BenchBase.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false diff --git a/bench/AElf.Benchmark.PerformanceTestContract/AElf.Benchmark.PerformanceTestContract.csproj b/bench/AElf.Benchmark.PerformanceTestContract/AElf.Benchmark.PerformanceTestContract.csproj index 15c160229f..d8a7b2261b 100644 --- a/bench/AElf.Benchmark.PerformanceTestContract/AElf.Benchmark.PerformanceTestContract.csproj +++ b/bench/AElf.Benchmark.PerformanceTestContract/AElf.Benchmark.PerformanceTestContract.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false true diff --git a/bench/AElf.Benchmark/AElf.Benchmark.csproj b/bench/AElf.Benchmark/AElf.Benchmark.csproj index d24e1eafc6..431fb96346 100644 --- a/bench/AElf.Benchmark/AElf.Benchmark.csproj +++ b/bench/AElf.Benchmark/AElf.Benchmark.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false Exe diff --git a/bench/AElf.Database.Benches/AElf.Database.Benches.csproj b/bench/AElf.Database.Benches/AElf.Database.Benches.csproj index 21a43a9247..43f5236477 100644 --- a/bench/AElf.Database.Benches/AElf.Database.Benches.csproj +++ b/bench/AElf.Database.Benches/AElf.Database.Benches.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false xUnit1013 diff --git a/build.config b/build.config index d956e69e20..b55ec20ed7 100644 --- a/build.config +++ b/build.config @@ -1,3 +1,3 @@ #!/usr/bin/env bash CAKE_VERSION=0.37.0 -DOTNET_VERSION=6.0.300 \ No newline at end of file +DOTNET_VERSION=8.0.303 \ No newline at end of file diff --git a/contract/AElf.Contracts.Association/AElf.Contracts.Association.csproj b/contract/AElf.Contracts.Association/AElf.Contracts.Association.csproj index 0d2c24b45d..cafcb3417b 100644 --- a/contract/AElf.Contracts.Association/AElf.Contracts.Association.csproj +++ b/contract/AElf.Contracts.Association/AElf.Contracts.Association.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Association true Association is a contract that enables the creation of organizations and approvals. diff --git a/contract/AElf.Contracts.Association/Association.cs b/contract/AElf.Contracts.Association/Association.cs index db9a2d81dd..f00b978f27 100644 --- a/contract/AElf.Contracts.Association/Association.cs +++ b/contract/AElf.Contracts.Association/Association.cs @@ -35,7 +35,9 @@ public override ProposalOutput GetProposal(Hash proposalId) ToBeReleased = readyToRelease, ApprovalCount = proposal.Approvals.Count, RejectionCount = proposal.Rejections.Count, - AbstentionCount = proposal.Abstentions.Count + AbstentionCount = proposal.Abstentions.Count, + Title = proposal.Title, + Description = proposal.Description }; } diff --git a/contract/AElf.Contracts.Association/AssociationConstants.cs b/contract/AElf.Contracts.Association/AssociationConstants.cs new file mode 100644 index 0000000000..d2afee8e13 --- /dev/null +++ b/contract/AElf.Contracts.Association/AssociationConstants.cs @@ -0,0 +1,8 @@ +namespace AElf.Contracts.Association; + +public static class AssociationConstants +{ + public const int MaxLengthForTitle = 255; + public const int MaxLengthForDescription = 10200; + public const int MaxLengthForProposalDescriptionUrl = 255; +} \ No newline at end of file diff --git a/contract/AElf.Contracts.Association/Association_Helper.cs b/contract/AElf.Contracts.Association/Association_Helper.cs index c246df26ee..cc1a7d0643 100644 --- a/contract/AElf.Contracts.Association/Association_Helper.cs +++ b/contract/AElf.Contracts.Association/Association_Helper.cs @@ -144,6 +144,7 @@ private Hash GenerateProposalId(CreateProposalInput input) private Hash CreateNewProposal(CreateProposalInput input) { + CheckCreateProposalInput(input); var proposalId = GenerateProposalId(input); var proposal = new ProposalInfo { @@ -154,7 +155,9 @@ private Hash CreateNewProposal(CreateProposalInput input) OrganizationAddress = input.OrganizationAddress, ProposalId = proposalId, Proposer = Context.Sender, - ProposalDescriptionUrl = input.ProposalDescriptionUrl + ProposalDescriptionUrl = input.ProposalDescriptionUrl, + Title = input.Title, + Description = input.Description }; Assert(Validate(proposal), "Invalid proposal."); Assert(State.Proposals[proposalId] == null, "Proposal already exists."); @@ -162,8 +165,21 @@ private Hash CreateNewProposal(CreateProposalInput input) Context.Fire(new ProposalCreated { ProposalId = proposalId, - OrganizationAddress = input.OrganizationAddress + OrganizationAddress = input.OrganizationAddress, + Title = input.Title, + Description = input.Description }); return proposalId; } + + private void CheckCreateProposalInput(CreateProposalInput input) + { + // Check the length of title + Assert(input.Title.Length <= AssociationConstants.MaxLengthForTitle, "Title is too long."); + // Check the length of description + Assert(input.Description.Length <= AssociationConstants.MaxLengthForDescription, "Description is too long."); + // Check the length of description url + Assert(input.ProposalDescriptionUrl.Length <= AssociationConstants.MaxLengthForProposalDescriptionUrl, + "Description url is too long."); + } } \ No newline at end of file diff --git a/contract/AElf.Contracts.Configuration/AElf.Contracts.Configuration.csproj b/contract/AElf.Contracts.Configuration/AElf.Contracts.Configuration.csproj index 414dc60419..e06e6e236c 100644 --- a/contract/AElf.Contracts.Configuration/AElf.Contracts.Configuration.csproj +++ b/contract/AElf.Contracts.Configuration/AElf.Contracts.Configuration.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Configuration true Configuration is a contract used for changing configurable aspects of the chain, like for example diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContractConstants.cs b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContractConstants.cs index 9c4f4c1599..8fd009bab6 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContractConstants.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContractConstants.cs @@ -12,4 +12,5 @@ public static class AEDPoSContractConstants public const string SideChainShareProfitsTokenSymbol = "SHARE"; public const string PayTxFeeSymbolListName = "SymbolListToPayTxFee"; public const string PayRentalSymbolListName = "SymbolListToPayRental"; + public const string SecretSharingEnabledConfigurationKey = "SecretSharingEnabled"; } \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ACS11_CrossChainInformationProvider.cs b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ACS11_CrossChainInformationProvider.cs index 0b7fd8af6b..bb05712a7c 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ACS11_CrossChainInformationProvider.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ACS11_CrossChainInformationProvider.cs @@ -57,7 +57,7 @@ public override Empty UpdateInformationFromCrossChain(BytesValue input) var minersKeys = consensusInformation.Round.RealTimeMinersInformation.Keys; State.MainChainCurrentMinerList.Value = new MinerList { - Pubkeys = { minersKeys.Select(ByteStringHelper.FromHexString) } + Pubkeys = { minersKeys.Select(k => ByteStringHelper.FromHexString(k)) } }; return new Empty(); diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_GetConsensusBlockExtraData.cs b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_GetConsensusBlockExtraData.cs index bbbce356a4..70d9a25596 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_GetConsensusBlockExtraData.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_GetConsensusBlockExtraData.cs @@ -118,7 +118,11 @@ private AElfConsensusHeaderInformation GetConsensusExtraDataToPublishOutValue(Ro updatedRound.RealTimeMinersInformation[pubkey].ImpliedIrreversibleBlockHeight = Context.CurrentHeight; // Update secret pieces of latest in value. - UpdateLatestSecretPieces(updatedRound, pubkey, triggerInformation); + + if (IsSecretSharingEnabled()) + { + UpdateLatestSecretPieces(updatedRound, pubkey, triggerInformation); + } // To publish Out Value. return new AElfConsensusHeaderInformation diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ProcessConsensusInformation.cs b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ProcessConsensusInformation.cs index fd1e42e738..88632c10ff 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ProcessConsensusInformation.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ProcessConsensusInformation.cs @@ -184,7 +184,7 @@ private void ProcessNextTerm(NextTermInput input) // Update miners list. var miners = new MinerList(); - miners.Pubkeys.AddRange(nextRound.RealTimeMinersInformation.Keys.Select(ByteStringHelper.FromHexString)); + miners.Pubkeys.AddRange(nextRound.RealTimeMinersInformation.Keys.Select(k => ByteStringHelper.FromHexString(k))); if (!SetMinerList(miners, nextRound.TermNumber)) Assert(false, "Failed to update miner list."); // Update term number lookup. (Using term number to get first round number of related term.) @@ -249,7 +249,10 @@ private void ProcessUpdateValue(UpdateValueInput updateValueInput) minerInRound.ProducedBlocks = minerInRound.ProducedBlocks.Add(1); minerInRound.ProducedTinyBlocks = minerInRound.ProducedTinyBlocks.Add(1); - PerformSecretSharing(updateValueInput, minerInRound, currentRound, _processingBlockMinerPubkey); + if (IsSecretSharingEnabled()) + { + PerformSecretSharing(updateValueInput, minerInRound, currentRound, _processingBlockMinerPubkey); + } foreach (var tuneOrder in updateValueInput.TuneOrderInformation) currentRound.RealTimeMinersInformation[tuneOrder.Key].FinalOrderOfNextRound = tuneOrder.Value; diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_SecretSharing.cs b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_SecretSharing.cs index 57f132e0de..7fafcc8d67 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_SecretSharing.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_SecretSharing.cs @@ -1,6 +1,9 @@ using System.Linq; using AElf.Cryptography.SecretSharing; using AElf.CSharp.Core; +using AElf.Sdk.CSharp; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; namespace AElf.Contracts.Consensus.AEDPoS; @@ -49,4 +52,28 @@ private void RevealSharedInValues(Round currentRound, string publicKey) currentRound.RealTimeMinersInformation[publicKeyOfAnotherMiner].PreviousInValue = revealedInValue; } } + + private bool IsSecretSharingEnabled() + { + if (State.ConfigurationContract.Value == null) + { + var configurationContractAddress = + Context.GetContractAddressByName(SmartContractConstants.ConfigurationContractSystemName); + if (configurationContractAddress == null) + { + // Which means Configuration Contract hasn't been deployed yet. + return false; + } + + State.ConfigurationContract.Value = configurationContractAddress; + } + + var secretSharingEnabled = new BoolValue(); + secretSharingEnabled.MergeFrom(State.ConfigurationContract.GetConfiguration.Call(new StringValue + { + Value = AEDPoSContractConstants.SecretSharingEnabledConfigurationKey + }).Value); + + return secretSharingEnabled.Value; + } } \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ViewMethods.cs b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ViewMethods.cs index 02fcd80818..ed6e0e0092 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ViewMethods.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ViewMethods.cs @@ -35,7 +35,7 @@ public override MinerList GetCurrentMinerList(Empty input) { Pubkeys = { - round.RealTimeMinersInformation.Keys.Select(ByteStringHelper.FromHexString) + round.RealTimeMinersInformation.Keys.Select(k => ByteStringHelper.FromHexString(k)) } } : new MinerList(); @@ -236,7 +236,7 @@ private Round GenerateFirstRoundOfNextTerm(string senderPubkey, int miningInterv // Miners of new round are same with current round. var miners = new MinerList(); miners.Pubkeys.AddRange( - currentRound.RealTimeMinersInformation.Keys.Select(ByteStringHelper.FromHexString)); + currentRound.RealTimeMinersInformation.Keys.Select(k => ByteStringHelper.FromHexString(k))); newRound = miners.GenerateFirstRoundOfNewTerm(currentRound.GetMiningInterval(), Context.CurrentBlockTime, currentRound); } diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/AElf.Contracts.Consensus.AEDPoS.csproj b/contract/AElf.Contracts.Consensus.AEDPoS/AElf.Contracts.Consensus.AEDPoS.csproj index e197019f68..49c8eed8af 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/AElf.Contracts.Consensus.AEDPoS.csproj +++ b/contract/AElf.Contracts.Consensus.AEDPoS/AElf.Contracts.Consensus.AEDPoS.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Consensus.AEDPoS true Consensus is a contract that implements AElf’s DPoS consensus protocol. @@ -47,6 +47,9 @@ Protobuf\Proto\reference\profit_contract.proto + + Protobuf\Proto\reference\configuration_contract.proto + diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/ContractsReferences.cs b/contract/AElf.Contracts.Consensus.AEDPoS/ContractsReferences.cs index 48852984c8..19274e6b45 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/ContractsReferences.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/ContractsReferences.cs @@ -1,3 +1,4 @@ +using AElf.Contracts.Configuration; using AElf.Contracts.Election; using AElf.Contracts.MultiToken; using AElf.Contracts.Parliament; @@ -15,4 +16,5 @@ public partial class AEDPoSContractState internal TokenContractContainer.TokenContractReferenceState TokenContract { get; set; } internal TokenHolderContractContainer.TokenHolderContractReferenceState TokenHolderContract { get; set; } internal ParliamentContractContainer.ParliamentContractReferenceState ParliamentContract { get; set; } + internal ConfigurationContainer.ConfigurationReferenceState ConfigurationContract { get; set; } } \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.AEDPoS/Types/Round.cs b/contract/AElf.Contracts.Consensus.AEDPoS/Types/Round.cs index b062d408e9..ca45dec196 100644 --- a/contract/AElf.Contracts.Consensus.AEDPoS/Types/Round.cs +++ b/contract/AElf.Contracts.Consensus.AEDPoS/Types/Round.cs @@ -130,7 +130,7 @@ public MinerList GetMinerList() { return new MinerList { - Pubkeys = { RealTimeMinersInformation.Keys.Select(ByteStringHelper.FromHexString) } + Pubkeys = { RealTimeMinersInformation.Keys.Select(k => ByteStringHelper.FromHexString(k)) } }; } diff --git a/contract/AElf.Contracts.CrossChain/AElf.Contracts.CrossChain.csproj b/contract/AElf.Contracts.CrossChain/AElf.Contracts.CrossChain.csproj index e4a88d7962..285afe7876 100644 --- a/contract/AElf.Contracts.CrossChain/AElf.Contracts.CrossChain.csproj +++ b/contract/AElf.Contracts.CrossChain/AElf.Contracts.CrossChain.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 AElf.Contracts.CrossChain true CrossChain is a contract that implements cross-chain related features, especially diff --git a/contract/AElf.Contracts.Economic/AElf.Contracts.Economic.csproj b/contract/AElf.Contracts.Economic/AElf.Contracts.Economic.csproj index 0ec68211bf..2bb0f5fc48 100644 --- a/contract/AElf.Contracts.Economic/AElf.Contracts.Economic.csproj +++ b/contract/AElf.Contracts.Economic/AElf.Contracts.Economic.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Economic true Economic is a contract that implements the basic functionality used to manage the economic diff --git a/contract/AElf.Contracts.Election/AElf.Contracts.Election.csproj b/contract/AElf.Contracts.Election/AElf.Contracts.Election.csproj index 30187f8423..563a7d8083 100644 --- a/contract/AElf.Contracts.Election/AElf.Contracts.Election.csproj +++ b/contract/AElf.Contracts.Election/AElf.Contracts.Election.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Election true Election is a contract that implements voting. diff --git a/contract/AElf.Contracts.Election/ElectionContract_Maintainence.cs b/contract/AElf.Contracts.Election/ElectionContract_Maintainence.cs index 2ffc98c8e3..429db8c92f 100644 --- a/contract/AElf.Contracts.Election/ElectionContract_Maintainence.cs +++ b/contract/AElf.Contracts.Election/ElectionContract_Maintainence.cs @@ -33,7 +33,8 @@ public override Empty InitialElectionContract(InitialElectionContractInput input State.MinersCount.Value = input.MinerList.Count; State.InitialMiners.Value = new PubkeyList { - Value = { input.MinerList.Select(ByteStringHelper.FromHexString) } + // ReSharper disable once ConvertClosureToMethodGroup + Value = { input.MinerList.Select(m => ByteStringHelper.FromHexString(m)) } }; foreach (var pubkey in input.MinerList) State.CandidateInformationMap[pubkey] = new CandidateInformation diff --git a/contract/AElf.Contracts.Election/ViewMethods.cs b/contract/AElf.Contracts.Election/ViewMethods.cs index ef8735b3d5..00dd4d4e25 100644 --- a/contract/AElf.Contracts.Election/ViewMethods.cs +++ b/contract/AElf.Contracts.Election/ViewMethods.cs @@ -62,7 +62,7 @@ private List GetVictories(List currentMiners) if (diff > 0) { victories = - new List(validCandidates.Select(ByteStringHelper.FromHexString)); + new List(validCandidates.Select(v => ByteStringHelper.FromHexString(v))); var backups = currentMiners.Where(k => !validCandidates.Contains(k)).ToList(); if (State.InitialMiners.Value != null) backups.AddRange( @@ -70,7 +70,8 @@ private List GetVictories(List currentMiners) victories.AddRange(backups.OrderBy(p => p) .Take(Math.Min(diff, currentMiners.Count)) - .Select(ByteStringHelper.FromHexString)); + // ReSharper disable once ConvertClosureToMethodGroup + .Select(v => ByteStringHelper.FromHexString(v))); Context.LogDebug(() => string.Join("\n", victories.Select(v => v.ToHex().Substring(0, 10)).ToList())); return victories; } diff --git a/contract/AElf.Contracts.Genesis/AElf.Contracts.Genesis.csproj b/contract/AElf.Contracts.Genesis/AElf.Contracts.Genesis.csproj index 7310f1b799..91356b10eb 100644 --- a/contract/AElf.Contracts.Genesis/AElf.Contracts.Genesis.csproj +++ b/contract/AElf.Contracts.Genesis/AElf.Contracts.Genesis.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 AElf.Contracts.Genesis true Genesis is a contract that implements base functionality of the chain such as contract proposal diff --git a/contract/AElf.Contracts.MultiToken/AElf.Contracts.MultiToken.csproj b/contract/AElf.Contracts.MultiToken/AElf.Contracts.MultiToken.csproj index 44d6ef3422..bb668e4b2a 100644 --- a/contract/AElf.Contracts.MultiToken/AElf.Contracts.MultiToken.csproj +++ b/contract/AElf.Contracts.MultiToken/AElf.Contracts.MultiToken.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.MultiToken true MultiToken is a contract that implements token functionality like creation, issuance and diff --git a/contract/AElf.Contracts.MultiToken/TokenContract_ACS2_StatePathsProvider.cs b/contract/AElf.Contracts.MultiToken/TokenContract_ACS2_StatePathsProvider.cs index 8d013d3180..79f26a4f3b 100644 --- a/contract/AElf.Contracts.MultiToken/TokenContract_ACS2_StatePathsProvider.cs +++ b/contract/AElf.Contracts.MultiToken/TokenContract_ACS2_StatePathsProvider.cs @@ -118,7 +118,7 @@ private void AddPathForDelegatees(ResourceInfo resourceInfo, Address from, Addre if (delegateeList.Count <= 0) return; var secondDelegateeList = new List(); //get and add second-level delegatee list - foreach (var delegateeAddress in delegateeList.Select(Address.FromBase58)) + foreach (var delegateeAddress in delegateeList.Select(a => Address.FromBase58(a))) { //delegatee of the first-level delegate is delegator of the second-level delegate secondDelegateeList.AddRange(GetDelegateeList(delegateeAddress, to, methodName)); diff --git a/contract/AElf.Contracts.MultiToken/TokenContract_Delegation.cs b/contract/AElf.Contracts.MultiToken/TokenContract_Delegation.cs index 1ac302ccef..37bf3219fd 100644 --- a/contract/AElf.Contracts.MultiToken/TokenContract_Delegation.cs +++ b/contract/AElf.Contracts.MultiToken/TokenContract_Delegation.cs @@ -191,7 +191,7 @@ public override GetTransactionFeeDelegateesOutput GetTransactionFeeDelegatees( return new GetTransactionFeeDelegateesOutput { - DelegateeAddresses = { allDelegatees.Delegatees.Keys.Select(Address.FromBase58) } + DelegateeAddresses = { allDelegatees.Delegatees.Keys.Select(k => Address.FromBase58(k)) } }; } @@ -413,7 +413,7 @@ public override GetTransactionFeeDelegateeListOutput GetTransactionFeeDelegateeL return new GetTransactionFeeDelegateeListOutput { - DelegateeAddresses = { allDelegatees.Delegatees.Keys.Select(Address.FromBase58) } + DelegateeAddresses = { allDelegatees.Delegatees.Keys.Select(k => Address.FromBase58(k)) } }; } diff --git a/contract/AElf.Contracts.NFT/AElf.Contracts.NFT.csproj b/contract/AElf.Contracts.NFT/AElf.Contracts.NFT.csproj index 9b9bf5e782..dbf4344ac9 100644 --- a/contract/AElf.Contracts.NFT/AElf.Contracts.NFT.csproj +++ b/contract/AElf.Contracts.NFT/AElf.Contracts.NFT.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.NFT true NFT Contract is a contract that implements Non-Fungible-Token functionality like creation, issuance and diff --git a/contract/AElf.Contracts.Parliament/AElf.Contracts.Parliament.csproj b/contract/AElf.Contracts.Parliament/AElf.Contracts.Parliament.csproj index aa4fe7db45..6aafafffcc 100644 --- a/contract/AElf.Contracts.Parliament/AElf.Contracts.Parliament.csproj +++ b/contract/AElf.Contracts.Parliament/AElf.Contracts.Parliament.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Parliament true Parliament is a contract that enables the creation of organizations and approvals. The created diff --git a/contract/AElf.Contracts.Parliament/Parliament.cs b/contract/AElf.Contracts.Parliament/Parliament.cs index 98ae606896..7e52c07d2d 100644 --- a/contract/AElf.Contracts.Parliament/Parliament.cs +++ b/contract/AElf.Contracts.Parliament/Parliament.cs @@ -241,7 +241,9 @@ public override ProposalOutput GetProposal(Hash proposalId) ToBeReleased = Validate(proposal) && IsReleaseThresholdReached(proposal, organization), ApprovalCount = proposal.Approvals.Count, RejectionCount = proposal.Rejections.Count, - AbstentionCount = proposal.Abstentions.Count + AbstentionCount = proposal.Abstentions.Count, + Title = proposal.Title, + Description = proposal.Description }; } diff --git a/contract/AElf.Contracts.Parliament/ParliamentConstants.cs b/contract/AElf.Contracts.Parliament/ParliamentConstants.cs new file mode 100644 index 0000000000..a1646221e8 --- /dev/null +++ b/contract/AElf.Contracts.Parliament/ParliamentConstants.cs @@ -0,0 +1,8 @@ +namespace AElf.Contracts.Parliament; + +public static class ParliamentConstants +{ + public const int MaxLengthForTitle = 255; + public const int MaxLengthForDescription = 10200; + public const int MaxLengthForProposalDescriptionUrl = 255; +} \ No newline at end of file diff --git a/contract/AElf.Contracts.Parliament/Parliament_Helper.cs b/contract/AElf.Contracts.Parliament/Parliament_Helper.cs index 7e1a763d2b..b1317eceb2 100644 --- a/contract/AElf.Contracts.Parliament/Parliament_Helper.cs +++ b/contract/AElf.Contracts.Parliament/Parliament_Helper.cs @@ -224,6 +224,7 @@ private Hash GenerateProposalId(CreateProposalInput input) private Hash CreateNewProposal(CreateProposalInput input) { + CheckCreateProposalInput(input); var proposalId = GenerateProposalId(input); var proposal = new ProposalInfo { @@ -234,15 +235,33 @@ private Hash CreateNewProposal(CreateProposalInput input) OrganizationAddress = input.OrganizationAddress, ProposalId = proposalId, Proposer = Context.Sender, - ProposalDescriptionUrl = input.ProposalDescriptionUrl + ProposalDescriptionUrl = input.ProposalDescriptionUrl, + Title = input.Title, + Description = input.Description }; Assert(Validate(proposal), "Invalid proposal."); Assert(State.Proposals[proposalId] == null, "Proposal already exists."); State.Proposals[proposalId] = proposal; Context.Fire(new ProposalCreated - { ProposalId = proposalId, OrganizationAddress = input.OrganizationAddress }); + { + ProposalId = proposalId, + OrganizationAddress = input.OrganizationAddress, + Title = input.Title, + Description = input.Description + }); return proposalId; } + + private void CheckCreateProposalInput(CreateProposalInput input) + { + // Check the length of title + Assert(input.Title.Length <= ParliamentConstants.MaxLengthForTitle, "Title is too long."); + // Check the length of description + Assert(input.Description.Length <= ParliamentConstants.MaxLengthForDescription, "Description is too long."); + // Check the length of description url + Assert(input.ProposalDescriptionUrl.Length <= ParliamentConstants.MaxLengthForProposalDescriptionUrl, + "Description url is too long."); + } private Address CreateNewOrganization(CreateOrganizationInput input) { diff --git a/contract/AElf.Contracts.Profit/AElf.Contracts.Profit.csproj b/contract/AElf.Contracts.Profit/AElf.Contracts.Profit.csproj index 37a6090cc3..ed7f7096bd 100644 --- a/contract/AElf.Contracts.Profit/AElf.Contracts.Profit.csproj +++ b/contract/AElf.Contracts.Profit/AElf.Contracts.Profit.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Profit true Profit is a contract that enables the creation of schemes for profit distribution. diff --git a/contract/AElf.Contracts.Referendum/AElf.Contracts.Referendum.csproj b/contract/AElf.Contracts.Referendum/AElf.Contracts.Referendum.csproj index a59a11dedb..11725e3094 100644 --- a/contract/AElf.Contracts.Referendum/AElf.Contracts.Referendum.csproj +++ b/contract/AElf.Contracts.Referendum/AElf.Contracts.Referendum.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Referendum true Referendum is a contract that enables the creation of organizations and approvals. The created diff --git a/contract/AElf.Contracts.Referendum/Referendum.cs b/contract/AElf.Contracts.Referendum/Referendum.cs index f6112e2827..b2d63bf78f 100644 --- a/contract/AElf.Contracts.Referendum/Referendum.cs +++ b/contract/AElf.Contracts.Referendum/Referendum.cs @@ -202,7 +202,9 @@ public override ProposalOutput GetProposal(Hash proposalId) ToBeReleased = readyToRelease, ApprovalCount = proposal.ApprovalCount, RejectionCount = proposal.RejectionCount, - AbstentionCount = proposal.AbstentionCount + AbstentionCount = proposal.AbstentionCount, + Title = proposal.Title, + Description = proposal.Description }; } diff --git a/contract/AElf.Contracts.Referendum/ReferendumConstants.cs b/contract/AElf.Contracts.Referendum/ReferendumConstants.cs new file mode 100644 index 0000000000..89eded59d7 --- /dev/null +++ b/contract/AElf.Contracts.Referendum/ReferendumConstants.cs @@ -0,0 +1,8 @@ +namespace AElf.Contracts.Referendum; + +public static class ReferendumConstants +{ + public const int MaxLengthForTitle = 255; + public const int MaxLengthForDescription = 10200; + public const int MaxLengthForProposalDescriptionUrl = 255; +} \ No newline at end of file diff --git a/contract/AElf.Contracts.Referendum/Referendum_Helper.cs b/contract/AElf.Contracts.Referendum/Referendum_Helper.cs index 02b00d07c1..9b6e4343d9 100644 --- a/contract/AElf.Contracts.Referendum/Referendum_Helper.cs +++ b/contract/AElf.Contracts.Referendum/Referendum_Helper.cs @@ -158,6 +158,7 @@ private Hash GenerateProposalId(CreateProposalInput input) private Hash CreateNewProposal(CreateProposalInput input) { + CheckCreateProposalInput(input); var proposalId = GenerateProposalId(input); Assert(State.Proposals[proposalId] == null, "Proposal already exists."); var proposal = new ProposalInfo @@ -168,14 +169,33 @@ private Hash CreateNewProposal(CreateProposalInput input) Params = input.Params, OrganizationAddress = input.OrganizationAddress, Proposer = Context.Sender, - ProposalDescriptionUrl = input.ProposalDescriptionUrl + ProposalDescriptionUrl = input.ProposalDescriptionUrl, + Title = input.Title, + Description = input.Description }; Assert(Validate(proposal), "Invalid proposal."); State.Proposals[proposalId] = proposal; - Context.Fire(new ProposalCreated { ProposalId = proposalId, OrganizationAddress = input.OrganizationAddress }); + Context.Fire(new ProposalCreated + { + ProposalId = proposalId, + OrganizationAddress = input.OrganizationAddress, + Title = input.Title, + Description = input.Description + }); return proposalId; } + + private void CheckCreateProposalInput(CreateProposalInput input) + { + // Check the length of title + Assert(input.Title.Length <= ReferendumConstants.MaxLengthForTitle, "Title is too long."); + // Check the length of description + Assert(input.Description.Length <= ReferendumConstants.MaxLengthForDescription, "Description is too long."); + // Check the length of description url + Assert(input.ProposalDescriptionUrl.Length <= ReferendumConstants.MaxLengthForProposalDescriptionUrl, + "Description url is too long."); + } private void AssertIsAuthorizedProposer(Address organizationAddress, Address proposer) { diff --git a/contract/AElf.Contracts.TokenConverter/AElf.Contracts.TokenConverter.csproj b/contract/AElf.Contracts.TokenConverter/AElf.Contracts.TokenConverter.csproj index 073abc3ec4..1593aa77ec 100644 --- a/contract/AElf.Contracts.TokenConverter/AElf.Contracts.TokenConverter.csproj +++ b/contract/AElf.Contracts.TokenConverter/AElf.Contracts.TokenConverter.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 AElf.Contracts.TokenConverter true TokenConverter is a contract that enables buying and selling tokens based on connector diff --git a/contract/AElf.Contracts.TokenHolder/AElf.Contracts.TokenHolder.csproj b/contract/AElf.Contracts.TokenHolder/AElf.Contracts.TokenHolder.csproj index 1d8fbf296f..69a8e89213 100644 --- a/contract/AElf.Contracts.TokenHolder/AElf.Contracts.TokenHolder.csproj +++ b/contract/AElf.Contracts.TokenHolder/AElf.Contracts.TokenHolder.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 AElf.Contracts.TokenHolder true TokenHolder is a contract that assists dApp developers to manage profit schemes for token diff --git a/contract/AElf.Contracts.Treasury/AElf.Contracts.Treasury.csproj b/contract/AElf.Contracts.Treasury/AElf.Contracts.Treasury.csproj index e80a82b65b..47dff10f6b 100644 --- a/contract/AElf.Contracts.Treasury/AElf.Contracts.Treasury.csproj +++ b/contract/AElf.Contracts.Treasury/AElf.Contracts.Treasury.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Treasury true Treasury is a contract used to manage the finances of the system (dividend pool for diff --git a/contract/AElf.Contracts.Vote/AElf.Contracts.Vote.csproj b/contract/AElf.Contracts.Vote/AElf.Contracts.Vote.csproj index 4efe86b949..b199e31b19 100644 --- a/contract/AElf.Contracts.Vote/AElf.Contracts.Vote.csproj +++ b/contract/AElf.Contracts.Vote/AElf.Contracts.Vote.csproj @@ -2,7 +2,7 @@ - net6.0 + net8.0 AElf.Contracts.Vote true Vote is a contract used for voting. diff --git a/docs-sphinx/architecture/smart-contract/restrictions/project.md b/docs-sphinx/architecture/smart-contract/restrictions/project.md index a5a2fbe591..93236cb1b6 100644 --- a/docs-sphinx/architecture/smart-contract/restrictions/project.md +++ b/docs-sphinx/architecture/smart-contract/restrictions/project.md @@ -5,7 +5,7 @@ ```xml - net6.0 + net8.0 AElf.Contracts.MyContract true diff --git a/docs/contract/restrictions/project.md b/docs/contract/restrictions/project.md index 73bd5b3f59..92734ddb9d 100644 --- a/docs/contract/restrictions/project.md +++ b/docs/contract/restrictions/project.md @@ -5,7 +5,7 @@ ```xml - net6.0 + net8.0 AElf.Contracts.MyContract true true diff --git a/global.json b/global.json new file mode 100644 index 0000000000..1978c843c7 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "8.0.303" + } +} \ No newline at end of file diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000000..8b19203c51 --- /dev/null +++ b/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/protobuf/acs3.proto b/protobuf/acs3.proto index 65ee66e8ac..79b3391202 100644 --- a/protobuf/acs3.proto +++ b/protobuf/acs3.proto @@ -90,6 +90,10 @@ message CreateProposalInput { string proposal_description_url = 6; // The token is for proposal id generation and with this token, proposal id can be calculated before proposing. aelf.Hash token = 7; + // Title of this proposal. + string title = 8; + // Description of this proposal. + string description = 9; } message ProposalOutput { @@ -115,6 +119,10 @@ message ProposalOutput { int64 rejection_count = 10; // Abstention count for this proposal. int64 abstention_count = 11; + // Title of this proposal. + string title = 12; + // Description of this proposal. + string description = 13; } message ProposalReleaseThreshold { @@ -159,7 +167,11 @@ message ProposalCreated{ // The id of the created proposal. aelf.Hash proposal_id = 1; // The organization address of the created proposal. - aelf.Address organization_address=2 [(aelf.is_indexed) = true]; + aelf.Address organization_address = 2 [(aelf.is_indexed) = true]; + // Title of this proposal. + string title = 3; + // Description of this proposal. + string description = 4; } message ProposalReleased{ @@ -168,6 +180,10 @@ message ProposalReleased{ aelf.Hash proposal_id = 1; // The organization address of the released proposal. aelf.Address organization_address=2 [(aelf.is_indexed) = true]; + // Title of this proposal. + string title = 3; + // Description of this proposal. + string description = 4; } message OrganizationCreated{ diff --git a/protobuf/association_contract.proto b/protobuf/association_contract.proto index 2efb8210c6..5b2a78e2b7 100644 --- a/protobuf/association_contract.proto +++ b/protobuf/association_contract.proto @@ -96,6 +96,10 @@ message ProposalInfo { repeated aelf.Address abstentions = 10; // Url is used for proposal describing. string proposal_description_url = 11; + // Title of this proposal. + string title = 12; + // Description of this proposal. + string description = 13; } message OrganizationMemberList { diff --git a/protobuf/parliament_contract.proto b/protobuf/parliament_contract.proto index e5d2ef4422..8d0fca5bef 100644 --- a/protobuf/parliament_contract.proto +++ b/protobuf/parliament_contract.proto @@ -136,6 +136,10 @@ message ProposalInfo { repeated aelf.Address abstentions = 10; // Url is used for proposal describing. string proposal_description_url = 11; + // Title of this proposal. + string title = 12; + // Description of this proposal. + string description = 13; } message InitializeInput{ diff --git a/protobuf/referendum_contract.proto b/protobuf/referendum_contract.proto index 82af016f13..53bb243b6e 100644 --- a/protobuf/referendum_contract.proto +++ b/protobuf/referendum_contract.proto @@ -101,6 +101,10 @@ message ProposalInfo { int64 abstention_count = 10; // Url is used for proposal describing. string proposal_description_url = 11; + // Title of this proposal. + string title = 12; + // Description of this proposal. + string description = 13; } message CreateOrganizationBySystemContractInput { diff --git a/scripts/install_protobuf.sh b/scripts/install_protobuf.sh index 941fd8e0dd..e29e5b5427 100644 --- a/scripts/install_protobuf.sh +++ b/scripts/install_protobuf.sh @@ -13,18 +13,18 @@ fi echo "Install protobuf on ${osn}" if [[ ${osn} == "macosx" ]]; then - curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-osx-x86_64.zip - unzip protoc-3.11.4-osx-x86_64.zip -d protoc3 + curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-osx-x86_64.zip + unzip protoc-3.19.4-osx-x86_64.zip -d protoc3 sudo mv protoc3/bin/* /usr/local/bin/ sudo mv protoc3/include/* /usr/local/include sudo chown ${USER} /usr/local/bin/protoc sudo chown -R ${USER} /usr/local/include/google elif [[ ${osn} == "linux" ]]; then # Make sure you grab the latest version - curl -OL https://github.com/google/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip + curl -OL https://github.com/google/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip # Unzip - unzip protoc-3.11.4-linux-x86_64.zip -d protoc3 + unzip protoc-3.19.4-linux-x86_64.zip -d protoc3 # Move protoc to /usr/local/bin/ sudo mv protoc3/bin/* /usr/local/bin/ diff --git a/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj b/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj index e32d4beb7d..0171e4a76b 100644 --- a/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj +++ b/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj @@ -1,29 +1,29 @@ - - + + - net6.0 + net8.0 AElf.Blockchains.BasicBaseChain true Base AElf Module for different chain types. - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs index 844998a236..d056ecd523 100644 --- a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs +++ b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs @@ -25,11 +25,13 @@ public virtual IEnumerable GetGenesisSmartContractDtos( { var contractCodes = GetContractCodes(); var deploymentList = ContractDeploymentListProvider.GetDeployContractNameList(); - return ContractInitializationProviders - .Where(p => deploymentList.Contains(p.SystemSmartContractName)) - .OrderBy(p => deploymentList.IndexOf(p.SystemSmartContractName)) - .Select(p => + return ContractInitializationProviders + .GroupBy(p => p.SystemSmartContractName) + .Where(g => deploymentList.Contains(g.Key)) + .OrderBy(g => deploymentList.IndexOf(g.Key)) + .Select(g => { + var p = g.Last(); var code = contractCodes[p.ContractCodeName]; var methodList = p.GetInitializeMethodList(code); var genesisSmartContractDto = new GenesisSmartContractDto diff --git a/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj b/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj index 4765c5a414..c99ca2bf21 100644 --- a/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj +++ b/src/AElf.Blockchains.MainChain/AElf.Blockchains.MainChain.csproj @@ -1,15 +1,15 @@  - net6.0 + net8.0 0436 Main module for a mainchain node. - - - + + + diff --git a/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs b/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs index 78826cdd23..460f4759f2 100644 --- a/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs +++ b/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; +using System.Linq; using AElf.Blockchains.BasicBaseChain; using AElf.ContractDeployer; +using AElf.Kernel.Plugin.Application; using AElf.Kernel.SmartContract; using AElf.Kernel.SmartContract.Application; using Microsoft.Extensions.Options; @@ -12,19 +14,23 @@ namespace AElf.Blockchains.MainChain; /// public class MainChainGenesisSmartContractDtoProvider : GenesisSmartContractDtoProviderBase { + private readonly IEnumerable _pluginContractProviders; private readonly ContractOptions _contractOptions; public MainChainGenesisSmartContractDtoProvider(IContractDeploymentListProvider contractDeploymentListProvider, IEnumerable contractInitializationProviders, + IEnumerable pluginContractProviders, IOptionsSnapshot contractOptions) : base(contractDeploymentListProvider, contractInitializationProviders) { + _pluginContractProviders = pluginContractProviders; _contractOptions = contractOptions.Value; } protected override IReadOnlyDictionary GetContractCodes() { - return ContractsDeployer.GetContractCodes(_contractOptions - .GenesisContractDir); + return ContractsDeployer.GetContractCodes( + _contractOptions.GenesisContractDir, + pluginContractNames: _pluginContractProviders.Select(p => p.GetContractName()).ToList()); } } \ No newline at end of file diff --git a/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj b/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj index f32797732a..9364aac96b 100644 --- a/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj +++ b/src/AElf.Blockchains.SideChain/AElf.Blockchains.SideChain.csproj @@ -1,15 +1,15 @@  - net6.0 + net8.0 Main module for a sidechain node. 1701;1702 - - + + @@ -105,6 +105,6 @@ - + diff --git a/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj b/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj index 89c51e7004..dc5501294c 100644 --- a/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj +++ b/src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj @@ -1,15 +1,17 @@ - + - net6.0 + net8.0 true Smart contract code operations like auditing, patching and validating. - + + + diff --git a/src/AElf.CSharp.CodeOps/CSharpContractAuditor.cs b/src/AElf.CSharp.CodeOps/CSharpContractAuditor.cs index 58c015f563..b7999fb6d1 100644 --- a/src/AElf.CSharp.CodeOps/CSharpContractAuditor.cs +++ b/src/AElf.CSharp.CodeOps/CSharpContractAuditor.cs @@ -1,8 +1,10 @@ +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Threading; +using System.Threading.Tasks; using AElf.CSharp.CodeOps.Policies; using AElf.CSharp.CodeOps.Validators; using AElf.CSharp.CodeOps.Validators.Assembly; @@ -11,77 +13,112 @@ using Microsoft.Extensions.Options; using Mono.Cecil; - -namespace AElf.CSharp.CodeOps; - -public class CSharpContractAuditor : IContractAuditor +namespace AElf.CSharp.CodeOps { - private readonly IAcsValidator _acsValidator; - - public int Category { get; } = 0; - - public IOptionsMonitor CodeOpsOptionsMonitor { get; set; } - - private readonly IPolicy _policy; - - public CSharpContractAuditor(IPolicy policy, IAcsValidator acsValidator) + public class CSharpContractAuditor : IContractAuditor { - _policy = policy; - _acsValidator = acsValidator; - } + private readonly IAcsValidator _acsValidator; + private readonly IPolicy _policy; - public void Audit(byte[] code, RequiredAcs requiredAcs, bool isSystemContract) - { - var findings = new List(); - var asm = Assembly.Load(code); - var modDef = ModuleDefinition.ReadModule(new MemoryStream(code)); - var cts = new CancellationTokenSource(CodeOpsOptionsMonitor?.CurrentValue.AuditTimeoutDuration ?? - Constants.DefaultAuditTimeoutDuration); - // Run module validators - findings.AddRange(Validate(modDef, cts.Token, isSystemContract)); - - // Run assembly validators (run after module validators since we invoke BindService method below) - findings.AddRange(Validate(asm, cts.Token, isSystemContract)); - - // Run method validators - foreach (var type in modDef.Types) + public int Category { get; } = 0; + public IOptionsMonitor CodeOpsOptionsMonitor { get; set; } + + public CSharpContractAuditor(IPolicy policy, IAcsValidator acsValidator) { - findings.AddRange(ValidateMethodsInType(type, cts.Token, isSystemContract)); + _policy = policy; + _acsValidator = acsValidator; } - // Perform ACS validation - if (requiredAcs != null) - findings.AddRange(_acsValidator.Validate(asm, requiredAcs)); - - if (findings.Count > 0) + public void Audit(byte[] code, RequiredAcs requiredAcs, bool isSystemContract) { - throw new CSharpCodeCheckException( - $"Contract code did not pass audit. Audit failed for contract: {modDef.Assembly.MainModule.Name}\n" + - string.Join("\n", findings), findings); + var findings = new ConcurrentBag(); + var asm = Assembly.Load(code); + var modDef = ModuleDefinition.ReadModule(new MemoryStream(code)); + var cts = new CancellationTokenSource(CodeOpsOptionsMonitor?.CurrentValue.AuditTimeoutDuration ?? + Constants.DefaultAuditTimeoutDuration); + + // Run module validators + var moduleFindings = Validate(modDef, cts.Token, isSystemContract); + foreach (var finding in moduleFindings) + { + findings.Add(finding); + } + + // Run assembly validators + var assemblyFindings = Validate(asm, cts.Token, isSystemContract); + foreach (var finding in assemblyFindings) + { + findings.Add(finding); + } + + // Run method validators + foreach (var type in modDef.Types) + { + var methodFindings = ValidateMethodsInType(type, cts.Token, isSystemContract); + foreach (var finding in methodFindings) + { + findings.Add(finding); + } + } + + + // Perform ACS validation + if (requiredAcs != null) + { + var acsFindings = _acsValidator.Validate(asm, requiredAcs); + foreach (var finding in acsFindings) + { + findings.Add(finding); + } + } + + if (findings.Count > 0) + { + throw new CSharpCodeCheckException( + $"Contract code did not pass audit. Audit failed for contract: {modDef.Assembly.MainModule.Name}\n" + + string.Join("\n", findings), findings.ToList()); + } } - } - - private IEnumerable Validate(T t, CancellationToken ct, bool isSystemContract) - { - var validators = _policy.GetValidators().Where(v => !v.SystemContactIgnored || !isSystemContract); - return validators.SelectMany(v => v.Validate(t, ct)); - } - - private IEnumerable ValidateMethodsInType(TypeDefinition type, - CancellationToken ct, bool isSystemContract) - { - var findings = new List(); - foreach (var method in type.Methods) + private IEnumerable Validate(T t, CancellationToken ct, bool isSystemContract) { - findings.AddRange(Validate(method, ct, isSystemContract)); + var validators = _policy.GetValidators().AsParallel() + .Where(v => !v.SystemContactIgnored || !isSystemContract); + + var results = new ConcurrentBag(); + foreach (var v in validators) + { + foreach (var result in v.Validate(t, ct)) + { + results.Add(result); + } + } + + return results; } - foreach (var nestedType in type.NestedTypes) + private IEnumerable ValidateMethodsInType(TypeDefinition type, + CancellationToken ct, bool isSystemContract) { - findings.AddRange(ValidateMethodsInType(nestedType, ct, isSystemContract)); + var findings = new ConcurrentBag(); + + Parallel.ForEach(type.Methods, method => + { + foreach (var finding in Validate(method, ct, isSystemContract)) + { + findings.Add(finding); + } + }); + + Parallel.ForEach(type.NestedTypes, nestedType => + { + foreach (var finding in ValidateMethodsInType(nestedType, ct, isSystemContract)) + { + findings.Add(finding); + } + }); + + return findings; } - - return findings; } -} \ No newline at end of file +} diff --git a/src/AElf.CSharp.CodeOps/Patchers/Module/ResetFieldsMethodInjector.cs b/src/AElf.CSharp.CodeOps/Patchers/Module/ResetFieldsMethodInjector.cs index f17c0930cb..9e6d4f60a8 100644 --- a/src/AElf.CSharp.CodeOps/Patchers/Module/ResetFieldsMethodInjector.cs +++ b/src/AElf.CSharp.CodeOps/Patchers/Module/ResetFieldsMethodInjector.cs @@ -188,7 +188,7 @@ public partial class ResetFieldsMethodInjector static ResetFieldsMethodInjector() { - var systemRuntime = Basic.Reference.Assemblies.Net60.Resources.SystemRuntime; + var systemRuntime = Basic.Reference.Assemblies.Net80.Resources.SystemRuntime; using var stream = new MemoryStream(systemRuntime); diff --git a/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs b/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs index 7c9f30c65d..4f3ec683be 100644 --- a/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs +++ b/src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs @@ -11,6 +11,7 @@ using AElf.Types; using Volo.Abp.DependencyInjection; + namespace AElf.CSharp.CodeOps.Validators.Whitelist; public interface IWhitelistProvider diff --git a/src/AElf.CSharp.Core/AElf.CSharp.Core.csproj b/src/AElf.CSharp.Core/AElf.CSharp.Core.csproj index 4fa8489d88..77199b6659 100644 --- a/src/AElf.CSharp.Core/AElf.CSharp.Core.csproj +++ b/src/AElf.CSharp.Core/AElf.CSharp.Core.csproj @@ -1,15 +1,15 @@ - - + + - net6.0 + net8.0 AElf.CSharp.Core true Base definitions for C# smart contracts. - + - + \ No newline at end of file diff --git a/src/AElf.Cluster/AElf.Cluster.csproj b/src/AElf.Cluster/AElf.Cluster.csproj index 28d99c4579..53bcaa6eb2 100644 --- a/src/AElf.Cluster/AElf.Cluster.csproj +++ b/src/AElf.Cluster/AElf.Cluster.csproj @@ -1,18 +1,18 @@  - net6.0 + net8.0 - + - - - + + + diff --git a/src/AElf.ContractDeployer/AElf.ContractDeployer.csproj b/src/AElf.ContractDeployer/AElf.ContractDeployer.csproj index 0d99f17fc2..8f34424e0a 100644 --- a/src/AElf.ContractDeployer/AElf.ContractDeployer.csproj +++ b/src/AElf.ContractDeployer/AElf.ContractDeployer.csproj @@ -1,10 +1,10 @@ - - + + AElf.ContractDeployer true - net6.0 + net8.0 Exe Smart contract deployer. AElf.ContractDeployer @@ -13,22 +13,22 @@ TRACE;UNIT_TEST - + - - - + + + - + - + - - + + diff --git a/src/AElf.ContractDeployer/ContractsDeployer.cs b/src/AElf.ContractDeployer/ContractsDeployer.cs index 6c2aec9dd0..a79e0e5121 100644 --- a/src/AElf.ContractDeployer/ContractsDeployer.cs +++ b/src/AElf.ContractDeployer/ContractsDeployer.cs @@ -8,9 +8,14 @@ namespace AElf.ContractDeployer; public static class ContractsDeployer { public static IReadOnlyDictionary GetContractCodes(string contractDir = null, - bool isPatched = false) + bool isPatched = false, List pluginContractNames = null) { var contractNames = GetContractNames(typeof(T).Assembly).ToList(); + if (pluginContractNames is { Count: > 0 }) + { + contractNames.AddRange(pluginContractNames); + } + if (contractNames.Count == 0) throw new NoContractDllFoundInManifestException(); return contractNames.Select(n => (n, GetCode(n, contractDir, isPatched))) diff --git a/src/AElf.ContractDeployer/Program.cs b/src/AElf.ContractDeployer/Program.cs index f9230328a2..2f39589da5 100644 --- a/src/AElf.ContractDeployer/Program.cs +++ b/src/AElf.ContractDeployer/Program.cs @@ -43,7 +43,7 @@ private static void Run(Options o) saveAsPath = o.ContractDllPath + ".patched"; Console.WriteLine($"[CONTRACT-PATCHER] Saving as {saveAsPath}"); } - + using var application = AbpApplicationFactory.Create(); application.Initialize(); var contractPatcher = application.ServiceProvider.GetRequiredService(); @@ -61,6 +61,10 @@ private static void Run(Options o) // Print error in parsable format so that it can be shown in IDE Console.WriteLine($"error: {finding}"); } + catch (Exception e) + { + Console.WriteLine("Audit exception: ",e); + } File.WriteAllBytes(saveAsPath, patchedCode); } diff --git a/src/AElf.ContractTestBase/AElf.ContractTestBase.csproj b/src/AElf.ContractTestBase/AElf.ContractTestBase.csproj index cb38e8bf85..6fe993cbeb 100644 --- a/src/AElf.ContractTestBase/AElf.ContractTestBase.csproj +++ b/src/AElf.ContractTestBase/AElf.ContractTestBase.csproj @@ -1,23 +1,23 @@ - - + + - net6.0 + net8.0 AElf.ContractTestBase true Contract test base. - - - - - - - - - - + + + + + + + + + + false Contract @@ -56,10 +56,10 @@ - - - - - + + + + + diff --git a/src/AElf.ContractTestKit.AEDPoSExtension/AEDPoSExtensionTestBase.cs b/src/AElf.ContractTestKit.AEDPoSExtension/AEDPoSExtensionTestBase.cs index 23b387d996..0f123194e4 100644 --- a/src/AElf.ContractTestKit.AEDPoSExtension/AEDPoSExtensionTestBase.cs +++ b/src/AElf.ContractTestKit.AEDPoSExtension/AEDPoSExtensionTestBase.cs @@ -4,6 +4,7 @@ using AElf.EconomicSystem; using AElf.GovernmentSystem; using AElf.Kernel.Blockchain.Application; +using AElf.Kernel.Configuration; using AElf.Kernel.Consensus; using AElf.Kernel.Proposal; using AElf.Kernel.Token; @@ -30,7 +31,8 @@ public class AEDPoSExtensionTestBase : ContractTestBase ContractAddresses; diff --git a/src/AElf.ContractTestKit.AEDPoSExtension/AElf.ContractTestKit.AEDPoSExtension.csproj b/src/AElf.ContractTestKit.AEDPoSExtension/AElf.ContractTestKit.AEDPoSExtension.csproj index 8230cdb5e4..4fceae4d77 100644 --- a/src/AElf.ContractTestKit.AEDPoSExtension/AElf.ContractTestKit.AEDPoSExtension.csproj +++ b/src/AElf.ContractTestKit.AEDPoSExtension/AElf.ContractTestKit.AEDPoSExtension.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.ContractTestKit.AEDPoSExtension true Contract testing kit using AEDPoS Consensus. diff --git a/src/AElf.ContractTestKit.AEDPoSExtension/UnitTestPlainTransactionExecutingService.cs b/src/AElf.ContractTestKit.AEDPoSExtension/UnitTestPlainTransactionExecutingService.cs index ca7ce8e3f6..37f1b50c43 100644 --- a/src/AElf.ContractTestKit.AEDPoSExtension/UnitTestPlainTransactionExecutingService.cs +++ b/src/AElf.ContractTestKit.AEDPoSExtension/UnitTestPlainTransactionExecutingService.cs @@ -2,6 +2,7 @@ using System.Threading; using System.Threading.Tasks; using AElf.Kernel; +using AElf.Kernel.FeatureDisable.Core; using AElf.Kernel.SmartContract; using AElf.Kernel.SmartContract.Application; using AElf.Kernel.SmartContractExecution.Events; @@ -12,8 +13,8 @@ public class UnitTestPlainTransactionExecutingService : PlainTransactionExecutin { public UnitTestPlainTransactionExecutingService(ISmartContractExecutiveService smartContractExecutiveService, IEnumerable postPlugins, IEnumerable prePlugins, - ITransactionContextFactory transactionContextFactory) : base( - smartContractExecutiveService, postPlugins, prePlugins, transactionContextFactory) + ITransactionContextFactory transactionContextFactory, IFeatureDisableService featureDisableService) : base( + smartContractExecutiveService, postPlugins, prePlugins, transactionContextFactory, featureDisableService) { } diff --git a/src/AElf.ContractTestKit/AElf.ContractTestKit.csproj b/src/AElf.ContractTestKit/AElf.ContractTestKit.csproj index 928732975c..c694129b0d 100644 --- a/src/AElf.ContractTestKit/AElf.ContractTestKit.csproj +++ b/src/AElf.ContractTestKit/AElf.ContractTestKit.csproj @@ -1,7 +1,7 @@ - - + + - net6.0 + net8.0 AElf.ContractTestKit true Contract testing kit. @@ -13,15 +13,15 @@ - - - - - - - - - + + + + + + + + + @@ -49,10 +49,10 @@ - - - - - + + + + + \ No newline at end of file diff --git a/src/AElf.Core/AElf.Core.csproj b/src/AElf.Core/AElf.Core.csproj index 01ffb3ff04..ffab63014d 100644 --- a/src/AElf.Core/AElf.Core.csproj +++ b/src/AElf.Core/AElf.Core.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf AElf.Core true @@ -10,10 +10,10 @@ - - - - + + + + diff --git a/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj b/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj index 310eb85cdb..9c1e1e9711 100644 --- a/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj +++ b/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj @@ -1,7 +1,7 @@ - - + + - net6.0 + net8.0 AElf.CrossChain.Core true AElf.CrossChain @@ -13,8 +13,8 @@ - - + + diff --git a/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj b/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj index 2c679e0a27..8b6b48b8de 100644 --- a/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj +++ b/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 AElf.CrossChain.Grpc true Grpc implementation of cross-chain communication functionality. diff --git a/src/AElf.CrossChain/AElf.CrossChain.csproj b/src/AElf.CrossChain/AElf.CrossChain.csproj index 05c4170990..e7f854420b 100644 --- a/src/AElf.CrossChain/AElf.CrossChain.csproj +++ b/src/AElf.CrossChain/AElf.CrossChain.csproj @@ -1,14 +1,14 @@ - + - net6.0 + net8.0 AElf.CrossChain true Main functionality for crosschain operations. - + diff --git a/src/AElf.Cryptography/AElf.Cryptography.csproj b/src/AElf.Cryptography/AElf.Cryptography.csproj index 91995f617e..1f5c07064d 100644 --- a/src/AElf.Cryptography/AElf.Cryptography.csproj +++ b/src/AElf.Cryptography/AElf.Cryptography.csproj @@ -1,7 +1,7 @@ - + - netstandard2.1;net6.0 + netstandard2.1;net8.0 AElf.Cryptography true Cryptographic primitives used in AElf. @@ -10,7 +10,6 @@ - diff --git a/src/AElf.Cryptography/CryptoHelper.cs b/src/AElf.Cryptography/CryptoHelper.cs index 56a1c1b73c..ea44d70a9a 100644 --- a/src/AElf.Cryptography/CryptoHelper.cs +++ b/src/AElf.Cryptography/CryptoHelper.cs @@ -6,8 +6,15 @@ using AElf.Cryptography.ECDSA; using AElf.Cryptography.ECVRF; using AElf.Cryptography.Exceptions; +using Org.BouncyCastle.Crypto.Digests; +using Org.BouncyCastle.Crypto.Engines; +using Org.BouncyCastle.Crypto.Generators; +using Org.BouncyCastle.Crypto.Modes; +using Org.BouncyCastle.Crypto.Paddings; +using Org.BouncyCastle.Crypto.Parameters; +using Org.BouncyCastle.Math; +using Org.BouncyCastle.Security; using Secp256k1Net; -using Virgil.Crypto; using ECParameters = AElf.Cryptography.ECDSA.ECParameters; namespace AElf.Cryptography @@ -17,8 +24,7 @@ public static class CryptoHelper { private static readonly Secp256k1 Secp256K1 = new Secp256k1(); - // ReaderWriterLock for thread-safe with Secp256k1 APIs - private static readonly ReaderWriterLock Lock = new ReaderWriterLock(); + private static readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim(); private static readonly Vrf Vrf = new Vrf(new VrfConfig(0xfe, ECParameters.Curve)); @@ -36,7 +42,7 @@ public static ECKeyPair FromPrivateKey(byte[] privateKey) try { - Lock.AcquireWriterLock(Timeout.Infinite); + Lock.EnterWriteLock(); var secp256K1PubKey = new byte[64]; if (!Secp256K1.PublicKeyCreate(secp256K1PubKey, privateKey)) @@ -48,7 +54,7 @@ public static ECKeyPair FromPrivateKey(byte[] privateKey) } finally { - Lock.ReleaseWriterLock(); + Lock.ExitWriteLock(); } } @@ -56,7 +62,7 @@ public static ECKeyPair GenerateKeyPair() { try { - Lock.AcquireWriterLock(Timeout.Infinite); + Lock.EnterWriteLock(); var privateKey = new byte[32]; var secp256K1PubKey = new byte[64]; @@ -76,7 +82,7 @@ public static ECKeyPair GenerateKeyPair() } finally { - Lock.ReleaseWriterLock(); + Lock.ExitWriteLock(); } } @@ -84,7 +90,7 @@ public static byte[] SignWithPrivateKey(byte[] privateKey, byte[] hash) { try { - Lock.AcquireWriterLock(Timeout.Infinite); + Lock.EnterWriteLock(); var recSig = new byte[65]; var compactSig = new byte[65]; if (!Secp256K1.SignRecoverable(recSig, hash, privateKey)) @@ -96,7 +102,7 @@ public static byte[] SignWithPrivateKey(byte[] privateKey, byte[] hash) } finally { - Lock.ReleaseWriterLock(); + Lock.ExitWriteLock(); } } @@ -111,7 +117,7 @@ public static bool RecoverPublicKey(byte[] signature, byte[] hash, out byte[] pu pubkey = null; try { - Lock.AcquireWriterLock(Timeout.Infinite); + Lock.EnterWriteLock(); // Recover id should be greater than or equal to 0 and less than 4 if (signature.Length != Secp256k1.SERIALIZED_UNCOMPRESSED_PUBKEY_LENGTH || signature.Last() >= 4) return false; @@ -129,55 +135,72 @@ public static bool RecoverPublicKey(byte[] signature, byte[] hash, out byte[] pu } finally { - Lock.ReleaseWriterLock(); + Lock.ExitWriteLock(); } } public static byte[] EncryptMessage(byte[] senderPrivateKey, byte[] receiverPublicKey, byte[] plainText) { - var crypto = new VirgilCrypto(KeyPairType.EC_SECP256K1); - var ecdhKey = Ecdh(senderPrivateKey, receiverPublicKey); - var newKeyPair = crypto.GenerateKeys(KeyPairType.EC_SECP256K1, ecdhKey); - return crypto.Encrypt(plainText, newKeyPair.PublicKey); + var keyBytes = GetSharedSecret(senderPrivateKey, receiverPublicKey); + + var cipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(new AesEngine())); + cipher.Init(true, new ParametersWithIV(new KeyParameter(keyBytes), new byte[16])); + + var cipherText = new byte[cipher.GetOutputSize(plainText.Length)]; + var len = cipher.ProcessBytes(plainText, 0, plainText.Length, cipherText, 0); + cipher.DoFinal(cipherText, len); + + return cipherText; } public static byte[] DecryptMessage(byte[] senderPublicKey, byte[] receiverPrivateKey, byte[] cipherText) { - var crypto = new VirgilCrypto(KeyPairType.EC_SECP256K1); - var ecdhKey = Ecdh(receiverPrivateKey, senderPublicKey); - var newKeyPair = crypto.GenerateKeys(KeyPairType.EC_SECP256K1, ecdhKey); - return crypto.Decrypt(cipherText, newKeyPair.PrivateKey); + var keyBytes = GetSharedSecret(receiverPrivateKey, senderPublicKey); + + var cipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(new AesEngine())); + cipher.Init(false, new ParametersWithIV(new KeyParameter(keyBytes), new byte[16])); + + var temp = new byte[cipher.GetOutputSize(cipherText.Length)]; + var len = cipher.ProcessBytes(cipherText, 0, cipherText.Length, temp, 0); + len += cipher.DoFinal(temp, len); + + // Remove padding + var plainText = new byte[len]; + Array.Copy(temp, 0, plainText, 0, len); + + return plainText; } - public static byte[] Ecdh(byte[] privateKey, byte[] publicKey) + private static byte[] GetSharedSecret(byte[] privateKey, byte[] publicKey) { - try - { - Lock.AcquireWriterLock(Timeout.Infinite); - var usablePublicKey = new byte[Secp256k1.SERIALIZED_UNCOMPRESSED_PUBKEY_LENGTH]; - if (!Secp256K1.PublicKeyParse(usablePublicKey, publicKey)) - throw new PublicKeyOperationException("Parse public key failed."); - var ecdhKey = new byte[Secp256k1.SERIALIZED_COMPRESSED_PUBKEY_LENGTH]; - if (!Secp256K1.Ecdh(ecdhKey, usablePublicKey, privateKey)) - throw new EcdhOperationException("Compute EC Diffie- secret failed."); - return ecdhKey; - } - finally - { - Lock.ReleaseWriterLock(); - } + var curve = ECParameters.Curve; + var domainParams = ECParameters.DomainParams; + var privateKeyParams = new ECPrivateKeyParameters(new BigInteger(1, privateKey), domainParams); + var publicKeyParams = new ECPublicKeyParameters(curve.Curve.DecodePoint(publicKey), domainParams); + + var agreement = AgreementUtilities.GetBasicAgreement("ECDH"); + agreement.Init(privateKeyParams); + var secret = agreement.CalculateAgreement(publicKeyParams); + + var kdf = new Kdf2BytesGenerator(new Sha256Digest()); + kdf.Init(new KdfParameters(secret.ToByteArray(), null)); + + var keyBytes = new byte[32]; + kdf.GenerateBytes(keyBytes, 0, keyBytes.Length); + + return keyBytes; } public static byte[] ECVrfProve(ECKeyPair keyPair, byte[] alpha) { try { - Lock.AcquireWriterLock(Timeout.Infinite); + Lock.EnterWriteLock(); return Vrf.Prove(keyPair, alpha); } finally { - Lock.ReleaseWriterLock(); + Lock.ExitWriteLock(); } } @@ -185,12 +208,12 @@ public static byte[] ECVrfVerify(byte[] publicKey, byte[] alpha, byte[] pi) { try { - Lock.AcquireWriterLock(Timeout.Infinite); + Lock.EnterWriteLock(); return Vrf.Verify(publicKey, alpha, pi); } finally { - Lock.ReleaseWriterLock(); + Lock.ExitWriteLock(); } } } diff --git a/src/AElf.Database/AElf.Database.csproj b/src/AElf.Database/AElf.Database.csproj index bce730bb49..b404d7ac4c 100644 --- a/src/AElf.Database/AElf.Database.csproj +++ b/src/AElf.Database/AElf.Database.csproj @@ -1,15 +1,15 @@ - - + + - net6.0 + net8.0 AElf.Database true Types and definitions of the data access layer. - + - + \ No newline at end of file diff --git a/src/AElf.EconomicSystem/AElf.EconomicSystem.csproj b/src/AElf.EconomicSystem/AElf.EconomicSystem.csproj index 2ddb7d08d9..70fc3b1dbb 100644 --- a/src/AElf.EconomicSystem/AElf.EconomicSystem.csproj +++ b/src/AElf.EconomicSystem/AElf.EconomicSystem.csproj @@ -1,16 +1,16 @@ - - + + - net6.0 + net8.0 AElf.EconomicSystem true Projects for AElf Economic System contracts releated stuff. - - - + + + diff --git a/src/AElf.GovernmentSystem/AElf.GovernmentSystem.csproj b/src/AElf.GovernmentSystem/AElf.GovernmentSystem.csproj index 4122562536..18435fde09 100644 --- a/src/AElf.GovernmentSystem/AElf.GovernmentSystem.csproj +++ b/src/AElf.GovernmentSystem/AElf.GovernmentSystem.csproj @@ -1,17 +1,17 @@ - - + + - net6.0 + net8.0 AElf.GovernmentSystem true Projects for AElf Government System contracts releated stuff. - - - - + + + + diff --git a/src/AElf.Kernel.ChainController/AElf.Kernel.ChainController.csproj b/src/AElf.Kernel.ChainController/AElf.Kernel.ChainController.csproj index 812b5b0050..a1df9b57b3 100644 --- a/src/AElf.Kernel.ChainController/AElf.Kernel.ChainController.csproj +++ b/src/AElf.Kernel.ChainController/AElf.Kernel.ChainController.csproj @@ -1,12 +1,12 @@ - - + + - net6.0 + net8.0 AElf.Kernel.ChainController true Module that contains chain creation functionality. - + \ No newline at end of file diff --git a/src/AElf.Kernel.CodeCheck/AElf.Kernel.CodeCheck.csproj b/src/AElf.Kernel.CodeCheck/AElf.Kernel.CodeCheck.csproj index 211cd26f0a..a8e9025c77 100644 --- a/src/AElf.Kernel.CodeCheck/AElf.Kernel.CodeCheck.csproj +++ b/src/AElf.Kernel.CodeCheck/AElf.Kernel.CodeCheck.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 latest AElf.Kernel.CodeCheck true diff --git a/src/AElf.Kernel.CodeCheck/Application/CodeCheckProposalService.cs b/src/AElf.Kernel.CodeCheck/Application/CodeCheckProposalService.cs index 7fe9ebc680..4fc0828431 100644 --- a/src/AElf.Kernel.CodeCheck/Application/CodeCheckProposalService.cs +++ b/src/AElf.Kernel.CodeCheck/Application/CodeCheckProposalService.cs @@ -37,7 +37,7 @@ public void AddReleasableProposal(Hash proposalId, Hash proposalInputHash, long public async Task> GetReleasableProposalListAsync(Address from, Hash blockHash, long blockHeight) { - var allOpenProposals = _codeCheckProposalProvider.GetAllProposals(); + var allOpenProposals = _codeCheckProposalProvider.GetAllProposals().ToList(); if (allOpenProposals.Count == 0) return null; var releaseThresholdReachedProposals = await _contractReaderFactory.Create(new ContractReaderContext diff --git a/src/AElf.Kernel.CodeCheck/ContractCodeHashMap.cs b/src/AElf.Kernel.CodeCheck/ContractCodeHashMap.cs index 329f6cca7e..1dcc588c7c 100644 --- a/src/AElf.Kernel.CodeCheck/ContractCodeHashMap.cs +++ b/src/AElf.Kernel.CodeCheck/ContractCodeHashMap.cs @@ -6,11 +6,9 @@ internal partial class ContractCodeHashMap { public void TryAdd(long blockHeight, Hash codeHash) { - if (Value.ContainsKey(blockHeight)) + if (Value.TryGetValue(blockHeight, out var hashList)) { - var hashList = Value[blockHeight]; hashList.Value.Add(codeHash); - Value[blockHeight] = hashList; } else { diff --git a/src/AElf.Kernel.CodeCheck/Infrastructure/CodeCheckProposalProvider.cs b/src/AElf.Kernel.CodeCheck/Infrastructure/CodeCheckProposalProvider.cs index 864039c4ec..c2849fefb3 100644 --- a/src/AElf.Kernel.CodeCheck/Infrastructure/CodeCheckProposalProvider.cs +++ b/src/AElf.Kernel.CodeCheck/Infrastructure/CodeCheckProposalProvider.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Collections.Generic; -using System.Linq; using AElf.Kernel.CodeCheck.Application; namespace AElf.Kernel.CodeCheck.Infrastructure; @@ -11,25 +10,20 @@ public class CodeCheckProposalProvider : ICodeCheckProposalProvider, ISingletonD public void AddProposal(Hash proposalId, Hash proposalInputHash, long height) { - // keep the higher block index - _proposalsToRelease.AddOrUpdate(proposalId, new CodeCheckProposal + var newProposal = new CodeCheckProposal { ProposalId = proposalId, ProposedContractInputHash = proposalInputHash, BlockHeight = height - }, (hash, proposal) => proposal.BlockHeight >= height - ? proposal - : new CodeCheckProposal - { - ProposalId = proposalId, - BlockHeight = height, - ProposedContractInputHash = proposalInputHash - }); + }; + + _proposalsToRelease.AddOrUpdate(proposalId, newProposal, + (hash, proposal) => proposal.BlockHeight >= height ? proposal : newProposal); } - public List GetAllProposals() + public IEnumerable GetAllProposals() { - return _proposalsToRelease.Values.ToList(); + return _proposalsToRelease.Values; } public bool TryGetProposalCreatedHeight(Hash proposalId, out long height) diff --git a/src/AElf.Kernel.CodeCheck/Infrastructure/ICodeCheckProposalProvider.cs b/src/AElf.Kernel.CodeCheck/Infrastructure/ICodeCheckProposalProvider.cs index 403114fd39..b582b74e5e 100644 --- a/src/AElf.Kernel.CodeCheck/Infrastructure/ICodeCheckProposalProvider.cs +++ b/src/AElf.Kernel.CodeCheck/Infrastructure/ICodeCheckProposalProvider.cs @@ -6,7 +6,7 @@ namespace AElf.Kernel.CodeCheck.Infrastructure; public interface ICodeCheckProposalProvider { void AddProposal(Hash proposalId, Hash proposalInputHash, long height); - List GetAllProposals(); + IEnumerable GetAllProposals(); bool TryGetProposalCreatedHeight(Hash proposalId, out long height); void RemoveProposalById(Hash proposalId); } \ No newline at end of file diff --git a/src/AElf.Kernel.Configuration/AElf.Kernel.Configuration.csproj b/src/AElf.Kernel.Configuration/AElf.Kernel.Configuration.csproj index 842741825b..e6cb671608 100644 --- a/src/AElf.Kernel.Configuration/AElf.Kernel.Configuration.csproj +++ b/src/AElf.Kernel.Configuration/AElf.Kernel.Configuration.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 latest AElf.Kernel.Configuration true @@ -25,6 +25,6 @@ - + \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.AEDPoS/AElf.Kernel.Consensus.AEDPoS.csproj b/src/AElf.Kernel.Consensus.AEDPoS/AElf.Kernel.Consensus.AEDPoS.csproj index fc3fc47069..0df27c0df6 100644 --- a/src/AElf.Kernel.Consensus.AEDPoS/AElf.Kernel.Consensus.AEDPoS.csproj +++ b/src/AElf.Kernel.Consensus.AEDPoS/AElf.Kernel.Consensus.AEDPoS.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 latest AElf.Kernel.Consensus.AEDPoS true diff --git a/src/AElf.Kernel.Consensus.Core/AElf.Kernel.Consensus.Core.csproj b/src/AElf.Kernel.Consensus.Core/AElf.Kernel.Consensus.Core.csproj index d24ddf32c1..8bf006e0a9 100644 --- a/src/AElf.Kernel.Consensus.Core/AElf.Kernel.Consensus.Core.csproj +++ b/src/AElf.Kernel.Consensus.Core/AElf.Kernel.Consensus.Core.csproj @@ -1,7 +1,7 @@ - - + + - net6.0 + net8.0 AElf.Kernel.Consensus AElf.Kernel.Consensus.Core true @@ -10,7 +10,7 @@ - + diff --git a/src/AElf.Kernel.Consensus.Core/Application/ConsensusService.cs b/src/AElf.Kernel.Consensus.Core/Application/ConsensusService.cs index 50a75d9f90..21a3a41fbf 100644 --- a/src/AElf.Kernel.Consensus.Core/Application/ConsensusService.cs +++ b/src/AElf.Kernel.Consensus.Core/Application/ConsensusService.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AElf.CSharp.Core.Extension; @@ -18,6 +19,7 @@ internal class ConsensusService : IConsensusService, ISingletonDependency { private readonly IBlockTimeProvider _blockTimeProvider; private readonly IConsensusReaderContextService _consensusReaderContextService; + private readonly IMiningTimeProvider _miningTimeProvider; private readonly IConsensusScheduler _consensusScheduler; private readonly IContractReaderFactory @@ -31,13 +33,15 @@ private readonly IContractReaderFactory contractReaderFactory, ITriggerInformationProvider triggerInformationProvider, - IBlockTimeProvider blockTimeProvider, IConsensusReaderContextService consensusReaderContextService) + IBlockTimeProvider blockTimeProvider, IConsensusReaderContextService consensusReaderContextService, + IMiningTimeProvider miningTimeProvider) { _contractReaderFactory = contractReaderFactory; _triggerInformationProvider = triggerInformationProvider; _blockTimeProvider = blockTimeProvider; _consensusReaderContextService = consensusReaderContextService; _consensusScheduler = consensusScheduler; + _miningTimeProvider = miningTimeProvider; Logger = NullLogger.Instance; LocalEventBus = NullLocalEventBus.Instance; @@ -86,11 +90,19 @@ public async Task TriggerConsensusAsync(ChainContext chainContext) ? new Duration { Seconds = ConsensusConstants.MaximumLeftMillisecondsForNextBlock } : leftMilliseconds; + var configuredMiningTime = await _miningTimeProvider.GetLimitMillisecondsOfMiningBlockAsync(new BlockIndex + { + BlockHeight = chainContext.BlockHeight, + BlockHash = chainContext.BlockHash + }); + var limitMillisecondsOfMiningBlock = configuredMiningTime == 0 + ? _consensusCommand.LimitMillisecondsOfMiningBlock + : configuredMiningTime; // Update consensus scheduler. var blockMiningEventData = new ConsensusRequestMiningEventData(chainContext.BlockHash, chainContext.BlockHeight, _nextMiningTime, - TimestampHelper.DurationFromMilliseconds(_consensusCommand.LimitMillisecondsOfMiningBlock), + TimestampHelper.DurationFromMilliseconds(limitMillisecondsOfMiningBlock), _consensusCommand.MiningDueTime); _consensusScheduler.CancelCurrentEvent(); _consensusScheduler.NewEvent(leftMilliseconds.Milliseconds(), blockMiningEventData); diff --git a/src/AElf.Kernel.Consensus.Core/Application/IMiningTimeProvider.cs b/src/AElf.Kernel.Consensus.Core/Application/IMiningTimeProvider.cs new file mode 100644 index 0000000000..06500adeed --- /dev/null +++ b/src/AElf.Kernel.Consensus.Core/Application/IMiningTimeProvider.cs @@ -0,0 +1,50 @@ +using System.Threading.Tasks; +using AElf.Kernel.SmartContract.Application; +using Google.Protobuf.WellKnownTypes; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.Consensus.Application; + +public interface IMiningTimeProvider +{ + Task SetLimitMillisecondsOfMiningBlockAsync(IBlockIndex blockIndex, long limit); + Task GetLimitMillisecondsOfMiningBlockAsync(IBlockIndex blockIndex); +} + +public class MiningTimeProvider : BlockExecutedDataBaseProvider, + IMiningTimeProvider, ISingletonDependency +{ + private const string BlockExecutedDataName = "LimitMillisecondsOfMiningBlock"; + + public MiningTimeProvider( + ICachedBlockchainExecutedDataService cachedBlockchainExecutedDataService) : base( + cachedBlockchainExecutedDataService) + { + Logger = NullLogger.Instance; + } + + public ILogger Logger { get; set; } + + public Task GetLimitMillisecondsOfMiningBlockAsync(IBlockIndex blockIndex) + { + var limit = GetBlockExecutedData(blockIndex); + return Task.FromResult(limit?.Value ?? 0); + } + + public async Task SetLimitMillisecondsOfMiningBlockAsync(IBlockIndex blockIndex, long limit) + { + var blockTransactionLimit = new Int64Value + { + Value = limit + }; + await AddBlockExecutedDataAsync(blockIndex, blockTransactionLimit); + Logger.LogDebug($"LimitMillisecondsOfMiningBlock has been changed to {limit}"); + } + + protected override string GetBlockExecutedDataName() + { + return BlockExecutedDataName; + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.Core/Application/MiningTimeConfigurationProcessor.cs b/src/AElf.Kernel.Consensus.Core/Application/MiningTimeConfigurationProcessor.cs new file mode 100644 index 0000000000..db407cd710 --- /dev/null +++ b/src/AElf.Kernel.Consensus.Core/Application/MiningTimeConfigurationProcessor.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using AElf.Kernel.Configuration; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.Consensus.Application; + +public class MiningTimeConfigurationProcessor : IConfigurationProcessor, ITransientDependency +{ + private readonly IMiningTimeProvider _miningTimeProvider; + + public MiningTimeConfigurationProcessor(IMiningTimeProvider miningTimeProvider) + { + _miningTimeProvider = miningTimeProvider; + } + + public string ConfigurationName => ConsensusConstants.MiningTimeConfigurationName; + + public async Task ProcessConfigurationAsync(ByteString byteString, BlockIndex blockIndex) + { + var limit = new Int64Value(); + limit.MergeFrom(byteString); + if (limit.Value < 0) return; + await _miningTimeProvider.SetLimitMillisecondsOfMiningBlockAsync(blockIndex, limit.Value); + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.Core/ConsensusConstants.cs b/src/AElf.Kernel.Consensus.Core/ConsensusConstants.cs index 4b838b9fac..7bd3766d46 100644 --- a/src/AElf.Kernel.Consensus.Core/ConsensusConstants.cs +++ b/src/AElf.Kernel.Consensus.Core/ConsensusConstants.cs @@ -5,4 +5,6 @@ public static class ConsensusConstants public const long MaximumLeftMillisecondsForNextBlock = 3600_000; public const string ConsensusExtraDataKey = "Consensus"; + + public const string MiningTimeConfigurationName = "MiningTime"; } \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.Core/CoreConsensusAElfModule.cs b/src/AElf.Kernel.Consensus.Core/CoreConsensusAElfModule.cs index 4535545f26..0437a38b78 100644 --- a/src/AElf.Kernel.Consensus.Core/CoreConsensusAElfModule.cs +++ b/src/AElf.Kernel.Consensus.Core/CoreConsensusAElfModule.cs @@ -1,4 +1,5 @@ using AElf.Kernel.Blockchain.Application; +using AElf.Kernel.Configuration; using AElf.Kernel.Consensus.Application; using AElf.Kernel.Miner.Application; using AElf.Modularity; @@ -7,6 +8,7 @@ namespace AElf.Kernel.Consensus; +[DependsOn(typeof(ConfigurationAElfModule))] public class CoreConsensusAElfModule : AElfModule { public override void ConfigureServices(ServiceConfigurationContext context) @@ -15,5 +17,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddTransient(); context.Services.AddSingleton(); context.Services.AddTransient(); + context.Services.AddTransient(typeof(IConfigurationProcessor), + typeof(MiningTimeConfigurationProcessor)); } } \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.Scheduler.FluentScheduler/AElf.Kernel.Consensus.Scheduler.FluentScheduler.csproj b/src/AElf.Kernel.Consensus.Scheduler.FluentScheduler/AElf.Kernel.Consensus.Scheduler.FluentScheduler.csproj index 5eca3a7a60..1a6814fffe 100644 --- a/src/AElf.Kernel.Consensus.Scheduler.FluentScheduler/AElf.Kernel.Consensus.Scheduler.FluentScheduler.csproj +++ b/src/AElf.Kernel.Consensus.Scheduler.FluentScheduler/AElf.Kernel.Consensus.Scheduler.FluentScheduler.csproj @@ -1,19 +1,19 @@ - - + + - net6.0 + net8.0 AElf.Kernel.Consensus.Scheduler.FluentScheduler true Scheduler implementation for AEDPos using FluentScheduler. - + - + diff --git a/src/AElf.Kernel.Consensus.Scheduler.RxNet/AElf.Kernel.Consensus.Scheduler.RxNet.csproj b/src/AElf.Kernel.Consensus.Scheduler.RxNet/AElf.Kernel.Consensus.Scheduler.RxNet.csproj index dfd729dd0c..963881ceea 100644 --- a/src/AElf.Kernel.Consensus.Scheduler.RxNet/AElf.Kernel.Consensus.Scheduler.RxNet.csproj +++ b/src/AElf.Kernel.Consensus.Scheduler.RxNet/AElf.Kernel.Consensus.Scheduler.RxNet.csproj @@ -1,19 +1,19 @@ - - + + - net6.0 + net8.0 AElf.Kernel.Consensus.Scheduler.RxNet true Scheduler implementation for AEDPos using RxNet. - + - + diff --git a/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj b/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj index 99ddd91f24..e96f07073b 100644 --- a/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj +++ b/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Kernel latest AElf.Kernel.Core @@ -13,8 +13,10 @@ true + + - + diff --git a/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs b/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs index 06bcd4b719..7f6ca2cb4e 100644 --- a/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs +++ b/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs @@ -2,6 +2,7 @@ using System.Linq; using AElf.Kernel.Blockchain.Infrastructure; using AElf.Kernel.Infrastructure; +using Microsoft.Extensions.Caching.Memory; namespace AElf.Kernel.Blockchain.Domain; @@ -49,6 +50,7 @@ public class ChainManager : IChainManager, ISingletonDependency private readonly IChainBlockLinkCacheProvider _chainBlockLinkCacheProvider; private readonly IBlockchainStore _chainBlockLinks; private readonly IBlockchainStore _chains; + private readonly Dictionary _chainCache; private readonly IStaticChainInformationProvider _staticChainInformationProvider; @@ -63,6 +65,7 @@ public ChainManager(IBlockchainStore chains, _chainBlockIndexes = chainBlockIndexes; _staticChainInformationProvider = staticChainInformationProvider; _chainBlockLinkCacheProvider = chainBlockLinkCacheProvider; + _chainCache = new Dictionary(); } private int ChainId => _staticChainInformationProvider.ChainId; @@ -104,12 +107,19 @@ await SetChainBlockLinkAsync(new ChainBlockLink await _chains.SetAsync(ChainId.ToStorageKey(), chain); + // Update the cache. + _chainCache[ChainId] = chain; return chain; } public async Task GetAsync() { - var chain = await _chains.GetAsync(ChainId.ToStorageKey()); + if (_chainCache.TryGetValue(ChainId, out var chain)) + { + return chain?.Clone(); + } + chain = await _chains.GetAsync(ChainId.ToStorageKey()); + _chainCache[ChainId] = chain; return chain; } @@ -220,6 +230,9 @@ public async Task AttachBlockToChainAsync(Chain chai Logger.LogInformation($"Attach {chainBlockLink.BlockHash} to longest chain, status: {status}, " + $"longest chain height: {chain.LongestChainHeight}, longest chain hash: {chain.LongestChainHash}"); + // Update the cache. + _chainCache[ChainId] = chain; + return status; } @@ -250,6 +263,9 @@ public async Task SetIrreversibleBlockAsync(Chain chain, Hash irreversible chain.LastIrreversibleBlockHeight = links.First().Height; await _chains.SetAsync(chain.Id.ToStorageKey(), chain); + // Update the cache. + _chainCache[ChainId] = chain; + Logger.LogDebug( $"Setting chain lib height: {chain.LastIrreversibleBlockHeight}, chain lib hash: {chain.LastIrreversibleBlockHash}"); @@ -322,6 +338,9 @@ public async Task SetBestChainAsync(Chain chain, long bestChainHeight, Hash best chain.BestChainHash = bestChainHash; await _chains.SetAsync(chain.Id.ToStorageKey(), chain); + + // Update the cache. + _chainCache[ChainId] = chain; } public int GetChainId() @@ -417,6 +436,9 @@ public async Task CleanChainBranchAsync(Chain chain, DiscardedBranch discardedBr $"Clean chain branch, Branches: [{discardedBranch.BranchKeys.JoinAsString(",")}], NotLinkedBlocks: [{discardedBranch.NotLinkedKeys.JoinAsString(",")}]"); await _chains.SetAsync(chain.Id.ToStorageKey(), chain); + + // Update the cache. + _chainCache[ChainId] = chain; } public async Task RemoveLongestBranchAsync(Chain chain) @@ -430,6 +452,9 @@ public async Task RemoveLongestBranchAsync(Chain chain) $"Switch Longest chain to height: {chain.LongestChainHeight}, hash: {chain.LongestChainHash}."); await _chains.SetAsync(chain.Id.ToStorageKey(), chain); + + // Update the cache. + _chainCache[ChainId] = chain; } public async Task ResetChainToLibAsync(Chain chain) @@ -465,6 +490,9 @@ public async Task ResetChainToLibAsync(Chain chain) Logger.LogInformation($"Rollback to height {chain.BestChainHeight}, hash {chain.BestChainHash}."); await _chains.SetAsync(chain.Id.ToStorageKey(), chain); + // Update the cache. + _chainCache[ChainId] = chain; + return chain; } diff --git a/src/AElf.Kernel.Core/Plugin/Application/IPluginContractProvider.cs b/src/AElf.Kernel.Core/Plugin/Application/IPluginContractProvider.cs new file mode 100644 index 0000000000..73f04c6d47 --- /dev/null +++ b/src/AElf.Kernel.Core/Plugin/Application/IPluginContractProvider.cs @@ -0,0 +1,6 @@ +namespace AElf.Kernel.Plugin.Application; + +public interface IPluginContractProvider +{ + string GetContractName(); +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj b/src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj new file mode 100644 index 0000000000..7b39f518d5 --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/src/AElf.Kernel.FeatureDisable.Core/FeatureDisableConstants.cs b/src/AElf.Kernel.FeatureDisable.Core/FeatureDisableConstants.cs new file mode 100644 index 0000000000..84ce24c6fa --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable.Core/FeatureDisableConstants.cs @@ -0,0 +1,6 @@ +namespace AElf.Kernel.FeatureDisable.Core; + +public class FeatureDisableConstants +{ + public const string FeatureDisableConfigurationName = "DisableFeatureNameList"; +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable.Core/FeatureDisableCoreAElfModule.cs b/src/AElf.Kernel.FeatureDisable.Core/FeatureDisableCoreAElfModule.cs new file mode 100644 index 0000000000..c9e524ec01 --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable.Core/FeatureDisableCoreAElfModule.cs @@ -0,0 +1,11 @@ +using AElf.Modularity; +using Volo.Abp.Modularity; + +namespace AElf.Kernel.FeatureDisable.Core; + +public class FeatureDisableCoreAElfModule : AElfModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable.Core/IFeatureDisableService.cs b/src/AElf.Kernel.FeatureDisable.Core/IFeatureDisableService.cs new file mode 100644 index 0000000000..0131adc57b --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable.Core/IFeatureDisableService.cs @@ -0,0 +1,16 @@ +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.FeatureDisable.Core; + +public interface IFeatureDisableService +{ + Task IsFeatureDisabledAsync(params string[] featureNames); +} + +public class DefaultFeatureDisableService : IFeatureDisableService, ITransientDependency +{ + public Task IsFeatureDisabledAsync(params string[] featureNames) + { + return Task.FromResult(false); + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj b/src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj new file mode 100644 index 0000000000..fae7fc0cdf --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + + + + + + + + + diff --git a/src/AElf.Kernel.FeatureDisable/DisableFeatureOptions.cs b/src/AElf.Kernel.FeatureDisable/DisableFeatureOptions.cs new file mode 100644 index 0000000000..f5968ba95a --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable/DisableFeatureOptions.cs @@ -0,0 +1,6 @@ +namespace AElf.Kernel.FeatureDisable; + +public class DisableFeatureOptions +{ + public List FeatureNameList { get; set; } +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable/FeatureDisableAElfModule.cs b/src/AElf.Kernel.FeatureDisable/FeatureDisableAElfModule.cs new file mode 100644 index 0000000000..705246e612 --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable/FeatureDisableAElfModule.cs @@ -0,0 +1,15 @@ +using AElf.Kernel.Configuration; +using AElf.Kernel.FeatureDisable.Core; +using AElf.Modularity; +using Volo.Abp.Modularity; + +namespace AElf.Kernel.FeatureDisable; + +[DependsOn(typeof(FeatureDisableCoreAElfModule), + typeof(ConfigurationAElfModule))] +public class FeatureDisableAElfModule : AElfModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable/FeatureDisableConfigurationProcessor.cs b/src/AElf.Kernel.FeatureDisable/FeatureDisableConfigurationProcessor.cs new file mode 100644 index 0000000000..1adb8c45a9 --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable/FeatureDisableConfigurationProcessor.cs @@ -0,0 +1,26 @@ +using AElf.Kernel.Configuration; +using AElf.Kernel.FeatureDisable.Core; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.FeatureDisable; + +public class FeatureDisableConfigurationProcessor : IConfigurationProcessor, ITransientDependency +{ + private readonly IDisabledFeatureListProvider _disabledFeatureListProvider; + + public FeatureDisableConfigurationProcessor(IDisabledFeatureListProvider disabledFeatureListProvider) + { + _disabledFeatureListProvider = disabledFeatureListProvider; + } + + public string ConfigurationName => FeatureDisableConstants.FeatureDisableConfigurationName; + + public async Task ProcessConfigurationAsync(ByteString byteString, BlockIndex blockIndex) + { + var featureNameList = new StringValue(); + featureNameList.MergeFrom(byteString); + await _disabledFeatureListProvider.SetDisabledFeatureListAsync(blockIndex, featureNameList.Value); + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable/FeatureDisableService.cs b/src/AElf.Kernel.FeatureDisable/FeatureDisableService.cs new file mode 100644 index 0000000000..2ac30dbe73 --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable/FeatureDisableService.cs @@ -0,0 +1,41 @@ +using AElf.Kernel.Blockchain.Application; +using AElf.Kernel.FeatureDisable.Core; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.FeatureDisable; + +public class FeatureDisableService : IFeatureDisableService, ITransientDependency +{ + private readonly IDisabledFeatureListProvider _disabledFeatureListProvider; + private readonly IBlockchainService _blockchainService; + + public FeatureDisableService(IDisabledFeatureListProvider disabledFeatureListProvider, + IBlockchainService blockchainService) + { + _disabledFeatureListProvider = disabledFeatureListProvider; + _blockchainService = blockchainService; + } + + public async Task IsFeatureDisabledAsync(params string[] featureNames) + { + var chain = await _blockchainService.GetChainAsync(); + if (chain == null || chain.BestChainHeight <= 1) + { + // Which means chain hasn't been created yet or only genesis block exists. + return false; + } + + var nameList = await _disabledFeatureListProvider.GetDisabledFeatureListAsync(new BlockIndex + { + BlockHash = chain.BestChainHash, + BlockHeight = chain.BestChainHeight + }); + if (nameList.Length == 0) + { + return false; + } + + var isDisabled = nameList.Select(n => n.Trim()).Intersect(featureNames).Any(); + return isDisabled; + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureDisable/IDisabledFeatureListProvider.cs b/src/AElf.Kernel.FeatureDisable/IDisabledFeatureListProvider.cs new file mode 100644 index 0000000000..36b05ecad1 --- /dev/null +++ b/src/AElf.Kernel.FeatureDisable/IDisabledFeatureListProvider.cs @@ -0,0 +1,49 @@ +using AElf.Kernel.SmartContract.Application; +using Google.Protobuf.WellKnownTypes; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.FeatureDisable; + +public interface IDisabledFeatureListProvider +{ + Task SetDisabledFeatureListAsync(IBlockIndex blockIndex, string disabledFeatures); + Task GetDisabledFeatureListAsync(IBlockIndex blockIndex); +} + +public class DisabledFeatureListProvider : BlockExecutedDataBaseProvider, + IDisabledFeatureListProvider, ISingletonDependency +{ + private const string BlockExecutedDataName = "DisabledFeatureList"; + + public ILogger Logger { get; set; } + + public DisabledFeatureListProvider( + ICachedBlockchainExecutedDataService cachedBlockchainExecutedDataService) : base( + cachedBlockchainExecutedDataService) + { + Logger = NullLogger.Instance; + } + + public async Task SetDisabledFeatureListAsync(IBlockIndex blockIndex, string disabledFeatures) + { + var blockTransactionLimit = new StringValue + { + Value = disabledFeatures + }; + await AddBlockExecutedDataAsync(blockIndex, blockTransactionLimit); + Logger.LogDebug($"DisabledFeatureList has been changed to {disabledFeatures}"); + } + + public Task GetDisabledFeatureListAsync(IBlockIndex blockIndex) + { + var limit = GetBlockExecutedData(blockIndex); + return Task.FromResult(limit?.Value.Split(',') ?? Array.Empty()); + } + + protected override string GetBlockExecutedDataName() + { + return BlockExecutedDataName; + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.FeatureManager/AElf.Kernel.FeatureManager.csproj b/src/AElf.Kernel.FeatureManager/AElf.Kernel.FeatureManager.csproj index dc52cc861d..20260d21b7 100644 --- a/src/AElf.Kernel.FeatureManager/AElf.Kernel.FeatureManager.csproj +++ b/src/AElf.Kernel.FeatureManager/AElf.Kernel.FeatureManager.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 latest AElf.Kernel.FeatureManager true @@ -9,7 +9,7 @@ - + diff --git a/src/AElf.Kernel.FeeCalculation/AElf.Kernel.FeeCalculation.csproj b/src/AElf.Kernel.FeeCalculation/AElf.Kernel.FeeCalculation.csproj index 1bb381ee7d..9cf99272d6 100644 --- a/src/AElf.Kernel.FeeCalculation/AElf.Kernel.FeeCalculation.csproj +++ b/src/AElf.Kernel.FeeCalculation/AElf.Kernel.FeeCalculation.csproj @@ -1,15 +1,15 @@ - + - net6.0 + net8.0 latest AElf.Kernel.FeeCalculation true Fee Calculation Project. - - + + diff --git a/src/AElf.Kernel.Node/AElf.Kernel.Node.csproj b/src/AElf.Kernel.Node/AElf.Kernel.Node.csproj index 886b346a0a..80bb01b239 100644 --- a/src/AElf.Kernel.Node/AElf.Kernel.Node.csproj +++ b/src/AElf.Kernel.Node/AElf.Kernel.Node.csproj @@ -1,17 +1,17 @@ - - + + - net6.0 + net8.0 AElf.Kernel.Node true Base Module for building a node. - - - + + + diff --git a/src/AElf.Kernel.Proposal/AElf.Kernel.Proposal.csproj b/src/AElf.Kernel.Proposal/AElf.Kernel.Proposal.csproj index 417f66fc5f..c767d0942d 100644 --- a/src/AElf.Kernel.Proposal/AElf.Kernel.Proposal.csproj +++ b/src/AElf.Kernel.Proposal/AElf.Kernel.Proposal.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 latest AElf.Kernel.Proposal true @@ -9,7 +9,7 @@ - + diff --git a/src/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.csproj b/src/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.csproj index 8fa28f5c0b..6edbbe8a55 100644 --- a/src/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.csproj +++ b/src/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.csproj @@ -1,16 +1,16 @@ - - + + - net6.0 + net8.0 AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold true ACS 5 execution plugin. - - + + diff --git a/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.csproj b/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.csproj index 3c6ca0f576..d4eba82866 100644 --- a/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.csproj +++ b/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 AElf.Kernel.SmartContract.ExecutionPluginForMethodFee true ACS 1 execution plugin. diff --git a/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.csproj b/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.csproj index 3abe851ea8..fe23cb0e68 100644 --- a/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.csproj +++ b/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.csproj @@ -1,16 +1,16 @@ - - + + - net6.0 + net8.0 AElf.Kernel.SmartContract.ExecutionPluginForResourceFee true ACS 8 execution plugin. - - + + @@ -35,6 +35,6 @@ - + diff --git a/src/AElf.Kernel.SmartContract.Parallel/AElf.Kernel.SmartContract.Parallel.csproj b/src/AElf.Kernel.SmartContract.Parallel/AElf.Kernel.SmartContract.Parallel.csproj index dc8ed0e072..b195f0eb27 100644 --- a/src/AElf.Kernel.SmartContract.Parallel/AElf.Kernel.SmartContract.Parallel.csproj +++ b/src/AElf.Kernel.SmartContract.Parallel/AElf.Kernel.SmartContract.Parallel.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.Kernel.SmartContract.Parallel true Service module for parallel execution. @@ -21,6 +21,6 @@ - + diff --git a/src/AElf.Kernel.SmartContract.Parallel/Domain/ResourceExtractionService.cs b/src/AElf.Kernel.SmartContract.Parallel/Domain/ResourceExtractionService.cs index 028188e88b..8fd9598c7a 100644 --- a/src/AElf.Kernel.SmartContract.Parallel/Domain/ResourceExtractionService.cs +++ b/src/AElf.Kernel.SmartContract.Parallel/Domain/ResourceExtractionService.cs @@ -61,6 +61,22 @@ public async Task> GetResourcesAsync( return transactionResourceList; } + // TODO: Fix + // public async Task> GetResourcesAsync( + // IChainContext chainContext, + // IEnumerable transactions, CancellationToken ct) + // { + // var contractResourceInfoCache = new ConcurrentDictionary(); + // var transactionResourceList = await transactions.AsParallel().WithCancellation(ct).Select(async transaction => + // { + // var transactionResourcePair = + // await GetResourcesForOneWithCacheAsync(chainContext, transaction, ct, contractResourceInfoCache); + // return transactionResourcePair; + // }).WhenAll(); + // + // return transactionResourceList; + // } + public void ClearConflictingTransactionsResourceCache(IEnumerable transactionIds) { ClearResourceCache(transactionIds); @@ -215,6 +231,7 @@ public async Task HandleNewIrreversibleBlockFoundAsync(NewIrreversibleBlockFound try { ClearResourceCache(_resourceCache + //.AsParallel() .Where(c => c.Value.ResourceUsedBlockHeight <= eventData.BlockHeight) .Select(c => c.Key).Distinct().ToList()); } diff --git a/src/AElf.Kernel.SmartContract.Shared/AElf.Kernel.SmartContract.Shared.csproj b/src/AElf.Kernel.SmartContract.Shared/AElf.Kernel.SmartContract.Shared.csproj index c69bed6d92..899d51e6fa 100644 --- a/src/AElf.Kernel.SmartContract.Shared/AElf.Kernel.SmartContract.Shared.csproj +++ b/src/AElf.Kernel.SmartContract.Shared/AElf.Kernel.SmartContract.Shared.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.Kernel.SmartContract AElf.Kernel.SmartContract.Shared true @@ -10,7 +10,7 @@ - + diff --git a/src/AElf.Kernel.SmartContract/AElf.Kernel.SmartContract.csproj b/src/AElf.Kernel.SmartContract/AElf.Kernel.SmartContract.csproj index 15a367eef4..ab2cf443cf 100644 --- a/src/AElf.Kernel.SmartContract/AElf.Kernel.SmartContract.csproj +++ b/src/AElf.Kernel.SmartContract/AElf.Kernel.SmartContract.csproj @@ -1,18 +1,19 @@ - - + + - net6.0 + net8.0 AElf.Kernel.SmartContract true High level smart contract definitions and core functionality implementation. - + + diff --git a/src/AElf.Kernel.SmartContract/Application/PlainTransactionExecutingService.cs b/src/AElf.Kernel.SmartContract/Application/PlainTransactionExecutingService.cs index 66045dc7bc..79b09034f9 100644 --- a/src/AElf.Kernel.SmartContract/Application/PlainTransactionExecutingService.cs +++ b/src/AElf.Kernel.SmartContract/Application/PlainTransactionExecutingService.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using AElf.Kernel.FeatureDisable.Core; using AElf.Kernel.SmartContract.Domain; using AElf.Kernel.SmartContract.Infrastructure; using AElf.Types; @@ -21,13 +22,15 @@ public class PlainTransactionExecutingService : IPlainTransactionExecutingServic private readonly List _prePlugins; private readonly ISmartContractExecutiveService _smartContractExecutiveService; private readonly ITransactionContextFactory _transactionContextFactory; + private readonly IFeatureDisableService _featureDisableService; public PlainTransactionExecutingService(ISmartContractExecutiveService smartContractExecutiveService, IEnumerable postPlugins, IEnumerable prePlugins, - ITransactionContextFactory transactionContextFactory) + ITransactionContextFactory transactionContextFactory, IFeatureDisableService featureDisableService) { _smartContractExecutiveService = smartContractExecutiveService; _transactionContextFactory = transactionContextFactory; + _featureDisableService = featureDisableService; _prePlugins = GetUniquePlugins(prePlugins); _postPlugins = GetUniquePlugins(postPlugins); Logger = NullLogger.Instance; @@ -250,6 +253,11 @@ private async Task ExecutePluginOnPreTransactionStageAsync(IExecutive exec TieredStateCache internalStateCache, CancellationToken cancellationToken) { + if (await _featureDisableService.IsFeatureDisabledAsync("TxPlugin", "PrePlugin")) + { + return true; + } + var trace = txContext.Trace; foreach (var plugin in _prePlugins) { @@ -296,6 +304,11 @@ private async Task ExecutePluginOnPostTransactionStageAsync(IExecutive exe TieredStateCache internalStateCache, CancellationToken cancellationToken) { + if (await _featureDisableService.IsFeatureDisabledAsync("TxPlugin", "PostPlugin")) + { + return true; + } + var trace = txContext.Trace; if (!trace.IsSuccessful()) diff --git a/src/AElf.Kernel.SmartContract/Application/SmartContractExecutiveService.cs b/src/AElf.Kernel.SmartContract/Application/SmartContractExecutiveService.cs index 06d0bff8dd..9b013653e2 100644 --- a/src/AElf.Kernel.SmartContract/Application/SmartContractExecutiveService.cs +++ b/src/AElf.Kernel.SmartContract/Application/SmartContractExecutiveService.cs @@ -14,7 +14,7 @@ namespace AElf.Kernel.SmartContract.Application; public class SmartContractExecutiveService : ISmartContractExecutiveService, ISingletonDependency { private const int ExecutiveExpirationTime = 3600; // 1 Hour - private const int ExecutiveClearLimit = 10; + private const int ExecutiveClearLimit = 50; private readonly IDefaultContractZeroCodeProvider _defaultContractZeroCodeProvider; private readonly IHostSmartContractBridgeContextService _hostSmartContractBridgeContextService; diff --git a/src/AElf.Kernel.SmartContract/SmartContractAElfModule.cs b/src/AElf.Kernel.SmartContract/SmartContractAElfModule.cs index e8e62a97c8..670ee60cdb 100644 --- a/src/AElf.Kernel.SmartContract/SmartContractAElfModule.cs +++ b/src/AElf.Kernel.SmartContract/SmartContractAElfModule.cs @@ -1,3 +1,4 @@ +using AElf.Kernel.FeatureDisable.Core; using AElf.Kernel.SmartContract.Application; using AElf.Kernel.SmartContract.Infrastructure; using AElf.Modularity; @@ -6,7 +7,8 @@ namespace AElf.Kernel.SmartContract; -[DependsOn(typeof(CoreKernelAElfModule))] +[DependsOn(typeof(CoreKernelAElfModule), + typeof(FeatureDisableCoreAElfModule))] public class SmartContractAElfModule : AElfModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/src/AElf.Kernel.SmartContractExecution/AElf.Kernel.SmartContractExecution.csproj b/src/AElf.Kernel.SmartContractExecution/AElf.Kernel.SmartContractExecution.csproj index ab40e1634d..c1ae56325e 100644 --- a/src/AElf.Kernel.SmartContractExecution/AElf.Kernel.SmartContractExecution.csproj +++ b/src/AElf.Kernel.SmartContractExecution/AElf.Kernel.SmartContractExecution.csproj @@ -1,15 +1,15 @@ - - + + - net6.0 + net8.0 AElf.Kernel.SmartContractExecution true Smart contract execution related components. - - + + diff --git a/src/AElf.Kernel.SmartContractExecution/Application/BlockExecutionResultProcessingService.cs b/src/AElf.Kernel.SmartContractExecution/Application/BlockExecutionResultProcessingService.cs index 0c02156f93..d8871bc2e4 100644 --- a/src/AElf.Kernel.SmartContractExecution/Application/BlockExecutionResultProcessingService.cs +++ b/src/AElf.Kernel.SmartContractExecution/Application/BlockExecutionResultProcessingService.cs @@ -53,8 +53,8 @@ await LocalEventBus.PublishAsync(new BlocksExecutionSucceededEvent BlockExecutedSets = blockExecutionResult.SuccessBlockExecutedSets }); - Logger.LogInformation( - $"Attach blocks to best chain, best chain hash: {chain.BestChainHash}, height: {chain.BestChainHeight}"); + // Logger.LogInformation( + // $"Attach blocks to best chain, best chain hash: {chain.BestChainHash}, height: {chain.BestChainHeight}"); } private async Task SetBlockExecutionStatusAsync(IEnumerable blockHashes, diff --git a/src/AElf.Kernel.SmartContractExecution/Extensions/BlockchainServiceExtensions.cs b/src/AElf.Kernel.SmartContractExecution/Extensions/BlockchainServiceExtensions.cs index 0d35970d9c..1cabfd0161 100644 --- a/src/AElf.Kernel.SmartContractExecution/Extensions/BlockchainServiceExtensions.cs +++ b/src/AElf.Kernel.SmartContractExecution/Extensions/BlockchainServiceExtensions.cs @@ -11,9 +11,8 @@ public static class BlockchainServiceExtensions public static async Task> GetBlocksAsync(this IBlockchainService blockchainService, IEnumerable blockHashes) { - var list = blockHashes - .Select(async blockHash => await blockchainService.GetBlockByHashAsync(blockHash)); - - return (await Task.WhenAll(list)).ToList(); + var tasks = blockHashes.Select(blockchainService.GetBlockByHashAsync); + var blocks = await Task.WhenAll(tasks); + return blocks.ToList(); } } \ No newline at end of file diff --git a/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj b/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj index 0ed272fad3..33d51d7019 100644 --- a/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj +++ b/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj @@ -1,16 +1,16 @@ - - + + - net6.0 + net8.0 AElf.Kernel.Token true Core token package. - - + + diff --git a/src/AElf.Kernel.TransactionPool/AElf.Kernel.TransactionPool.csproj b/src/AElf.Kernel.TransactionPool/AElf.Kernel.TransactionPool.csproj index 59b7350b5d..0cbf5e63a7 100644 --- a/src/AElf.Kernel.TransactionPool/AElf.Kernel.TransactionPool.csproj +++ b/src/AElf.Kernel.TransactionPool/AElf.Kernel.TransactionPool.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.Kernel.TransactionPool true latest @@ -10,7 +10,7 @@ - + diff --git a/src/AElf.Kernel.TransactionPool/Application/TransactionValidationService.cs b/src/AElf.Kernel.TransactionPool/Application/TransactionValidationService.cs index fc33b15bbc..324cfb14d6 100644 --- a/src/AElf.Kernel.TransactionPool/Application/TransactionValidationService.cs +++ b/src/AElf.Kernel.TransactionPool/Application/TransactionValidationService.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using AElf.Kernel.Blockchain.Application; using AElf.Kernel.Txn.Application; @@ -32,31 +33,32 @@ public TransactionValidationService( /// /// /// - public async Task ValidateTransactionWhileCollectingAsync(IChainContext chainContext, - Transaction transaction) + public async Task ValidateTransactionWhileCollectingAsync(IChainContext chainContext, Transaction transaction) { - foreach (var provider in _transactionValidationProviders) + var validationTasks = _transactionValidationProviders.AsParallel().Select(async provider => { - if (await provider.ValidateTransactionAsync(transaction, chainContext)) continue; + if (await provider.ValidateTransactionAsync(transaction, chainContext)) return true; Logger.LogDebug( $"[ValidateTransactionWhileCollectingAsync]Transaction {transaction.GetHash()} validation failed in {provider.GetType()}"); return false; - } + }); - return true; + var results = await Task.WhenAll(validationTasks); + return results.All(result => result); } public async Task ValidateTransactionWhileSyncingAsync(Transaction transaction) { - foreach (var provider in _transactionValidationProviders) - { - if (!provider.ValidateWhileSyncing || - await provider.ValidateTransactionAsync(transaction)) continue; - Logger.LogDebug( - $"[ValidateTransactionWhileSyncingAsync]Transaction {transaction.GetHash()} validation failed in {provider.GetType()}"); - return false; - } + var validationTasks = _transactionValidationProviders.AsParallel() + .Where(provider => provider.ValidateWhileSyncing).Select(async provider => + { + if (await provider.ValidateTransactionAsync(transaction)) return true; + Logger.LogDebug( + $"[ValidateTransactionWhileSyncingAsync]Transaction {transaction.GetHash()} validation failed in {provider.GetType()}"); + return false; + }); - return true; + var results = await Task.WhenAll(validationTasks); + return results.All(result => result); } } \ No newline at end of file diff --git a/src/AElf.Kernel.TransactionPool/Infrastructure/TxHub.cs b/src/AElf.Kernel.TransactionPool/Infrastructure/TxHub.cs index eeb7a21242..2412494f97 100644 --- a/src/AElf.Kernel.TransactionPool/Infrastructure/TxHub.cs +++ b/src/AElf.Kernel.TransactionPool/Infrastructure/TxHub.cs @@ -55,7 +55,8 @@ public TxHub(ITransactionManager transactionManager, IBlockchainService blockcha public ILocalEventBus LocalEventBus { get; set; } - public async Task GetExecutableTransactionSetAsync(Hash blockHash, int transactionCount) + public async Task GetExecutableTransactionSetAsync( + Hash blockHash, int transactionCount) { var output = new ExecutableTransactionSet { diff --git a/src/AElf.Kernel.TransactionPool/TransactionOptions.cs b/src/AElf.Kernel.TransactionPool/TransactionOptions.cs index 491ddd51be..b2dfbc08ea 100644 --- a/src/AElf.Kernel.TransactionPool/TransactionOptions.cs +++ b/src/AElf.Kernel.TransactionPool/TransactionOptions.cs @@ -18,11 +18,11 @@ public class TransactionOptions /// public bool EnableTransactionExecutionValidation { get; set; } = true; + public static int BlockTransactionLimit { get; set; } = 512; /// /// Configuration whether to save failed transaction results /// public bool StoreInvalidTransactionResultEnabled { get; set; } - } \ No newline at end of file diff --git a/src/AElf.Kernel.Types/AElf.Kernel.Types.csproj b/src/AElf.Kernel.Types/AElf.Kernel.Types.csproj index 2b4ff86a2a..e2b894cd30 100644 --- a/src/AElf.Kernel.Types/AElf.Kernel.Types.csproj +++ b/src/AElf.Kernel.Types/AElf.Kernel.Types.csproj @@ -1,7 +1,7 @@ - - + + - net6.0 + net8.0 AElf.Kernel AElf.Kernel.Types true @@ -9,7 +9,7 @@ - + diff --git a/src/AElf.Kernel/AElf.Kernel.csproj b/src/AElf.Kernel/AElf.Kernel.csproj index 20e2f545d3..d45c62fa75 100644 --- a/src/AElf.Kernel/AElf.Kernel.csproj +++ b/src/AElf.Kernel/AElf.Kernel.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.Kernel true Main kernel module for building the kernel. @@ -13,6 +13,7 @@ + diff --git a/src/AElf.Kernel/KernelAElfModule.cs b/src/AElf.Kernel/KernelAElfModule.cs index d587922d61..5e27d0dd72 100644 --- a/src/AElf.Kernel/KernelAElfModule.cs +++ b/src/AElf.Kernel/KernelAElfModule.cs @@ -1,5 +1,6 @@ using AElf.Kernel.ChainController; using AElf.Kernel.Configuration; +using AElf.Kernel.FeatureDisable; using AElf.Kernel.Miner; using AElf.Kernel.Node; using AElf.Kernel.Proposal; @@ -17,6 +18,7 @@ namespace AElf.Kernel; typeof(CoreKernelAElfModule), typeof(ChainControllerAElfModule), typeof(SmartContractAElfModule), + typeof(FeatureDisableAElfModule), typeof(NodeAElfModule), typeof(SmartContractExecutionAElfModule), typeof(TransactionPoolAElfModule), diff --git a/src/AElf.Kernel/Miner/Application/MinerService.cs b/src/AElf.Kernel/Miner/Application/MinerService.cs index 6dafb7bed9..6450a58ff0 100644 --- a/src/AElf.Kernel/Miner/Application/MinerService.cs +++ b/src/AElf.Kernel/Miner/Application/MinerService.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using AElf.Kernel.Blockchain; +using AElf.Kernel.TransactionPool; using AElf.Kernel.TransactionPool.Application; using AElf.Kernel.Txn.Application; using Google.Protobuf.WellKnownTypes; @@ -37,8 +38,7 @@ public async Task MineAsync(Hash previousBlockHash, long previ Timestamp blockTime, Duration blockExecutionTime) { - var txList = new List(); - + var txList = new List(TransactionOptions.BlockTransactionLimit); var chainContext = new ChainContext { BlockHash = previousBlockHash, @@ -46,6 +46,7 @@ public async Task MineAsync(Hash previousBlockHash, long previ }; var limit = await _blockTransactionLimitProvider.GetLimitAsync(chainContext); + if (_transactionPackingOptionProvider.IsTransactionPackable(chainContext)) { var executableTransactionSet = await _transactionPoolService.GetExecutableTransactionSetAsync( @@ -54,9 +55,9 @@ public async Task MineAsync(Hash previousBlockHash, long previ txList.AddRange(executableTransactionSet.Transactions); } - Logger.LogInformation( - "Start mining with previous hash: {PreviousBlockHash}, previous height: {PreviousBlockHeight}", - previousBlockHash.ToHex(), previousBlockHeight); + // Logger.LogInformation( + // "Start mining with previous hash: {PreviousBlockHash}, previous height: {PreviousBlockHeight}", + // previousBlockHash.ToHex(), previousBlockHeight); return await _miningService.MineAsync( new RequestMiningDto { diff --git a/src/AElf.Kernel/Miner/Application/MiningService.cs b/src/AElf.Kernel/Miner/Application/MiningService.cs index 319e27fbfe..46900722cb 100644 --- a/src/AElf.Kernel/Miner/Application/MiningService.cs +++ b/src/AElf.Kernel/Miner/Application/MiningService.cs @@ -61,12 +61,12 @@ public async Task MineAsync(RequestMiningDto requestMiningDto, cts.CancelAfter(ts); } - var block = await GenerateBlock(requestMiningDto.PreviousBlockHash, - requestMiningDto.PreviousBlockHeight, blockTime); - var systemTransactions = await GenerateSystemTransactions(requestMiningDto.PreviousBlockHash, - requestMiningDto.PreviousBlockHeight); + var block = await GenerateBlock(requestMiningDto.PreviousBlockHash, requestMiningDto.PreviousBlockHeight, blockTime); + var systemTransactions = await GenerateSystemTransactions(requestMiningDto.PreviousBlockHash, requestMiningDto.PreviousBlockHeight); + _systemTransactionExtraDataProvider.SetSystemTransactionCount(systemTransactions.Count, block.Header); + var txTotalCount = transactions.Count + systemTransactions.Count; var pending = txTotalCount > requestMiningDto.TransactionCountLimit @@ -79,12 +79,15 @@ public async Task MineAsync(RequestMiningDto requestMiningDto, block = blockExecutedSet.Block; await SignBlockAsync(block); - Logger.LogInformation("Generated block: {Block}, " + - "previous: {PreviousBlockHash}, " + - "executed transactions: {TransactionsCount}, " + - "not executed transactions {NotExecutedTransactionsCount}", - block.ToDiagnosticString(), block.Header.PreviousBlockHash.ToHex(), block.Body.TransactionsCount, - pending.Count + systemTransactions.Count - block.Body.TransactionsCount); + if (block.Body.TransactionsCount > 2) + { + Logger.LogInformation("Generated block: {Block}, " + + "previous: {PreviousBlockHash}, " + + "executed transactions: {TransactionsCount}, " + + "not executed transactions {NotExecutedTransactionsCount}", + block.ToDiagnosticString(), block.Header.PreviousBlockHash.ToHex(), block.Body.TransactionsCount, + pending.Count + systemTransactions.Count - block.Body.TransactionsCount); + } return blockExecutedSet; } catch (Exception e) diff --git a/src/AElf.Launcher/AElf.Launcher.csproj b/src/AElf.Launcher/AElf.Launcher.csproj index 663c4536de..06559583c6 100644 --- a/src/AElf.Launcher/AElf.Launcher.csproj +++ b/src/AElf.Launcher/AElf.Launcher.csproj @@ -1,7 +1,7 @@  Exe - net6.0 + net8.0 true @@ -15,8 +15,8 @@ - - + + diff --git a/src/AElf.Launcher/Startup.cs b/src/AElf.Launcher/Startup.cs index 1c293abd9a..42a4537bde 100644 --- a/src/AElf.Launcher/Startup.cs +++ b/src/AElf.Launcher/Startup.cs @@ -1,5 +1,6 @@ using System; using System.Globalization; +using System.IO; using System.Linq; using AElf.Blockchains.MainChain; using AElf.Blockchains.SideChain; @@ -9,7 +10,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Modularity; +using Volo.Abp; +using Volo.Abp.Modularity.PlugIns; namespace AElf.Launcher; @@ -28,13 +30,23 @@ public Startup(IConfiguration configuration) public void ConfigureServices(IServiceCollection services) { var chainType = _configuration.GetValue("ChainType", ChainType.MainChain); + var pluginSourcesFolder = _configuration.GetValue("PluginSourcesFolder", Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "aelf", "plugins")); + Action optionsAction = options => + { + if (Directory.Exists(pluginSourcesFolder)) + { + options.PlugInSources.AddFolder(pluginSourcesFolder); + } + }; switch (chainType) { case ChainType.SideChain: - AddApplication(services); + services.AddApplication(optionsAction); break; - default: - AddApplication(services); + case ChainType.MainChain: + services.AddApplication(optionsAction); break; } @@ -56,11 +68,6 @@ public void ConfigureServices(IServiceCollection services) }); } - private static void AddApplication(IServiceCollection services) where T : IAbpModule - { - services.AddApplication(); - } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // ReSharper disable once UnusedMember.Global public void Configure(IApplicationBuilder app, IWebHostEnvironment env) diff --git a/src/AElf.Launcher/appsettings.json b/src/AElf.Launcher/appsettings.json index 45c0923284..7e3d567c35 100644 --- a/src/AElf.Launcher/appsettings.json +++ b/src/AElf.Launcher/appsettings.json @@ -30,8 +30,13 @@ "PeriodSeconds": 604800, "MinerIncreaseInterval": 31536000 }, + "MiningTime": { + "LimitMillisecondsOfMiningBlock": 400 + }, + "DisableFeature": { + "FeatureNameList": ["TxPlugin"] + }, "Transaction": { - "StoreInvalidTransactionResultEnabled" : false, "PoolLimit": 10240 }, "BasicAuth": { diff --git a/src/AElf.OS.Core/AElf.OS.Core.csproj b/src/AElf.OS.Core/AElf.OS.Core.csproj index 47ea5135a5..4c47b99c2f 100644 --- a/src/AElf.OS.Core/AElf.OS.Core.csproj +++ b/src/AElf.OS.Core/AElf.OS.Core.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.OS AElf.OS.Core true diff --git a/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj b/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj index e4a8dfcc99..f47b94d80c 100644 --- a/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj +++ b/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 AElf.OS.Network.Grpc true gRPC implementations of AElf's network communication layer. diff --git a/src/AElf.OS/AElf.OS.csproj b/src/AElf.OS/AElf.OS.csproj index 531d4f7d4d..7da7c68f76 100644 --- a/src/AElf.OS/AElf.OS.csproj +++ b/src/AElf.OS/AElf.OS.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 AElf.OS true Main module for the OS layer. @@ -15,7 +15,7 @@ - + diff --git a/src/AElf.Runtime.CSharp.Core/AElf.Runtime.CSharp.Core.csproj b/src/AElf.Runtime.CSharp.Core/AElf.Runtime.CSharp.Core.csproj index 4cd89b4173..48a59a9535 100644 --- a/src/AElf.Runtime.CSharp.Core/AElf.Runtime.CSharp.Core.csproj +++ b/src/AElf.Runtime.CSharp.Core/AElf.Runtime.CSharp.Core.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.Runtime.CSharp.Core AElf.Runtime.CSharp.Core true @@ -10,7 +10,7 @@ - + diff --git a/src/AElf.Runtime.CSharp.ExecutiveTokenPlugin/AElf.Runtime.CSharp.ExecutiveTokenPlugin.csproj b/src/AElf.Runtime.CSharp.ExecutiveTokenPlugin/AElf.Runtime.CSharp.ExecutiveTokenPlugin.csproj index ab7eccbf55..215dbf3a3f 100644 --- a/src/AElf.Runtime.CSharp.ExecutiveTokenPlugin/AElf.Runtime.CSharp.ExecutiveTokenPlugin.csproj +++ b/src/AElf.Runtime.CSharp.ExecutiveTokenPlugin/AElf.Runtime.CSharp.ExecutiveTokenPlugin.csproj @@ -1,15 +1,15 @@ - - + + - net6.0 + net8.0 AElf.Runtime.CSharp.ExecutiveTokenPlugin true Executive plugin for C# smart contracts. - + diff --git a/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj b/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj index 576dc9d875..bf9914645e 100644 --- a/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj +++ b/src/AElf.Runtime.CSharp/AElf.Runtime.CSharp.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.Runtime.CSharp AElf.Runtime.CSharp true @@ -14,14 +14,14 @@ - - - - + + + + - + diff --git a/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj b/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj index 75a439494b..ea1434095c 100644 --- a/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj +++ b/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj @@ -1,20 +1,20 @@ - - + + - net6.0 + net8.0 AElf.RuntimeSetup true Module for the nodes runtime setup (logging for example). - + - - + + diff --git a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj index 1138bc5cc3..3d27d43369 100644 --- a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj +++ b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.Sdk.CSharp true latest @@ -10,9 +10,9 @@ - - - + + + diff --git a/src/AElf.Types/AElf.Types.csproj b/src/AElf.Types/AElf.Types.csproj index f819ee9d12..867163cd35 100644 --- a/src/AElf.Types/AElf.Types.csproj +++ b/src/AElf.Types/AElf.Types.csproj @@ -1,7 +1,7 @@ - - + + - netstandard2.1;net6.0 + netstandard2.1;net8.0 AElf AElf.Types true @@ -11,7 +11,7 @@ true - + diff --git a/src/AElf.Types/Extensions/StringExtensions.cs b/src/AElf.Types/Extensions/StringExtensions.cs index 7e714a9a65..f97f6d7a79 100644 --- a/src/AElf.Types/Extensions/StringExtensions.cs +++ b/src/AElf.Types/Extensions/StringExtensions.cs @@ -1,4 +1,5 @@ using System.Text; +using Google.Protobuf.Collections; namespace AElf { @@ -9,5 +10,10 @@ public static byte[] GetBytes(this string value) { return Encoding.UTF8.GetBytes(value); } + + public static void MergeFrom(this MapField field, MapField others) + { + field.Add(others); + } } } \ No newline at end of file diff --git a/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj b/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj index 575f4c97e2..7d3417b81e 100644 --- a/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj +++ b/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 AElf.WebApp.Application.Chain true $(NoWarn);1591 @@ -19,7 +19,7 @@ - + diff --git a/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj b/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj index b85df20afb..ae0fe7ad3b 100644 --- a/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj +++ b/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 AElf.WebApp.Application true AElf.WebApp.Application.Core @@ -11,12 +11,12 @@ - - + + - + diff --git a/src/AElf.WebApp.Application.Net/AElf.WebApp.Application.Net.csproj b/src/AElf.WebApp.Application.Net/AElf.WebApp.Application.Net.csproj index d2d0066780..01beab4148 100644 --- a/src/AElf.WebApp.Application.Net/AElf.WebApp.Application.Net.csproj +++ b/src/AElf.WebApp.Application.Net/AElf.WebApp.Application.Net.csproj @@ -1,8 +1,8 @@ - - + + - net6.0 + net8.0 $(NoWarn);1591 true AElf.WebApp.Application.Net @@ -11,12 +11,12 @@ - - + + - + diff --git a/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj b/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj index 33a752255d..b11907855a 100644 --- a/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj +++ b/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 AElf.WebApp.Web true Main module for the node's Web API. @@ -14,13 +14,13 @@ - - - - - - - + + + + + + + diff --git a/templates/build-template-linux.yml b/templates/build-template-linux.yml index 62148b2d1d..37be791f86 100644 --- a/templates/build-template-linux.yml +++ b/templates/build-template-linux.yml @@ -21,7 +21,7 @@ jobs: - task: UseDotNet@2 displayName: 'Install .NET Core SDK' inputs: - version: 6.0.x + version: 8.0.303 - script: bash scripts/install_protobuf.sh - script: bash scripts/download_binary.sh - script: bash build.sh --target=Test-with-Codecov-N --parts=${{ parameters.parts }} --number=${{ parameters.n }} --codecoverage=${{ parameters.codecoverage }} diff --git a/templates/build-template-macos.yml b/templates/build-template-macos.yml index 5c3c543811..de6a350a35 100644 --- a/templates/build-template-macos.yml +++ b/templates/build-template-macos.yml @@ -21,7 +21,7 @@ jobs: - task: UseDotNet@2 displayName: 'Install .NET Core SDK' inputs: - version: 6.0.x + version: 8.0.303 - script: bash scripts/install_protobuf.sh - script: bash scripts/download_binary.sh - script: bash build.sh --target=Test-with-Codecov-N --parts=${{ parameters.parts }} --number=${{ parameters.n }} --codecoverage=${{ parameters.codecoverage }} diff --git a/templates/build-template-window.yml b/templates/build-template-window.yml index a222d4b8d1..e5e6d20dc9 100644 --- a/templates/build-template-window.yml +++ b/templates/build-template-window.yml @@ -21,7 +21,7 @@ jobs: - task: UseDotNet@2 displayName: 'Install .NET Core SDK' inputs: - version: 6.0.x + version: 8.0.303 - script: choco install protoc --version=3.19.4 -y displayName: 'Install protobuf' - script: choco install unzip diff --git a/test/AElf.CSharp.CodeOps.Tests/AElf.CSharp.CodeOps.Tests.csproj b/test/AElf.CSharp.CodeOps.Tests/AElf.CSharp.CodeOps.Tests.csproj index b801d4a542..8d675e45ed 100644 --- a/test/AElf.CSharp.CodeOps.Tests/AElf.CSharp.CodeOps.Tests.csproj +++ b/test/AElf.CSharp.CodeOps.Tests/AElf.CSharp.CodeOps.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.CSharp.CodeOps false @@ -13,9 +13,9 @@ all runtime; build; native; contentfiles; analyzers - + - + all @@ -25,30 +25,30 @@ all runtime; build; native; contentfiles; analyzers - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/test/AElf.CSharp.CodeOps.Tests/ContractAuditorTests.cs b/test/AElf.CSharp.CodeOps.Tests/ContractAuditorTests.cs index ca6affbda5..56be0fc22c 100644 --- a/test/AElf.CSharp.CodeOps.Tests/ContractAuditorTests.cs +++ b/test/AElf.CSharp.CodeOps.Tests/ContractAuditorTests.cs @@ -111,7 +111,7 @@ public void AuditTimeout() var codeOpsOptions = GetRequiredService>(); codeOpsOptions.CurrentValue.AuditTimeoutDuration = 0; Should.Throw(() => - _auditor.Audit(ReadPatchedContractCode(typeof(TokenContract)), true)); + _auditor.Audit(ReadPatchedContractCode(typeof(TokenContract)), true)); } [Fact] diff --git a/test/AElf.CSharp.CodeOps.UnitTests/AElf.CSharp.CodeOps.UnitTests.csproj b/test/AElf.CSharp.CodeOps.UnitTests/AElf.CSharp.CodeOps.UnitTests.csproj index 5fc8f412c4..f80d415417 100644 --- a/test/AElf.CSharp.CodeOps.UnitTests/AElf.CSharp.CodeOps.UnitTests.csproj +++ b/test/AElf.CSharp.CodeOps.UnitTests/AElf.CSharp.CodeOps.UnitTests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 enable enable diff --git a/test/AElf.CSharp.CodeOps.UnitTests/CSharpCodeOpsTestBase.cs b/test/AElf.CSharp.CodeOps.UnitTests/CSharpCodeOpsTestBase.cs index 338ae2accd..8e95404725 100644 --- a/test/AElf.CSharp.CodeOps.UnitTests/CSharpCodeOpsTestBase.cs +++ b/test/AElf.CSharp.CodeOps.UnitTests/CSharpCodeOpsTestBase.cs @@ -104,7 +104,7 @@ protected static string DecompileType(TypeDefinition typ) static CSharpCodeOpsTestBase() { - AddNet6References(); + AddNet8References(); AddSmartContractReferences(); } @@ -145,9 +145,9 @@ public static void AddAssemblies(params string[] assemblies) } - public static void AddNet6References() + public static void AddNet8References() { - foreach (var portableExecutableReference in Basic.Reference.Assemblies.Net60.References.All) + foreach (var portableExecutableReference in Basic.Reference.Assemblies.Net80.References.All) { References.Add(portableExecutableReference); } diff --git a/test/AElf.CSharp.Core.Tests/AElf.CSharp.Core.Tests.csproj b/test/AElf.CSharp.Core.Tests/AElf.CSharp.Core.Tests.csproj index 2fb02a1378..844a0d183d 100644 --- a/test/AElf.CSharp.Core.Tests/AElf.CSharp.Core.Tests.csproj +++ b/test/AElf.CSharp.Core.Tests/AElf.CSharp.Core.Tests.csproj @@ -1,11 +1,11 @@  - net6.0 + net8.0 false - - + + @@ -13,7 +13,7 @@ runtime; build; native; contentfiles; analyzers - + all diff --git a/test/AElf.ContractDeployer.Tests/AElf.ContractDeployer.Tests.csproj b/test/AElf.ContractDeployer.Tests/AElf.ContractDeployer.Tests.csproj index 7a238fd81a..f0b58e0b74 100644 --- a/test/AElf.ContractDeployer.Tests/AElf.ContractDeployer.Tests.csproj +++ b/test/AElf.ContractDeployer.Tests/AElf.ContractDeployer.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.ContractDeployer @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -22,8 +22,8 @@ - - + + diff --git a/test/AElf.ContractTestBase.Tests/AElf.ContractTestBase.Tests.csproj b/test/AElf.ContractTestBase.Tests/AElf.ContractTestBase.Tests.csproj index 9a4c5e6b0a..ca8838ea8a 100644 --- a/test/AElf.ContractTestBase.Tests/AElf.ContractTestBase.Tests.csproj +++ b/test/AElf.ContractTestBase.Tests/AElf.ContractTestBase.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -10,7 +10,7 @@ - + @@ -161,9 +161,9 @@ runtime; build; native; contentfiles; analyzers - + - + all runtime; build; native; contentfiles; analyzers diff --git a/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AEDPoSExtensionDemoTestBase.cs b/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AEDPoSExtensionDemoTestBase.cs index a3550cb210..fd6ff9c9be 100644 --- a/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AEDPoSExtensionDemoTestBase.cs +++ b/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AEDPoSExtensionDemoTestBase.cs @@ -15,6 +15,7 @@ using AElf.EconomicSystem; using AElf.GovernmentSystem; using AElf.Kernel; +using AElf.Kernel.Configuration; using AElf.Kernel.Consensus; using AElf.Kernel.Proposal; using AElf.Kernel.Token; @@ -74,7 +75,8 @@ internal void InitialContracts() ParliamentSmartContractAddressNameProvider.Name, ElectionSmartContractAddressNameProvider.Name, AssociationSmartContractAddressNameProvider.Name, - ReferendumSmartContractAddressNameProvider.Name + ReferendumSmartContractAddressNameProvider.Name, + ConfigurationSmartContractAddressNameProvider.Name, })); } diff --git a/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AElf.Contracts.AEDPoSExtension.Demo.Tests.csproj b/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AElf.Contracts.AEDPoSExtension.Demo.Tests.csproj index 5a03f644f1..0e01048c51 100644 --- a/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AElf.Contracts.AEDPoSExtension.Demo.Tests.csproj +++ b/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/AElf.Contracts.AEDPoSExtension.Demo.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -23,8 +23,8 @@ - - + + @@ -34,7 +34,7 @@ PreserveNewest - + diff --git a/test/AElf.Contracts.Association.Tests/AElf.Contracts.Association.Tests.csproj b/test/AElf.Contracts.Association.Tests/AElf.Contracts.Association.Tests.csproj index f0517749dd..849bcfa27f 100644 --- a/test/AElf.Contracts.Association.Tests/AElf.Contracts.Association.Tests.csproj +++ b/test/AElf.Contracts.Association.Tests/AElf.Contracts.Association.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.Association false @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -28,7 +28,7 @@ - + @@ -86,5 +86,5 @@ - + diff --git a/test/AElf.Contracts.Association.Tests/AssociationContractTests.cs b/test/AElf.Contracts.Association.Tests/AssociationContractTests.cs index 0da11d0fa3..89ec1025ed 100644 --- a/test/AElf.Contracts.Association.Tests/AssociationContractTests.cs +++ b/test/AElf.Contracts.Association.Tests/AssociationContractTests.cs @@ -169,6 +169,8 @@ public async Task Get_Proposal_Test() getProposal.Output.OrganizationAddress.ShouldBe(organizationAddress); getProposal.Output.ToAddress.ShouldBe(TokenContractAddress); getProposal.Output.Params.ShouldBe(transferInput.ToByteString()); + getProposal.Output.Title.ShouldNotBeNullOrEmpty(); + getProposal.Output.Description.ShouldNotBeNullOrEmpty(); } } @@ -1231,7 +1233,9 @@ private async Task CreateProposalAsync(ECKeyPair proposalKeyPair, Address ToAddress = TokenContractAddress, Params = transferInput.ToByteString(), ExpiredTime = BlockTimeProvider.GetBlockTime().AddDays(2), - OrganizationAddress = organizationAddress + OrganizationAddress = organizationAddress, + Title = "Token Transfer", + Description = "Transfer 100 ELF to Reviewer1's address", }; var proposal = await associationContractStub.CreateProposal.SendAsync(createProposalInput); var proposalCreated = ProposalCreated.Parser.ParseFrom(proposal.TransactionResult.Logs diff --git a/test/AElf.Contracts.Configuration.Tests/AElf.Contracts.Configuration.Tests.csproj b/test/AElf.Contracts.Configuration.Tests/AElf.Contracts.Configuration.Tests.csproj index 3f108c2698..11cf5249e2 100644 --- a/test/AElf.Contracts.Configuration.Tests/AElf.Contracts.Configuration.Tests.csproj +++ b/test/AElf.Contracts.Configuration.Tests/AElf.Contracts.Configuration.Tests.csproj @@ -1,13 +1,13 @@  - net6.0 + net8.0 AElf.Contracts.ConfigurationContract.Tests false - + false Contract @@ -57,6 +57,6 @@ - + diff --git a/test/AElf.Contracts.Consensus.AEDPoS.Tests/AElf.Contracts.Consensus.AEDPoS.Tests.csproj b/test/AElf.Contracts.Consensus.AEDPoS.Tests/AElf.Contracts.Consensus.AEDPoS.Tests.csproj index f9397a21b3..35e2ad70cf 100644 --- a/test/AElf.Contracts.Consensus.AEDPoS.Tests/AElf.Contracts.Consensus.AEDPoS.Tests.csproj +++ b/test/AElf.Contracts.Consensus.AEDPoS.Tests/AElf.Contracts.Consensus.AEDPoS.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.Consensus.AEDPoS false diff --git a/test/AElf.Contracts.CrossChain.Tests/AElf.Contracts.CrossChain.Tests.csproj b/test/AElf.Contracts.CrossChain.Tests/AElf.Contracts.CrossChain.Tests.csproj index a27276b8c9..abb1a0b320 100644 --- a/test/AElf.Contracts.CrossChain.Tests/AElf.Contracts.CrossChain.Tests.csproj +++ b/test/AElf.Contracts.CrossChain.Tests/AElf.Contracts.CrossChain.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.CrossChain.Tests AElf.Contracts.CrossChain.Tests false @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -23,7 +23,7 @@ runtime; build; native; contentfiles; analyzers - + Protobuf\Proto\authority_info.proto @@ -93,6 +93,6 @@ - + diff --git a/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj b/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj index 732176b7fe..978a185781 100644 --- a/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj +++ b/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -23,11 +23,11 @@ - - - + + + - + Protobuf\Proto\authority_info.proto diff --git a/test/AElf.Contracts.Economic.TestBase/AElf.Contracts.Economic.TestBase.csproj b/test/AElf.Contracts.Economic.TestBase/AElf.Contracts.Economic.TestBase.csproj index c0b204fe14..6756f5c799 100644 --- a/test/AElf.Contracts.Economic.TestBase/AElf.Contracts.Economic.TestBase.csproj +++ b/test/AElf.Contracts.Economic.TestBase/AElf.Contracts.Economic.TestBase.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false 0436 diff --git a/test/AElf.Contracts.EconomicSystem.Tests/AElf.Contracts.EconomicSystem.Tests.csproj b/test/AElf.Contracts.EconomicSystem.Tests/AElf.Contracts.EconomicSystem.Tests.csproj index dbad41ec40..e738b21493 100644 --- a/test/AElf.Contracts.EconomicSystem.Tests/AElf.Contracts.EconomicSystem.Tests.csproj +++ b/test/AElf.Contracts.EconomicSystem.Tests/AElf.Contracts.EconomicSystem.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false diff --git a/test/AElf.Contracts.Election.Tests/AElf.Contracts.Election.Tests.csproj b/test/AElf.Contracts.Election.Tests/AElf.Contracts.Election.Tests.csproj index e472065cfe..8934ab1474 100644 --- a/test/AElf.Contracts.Election.Tests/AElf.Contracts.Election.Tests.csproj +++ b/test/AElf.Contracts.Election.Tests/AElf.Contracts.Election.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Contracts.Election false diff --git a/test/AElf.Contracts.Genesis.Tests/AElf.Contracts.Genesis.Tests.csproj b/test/AElf.Contracts.Genesis.Tests/AElf.Contracts.Genesis.Tests.csproj index c439d16de0..8921a2c5c3 100644 --- a/test/AElf.Contracts.Genesis.Tests/AElf.Contracts.Genesis.Tests.csproj +++ b/test/AElf.Contracts.Genesis.Tests/AElf.Contracts.Genesis.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false @@ -10,7 +10,7 @@ - + false Contract @@ -27,7 +27,7 @@ Contract PreserveNewest - + false Contract diff --git a/test/AElf.Contracts.GenesisUpdate/AElf.Contracts.GenesisUpdate.csproj b/test/AElf.Contracts.GenesisUpdate/AElf.Contracts.GenesisUpdate.csproj index 6382b39aa6..37b89f1a71 100644 --- a/test/AElf.Contracts.GenesisUpdate/AElf.Contracts.GenesisUpdate.csproj +++ b/test/AElf.Contracts.GenesisUpdate/AElf.Contracts.GenesisUpdate.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 1.3.0 @@ -14,7 +14,7 @@ - + diff --git a/test/AElf.Contracts.MultiToken.Tests/AElf.Contracts.MultiToken.Tests.csproj b/test/AElf.Contracts.MultiToken.Tests/AElf.Contracts.MultiToken.Tests.csproj index a7de2a24a1..c23a5bd985 100644 --- a/test/AElf.Contracts.MultiToken.Tests/AElf.Contracts.MultiToken.Tests.csproj +++ b/test/AElf.Contracts.MultiToken.Tests/AElf.Contracts.MultiToken.Tests.csproj @@ -1,12 +1,12 @@  - net6.0 + net8.0 AElf.Contracts.MultiToken false - + false Contract @@ -63,9 +63,9 @@ all runtime; build; native; contentfiles; analyzers - - - + + + all diff --git a/test/AElf.Contracts.MultiTokenCrossChainTransfer.Tests/AElf.Contracts.MultiTokenCrossChainTransfer.Tests.csproj b/test/AElf.Contracts.MultiTokenCrossChainTransfer.Tests/AElf.Contracts.MultiTokenCrossChainTransfer.Tests.csproj index d913d0ca09..d1a1ac78b4 100644 --- a/test/AElf.Contracts.MultiTokenCrossChainTransfer.Tests/AElf.Contracts.MultiTokenCrossChainTransfer.Tests.csproj +++ b/test/AElf.Contracts.MultiTokenCrossChainTransfer.Tests/AElf.Contracts.MultiTokenCrossChainTransfer.Tests.csproj @@ -1,11 +1,11 @@ - + - net6.0 + net8.0 AElf.Contracts.MultiTokenCrossSideChain false - + false Contract @@ -59,7 +59,7 @@ runtime; build; native; contentfiles; analyzers - + all diff --git a/test/AElf.Contracts.NFT.Tests/AElf.Contracts.NFT.Tests.csproj b/test/AElf.Contracts.NFT.Tests/AElf.Contracts.NFT.Tests.csproj index 1fcbbe1435..7943f658f4 100644 --- a/test/AElf.Contracts.NFT.Tests/AElf.Contracts.NFT.Tests.csproj +++ b/test/AElf.Contracts.NFT.Tests/AElf.Contracts.NFT.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Contracts.NFT false diff --git a/test/AElf.Contracts.Parliament.Tests/AElf.Contracts.Parliament.Tests.csproj b/test/AElf.Contracts.Parliament.Tests/AElf.Contracts.Parliament.Tests.csproj index 525f9f9403..196851f316 100644 --- a/test/AElf.Contracts.Parliament.Tests/AElf.Contracts.Parliament.Tests.csproj +++ b/test/AElf.Contracts.Parliament.Tests/AElf.Contracts.Parliament.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.Parliament false @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -27,8 +27,8 @@ - - + + @@ -95,5 +95,5 @@ - + diff --git a/test/AElf.Contracts.Parliament.Tests/ParliamentContractTest.cs b/test/AElf.Contracts.Parliament.Tests/ParliamentContractTest.cs index 5a82089232..caeb34f557 100644 --- a/test/AElf.Contracts.Parliament.Tests/ParliamentContractTest.cs +++ b/test/AElf.Contracts.Parliament.Tests/ParliamentContractTest.cs @@ -108,6 +108,8 @@ public async Task Get_Proposal_Test() getProposal.Output.ProposalId.ShouldBe(proposalId); getProposal.Output.OrganizationAddress.ShouldBe(organizationAddress); getProposal.Output.ToAddress.ShouldBe(TokenContractAddress); + getProposal.Output.Title.ShouldNotBeNullOrEmpty(); + getProposal.Output.Description.ShouldNotBeNullOrEmpty(); var transferParam = TransferInput.Parser.ParseFrom(getProposal.Output.Params); transferParam.Symbol.ShouldBe(transferInput.Symbol); @@ -1541,7 +1543,9 @@ private async Task CreateProposalAsync(ECKeyPair proposalKeyPair, Address ToAddress = TokenContractAddress, Params = transferInput.ToByteString(), ExpiredTime = BlockTimeProvider.GetBlockTime().AddDays(2), - OrganizationAddress = organizationAddress + OrganizationAddress = organizationAddress, + Title = "Token Transfer", + Description = "Transfer 100 ELF to Tester's address", }; var parliamentContractStub = GetParliamentContractTester(proposalKeyPair); var proposal = await parliamentContractStub.CreateProposal.SendAsync(createProposalInput); diff --git a/test/AElf.Contracts.Profit.Tests/AElf.Contracts.Profit.Tests.csproj b/test/AElf.Contracts.Profit.Tests/AElf.Contracts.Profit.Tests.csproj index 53b98d7d62..a86fafe9e7 100644 --- a/test/AElf.Contracts.Profit.Tests/AElf.Contracts.Profit.Tests.csproj +++ b/test/AElf.Contracts.Profit.Tests/AElf.Contracts.Profit.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.Profit false diff --git a/test/AElf.Contracts.Referendum.Tests/AElf.Contracts.Referendum.Tests.csproj b/test/AElf.Contracts.Referendum.Tests/AElf.Contracts.Referendum.Tests.csproj index 417c55448b..a63f0c6b22 100644 --- a/test/AElf.Contracts.Referendum.Tests/AElf.Contracts.Referendum.Tests.csproj +++ b/test/AElf.Contracts.Referendum.Tests/AElf.Contracts.Referendum.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.Referendum false @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -28,13 +28,13 @@ - - - - - - - + + + + + + + diff --git a/test/AElf.Contracts.Referendum.Tests/ReferendumContractTest.cs b/test/AElf.Contracts.Referendum.Tests/ReferendumContractTest.cs index d22a250401..81dd45896c 100644 --- a/test/AElf.Contracts.Referendum.Tests/ReferendumContractTest.cs +++ b/test/AElf.Contracts.Referendum.Tests/ReferendumContractTest.cs @@ -110,6 +110,8 @@ public async Task Get_Proposal_Test() getProposal.Output.OrganizationAddress.ShouldBe(organizationAddress); getProposal.Output.ToAddress.ShouldBe(TokenContractAddress); getProposal.Output.Params.ShouldBe(createInput.ToByteString()); + getProposal.Output.Title.ShouldNotBeNullOrEmpty(); + getProposal.Output.Description.ShouldNotBeNullOrEmpty(); } [Fact] @@ -1320,7 +1322,9 @@ private async Task CreateProposalAsync(ECKeyPair proposalKeyPair, Address ToAddress = TokenContractAddress, Params = createInput.ToByteString(), ExpiredTime = timestamp ?? BlockTimeProvider.GetBlockTime().AddSeconds(1000), - OrganizationAddress = organizationAddress + OrganizationAddress = organizationAddress, + Title = "Create token: NEW", + Description = "Create a new token named NEW." }; ReferendumContractStub = GetReferendumContractTester(proposalKeyPair); var proposal = await ReferendumContractStub.CreateProposal.SendAsync(createProposalInput); diff --git a/test/AElf.Contracts.TestBase.Tests/AElf.Contracts.TestBase.Tests.csproj b/test/AElf.Contracts.TestBase.Tests/AElf.Contracts.TestBase.Tests.csproj index 134f6b7250..63bac56eb0 100644 --- a/test/AElf.Contracts.TestBase.Tests/AElf.Contracts.TestBase.Tests.csproj +++ b/test/AElf.Contracts.TestBase.Tests/AElf.Contracts.TestBase.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -23,8 +23,8 @@ - - + + false Contract @@ -42,5 +42,5 @@ - + diff --git a/test/AElf.Contracts.TestBase/AElf.Contracts.TestBase.csproj b/test/AElf.Contracts.TestBase/AElf.Contracts.TestBase.csproj index 2f987b9204..1ad7c881a8 100644 --- a/test/AElf.Contracts.TestBase/AElf.Contracts.TestBase.csproj +++ b/test/AElf.Contracts.TestBase/AElf.Contracts.TestBase.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -15,7 +15,7 @@ Contract PreserveNewest - + false Contract @@ -28,17 +28,17 @@ - - - - - - - - - - - + + + + + + + + + + + false Contract diff --git a/test/AElf.Contracts.TestContract.A/AElf.Contracts.TestContract.A.csproj b/test/AElf.Contracts.TestContract.A/AElf.Contracts.TestContract.A.csproj index 2d93fecc34..b16dce2ac5 100644 --- a/test/AElf.Contracts.TestContract.A/AElf.Contracts.TestContract.A.csproj +++ b/test/AElf.Contracts.TestContract.A/AElf.Contracts.TestContract.A.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -9,7 +9,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.B/AElf.Contracts.TestContract.B.csproj b/test/AElf.Contracts.TestContract.B/AElf.Contracts.TestContract.B.csproj index 3315de616a..443237c2f5 100644 --- a/test/AElf.Contracts.TestContract.B/AElf.Contracts.TestContract.B.csproj +++ b/test/AElf.Contracts.TestContract.B/AElf.Contracts.TestContract.B.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -9,7 +9,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.BasicFunction/AElf.Contracts.TestContract.BasicFunction.csproj b/test/AElf.Contracts.TestContract.BasicFunction/AElf.Contracts.TestContract.BasicFunction.csproj index a126d734c2..0aa5cb2dee 100644 --- a/test/AElf.Contracts.TestContract.BasicFunction/AElf.Contracts.TestContract.BasicFunction.csproj +++ b/test/AElf.Contracts.TestContract.BasicFunction/AElf.Contracts.TestContract.BasicFunction.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 1.2.0 AElf.Contracts.TestContract.BasicFunction diff --git a/test/AElf.Contracts.TestContract.BasicFunctionWithParallel/AElf.Contracts.TestContract.BasicFunctionWithParallel.csproj b/test/AElf.Contracts.TestContract.BasicFunctionWithParallel/AElf.Contracts.TestContract.BasicFunctionWithParallel.csproj index af22ae709f..4b5cbe53e4 100644 --- a/test/AElf.Contracts.TestContract.BasicFunctionWithParallel/AElf.Contracts.TestContract.BasicFunctionWithParallel.csproj +++ b/test/AElf.Contracts.TestContract.BasicFunctionWithParallel/AElf.Contracts.TestContract.BasicFunctionWithParallel.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.BasicFunctionWithParallel @@ -14,7 +14,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.BasicSecurity/AElf.Contracts.TestContract.BasicSecurity.csproj b/test/AElf.Contracts.TestContract.BasicSecurity/AElf.Contracts.TestContract.BasicSecurity.csproj index e95c2af876..01305ab328 100644 --- a/test/AElf.Contracts.TestContract.BasicSecurity/AElf.Contracts.TestContract.BasicSecurity.csproj +++ b/test/AElf.Contracts.TestContract.BasicSecurity/AElf.Contracts.TestContract.BasicSecurity.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.BasicSecurity 1.3.0 diff --git a/test/AElf.Contracts.TestContract.BasicUpdate/AElf.Contracts.TestContract.BasicUpdate.csproj b/test/AElf.Contracts.TestContract.BasicUpdate/AElf.Contracts.TestContract.BasicUpdate.csproj index 4fc971a3c3..8d26667737 100644 --- a/test/AElf.Contracts.TestContract.BasicUpdate/AElf.Contracts.TestContract.BasicUpdate.csproj +++ b/test/AElf.Contracts.TestContract.BasicUpdate/AElf.Contracts.TestContract.BasicUpdate.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.BasicUpdate 1.3.0 @@ -15,7 +15,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.BigIntValue/AElf.Contracts.TestContract.BigIntValue.csproj b/test/AElf.Contracts.TestContract.BigIntValue/AElf.Contracts.TestContract.BigIntValue.csproj index 0de8c68964..0049e79e86 100644 --- a/test/AElf.Contracts.TestContract.BigIntValue/AElf.Contracts.TestContract.BigIntValue.csproj +++ b/test/AElf.Contracts.TestContract.BigIntValue/AElf.Contracts.TestContract.BigIntValue.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Contracts.TestContract.BigIntValue AElf.Contracts.TestContract.BigIntValue @@ -15,7 +15,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.C/AElf.Contracts.TestContract.C.csproj b/test/AElf.Contracts.TestContract.C/AElf.Contracts.TestContract.C.csproj index 9c006d0980..23cedffd2a 100644 --- a/test/AElf.Contracts.TestContract.C/AElf.Contracts.TestContract.C.csproj +++ b/test/AElf.Contracts.TestContract.C/AElf.Contracts.TestContract.C.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -9,7 +9,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.DApp/AElf.Contracts.TestContract.DApp.csproj b/test/AElf.Contracts.TestContract.DApp/AElf.Contracts.TestContract.DApp.csproj index 055e91deb0..a0991a0dce 100644 --- a/test/AElf.Contracts.TestContract.DApp/AElf.Contracts.TestContract.DApp.csproj +++ b/test/AElf.Contracts.TestContract.DApp/AElf.Contracts.TestContract.DApp.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -13,7 +13,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.Events/AElf.Contracts.TestContract.Events.csproj b/test/AElf.Contracts.TestContract.Events/AElf.Contracts.TestContract.Events.csproj index 55554c6d93..f92b7644b8 100644 --- a/test/AElf.Contracts.TestContract.Events/AElf.Contracts.TestContract.Events.csproj +++ b/test/AElf.Contracts.TestContract.Events/AElf.Contracts.TestContract.Events.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.Events @@ -27,7 +27,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.MethodCallThreshold/AElf.Contracts.TestContract.MethodCallThreshold.csproj b/test/AElf.Contracts.TestContract.MethodCallThreshold/AElf.Contracts.TestContract.MethodCallThreshold.csproj index 0d545b6fec..ab554493ac 100644 --- a/test/AElf.Contracts.TestContract.MethodCallThreshold/AElf.Contracts.TestContract.MethodCallThreshold.csproj +++ b/test/AElf.Contracts.TestContract.MethodCallThreshold/AElf.Contracts.TestContract.MethodCallThreshold.csproj @@ -1,14 +1,14 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.MethodCallThreshold AElf.Contracts.TestContract.MethodCallThreshold false - + diff --git a/test/AElf.Contracts.TestContract.MockParliament/AElf.Contracts.TestContract.MockParliament.csproj b/test/AElf.Contracts.TestContract.MockParliament/AElf.Contracts.TestContract.MockParliament.csproj index b9228e40c9..8aaf0217fd 100644 --- a/test/AElf.Contracts.TestContract.MockParliament/AElf.Contracts.TestContract.MockParliament.csproj +++ b/test/AElf.Contracts.TestContract.MockParliament/AElf.Contracts.TestContract.MockParliament.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 1.2.0 AElf.Contracts.TestContract.MockParliament AElf.Contracts.TestContract.MockParliament diff --git a/test/AElf.Contracts.TestContract.Performance/AElf.Contracts.TestContract.Performance.csproj b/test/AElf.Contracts.TestContract.Performance/AElf.Contracts.TestContract.Performance.csproj index b7f3170b75..b01b79b009 100644 --- a/test/AElf.Contracts.TestContract.Performance/AElf.Contracts.TestContract.Performance.csproj +++ b/test/AElf.Contracts.TestContract.Performance/AElf.Contracts.TestContract.Performance.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.Performance @@ -10,7 +10,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.RandomNumberProvider/AElf.Contracts.TestContract.RandomNumberProvider.csproj b/test/AElf.Contracts.TestContract.RandomNumberProvider/AElf.Contracts.TestContract.RandomNumberProvider.csproj index 7a8ce3c515..cf77b1697c 100644 --- a/test/AElf.Contracts.TestContract.RandomNumberProvider/AElf.Contracts.TestContract.RandomNumberProvider.csproj +++ b/test/AElf.Contracts.TestContract.RandomNumberProvider/AElf.Contracts.TestContract.RandomNumberProvider.csproj @@ -1,14 +1,14 @@ - + - net6.0 + net8.0 AElf.Contracts.TestContract.RandomNumberProvider AElf.Contracts.TestContract.RandomNumberProvider false - + diff --git a/test/AElf.Contracts.TestContract.ResourceSpender/AElf.Contracts.TestContract.ResourceSpender.csproj b/test/AElf.Contracts.TestContract.ResourceSpender/AElf.Contracts.TestContract.ResourceSpender.csproj index 0576361b4c..750aacbc5d 100644 --- a/test/AElf.Contracts.TestContract.ResourceSpender/AElf.Contracts.TestContract.ResourceSpender.csproj +++ b/test/AElf.Contracts.TestContract.ResourceSpender/AElf.Contracts.TestContract.ResourceSpender.csproj @@ -1,14 +1,14 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.ResourceSpender AElf.Contracts.TestContract.ResourceSpender false - + diff --git a/test/AElf.Contracts.TestContract.Tests/AElf.Contracts.TestContract.Tests.csproj b/test/AElf.Contracts.TestContract.Tests/AElf.Contracts.TestContract.Tests.csproj index e2b3567e17..b38736f190 100644 --- a/test/AElf.Contracts.TestContract.Tests/AElf.Contracts.TestContract.Tests.csproj +++ b/test/AElf.Contracts.TestContract.Tests/AElf.Contracts.TestContract.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contract.TestContract false @@ -17,7 +17,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -50,8 +50,8 @@ Contract PreserveNewest - - + + false Contract @@ -163,7 +163,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.TransactionFeeCharging/AElf.Contracts.TestContract.TransactionFeeCharging.csproj b/test/AElf.Contracts.TestContract.TransactionFeeCharging/AElf.Contracts.TestContract.TransactionFeeCharging.csproj index 3671ada17c..db9f5b986b 100644 --- a/test/AElf.Contracts.TestContract.TransactionFeeCharging/AElf.Contracts.TestContract.TransactionFeeCharging.csproj +++ b/test/AElf.Contracts.TestContract.TransactionFeeCharging/AElf.Contracts.TestContract.TransactionFeeCharging.csproj @@ -1,14 +1,14 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.TransactionFeeCharging AElf.Contracts.TestContract.TransactionFeeCharging false - + diff --git a/test/AElf.Contracts.TestContract.TransactionFees/AElf.Contracts.TestContract.TransactionFees.csproj b/test/AElf.Contracts.TestContract.TransactionFees/AElf.Contracts.TestContract.TransactionFees.csproj index 80cbb8a162..cc48a779b2 100644 --- a/test/AElf.Contracts.TestContract.TransactionFees/AElf.Contracts.TestContract.TransactionFees.csproj +++ b/test/AElf.Contracts.TestContract.TransactionFees/AElf.Contracts.TestContract.TransactionFees.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Contracts.TestContract.TransactionFees @@ -11,7 +11,7 @@ - + diff --git a/test/AElf.Contracts.TestContract.VirtualAddress/AElf.Contracts.TestContract.VirtualAddress.csproj b/test/AElf.Contracts.TestContract.VirtualAddress/AElf.Contracts.TestContract.VirtualAddress.csproj index 79dacdf5f2..ea78dda337 100644 --- a/test/AElf.Contracts.TestContract.VirtualAddress/AElf.Contracts.TestContract.VirtualAddress.csproj +++ b/test/AElf.Contracts.TestContract.VirtualAddress/AElf.Contracts.TestContract.VirtualAddress.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Contracts.TestContract.VirtualAddress AElf.Contracts.TestContract.VirtualAddress false diff --git a/test/AElf.Contracts.TestContract.VirtualTransactionEvent/AElf.Contracts.TestContract.VirtualTransactionEvent.csproj b/test/AElf.Contracts.TestContract.VirtualTransactionEvent/AElf.Contracts.TestContract.VirtualTransactionEvent.csproj index 01cbf1667c..2f4b9607e0 100644 --- a/test/AElf.Contracts.TestContract.VirtualTransactionEvent/AElf.Contracts.TestContract.VirtualTransactionEvent.csproj +++ b/test/AElf.Contracts.TestContract.VirtualTransactionEvent/AElf.Contracts.TestContract.VirtualTransactionEvent.csproj @@ -1,8 +1,8 @@ - + - net6.0 + net8.0 AElf.Contracts.TestContract.VirtualTransactionEvent AElf.Contracts.TestContract.VirtualTransactionEvent false diff --git a/test/AElf.Contracts.TestContract.Vote/AElf.Contracts.TestContract.Vote.csproj b/test/AElf.Contracts.TestContract.Vote/AElf.Contracts.TestContract.Vote.csproj index 2924bb78db..bac61a35f4 100644 --- a/test/AElf.Contracts.TestContract.Vote/AElf.Contracts.TestContract.Vote.csproj +++ b/test/AElf.Contracts.TestContract.Vote/AElf.Contracts.TestContract.Vote.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 1.1.0 diff --git a/test/AElf.Contracts.TokenConverter.Internal.Tests/AElf.Contracts.TokenConverter.Internal.Tests.csproj b/test/AElf.Contracts.TokenConverter.Internal.Tests/AElf.Contracts.TokenConverter.Internal.Tests.csproj index d8ff4f55d0..87112d8b29 100644 --- a/test/AElf.Contracts.TokenConverter.Internal.Tests/AElf.Contracts.TokenConverter.Internal.Tests.csproj +++ b/test/AElf.Contracts.TokenConverter.Internal.Tests/AElf.Contracts.TokenConverter.Internal.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -20,7 +20,7 @@ - + diff --git a/test/AElf.Contracts.TokenConverter.Tests/AElf.Contracts.TokenConverter.Tests.csproj b/test/AElf.Contracts.TokenConverter.Tests/AElf.Contracts.TokenConverter.Tests.csproj index 551170282f..27099aa8ec 100644 --- a/test/AElf.Contracts.TokenConverter.Tests/AElf.Contracts.TokenConverter.Tests.csproj +++ b/test/AElf.Contracts.TokenConverter.Tests/AElf.Contracts.TokenConverter.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Contracts.TokenConverter false @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -24,8 +24,8 @@ - - + + @@ -79,5 +79,5 @@ - + diff --git a/test/AElf.Contracts.TokenHolder.Tests/AElf.Contracts.TokenHolder.Tests.csproj b/test/AElf.Contracts.TokenHolder.Tests/AElf.Contracts.TokenHolder.Tests.csproj index 92957ed179..6049bacb46 100644 --- a/test/AElf.Contracts.TokenHolder.Tests/AElf.Contracts.TokenHolder.Tests.csproj +++ b/test/AElf.Contracts.TokenHolder.Tests/AElf.Contracts.TokenHolder.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Contracts.TokenHolder false diff --git a/test/AElf.Contracts.VirtualTransactionEventContract.Tests/AElf.Contracts.VirtualTransactionEventContract.Tests.csproj b/test/AElf.Contracts.VirtualTransactionEventContract.Tests/AElf.Contracts.VirtualTransactionEventContract.Tests.csproj index a2bcf0cb45..237875d951 100644 --- a/test/AElf.Contracts.VirtualTransactionEventContract.Tests/AElf.Contracts.VirtualTransactionEventContract.Tests.csproj +++ b/test/AElf.Contracts.VirtualTransactionEventContract.Tests/AElf.Contracts.VirtualTransactionEventContract.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Contracts.TestContract.VirtualTransactionEvent false diff --git a/test/AElf.Contracts.Vote.AEDPoSExtension.Tests/AElf.Contracts.Vote.AEDPoSExtension.Tests.csproj b/test/AElf.Contracts.Vote.AEDPoSExtension.Tests/AElf.Contracts.Vote.AEDPoSExtension.Tests.csproj index 48c97757ba..7014e31396 100644 --- a/test/AElf.Contracts.Vote.AEDPoSExtension.Tests/AElf.Contracts.Vote.AEDPoSExtension.Tests.csproj +++ b/test/AElf.Contracts.Vote.AEDPoSExtension.Tests/AElf.Contracts.Vote.AEDPoSExtension.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Contract.Vote false @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -24,8 +24,8 @@ - - + + diff --git a/test/AElf.Contracts.Vote.Tests/AElf.Contracts.Vote.Tests.csproj b/test/AElf.Contracts.Vote.Tests/AElf.Contracts.Vote.Tests.csproj index 5ad16fa9b5..f6cc22c50d 100644 --- a/test/AElf.Contracts.Vote.Tests/AElf.Contracts.Vote.Tests.csproj +++ b/test/AElf.Contracts.Vote.Tests/AElf.Contracts.Vote.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Contract.Vote false @@ -14,7 +14,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -27,13 +27,13 @@ - - - - - - - + + + + + + + false Contract diff --git a/test/AElf.Core.Tests/AElf.Core.Tests.csproj b/test/AElf.Core.Tests/AElf.Core.Tests.csproj index 78cf86ca08..737e5851d7 100644 --- a/test/AElf.Core.Tests/AElf.Core.Tests.csproj +++ b/test/AElf.Core.Tests/AElf.Core.Tests.csproj @@ -1,13 +1,13 @@  - net6.0 + net8.0 AElf false - + @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers - + all diff --git a/test/AElf.CrossChain.Core.Tests/AElf.CrossChain.Core.Tests.csproj b/test/AElf.CrossChain.Core.Tests/AElf.CrossChain.Core.Tests.csproj index 93e998483b..21b37bf8ab 100644 --- a/test/AElf.CrossChain.Core.Tests/AElf.CrossChain.Core.Tests.csproj +++ b/test/AElf.CrossChain.Core.Tests/AElf.CrossChain.Core.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.CrossChain false @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -22,9 +22,9 @@ - - - + + + @@ -44,5 +44,5 @@ Protobuf\Proto\cross_chain_contract_impl.proto - + diff --git a/test/AElf.CrossChain.Grpc.Tests/AElf.CrossChain.Grpc.Tests.csproj b/test/AElf.CrossChain.Grpc.Tests/AElf.CrossChain.Grpc.Tests.csproj index ff92a0a8f1..6f74926793 100644 --- a/test/AElf.CrossChain.Grpc.Tests/AElf.CrossChain.Grpc.Tests.csproj +++ b/test/AElf.CrossChain.Grpc.Tests/AElf.CrossChain.Grpc.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.CrossChain.Grpc false @@ -9,9 +9,9 @@ all runtime; build; native; contentfiles; analyzers - + - + all @@ -23,7 +23,7 @@ - - + + diff --git a/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj b/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj index 6665195b02..fc8e6ffb0f 100644 --- a/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj +++ b/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj @@ -1,12 +1,12 @@  - net6.0 + net8.0 AElf.CrossChain false - + all runtime; build; native; contentfiles; analyzers @@ -24,9 +24,9 @@ - - - + + + diff --git a/test/AElf.Cryptography.Tests/AElf.Cryptography.Tests.csproj b/test/AElf.Cryptography.Tests/AElf.Cryptography.Tests.csproj index 7ef8543522..74dcc8734d 100644 --- a/test/AElf.Cryptography.Tests/AElf.Cryptography.Tests.csproj +++ b/test/AElf.Cryptography.Tests/AElf.Cryptography.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false diff --git a/test/AElf.Cryptography.Tests/CryptoHelperTests.cs b/test/AElf.Cryptography.Tests/CryptoHelperTests.cs index 7ec4e7c59e..4b5d2915d7 100644 --- a/test/AElf.Cryptography.Tests/CryptoHelperTests.cs +++ b/test/AElf.Cryptography.Tests/CryptoHelperTests.cs @@ -2,9 +2,8 @@ using System.Text; using AElf.Cryptography.Exceptions; using AElf.Types; -using Org.BouncyCastle.Utilities.Encoders; +using Org.BouncyCastle.Crypto; using Shouldly; -using Virgil.Crypto; using Xunit; namespace AElf.Cryptography.Tests; @@ -100,30 +99,12 @@ public void Decrypt_Message_Test() // Bob decrypt the message. var decrypt = CryptoHelper.DecryptMessage(alice.PublicKey, bob.PrivateKey, cipherText); - Assert.True(decrypt.BytesEqual(plainText)); + decrypt.ShouldBe(plainText); // Sam can't decrypt this message. var func = new Func(() => CryptoHelper.DecryptMessage(alice.PublicKey, sam.PrivateKey, cipherText)); - Assert.Throws(func); - } - - [Fact] - public void Ecdh_Test() - { - var alice = CryptoHelper.GenerateKeyPair(); - var bob = CryptoHelper.GenerateKeyPair(); - - var ecdhKey1 = CryptoHelper.Ecdh(alice.PrivateKey, bob.PublicKey); - var ecdhKey2 = CryptoHelper.Ecdh(bob.PrivateKey, alice.PublicKey); - - Assert.Equal(ecdhKey1.ToHex(), ecdhKey2.ToHex()); - } - - [Fact] - public void Ecdh_BadArgument_ShouldThrowException() - { - Assert.Throws(() => CryptoHelper.Ecdh(new byte[32], new byte[33])); + Assert.Throws(func); } [Fact] diff --git a/test/AElf.Database.Tests/AElf.Database.Tests.csproj b/test/AElf.Database.Tests/AElf.Database.Tests.csproj index af0016902d..fd1be28a2e 100644 --- a/test/AElf.Database.Tests/AElf.Database.Tests.csproj +++ b/test/AElf.Database.Tests/AElf.Database.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false @@ -9,7 +9,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -21,7 +21,7 @@ - - + + \ No newline at end of file diff --git a/test/AElf.EconomicSystem.Tests/AElf.EconomicSystem.Tests.csproj b/test/AElf.EconomicSystem.Tests/AElf.EconomicSystem.Tests.csproj index 0b450dee06..80a9edf1f9 100644 --- a/test/AElf.EconomicSystem.Tests/AElf.EconomicSystem.Tests.csproj +++ b/test/AElf.EconomicSystem.Tests/AElf.EconomicSystem.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -14,7 +14,7 @@ all runtime; build; native; contentfiles; analyzers - + all @@ -23,7 +23,7 @@ - - + + diff --git a/test/AElf.GovernmentSystem.Tests/AElf.GovernmentSystem.Tests.csproj b/test/AElf.GovernmentSystem.Tests/AElf.GovernmentSystem.Tests.csproj index 966b67b28e..0e42f91fb2 100644 --- a/test/AElf.GovernmentSystem.Tests/AElf.GovernmentSystem.Tests.csproj +++ b/test/AElf.GovernmentSystem.Tests/AElf.GovernmentSystem.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -14,7 +14,7 @@ all runtime; build; native; contentfiles; analyzers - + all @@ -23,8 +23,8 @@ - - + + diff --git a/test/AElf.Kernel.ChainController.Tests/AElf.Kernel.ChainController.Tests.csproj b/test/AElf.Kernel.ChainController.Tests/AElf.Kernel.ChainController.Tests.csproj index b6137fa2b3..d6b52e47ed 100644 --- a/test/AElf.Kernel.ChainController.Tests/AElf.Kernel.ChainController.Tests.csproj +++ b/test/AElf.Kernel.ChainController.Tests/AElf.Kernel.ChainController.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Kernel.ChainController false @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -22,7 +22,7 @@ - - + + diff --git a/test/AElf.Kernel.CodeCheck.Tests/AElf.Kernel.CodeCheck.Tests.csproj b/test/AElf.Kernel.CodeCheck.Tests/AElf.Kernel.CodeCheck.Tests.csproj index 050b715175..c36b8f08c6 100644 --- a/test/AElf.Kernel.CodeCheck.Tests/AElf.Kernel.CodeCheck.Tests.csproj +++ b/test/AElf.Kernel.CodeCheck.Tests/AElf.Kernel.CodeCheck.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Kernel.CodeCheck diff --git a/test/AElf.Kernel.CodeCheck.Tests/Application/CodeCheckJobProcessorTests.cs b/test/AElf.Kernel.CodeCheck.Tests/Application/CodeCheckJobProcessorTests.cs index 693faf3d8e..48bd37750d 100644 --- a/test/AElf.Kernel.CodeCheck.Tests/Application/CodeCheckJobProcessorTests.cs +++ b/test/AElf.Kernel.CodeCheck.Tests/Application/CodeCheckJobProcessorTests.cs @@ -65,7 +65,7 @@ public async Task CodeCheckTest(bool isUserContract) if (isUserContract) { - var codeCheckProposals = _codeCheckProposalProvider.GetAllProposals(); + var codeCheckProposals = _codeCheckProposalProvider.GetAllProposals().ToList(); codeCheckProposals.Count.ShouldBe(1); codeCheckProposals[0].ProposalId.ShouldBe(job.CodeCheckProposalId); codeCheckProposals[0].ProposedContractInputHash.ShouldBe(job.ProposedContractInputHash); @@ -103,7 +103,7 @@ public async Task CodeCheck_Failed_Test() var notApprovedProposalIdList = _proposalProvider.GetAllProposals(); notApprovedProposalIdList.Count.ShouldBe(0); - var codeCheckProposals = _codeCheckProposalProvider.GetAllProposals(); + var codeCheckProposals = _codeCheckProposalProvider.GetAllProposals().ToList(); codeCheckProposals.Count.ShouldBe(0); var codeHashExists = _checkedCodeHashProvider.IsCodeHashExists(new BlockIndex @@ -143,7 +143,7 @@ public async Task CodeCheck_Parallel_Test() var notApprovedProposalIdList = _proposalProvider.GetAllProposals(); notApprovedProposalIdList.Count.ShouldBe(jobs.Count); - var codeCheckProposals = _codeCheckProposalProvider.GetAllProposals(); + var codeCheckProposals = _codeCheckProposalProvider.GetAllProposals().ToList(); codeCheckProposals.Count.ShouldBe(jobs.Count); foreach (var codeHashExists in jobs.Select(job => _checkedCodeHashProvider.IsCodeHashExists(new BlockIndex diff --git a/test/AElf.Kernel.CodeCheck.Tests/Infrastructure/CodeCheckProposalProviderTests.cs b/test/AElf.Kernel.CodeCheck.Tests/Infrastructure/CodeCheckProposalProviderTests.cs index a6239107be..477915f298 100644 --- a/test/AElf.Kernel.CodeCheck.Tests/Infrastructure/CodeCheckProposalProviderTests.cs +++ b/test/AElf.Kernel.CodeCheck.Tests/Infrastructure/CodeCheckProposalProviderTests.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Threading.Tasks; using AElf.Kernel.CodeCheck.Tests; using Shouldly; @@ -20,7 +21,7 @@ public async Task ProposalTest() var proposalId = HashHelper.ComputeFrom("ProposalId"); var proposedContractInputHash = HashHelper.ComputeFrom("ProposedContractInputHash"); var blockHeight = 10; - var proposalList = _codeCheckProposalProvider.GetAllProposals(); + var proposalList = _codeCheckProposalProvider.GetAllProposals().ToList(); proposalList.ShouldBeEmpty(); var getHeightResult = _codeCheckProposalProvider.TryGetProposalCreatedHeight(proposalId, out var createdHeight); @@ -28,7 +29,7 @@ public async Task ProposalTest() createdHeight.ShouldBe(0); _codeCheckProposalProvider.AddProposal(proposalId, proposedContractInputHash, blockHeight); - proposalList = _codeCheckProposalProvider.GetAllProposals(); + proposalList = _codeCheckProposalProvider.GetAllProposals().ToList(); proposalList.Count.ShouldBe(1); proposalList[0].BlockHeight.ShouldBe(blockHeight); proposalList[0].ProposalId.ShouldBe(proposalId); @@ -40,7 +41,7 @@ public async Task ProposalTest() var lowerHeight = blockHeight - 1; _codeCheckProposalProvider.AddProposal(proposalId, proposedContractInputHash, lowerHeight); - proposalList = _codeCheckProposalProvider.GetAllProposals(); + proposalList = _codeCheckProposalProvider.GetAllProposals().ToList(); proposalList.Count.ShouldBe(1); proposalList[0].BlockHeight.ShouldBe(blockHeight); proposalList[0].ProposalId.ShouldBe(proposalId); @@ -52,7 +53,7 @@ public async Task ProposalTest() var higherHeight = blockHeight + 1; _codeCheckProposalProvider.AddProposal(proposalId, proposedContractInputHash, higherHeight); - proposalList = _codeCheckProposalProvider.GetAllProposals(); + proposalList = _codeCheckProposalProvider.GetAllProposals().ToList(); proposalList.Count.ShouldBe(1); proposalList[0].BlockHeight.ShouldBe(higherHeight); proposalList[0].ProposalId.ShouldBe(proposalId); @@ -66,12 +67,12 @@ public async Task ProposalTest() var newBlockHeight = 100; _codeCheckProposalProvider.AddProposal(newProposalId, proposedContractInputHash, newBlockHeight); - proposalList = _codeCheckProposalProvider.GetAllProposals(); + proposalList = _codeCheckProposalProvider.GetAllProposals().ToList(); proposalList.Count.ShouldBe(2); _codeCheckProposalProvider.RemoveProposalById(newProposalId); - proposalList = _codeCheckProposalProvider.GetAllProposals(); + proposalList = _codeCheckProposalProvider.GetAllProposals().ToList(); proposalList.Count.ShouldBe(1); proposalList[0].BlockHeight.ShouldBe(higherHeight); proposalList[0].ProposalId.ShouldBe(proposalId); diff --git a/test/AElf.Kernel.Configuration.Tests/AElf.Kernel.Configuration.Tests.csproj b/test/AElf.Kernel.Configuration.Tests/AElf.Kernel.Configuration.Tests.csproj index 14144cde8b..6be4f0c20c 100644 --- a/test/AElf.Kernel.Configuration.Tests/AElf.Kernel.Configuration.Tests.csproj +++ b/test/AElf.Kernel.Configuration.Tests/AElf.Kernel.Configuration.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -15,7 +15,7 @@ all runtime; build; native; contentfiles; analyzers - + all @@ -45,7 +45,7 @@ Contract PreserveNewest - + diff --git a/test/AElf.Kernel.Consensus.AEDPoS.Tests/AElf.Kernel.Consensus.AEDPoS.Tests.csproj b/test/AElf.Kernel.Consensus.AEDPoS.Tests/AElf.Kernel.Consensus.AEDPoS.Tests.csproj index 5189f1564b..ec2bd1c7e6 100644 --- a/test/AElf.Kernel.Consensus.AEDPoS.Tests/AElf.Kernel.Consensus.AEDPoS.Tests.csproj +++ b/test/AElf.Kernel.Consensus.AEDPoS.Tests/AElf.Kernel.Consensus.AEDPoS.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Kernel.Consensus.DPoS.Tests false @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -24,9 +24,9 @@ - - - + + + diff --git a/test/AElf.Kernel.Consensus.Tests/AElf.Kernel.Consensus.Tests.csproj b/test/AElf.Kernel.Consensus.Tests/AElf.Kernel.Consensus.Tests.csproj index 2f7cd9894d..6e9c018681 100644 --- a/test/AElf.Kernel.Consensus.Tests/AElf.Kernel.Consensus.Tests.csproj +++ b/test/AElf.Kernel.Consensus.Tests/AElf.Kernel.Consensus.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 AElf.Kernel.Consensus false @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -23,12 +23,12 @@ - - - - - - + + + + + + diff --git a/test/AElf.Kernel.Core.Tests/AElf.Kernel.Core.Tests.csproj b/test/AElf.Kernel.Core.Tests/AElf.Kernel.Core.Tests.csproj index 0da9830237..f70d4d2944 100644 --- a/test/AElf.Kernel.Core.Tests/AElf.Kernel.Core.Tests.csproj +++ b/test/AElf.Kernel.Core.Tests/AElf.Kernel.Core.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Kernel AElf.Kernel.Core.Tests false diff --git a/test/AElf.Kernel.FeatureDisable.Tests/AElf.Kernel.FeatureDisable.Tests.csproj b/test/AElf.Kernel.FeatureDisable.Tests/AElf.Kernel.FeatureDisable.Tests.csproj new file mode 100644 index 0000000000..b4e597e5e3 --- /dev/null +++ b/test/AElf.Kernel.FeatureDisable.Tests/AElf.Kernel.FeatureDisable.Tests.csproj @@ -0,0 +1,85 @@ + + + + net8.0 + enable + enable + false + AElf.Kernel.FeatureDisable.Tests + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + false + Contract + PreserveNewest + + + false + Contract + PreserveNewest + + + False + Contract + PreserveNewest + + + + + + + + + Protobuf\Proto\authority_info.proto + + + + + Protobuf\Proto\acs3.proto + + + Protobuf\Proto\acs4.proto + + + Protobuf\Proto\acs6.proto + + + Protobuf\Proto\reference\acs10.proto + + + Protobuf\Proto\reference\acs11.proto + + + + + Protobuf\Proto\aedpos_contract.proto + + + Protobuf\Proto\aedpos_contract_impl.proto + + + Protobuf\Proto\parliament_contract.proto + + + Protobuf\Proto\parliament_contract_impl.proto + + + Protobuf\Proto\configuration_contract.proto + + + + diff --git a/test/AElf.Kernel.FeatureDisable.Tests/FeatureDisableTest.cs b/test/AElf.Kernel.FeatureDisable.Tests/FeatureDisableTest.cs new file mode 100644 index 0000000000..2343599aeb --- /dev/null +++ b/test/AElf.Kernel.FeatureDisable.Tests/FeatureDisableTest.cs @@ -0,0 +1,55 @@ +using AElf.Contracts.Configuration; +using AElf.CSharp.Core.Extension; +using AElf.Kernel.Blockchain.Application; +using AElf.Kernel.FeatureDisable.Core; +using AElf.Standards.ACS3; +using AElf.TestBase; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; +using Shouldly; +using Xunit; + +namespace AElf.Kernel.FeatureDisable.Tests; + +public class FeatureDisableTest : KernelFeatureDisableTestBase +{ + private readonly IMockService _mockService; + private readonly IBlockchainService _blockchainService; + + public FeatureDisableTest() + { + _mockService = GetRequiredService(); + _blockchainService = GetRequiredService(); + } + + [Fact] + public async Task IsFeatureDisabledTest() + { + await DeployContractsAsync(); + await ConfigDisabledFeaturesAsync("FeatureA, FeatureB, FeatureBAndC"); + (await _mockService.IsFeatureADisabledAsync()).ShouldBeTrue(); + (await _mockService.IsFeatureBDisabledAsync()).ShouldBeTrue(); + (await _mockService.IsFeatureCDisabledAsync()).ShouldBeTrue(); + (await _mockService.IsFeatureDDisabledAsync()).ShouldBeFalse(); + } + + private async Task ConfigDisabledFeaturesAsync(string disableFeatureNames) + { + var chain = await _blockchainService.GetChainAsync(); + await _blockchainService.SetIrreversibleBlockAsync(chain, chain.BestChainHeight, chain.BestChainHash); + var proposalId = (await ParliamentContractStub.CreateProposal.SendAsync(new CreateProposalInput + { + ContractMethodName = "SetConfiguration", + ExpiredTime = TimestampHelper.GetUtcNow().AddDays(1), + Params = new SetConfigurationInput + { + Key = FeatureDisableConstants.FeatureDisableConfigurationName, + Value = new StringValue { Value = disableFeatureNames }.ToByteString() + }.ToByteString(), + ToAddress = ConfigurationContractAddress, + OrganizationAddress = await ParliamentContractStub.GetDefaultOrganizationAddress.CallAsync(new Empty()) + })).Output; + await ParliamentContractStub.Approve.SendAsync(proposalId); + await ParliamentContractStub.Release.SendAsync(proposalId); + } +} \ No newline at end of file diff --git a/test/AElf.Kernel.FeatureDisable.Tests/FeatureDisableTestModule.cs b/test/AElf.Kernel.FeatureDisable.Tests/FeatureDisableTestModule.cs new file mode 100644 index 0000000000..63bd29b6ee --- /dev/null +++ b/test/AElf.Kernel.FeatureDisable.Tests/FeatureDisableTestModule.cs @@ -0,0 +1,25 @@ +using AElf.ContractTestKit; +using AElf.Kernel.SmartContract; +using AElf.Kernel.SmartContract.Application; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Volo.Abp.Modularity; + +namespace AElf.Kernel.FeatureDisable.Tests; + +[DependsOn( + typeof(ContractTestModule), + typeof(FeatureDisableAElfModule), + typeof(KernelAElfModule))] +public class FeatureDisableTestModule : ContractTestModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddSingleton(typeof(LogEventProcessingService<>)); + context.Services + .Replace(ServiceDescriptor + .Singleton, + OptionalLogEventProcessingService>()); + Configure(o => o.ContractDeploymentAuthorityRequired = false); + } +} \ No newline at end of file diff --git a/test/AElf.Kernel.FeatureDisable.Tests/IMockService.cs b/test/AElf.Kernel.FeatureDisable.Tests/IMockService.cs new file mode 100644 index 0000000000..ee837e1ad5 --- /dev/null +++ b/test/AElf.Kernel.FeatureDisable.Tests/IMockService.cs @@ -0,0 +1,44 @@ +using AElf.Kernel.FeatureDisable.Core; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.FeatureDisable.Tests; + +public interface IMockService +{ + Task IsFeatureADisabledAsync(); + Task IsFeatureBDisabledAsync(); + Task IsFeatureCDisabledAsync(); + Task IsFeatureDDisabledAsync(); +} + +public class MockService : IMockService, ITransientDependency +{ + private readonly IFeatureDisableService _featureDisableService; + + public MockService(IFeatureDisableService featureDisableService) + { + _featureDisableService = featureDisableService; + } + + public Task IsFeatureADisabledAsync() + { + return _featureDisableService.IsFeatureDisabledAsync("FeatureA"); + } + + public Task IsFeatureBDisabledAsync() + { + return _featureDisableService.IsFeatureDisabledAsync("FeatureB", "FeatureBAndC"); + + } + + public Task IsFeatureCDisabledAsync() + { + return _featureDisableService.IsFeatureDisabledAsync("FeatureC", "FeatureBAndC"); + + } + + public Task IsFeatureDDisabledAsync() + { + return _featureDisableService.IsFeatureDisabledAsync("FeatureD"); + } +} \ No newline at end of file diff --git a/test/AElf.Kernel.FeatureDisable.Tests/KernelFeatureManagerTestBase.cs b/test/AElf.Kernel.FeatureDisable.Tests/KernelFeatureManagerTestBase.cs new file mode 100644 index 0000000000..7a81535514 --- /dev/null +++ b/test/AElf.Kernel.FeatureDisable.Tests/KernelFeatureManagerTestBase.cs @@ -0,0 +1,60 @@ +using AElf.Contracts.Configuration; +using AElf.Contracts.Consensus.AEDPoS; +using AElf.Contracts.Parliament; +using AElf.ContractTestKit; +using AElf.Cryptography.ECDSA; +using AElf.Kernel.Configuration; +using AElf.Kernel.Consensus; +using AElf.Kernel.Proposal; +using AElf.Kernel.SmartContract.Application; +using AElf.Types; +using Google.Protobuf; + +namespace AElf.Kernel.FeatureDisable.Tests; + +public class KernelFeatureDisableTestBase : ContractTestBase +{ + internal ConfigurationContainer.ConfigurationStub ConfigurationStub; + internal ParliamentContractImplContainer.ParliamentContractImplStub ParliamentContractStub; + internal Address ParliamentContractAddress { get; set; } + internal Address ConfigurationContractAddress { get; set; } + internal ECKeyPair DefaultSenderKeyPair => Accounts[0].KeyPair; + + protected async Task DeployContractsAsync() + { + const int category = KernelConstants.CodeCoverageRunnerCategory; + var code = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Configuration")).Value; + OptionalLogEventProcessingService.Enabled = true; + ConfigurationContractAddress = await DeploySystemSmartContract(category, code, + ConfigurationSmartContractAddressNameProvider.Name, DefaultSenderKeyPair); + ConfigurationStub = + GetTester(ConfigurationContractAddress, + DefaultSenderKeyPair); + + var consensusContractCode = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Consensus.AEDPoS")).Value; + var consensusContractAddress = await DeploySystemSmartContract(category, consensusContractCode, + ConsensusSmartContractAddressNameProvider.Name, DefaultSenderKeyPair); + var consensusStub = GetTester(consensusContractAddress, + DefaultSenderKeyPair); + + await consensusStub.FirstRound.SendAsync( + new MinerList + { + Pubkeys = { ByteString.CopyFrom(DefaultSenderKeyPair.PublicKey) } + }.GenerateFirstRoundOfNewTerm(4000, TimestampHelper.GetUtcNow()) + ); + + var parliamentContractCode = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Parliament")).Value; + ParliamentContractAddress = await DeploySystemSmartContract(category, parliamentContractCode, + ParliamentSmartContractAddressNameProvider.Name, DefaultSenderKeyPair); + ParliamentContractStub = GetTester( + ParliamentContractAddress, + DefaultSenderKeyPair); + + await ParliamentContractStub.Initialize.SendAsync(new InitializeInput + { + ProposerAuthorityRequired = true, + PrivilegedProposer = Address.FromPublicKey(DefaultSenderKeyPair.PublicKey) + }); + } +} \ No newline at end of file diff --git a/test/AElf.Kernel.FeatureDisable.Tests/MinerList.cs b/test/AElf.Kernel.FeatureDisable.Tests/MinerList.cs new file mode 100644 index 0000000000..0ef019af8c --- /dev/null +++ b/test/AElf.Kernel.FeatureDisable.Tests/MinerList.cs @@ -0,0 +1,50 @@ +using System.Linq; +using AElf.CSharp.Core.Extension; +using AElf.Types; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; + +namespace AElf.Contracts.Consensus.AEDPoS; + +internal partial class MinerList +{ + public Round GenerateFirstRoundOfNewTerm(int miningInterval, + Timestamp currentBlockTime, long currentRoundNumber = 0, long currentTermNumber = 0) + { + var sortedMiners = + (from obj in Pubkeys + .ToDictionary(miner => miner.ToHex(), miner => miner[0]) + orderby obj.Value descending + select obj.Key).ToList(); + + var round = new Round(); + + for (var i = 0; i < sortedMiners.Count; i++) + { + var minerInRound = new MinerInRound(); + + // The first miner will be the extra block producer of first round of each term. + if (i == 0) minerInRound.IsExtraBlockProducer = true; + + minerInRound.Pubkey = sortedMiners[i]; + minerInRound.Order = i + 1; + minerInRound.ExpectedMiningTime = currentBlockTime.AddMilliseconds(i * miningInterval + miningInterval); + // Should be careful during validation. + minerInRound.PreviousInValue = Hash.Empty; + + round.RealTimeMinersInformation.Add(sortedMiners[i], minerInRound); + } + + round.RoundNumber = currentRoundNumber + 1; + round.TermNumber = currentTermNumber + 1; + round.IsMinerListJustChanged = true; + + return round; + } + + public Hash GetMinersHash() + { + var orderedMiners = Pubkeys.OrderBy(p => p); + return HashHelper.ComputeFrom(orderedMiners.Aggregate("", (current, publicKey) => current + publicKey)); + } +} \ No newline at end of file diff --git a/test/AElf.Kernel.FeatureDisable.Tests/OptionalLogEventProcessingService.cs b/test/AElf.Kernel.FeatureDisable.Tests/OptionalLogEventProcessingService.cs new file mode 100644 index 0000000000..4a5d9a0bb9 --- /dev/null +++ b/test/AElf.Kernel.FeatureDisable.Tests/OptionalLogEventProcessingService.cs @@ -0,0 +1,21 @@ +using AElf.Kernel.Blockchain; +using AElf.Kernel.SmartContract.Application; + +namespace AElf.Kernel.FeatureDisable.Tests; + +public class OptionalLogEventProcessingService : ILogEventProcessingService where T : ILogEventProcessor +{ + private readonly LogEventProcessingService _inner; + + public OptionalLogEventProcessingService(LogEventProcessingService inner) + { + _inner = inner; + } + + public static bool Enabled { get; set; } + + public async Task ProcessAsync(List blockExecutedSets) + { + if (Enabled) await _inner.ProcessAsync(blockExecutedSets); + } +} \ No newline at end of file diff --git a/test/AElf.Kernel.FeatureManager.Tests/AElf.Kernel.FeatureManager.Tests.csproj b/test/AElf.Kernel.FeatureManager.Tests/AElf.Kernel.FeatureManager.Tests.csproj index df20fffd91..d85c33fa68 100644 --- a/test/AElf.Kernel.FeatureManager.Tests/AElf.Kernel.FeatureManager.Tests.csproj +++ b/test/AElf.Kernel.FeatureManager.Tests/AElf.Kernel.FeatureManager.Tests.csproj @@ -1,15 +1,15 @@ - + - net6.0 + net8.0 enable false - - + + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -41,8 +41,8 @@ Contract PreserveNewest - - + + diff --git a/test/AElf.Kernel.FeeCalculation.Tests/AElf.Kernel.FeeCalculation.Tests.csproj b/test/AElf.Kernel.FeeCalculation.Tests/AElf.Kernel.FeeCalculation.Tests.csproj index d61476a858..578295502d 100644 --- a/test/AElf.Kernel.FeeCalculation.Tests/AElf.Kernel.FeeCalculation.Tests.csproj +++ b/test/AElf.Kernel.FeeCalculation.Tests/AElf.Kernel.FeeCalculation.Tests.csproj @@ -1,6 +1,6 @@ - + - net6.0 + net8.0 AElf.Kernel.FeeCalculation false @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -22,7 +22,7 @@ - - + + diff --git a/test/AElf.Kernel.Node.Tests/AElf.Kernel.Node.Tests.csproj b/test/AElf.Kernel.Node.Tests/AElf.Kernel.Node.Tests.csproj index 583e6f2452..2b742c06c2 100644 --- a/test/AElf.Kernel.Node.Tests/AElf.Kernel.Node.Tests.csproj +++ b/test/AElf.Kernel.Node.Tests/AElf.Kernel.Node.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false AElf.Kernel.Node @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -22,8 +22,8 @@ - - - + + + diff --git a/test/AElf.Kernel.Proposal.Tests/AElf.Kernel.Proposal.Tests.csproj b/test/AElf.Kernel.Proposal.Tests/AElf.Kernel.Proposal.Tests.csproj index 7bc3a24986..1dc00fcc5f 100644 --- a/test/AElf.Kernel.Proposal.Tests/AElf.Kernel.Proposal.Tests.csproj +++ b/test/AElf.Kernel.Proposal.Tests/AElf.Kernel.Proposal.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 @@ -14,7 +14,7 @@ all runtime; build; native; contentfiles; analyzers - + all @@ -23,8 +23,8 @@ - - + + diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract.csproj b/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract.csproj index cc88e79370..80703eb7cc 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract.csproj +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.TestContract @@ -10,7 +10,7 @@ true - + diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.csproj b/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.csproj index 572810cff3..025aa71f5e 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.csproj +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests/AElf.Kernel.SmartContract.ExecutionPluginForCallThreshold.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false @@ -13,7 +13,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -25,13 +25,13 @@ - - - - + + + + - + false Contract diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract.csproj b/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract.csproj index d2729b3029..e925a6dcfe 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract.csproj +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.TestContract @@ -10,7 +10,7 @@ true - + diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.csproj b/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.csproj index 8a46bd22dc..c3b35edf1d 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.csproj +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/Service/PlainTransactionExecutingAsPluginService.cs b/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/Service/PlainTransactionExecutingAsPluginService.cs index 2ea2db6654..f43cef0e42 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/Service/PlainTransactionExecutingAsPluginService.cs +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee.Tests/Service/PlainTransactionExecutingAsPluginService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using AElf.Kernel.FeatureDisable.Core; using AElf.Kernel.SmartContract.Application; using AElf.Kernel.SmartContract.Domain; using AElf.Kernel.SmartContract.Infrastructure; @@ -20,8 +21,8 @@ public class PlainTransactionExecutingAsPluginService : PlainTransactionExecutin public PlainTransactionExecutingAsPluginService (ISmartContractExecutiveService smartContractExecutiveService, IEnumerable postPlugins, IEnumerable prePlugins, - ITransactionContextFactory transactionContextFactory) : base( - smartContractExecutiveService, postPlugins, prePlugins, transactionContextFactory) + ITransactionContextFactory transactionContextFactory, IFeatureDisableService featureDisableService) : base( + smartContractExecutiveService, postPlugins, prePlugins, transactionContextFactory, featureDisableService) { _smartContractExecutiveService = smartContractExecutiveService; } diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract.csproj b/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract.csproj index a52621689a..41682307a9 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract.csproj +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.TestContract true @@ -11,7 +11,7 @@ true - + diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.csproj b/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.csproj index 6413e7f543..de9d8be462 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.csproj +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false diff --git a/test/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract.csproj b/test/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract.csproj index 2e31987432..979af2ea9b 100644 --- a/test/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract.csproj +++ b/test/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract/AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract AElf.Kernel.SmartContract.ExecutionPluginForUserContractFee.Tests.TestContract diff --git a/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj b/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj index f900ca7ae4..d3e0c77eea 100644 --- a/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj +++ b/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj @@ -1,17 +1,17 @@  - net6.0 + net8.0 false - - - - - + + + + + - + false Contract @@ -65,8 +65,8 @@ runtime; build; native; contentfiles; analyzers - - + + all diff --git a/test/AElf.Kernel.SmartContract.Shared.Tests/AElf.Kernel.SmartContract.Shared.Tests.csproj b/test/AElf.Kernel.SmartContract.Shared.Tests/AElf.Kernel.SmartContract.Shared.Tests.csproj index 7c886c44f7..3c87021fde 100644 --- a/test/AElf.Kernel.SmartContract.Shared.Tests/AElf.Kernel.SmartContract.Shared.Tests.csproj +++ b/test/AElf.Kernel.SmartContract.Shared.Tests/AElf.Kernel.SmartContract.Shared.Tests.csproj @@ -1,12 +1,12 @@ - + - net6.0 + net8.0 AElf.Kernel.SmartContract.Shared.Tests - + @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + all diff --git a/test/AElf.Kernel.SmartContract.Tests/AElf.Kernel.SmartContract.Tests.csproj b/test/AElf.Kernel.SmartContract.Tests/AElf.Kernel.SmartContract.Tests.csproj index d8848b909f..0dd224e854 100644 --- a/test/AElf.Kernel.SmartContract.Tests/AElf.Kernel.SmartContract.Tests.csproj +++ b/test/AElf.Kernel.SmartContract.Tests/AElf.Kernel.SmartContract.Tests.csproj @@ -1,15 +1,15 @@  - net6.0 + net8.0 AElf.Kernel.SmartContract false - - - - - + + + + + @@ -29,7 +29,7 @@ runtime; build; native; contentfiles; analyzers - + all diff --git a/test/AElf.Kernel.SmartContract.Tests/Application/SmartContractExecutiveServiceTests.cs b/test/AElf.Kernel.SmartContract.Tests/Application/SmartContractExecutiveServiceTests.cs index c75d5d4a53..07eafbf4a8 100644 --- a/test/AElf.Kernel.SmartContract.Tests/Application/SmartContractExecutiveServiceTests.cs +++ b/test/AElf.Kernel.SmartContract.Tests/Application/SmartContractExecutiveServiceTests.cs @@ -190,7 +190,7 @@ public async Task CleanIdleExecutive_Test() }; var executives = new List(); - for (var i = 0; i < 11; i++) + for (var i = 0; i < 51; i++) { var executive = await _smartContractExecutiveService.GetExecutiveAsync(chainContext, address); executives.Add(executive); @@ -199,23 +199,23 @@ public async Task CleanIdleExecutive_Test() foreach (var executive in executives) await _smartContractExecutiveService.PutExecutiveAsync(chainContext, address, executive); _smartContractExecutiveProvider.TryGetValue(address, out pool); - pool.Count.ShouldBe(11); + pool.Count.ShouldBe(51); _smartContractExecutiveService.CleanIdleExecutive(); - pool.Count.ShouldBe(10); + pool.Count.ShouldBe(50); _smartContractExecutiveProvider.TryGetValue(address, out pool); - pool.Count.ShouldBe(10); + pool.Count.ShouldBe(50); pool.TryPeek(out var item); item.LastUsedTime = item.LastUsedTime.AddHours(-2); _smartContractExecutiveService.CleanIdleExecutive(); _smartContractExecutiveProvider.TryGetValue(address, out pool); - pool.Count.ShouldBe(9); + pool.Count.ShouldBe(49); pool.TryPeek(out item); item.LastUsedTime = item.LastUsedTime.AddHours(-2); _smartContractExecutiveService.CleanIdleExecutive(); _smartContractExecutiveProvider.TryGetValue(address, out pool); - pool.Count.ShouldBe(8); + pool.Count.ShouldBe(48); } [Fact] diff --git a/test/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract.csproj b/test/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract.csproj index 9eaaad2806..e819c686e3 100644 --- a/test/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract.csproj +++ b/test/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract/AElf.Kernel.SmartContractExecution.Parallel.Tests.TestContract.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false @@ -13,6 +13,6 @@ - + diff --git a/test/AElf.Kernel.SmartContractExecution.Tests/AElf.Kernel.SmartContractExecution.Tests.csproj b/test/AElf.Kernel.SmartContractExecution.Tests/AElf.Kernel.SmartContractExecution.Tests.csproj index 55cbcd56cf..525376a71a 100644 --- a/test/AElf.Kernel.SmartContractExecution.Tests/AElf.Kernel.SmartContractExecution.Tests.csproj +++ b/test/AElf.Kernel.SmartContractExecution.Tests/AElf.Kernel.SmartContractExecution.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Kernel.SmartContractExecution false @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -22,9 +22,9 @@ - - - + + + diff --git a/test/AElf.Kernel.TestBase/AElf.Kernel.TestBase.csproj b/test/AElf.Kernel.TestBase/AElf.Kernel.TestBase.csproj index 3f97c6eea1..993eeca963 100644 --- a/test/AElf.Kernel.TestBase/AElf.Kernel.TestBase.csproj +++ b/test/AElf.Kernel.TestBase/AElf.Kernel.TestBase.csproj @@ -1,11 +1,11 @@  - net6.0 + net8.0 AElf.Kernel false - - + + diff --git a/test/AElf.Kernel.Tests/AElf.Kernel.Tests.csproj b/test/AElf.Kernel.Tests/AElf.Kernel.Tests.csproj index 9410aa71fb..3c017d6a7c 100644 --- a/test/AElf.Kernel.Tests/AElf.Kernel.Tests.csproj +++ b/test/AElf.Kernel.Tests/AElf.Kernel.Tests.csproj @@ -1,16 +1,16 @@  - net6.0 + net8.0 AElf.Kernel false - - - - - - + + + + + + @@ -18,7 +18,7 @@ runtime; build; native; contentfiles; analyzers - + all diff --git a/test/AElf.Kernel.Token.Tests/AElf.Kernel.Token.Tests.csproj b/test/AElf.Kernel.Token.Tests/AElf.Kernel.Token.Tests.csproj index d0056f5676..6588651a1c 100644 --- a/test/AElf.Kernel.Token.Tests/AElf.Kernel.Token.Tests.csproj +++ b/test/AElf.Kernel.Token.Tests/AElf.Kernel.Token.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 false @@ -14,7 +14,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -27,9 +27,9 @@ - - - + + + diff --git a/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj b/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj index ab3834c03d..144af8c51c 100644 --- a/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj +++ b/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj @@ -1,17 +1,17 @@  - net6.0 + net8.0 AElf.Kernel.TransactionPool false - + all runtime; build; native; contentfiles; analyzers - + all @@ -23,7 +23,7 @@ - - + + \ No newline at end of file diff --git a/test/AElf.Kernel.Types.Tests/AElf.Kernel.Types.Tests.csproj b/test/AElf.Kernel.Types.Tests/AElf.Kernel.Types.Tests.csproj index 35ed188b9e..bf7b9f2962 100644 --- a/test/AElf.Kernel.Types.Tests/AElf.Kernel.Types.Tests.csproj +++ b/test/AElf.Kernel.Types.Tests/AElf.Kernel.Types.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false @@ -9,7 +9,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -21,7 +21,7 @@ - - + + diff --git a/test/AElf.OS.Core.Tests/AElf.OS.Core.Tests.csproj b/test/AElf.OS.Core.Tests/AElf.OS.Core.Tests.csproj index 11e1fe7758..1f6428d77f 100644 --- a/test/AElf.OS.Core.Tests/AElf.OS.Core.Tests.csproj +++ b/test/AElf.OS.Core.Tests/AElf.OS.Core.Tests.csproj @@ -1,12 +1,12 @@  - net6.0 + net8.0 AElf.OS false - - + + @@ -14,7 +14,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -26,5 +26,5 @@ - + diff --git a/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj b/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj index 4ff60eec84..8265c66783 100644 --- a/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj +++ b/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false AElf.OS.Network.Grpc diff --git a/test/AElf.OS.TestBase/AElf.OS.TestBase.csproj b/test/AElf.OS.TestBase/AElf.OS.TestBase.csproj index 1e84ca5e86..f94b070120 100644 --- a/test/AElf.OS.TestBase/AElf.OS.TestBase.csproj +++ b/test/AElf.OS.TestBase/AElf.OS.TestBase.csproj @@ -1,18 +1,18 @@  - net6.0 + net8.0 AElf.OS false - - - - - - - - + + + + + + + + diff --git a/test/AElf.OS.TestBase/MockTxHub.cs b/test/AElf.OS.TestBase/MockTxHub.cs index c7f5d3314d..c4870757c9 100644 --- a/test/AElf.OS.TestBase/MockTxHub.cs +++ b/test/AElf.OS.TestBase/MockTxHub.cs @@ -26,7 +26,8 @@ public MockTxHub(ITransactionManager transactionManager, IBlockchainService bloc _blockchainService = blockchainService; } - public Task GetExecutableTransactionSetAsync(Hash blockHash, int transactionCount = 0) + public Task GetExecutableTransactionSetAsync(Hash blockHash, + int transactionCount) { return Task.FromResult(new ExecutableTransactionSet { diff --git a/test/AElf.OS.Tests/AElf.OS.Tests.csproj b/test/AElf.OS.Tests/AElf.OS.Tests.csproj index 174bf21bb6..001264e0bc 100644 --- a/test/AElf.OS.Tests/AElf.OS.Tests.csproj +++ b/test/AElf.OS.Tests/AElf.OS.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.OS false diff --git a/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj b/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj index 15bada8c30..6f836e139e 100644 --- a/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj +++ b/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj @@ -1,18 +1,18 @@  - net6.0 + net8.0 false 0436 - + all runtime; build; native; contentfiles; analyzers - + all @@ -24,8 +24,8 @@ - - + + diff --git a/test/AElf.Runtime.CSharp.Core.Tests/AElf.Runtime.CSharp.Core.Tests.csproj b/test/AElf.Runtime.CSharp.Core.Tests/AElf.Runtime.CSharp.Core.Tests.csproj index c376b7a839..76bacc1375 100644 --- a/test/AElf.Runtime.CSharp.Core.Tests/AElf.Runtime.CSharp.Core.Tests.csproj +++ b/test/AElf.Runtime.CSharp.Core.Tests/AElf.Runtime.CSharp.Core.Tests.csproj @@ -1,6 +1,6 @@ - + - net6.0 + net8.0 AElf.Runtime.CSharp.Core false @@ -10,7 +10,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -22,10 +22,10 @@ - - - - + + + + diff --git a/test/AElf.Runtime.CSharp.Tests.BadContract/AElf.Runtime.CSharp.Tests.BadContract.csproj b/test/AElf.Runtime.CSharp.Tests.BadContract/AElf.Runtime.CSharp.Tests.BadContract.csproj index f38e72b499..c883a7dd37 100644 --- a/test/AElf.Runtime.CSharp.Tests.BadContract/AElf.Runtime.CSharp.Tests.BadContract.csproj +++ b/test/AElf.Runtime.CSharp.Tests.BadContract/AElf.Runtime.CSharp.Tests.BadContract.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Runtime.CSharp.Tests.BadContract AElf.Runtime.CSharp.Tests.BadContract false @@ -8,8 +8,8 @@ true - - + + diff --git a/test/AElf.Runtime.CSharp.Tests.TestContract/AElf.Runtime.CSharp.Tests.TestContract.csproj b/test/AElf.Runtime.CSharp.Tests.TestContract/AElf.Runtime.CSharp.Tests.TestContract.csproj index 6faf712389..439e856813 100644 --- a/test/AElf.Runtime.CSharp.Tests.TestContract/AElf.Runtime.CSharp.Tests.TestContract.csproj +++ b/test/AElf.Runtime.CSharp.Tests.TestContract/AElf.Runtime.CSharp.Tests.TestContract.csproj @@ -1,12 +1,12 @@  - net6.0 + net8.0 AElf.Runtime.CSharp.Tests.TestContract AElf.Runtime.CSharp.Tests.TestContract false - + diff --git a/test/AElf.Runtime.CSharp.Tests/AElf.Runtime.CSharp.Tests.csproj b/test/AElf.Runtime.CSharp.Tests/AElf.Runtime.CSharp.Tests.csproj index 26738d1e1f..8e4954bf65 100644 --- a/test/AElf.Runtime.CSharp.Tests/AElf.Runtime.CSharp.Tests.csproj +++ b/test/AElf.Runtime.CSharp.Tests/AElf.Runtime.CSharp.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 AElf.Runtime.CSharp false @@ -9,10 +9,10 @@ all runtime; build; native; contentfiles; analyzers - - - - + + + + all runtime; build; native; contentfiles; analyzers @@ -21,29 +21,29 @@ all runtime; build; native; contentfiles; analyzers - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/AElf.Sdk.CSharp.Tests.TestContract/AElf.Sdk.CSharp.Tests.TestContract.csproj b/test/AElf.Sdk.CSharp.Tests.TestContract/AElf.Sdk.CSharp.Tests.TestContract.csproj index 8e292cb90a..ccfcfd29cd 100644 --- a/test/AElf.Sdk.CSharp.Tests.TestContract/AElf.Sdk.CSharp.Tests.TestContract.csproj +++ b/test/AElf.Sdk.CSharp.Tests.TestContract/AElf.Sdk.CSharp.Tests.TestContract.csproj @@ -1,11 +1,11 @@  - net6.0 + net8.0 AElf.Sdk.CSharp.Tests.TestContract2 false - + Protobuf\Proto\reference\acs0.proto diff --git a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj index e666048ed6..b7379a81dc 100644 --- a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj +++ b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj @@ -1,16 +1,16 @@  - net6.0 + net8.0 false - + all runtime; build; native; contentfiles; analyzers - + all @@ -22,12 +22,12 @@ - - + + - - - - + + + + \ No newline at end of file diff --git a/test/AElf.TestBase/AElf.TestBase.csproj b/test/AElf.TestBase/AElf.TestBase.csproj index cf517abde8..a35ba40e35 100644 --- a/test/AElf.TestBase/AElf.TestBase.csproj +++ b/test/AElf.TestBase/AElf.TestBase.csproj @@ -1,20 +1,20 @@  - net6.0 + net8.0 false - + - - - - + + + + - - + + - + diff --git a/test/AElf.Types.Tests/AElf.Types.Tests.csproj b/test/AElf.Types.Tests/AElf.Types.Tests.csproj index f97e75afb0..4d2622f091 100644 --- a/test/AElf.Types.Tests/AElf.Types.Tests.csproj +++ b/test/AElf.Types.Tests/AElf.Types.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false @@ -9,7 +9,7 @@ runtime; build; native; contentfiles; analyzers - + all @@ -21,6 +21,6 @@ - + \ No newline at end of file diff --git a/test/AElf.WebApp.Application.Chain.Tests/AElf.WebApp.Application.Chain.Tests.csproj b/test/AElf.WebApp.Application.Chain.Tests/AElf.WebApp.Application.Chain.Tests.csproj index f629badebd..625df18fbf 100644 --- a/test/AElf.WebApp.Application.Chain.Tests/AElf.WebApp.Application.Chain.Tests.csproj +++ b/test/AElf.WebApp.Application.Chain.Tests/AElf.WebApp.Application.Chain.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 false diff --git a/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj b/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj index d388dbb19d..da690ecf7d 100644 --- a/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj +++ b/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj @@ -1,11 +1,11 @@  - net6.0 + net8.0 false - - + + all runtime; build; native; contentfiles; analyzers @@ -21,8 +21,8 @@ runtime; build; native; contentfiles; analyzers - + - + diff --git a/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj b/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj index 34f640be6b..191105c3d2 100644 --- a/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj +++ b/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj @@ -1,14 +1,14 @@  - net6.0 + net8.0 AElf.WebApp.Application false - - - - + + + + all runtime; build; native; contentfiles; analyzers @@ -16,8 +16,8 @@ - - + +