diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index df1d99c4..c308d08c 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -11,7 +11,7 @@ defaults: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - name: Checkout Ixian-DLT @@ -26,17 +26,16 @@ jobs: path: Ixian-Core ref: ${{ github.event.push.ref }} - # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16 - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' - name: Restore dependencies - run: nuget restore DLTNode.sln + run: dotnet restore - name: Building Ixian-DLT - run: msbuild DLTNode.sln + run: dotnet build - - name: Running Unit Tests - run: dotnet test UnitTests\bin\Debug\net6.0\unittests.dll --verbosity normal + #- name: Running Unit Tests + # run: dotnet test UnitTests\bin\Debug\net8.0\unittests.dll --verbosity normal diff --git a/IxianDLT/Block/BlockProcessor.cs b/IxianDLT/Block/BlockProcessor.cs index c0016cd3..beac017e 100644 --- a/IxianDLT/Block/BlockProcessor.cs +++ b/IxianDLT/Block/BlockProcessor.cs @@ -740,7 +740,7 @@ public void onBlockReceived(Block b, RemoteEndpoint endpoint = null) // remove signatures without PL entry but not if we're catching up with the network or if the chain is stuck if (IxianHandler.getHighestKnownNetworkBlockHeight() < b.blockNum + 5 - && b.timestamp + 3600 > Clock.getNetworkTimestamp()) + && b.timestamp + CoreConfig.blockSignaturePlCheckTimeout > Clock.getNetworkTimestamp()) { if (removeSignaturesWithoutPlEntry(b)) { @@ -1829,7 +1829,7 @@ public bool verifyBlockSignatures(Block block, RemoteEndpoint endpoint) if (highestNetworkBlockNum > last_block_num + 5 - || block.timestamp + 3600 < Clock.getNetworkTimestamp()) + || block.timestamp + CoreConfig.blockSignaturePlCheckTimeout < Clock.getNetworkTimestamp()) { // catching up @@ -1924,7 +1924,7 @@ public bool freezeSignatures(Block target_block) List frozen_block_sigs = null; if (highestNetworkBlockNum > target_block.blockNum + 10 - || target_block.timestamp + 3600 < Clock.getNetworkTimestamp()) + || target_block.timestamp + CoreConfig.blockSignaturePlCheckTimeout < Clock.getNetworkTimestamp()) { // catching up frozen_block_sigs = extractRequiredSignatures(target_block, required_consensus_count); @@ -4131,5 +4131,28 @@ public ulong determineHighestNetworkBlockNum() } return netBh; } + + public void applyUpdatedSolutionSignature() + { + lock (localBlockLock) + { + var lastBlockHeight = IxianHandler.getLastBlockHeight(); + if (lastBlockHeight < 5) + { + return; + } + + for (uint i = 0; i < 5; i++) + { + Block b = Node.blockChain.getBlock(lastBlockHeight - i); + BlockSignature blockSig = b.applySignature(PresenceList.getPowSolution()); + if (blockSig != null) + { + Node.inventoryCache.setProcessedFlag(InventoryItemTypes.blockSignature, InventoryItemSignature.getHash(blockSig.recipientPubKeyOrAddress.addressNoChecksum, b.blockChecksum), true); + SignatureProtocolMessages.broadcastBlockSignature(blockSig, b.blockNum, b.blockChecksum, null, null); + } + } + } + } } } diff --git a/IxianDLT/Miner/SignerPowMiner.cs b/IxianDLT/Miner/SignerPowMiner.cs index 4c53a1c9..92752f07 100644 --- a/IxianDLT/Miner/SignerPowMiner.cs +++ b/IxianDLT/Miner/SignerPowMiner.cs @@ -241,7 +241,7 @@ private void searchForBlock() var submittedSolution = PresenceList.getPowSolution(); if (lastSignerPowSolution != null - && Node.blockChain.getTimeSinceLastBlock() < 450 + && Node.blockChain.getTimeSinceLastBlock() < CoreConfig.blockSignaturePlCheckTimeout && lastSignerPowSolution.blockNum + calculationInterval + blockOffset > highestNetworkBlockHeight && (submittedSolution != null && solvingDifficulty <= submittedSolution.difficulty)) { @@ -373,17 +373,15 @@ private void sendFoundSolution() var solution = PresenceList.getPowSolution(); if (solution != null) { - ulong lastBlockHeight = IxianHandler.getLastBlockHeight(); - if (newSolution.difficulty <= solution.difficulty - && solution.blockNum + ConsensusConfig.getPlPowBlocksValidity(IxianHandler.getLastBlockVersion()) > lastBlockHeight - && solution.difficulty > solvingDifficulty) + && solution.blockNum + ConsensusConfig.getPlPowBlocksValidity(IxianHandler.getLastBlockVersion()) - 1 > IxianHandler.getHighestKnownNetworkBlockHeight() + && solution.difficulty > Node.blockChain.getMinSignerPowDifficulty(IxianHandler.getLastBlockHeight() + 1, Clock.getNetworkTimestamp())) { // If the new solution has a lower difficulty than the previously submitted solution and the previously submitted solution is still valid // Check if we're mining for at least X minutes and that the blockchain isn't stuck if (IxianHandler.getHighestKnownNetworkBlockHeight() - startedSolvingBlockHeight > ConsensusConfig.getPlPowMinCalculationBlockTime(IxianHandler.getLastBlockVersion()) - && Node.blockChain.getTimeSinceLastBlock() < 450) // TODO move 450 to CoreConfig + && Node.blockChain.getTimeSinceLastBlock() < CoreConfig.blockSignaturePlCheckTimeout) { // Reset the blockReadyForMining, to stop mining on all threads blockReadyForMining = false; @@ -394,6 +392,12 @@ private void sendFoundSolution() } PresenceList.setPowSolution(newSolution); + + if (Node.blockChain.getTimeSinceLastBlock() > CoreConfig.blockSignaturePlCheckTimeout) + { + Node.blockProcessor.applyUpdatedSolutionSignature(); + } + Node.blockProcessor.acceptLocalNewBlock(); } }