Documentation
¶
Index ¶
- Constants
- Variables
- type BaseTransaction
- func (tx *BaseTransaction) Bytes() []byte
- func (tx *BaseTransaction) Execute() error
- func (tx *BaseTransaction) Fee() uint64
- func (tx *BaseTransaction) GetQuantumSignature() *quantum.QuantumSignature
- func (tx *BaseTransaction) ID() ids.ID
- func (tx *BaseTransaction) Timestamp() time.Time
- func (tx *BaseTransaction) Verify() error
- type Block
- func (b *Block) Accept(ctx context.Context) error
- func (b *Block) Bytes() []byte
- func (b *Block) Height() uint64
- func (b *Block) ID() ids.ID
- func (b *Block) Parent() ids.ID
- func (b *Block) ParentID() ids.ID
- func (b *Block) Reject(context.Context) error
- func (b *Block) Status() uint8
- func (b *Block) String() string
- func (b *Block) Timestamp() time.Time
- func (b *Block) TimestampUnix() int64
- func (b *Block) Verify(ctx context.Context) error
- type BlockSummary
- type Factory
- type GenerateCoronaKeyArgs
- type GenerateCoronaKeyReply
- type GetBlockArgs
- type GetBlockReply
- type GetConfigArgs
- type GetConfigReply
- type GetHealthArgs
- type GetHealthReply
- type GetPendingTransactionsArgs
- type GetPendingTransactionsReply
- type PendingBlock
- type Quasar
- func (q *Quasar) AddSignature(blockID ids.ID, sig *quasar.QuasarSig) error
- func (q *Quasar) AddValidator(validatorID string, weight uint64) error
- func (q *Quasar) Cleanup(minHeight uint64)
- func (q *Quasar) Committee() int
- func (q *Quasar) GetActiveValidators() int
- func (q *Quasar) GetQuasar() *quasar.Quasar
- func (q *Quasar) GetThreshold() int
- func (q *Quasar) IsFinalized(blockID ids.ID) bool
- func (q *Quasar) SignBlock(ctx context.Context, blockID ids.ID, blockHash []byte, height uint64) (*quasar.QuasarSig, error)
- func (q *Quasar) TryFinalize(ctx context.Context, blockID ids.ID) (*quasar.AggregatedSignature, bool, error)
- func (q *Quasar) VerifyAggregate(ctx context.Context, message []byte, agg *quasar.AggregatedSignature) bool
- func (q *Quasar) VerifySignature(message []byte, sig *quasar.QuasarSig) bool
- type QuasarBridge
- type QuasarBridgeConfig
- type QuasarConfig
- type Service
- func (s *Service) GenerateCoronaKey(r *http.Request, args *GenerateCoronaKeyArgs, reply *GenerateCoronaKeyReply) error
- func (s *Service) GetBlock(r *http.Request, args *GetBlockArgs, reply *GetBlockReply) error
- func (s *Service) GetConfig(r *http.Request, args *GetConfigArgs, reply *GetConfigReply) error
- func (s *Service) GetHealth(r *http.Request, args *GetHealthArgs, reply *GetHealthReply) error
- func (s *Service) GetPendingTransactions(r *http.Request, args *GetPendingTransactionsArgs, ...) error
- func (s *Service) VerifyQuantumSignature(r *http.Request, args *VerifyQuantumSignatureArgs, ...) error
- type Transaction
- type TransactionPool
- func (p *TransactionPool) AddTransaction(tx Transaction) error
- func (p *TransactionPool) Close()
- func (p *TransactionPool) GetPendingTransactions(limit int) []Transaction
- func (p *TransactionPool) PendingCount() int
- func (p *TransactionPool) RemoveTransaction(txID ids.ID) error
- func (p *TransactionPool) WaitForEvent(ctx context.Context) (luxvm.Message, error)
- type TransactionSummary
- type TransactionWorker
- type VM
- func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)
- func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
- func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)
- func (vm *VM) CreateStaticHandlers(ctx context.Context) (map[string]http.Handler, error)
- func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) FeePolicy() fee.Policy
- func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (chain.Block, error)
- func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
- func (vm *VM) GetQuasarBridge() *QuasarBridge
- func (vm *VM) HealthCheck(ctx context.Context) (chain.HealthResult, error)
- func (vm *VM) Initialize(ctx context.Context, init luxvm.Init) error
- func (vm *VM) IssueTx(tx Transaction) error
- func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)
- func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)
- func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (chain.Block, error)
- func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error
- func (vm *VM) SetState(ctx context.Context, state uint32) error
- func (vm *VM) Shutdown(ctx context.Context) error
- func (vm *VM) StampBlock(blockID ids.ID, pChainHeight uint64, message []byte) (interface{}, error)
- func (vm *VM) VerifyStamp(message []byte, stamp interface{}) error
- func (vm *VM) Version(ctx context.Context) (string, error)
- func (vm *VM) WaitForEvent(ctx context.Context) (luxvm.Message, error)
- type VerifyQuantumSignatureArgs
- type VerifyQuantumSignatureReply
Constants ¶
const MaxBlockSize = 2 << 20 // 2 MiB
MaxBlockSize bounds a block on the wire. Without it a peer decides how much memory this node allocates and how much its store holds: parse, verify and commit each walked whatever arrived.
const MaxFutureSkew = 60 * time.Second
MaxFutureSkew is how far ahead of the verifying node's clock a proposer may stamp a block. Peers' clocks differ, and this is the allowance for that; an uncapped timestamp is a proposer writing chain time, which is what decides whether the NEXT block may be stamped at all.
const Version = "1.0.0"
Version of the QVM
Variables ¶
var VMID = ids.ID{'q', 'u', 'a', 'n', 't', 'u', 'm', 'v', 'm'}
VMID is the unique identifier for QuantumVM (Q-Chain)
Functions ¶
This section is empty.
Types ¶
type BaseTransaction ¶
type BaseTransaction struct {
// contains filtered or unexported fields
}
BaseTransaction provides common transaction functionality
func (*BaseTransaction) Bytes ¶
func (tx *BaseTransaction) Bytes() []byte
Bytes returns the transaction's canonical ZAP wire. It excludes the quantum signature (which signs over exactly these bytes).
func (*BaseTransaction) Execute ¶
func (tx *BaseTransaction) Execute() error
Execute executes the transaction
func (*BaseTransaction) Fee ¶ added in v1.2.6
func (tx *BaseTransaction) Fee() uint64
Fee returns the user-paid tx burn (nLUX).
func (*BaseTransaction) GetQuantumSignature ¶
func (tx *BaseTransaction) GetQuantumSignature() *quantum.QuantumSignature
GetQuantumSignature returns the quantum signature
func (*BaseTransaction) ID ¶
func (tx *BaseTransaction) ID() ids.ID
ID returns the transaction ID — the content hash of the canonical ZAP wire (sha256(Bytes())), matching the other VMs in this repo. The prior ids.ToID(Bytes()) required an exactly-32-byte input and silently yielded ids.Empty for the always-≥32-byte wire, collapsing every tx to one pool slot.
func (*BaseTransaction) Timestamp ¶
func (tx *BaseTransaction) Timestamp() time.Time
Timestamp returns the transaction timestamp
func (*BaseTransaction) Verify ¶
func (tx *BaseTransaction) Verify() error
Verify verifies the transaction
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block represents a QVM block with quantum features
func (*Block) Accept ¶
Accept makes the block the tip: commitBlock admits it, applies it and persists it as one step.
Nothing is dropped from the mempool until that succeeds. Evicting first would lose the transactions of a block that then failed to persist.
func (*Block) ParentID ¶
ParentID returns the parent block ID (implements consensus Block interface)
func (*Block) Reject ¶
Reject discards the block. Nothing ran — execution belongs to Accept — and its transactions are still in the mempool, because BuildBlock copies from the queue rather than draining it and only Accept removes anything. So there is nothing to undo and nothing to give back.
func (*Block) Status ¶
Status reports 0 while the block is only proposed and 1 once it is stored. A stored block is an accepted one: Accept is the only writer, and it commits the block and the tip pointer together.
func (*Block) TimestampUnix ¶
TimestampUnix returns the block timestamp as Unix seconds.
func (*Block) Verify ¶
Verify decides whether the block may be built on, without changing any state.
It sits on its parent in both height and time. Checking only that the parent EXISTS lets a proposer pick height and timestamp freely: it can name genesis as the parent of a height-500 block, rewind chain time to revive expired quantum stamps, or jump forward and expire every stamp in flight at once.
type BlockSummary ¶ added in v1.7.35
type BlockSummary struct {
ID string `json:"id"`
ParentID string `json:"parentID"`
Height uint64 `json:"height"`
}
BlockSummary is how a block appears over RPC.
type GenerateCoronaKeyArgs ¶ added in v1.2.3
type GenerateCoronaKeyArgs struct{}
GenerateCoronaKeyArgs are the arguments for GenerateCoronaKey
type GenerateCoronaKeyReply ¶ added in v1.2.3
type GenerateCoronaKeyReply struct {
PublicKey string `json:"publicKey"`
Version uint32 `json:"version"`
KeySize int `json:"keySize"`
}
GenerateCoronaKeyReply is the reply for GenerateCoronaKey
type GetBlockArgs ¶
type GetBlockArgs struct {
BlockID string `json:"blockID"`
}
GetBlockArgs are the arguments for GetBlock
type GetBlockReply ¶
type GetBlockReply struct {
Block BlockSummary `json:"block"`
Height uint64 `json:"height"`
Timestamp int64 `json:"timestamp"`
TxCount int `json:"txCount"`
QuantumSig bool `json:"quantumSig"`
}
GetBlockReply is the reply for GetBlock
type GetConfigReply ¶
type GetConfigReply struct {
MaxParallelTxs int `json:"maxParallelTxs"`
QuantumAlgorithmVersion uint32 `json:"quantumAlgorithmVersion"`
QuantumStampEnabled bool `json:"quantumStampEnabled"`
CoronaEnabled bool `json:"coronaEnabled"`
ParallelBatchSize int `json:"parallelBatchSize"`
}
GetConfigReply is the reply for GetConfig. It reports what actually governs the chain — no fee schedule, because Q-Chain charges none (LP-0130 §6).
type GetHealthReply ¶
type GetHealthReply struct {
Healthy bool `json:"healthy"`
Version string `json:"version"`
QuantumEnabled bool `json:"quantumEnabled"`
CoronaEnabled bool `json:"coronaEnabled"`
PendingTxCount int `json:"pendingTxCount"`
ParallelWorkers int `json:"parallelWorkers"`
}
GetHealthReply is the reply for GetHealth
type GetPendingTransactionsArgs ¶
type GetPendingTransactionsArgs struct {
Limit int `json:"limit"`
}
GetPendingTransactionsArgs are the arguments for GetPendingTransactions
type GetPendingTransactionsReply ¶
type GetPendingTransactionsReply struct {
Transactions []TransactionSummary `json:"transactions"`
Count int `json:"count"`
}
GetPendingTransactionsReply is the reply for GetPendingTransactions
type PendingBlock ¶
type PendingBlock struct {
BlockID ids.ID
BlockHash []byte
Height uint64
Signatures []*quasar.QuasarSig
Finalized bool
}
PendingBlock tracks a block gathering signatures. Every signature in the slice has been verified against BlockHash and against the registered key of the validator it names, and no two name the same validator.
type Quasar ¶
type Quasar struct {
// contains filtered or unexported fields
}
Quasar collects validator signatures for Q-Chain blocks and finalizes a block once the quorum's aggregate signature verifies.
The core underneath signs with the validator's BLS key and, in the same call, attests the same message with that validator's ML-DSA-65 identity key (FIPS 204) — so the post-quantum half rides inside every signature this collects, and VerifyQuasarSig checks both halves or rejects.
func NewQuasar ¶
func NewQuasar(cfg QuasarConfig) (*Quasar, error)
NewQuasar creates the finality bridge and registers this node with the consensus core as its own validator.
Registration is not optional and not deferred, because a bridge that cannot sign for its own identity does nothing at all: SignMessage answers "validator not found", so no signature is ever recorded, so no peer signature ever finds a block to attach to, so the quorum is never reached and finality is unreachable — silently, one warning line per block.
The committee must be able to survive a fault. Below config.CommitteeMin the quorum ⌊2n/3⌋+1 is the entire committee, which the consensus core refuses outright and which would in any case make one absent validator a halt and one dishonest validator the decision.
func (*Quasar) AddSignature ¶ added in v1.7.35
AddSignature admits a peer's signature for a block this node is tracking.
func (*Quasar) AddValidator ¶
AddValidator registers a validator with the consensus core. Only a registered validator's signature can verify, so this is what decides whose statements count toward the quorum.
The committee is a SET, and it is the set the threshold was derived from. Registering an id twice hands the core a fresh key for it, which silently invalidates every signature that validator has already contributed; registering more validators than the committee declares makes the threshold a quorum of a committee that no longer exists.
func (*Quasar) Cleanup ¶
Cleanup drops every block tracked below minHeight.
The height is the caller's finalized frontier, so a block beneath it will never gather another signature whether it finalized or not. Keeping only the finalized ones meant the entries that could not be cleaned up were exactly the ones that accumulated: every proposal that lost, timed out, or failed to sign stayed in both maps for the life of the process.
func (*Quasar) Committee ¶ added in v1.7.35
Committee returns the committee size the threshold was derived from.
func (*Quasar) GetActiveValidators ¶
GetActiveValidators returns the count of registered validators.
func (*Quasar) GetThreshold ¶
GetThreshold returns how many validators must sign a block.
func (*Quasar) IsFinalized ¶
IsFinalized checks if a block has been finalized
func (*Quasar) SignBlock ¶
func (q *Quasar) SignBlock(ctx context.Context, blockID ids.ID, blockHash []byte, height uint64) (*quasar.QuasarSig, error)
SignBlock signs a block with this node's validator key and records the signature. Signing the same block again returns the signature already recorded: one validator makes one statement about one block.
func (*Quasar) TryFinalize ¶
func (q *Quasar) TryFinalize(ctx context.Context, blockID ids.ID) (*quasar.AggregatedSignature, bool, error)
TryFinalize finalizes a block once the quorum's signatures aggregate into a signature that verifies over the block.
Reaching the count is necessary and not sufficient: the aggregate is built and checked, and only a check that passes finalizes anything.
func (*Quasar) VerifyAggregate ¶ added in v1.7.35
func (q *Quasar) VerifyAggregate(ctx context.Context, message []byte, agg *quasar.AggregatedSignature) bool
VerifyAggregate reports whether an aggregated signature checks out over a message: the aggregate itself against the aggregated keys of the DISTINCT registered validators it names, at or above the threshold.
type QuasarBridge ¶
type QuasarBridge = Quasar
QuasarBridge is the Q-Chain finality bridge.
func NewQuasarBridge ¶
func NewQuasarBridge(cfg QuasarBridgeConfig) (*QuasarBridge, error)
NewQuasarBridge creates a new Quasar bridge (alias for NewQuasar)
type QuasarBridgeConfig ¶
type QuasarBridgeConfig = QuasarConfig
QuasarBridgeConfig is an alias for QuasarConfig
type QuasarConfig ¶
QuasarConfig configures the finality bridge. The committee size is the only quorum input: the threshold follows from it, so the two cannot be set to disagree.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides QVM RPC service
func (*Service) GenerateCoronaKey ¶ added in v1.2.3
func (s *Service) GenerateCoronaKey(r *http.Request, args *GenerateCoronaKeyArgs, reply *GenerateCoronaKeyReply) error
GenerateCoronaKey generates a new Corona key pair
func (*Service) GetBlock ¶
func (s *Service) GetBlock(r *http.Request, args *GetBlockArgs, reply *GetBlockReply) error
GetBlock returns a block by ID
func (*Service) GetConfig ¶
func (s *Service) GetConfig(r *http.Request, args *GetConfigArgs, reply *GetConfigReply) error
GetConfig returns the QVM configuration
func (*Service) GetHealth ¶
func (s *Service) GetHealth(r *http.Request, args *GetHealthArgs, reply *GetHealthReply) error
GetHealth returns the health status of the QVM
func (*Service) GetPendingTransactions ¶
func (s *Service) GetPendingTransactions(r *http.Request, args *GetPendingTransactionsArgs, reply *GetPendingTransactionsReply) error
GetPendingTransactions returns pending transactions
func (*Service) VerifyQuantumSignature ¶
func (s *Service) VerifyQuantumSignature(r *http.Request, args *VerifyQuantumSignatureArgs, reply *VerifyQuantumSignatureReply) error
VerifyQuantumSignature verifies a quantum signature
type Transaction ¶
type Transaction interface {
ID() ids.ID
Bytes() []byte
Verify() error
Execute() error
GetQuantumSignature() *quantum.QuantumSignature
Timestamp() time.Time
// Fee returns the user-paid tx burn in nLUX. Q-Chain's policy is the
// committee-only sentinel, which refuses every amount (LP-0130 §6).
Fee() uint64
}
Transaction represents a QVM transaction
type TransactionPool ¶
type TransactionPool struct {
// contains filtered or unexported fields
}
TransactionPool manages pending transactions
func NewTransactionPool ¶
func NewTransactionPool(maxSize int, logger log.Logger) *TransactionPool
NewTransactionPool creates a new transaction pool
func (*TransactionPool) AddTransaction ¶
func (p *TransactionPool) AddTransaction(tx Transaction) error
AddTransaction adds a transaction to the pool
func (*TransactionPool) GetPendingTransactions ¶
func (p *TransactionPool) GetPendingTransactions(limit int) []Transaction
GetPendingTransactions returns pending transactions up to the limit
func (*TransactionPool) PendingCount ¶
func (p *TransactionPool) PendingCount() int
PendingCount returns the number of pending transactions
func (*TransactionPool) RemoveTransaction ¶
func (p *TransactionPool) RemoveTransaction(txID ids.ID) error
RemoveTransaction removes a transaction from the pool
func (*TransactionPool) WaitForEvent ¶ added in v1.7.35
WaitForEvent blocks until there is a transaction to build a block from, or the caller gives up.
type TransactionSummary ¶ added in v1.7.35
TransactionSummary is how a pending transaction appears over RPC.
type TransactionWorker ¶
type TransactionWorker struct {
// contains filtered or unexported fields
}
TransactionWorker processes transactions in parallel
func (*TransactionWorker) ProcessBatch ¶
func (w *TransactionWorker) ProcessBatch(txs []Transaction) (valid, rejected []Transaction)
ProcessBatch VERIFIES a batch, reporting what survived and what did not. Both halves matter: the survivors go in the block, and the rest have to leave the pool — a transaction whose quantum stamp has aged out will never verify again, and left in place it holds its slot for good.
It does not execute anything. Effects belong to Accept, on every node, once: running them here ran them on a block the network may never accept, ran them twice when the builder rebuilt, and ran them nowhere at all on a node that received the block rather than building it.
Uses GPU batch ML-DSA verification when available and the batch is large enough.
type VM ¶
VM implements the Q-chain Virtual Machine with quantum features
func (*VM) BuildBlock ¶
BuildBlock builds a new block with pending transactions. Implements chain.ChainVM.
func (*VM) Connected ¶
func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
Connected notifies the VM that a validator has connected
func (*VM) CreateHandlers ¶
CreateHandlers returns HTTP handlers for the VM
func (*VM) CreateStaticHandlers ¶
CreateStaticHandlers returns static HTTP handlers
func (*VM) Disconnected ¶
Disconnected notifies the VM that a validator has disconnected
func (*VM) FeePolicy ¶ added in v1.2.6
FeePolicy exposes the chain's declared fee policy for diagnostics and the boot-time Validate gate.
func (*VM) GetBlockIDAtHeight ¶
GetBlockIDAtHeight answers what block this node accepted at a height, from the index Accept writes in the same commit as the block itself. A peer catching up asks by height; the index is what lets the answer be one read rather than a walk back from the tip.
func (*VM) GetQuasarBridge ¶
func (vm *VM) GetQuasarBridge() *QuasarBridge
GetQuasarBridge returns the Quasar threshold-signature bridge.
func (*VM) HealthCheck ¶
HealthCheck returns the health status of the VM. Implements chain.ChainVM, whose signature carries an error the VM has no way to produce.
func (*VM) Initialize ¶
Initialize initializes the VM. Implements chain.ChainVM.
func (*VM) IssueTx ¶ added in v1.2.6
func (vm *VM) IssueTx(tx Transaction) error
IssueTx is the user-tx admission point on Q-Chain, and it admits nothing. Under NoUserTxPolicy every amount is refused (LP-0130 §6), so there is no path from here into the pool — Q-Chain state advances only through consensus-internal cert aggregation, which reaches txPool.AddTransaction directly and never passes this way.
func (*VM) LastAccepted ¶
LastAccepted returns the last accepted block ID. Implements chain.ChainVM.
func (*VM) NewHTTPHandler ¶
NewHTTPHandler returns the VM's HTTP handler. Implements chain.ChainVM.
func (*VM) ParseBlock ¶
ParseBlock parses a block from bytes. Implements chain.ChainVM.
func (*VM) SetPreference ¶
SetPreference sets the preferred block. Implements chain.ChainVM. Q-Chain finalizes on a verified threshold signature rather than preference, so this is a no-op until preference-based fork choice is wired in.
func (*VM) StampBlock ¶
StampBlock attests to a message for the finality bridge: a Quasar validator signature when the bridge is up, an ML-DSA signature otherwise.
func (*VM) VerifyStamp ¶
VerifyStamp checks a stamp against the message it claims to attest.
The message is the argument that makes this a verification. Without it there was nothing to check a signature against, so each arm could only look at the stamp's own shape — and shape is what the sender chose: a two-byte aggregate declaring three signers passed, and so did a one-byte BLS signature. A self-declared signer count is not evidence of anything.
func (*VM) WaitForEvent ¶
WaitForEvent blocks until there is a transaction to build a block from, or the VM stops. Waiting only on the context would mean BuildBlock is never called and the chain never leaves genesis, however many transactions the pool has accepted.
type VerifyQuantumSignatureArgs ¶
type VerifyQuantumSignatureArgs struct {
Message string `json:"message"`
Signature json.RawMessage `json:"signature"`
}
VerifyQuantumSignatureArgs are the arguments for VerifyQuantumSignature
type VerifyQuantumSignatureReply ¶
type VerifyQuantumSignatureReply struct {
Valid bool `json:"valid"`
Algorithm uint32 `json:"algorithm"`
}
VerifyQuantumSignatureReply is the reply for VerifyQuantumSignature