HotShot
HotShot copied to clipboard
Add versioning in the application interface
Closes #3212
This PR:
This is motivated by a requirement for the sequencer to be able to upgrade the BlockHeader and InstanceState through a consensus protocol upgrade, to e.g. introduce fees.
To do this, we introduce a VersionedNode trait which will be a required bound for the initialization functions in SystemContext. Nodes must implement VersionedNode<BASE_VERSION, UPGRADE_VERSION> matching the version (at the type-level) that HotShot requires in initialization.
HotShot will propagate the correct NodeType implementation to the consensus tasks, and transition between them when the network is upgraded.
This PR does not:
An alternative implementation would have been to parametrize NodeType, i.e.:
pub trait NodeType<VERSION>
where
VERSION: StaticVersionType
{ ... }
In my mind, this is the more correct way to go about this, but the VERSION parameter is extremely invasive, requiring difficult-to-automate changes in the 600+ places we use NodeType in HotShot. I think the current PR provides the same level of type safety in a much smaller change, with a marginal downstream cost.
Key places to review:
This PR will depend on #3133 for general task restartability.