2023-09-03 23:47:09 +00:00
|
|
|
package consensus
|
|
|
|
|
|
|
|
import (
|
2023-09-25 02:43:35 +00:00
|
|
|
"crypto"
|
2023-11-01 03:45:20 +00:00
|
|
|
"time"
|
2023-09-25 02:43:35 +00:00
|
|
|
|
|
|
|
"source.quilibrium.com/quilibrium/monorepo/node/config"
|
2023-09-03 23:47:09 +00:00
|
|
|
"source.quilibrium.com/quilibrium/monorepo/node/execution"
|
2023-09-25 02:43:35 +00:00
|
|
|
"source.quilibrium.com/quilibrium/monorepo/node/keys"
|
|
|
|
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
|
2023-09-03 23:47:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type EngineState int
|
|
|
|
|
|
|
|
const (
|
|
|
|
EngineStateStopped EngineState = iota
|
|
|
|
EngineStateStarting
|
|
|
|
EngineStateLoading
|
|
|
|
EngineStateCollecting
|
|
|
|
EngineStateProving
|
|
|
|
EngineStatePublishing
|
|
|
|
EngineStateVerifying
|
|
|
|
EngineStateStopping
|
|
|
|
)
|
|
|
|
|
|
|
|
type ConsensusEngine interface {
|
|
|
|
Start() <-chan error
|
|
|
|
Stop(force bool) <-chan error
|
|
|
|
RegisterExecutor(exec execution.ExecutionEngine, frame uint64) <-chan error
|
|
|
|
UnregisterExecutor(name string, frame uint64, force bool) <-chan error
|
2024-01-03 07:31:42 +00:00
|
|
|
GetFrame() *protobufs.ClockFrame
|
2023-09-03 23:47:09 +00:00
|
|
|
GetDifficulty() uint32
|
|
|
|
GetState() EngineState
|
2024-01-03 07:31:42 +00:00
|
|
|
GetFrameChannel() <-chan *protobufs.ClockFrame
|
2023-09-03 23:47:09 +00:00
|
|
|
}
|
2023-09-25 02:43:35 +00:00
|
|
|
|
|
|
|
type DataConsensusEngine interface {
|
2024-01-03 07:31:42 +00:00
|
|
|
Start() <-chan error
|
2023-09-25 02:43:35 +00:00
|
|
|
Stop(force bool) <-chan error
|
|
|
|
RegisterExecutor(exec execution.ExecutionEngine, frame uint64) <-chan error
|
|
|
|
UnregisterExecutor(name string, frame uint64, force bool) <-chan error
|
2024-01-03 07:31:42 +00:00
|
|
|
GetFrame() *protobufs.ClockFrame
|
2023-09-25 02:43:35 +00:00
|
|
|
GetDifficulty() uint32
|
|
|
|
GetState() EngineState
|
|
|
|
GetFrameChannel() <-chan *protobufs.ClockFrame
|
|
|
|
GetProvingKey(
|
|
|
|
engineConfig *config.EngineConfig,
|
|
|
|
) (crypto.Signer, keys.KeyType, []byte, []byte)
|
|
|
|
IsInProverTrie(key []byte) bool
|
2023-10-09 04:52:19 +00:00
|
|
|
GetPeerInfo() *protobufs.PeerInfoResponse
|
2023-09-25 02:43:35 +00:00
|
|
|
}
|
2023-11-01 03:45:20 +00:00
|
|
|
|
|
|
|
func GetMinimumVersionCutoff() time.Time {
|
2024-03-01 07:12:31 +00:00
|
|
|
return time.Date(2024, time.March, 1, 7, 0, 0, 0, time.UTC)
|
2023-11-01 03:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetMinimumVersion() []byte {
|
2024-03-01 07:12:31 +00:00
|
|
|
return []byte{0x01, 0x04, 0x00}
|
2023-11-01 03:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetVersion() []byte {
|
2024-03-05 05:11:01 +00:00
|
|
|
return []byte{0x01, 0x04, 0x02}
|
2023-11-01 03:45:20 +00:00
|
|
|
}
|