From fdf61bf3159a2adc860c490c6c77141d9f90926a Mon Sep 17 00:00:00 2001 From: eanzhao Date: Fri, 28 Jun 2024 11:51:00 +0800 Subject: [PATCH 1/8] Enable plugin modules, and commit web api plugin for full nodes. --- AElf.All.sln | 7 +++ src/AElf.Launcher/Startup.cs | 20 ++++--- .../AElf.WebApp.Application.FullNode.csproj | 21 +++++++ .../FullNodeApplicationWebAppAElfModule.cs | 37 ++++++++++++ .../Services/ContractMethodAppService.cs | 57 +++++++++++++++++++ 5 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 src/AElf.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj create mode 100644 src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs create mode 100644 src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs diff --git a/AElf.All.sln b/AElf.All.sln index 8a5a57bb48..c0e890cbd1 100644 --- a/AElf.All.sln +++ b/AElf.All.sln @@ -379,6 +379,8 @@ 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.WebApp.Application.FullNode", "src\AElf.WebApp.Application.FullNode\AElf.WebApp.Application.FullNode.csproj", "{D1FF1778-4195-426F-8BA7-24FCFF3F677D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1089,6 +1091,10 @@ 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 + {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1280,5 +1286,6 @@ 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} + {D1FF1778-4195-426F-8BA7-24FCFF3F677D} = {13B37500-5DF4-4C64-BD57-2CA6A619596A} EndGlobalSection EndGlobal diff --git a/src/AElf.Launcher/Startup.cs b/src/AElf.Launcher/Startup.cs index 1c293abd9a..605812f0c7 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,20 @@ 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 => + { + options.PlugInSources.AddFolder(pluginSourcesFolder); + }; switch (chainType) { case ChainType.SideChain: - AddApplication(services); + services.AddApplication(optionsAction); break; default: - AddApplication(services); + services.AddApplication(optionsAction); break; } @@ -56,11 +65,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.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj b/src/AElf.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj new file mode 100644 index 0000000000..fc3911f45e --- /dev/null +++ b/src/AElf.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj @@ -0,0 +1,21 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs b/src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs new file mode 100644 index 0000000000..dcb6d318f3 --- /dev/null +++ b/src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs @@ -0,0 +1,37 @@ +using AElf.Kernel; +using AElf.Modularity; +using AElf.WebApp.Application.Chain; +using AElf.WebApp.Application.FullNode.Services; +using Microsoft.AspNetCore.Mvc.ApplicationParts; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Modularity; + +namespace AElf.WebApp.Application.FullNode; + +[DependsOn( + typeof(CoreKernelAElfModule), + typeof(CoreApplicationWebAppAElfModule), + typeof(ChainApplicationWebAppAElfModule) +)] +public class FullNodeApplicationWebAppAElfModule : AElfModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + context.Services.PreConfigure(options => + { + options.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(FullNodeApplicationWebAppAElfModule).Assembly)); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAssemblyOf(); + context.Services.AddControllers(); + Configure(options => + { + options.ConventionalControllers.Create(typeof(FullNodeApplicationWebAppAElfModule).Assembly, + setting => { setting.UrlControllerNameNormalizer = _ => "fullNode"; }); + }); + } +} \ No newline at end of file diff --git a/src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs b/src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs new file mode 100644 index 0000000000..339c596c7d --- /dev/null +++ b/src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs @@ -0,0 +1,57 @@ +using AElf.WebApp.Application.Chain; +using Google.Protobuf; +using Google.Protobuf.Reflection; +using Microsoft.Extensions.Logging; +using Volo.Abp; +using Volo.Abp.Application.Services; +using FileDescriptorSet = AElf.Runtime.CSharp.FileDescriptorSet; + +namespace AElf.WebApp.Application.FullNode.Services; + +public interface IContractMethodAppService +{ + Task GetContractViewMethodListAsync(string address); +} + +public class ContractMethodAppService : ApplicationService, IContractMethodAppService +{ + private static IContractFileDescriptorSetAppService _contractFileDescriptorSetAppService; + + public ILogger Logger { get; set; } + + public ContractMethodAppService(IContractFileDescriptorSetAppService contractFileDescriptorSetAppService) + { + _contractFileDescriptorSetAppService = contractFileDescriptorSetAppService; + } + + /// + /// Get the view method list of a contract + /// + /// contract address + /// + public async Task GetContractViewMethodListAsync(string address) + { + try + { + var set = new FileDescriptorSet(); + var fds = await _contractFileDescriptorSetAppService.GetContractFileDescriptorSetAsync(address); + set.MergeFrom(ByteString.CopyFrom(fds)); + var fdList = FileDescriptor.BuildFromByteStrings(set.File, new ExtensionRegistry + { + OptionsExtensions.IsView, + }); + var viewMethodList = + (from fd in fdList + from service in fd.Services + from method in service.Methods + where method.GetOptions().GetExtension(OptionsExtensions.IsView) + select method.Name).ToList(); + return viewMethodList.ToArray(); + } + catch (Exception e) + { + Logger.LogWarning(e, "Error during GetContractViewMethodListAsync"); + throw new UserFriendlyException(Error.Message[Error.NotFound], Error.NotFound.ToString()); + } + } +} \ No newline at end of file From da843dde1564e961dc84be2bcb20317cd2f56257 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 3 Jul 2024 10:27:14 +0800 Subject: [PATCH 2/8] Now the dpos consensus can be replaced by poa consensus via plugin mechanism. --- AElf.All.sln | 19 ++++-- .../AElf.Contracts.Consensus.PoA.csproj | 41 ++++++++++++ .../PoAContract.ACS1.cs | 12 ++++ .../PoAContract.ACS4.cs | 64 +++++++++++++++++++ .../PoAContract.cs | 31 +++++++++ .../PoAContractState.cs | 12 ++++ protobuf/poa_contract.proto | 34 ++++++++++ protobuf/poa_contract_impl.proto | 18 ++++++ .../AElf.Blockchains.BasicBaseChain.csproj | 1 + .../GenesisSmartContractDtoProviderBase.cs | 8 ++- ...ainChainGenesisSmartContractDtoProvider.cs | 10 ++- .../ContractsDeployer.cs | 7 +- .../EconomicContractInitializationProvider.cs | 52 +++++++-------- .../ElectionContractInitializationProvider.cs | 24 +++---- .../AElf.Kernel.Consensus.PoA.csproj | 36 +++++++++++ ...oABroadcastPrivilegedPubkeyListProvider.cs | 13 ++++ .../Application/PoAExtraDataExtractor.cs | 12 ++++ .../PoATriggerInformationProvider.cs | 33 ++++++++++ .../PoAAElfModule.cs | 21 ++++++ .../PoAContractInitializationProvider.cs | 29 +++++++++ .../PoAPluginContractProvider.cs | 12 ++++ .../Application/IPluginContractProvider.cs | 6 ++ .../appsettings.MainChain.MainNet.json | 2 +- src/AElf.Launcher/appsettings.json | 11 +--- 24 files changed, 450 insertions(+), 58 deletions(-) create mode 100644 contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj create mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs create mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs create mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContract.cs create mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs create mode 100644 protobuf/poa_contract.proto create mode 100644 protobuf/poa_contract_impl.proto create mode 100644 src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj create mode 100644 src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs create mode 100644 src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs create mode 100644 src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs create mode 100644 src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs create mode 100644 src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs create mode 100644 src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs create mode 100644 src/AElf.Kernel.Core/Plugin/Application/IPluginContractProvider.cs diff --git a/AElf.All.sln b/AElf.All.sln index c0e890cbd1..3a4f5d9dec 100644 --- a/AElf.All.sln +++ b/AElf.All.sln @@ -381,6 +381,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.VirtualTrans EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.WebApp.Application.FullNode", "src\AElf.WebApp.Application.FullNode\AElf.WebApp.Application.FullNode.csproj", "{D1FF1778-4195-426F-8BA7-24FCFF3F677D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.Consensus.PoA", "contract\AElf.Contracts.Consensus.PoA\AElf.Contracts.Consensus.PoA.csproj", "{489F7191-64AE-4F68-A251-10222A56025F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.Consensus.PoA", "src\AElf.Kernel.Consensus.PoA\AElf.Kernel.Consensus.PoA.csproj", "{78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1091,10 +1095,14 @@ 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 - {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D1FF1778-4195-426F-8BA7-24FCFF3F677D}.Release|Any CPU.Build.0 = Release|Any CPU + {489F7191-64AE-4F68-A251-10222A56025F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {489F7191-64AE-4F68-A251-10222A56025F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {489F7191-64AE-4F68-A251-10222A56025F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {489F7191-64AE-4F68-A251-10222A56025F}.Release|Any CPU.Build.0 = Release|Any CPU + {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1286,6 +1294,7 @@ 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} - {D1FF1778-4195-426F-8BA7-24FCFF3F677D} = {13B37500-5DF4-4C64-BD57-2CA6A619596A} + {489F7191-64AE-4F68-A251-10222A56025F} = {9AA521A5-80BF-4D20-9339-31D7E86D5868} + {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC} EndGlobalSection EndGlobal diff --git a/contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj b/contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj new file mode 100644 index 0000000000..77ccf0beed --- /dev/null +++ b/contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj @@ -0,0 +1,41 @@ + + + + + net6.0 + AElf.Contracts.Consensus.PoA + true + Consensus is a contract that implements AElf’s PoA consensus protocol for single node. + + + + true + + + + true + + + + + Protobuf\Proto\authority_info.proto + + + Protobuf\Proto\acs1.proto + + + Protobuf\Proto\acs4.proto + + + Protobuf\Proto\poa_contract.proto + + + + + + Protobuf\Proto\poa_contract_impl.proto + true + + + + \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs new file mode 100644 index 0000000000..2e771e3450 --- /dev/null +++ b/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs @@ -0,0 +1,12 @@ +using AElf.Standards.ACS1; +using Google.Protobuf.WellKnownTypes; + +namespace AElf.Contracts.Consensus.PoA; + +public partial class PoAContract +{ + public override MethodFees GetMethodFee(StringValue input) + { + return new MethodFees(); + } +} \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs new file mode 100644 index 0000000000..9d330b7bc9 --- /dev/null +++ b/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs @@ -0,0 +1,64 @@ +using AElf.CSharp.Core.Extension; +using AElf.Standards.ACS4; +using AElf.Types; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; + +namespace AElf.Contracts.Consensus.PoA; + +public partial class PoAContract : PoAContractImplContainer.PoAContractImplBase +{ + public override ConsensusCommand GetConsensusCommand(BytesValue input) + { + Context.LogDebug(() => "Getting consensus command from PoA Contract."); + + var arrangedMiningTime = Context.CurrentBlockTime.AddMilliseconds(State.MiningInterval.Value); + var dueTime = arrangedMiningTime.AddMilliseconds(State.MiningInterval.Value); + return new ConsensusCommand + { + ArrangedMiningTime = arrangedMiningTime, + MiningDueTime = dueTime, + LimitMillisecondsOfMiningBlock = (int)State.MiningInterval.Value, + }; + } + + public override TransactionList GenerateConsensusTransactions(BytesValue input) + { + return new TransactionList + { + Transactions = + { + GenerateTransaction(nameof(Mine), new MineInput()) + } + }; + } + + public override ValidationResult ValidateConsensusBeforeExecution(BytesValue input) + { + return new ValidationResult + { + Success = true + }; + } + + public override ValidationResult ValidateConsensusAfterExecution(BytesValue input) + { + return new ValidationResult + { + Success = true + }; + } + + private Transaction GenerateTransaction(string methodName, IMessage parameter) + { + return new Transaction + { + From = Context.Sender, + To = Context.Self, + MethodName = methodName, + Params = parameter.ToByteString(), + RefBlockNumber = Context.CurrentHeight, + RefBlockPrefix = BlockHelper.GetRefBlockPrefix(Context.PreviousBlockHash) + }; + } +} \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContract.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContract.cs new file mode 100644 index 0000000000..68b5b6e0bf --- /dev/null +++ b/contract/AElf.Contracts.Consensus.PoA/PoAContract.cs @@ -0,0 +1,31 @@ +using AElf.Types; +using Google.Protobuf.WellKnownTypes; + +namespace AElf.Contracts.Consensus.PoA; + +public partial class PoAContract +{ + public override Empty Initialize(InitializeInput input) + { + Context.LogDebug(() => "PoA Contract initialized."); + State.MiningInterval.Value = input.MiningInterval == 0 ? 4000 : input.MiningInterval; + return new Empty(); + } + + /// + /// Not used for now. + /// + /// + /// + public override Empty Mine(MineInput input) + { + State.InitialMiner.Value = Context.Sender; + State.LastMiningTime.Value = Context.CurrentBlockTime; + return new Empty(); + } + + public override Address GetMiner(Empty input) + { + return State.InitialMiner.Value; + } +} \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs new file mode 100644 index 0000000000..4fda3ce0ed --- /dev/null +++ b/contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs @@ -0,0 +1,12 @@ +using AElf.Sdk.CSharp.State; +using AElf.Types; +using Google.Protobuf.WellKnownTypes; + +namespace AElf.Contracts.Consensus.PoA; + +public class PoAContractState : ContractState +{ + public SingletonState
InitialMiner { get; set; } + public Int64State MiningInterval { get; set; } + public SingletonState LastMiningTime { get; set; } +} \ No newline at end of file diff --git a/protobuf/poa_contract.proto b/protobuf/poa_contract.proto new file mode 100644 index 0000000000..4ed5fba831 --- /dev/null +++ b/protobuf/poa_contract.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package PoA; + +import "aelf/options.proto"; +import "aelf/core.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "AElf.Contracts.Consensus.PoA"; + +service PoAContract { + + option (aelf.csharp_state) = "AElf.Contracts.Consensus.PoA.PoAContractState"; + + // Initialize the consensus contract. + rpc Initialize (InitializeInput) returns (google.protobuf.Empty) { + } + + rpc Mine (MineInput) returns (google.protobuf.Empty) { + } + + rpc GetMiner (google.protobuf.Empty) returns (aelf.Address) { + option (aelf.is_view) = true; + } +} + +message InitializeInput { + int64 mining_interval = 1; +} + +message MineInput { +} \ No newline at end of file diff --git a/protobuf/poa_contract_impl.proto b/protobuf/poa_contract_impl.proto new file mode 100644 index 0000000000..beba6d122f --- /dev/null +++ b/protobuf/poa_contract_impl.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package PoAImpl; + +import "aelf/options.proto"; +import "aelf/core.proto"; +import "acs4.proto"; +import "acs1.proto"; +import "poa_contract.proto"; + +option csharp_namespace = "AElf.Contracts.Consensus.PoA"; + +service PoAContractImpl { + option (aelf.csharp_state) = "AElf.Contracts.Consensus.PoA.PoAContractState"; + option (aelf.base) = "acs1.proto"; + option (aelf.base) = "acs4.proto"; + option (aelf.base) = "poa_contract.proto"; +} \ No newline at end of file diff --git a/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj b/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj index e32d4beb7d..afed4782c5 100644 --- a/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj +++ b/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj @@ -15,6 +15,7 @@ + diff --git a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs index 844998a236..f595099ffe 100644 --- a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs +++ b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs @@ -26,10 +26,12 @@ 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 => + .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/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.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.EconomicSystem/EconomicContractInitializationProvider.cs b/src/AElf.EconomicSystem/EconomicContractInitializationProvider.cs index bbe1333563..ec334c7223 100644 --- a/src/AElf.EconomicSystem/EconomicContractInitializationProvider.cs +++ b/src/AElf.EconomicSystem/EconomicContractInitializationProvider.cs @@ -32,32 +32,32 @@ public List GetInitializeMethodList(byte[] con { return new List { - new() - { - MethodName = nameof(EconomicContractContainer.EconomicContractStub.InitialEconomicSystem), - Params = new InitialEconomicSystemInput - { - NativeTokenDecimals = _economicOptions.Decimals, - IsNativeTokenBurnable = _economicOptions.IsBurnable, - NativeTokenSymbol = _economicOptions.Symbol, - NativeTokenName = _economicOptions.TokenName, - NativeTokenTotalSupply = _economicOptions.TotalSupply, - MiningRewardTotalAmount = - Convert.ToInt64(_economicOptions.TotalSupply * _economicOptions.DividendPoolRatio), - TransactionSizeFeeUnitPrice = _economicOptions.TransactionSizeFeeUnitPrice - }.ToByteString() - }, - new() - { - MethodName = nameof(EconomicContractContainer.EconomicContractStub.IssueNativeToken), - Params = new IssueNativeTokenInput - { - Amount = Convert.ToInt64(_economicOptions.TotalSupply * (1 - _economicOptions.DividendPoolRatio)), - To = Address.FromPublicKey( - ByteArrayHelper.HexStringToByteArray(_consensusOptions.InitialMinerList.First())), - Memo = "Issue native token" - }.ToByteString() - } + // new() + // { + // MethodName = nameof(EconomicContractContainer.EconomicContractStub.InitialEconomicSystem), + // Params = new InitialEconomicSystemInput + // { + // NativeTokenDecimals = _economicOptions.Decimals, + // IsNativeTokenBurnable = _economicOptions.IsBurnable, + // NativeTokenSymbol = _economicOptions.Symbol, + // NativeTokenName = _economicOptions.TokenName, + // NativeTokenTotalSupply = _economicOptions.TotalSupply, + // MiningRewardTotalAmount = + // Convert.ToInt64(_economicOptions.TotalSupply * _economicOptions.DividendPoolRatio), + // TransactionSizeFeeUnitPrice = _economicOptions.TransactionSizeFeeUnitPrice + // }.ToByteString() + // }, + // new() + // { + // MethodName = nameof(EconomicContractContainer.EconomicContractStub.IssueNativeToken), + // Params = new IssueNativeTokenInput + // { + // Amount = Convert.ToInt64(_economicOptions.TotalSupply * (1 - _economicOptions.DividendPoolRatio)), + // To = Address.FromPublicKey( + // ByteArrayHelper.HexStringToByteArray(_consensusOptions.InitialMinerList.First())), + // Memo = "Issue native token" + // }.ToByteString() + // } }; } } \ No newline at end of file diff --git a/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs b/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs index 8d52ad10d3..2d615598dc 100644 --- a/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs +++ b/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs @@ -30,18 +30,18 @@ public List GetInitializeMethodList(byte[] con { return new List { - new() - { - MethodName = nameof(ElectionContractContainer.ElectionContractStub.InitialElectionContract), - Params = new InitialElectionContractInput - { - MaximumLockTime = _economicOptions.MaximumLockTime, - MinimumLockTime = _economicOptions.MinimumLockTime, - TimeEachTerm = _consensusOptions.PeriodSeconds, - MinerList = { _consensusOptions.InitialMinerList }, - MinerIncreaseInterval = _consensusOptions.MinerIncreaseInterval - }.ToByteString() - } + // new() + // { + // MethodName = nameof(ElectionContractContainer.ElectionContractStub.InitialElectionContract), + // Params = new InitialElectionContractInput + // { + // MaximumLockTime = _economicOptions.MaximumLockTime, + // MinimumLockTime = _economicOptions.MinimumLockTime, + // TimeEachTerm = _consensusOptions.PeriodSeconds, + // MinerList = { _consensusOptions.InitialMinerList }, + // MinerIncreaseInterval = _consensusOptions.MinerIncreaseInterval + // }.ToByteString() + // } }; } } \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj b/src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj new file mode 100644 index 0000000000..c307489740 --- /dev/null +++ b/src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj @@ -0,0 +1,36 @@ + + + + net6.0 + latest + AElf.Kernel.Consensus.PoA + true + AElf.Kernel.Consensus.PoA + AElf PoA consensus for single node. + + + + 0436 + + + + + + + + + Protobuf\Proto\acs1.proto + + + Protobuf\Proto\acs4.proto + + + Protobuf\Proto\poa_contract.proto + + + + + + + + diff --git a/src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs b/src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs new file mode 100644 index 0000000000..ba81a87764 --- /dev/null +++ b/src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using AElf.Kernel.Consensus.Application; + +namespace AElf.Kernel.Consensus.PoA.Application; + +public class PoABroadcastPrivilegedPubkeyListProvider : IBroadcastPrivilegedPubkeyListProvider +{ + public async Task> GetPubkeyList(BlockHeader blockHeader) + { + return new List(); + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs b/src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs new file mode 100644 index 0000000000..69fa51fc07 --- /dev/null +++ b/src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs @@ -0,0 +1,12 @@ +using AElf.Kernel.Consensus.Application; +using Google.Protobuf; + +namespace AElf.Kernel.Consensus.PoA.Application; + +public class PoAExtraDataExtractor : IConsensusExtraDataExtractor +{ + public ByteString ExtractConsensusExtraData(BlockHeader header) + { + return ByteString.Empty; + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs b/src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs new file mode 100644 index 0000000000..2feeead56b --- /dev/null +++ b/src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs @@ -0,0 +1,33 @@ +using AElf.Kernel.Consensus.Application; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.Consensus.PoA.Application; + +public class PoATriggerInformationProvider : ITriggerInformationProvider, ISingletonDependency +{ + public BytesValue GetTriggerInformationForConsensusCommand(BytesValue consensusCommandBytes) + { + return new BytesValue + { + Value = ByteString.Empty + }; + } + + public BytesValue GetTriggerInformationForBlockHeaderExtraData(BytesValue consensusCommandBytes) + { + return new BytesValue + { + Value = ByteString.Empty + }; + } + + public BytesValue GetTriggerInformationForConsensusTransactions(IChainContext chainContext, BytesValue consensusCommandBytes) + { + return new BytesValue + { + Value = ByteString.Empty + }; + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs b/src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs new file mode 100644 index 0000000000..55e78048ba --- /dev/null +++ b/src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs @@ -0,0 +1,21 @@ +using AElf.Kernel.Consensus.Application; +using AElf.Kernel.Consensus.PoA.Application; +using AElf.Kernel.Consensus.Scheduler.RxNet; +using AElf.Modularity; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; + +namespace AElf.Kernel.Consensus.PoA; + +[DependsOn( + typeof(RxNetSchedulerAElfModule), + typeof(CoreConsensusAElfModule) +)] +public class PoAAElfModule : AElfModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddTransient(); + context.Services.AddSingleton(); + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs b/src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs new file mode 100644 index 0000000000..6daeb03fc1 --- /dev/null +++ b/src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using AElf.Contracts.Consensus.PoA; +using AElf.Kernel.SmartContract.Application; +using AElf.Types; +using Google.Protobuf; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.Consensus.PoA; + +public class PoAContractInitializationProvider : IContractInitializationProvider, ITransientDependency +{ + public Hash SystemSmartContractName => ConsensusSmartContractAddressNameProvider.Name; + public string ContractCodeName => "AElf.Contracts.Consensus.PoA"; + + public List GetInitializeMethodList(byte[] contractCode) + { + return new List + { + new() + { + MethodName = nameof(PoAContractContainer.PoAContractStub.Initialize), + Params = new InitializeInput + { + MiningInterval = 4000 + }.ToByteString() + } + }; + } +} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs b/src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs new file mode 100644 index 0000000000..a21ae69af4 --- /dev/null +++ b/src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs @@ -0,0 +1,12 @@ +using AElf.Kernel.Plugin.Application; +using Volo.Abp.DependencyInjection; + +namespace AElf.Kernel.Consensus.PoA; + +public class PoAPluginContractProvider : IPluginContractProvider, ITransientDependency +{ + public string GetContractName() + { + return "AElf.Contracts.Consensus.PoA"; + } +} \ No newline at end of file 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.Launcher/appsettings.MainChain.MainNet.json b/src/AElf.Launcher/appsettings.MainChain.MainNet.json index 5d9ead6291..18419607b4 100644 --- a/src/AElf.Launcher/appsettings.MainChain.MainNet.json +++ b/src/AElf.Launcher/appsettings.MainChain.MainNet.json @@ -14,7 +14,7 @@ }, "CrossChain": { "Grpc": { - "ListeningPort": 5000 + "ListeningPort": 5001 } } } \ No newline at end of file diff --git a/src/AElf.Launcher/appsettings.json b/src/AElf.Launcher/appsettings.json index 45c0923284..c3681a303e 100644 --- a/src/AElf.Launcher/appsettings.json +++ b/src/AElf.Launcher/appsettings.json @@ -9,8 +9,8 @@ "StateDb": "redis://localhost:6379?db=1" }, "Account": { - "NodeAccount": "", - "NodeAccountPassword": "" + "NodeAccount": "2ceeqZ7iNTLXfzkmNzXCiPYiZTbkRAxH48FS7rBCX5qFtptajP", + "NodeAccountPassword": "12345678" }, "Network": { "BootNodes": [], @@ -40,12 +40,7 @@ }, "Logging": { "LogLevel": { - "Default": "Information", - "System": "Error", - "Microsoft": "Error", - "AElf.OS": "Information", - "AElf.Kernel.Consensus": "Information", - "AElf": "Information" + "Default": "Trace" } } } \ No newline at end of file From 6ec88ef186376fd535d80134c23bf1f00173f8e0 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Thu, 4 Jul 2024 14:56:44 +0800 Subject: [PATCH 3/8] Add plugin sources if only directory exists. --- src/AElf.Launcher/Startup.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/AElf.Launcher/Startup.cs b/src/AElf.Launcher/Startup.cs index 605812f0c7..74332d4a14 100644 --- a/src/AElf.Launcher/Startup.cs +++ b/src/AElf.Launcher/Startup.cs @@ -35,7 +35,10 @@ public void ConfigureServices(IServiceCollection services) "aelf", "plugins")); Action optionsAction = options => { - options.PlugInSources.AddFolder(pluginSourcesFolder); + if (Directory.Exists(pluginSourcesFolder)) + { + options.PlugInSources.AddFolder(pluginSourcesFolder); + } }; switch (chainType) { From ed08d7acfb5fcbf077b18d34634635699c4b9fce Mon Sep 17 00:00:00 2001 From: eanzhao Date: Thu, 4 Jul 2024 17:50:36 +0800 Subject: [PATCH 4/8] Remove unnecessary files. --- AElf.All.sln | 16 ----- .../AElf.Contracts.Consensus.PoA.csproj | 41 ------------ .../PoAContract.ACS1.cs | 12 ---- .../PoAContract.ACS4.cs | 64 ------------------- .../PoAContract.cs | 31 --------- .../PoAContractState.cs | 12 ---- .../AElf.Blockchains.BasicBaseChain.csproj | 1 - .../AElf.Kernel.Consensus.PoA.csproj | 36 ----------- ...oABroadcastPrivilegedPubkeyListProvider.cs | 13 ---- .../Application/PoAExtraDataExtractor.cs | 12 ---- .../PoATriggerInformationProvider.cs | 33 ---------- .../PoAAElfModule.cs | 21 ------ .../PoAContractInitializationProvider.cs | 29 --------- .../PoAPluginContractProvider.cs | 12 ---- .../AElf.WebApp.Application.FullNode.csproj | 21 ------ .../FullNodeApplicationWebAppAElfModule.cs | 37 ----------- .../Services/ContractMethodAppService.cs | 57 ----------------- 17 files changed, 448 deletions(-) delete mode 100644 contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj delete mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs delete mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs delete mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContract.cs delete mode 100644 contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs delete mode 100644 src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj delete mode 100644 src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs delete mode 100644 src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs delete mode 100644 src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs delete mode 100644 src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs delete mode 100644 src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs delete mode 100644 src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs delete mode 100644 src/AElf.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj delete mode 100644 src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs delete mode 100644 src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs diff --git a/AElf.All.sln b/AElf.All.sln index 3a4f5d9dec..8a5a57bb48 100644 --- a/AElf.All.sln +++ b/AElf.All.sln @@ -379,12 +379,6 @@ 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.WebApp.Application.FullNode", "src\AElf.WebApp.Application.FullNode\AElf.WebApp.Application.FullNode.csproj", "{D1FF1778-4195-426F-8BA7-24FCFF3F677D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Contracts.Consensus.PoA", "contract\AElf.Contracts.Consensus.PoA\AElf.Contracts.Consensus.PoA.csproj", "{489F7191-64AE-4F68-A251-10222A56025F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.Consensus.PoA", "src\AElf.Kernel.Consensus.PoA\AElf.Kernel.Consensus.PoA.csproj", "{78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1095,14 +1089,6 @@ 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 - {489F7191-64AE-4F68-A251-10222A56025F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {489F7191-64AE-4F68-A251-10222A56025F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {489F7191-64AE-4F68-A251-10222A56025F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {489F7191-64AE-4F68-A251-10222A56025F}.Release|Any CPU.Build.0 = Release|Any CPU - {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1294,7 +1280,5 @@ 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} - {489F7191-64AE-4F68-A251-10222A56025F} = {9AA521A5-80BF-4D20-9339-31D7E86D5868} - {78FE0FCF-FFC7-4A06-8571-6C22F463D1CE} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC} EndGlobalSection EndGlobal diff --git a/contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj b/contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj deleted file mode 100644 index 77ccf0beed..0000000000 --- a/contract/AElf.Contracts.Consensus.PoA/AElf.Contracts.Consensus.PoA.csproj +++ /dev/null @@ -1,41 +0,0 @@ - - - - - net6.0 - AElf.Contracts.Consensus.PoA - true - Consensus is a contract that implements AElf’s PoA consensus protocol for single node. - - - - true - - - - true - - - - - Protobuf\Proto\authority_info.proto - - - Protobuf\Proto\acs1.proto - - - Protobuf\Proto\acs4.proto - - - Protobuf\Proto\poa_contract.proto - - - - - - Protobuf\Proto\poa_contract_impl.proto - true - - - - \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs deleted file mode 100644 index 2e771e3450..0000000000 --- a/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS1.cs +++ /dev/null @@ -1,12 +0,0 @@ -using AElf.Standards.ACS1; -using Google.Protobuf.WellKnownTypes; - -namespace AElf.Contracts.Consensus.PoA; - -public partial class PoAContract -{ - public override MethodFees GetMethodFee(StringValue input) - { - return new MethodFees(); - } -} \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs deleted file mode 100644 index 9d330b7bc9..0000000000 --- a/contract/AElf.Contracts.Consensus.PoA/PoAContract.ACS4.cs +++ /dev/null @@ -1,64 +0,0 @@ -using AElf.CSharp.Core.Extension; -using AElf.Standards.ACS4; -using AElf.Types; -using Google.Protobuf; -using Google.Protobuf.WellKnownTypes; - -namespace AElf.Contracts.Consensus.PoA; - -public partial class PoAContract : PoAContractImplContainer.PoAContractImplBase -{ - public override ConsensusCommand GetConsensusCommand(BytesValue input) - { - Context.LogDebug(() => "Getting consensus command from PoA Contract."); - - var arrangedMiningTime = Context.CurrentBlockTime.AddMilliseconds(State.MiningInterval.Value); - var dueTime = arrangedMiningTime.AddMilliseconds(State.MiningInterval.Value); - return new ConsensusCommand - { - ArrangedMiningTime = arrangedMiningTime, - MiningDueTime = dueTime, - LimitMillisecondsOfMiningBlock = (int)State.MiningInterval.Value, - }; - } - - public override TransactionList GenerateConsensusTransactions(BytesValue input) - { - return new TransactionList - { - Transactions = - { - GenerateTransaction(nameof(Mine), new MineInput()) - } - }; - } - - public override ValidationResult ValidateConsensusBeforeExecution(BytesValue input) - { - return new ValidationResult - { - Success = true - }; - } - - public override ValidationResult ValidateConsensusAfterExecution(BytesValue input) - { - return new ValidationResult - { - Success = true - }; - } - - private Transaction GenerateTransaction(string methodName, IMessage parameter) - { - return new Transaction - { - From = Context.Sender, - To = Context.Self, - MethodName = methodName, - Params = parameter.ToByteString(), - RefBlockNumber = Context.CurrentHeight, - RefBlockPrefix = BlockHelper.GetRefBlockPrefix(Context.PreviousBlockHash) - }; - } -} \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContract.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContract.cs deleted file mode 100644 index 68b5b6e0bf..0000000000 --- a/contract/AElf.Contracts.Consensus.PoA/PoAContract.cs +++ /dev/null @@ -1,31 +0,0 @@ -using AElf.Types; -using Google.Protobuf.WellKnownTypes; - -namespace AElf.Contracts.Consensus.PoA; - -public partial class PoAContract -{ - public override Empty Initialize(InitializeInput input) - { - Context.LogDebug(() => "PoA Contract initialized."); - State.MiningInterval.Value = input.MiningInterval == 0 ? 4000 : input.MiningInterval; - return new Empty(); - } - - /// - /// Not used for now. - /// - /// - /// - public override Empty Mine(MineInput input) - { - State.InitialMiner.Value = Context.Sender; - State.LastMiningTime.Value = Context.CurrentBlockTime; - return new Empty(); - } - - public override Address GetMiner(Empty input) - { - return State.InitialMiner.Value; - } -} \ No newline at end of file diff --git a/contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs b/contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs deleted file mode 100644 index 4fda3ce0ed..0000000000 --- a/contract/AElf.Contracts.Consensus.PoA/PoAContractState.cs +++ /dev/null @@ -1,12 +0,0 @@ -using AElf.Sdk.CSharp.State; -using AElf.Types; -using Google.Protobuf.WellKnownTypes; - -namespace AElf.Contracts.Consensus.PoA; - -public class PoAContractState : ContractState -{ - public SingletonState
InitialMiner { get; set; } - public Int64State MiningInterval { get; set; } - public SingletonState LastMiningTime { get; set; } -} \ No newline at end of file diff --git a/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj b/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj index afed4782c5..e32d4beb7d 100644 --- a/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj +++ b/src/AElf.Blockchains.BasicBaseChain/AElf.Blockchains.BasicBaseChain.csproj @@ -15,7 +15,6 @@ - diff --git a/src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj b/src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj deleted file mode 100644 index c307489740..0000000000 --- a/src/AElf.Kernel.Consensus.PoA/AElf.Kernel.Consensus.PoA.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - - net6.0 - latest - AElf.Kernel.Consensus.PoA - true - AElf.Kernel.Consensus.PoA - AElf PoA consensus for single node. - - - - 0436 - - - - - - - - - Protobuf\Proto\acs1.proto - - - Protobuf\Proto\acs4.proto - - - Protobuf\Proto\poa_contract.proto - - - - - - - - diff --git a/src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs b/src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs deleted file mode 100644 index ba81a87764..0000000000 --- a/src/AElf.Kernel.Consensus.PoA/Application/PoABroadcastPrivilegedPubkeyListProvider.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using AElf.Kernel.Consensus.Application; - -namespace AElf.Kernel.Consensus.PoA.Application; - -public class PoABroadcastPrivilegedPubkeyListProvider : IBroadcastPrivilegedPubkeyListProvider -{ - public async Task> GetPubkeyList(BlockHeader blockHeader) - { - return new List(); - } -} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs b/src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs deleted file mode 100644 index 69fa51fc07..0000000000 --- a/src/AElf.Kernel.Consensus.PoA/Application/PoAExtraDataExtractor.cs +++ /dev/null @@ -1,12 +0,0 @@ -using AElf.Kernel.Consensus.Application; -using Google.Protobuf; - -namespace AElf.Kernel.Consensus.PoA.Application; - -public class PoAExtraDataExtractor : IConsensusExtraDataExtractor -{ - public ByteString ExtractConsensusExtraData(BlockHeader header) - { - return ByteString.Empty; - } -} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs b/src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs deleted file mode 100644 index 2feeead56b..0000000000 --- a/src/AElf.Kernel.Consensus.PoA/Application/PoATriggerInformationProvider.cs +++ /dev/null @@ -1,33 +0,0 @@ -using AElf.Kernel.Consensus.Application; -using Google.Protobuf; -using Google.Protobuf.WellKnownTypes; -using Volo.Abp.DependencyInjection; - -namespace AElf.Kernel.Consensus.PoA.Application; - -public class PoATriggerInformationProvider : ITriggerInformationProvider, ISingletonDependency -{ - public BytesValue GetTriggerInformationForConsensusCommand(BytesValue consensusCommandBytes) - { - return new BytesValue - { - Value = ByteString.Empty - }; - } - - public BytesValue GetTriggerInformationForBlockHeaderExtraData(BytesValue consensusCommandBytes) - { - return new BytesValue - { - Value = ByteString.Empty - }; - } - - public BytesValue GetTriggerInformationForConsensusTransactions(IChainContext chainContext, BytesValue consensusCommandBytes) - { - return new BytesValue - { - Value = ByteString.Empty - }; - } -} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs b/src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs deleted file mode 100644 index 55e78048ba..0000000000 --- a/src/AElf.Kernel.Consensus.PoA/PoAAElfModule.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AElf.Kernel.Consensus.Application; -using AElf.Kernel.Consensus.PoA.Application; -using AElf.Kernel.Consensus.Scheduler.RxNet; -using AElf.Modularity; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Modularity; - -namespace AElf.Kernel.Consensus.PoA; - -[DependsOn( - typeof(RxNetSchedulerAElfModule), - typeof(CoreConsensusAElfModule) -)] -public class PoAAElfModule : AElfModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddTransient(); - context.Services.AddSingleton(); - } -} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs b/src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs deleted file mode 100644 index 6daeb03fc1..0000000000 --- a/src/AElf.Kernel.Consensus.PoA/PoAContractInitializationProvider.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections.Generic; -using AElf.Contracts.Consensus.PoA; -using AElf.Kernel.SmartContract.Application; -using AElf.Types; -using Google.Protobuf; -using Volo.Abp.DependencyInjection; - -namespace AElf.Kernel.Consensus.PoA; - -public class PoAContractInitializationProvider : IContractInitializationProvider, ITransientDependency -{ - public Hash SystemSmartContractName => ConsensusSmartContractAddressNameProvider.Name; - public string ContractCodeName => "AElf.Contracts.Consensus.PoA"; - - public List GetInitializeMethodList(byte[] contractCode) - { - return new List - { - new() - { - MethodName = nameof(PoAContractContainer.PoAContractStub.Initialize), - Params = new InitializeInput - { - MiningInterval = 4000 - }.ToByteString() - } - }; - } -} \ No newline at end of file diff --git a/src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs b/src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs deleted file mode 100644 index a21ae69af4..0000000000 --- a/src/AElf.Kernel.Consensus.PoA/PoAPluginContractProvider.cs +++ /dev/null @@ -1,12 +0,0 @@ -using AElf.Kernel.Plugin.Application; -using Volo.Abp.DependencyInjection; - -namespace AElf.Kernel.Consensus.PoA; - -public class PoAPluginContractProvider : IPluginContractProvider, ITransientDependency -{ - public string GetContractName() - { - return "AElf.Contracts.Consensus.PoA"; - } -} \ No newline at end of file diff --git a/src/AElf.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj b/src/AElf.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj deleted file mode 100644 index fc3911f45e..0000000000 --- a/src/AElf.WebApp.Application.FullNode/AElf.WebApp.Application.FullNode.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - - - - - diff --git a/src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs b/src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs deleted file mode 100644 index dcb6d318f3..0000000000 --- a/src/AElf.WebApp.Application.FullNode/FullNodeApplicationWebAppAElfModule.cs +++ /dev/null @@ -1,37 +0,0 @@ -using AElf.Kernel; -using AElf.Modularity; -using AElf.WebApp.Application.Chain; -using AElf.WebApp.Application.FullNode.Services; -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.Modularity; - -namespace AElf.WebApp.Application.FullNode; - -[DependsOn( - typeof(CoreKernelAElfModule), - typeof(CoreApplicationWebAppAElfModule), - typeof(ChainApplicationWebAppAElfModule) -)] -public class FullNodeApplicationWebAppAElfModule : AElfModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - context.Services.PreConfigure(options => - { - options.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(FullNodeApplicationWebAppAElfModule).Assembly)); - }); - } - - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAssemblyOf(); - context.Services.AddControllers(); - Configure(options => - { - options.ConventionalControllers.Create(typeof(FullNodeApplicationWebAppAElfModule).Assembly, - setting => { setting.UrlControllerNameNormalizer = _ => "fullNode"; }); - }); - } -} \ No newline at end of file diff --git a/src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs b/src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs deleted file mode 100644 index 339c596c7d..0000000000 --- a/src/AElf.WebApp.Application.FullNode/Services/ContractMethodAppService.cs +++ /dev/null @@ -1,57 +0,0 @@ -using AElf.WebApp.Application.Chain; -using Google.Protobuf; -using Google.Protobuf.Reflection; -using Microsoft.Extensions.Logging; -using Volo.Abp; -using Volo.Abp.Application.Services; -using FileDescriptorSet = AElf.Runtime.CSharp.FileDescriptorSet; - -namespace AElf.WebApp.Application.FullNode.Services; - -public interface IContractMethodAppService -{ - Task GetContractViewMethodListAsync(string address); -} - -public class ContractMethodAppService : ApplicationService, IContractMethodAppService -{ - private static IContractFileDescriptorSetAppService _contractFileDescriptorSetAppService; - - public ILogger Logger { get; set; } - - public ContractMethodAppService(IContractFileDescriptorSetAppService contractFileDescriptorSetAppService) - { - _contractFileDescriptorSetAppService = contractFileDescriptorSetAppService; - } - - /// - /// Get the view method list of a contract - /// - /// contract address - /// - public async Task GetContractViewMethodListAsync(string address) - { - try - { - var set = new FileDescriptorSet(); - var fds = await _contractFileDescriptorSetAppService.GetContractFileDescriptorSetAsync(address); - set.MergeFrom(ByteString.CopyFrom(fds)); - var fdList = FileDescriptor.BuildFromByteStrings(set.File, new ExtensionRegistry - { - OptionsExtensions.IsView, - }); - var viewMethodList = - (from fd in fdList - from service in fd.Services - from method in service.Methods - where method.GetOptions().GetExtension(OptionsExtensions.IsView) - select method.Name).ToList(); - return viewMethodList.ToArray(); - } - catch (Exception e) - { - Logger.LogWarning(e, "Error during GetContractViewMethodListAsync"); - throw new UserFriendlyException(Error.Message[Error.NotFound], Error.NotFound.ToString()); - } - } -} \ No newline at end of file From c219521fb5986fe57864a440bc0b66afaf957635 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Thu, 4 Jul 2024 17:54:35 +0800 Subject: [PATCH 5/8] Revert a few changes. --- protobuf/poa_contract.proto | 34 ------------ protobuf/poa_contract_impl.proto | 18 ------- .../EconomicContractInitializationProvider.cs | 52 +++++++++---------- .../ElectionContractInitializationProvider.cs | 24 ++++----- src/AElf.Launcher/Startup.cs | 2 +- .../appsettings.MainChain.MainNet.json | 2 +- src/AElf.Launcher/appsettings.json | 11 ++-- 7 files changed, 48 insertions(+), 95 deletions(-) delete mode 100644 protobuf/poa_contract.proto delete mode 100644 protobuf/poa_contract_impl.proto diff --git a/protobuf/poa_contract.proto b/protobuf/poa_contract.proto deleted file mode 100644 index 4ed5fba831..0000000000 --- a/protobuf/poa_contract.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; - -package PoA; - -import "aelf/options.proto"; -import "aelf/core.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "AElf.Contracts.Consensus.PoA"; - -service PoAContract { - - option (aelf.csharp_state) = "AElf.Contracts.Consensus.PoA.PoAContractState"; - - // Initialize the consensus contract. - rpc Initialize (InitializeInput) returns (google.protobuf.Empty) { - } - - rpc Mine (MineInput) returns (google.protobuf.Empty) { - } - - rpc GetMiner (google.protobuf.Empty) returns (aelf.Address) { - option (aelf.is_view) = true; - } -} - -message InitializeInput { - int64 mining_interval = 1; -} - -message MineInput { -} \ No newline at end of file diff --git a/protobuf/poa_contract_impl.proto b/protobuf/poa_contract_impl.proto deleted file mode 100644 index beba6d122f..0000000000 --- a/protobuf/poa_contract_impl.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package PoAImpl; - -import "aelf/options.proto"; -import "aelf/core.proto"; -import "acs4.proto"; -import "acs1.proto"; -import "poa_contract.proto"; - -option csharp_namespace = "AElf.Contracts.Consensus.PoA"; - -service PoAContractImpl { - option (aelf.csharp_state) = "AElf.Contracts.Consensus.PoA.PoAContractState"; - option (aelf.base) = "acs1.proto"; - option (aelf.base) = "acs4.proto"; - option (aelf.base) = "poa_contract.proto"; -} \ No newline at end of file diff --git a/src/AElf.EconomicSystem/EconomicContractInitializationProvider.cs b/src/AElf.EconomicSystem/EconomicContractInitializationProvider.cs index ec334c7223..bbe1333563 100644 --- a/src/AElf.EconomicSystem/EconomicContractInitializationProvider.cs +++ b/src/AElf.EconomicSystem/EconomicContractInitializationProvider.cs @@ -32,32 +32,32 @@ public List GetInitializeMethodList(byte[] con { return new List { - // new() - // { - // MethodName = nameof(EconomicContractContainer.EconomicContractStub.InitialEconomicSystem), - // Params = new InitialEconomicSystemInput - // { - // NativeTokenDecimals = _economicOptions.Decimals, - // IsNativeTokenBurnable = _economicOptions.IsBurnable, - // NativeTokenSymbol = _economicOptions.Symbol, - // NativeTokenName = _economicOptions.TokenName, - // NativeTokenTotalSupply = _economicOptions.TotalSupply, - // MiningRewardTotalAmount = - // Convert.ToInt64(_economicOptions.TotalSupply * _economicOptions.DividendPoolRatio), - // TransactionSizeFeeUnitPrice = _economicOptions.TransactionSizeFeeUnitPrice - // }.ToByteString() - // }, - // new() - // { - // MethodName = nameof(EconomicContractContainer.EconomicContractStub.IssueNativeToken), - // Params = new IssueNativeTokenInput - // { - // Amount = Convert.ToInt64(_economicOptions.TotalSupply * (1 - _economicOptions.DividendPoolRatio)), - // To = Address.FromPublicKey( - // ByteArrayHelper.HexStringToByteArray(_consensusOptions.InitialMinerList.First())), - // Memo = "Issue native token" - // }.ToByteString() - // } + new() + { + MethodName = nameof(EconomicContractContainer.EconomicContractStub.InitialEconomicSystem), + Params = new InitialEconomicSystemInput + { + NativeTokenDecimals = _economicOptions.Decimals, + IsNativeTokenBurnable = _economicOptions.IsBurnable, + NativeTokenSymbol = _economicOptions.Symbol, + NativeTokenName = _economicOptions.TokenName, + NativeTokenTotalSupply = _economicOptions.TotalSupply, + MiningRewardTotalAmount = + Convert.ToInt64(_economicOptions.TotalSupply * _economicOptions.DividendPoolRatio), + TransactionSizeFeeUnitPrice = _economicOptions.TransactionSizeFeeUnitPrice + }.ToByteString() + }, + new() + { + MethodName = nameof(EconomicContractContainer.EconomicContractStub.IssueNativeToken), + Params = new IssueNativeTokenInput + { + Amount = Convert.ToInt64(_economicOptions.TotalSupply * (1 - _economicOptions.DividendPoolRatio)), + To = Address.FromPublicKey( + ByteArrayHelper.HexStringToByteArray(_consensusOptions.InitialMinerList.First())), + Memo = "Issue native token" + }.ToByteString() + } }; } } \ No newline at end of file diff --git a/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs b/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs index 2d615598dc..8d52ad10d3 100644 --- a/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs +++ b/src/AElf.GovernmentSystem/ElectionContractInitializationProvider.cs @@ -30,18 +30,18 @@ public List GetInitializeMethodList(byte[] con { return new List { - // new() - // { - // MethodName = nameof(ElectionContractContainer.ElectionContractStub.InitialElectionContract), - // Params = new InitialElectionContractInput - // { - // MaximumLockTime = _economicOptions.MaximumLockTime, - // MinimumLockTime = _economicOptions.MinimumLockTime, - // TimeEachTerm = _consensusOptions.PeriodSeconds, - // MinerList = { _consensusOptions.InitialMinerList }, - // MinerIncreaseInterval = _consensusOptions.MinerIncreaseInterval - // }.ToByteString() - // } + new() + { + MethodName = nameof(ElectionContractContainer.ElectionContractStub.InitialElectionContract), + Params = new InitialElectionContractInput + { + MaximumLockTime = _economicOptions.MaximumLockTime, + MinimumLockTime = _economicOptions.MinimumLockTime, + TimeEachTerm = _consensusOptions.PeriodSeconds, + MinerList = { _consensusOptions.InitialMinerList }, + MinerIncreaseInterval = _consensusOptions.MinerIncreaseInterval + }.ToByteString() + } }; } } \ No newline at end of file diff --git a/src/AElf.Launcher/Startup.cs b/src/AElf.Launcher/Startup.cs index 74332d4a14..42a4537bde 100644 --- a/src/AElf.Launcher/Startup.cs +++ b/src/AElf.Launcher/Startup.cs @@ -45,7 +45,7 @@ public void ConfigureServices(IServiceCollection services) case ChainType.SideChain: services.AddApplication(optionsAction); break; - default: + case ChainType.MainChain: services.AddApplication(optionsAction); break; } diff --git a/src/AElf.Launcher/appsettings.MainChain.MainNet.json b/src/AElf.Launcher/appsettings.MainChain.MainNet.json index 18419607b4..5d9ead6291 100644 --- a/src/AElf.Launcher/appsettings.MainChain.MainNet.json +++ b/src/AElf.Launcher/appsettings.MainChain.MainNet.json @@ -14,7 +14,7 @@ }, "CrossChain": { "Grpc": { - "ListeningPort": 5001 + "ListeningPort": 5000 } } } \ No newline at end of file diff --git a/src/AElf.Launcher/appsettings.json b/src/AElf.Launcher/appsettings.json index c3681a303e..45c0923284 100644 --- a/src/AElf.Launcher/appsettings.json +++ b/src/AElf.Launcher/appsettings.json @@ -9,8 +9,8 @@ "StateDb": "redis://localhost:6379?db=1" }, "Account": { - "NodeAccount": "2ceeqZ7iNTLXfzkmNzXCiPYiZTbkRAxH48FS7rBCX5qFtptajP", - "NodeAccountPassword": "12345678" + "NodeAccount": "", + "NodeAccountPassword": "" }, "Network": { "BootNodes": [], @@ -40,7 +40,12 @@ }, "Logging": { "LogLevel": { - "Default": "Trace" + "Default": "Information", + "System": "Error", + "Microsoft": "Error", + "AElf.OS": "Information", + "AElf.Kernel.Consensus": "Information", + "AElf": "Information" } } } \ No newline at end of file From 33b0f23fafce9b06c0f78f029cd9aa042fa83643 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Thu, 18 Jul 2024 14:28:15 +0800 Subject: [PATCH 6/8] Retrigger sonarqube --- .../GenesisSmartContractDtoProviderBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs index f595099ffe..d056ecd523 100644 --- a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs +++ b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs @@ -25,7 +25,7 @@ public virtual IEnumerable GetGenesisSmartContractDtos( { var contractCodes = GetContractCodes(); var deploymentList = ContractDeploymentListProvider.GetDeployContractNameList(); - return ContractInitializationProviders + return ContractInitializationProviders .GroupBy(p => p.SystemSmartContractName) .Where(g => deploymentList.Contains(g.Key)) .OrderBy(g => deploymentList.IndexOf(g.Key)) From 45027f09f5408cb2dda857aace61d4bcd305182d Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Thu, 18 Jul 2024 14:37:59 +0800 Subject: [PATCH 7/8] Retrigger sonarqube --- .../GenesisSmartContractDtoProviderBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs index d056ecd523..f595099ffe 100644 --- a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs +++ b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs @@ -25,7 +25,7 @@ public virtual IEnumerable GetGenesisSmartContractDtos( { var contractCodes = GetContractCodes(); var deploymentList = ContractDeploymentListProvider.GetDeployContractNameList(); - return ContractInitializationProviders + return ContractInitializationProviders .GroupBy(p => p.SystemSmartContractName) .Where(g => deploymentList.Contains(g.Key)) .OrderBy(g => deploymentList.IndexOf(g.Key)) From bcc764de16a4eb1545a897d92e71f3e256e7eb49 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Thu, 18 Jul 2024 14:45:05 +0800 Subject: [PATCH 8/8] Retrigger sonarqube --- .../GenesisSmartContractDtoProviderBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs index f595099ffe..d056ecd523 100644 --- a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs +++ b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs @@ -25,7 +25,7 @@ public virtual IEnumerable GetGenesisSmartContractDtos( { var contractCodes = GetContractCodes(); var deploymentList = ContractDeploymentListProvider.GetDeployContractNameList(); - return ContractInitializationProviders + return ContractInitializationProviders .GroupBy(p => p.SystemSmartContractName) .Where(g => deploymentList.Contains(g.Key)) .OrderBy(g => deploymentList.IndexOf(g.Key))