github.com/onflow/flow-go@v0.33.17/state/protocol/params.go (about) 1 package protocol 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 ) 6 7 // Params are parameters of the protocol state, divided into parameters of 8 // this specific instance of the state (varies from node to node) and global 9 // parameters of the state. 10 type Params interface { 11 InstanceParams 12 GlobalParams 13 } 14 15 // InstanceParams represents protocol state parameters that vary between instances. 16 // For example, two nodes both running in the same spork on Flow Mainnet may have 17 // different instance params. 18 type InstanceParams interface { 19 20 // FinalizedRoot returns the finalized root header of the current protocol state. This will be 21 // the head of the protocol state snapshot used to bootstrap this state and 22 // may differ from node to node for the same protocol state. 23 // No errors are expected during normal operation. 24 FinalizedRoot() (*flow.Header, error) 25 26 // SealedRoot returns the sealed root block. If it's different from FinalizedRoot() block, 27 // it means the node is bootstrapped from mid-spork. 28 // No errors are expected during normal operation. 29 SealedRoot() (*flow.Header, error) 30 31 // Seal returns the root block seal of the current protocol state. This will be 32 // the seal for the root block used to bootstrap this state and may differ from 33 // node to node for the same protocol state. 34 // No errors are expected during normal operation. 35 Seal() (*flow.Seal, error) 36 37 // EpochFallbackTriggered returns whether epoch fallback mode (EECC) has been triggered. 38 // EECC is a permanent, spork-scoped state which is triggered when the next 39 // epoch fails to be committed in the allocated time. Once EECC is triggered, 40 // it will remain in effect until the next spork. 41 // No errors are expected during normal operation. 42 EpochFallbackTriggered() (bool, error) 43 } 44 45 // GlobalParams represents protocol state parameters that do not vary between instances. 46 // Any nodes running in the same spork, on the same network (same chain ID) must 47 // have the same global params. 48 type GlobalParams interface { 49 50 // ChainID returns the chain ID for the current Flow network. The chain ID 51 // uniquely identifies a Flow network in perpetuity across epochs and sporks. 52 // No errors are expected during normal operation. 53 ChainID() (flow.ChainID, error) 54 55 // SporkID returns the unique identifier for this network within the current spork. 56 // This ID is determined at the beginning of a spork during bootstrapping and is 57 // part of the root protocol state snapshot. 58 // No errors are expected during normal operation. 59 SporkID() (flow.Identifier, error) 60 61 // SporkRootBlockHeight returns the height of the spork's root block. 62 // This value is determined at the beginning of a spork during bootstrapping. 63 // If node uses a sealing segment for bootstrapping then this value will be carried over 64 // as part of snapshot. 65 // No errors are expected during normal operation. 66 SporkRootBlockHeight() (uint64, error) 67 68 // ProtocolVersion returns the protocol version, the major software version 69 // of the protocol software. 70 // No errors are expected during normal operation. 71 ProtocolVersion() (uint, error) 72 73 // EpochCommitSafetyThreshold defines a deadline for sealing the EpochCommit 74 // service event near the end of each epoch - the "epoch commitment deadline". 75 // Given a safety threshold t, the deadline for an epoch with final view f is: 76 // Epoch Commitment Deadline: d=f-t 77 // 78 // DEFINITION: 79 // This deadline is used to determine when to trigger epoch emergency fallback mode. 80 // Epoch Emergency Fallback mode is triggered when the EpochCommit service event 81 // fails to be sealed. 82 // 83 // Example: A service event is emitted in block A. The seal for A is included in C. 84 // A<-B(RA)<-C(SA)<-...<-R 85 // 86 // A service event S is considered sealed w.r.t. a reference block R if: 87 // * S was emitted during execution of some block A, s.t. A is an ancestor of R 88 // * The seal for block A was included in some block C, s.t C is an ancestor of R 89 // 90 // When we finalize the first block B with B.View >= d: 91 // HAPPY PATH: If an EpochCommit service event has been sealed w.r.t. B, no action is taken. 92 // FALLBACK PATH: If no EpochCommit service event has been sealed w.r.t. B, epoch fallback mode (EECC) is triggered. 93 // 94 // CONTEXT: 95 // The epoch commitment deadline exists to ensure that all nodes agree on 96 // whether epoch fallback mode is triggered for a particular epoch, before 97 // the epoch actually ends. Although the use of this deadline DOES NOT 98 // guarantee these properties, it is a simpler way to assure them with high 99 // likelihood, given reasonable configuration. 100 // In particular, all nodes will agree about EECC being triggered (or not) 101 // if at least one block with view in [d, f] is finalized - in other words 102 // at least one block is finalized after the epoch commitment deadline, and 103 // before the next epoch begins. 104 // 105 // When selecting a threshold value, ensure: 106 // * The deadline is after the end of the DKG, with enough buffer between 107 // the two that the EpochCommit event is overwhelmingly likely to be emitted 108 // before the deadline, if it is emitted at all. 109 // * The buffer between the deadline and the final view of the epoch is large 110 // enough that the network is overwhelming likely to finalize at least one 111 // block with a view in this range 112 // 113 // /- Epoch Commitment Deadline 114 // EPOCH N v EPOCH N+1 115 // ...------------|------||-----... 116 // 117 // No errors are expected during normal operation. 118 EpochCommitSafetyThreshold() (uint64, error) 119 }