-
Notifications
You must be signed in to change notification settings - Fork 142
/
chain.go
95 lines (85 loc) · 3.08 KB
/
chain.go
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
package chain
import (
"context"
"fmt"
"time"
"github.com/iotaledger/hive.go/logger"
iotago "github.com/iotaledger/iota.go/v3"
"github.com/iotaledger/wasp/packages/isc"
"github.com/iotaledger/wasp/packages/parameters"
"github.com/iotaledger/wasp/packages/peering"
"github.com/iotaledger/wasp/packages/state"
"github.com/iotaledger/wasp/packages/state/indexedstore"
"github.com/iotaledger/wasp/packages/vm/core/governance"
"github.com/iotaledger/wasp/packages/vm/processors"
)
type NodeConnection interface {
ChainNodeConn
Run(ctx context.Context) error
WaitUntilInitiallySynced(context.Context) error
GetBech32HRP() iotago.NetworkPrefix
GetL1Params() *parameters.L1Params
GetL1ProtocolParams() *iotago.ProtocolParameters
}
type StateFreshness byte
const (
ActiveOrCommittedState StateFreshness = iota // ActiveState, if exist; Confirmed state otherwise.
ActiveState // The state the chain build next TX on, can be ahead of ConfirmedState.
ConfirmedState // The state confirmed on L1.
)
func (sf StateFreshness) String() string {
switch sf {
case ActiveOrCommittedState:
return "ActiveOrCommittedState"
case ActiveState:
return "ActiveState"
case ConfirmedState:
return "ConfirmedState"
default:
return fmt.Sprintf("StateFreshness=%v", int(sf))
}
}
type ChainCore interface {
ID() isc.ChainID
// Returns the current latest confirmed alias output and the active one.
// The active AO can be ahead of the confirmed one by several blocks.
// Both values can be nil, if the node haven't received an output from
// L1 yet (after a restart or a chain activation).
LatestAliasOutput(freshness StateFreshness) (*isc.AliasOutputWithID, error)
LatestState(freshness StateFreshness) (state.State, error)
GetCommitteeInfo() *CommitteeInfo // TODO: Review, maybe we can reorganize the CommitteeInfo structure.
Store() indexedstore.IndexedStore // Use LatestState whenever possible. That will work faster.
Processors() *processors.Cache
GetChainNodes() []peering.PeerStatusProvider // CommitteeNodes + AccessNodes
GetCandidateNodes() []*governance.AccessNodeInfo // All the current candidates.
Log() *logger.Logger
}
type ConsensusPipeMetrics interface { // TODO: Review it.
GetEventStateTransitionMsgPipeSize() int
GetEventPeerLogIndexMsgPipeSize() int
GetEventACSMsgPipeSize() int
GetEventVMResultMsgPipeSize() int
GetEventTimerMsgPipeSize() int
}
type ConsensusWorkflowStatus interface { // TODO: Review it.
IsStateReceived() bool
IsBatchProposalSent() bool
IsConsensusBatchKnown() bool
IsVMStarted() bool
IsVMResultSigned() bool
IsTransactionFinalized() bool
IsTransactionPosted() bool
IsTransactionSeen() bool
IsInProgress() bool
GetBatchProposalSentTime() time.Time
GetConsensusBatchKnownTime() time.Time
GetVMStartedTime() time.Time
GetVMResultSignedTime() time.Time
GetTransactionFinalizedTime() time.Time
GetTransactionPostedTime() time.Time
GetTransactionSeenTime() time.Time
GetCompletedTime() time.Time
GetCurrentStateIndex() uint32
}