package
0.0.0-20250128221834-b70a5daccdb4
Repository: https://github.com/canopy-network/canopy.git
Documentation: pkg.go.dev
# Functions
AddToPort() adds some number to the port ensuring it doesn't exceed the max port.
BigLess() compares two big.Int values and returns true if the first is less.
BytesToString() converts a byte slice to a hexadecimal string.
BytesToTruncatedString() converts a byte slice to a truncated hexadecimal string.
CatchPanic() catches any panic in the function call or child function calls.
DefaultConfig() returns a Config with developer set options.
DefaultConsensusConfig() configures 10 minute blocks.
DefaultDataDirPath() is $USERHOME/.canopy.
DefaultMainConfig() sets log level to 'info'.
DefaultMempoolConfig() returns the developer created Mempool options.
No description provided by the author
DefaultRPCConfig() sets rpc url to localhost and sets wallet, explorer, rpc, and admin ports from [50000-50003].
DefaultStateMachineConfig returns an empty object.
DefaultStoreConfig() returns the developer recommended store configuration.
Delimit() appends the items together separated by a delimiter.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FormatSortitionInput() returns the 'seed data' for the VRF function `seed = lastNProposerPublicKeys + height + round`.
FromAny() converts an anypb.Any type back into a proto.Message.
Marshal() serializes a proto.Message into a byte slice.
MarshalJSON() serializes a message into a JSON byte slice.
MarshalJSONIndent() serializes a message into an indented JSON byte slice.
MarshalJSONIndentString() serializes a message into an indented JSON string.
MerkleTree() generates a Merkle tree and its root from a list of items.
NewAny() converts a proto.Message into an anypb.Any type.
NewConfigFromFile() populates a Config object from a JSON file.
NewDefaultLogger() creates a Logger with default settings, logging at the Debug level to stdout.
No description provided by the author
NewFailedTxCache returns a new FailedTxCache.
NewHexBytesFromString() converts a hexadecimal string into HexBytes.
NewJSONFromFile() reads a json object from file.
NewLimiter() returns a new instance of SimpleLimiter with - max requests per requester - max total requests - how often to reset the limiter.
NewLogger() creates a new Logger instance with the specified configuration and optional data directory path.
NewMempool() creates a new FeeMempool instance of a Mempool.
NewMempoolIterator() initializes a new iterator for the mempool transactions.
NewMessageCache() initializes and returns a new MessageCache instance.
NewNullLogger() creates a Logger that discards all log output.
NewPage() returns a new instance of the Page object from the params and pageType Load() or LoadArray() is the likely next function call.
NewRetry() constructs a new Retry given parameters.
NewTimer() creates a 0 value initialized instance of a timer.
NewValidatorSet() initializes a ValidatorSet from a given set of consensus validators.
NewVDFService() creates a new instance of the VDF service.
No description provided by the author
PublicKeyFromBytes() converts a byte slice into a BLS public key.
RemoveIPV4Port() removes the port from an IP address or URL string.
ResetTimer() stops the existing timer, and resets with the new duration.
ResolvePort() executes a network wide protocol for determining what the p2p port of the peer is This is useful to allow 1 URL in state to expand to many different routing paths for sub-chains Example: ResolvePort(CHAIN-ID = 2) returns 9002.
SaveJSONToFile() saves a json object to a file.
StopTimer() stops the existing timer.
StringToBytes() converts a hexadecimal string back into a byte slice.
TimeTrack() a utility function to benchmark the time.
TruncateSlice() safely ensures that a slice doesn't exceed the max size.
Uint64Percentage() calculates the result of a percentage of an amount.
Uint64PercentageDiv() calculates the percentage from dividend/divisor.
Uint64ReducePercentage() reduces an amount by a specified percentage.
Uint64ToBigFloat() converts a uint64 to a big.Float.
Unmarshal() deserializes a byte slice into a proto.Message.
UnmarshalJSON() deserializes a JSON byte slice into the specified object.
ValidNetURLInput() validates the input netURL via regex Allow: - optional tcp:// prefix - valid hostname - valid ip4 and ip6 address
Disallow: - Ports - Sub-paths.
WeightedPseudorandom() runs the 'no candidates' backup algorithm - generates an index for the 'token' that is our Leader from the seed data.
# Constants
BlockResults as a pageable name.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Consensus Module Error Codes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Main Module Error Codes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
State Machine Module Error Codes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
P2P Module Error Codes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Consensus Module.
No description provided by the author
No description provided by the author
No description provided by the author
ensures developers are aware of a change to the header size (which is a consensus breaking change).
the name of a page of failed transactions.
condition must be false.
condition must be true.
true or false condition.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
IterationsFixedDecreasePercent is a 'best-guess' iteration reduction when a Stop() is called before finishing.
No description provided by the author
No description provided by the author
Main Module.
No description provided by the author
P2P Module.
the name of a page of mempool pending transactions.
commit: The leader collects PRECOMMIT_VOTEs from +2/3 from the replicas, each including a signature from the sender.
commit_process: Each replica validates the COMMIT msg by verifying the aggregate signature.
election: Each replica runs a Verifiable Random Function (VRF); if selected as a candidate, the replica sends its VRF output to the other replicas.
election_vote: Each replica sends ELECTION votes (signature) for the leader based on the lowest VRF value if no candidates exist, the process falls back to a stake-weighted-pseudorandom selection.
pacemaker: This phase follows ROUND_INTERRUPT, each replica calculates the highest round a super-majority has seen and jumps to it to assist in 'round out of sync' issues.
precommit: The leader collects PROPOSE_VOTEs from +2/3 of the replicas, each including a signature from the sender.
precommit_vote: Each replica validates the PRECOMMIT msg by verifying the aggregate signature.
propose: The leader collects ELECTION_VOTEs from +2/3 of the replicas, each including the lock, evidence, and signature from the sender.
propose_vote: Each replica validates the PROPOSE msg by verifying the aggregate signature, applying the proposal block against their state machine, and checking the header and results against what they produced.
round_interrupt: A failure in the bft cycle caused a premature exit in the round.
unknown: is an unidentified phase that is likely an error.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StartingIterationsPerSecond is a 'best-guess' estimate based on 2.3 GHz 8-Core Intel Core i9.
State Machine Module.
No description provided by the author
BLOCK: topic for an inbound block and certificate.
BLOCK_REQUEST: topic for a peer requesting a certain block and certificate.
CONSENSUS: topic for the BFT process.
INVALID: topic to mark the exclusive end of valid topics.
PEERS_REQUEST: topic a peer requesting an exchange of book peers.
PEERS_RESPONSE: topic for a response to a peer exchange request.
TX: topic for an inbound transaction.
the name of a page of transactions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
the delimiter that allows safe key prefixing (ex.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Enum value maps for Phase.
Enum value maps for Phase.
Messages must be pre-registered for Transaction JSON unmarshalling.
RegisteredPageables is a global slice of registered pageables for generic unmarshalling.
Enum value maps for Topic.
Enum value maps for Topic.
# Structs
An Aggregate Signature is a single, compact signature created by combining multiple individual signatures from different participants.
BaseChainInfo maintains base-chain data needed for consensus.
BasicAuth is the golang abstraction of the simple user/pass http authentication scheme.
A block is a batch of transactions and essential header information that marks a unit of committed information in the blockchain.
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format.
BlockMessage is a p2p message payload that is responding to a block request message.
BlockRequestMessage is a p2p message payload that is requesting a block and/or max_height of the peer.
a block_result is a batch of transaction results, essential header information, and non-essential metadata about processing that block.
block_result_meta is non-essential information about the processing of a block.
BuyOrder is a buyer expressing an intent to purchase an order, often referred to as 'claiming' the order.
CertificateResult contains the outcome of a Quorum Certificate as it pertains to Canopy's base chain.
Checkpoint is 3rd party chain information that allows Canopy to provide Checkpointing-as-a-Service for the 3rd party checkpointing is important to prevent `long-range-attacks` in proof of stake blockchains and is currently the secure standard.
CommitteeData is current status information about the current status of the Committee.
CommitteesData is a list of essential information about the committee.
Config is the structure of the user configuration options for a Canopy node.
ConsensusConfig defines the consensus phase timeouts for bft synchronicity NOTES: - BlockTime = ElectionTimeout + ElectionVoteTimeout + ProposeTimeout + ProposeVoteTimeout + PrecommitTimeout + PrecommitVoteTimeout + CommitTimeout + CommitProcess - async faults may lead to extended block time - social consensus dictates BlockTime for the protocol - being too fast or too slow can lead to Non-Signing and Consensus failures.
ConsensusMessage is a p2p message payload that is handled by the BFT module.
ConsensusValidator is the bft abstraction of the Validator structure that only contains information relevant to the bft process.
ConsensusValidators is a list of Consensus Validator objects used in the bft process often representing a BFT committee.
DoubleSigner identifies a validator who has been caught double signing and should be slashed The structure includes the validator's public key and a list of block heights where the double signing occurred.
No description provided by the author
FailedTx contains a failed transaction and its error.
FailedTxCache is a cache of failed transactions that is used to inform the user of the failure.
FeeMempool is a Mempool implementation that prioritizes transactions with the highest fees.
Logger is the concrete implementation of LoggerI, managing log output based on configuration.
LoggerConfig holds configuration settings for the logger, including logging level and output writer.
LotteryWinner is a structure that holds the subject of a pseudorandom selection and their % cut of the reward This is used for delegation + sub-delegation + sub-validator earnings.
No description provided by the author
MempoolConfig is the user configuration of the unconfirmed transaction pool.
MempoolTx is a wrapper over Transaction bytes that maintains the fee associated with the bytes.
MempoolTxs is a list of MempoolTxs with a count.
MessageAndMetadata is a wrapper over a P2P message with information about the sender and the hash of the message for easy de-duplication at the module level.
MessageCache is a simple p2p message de-duplicator that protects redundancy in the p2p network.
OrderBook: a list of sell orders associated with a particular committee held in the blockchain state.
OrderBooks: is a list of order book objects held in the blockchain state.
Orders: tracks actions related to 'buyer side' activities for sell orders The committee monitors the 3rd party chain for actions such as intent to buy, funds sent, and funds not sent, and communicates these states to the Canopy chain.
P2PConfig defines peering compatibility and limits as well as actions on specific peering IPs / IDs.
Page is a pagination wrapper over a slice of data.
PageParams are the input parameters to calculate the proper page.
PaymentPercents represents the distribution of rewards to recipients from the committee treasury pool Each recipient is identified by their address and the percentage of the reward they will receive Percents are diluted based on how many samples are in the Committee Data.
PeerAddress holds the details of the peer's network address and public key.
PeerInfo contains peering information about a peer node, like its address, connection type, trust level, and reputation.
PeerMeta contains additional metadata about a peer, including supported networks and chains.
PluginConfig defines the 'add-on' software that dictates and enables Committee consensus.
PluginsConfig is a list of the 'add-on' software that dictates and enables Committee consensus.
Proposers is a list of addresses that represent the previous proposers.
PseudorandomParams are the input params to run the Stake-Weighted-Pseudorandom fallback leader selection algorithm.
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format.
RemoteCallbacks are fallback rpc callbacks to the base-chain.
Retry is a simple exponential backoff retry structure in the form of doubling the timeout.
RewardRecipients is the list of recipients who will receive rewards from the committee's treasury pool, based on decisions confirmed in a Quorum Certificate.
No description provided by the author
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format.
A Signature is a digital signature is a cryptographic "fingerprint" created with a private key, allowing others to verify the authenticity and integrity of a message using the corresponding public key.
SimpleLimiter ensures the number of requests don't exceed a total limit and a limit per requester during a timeframe.
SlashRecipients is the list of recipients who are penalized based on misbehavior, like double signing or bad proposing based on a committee agreement confirmed in a Quorum Certificate.
SortitionData is the seed data for the IsCandidate and VRF functions.
StateMachineConfig is an empty placeholder.
StoreConfig is user configurations for the key value database.
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format.
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format.
TxMessage is a p2p message payload that is an inbound transaction to be processed by the blockchain's FSM and saved in that chains mempool.
TxResult represents the result of a processed transaction, including information about the sender, recipient, transaction hash, and the associated block height and index.
UInt64Wrapper is a protobuf wrapper around a string primitive.
ValidatorFilters are used to filter types of validators from a ValidatorPage.
ValidatorSet represents a collection of validators responsible for consensus It facilitates the creation and validation of +2/3 Majority agreements using multi-signatures.
VDFService is a structure that wraps Verifiable Delay Functionality Verifiable Delay Function (VDF) is a cryptographic algorithm that requires a specific, non-parallelizable amount of time to compute, while its result can be quickly and easily verified Here's how it works: - VDFService.Run() runs the VDF for a pre-defined number of iterations - There's two paths: Success and Interrupt, either path results in an adjustment in the number of iterations based on ProcessingTime (how long it took) vs TargetTime (the desired completion time) - - The success path is a non-interrupted VDF run.
A View is a specific point in the consensus process; think of it like a snapshot of the consensus process at a certain point in time.
# Interfaces
No description provided by the author
IteratorI defines an interface for iterating over key-value pairs in a data store.
LoggerI defines the interface for various logging levels and formatted output.
Mempool interface is a model for a pre-block, in-memory, Transaction store.
MessageI is the model of a message object (send, stake, edit-stake, etc.).
Pageable() is a simple interface that represents Page structures.
ProveStoreI defines an interface.
ReadOnlyStoreI defines a Read-Only interface for accessing the blockchain storage including membership and non-membership proofs.
RIndexerI defines the read interface for the indexing operations.
WStoreI defines an interface for basic read operations.
RWIndexerI defines the Read/Write interface for indexing operations.
RWStoreI defines the Read/Write interface for basic db CRUD operations.
No description provided by the author
SignatureI is the model of a signature object (a signature and public key bytes pair).
No description provided by the author
StoreI defines the interface for interacting with blockchain storage.
StoreTxnI defines an interface for discardable.
TransactionI is the model of a transaction object (a record of an action or event).
TxResultI is the model of a completed transaction object after execution.
WIndexerI defines the write interface for the indexing operations.
WStoreI defines an interface for basic write operations.
# Type aliases
BlockResults is a collection of Blocks containing their TransactionResults and Meta after commitment.
Channels are logical communication paths or streams that operate over a single 'multiplexed' network connection.
No description provided by the author
No description provided by the author
No description provided by the author
FilterOption symbolizes 'condition must be true (yes)' 'condition must be false (no)' or 'filter off (both)' for filters.
HexBytes represents a byte slice that can be marshaled and unmarshalled as hex strings.
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format.
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format.
No description provided by the author