postypes

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: LGPL-3.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	L                = 64
	H_IN_CHUNK_SIZE  = 64
	H_OUT_CHUNK_SIZE = 32
)

Variables

View Source
var (
	DST []byte = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Address     Address        `json:"address"`
	BlockNumber hexutil.Uint64 `json:"blockNumber"`
	Status      NodeLockStatus `json:"status"`
}

type Address

type Address = common.Hash

type Block

type Block struct {
	Hash          common.Hash    `json:"hash"`
	Height        hexutil.Uint64 `json:"height"`
	Epoch         hexutil.Uint64 `json:"epoch"`
	Round         hexutil.Uint64 `json:"round"`
	LastTxNumber  hexutil.Uint64 `json:"lastTxNumber"`
	Miner         *Address       `json:"miner"`
	ParentHash    common.Hash    `json:"parentHash"`
	Timestamp     hexutil.Uint64 `json:"timestamp"`
	PivotDecision *Decision      `json:"pivotDecision"`
	// Transactions  BlockTransactions `json:"transactions"`
	Signatures []Signature `json:"signatures"`
}

type BlockInfo added in v1.5.4

type BlockInfo struct {
	/// Epoch number corresponds to the set of validators that are active for
	/// this block.
	Epoch hexutil.Uint64 `json:"epoch"`
	/// The consensus protocol is executed in rounds, which monotonically
	/// increase per epoch.
	Round hexutil.Uint64 `json:"round"`
	/// The identifier (hash) of the block.
	Id hexutil.Bytes `json:"id"`
	/// The accumulator root hash after executing this block.
	ExecutedStateId hexutil.Bytes `json:"executedStateId"`
	/// The version of the latest transaction after executing this block.
	Version hexutil.Uint64 `json:"version"`
	/// The timestamp this block was proposed by a proposer.
	TimestampUsecs hexutil.Uint64 `json:"timestampUsecs"`
	/// An optional field containing the next epoch info
	NextEpochState *EpochState `json:"nextEpochState"`
	/// TODO(lpl): Remove Option?
	/// The last pivot block selection after executing this block.
	/// None means choosing TreeGraph genesis as the first pivot block.
	Pivot *PivotBlockDecision `json:"pivot"`
}

/ This structure contains all the information needed for tracking a block / without having access to the block or its execution output state. It / assumes that the block is the last block executed within the ledger.

type BlockNumber

type BlockNumber struct {
	// contains filtered or unexported fields
}
var (
	BlockEarliest        *BlockNumber = &BlockNumber{"earliest", 0}
	BlockLatestCommitted *BlockNumber = &BlockNumber{"latest_committed", 0}
	BlockLatestVoted     *BlockNumber = &BlockNumber{"latest_voted", 0}
)

func NewBlockNumber

func NewBlockNumber(number uint64) BlockNumber

func (BlockNumber) MarshalText

func (e BlockNumber) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*BlockNumber) String

func (e *BlockNumber) String() string

String implements the fmt.Stringer interface

func (*BlockNumber) UnmarshalJSON

func (e *BlockNumber) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Committee added in v1.5.7

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

func (*Committee) GetPublicKey added in v1.5.8

func (c *Committee) GetPublicKey(account common.Hash) (pubKey []byte, ok bool)

type CommitteeState

type CommitteeState struct {
	CurrentCommittee RpcCommittee  `json:"currentCommittee"`
	Elections        []RpcTermData `json:"elections"`
}

type ConflictSignature

type ConflictSignature struct {
	Proposal [2][]byte
	Vote     [2][]byte
}

type ConflictingVotes added in v1.4.4

type ConflictingVotes struct {
	ConflictVoteType string `json:"conflictVoteType"`
	First            string `json:"first"`
	Second           string `json:"second"`
}

type Decision

type Decision struct {
	BlockHash common.Hash    `json:"blockHash"`
	Height    hexutil.Uint64 `json:"height"`
}

type DisputePayload

type DisputePayload struct {
	Address          Address          `json:"address"`
	BlsPublicKey     string           `json:"blsPublicKey"`
	VrfPublicKey     string           `json:"vrfPublicKey"`
	ConflictingVotes ConflictingVotes `json:"conflictingVotes"`
}

type ElectionPayload

type ElectionPayload struct {
	PublicKey    string         `json:"publicKey"`
	VrfPublicKey string         `json:"vrfPublicKey"`
	TargetTerm   hexutil.Uint64 `json:"targetTerm"`
	VrfProof     string         `json:"vrfProof"`
}

type EpochReward

type EpochReward struct {
	PowEpochHash   common.Hash `json:"powEpochHash"`
	AccountRewards []Reward    `json:"accountRewards"`
}

type EpochState added in v1.5.4

type EpochState struct {
	Epoch    hexutil.Uint64    `json:"epoch"`
	Verifier ValidatorVerifier `json:"verifier"`
	VrfSeed  hexutil.Bytes     `json:"vrfSeed"`
}

EpochState represents a trusted validator set to validate messages from the specific epoch, it could be updated with EpochChangeProof.

type H256 added in v1.5.7

type H256 string

for BCS serialization purpose

func (H256) String added in v1.5.7

func (h H256) String() string

func (H256) ToHash added in v1.5.7

func (h H256) ToHash() common.Hash

type LedgerInfo added in v1.5.4

type LedgerInfo struct {
	CommitInfo BlockInfo `json:"commitInfo"`

	/// Hash of consensus specific data that is opaque to all parts of the
	/// system other than consensus.
	ConsensusDataHash hexutil.Bytes `json:"consensusDataHash"`
}

type LedgerInfoWithSignatures added in v1.5.4

type LedgerInfoWithSignatures struct {
	LedgerInfo LedgerInfo `json:"ledgerInfo"`
	// The validator is identified by its account address: in order to verify
	// a signature one needs to retrieve the public key of the validator
	// for the given epoch.
	//
	// BLS signature in uncompressed format
	Signatures map[common.Hash]hexutil.Bytes `json:"signatures"`
	// Validators with uncompressed BLS public key (in 96 bytes) if next epoch
	// state available. Generally, this is used to verify BLS signatures at client side.
	NextEpochValidators map[common.Hash]hexutil.Bytes `json:"nextEpochValidators"`
	// Aggregated BLS signature in 192 bytes.
	AggregatedSignature hexutil.Bytes `json:"aggregatedSignature"`
}

/ The validator node returns this structure which includes signatures / from validators that confirm the state. The client needs to only pass back / the LedgerInfo element since the validator node doesn't need to know the / signatures again when the client performs a query, those are only there for / the client to be able to verify the state

func (*LedgerInfoWithSignatures) AggregatedPublicKey added in v1.5.8

func (info *LedgerInfoWithSignatures) AggregatedPublicKey(committee Committee) (*bls12381.PointG1, error)

func (*LedgerInfoWithSignatures) EncodeBCS added in v1.5.7

func (info *LedgerInfoWithSignatures) EncodeBCS() []byte

func (*LedgerInfoWithSignatures) NextCommittee added in v1.5.7

func (info *LedgerInfoWithSignatures) NextCommittee() (Committee, bool)

func (*LedgerInfoWithSignatures) NextEpochValidatorsSorted added in v1.5.8

func (info *LedgerInfoWithSignatures) NextEpochValidatorsSorted() []common.Hash

func (*LedgerInfoWithSignatures) ValidatorsSorted added in v1.5.8

func (info *LedgerInfoWithSignatures) ValidatorsSorted() []common.Hash

func (*LedgerInfoWithSignatures) Verify added in v1.5.7

func (info *LedgerInfoWithSignatures) Verify(committee Committee) (bool, error)

type NodeLockStatus

type NodeLockStatus struct {
	InQueue  []VotePowerState `json:"inQueue"`
	Locked   hexutil.Uint64   `json:"locked"`
	OutQueue []VotePowerState `json:"outQueue"`
	Unlocked hexutil.Uint64   `json:"unlocked"`

	// Equals to the summation of in_queue + locked
	AvailableVotes hexutil.Uint64  `json:"availableVotes"`
	ForceRetired   *hexutil.Uint64 `json:"forceRetired"`

	// If the staking is forfeited, the unlocked votes before forfeiting is
	// exempted.
	Forfeited hexutil.Uint64 `json:"forfeited"`
}

type NodeVotingPower

type NodeVotingPower struct {
	Address     common.Hash    `json:"address"`
	VotingPower hexutil.Uint64 `json:"votingPower"`
}

type PivotBlockDecision

type PivotBlockDecision struct {
	Height    hexutil.Uint64 `json:"height"`
	BlockHash H256           `json:"blockHash"`
}

type PoSAccounts added in v1.5.8

type PoSAccounts []common.Hash

func (PoSAccounts) Len added in v1.5.8

func (s PoSAccounts) Len() int

func (PoSAccounts) Less added in v1.5.8

func (s PoSAccounts) Less(i, j int) bool

func (PoSAccounts) Swap added in v1.5.8

func (s PoSAccounts) Swap(i, j int)

type RegisterPayload

type RegisterPayload struct {
	PublicKey    string `json:"publicKey"`
	VrfPublicKey string `json:"vrfPublicKey"`
}

type RetirePayload

type RetirePayload struct {
	NodeId Address        `json:"nodeId"`
	Votes  hexutil.Uint64 `json:"votes"`
}

type Reward

type Reward struct {
	PosAddress Address            `json:"posAddress"`
	PowAddress cfxaddress.Address `json:"powAddress"`
	Reward     hexutil.Big        `json:"reward"`
}

type RpcCommittee

type RpcCommittee struct {
	EpochNumber       hexutil.Uint64    `json:"epochNumber"`
	QuorumVotingPower hexutil.Uint64    `json:"quorumVotingPower"`
	TotalVotingPower  hexutil.Uint64    `json:"totalVotingPower"`
	Nodes             []NodeVotingPower `json:"nodes"`
}

type RpcTermData

type RpcTermData struct {
	StartBlockNumber hexutil.Uint64    `json:"startBlockNumber"`
	IsFinalized      bool              `json:"isFinalized"`
	TopElectingNodes []NodeVotingPower `json:"topElectingNodes"`
}

type Signature

type Signature struct {
	Account Address        `json:"account"`
	Votes   hexutil.Uint64 `json:"votes"`
}

type Status

type Status struct {
	LatestCommitted hexutil.Uint64  `json:"latestCommitted"`
	Epoch           hexutil.Uint64  `json:"epoch"`
	PivotDecision   Decision        `json:"pivotDecision"`
	LatestVoted     *hexutil.Uint64 `json:"latestVoted"`
	LatestTxNumber  hexutil.Uint64  `json:"latestTxNumber"`
}

type Transaction

type Transaction struct {
	Hash        common.Hash         `json:"hash"`
	From        Address             `json:"from"`
	BlockHash   *common.Hash        `json:"blockHash"`
	BlockNumber *hexutil.Uint64     `json:"blockNumber"`
	Timestamp   *hexutil.Uint64     `json:"timestamp"`
	Number      hexutil.Uint64      `json:"number"`
	Payload     *TransactionPayload `json:"payload"`
	Status      *string             `json:"status"`
	Type        string              `json:"type"`
}

func (*Transaction) UnmarshalJSON

func (b *Transaction) UnmarshalJSON(data []byte) error

type TransactionPayload

type TransactionPayload struct {
	ElectionPayload
	RetirePayload
	RegisterPayload
	UpdateVotingPowerPayload
	PivotBlockDecision
	DisputePayload
	// contains filtered or unexported fields
}

func (TransactionPayload) MarshalJSON

func (b TransactionPayload) MarshalJSON() ([]byte, error)

func (*TransactionPayload) SetTransactionType

func (t *TransactionPayload) SetTransactionType(txType string)

func (*TransactionPayload) UnmarshalJSON

func (b *TransactionPayload) UnmarshalJSON(data []byte) error

type UpdateVotingPowerPayload

type UpdateVotingPowerPayload struct {
	NodeAddress Address        `json:"nodeAddress"`
	VotingPower hexutil.Uint64 `json:"votingPower"`
}

type ValidatorConsensusInfo added in v1.5.4

type ValidatorConsensusInfo struct {
	PublicKey    hexutil.Bytes  `json:"publicKey"`              // compressed BLS public key
	VrfPublicKey *hexutil.Bytes `json:"vrfPublicKey,omitempty"` // nil if VRF not needed
	VotingPower  hexutil.Uint64 `json:"votingPower"`
}

Helper struct to manage validator information for validation

type ValidatorVerifier added in v1.5.4

type ValidatorVerifier struct {
	// An ordered map of each validator's on-chain account address to its
	// pubkeys and voting power.
	AddressToValidatorInfo map[common.Hash]ValidatorConsensusInfo `json:"addressToValidatorInfo"`
	// The minimum voting power required to achieve a quorum
	QuorumVotingPower hexutil.Uint64 `json:"quorumVotingPower"`
	// Total voting power of all validators (cached from
	// address_to_validator_info)
	TotalVotingPower hexutil.Uint64 `json:"totalVotingPower"`
}

Supports validation of signatures for known authors with individual voting powers. This struct can be used for all signature verification operations including block and network signature verification, respectively.

type VoteParamsInfo added in v1.4.1

type VoteParamsInfo struct {
	PowBaseReward    *hexutil.Big `json:"powBaseReward"`
	InterestRate     *hexutil.Big `json:"interestRate"`
	StoragePointProp *hexutil.Big `json:"storagePointProp"`
	BaseFeeShareProp *hexutil.Big `json:"baseFeeShareProp"`
}

type VotePowerState

type VotePowerState struct {
	EndBlockNumber hexutil.Uint64 `json:"endBlockNumber"`
	Power          hexutil.Uint64 `json:"power"`
}

Jump to

Keyboard shortcuts

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