State Machine

Introduction

The State Machine is a core protocol component responsible for maintaining and updating the state of the blockchain as it progresses. It represents the collective state of all accounts, validators, and other relevant data stored on the blockchain.

Accounts

An account is a structure that holds funds and can send or receive transactions. Each account has a unique address and a balance, think of a bank account, but managed by the blockchain instead of a bank.

message Account {
  // address: the short version of a public key
  bytes address = 1;
  // amount: the balance of funds the account has
  uint64 amount = 2;
}

The native cryptocurrency is able to be transferred to and from accounts from a digital signature from the user's private key that corresponds to the account Address.

message MessageSend {
  // from_address: is the sender of the funds
  bytes from_address = 1;
  // to_address: is the recipient of the funds
  bytes to_address = 2;
  // amount: is the amount of tokens in micro-denomination
  uint64 amount = 3;
}

Pool

A pool is like an account without an owner, holding funds that are managed directly by the blockchain protocol. It's very similar to an account, but instead of an address, it has a unique ID and operates based on predefined blockchain rules rather than individual control.

For example:

  • DAO Treasury Pool

  • Committee Funds Pool

  • Committee Escrow Pool

Validators

A Validator is an actor in the blockchain network responsible for verifying transactions, creating new blocks, and maintaining the blockchain's integrity and security. In Canopy, Validators provide this service for multiple chains by restaking their tokens across multiple 'committees' and run a blockchain client for each.

The native cryptocurrency is able to be surety-bonded by participants to become validators. When staking (bonding), validators are able to choose a variety of configurations:

  • Amount: The amount of tokens to be removed from the sender account and locked as a surety bond against bad behavior during BFT. The entirety of this 'stake' is re-used (restaked) in each Committee BFT at the same time.

  • Committees: The list of chains the validator is restaking their tokens towards.

  • Delegate: A non-delegate is registering for active participation in the committee consensus, whereas a delegate is a passive participant who contributes their tokens to influence subsidized status.

  • Compounding: Automatically compounds rewards to the stake or early withdraws them to the reward address for a penalty.

  • Output Address: The address where early-withdrawal rewards and the unstaking surety bond are transferred to.

⇨ The more tokens the validator bonds, the more voting power it has in consensus operations. However, the more staked, the more at risk if β€˜slashed’ for bad behavior like double or non-signing during consensus.

At any time a validator is able to update their stake information like committees and compounding status by submitting an edit_stake transaction:

In addition to this, the validator may also pause operations across all committees by submitting a pause_tx, temporarily removing it from service, and submit an unpause_tx to resume committee membership.

➩ To exit completely the validator may submit an unstake_tx, permanently leaving the committees it is staked for. A Validator may be Paused up to MaxPauseBlocks before it's automatically unstaked.

Committee

A validator is eligible to provide shared security services to any Nested Chain it chooses.

The quorum of Validators that participate in the BFT process are called Committees.

Once staked for a Committee, the validator connects with the other members of that Committee via the P2P layer. Together, the committee executes consensus for the Nested-Chain, producing immediately final Nested-Chain blocks.

The Root-Chain functions as just another Nested Chain, leveraging the network's shared security. This design allows validators to secure other sub-chains without being required to validate the Root-Chain itself.

➩ For each Nested-Chain block, the elected leader submits a Certificate Result Transaction to the Canopy Root-Chain, encapsulating the results of the quorum.

Subsidization

Each Root-Chain block, new mint is created and is equally sent to the auto-subsidized committees' 'Committee Funds Pool'.

Committees qualify as AutoSubsidized using the following formula:

Example

Subsidization Threshold:

  • 33%

Stakes (Total=200):

  • V1=50,

  • V2=50,

  • V3=100

Committees:

  • C1 β†’ V1 + V2 = 100/200 = 50% βœ… (auto-subsidized)

  • C2 β†’ V1 = 50/200 = 25% ❌ (not-auto-subsidized)

  • C3 β†’ V3 = 100/200 = 50% βœ… (auto-subsidized)

Patrons may manually subsidize the Committee Funds Pool by directly sending tokens to it with an OpCode instruction on distribution rules (if applicable)

From the Committee Funds Pool, the Committee may distribute these rewards at the quorum's discretion.

Rewards

The tokens for the RewardRecipients are distributed from the Committee Pool β€” which is funded by (auto & manual) Subsidies.

If there are multiple Certificate Result Transactions included in a single Root-Chain block β€” the rewards are normalized based on the number of transactions.

Each committee may choose Reward Recipients as determined by their respective softwareβ€”but the default is:

  • 70% β†’ Block Producer: The Root-Chain Validator who produced the Nested-Chain block.

  • 10% β†’ Root-Chain Delegate: Randomly selected by stake-weight from Delegates staked for the NestedChainID on the Root-Chain.

  • 10% β†’ Nested-Chain Validator: Randomly selected by stake-weight from Validators staked for the NestedChainID on the Nested-Chain (will perform BFT once Nested-Chain is independent).

  • 10% β†’ Nested-Chain Delegate: Randomly selected by stake-weight from Delegates staked for the NestedChainID on the Nested-Chain (will influence subsidization once Nested-Chain is independent).

Slashes

SlashRecipients are burned when processing each Certificate Result. By default, slashes only occur for 2 reasons:

  • A Validator didn't sign MaxNonSign blocks within the NonSignWindow of blocks.

  • A Validator Double-Signed blocks β€” violating BFT safety.

Both of these Slashes have respective burn amounts, which are parameterized.

A governance parameter, MaxSlashPerCommittee limits the number of slashes per Committee per block.

⇨ If this limit is exceeded, slashes are capped, and a safety mechanism automatically ejects Validators from the Committee β€” removing their eligibility to participate and receive slashes, preventing cascading failures.

Token Swaps

  1. A Seller may submit CreateOrder transactions that create a sell order on the Root-Chain. When submitting a CreateOrder transaction, the 'Root-Chain asset' is transferred to a Committee controlled escrow pool.

  2. The Buyer may reserve an Order by submitting a transaction to themselves on the 'buyer asset' chain with a LockOrder embedded in the transaction (via SigScript, OpData, Memo etc).

  3. The Committee witnesses the Lock by deterministically parsing the buyer chain block. The Committee marks the on-chain SellOrder as 'Locked' by recording the Buyer's information and setting the BuyerChainDeadline.

  4. The Buyer witnesses their information in the SellOrder on the Root-Chain and directly sends the funds to the Seller β€” embedding a CloseOrder in the transaction.

  5. The Committee witnesses the CloseOrder by deterministically parsing the buyer chain block and releases the Seller's escrowed funds to the Buyer.

  6. The Seller may EditOrder or DeleteOrder if the order is not yet locked.

Governance

Canopy is pre-built with 2 different on-chain governance mechanisms:

  • Polling: Gather community sentiment by executing an on-chain vote of Accounts and Validators.

  • Proposals: Change governance parameters and distribute tokens from the DAO Treasury Fund by completing an on-chain referendum of Validators staked for the Root-Chain committee.

Polling

Polling transactions come in 2 flavors:

  • StartPoll: Encoded in Root-Chain SendTransactions β€” an Account or Validator begins an on-chain poll. StartPoll transactions cost a higher fee as dictated by governance parameters to prevent spam.

  • VotePoll: Encoded in Root-Chain SendTransactions β€” an Account or Validator signals their sentiment with a vote on an existing poll.

Polls are initiated through the built-in decentralized web-wallet

The result of a poll are automatically recorded by the Canopy node deterministically parsing the block for StartPoll and VotePoll transactions.

⇨ The results are updated per block as Account and Validator funds change and may be viewed in the web wallet. Results are locked in after EndBlock and are pruned after a node-configurable expiration height.

Proposals

Canopy has 2 different flavors of Proposal:

  • Change Parameter: update on-chain governance parameters that allow 'on-the-fly' adjustments to the protocol without any software changes.

  • DAO Transfer: Distribute treasury funds from the DAO pool to any account

Proposals require approval from +β…” of the Voting Power of the Root-Chain committee to be finalized.

  1. A Proposal Transaction is created by any community member.

Via built in decentralized Web Wallet
  1. This proposal is exported in JSON format and may be distributed via governance forum.

    Once exported, each Validator configures their node to approve or reject the proposal via the web interface. This configures the node to accept or reject this proposal hash when validating the transaction at the Mempool and BFT level.

  1. Once +β…” of the Voting Power has approved the proposal, the Proposal Transaction may be submitted by any community member to be included in a block. Importantly, the transaction may never be sent before the StartHeight ensuring sufficient time to achieve quorum.

It's an expected pattern to execute a poll to check Validator votes and then execute a proposal to execute an action.

Supply Tracker

A supply tracker is a structure that keeps track of the total amount of tokens or funds available across the entire blockchain.

➀ It provides a single source of truth for the overall token supply managed by the network. It conveniently buckets the tokens into useful categories, allowing transparency and consistency.

'staked' includes delegations, to calculate stake without delegations, simply staked - delegated_only

Last updated