Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Release/1.0.9.5 to SidechainMasternode #683

Merged
merged 16 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FederationSetup/FederationSetup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.7.2</Version>
<Version>1.0.9.4</Version>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/FodyNlogAdapter/FodyNlogAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>FodyNlogAdapter</AssemblyName>
<Version>1.0.7.2</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
<PackageId>Stratis.Utils.FodyNlogAdapter</PackageId>
Expand Down
6 changes: 5 additions & 1 deletion src/NBitcoin/ChainStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace NBitcoin
{
public interface IChainStore
public interface IChainStore : IDisposable
{
BlockHeader GetHeader(ChainedHeader chainedHeader, uint256 hash);

Expand Down Expand Up @@ -90,5 +90,9 @@ public void PutChainData(IEnumerable<ChainDataItem> items)
foreach (ChainDataItem item in items)
this.chainData.TryAdd(item.Height, item.Data);
}

public void Dispose()
{
}
}
}
2 changes: 1 addition & 1 deletion src/NBitcoin/NBitcoin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>4.0.0.81</Version>
<Version>4.0.0.82</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
18 changes: 13 additions & 5 deletions src/Stratis.Bitcoin.Api.Tests/ApiSettingsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ namespace Stratis.Bitcoin.Api.Tests
/// <summary>
/// Tests the settings for the API features.
/// </summary>
public class ApiSettingsTest : TestBase
public class ApiSettingsTest : TestBase, IDisposable
{
private IFullNode fullNode;

public ApiSettingsTest() : base(KnownNetworks.Main)
{
}
Expand Down Expand Up @@ -266,14 +268,20 @@ public void GivenUseHttpsAndNoCertificateFilePath_ThenShouldThrowConfigurationEx
settingsAction.Should().Throw<ConfigurationException>();
}

private static ApiSettings FullNodeSetup(NodeSettings nodeSettings)
private ApiSettings FullNodeSetup(NodeSettings nodeSettings)
{
return new FullNodeBuilder()
this.fullNode = new FullNodeBuilder()
.UseNodeSettings(nodeSettings)
.UseApi()
.UsePowConsensus()
.Build()
.NodeService<ApiSettings>();
.Build();

return this.fullNode.NodeService<ApiSettings>();
}

public void Dispose()
{
this.fullNode.NodeService<IChainStore>().Dispose();
}
}
}
2 changes: 1 addition & 1 deletion src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.7.2</Version>
<Version>1.0.9.4</Version>
<Authors>Stratis Group Ltd.</Authors>
<Company>Stratis Group Ltd.</Company>
<Product />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>Stratis.Bitcoin.Features.Api</AssemblyName>
<OutputType>Library</OutputType>
<PackageId>Stratis.Features.Api</PackageId>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<ApplicationIcon />
<OutputTypeEx>library</OutputTypeEx>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<Authors>Stratis Group Ltd.</Authors>
<PackageId>Stratis.Features.Interop</PackageId>
<Product>Stratis.Features.Interop</Product>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<OutputTypeEx>library</OutputTypeEx>
<Authors>Stratis Group Ltd.</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Product />
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using NBitcoin;
using Stratis.Bitcoin.Base;
using Stratis.Bitcoin.Consensus;
using Stratis.Bitcoin.Consensus.Rules;
using Stratis.Bitcoin.Utilities;

namespace Stratis.Bitcoin.Features.PoA.BasePoAFeatureConsensusRules
{
Expand All @@ -26,6 +28,8 @@ public class PoAHeaderSignatureRule : FullValidationConsensusRule

private Network network;

private HashHeightPair lastCheckPoint;

/// <inheritdoc />
public override void Initialize()
{
Expand All @@ -41,10 +45,17 @@ public override void Initialize()
this.network = this.Parent.Network;

this.maxReorg = this.network.Consensus.MaxReorgLength;

KeyValuePair<int, CheckpointInfo> lastCheckPoint = engine.Network.Checkpoints.LastOrDefault();
this.lastCheckPoint = (lastCheckPoint.Value != null) ? new HashHeightPair(lastCheckPoint.Value.Hash, lastCheckPoint.Key) : null;
}

public override async Task RunAsync(RuleContext context)
{
// Only start validating at the last checkpoint block.
if (context.ValidationContext.ChainedHeaderToValidate.Height < (this.lastCheckPoint?.Height ?? 0))
return;

ChainedHeader chainedHeader = context.ValidationContext.ChainedHeaderToValidate;

var header = chainedHeader.Header as PoABlockHeader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<PackageId>Stratis.Features.SignalR</PackageId>
<Product>Stratis.Features.SignalR</Product>
<Authors>Stratis Group Ltd.</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<Authors>Stratis Group Ltd.</Authors>
<PackageId>Stratis.Features.SmartContracts</PackageId>
<Product>Stratis.Features.SmartContracts</Product>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Product />
</PropertyGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/Stratis.Bitcoin.IntegrationTests/CoinViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,15 @@ public void CanSaveChainIncrementally()
var chain = new ChainIndexer(this.regTest);
var data = new DataFolder(TestBase.CreateTestDir(this));

using (var repo = new ChainRepository(new LevelDbChainStore(this.network, data, chain)))
var chainStore = new LevelDbChainStore(this.network, data, chain);
chain[0].SetChainStore(chainStore);

using (var repo = new ChainRepository(chainStore))
{
chain.SetTip(repo.LoadAsync(chain.Genesis).GetAwaiter().GetResult());
Assert.True(chain.Tip == chain.Genesis);
chain = new ChainIndexer(this.regTest);
chain[0].SetChainStore(chainStore);
ChainedHeader tip = this.AppendBlock(chain);
repo.SaveAsync(chain).GetAwaiter().GetResult();
var newChain = new ChainIndexer(this.regTest);
Expand Down
6 changes: 3 additions & 3 deletions src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<AssemblyVersion>1.0.9.0</AssemblyVersion>
<FileVersion>1.0.9.0</FileVersion>
<Version>1.0.9.0</Version>
<AssemblyVersion>1.0.9.4</AssemblyVersion>
<FileVersion>1.0.9.4</FileVersion>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>1.0.9.0</Version>
<Version>1.0.9.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
</PropertyGroup>

Expand Down
7 changes: 6 additions & 1 deletion src/Stratis.Bitcoin.Tests/Base/ChainRepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,20 @@ public void LoadChainFromDisk()
new ChainRepository.ChainRepositoryData()
{ Hash = block.HashBlock, Work = block.ChainWorkBytes }
.ToBytes(this.Network.Consensus.ConsensusFactory));

ConsensusFactory consensusFactory = KnownNetworks.StraxRegTest.Consensus.ConsensusFactory;
batch.Put(2, block.Header.GetHash().ToBytes(), block.Header.ToBytes(consensusFactory));
}

engine.Write(batch);
}
}

using (var repo = new ChainRepository(new LevelDbChainStore(chain.Network, new DataFolder(dir), chain)))
var chainStore = new LevelDbChainStore(chain.Network, new DataFolder(dir), chain);
using (var repo = new ChainRepository(chainStore))
{
var testChain = new ChainIndexer(KnownNetworks.StraxRegTest);
testChain[0].SetChainStore(chainStore);
testChain.SetTip(repo.LoadAsync(testChain.Genesis).GetAwaiter().GetResult());
Assert.Equal(tip, testChain.Tip);
}
Expand Down
22 changes: 15 additions & 7 deletions src/Stratis.Bitcoin/Base/BaseFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,24 +390,32 @@ public static IFullNodeBuilder UseBaseFeature(this IFullNodeBuilder fullNodeBuil
services.AddSingleton<ISignals, Signals.Signals>();
services.AddSingleton<ISubscriptionErrorHandler, DefaultSubscriptionErrorHandler>();
services.AddSingleton<FullNode>().AddSingleton((provider) => { return provider.GetService<FullNode>() as IFullNode; });
services.AddSingleton(new ChainIndexer(fullNodeBuilder.Network));
services.AddSingleton(DateTimeProvider.Default);
services.AddSingleton<IInvalidBlockHashStore, InvalidBlockHashStore>();
services.AddSingleton<IChainState, ChainState>();
services.AddSingleton<IChainRepository, ChainRepository>();

ChainIndexer chainIndexer = new ChainIndexer(fullNodeBuilder.Network);
IChainStore chainStore = null;

if (dbType == DbType.Leveldb)
{
services.AddSingleton<IChainStore, LevelDbChainStore>();
chainStore = new LevelDbChainStore(fullNodeBuilder.Network, fullNodeBuilder.NodeSettings.DataFolder, chainIndexer);
services.AddSingleton<IKeyValueRepository, LevelDbKeyValueRepository>();
}

if (dbType == DbType.RocksDb)
{
services.AddSingleton<IChainStore, RocksDbChainStore>();
chainStore = new RocksDbChainStore(fullNodeBuilder.Network, fullNodeBuilder.NodeSettings.DataFolder, chainIndexer);
services.AddSingleton<IKeyValueRepository, RocksDbKeyValueRepository>();
}

chainIndexer[0].SetChainStore(chainStore);

services.AddSingleton(chainStore);
services.AddSingleton(chainIndexer);

services.AddSingleton(DateTimeProvider.Default);
services.AddSingleton<IInvalidBlockHashStore, InvalidBlockHashStore>();
services.AddSingleton<IChainState, ChainState>();
services.AddSingleton<IChainRepository, ChainRepository>();

services.AddSingleton<IFinalizedBlockInfoRepository, FinalizedBlockInfoRepository>();
services.AddSingleton<ITimeSyncBehaviorState, TimeSyncBehaviorState>();
services.AddSingleton<NodeDeployments>();
Expand Down
Loading