diff --git a/src/NBitcoin/BuriedDeploymentsArray.cs b/src/NBitcoin/BuriedDeploymentsArray.cs index 5143e24703..f9a8dd0c4f 100644 --- a/src/NBitcoin/BuriedDeploymentsArray.cs +++ b/src/NBitcoin/BuriedDeploymentsArray.cs @@ -4,17 +4,23 @@ namespace NBitcoin { public class BuriedDeploymentsArray { - private readonly int[] heights; + protected int[] heights; public BuriedDeploymentsArray() { - this.heights = new int[Enum.GetValues(typeof(BuriedDeployments)).Length]; + this.heights = new int[0]; + } + + protected void EnsureIndex(int index) + { + if (index >= this.heights.Length) + Array.Resize(ref this.heights, index + 1); } public int this[BuriedDeployments index] { - get => this.heights[(int)index]; - set => this.heights[(int)index] = value; + get { EnsureIndex((int)index); return this.heights[(int)index]; } + set { EnsureIndex((int)index); this.heights[(int)index] = value; } } } diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/TestPoANetwork.cs b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/TestPoANetwork.cs index 104e020f0d..bc74a9ae23 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/TestPoANetwork.cs +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/TestPoANetwork.cs @@ -48,6 +48,7 @@ public TestPoANetwork(string networkName = "") targetSpacingSeconds: 60, votingEnabled: baseOptions.VotingEnabled, autoKickIdleMembers: false, + contractSerializerV2ActivationHeight: 0, federationMemberMaxIdleTimeSeconds: baseOptions.FederationMemberMaxIdleTimeSeconds ) { diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/EnableVoteKickingTests.cs b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/EnableVoteKickingTests.cs index 97f8074144..7568f4e1fc 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/EnableVoteKickingTests.cs +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/EnableVoteKickingTests.cs @@ -32,6 +32,7 @@ public async Task EnableAutoKickAsync() targetSpacingSeconds: 60, votingEnabled: true, autoKickIdleMembers: false, + contractSerializerV2ActivationHeight: 0, federationMemberMaxIdleTimeSeconds: oldOptions.FederationMemberMaxIdleTimeSeconds); CoreNode node1 = builder.CreatePoANode(votingNetwork1, votingNetwork1.FederationKey1).Start(); @@ -54,6 +55,7 @@ public async Task EnableAutoKickAsync() targetSpacingSeconds: 60, votingEnabled: true, autoKickIdleMembers: true, + contractSerializerV2ActivationHeight: 0, federationMemberMaxIdleTimeSeconds: idleTimeSeconds); // Restart node 1 to ensure that we have the new network consensus options which reflects diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs b/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs index 6eae3eb7f5..88644c2e4b 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs @@ -189,13 +189,15 @@ public TestPoANetwork(List pubKeysOverride = null) targetSpacingSeconds: 60, votingEnabled: baseOptions.VotingEnabled, autoKickIdleMembers: baseOptions.AutoKickIdleMembers, + contractSerializerV2ActivationHeight: 0, federationMemberMaxIdleTimeSeconds: baseOptions.FederationMemberMaxIdleTimeSeconds ) { - PollExpiryBlocks = 10, - Release1100ActivationHeight = 10 + PollExpiryBlocks = 10 }; + ((PoABuriedDeploymentsArray)this.Consensus)[PoABuriedDeployments.Release1100] = 10; + this.Consensus.SetPrivatePropertyValue(nameof(this.Consensus.MaxReorgLength), (uint)5); } } diff --git a/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs b/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs index 0b631843fc..cce1951749 100644 --- a/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs +++ b/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs @@ -24,7 +24,7 @@ public class PoAHeaderSignatureRule : FullValidationConsensusRule private HashHeightPair lastCheckPoint; - private PoAConsensusOptions poAConsensusOptions; + private IConsensus consensus; /// public override void Initialize() @@ -37,7 +37,7 @@ public override void Initialize() this.slotsManager = engine.SlotsManager; this.federationHistory = engine.FederationHistory; this.validator = engine.PoaHeaderValidator; - this.poAConsensusOptions = engine.Network.Consensus.Options as PoAConsensusOptions; + this.consensus = engine.Network.Consensus; KeyValuePair lastCheckPoint = engine.Network.Checkpoints.LastOrDefault(); this.lastCheckPoint = (lastCheckPoint.Value != null) ? new HashHeightPair(lastCheckPoint.Value.Hash, lastCheckPoint.Key) : null; @@ -75,7 +75,7 @@ public override Task RunAsync(RuleContext context) PoAConsensusErrors.InvalidHeaderSignature.Throw(); } - if (chainedHeader.Height >= this.poAConsensusOptions.GetMiningTimestampV2ActivationStrictHeight) + if (chainedHeader.Height >= this.consensus.PoABuriedDeployments(PoABuriedDeployments.GetMiningTimestampV2Strict)) { uint expectedSlot = this.slotsManager.GetMiningTimestamp(chainedHeader.Previous, chainedHeader.Header.Time, pubKey); diff --git a/src/Stratis.Bitcoin.Features.PoA/FederationHistory.cs b/src/Stratis.Bitcoin.Features.PoA/FederationHistory.cs index bdd3a3d18a..33e71833af 100644 --- a/src/Stratis.Bitcoin.Features.PoA/FederationHistory.cs +++ b/src/Stratis.Bitcoin.Features.PoA/FederationHistory.cs @@ -173,7 +173,7 @@ private IFederationMember[] GetFederationMembersForBlocks(ChainedHeader lastHead IFederationMember[] miners = new IFederationMember[headers.Length]; // Reading chainedHeader's "Header" does not play well with asynchronocity so we will load the block times here. - int votingManagerV2ActivationHeight = (this.network.Consensus.Options as PoAConsensusOptions).VotingManagerV2ActivationHeight; + int votingManagerV2ActivationHeight = this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.VotingManagerV2); int startHeight = lastHeader.Height + 1 - count; diff --git a/src/Stratis.Bitcoin.Features.PoA/PoAConsensusOptions.cs b/src/Stratis.Bitcoin.Features.PoA/PoAConsensusOptions.cs index 2d93d0d1d6..ea25f42df5 100644 --- a/src/Stratis.Bitcoin.Features.PoA/PoAConsensusOptions.cs +++ b/src/Stratis.Bitcoin.Features.PoA/PoAConsensusOptions.cs @@ -1,39 +1,16 @@ using System; using System.Collections.Generic; +using System.Linq; using NBitcoin; namespace Stratis.Bitcoin.Features.PoA { - public class PoAConsensusOptions : ConsensusOptions + public enum PoABuriedDeployments { - /// Public keys and other federation members related information at the start of the chain. - /// - /// Do not use this list anywhere except for at the initialization of the chain. - /// Actual collection of the federation members can be changed with time. - /// Use as a source of - /// up to date federation keys. - /// - public List GenesisFederationMembers { get; protected set; } - - /// - /// The number of elapsed seconds required between mined block. - /// - public uint TargetSpacingSeconds { get; protected set; } - - /// Adds capability of voting for adding\kicking federation members and other things. - public bool VotingEnabled { get; protected set; } - - /// Makes federation members kick idle members. - /// Requires voting to be enabled to be set true. - public bool AutoKickIdleMembers { get; set; } - - /// Time that federation member has to be idle to be kicked by others in case is enabled. - public uint FederationMemberMaxIdleTimeSeconds { get; protected set; } - /// - /// This currently only applies to Cirrus Main Net. + /// This is the height on the main chain at which the dynamic fees paid to the multsig for interop conversion requests will activate. /// - public uint? FederationMemberActivationTime { get; set; } + InterFluxV2MainChain, /// /// The height at which a federation members will be resolved via the class. @@ -46,17 +23,46 @@ public class PoAConsensusOptions : ConsensusOptions /// method which resolves the pubkey from the signature directly. /// /// - public int VotingManagerV2ActivationHeight { get; set; } + VotingManagerV2, /// - /// This is the height on the main chain at which the dynamic fees paid to the multsig for interop conversion requests will activate. + /// Defines when V2 of the contract serializer will be used. + /// I.e if tip <= ContractSerializerV2ActivationHeight, V1 will be used. + /// + ContractSerializerV2, + + /// + /// Logic related to release 1.1.0.0 will activate at this height, this includes Poll Expiry and the Join Federation Voting Request consensus rule. /// - public int InterFluxV2MainChainActivationHeight { get; set; } + Release1100, + + /// + /// The height at which inituitive mining slots become active. + /// Legacy mining slots are determined by mining_slot = block_height % number_of_federation_members. + /// Once the specified height is reached there should no longer be a shift in mining slots when new federation members are added/removed. + /// + GetMiningTimestampV2, + + /// + /// The height at which inituitive mining slots are enfored without any lenience. + /// Currently errors are sometimes suppressed if a federation change occurred. + /// + GetMiningTimestampV2Strict, /// /// The height at which Release 1.3.0.0 became BIP activated. /// - public int Release1300ActivationHeight { get; set; } + Release1300, + + /// + /// The height at which Release 1.3.2.0 became BIP activated. + /// + Release1320, + + /// + /// The height at which Release 1.3.2.4 became BIP activated. + /// + Release1324, /// /// The height at which Release 1.4.0.0 became active. @@ -64,25 +70,39 @@ public class PoAConsensusOptions : ConsensusOptions /// This was primarily used for activating ScriptPubkey sorting for paying multisig recipients. /// /// - public int Release1400ActivationHeight { get; set; } + Release1400 + } - /// - /// The height at which inituitive mining slots become active. - /// Legacy mining slots are determined by mining_slot = block_height % number_of_federation_members. - /// Once the specified height is reached there should no longer be a shift in mining slots when new federation members are added/removed. - /// - public int GetMiningTimestampV2ActivationHeight { get; set; } + public class PoAConsensusOptions : ConsensusOptions + { + /// Public keys and other federation members related information at the start of the chain. + /// + /// Do not use this list anywhere except for at the initialization of the chain. + /// Actual collection of the federation members can be changed with time. + /// Use as a source of + /// up to date federation keys. + /// + public List GenesisFederationMembers { get; protected set; } /// - /// The height at which inituitive mining slots are enfored without any lenience. - /// Currently errors are sometimes suppressed if a federation change occurred. + /// The number of elapsed seconds required between mined block. /// - public int GetMiningTimestampV2ActivationStrictHeight { get; set; } + public uint TargetSpacingSeconds { get; protected set; } + + /// Adds capability of voting for adding\kicking federation members and other things. + public bool VotingEnabled { get; protected set; } + + /// Makes federation members kick idle members. + /// Requires voting to be enabled to be set true. + public bool AutoKickIdleMembers { get; set; } + + /// Time that federation member has to be idle to be kicked by others in case is enabled. + public uint FederationMemberMaxIdleTimeSeconds { get; protected set; } /// - /// Logic related to release 1.1.0.0 will activate at this height, this includes Poll Expiry and the Join Federation Voting Request consensus rule. + /// This currently only applies to Cirrus Main Net. /// - public int Release1100ActivationHeight { get; set; } + public uint? FederationMemberActivationTime { get; set; } /// /// Polls are expired once the tip reaches a block this far beyond the poll start block. @@ -91,8 +111,7 @@ public class PoAConsensusOptions : ConsensusOptions public int PollExpiryBlocks { get; set; } /// - /// Defines when V2 of the contract serializer will be used. - /// I.e if tip <= ContractSerializerV2ActivationHeight, V1 will be used. + /// Leaving this for now for use by Stratis.SmartContracts.CLR. /// public int ContractSerializerV2ActivationHeight { get; set; } @@ -107,6 +126,7 @@ public class PoAConsensusOptions : ConsensusOptions /// See . /// See . /// See . + /// See . public PoAConsensusOptions( uint maxBlockBaseSize, int maxStandardVersion, @@ -117,6 +137,7 @@ public PoAConsensusOptions( uint targetSpacingSeconds, bool votingEnabled, bool autoKickIdleMembers, + int contractSerializerV2ActivationHeight, uint federationMemberMaxIdleTimeSeconds = 60 * 60 * 24 * 7) : base(maxBlockBaseSize, maxStandardVersion, maxStandardTxWeight, maxBlockSigopsCost, maxStandardTxSigopsCost, witnessScaleFactor: 1) { @@ -125,7 +146,7 @@ public PoAConsensusOptions( this.VotingEnabled = votingEnabled; this.AutoKickIdleMembers = autoKickIdleMembers; this.FederationMemberMaxIdleTimeSeconds = federationMemberMaxIdleTimeSeconds; - this.InterFluxV2MainChainActivationHeight = 0; + this.ContractSerializerV2ActivationHeight = contractSerializerV2ActivationHeight; if (this.AutoKickIdleMembers && !this.VotingEnabled) throw new ArgumentException("Voting should be enabled for automatic kicking to work."); diff --git a/src/Stratis.Bitcoin.Features.PoA/PoANetwork.cs b/src/Stratis.Bitcoin.Features.PoA/PoANetwork.cs index 0680392469..c97c899e92 100644 --- a/src/Stratis.Bitcoin.Features.PoA/PoANetwork.cs +++ b/src/Stratis.Bitcoin.Features.PoA/PoANetwork.cs @@ -11,6 +11,23 @@ namespace Stratis.Bitcoin.Features.PoA { + public class PoABuriedDeploymentsArray : BuriedDeploymentsArray + { + public int this[PoABuriedDeployments index] + { + get { EnsureIndex((int)index); return this.heights[(int)index]; } + set { EnsureIndex((int)index); this.heights[(int)index] = value; } + } + } + + public static class ConsensusExt + { + public static int PoABuriedDeployments(this IConsensus consensus, PoABuriedDeployments index) + { + return ((PoABuriedDeploymentsArray)consensus.BuriedDeployments)[index]; + } + } + /// /// Example network for PoA consensus. /// @@ -106,19 +123,13 @@ public PoANetwork() genesisFederationMembers: genesisFederationMembers, targetSpacingSeconds: 16, votingEnabled: true, + contractSerializerV2ActivationHeight: 0, autoKickIdleMembers: true ) { PollExpiryBlocks = 450 }; - var buriedDeployments = new BuriedDeploymentsArray - { - [BuriedDeployments.BIP34] = 0, - [BuriedDeployments.BIP65] = 0, - [BuriedDeployments.BIP66] = 0 - }; - var bip9Deployments = new NoBIP9Deployments(); this.Consensus = new NBitcoin.Consensus( @@ -130,7 +141,7 @@ public PoANetwork() majorityEnforceBlockUpgrade: 750, majorityRejectBlockOutdated: 950, majorityWindow: 1000, - buriedDeployments: buriedDeployments, + buriedDeployments: new PoABuriedDeploymentsArray(), bip9Deployments: bip9Deployments, bip34Hash: new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"), minerConfirmationWindow: 2016, // nPowTargetTimespan / nPowTargetSpacing diff --git a/src/Stratis.Bitcoin.Features.PoA/SlotsManager.cs b/src/Stratis.Bitcoin.Features.PoA/SlotsManager.cs index e74ab4b347..048560dae4 100644 --- a/src/Stratis.Bitcoin.Features.PoA/SlotsManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/SlotsManager.cs @@ -35,6 +35,8 @@ public interface ISlotsManager public class SlotsManager : ISlotsManager { + private readonly IConsensus consensus; + private readonly PoAConsensusOptions consensusOptions; private readonly IFederationManager federationManager; @@ -50,6 +52,7 @@ public SlotsManager(Network network, IFederationManager federationManager, IFede this.federationManager = Guard.NotNull(federationManager, nameof(federationManager)); this.federationHistory = federationHistory; this.chainIndexer = chainIndexer; + this.consensus = (network as PoANetwork).Consensus; this.consensusOptions = (network as PoANetwork).ConsensusOptions; } @@ -73,7 +76,7 @@ The fact that the federation can change at any time adds extra complexity to thi The miner that mined the last block may no longer exist when the next block is about to be mined. As such we may need to look a bit further back to find a "reference miner" that still occurs in the latest federation. */ - if (tip.Height < this.consensusOptions.GetMiningTimestampV2ActivationHeight) + if (tip.Height < this.consensus.PoABuriedDeployments(PoABuriedDeployments.GetMiningTimestampV2)) return GetMiningTimestampLegacy(tip, currentTime, currentMiner); List federationMembers = this.federationHistory.GetFederationForBlock(tip, 1); diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs index 129896e406..f756cd7131 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs @@ -378,7 +378,7 @@ public List GetAllPolls(DBreeze.Transactions.Transaction transaction) private static int GetPollExpiryHeight(Poll poll, PoANetwork network) { - return Math.Max(poll.PollStartBlockData.Height + network.ConsensusOptions.PollExpiryBlocks, network.ConsensusOptions.Release1100ActivationHeight); + return Math.Max(poll.PollStartBlockData.Height + network.ConsensusOptions.PollExpiryBlocks, network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1100)); } public static int GetPollExpiryOrExecutionHeight(Poll poll, PoANetwork network) diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs index d0e1b9105b..2ea68f1f6d 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs @@ -606,7 +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) { - if (chBlock.ChainedHeader.Height >= this.poaConsensusOptions.Release1300ActivationHeight) + if (chBlock.ChainedHeader.Height >= this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1300)) continue; } @@ -990,7 +990,7 @@ private void AddComponentStats(StringBuilder log) foreach (Poll poll in pendingPolls.Where(p => !p.IsExecuted && (p.VotingData.Key == VoteKey.AddFederationMember || p.VotingData.Key == VoteKey.KickFederationMember))) { IFederationMember federationMember = ((PoAConsensusFactory)(this.network.Consensus.ConsensusFactory)).DeserializeFederationMember(poll.VotingData.Data); - string expiresIn = $", Expires In = {(Math.Max(this.poaConsensusOptions.Release1100ActivationHeight, poll.PollStartBlockData.Height + this.poaConsensusOptions.PollExpiryBlocks) - tipHeight)}"; + string expiresIn = $", Expires In = {(Math.Max(this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1100), poll.PollStartBlockData.Height + this.poaConsensusOptions.PollExpiryBlocks) - tipHeight)}"; log.Append($"{poll.VotingData.Key.ToString().PadLeft(22)}, PubKey = { federationMember.PubKey.ToHex() }, In Favor = {poll.PubKeysHexVotedInFavor.Count}{expiresIn}"); bool exists = this.federationManager.GetFederationMembers().Any(m => m.PubKey == federationMember.PubKey); if (poll.VotingData.Key == VoteKey.AddFederationMember && exists) diff --git a/src/Stratis.Features.Collateral/CheckCollateralCommitmentHeightRule.cs b/src/Stratis.Features.Collateral/CheckCollateralCommitmentHeightRule.cs index 6a385bbbd9..16a575866e 100644 --- a/src/Stratis.Features.Collateral/CheckCollateralCommitmentHeightRule.cs +++ b/src/Stratis.Features.Collateral/CheckCollateralCommitmentHeightRule.cs @@ -39,10 +39,7 @@ public override Task RunAsync(RuleContext context) } // Check that the commitment height is not less that of the prior block. - int release1324ActivationHeight = 0; - NodeDeployments nodeDeployments = this.Parent.NodeDeployments; - if (nodeDeployments.BIP9.ArraySize > 0 /* Not NoBIP9Deployments */) - release1324ActivationHeight = nodeDeployments.BIP9.ActivationHeightProviders[1 /* Release1324 */].ActivationHeight; + int release1324ActivationHeight = this.Parent.Network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1324); if (context.ValidationContext.ChainedHeaderToValidate.Height >= release1324ActivationHeight) { diff --git a/src/Stratis.Features.Collateral/CollateralChecker.cs b/src/Stratis.Features.Collateral/CollateralChecker.cs index 11e36d56e7..efc1eeab92 100644 --- a/src/Stratis.Features.Collateral/CollateralChecker.cs +++ b/src/Stratis.Features.Collateral/CollateralChecker.cs @@ -79,6 +79,8 @@ public class CollateralChecker : ICollateralChecker private readonly NodeDeployments nodeDeployments; + private readonly IConsensus consensus; + private Task updateCollateralContinuouslyTask; private bool collateralUpdated; @@ -97,6 +99,7 @@ public CollateralChecker(IHttpClientFactory httpClientFactory, ICounterChainSett this.logger = LogManager.GetCurrentClassLogger(); this.blockStoreClient = new BlockStoreClient(httpClientFactory, $"http://{settings.CounterChainApiHost}", settings.CounterChainApiPort); this.nodeDeployments = nodeDeployments; + this.consensus = network.Consensus; } public async Task InitializeAsync() @@ -271,9 +274,7 @@ public bool CheckCollateral(IFederationMember federationMember, int heightToChec return false; } - int release1320ActivationHeight = 0; - if (this.nodeDeployments?.BIP9.ArraySize > 0 /* Not NoBIP9Deployments */) - release1320ActivationHeight = this.nodeDeployments.BIP9.ActivationHeightProviders[0 /* Release1320 */].ActivationHeight; + int release1320ActivationHeight = this.consensus.PoABuriedDeployments(PoABuriedDeployments.Release1320); // Legacy behavior before activation. if (localChainHeight < release1320ActivationHeight) diff --git a/src/Stratis.Features.Collateral/ConsensusRules/VotingRequestFullValidationRule.cs b/src/Stratis.Features.Collateral/ConsensusRules/VotingRequestFullValidationRule.cs index 424734fad0..b569917d81 100644 --- a/src/Stratis.Features.Collateral/ConsensusRules/VotingRequestFullValidationRule.cs +++ b/src/Stratis.Features.Collateral/ConsensusRules/VotingRequestFullValidationRule.cs @@ -75,7 +75,7 @@ public void CheckTransaction(Transaction transaction, int height) } // Prohibit re-use of collateral addresses. - if (height >= ((PoAConsensusOptions)(this.network.Consensus.Options)).Release1100ActivationHeight) + if (height >= this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1100)) { Script script = PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(request.CollateralMainchainAddress); string collateralAddress = script.GetDestinationAddress(this.counterChainNetwork).ToString(); diff --git a/src/Stratis.Features.Collateral/JoinFederationRequestMonitor.cs b/src/Stratis.Features.Collateral/JoinFederationRequestMonitor.cs index 9842542602..7b41b34447 100644 --- a/src/Stratis.Features.Collateral/JoinFederationRequestMonitor.cs +++ b/src/Stratis.Features.Collateral/JoinFederationRequestMonitor.cs @@ -113,7 +113,7 @@ public void OnBlockConnected(VotingManagerProcessBlock blockConnectedData) Data = federationMemberBytes }; - if (blockConnectedData.ConnectedBlock.ChainedHeader.Height >= ((PoAConsensusOptions)this.network.Consensus.Options).Release1300ActivationHeight) + if (blockConnectedData.ConnectedBlock.ChainedHeader.Height >= this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1300)) { // If we are executing this from the miner, there will be no transaction present. if (blockConnectedData.PollsRepositoryTransaction == null) diff --git a/src/Stratis.Features.FederatedPeg.Tests/MaturedBlocksProviderTests.cs b/src/Stratis.Features.FederatedPeg.Tests/MaturedBlocksProviderTests.cs index 8a7e47b598..719d5d9b66 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/MaturedBlocksProviderTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/MaturedBlocksProviderTests.cs @@ -56,7 +56,7 @@ public MaturedBlocksProviderTests() 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; + ((PoABuriedDeploymentsArray)this.network.Consensus.BuriedDeployments)[PoABuriedDeployments.Release1300] = int.MaxValue; this.opReturnDataReader = Substitute.For(); this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return false; }); diff --git a/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs b/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs index 0758c37040..d3d5bcbea5 100644 --- a/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs +++ b/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs @@ -144,7 +144,7 @@ public List DistributeToMultisigNodes(uint256 depositId, Money fee) } } - if (this.chainIndexer.Tip.Height >= (this.network.Consensus.Options as PoAConsensusOptions).Release1400ActivationHeight) + if (this.chainIndexer.Tip.Height >= this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1400)) return multiSigRecipients.OrderBy(m => m.ScriptPubKey.ToHex()).ToList(); return multiSigRecipients; diff --git a/src/Stratis.Features.FederatedPeg/SourceChain/RetrievalTypeConfirmations.cs b/src/Stratis.Features.FederatedPeg/SourceChain/RetrievalTypeConfirmations.cs index 775d0e8a2f..840dc3ee06 100644 --- a/src/Stratis.Features.FederatedPeg/SourceChain/RetrievalTypeConfirmations.cs +++ b/src/Stratis.Features.FederatedPeg/SourceChain/RetrievalTypeConfirmations.cs @@ -115,7 +115,7 @@ private int Release1300ActivationHeight if (this.federatedPegSettings.IsMainChain) return ((PosConsensusOptions)this.network.Consensus.Options).Release1300ActivationHeight; - return ((PoAConsensusOptions)this.network.Consensus.Options).Release1300ActivationHeight; + return this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.Release1300); } } } diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs b/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs index 076ecbfd34..ea3da2caf8 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs @@ -45,7 +45,6 @@ public interface IMaturedBlocksSyncManager : IDisposable /// public class MaturedBlocksSyncManager : IMaturedBlocksSyncManager { - private const string Release1320DeploymentNameLower = "release1320"; private readonly IAsyncProvider asyncProvider; private readonly ICrossChainTransferStore crossChainTransferStore; private readonly IFederationGatewayClient federationGatewayClient; @@ -239,7 +238,7 @@ private async Task ProcessMatureBlockDepositsAsync(SerializableResult /// Constructs the BIP9 deployments array. diff --git a/src/Stratis.SmartContracts.CLR/Serialization/ContractPrimitiveSerializer.cs b/src/Stratis.SmartContracts.CLR/Serialization/ContractPrimitiveSerializer.cs index b407e1fa8a..17391cff93 100644 --- a/src/Stratis.SmartContracts.CLR/Serialization/ContractPrimitiveSerializer.cs +++ b/src/Stratis.SmartContracts.CLR/Serialization/ContractPrimitiveSerializer.cs @@ -26,7 +26,7 @@ public ContractPrimitiveSerializer(Network network, ChainIndexer chainIndexer) public override object Deserialize(Type type, byte[] stream) { - if (this.network.Consensus.Options is PoAConsensusOptions poaConsensusOptions && this.chainIndexer.Tip.Height <= poaConsensusOptions.ContractSerializerV2ActivationHeight) + if (this.network.Consensus.Options is PoAConsensusOptions poaConsensusOptions && this.chainIndexer.Tip.Height <= this.network.Consensus.PoABuriedDeployments(PoABuriedDeployments.ContractSerializerV2)) return this.serializerV1.Deserialize(type, stream); return base.Deserialize(type, stream); diff --git a/src/Stratis.SmartContracts.Networks/SmartContractsPoARegTest.cs b/src/Stratis.SmartContracts.Networks/SmartContractsPoARegTest.cs index 5d32a93ac9..ed452578f1 100644 --- a/src/Stratis.SmartContracts.Networks/SmartContractsPoARegTest.cs +++ b/src/Stratis.SmartContracts.Networks/SmartContractsPoARegTest.cs @@ -65,19 +65,13 @@ public SmartContractsPoARegTest() genesisFederationMembers: genesisFederationMembers, targetSpacingSeconds: 60, votingEnabled: true, - autoKickIdleMembers: false + autoKickIdleMembers: false, + contractSerializerV2ActivationHeight: 0 ) { PollExpiryBlocks = 450 }; - var buriedDeployments = new BuriedDeploymentsArray - { - [BuriedDeployments.BIP34] = 0, - [BuriedDeployments.BIP65] = 0, - [BuriedDeployments.BIP66] = 0 - }; - var bip9Deployments = new NoBIP9Deployments(); this.Consensus = new Consensus( @@ -89,7 +83,7 @@ public SmartContractsPoARegTest() majorityEnforceBlockUpgrade: 750, majorityRejectBlockOutdated: 950, majorityWindow: 1000, - buriedDeployments: buriedDeployments, + buriedDeployments: new PoABuriedDeploymentsArray(), bip9Deployments: bip9Deployments, bip34Hash: new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"), minerConfirmationWindow: 2016, // nPowTargetTimespan / nPowTargetSpacing