espresso-sequencer
espresso-sequencer copied to clipboard
Implement a general upgrade mechanism
Rough Proposal
Add the following to genesis:
enum UpgradeType {
// An upgrade type which replaces the chain config with the given one
ChainConfig(ChainConfig),
// More upgrade types may be added as the software evolves. For example, a specific protocol upgrade may just have a name
// (like an Ethereum hardfork name) and a unit variant here, which the validation logic is hard-coded to handle.
}
struct Upgrade {
type: UpgradeType,
block: u64,
}
struct Genesis {
...
upgrades: BTreeMap<Version, Upgrade>,
}
Add upgrades: BtreeMap<Version, Upgrade> to NodeState.
On startup, check the current version and find the next configured upgrade. If there is one, configure HotShot to upgrade to the next protocol version at the specified block.
In validation logic, check the current protocol version. If it is greater than the previous version, look up the corresponding upgrade and execute it. At first, the only type of upgrade we will support executing is a ChainConfig upgrade, which just sets the chain_config in ValidatedState