Skip to content
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
5 changes: 5 additions & 0 deletions src/Stratis.Bitcoin.Features.PoA/PoAConsensusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public class PoAConsensusOptions : ConsensusOptions
/// </summary>
public int InterFluxV2MainChainActivationHeight { get; set; }

/// <summary>
/// The height at which Release 1.3.0.0 became BIP activated.
/// </summary>
public int Release1300ActivationHeight { get; set; }

/// <summary>
/// The height at which inituitive mining slots become active.
/// Legacy mining slots are determined by mining_slot = block_height % number_of_federation_members.
Expand Down
6 changes: 1 addition & 5 deletions src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,7 @@ private void ProcessBlock(DBreeze.Transactions.Transaction transaction, ChainedH
// Hence, if the poll does not exist then this is not a valid vote.
if (data.Key == VoteKey.AddFederationMember)
{
int release1300ActivationHeight = 0;
if (this.nodeDeployments?.BIP9.ArraySize > 0 /* Not NoBIP9Deployments */)
release1300ActivationHeight = this.nodeDeployments.BIP9.ActivationHeightProviders[0 /* Release1300 */].ActivationHeight;

if (chBlock.ChainedHeader.Height >= release1300ActivationHeight)
if (chBlock.ChainedHeader.Height >= this.poaConsensusOptions.Release1300ActivationHeight)
continue;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Stratis.Features.Collateral/CollateralChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public class CollateralChecker : ICollateralChecker
/// <summary>
/// The number of Strax blocks the collateral should remain above the threshold to be suiable for mining a block.
/// </summary>
private const int collateralMaturationPeriod = 500;
/// <remarks>This value is added to the maxReorgLength of 240 for a confirmnation period of 500 in total.</remarks>
private const int collateralMaturationPeriod = 260;

private readonly IBlockStoreClient blockStoreClient;

Expand Down Expand Up @@ -270,7 +271,7 @@ public bool CheckCollateral(IFederationMember federationMember, int heightToChec

int release1320ActivationHeight = 0;
if (this.nodeDeployments?.BIP9.ArraySize > 0 /* Not NoBIP9Deployments */)
release1320ActivationHeight = this.nodeDeployments.BIP9.ActivationHeightProviders[1 /* Release1320 */].ActivationHeight;
release1320ActivationHeight = this.nodeDeployments.BIP9.ActivationHeightProviders[0 /* Release1320 */].ActivationHeight;

// Legacy behavior before activation.
if (localChainHeight < release1320ActivationHeight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,7 @@ public void OnBlockConnected(VotingManagerProcessBlock blockConnectedData)
Data = federationMemberBytes
};

int release1300ActivationHeight = 0;
if (this.nodeDeployments?.BIP9.ArraySize > 0 /* Not NoBIP9Deployments */)
{
release1300ActivationHeight = this.nodeDeployments.BIP9.ActivationHeightProviders[0 /* Release1300 */].ActivationHeight;
this.logger.LogDebug($"{nameof(release1300ActivationHeight)}:{release1300ActivationHeight}");
}

if (blockConnectedData.ConnectedBlock.ChainedHeader.Height >= release1300ActivationHeight)
if (blockConnectedData.ConnectedBlock.ChainedHeader.Height >= ((PoAConsensusOptions)this.network.Consensus.Options).Release1300ActivationHeight)
{
// If we are executing this from the miner, there will be no transaction present.
if (blockConnectedData.PollsRepositoryTransaction == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Stratis.Bitcoin;
using Stratis.Bitcoin.Base.Deployments;
using Stratis.Bitcoin.Consensus;
using Stratis.Bitcoin.Features.PoA;
using Stratis.Bitcoin.Features.Wallet;
using Stratis.Bitcoin.Networks;
using Stratis.Bitcoin.Primitives;
Expand Down Expand Up @@ -52,6 +53,9 @@ public MaturedBlocksProviderTests()
this.network = new CirrusRegTest();
this.mainChainNetwork = new StraxRegTest();

// TODO: Upgrade these tests to conform with release 1.3.0.0 activation.
((PoAConsensusOptions)this.network.Consensus.Options).Release1300ActivationHeight = int.MaxValue;

this.opReturnDataReader = Substitute.For<IOpReturnDataReader>();
this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return false; });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using NBitcoin;
using Stratis.Bitcoin.Base.Deployments;
using Stratis.Bitcoin.Features.PoA;
using Stratis.Features.FederatedPeg.Interfaces;
using Stratis.Features.FederatedPeg.TargetChain;
using Stratis.Features.PoA.Collateral.CounterChain;
Expand Down Expand Up @@ -79,7 +80,7 @@ public RetrievalTypeConfirmations(Network network, NodeDeployments nodeDeploymen
/// <inheritdoc/>
public int MaximumConfirmationsAtMaturityHeight(int maturityHeight)
{
if (maturityHeight < this.Release1300ActivationHeight)
if (maturityHeight < ((PoAConsensusOptions)this.network.Consensus.Options).Release1300ActivationHeight)
return this.legacyRetrievalTypeConfirmations.Values.Max();

return this.retrievalTypeConfirmations.Values.Max();
Expand All @@ -89,7 +90,7 @@ public int MaximumConfirmationsAtMaturityHeight(int maturityHeight)
public int GetDepositConfirmations(int depositHeight, DepositRetrievalType retrievalType)
{
// Keep everything maturity-height-centric. Otherwise the way we use MaximumConfirmationsAtMaturityHeight will have to change as well.
if (depositHeight + this.legacyRetrievalTypeConfirmations[retrievalType] < this.Release1300ActivationHeight)
if (depositHeight + this.legacyRetrievalTypeConfirmations[retrievalType] < ((PoAConsensusOptions)this.network.Consensus.Options).Release1300ActivationHeight)
return this.legacyRetrievalTypeConfirmations[retrievalType];

return this.retrievalTypeConfirmations[retrievalType];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public interface IMaturedBlocksSyncManager : IDisposable
/// <inheritdoc cref="IMaturedBlocksSyncManager"/>
public class MaturedBlocksSyncManager : IMaturedBlocksSyncManager
{
private const string Release1300DeploymentNameLower = "release1300";
private const string Release1320DeploymentNameLower = "release1320";
private readonly IAsyncProvider asyncProvider;
private readonly ICrossChainTransferStore crossChainTransferStore;
private readonly IFederationGatewayClient federationGatewayClient;
Expand Down Expand Up @@ -139,10 +139,10 @@ public void RecordCounterChainActivations()
return;
}

ThresholdActivationModel model = lockedInActivations.FirstOrDefault(a => a.DeploymentName.ToLowerInvariant() == Release1300DeploymentNameLower);
ThresholdActivationModel model = lockedInActivations.FirstOrDefault(a => a.DeploymentName.ToLowerInvariant() == Release1320DeploymentNameLower);
if (model == null || model.LockedInTimestamp == null)
{
this.logger.LogDebug("There are no locked-in deployments for '{0}'.", Release1300DeploymentNameLower);
this.logger.LogDebug("There are no locked-in deployments for '{0}'.", Release1320DeploymentNameLower);
return;
}

Expand Down
1 change: 0 additions & 1 deletion src/Stratis.Sidechains.Networks/CirrusDev.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public CirrusDev()
var bip9Deployments = new CirrusBIP9Deployments()
{
// Deployment will go active once 75% of nodes are on 1.3.0.0 or later.
[CirrusBIP9Deployments.Release1300] = new BIP9DeploymentsParameters("Release1300", CirrusBIP9Deployments.FlagBitRelease1300, DateTime.Parse("2022-3-22 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Now.AddDays(50).ToUnixTimestamp(), BIP9DeploymentsParameters.DefaultRegTestThreshold),
[CirrusBIP9Deployments.Release1320] = new BIP9DeploymentsParameters("Release1320", CirrusBIP9Deployments.FlagBitRelease1320, DateTime.Parse("2022-6-15 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Now.AddDays(50).ToUnixTimestamp(), BIP9DeploymentsParameters.DefaultRegTestThreshold)
};

Expand Down
4 changes: 2 additions & 2 deletions src/Stratis.Sidechains.Networks/CirrusMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ public CirrusMain()
PollExpiryBlocks = 50_000, // Roughly 9 days
GetMiningTimestampV2ActivationHeight = 3_709_000, // Monday 14 February 00:00:00 (Estimated)
GetMiningTimestampV2ActivationStrictHeight = 3_783_000, // Monday 28 February 07:00:00 (London Time) (Estimated)
ContractSerializerV2ActivationHeight = 3_386_335 // Monday 13 December 16:00:00 (Estimated)
ContractSerializerV2ActivationHeight = 3_386_335, // Monday 13 December 16:00:00 (Estimated)
Release1300ActivationHeight = 4_334_400
};

var buriedDeployments = new BuriedDeploymentsArray
Expand All @@ -197,7 +198,6 @@ public CirrusMain()
var bip9Deployments = new CirrusBIP9Deployments()
{
// Deployment will go active once 75% of nodes are on 1.3.0.0 or later.
[CirrusBIP9Deployments.Release1300] = new BIP9DeploymentsParameters("Release1300", CirrusBIP9Deployments.FlagBitRelease1300, DateTime.Parse("2022-3-22 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Parse("2023-1-1 +0").ToUnixTimestamp(), 1512 /* 75% Activation Threshold */),
[CirrusBIP9Deployments.Release1320] = new BIP9DeploymentsParameters("Release1320", CirrusBIP9Deployments.FlagBitRelease1320, DateTime.Parse("2022-6-15 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Parse("2023-1-1 +0").ToUnixTimestamp(), 1512 /* 75% Activation Threshold */)
};

Expand Down
1 change: 0 additions & 1 deletion src/Stratis.Sidechains.Networks/CirrusRegTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public CirrusRegTest()
var bip9Deployments = new CirrusBIP9Deployments()
{
// Deployment will go active once 75% of nodes are on 1.3.0.0 or later.
[CirrusBIP9Deployments.Release1300] = new BIP9DeploymentsParameters("Release1300", CirrusBIP9Deployments.FlagBitRelease1300, DateTime.Parse("2022-3-22 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Now.AddDays(50).ToUnixTimestamp(), BIP9DeploymentsParameters.DefaultRegTestThreshold),
[CirrusBIP9Deployments.Release1320] = new BIP9DeploymentsParameters("Release1320", CirrusBIP9Deployments.FlagBitRelease1320, DateTime.Parse("2022-6-15 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Now.AddDays(50).ToUnixTimestamp(), BIP9DeploymentsParameters.DefaultRegTestThreshold)
};

Expand Down
4 changes: 2 additions & 2 deletions src/Stratis.Sidechains.Networks/CirrusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public CirrusTest()
PollExpiryBlocks = 450,
GetMiningTimestampV2ActivationHeight = 3_000_000, // 15 January 2022
GetMiningTimestampV2ActivationStrictHeight = 3_121_500, // 17 January 2022
ContractSerializerV2ActivationHeight = 2_842_681
ContractSerializerV2ActivationHeight = 2_842_681,
Release1300ActivationHeight = 3_280_032
};

var buriedDeployments = new BuriedDeploymentsArray
Expand All @@ -148,7 +149,6 @@ public CirrusTest()
var bip9Deployments = new CirrusBIP9Deployments()
{
// Deployment will go active once 75% of nodes are on 1.3.0.0 or later.
[CirrusBIP9Deployments.Release1300] = new BIP9DeploymentsParameters("Release1300", CirrusBIP9Deployments.FlagBitRelease1300, DateTime.Parse("2022-3-28 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Parse("2023-1-1 +0").ToUnixTimestamp(), BIP9DeploymentsParameters.DefaultTestnetThreshold),
[CirrusBIP9Deployments.Release1320] = new BIP9DeploymentsParameters("Release1320", CirrusBIP9Deployments.FlagBitRelease1320, DateTime.Parse("2022-6-15 +0").ToUnixTimestamp() /* Activation date lower bound */, DateTime.Parse("2023-1-1 +0").ToUnixTimestamp(), BIP9DeploymentsParameters.DefaultRegTestThreshold)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ namespace Stratis.Sidechains.Networks.Deployments
public class CirrusBIP9Deployments : BIP9DeploymentsArray
{
// The position of each deployment in the deployments array. Note that this is decoupled from the actual position of the flag bit for the deployment in the block version.
public const int Release1300 = 0;
public const int Release1320 = 1;
public const int Release1320 = 0;

public const int FlagBitRelease1300 = 0;
public const int FlagBitRelease1320 = 1;

// The number of deployments.
public const int NumberOfDeployments = 2;
public const int NumberOfDeployments = 1;

/// <summary>
/// Constructs the BIP9 deployments array.
Expand Down