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

Clean-up activation heights #1094

Open
wants to merge 11 commits into
base: release/1.4.0.0
Choose a base branch
from

Conversation

quantumagi
Copy link
Contributor

@quantumagi quantumagi commented Nov 16, 2022

This PR:

  • Removes the legacy BIP 9's and replaces them with hard-coded heights
  • Moves the activation heights into the PoABuriedDeploymentsArray. Some advantages to this:
    • The PoAConsensusOptions class-definition will remain static instead of changing with almost every release.

@@ -107,8 +107,8 @@ public CirrusDev()
var bip9Deployments = new CirrusBIP9Deployments()
{
// Deployment will go active once 75% of nodes are on 1.3.0.0 or later.
[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),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that there is no activation heights array defined for this network, is that intentional?

Copy link
Contributor Author

@quantumagi quantumagi Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it intentionally defaults the activation height to 0 by omitting the array initialization.

@@ -91,10 +111,11 @@ public class PoAConsensusOptions : ConsensusOptions
public int PollExpiryBlocks { get; set; }

/// <summary>
/// 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still applicable? It seems that ContractPrimitiveSerializer is using the new approach

Copy link
Contributor Author

@quantumagi quantumagi Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to reduce the chances of possible version incompatibilities where projects may still be using the older Stratis.SmartContracs.CLR NuGets such as Stratis.SmartContracts within say test projects that use network classes that don't have the field available. Can't remember the exact circumstance that caused issues for me but I concluded this would do more good than harm and can easily be removed in the future.

@zeptin
Copy link
Collaborator

zeptin commented Nov 22, 2022

This approach looks sound, and I don't see any problems with the PR per se. However, this functionality is effectively mimicing what the BuriedDeploymentsArray within NBitcoin.Consensus class is already being used for: BIP9 deployments that have activated far enough in the past that their block heights can be permanently recorded, rather than incurring the overhead of tracking them via the rest of the BIP9 mechanism. It seems preferable to use existing functionality, particularly considering it is available across all network types, not just PoA.

@quantumagi
Copy link
Contributor Author

quantumagi commented Nov 23, 2022

The challenge is to have a different set of index constants for PoA seeing a specific enum is being passed to the array methods.

@quantumagi
Copy link
Contributor Author

quantumagi commented Nov 23, 2022

Made the necessary changes to be able to derive PoABuriedDeploymentsArray from BuriedDeploymentsArray. Added a method that accepts a new enum named PoABuriedDeployments .

Copy link
Collaborator

@zeptin zeptin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, we just have to be careful with the implicit setting of the buried deployment heights to 0 on multiple networks when the enum is extended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants