gossip

package
v1.9.25-zilion-0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 91 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HandshakeMsg = 0

	// Signals about the current synchronization status.
	// The current peer's status is used during packs downloading,
	// and to estimate may peer be interested in the new event or not
	// (based on peer's epoch).
	ProgressMsg = 1

	EvmTxsMsg         = 2
	NewEvmTxHashesMsg = 3
	GetEvmTxsMsg      = 4

	// Non-aggressive events propagation. Signals about newly-connected
	// batch of events, sending only their IDs.
	NewEventIDsMsg = 5

	// Request the batch of events by IDs
	GetEventsMsg = 6
	// Contains the batch of events.
	// May be an answer to GetEventsMsg, or be sent during aggressive events propagation.
	EventsMsg = 7

	// Request a range of events by a selector
	RequestEventsStream = 8
	// Contains the requested events by RequestEventsStream
	EventsStreamResponse = 9
)

protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIDMismatch
	ErrGenesisMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
	ErrEmptyMessage = 0xf00
)
View Source
const ProtocolName = "zilionixx"

ProtocolName is the official short name of the protocol used during capability negotiation.

View Source
const (
	ProtocolVersion = 62 // derived from eth62
)

Constants to match up protocol versions and messages

Variables

View Source
var ProtocolVersions = []uint{ProtocolVersion}

ProtocolVersions are the supported versions of the protocol (first is primary).

Functions

func MakeProtocols

func MakeProtocols(svc *Service, backend *ProtocolManager, network uint64, disc enode.Iterator) []p2p.Protocol

MakeProtocols constructs the P2P protocol definitions for `zilionixx`.

func NewGasPowerContext

func NewGasPowerContext(s *Store, validators *pos.Validators, epoch idx.Epoch, cfg zilionixx.EconomyRules) *gaspowercheck.ValidationContext

NewGasPowerContext reads current validation context for gaspowercheck

func NewPeer

func NewPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter, cfg PeerCacheConfig) *peer

func SplitTransactions

func SplitTransactions(txs types.Transactions, fn func(types.Transactions))

func StartENRUpdater

func StartENRUpdater(svc *Service, ln *enode.LocalNode)

StartENRUpdater starts the `zilionixx` ENR updater loop, which listens for chain head events and updates the requested node record whenever a fork is passed.

Types

type BlockEpochState

type BlockEpochState struct {
	BlockState *blockproc.BlockState
	EpochState *blockproc.EpochState
}

type BlockProc

type BlockProc struct {
	SealerModule        blockproc.SealerModule
	TxListenerModule    blockproc.TxListenerModule
	GenesisTxTransactor blockproc.TxTransactor
	PreTxTransactor     blockproc.TxTransactor
	PostTxTransactor    blockproc.TxTransactor
	EventsModule        blockproc.ConfirmedEventsModule
	EVMModule           blockproc.EVM
}

func DefaultBlockProc

func DefaultBlockProc(g zilionixx.Genesis) BlockProc

type Config

type Config struct {
	Emitter emitter.Config
	TxPool  evmcore.TxPoolConfig

	FilterAPI filters.Config

	TxIndex bool // Whether to enable indexing transactions and receipts or not

	// Protocol options
	Protocol ProtocolConfig

	HeavyCheck heavycheck.Config

	// Gas Price Oracle options
	GPO gasprice.Config

	VersionWatcher verwatcher.Config

	// RPCGasCap is the global gas cap for eth-call variants.
	RPCGasCap uint64 `toml:",omitempty"`

	// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
	// send-transction variants. The unit is ether.
	RPCTxFeeCap float64 `toml:",omitempty"`

	// allows only for EIP155 transactions.
	AllowUnprotectedTxs bool

	ExtRPCEnabled bool

	RPCLogsBloom bool
}

Config for the gossip service.

func DefaultConfig

func DefaultConfig(scale cachescale.Func) Config

DefaultConfig returns the default configurations for the gossip service.

func FakeConfig

func FakeConfig(num int, scale cachescale.Func) Config

FakeConfig returns the default configurations for the gossip service in fakenet.

func (*Config) Validate

func (c *Config) Validate() error

type Enr

type Enr struct {
	ForkID forkid.ID
	// Ignore additional fields (for forward compatibility).
	Rest []rlp.RawValue `rlp:"tail"`
}

Enr is ENR entry which advertises eth protocol on the discovery network.

func (Enr) ENRKey

func (e Enr) ENRKey() string

ENRKey implements enr.Entry.

type EthAPIBackend

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

EthAPIBackend implements ethapi.Backend.

func (*EthAPIBackend) AccountManager

func (b *EthAPIBackend) AccountManager() *accounts.Manager

func (*EthAPIBackend) BlockByHash

func (b *EthAPIBackend) BlockByHash(ctx context.Context, h common.Hash) (*evmcore.EvmBlock, error)

func (*EthAPIBackend) BlockByNumber

func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*evmcore.EvmBlock, error)

BlockByNumber returns block by its number.

func (*EthAPIBackend) CalcLogsBloom

func (b *EthAPIBackend) CalcLogsBloom() bool

func (*EthAPIBackend) ChainConfig

func (b *EthAPIBackend) ChainConfig() *params.ChainConfig

ChainConfig returns the active chain configuration.

func (*EthAPIBackend) ChainDb

func (b *EthAPIBackend) ChainDb() ethdb.Database

func (*EthAPIBackend) CurrentBlock

func (b *EthAPIBackend) CurrentBlock() *evmcore.EvmBlock

func (*EthAPIBackend) CurrentEpoch

func (b *EthAPIBackend) CurrentEpoch(ctx context.Context) idx.Epoch

CurrentEpoch returns current epoch number.

func (*EthAPIBackend) EvmLogIndex

func (b *EthAPIBackend) EvmLogIndex() *topicsdb.Index

func (*EthAPIBackend) ExtRPCEnabled

func (b *EthAPIBackend) ExtRPCEnabled() bool

func (*EthAPIBackend) ForEachEpochEvent

func (b *EthAPIBackend) ForEachEpochEvent(ctx context.Context, epoch rpc.BlockNumber, onEvent func(event *inter.EventPayload) bool) error

ForEachEpochEvent iterates all the events which are observed by head, and accepted by a filter. filter CANNOT called twice for the same event.

func (*EthAPIBackend) GetDelegation

func (b *EthAPIBackend) GetDelegation(ctx context.Context, id sfcapi.DelegationID) (*sfcapi.SfcDelegation, error)

func (*EthAPIBackend) GetDelegationClaimedRewards

func (b *EthAPIBackend) GetDelegationClaimedRewards(ctx context.Context, id sfcapi.DelegationID) (*big.Int, error)

func (*EthAPIBackend) GetDelegationsByAddress

func (b *EthAPIBackend) GetDelegationsByAddress(ctx context.Context, addr common.Address) ([]sfcapi.SfcDelegationAndID, error)

func (*EthAPIBackend) GetDelegationsOf

func (b *EthAPIBackend) GetDelegationsOf(ctx context.Context, stakerID idx.ValidatorID) ([]sfcapi.SfcDelegationAndID, error)

func (*EthAPIBackend) GetDowntime

func (b *EthAPIBackend) GetDowntime(ctx context.Context, stakerID idx.ValidatorID) (idx.Block, inter.Timestamp, error)

func (*EthAPIBackend) GetEVM

func (b *EthAPIBackend) GetEVM(ctx context.Context, msg evmcore.Message, state *state.StateDB, header *evmcore.EvmHeader, vmConfig *vm.Config) (*vm.EVM, func() error, error)

func (*EthAPIBackend) GetEvent

func (b *EthAPIBackend) GetEvent(ctx context.Context, shortEventID string) (*inter.Event, error)

GetEvent returns the ZilionBFT event header by hash or short ID.

func (*EthAPIBackend) GetEventPayload

func (b *EthAPIBackend) GetEventPayload(ctx context.Context, shortEventID string) (*inter.EventPayload, error)

GetEventPayload returns ZilionBFT event by hash or short ID.

func (*EthAPIBackend) GetFullEventID

func (b *EthAPIBackend) GetFullEventID(shortEventID string) (hash.Event, error)

GetFullEventID "converts" ShortID to full event's hash, by searching in events DB.

func (*EthAPIBackend) GetHeads

func (b *EthAPIBackend) GetHeads(ctx context.Context, epoch rpc.BlockNumber) (heads hash.Events, err error)

GetHeads returns IDs of all the epoch events with no descendants. * When epoch is -2 the heads for latest epoch are returned. * When epoch is -1 the heads for latest sealed epoch are returned.

func (*EthAPIBackend) GetLogs

func (b *EthAPIBackend) GetLogs(ctx context.Context, block common.Hash) ([][]*types.Log, error)

func (*EthAPIBackend) GetOriginatedFee

func (b *EthAPIBackend) GetOriginatedFee(ctx context.Context, stakerID idx.ValidatorID) (*big.Int, error)

func (*EthAPIBackend) GetPoolNonce

func (b *EthAPIBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)

func (*EthAPIBackend) GetPoolTransaction

func (b *EthAPIBackend) GetPoolTransaction(hash common.Hash) *types.Transaction

func (*EthAPIBackend) GetPoolTransactions

func (b *EthAPIBackend) GetPoolTransactions() (types.Transactions, error)

func (*EthAPIBackend) GetReceipts

func (b *EthAPIBackend) GetReceipts(ctx context.Context, block common.Hash) (types.Receipts, error)

GetReceipts retrieves the receipts for all transactions in a given block.

func (*EthAPIBackend) GetReceiptsByNumber

func (b *EthAPIBackend) GetReceiptsByNumber(ctx context.Context, number rpc.BlockNumber) (types.Receipts, error)

GetReceiptsByNumber returns receipts by block number.

func (*EthAPIBackend) GetRewardWeights

func (b *EthAPIBackend) GetRewardWeights(ctx context.Context, stakerID idx.ValidatorID) (*big.Int, *big.Int, error)

func (*EthAPIBackend) GetStaker

func (b *EthAPIBackend) GetStaker(ctx context.Context, stakerID idx.ValidatorID) (*sfcapi.SfcStaker, error)

func (*EthAPIBackend) GetStakerClaimedRewards

func (b *EthAPIBackend) GetStakerClaimedRewards(ctx context.Context, stakerID idx.ValidatorID) (*big.Int, error)

func (*EthAPIBackend) GetStakerDelegationsClaimedRewards

func (b *EthAPIBackend) GetStakerDelegationsClaimedRewards(ctx context.Context, stakerID idx.ValidatorID) (*big.Int, error)

func (*EthAPIBackend) GetStakerID

func (b *EthAPIBackend) GetStakerID(ctx context.Context, addr common.Address) (idx.ValidatorID, error)

func (*EthAPIBackend) GetStakerPoI

func (b *EthAPIBackend) GetStakerPoI(ctx context.Context, stakerID idx.ValidatorID) (*big.Int, error)

func (*EthAPIBackend) GetStakers

func (b *EthAPIBackend) GetStakers(ctx context.Context) ([]sfcapi.SfcStakerAndID, error)

func (*EthAPIBackend) GetTd

func (b *EthAPIBackend) GetTd(_ common.Hash) *big.Int

func (*EthAPIBackend) GetTransaction

func (b *EthAPIBackend) GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, uint64, uint64, error)

func (*EthAPIBackend) GetUptime

func (b *EthAPIBackend) GetUptime(ctx context.Context, stakerID idx.ValidatorID) (*big.Int, error)

func (*EthAPIBackend) GetValidators

func (b *EthAPIBackend) GetValidators(ctx context.Context) *pos.Validators

func (*EthAPIBackend) HeaderByHash

func (b *EthAPIBackend) HeaderByHash(ctx context.Context, h common.Hash) (*evmcore.EvmHeader, error)

HeaderByHash returns evm header by its (atropos) hash.

func (*EthAPIBackend) HeaderByNumber

func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*evmcore.EvmHeader, error)

func (*EthAPIBackend) MaxGasLimit

func (b *EthAPIBackend) MaxGasLimit() uint64

func (*EthAPIBackend) MinGasPrice

func (b *EthAPIBackend) MinGasPrice() *big.Int

func (*EthAPIBackend) Progress

func (b *EthAPIBackend) Progress() ethapi.PeerProgress

Progress returns current synchronization status of this node

func (*EthAPIBackend) RPCGasCap

func (b *EthAPIBackend) RPCGasCap() uint64

func (*EthAPIBackend) RPCTxFeeCap

func (b *EthAPIBackend) RPCTxFeeCap() float64

func (*EthAPIBackend) SealedEpochTiming

func (b *EthAPIBackend) SealedEpochTiming(ctx context.Context) (start inter.Timestamp, end inter.Timestamp)

func (*EthAPIBackend) SendTx

func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error

func (*EthAPIBackend) StateAndHeaderByNumberOrHash

func (b *EthAPIBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *evmcore.EvmHeader, error)

func (*EthAPIBackend) Stats

func (b *EthAPIBackend) Stats() (pending int, queued int)

func (*EthAPIBackend) SubscribeLogsEvent

func (b *EthAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) notify.Subscription

func (*EthAPIBackend) SubscribeNewBlockEvent

func (b *EthAPIBackend) SubscribeNewBlockEvent(ch chan<- evmcore.ChainHeadNotify) notify.Subscription

func (*EthAPIBackend) SubscribeNewTxsEvent

func (b *EthAPIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) notify.Subscription

func (*EthAPIBackend) SubscribeNewTxsNotify

func (b *EthAPIBackend) SubscribeNewTxsNotify(ch chan<- evmcore.NewTxsNotify) notify.Subscription

func (*EthAPIBackend) SuggestPrice

func (b *EthAPIBackend) SuggestPrice(ctx context.Context) (*big.Int, error)

func (*EthAPIBackend) TxPoolContent

func (*EthAPIBackend) UnprotectedAllowed

func (b *EthAPIBackend) UnprotectedAllowed() bool

type EvmStateReader

type EvmStateReader struct {
	*ServiceFeed
	// contains filtered or unexported fields
}

func (*EvmStateReader) Config

func (r *EvmStateReader) Config() *params.ChainConfig

func (*EvmStateReader) CurrentBlock

func (r *EvmStateReader) CurrentBlock() *evmcore.EvmBlock

func (*EvmStateReader) CurrentHeader

func (r *EvmStateReader) CurrentHeader() *evmcore.EvmHeader

func (*EvmStateReader) GetBlock

func (r *EvmStateReader) GetBlock(h common.Hash, n uint64) *evmcore.EvmBlock

func (*EvmStateReader) GetHeader

func (r *EvmStateReader) GetHeader(h common.Hash, n uint64) *evmcore.EvmHeader

func (*EvmStateReader) MaxGasLimit

func (r *EvmStateReader) MaxGasLimit() uint64

func (*EvmStateReader) MinGasPrice

func (r *EvmStateReader) MinGasPrice() *big.Int

MinGasPrice returns current hard lower bound for gas price

func (*EvmStateReader) RecommendedMinGasPrice

func (r *EvmStateReader) RecommendedMinGasPrice() *big.Int

RecommendedMinGasPrice returns current soft lower bound for gas price

func (*EvmStateReader) StateAt

func (r *EvmStateReader) StateAt(root common.Hash) (*state.StateDB, error)

func (*EvmStateReader) TxExists

func (r *EvmStateReader) TxExists(txid common.Hash) bool

type ExtendedTxPosition

type ExtendedTxPosition struct {
	evmstore.TxPosition
	EventCreator idx.ValidatorID
}

type GPOBackend

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

func (*GPOBackend) GetLatestBlockIndex

func (b *GPOBackend) GetLatestBlockIndex() idx.Block

func (*GPOBackend) GetPendingRules

func (b *GPOBackend) GetPendingRules() zilionixx.Rules

func (*GPOBackend) GetRules

func (b *GPOBackend) GetRules() zilionixx.Rules

func (*GPOBackend) TotalGasPowerLeft

func (b *GPOBackend) TotalGasPowerLeft() uint64

TotalGasPowerLeft returns a total amount of obtained gas power by the validators, according to the latest events from each validator

type GasPowerCheckReader

type GasPowerCheckReader struct {
	Ctx atomic.Value
}

GasPowerCheckReader is a helper to run gas power check

func (*GasPowerCheckReader) GetValidationContext

func (r *GasPowerCheckReader) GetValidationContext() *gaspowercheck.ValidationContext

GetValidationContext returns current validation context for gaspowercheck

type HeavyCheckReader

type HeavyCheckReader struct {
	Addrs atomic.Value
}

HeavyCheckReader is a helper to run heavy power checks

func (*HeavyCheckReader) GetEpochPubKeys

func (r *HeavyCheckReader) GetEpochPubKeys() (map[idx.ValidatorID]validatorpk.PubKey, idx.Epoch)

GetEpochPubKeys is safe for concurrent use

type NodeInfo

type NodeInfo struct {
	Network     uint64      `json:"network"` // network ID
	Genesis     common.Hash `json:"genesis"` // SHA3 hash of the host's genesis object
	Epoch       idx.Epoch   `json:"epoch"`
	NumOfBlocks idx.Block   `json:"blocks"`
}

NodeInfo represents a short summary of the sub-protocol metadata known about the host peer.

type PeerCacheConfig

type PeerCacheConfig struct {
	MaxKnownTxs    int // Maximum transactions hashes to keep in the known list (prevent DOS)
	MaxKnownEvents int // Maximum event hashes to keep in the known list (prevent DOS)
	// MaxQueuedItems is the maximum number of items to queue up before
	// dropping broadcasts. This is a sensitive number as a transaction list might
	// contain a single transaction, or thousands.
	MaxQueuedItems idx.Event
	MaxQueuedSize  uint64
}

func DefaultPeerCacheConfig

func DefaultPeerCacheConfig(scale cachescale.Func) PeerCacheConfig

type PeerInfo

type PeerInfo struct {
	Version     int       `json:"version"` // protocol version negotiated
	Epoch       idx.Epoch `json:"epoch"`
	NumOfBlocks idx.Block `json:"blocks"`
}

PeerInfo represents a short summary of the sub-protocol metadata known about a connected peer.

type PeerProgress

type PeerProgress struct {
	Epoch            idx.Epoch
	LastBlockIdx     idx.Block
	LastBlockAtropos hash.Event
	// Currently unused
	HighestLamport idx.Lamport
}

PeerProgress is synchronization status of a peer

func (*PeerProgress) Less

func (a *PeerProgress) Less(b PeerProgress) bool

type ProtocolConfig

type ProtocolConfig struct {
	LatencyImportance    int
	ThroughputImportance int

	EventsSemaphoreLimit dag.Metric
	MsgsSemaphoreLimit   dag.Metric
	MsgsSemaphoreTimeout time.Duration

	ProgressBroadcastPeriod time.Duration

	Processor dagprocessor.Config

	DagFetcher    itemsfetcher.Config
	TxFetcher     itemsfetcher.Config
	StreamLeecher streamleecher.Config
	StreamSeeder  streamseeder.Config

	MaxInitialTxHashesSend   int
	MaxRandomTxHashesSend    int
	RandomTxHashesSendPeriod time.Duration

	PeerCache PeerCacheConfig
}

ProtocolConfig is config for p2p protocol

type ProtocolManager

type ProtocolManager struct {
	logger.Instance
	// contains filtered or unexported fields
}

func (*ProtocolManager) BroadcastEvent

func (pm *ProtocolManager) BroadcastEvent(event *inter.EventPayload, passed time.Duration) int

BroadcastEvent will either propagate a event to a subset of it's peers, or will only announce it's availability (depending what's requested).

func (*ProtocolManager) BroadcastTxs

func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)

BroadcastTxs will propagate a batch of transactions to all peers which are not known to already have the given transaction.

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo() *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

type PublicEthereumAPI

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

PublicEthereumAPI provides an API to access Ethereum-like information. It is a github.com/ethereum/go-ethereum/eth simulation for console.

func NewPublicEthereumAPI

func NewPublicEthereumAPI(s *Service) *PublicEthereumAPI

NewPublicEthereumAPI creates a new Ethereum protocol API for gossip.

func (*PublicEthereumAPI) ChainId

func (api *PublicEthereumAPI) ChainId() hexutil.Uint64

ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.

func (*PublicEthereumAPI) Coinbase

func (api *PublicEthereumAPI) Coinbase() (common.Address, error)

Coinbase returns the zero address for web3 compatibility

func (*PublicEthereumAPI) Etherbase

func (api *PublicEthereumAPI) Etherbase() (common.Address, error)

Etherbase returns the zero address for web3 compatibility

func (*PublicEthereumAPI) Hashrate

func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64

Hashrate returns the zero POW hashrate for web3 compatibility

type Service

type Service struct {
	Name string

	EthAPI *EthAPIBackend

	logger.Instance
	// contains filtered or unexported fields
}

Service implements go-ethereum/node.Service interface.

func NewService

func NewService(stack *node.Node, config Config, store *Store, signer valkeystore.SignerI, blockProc BlockProc, engine zilionbft.Consensus, dagIndexer *vecmt.Index) (*Service, error)

func (*Service) APIs

func (s *Service) APIs() []rpc.API

APIs returns api methods the service wants to expose on rpc channels.

func (*Service) AccountManager

func (s *Service) AccountManager() *accounts.Manager

AccountManager return node's account manager

func (*Service) DagProcessor

func (s *Service) DagProcessor() *dagprocessor.Processor

func (*Service) GetConsensusCallbacks

func (s *Service) GetConsensusCallbacks() zilionbft.ConsensusCallbacks

GetConsensusCallbacks returns single (for Service) callback instance.

func (*Service) GetEvmStateReader

func (s *Service) GetEvmStateReader() *EvmStateReader

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

Protocols returns protocols the service can communicate on.

func (*Service) Start

func (s *Service) Start() error

Start method invoked when the node is ready to start the service.

func (*Service) Stop

func (s *Service) Stop() error

Stop method invoked when the node terminates the service.

func (*Service) WaitBlockEnd

func (s *Service) WaitBlockEnd()

WaitBlockEnd waits until parallel block processing is complete (if any)

type ServiceFeed

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

func (*ServiceFeed) SubscribeNewBlock

func (f *ServiceFeed) SubscribeNewBlock(ch chan<- evmcore.ChainHeadNotify) notify.Subscription

func (*ServiceFeed) SubscribeNewEmitted

func (f *ServiceFeed) SubscribeNewEmitted(ch chan<- *inter.EventPayload) notify.Subscription

func (*ServiceFeed) SubscribeNewEpoch

func (f *ServiceFeed) SubscribeNewEpoch(ch chan<- idx.Epoch) notify.Subscription

func (*ServiceFeed) SubscribeNewLogs

func (f *ServiceFeed) SubscribeNewLogs(ch chan<- []*types.Log) notify.Subscription

func (*ServiceFeed) SubscribeNewTxs

func (f *ServiceFeed) SubscribeNewTxs(ch chan<- core.NewTxsEvent) notify.Subscription

type Store

type Store struct {
	logger.Instance
	// contains filtered or unexported fields
}

Store is a node persistent storage working over physical key-value database.

func NewMemStore

func NewMemStore() *Store

NewMemStore creates store over memory map.

func NewStore

func NewStore(dbs kvdb.FlushableDBProducer, cfg StoreConfig) *Store

NewStore creates store over key-value db.

func (*Store) ApplyGenesis

func (s *Store) ApplyGenesis(blockProc BlockProc, g zilionixx.Genesis) (genesisHash hash.Hash, err error)

ApplyGenesis writes initial state.

func (*Store) Close

func (s *Store) Close()

Close closes underlying database.

func (*Store) Commit

func (s *Store) Commit() error

Commit changes.

func (*Store) DelEvent

func (s *Store) DelEvent(id hash.Event)

DelEvent deletes event.

func (*Store) EvmStore

func (s *Store) EvmStore() *evmstore.Store

func (*Store) FindEventHashes

func (s *Store) FindEventHashes(epoch idx.Epoch, lamport idx.Lamport, hashPrefix []byte) hash.Events

func (*Store) FlushBlockEpochState

func (s *Store) FlushBlockEpochState()

FlushBlockEpochState stores the latest epoch and block state in DB

func (*Store) FlushHighestLamport

func (s *Store) FlushHighestLamport()

func (*Store) ForEachBlock

func (s *Store) ForEachBlock(fn func(index idx.Block, block *inter.Block))

func (*Store) ForEachEpochEvent

func (s *Store) ForEachEpochEvent(epoch idx.Epoch, onEvent func(event *inter.EventPayload) bool)

func (*Store) ForEachEvent

func (s *Store) ForEachEvent(start idx.Epoch, onEvent func(event *inter.EventPayload) bool)

func (*Store) ForEachEventRLP

func (s *Store) ForEachEventRLP(start []byte, onEvent func(key hash.Event, event rlp.RawValue) bool)

func (*Store) GetBlock

func (s *Store) GetBlock(n idx.Block) *inter.Block

GetBlock returns stored block.

func (*Store) GetBlockEpochState

func (s *Store) GetBlockEpochState() (blockproc.BlockState, blockproc.EpochState)

func (*Store) GetBlockIndex

func (s *Store) GetBlockIndex(id hash.Event) *idx.Block

GetBlockIndex returns stored block index.

func (*Store) GetBlockState

func (s *Store) GetBlockState() blockproc.BlockState

GetBlockState retrieves the latest block state

func (*Store) GetEpoch

func (s *Store) GetEpoch() idx.Epoch

GetEpoch retrieves the current epoch

func (*Store) GetEpochRules

func (s *Store) GetEpochRules() (zilionixx.Rules, idx.Epoch)

GetEpochRules retrieves current network rules and epoch atomically

func (*Store) GetEpochState

func (s *Store) GetEpochState() blockproc.EpochState

GetEpochState retrieves the latest epoch state

func (*Store) GetEpochValidators

func (s *Store) GetEpochValidators() (*pos.Validators, idx.Epoch)

GetEpochValidators retrieves the current epoch and validators atomically

func (*Store) GetEvent

func (s *Store) GetEvent(id hash.Event) *inter.Event

GetEvent returns stored event.

func (*Store) GetEventPayload

func (s *Store) GetEventPayload(id hash.Event) *inter.EventPayload

GetEventPayload returns stored event.

func (*Store) GetEventPayloadRLP

func (s *Store) GetEventPayloadRLP(id hash.Event) rlp.RawValue

GetEventPayloadRLP returns stored event. Serialized.

func (*Store) GetGenesisBlockIndex

func (s *Store) GetGenesisBlockIndex() *idx.Block

GetGenesisBlockIndex returns stored genesis block index.

func (*Store) GetGenesisHash

func (s *Store) GetGenesisHash() *hash.Hash

func (*Store) GetGenesisTime

func (s *Store) GetGenesisTime() inter.Timestamp

func (*Store) GetHeads

func (s *Store) GetHeads(epoch idx.Epoch) *concurrent.EventsSet

GetHeads returns set of all the epoch event IDs with no descendants

func (*Store) GetHeadsSlice

func (s *Store) GetHeadsSlice(epoch idx.Epoch) hash.Events

GetHeadsSlice returns IDs of all the epoch events with no descendants

func (*Store) GetHighestLamport

func (s *Store) GetHighestLamport() idx.Lamport

func (*Store) GetLastEvent

func (s *Store) GetLastEvent(epoch idx.Epoch, vid idx.ValidatorID) *hash.Event

GetLastEvents returns latest connected epoch event from specified validator

func (*Store) GetLastEvents

func (s *Store) GetLastEvents(epoch idx.Epoch) *concurrent.ValidatorEventsSet

GetLastEvents returns latest connected epoch events from each validator

func (*Store) GetLatestBlockIndex

func (s *Store) GetLatestBlockIndex() idx.Block

GetLatestBlockIndex retrieves the current block number

func (*Store) GetRules

func (s *Store) GetRules() zilionixx.Rules

GetRules retrieves current network rules

func (*Store) GetValidators

func (s *Store) GetValidators() *pos.Validators

GetValidators retrieves current validators

func (*Store) HasEvent

func (s *Store) HasEvent(h hash.Event) bool

HasEvent returns true if event exists.

func (*Store) Init

func (s *Store) Init() error

func (*Store) IsCommitNeeded

func (s *Store) IsCommitNeeded(epochSealing bool) bool

func (*Store) SetBlock

func (s *Store) SetBlock(n idx.Block, b *inter.Block)

SetBlock stores chain block.

func (*Store) SetBlockEpochState

func (s *Store) SetBlockEpochState(bs blockproc.BlockState, es blockproc.EpochState)

SetBlockEpochState stores the latest block and epoch state in memory

func (*Store) SetBlockIndex

func (s *Store) SetBlockIndex(id hash.Event, n idx.Block)

SetBlockIndex stores chain block index.

func (*Store) SetEvent

func (s *Store) SetEvent(e *inter.EventPayload)

SetEvent stores event.

func (*Store) SetGenesisBlockIndex

func (s *Store) SetGenesisBlockIndex(n idx.Block)

SetGenesisBlockIndex stores genesis block index.

func (*Store) SetGenesisHash

func (s *Store) SetGenesisHash(val hash.Hash)

func (*Store) SetHeads

func (s *Store) SetHeads(epoch idx.Epoch, ids *concurrent.EventsSet)

func (*Store) SetHighestLamport

func (s *Store) SetHighestLamport(lamport idx.Lamport)

func (*Store) SetLastEvents

func (s *Store) SetLastEvents(epoch idx.Epoch, ids *concurrent.ValidatorEventsSet)

type StoreCacheConfig

type StoreCacheConfig struct {
	// Cache size for full events.
	EventsNum  int
	EventsSize uint
	// Cache size for full blocks.
	BlocksNum  int
	BlocksSize uint
}

type StoreConfig

type StoreConfig struct {
	Cache StoreCacheConfig
	// EVM is EVM store config
	EVM                 evmstore.StoreConfig
	MaxNonFlushedSize   int
	MaxNonFlushedPeriod time.Duration
}

StoreConfig is a config for store db.

func DefaultStoreConfig

func DefaultStoreConfig(scale cachescale.Func) StoreConfig

DefaultStoreConfig for product.

func LiteStoreConfig

func LiteStoreConfig() StoreConfig

LiteStoreConfig is for tests or inmemory.

type ValidatorsPubKeys

type ValidatorsPubKeys struct {
	Epoch   idx.Epoch
	PubKeys map[idx.ValidatorID]validatorpk.PubKey
}

ValidatorsPubKeys stores info to authenticate validators

func NewEpochPubKeys

func NewEpochPubKeys(s *Store, epoch idx.Epoch) *ValidatorsPubKeys

NewEpochPubKeys is the same as GetEpochValidators, but returns only addresses

Directories

Path Synopsis
contract
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package filters implements an ethereum filtering system for block, transactions and log events.
Package filters implements an ethereum filtering system for block, transactions and log events.

Jump to

Keyboard shortcuts

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