From b5fd4ec9024fa5d76d88f3eb95e197a6b3d0fa09 Mon Sep 17 00:00:00 2001 From: Vitor Nazario Coelho Date: Thu, 5 Dec 2024 15:51:36 -0300 Subject: [PATCH 1/7] First commit and no format --- benchmarks/Neo.Benchmarks/config.json | 4 ++-- docs/config.json.md | 4 ++-- src/Neo.CLI/config.fs.mainnet.json | 4 ++-- src/Neo.CLI/config.fs.testnet.json | 4 ++-- src/Neo.CLI/config.json | 4 ++-- src/Neo.CLI/config.mainnet.json | 4 ++-- src/Neo.CLI/config.testnet.json | 4 ++-- src/Neo/ProtocolSettings.cs | 6 +++--- .../DBFTPlugin/Consensus/ConsensusService.Check.cs | 4 ++-- .../Consensus/ConsensusService.OnMessage.cs | 12 ++++++------ .../StateService/Verification/VerificationContext.cs | 2 +- tests/Neo.Network.RPC.Tests/RpcTestCases.json | 2 +- tests/Neo.Plugins.OracleService.Tests/config.json | 4 ++-- tests/Neo.UnitTests/UT_ProtocolSettings.cs | 6 +++--- tests/Neo.UnitTests/test.config.json | 4 ++-- 15 files changed, 34 insertions(+), 34 deletions(-) diff --git a/benchmarks/Neo.Benchmarks/config.json b/benchmarks/Neo.Benchmarks/config.json index 01471e4c76..c69d08ab43 100644 --- a/benchmarks/Neo.Benchmarks/config.json +++ b/benchmarks/Neo.Benchmarks/config.json @@ -27,8 +27,8 @@ "ProtocolConfiguration": { "Network": 860833102, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 512, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": { diff --git a/docs/config.json.md b/docs/config.json.md index b32b1f2f8f..55a53bd840 100644 --- a/docs/config.json.md +++ b/docs/config.json.md @@ -42,10 +42,10 @@ This README provides an explanation for each field in the JSON configuration fil - **AddressVersion**: Version byte used in Neo address generation. Default is `53`. ### MillisecondsPerBlock -- **MillisecondsPerBlock**: Time interval between blocks in milliseconds. Default is `15000` (15 seconds). +- **MillisecondsPerBlock**: Time interval between blocks in milliseconds. Default is `3600` (3 seconds). ### MaxTransactionsPerBlock -- **MaxTransactionsPerBlock**: Maximum number of transactions allowed per block. Default is `512`. +- **MaxTransactionsPerBlock**: Maximum number of transactions allowed per block. Default is `256`. ### MemoryPoolMaxTransactions - **MemoryPoolMaxTransactions**: Maximum number of transactions that can be held in the memory pool. Default is `50000`. diff --git a/src/Neo.CLI/config.fs.mainnet.json b/src/Neo.CLI/config.fs.mainnet.json index 6879232732..3faeb30724 100644 --- a/src/Neo.CLI/config.fs.mainnet.json +++ b/src/Neo.CLI/config.fs.mainnet.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 91414437, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 512, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 17280, "InitialGasDistribution": 5200000000000000, diff --git a/src/Neo.CLI/config.fs.testnet.json b/src/Neo.CLI/config.fs.testnet.json index 9dc2d3b72f..505dd8985e 100644 --- a/src/Neo.CLI/config.fs.testnet.json +++ b/src/Neo.CLI/config.fs.testnet.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 91466898, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 512, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 17280, "InitialGasDistribution": 5200000000000000, diff --git a/src/Neo.CLI/config.json b/src/Neo.CLI/config.json index 772a221714..d243cf4771 100644 --- a/src/Neo.CLI/config.json +++ b/src/Neo.CLI/config.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 860833102, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 512, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": { diff --git a/src/Neo.CLI/config.mainnet.json b/src/Neo.CLI/config.mainnet.json index 772a221714..d243cf4771 100644 --- a/src/Neo.CLI/config.mainnet.json +++ b/src/Neo.CLI/config.mainnet.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 860833102, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 512, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": { diff --git a/src/Neo.CLI/config.testnet.json b/src/Neo.CLI/config.testnet.json index dc102be54b..4057bac48f 100644 --- a/src/Neo.CLI/config.testnet.json +++ b/src/Neo.CLI/config.testnet.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 894710606, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 5000, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": { diff --git a/src/Neo/ProtocolSettings.cs b/src/Neo/ProtocolSettings.cs index 19011dc24c..d13dee5bb4 100644 --- a/src/Neo/ProtocolSettings.cs +++ b/src/Neo/ProtocolSettings.cs @@ -69,7 +69,7 @@ public record ProtocolSettings /// /// The maximum increment of the field. /// - public uint MaxValidUntilBlockIncrement => 86400000 / MillisecondsPerBlock; + public uint MaxValidUntilBlockIncrement => 86400000 / MillisecondsPerBlock; //TODO keep the same?? /// /// Indicates the maximum number of transactions that can be contained in a block. @@ -113,8 +113,8 @@ public record ProtocolSettings StandbyCommittee = Array.Empty(), ValidatorsCount = 0, SeedList = Array.Empty(), - MillisecondsPerBlock = 15000, - MaxTransactionsPerBlock = 512, + MillisecondsPerBlock = 3000, + MaxTransactionsPerBlock = 256, MemoryPoolMaxTransactions = 50_000, MaxTraceableBlocks = 2_102_400, InitialGasDistribution = 52_000_000_00000000, diff --git a/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs b/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs index c6ba86ee86..3f380d6ac1 100644 --- a/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs +++ b/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs @@ -46,8 +46,8 @@ private bool CheckPrepareResponse() } // Timeout extension due to prepare response sent - // around 2*15/M=30.0/5 ~ 40% block time (for M=5) - ExtendTimerByFactor(2); + // around 4*3/M=12.0/5 ~ 80% block time (for M=5) + ExtendTimerByFactor(4); Log($"Sending {nameof(PrepareResponse)}"); localNode.Tell(new LocalNode.SendDirectly { Inventory = context.MakePrepareResponse() }); diff --git a/src/Plugins/DBFTPlugin/Consensus/ConsensusService.OnMessage.cs b/src/Plugins/DBFTPlugin/Consensus/ConsensusService.OnMessage.cs index b00fdd9393..456cc1ed71 100644 --- a/src/Plugins/DBFTPlugin/Consensus/ConsensusService.OnMessage.cs +++ b/src/Plugins/DBFTPlugin/Consensus/ConsensusService.OnMessage.cs @@ -95,8 +95,8 @@ private void OnPrepareRequestReceived(ExtensiblePayload payload, PrepareRequest } // Timeout extension: prepare request has been received with success - // around 2*15/M=30.0/5 ~ 40% block time (for M=5) - ExtendTimerByFactor(2); + // around 4*3/M=12.0/5 ~ 80% block time (for M=5) + ExtendTimerByFactor(4); context.Block.Header.Timestamp = message.Timestamp; context.Block.Header.Nonce = message.Nonce; @@ -171,8 +171,8 @@ private void OnPrepareResponseReceived(ExtensiblePayload payload, PrepareRespons return; // Timeout extension: prepare response has been received with success - // around 2*15/M=30.0/5 ~ 40% block time (for M=5) - ExtendTimerByFactor(2); + // around 4*3/M=12.0/5 ~ 80% block time (for M=5) + ExtendTimerByFactor(4); Log($"{nameof(OnPrepareResponseReceived)}: height={message.BlockIndex} view={message.ViewNumber} index={message.ValidatorIndex}"); context.PreparationPayloads[message.ValidatorIndex] = payload; @@ -210,8 +210,8 @@ private void OnCommitReceived(ExtensiblePayload payload, Commit commit) if (commit.ViewNumber == context.ViewNumber) { // Timeout extension: commit has been received with success - // around 4*15s/M=60.0s/5=12.0s ~ 80% block time (for M=5) - ExtendTimerByFactor(4); + // around 6*3s/M=18.0s/5=12.0s ~ 120% block time (for M=5) + ExtendTimerByFactor(6); Log($"{nameof(OnCommitReceived)}: height={commit.BlockIndex} view={commit.ViewNumber} index={commit.ValidatorIndex} nc={context.CountCommitted} nf={context.CountFailed}"); diff --git a/src/Plugins/StateService/Verification/VerificationContext.cs b/src/Plugins/StateService/Verification/VerificationContext.cs index feaf591795..bdea3c9e40 100644 --- a/src/Plugins/StateService/Verification/VerificationContext.cs +++ b/src/Plugins/StateService/Verification/VerificationContext.cs @@ -27,7 +27,7 @@ namespace Neo.Plugins.StateService.Verification { class VerificationContext { - private const uint MaxValidUntilBlockIncrement = 100; + private const uint MaxValidUntilBlockIncrement = 100; // Change to 500!?? private StateRoot root; private ExtensiblePayload rootPayload; private ExtensiblePayload votePayload; diff --git a/tests/Neo.Network.RPC.Tests/RpcTestCases.json b/tests/Neo.Network.RPC.Tests/RpcTestCases.json index 623b59f0d9..455bafe528 100644 --- a/tests/Neo.Network.RPC.Tests/RpcTestCases.json +++ b/tests/Neo.Network.RPC.Tests/RpcTestCases.json @@ -3148,7 +3148,7 @@ "protocol": { "network": 0, "validatorscount": 0, - "msperblock": 15000, + "msperblock": 3000, "maxvaliduntilblockincrement": 1, "maxtraceableblocks": 1, "addressversion": 0, diff --git a/tests/Neo.Plugins.OracleService.Tests/config.json b/tests/Neo.Plugins.OracleService.Tests/config.json index edcd76127a..a59f24f16a 100644 --- a/tests/Neo.Plugins.OracleService.Tests/config.json +++ b/tests/Neo.Plugins.OracleService.Tests/config.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 5195086, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 512, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": { diff --git a/tests/Neo.UnitTests/UT_ProtocolSettings.cs b/tests/Neo.UnitTests/UT_ProtocolSettings.cs index 97a36e5907..1481d5d517 100644 --- a/tests/Neo.UnitTests/UT_ProtocolSettings.cs +++ b/tests/Neo.UnitTests/UT_ProtocolSettings.cs @@ -46,7 +46,7 @@ public void TestGetMemoryPoolMaxTransactions() [TestMethod] public void TestGetMillisecondsPerBlock() { - TestProtocolSettings.Default.MillisecondsPerBlock.Should().Be(15000); + TestProtocolSettings.Default.MillisecondsPerBlock.Should().Be(3000); } [TestMethod] @@ -131,8 +131,8 @@ internal static string CreateHFSettings(string hf) ""ProtocolConfiguration"": { ""Network"": 860833102, ""AddressVersion"": 53, - ""MillisecondsPerBlock"": 15000, - ""MaxTransactionsPerBlock"": 512, + ""MillisecondsPerBlock"": 3000, + ""MaxTransactionsPerBlock"": 256, ""MemoryPoolMaxTransactions"": 50000, ""MaxTraceableBlocks"": 2102400, ""Hardforks"": { diff --git a/tests/Neo.UnitTests/test.config.json b/tests/Neo.UnitTests/test.config.json index 0d2f885da6..e502c0b703 100644 --- a/tests/Neo.UnitTests/test.config.json +++ b/tests/Neo.UnitTests/test.config.json @@ -25,8 +25,8 @@ "ProtocolConfiguration": { "Network": 860833102, "AddressVersion": 53, - "MillisecondsPerBlock": 15000, - "MaxTransactionsPerBlock": 512, + "MillisecondsPerBlock": 3000, + "MaxTransactionsPerBlock": 256, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": {}, From 91c4bd2c8ebc710075494c6418abfb4c4024920f Mon Sep 17 00:00:00 2001 From: Vitor Nazario Coelho Date: Thu, 5 Dec 2024 16:01:06 -0300 Subject: [PATCH 2/7] Start adjusting param but devcontainer not working --- src/Neo/SmartContract/Native/NeoToken.cs | 3 +++ tests/Neo.UnitTests/SmartContract/Native/UT_NeoToken.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/NeoToken.cs b/src/Neo/SmartContract/Native/NeoToken.cs index 85309b4246..a3344632a6 100644 --- a/src/Neo/SmartContract/Native/NeoToken.cs +++ b/src/Neo/SmartContract/Native/NeoToken.cs @@ -188,6 +188,9 @@ internal override ContractTask InitializeAsync(ApplicationEngine engine, Hardfor engine.SnapshotCache.Add(CreateStorageKey(Prefix_Committee), new StorageItem(cachedCommittee)); engine.SnapshotCache.Add(CreateStorageKey(Prefix_VotersCount), new StorageItem(System.Array.Empty())); engine.SnapshotCache.Add(CreateStorageKey(Prefix_GasPerBlock).AddBigEndian(0u), new StorageItem(5 * GAS.Factor)); + // TODO - Add hardfork otherwise storage will be different + // After HARD FORK + engine.SnapshotCache.Add(CreateStorageKey(Prefix_GasPerBlock).AddBigEndian(0u), new StorageItem(5 * GAS.Factor)); engine.SnapshotCache.Add(CreateStorageKey(Prefix_RegisterPrice), new StorageItem(1000 * GAS.Factor)); return Mint(engine, Contract.GetBFTAddress(engine.ProtocolSettings.StandbyValidators), TotalAmount, false); } diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_NeoToken.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_NeoToken.cs index 2ff07d5a69..853d3e379a 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_NeoToken.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_NeoToken.cs @@ -744,7 +744,7 @@ public void TestEconomicParameter() (BigInteger, bool) result = Check_GetGasPerBlock(clonedCache, persistingBlock); result.Item2.Should().BeTrue(); - result.Item1.Should().Be(5 * NativeContract.GAS.Factor); + result.Item1.Should().Be(5 * NativeContract.GAS.Factor); // Test should occur with all hardfork enable TODO persistingBlock = new Block { Header = new Header { Index = 10 } }; (VM.Types.Boolean, bool) result1 = Check_SetGasPerBlock(clonedCache, 10 * NativeContract.GAS.Factor, persistingBlock); From 3329c54296b1f476582facea5851bdcd54976e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Naz=C3=A1rio=20Coelho?= Date: Sat, 7 Dec 2024 10:42:13 -0300 Subject: [PATCH 3/7] Update docs/config.json.md Co-authored-by: Christopher Schuchardt --- docs/config.json.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.json.md b/docs/config.json.md index 55a53bd840..3f9fc61a79 100644 --- a/docs/config.json.md +++ b/docs/config.json.md @@ -42,7 +42,7 @@ This README provides an explanation for each field in the JSON configuration fil - **AddressVersion**: Version byte used in Neo address generation. Default is `53`. ### MillisecondsPerBlock -- **MillisecondsPerBlock**: Time interval between blocks in milliseconds. Default is `3600` (3 seconds). +- **MillisecondsPerBlock**: Time interval between blocks in milliseconds. Default is `3000` (3 seconds). ### MaxTransactionsPerBlock - **MaxTransactionsPerBlock**: Maximum number of transactions allowed per block. Default is `256`. From 739beaf2434a4b7416b481d8c0bf90fc4f865842 Mon Sep 17 00:00:00 2001 From: Vitor Nazario Coelho Date: Mon, 9 Dec 2024 18:59:30 -0300 Subject: [PATCH 4/7] format --- src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs b/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs index 3f380d6ac1..71bd904be2 100644 --- a/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs +++ b/src/Plugins/DBFTPlugin/Consensus/ConsensusService.Check.cs @@ -46,8 +46,8 @@ private bool CheckPrepareResponse() } // Timeout extension due to prepare response sent - // around 4*3/M=12.0/5 ~ 80% block time (for M=5) - ExtendTimerByFactor(4); + // around 4*3/M=12.0/5 ~ 80% block time (for M=5) + ExtendTimerByFactor(4); Log($"Sending {nameof(PrepareResponse)}"); localNode.Tell(new LocalNode.SendDirectly { Inventory = context.MakePrepareResponse() }); From cd914402d1fab5fd617230c3d81022d7a7fb7463 Mon Sep 17 00:00:00 2001 From: Shargon Date: Thu, 12 Dec 2024 00:52:35 -0800 Subject: [PATCH 5/7] Update src/Neo.CLI/config.fs.mainnet.json --- src/Neo.CLI/config.fs.mainnet.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Neo.CLI/config.fs.mainnet.json b/src/Neo.CLI/config.fs.mainnet.json index 3faeb30724..6879232732 100644 --- a/src/Neo.CLI/config.fs.mainnet.json +++ b/src/Neo.CLI/config.fs.mainnet.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 91414437, "AddressVersion": 53, - "MillisecondsPerBlock": 3000, - "MaxTransactionsPerBlock": 256, + "MillisecondsPerBlock": 15000, + "MaxTransactionsPerBlock": 512, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 17280, "InitialGasDistribution": 5200000000000000, From 26b1e587f4ace458795a450c3c06b85c1820ba6e Mon Sep 17 00:00:00 2001 From: Shargon Date: Thu, 12 Dec 2024 00:53:22 -0800 Subject: [PATCH 6/7] Update src/Neo.CLI/config.json --- src/Neo.CLI/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Neo.CLI/config.json b/src/Neo.CLI/config.json index d243cf4771..772a221714 100644 --- a/src/Neo.CLI/config.json +++ b/src/Neo.CLI/config.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 860833102, "AddressVersion": 53, - "MillisecondsPerBlock": 3000, - "MaxTransactionsPerBlock": 256, + "MillisecondsPerBlock": 15000, + "MaxTransactionsPerBlock": 512, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": { From 3b52a3ce63f9300ff3c4cda89fbbbe82bb3dbc4d Mon Sep 17 00:00:00 2001 From: Shargon Date: Thu, 12 Dec 2024 00:53:40 -0800 Subject: [PATCH 7/7] Update src/Neo.CLI/config.mainnet.json --- src/Neo.CLI/config.mainnet.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Neo.CLI/config.mainnet.json b/src/Neo.CLI/config.mainnet.json index d243cf4771..772a221714 100644 --- a/src/Neo.CLI/config.mainnet.json +++ b/src/Neo.CLI/config.mainnet.json @@ -30,8 +30,8 @@ "ProtocolConfiguration": { "Network": 860833102, "AddressVersion": 53, - "MillisecondsPerBlock": 3000, - "MaxTransactionsPerBlock": 256, + "MillisecondsPerBlock": 15000, + "MaxTransactionsPerBlock": 512, "MemoryPoolMaxTransactions": 50000, "MaxTraceableBlocks": 2102400, "Hardforks": {