Documentation ¶
Index ¶
- Constants
- Variables
- func TestMockDiff(at time.Duration)
- func TestMockReset()
- type ActionBuffer
- type CNode
- type CNodeWork
- type CacheRound
- type Chain
- func (chain *Chain) AddSnapshot(final *FinalRound, cache *CacheRound, s *common.Snapshot, ...) error
- func (chain *Chain) AggregateMintWork()
- func (chain *Chain) AggregateRoundSpace()
- func (chain *Chain) AppendCosiAction(m *CosiAction) error
- func (chain *Chain) AppendFinalSnapshot(peerId crypto.Hash, s *common.Snapshot) error
- func (chain *Chain) AppendSelfEmpty(s *common.Snapshot) error
- func (chain *Chain) ConsensusKeys(round, timestamp uint64) ([]crypto.Hash, []*crypto.Key)
- func (chain *Chain) ConsumeFinalActions()
- func (chain *Chain) IsPledging() bool
- func (chain *Chain) QueuePollSnapshots()
- func (chain *Chain) StateCopy() (*CacheRound, *FinalRound)
- func (chain *Chain) StepForward()
- func (chain *Chain) Teardown()
- type ChainRound
- type ChainState
- type CosiAction
- type CosiAggregator
- type CosiChainData
- type CosiVerifier
- type FinalRound
- type Node
- func (node *Node) AuthenticateAs(recipientId crypto.Hash, msg []byte, timeoutSec int64) (*p2p.AuthToken, error)
- func (node *Node) BootChain(id crypto.Hash) *Chain
- func (node *Node) BuildAuthenticationMessage(relayerId crypto.Hash) []byte
- func (node *Node) BuildGraph() []*p2p.SyncPoint
- func (node *Node) CachePutTransaction(peerId crypto.Hash, tx *common.VersionedTransaction) error
- func (node *Node) CheckBroadcastedToPeers() bool
- func (node *Node) CheckCatchUpWithPeers() bool
- func (node *Node) ConsensusReady(cn *CNode, timestamp uint64) bool
- func (node *Node) ConsensusThreshold(timestamp uint64, final bool) int
- func (node *Node) CosiAggregateSelfCommitments(peerId crypto.Hash, snap crypto.Hash, commitment *crypto.Key, wantTx bool, ...) error
- func (node *Node) CosiAggregateSelfResponses(peerId crypto.Hash, snap crypto.Hash, response *[32]byte) error
- func (node *Node) CosiQueueExternalAnnouncement(peerId crypto.Hash, s *common.Snapshot, commitment *crypto.Key, ...) error
- func (node *Node) CosiQueueExternalChallenge(peerId crypto.Hash, snap crypto.Hash, cosi *crypto.CosiSignature, ...) error
- func (node *Node) CosiQueueExternalCommitments(peerId crypto.Hash, commitments []*crypto.Key, data []byte, ...) error
- func (node *Node) CosiQueueExternalFullChallenge(peerId crypto.Hash, s *common.Snapshot, commitment, challenge *crypto.Key, ...) error
- func (node *Node) ElectionLoop()
- func (node *Node) GetAcceptedOrPledgingNode(id crypto.Hash) *CNode
- func (node *Node) GetCacheStore() *ristretto.Cache[[]byte, any]
- func (node *Node) GetRemovedOrCancelledNode(id crypto.Hash, timestamp uint64) *CNode
- func (node *Node) GetRemovingOrSlashingNode(id crypto.Hash) *CNode
- func (node *Node) ListMintWorks(batch uint64) (map[crypto.Hash][2]uint64, error)
- func (node *Node) ListRoundSpaces(cids []crypto.Hash, day uint64) (map[crypto.Hash][]*common.RoundSpace, error)
- func (node *Node) ListWorkingAcceptedNodes(timestamp uint64) []*CNode
- func (node *Node) LoadAllChainsAndGraphTimestamp(store storage.Store, networkId crypto.Hash) error
- func (node *Node) LoadConsensusNodes() error
- func (node *Node) LoadGenesis(gns *common.Genesis) error
- func (node *Node) LoadRoundGraph() (map[crypto.Hash]*CacheRound, map[crypto.Hash]*FinalRound)
- func (node *Node) Loop() error
- func (node *Node) MintLoop()
- func (node *Node) NetworkId() crypto.Hash
- func (node *Node) NewTransaction(assetId crypto.Hash) *common.Transaction
- func (node *Node) NodesListWithoutState(threshold uint64, acceptedOnly bool) []*CNode
- func (node *Node) PledgingNode(timestamp uint64) *CNode
- func (node *Node) PoolSize() (common.Integer, error)
- func (node *Node) QueueState() (uint64, uint64, map[string][2]uint64)
- func (node *Node) QueueTransaction(tx *common.VersionedTransaction) (string, error)
- func (node *Node) ReadAllNodesWithoutState() []crypto.Hash
- func (node *Node) ReadSnapshotsForNodeRound(nodeIdWithNetwork crypto.Hash, round uint64) ([]*common.SnapshotWithTopologicalOrder, error)
- func (node *Node) ReadSnapshotsSinceTopology(offset, count uint64) ([]*common.SnapshotWithTopologicalOrder, error)
- func (node *Node) SPS() float64
- func (node *Node) SendTransactionToPeer(peerId, hash crypto.Hash) error
- func (node *Node) SignData(data []byte) crypto.Signature
- func (node *Node) SnapshotVersion() uint8
- func (node *Node) TPS() float64
- func (node *Node) Teardown()
- func (node *Node) TopoWrite(s *common.Snapshot, signers []crypto.Hash) *common.SnapshotWithTopologicalOrder
- func (node *Node) TopologicalOrder() uint64
- func (node *Node) UpdateSyncPoint(peerId crypto.Hash, points []*p2p.SyncPoint, data []byte, ...) error
- func (node *Node) Uptime() time.Duration
- func (node *Node) VerifyAndQueueAppendSnapshotFinalization(peerId crypto.Hash, s *common.Snapshot) error
- func (node *Node) WitnessSnapshot(s *common.SnapshotWithTopologicalOrder) *SnapshotWitness
- type NodeStateSequence
- type PeerSnapshot
- type SnapshotWitness
- type TopologicalSequence
Constants ¶
const ( FinalPoolSlotsLimit = config.SnapshotSyncRoundThreshold * 8 FinalPoolRoundSizeLimit = 1024 CachePoolSnapshotsLimit = 256 )
const ( CosiActionSelfEmpty = iota CosiActionSelfCommitment CosiActionSelfResponse CosiActionExternalAnnouncement CosiActionExternalChallenge CosiActionFinalization CosiActionExternalCommitments CosiActionSelfFullCommitment CosiActionExternalFullChallenge )
const ( MintYearDays = 365 KernelNetworkLegacyEnding = 1706 OneDay = 24 * uint64(time.Hour) )
const ( // All nodes should ensure consistent snapshots to keep the round space small. SlashReasonRoundSpace = 0x1 // After a kernel node is pledged successfully, it must be accepted timely. SlashReasonLateAccept = 0x2 // The payee should spend the node removal output as soon as possible. // The slash could be done by kernel nodes directly when the consumption // of the output happens. SlashReasonLateRemove = 0x3 // A sequencer node must produce consistent topology with witness signature. // Light node could provide evidence of inconsistent topology. SlashReasonInconsistentWitness = 0x4 // A node produces snapshot x in round A, then announces round B, which // references round A with only snapshot x in it. However during round A, // the node also announces snapshot y and gathered enough signatures, but // this snapshot y is never delivered to other nodes after the finalization // then the round A is considered stale if anyone could provide evidence of // the existence of the finalized snapshot y. Light node could do this job. // // Another kind of stale snapshot could directly happen in round A without // the announcement of round B. The node just announces x and keeps y, then // stops all future works. This can already be punished by large space and // mint rewards, but we still need to add more measurements for this behavior. // Because this stale snapshot y must be excluded from mint works // calculation forever, but if this node contiues to work after a long time, // and the failure to identity this stale snapshot timely, could result in // the full node sync failure of a fresh boot node. So the best punishment // is to remove this node, together with the large round space check. SlashReasonStaleSnapshot = 0x5 )
const MaxKernelNodesCount = 50
Variables ¶
var ( MintPool = common.NewInteger(500000) MintLiquidity = common.NewInteger(500000) MintYearPercent = common.NewInteger(10).Ration(common.NewInteger(100)) )
Functions ¶
func TestMockDiff ¶ added in v0.6.2
func TestMockReset ¶ added in v0.8.3
func TestMockReset()
Types ¶
type ActionBuffer ¶ added in v0.12.11
type ActionBuffer chan *CosiAction
func (ActionBuffer) Offer ¶ added in v0.12.11
func (ab ActionBuffer) Offer(m *CosiAction) error
func (ActionBuffer) Poll ¶ added in v0.12.11
func (ab ActionBuffer) Poll() *CosiAction
type CacheRound ¶
type CacheRound struct { NodeId crypto.Hash Number uint64 Timestamp uint64 References *common.RoundLink Snapshots []*common.Snapshot // contains filtered or unexported fields }
func (*CacheRound) Copy ¶
func (c *CacheRound) Copy() *CacheRound
func (*CacheRound) Gap ¶
func (c *CacheRound) Gap() (uint64, uint64)
func (*CacheRound) ValidateSnapshot ¶
func (c *CacheRound) ValidateSnapshot(s *common.Snapshot) error
type Chain ¶ added in v0.9.0
type Chain struct { sync.RWMutex ChainId crypto.Hash ConsensusInfo *CNode State *ChainState CosiRandoms map[crypto.Key]*crypto.Key UsedRandoms map[crypto.Hash]*crypto.Key CosiCommitments map[crypto.Hash][]*crypto.Key UsedCommitments map[crypto.Key]bool ComitmentsSentTime time.Time CosiCommunicatedAt map[crypto.Hash]time.Time CosiAggregators map[crypto.Hash]*CosiAggregator CosiVerifiers map[crypto.Hash]*CosiVerifier CachePool ActionBuffer FinalPool [FinalPoolSlotsLimit]*ChainRound FinalIndex int FinalCount int // contains filtered or unexported fields }
func (*Chain) AddSnapshot ¶ added in v0.9.1
func (chain *Chain) AddSnapshot(final *FinalRound, cache *CacheRound, s *common.Snapshot, signers []crypto.Hash) error
func (*Chain) AggregateMintWork ¶ added in v0.11.0
func (chain *Chain) AggregateMintWork()
func (*Chain) AggregateRoundSpace ¶ added in v0.14.0
func (chain *Chain) AggregateRoundSpace()
func (*Chain) AppendCosiAction ¶ added in v0.9.0
func (chain *Chain) AppendCosiAction(m *CosiAction) error
func (*Chain) AppendFinalSnapshot ¶ added in v0.9.0
func (*Chain) AppendSelfEmpty ¶ added in v0.9.0
func (*Chain) ConsensusKeys ¶ added in v0.9.1
func (*Chain) ConsumeFinalActions ¶ added in v0.9.0
func (chain *Chain) ConsumeFinalActions()
func (*Chain) IsPledging ¶ added in v0.9.1
func (*Chain) QueuePollSnapshots ¶ added in v0.9.0
func (chain *Chain) QueuePollSnapshots()
func (*Chain) StateCopy ¶ added in v0.9.1
func (chain *Chain) StateCopy() (*CacheRound, *FinalRound)
func (*Chain) StepForward ¶ added in v0.9.0
func (chain *Chain) StepForward()
type ChainRound ¶ added in v0.9.0
type ChainRound struct { Number uint64 Size int Timestamp uint64 Snapshots [FinalPoolRoundSizeLimit]*PeerSnapshot // contains filtered or unexported fields }
type ChainState ¶ added in v0.9.0
type ChainState struct { CacheRound *CacheRound FinalRound *FinalRound RoundHistory []*FinalRound RoundLinks map[crypto.Hash]uint64 }
type CosiAction ¶ added in v0.5.0
type CosiAction struct { Action int PeerId crypto.Hash SnapshotHash crypto.Hash Snapshot *common.Snapshot Commitment *crypto.Key Signature *crypto.CosiSignature Response *[32]byte Transaction *common.VersionedTransaction WantTx bool Commitments []*crypto.Key Challenge *crypto.Key // contains filtered or unexported fields }
type CosiAggregator ¶ added in v0.5.0
type CosiChainData ¶ added in v0.9.1
type CosiChainData struct { PN *CNode CN *CNode TX *common.VersionedTransaction F bool }
type CosiVerifier ¶ added in v0.5.0
type FinalRound ¶
type FinalRound struct { NodeId crypto.Hash Number uint64 Start uint64 End uint64 Hash crypto.Hash }
func (*FinalRound) Common ¶ added in v0.9.4
func (f *FinalRound) Common() *common.Round
func (*FinalRound) Copy ¶
func (f *FinalRound) Copy() *FinalRound
type Node ¶
type Node struct { IdForNetwork crypto.Hash Signer common.Address Peer *p2p.Peer TopoCounter *TopologicalSequence SyncPoints *syncMap SyncPointsMap map[crypto.Hash]*p2p.SyncPoint GraphTimestamp uint64 Epoch uint64 LastMint uint64 // contains filtered or unexported fields }
func (*Node) AuthenticateAs ¶ added in v0.18.0
func (*Node) BuildAuthenticationMessage ¶
func (*Node) BuildGraph ¶
func (*Node) CachePutTransaction ¶
func (*Node) CheckBroadcastedToPeers ¶ added in v0.2.12
func (*Node) CheckCatchUpWithPeers ¶ added in v0.2.12
func (*Node) ConsensusReady ¶ added in v0.9.1
An accepted node can sign transactions only when it satisfies either: 1. It is a genesis node. 2. It has been accepted more than 12 hours.
func (*Node) ConsensusThreshold ¶ added in v0.5.0
func (*Node) CosiAggregateSelfCommitments ¶ added in v0.5.0
func (*Node) CosiAggregateSelfResponses ¶ added in v0.5.0
func (*Node) CosiQueueExternalAnnouncement ¶ added in v0.5.0
func (*Node) CosiQueueExternalChallenge ¶ added in v0.5.0
func (node *Node) CosiQueueExternalChallenge(peerId crypto.Hash, snap crypto.Hash, cosi *crypto.CosiSignature, ver *common.VersionedTransaction) error
func (*Node) CosiQueueExternalCommitments ¶ added in v0.14.6
func (*Node) CosiQueueExternalFullChallenge ¶ added in v0.14.6
func (*Node) ElectionLoop ¶ added in v0.3.5
func (node *Node) ElectionLoop()
func (*Node) GetAcceptedOrPledgingNode ¶ added in v0.9.1
func (*Node) GetCacheStore ¶ added in v0.2.18
func (*Node) GetRemovedOrCancelledNode ¶ added in v0.14.0
func (*Node) GetRemovingOrSlashingNode ¶ added in v0.14.4
this returns the first to be removed node as normal, then if some node is being slashed, this will return it instead of the normal one, thus causes the removing or slashing node changes.
a removing or slashing node is not able to produce works during the state, but whenever another slashing node with more priority proceeds it, it resumes working again, a large round space may happen.
to make it equal and fair, the large round space slashing will cause zero loss, and the payee will get back the whole pledge. so the punishment to a removing or slashing node is only drastically mint decline.
func (*Node) ListMintWorks ¶ added in v0.11.1
func (*Node) ListRoundSpaces ¶ added in v0.16.5
func (*Node) ListWorkingAcceptedNodes ¶ added in v0.18.6
func (*Node) LoadAllChainsAndGraphTimestamp ¶ added in v0.14.3
func (*Node) LoadConsensusNodes ¶
func (*Node) LoadRoundGraph ¶ added in v0.13.2
func (node *Node) LoadRoundGraph() (map[crypto.Hash]*CacheRound, map[crypto.Hash]*FinalRound)
func (*Node) NewTransaction ¶ added in v0.14.0
func (node *Node) NewTransaction(assetId crypto.Hash) *common.Transaction
this is needed to handle mainnet transaction version upgrading fork
func (*Node) NodesListWithoutState ¶ added in v0.9.1
func (*Node) PledgingNode ¶ added in v0.9.1
func (*Node) QueueState ¶ added in v0.12.7
func (*Node) QueueTransaction ¶ added in v0.1.2
func (node *Node) QueueTransaction(tx *common.VersionedTransaction) (string, error)
func (*Node) ReadAllNodesWithoutState ¶ added in v0.9.1
func (*Node) ReadSnapshotsForNodeRound ¶
func (*Node) ReadSnapshotsSinceTopology ¶
func (node *Node) ReadSnapshotsSinceTopology(offset, count uint64) ([]*common.SnapshotWithTopologicalOrder, error)
func (*Node) SendTransactionToPeer ¶
func (*Node) SnapshotVersion ¶ added in v0.14.0
func (*Node) TopologicalOrder ¶ added in v0.1.2
func (*Node) UpdateSyncPoint ¶
func (*Node) VerifyAndQueueAppendSnapshotFinalization ¶ added in v0.5.0
func (*Node) WitnessSnapshot ¶ added in v0.9.7
func (node *Node) WitnessSnapshot(s *common.SnapshotWithTopologicalOrder) *SnapshotWitness
type NodeStateSequence ¶ added in v0.12.10
type PeerSnapshot ¶ added in v0.9.0
type SnapshotWitness ¶ added in v0.9.7
type TopologicalSequence ¶
func (*TopologicalSequence) TopoStats ¶ added in v0.9.0
func (topo *TopologicalSequence) TopoStats(node *Node)