quasar

package
v1.22.78 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package quasar provides EVM precompile access to Quasar consensus state. This precompile exposes the hybrid BLS+Ringtail quantum finality mechanism to smart contracts via the C-Chain.

Precompile Address: 0x0200000000000000000000000000000000000020

Methods:

  • getQuasarState() returns (pChainHeight, qChainHeight, isRunning, finalizedBlocks)
  • getValidatorInfo(nodeID) returns (weight, active, blsPubKey, ringtailKey)
  • getConsensusMetrics() returns (avgBLSLatency, avgRingtailLatency, totalFinalized)
  • getFinality(blockID) returns (blockID, pHeight, qHeight, blsProof, ringtailProof)
  • getRingtailStats() returns (numParties, threshold, sessionID, initialized)

Index

Constants

View Source
const (
	GetQuasarStateGas      uint64 = 2_000  // Read-only state query
	GetValidatorInfoGas    uint64 = 5_000  // Validator lookup + key retrieval
	GetConsensusMetricsGas uint64 = 3_000  // Metrics aggregation
	GetFinalityGas         uint64 = 10_000 // Block finality proof retrieval
	GetRingtailStatsGas    uint64 = 2_000  // Ringtail state query
)

Gas costs for precompile operations

Variables

View Source
var (
	// ErrQuasarNotConnected is returned when Quasar consensus is not connected
	ErrQuasarNotConnected = errors.New("quasar consensus not connected")
	// ErrInvalidInput is returned for malformed precompile input
	ErrInvalidInput = errors.New("invalid precompile input")
	// ErrUnknownMethod is returned for unrecognized function selector
	ErrUnknownMethod = errors.New("unknown precompile method")
	// ErrBlockNotFinalized is returned when querying unfinalized block
	ErrBlockNotFinalized = errors.New("block not finalized")
)
View Source
var (
	// getQuasarState() => keccak256("getQuasarState()")[:4]
	SelectorGetQuasarState = [4]byte{0x71, 0x8c, 0x52, 0xa4}
	// getValidatorInfo(bytes20) => keccak256("getValidatorInfo(bytes20)")[:4]
	SelectorGetValidatorInfo = [4]byte{0x2b, 0x9f, 0x1d, 0x67}
	// getConsensusMetrics() => keccak256("getConsensusMetrics()")[:4]
	SelectorGetConsensusMetrics = [4]byte{0x8d, 0x3e, 0x4a, 0x52}
	// getFinality(bytes32) => keccak256("getFinality(bytes32)")[:4]
	SelectorGetFinality = [4]byte{0x6f, 0x2a, 0x8b, 0xc3}
	// getRingtailStats() => keccak256("getRingtailStats()")[:4]
	SelectorGetRingtailStats = [4]byte{0x4e, 0x71, 0xd9, 0x28}
)

Function selectors (first 4 bytes of keccak256 hash)

Functions

This section is empty.

Types

type QuasarPrecompile

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

QuasarPrecompile provides EVM access to Quasar consensus state. This is a stateless precompile - it reads from the connected Quasar instance.

func NewQuasarPrecompile

func NewQuasarPrecompile(q *quasar.Quasar) *QuasarPrecompile

NewQuasarPrecompile creates a new Quasar precompile instance. The quasar parameter can be nil - methods will return ErrQuasarNotConnected.

func (*QuasarPrecompile) RequiredGas

func (p *QuasarPrecompile) RequiredGas(input []byte) uint64

RequiredGas returns the gas cost for the given input.

func (*QuasarPrecompile) Run

func (p *QuasarPrecompile) Run(input []byte) ([]byte, error)

Run executes the precompile based on the function selector.

func (*QuasarPrecompile) SetQuasar

func (p *QuasarPrecompile) SetQuasar(q *quasar.Quasar)

SetQuasar connects or updates the Quasar consensus instance.

Jump to

Keyboard shortcuts

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