gossip

package
v0.0.0-...-985cc99 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 116 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VLRY62          = 62
	VLRY63          = 63
	ProtocolVersion = VLRY63
)

Constants to match up protocol versions and messages

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

	RequestBVsStream  = 10
	BVsStreamResponse = 11
	RequestBRsStream  = 12
	BRsStreamResponse = 13
	RequestEPsStream  = 14
	EPsStreamResponse = 15
)

protocol message codes

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

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

Variables

View Source
var ProtocolVersions = []uint{VLRY62, VLRY63}

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

Functions

func MakeProtocols

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

MakeProtocols constructs the P2P protocol definitions for `opera`.

func NewGasPowerContext

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

NewGasPowerContext reads current validation context for gaspowercheck

func SplitTransactions

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

func StartENRUpdater

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

StartENRUpdater starts the `opera` 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 *iblockproc.BlockState
	EpochState *iblockproc.EpochState
}

type BlockEpochStateV0

type BlockEpochStateV0 struct {
	BlockState *BlockStateV0
	EpochState *iblockproc.EpochStateV0
}

type BlockProc

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

func DefaultBlockProc

func DefaultBlockProc() BlockProc

type BlockStateV0

type BlockStateV0 struct {
	LastBlock          iblockproc.BlockCtx
	FinalizedStateRoot hash.Hash

	EpochGas      uint64
	EpochCheaters lachesis.Cheaters

	ValidatorStates       []ValidatorBlockStateV0
	NextValidatorProfiles iblockproc.ValidatorProfiles

	DirtyRules opera.Rules

	AdvanceEpochs idx.Epoch
}

type Config

type Config struct {
	FilterAPI filters.Config

	// This can be set to list of enrtree:// URLs which will be queried for
	// for nodes to connect to.
	OperaDiscoveryURLs []string
	SnapDiscoveryURLs  []string

	AllowSnapsync bool

	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

	// 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

	RPCBlockExt bool
}

Config for the gossip service.

func DefaultConfig

func DefaultConfig(scale cachescale.Func) Config

DefaultConfig returns the default configurations for the gossip service.

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 evm block by its number, or nil if not exists.

func (*EthAPIBackend) CalcBlockExtApi

func (b *EthAPIBackend) CalcBlockExtApi() 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) EffectiveMinGasPrice

func (b *EthAPIBackend) EffectiveMinGasPrice(ctx context.Context) *big.Int

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) GetDowntime

func (b *EthAPIBackend) GetDowntime(ctx context.Context, vid 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) GetEpochBlockState

func (b *EthAPIBackend) GetEpochBlockState(ctx context.Context, epoch rpc.BlockNumber) (*iblockproc.BlockState, *iblockproc.EpochState, error)

func (*EthAPIBackend) GetEvent

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

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

func (*EthAPIBackend) GetEventPayload

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

GetEventPayload returns Lachesis 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, vid 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) 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) GetTxPosition

func (b *EthAPIBackend) GetTxPosition(txHash common.Hash) *evmstore.TxPosition

func (*EthAPIBackend) GetUptime

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

func (*EthAPIBackend) HeaderByHash

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

HeaderByHash returns evm block header by its (atropos) hash, or nil if not exists.

func (*EthAPIBackend) HeaderByNumber

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

HeaderByNumber returns evm block header by its number, or nil if not exists.

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) ResolveRpcBlockNumberOrHash

func (b *EthAPIBackend) ResolveRpcBlockNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (idx.Block, error)

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)

StateAndHeaderByNumberOrHash returns evm state and block header by block number or block hash, err if not exists.

func (*EthAPIBackend) Stats

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

func (*EthAPIBackend) SubscribeLogsNotify

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

func (*EthAPIBackend) SubscribeNewBlockNotify

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

func (*EthAPIBackend) SubscribeNewTxsNotify

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

func (*EthAPIBackend) SuggestGasTipCap

func (b *EthAPIBackend) SuggestGasTipCap(ctx context.Context, certainty uint64) *big.Int

func (*EthAPIBackend) TxPoolContent

func (*EthAPIBackend) TxPoolContentFrom

func (b *EthAPIBackend) TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions)

func (*EthAPIBackend) UnprotectedAllowed

func (b *EthAPIBackend) UnprotectedAllowed() bool

type EvmStateReader

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

func NewEvmStateReader

func NewEvmStateReader(s *Store) *EvmStateReader

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) EffectiveMinTip

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

EffectiveMinTip returns current soft lower bound for gas tip

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) StateAt

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

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() opera.Rules

func (*GPOBackend) GetRules

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

func (*GPOBackend) PendingTxs

func (b *GPOBackend) PendingTxs() types.Transactions

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 {
	Pubkeys atomic.Value
	Store   *Store
}

HeavyCheckReader is a helper to run heavy power checks

func (*HeavyCheckReader) GetEpochBlockStart

func (r *HeavyCheckReader) GetEpochBlockStart(epoch idx.Epoch) idx.Block

GetEpochBlockStart is safe for concurrent use

func (*HeavyCheckReader) GetEpochPubKeys

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

GetEpochPubKeys is safe for concurrent use

func (*HeavyCheckReader) GetEpochPubKeysOf

func (r *HeavyCheckReader) GetEpochPubKeysOf(epoch idx.Epoch) map[idx.ValidatorID]validatorpk.PubKey

GetEpochPubKeysOf is safe for concurrent use

type LlrEpochPackRLP

type LlrEpochPackRLP struct {
	VotesRLP []rlp.RawValue
	Record   LlrIdxFullEpochRecordRLP
}

type LlrFullBlockRecordRLP

type LlrFullBlockRecordRLP struct {
	Atropos     hash.Event
	Root        hash.Hash
	Txs         types.Transactions
	ReceiptsRLP rlp.RawValue
	Time        inter.Timestamp
	GasUsed     uint64
}

type LlrIdxFullBlockRecordRLP

type LlrIdxFullBlockRecordRLP struct {
	LlrFullBlockRecordRLP
	Idx idx.Block
}

type LlrIdxFullEpochRecordRLP

type LlrIdxFullEpochRecordRLP struct {
	RecordRLP rlp.RawValue
	Idx       idx.Epoch
}

type LlrState

type LlrState struct {
	LowestEpochToDecide idx.Epoch
	LowestEpochToFill   idx.Epoch

	LowestBlockToDecide idx.Block
	LowestBlockToFill   idx.Block
}

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     uint      `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 PeriodicFlusher

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

PeriodicFlusher periodically commits the Store if isCommitNeeded returns true

func (*PeriodicFlusher) Start

func (c *PeriodicFlusher) Start()

func (*PeriodicFlusher) Stop

func (c *PeriodicFlusher) Stop()

type PeriodicFlusherCallaback

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

type ProtocolConfig

type ProtocolConfig struct {
	LatencyImportance    int
	ThroughputImportance int

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

	ProgressBroadcastPeriod time.Duration

	DagProcessor dagprocessor.Config
	BvProcessor  bvprocessor.Config
	BrProcessor  brprocessor.Config
	EpProcessor  epprocessor.Config

	DagFetcher       itemsfetcher.Config
	TxFetcher        itemsfetcher.Config
	DagStreamLeecher dagstreamleecher.Config
	DagStreamSeeder  dagstreamseeder.Config
	BvStreamLeecher  bvstreamleecher.Config
	BvStreamSeeder   bvstreamseeder.Config
	BrStreamLeecher  brstreamleecher.Config
	BrStreamSeeder   brstreamseeder.Config
	EpStreamLeecher  epstreamleecher.Config
	EpStreamSeeder   epstreamseeder.Config

	MaxInitialTxHashesSend   int
	MaxRandomTxHashesSend    int
	RandomTxHashesSendPeriod time.Duration

	PeerCache PeerCacheConfig
}

ProtocolConfig is config for p2p protocol

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, blockProc BlockProc,
	engine lachesis.Consensus, dagIndexer *vecmt.Index, newTxPool func(evmcore.StateReader) TxPool,
	haltCheck func(oldEpoch, newEpoch idx.Epoch, age time.Time) bool) (*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) EmitterWorld

func (s *Service) EmitterWorld(signer valkeystore.SignerI) emitter.World

func (*Service) EvmSnapshotGeneration

func (s *Service) EvmSnapshotGeneration() bool

func (*Service) GetConsensusCallbacks

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

GetConsensusCallbacks returns single (for Service) callback instance.

func (*Service) GetEvmStateReader

func (s *Service) GetEvmStateReader() *EvmStateReader

func (*Service) PauseEvmSnapshot

func (s *Service) PauseEvmSnapshot()

func (*Service) ProcessBlockVotes

func (s *Service) ProcessBlockVotes(bvs inter.LlrSignedBlockVotes) error

func (*Service) ProcessEpochVote

func (s *Service) ProcessEpochVote(ev inter.LlrSignedEpochVote) error

func (*Service) ProcessFullBlockRecord

func (s *Service) ProcessFullBlockRecord(br ibr.LlrIdxFullBlockRecord) error

func (*Service) ProcessFullEpochRecord

func (s *Service) ProcessFullEpochRecord(er ier.LlrIdxFullEpochRecord) error

func (*Service) Protocols

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

Protocols returns protocols the service can communicate on.

func (*Service) RegisterEmitter

func (s *Service) RegisterEmitter(em *emitter.Emitter)

RegisterEmitter must be called before service is started

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) SwitchEpochTo

func (s *Service) SwitchEpochTo(newEpoch idx.Epoch) error

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

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) AddLlrBlockVoteWeight

func (s *Store) AddLlrBlockVoteWeight(block idx.Block, epoch idx.Epoch, bv hash.Hash, val idx.Validator, vals idx.Validator, diff pos.Weight) pos.Weight

func (*Store) AddLlrEpochVoteWeight

func (s *Store) AddLlrEpochVoteWeight(epoch idx.Epoch, ev hash.Hash, val idx.Validator, vals idx.Validator, diff pos.Weight) pos.Weight

func (*Store) ApplyGenesis

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

ApplyGenesis writes initial state.

func (*Store) CaptureEvmKvdbSnapshot

func (s *Store) CaptureEvmKvdbSnapshot()

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) FindBlockEpoch

func (s *Store) FindBlockEpoch(b idx.Block) idx.Epoch

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) FlushLastBVs

func (s *Store) FlushLastBVs()

func (*Store) FlushLastEV

func (s *Store) FlushLastEV()

func (*Store) FlushLlrState

func (s *Store) FlushLlrState()

FlushLlrState stores the LLR state in DB

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) GenerateSnapshotAt

func (s *Store) GenerateSnapshotAt(root common.Hash, async bool) (err error)

func (*Store) GetBlock

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

GetBlock returns stored block.

func (*Store) GetBlockEpochState

func (s *Store) GetBlockEpochState() (iblockproc.BlockState, iblockproc.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() iblockproc.BlockState

GetBlockState retrieves the latest block state

func (*Store) GetBlockTxs

func (s *Store) GetBlockTxs(n idx.Block, block *inter.Block) types.Transactions

func (*Store) GetEpoch

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

GetEpoch retrieves the current epoch

func (*Store) GetEpochRules

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

GetEpochRules retrieves current network rules and epoch atomically

func (*Store) GetEpochState

func (s *Store) GetEpochState() iblockproc.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) GetFullBlockRecord

func (s *Store) GetFullBlockRecord(n idx.Block) *ibr.LlrFullBlockRecord

func (*Store) GetFullEpochRecord

func (s *Store) GetFullEpochRecord(epoch idx.Epoch) *ier.LlrFullEpochRecord

func (*Store) GetGenesisBlockIndex

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

GetGenesisBlockIndex returns stored genesis block index.

func (*Store) GetGenesisID

func (s *Store) GetGenesisID() *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) GetHistoryBlockEpochState

func (s *Store) GetHistoryBlockEpochState(epoch idx.Epoch) (*iblockproc.BlockState, *iblockproc.EpochState)

func (*Store) GetHistoryEpochState

func (s *Store) GetHistoryEpochState(epoch idx.Epoch) *iblockproc.EpochState

func (*Store) GetLastBV

func (s *Store) GetLastBV(vid idx.ValidatorID) *idx.Block

GetLastBV returns latest connected LLR block votes from specified validator

func (*Store) GetLastBVs

func (s *Store) GetLastBVs() *concurrent.ValidatorBlocksSet

func (*Store) GetLastEV

func (s *Store) GetLastEV(vid idx.ValidatorID) *idx.Epoch

GetLastEV returns latest connected LLR epoch vote from specified validator

func (*Store) GetLastEVs

func (s *Store) GetLastEVs() *concurrent.ValidatorEpochsSet

func (*Store) GetLastEvent

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

GetLastEvent 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) GetLlrBlockResult

func (s *Store) GetLlrBlockResult(block idx.Block) *hash.Hash

func (*Store) GetLlrEpochResult

func (s *Store) GetLlrEpochResult(epoch idx.Epoch) *hash.Hash

func (*Store) GetLlrState

func (s *Store) GetLlrState() LlrState

func (*Store) GetRules

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

GetRules retrieves current network rules

func (*Store) GetValidators

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

GetValidators retrieves current validators

func (*Store) HasBlock

func (s *Store) HasBlock(n idx.Block) bool

func (*Store) HasBlockEpochState

func (s *Store) HasBlockEpochState() bool

func (*Store) HasBlockVotes

func (s *Store) HasBlockVotes(epoch idx.Epoch, lastBlock idx.Block, id hash.Event) bool

func (*Store) HasEpochVote

func (s *Store) HasEpochVote(epoch idx.Epoch, id hash.Event) bool

func (*Store) HasEvent

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

HasEvent returns true if event exists.

func (*Store) HasHistoryBlockEpochState

func (s *Store) HasHistoryBlockEpochState(epoch idx.Epoch) bool

func (*Store) IsCommitNeeded

func (s *Store) IsCommitNeeded() bool

func (*Store) IterateEpochPacksRLP

func (s *Store) IterateEpochPacksRLP(start idx.Epoch, f func(epoch idx.Epoch, ep rlp.RawValue) bool)

func (*Store) IterateFullBlockRecordsRLP

func (s *Store) IterateFullBlockRecordsRLP(start idx.Block, f func(b idx.Block, br rlp.RawValue) bool)

func (*Store) IterateOverlappingBlockVotesRLP

func (s *Store) IterateOverlappingBlockVotesRLP(start []byte, f func(key []byte, bvs rlp.RawValue) bool)

func (*Store) LastKvdbEvmSnapshot

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

func (*Store) ModifyLlrState

func (s *Store) ModifyLlrState(f func(*LlrState))

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 iblockproc.BlockState, es iblockproc.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) SetBlockVotes

func (s *Store) SetBlockVotes(bvs inter.LlrSignedBlockVotes)

func (*Store) SetEpochBlock

func (s *Store) SetEpochBlock(b idx.Block, e idx.Epoch)

func (*Store) SetEpochVote

func (s *Store) SetEpochVote(ev inter.LlrSignedEpochVote)

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) SetGenesisID

func (s *Store) SetGenesisID(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) SetHistoryBlockEpochState

func (s *Store) SetHistoryBlockEpochState(epoch idx.Epoch, bs iblockproc.BlockState, es iblockproc.EpochState)

TODO propose to pass bs, es arguments by pointer

func (*Store) SetLastBVs

func (s *Store) SetLastBVs(ids *concurrent.ValidatorBlocksSet)

func (*Store) SetLastEVs

func (s *Store) SetLastEVs(ids *concurrent.ValidatorEpochsSet)

func (*Store) SetLastEvents

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

func (*Store) SetLlrBlockResult

func (s *Store) SetLlrBlockResult(block idx.Block, bv hash.Hash)

func (*Store) SetLlrEpochResult

func (s *Store) SetLlrEpochResult(epoch idx.Epoch, ev hash.Hash)

func (*Store) WriteFullBlockRecord

func (s *Store) WriteFullBlockRecord(br ibr.LlrIdxFullBlockRecord)

func (*Store) WriteFullEpochRecord

func (s *Store) WriteFullEpochRecord(er ier.LlrIdxFullEpochRecord)

type StoreCacheConfig

type StoreCacheConfig struct {
	// Cache size for full events.
	EventsNum  int
	EventsSize uint
	// Cache size for full blocks.
	BlocksNum  int
	BlocksSize uint
	// Cache size for history block/epoch states.
	BlockEpochStateNum int
}

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 TxPool

type TxPool interface {
	emitter.TxPool
	// AddRemotes should add the given transactions to the pool.
	AddRemotes([]*types.Transaction) []error
	AddLocals(txs []*types.Transaction) []error
	AddLocal(tx *types.Transaction) error

	Get(common.Hash) *types.Transaction

	OnlyNotExisting(hashes []common.Hash) []common.Hash
	SampleHashes(max int) []common.Hash

	Nonce(addr common.Address) uint64
	Stats() (int, int)
	Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
	ContentFrom(addr common.Address) (types.Transactions, types.Transactions)
	PendingSlice() types.Transactions
}

type ValidatorBlockStateV0

type ValidatorBlockStateV0 struct {
	Cheater          bool
	LastEvent        hash.Event
	Uptime           inter.Timestamp
	LastOnlineTime   inter.Timestamp
	LastGasPowerLeft inter.GasPowerLeft
	LastBlock        idx.Block
	DirtyGasRefund   uint64
	Originated       *big.Int
}

type ValidatorsPubKeys

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

ValidatorsPubKeys stores info to authenticate validators

Jump to

Keyboard shortcuts

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