conflux

package
v1.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DeferredExecutionEpochs uint64 = 5

Variables

View Source
var (
	BlockEarliest        = &BlockNumber{"earliest", 0}
	BlockLatestCommitted = &BlockNumber{"latest_committed", 0}
	BlockLatestVoted     = &BlockNumber{"latest_voted", 0}
)
View Source
var ErrNoResult = errors.New("no result in JSON-RPC response")
View Source
var ErrTransactionExecutionFailed = errors.New("transaction execution failed")

Functions

func ABIEncodePublicKey

func ABIEncodePublicKey(publicKey []byte) []byte

func ABIEncodeSignature

func ABIEncodeSignature(signature []byte) []byte

func AssembleProof

func AssembleProof(client *Client, pivot, proofType uint64, method string, fId msg.ChainId, log *ethtypes.Log,
	receipts []*ethtypes.Receipt, orderId [32]byte) ([]byte, error)

func CreateReceiptsMPT

func CreateReceiptsMPT(epochReceipts [][]types.TransactionReceipt) ([]*mpt.Node, *mpt.Node)

func MustRLPEncodeBlock

func MustRLPEncodeBlock(block *BlockSummary) []byte

func NewBigIntByRaw

func NewBigIntByRaw(x *big.Int) *hexutil.Big

Types

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"`
	Signatures    []Signature    `json:"signatures"`
}

type BlockHeader

type BlockHeader struct {
	Hash                  types.Hash     `json:"hash"`
	ParentHash            types.Hash     `json:"parentHash"`
	Height                *hexutil.Big   `json:"height"`
	Miner                 types.Address  `json:"miner"`
	DeferredStateRoot     types.Hash     `json:"deferredStateRoot"`
	DeferredReceiptsRoot  types.Hash     `json:"deferredReceiptsRoot"`
	DeferredLogsBloomHash types.Hash     `json:"deferredLogsBloomHash"`
	Blame                 hexutil.Uint64 `json:"blame"`
	TransactionsRoot      types.Hash     `json:"transactionsRoot"`
	EpochNumber           *hexutil.Big   `json:"epochNumber"`
	BlockNumber           *hexutil.Big   `json:"blockNumber"`
	GasLimit              *hexutil.Big   `json:"gasLimit"`
	GasUsed               *hexutil.Big   `json:"gasUsed"`
	Timestamp             *hexutil.Big   `json:"timestamp"`
	Difficulty            *hexutil.Big   `json:"difficulty"`
	PowQuality            *hexutil.Big   `json:"powQuality"`
	RefereeHashes         []types.Hash   `json:"refereeHashes"`
	Adaptive              bool           `json:"adaptive"`
	Nonce                 *hexutil.Big   `json:"nonce"`
	Size                  *hexutil.Big   `json:"size"`
	Custom                []Bytes        `json:"custom"`
	PosReference          *types.Hash    `json:"posReference"`
	BaseFeePerGas         *hexutil.Big   `json:"baseFeePerGas"`
}

func (*BlockHeader) DecodeRLP

func (bh *BlockHeader) DecodeRLP(r *rlp.Stream) error

DecodeRLP implements the rlp.Decoder interface.

func (BlockHeader) EncodeRLP

func (bh BlockHeader) EncodeRLP(w io.Writer) error

EncodeRLP implements the rlp.Encoder interface.

type BlockInfo

type BlockInfo struct {
	Epoch           hexutil.Uint64      `json:"epoch"`
	Round           hexutil.Uint64      `json:"round"`
	Id              hexutil.Bytes       `json:"id"`
	ExecutedStateId hexutil.Bytes       `json:"executedStateId"`
	Version         hexutil.Uint64      `json:"version"`
	TimestampUsecs  hexutil.Uint64      `json:"timestampUsecs"`
	NextEpochState  *EpochState         `json:"nextEpochState"`
	Pivot           *PivotBlockDecision `json:"pivot"`
}

type BlockNumber

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

func NewBlockNumber

func NewBlockNumber(number hexutil.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 BlockRlp

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

func ConvertBlock

func ConvertBlock(block *BlockSummary) BlockRlp

func (BlockRlp) EncodeRLP

func (header BlockRlp) EncodeRLP(w io.Writer) error

type BlockSummary

type BlockSummary struct {
	BlockHeader
}

BlockSummary includes block header and a list of transaction hashes

func (*BlockSummary) DecodeRLP

func (bs *BlockSummary) DecodeRLP(r *rlp.Stream) error

DecodeRLP implements the rlp.Decoder interface.

func (BlockSummary) EncodeRLP

func (bs BlockSummary) EncodeRLP(w io.Writer) error

EncodeRLP implements the rlp.Encoder interface.

type Bytes

type Bytes []byte

func (Bytes) MarshalText

func (b Bytes) MarshalText() ([]byte, error)

func (*Bytes) ToBytes

func (b *Bytes) ToBytes() []byte

func (*Bytes) ToHexBytes

func (b *Bytes) ToHexBytes() hexutil.Bytes

func (*Bytes) UnmarshalJSON

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

type CfxBlock

type CfxBlock struct {
	BlockHeader
	Transactions []Transaction `json:"transactions"`
}

func (*CfxBlock) DecodeRLP

func (block *CfxBlock) DecodeRLP(r *rlp.Stream) error

DecodeRLP implements the rlp.Decoder interface.

func (CfxBlock) EncodeRLP

func (block CfxBlock) EncodeRLP(w io.Writer) error

EncodeRLP implements the rlp.Encoder interface.

type Client

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

func NewClient

func NewClient(endpoint string) (*Client, error)

func (*Client) CallContext

func (c *Client) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error

func (*Client) GetBlockByEpochNumber

func (c *Client) GetBlockByEpochNumber(ctx context.Context, blockNumber hexutil.Uint64) (*BlockSummary, error)

func (*Client) GetBlockByNumber

func (c *Client) GetBlockByNumber(ctx context.Context, blockNumber BlockNumber) (*Block, error)

func (*Client) GetEpochReceipts

func (c *Client) GetEpochReceipts(ctx context.Context, epoch types.EpochOrBlockHash,
	includeEthReceipts ...bool) ([][]types.TransactionReceipt, error)

func (*Client) GetLedgerInfoByEpochAndRound

func (c *Client) GetLedgerInfoByEpochAndRound(ctx context.Context, epochNumber hexutil.Uint64,
	round hexutil.Uint64) (*LedgerInfoWithSignatures, error)

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context) (*Status, error)

type Decision

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

type Epoch

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

Epoch represents an epoch in Conflux.

var (
	EpochEarliest         *Epoch = &Epoch{"earliest", nil}
	EpochLatestCheckpoint *Epoch = &Epoch{"latest_checkpoint", nil}
	EpochLatestConfirmed  *Epoch = &Epoch{"latest_confirmed", nil}
	EpochLatestState      *Epoch = &Epoch{"latest_state", nil}
	EpochLatestMined      *Epoch = &Epoch{"latest_mined", nil}
	EpochLatestFinalized  *Epoch = &Epoch{"latest_finalized", nil}
)

Const epoch definitions

func NewEpochNumber

func NewEpochNumber(number *hexutil.Big) *Epoch

NewEpochNumber creates an instance of Epoch with specified number.

func (*Epoch) Equals

func (e *Epoch) Equals(target *Epoch) bool

func (Epoch) MarshalText

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

func (*Epoch) String

func (e *Epoch) String() string

func (*Epoch) ToInt

func (e *Epoch) ToInt() (result *big.Int, isSuccess bool)

func (*Epoch) UnmarshalJSON

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

type EpochState

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

type H256

type H256 string

func (H256) String

func (h H256) String() string

func (H256) ToHash

func (h H256) ToHash() common.Hash

type ILightNodeState

type ILightNodeState struct {
	Epoch                *big.Int
	Round                *big.Int
	EarliestBlockNumber  *big.Int
	FinalizedBlockNumber *big.Int
	Blocks               *big.Int
	MaxBlocks            *big.Int
}

ILightNodeState is an auto generated low-level Go binding around an user-defined struct.

type LedgerInfo

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 LedgerInfoLibAccountSignature

type LedgerInfoLibAccountSignature struct {
	Account            [32]byte
	ConsensusSignature []byte
}

type LedgerInfoLibDecision

type LedgerInfoLibDecision struct {
	BlockHash [32]byte
	Height    uint64
}

type LedgerInfoLibEpochState

type LedgerInfoLibEpochState struct {
	Epoch             uint64
	Validators        []LedgerInfoLibValidatorInfo
	QuorumVotingPower uint64
	TotalVotingPower  uint64
	VrfSeed           []byte
}

type LedgerInfoLibLedgerInfoWithSignatures

type LedgerInfoLibLedgerInfoWithSignatures struct {
	Epoch               uint64
	Round               uint64
	Id                  [32]byte
	ExecutedStateId     [32]byte
	Version             uint64
	TimestampUsecs      uint64
	NextEpochState      LedgerInfoLibEpochState
	Pivot               LedgerInfoLibDecision
	ConsensusDataHash   [32]byte
	Accounts            [][32]byte
	AggregatedSignature []byte
}

LedgerInfoLibLedgerInfoWithSignatures is an auto generated low-level Go binding around an user-defined struct.

type LedgerInfoLibValidatorInfo

type LedgerInfoLibValidatorInfo struct {
	Account               [32]byte
	CompressedPublicKey   []byte
	UncompressedPublicKey []byte
	VrfPublicKey          []byte
	VotingPower           uint64
}

type LedgerInfoWithSignatures

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"`
}

func (*LedgerInfoWithSignatures) NextEpochValidatorsSorted

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

func (*LedgerInfoWithSignatures) ValidatorsSorted

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

type PivotBlockDecision

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

type PoSAccounts

type PoSAccounts []common.Hash

func (PoSAccounts) Len

func (s PoSAccounts) Len() int

func (PoSAccounts) Less

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

func (PoSAccounts) Swap

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

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             types.Hash      `json:"hash"`
	Nonce            *hexutil.Big    `json:"nonce"`
	BlockHash        *types.Hash     `json:"blockHash"`
	TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
	From             Address         `json:"from"`
	To               *Address        `json:"to"`
	Value            *hexutil.Big    `json:"value"`
	GasPrice         *hexutil.Big    `json:"gasPrice"`
	Gas              *hexutil.Big    `json:"gas"`
	ContractCreated  *Address        `json:"contractCreated"`
	Data             string          `json:"data"`
	StorageLimit     *hexutil.Big    `json:"storageLimit"`
	EpochHeight      *hexutil.Big    `json:"epochHeight"`
	ChainID          *hexutil.Big    `json:"chainId"`
	Status           *hexutil.Uint64 `json:"status"`
	V                *hexutil.Big    `json:"v"`
	R                *hexutil.Big    `json:"r"`
	S                *hexutil.Big    `json:"s"`
}

func (*Transaction) DecodeRLP

func (tx *Transaction) DecodeRLP(r *rlp.Stream) error

DecodeRLP implements the rlp.Decoder interface.

func (Transaction) EncodeRLP

func (tx Transaction) EncodeRLP(w io.Writer) error

EncodeRLP implements the rlp.Encoder interface.

type ValidatorConsensusInfo

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"`
}

type ValidatorVerifier

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"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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