node

package
v0.0.0-...-d1fbc97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package node is the Algorand node itself, with functions exposed to the frontend

Package node is the Algorand node itself, with functions exposed to the frontend

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NetPrioResponseMaxSize

func NetPrioResponseMaxSize() (s int)

MaxSize returns a maximum valid message size for this message type

func NetPrioResponseSignedMaxSize

func NetPrioResponseSignedMaxSize() (s int)

MaxSize returns a maximum valid message size for this message type

Types

type AlgorandFollowerNode

type AlgorandFollowerNode struct {
	// contains filtered or unexported fields
}

AlgorandFollowerNode implements follower mode/ledger delta APIs and disables participation-related methods

func MakeFollower

func MakeFollower(log logging.Logger, rootDir string, cfg config.Local, phonebookAddresses []string, genesis bookkeeping.Genesis) (*AlgorandFollowerNode, error)

MakeFollower sets up an Algorand data node

func (*AlgorandFollowerNode) AbortCatchup

func (node *AlgorandFollowerNode) AbortCatchup(catchpoint string) error

AbortCatchup aborts the given catchpoint this function is intended to be called externally via the REST api interface.

func (*AlgorandFollowerNode) AppendParticipationKeys

func (node *AlgorandFollowerNode) AppendParticipationKeys(_ account.ParticipationID, _ account.StateProofKeys) error

AppendParticipationKeys returns an error in follower mode

func (*AlgorandFollowerNode) AsyncBroadcastSignedTxGroup

func (node *AlgorandFollowerNode) AsyncBroadcastSignedTxGroup(_ []transactions.SignedTxn) (err error)

AsyncBroadcastSignedTxGroup errors in follower mode

func (*AlgorandFollowerNode) BroadcastInternalSignedTxGroup

func (node *AlgorandFollowerNode) BroadcastInternalSignedTxGroup(_ []transactions.SignedTxn) (err error)

BroadcastInternalSignedTxGroup errors in follower mode

func (*AlgorandFollowerNode) BroadcastSignedTxGroup

func (node *AlgorandFollowerNode) BroadcastSignedTxGroup(_ []transactions.SignedTxn) (err error)

BroadcastSignedTxGroup errors in follower mode

func (*AlgorandFollowerNode) Config

func (node *AlgorandFollowerNode) Config() config.Local

Config returns a copy of the node's Local configuration

func (*AlgorandFollowerNode) GenesisHash

func (node *AlgorandFollowerNode) GenesisHash() crypto.Digest

GenesisHash returns the hash of the genesis configuration.

func (*AlgorandFollowerNode) GenesisID

func (node *AlgorandFollowerNode) GenesisID() string

GenesisID returns the ID of the genesis node.

func (*AlgorandFollowerNode) GetBlockTimeStampOffset

func (node *AlgorandFollowerNode) GetBlockTimeStampOffset() (*int64, error)

GetBlockTimeStampOffset gets a timestamp offset. This is only available in dev mode.

func (*AlgorandFollowerNode) GetParticipationKey

GetParticipationKey returns an error in follower mode

func (*AlgorandFollowerNode) GetPendingTransaction

func (node *AlgorandFollowerNode) GetPendingTransaction(_ transactions.Txid) (res TxnWithStatus, found bool)

GetPendingTransaction no-ops in follower mode

func (*AlgorandFollowerNode) GetPendingTxnsFromPool

func (node *AlgorandFollowerNode) GetPendingTxnsFromPool() ([]transactions.SignedTxn, error)

GetPendingTxnsFromPool returns an empty array in follower mode.

func (*AlgorandFollowerNode) GetSyncRound

func (node *AlgorandFollowerNode) GetSyncRound() uint64

GetSyncRound retrieves the sync round, removes cache offset used during SetSyncRound

func (*AlgorandFollowerNode) InstallParticipationKey

func (node *AlgorandFollowerNode) InstallParticipationKey(_ []byte) (account.ParticipationID, error)

InstallParticipationKey returns an error in follower mode

func (*AlgorandFollowerNode) Ledger

func (node *AlgorandFollowerNode) Ledger() *data.Ledger

Ledger exposes the node's ledger handle to the algod API code

func (*AlgorandFollowerNode) ListParticipationKeys

func (node *AlgorandFollowerNode) ListParticipationKeys() (partKeys []account.ParticipationRecord, err error)

ListParticipationKeys returns an empty list in follower mode

func (*AlgorandFollowerNode) ListeningAddress

func (node *AlgorandFollowerNode) ListeningAddress() (string, bool)

ListeningAddress retrieves the node's current listening address, if any. Returns true if currently listening, false otherwise.

func (*AlgorandFollowerNode) OnNewBlock

func (node *AlgorandFollowerNode) OnNewBlock(block bookkeeping.Block, _ ledgercore.StateDelta)

OnNewBlock implements the BlockListener interface so we're notified after each block is written to the ledger

func (*AlgorandFollowerNode) RemoveParticipationKey

func (node *AlgorandFollowerNode) RemoveParticipationKey(_ account.ParticipationID) error

RemoveParticipationKey returns an error in follower mode

func (*AlgorandFollowerNode) SetBlockTimeStampOffset

func (node *AlgorandFollowerNode) SetBlockTimeStampOffset(offset int64) error

SetBlockTimeStampOffset sets a timestamp offset in the block header. This is only available in dev mode.

func (*AlgorandFollowerNode) SetCatchpointCatchupMode

func (node *AlgorandFollowerNode) SetCatchpointCatchupMode(catchpointCatchupMode bool) (outCtxCh <-chan context.Context)

SetCatchpointCatchupMode change the node's operational mode from catchpoint catchup mode and back, it returns a channel which contains the updated node context. This function need to work asynchronously so that the caller could detect and handle the use case where the node is being shut down while we're switching to/from catchup mode without deadlocking on the shared node mutex.

func (*AlgorandFollowerNode) SetSyncRound

func (node *AlgorandFollowerNode) SetSyncRound(rnd uint64) error

SetSyncRound sets the minimum sync round on the catchup service

func (*AlgorandFollowerNode) Simulate

func (node *AlgorandFollowerNode) Simulate(request simulation.Request) (result simulation.Result, err error)

Simulate speculatively runs a transaction group against the current blockchain state and returns the effects and/or errors that would result.

func (*AlgorandFollowerNode) Start

func (node *AlgorandFollowerNode) Start() error

Start the node: connect to peers while obtaining a lock. Doesn't wait for initial sync.

func (*AlgorandFollowerNode) StartCatchup

func (node *AlgorandFollowerNode) StartCatchup(catchpoint string) error

StartCatchup starts the catchpoint mode and attempt to get to the provided catchpoint this function is intended to be called externally via the REST api interface.

func (*AlgorandFollowerNode) Status

func (node *AlgorandFollowerNode) Status() (StatusReport, error)

Status returns a StatusReport structure reporting our status as Active and with our ledger's LastRound

func (*AlgorandFollowerNode) Stop

func (node *AlgorandFollowerNode) Stop()

Stop stops running the node. Once a node is closed, it can never start again.

func (*AlgorandFollowerNode) SuggestedFee

func (node *AlgorandFollowerNode) SuggestedFee() basics.MicroAlgos

SuggestedFee no-ops in follower mode

func (*AlgorandFollowerNode) UnsetSyncRound

func (node *AlgorandFollowerNode) UnsetSyncRound()

UnsetSyncRound removes the sync round constraint on the catchup service

type AlgorandFullNode

type AlgorandFullNode struct {
	// contains filtered or unexported fields
}

AlgorandFullNode specifies and implements a full Algorand node.

func MakeFull

func MakeFull(log logging.Logger, rootDir string, cfg config.Local, phonebookAddresses []string, genesis bookkeeping.Genesis) (*AlgorandFullNode, error)

MakeFull sets up an Algorand full node (i.e., it returns a node that participates in consensus)

func (*AlgorandFullNode) AbortCatchup

func (node *AlgorandFullNode) AbortCatchup(catchpoint string) error

AbortCatchup aborts the given catchpoint this function is intended to be called externally via the REST api interface.

func (*AlgorandFullNode) AppendParticipationKeys

func (node *AlgorandFullNode) AppendParticipationKeys(partKeyID account.ParticipationID, keys account.StateProofKeys) error

AppendParticipationKeys given a participation id, remove the records from the node

func (*AlgorandFullNode) AssembleBlock

func (node *AlgorandFullNode) AssembleBlock(round basics.Round, addrs []basics.Address) (agreement.UnfinishedBlock, error)

AssembleBlock implements Ledger.AssembleBlock.

func (*AlgorandFullNode) AsyncBroadcastSignedTxGroup

func (node *AlgorandFullNode) AsyncBroadcastSignedTxGroup(txgroup []transactions.SignedTxn) (err error)

AsyncBroadcastSignedTxGroup feeds a raw transaction group directly to the transaction pool. This method is intended to be used for performance testing and debugging purposes only.

func (*AlgorandFullNode) BroadcastInternalSignedTxGroup

func (node *AlgorandFullNode) BroadcastInternalSignedTxGroup(txgroup []transactions.SignedTxn) (err error)

BroadcastInternalSignedTxGroup broadcasts a transaction group that has already been signed. It is originated internally, and in DevMode, it will not advance the round.

func (*AlgorandFullNode) BroadcastSignedTxGroup

func (node *AlgorandFullNode) BroadcastSignedTxGroup(txgroup []transactions.SignedTxn) (err error)

BroadcastSignedTxGroup broadcasts a transaction group that has already been signed.

func (*AlgorandFullNode) Capabilities

func (node *AlgorandFullNode) Capabilities() []p2p.Capability

Capabilities returns the node's capabilities for advertising to other nodes.

func (*AlgorandFullNode) Config

func (node *AlgorandFullNode) Config() config.Local

Config returns a copy of the node's Local configuration

func (*AlgorandFullNode) GenesisHash

func (node *AlgorandFullNode) GenesisHash() crypto.Digest

GenesisHash returns the hash of the genesis configuration.

func (*AlgorandFullNode) GenesisID

func (node *AlgorandFullNode) GenesisID() string

GenesisID returns the ID of the genesis node.

func (*AlgorandFullNode) GetBlockTimeStampOffset

func (node *AlgorandFullNode) GetBlockTimeStampOffset() (*int64, error)

GetBlockTimeStampOffset gets a timestamp offset. This is only available in dev mode.

func (*AlgorandFullNode) GetParticipationKey

func (node *AlgorandFullNode) GetParticipationKey(partKeyID account.ParticipationID) (account.ParticipationRecord, error)

GetParticipationKey retries the information of a participation id from the node

func (*AlgorandFullNode) GetPendingTransaction

func (node *AlgorandFullNode) GetPendingTransaction(txID transactions.Txid) (res TxnWithStatus, found bool)

GetPendingTransaction looks for the required txID in the recent ledger blocks, in the txpool, and in the txpool's status cache. It returns the SignedTxn (with status information), and a bool to indicate if the transaction was found.

func (*AlgorandFullNode) GetPendingTxnsFromPool

func (node *AlgorandFullNode) GetPendingTxnsFromPool() ([]transactions.SignedTxn, error)

GetPendingTxnsFromPool returns a snapshot of every pending transactions from the node's transaction pool in a slice. Transactions are sorted in decreasing order. If no transactions, returns an empty slice.

func (*AlgorandFullNode) GetPrioWeight

func (node *AlgorandFullNode) GetPrioWeight(addr basics.Address) uint64

GetPrioWeight implements the network.NetPrioScheme interface

func (*AlgorandFullNode) GetSyncRound

func (node *AlgorandFullNode) GetSyncRound() uint64

GetSyncRound returns 0 (not set) in the base node implementation

func (*AlgorandFullNode) InstallParticipationKey

func (node *AlgorandFullNode) InstallParticipationKey(partKeyBinary []byte) (account.ParticipationID, error)

InstallParticipationKey Given a participation key binary stream install the participation key.

func (*AlgorandFullNode) IsParticipating

func (node *AlgorandFullNode) IsParticipating() bool

IsParticipating implements network.NodeInfo

This function is not fully precise. node.ledger and node.accountManager might move relative to each other and there is no synchronization. This is good-enough for current uses of IsParticipating() which is used in networking code to determine if the node should ask for transaction gossip (or skip it to save bandwidth). The current transaction pool size is about 3 rounds. Starting to receive transaction gossip 10 rounds in the future when we might propose or vote on blocks in that future is a little extra buffer but seems reasonable at this time. -- bolson 2022-05-18

func (*AlgorandFullNode) Ledger

func (node *AlgorandFullNode) Ledger() *data.Ledger

Ledger exposes the node's ledger handle to the algod API code

func (*AlgorandFullNode) ListParticipationKeys

func (node *AlgorandFullNode) ListParticipationKeys() (partKeys []account.ParticipationRecord, err error)

ListParticipationKeys returns all participation keys currently installed on the node

func (*AlgorandFullNode) ListeningAddress

func (node *AlgorandFullNode) ListeningAddress() (string, bool)

ListeningAddress retrieves the node's current listening address, if any. Returns true if currently listening, false otherwise.

func (*AlgorandFullNode) MakePrioResponse

func (node *AlgorandFullNode) MakePrioResponse(challenge string) []byte

MakePrioResponse implements the network.NetPrioScheme interface

func (*AlgorandFullNode) NewPrioChallenge

func (node *AlgorandFullNode) NewPrioChallenge() string

NewPrioChallenge implements the network.NetPrioScheme interface

func (*AlgorandFullNode) OnNewBlock

func (node *AlgorandFullNode) OnNewBlock(block bookkeeping.Block, delta ledgercore.StateDelta)

OnNewBlock implements the BlockListener interface so we're notified after each block is written to the ledger

func (*AlgorandFullNode) Record

func (node *AlgorandFullNode) Record(account basics.Address, round basics.Round, participationType account.ParticipationAction)

Record forwards participation record calls to the participation registry.

func (*AlgorandFullNode) RemoveParticipationKey

func (node *AlgorandFullNode) RemoveParticipationKey(partKeyID account.ParticipationID) error

RemoveParticipationKey given a participation id, remove the records from the node

func (*AlgorandFullNode) SetBlockTimeStampOffset

func (node *AlgorandFullNode) SetBlockTimeStampOffset(offset int64) error

SetBlockTimeStampOffset sets a timestamp offset in the block header. This is only available in dev mode.

func (*AlgorandFullNode) SetCatchpointCatchupMode

func (node *AlgorandFullNode) SetCatchpointCatchupMode(catchpointCatchupMode bool) (outCtxCh <-chan context.Context)

SetCatchpointCatchupMode change the node's operational mode from catchpoint catchup mode and back, it returns a channel which contains the updated node context. This function need to work asynchronously so that the caller could detect and handle the use case where the node is being shut down while we're switching to/from catchup mode without deadlocking on the shared node mutex.

func (*AlgorandFullNode) SetSyncRound

func (node *AlgorandFullNode) SetSyncRound(_ uint64) error

SetSyncRound no-ops

func (*AlgorandFullNode) Simulate

func (node *AlgorandFullNode) Simulate(request simulation.Request) (result simulation.Result, err error)

Simulate speculatively runs a transaction group against the current blockchain state and returns the effects and/or errors that would result.

func (*AlgorandFullNode) Start

func (node *AlgorandFullNode) Start() error

Start the node: connect to peers and run the agreement service while obtaining a lock. Doesn't wait for initial sync.

func (*AlgorandFullNode) StartCatchup

func (node *AlgorandFullNode) StartCatchup(catchpoint string) error

StartCatchup starts the catchpoint mode and attempt to get to the provided catchpoint this function is intended to be called externally via the REST api interface.

func (*AlgorandFullNode) Status

func (node *AlgorandFullNode) Status() (StatusReport, error)

Status returns a StatusReport structure reporting our status as Active and with our ledger's LastRound

func (*AlgorandFullNode) Stop

func (node *AlgorandFullNode) Stop()

Stop stops running the node. Once a node is closed, it can never start again.

func (*AlgorandFullNode) SuggestedFee

func (node *AlgorandFullNode) SuggestedFee() basics.MicroAlgos

SuggestedFee returns the suggested fee per byte recommended to ensure a new transaction is processed in a timely fashion. Caller should set fee to max(MinTxnFee, SuggestedFee() * len(encoded SignedTxn))

func (*AlgorandFullNode) Uint64

func (node *AlgorandFullNode) Uint64() uint64

Uint64 implements the randomness by calling the crypto library.

func (*AlgorandFullNode) UnsetSyncRound

func (node *AlgorandFullNode) UnsetSyncRound()

UnsetSyncRound no-ops

func (*AlgorandFullNode) VerifyPrioResponse

func (node *AlgorandFullNode) VerifyPrioResponse(challenge string, response []byte) (addr basics.Address, err error)

VerifyPrioResponse implements the network.NetPrioScheme interface

func (*AlgorandFullNode) VotingAccountsForRound

func (node *AlgorandFullNode) VotingAccountsForRound(round basics.Round) []basics.Address

VotingAccountsForRound provides a list of addresses that have participation keys valid for the given round. These accounts may not all be eligible to propose, but they are a superset of eligible proposers.

func (*AlgorandFullNode) VotingKeys

func (node *AlgorandFullNode) VotingKeys(votingRound, keysRound basics.Round) []account.ParticipationRecordForRound

VotingKeys implements the key manager's VotingKeys method, and provides additional validation with the ledger. that allows us to load multiple overlapping keys for the same account, and filter these per-round basis.

type CatchpointAlreadyInProgressError

type CatchpointAlreadyInProgressError struct {
	// contains filtered or unexported fields
}

CatchpointAlreadyInProgressError indicates that the requested catchpoint is already running

func MakeCatchpointAlreadyInProgressError

func MakeCatchpointAlreadyInProgressError(catchpoint string) *CatchpointAlreadyInProgressError

MakeCatchpointAlreadyInProgressError creates the error

func (*CatchpointAlreadyInProgressError) Error

Error satisfies builtin interface `error`

type CatchpointUnableToStartError

type CatchpointUnableToStartError struct {
	// contains filtered or unexported fields
}

CatchpointUnableToStartError indicates that the requested catchpoint cannot be started

func MakeCatchpointUnableToStartError

func MakeCatchpointUnableToStartError(catchpointRunning, catchpointRequested string) *CatchpointUnableToStartError

MakeCatchpointUnableToStartError creates the error

func (*CatchpointUnableToStartError) Error

Error satisfies builtin interface `error`

type StartCatchpointError

type StartCatchpointError struct {
	// contains filtered or unexported fields
}

StartCatchpointError is returned when the catchpoint service cannot start up.

func MakeStartCatchpointError

func MakeStartCatchpointError(catchpointRequested string, err error) *StartCatchpointError

MakeStartCatchpointError creates a StartCatchpointError for a given catchpoint

func (*StartCatchpointError) Error

func (e *StartCatchpointError) Error() string

Error satisfies the builtin interface `error`

type StatusReport

type StatusReport struct {
	LastRound                          basics.Round
	LastVersion                        protocol.ConsensusVersion
	NextVersion                        protocol.ConsensusVersion
	NextVersionRound                   basics.Round
	NextVersionSupported               bool
	LastRoundTimestamp                 time.Time
	SynchronizingTime                  time.Duration
	CatchupTime                        time.Duration
	HasSyncedSinceStartup              bool
	StoppedAtUnsupportedRound          bool
	LastCatchpoint                     string // the last catchpoint hit by the node. This would get updated regardless of whether the node is catching up using catchpoints or not.
	Catchpoint                         string // the catchpoint where we're currently catching up to. If the node isn't in fast catchup mode, it will be empty.
	CatchpointCatchupTotalAccounts     uint64
	CatchpointCatchupProcessedAccounts uint64
	CatchpointCatchupVerifiedAccounts  uint64
	CatchpointCatchupTotalKVs          uint64
	CatchpointCatchupProcessedKVs      uint64
	CatchpointCatchupVerifiedKVs       uint64
	CatchpointCatchupTotalBlocks       uint64
	CatchpointCatchupAcquiredBlocks    uint64
	UpgradePropose                     protocol.ConsensusVersion
	UpgradeApprove                     bool
	UpgradeDelay                       uint64
	NextProtocolVoteBefore             basics.Round
	NextProtocolApprovals              uint64
}

StatusReport represents the current basic status of the node

func (StatusReport) TimeSinceLastRound

func (status StatusReport) TimeSinceLastRound() time.Duration

TimeSinceLastRound returns the time since the last block was approved (locally), or 0 if no blocks seen

type TxnWithStatus

type TxnWithStatus struct {
	Txn transactions.SignedTxn

	// Zero indicates no confirmation
	ConfirmedRound basics.Round

	// PoolError indicates that the transaction was kicked out of this
	// node's transaction pool (and specifies why that happened).  An
	// empty string indicates the transaction wasn't kicked out of this
	// node's txpool due to an error.
	PoolError string

	// ApplyData is the transaction.ApplyData, if committed.
	ApplyData transactions.ApplyData
}

TxnWithStatus represents information about a single transaction, in particular, whether it has appeared in some block yet or not, and whether it was kicked out of the txpool due to some error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL