Documentation ¶
Index ¶
- Constants
- func BroadcastCXReceipts(newBlock *types.Block, consensus *consensus.Consensus)
- func BroadcastCXReceiptsWithShardID(block *block.Header, commitSig []byte, commitBitmap []byte, toShardID uint32, ...)
- func BroadcastMissingCXReceipts(c *consensus.Consensus)
- func GenerateRandomString(n int) string
- func GenerateSyncID() [SyncIDLength]byte
- type DNSSyncingPeerProvider
- type Downloaders
- type ISync
- type LocalSyncingPeerProvider
- type Node
- func (node *Node) APIs(intelchain *itc.Intelchain) []rpc.API
- func (node *Node) AddNewBlockForExplorer(block *types.Block)
- func (node *Node) AddPendingReceipts(receipts *types.CXReceiptsProof)
- func (node *Node) AddPendingStakingTransaction(newStakingTx *staking.StakingTransaction) error
- func (node *Node) AddPendingTransaction(newTx *types.Transaction) error
- func (node *Node) BeaconSyncHook()
- func (node *Node) Beaconchain() core.BlockChain
- func (node *Node) Blockchain() core.BlockChain
- func (node *Node) BootstrapConsensus() error
- func (node *Node) BroadcastCrossLinkFromShardsToBeacon()
- func (node *Node) BroadcastCrosslinkHeartbeatSignalFromBeaconToShards()
- func (node *Node) BroadcastNewBlock(newBlock *types.Block, nodeConfig *nodeconfig.ConfigType)
- func (node *Node) BroadcastSlash(witness *slash.Record)
- func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, incomingPeer string) (*downloader_pb.DownloaderResponse, error)
- func (node *Node) DoSyncing(bc core.BlockChain, willJoinConsensus bool)
- func (node *Node) EpochChain() core.BlockChain
- func (node *Node) GetAddressForBLSKey(blskey *bls_core.PublicKey, epoch *big.Int) common.Address
- func (node *Node) GetAddresses(epoch *big.Int) map[string]common.Address
- func (node *Node) GetConfig() rpc_common.Config
- func (node *Node) GetConsensusBlockNum() uint64
- func (node *Node) GetConsensusCurViewID() uint64
- func (node *Node) GetConsensusInternal() rpc_common.ConsensusInternal
- func (node *Node) GetConsensusMode() string
- func (node *Node) GetConsensusPhase() string
- func (node *Node) GetConsensusViewChangingID() uint64
- func (node *Node) GetLastSigningPower() (float64, error)
- func (node *Node) GetLastSigningPower2() (float64, error)
- func (node *Node) GetNodeBootTime() int64
- func (node *Node) GetOrCreateSyncInstance(initiate bool) ISync
- func (node *Node) GetStakingTransactionsCount(address, txType string) (uint64, error)
- func (node *Node) GetStakingTransactionsHistory(address, txType, order string) ([]common.Hash, error)
- func (node *Node) GetSyncID() [SyncIDLength]byte
- func (node *Node) GetTraceResultByHash(hash common.Hash) (json.RawMessage, error)
- func (node *Node) GetTransactionsCount(address, txType string) (uint64, error)
- func (node *Node) GetTransactionsHistory(address, txType, order string) ([]common.Hash, error)
- func (node *Node) HandleNodeMessage(ctx context.Context, msgPayload []byte, actionType proto_node.MessageType) error
- func (node *Node) InitSyncingServer(port int)
- func (node *Node) IsBackup() bool
- func (node *Node) IsCurrentlyLeader() bool
- func (node *Node) IsOutOfSync(shardID uint32) bool
- func (node *Node) IsRunningBeaconChain() bool
- func (node *Node) ListBlockedPeer() []peer.ID
- func (node *Node) ListPeer(topic string) []peer.ID
- func (node *Node) ListTopic() []string
- func (node *Node) NodeSyncing()
- func (node *Node) PeerConnectivity() (int, int, int)
- func (node *Node) PendingCXReceipts() []*types.CXReceiptsProof
- func (node *Node) PostConsensusProcessing(newBlock *types.Block) error
- func (node *Node) ProcessCrossLinkHeartbeatMessage(msgPayload []byte)
- func (node *Node) ProcessCrossLinkMessage(msgPayload []byte)
- func (node *Node) ProcessReceiptMessage(msgPayload []byte)
- func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
- func (node *Node) RegisterExplorerServices()
- func (node *Node) RegisterService(st service.Type, s service.Service)
- func (node *Node) RegisterValidatorServices()
- func (node *Node) ReportPlainErrorSink() types.TransactionErrorReports
- func (node *Node) ReportStakingErrorSink() types.TransactionErrorReports
- func (node *Node) SendNewBlockToUnsync()
- func (node *Node) ServiceManager() *service.Manager
- func (node *Node) SetNodeBackupMode(isBackup bool) bool
- func (node *Node) ShutDown()
- func (node *Node) StartGRPCSyncClient()
- func (node *Node) StartPubSub() error
- func (node *Node) StartRPC() error
- func (node *Node) StartRosetta() error
- func (node *Node) StartServices() error
- func (node *Node) StartSyncingServer(port int)
- func (node *Node) StopPubSub()
- func (node *Node) StopRPC() error
- func (node *Node) StopRosetta() error
- func (node *Node) StopServices() error
- func (node *Node) SupportGRPCSyncServer(port int)
- func (node *Node) SyncInstance() ISync
- func (node *Node) SyncPeers() map[string]int
- func (node *Node) SyncStatus(shardID uint32) (bool, uint64, uint64)
- func (node *Node) TraceLoopForExplorer()
- func (node *Node) VerifyCrossLink(cl types.CrossLink) error
- func (node *Node) WaitForConsensusReadyV2(cs *consensus.Consensus, stopChan chan struct{}, stoppedChan chan struct{})
- type SyncingPeerProvider
Constants ¶
const ( // NumTryBroadCast is the number of times trying to broadcast NumTryBroadCast = 3 // MsgChanBuffer is the buffer of consensus message handlers. MsgChanBuffer = 1024 )
const ( SleepPeriod = 20 * time.Millisecond IncomingReceiptsLimit = 6000 // 2000 * (numShards - 1) )
Constants of proposing a new block
const (
SyncFrequency = 60 * time.Second
)
Constants related to doing syncing.
const (
//SyncIDLength is the length of bytes for syncID
SyncIDLength = 20
)
Variables ¶
This section is empty.
Functions ¶
func BroadcastCXReceipts ¶
BroadcastCXReceipts broadcasts cross shard receipts to correspoding destination shards
func BroadcastCXReceiptsWithShardID ¶
func BroadcastCXReceiptsWithShardID(block *block.Header, commitSig []byte, commitBitmap []byte, toShardID uint32, consensus *consensus.Consensus)
BroadcastCXReceiptsWithShardID broadcasts cross shard receipts to given ToShardID
func BroadcastMissingCXReceipts ¶
BroadcastMissingCXReceipts broadcasts missing cross shard receipts per request
func GenerateRandomString ¶
GenerateRandomString generates a random string with given length
func GenerateSyncID ¶
func GenerateSyncID() [SyncIDLength]byte
GenerateSyncID generates a random string with given length
Types ¶
type DNSSyncingPeerProvider ¶
type DNSSyncingPeerProvider struct {
// contains filtered or unexported fields
}
DNSSyncingPeerProvider uses the given DNS zone to resolve syncing peers.
func NewDNSSyncingPeerProvider ¶
func NewDNSSyncingPeerProvider(zone, port string, addrs []multiaddr.Multiaddr) *DNSSyncingPeerProvider
NewDNSSyncingPeerProvider returns a provider that uses given DNS name and port number to resolve syncing peers.
func (*DNSSyncingPeerProvider) SyncingPeers ¶
func (p *DNSSyncingPeerProvider) SyncingPeers(shardID uint32) (peers []p2p.Peer, err error)
SyncingPeers resolves DNS name into peers and returns them.
type Downloaders ¶
type ISync ¶
type ISync interface { UpdateBlockAndStatus(block *types.Block, bc core.BlockChain) error AddLastMileBlock(block *types.Block) GetActivePeerNumber() int CreateSyncConfig(peers []p2p.Peer, shardID uint32, selfPeerID libp2p_peer.ID, waitForEachPeerToConnect bool) error SyncLoop(bc core.BlockChain, isBeacon bool, consensus *consensus.Consensus, loopMinTime time.Duration) IsSynchronized() bool IsSameBlockchainHeight(bc core.BlockChain) (uint64, bool) AddNewBlock(peerHash []byte, block *types.Block) RegisterNodeInfo() int GetParsedSyncStatus() (IsSynchronized bool, OtherHeight uint64, HeightDiff uint64) GetParsedSyncStatusDoubleChecked() (IsSynchronized bool, OtherHeight uint64, HeightDiff uint64) }
type LocalSyncingPeerProvider ¶
type LocalSyncingPeerProvider struct {
// contains filtered or unexported fields
}
LocalSyncingPeerProvider uses localnet deployment convention to synthesize syncing peers.
func NewLocalSyncingPeerProvider ¶
func NewLocalSyncingPeerProvider( basePort, selfPort uint16, numShards, shardSize uint32, ) *LocalSyncingPeerProvider
NewLocalSyncingPeerProvider returns a provider that synthesizes syncing peers given the network configuration
func (*LocalSyncingPeerProvider) SyncingPeers ¶
func (p *LocalSyncingPeerProvider) SyncingPeers(shardID uint32) (peers []p2p.Peer, err error)
SyncingPeers returns local syncing peers using the sharding configuration.
type Node ¶
type Node struct { Consensus *consensus.Consensus // Consensus object containing all Consensus related data (e.g. committee members, signatures, commits) BeaconBlockChannel chan *types.Block // The channel to send beacon blocks for non-beaconchain nodes SelfPeer p2p.Peer TxPool *core.TxPool CxPool *core.CxPool // pool for missing cross shard receipts resend Worker *worker.Worker SyncingPeerProvider SyncingPeerProvider ContractDeployerCurrentNonce uint64 // The nonce of the deployer contract at current block ContractAddresses []common.Address IntelchainConfig *intelchainconfig.IntelchainConfig // node configuration, including group ID, shard ID, etc NodeConfig *nodeconfig.ConfigType // TransactionErrorSink contains error messages for any failed transaction, in memory only TransactionErrorSink *types.TransactionErrorSink // BroadcastInvalidTx flag is considered when adding pending tx to tx-pool BroadcastInvalidTx bool // InSync flag indicates the node is in-sync or not IsSynchronized *abool.AtomicBool Metrics metrics.Registry // contains filtered or unexported fields }
Node represents a protocol-participating node in the network
func New ¶
func New( host p2p.Host, consensusObj *consensus.Consensus, blacklist map[common.Address]struct{}, allowedTxs map[common.Address][]core.AllowedTxData, localAccounts []common.Address, intelchainconfig *intelchainconfig.IntelchainConfig, registry *registry.Registry, ) *Node
New creates a new node.
func (*Node) APIs ¶
func (node *Node) APIs(intelchain *itc.Intelchain) []rpc.API
APIs return the collection of local RPC services. NOTE, some of these services probably need to be moved to somewhere else.
func (*Node) AddNewBlockForExplorer ¶
AddNewBlockForExplorer add new block for explorer.
func (*Node) AddPendingReceipts ¶
func (node *Node) AddPendingReceipts(receipts *types.CXReceiptsProof)
AddPendingReceipts adds one receipt message to pending list.
func (*Node) AddPendingStakingTransaction ¶
func (node *Node) AddPendingStakingTransaction( newStakingTx *staking.StakingTransaction, ) error
AddPendingStakingTransaction staking transactions
func (*Node) AddPendingTransaction ¶
func (node *Node) AddPendingTransaction(newTx *types.Transaction) error
AddPendingTransaction adds one new transaction to the pending transaction list. This is only called from SDK.
func (*Node) BeaconSyncHook ¶
func (node *Node) BeaconSyncHook()
BeaconSyncHook is the hook function called after inserted beacon in downloader TODO: This is a small misc piece of consensus logic. Better put it to consensus module.
func (*Node) Beaconchain ¶
func (node *Node) Beaconchain() core.BlockChain
Beaconchain returns the beacon chain from node.
func (*Node) Blockchain ¶
func (node *Node) Blockchain() core.BlockChain
Blockchain returns the blockchain for the node's current shard.
func (*Node) BootstrapConsensus ¶
BootstrapConsensus is a goroutine to check number of peers and start the consensus
func (*Node) BroadcastCrossLinkFromShardsToBeacon ¶
func (node *Node) BroadcastCrossLinkFromShardsToBeacon()
BroadcastCrossLinkFromShardsToBeacon is called by consensus leader to send the new header as cross link to beacon chain.
func (*Node) BroadcastCrosslinkHeartbeatSignalFromBeaconToShards ¶
func (node *Node) BroadcastCrosslinkHeartbeatSignalFromBeaconToShards()
BroadcastCrosslinkHeartbeatSignalFromBeaconToShards is called by consensus leader or 1% validators to send last cross link to shard chains.
func (*Node) BroadcastNewBlock ¶
func (node *Node) BroadcastNewBlock(newBlock *types.Block, nodeConfig *nodeconfig.ConfigType)
BroadcastNewBlock is called by consensus leader to sync new blocks with other clients/nodes. NOTE: For now, just send to the client (basically not broadcasting) TODO (lc): broadcast the new blocks to new nodes doing state sync
func (*Node) BroadcastSlash ¶
BroadcastSlash ..
func (*Node) CalculateResponse ¶
func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, incomingPeer string) (*downloader_pb.DownloaderResponse, error)
CalculateResponse implements DownloadInterface on Node object.
func (*Node) DoSyncing ¶
func (node *Node) DoSyncing(bc core.BlockChain, willJoinConsensus bool)
DoSyncing keep the node in sync with other peers, willJoinConsensus means the node will try to join consensus after catch up
func (*Node) EpochChain ¶
func (node *Node) EpochChain() core.BlockChain
EpochChain returns the epoch chain from node. Epoch chain is the same as BeaconChain, but with differences in behaviour.
func (*Node) GetAddressForBLSKey ¶
GetAddressForBLSKey retrieves the ECDSA address associated with bls key for epoch
func (*Node) GetAddresses ¶
GetAddresses retrieves all ECDSA addresses of the bls keys for epoch
func (*Node) GetConfig ¶
func (node *Node) GetConfig() rpc_common.Config
func (*Node) GetConsensusBlockNum ¶
GetConsensusBlockNum returns the current block number of the consensus
func (*Node) GetConsensusCurViewID ¶
GetConsensusCurViewID returns the current view ID
func (*Node) GetConsensusInternal ¶
func (node *Node) GetConsensusInternal() rpc_common.ConsensusInternal
GetConsensusInternal returns consensus internal data
func (*Node) GetConsensusMode ¶
GetConsensusMode returns the current consensus mode
func (*Node) GetConsensusPhase ¶
GetConsensusPhase returns the current consensus phase
func (*Node) GetConsensusViewChangingID ¶
GetConsensusViewChangingID returns the view changing ID
func (*Node) GetLastSigningPower ¶
GetLastSigningPower get last signed power
func (*Node) GetLastSigningPower2 ¶
func (*Node) GetOrCreateSyncInstance ¶
GetOrCreateSyncInstance returns an instance of state sync, either legacy or staged if initiate sets to true, it generates a new instance
func (*Node) GetStakingTransactionsCount ¶
GetStakingTransactionsCount returns the number of staking transactions hashes of address for input type.
func (*Node) GetStakingTransactionsHistory ¶
func (node *Node) GetStakingTransactionsHistory(address, txType, order string) ([]common.Hash, error)
GetStakingTransactionsHistory returns list of staking transactions hashes of address.
func (*Node) GetSyncID ¶
func (node *Node) GetSyncID() [SyncIDLength]byte
GetSyncID returns the syncID of this node
func (*Node) GetTraceResultByHash ¶
GetStakingTransactionsCount returns the number of staking transactions hashes of address for input type.
func (*Node) GetTransactionsCount ¶
GetTransactionsCount returns the number of regular transactions hashes of address for input type.
func (*Node) GetTransactionsHistory ¶
GetTransactionsHistory returns list of transactions hashes of address.
func (*Node) HandleNodeMessage ¶
func (node *Node) HandleNodeMessage( ctx context.Context, msgPayload []byte, actionType proto_node.MessageType, ) error
HandleNodeMessage parses the message and dispatch the actions.
func (*Node) InitSyncingServer ¶
InitSyncingServer starts downloader server.
func (*Node) IsCurrentlyLeader ¶
IsCurrentlyLeader exposes if node is currently the leader node
func (*Node) IsOutOfSync ¶
IsOutOfSync return whether the node is out of sync of the given shardID
func (*Node) IsRunningBeaconChain ¶
IsRunningBeaconChain returns whether the node is running on beacon chain.
func (*Node) ListBlockedPeer ¶
ListBlockedPeer return list of blocked peers
func (*Node) NodeSyncing ¶
func (node *Node) NodeSyncing()
NodeSyncing makes sure to start all the processes needed to sync the node based on different configuration factors.
func (*Node) PeerConnectivity ¶
PeerConnectivity ..
func (*Node) PendingCXReceipts ¶
func (node *Node) PendingCXReceipts() []*types.CXReceiptsProof
PendingCXReceipts returns node.pendingCXReceiptsProof
func (*Node) PostConsensusProcessing ¶
PostConsensusProcessing is called by consensus participants, after consensus is done, to: 1. [leader] send new block to the client 2. [leader] send cross shard tx receipts to destination shard
func (*Node) ProcessCrossLinkHeartbeatMessage ¶
ProcessCrossLinkHeartbeatMessage process crosslink heart beat signal. This function is only called on shards 1,2,3 when network message `CrosslinkHeartbeat` receiving.
func (*Node) ProcessCrossLinkMessage ¶
ProcessCrossLinkMessage verify and process Node/CrossLink message into crosslink when it's valid
func (*Node) ProcessReceiptMessage ¶
ProcessReceiptMessage store the receipts and merkle proof in local data store
func (*Node) ProposeNewBlock ¶
ProposeNewBlock proposes a new block...
func (*Node) RegisterExplorerServices ¶
func (node *Node) RegisterExplorerServices()
RegisterExplorerServices register the explorer services
func (*Node) RegisterService ¶
RegisterService register a service to the node service manager
func (*Node) RegisterValidatorServices ¶
func (node *Node) RegisterValidatorServices()
RegisterValidatorServices register the validator services.
func (*Node) ReportPlainErrorSink ¶
func (node *Node) ReportPlainErrorSink() types.TransactionErrorReports
ReportPlainErrorSink is the report of failed transactions this node has (held in memory only)
func (*Node) ReportStakingErrorSink ¶
func (node *Node) ReportStakingErrorSink() types.TransactionErrorReports
ReportStakingErrorSink is the report of failed staking transactions this node has (held in memory only)
func (*Node) SendNewBlockToUnsync ¶
func (node *Node) SendNewBlockToUnsync()
SendNewBlockToUnsync send latest verified block to unsync, registered nodes
func (*Node) ServiceManager ¶
ServiceManager ...
func (*Node) SetNodeBackupMode ¶
SetNodeBackupMode change node backup mode
func (*Node) ShutDown ¶
func (node *Node) ShutDown()
ShutDown gracefully shut down the node server and dump the in-memory blockchain state into DB.
func (*Node) StartGRPCSyncClient ¶
func (node *Node) StartGRPCSyncClient()
StartGRPCSyncClient start the legacy gRPC sync process
func (*Node) StartPubSub ¶
StartPubSub kicks off the node message handling
func (*Node) StartRosetta ¶
StartRosetta start rosetta service
func (*Node) StartServices ¶
StartServices runs registered services.
func (*Node) StartSyncingServer ¶
StartSyncingServer starts syncing server.
func (*Node) StopServices ¶
StopServices runs registered services.
func (*Node) SupportGRPCSyncServer ¶
SupportGRPCSyncServer do gRPC sync server
func (*Node) SyncInstance ¶
func (*Node) SyncStatus ¶
SyncStatus return the syncing status, including whether node is syncing and the target block number, and the difference between current block and target block.
func (*Node) TraceLoopForExplorer ¶
func (node *Node) TraceLoopForExplorer()
func (*Node) VerifyCrossLink ¶
VerifyCrossLink verifies the header is valid
func (*Node) WaitForConsensusReadyV2 ¶
func (node *Node) WaitForConsensusReadyV2(cs *consensus.Consensus, stopChan chan struct{}, stoppedChan chan struct{})
WaitForConsensusReadyV2 listen for the readiness signal from consensus and generate new block for consensus. only leader will receive the ready signal