-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathconsensus_242.go
More file actions
65 lines (53 loc) · 1.95 KB
/
Copy pathconsensus_242.go
File metadata and controls
65 lines (53 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package migrations
import (
"fmt"
"github.com/oasisprotocol/oasis-core/go/common/version"
abciAPI "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/api"
consensusState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/apps/consensus/state"
)
// Consensus242 is the name of the upgrade that enables features introduced in Oasis Core 24.2.
//
// This upgrade includes:
// - The `MayQuery` field in the CHURP SGX policy, which defines which enclave identities
// are allowed to query runtime key shares.
// - An updated key manager policy update transaction that applies a new policy at the epoch
// boundary.
const Consensus242 = "consensus242"
// Version242 is the Oasis Core 24.2 version.
var Version242 = version.MustFromString("24.2")
var _ Handler = (*Handler242)(nil)
// Handler242 is the upgrade handler that transitions Oasis Core from version 24.1 to 24.2.
type Handler242 struct{}
// HasStartupUpgrade implements Handler.
func (h *Handler242) HasStartupUpgrade() bool {
return false
}
// StartupUpgrade implements Handler.
func (h *Handler242) StartupUpgrade() error {
return nil
}
// ConsensusUpgrade implements Handler.
func (h *Handler242) ConsensusUpgrade(privateCtx any) error {
abciCtx := privateCtx.(*abciAPI.Context)
switch abciCtx.Mode() {
case abciAPI.ContextBeginBlock:
// Nothing to do.
case abciAPI.ContextEndBlock:
// Consensus parameters.
consState := consensusState.NewMutableState(abciCtx.State())
consParams, err := consState.ConsensusParameters(abciCtx)
if err != nil {
return fmt.Errorf("failed to load consensus parameters: %w", err)
}
consParams.FeatureVersion = &Version242
if err = consState.SetConsensusParameters(abciCtx, consParams); err != nil {
return fmt.Errorf("failed to set consensus parameters: %w", err)
}
default:
return fmt.Errorf("upgrade handler called in unexpected context: %s", abciCtx.Mode())
}
return nil
}
func init() {
Register(Consensus242, &Handler242{})
}