hmy

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BloomBitsBlocks is the number of blocks a single bloom bit section vector
	// contains on the server side.
	BloomBitsBlocks uint64 = 4096
)

Variables

View Source
var (
	// ErrFinalizedTransaction is returned if the transaction to be submitted is already on-chain
	ErrFinalizedTransaction = errors.New("transaction already finalized")
)

Functions

func NewBloomIndexer

func NewBloomIndexer(db ethdb.Database, size, confirms uint64) *core.ChainIndexer

NewBloomIndexer returns a chain indexer that generates bloom bits data for the canonical chain for fast logs filtering.

Types

type BloomIndexer

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

BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the Ethereum header bloom filters, permitting blazing fast filtering.

func (*BloomIndexer) Commit

func (b *BloomIndexer) Commit() error

Commit implements core.ChainIndexerBackend, finalizing the bloom section and writing it out into the database.

func (*BloomIndexer) Process

func (b *BloomIndexer) Process(ctx context.Context, header *block.Header) error

Process implements core.ChainIndexerBackend, adding a new header's bloom into the index.

func (*BloomIndexer) Reset

func (b *BloomIndexer) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error

Reset implements core.ChainIndexerBackend, starting a new bloombits index section.

type DetailedBlockSignerInfo added in v1.10.0

type DetailedBlockSignerInfo struct {
	// Signers are all the signers for the block
	Signers shard.SlotList
	// Committee when the block was signed.
	Committee shard.SlotList
	BlockHash common.Hash
}

DetailedBlockSignerInfo contains all of the block singing information

type ExecutionResult added in v1.10.0

type ExecutionResult struct {
	Gas         uint64         `json:"gas"`
	Failed      bool           `json:"failed"`
	ReturnValue string         `json:"returnValue"`
	StructLogs  []StructLogRes `json:"structLogs"`
}

ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as transaction execution status, the amount of gas used and the return value Taken from go-ethereum/internal/ethapi/api.go

type Harmony

type Harmony struct {
	// Channel for shutting down the service
	ShutdownChan  chan bool                      // Channel for shutting down the Harmony
	BloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests
	BlockChain    *core.BlockChain
	BeaconChain   *core.BlockChain
	TxPool        *core.TxPool
	CxPool        *core.CxPool // CxPool is used to store the blockHashes of blocks containing cx receipts to be sent
	// DB interfaces
	BloomIndexer *core.ChainIndexer // Bloom indexer operating during block imports
	NodeAPI      NodeAPI
	// ChainID is used to identify which network we are using
	ChainID uint64
	// EthCompatibleChainID is used to identify the Ethereum compatible chain ID
	EthChainID uint64
	// RPCGasCap is the global gas cap for eth-call variants.
	RPCGasCap *big.Int `toml:",omitempty"`
	ShardID   uint32
	// contains filtered or unexported fields
}

Harmony implements the Harmony full node service.

func New

func New(
	nodeAPI NodeAPI, txPool *core.TxPool, cxPool *core.CxPool, shardID uint32,
) *Harmony

New creates a new Harmony object (including the initialisation of the common Harmony object)

func (*Harmony) BlockByNumber added in v1.10.0

func (hmy *Harmony) BlockByNumber(ctx context.Context, blockNum rpc.BlockNumber) (*types.Block, error)

BlockByNumber ...

func (*Harmony) BloomStatus added in v1.10.0

func (hmy *Harmony) BloomStatus() (uint64, uint64)

BloomStatus ... TODO: this is not implemented or verified yet for harmony.

func (*Harmony) ChainConfig added in v1.10.0

func (hmy *Harmony) ChainConfig() *params.ChainConfig

ChainConfig ...

func (*Harmony) ChainDb added in v1.10.0

func (hmy *Harmony) ChainDb() ethdb.Database

ChainDb ..

func (*Harmony) ComputeStateDB added in v1.10.0

func (hmy *Harmony) ComputeStateDB(block *types.Block, reexec uint64) (*state.DB, error)

ComputeStateDB retrieves the state database associated with a certain block. If no state is locally available for the given block, a number of blocks are attempted to be reexecuted to generate the desired state.

func (*Harmony) ComputeTxEnv added in v1.10.0

func (hmy *Harmony) ComputeTxEnv(block *types.Block, txIndex int, reexec uint64) (core.Message, vm.Context, *state.DB, error)

ComputeTxEnv returns the execution environment of a certain transaction.

func (*Harmony) CurrentBlock added in v1.10.0

func (hmy *Harmony) CurrentBlock() *types.Block

CurrentBlock ...

func (*Harmony) EventMux added in v1.10.0

func (hmy *Harmony) EventMux() *event.TypeMux

EventMux ..

func (*Harmony) GetAccountNonce added in v1.10.0

func (hmy *Harmony) GetAccountNonce(
	ctx context.Context, address common.Address, blockNum rpc.BlockNumber) (uint64, error)

GetAccountNonce returns the nonce value of the given address for the given block number

func (*Harmony) GetAllValidatorAddresses added in v1.10.0

func (hmy *Harmony) GetAllValidatorAddresses() []common.Address

GetAllValidatorAddresses returns the up to date validator candidates for next epoch

func (*Harmony) GetBalance added in v1.10.0

func (hmy *Harmony) GetBalance(ctx context.Context, address common.Address, blockNum rpc.BlockNumber) (*big.Int, error)

GetBalance returns balance of an given address.

func (*Harmony) GetBlock added in v1.10.0

func (hmy *Harmony) GetBlock(ctx context.Context, hash common.Hash) (*types.Block, error)

GetBlock ...

func (*Harmony) GetBlockSigners added in v1.10.0

func (hmy *Harmony) GetBlockSigners(
	ctx context.Context, blockNum rpc.BlockNumber,
) (shard.SlotList, *internal_bls.Mask, error)

GetBlockSigners ..

func (*Harmony) GetCurrentBadBlocks added in v1.10.0

func (hmy *Harmony) GetCurrentBadBlocks() []core.BadBlock

GetCurrentBadBlocks ..

func (*Harmony) GetCurrentStakingErrorSink added in v1.10.0

func (hmy *Harmony) GetCurrentStakingErrorSink() types.TransactionErrorReports

GetCurrentStakingErrorSink ..

func (*Harmony) GetCurrentTransactionErrorSink added in v1.10.0

func (hmy *Harmony) GetCurrentTransactionErrorSink() types.TransactionErrorReports

GetCurrentTransactionErrorSink ..

func (*Harmony) GetCurrentUtilityMetrics added in v1.10.0

func (hmy *Harmony) GetCurrentUtilityMetrics() (*network.UtilityMetric, error)

GetCurrentUtilityMetrics ..

func (*Harmony) GetDelegationLockingPeriodInEpoch added in v1.10.0

func (hmy *Harmony) GetDelegationLockingPeriodInEpoch(epoch *big.Int) int

GetDelegationLockingPeriodInEpoch ...

func (*Harmony) GetDelegationsByDelegator added in v1.10.0

func (hmy *Harmony) GetDelegationsByDelegator(
	delegator common.Address,
) ([]common.Address, []*staking.Delegation)

GetDelegationsByDelegator returns all delegation information of a delegator

func (*Harmony) GetDelegationsByDelegatorByBlock added in v1.10.0

func (hmy *Harmony) GetDelegationsByDelegatorByBlock(
	delegator common.Address, block *types.Block,
) ([]common.Address, []*staking.Delegation)

GetDelegationsByDelegatorByBlock returns all delegation information of a delegator

func (*Harmony) GetDelegationsByValidator added in v1.10.0

func (hmy *Harmony) GetDelegationsByValidator(validator common.Address) []*staking.Delegation

GetDelegationsByValidator returns all delegation information of a validator

func (*Harmony) GetDelegationsByValidatorAtBlock added in v1.10.0

func (hmy *Harmony) GetDelegationsByValidatorAtBlock(
	validator common.Address, block *types.Block,
) []*staking.Delegation

GetDelegationsByValidatorAtBlock returns all delegation information of a validator at the given block

func (*Harmony) GetDetailedBlockSignerInfo added in v1.10.0

func (hmy *Harmony) GetDetailedBlockSignerInfo(
	ctx context.Context, blk *types.Block,
) (*DetailedBlockSignerInfo, error)

GetDetailedBlockSignerInfo fetches the block signer information for any non-genesis block

func (*Harmony) GetEVM added in v1.10.0

func (hmy *Harmony) GetEVM(ctx context.Context, msg core.Message, state *state.DB, header *block.Header) (*vm.EVM, error)

GetEVM returns a new EVM entity

func (*Harmony) GetElectedValidatorAddresses added in v1.10.0

func (hmy *Harmony) GetElectedValidatorAddresses() []common.Address

GetElectedValidatorAddresses returns the address of elected validators for current epoch

func (hmy *Harmony) GetLastCrossLinks() ([]*types.CrossLink, error)

GetLastCrossLinks ..

func (*Harmony) GetLatestChainHeaders added in v1.10.0

func (hmy *Harmony) GetLatestChainHeaders() *block.HeaderPair

GetLatestChainHeaders ..

func (*Harmony) GetLeaderAddress added in v1.10.0

func (hmy *Harmony) GetLeaderAddress(coinbaseAddr common.Address, epoch *big.Int) string

GetLeaderAddress returns the one address of the leader, given the coinbaseAddr. Note that the coinbaseAddr is overloaded with the BLS pub key hash in staking era.

func (*Harmony) GetLogs added in v1.10.0

func (hmy *Harmony) GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error)

GetLogs ...

func (*Harmony) GetMedianRawStakeSnapshot added in v1.10.0

func (hmy *Harmony) GetMedianRawStakeSnapshot() (
	*committee.CompletedEPoSRound, error,
)

GetMedianRawStakeSnapshot ..

func (*Harmony) GetNodeMetadata added in v1.10.0

func (hmy *Harmony) GetNodeMetadata() commonRPC.NodeMetadata

GetNodeMetadata ..

func (*Harmony) GetPeerInfo added in v1.10.0

func (hmy *Harmony) GetPeerInfo() commonRPC.NodePeerInfo

GetPeerInfo returns the peer info to the node, including blocked peer, connected peer, number of peers

func (*Harmony) GetPendingCXReceipts added in v1.10.0

func (hmy *Harmony) GetPendingCXReceipts() []*types.CXReceiptsProof

GetPendingCXReceipts ..

func (*Harmony) GetPoolNonce added in v1.10.0

func (hmy *Harmony) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)

GetPoolNonce ...

func (*Harmony) GetPoolStats added in v1.10.0

func (hmy *Harmony) GetPoolStats() (pendingCount, queuedCount int)

GetPoolStats returns the number of pending and queued transactions

func (*Harmony) GetPoolTransaction added in v1.10.0

func (hmy *Harmony) GetPoolTransaction(hash common.Hash) types.PoolTransaction

GetPoolTransaction ...

func (*Harmony) GetPoolTransactions added in v1.10.0

func (hmy *Harmony) GetPoolTransactions() (types.PoolTransactions, error)

GetPoolTransactions returns pool transactions.

func (*Harmony) GetPreStakingBlockRewards added in v1.10.0

func (hmy *Harmony) GetPreStakingBlockRewards(
	ctx context.Context, blk *types.Block,
) (PreStakingBlockRewards, error)

GetPreStakingBlockRewards for the given block number. Calculated rewards are done exactly like chain.AccumulateRewardsAndCountSigs.

func (*Harmony) GetReceipts added in v1.10.0

func (hmy *Harmony) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)

GetReceipts ...

func (*Harmony) GetShardState added in v1.10.0

func (hmy *Harmony) GetShardState() (*shard.State, error)

GetShardState ...

func (*Harmony) GetStakingTransactionsCount added in v1.10.0

func (hmy *Harmony) GetStakingTransactionsCount(address, txType string) (uint64, error)

GetStakingTransactionsCount returns the number of staking transactions of address.

func (*Harmony) GetStakingTransactionsHistory added in v1.10.0

func (hmy *Harmony) GetStakingTransactionsHistory(address, txType, order string) ([]common.Hash, error)

GetStakingTransactionsHistory returns list of staking transactions hashes of address.

func (*Harmony) GetSuperCommittees added in v1.10.0

func (hmy *Harmony) GetSuperCommittees() (*quorum.Transition, error)

GetSuperCommittees ..

func (*Harmony) GetTotalStakingSnapshot added in v1.10.0

func (hmy *Harmony) GetTotalStakingSnapshot() *big.Int

GetTotalStakingSnapshot ..

func (*Harmony) GetTransactionsCount added in v1.10.0

func (hmy *Harmony) GetTransactionsCount(address, txType string) (uint64, error)

GetTransactionsCount returns the number of regular transactions of address.

func (*Harmony) GetTransactionsHistory added in v1.10.0

func (hmy *Harmony) GetTransactionsHistory(address, txType, order string) ([]common.Hash, error)

GetTransactionsHistory returns list of transactions hashes of address.

func (*Harmony) GetUndelegationPayouts added in v1.10.0

func (hmy *Harmony) GetUndelegationPayouts(
	ctx context.Context, epoch *big.Int,
) (UndelegationPayouts, error)

GetUndelegationPayouts returns the undelegation payouts for each delegator

Due to in-memory caching, it is possible to get undelegation payouts for a state / epoch that has been pruned but have it be lost (and unable to recompute) after the node restarts. This not a problem if a full (archival) DB is used.

func (*Harmony) GetValidatorInformation added in v1.10.0

func (hmy *Harmony) GetValidatorInformation(
	addr common.Address, block *types.Block,
) (*staking.ValidatorRPCEnhanced, error)

GetValidatorInformation returns the information of validator

func (*Harmony) GetValidatorSelfDelegation added in v1.10.0

func (hmy *Harmony) GetValidatorSelfDelegation(addr common.Address) *big.Int

GetValidatorSelfDelegation returns the amount of staking after applying all delegated stakes

func (*Harmony) GetValidators added in v1.10.0

func (hmy *Harmony) GetValidators(epoch *big.Int) (*shard.Committee, error)

GetValidators returns validators for a particular epoch.

func (*Harmony) HeaderByHash added in v1.10.0

func (hmy *Harmony) HeaderByHash(ctx context.Context, blockHash common.Hash) (*block.Header, error)

HeaderByHash ...

func (*Harmony) HeaderByNumber added in v1.10.0

func (hmy *Harmony) HeaderByNumber(ctx context.Context, blockNum rpc.BlockNumber) (*block.Header, error)

HeaderByNumber ...

func (*Harmony) IsCommitteeSelectionBlock added in v1.10.0

func (hmy *Harmony) IsCommitteeSelectionBlock(header *block.Header) bool

IsCommitteeSelectionBlock checks if the given block is the committee selection block

func (*Harmony) IsLeader added in v1.10.0

func (hmy *Harmony) IsLeader() bool

IsLeader exposes if node is currently leader

func (*Harmony) IsPreStakingEpoch added in v1.10.0

func (hmy *Harmony) IsPreStakingEpoch(epoch *big.Int) bool

IsPreStakingEpoch ...

func (*Harmony) IsStakingEpoch added in v1.10.0

func (hmy *Harmony) IsStakingEpoch(epoch *big.Int) bool

IsStakingEpoch ...

func (*Harmony) ProtocolVersion added in v1.10.0

func (hmy *Harmony) ProtocolVersion() int

ProtocolVersion ...

func (*Harmony) ResendCx added in v1.10.0

func (hmy *Harmony) ResendCx(ctx context.Context, txID common.Hash) (uint64, bool)

ResendCx retrieve blockHash from txID and add blockHash to CxPool for resending Note that cross shard txn is only for regular txns, not for staking txns, so the input txn hash is expected to be regular txn hash

func (*Harmony) SendStakingTx added in v1.10.0

func (hmy *Harmony) SendStakingTx(ctx context.Context, signedStakingTx *staking.StakingTransaction) error

SendStakingTx adds a staking transaction

func (*Harmony) SendTx added in v1.10.0

func (hmy *Harmony) SendTx(ctx context.Context, signedTx *types.Transaction) error

SendTx ...

func (*Harmony) ServiceFilter added in v1.10.0

func (hmy *Harmony) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)

ServiceFilter ...

func (*Harmony) SingleFlightForgetKey added in v1.10.0

func (hmy *Harmony) SingleFlightForgetKey(key string)

SingleFlightForgetKey ...

func (*Harmony) SingleFlightRequest added in v1.10.0

func (hmy *Harmony) SingleFlightRequest(
	key string,
	fn func() (interface{}, error),
) (interface{}, error)

SingleFlightRequest ..

func (*Harmony) StateAndHeaderByNumber added in v1.10.0

func (hmy *Harmony) StateAndHeaderByNumber(ctx context.Context, blockNum rpc.BlockNumber) (*state.DB, *block.Header, error)

StateAndHeaderByNumber ...

func (*Harmony) SubscribeChainEvent added in v1.10.0

func (hmy *Harmony) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

SubscribeChainEvent subscribes chain event. TODO: this is not implemented or verified yet for harmony.

func (*Harmony) SubscribeChainHeadEvent added in v1.10.0

func (hmy *Harmony) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

SubscribeChainHeadEvent subcribes chain head event. TODO: this is not implemented or verified yet for harmony.

func (*Harmony) SubscribeChainSideEvent added in v1.10.0

func (hmy *Harmony) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

SubscribeChainSideEvent subcribes chain side event. TODO: this is not implemented or verified yet for harmony.

func (*Harmony) SubscribeLogsEvent added in v1.10.0

func (hmy *Harmony) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription

SubscribeLogsEvent subcribes log event. TODO: this is not implemented or verified yet for harmony.

func (*Harmony) SubscribeNewTxsEvent added in v1.10.0

func (hmy *Harmony) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription

SubscribeNewTxsEvent subscribes new tx event. TODO: this is not implemented or verified yet for harmony.

func (*Harmony) SubscribeRemovedLogsEvent added in v1.10.0

func (hmy *Harmony) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

SubscribeRemovedLogsEvent subcribes removed logs event. TODO: this is not implemented or verified yet for harmony.

func (*Harmony) TraceBlock added in v1.10.0

func (hmy *Harmony) TraceBlock(ctx context.Context, block *types.Block, config *TraceConfig) ([]*TxTraceResult, error)

TraceBlock configures a new tracer according to the provided configuration, and executes all the transactions contained within. The return value will be one item per transaction, dependent on the requested tracer.

func (*Harmony) TraceChain added in v1.10.0

func (hmy *Harmony) TraceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error)

TraceChain configures a new tracer according to the provided configuration, and executes all the transactions contained within. The return value will be one item per transaction, dependent on the requested tracer.

func (*Harmony) TraceTx added in v1.10.0

func (hmy *Harmony) TraceTx(ctx context.Context, message core.Message, vmctx vm.Context, statedb *state.DB, config *TraceConfig) (interface{}, error)

TraceTx configures a new tracer according to the provided configuration, and executes the given message in the provided environment. The return value will be tracer dependent. NOTE: Only support default StructLogger tracer

type NodeAPI

type NodeAPI interface {
	AddPendingStakingTransaction(*staking.StakingTransaction) error
	AddPendingTransaction(newTx *types.Transaction) error
	Blockchain() *core.BlockChain
	Beaconchain() *core.BlockChain
	GetTransactionsHistory(address, txType, order string) ([]common.Hash, error)
	GetStakingTransactionsHistory(address, txType, order string) ([]common.Hash, error)
	GetTransactionsCount(address, txType string) (uint64, error)
	GetStakingTransactionsCount(address, txType string) (uint64, error)
	IsCurrentlyLeader() bool
	IsOutOfSync(*core.BlockChain) bool
	GetMaxPeerHeight() uint64
	ReportStakingErrorSink() types.TransactionErrorReports
	ReportPlainErrorSink() types.TransactionErrorReports
	PendingCXReceipts() []*types.CXReceiptsProof
	GetNodeBootTime() int64
	PeerConnectivity() (int, int, int)
	ListPeer(topic string) []peer.ID
	ListTopic() []string
	ListBlockedPeer() []peer.ID

	GetConsensusInternal() commonRPC.ConsensusInternal

	// debug API
	GetConsensusMode() string
	GetConsensusPhase() string
	GetConsensusViewChangingID() uint64
	GetConsensusCurViewID() uint64
	ShutDown()
}

NodeAPI is the list of functions from node used to call rpc apis.

type PreStakingBlockRewards added in v1.10.0

type PreStakingBlockRewards map[common.Address]*big.Int

PreStakingBlockRewards are the rewards for a block in the pre-staking era (epoch < staking epoch).

type StdTraceConfig added in v1.10.0

type StdTraceConfig struct {
	*vm.LogConfig
	Reexec *uint64
	TxHash common.Hash
}

StdTraceConfig holds extra parameters to standard-json trace functions.

type StructLogRes added in v1.10.0

type StructLogRes struct {
	Pc              uint64            `json:"pc"`
	Op              string            `json:"op"`
	CallerAddress   common.Address    `json:"callerAddress"`
	ContractAddress common.Address    `json:"contractAddress"`
	Gas             uint64            `json:"gas"`
	GasCost         uint64            `json:"gasCost"`
	Depth           int               `json:"depth"`
	Error           error             `json:"error,omitempty"`
	Stack           []string          `json:"stack,omitempty"`
	Memory          []string          `json:"memory,omitempty"`
	Storage         map[string]string `json:"storage,omitempty"`
}

StructLogRes stores a structured log emitted by the EVM while replaying a transaction in debug mode

func FormatLogs added in v1.10.0

func FormatLogs(logs []vm.StructLog) []StructLogRes

FormatLogs formats EVM returned structured logs for json output

type TraceConfig added in v1.10.0

type TraceConfig struct {
	*vm.LogConfig
	Tracer  *string
	Timeout *string
	Reexec  *uint64
}

TraceConfig holds extra parameters to trace functions.

type TxTraceResult added in v1.10.0

type TxTraceResult struct {
	Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
	Error  string      `json:"error,omitempty"`  // Trace failure produced by the tracer
}

TxTraceResult is the result of a single transaction trace.

type UndelegationPayouts added in v1.10.0

type UndelegationPayouts map[common.Address]*big.Int

UndelegationPayouts ..

Directories

Path Synopsis
Package tracers is a collection of JavaScript transaction tracers.
Package tracers is a collection of JavaScript transaction tracers.
internal/tracers
Package tracers contains the actual JavaScript tracer assets.
Package tracers contains the actual JavaScript tracer assets.

Jump to

Keyboard shortcuts

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